lang
stringclasses
3 values
file_path
stringlengths
5
150
repo_name
stringlengths
6
110
commit
stringlengths
40
40
file_code
stringlengths
1.52k
18.9k
prefix
stringlengths
82
16.5k
suffix
stringlengths
0
15.1k
middle
stringlengths
121
8.18k
strategy
stringclasses
8 values
context_items
listlengths
0
100
C++
lib/src/Core/AnimatedEntity.cpp
emilhornlund/DV1537Project-AlienAdventure
b370e49d259ee722edd6f39c979824280522076a
#include <Core/AnimatedEntity.hpp> #include <Core/Animation.hpp> #include <SFML/Graphics/RenderStates.hpp> #include <SFML/Graphics/RenderTarget.hpp> CGL::AnimatedEntity::AnimatedEntity(const bool paused) : m_animation(nullptr), m_currentFrame(0), m_isPaused(paused) {} CGL::AnimatedEntity::~AnimatedEntity() = default; void CGL::AnimatedEntity::setAnimation(const CGL::Animation &animation) { this->m_animation = &animation; this->setTexture(*this->m_animation->getSpriteSheet()); this->m_currentFrame = 0; this->setFrame(this->m_currentFrame); } void CGL::AnimatedEntity::play() { this->m_isPaused = false; } void CGL::AnimatedEntity::play(const CGL::Animation &animation) { if (this->getAnimation() != &animation) this->setAnimation(animation); this->play(); } void CGL::AnimatedEntity::pause() { this->m_isPaused = true; } void CGL::AnimatedEntity::stop() { this->m_isPaused = true; this->m_currentFrame = 0; this->setFrame(this->m_currentFrame); } const CGL::Animation *CGL::AnimatedEntity::getAnimation() const { return this->m_animation; } const sf::FloatRect CGL::AnimatedEntity::getLocalBounds() const { const auto& rect = this->m_animation->getFrame(this->m_currentFrame); return sf::FloatRect(0.f, 0.f, std::abs(rect.width), std::abs(rect.height)); } const sf::FloatRect CGL::AnimatedEntity::getGlobalBounds() const { return this->getTransform().transformRect(this->getLocalBounds()); } bool CGL::AnimatedEntity::isPlaying() const { return !this->m_isPaused; } void CGL::AnimatedEntity::setFrame(std::size_t newFrame, bool resetTime) { if (this->m_animation) { sf::IntRect rect = this->m_animation->getFrame(newFrame); this->m_vertices[0].position = sf::Vector2f(0.f, 0.f); this->m_vertices[1].position = sf::Vector2f(0.f, static_cast<float>(rect.height)); this->m_vertices[2].position = sf::Vector2f(static_cast<float>(rect.width), static_cast<float>(rect.height)); this->m_vertices[3].position = sf::Vector2f(static_cast<float>(rect.width), 0.f); float left = static_cast<float>(rect.left) + 0.0001f; float right = left + static_cast<float>(rect.width); float top = static_cast<float>(rect.top); float bottom = top + static_cast<float>(rect.height); this->m_vertices[0].texCoords = sf::Vector2f(left, top); this->m_vertices[1].texCoords = sf::Vector2f(left, bottom); this->m_vertices[2].texCoords = sf::Vector2f(right, bottom); this->m_vertices[3].texCoords = sf::Vector2f(right, top); } if (resetTime) { this->m_currentTime = sf::Time::Zero; } } void CGL::AnimatedEntity::update(sf::Time deltaTime) { if (!this->m_isPaused && this->m_animation) { this->m_currentTime += deltaTime; if (this->m_currentTime >= this->m_animation->getFrameTime()) { this->m_currentTime = sf::microseconds(this->m_currentTime.asMicroseconds() % this->m_animation->getFrameTime().asMicroseconds()); if (this->m_currentFrame + 1 < this->m_animation->getSize()) { this->m_currentFrame++; } else { this->m_currentFrame = 0; if (!this->m_animation->isLooped()) { m_isPaused = true; } } this->setFrame(this->m_currentFrame, false); } } } void CGL::AnimatedEntity::setColor(const sf::Color &color) { this->m_vertices[0].color = color; this->m_vertices[1].color = color; this->m_vertices[2].color = color; this->m_vertices[3].color = color; } void CGL::AnimatedEntity::draw(sf::RenderTarget &target, sf::RenderStates states) const { if (this->m_animation) { states.transform *= getTransform(); states.texture = &this->getTexture(); target.draw(this->m_vertices, 4, sf::Quads, states); } }
#include <Core/AnimatedEntity.hpp> #include <Core/Animation.hpp> #include <SFML/Graphics/RenderStates.hpp> #include <SFML/Graphics/RenderTarget.hpp> CGL::AnimatedEntity::AnimatedEntity(const bool paused) : m_animation(nullptr), m_currentFrame(0), m_isPaused(paused) {} CGL::AnimatedEntity::~AnimatedEntity() = default; void CGL::AnimatedEntity::setAnimation(const CGL::Animation &animation) { this->m_animation = &animation; this->setTexture(*this->m_animation->getSpriteSheet()); this->m_currentFrame = 0; this->setFrame(this->m_currentFrame); } void CGL::AnimatedEntity::play() { this->m_isPaused = false; } void CGL::AnimatedEntity::play(const CGL::Animation &animation) { if (this->getAnimation() != &animation) this->setAnimation(animation); this->play(); } void CGL::AnimatedEntity::pause() { this->m_isPaused = true; } void CGL::AnimatedEntity::stop() { this->m_isPaused = true; this->m_currentFrame = 0; this->setFrame(this->m_currentFrame); } const CGL::Animation *CGL::AnimatedEntity::getAnimation() const { return this->m_animation; } const sf::FloatRect CGL::AnimatedEntity::getLocalBounds() const { const auto& rect = this->m_animation->getFrame(this->m_currentFrame); return sf::FloatRect(0.f, 0.f, std::abs(rect.width), std::abs(rect.height)); } const sf::FloatRect CGL::AnimatedEntity::getGlobalBounds() const { return this->getTransform().transformRect(this->getLocalBounds()); } bool CGL::AnimatedEntity::isPlaying() const { return !this->m_isPaused; } void CGL::AnimatedEntity::setFrame(std::size_t newFrame, bool resetTime) { if (this->m_animation) { sf::IntRect rect = this->m_animation->getFrame(newFrame); this->m_vertices[0].position = sf::Vector2f(0.f, 0.f); this->m_vertices[1].position = sf::Vector2f(0.f, static_cast<float>(rect.height)); this->m_vertices[2].position = sf::Vector2f(static_cast<float>(rect.width), static_cast<float>(rect.height)); this->m_vertices[3].position = sf::Vector2f(static_cast<float>(rect.width), 0.f); float left = static_cast<floa
void CGL::AnimatedEntity::update(sf::Time deltaTime) { if (!this->m_isPaused && this->m_animation) { this->m_currentTime += deltaTime; if (this->m_currentTime >= this->m_animation->getFrameTime()) { this->m_currentTime = sf::microseconds(this->m_currentTime.asMicroseconds() % this->m_animation->getFrameTime().asMicroseconds()); if (this->m_currentFrame + 1 < this->m_animation->getSize()) { this->m_currentFrame++; } else { this->m_currentFrame = 0; if (!this->m_animation->isLooped()) { m_isPaused = true; } } this->setFrame(this->m_currentFrame, false); } } } void CGL::AnimatedEntity::setColor(const sf::Color &color) { this->m_vertices[0].color = color; this->m_vertices[1].color = color; this->m_vertices[2].color = color; this->m_vertices[3].color = color; } void CGL::AnimatedEntity::draw(sf::RenderTarget &target, sf::RenderStates states) const { if (this->m_animation) { states.transform *= getTransform(); states.texture = &this->getTexture(); target.draw(this->m_vertices, 4, sf::Quads, states); } }
t>(rect.left) + 0.0001f; float right = left + static_cast<float>(rect.width); float top = static_cast<float>(rect.top); float bottom = top + static_cast<float>(rect.height); this->m_vertices[0].texCoords = sf::Vector2f(left, top); this->m_vertices[1].texCoords = sf::Vector2f(left, bottom); this->m_vertices[2].texCoords = sf::Vector2f(right, bottom); this->m_vertices[3].texCoords = sf::Vector2f(right, top); } if (resetTime) { this->m_currentTime = sf::Time::Zero; } }
function_block-function_prefixed
[ { "content": " class Animation {\n\n private:\n\n sf::Time m_frameTime;\n\n\n\n bool m_isLooped;\n\n\n\n std::vector<sf::IntRect> m_frames;\n\n\n\n const sf::Texture *m_texture;\n\n\n\n Animation(const Animation &original);\n\n\n\n Animation &operator=(const Animation &original);\n\n public:\n\n explicit Animation(sf::Time frameTime = sf::seconds(0.2f), bool looped = true);\n\n\n\n ~Animation();\n\n\n\n void addFrame(const sf::IntRect &rect);\n\n\n", "file_path": "lib/include/Core/Animation.hpp", "rank": 0, "score": 74769.49077029979 }, { "content": " class Animation;\n\n\n", "file_path": "lib/include/Core/AnimatedEntity.hpp", "rank": 1, "score": 72775.74852583074 }, { "content": " void setSpriteSheet(const sf::Texture &texture);\n\n\n\n const sf::Texture *getSpriteSheet() const;\n\n\n\n unsigned long getSize() const;\n\n\n\n const sf::IntRect &getFrame(unsigned long index) const;\n\n\n\n void setFrameTime(sf::Time time);\n\n\n\n sf::Time getFrameTime() const;\n\n\n\n void setLooped(bool looped);\n\n\n\n bool isLooped() const;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_ANIMATION_HPP\n", "file_path": "lib/include/Core/Animation.hpp", "rank": 2, "score": 67991.60769012748 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-08.\n\n//\n\n\n\n#ifndef COREGAMELIB_ANIMATION_HPP\n\n#define COREGAMELIB_ANIMATION_HPP\n\n\n\n#include <SFML/Graphics/Rect.hpp>\n\n#include <SFML/System/Time.hpp>\n\n\n\n#include <vector>\n\n\n\nnamespace sf { //SFML\n", "file_path": "lib/include/Core/Animation.hpp", "rank": 3, "score": 67990.45464335942 }, { "content": " class AnimatedEntity : public IEntity {\n\n private:\n\n const Animation* m_animation;\n\n\n\n sf::Time m_currentTime;\n\n\n\n std::size_t m_currentFrame;\n\n\n\n bool m_isPaused;\n\n\n\n sf::Vertex m_vertices[4];\n\n\n\n AnimatedEntity(const AnimatedEntity &original);\n\n\n\n AnimatedEntity& operator=(const AnimatedEntity &original);\n\n\n\n void draw(sf::RenderTarget& target, sf::RenderStates states) const override;\n\n public:\n\n explicit AnimatedEntity(const bool paused = false);\n\n\n", "file_path": "lib/include/Core/AnimatedEntity.hpp", "rank": 4, "score": 67410.58253719626 }, { "content": " ~AnimatedEntity() override;\n\n\n\n void setAnimation(const Animation& animation);\n\n\n\n void play();\n\n\n\n void play(const Animation& animation);\n\n\n\n void pause();\n\n\n\n void stop();\n\n\n\n const Animation* getAnimation() const;\n\n\n\n const sf::FloatRect getLocalBounds() const;\n\n\n\n const sf::FloatRect getGlobalBounds() const;\n\n\n\n bool isPlaying() const;\n\n\n", "file_path": "lib/include/Core/AnimatedEntity.hpp", "rank": 5, "score": 65625.70077570625 }, { "content": " void setFrame(std::size_t newFrame, bool resetTime = true);\n\n\n\n void update(sf::Time deltaTime);\n\n\n\n void setColor(const sf::Color& color) override;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_ANIMATEDENTITY_HPP\n", "file_path": "lib/include/Core/AnimatedEntity.hpp", "rank": 6, "score": 65613.42795844549 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-07.\n\n//\n\n\n\n#ifndef COREGAMELIB_ANIMATEDENTITY_HPP\n\n#define COREGAMELIB_ANIMATEDENTITY_HPP\n\n\n\n#include <Core/IEntity.hpp>\n\n\n\n#include <SFML/Graphics/Vertex.hpp>\n\n#include <SFML/System/Time.hpp>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/AnimatedEntity.hpp", "rank": 7, "score": 65607.26569721935 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/IEnemy.hpp", "rank": 8, "score": 65603.10434697501 }, { "content": " class Texture;\n\n}\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/Animation.hpp", "rank": 9, "score": 65603.10434697501 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace sf { //SFML\n", "file_path": "game/include/Game/Player.hpp", "rank": 10, "score": 65603.10434697501 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_PAUSEMENUOBJECT_HPP\n\n#define ALIENADVENTURE_PAUSEMENUOBJECT_HPP\n\n\n\n#include <Core/IMenuObject.hpp>\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/PauseMenuObject.hpp", "rank": 11, "score": 63758.71065821689 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemySnail.hpp", "rank": 12, "score": 63387.60487830993 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/CollectibleHealth.hpp", "rank": 13, "score": 63387.60487830993 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/CollectibleCoin.hpp", "rank": 14, "score": 63387.60487830993 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemyBee.hpp", "rank": 15, "score": 63387.60487830993 }, { "content": " class PauseMenuObject : public CGL::IMenuObject {\n\n private:\n\n PauseMenuObject(const PauseMenuObject &original);\n\n\n\n PauseMenuObject &operator=(const PauseMenuObject &original);\n\n public:\n\n explicit PauseMenuObject(CGL::IGame *game);\n\n\n\n ~PauseMenuObject() override;\n\n\n\n void update(const float dt) override;\n\n };\n\n}\n\n\n\n#endif //ALIENADVENTURE_PAUSEMENUOBJECT_HPP", "file_path": "game/include/Game/PauseMenuObject.hpp", "rank": 16, "score": 61826.38589097039 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemyBeeBlack.hpp", "rank": 17, "score": 61316.857369121906 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemyWormGreen.hpp", "rank": 18, "score": 61316.857369121906 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemySlimePurple.hpp", "rank": 19, "score": 61316.857369121906 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemySnailMushroom.hpp", "rank": 20, "score": 61316.857369121906 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemyWormPink.hpp", "rank": 21, "score": 61316.857369121906 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemySlimeBlue.hpp", "rank": 22, "score": 61316.857369121906 }, { "content": " class Animation;\n\n}\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/EnemySlimeGreen.hpp", "rank": 23, "score": 61316.857369121906 }, { "content": " class PauseMenuObject;\n", "file_path": "game/include/Game/GameScene.hpp", "rank": 24, "score": 59721.73766349448 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-08.\n\n//\n\n\n\n#include <Core/Animation.hpp>\n\n\n\n#include <SFML/Graphics/Texture.hpp>\n\n\n\nCGL::Animation::Animation(sf::Time frameTime, bool looped) : m_frameTime(frameTime),\n\n m_isLooped(looped),\n\n m_texture(nullptr) {}\n\n\n\nCGL::Animation::~Animation() = default;\n\n\n\nvoid CGL::Animation::addFrame(const sf::IntRect &rect) {\n\n this->m_frames.push_back(rect);\n\n}\n\n\n\nvoid CGL::Animation::setSpriteSheet(const sf::Texture &texture) {\n\n this->m_texture = &texture;\n", "file_path": "lib/src/Core/Animation.cpp", "rank": 25, "score": 35860.3485387149 }, { "content": "}\n\n\n\nvoid CGL::Animation::setLooped(bool looped) {\n\n this->m_isLooped = looped;\n\n}\n\n\n\nbool CGL::Animation::isLooped() const {\n\n return this->m_isLooped;\n\n}\n", "file_path": "lib/src/Core/Animation.cpp", "rank": 26, "score": 35855.074456602466 }, { "content": "}\n\n\n\nconst sf::Texture *CGL::Animation::getSpriteSheet() const {\n\n return this->m_texture;\n\n}\n\n\n\nunsigned long CGL::Animation::getSize() const {\n\n return this->m_frames.size();\n\n}\n\n\n\nconst sf::IntRect &CGL::Animation::getFrame(unsigned long index) const {\n\n return this->m_frames.at(index);\n\n}\n\n\n\nvoid CGL::Animation::setFrameTime(sf::Time time) {\n\n this->m_frameTime = time;\n\n}\n\n\n\nsf::Time CGL::Animation::getFrameTime() const {\n\n return this->m_frameTime;\n", "file_path": "lib/src/Core/Animation.cpp", "rank": 27, "score": 35852.55764059335 }, { "content": "}\n\n\n\nAA::PauseMenuObject::~PauseMenuObject() = default;\n\n\n\nvoid AA::PauseMenuObject::update(const float dt) {\n\n const auto index = this->getSelectedItemIndex();\n\n if (index >= 0) {\n\n auto& scene = this->getGame()->getSceneHandler().getActiveScene();\n\n switch (index) {\n\n case 0:\n\n scene.resume();\n\n break;\n\n case 1:\n\n scene.resume();\n\n scene.getObjectHandler().restoreObjects(false);\n\n break;\n\n case 2:\n\n this->getGame()->quit(0);\n\n break;\n\n default:\n\n break;\n\n }\n\n this->restore(false);\n\n this->getGame()->closeMenu();\n\n }\n\n}\n", "file_path": "game/src/Game/PauseMenuObject.cpp", "rank": 34, "score": 33801.49409776577 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#include <Core/ObjectHandler.hpp>\n\n#include <Core/ResourceHandler.hpp>\n\n#include <Core/SceneHandler.hpp>\n\n#include <Core/IGame.hpp>\n\n#include <Core/IScene.hpp>\n\n\n\n#include <Game/PauseMenuObject.hpp>\n\n#include <Game/GameScene.hpp>\n\n\n\n#include <SFML/Graphics/Texture.hpp>\n\n\n\nAA::PauseMenuObject::PauseMenuObject(CGL::IGame *game) : IMenuObject(game, GameScene::DRAW_ORDER_MENU) {\n\n auto& texture = this->getGame()->getTextureResourceHandler().load(\"Menu.png\");\n\n this->addItem({0, 64*3, 480, 64}, {0, 64*2, 480, 64}, texture);\n\n this->addItem({0, 64*5, 480, 64}, {0, 64*4, 480, 64}, texture);\n\n this->addItem({0, 64*9, 480, 64}, {0, 64*8, 480, 64}, texture);\n", "file_path": "game/src/Game/PauseMenuObject.cpp", "rank": 35, "score": 33800.04039445703 }, { "content": " std::shared_ptr<CGL::Animation> m_hurtLeftAnimation;\n\n\n\n std::shared_ptr<CGL::Animation> m_hurtRightAnimation;\n\n\n\n Player(const Player &original);\n\n\n\n Player &operator=(const Player &original);\n\n\n\n void setupSounds();\n\n\n\n void setupAnimations();\n\n\n\n bool isAlive() const;\n\n\n\n bool isVictorious() const;\n\n\n\n void decelerate(const float dt);\n\n\n\n void accelerate(const float dt);\n\n\n", "file_path": "game/include/Game/Player.hpp", "rank": 36, "score": 32154.62815623595 }, { "content": " void handleAnimation(const float dt);\n\n\n\n virtual const CGL::Animation &getMovingAnimation() const = 0;\n\n\n\n virtual const CGL::Animation &getDeadAnimation() const = 0;\n\n public:\n\n IEnemy(CGL::IGame *game, const sf::IntRect &spawnArea);\n\n\n\n ~IEnemy() override = 0;\n\n\n\n const EnemyDirection &getDirection() const;\n\n\n\n bool isAlive();\n\n\n\n void setDead();\n\n\n\n void restore(const bool respawn) override;\n\n\n\n void processEvents() override;\n\n\n\n void update(const float dt) override;\n\n };\n\n}\n\n\n\n#endif /* ALIENADVENTURE_ENEMY_HPP */\n", "file_path": "game/include/Game/IEnemy.hpp", "rank": 37, "score": 32153.651314973045 }, { "content": " void updatePosition(const float dt);\n\n\n\n void applyGravity(const float dt);\n\n\n\n void bounceAgainstSide(const sf::Vector2f &threshold, const sf::Vector2f &distance);\n\n\n\n void handleMovement(const float dt);\n\n\n\n void handleCollision();\n\n\n\n void handleAnimation(const float dt);\n\n public:\n\n Player(CGL::IGame *game, const std::vector<sf::IntRect> &spawnAreas, const sf::IntRect &exitArea);\n\n\n\n ~Player() override;\n\n\n\n void restore(const bool respawn) override;\n\n\n\n void processEvents() override;\n\n\n\n void update(const float dt) override;\n\n };\n\n}\n\n\n\n#endif /* ALIENADVENTURE_PLAYER_HPP */\n", "file_path": "game/include/Game/Player.hpp", "rank": 38, "score": 32152.192157045454 }, { "content": "\n\n void resume();\n\n\n\n bool isPaused() const;\n\n\n\n float getElapsedTime() const;\n\n\n\n float getPausedTime() const;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_ISCENE_HPP\n", "file_path": "lib/include/Core/IScene.hpp", "rank": 39, "score": 32151.34837422598 }, { "content": " Camera &operator=(const Camera &original);\n\n public:\n\n explicit Camera(const sf::FloatRect &rect);\n\n\n\n ~Camera();\n\n\n\n void setGlobalBounds(const sf::FloatRect &bounds);\n\n\n\n sf::FloatRect getGlobalBounds() const;\n\n\n\n void setCenter(const sf::Vector2f &center, bool force = false);\n\n\n\n sf::Vector2f getCenter() const;\n\n\n\n sf::View &getView() const;\n\n\n\n void update(const double &dt);\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_CAMERA_HPP\n", "file_path": "lib/include/Core/Camera.hpp", "rank": 40, "score": 32150.394243061688 }, { "content": "\n\n IGame *getGame() const;\n\n\n\n void init();\n\n\n\n void deinit();\n\n\n\n void processEvents();\n\n\n\n void update(const float dt);\n\n\n\n void draw();\n\n\n\n virtual void cleanup() = 0;\n\n\n\n ObjectHandler &getObjectHandler() const;\n\n\n\n bool isInitialized() const;\n\n\n\n void pause();\n", "file_path": "lib/include/Core/IScene.hpp", "rank": 41, "score": 32149.808071828524 }, { "content": " void setCollected(const bool collected);\n\n\n\n void restore(const bool respawn) override = 0;\n\n\n\n void processEvents() override;\n\n\n\n void update(const float dt) override;\n\n };\n\n}\n\n\n\n#endif /* ALIENADVENTURE_COLLECTIBLE_HPP */\n", "file_path": "game/include/Game/ICollectible.hpp", "rank": 42, "score": 32147.63866784443 }, { "content": " IScene &operator=(const IScene &original);\n\n protected:\n\n virtual void performInit() = 0;\n\n\n\n virtual void performDeinit() = 0;\n\n\n\n virtual void processExtraEvents() = 0;\n\n\n\n virtual void performExtraUpdates(const float dt) = 0;\n\n\n\n virtual void performExtraDrawing() = 0;\n\n\n\n virtual void didPause() = 0;\n\n\n\n virtual void didResume() = 0;\n\n\n\n public:\n\n explicit IScene(IGame *game);\n\n\n\n virtual ~IScene() = 0;\n", "file_path": "lib/include/Core/IScene.hpp", "rank": 43, "score": 32145.949794411215 }, { "content": " void updateCoins(const unsigned coins);\n\n\n\n void setupCoin();\n\n\n\n void setupCoinInitialDigit();\n\n\n\n void setupCoinMultiplier();\n\n public:\n\n explicit Hud(CGL::IGame *game);\n\n\n\n ~Hud() override;\n\n\n\n void restore(const bool respawn) override;\n\n\n\n void processEvents() override;\n\n\n\n void update(const float dt) override;\n\n };\n\n}\n\n\n\n#endif //ALIENADVENTURE_HUD_HPP\n", "file_path": "game/include/Game/Hud.hpp", "rank": 44, "score": 32145.8600276959 }, { "content": " void addTileMap(std::shared_ptr<TileMap> tileMap, int depth);\n\n\n\n sf::Vector2f getShortestCollisionDistance(const sf::Vector2f &position);\n\n\n\n sf::Vector2i getTileSize() const;\n\n\n\n void restore(const bool respawn) override;\n\n\n\n void processEvents() override;\n\n\n\n void update(const float dt) override;\n\n };\n\n}\n\n\n\n#endif /* ALIENADVENTURE_WORLD_HPP */\n", "file_path": "game/include/Game/World.hpp", "rank": 45, "score": 32145.288242242972 }, { "content": " sf::SoundBuffer *m_gameOverSoundBuffer;\n\n\n\n std::shared_ptr<sf::Sound> m_gameOverSound;\n\n\n\n sf::SoundBuffer *m_victoriousSoundBuffer;\n\n\n\n std::shared_ptr<sf::Sound> m_victoriousSound;\n\n\n\n std::shared_ptr<CGL::Animation> m_stationaryLeftAnimation;\n\n\n\n std::shared_ptr<CGL::Animation> m_stationaryRightAnimation;\n\n\n\n std::shared_ptr<CGL::Animation> m_walkLeftAnimation;\n\n\n\n std::shared_ptr<CGL::Animation> m_walkRightAnimation;\n\n\n\n std::shared_ptr<CGL::Animation> m_jumpLeftAnimation;\n\n\n\n std::shared_ptr<CGL::Animation> m_jumpRightAnimation;\n\n\n", "file_path": "game/include/Game/Player.hpp", "rank": 46, "score": 32144.471383583183 }, { "content": " void setOffset(const sf::Vector2f &offset);\n\n\n\n void setOffset(const float x, const float y);\n\n\n\n const sf::Vector2f &getOffset() const;\n\n\n\n virtual void setColor(const sf::Color &color) = 0;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_IENTITY_HPP\n", "file_path": "lib/include/Core/IEntity.hpp", "rank": 47, "score": 32144.072181307885 }, { "content": " float m_timeSinceHurt;\n\n\n\n float m_timeSinceGameOver;\n\n\n\n bool m_isJumping;\n\n\n\n bool m_wasJumping;\n\n\n\n unsigned int m_health;\n\n\n\n unsigned int m_coins;\n\n\n\n sf::SoundBuffer *m_jumpSoundBuffer;\n\n\n\n std::shared_ptr<sf::Sound> m_jumpSound;\n\n\n\n sf::SoundBuffer *m_hurtSoundBuffer;\n\n\n\n std::shared_ptr<sf::Sound> m_hurtSound;\n\n\n", "file_path": "game/include/Game/Player.hpp", "rank": 48, "score": 32143.016845169575 }, { "content": " bool isRunning() const;\n\n\n\n void quit(const int exitCode);\n\n\n\n void setMenu(std::shared_ptr<IMenuObject> menu);\n\n\n\n bool hasActiveMenu() const;\n\n\n\n void closeMenu();\n\n\n\n PropertyHandler &getPropertyHandler() const;\n\n\n\n ResourceHandler<sf::Image> &getImageResourceHandler() const;\n\n\n\n ResourceHandler<sf::Music> &getMusicResourceHandler() const;\n\n\n\n ResourceHandler<sf::SoundBuffer> &getSoundBufferResourceHandler() const;\n\n\n\n ResourceHandler<sf::Texture> &getTextureResourceHandler() const;\n\n\n", "file_path": "lib/include/Core/IGame.hpp", "rank": 49, "score": 32142.745603636846 }, { "content": "#include <utility>\n\n\n\n#include <utility>\n\n\n\n#include <utility>\n\n\n\n//\n\n// Created by Emil Hörnlund on 2018-09-15.\n\n//\n\n\n\n#ifndef COREGAMELIB_LEVEL_HPP\n\n#define COREGAMELIB_LEVEL_HPP\n\n\n\n#include <SFML/System/NonCopyable.hpp>\n\n#include <SFML/System/Vector2.hpp>\n\n\n\n#include <string>\n\n#include <vector>\n\n#include <memory>\n\n\n\nnamespace tinyxml2 { //TinyXML2\n", "file_path": "lib/include/Core/Level.hpp", "rank": 50, "score": 32140.687861221082 }, { "content": "//\n\n// Created by Emil Hörnlund on 2019-02-19.\n\n//\n\n\n\n#ifndef COREGAMELIB_TILELAYER_HPP\n\n#define COREGAMELIB_TILELAYER_HPP\n\n\n\n#include <SFML/System/NonCopyable.hpp>\n\n#include <SFML/System/Vector2.hpp>\n\n\n\n#include <string>\n\n#include <vector>\n\n\n\nnamespace tinyxml2 { //TinyXML2\n", "file_path": "lib/include/Core/Tilelayer.hpp", "rank": 51, "score": 32140.35234734556 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-07.\n\n//\n\n\n\n#ifndef COREGAMELIB_IGAME_HPP\n\n#define COREGAMELIB_IGAME_HPP\n\n\n\n#include <string>\n\n#include <memory>\n\n\n\n#include <SFML/System/Clock.hpp>\n\n\n\nnamespace sf { //SFML\n", "file_path": "lib/include/Core/IGame.hpp", "rank": 52, "score": 32140.25286126123 }, { "content": "/**\n\n * @file Collectible.hpp\n\n * @date 2016-12-09\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef ALIENADVENTURE_COLLECTIBLE_HPP\n\n#define ALIENADVENTURE_COLLECTIBLE_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <SFML/Audio/Sound.hpp>\n\n#include <SFML/Audio/SoundBuffer.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/ICollectible.hpp", "rank": 53, "score": 32140.243760978603 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-13.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_SUN_HPP\n\n#define ALIENADVENTURE_SUN_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/Sun.hpp", "rank": 54, "score": 32140.23269813513 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-08.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_HUD_HPP\n\n#define ALIENADVENTURE_HUD_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <vector>\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/Hud.hpp", "rank": 55, "score": 32140.212723280045 }, { "content": "//\n\n// Created by Emil Hörnlund on 2019-02-19.\n\n//\n\n\n\n#ifndef COREGAMELIB_TILESET_HPP\n\n#define COREGAMELIB_TILESET_HPP\n\n\n\n#include <SFML/System/NonCopyable.hpp>\n\n#include <SFML/System/Vector2.hpp>\n\n\n\n#include <string>\n\n\n\nnamespace tinyxml2 { //TinyXML2\n", "file_path": "lib/include/Core/Tileset.hpp", "rank": 56, "score": 32140.15390233571 }, { "content": "/**\n\n * @file Enemy.hpp\n\n * @date 2016-11-28\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef ALIENADVENTURE_ENEMY_HPP\n\n#define ALIENADVENTURE_ENEMY_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <SFML/Audio/Sound.hpp>\n\n#include <SFML/Audio/SoundBuffer.hpp>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/IEnemy.hpp", "rank": 57, "score": 32140.00470843493 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_CLOUD_HPP\n\n#define ALIENADVENTURE_CLOUD_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/Cloud.hpp", "rank": 58, "score": 32139.88091174234 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#ifndef COREGAMELIB_ISCENE_HPP\n\n#define COREGAMELIB_ISCENE_HPP\n\n\n\n#include <SFML/System/Clock.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/IScene.hpp", "rank": 59, "score": 32139.88091174234 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-06.\n\n//\n\n\n\n#ifndef COREGAMELIB_CAMERA_HPP\n\n#define COREGAMELIB_CAMERA_HPP\n\n\n\n#include <SFML/Graphics/View.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/Camera.hpp", "rank": 60, "score": 32139.88091174234 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-07.\n\n//\n\n\n\n#ifndef COREGAMELIB_IENTITY_HPP\n\n#define COREGAMELIB_IENTITY_HPP\n\n\n\n#include <SFML/Graphics/Drawable.hpp>\n\n#include <SFML/Graphics/Transformable.hpp>\n\n\n\nnamespace sf { //SFML\n", "file_path": "lib/include/Core/IEntity.hpp", "rank": 61, "score": 32139.85571835305 }, { "content": "/**\n\n * @file Game.hpp\n\n * @date 2016-11-25\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef ALIENADVENTURE_GAME_HPP\n\n#define ALIENADVENTURE_GAME_HPP\n\n\n\n#include <Core/IGame.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/Game.hpp", "rank": 62, "score": 32139.83084618205 }, { "content": "/**\n\n * @file Player.hpp\n\n * @date 2016-11-25\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef ALIENADVENTURE_PLAYER_HPP\n\n#define ALIENADVENTURE_PLAYER_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/Player.hpp", "rank": 63, "score": 32139.782041230894 }, { "content": "/**\n\n * @file World.hpp\n\n * @date 2016-11-28\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef ALIENADVENTURE_WORLD_HPP\n\n#define ALIENADVENTURE_WORLD_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/World.hpp", "rank": 64, "score": 32139.040038286254 }, { "content": " std::shared_ptr<IMenuObject> m_menu;\n\n\n\n std::shared_ptr<ConfigParser> m_configParser;\n\n\n\n bool m_running;\n\n\n\n int m_exitCode;\n\n\n\n sf::Clock m_gameClock;\n\n\n\n IGame(const IGame &original);\n\n\n\n IGame &operator=(const IGame &original);\n\n public:\n\n IGame(const std::string &title);\n\n\n\n virtual ~IGame() = 0;\n\n\n\n int run();\n\n\n", "file_path": "lib/include/Core/IGame.hpp", "rank": 65, "score": 32138.742889590765 }, { "content": " Level() = default;\n\n\n\n virtual ~Level() = default;\n\n\n\n bool loadFromFile(const std::string &filename);\n\n\n\n sf::Vector2i getTileSize() const;\n\n\n\n sf::Vector2i getMapSize() const;\n\n\n\n const std::vector<TilesetPtr>& getTilesets() const;\n\n\n\n const std::vector<TilelayerPtr>& getTilelayers() const;\n\n\n\n const std::vector<ObjectGroupPtr>& getObjectGroups() const;\n\n\n\n const std::vector<TilesetPtr> getUsedTilesets(TilelayerPtr tilelayerPtr) const;\n\n\n\n const std::vector<int> getTileData(TilelayerPtr tilelayerPtr, TilesetPtr tilesetPtr) const;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_LEVEL_HPP\n", "file_path": "lib/include/Core/Level.hpp", "rank": 66, "score": 32138.121160541512 }, { "content": " public:\n\n unsigned int id;\n\n std::string name;\n\n std::vector<ObjectPtr> objects;\n\n\n\n ObjectGroup(const unsigned int id, std::string name,\n\n std::vector<std::shared_ptr<const Object>> objects) : id(id), name(std::move(name)), objects(std::move(objects)) {}\n\n };\n\n\n\n typedef std::shared_ptr<const ObjectGroup> ObjectGroupPtr;\n\n\n", "file_path": "lib/include/Core/Level.hpp", "rank": 67, "score": 32135.9542326379 }, { "content": "\n\n explicit Tileset(const tinyxml2::XMLElement *node);\n\n\n\n ~Tileset() = default;\n\n\n\n std::string getName() const;\n\n\n\n std::string getSource() const;\n\n\n\n int getFirstGID() const;\n\n\n\n sf::Vector2i getTileSize() const;\n\n\n\n unsigned int getSpacing() const;\n\n\n\n unsigned int getTileCount() const;\n\n\n\n unsigned int getColumns() const;\n\n\n\n unsigned int getRows() const;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_TILESET_HPP\n", "file_path": "lib/include/Core/Tileset.hpp", "rank": 68, "score": 32135.9542326379 }, { "content": " ResourceHandler<Level> &getLevelResourceHandler() const;\n\n\n\n WindowHandler &getWindowHandler() const;\n\n\n\n EventHandler &getEventHandler() const;\n\n\n\n SceneHandler &getSceneHandler() const;\n\n\n\n ConfigParser &getConfigParser() const;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_IGAME_HPP\n", "file_path": "lib/include/Core/IGame.hpp", "rank": 69, "score": 32135.9542326379 }, { "content": " IMenuObject(const IMenuObject &original);\n\n\n\n IMenuObject &operator=(const IMenuObject &original);\n\n\n\n void updateOffsets();\n\n public:\n\n IMenuObject(IGame *game, const int zIndex);\n\n\n\n ~IMenuObject() override = 0;\n\n\n\n void addItem(const sf::IntRect &unselectedTextureRect, const sf::IntRect &selectedTextureRect,\n\n const sf::Texture &texture);\n\n\n\n void toggleNext();\n\n\n\n void togglePrevious();\n\n\n\n int getSelectedItemIndex() const;\n\n\n\n void restore(const bool respawn) override;\n\n\n\n void processEvents() override;\n\n\n\n void update(const float dt) override = 0;\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_IMENUOBJECT_HPP\n", "file_path": "lib/include/Core/IMenuObject.hpp", "rank": 70, "score": 31025.3488729038 }, { "content": " void clearObjects();\n\n\n\n void restoreObjects(const bool respawn = false);\n\n\n\n void updateObjects(const float dt);\n\n\n\n void drawObjects() const;\n\n };\n\n}\n\n\n\n#endif /* COREGAMELIB_OBJECTHANDLER_HPP */\n", "file_path": "lib/include/Core/ObjectHandler.hpp", "rank": 71, "score": 31023.783502115446 }, { "content": " virtual void processEvents() = 0;\n\n\n\n virtual void update(const float dt) = 0;\n\n\n\n int getZIndex() const;\n\n\n\n void setZIndex(const int depth);\n\n\n\n bool isVisible() const;\n\n\n\n void setVisible(const bool visible);\n\n\n\n bool isUsingCamera() const;\n\n\n\n void setPosition(const sf::Vector2f &position);\n\n\n\n void move(const sf::Vector2f &moveBy);\n\n\n\n sf::Vector2f getPosition() const;\n\n\n", "file_path": "lib/include/Core/IGameObject.hpp", "rank": 72, "score": 31023.771091016635 }, { "content": " std::shared_ptr<GameOverMenuObject> m_gameOverMenu;\n\n\n\n std::shared_ptr<LevelCompleteMenuObject> m_levelCompleteMenu;\n\n\n\n GameScene(const GameScene &original);\n\n\n\n GameScene &operator=(const GameScene &original);\n\n protected:\n\n void performInit() override;\n\n\n\n void performDeinit() override;\n\n\n\n void processExtraEvents() override;\n\n\n\n void performExtraUpdates(const float dt) override;\n\n\n\n void performExtraDrawing() override;\n\n\n\n void didPause() override;\n\n\n", "file_path": "game/include/Game/GameScene.hpp", "rank": 73, "score": 31021.817923347295 }, { "content": " void setVelocity(const sf::Vector2f &velocity);\n\n\n\n sf::Vector2f getVelocity() const;\n\n\n\n void setAcceleration(const sf::Vector2f &acceleration);\n\n\n\n sf::Vector2f getAcceleration() const;\n\n\n\n void updateSprites();\n\n\n\n sf::IntRect getBoundingBox() const;\n\n\n\n void setBoundingBox(const sf::IntRect &boundingBox);\n\n };\n\n}\n\n\n\n#endif /* COREGAMELIB_GAMEOBJECT_HPP */\n", "file_path": "lib/include/Core/IGameObject.hpp", "rank": 74, "score": 31020.53978528606 }, { "content": " ss >> value;\n\n return value;\n\n }\n\n\n\n template<>\n\n inline bool ConfigParser::convertToType<bool>(const std::string &input) const {\n\n return input == \"TRUE\";\n\n }\n\n}\n\n\n\n#endif //COREGAMELIB_CONFIGPARSER_HPP\n", "file_path": "lib/include/Core/ConfigParser.hpp", "rank": 75, "score": 31020.275261623443 }, { "content": "/**\n\n * @file GameObject.hpp\n\n * @date 2016-11-25\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef COREGAMELIB_GAMEOBJECT_HPP\n\n#define COREGAMELIB_GAMEOBJECT_HPP\n\n\n\n#include <SFML/System/Vector2.hpp>\n\n#include <SFML/Graphics/Rect.hpp>\n\n\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/IGameObject.hpp", "rank": 76, "score": 31019.952234190514 }, { "content": " IGameObject(const IGameObject &original);\n\n\n\n IGameObject &operator=(const IGameObject &original);\n\n public:\n\n IGameObject(IGame *game, const int zIndex, const bool useCamera);\n\n\n\n virtual ~IGameObject();\n\n\n\n IGame *getGame() const;\n\n\n\n void addEntity(std::shared_ptr<IEntity> entity);\n\n\n\n unsigned long getEntitiesSize() const;\n\n\n\n IEntity &getEntity(unsigned long index) const;\n\n\n\n void clearEntities();\n\n\n\n virtual void restore(const bool respawn) = 0;\n\n\n", "file_path": "lib/include/Core/IGameObject.hpp", "rank": 77, "score": 31019.799317962377 }, { "content": " return this->get(filename);\n\n}\n\n\n\ntemplate<typename Resource>\n\nResource &CGL::ResourceHandler<Resource>::open(const std::string &filename) {\n\n if (!this->hasResource(filename)) {\n\n auto *resource = new Resource;\n\n if (!resource->openFromFile(this->resourcePath() + filename))\n\n throw std::runtime_error(\"Failed to load \" + filename);\n\n this->resources.insert(std::make_pair(filename, resource));\n\n }\n\n return this->get(filename);\n\n}\n\n\n\ntemplate<typename Resource>\n\nbool CGL::ResourceHandler<Resource>::hasResource(const std::string &filename) {\n\n auto found = this->resources.find(filename);\n\n return (found != this->resources.end());\n\n}\n\n\n", "file_path": "lib/include/Core/ResourceHandler.hpp", "rank": 78, "score": 31018.317346836273 }, { "content": "//\n\n// Created by Emil Hörnlund on 2019-02-20.\n\n//\n\n\n\n#ifndef COREGAMELIB_CONFIGPARSER_HPP\n\n#define COREGAMELIB_CONFIGPARSER_HPP\n\n\n\n#include <string>\n\n#include <map>\n\n#include <locale>\n\n#include <sstream>\n\n#include <algorithm>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/ConfigParser.hpp", "rank": 79, "score": 31017.35935850107 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-06.\n\n//\n\n\n\n#ifndef COREGAMELIB_PROPERTYHANDLER_HPP\n\n#define COREGAMELIB_PROPERTYHANDLER_HPP\n\n\n\n#include <string>\n\n#include <map>\n\n#include <memory>\n\n#include <iostream>\n\n#include <utility>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/PropertyHandler.hpp", "rank": 80, "score": 31017.35935850107 }, { "content": "/**\n\n * @file ResourceHandler.hpp\n\n * @date 2018-09-04\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef COREGAMELIB_RESOURCEHANDLER_HPP\n\n#define COREGAMELIB_RESOURCEHANDLER_HPP\n\n\n\n#include <map>\n\n#include <string>\n\n#include <memory>\n\n#include <stdexcept>\n\n#include <cassert>\n\n\n\n#include <iostream>\n\n\n\nnamespace CGL { //CoreGameLib\n\n template<typename Resource>\n", "file_path": "lib/include/Core/ResourceHandler.hpp", "rank": 81, "score": 31017.343576049614 }, { "content": " if (this->properties.find(id) != this->properties.end()) {\n\n return static_cast<TProperty<T> *>(this->properties.at(id))->getValue();\n\n } else {\n\n return T();\n\n }\n\n }\n\n\n\n template<class T>\n\n void set(const std::string &id, T value) {\n\n if (this->properties.find(id) == this->properties.end()) {\n\n this->properties.insert(std::make_pair(id, new TProperty<T>(value)));\n\n } else {\n\n static_cast<TProperty<T> *>(this->properties.at(id))->setValue(value);\n\n }\n\n }\n\n\n\n bool hasProperty(const std::string &id) {\n\n return (this->properties.find(id) != this->properties.end());\n\n }\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_PROPERTYHANDLER_HPP\n", "file_path": "lib/include/Core/PropertyHandler.hpp", "rank": 82, "score": 31017.30699105134 }, { "content": " void setTilesetColumns(const unsigned int tilesetColumns);\n\n\n\n void setTilesetRows(const unsigned int tilesetRows);\n\n\n\n void setFilename(const std::string &filename);\n\n\n\n void setData(const std::vector<int> &data);\n\n\n\n void generate();\n\n\n\n void setColor(const sf::Color &color) override;\n\n };\n\n}\n\n\n\n#endif /* ALIENADVENTURE_TILEMAP_HPP */\n", "file_path": "game/include/Game/TileMap.hpp", "rank": 83, "score": 31017.187328968183 }, { "content": "/**\n\n * @file Renderer.hpp\n\n * @date 2016-11-25\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef COREGAMELIB_WINDOWHANDLER_HPP\n\n#define COREGAMELIB_WINDOWHANDLER_HPP\n\n\n\n#include <memory>\n\n#include <vector>\n\n\n\n#include <SFML/Graphics/Color.hpp>\n\n#include <SFML/System/Vector2.hpp>\n\n\n\nnamespace sf { //SFML\n", "file_path": "lib/include/Core/WindowHandler.hpp", "rank": 84, "score": 31017.117109987947 }, { "content": " void addInactiveScene(std::shared_ptr<IScene> scene);\n\n\n\n IScene &getActiveScene() const;\n\n\n\n void inactivateActivateScene();\n\n\n\n void dropActiveScene();\n\n\n\n void cleanup();\n\n };\n\n}\n\n\n\n#endif //COREGAMELIB_SCENEMANAGER_HPP\n", "file_path": "lib/include/Core/SceneHandler.hpp", "rank": 85, "score": 31017.115699552145 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_SPLASHOBJECT_HPP\n\n#define ALIENADVENTURE_SPLASHOBJECT_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <vector>\n\n#include <memory>\n\n\n\nnamespace AA { //AlienAdventure\n", "file_path": "game/include/Game/SplashObject.hpp", "rank": 86, "score": 31017.02904240248 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-07.\n\n//\n\n\n\n#ifndef COREGAMELIB_SPRITEENTITY_HPP\n\n#define COREGAMELIB_SPRITEENTITY_HPP\n\n\n\n#include <Core/IEntity.hpp>\n\n\n\n#include <SFML/Graphics/Vertex.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/SpriteEntity.hpp", "rank": 87, "score": 31016.969672200088 }, { "content": "/**\n\n * @file Background.hpp\n\n * @date 2016-12-10\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef ALIENADVENTURE_PARALLAXBACKGROUND_HPP\n\n#define ALIENADVENTURE_PARALLAXBACKGROUND_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/ParallaxBackground.hpp", "rank": 88, "score": 31016.930999065236 }, { "content": " unsigned int getTileHeight() const;\n\n\n\n unsigned int getTilesetColumns() const;\n\n\n\n unsigned int getTilesetRows() const;\n\n\n\n std::string getFilename() const;\n\n\n\n std::vector<int> getData() const;\n\n\n\n void setName(const std::string &name);\n\n\n\n void setColumns(const unsigned int columns);\n\n\n\n void setRows(const unsigned int rows);\n\n\n\n void setTileWidth(const unsigned int tileWidth);\n\n\n\n void setTileHeight(const unsigned int tileHeight);\n\n\n", "file_path": "game/include/Game/TileMap.hpp", "rank": 89, "score": 31016.859957869467 }, { "content": "/**\n\n * @file TileMap.hpp\n\n * @date 2016-11-29\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef ALIENADVENTURE_TILEMAP_HPP\n\n#define ALIENADVENTURE_TILEMAP_HPP\n\n\n\n#include <Core/IEntity.hpp>\n\n\n\n#include <SFML/Graphics/VertexArray.hpp>\n\n\n\n#include <string>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/TileMap.hpp", "rank": 90, "score": 31016.85574142353 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_GAMESCENE_HPP\n\n#define ALIENADVENTURE_GAMESCENE_HPP\n\n\n\n#include <Core/IScene.hpp>\n\n\n\n#include <string>\n\n\n\nnamespace sf { //SFML\n", "file_path": "game/include/Game/GameScene.hpp", "rank": 91, "score": 31016.754826943477 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#ifndef COREGAMELIB_SCENEMANAGER_HPP\n\n#define COREGAMELIB_SCENEMANAGER_HPP\n\n\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/SceneHandler.hpp", "rank": 92, "score": 31016.754826943477 }, { "content": " WindowHandler &operator=(const WindowHandler &original);\n\n\n\n void sortQueue();\n\n public:\n\n WindowHandler(CGL::IGame *game, const std::string &title);\n\n\n\n ~WindowHandler();\n\n\n\n IGame *getGame() const;\n\n\n\n sf::RenderWindow &getRenderWindow() const;\n\n\n\n Camera &getCamera() const;\n\n\n\n const sf::Vector2f &getWindowSize() const;\n\n\n\n void render();\n\n\n\n void clear(sf::Color color = sf::Color::Black);\n\n\n\n void draw(IGameObject &object);\n\n };\n\n}\n\n\n\n#endif /* COREGAMELIB_WINDOWHANDLER_HPP */\n", "file_path": "lib/include/Core/WindowHandler.hpp", "rank": 93, "score": 31016.722213722234 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-05.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_ENEMYSNAIL_HPP\n\n#define ALIENADVENTURE_ENEMYSNAIL_HPP\n\n\n\n#include <Game/IEnemy.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/EnemySnail.hpp", "rank": 94, "score": 31016.702776880404 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-05.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_COLLECTIBLECOIN_HPP\n\n#define ALIENADVENTURE_COLLECTIBLECOIN_HPP\n\n\n\n#include <Game/ICollectible.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/CollectibleCoin.hpp", "rank": 95, "score": 31016.702776880404 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-05.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_ENEMYBEE_HPP\n\n#define ALIENADVENTURE_ENEMYBEE_HPP\n\n\n\n#include <Game/IEnemy.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/EnemyBee.hpp", "rank": 96, "score": 31016.702776880404 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-05.\n\n//\n\n\n\n#ifndef ALIENADVENTURE_COLLECTIBLEHEALTH_HPP\n\n#define ALIENADVENTURE_COLLECTIBLEHEALTH_HPP\n\n\n\n#include <Game/ICollectible.hpp>\n\n\n\n#include <memory>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "game/include/Game/CollectibleHealth.hpp", "rank": 97, "score": 31016.702776880404 }, { "content": "//\n\n// Created by Emil Hörnlund on 2018-09-14.\n\n//\n\n\n\n#ifndef COREGAMELIB_IMENUOBJECT_HPP\n\n#define COREGAMELIB_IMENUOBJECT_HPP\n\n\n\n#include <Core/IGameObject.hpp>\n\n\n\n#include <SFML/System/Clock.hpp>\n\n\n\nnamespace sf { //SFML\n", "file_path": "lib/include/Core/IMenuObject.hpp", "rank": 98, "score": 31016.6520626204 }, { "content": "/**\n\n * @file ObjectHandler.hpp\n\n * @date 2016-11-25\n\n * @author Emil Hörnlund\n\n */\n\n\n\n#ifndef COREGAMELIB_OBJECTHANDLER_HPP\n\n#define COREGAMELIB_OBJECTHANDLER_HPP\n\n\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace CGL { //CoreGameLib\n", "file_path": "lib/include/Core/ObjectHandler.hpp", "rank": 99, "score": 31016.6271904494 } ]
C++
NNet/ModelIO/NNetModelImporter.cpp
pk1954/solutions
02cd67fc1e6299e9fe56ce04dce2515d6f30df92
#include "stdafx.h" #include <filesystem> #include <assert.h> #include "ERRHNDL.H" #include "SignalFactory.h" #include "SignalGenerator.h" #include "UPSigGenList.h" #include "Knot.h" #include "Neuron.h" #include "InputConnector.h" #include "OutputConnector.h" #include "MonitorData.h" #include "NobException.h" #include "NNetWrapperHelpers.h" #include "NNetParameters.h" #include "InputLine.h" #include "OutputLine.h" #include "IoLine.h" #include "win32_script.h" #include "win32_thread.h" #include "NNetModelStorage.h" #include "NNetModelImporter.h" #include "ImportTermination.h" #include "WrapCreateNob.h" #include "WrapVoltage.h" #include "WrapperBase.h" using std::filesystem::exists; using std::make_unique; using std::to_wstring; using std::bit_cast; class WrapProtocol : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { script.ScrReadString(L"version"); double dVersion = script.ScrReadFloat(); } }; class WrapDescription : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { wstring const wstrDescription { script.ScrReadString() }; GetWriterInterface().AddDescriptionLine(wstrDescription); } }; class WrapGlobalParameter : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { auto const param(static_cast<ParamType::Value>(script.ScrReadUint())); script.ScrReadSpecial(L'='); float const fValue { Cast2Float(script.ScrReadFloat()) }; GetWriterInterface().SetParam(param, fValue); } }; class WrapNrOfNobs : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { script.ScrReadSpecial(L'='); long lNrOfNobs { script.ScrReadLong() }; GetUPNobsRef().IncreaseSize(lNrOfNobs); } }; class WrapNobParameter : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { script.ScrReadString(L"InputLine"); NobId const id (script.ScrReadLong()); auto const param(static_cast< ParamType::Value >(script.ScrReadUint())); assert(param == ParamType::Value::pulseRate); script.ScrReadSpecial(L'='); Cast2Float(script.ScrReadFloat()); } }; class WrapTriggerSound : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { NobId const id { ScrReadNobId(script) }; Neuron * pNeuron { GetWriterInterface().GetNobPtr<Neuron *>(id) }; Hertz const freq { script.ScrReadUlong() }; script.ScrReadString(L"Hertz"); MilliSecs const msec { script.ScrReadUlong() }; script.ScrReadString(L"msec"); pNeuron->SetTriggerSound(SoundDescr{ true, freq, msec }); } }; class WrapNrOfTracks : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { unsigned int const uiNrOfTracks { script.ScrReadUint() }; for (unsigned int ui = 0; ui < uiNrOfTracks; ++ui) GetMonitorData().InsertTrack(TrackNr(0)); } }; class WrapSignal : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { MicroMeterCircle umCircle; TrackNr trackNr { ScrReadTrackNr(script) }; script.ScrReadString(L"source"); unsigned long ulSigSrc { script.ScrReadUlong() }; if (ulSigSrc == NNetModelStorage::SIGSRC_CIRCLE) { umCircle = ScrReadMicroMeterCircle(script); } else { throw ScriptErrorHandler::ScriptException(999, wstring(L"Signal source type must be 101")); } GetMonitorData().AddSignal(GetUPNobsRef(), trackNr, umCircle); } }; class WrapSetParam : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { NobId const id { ScrReadNobId(script) }; ParamType::Value const param { ScrReadParamType(script) }; float fVal { Cast2Float(script.ScrReadFloat()) }; if (InputConnector * pInpConn { GetWriterInterface().GetNobPtr<InputConnector *>(id) }) { pInpConn->Apply2All ( [param, fVal](IoLine & n) { auto & inputLine { static_cast<InputLine &>(n) }; inputLine.GetSigGen()->SetParam(param, fVal); } ); } else if ( InputLine * pInpNeuron { GetWriterInterface().GetNobPtr<InputLine*>(id) } ) { pInpNeuron->GetSigGen()->SetParam(param, fVal); } } }; class WrapSignalGenerator : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { NNetModelWriterInterface & nmwi { GetWriterInterface() }; wstring const name { script.ScrReadString() }; SigGenStaticData const sigGenData { ScrReadSigGenStaticData(script) }; SigGenId const sigGenId { nmwi.FindSigGen(name) }; if (nmwi.IsValid(sigGenId)) { SignalGenerator * pSigGen { nmwi.GetSigGen(sigGenId) }; pSigGen->SetStaticData(sigGenData); } else { UPSigGen upSigGen { move(nmwi.NewSigGen(name)) }; upSigGen->SetStaticData(sigGenData); nmwi.PushSigGen(move(upSigGen)); } } }; void NNetModelImporter::Initialize() { SymbolTable::ScrDefConst(L"circle", NNetModelStorage::SIGSRC_CIRCLE ); SymbolTable::ScrDefConst(L"Description", new WrapDescription (* this)); SymbolTable::ScrDefConst(L"Protocol", new WrapProtocol (* this)); SymbolTable::ScrDefConst(L"GlobalParameter", new WrapGlobalParameter(* this)); SymbolTable::ScrDefConst(L"NrOfNobs", new WrapNrOfNobs (* this)); SymbolTable::ScrDefConst(L"CreateNob", new WrapCreateNob (* this)); SymbolTable::ScrDefConst(L"NobParameter", new WrapNobParameter (* this)); SymbolTable::ScrDefConst(L"TriggerSound", new WrapTriggerSound (* this)); SymbolTable::ScrDefConst(L"NrOfTracks", new WrapNrOfTracks (* this)); SymbolTable::ScrDefConst(L"Signal", new WrapSignal (* this)); SymbolTable::ScrDefConst(L"SetParam", new WrapSetParam (* this)); SymbolTable::ScrDefConst(L"Voltage", new WrapVoltage (* this)); SymbolTable::ScrDefConst(L"SignalGenerator", new WrapSignalGenerator(* this)); NobType::Apply2All ( [](NobType const & type) { SymbolTable::ScrDefConst ( NobType::GetName(type.GetValue()), static_cast<unsigned long>(type.GetValue()) ); } ); SymbolTable::ScrDefConst(L"inputNeuron", static_cast<unsigned long>(NobType::Value::inputLine)); SymbolTable::ScrDefConst(L"outputNeuron", static_cast<unsigned long>(NobType::Value::outputLine)); ParamType::Apply2AllParameters ( [](ParamType::Value const & param) { SymbolTable::ScrDefConst ( ParamType::GetName(param), static_cast<unsigned long>(param) ); } ); } void NNetModelImporter::importModel() { ImportTermination::Result res; Script script; bool bSuccess { false }; if (! m_wstrFile2Read.empty()) { script.SetEcho(true); try { bSuccess = script.ScrProcess(m_wstrFile2Read); } catch (NobException const & e) { CheckImportedNobId(script, m_ImportedNMWI.GetUPNobs(), e.m_id); } } if (bSuccess) { m_ImportedNMWI.RemoveOrphans(); m_ImportedNMWI.SetModelFilePath(m_wstrFile2Read); m_ImportedNMWI.DescriptionComplete(); res = ImportTermination::Result::ok; } else { m_upImportedModel.release(); res = ImportTermination::Result::errorInFile; } m_upTermination->Reaction(res, m_wstrFile2Read); } void NNetModelImporter::CheckImportedNobId ( Script & script, UPNobList const & list, NobId const id ) { wstring const strNobId { to_wstring(id.GetValue()) }; if (IsUndefined(id)) { script.SetExpectedToken(L"NobId != NO_NOB"); throw ScriptErrorHandler::ScriptException(999, wstring(L"Invalid nob id: ") + strNobId); } else if (! list.IsValidNobId(id)) { script.SetExpectedToken(L"id < " + to_wstring(list.Size())); throw ScriptErrorHandler::ScriptException(999, wstring(L"Invalid nob id: ") + strNobId); } else if (! list.IsNobDefined(id)) { script.SetExpectedToken(L"Defined NobId"); throw ScriptErrorHandler::ScriptException(999, wstring(L"Nob is not defined: ") + strNobId); } }; static unsigned int __stdcall importModelThreadProc(void * data) { SetThreadDescription(GetCurrentThread(), L"ImportModel"); NNetModelImporter * pModelImporter { bit_cast<NNetModelImporter *>(data) }; pModelImporter->importModel(); return 0; } bool NNetModelImporter::Import ( wstring const & wstrPath, unique_ptr<ImportTermination> upTermination ) { if (wstrPath.empty()) return false; if (m_upImportedModel.get()) return false; if (! exists(wstrPath)) { upTermination->Reaction(ImportTermination::Result::fileNotFound, wstrPath); return false; } m_upTermination = move(upTermination); m_upImportedModel = make_unique<NNetModel>(); m_ImportedNMWI.SetModel(m_upImportedModel.get()); m_wstrFile2Read = wstrPath; Util::RunAsAsyncThread(importModelThreadProc, static_cast<void *>(this)); return true; } unique_ptr<NNetModel> NNetModelImporter::GetImportedModel() { return move(m_upImportedModel); }
#include "stdafx.h" #include <filesystem> #include <assert.h> #include "ERRHNDL.H" #include "SignalFactory.h" #include "SignalGenerator.h" #include "UPSigGenList.h" #include "Knot.h" #include "Neuron.h" #include "InputConnector.h" #include "OutputConnector.h" #include "MonitorData.h" #include "NobException.h" #include "NNetWrapperHelpers.h" #include "NNetParameters.h" #include "InputLine.h" #include "OutputLine.h" #include "IoLine.h" #include "win32_script.h" #include "win32_thread.h" #include "NNetModelStorage.h" #include "NNetModelImporter.h" #include "ImportTermination.h" #include "WrapCreateNob.h" #include "WrapVoltage.h" #include "WrapperBase.h" using std::filesystem::exists; using std::make_unique; using std::to_wstring; using std::bit_cast; class WrapProtocol : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { script.ScrReadString(L"version"); double dVersion = script.ScrReadFloat(); } }; class WrapDescription : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { wstring const wstrDescription { script.ScrReadString() }; GetWriterInterface().AddDescriptionLine(wstrDescription); } }; class WrapGlobalParameter : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { auto const param(static_cast<ParamType::Value>(script.ScrReadUint())); script.ScrReadSpecial(L'='); float const fValue { Cast2Float(script.ScrReadFloat()) }; GetWriterInterface().SetParam(param, fValue); } }; class WrapNrOfNobs : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { script.ScrReadSpecial(L'='); long lNrOfNobs { script.ScrReadLong() }; GetUPNobsRef().IncreaseSize(lNrOfNobs); } }; class WrapNobParameter : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { script.ScrReadString(L"InputLine"); NobId const id (script.ScrReadLong()); auto const param(static_cast< ParamType::Value >(script.ScrReadUint())); assert(param == ParamType::Value::pulseRate); script.ScrReadSpecial(L'='); Cast2Float(script.ScrReadFloat()); } }; class WrapTriggerSound : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { NobId const id { ScrReadNobId(script) }; Neuron * pNeuron { GetWriterInterface().GetNobPtr<Neuron *>(id) }; Hertz const freq { script.ScrReadUlong() }; script.ScrReadString(L"Hertz"); MilliSecs const msec { script.ScrReadUlong() }; script.ScrReadString(L"msec"); pNeuron->SetTriggerSound(SoundDescr{ true, freq, msec }); } }; class WrapNrOfTracks : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { unsigned int const uiNrOfTracks { script.ScrReadUint() }; for (unsigned int ui = 0; ui < uiNrOfTracks; ++ui) GetMonitorData().InsertTrack(TrackNr(0)); } }; class WrapSignal : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { MicroMeterCircle umCircle; TrackNr trackNr { ScrReadTrackNr(script) }; script.ScrReadString(L"source"); unsigned long ulSigSrc { script.ScrReadUlong() }; if (ulSigSrc == NNetModelStorage::SIGSRC_CIRCLE) { umCircle = ScrReadMicroMeterCircle(script); } else { throw ScriptErrorHandler::ScriptException(999, wstring(L"Signal source type must be 101")); } GetMonitorData().AddSignal(GetUPNobsRef(), trackNr, umCircle); } }; class WrapSetParam : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { NobId const id { ScrReadNobId(script) }; ParamType::Value const param { ScrReadParamType(script) }; float fVal { Cast2Float(script.ScrReadFloat()) }; if (InputConnector * pInpConn { GetWriterInterface().GetNobPtr<InputConnector *>(id) }) { pInpConn->Apply2All ( [param, fVal](IoLine & n) { auto & inputLine { static_cast<InputLine &>(n) }; inputLine.GetSigGen()->SetParam(param, fVal); } ); } else if ( InputLine * pInpNeuron { GetWriterInterface().GetNobPtr<InputLine*>(id) } ) { pInpNeuron->GetSigGen()->SetParam(param, fVal); } } }; class WrapSignalGenerator : public WrapperBase { public: using WrapperBase::WrapperBase; void operator() (Script & script) const final { NNetModelWriterInterface & nmwi { GetWriterInterface() }; wstring const name { script.ScrReadString() }; SigGenStaticData const sigGenData { ScrReadSigGenStaticData(script) }; SigGenId const sigGenId { nmwi.FindSigGen(name) }; if (nmwi.IsValid(sigGenId)) { SignalGenerator * pSigGen { nmwi.GetSigGen(sigGenId) }; pSigGen->SetStaticData(sigGenData); } else { UPSigGen upSigGen { move(nmwi.NewSigGen(name)) }; upSigGen->SetStaticData(sigGenData); nmwi.PushSigGen(move(upSigGen)); } } }; void NNetModelImporter::Initialize() { SymbolTable::ScrDefConst(L"circle", NNetModelStorage::SIGSRC_CIRCLE ); SymbolTable::ScrDefConst(L"Description", new WrapDescription (* this)); SymbolTable::ScrDefConst(L"Protocol", new WrapProtocol (* this)); SymbolTable::ScrDefConst(L"GlobalParameter", new WrapGlobalParameter(* this)); SymbolTable::ScrDefConst(L"NrOfNobs", new WrapNrOfNobs (* this)); SymbolTable::ScrDefConst(L"CreateNob", new WrapCreateNob (* this)); SymbolTable::ScrDefConst(L"NobParameter", new WrapNobParameter (* this)); SymbolTable::ScrDefConst(L"TriggerSound", new WrapTriggerSound (* this)); SymbolTable::ScrDefConst(L"NrOfTracks", new WrapNrOfTracks (* this)); SymbolTable::ScrDefConst(L"Signal", new WrapSignal (* this)); SymbolTable::ScrDefConst(L"SetParam", new WrapSetParam (* this)); SymbolTable::ScrDefConst(L"Voltage", new WrapVoltage (* this)); SymbolTable::ScrDefConst(L"SignalGenerator", new WrapSignalGenerator(* this)); NobType::Apply2All ( [](NobType const & type) { SymbolTable::ScrDefConst ( NobType::GetName(type.GetValue()), static_cast<unsigned long>(type.GetValue()) ); } ); SymbolTable::ScrDefConst(L"inputNeuron", static_cast<unsigned long>(NobType::Value::inputLine)); SymbolTable::ScrDefConst(L"outputNeuron", static_cast<unsigned long>(NobType::Value::outputLine)); ParamType::Apply2AllParameters ( [](ParamType::Value const & param) {
; } ); } void NNetModelImporter::importModel() { ImportTermination::Result res; Script script; bool bSuccess { false }; if (! m_wstrFile2Read.empty()) { script.SetEcho(true); try { bSuccess = script.ScrProcess(m_wstrFile2Read); } catch (NobException const & e) { CheckImportedNobId(script, m_ImportedNMWI.GetUPNobs(), e.m_id); } } if (bSuccess) { m_ImportedNMWI.RemoveOrphans(); m_ImportedNMWI.SetModelFilePath(m_wstrFile2Read); m_ImportedNMWI.DescriptionComplete(); res = ImportTermination::Result::ok; } else { m_upImportedModel.release(); res = ImportTermination::Result::errorInFile; } m_upTermination->Reaction(res, m_wstrFile2Read); } void NNetModelImporter::CheckImportedNobId ( Script & script, UPNobList const & list, NobId const id ) { wstring const strNobId { to_wstring(id.GetValue()) }; if (IsUndefined(id)) { script.SetExpectedToken(L"NobId != NO_NOB"); throw ScriptErrorHandler::ScriptException(999, wstring(L"Invalid nob id: ") + strNobId); } else if (! list.IsValidNobId(id)) { script.SetExpectedToken(L"id < " + to_wstring(list.Size())); throw ScriptErrorHandler::ScriptException(999, wstring(L"Invalid nob id: ") + strNobId); } else if (! list.IsNobDefined(id)) { script.SetExpectedToken(L"Defined NobId"); throw ScriptErrorHandler::ScriptException(999, wstring(L"Nob is not defined: ") + strNobId); } }; static unsigned int __stdcall importModelThreadProc(void * data) { SetThreadDescription(GetCurrentThread(), L"ImportModel"); NNetModelImporter * pModelImporter { bit_cast<NNetModelImporter *>(data) }; pModelImporter->importModel(); return 0; } bool NNetModelImporter::Import ( wstring const & wstrPath, unique_ptr<ImportTermination> upTermination ) { if (wstrPath.empty()) return false; if (m_upImportedModel.get()) return false; if (! exists(wstrPath)) { upTermination->Reaction(ImportTermination::Result::fileNotFound, wstrPath); return false; } m_upTermination = move(upTermination); m_upImportedModel = make_unique<NNetModel>(); m_ImportedNMWI.SetModel(m_upImportedModel.get()); m_wstrFile2Read = wstrPath; Util::RunAsAsyncThread(importModelThreadProc, static_cast<void *>(this)); return true; } unique_ptr<NNetModel> NNetModelImporter::GetImportedModel() { return move(m_upImportedModel); }
SymbolTable::ScrDefConst ( ParamType::GetName(param), static_cast<unsigned long>(param) )
call_expression
[ { "content": "class Neuron : public BaseKnot\n\n{\n\npublic:\n\n\tNeuron(MicroMeterPnt const &, NobType const = NobType::Value::neuron);\n\n\tNeuron(BaseKnot const &, NobType const = NobType::Value::neuron);\n\n\tNeuron(Neuron const &); // copy constructor\n\n\n\n\tNeuron & operator=(Neuron const &); // copy assignment operator\n\n\n\n\t~Neuron() override = default;\n\n\n\n\tbool operator==(Nob const &) const override;\n\n\n\n\tvoid Prepare () override;\n\n\tvoid AppendMenuItems(AddMenuFunc const &) const override;\n\n\n\n\tstatic bool TypeFits(NobType const type) { return type.IsNeuronType(); }\n\n\n\n\tbool HasAxon () const { return HasOutgoing(); }\n\n\tbool HasTriggerSound () const { return m_triggerSound.m_bOn; }\n", "file_path": "NNet/NNetModel/Neuron.h", "rank": 0, "score": 287373.5319380918 }, { "content": "class Param : public Observable\n\n{\n\npublic:\n\n\n\n\tbool operator==(Param const & rhs) const;\n\n\n\n\tfloat GetParameterValue(ParamType::Value const) const;\n\n\tvoid SetParameterValue(ParamType::Value const, float const);\n\n\n\n\tSigGenStaticData const & GetSigGenStaticData() const { return m_sigGenData; }\n\n\n\n\tvoid SetSigGenStaticData(SigGenStaticData const&);\n\n\n\n\tmV NeuronPeakVolt() const { return m_neuronPeakVolt; }\n\n\tmV Threshold () const { return m_threshold; \t }\n\n\tfMicroSecs SpikeWidth () const { return m_spikeWidth; }\n\n\tfMicroSecs RefractPeriod () const { return m_refractPeriod; }\n\n\tmeterPerSec PulseSpeed () const { return m_pulseSpeed; }\n\n\tfMicroSecs TimeResolution() const { return m_usResolution; }\n\n\tfMicroSecs FilterSize () const { return m_usFilterSize; }\n", "file_path": "NNet/NNetModel/NNetParameters.h", "rank": 1, "score": 275872.181504117 }, { "content": "class WrapSplitNeuron: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n m_pCommands->SplitNeuron(id);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 2, "score": 266037.04871413356 }, { "content": "class WrapInsertNeuron: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n MicroMeterPnt const umPos { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->InsertNeuron(id, umPos);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 3, "score": 266037.04871413356 }, { "content": "class WrapNewIoLinePair: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n MicroMeterPnt const umPos { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->NewIoLinePair(umPos);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 4, "score": 257716.63344941742 }, { "content": "class ScriptHook : public ScriptFunctor\n\n{\n\npublic:\n\n\tvoid Initialize\n\n\t(\n\n\t\tStatusBar * const pStatusBar, \n\n\t\tint const iPart\n\n\t)\n\n\t{\n\n\t\tm_pStatusBar = pStatusBar;\n\n\t\tm_iStatusBarPart = iPart;\n\n\t\tm_pStatusBar->AddCustomControl(80); // nr of characters\n\n\t}\n\n\n\n\tvoid operator() (Script & script) const final\n\n\t{\n\n\t\tif (!m_pStatusBar)\n\n\t\t\treturn;\n\n\n\n\t\tif (Script const * const pScript { ScriptStack::GetScript() })\n", "file_path": "NNet/NNetWindows/win32_scriptHook.h", "rank": 6, "score": 248986.28840076624 }, { "content": "class SplitNeuronCmd : public NNetCommand\n\n{\n\npublic:\n\n explicit SplitNeuronCmd(NobId const id)\n\n : m_neuron(*m_pNMWI->GetNobPtr<Neuron *>(id))\n\n {\n\n MicroMeterPnt umPos { m_neuron.GetPos() };\n\n m_upInputLine = make_unique<InputLine >(m_pNMWI->StdSigGen(), umPos);\n\n m_upOutputLine = make_unique<OutputLine>(umPos);\n\n m_upInputLine ->SetOutgoing(m_neuron);\n\n m_upOutputLine->SetIncoming(m_neuron);\n\n m_upInputLine ->MoveNob((m_neuron.GetFirstOutgoing().GetEndPoint ()-umPos).ScaledTo(NEURON_RADIUS*2));\n\n m_upOutputLine->MoveNob((m_neuron.GetFirstIncoming().GetStartPoint()-umPos).ScaledTo(NEURON_RADIUS*2));\n\n }\n\n\n\n ~SplitNeuronCmd() final = default;\n\n\n\n void Do() final\n\n {\n\n m_upNeuron = m_pNMWI->RemoveFromModel<Neuron>(m_neuron);\n", "file_path": "NNet/Commands/SplitNeuronCmd.h", "rank": 7, "score": 242401.6897274237 }, { "content": "class ParamType\n\n{\n\npublic:\n", "file_path": "NNet/NNetModel/ParameterType.h", "rank": 8, "score": 234524.10993006895 }, { "content": "class DescriptionWindow : public BaseWindow, public DescriptionUI\n\n{\n\npublic:\n\n\tvoid Start(HWND const);\n\n\tvoid Stop();\n\n\n\n\tbool SetFontSize(int const);\n\n\tint GetFontSize() const { return m_iFontSize; }\n\n\n\n\tint GetLineCount () const final;\n\n\tbool GetDescriptionLine(int const, wstring &) const final;\n\n\tvoid ClearDescription () final;\n\n\tvoid SetDescription (wstring const &) final;\n\n\n\n\tbool IsDirty() final { return m_bDirty; };\n\n\tvoid ResetDirtyFlag() final { m_bDirty = false; };\n\n\n\nprivate:\n\n\tint m_iFontSize { 20 };\n\n\tHFONT m_hFont { nullptr };\n", "file_path": "NNet/NNetWindows/win32_descriptionWindow.h", "rank": 9, "score": 233381.80946971264 }, { "content": "class WrapBreak : public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n int x = 42;\n\n }\n\n};\n\n\n\nvoid NNetWrappersSetModelInterface(NNetModelReaderInterface * const pNMRI)\n\n{\n\n m_pNMRI = pNMRI;\n\n};\n\n\n\nvoid InitializeNNetWrappers\n\n(\n\n NNetModelCommands * const pCommands,\n\n NNetModelImporter * const pModelImporter\n\n)\n\n{\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 10, "score": 231346.53433069293 }, { "content": "class WrapSelectAll: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n bool const bOn { script.ScrReadInt() != 0 };\n\n m_pCommands->SelectAll(bOn);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 11, "score": 231346.53433069293 }, { "content": "class WrapConnect: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const idSrc { ScrReadNobId(script) };\n\n NobId const idDst { ScrReadNobId(script) };\n\n ConnectionType const ctype { m_pNMRI->ConnectionResult(idSrc, idDst) };\n\n if (ctype != ConnectionType::ct_none)\n\n {\n\n m_pCommands->Connect(idSrc, idDst, ctype);\n\n }\n\n else\n\n {\n\n script.SetExpectedToken(L\"\");\n\n wstring wstrMsg\n\n {\n\n L\"Invalid: Connect \" + \n\n m_pNMRI->GetTypeName(idSrc) + \n\n L\" to \" + \n\n m_pNMRI->GetTypeName(idDst)\n\n };\n\n throw ScriptErrorHandler::ScriptException(999, wstrMsg);\n\n }\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 12, "score": 231346.53433069293 }, { "content": "class NewIoLinePairCmd : public NNetCommand\n\n{\n\npublic:\n\n\texplicit NewIoLinePairCmd\n\n\t(\n\n\t\tNNetModelWriterInterface & nmwi,\n\n\t\tMicroMeterPnt const & pos\n\n\t)\n\n\t\t: m_IoLinePair(nmwi, pos)\n\n\t{}\n\n\n\n\t~NewIoLinePairCmd() final = default;\n\n\n\n\tvoid Do() final \n\n\t{\n\n\t\tm_IoLinePair.Push(*m_pNMWI);\n\n\t}\n\n\n\n\tvoid Undo() final\n\n\t{ \n\n\t\tm_IoLinePair.Pop(*m_pNMWI);\n\n\t}\n\n\n\nprivate:\n\n\tIoLinePair m_IoLinePair;\n\n};\n", "file_path": "NNet/Commands/NewIoLinePairCmd.h", "rank": 13, "score": 228505.2967474762 }, { "content": "\tenum class Id : unsigned short\n\n\t{\n\n\t\tmove, \n\n\t\tclone,\n\n\t\tmarry,\n\n\t\tinteract, \n\n\t\teat, \n\n\t\tfertilize,\n\n\t\tappetite,\n\n\t\tfertilInvest,\n\n\t\tmemSize,\n\n\t\tthresholdClone, // minimum available energy for considering CLONE\n\n\t\tthresholdMarry, // minimum available energy for considering MARRY\n\n\t\tthresholdMove, // minimum available energy for considering MOVE\n\n\t\tthresholdFert, // minimum available energy for considering FERTILIZE\n\n\t\tmaxEat, // maximum available energy for considering EAT\n\n\t\tcloneDonation, // amount of energy donated to clone. 0 means nothing (clone dies), SHORT_MAX means all available energy (parent dies)\n\n\t\treserve1,\n\n\t\tcount,\n\n\t\tundefined = count\n", "file_path": "Evo/EvolutionCoreInterface/GeneType.h", "rank": 14, "score": 227872.3791400829 }, { "content": "class WrapAnalyzeLoops: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->AnalyzeLoops();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 15, "score": 227839.67688351602 }, { "content": "class WrapMoveSelection: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n MicroMeterPnt const umPos { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->MoveSelection(umPos);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 16, "score": 227839.67688351602 }, { "content": "class WrapSelectSubtree: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n bool const bOn { script.ScrReadInt() != 0 };\n\n m_pCommands->SelectSubtree(id, bOn);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 17, "score": 227839.67688351602 }, { "content": "class WrapSelectAllBeepers: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->SelectAllBeepers();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 18, "score": 227839.67688351602 }, { "content": "class WrapRedoCommand: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->RedoCommand();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 19, "score": 227839.67688351602 }, { "content": "class WrapDeleteSelection: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->DeleteSelection();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 20, "score": 227839.67688351602 }, { "content": "class WrapCopySelection: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->CopySelection();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 21, "score": 227839.67688351602 }, { "content": "class WrapClearBeepers: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->ClearBeepers();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 22, "score": 227839.67688351602 }, { "content": "class WrapSetParameter: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n ParamType::Value const param { static_cast<ParamType::Value>(script.ScrReadUlong()) };\n\n float const fValue { Cast2Float(script.ScrReadFloat()) };\n\n m_pCommands->SetParameter(param, fValue);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 23, "score": 227839.67688351602 }, { "content": "class WrapUndoCommand: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->UndoCommand();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 24, "score": 227839.67688351602 }, { "content": "class WrapResetModel: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->ResetModel();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 25, "score": 227839.67688351602 }, { "content": "class WrapAddModel: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pModelImporter->Import\n\n (\n\n script.ScrReadString(), \n\n NNetImportTermination::CreateNew(IDM_ADD_IMPORTED_MODEL)\n\n );\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 26, "score": 227839.67688351602 }, { "content": "class WrapMoveNob: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n MicroMeterPnt const umDelta { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->MoveNob(id, umDelta);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 27, "score": 227839.67688351602 }, { "content": "class WrapAnalyzeAnomalies: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->AnalyzeAnomalies();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 28, "score": 227839.67688351602 }, { "content": "class WrapMoveSensor: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n SignalId const id { ScrReadSignalId(script) };\n\n MicroMeterPnt const umDelta { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->MoveSensor(id, umDelta);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 29, "score": 227839.67688351602 }, { "content": "class WrapSelectNob: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n tBoolOp const op { ScrReadBoolOp(script) };\n\n m_pCommands->SelectNob(id, op);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 30, "score": 227839.67688351602 }, { "content": "class WrapAddSignal: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n MicroMeterCircle const umCircle { ScrReadMicroMeterCircle(script) };\n\n TrackNr const trackNr { ScrReadTrackNr(script) };\n\n m_pCommands->AddSignal(umCircle, trackNr);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 31, "score": 227839.67688351602 }, { "content": "class WrapDeleteNob: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n m_pCommands->DeleteNob(id);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 32, "score": 227839.67688351602 }, { "content": "class Param;\n", "file_path": "NNet/NNetModel/Signal.h", "rank": 33, "score": 225497.2148946685 }, { "content": "class Param;\n", "file_path": "NNet/NNetModel/Nob.h", "rank": 34, "score": 225497.2148946685 }, { "content": "class WrapSetAutoOpen: public WrapBase\n\n{\n\npublic:\n\n WrapSetAutoOpen()\n\n : WrapBase(L\"SetAutoOpen\")\n\n {}\n\n\n\n void operator() (Script & script) const final\n\n {\n\n bool bMode { static_cast<bool>(script.ScrReadUint()) };\n\n if (bMode)\n\n AutoOpen::On();\n\n else\n\n AutoOpen::Off();\n\n }\n\n\n\n void Write(wostream & out) const final\n\n {\n\n out << (AutoOpen::IsOn() ? PREF_ON : PREF_OFF);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/Preferences.cpp", "rank": 35, "score": 225041.40901799753 }, { "content": "class WrapToggleStopOnTrigger: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n m_pCommands->ToggleStopOnTrigger(id);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 36, "score": 224483.30800698785 }, { "content": "class WrapDeleteBaseKnot: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n m_pCommands->DeleteBaseKnot(id);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 37, "score": 224483.30800698785 }, { "content": "class WrapSetTriggerSound: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n SoundDescr desc \n\n {\n\n script.ScrReadInt() != 0,\n\n Hertz(script.ScrReadUlong()),\n\n MilliSecs(script.ScrReadUlong())\n\n };\n\n m_pCommands->SetTriggerSound(id, desc);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 38, "score": 224483.30800698785 }, { "content": "class WrapAddOutgoing2Pipe: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const idNob { ScrReadNobId(script) };\n\n MicroMeterPnt const umPos { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->AddOutgoing2Pipe(idNob, umPos);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 39, "score": 224483.30800698785 }, { "content": "class WrapAddIncoming2Pipe: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const idNob { ScrReadNobId(script) };\n\n MicroMeterPnt const umPos { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->AddIncoming2Pipe(idNob, umPos);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 40, "score": 224483.30800698785 }, { "content": "class WrapSelectNobsInRect: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n MicroMeterPnt const umPntStart { ScrReadMicroMeterPnt(script) };\n\n MicroMeterPnt const umPntEnd { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->SelectNobsInRect(MicroMeterRect(umPntStart, umPntEnd));\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 41, "score": 224483.30800698785 }, { "content": "class WrapCreateInitialNobs: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->CreateInitialNobs();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 42, "score": 224483.30800698785 }, { "content": "class WrapMakeIoConnector: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n m_pCommands->MakeIoConnector();\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 43, "score": 224483.30800698785 }, { "content": "class WrapDiscIoConnector: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const id { ScrReadNobId(script) };\n\n m_pCommands->DiscIoConnector(id);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 44, "score": 224483.30800698785 }, { "content": "class InputConnector: public IoConnector\n\n{\n\npublic:\n\n\n\n\tstatic bool TypeFits(NobType const type) { return type.IsInputConnectorType(); }\n\n\n\n\texplicit InputConnector(Param &, vector<IoLine *> &&);\n\n\n\n\t~InputConnector() final = default;\n\n\n\n\tInputLine & GetElem(size_t const) const;\n\n\n\n\tvoid SetSigGen(SignalGenerator * const p) final;\n\n\tSignalGenerator * GetSigGen () final;\n\n\tSignalGenerator const * GetSigGenC() const final;\n\n\n\n\tvoid Prepare() final { /* */ };\n\n\n\n\tNobIoMode GetIoMode() const final { return NobIoMode::input; }\n\n\n\n\tvoid DrawExterior(DrawContext const &, tHighlight const) const final;\n\n};\n", "file_path": "NNet/NNetModel/InputConnector.h", "rank": 45, "score": 224439.93774829674 }, { "content": "class WrapperBase : public ScriptFunctor\n\n{\n\npublic:\n\n explicit WrapperBase(NNetModelImporter & modelImporter) :\n\n m_modelImporter(modelImporter)\n\n { };\n\n\n\nprotected:\n\n NNetModelWriterInterface & GetWriterInterface() const { return m_modelImporter.GetWriterInterface(); }\n\n MonitorData & GetMonitorData() const { return m_modelImporter.GetWriterInterface().GetMonitorData(); }\n\n UPNobList & GetUPNobsRef() const { return m_modelImporter.GetWriterInterface().GetUPNobs(); }\n\n\n\n template <Nob_t T> T& GetNobRef(NobId const id) const\n\n {\n\n return * GetWriterInterface().GetNobPtr<T*>(id);\n\n }\n\nprivate:\n\n NNetModelImporter & m_modelImporter;\n\n};\n", "file_path": "NNet/ModelIO/WrapperBase.h", "rank": 46, "score": 224390.74327966102 }, { "content": "class NewSigGenCmd : public SigGenCommand\n\n{\n\npublic:\n\n\tNewSigGenCmd()\n\n\t{\n\n\t\tm_upSigGen = m_pNMWI->NewSigGen();\n\n\t}\n\n\n\n\tvoid Do() final \n\n\t{ \n\n\t\tm_sigGenIdNew = m_pNMWI->PushSigGen(move(m_upSigGen));\n\n\t\tPostCommand2Application(IDD_REGISTER_SIG_GEN, m_sigGenIdNew.GetValue());\n\n\t\tSetActiveSigGenId(m_sigGenIdNew);\n\n\t}\n\n\n\n\tvoid Undo() final \n\n\t{ \n\n\t\tm_upSigGen = m_pNMWI->PopSigGen();\n\n\t\tSetActiveSigGenId(m_sigGenIdOld);\n\n\t}\n\n\n\nprivate:\n\n\tUPSigGen m_upSigGen;\n\n\tSigGenId m_sigGenIdNew;\n\n\tSigGenId m_sigGenIdOld;\n\n};", "file_path": "NNet/Commands/NewSigGenCmd.h", "rank": 47, "score": 222364.35245451916 }, { "content": "class Param;\n", "file_path": "NNet/NNetModel/InputConnector.h", "rank": 48, "score": 221723.98564827995 }, { "content": "class Param;\n", "file_path": "NNet/NNetModel/SignalGenerator.h", "rank": 49, "score": 221723.98564827995 }, { "content": "class Param;\n", "file_path": "NNet/NNetWindows/SignalControl.h", "rank": 50, "score": 221723.98564827995 }, { "content": "class WrapAddOutgoing2BaseKnot: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const idNob { ScrReadNobId(script) };\n\n MicroMeterPnt const umPos { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->AddOutgoing2BaseKnot(idNob, umPos);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 51, "score": 221267.53645464528 }, { "content": "class WrapAddIncoming2BaseKnot: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n NobId const idNob { ScrReadNobId(script) };\n\n MicroMeterPnt const umPos { ScrReadMicroMeterPnt(script) };\n\n m_pCommands->AddIncoming2BaseKnot(idNob, umPos);\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 52, "score": 221267.53645464528 }, { "content": "class Param;\n", "file_path": "NNet/NNetWindows/NNetModelCommands.h", "rank": 53, "score": 220662.95451256871 }, { "content": "class Param;\n", "file_path": "NNet/ModelIO/NNetModelImporter.h", "rank": 55, "score": 218144.28819371824 }, { "content": "class Param;\n", "file_path": "NNet/NNetWindows/win32_parameterDlg.h", "rank": 56, "score": 218144.28819371824 }, { "content": "class Param;\n", "file_path": "NNet/ModelIO/NNetModelExporter.h", "rank": 57, "score": 218144.28819371824 }, { "content": "class Script;\n", "file_path": "NNet/ModelIO/NNetModelImporter.h", "rank": 58, "score": 217964.06891676807 }, { "content": "class Script;\n", "file_path": "NNet/ModelIO/NNetModelExporter.h", "rank": 59, "score": 217964.06891676807 }, { "content": "class SigGenStaticData : public Observable\n\n{\n\npublic:\n\n\n\n\tSigGenStaticData\n\n\t(\n\n\t\tBASE_PEAK<fHertz> f,\n\n\t\tBASE_PEAK<mV> a,\n\n\t\tfMicroSecs t\n\n\t)\n\n\t :\tm_freq(f),\n\n\t\tm_amplit(a),\n\n\t\tm_usPeak(t)\n\n\t{}\n\n\n\n\tSigGenStaticData()\n\n :\tm_freq(10.0_fHertz, 50.0_fHertz),\n\n\t\tm_amplit(10._mV, 20._mV),\n\n\t\tm_usPeak(500000._MicroSecs) // 1/2 sec\n\n\t{}\n", "file_path": "NNet/NNetModel/SigGenStaticData.h", "rank": 61, "score": 216027.25687474874 }, { "content": "class WrapSetPulseRate: public ScriptFunctor // Legacy\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n ScrReadNobId(script);\n\n Cast2Float(script.ScrReadFloat());\n\n }\n\n};\n\n\n", "file_path": "NNet/NNetWindows/NNetWrappers.cpp", "rank": 62, "score": 215804.02074745053 }, { "content": "class Signal : public ObserverInterface // observes signal source \n\n{\n\npublic:\n\n\n\n Signal\n\n (\n\n Observable &,\n\n UPNobList const &,\n\n MicroMeterCircle const & \n\n );\n\n\n\n ~Signal() override;\n\n\n\n bool operator==(Signal const & rhs) const { return m_circle == rhs.m_circle; }\n\n\n\n void SetSensorPos (UPNobList const &, MicroMeterPnt const &);\n\n void MoveSensor (UPNobList const &, MicroMeterPnt const &);\n\n void SetSensorSize(UPNobList const &, MicroMeter const);\n\n void SizeSensor (UPNobList const &, float const);\n\n void RotateSensor (MicroMeterPnt const &, Radian const);\n", "file_path": "NNet/NNetModel/Signal.h", "rank": 63, "score": 214983.19201260625 }, { "content": "class Param;\n\n\n", "file_path": "NNet/NNetModel/SigGenDynamicData.h", "rank": 64, "score": 214743.17595679098 }, { "content": "class Script;\n\n\n", "file_path": "NNet/ModelIO/WrapVoltage.h", "rank": 65, "score": 213697.72402462538 }, { "content": "class Script;\n\n\n", "file_path": "NNet/ModelIO/WrapCreateNob.h", "rank": 66, "score": 209679.94082239876 }, { "content": "class WrapCreateNob : public WrapperBase\n\n{\n\npublic:\n\n using WrapperBase::WrapperBase;\n\n\n\n void operator() (Script & script) const final\n\n { \n\n createNob(script);\n\n }\n\n\n\nprivate:\n\n\n\n Nob * createNob (Script &) const;\n\n UPNob createPipe (Script &) const;\n\n UPNob createBaseKnot (Script &, NobType const) const;\n\n UPNob createIoConnector(Script &, NobType const) const; \n\n};\n", "file_path": "NNet/ModelIO/WrapCreateNob.h", "rank": 67, "score": 208854.35896743997 }, { "content": "class EchoScriptLine: public ScriptFunctor\n\n{\n\npublic:\n\n void operator() (Script & script) const final\n\n {\n\n wcout << Scanner::COMMENT_SYMBOL << script.GetActLine();\n\n }\n\n};\n\n\n\n// ScrProcess: Process a test script\n\n\n\nbool Script::ScrProcess(wstring const & wstrPath)\n\n{ \n\n static EchoScriptLine newLineHook;\n\n if (!ScrOpen(wstrPath)) // could not open file \n\n return false; \n\n ScrSetNewLineHook(m_bEchoScript ? &newLineHook : nullptr);\n\n while (ReadNextToken() && (m_token != tTOKEN::End))\n\n {\n\n if (!ProcessToken()) \n", "file_path": "Toolbox/runtimeCPP/SCRIPT.cpp", "rank": 68, "score": 204756.92424029933 }, { "content": "class NamedType\n\n{\n\npublic:\n\n\n\n\tNamedType() : m_value(0) {}\n\n\t\n\n constexpr explicit NamedType(BASE_TYPE const value) : m_value(value) {}\n\n\n\n\tconstexpr BASE_TYPE const & GetValue() const { return m_value; }\n\n\n\n\tconstexpr NamedType GetAbs () const { return NamedType(abs(m_value)); }\n\n\tconstexpr BASE_TYPE GetAbsValue() const { return BASE_TYPE(abs(m_value)); }\n\n\n\n\tbool operator== (NamedType const other) const { return m_value == other.GetValue(); }\n\n bool operator!= (NamedType const other) const { return m_value != other.GetValue(); }\n\n bool operator<= (NamedType const other) const { return m_value <= other.GetValue(); }\n\n bool operator< (NamedType const other) const { return m_value < other.GetValue(); }\n\n bool operator>= (NamedType const other) const { return m_value >= other.GetValue(); }\n\n bool operator> (NamedType const other) const { return m_value > other.GetValue(); }\n\n\n", "file_path": "Toolbox/Utilities/NamedType.h", "rank": 69, "score": 204510.98309833213 }, { "content": "class ScriptHook : public Script_Functor\n\n{\n\npublic:\n\n\tScriptHook()\n\n\t: m_pStatusBar( nullptr ),\n\n\t m_iStatusBarPart( 0 )\n\n\t{}\n\n\n\n\tvoid Initialize( StatusBar * const pStatusBar, int iPart )\n\n\t{\n\n\t\tm_pStatusBar = pStatusBar;\n\n\t\tm_iStatusBarPart = iPart;\n\n\t}\n\n\n\n virtual void operator( ) ( Script & script ) const\n\n {\n\n if ( m_pStatusBar != nullptr )\n\n {\n\n\t\t\twstring m_wstrScriptLine;\n\n\n", "file_path": "Evo/Win32_appFramework/win32_scriptHook.h", "rank": 70, "score": 201780.551172824 }, { "content": "class Pipe : public Nob\n\n{\n\npublic:\n\n\tusing SegNr = NamedType<size_t, struct segNr_Parameter>;\n\n\n\n\tPipe();\n\n\tPipe(BaseKnot * const, BaseKnot * const);\n\n\tPipe(Pipe const &); // copy constructor\n\n\n\n\t~Pipe() final = default;\n\n\n\n\tbool operator==(Nob const &) const;\n\n\n\n\tvoid AppendMenuItems(AddMenuFunc const &) const final;\n\n\n\n\tvoid Dump() const override;\n\n\n\n\tstatic bool TypeFits(NobType const type) { return type.IsPipeType(); }\n\n\n\n\tvoid SetStartKnot(BaseKnot * const);\n", "file_path": "NNet/NNetModel/Pipe.h", "rank": 71, "score": 201283.2288743284 }, { "content": "class NNetCommand : public Command\n\n{\n\npublic:\n\n ~NNetCommand() override = default;\n\n\n\n static void SetModelInterface(NNetModelWriterInterface * const pNMWI)\n\n {\n\n m_pNMWI = pNMWI;\n\n }\n\n\n\n virtual NobId GetAffectedNob() const\n\n {\n\n return NO_NOB;\n\n }\n\n\n\nprotected:\n\n\n\n inline static NNetModelWriterInterface * m_pNMWI { nullptr };\n\n};", "file_path": "NNet/Commands/NNetCommand.h", "rank": 72, "score": 200749.57734599855 }, { "content": "class Knot : public BaseKnot\n\n{\n\npublic:\n\n\texplicit Knot(MicroMeterPnt const center)\n\n\t\t: BaseKnot(center, NobType::Value::knot, KNOT_WIDTH)\n\n\t{}\n\n\n\n\texplicit Knot(BaseKnot const &);\n\n\n\n\t~Knot() override = default;\n\n\n\n\tvoid Check() const override;\n\n\n\n\tvoid AppendMenuItems(AddMenuFunc const &) const final;\n\n\n\n\tstatic bool TypeFits(NobType const type) { return type.IsKnotType(); }\n\n\n\n\tvoid SetDir(Radian const r) final { /* Knot has no direction */ };\n\n\tRadian GetDir () const final { return Radian::NULL_VAL(); };\n\n\tmV GetNextOutput() const final { return m_mVinputBuffer; }\n", "file_path": "NNet/NNetModel/Knot.h", "rank": 73, "score": 197894.22134755625 }, { "content": "class RotationCommand : public NNetCommand\n\n{\n\npublic:\n\n\n\n\tbool CombineCommands(Command const & src) override\n\n\t{ \n\n\t\tRotationCommand const & srcCmd { static_cast<RotationCommand const &>(src) };\n\n\t\tm_radDelta += srcCmd.m_radDelta;\n\n\t\treturn true; \n\n\t}\n\n\n\nprotected:\n\n\n\n\tvoid SetPivotPnt\n\n\t(\n\n\t\tMicroMeterPnt const & umPnt,\n\n\t\tMicroMeterPnt const & umPntOld, \n\n\t\tMicroMeterPnt const & umPntNew\n\n\t)\n\n\t{\n", "file_path": "NNet/Commands/RotationCommand.h", "rank": 74, "score": 194669.73350953724 }, { "content": "class IoConnector: public Nob\n\n{\n\npublic:\n\n\tstatic bool TypeFits(NobType const type) { return type.IsIoConnectorType(); }\n\n\n\n\texplicit IoConnector(NobType const);\n\n\n\n\t~IoConnector() override = default;\n\n\n\n\tvoid AppendMenuItems(AddMenuFunc const &) const override;\n\n\n\n\tvoid Check() const override;\n\n\tvoid Dump () const override;\n\n\n\n\tMicroMeterPnt GetPos() const override;\n\n\n\n\tvoid DrawExterior(DrawContext const &, tHighlight const) const override;\n\n\tvoid DrawInterior(DrawContext const &, tHighlight const) const override;\n\n\tvoid Expand (MicroMeterRect &) const override;\n\n\tbool IsIncludedIn(MicroMeterRect const &) const override;\n", "file_path": "NNet/NNetModel/IoConnector.h", "rank": 75, "score": 194669.73350953724 }, { "content": "class SignalGenerator : public Observable\n\n{\n\npublic:\n\n\n\n\texplicit SignalGenerator(wstring const &);\n\n\n\n\tfHertz GetStimulusFrequency(fMicroSecs const) const;\n\n\tmV GetStimulusAmplitude(fMicroSecs const) const;\n\n\n\n\tfMicroSecs const & TimePeak () const { return m_statData.GetPeakTime (); }\n\n\tBASE_PEAK<fHertz> const & Frequency() const { return m_statData.GetFrequency(); }\n\n\tBASE_PEAK<mV> const & Amplitude() const { return m_statData.GetAmplitude(); }\n\n\n\n\tvoid SetParam(ParamType::Value const, float const);\n\n\n\n\tvoid SetStaticData(SigGenStaticData const &);\n\n\tSigGenStaticData const & GetStaticData() const;\n\n\n\n\tvoid SetName(wstring const & name) { m_name = name; }\n\n\twstring const & GetName() const { return m_name; }\n", "file_path": "NNet/NNetModel/SignalGenerator.h", "rank": 76, "score": 194669.73350953724 }, { "content": "class BaseKnot : public Nob\n\n{\n\npublic:\n\n\n\n\tBaseKnot(MicroMeterPnt const &, NobType const, MicroMeter const);\n\n\tBaseKnot(BaseKnot const &) = default;\n\n\t~BaseKnot() override = default;\n\n\n\n\tvirtual bool operator==(Nob const &) const;\n\n\n\n\tvirtual BaseKnot & operator*=(float const);\n\n\tvirtual BaseKnot & operator+=(BaseKnot const &);\n\n\tvirtual BaseKnot & operator-=(BaseKnot const &);\n\n\n\n\tvoid AppendMenuItems(AddMenuFunc const &) const override;\n\n\n\n\tMicroMeterPnt GetPos() const final { return m_circle.GetPos(); }\n\n\tmV GetVoltage() const { return m_mVinputBuffer; }\n\n\tvoid SetVoltage(mV const v) { m_mVinputBuffer = v; }\n\n\n", "file_path": "NNet/NNetModel/BaseKnot.h", "rank": 77, "score": 194669.73350953724 }, { "content": "class SelectionCommand : public NNetCommand\n\n{\n\npublic:\n\n\n\n\tvoid Undo() override\n\n\t{\n\n\t\tm_pNMWI->DeselectAllNobs();\n\n\t\tfor (auto it : *m_upSelectedNobs){ it->Select(true); };\n\n\t}\n\n\n\nprivate:\n\n\tunique_ptr<vector<Nob *>> m_upSelectedNobs { m_pNMWI->GetSelection() };\n\n};\n\n\n", "file_path": "NNet/Commands/SelectionCommand.h", "rank": 78, "score": 194669.73350953724 }, { "content": "class ComputeThread: public Util::Thread, public ObserverInterface\n\n{\n\npublic:\n\n\n\n\tvoid Initialize\n\n\t(\n\n\t\tSlowMotionRatio * const,\n\n\t\tObservable * const,\n\n\t\tObservable * const,\n\n\t\tObservable * const\n\n\t);\n\n\n\n\tvoid Reset();\n\n\tvoid SetModelInterface(NNetModelWriterInterface * const);\n\n\tvoid ThreadStartupFunc() final;\n\n\tvoid ThreadMsgDispatcher(MSG const &) final { }\n\n\tvoid Notify(bool const) final;\n\n\tvoid SingleStep();\n\n\tvoid ReleaseComputationLock();\n\n\tvoid LockComputation();\n", "file_path": "NNet/NNetWindows/ComputeThread.h", "rank": 79, "score": 194578.0584276506 }, { "content": "class NNetWindow : public GraphicsWindow\n\n{\n\npublic:\n\n\tNNetWindow() = default;\n\n\t~NNetWindow() override;\n\n\n\n\tvoid Start\n\n\t(\n\n\t\tHWND const, \n\n\t\tDWORD const,\n\n\t\tbool const,\n\n\t\tfPixel const,\n\n\t\tNNetController &\n\n\t);\n\n\n\n\tvoid SetModelInterface(NNetModelReaderInterface * const);\n\n\n\n\tMicroMeterRect GetViewRect() const;\n\n\n\n\tDrawContext const & GetDrawContextC() const { return m_context; }\n", "file_path": "NNet/NNetWindows/win32_NNetWindow.h", "rank": 80, "score": 193826.80090145688 }, { "content": "class MainWindow : public NNetWindow\n\n{\n\npublic:\n\n\n\n\tvoid Start\n\n\t(\n\n\t\tHWND const,\n\n\t\tbool const,\n\n\t\tfPixel const,\n\n\t\tNNetController &,\n\n\t\tNNetModelCommands &,\n\n\t\tObservable &,\n\n\t\tObservable &,\n\n\t\tActionTimer * const\n\n\t);\n\n\n\n\tvoid Stop () final;\n\n\tvoid Reset();\n\n\n\n\tLPARAM AddContextMenuEntries(HMENU const) final;\n", "file_path": "NNet/NNetWindows/win32_MainWindow.h", "rank": 81, "score": 192358.36877879602 }, { "content": "class MiniWindow : public NNetWindow\n\n{\n\npublic:\n\n\tvoid Start(HWND const, bool const, fPixel const, NNetController &);\n\n\n\n\tvoid OnMouseWheel (WPARAM const, LPARAM const) final { }; // mini window cannot be zoomed \n\n\tbool OnRButtonUp (WPARAM const, LPARAM const) final { return false; }\n\n\tbool OnRButtonDown (WPARAM const, LPARAM const) final { return false; }\n\n\tbool OnLButtonUp (WPARAM const, LPARAM const) final { return false; };\n\n\tvoid OnLButtonDblClick(WPARAM const, LPARAM const) final { };\n\n\tvoid OnChar (WPARAM const, LPARAM const) final { };\n\n\tvoid OnMouseMove (WPARAM const, LPARAM const) final;\n\n\n\n\tLPARAM AddContextMenuEntries(HMENU const) final { return 0; }\n\n\n\n\tvoid Notify(bool const) final;\n\n\n\n\tvoid ObservedNNetWindow(MainWindow * const);\n\n\n\nprivate:\n\n\n\n\twstring GetCaption() const final { return L\"Mini window\"; }\n\n\n\n\tvoid DoPaint() final;\n\n\n\n\tMainWindow * m_pObservedNNetWindow { nullptr }; // Observed NNetWindow (or nullptr)\n\n};\n\n\n", "file_path": "NNet/NNetWindows/win32_MiniWindow.h", "rank": 82, "score": 192358.36877879602 }, { "content": "class MonitorControl : public GraphicsWindow\n\n{\n\npublic:\n\n\tMonitorControl\n\n\t(\n\n\t\tHWND const, \n\n\t\tSound &,\n\n\t\tNNetModelCommands &,\n\n\t\tPixFpDimension<fMicroSecs> &\n\n\t);\n\n\n\n\t~MonitorControl() final = default;\n\n\n\n\tvoid Stop () final;\n\n\tvoid Reset();\n\n\tvoid SetModelInterface(NNetModelWriterInterface * const);\n\n\tbool SignalTooHigh() const;\n\n\tvoid ScaleSignals();\n\n\n\n\tLPARAM AddContextMenuEntries(HMENU const) final;\n", "file_path": "NNet/NNetWindows/MonitorControl.h", "rank": 83, "score": 191597.74037614185 }, { "content": "class StatusBar : public RootWindow\n\n{\n\npublic:\n\n\n\n\tvoid Start(HWND const);\n\n\tvoid Stop();\n\n\n\n\tPIXEL GetHeight() const;\n\n void Resize() const;\n\n\n\n\tHWND WINAPI AddStaticControl(int const);\n\n\tHWND WINAPI AddStaticControl(LPCTSTR const);\n\n\tHWND WINAPI AddButton (LPCTSTR const, HMENU const, DWORD const);\n\n HWND WINAPI AddTrackBar (HMENU const);\n\n\n\n\tvoid AddCustomControl(int const);\n\n\n\n\tint NewPart();\n\n\tvoid LastPart();\n\n\n", "file_path": "NNet/NNetWindows/win32_status.h", "rank": 84, "score": 191597.74037614185 }, { "content": "class InputLine : public IoLine\n\n{\n\npublic:\n\n\n\n\texplicit InputLine(SignalGenerator *, MicroMeterPnt const &);\n\n\texplicit InputLine(SignalGenerator *, BaseKnot const &);\n\n\n\n\t~InputLine() final = default;\n\n\n\n\tvoid Check() const final;\n\n\n\n\tvoid SetSigGen(SignalGenerator * const p) final { m_pSigGen = p; }\n\n\tSignalGenerator * GetSigGen () final { return m_pSigGen; }\n\n\tSignalGenerator const * GetSigGenC() const final { return m_pSigGen; }\n\n\n\n\tstatic bool TypeFits(NobType const type) { return type.IsInputLineType(); }\n\n\n\n\tvoid Prepare() final;\n\n\n\n\tvoid DrawExterior(DrawContext const &, tHighlight const) const final;\n", "file_path": "NNet/NNetModel/InputLine.h", "rank": 85, "score": 191597.74037614185 }, { "content": "class SignalControl : public TimeGraph\n\n{\n\npublic:\n\n\tSignalControl\n\n\t(\n\n\t\tHWND const, \n\n\t\tComputeThread const &, \n\n\t\tNNetModelCommands &,\n\n\t\tObservable &,\n\n\t\tObservable &,\n\n\t\tPixFpDimension<fMicroSecs> *\n\n\t);\n\n\n\n\t~SignalControl() final;\n\n\n", "file_path": "NNet/NNetWindows/SignalControl.h", "rank": 86, "score": 191597.74037614185 }, { "content": "class SignalPreview : public TimeGraph\n\n{\n\npublic:\n\n\tSignalPreview\n\n\t(\n\n\t\tBaseWindow const &,\n\n\t\tPixFpDimension<fMicroSecs> &,\n\n\t\tPixFpDimension<mV> &\n\n\t);\n\n\n\n\t~SignalPreview() final;\n\n\n\nprivate:\n\n\n\n\tPixFpDimension<mV> & m_vertCoord;\n\n\n\n\tvoid DoPaint() final;\n\n\tbool OnSize(PIXEL const, PIXEL const) final;\n\n\n\n\tfPixel getY (fPixel const fPix) const;\n\n\tfPixel yVolt(mV const volt) const;\n\n\n\n\tfPixelPoint pixPntVolt(fMicroSecs const t, mV const v) const;\n\n};", "file_path": "NNet/NNetWindows/SignalPreview.h", "rank": 87, "score": 191597.74037614185 }, { "content": "class OutputLine : public IoLine\n\n{\n\npublic:\n\n\n\n\texplicit OutputLine(MicroMeterPnt const &);\n\n\texplicit OutputLine(BaseKnot const &);\n\n\n\n\t~OutputLine() final = default;\n\n\n\n\tvoid Check() const final;\n\n\n\n\tbool operator==(Nob const &) const override;\n\n\n\n\tstatic bool TypeFits(NobType const type) { return type.IsOutputLineType(); }\n\n\n\n\tvoid DrawExterior(DrawContext const &, tHighlight const) const override;\n\n\tvoid DrawInterior(DrawContext const &, tHighlight const) const override;\n\n\n\n\tbool Includes(MicroMeterPnt const &) const final;\n\n\n", "file_path": "NNet/NNetModel/OutputLine.h", "rank": 88, "score": 191597.74037614185 }, { "content": "class OutputConnector: public IoConnector\n\n{\n\npublic:\n\n\n\n\tstatic bool TypeFits(NobType const type) { return type.IsOutputConnectorType(); }\n\n\n\n\tOutputConnector();\n\n\texplicit OutputConnector(vector<IoLine *> &);\n\n\texplicit OutputConnector(vector<IoLine *> &&);\n\n\n\n\t~OutputConnector() final = default;\n\n\n\n\tvoid Prepare() override { /* done by output neurons */ };\n\n\n\n\tNobIoMode GetIoMode() const final { return NobIoMode::output; }\n\n\n\n\tvoid DrawExterior(DrawContext const &, tHighlight const) const override;\n\n};\n", "file_path": "NNet/NNetModel/OutputConnector.h", "rank": 89, "score": 191597.74037614185 }, { "content": "class SignalDesigner : public GraphicsWindow\n\n{\n\npublic:\n\n\tvoid Initialize\n\n\t(\n\n\t\tHWND const, \n\n\t\tComputeThread const &, \n\n\t\tObservable &,\n\n\t\tObservable &,\n\n\t\tNNetModelCommands *\n\n\t);\n\n\n\n\tvoid Stop() final;\n\n\n\n\tLPARAM AddContextMenuEntries(HMENU const) final;\n\n\n\n\tvoid SetModelInterface(NNetModelWriterInterface * const);\n\n\n\n\twstring GetCaption() const final;\n\n\n\n\tvoid RegisterAtSigGen(SigGenId const);\n\n\n", "file_path": "NNet/NNetWindows/SignalDesigner.h", "rank": 90, "score": 191597.74037614185 }, { "content": "class IoLine : public BaseKnot\n\n{\n\npublic:\n\n\tstatic bool TypeFits(NobType const type) { return type.IsIoLineType(); }\n\n\n\n\tIoLine(MicroMeterPnt const & upCenter, NobType const type)\n\n\t\t: BaseKnot(upCenter, type, NEURON_RADIUS)\n\n\t{}\n\n\n\n\tIoLine(BaseKnot const & src, NobType const type)\n\n\t\t: BaseKnot(src)\n\n\t{\n\n\t\tSetId(src.GetId());\n\n\t\tSetType(type);\n\n\t\tSetExtension(NEURON_RADIUS);\n\n\t}\n\n\n\n\tbool CompStep() final { return false; }\n\n\n\n\tMicroMeterPosDir GetPosDir() const override;\n", "file_path": "NNet/NNetModel/IoLine.h", "rank": 91, "score": 191597.74037614185 }, { "content": "class TimeDisplay : public ObserverInterface\n\n{\n\npublic:\n\n\t~TimeDisplay();\n\n\n\n\tvoid Initialize(StatusBar *, int);\n\n\n\n\tvoid Notify(bool const) final;\n\n\n", "file_path": "NNet/NNetWindows/TimeDisplay.h", "rank": 92, "score": 191597.74037614185 }, { "content": "class TimeGraph : public GraphicsWindow\n\n{\n\npublic:\n\n\tTimeGraph\n\n\t(\n\n\t\tHWND const hwndParent,\n\n\t\tPixFpDimension<fMicroSecs> * pHorzCoord\n\n\t);\n\n\n\n\t~TimeGraph();\n\n\n\n\tvoid SetModelInterface(NNetModelWriterInterface * const);\n\n\n\nprotected:\n\n\n\n\tfPixel const STD_WIDTH { 1.0_fPixel };\n\n\tfPixel const HIGH_WIDTH { 3.0_fPixel };\n\n\n\n\tfPixel m_fPixRight { 0.0_fPixel };\n\n\tfPixel m_fPixBottom { 0.0_fPixel };\n", "file_path": "NNet/NNetWindows/TimeGraph.h", "rank": 93, "score": 191597.74037614185 }, { "content": "class DescriptionUI\n\n{\n\npublic:\n\n\tvirtual ~DescriptionUI() = default;\n\n\tvirtual void ClearDescription() = 0;\n\n\tvirtual void SetDescription(wstring const &) = 0;\n\n\tvirtual int GetLineCount() const = 0;;\n\n\tvirtual bool GetDescriptionLine(int const, wstring &) const = 0;\n\n\tvirtual bool IsDirty() = 0;\n\n\tvirtual void ResetDirtyFlag() = 0;\n\n};\n", "file_path": "NNet/NNetModel/DescriptionUI.h", "rank": 94, "score": 190105.5306910013 }, { "content": "class AutoOpen\n\n{\n\npublic:\n\n\n\n\tstatic void On () \n\n\t{ \n\n\t\tm_bActive = true; \n\n\t}\n\n\n\n\tstatic void Off() \n\n\t{ \n\n\t\tm_bActive = false; \n\n\t}\n\n\n\n\tstatic bool IsOn() \n\n\t{ \n\n\t\treturn m_bActive; \n\n\t}\n\n\n\nprivate:\n\n\n\n\tinline static bool m_bActive { true };\n\n};\n", "file_path": "NNet/NNetModel/AutoOpen.h", "rank": 95, "score": 190101.2855611183 }, { "content": "class SignalId\n\n{\n\npublic:\n\n\tusing Func = function<void(SignalId const &)>;\n\n\n\n\tSignalId()\n\n\t : trackNr (TrackNr::NULL_VAL()),\n\n\t\tsignalNr(SignalNr::NULL_VAL())\n\n\t{ }\n\n\n\n\tSignalId(TrackNr const tNr, SignalNr const sNr)\n\n\t : trackNr(tNr),\n\n\t\tsignalNr(sNr)\n\n\t{ }\n\n\n\n\tvoid Set2Null() \n\n\t{ \n\n\t\ttrackNr.Set2Null(); \n\n\t\tsignalNr.Set2Null(); \n\n\t}\n", "file_path": "NNet/NNetModel/SignalId.h", "rank": 96, "score": 190037.95898949492 }, { "content": "class NobType\n\n{\n\npublic:\n", "file_path": "NNet/NNetModel/NobType.h", "rank": 97, "score": 189799.02429468583 }, { "content": "class NNetImportTermination : public ImportTermination\n\n{\n\npublic:\n\n\tstatic void Initialize(HWND const hwndApp)\n\n\t{\n\n\t\tm_hwndApp = hwndApp;\n\n\t}\n\n\n\n\tstatic unique_ptr<NNetImportTermination> CreateNew(int const msg)\n\n\t{\n\n\t\treturn make_unique<NNetImportTermination>(msg);\n\n\t}\n\n\n\n\texplicit NNetImportTermination(int const msg)\n\n\t :\tm_msgImportFinished(msg)\n\n\t{}\n\n\n\n\tvoid Reaction(ImportTermination::Result const res, wstring const & name) final\n\n\t{\n\n\t\tswitch (res)\n", "file_path": "NNet/NNetWindows/win32_importTermination.h", "rank": 98, "score": 189798.49089745941 }, { "content": "class CoordAnimation : public Command\n\n{\n\n using ANIM_TYPE = Uniform2D<MicroMeter>;\n\n using ANIMATION = Animation<ANIM_TYPE>;\n\npublic:\n\n CoordAnimation\n\n (\n\n ANIM_TYPE & animated,\n\n ANIM_TYPE const & target\n\n )\n\n : m_animated(animated),\n\n m_start(animated),\n\n m_target(target)\n\n {\n\n m_upAnimation = make_unique<ANIMATION>(this);\n\n }\n\n\n\n void Do() final\n\n {\n\n m_upAnimation->Start(m_animated, m_target);\n", "file_path": "NNet/Commands/CoordAnimation.h", "rank": 99, "score": 189209.78846434507 } ]
C++
hpx/runtime/serialization/map.hpp
akemp/hpx
1ddf7282e322c30d82f2be044071aed14807ebe1
#ifndef HPX_SERIALIZATION_MAP_HPP #define HPX_SERIALIZATION_MAP_HPP #include <map> #include <boost/mpl/and.hpp> #include <boost/type_traits/remove_const.hpp> #include <boost/type_traits/add_reference.hpp> #include <hpx/runtime/serialization/input_archive.hpp> #include <hpx/runtime/serialization/output_archive.hpp> #include <hpx/traits/is_bitwise_serializable.hpp> namespace hpx { namespace traits { template <class Key, class Value> struct is_bitwise_serializable<std::pair<Key, Value> >: boost::mpl::and_< is_bitwise_serializable<Key>, is_bitwise_serializable<Value> > {}; } namespace serialization { namespace detail { template <class Key, class Value> void load_pair_impl(input_archive& ar, std::pair<Key, Value>& t, boost::mpl::false_) { ar >> const_cast< typename boost::add_reference< typename boost::remove_const<Key>::type >::type>(t.first); ar >> t.second; } template <class Key, class Value> void load_pair_impl(input_archive& ar, std::pair<Key, Value>& t, boost::mpl::true_) { if (!has_array_optimization(ar)) load_pair_impl(ar, t, boost::mpl::false_()); else load_binary(ar, &t, sizeof(std::pair<Key, Value>)); } template <class Key, class Value> void save_pair_impl(output_archive& ar, std::pair<Key, Value>& t, boost::mpl::false_) { ar << t.first; ar << t.second; } template <class Key, class Value> void save_pair_impl(output_archive& ar, std::pair<Key, Value>& t, boost::mpl::true_) { if (!has_array_optimization(ar)) save_pair_impl(ar, t, boost::mpl::false_()); else save_binary(ar, &t, sizeof(std::pair<Key, Value>)); } } template <class Key, class Value> void serialize(input_archive& ar, std::pair<Key, Value>& t, unsigned) { typedef std::pair<Key, Value> pair_type; typedef typename traits::is_bitwise_serializable<pair_type> optimized; detail::load_pair_impl(ar, t, optimized()); } template <class Key, class Value> void serialize(output_archive& ar, std::pair<Key, Value>& t, unsigned) { typedef std::pair<Key, Value> pair_type; typedef typename traits::is_bitwise_serializable<pair_type> optimized; detail::save_pair_impl(ar, t, optimized()); } template <class Key, class Value, class Comp, class Alloc> void serialize(input_archive& ar, std::map<Key, Value, Comp, Alloc>& t, unsigned) { typedef typename std::map<Key, Value, Comp, Alloc>::size_type size_type; typedef typename std::map<Key, Value, Comp, Alloc>::value_type value_type; size_type size; ar >> size; for (size_type i = 0; i < size; ++i) { value_type v; ar >> v; t.insert(t.end(), v); } } template <class Key, class Value, class Comp, class Alloc> void serialize(output_archive& ar, std::map<Key, Value, Comp, Alloc>& t, unsigned) { typedef typename std::map<Key, Value, Comp, Alloc>::value_type value_type; ar << t.size(); for(value_type& val : t) { ar << val; } } } } #endif
#ifndef HPX_SERIALIZATION_MAP_HPP #define HPX_SERIALIZATION_MAP_HPP #include <map> #include <boost/mpl/and.hpp> #include <boost/type_traits/remove_const.hpp> #include <boost/type_traits/add_reference.hpp> #include <hpx/runtime/serialization/input_archive.hpp> #include <hpx/runtime/serialization/output_archive.hpp> #include <hpx/traits/is_bitwise_serializable.hpp> namespace hpx { namespace traits { template <class Key, class Value> struct is_bitwise_serializable<std::pair<Key, Value> >: boost::mpl::and_< is_bitwise_serializable<Key>, is_bitwise_serializable<Value> > {}; } namespace serialization { namespace detail { template <class Key, class Value> void load_pair_impl(input_archive& ar, std::pair<Key, Value>& t, boost::mpl::false_) { ar >> const_cast< typename boost::add_reference< typename boost::remove_const<Key>::type >::type>(t.first); ar >> t.second; } template <class Key, class Value> void load_pair_impl(input_archive& ar, std::pair<Key, Value>& t, boost::mpl::true_) { if (!has_array_optimization(ar)) load_pair_impl(ar, t, boost::mpl::false_()); else load_binary(ar, &t, sizeof(std::pair<Key, Value>)); } template <class Key, class Value> void save_pair_impl(output_archive& ar, std::pair<Key, Value>& t, boost::mpl::false_) { ar << t.first; ar << t.second; } template <class Key, class Value> void save_pair_impl(output_archive& ar, std::pair<Key, Value>& t, boost::mpl::true_) {
} } template <class Key, class Value> void serialize(input_archive& ar, std::pair<Key, Value>& t, unsigned) { typedef std::pair<Key, Value> pair_type; typedef typename traits::is_bitwise_serializable<pair_type> optimized; detail::load_pair_impl(ar, t, optimized()); } template <class Key, class Value> void serialize(output_archive& ar, std::pair<Key, Value>& t, unsigned) { typedef std::pair<Key, Value> pair_type; typedef typename traits::is_bitwise_serializable<pair_type> optimized; detail::save_pair_impl(ar, t, optimized()); } template <class Key, class Value, class Comp, class Alloc> void serialize(input_archive& ar, std::map<Key, Value, Comp, Alloc>& t, unsigned) { typedef typename std::map<Key, Value, Comp, Alloc>::size_type size_type; typedef typename std::map<Key, Value, Comp, Alloc>::value_type value_type; size_type size; ar >> size; for (size_type i = 0; i < size; ++i) { value_type v; ar >> v; t.insert(t.end(), v); } } template <class Key, class Value, class Comp, class Alloc> void serialize(output_archive& ar, std::map<Key, Value, Comp, Alloc>& t, unsigned) { typedef typename std::map<Key, Value, Comp, Alloc>::value_type value_type; ar << t.size(); for(value_type& val : t) { ar << val; } } } } #endif
if (!has_array_optimization(ar)) save_pair_impl(ar, t, boost::mpl::false_()); else save_binary(ar, &t, sizeof(std::pair<Key, Value>));
if_condition
[ { "content": " class function<Sig, void, void>\n\n : public detail::basic_function<\n\n detail::function_vtable_ptr<Sig, void, void>\n\n , Sig\n\n >\n\n {\n\n typedef detail::function_vtable_ptr<Sig, void, void> vtable_ptr;\n\n typedef detail::basic_function<vtable_ptr, Sig> base_type;\n\n\n\n public:\n\n typedef typename base_type::result_type result_type;\n\n\n\n function() BOOST_NOEXCEPT\n\n : base_type()\n\n {}\n\n\n\n function(function const& other)\n\n : base_type()\n\n {\n\n detail::vtable::destruct<detail::empty_function<Sig> >(&this->object);\n", "file_path": "hpx/util/detail/function_template.hpp", "rank": 0, "score": 356074.7454325837 }, { "content": " class unique_function<Sig, void, void>\n\n : public detail::basic_function<\n\n detail::unique_function_vtable_ptr<Sig, void, void>\n\n , Sig\n\n >\n\n {\n\n friend struct traits::serialize_as_future<unique_function>;\n\n\n\n typedef detail::unique_function_vtable_ptr<Sig, void, void> vtable_ptr;\n\n typedef detail::basic_function<vtable_ptr, Sig> base_type;\n\n\n\n#if defined(HPX_INTEL14_WORKAROUND)\n\n private:\n\n unique_function& operator=(unique_function const&);\n\n\n\n public:\n\n // The Intel Compiler sometimes erroneously instantiates this ctor. In order\n\n // to avoid compile errors, we provide the definition here\n\n unique_function(unique_function const & other) BOOST_NOEXCEPT\n\n {\n", "file_path": "hpx/util/detail/unique_function_template.hpp", "rank": 1, "score": 343409.5854077917 }, { "content": " class param10 = detail::void_10> struct holder : detail::tag_holder_base<string_> {\n\n typedef typename use_default<string_, hold_string_type>::type string_type;\n\n typedef detail::tag_holder_base<string_> tag_base_type;\n\n\n\n operator string_type & () { return tag_base_type::m_string; }\n\n operator const string_type & () const { return tag_base_type::m_string; }\n\n\n\n operator const param1& () const { return m_tag1; }\n\n operator const param2& () const { return m_tag2; }\n\n operator const param3& () const { return m_tag3; }\n\n operator const param4& () const { return m_tag4; }\n\n operator const param5& () const { return m_tag5; }\n\n operator const param6& () const { return m_tag6; }\n\n operator const param7& () const { return m_tag7; }\n\n operator const param8& () const { return m_tag8; }\n\n operator const param9& () const { return m_tag9; }\n\n operator const param10& () const { return m_tag10; }\n\n\n\n template<class tag_type> holder& set_tag(const tag_type & val) {\n\n set_tag_impl(val);\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 2, "score": 340930.65838185756 }, { "content": " class promise<void> : public detail::promise_base<void>\n\n {\n\n HPX_MOVABLE_BUT_NOT_COPYABLE(promise);\n\n\n\n typedef detail::promise_base<void> base_type;\n\n\n\n public:\n\n // Effects: constructs a promise object and a shared state.\n\n promise()\n\n : base_type()\n\n {}\n\n\n\n // Effects: constructs a new promise object and transfers ownership of\n\n // the shared state of other (if any) to the newly-\n\n // constructed object.\n\n // Postcondition: other has no shared state.\n\n promise(promise&& other) BOOST_NOEXCEPT\n\n : base_type(std::move(other))\n\n {}\n\n\n", "file_path": "hpx/lcos/local/promise.hpp", "rank": 3, "score": 316330.215889909 }, { "content": "#define BOOST_SCOPED_LOG_CTX_IMPL(logger_macro, operator_, class_name) \\\n\nstruct class_name : ::hpx::util::logging::detail::scoped_gather_base<> { \\\n\n class_name() : m_is_enabled(false) { } \\\n\n ~class_name() { if ( m_is_enabled) logger_macro operator_ HPX_LOG_STR(\" end of \") operator_ m_str ; } \\\n\n void do_gather(const msg_type & str) { m_str = str; m_is_enabled = true; } \\\n\n msg_type m_str; \\\n\n bool m_is_enabled; \\\n\n} HPX_LOG_CONCATENATE(log_, __LINE__); \\\n\n logger_macro , ::hpx::util::logging::detail::scoped_logger<>( HPX_LOG_CONCATENATE(log_, __LINE__) )\n\n\n\n\n\n\n\n// note: to use BOOST_SCOPED_LOG_CTX, you need to #include <hpx/util/logging/gather/ostream_like.hpp>\n\n// This is included by default, in #include <hpx/util/logging/format_fwd.hpp>\n\n#define BOOST_SCOPED_LOG_CTX(logger) BOOST_SCOPED_LOG_CTX_IMPL(logger, << , HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) )\n\n\n\n\n\n}}}\n\n\n\n#endif\n\n\n", "file_path": "hpx/util/logging/detail/scoped_log.hpp", "rank": 4, "score": 302433.9074970673 }, { "content": " class param1 = detail::void_1,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 5, "score": 301489.0595218437 }, { "content": " class param6 = detail::void_6,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 6, "score": 301489.0595218437 }, { "content": " class param4 = detail::void_4,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 7, "score": 301489.0595218437 }, { "content": " class param8 = detail::void_8,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 8, "score": 301489.0595218437 }, { "content": " class param3 = detail::void_3,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 9, "score": 301489.0595218437 }, { "content": " class param9 = detail::void_9,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 10, "score": 301489.0595218437 }, { "content": " class param2 = detail::void_2,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 11, "score": 301489.0595218437 }, { "content": " class param5 = detail::void_5,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 12, "score": 301489.0595218437 }, { "content": " class param7 = detail::void_7,\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 13, "score": 301489.0595218437 }, { "content": " class base_lco_with_value<void, void> : public base_lco\n\n {\n\n protected:\n\n /// Destructor, needs to be virtual to allow for clean destruction of\n\n /// derived objects\n\n virtual ~base_lco_with_value() {}\n\n\n\n public:\n\n // components must contain a typedef for wrapping_type defining the\n\n // managed_component type used to encapsulate instances of this\n\n // component\n\n typedef components::managed_component<base_lco_with_value> wrapping_type;\n\n typedef base_lco_with_value base_type_holder;\n\n };\n\n}}\n\n\n\nnamespace hpx { namespace traits\n\n{\n\n // define component type data base entry generator\n\n template <typename Result, typename RemoteResult, typename Enable>\n", "file_path": "hpx/lcos/base_lco_with_value.hpp", "rank": 14, "score": 296372.30034858006 }, { "content": " class serialize_buffer<T, detail::serialize_buffer_no_allocator>\n\n {\n\n private:\n\n static void no_deleter(T*) {}\n\n\n\n static void array_delete(T * x)\n\n {\n\n delete [] x;\n\n }\n\n\n\n public:\n\n enum init_mode\n\n {\n\n copy = 0, // constructor copies data\n\n reference = 1, // constructor does not copy data and does not\n\n // manage the lifetime of it\n\n take = 2 // constructor does not copy data but does take\n\n // ownership and manages the lifetime of it\n\n };\n\n\n", "file_path": "hpx/runtime/serialization/serialize_buffer.hpp", "rank": 15, "score": 288947.54507788253 }, { "content": " class param10> struct holder ;\n\n }\n\n\n\n namespace gather { namespace ostream_like {\n\n template<class, class> struct return_str ;\n\n template<class holder_type, class stream_type> struct return_tag_holder ;\n\n }}\n\n\n\n namespace optimize {\n\n template<class> struct cache_string_one_str ;\n\n template<class, class> struct cache_string_several_str ;\n\n }\n\n\n\n namespace detail {\n\n template <class stream, class param> \n\n struct find_gather {};\n\n\n\n template <class stream>\n\n struct find_gather< stream, std::basic_string<logging::char_type> >\n\n {\n", "file_path": "hpx/util/logging/detail/find_gather.hpp", "rank": 16, "score": 278517.6728049851 }, { "content": " class value_or_error\n\n {\n\n protected:\n\n typedef T value_type;\n\n typedef boost::exception_ptr error_type;\n\n\n\n enum state { has_none, has_value, has_error };\n\n\n\n public:\n\n // constructors\n\n value_or_error()\n\n : state_(has_none)\n\n {}\n\n\n\n value_or_error(value_or_error const& rhs)\n\n : state_(rhs.state_)\n\n {\n\n switch (rhs.state_)\n\n {\n\n case has_none:\n", "file_path": "hpx/util/detail/value_or_error.hpp", "rank": 17, "score": 275015.5422564798 }, { "content": " class function\n\n : public detail::basic_function<\n\n detail::function_vtable_ptr<Sig, IArchive, OArchive>\n\n , Sig\n\n >\n\n {\n\n friend struct traits::serialize_as_future<function>;\n\n\n\n typedef detail::function_vtable_ptr<Sig, IArchive, OArchive> vtable_ptr;\n\n typedef detail::basic_function<vtable_ptr, Sig> base_type;\n\n\n\n public:\n\n typedef typename base_type::result_type result_type;\n\n\n\n function() BOOST_NOEXCEPT\n\n : base_type()\n\n {}\n\n\n\n function(function const& other)\n\n : base_type()\n", "file_path": "hpx/util/detail/function_template.hpp", "rank": 18, "score": 266275.72470618086 }, { "content": " class value_or_error<T&>\n\n {\n\n protected:\n\n typedef T& value_type;\n\n typedef boost::exception_ptr error_type;\n\n\n\n enum state { has_none, has_value, has_error };\n\n\n\n public:\n\n // constructors\n\n value_or_error()\n\n : state_(has_none)\n\n {}\n\n\n\n value_or_error(value_or_error const& rhs)\n\n : state_(rhs.state_)\n\n {\n\n switch (rhs.state_)\n\n {\n\n case has_none:\n", "file_path": "hpx/util/detail/value_or_error.hpp", "rank": 19, "score": 265924.5251608744 }, { "content": " class basic_any<void, void, Char>\n\n {\n\n public:\n\n // constructors\n\n basic_any() BOOST_NOEXCEPT\n\n : table(detail::any::get_table<\n\n detail::any::empty>::template get<void, void, Char>()),\n\n object(0)\n\n {\n\n }\n\n\n\n basic_any(basic_any const& x)\n\n : table(detail::any::get_table<\n\n detail::any::empty>::template get<void, void, Char>()),\n\n object(0)\n\n {\n\n assign(x);\n\n }\n\n\n\n template <typename T>\n", "file_path": "hpx/util/any.hpp", "rank": 20, "score": 263256.8283106224 }, { "content": " class function_nonser\n\n : public function<Sig, void, void>\n\n {\n\n typedef function<Sig, void, void> base_type;\n\n\n\n public:\n\n function_nonser() BOOST_NOEXCEPT\n\n : base_type()\n\n {}\n\n\n\n function_nonser(function_nonser const& other)\n\n : base_type(static_cast<base_type const&>(other))\n\n {}\n\n\n\n function_nonser(function_nonser&& other) BOOST_NOEXCEPT\n\n : base_type(static_cast<base_type&&>(other))\n\n {}\n\n\n\n template <typename F>\n\n function_nonser(F&& f,\n", "file_path": "hpx/util/detail/function_template.hpp", "rank": 21, "score": 259996.92843541107 }, { "content": "#define BOOST_SCOPED_LOG_WITH_CLASS_NAME(logger, msg, class_name) \\\n\nstruct class_name { \\\n\n class_name() { logger ( L\"start of \" msg ) ;} \\\n\n ~class_name() { logger ( L\" end of \" msg ) ; } \\\n\n} HPX_LOG_CONCATENATE(log_, __LINE__);\n\n\n\n#define BOOST_SCOPED_LOG(logger, msg) BOOST_SCOPED_LOG_WITH_CLASS_NAME(logger, msg, HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) )\n\n\n\n#endif\n\n\n\n// default scoped write - in case your gather class .read_msg().out() returns an STL ostream\n\ntemplate<class char_type, class char_traits> inline void scoped_write_msg(const hold_string_type & str, std::basic_ostream<char_type, char_traits> & out) {\n\n out << str;\n\n}\n\n\n\nnamespace detail {\n\n\n\n template<class gather_msg = default_> struct scoped_gather_base {\n\n typedef typename detail::find_gather_if_default<gather_msg>::msg_type msg_type;\n\n virtual void do_gather(const msg_type & ) = 0;\n\n };\n", "file_path": "hpx/util/logging/detail/scoped_log.hpp", "rank": 22, "score": 255687.209328465 }, { "content": " class unique_function\n\n : public detail::basic_function<\n\n detail::unique_function_vtable_ptr<Sig, IArchive, OArchive>\n\n , Sig\n\n >\n\n {\n\n typedef detail::unique_function_vtable_ptr<Sig, IArchive, OArchive> vtable_ptr;\n\n typedef detail::basic_function<vtable_ptr, Sig> base_type;\n\n\n\n#if defined(HPX_INTEL14_WORKAROUND)\n\n private:\n\n unique_function& operator=(unique_function const&);\n\n\n\n public:\n\n // The Intel Compiler sometimes erroneously instantiates this ctor. In order\n\n // to avoid compile errors, we provide the definition here\n\n unique_function(unique_function const & other) BOOST_NOEXCEPT\n\n {\n\n HPX_ASSERT(false);\n\n }\n", "file_path": "hpx/util/detail/unique_function_template.hpp", "rank": 23, "score": 254059.2712077515 }, { "content": " class pointer_output_dispatcher\n\n {\n\n typedef typename Pointer::element_type referred_type;\n\n\n\n struct intrusive_polymorphic\n\n {\n\n static void call(output_archive& ar, const Pointer& ptr)\n\n {\n\n const std::string name = access::get_name(ptr.get());\n\n ar << name;\n\n ar << *ptr;\n\n }\n\n };\n\n\n\n struct usual\n\n {\n\n static void call(output_archive& ar, const Pointer& ptr)\n\n {\n\n ar << *ptr;\n\n }\n", "file_path": "hpx/runtime/serialization/detail/pointer.hpp", "rank": 24, "score": 253937.30183860697 }, { "content": " class pointer_input_dispatcher\n\n {\n\n typedef typename Pointer::element_type referred_type;\n\n\n\n struct intrusive_polymorphic\n\n {\n\n static Pointer call(input_archive& ar, Pointer& ptr)\n\n {\n\n std::string name;\n\n ar >> name;\n\n\n\n Pointer t(\n\n polymorphic_intrusive_factory::instance().\n\n create<referred_type>(name)\n\n );\n\n ar >> *t;\n\n return t;\n\n }\n\n };\n\n\n", "file_path": "hpx/runtime/serialization/detail/pointer.hpp", "rank": 25, "score": 253937.30183860697 }, { "content": "class atomic<void *> : private detail::atomic::internal_atomic<void *, sizeof(void *), int> {\n\npublic:\n\n typedef detail::atomic::internal_atomic<void *, sizeof(void *), int> super;\n\n\n\n atomic() {}\n\n explicit atomic(void * p) : super(p) {}\n\n using super::load;\n\n using super::store;\n\n using super::compare_exchange_strong;\n\n using super::compare_exchange_weak;\n\n using super::exchange;\n\n using super::is_lock_free;\n\n\n\n operator void *(void) const volatile {return load();}\n\n void * operator=(void * v) volatile {store(v); return v;}\n\n\n\nprivate:\n\n atomic(const atomic &);\n\n void * operator=(const atomic &);\n\n};\n\n\n\n/* FIXME: pointer arithmetic still missing */\n\n\n\ntemplate<typename T>\n", "file_path": "external/atomic/boost/atomic.hpp", "rank": 26, "score": 253723.81276197342 }, { "content": "struct channel<void>\n\n{\n\n private:\n\n typedef hpx::lcos::detail::channel_future_data<void> future_data;\n\n\n\n boost::intrusive_ptr<future_data> data_;\n\n\n\n (channel<void>);\n\n\n\n public:\n\n typedef future_data::completed_callback_type\n\n completed_callback_type;\n\n\n\n channel() : data_(new future_data()) {}\n\n\n\n channel(channel const& other) : data_(other.data_) {}\n\n\n\n channel(channel && other) : data_(std::move(other.data_)) {}\n\n\n\n ~channel()\n", "file_path": "hpx/lcos/local/channel.hpp", "rank": 27, "score": 249519.66085175355 }, { "content": " class unique_function_nonser\n\n : public unique_function<Sig, void, void>\n\n {\n\n typedef unique_function<Sig, void, void> base_type;\n\n\n\n#if defined(HPX_INTEL14_WORKAROUND)\n\n private:\n\n unique_function_nonser& operator=(unique_function_nonser const&);\n\n\n\n public:\n\n // The Intel Compiler sometimes erroneously instantiates this ctor. In order\n\n // to avoid compile errors, we provide the definition here\n\n unique_function_nonser(unique_function_nonser const & other) BOOST_NOEXCEPT\n\n {\n\n HPX_ASSERT(false);\n\n }\n\n#else\n\n HPX_MOVABLE_BUT_NOT_COPYABLE(unique_function_nonser);\n\n#endif\n\n\n", "file_path": "hpx/util/detail/unique_function_template.hpp", "rank": 28, "score": 248435.68621140666 }, { "content": "class atomic<T *> : private detail::atomic::internal_atomic<void *, sizeof(void *), int> {\n\npublic:\n\n typedef detail::atomic::internal_atomic<void *, sizeof(void *), int> super;\n\n\n\n atomic() {}\n\n explicit atomic(T * p) : super(static_cast<void *>(p)) {}\n\n\n\n T *load(memory_order order=memory_order_seq_cst) const volatile\n\n {\n\n return static_cast<T*>(super::load(order));\n\n }\n\n void store(T *v, memory_order order=memory_order_seq_cst) volatile\n\n {\n\n super::store(static_cast<void *>(v), order);\n\n }\n\n bool compare_exchange_strong(\n\n T * &expected,\n\n T * desired,\n\n memory_order order=memory_order_seq_cst) volatile\n\n {\n", "file_path": "external/atomic/boost/atomic.hpp", "rank": 29, "score": 238067.13646727346 }, { "content": "struct A\n\n{\n\n A() {}\n\n\n\n A(T t) : t_(t) {}\n\n T t_;\n\n\n\n A & operator=(T t) { t_ = t; return *this; }\n\n bool operator==(const A& a) const { return t_ == a.t_; }\n\n\n\n template <typename Archive>\n\n void serialize(Archive & ar, unsigned)\n\n {\n\n ar & t_;\n\n }\n\n};\n\n\n\ntemplate <class T>\n\nstd::ostream& operator<<(std::ostream& os, const A<T>& a)\n\n{\n", "file_path": "tests/unit/serialization/serialization_map.cpp", "rank": 30, "score": 234610.1613252497 }, { "content": "struct X { void operator()(int); };\n", "file_path": "tests/unit/traits/is_callable.cpp", "rank": 31, "score": 232689.34838008793 }, { "content": " class void_continuation : public future_data<void>\n\n {\n\n private:\n\n template <typename Future>\n\n void on_ready(\n\n typename shared_state_ptr_for<Future>::type const& state)\n\n {\n\n try {\n\n (void)state->get_result();\n\n this->set_result(util::unused);\n\n }\n\n catch (...) {\n\n this->set_exception(boost::current_exception());\n\n }\n\n }\n\n\n\n public:\n\n template <typename Future>\n\n void attach(Future& future)\n\n {\n", "file_path": "hpx/lcos/local/packaged_continuation.hpp", "rank": 32, "score": 231298.01039412152 }, { "content": " class HPX_EXPORT polymorphic_intrusive_factory: boost::noncopyable\n\n {\n\n public:\n\n typedef void* (*ctor_type) ();\n\n typedef boost::unordered_map<std::string,\n\n ctor_type, hpx::util::jenkins_hash> ctor_map_type;\n\n\n\n static polymorphic_intrusive_factory& instance()\n\n {\n\n hpx::util::static_<polymorphic_intrusive_factory> factory;\n\n return factory.get();\n\n }\n\n\n\n void register_class(const std::string& name, ctor_type fun)\n\n {\n\n if(name.empty())\n\n {\n\n HPX_THROW_EXCEPTION(serialization_error\n\n , \"polymorphic_intrusive_factory::register_class\"\n\n , \"Cannot register a factory with an empty name\");\n", "file_path": "hpx/runtime/serialization/detail/polymorphic_intrusive_factory.hpp", "rank": 33, "score": 230469.12470803363 }, { "content": " class HPX_EXPORT polymorphic_nonintrusive_factory: boost::noncopyable\n\n {\n\n public:\n\n typedef boost::unordered_map<std::string,\n\n function_bunch_type, hpx::util::jenkins_hash> serializer_map_type;\n\n typedef boost::unordered_map<std::string,\n\n std::string, hpx::util::jenkins_hash> serializer_typeinfo_map_type;\n\n\n\n static polymorphic_nonintrusive_factory& instance()\n\n {\n\n hpx::util::static_<polymorphic_nonintrusive_factory> factory;\n\n return factory.get();\n\n }\n\n\n\n void register_class(const std::type_info& typeinfo, const std::string& class_name,\n\n const function_bunch_type& bunch)\n\n {\n\n if(!typeinfo.name() && std::string(typeinfo.name()).empty())\n\n {\n\n HPX_THROW_EXCEPTION(serialization_error\n", "file_path": "hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp", "rank": 34, "score": 230469.12470803363 }, { "content": "class platform_atomic_integral<void*, 8>\n\n : public build_atomic_from_add<atomic_interlocked_64<void*> >\n\n{\n\npublic:\n\n typedef build_atomic_from_add<atomic_interlocked_64<void*> > super;\n\n\n\n explicit platform_atomic_integral(void* v) : super(v) {}\n\n platform_atomic_integral(void) {}\n\n};\n\n\n\n#if BOOST_MSVC >= 1500 && defined(BOOST_ATOMIC_HAVE_SSE2)\n\n\n\ntemplate<typename T>\n", "file_path": "external/atomic/boost/atomic/detail/interlocked.hpp", "rank": 35, "score": 227625.1257469792 }, { "content": " class promise<void, util::unused_type>\n\n {\n\n public:\n\n typedef detail::promise<void, util::unused_type> wrapped_type;\n\n typedef components::managed_component<wrapped_type> wrapping_type;\n\n\n\n /// Construct a new \\a future instance. The supplied\n\n /// \\a thread will be notified as soon as the result of the\n\n /// operation associated with this future instance has been\n\n /// returned.\n\n ///\n\n /// \\note The result of the requested operation is expected to\n\n /// be returned as the first parameter using a\n\n /// \\a base_lco#set_value action. Any error has to be\n\n /// reported using a \\a base_lco::set_exception action. The\n\n /// target for either of these actions has to be this\n\n /// future instance (as it has to be sent along\n\n /// with the action as the continuation parameter).\n\n promise()\n\n : impl_(new wrapping_type(new wrapped_type())),\n", "file_path": "hpx/lcos/promise.hpp", "rank": 36, "score": 227315.02591650072 }, { "content": " class serialize_buffer\n\n {\n\n private:\n\n typedef Allocator allocator_type;\n\n\n\n static void no_deleter(T*) {}\n\n\n\n template <typename Deallocator>\n\n static void deleter(T* p, Deallocator dealloc, std::size_t size)\n\n {\n\n dealloc.deallocate(p, size);\n\n }\n\n\n\n public:\n\n enum init_mode\n\n {\n\n copy = 0, // constructor copies data\n\n reference = 1, // constructor does not copy data and does not\n\n // manage the lifetime of it\n\n take = 2 // constructor does not copy data but does take\n", "file_path": "hpx/runtime/serialization/serialize_buffer.hpp", "rank": 37, "score": 226503.66263810688 }, { "content": " class ucontext_context_impl_base : detail::context_impl_base\n\n {\n\n public:\n\n ucontext_context_impl_base()\n\n {\n\n HPX_COROUTINE_CREATE_CONTEXT(m_ctx);\n\n }\n\n ~ucontext_context_impl_base()\n\n {\n\n HPX_COROUTINE_DESTROY_CONTEXT(m_ctx);\n\n }\n\n\n\n private:\n\n /*\n\n * Free function. Saves the current context in @p from\n\n * and restores the context in @p to.\n\n */\n\n friend void\n\n swap_context(ucontext_context_impl_base& from,\n\n const ucontext_context_impl_base& to,\n", "file_path": "hpx/util/coroutine/detail/context_posix.hpp", "rank": 38, "score": 225983.29123944725 }, { "content": "struct A\n\n{\n\n int a = 0;\n\n\n\n explicit A(int a):\n\n a(a)\n\n {\n\n }\n\n A() = default;\n\n\n\n virtual void foo() const = 0;\n\n\n\n template <class Ar>\n\n void serialize(Ar& ar, unsigned)\n\n {\n\n ar & a;\n\n std::cout << __PRETTY_FUNCTION__ << std::endl;\n\n }\n\n HPX_SERIALIZATION_POLYMORPHIC_ABSTRACT(A);\n\n};\n\n\n\ntemplate <class T>\n", "file_path": "tests/unit/serialization/polymorphic/serialization_polymorphic_template.cpp", "rank": 39, "score": 225424.7008945999 }, { "content": " class value_logger\n\n {\n\n private:\n\n enum { hpx_initial_times_size = 64000 };\n\n typedef std::vector<std::pair<boost::uint64_t, T> > values_type;\n\n\n\n public:\n\n value_logger(char const* const description, bool enabled = true)\n\n : description_(description), enabled_(enabled && LTIM_ENABLED(fatal))\n\n {\n\n if (enabled_)\n\n values_.reserve(hpx_initial_times_size);\n\n }\n\n\n\n ~value_logger()\n\n {\n\n if (!enabled_)\n\n return; // generate output only if logging is enabled\n\n\n\n std::string name(description_);\n", "file_path": "hpx/util/value_logger.hpp", "rank": 40, "score": 224049.93110869554 }, { "content": " class serialize_dispatcher\n\n {\n\n struct intrusive_polymorphic\n\n {\n\n // both following template functions are viable\n\n // to call right overloaded function according to T constness\n\n // and to prevent calling templated version of serialize function\n\n static void call(hpx::serialization::input_archive& ar, T& t, unsigned)\n\n {\n\n t.serialize(ar, 0);\n\n }\n\n\n\n static void call(hpx::serialization::output_archive& ar, const T& t, unsigned)\n\n {\n\n t.serialize(ar, 0);\n\n }\n\n };\n\n\n\n struct non_intrusive_polymorphic\n\n {\n", "file_path": "hpx/runtime/serialization/access.hpp", "rank": 41, "score": 223896.64967890803 }, { "content": "struct Xc { void operator()(int) const; };\n\n\n\nvoid nullary_function()\n\n{\n\n using hpx::traits::is_callable;\n\n\n\n typedef void (*f)();\n\n HPX_TEST_MSG((is_callable<f()>::value == true), \"nullary function\");\n\n}\n\n\n\nvoid lambdas()\n\n{\n\n using hpx::traits::is_callable;\n\n# if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_DECLTYPE)\n\n auto lambda = [](){};\n\n\n\n typedef decltype(lambda) f;\n\n HPX_TEST_MSG((is_callable<f()>::value == true), \"lambda\");\n\n# endif\n\n}\n", "file_path": "tests/unit/traits/is_callable.cpp", "rank": 42, "score": 223741.94466122525 }, { "content": "class internal_atomic<T, Size, void> : private detail::atomic::platform_atomic<T> {\n\npublic:\n\n typedef detail::atomic::platform_atomic<T> super;\n\n\n\n internal_atomic() {}\n\n explicit internal_atomic(T v) : super(v) {}\n\n\n\n operator T(void) const volatile {return load();}\n\n T operator=(T v) volatile {store(v); return v;}\n\n\n\n using super::is_lock_free;\n\n using super::load;\n\n using super::store;\n\n using super::exchange;\n\n\n\n bool compare_exchange_strong(\n\n T &expected,\n\n T desired,\n\n memory_order order=memory_order_seq_cst) volatile\n\n {\n", "file_path": "external/atomic/boost/atomic/detail/base.hpp", "rank": 43, "score": 223729.98465551058 }, { "content": " class base_lco_with_value;\n\n\n\n template <typename Result,\n\n typename RemoteResult =\n\n typename traits::promise_remote_result<Result>::type>\n", "file_path": "hpx/hpx_fwd.hpp", "rank": 44, "score": 222990.5279107826 }, { "content": " class fibers_context_impl_base : detail::context_impl_base\n\n {\n\n public:\n\n /**\n\n * Create an empty context.\n\n * An empty context cannot be restored from,\n\n * but can be saved in.\n\n */\n\n fibers_context_impl_base() :\n\n m_ctx(0) {}\n\n\n\n /*\n\n * Free function. Saves the current context in @p from\n\n * and restores the context in @p to. On windows the from\n\n * parameter is ignored. The current context is saved on the\n\n * current fiber.\n\n * Note that if the current thread is not a fiber, it will be\n\n * converted to fiber on the fly on call and unconverted before\n\n * return. This is expensive. The user should convert the\n\n * current thread to a fiber once on thread creation for better performance.\n", "file_path": "hpx/util/coroutine/detail/context_windows_fibers.hpp", "rank": 45, "score": 222963.15281904215 }, { "content": " class param10> struct holder ;\n\n}\n\n\n\nnamespace formatter {\n\n\n\n\n\n/**\n\n @brief Allows format convertions - In case you're using a formatter that does not match your string type\n\n\n\n In case you want to use a formatter developed by someone else (for instance, a formatter provided by this lib),\n\n perhaps you're using another type of string to hold the message - thus, you need to provide a conversion function\n\n\n\n Example:\n\n FIXME\n\n\n\n --> convert_format::prepend\n\n\n\n explain that you can extend the following - since they're namespaces!!!\n\n so that you can \"inject\" your own write function in the convert_format::prepend/orwhatever namespace, and\n\n then it'll be automatically used!\n", "file_path": "hpx/util/logging/format/formatter/convert_format.hpp", "rank": 46, "score": 222135.1095605145 }, { "content": "struct symbol_namespace\n\n : components::client_base<symbol_namespace, stubs::symbol_namespace>\n\n{\n\n // {{{ nested types\n\n typedef components::client_base<\n\n symbol_namespace, stubs::symbol_namespace\n\n > base_type;\n\n\n\n typedef server::symbol_namespace server_type;\n\n\n\n typedef server_type::iterate_names_function_type\n\n iterate_names_function_type;\n\n // }}}\n\n\n\n symbol_namespace()\n\n : base_type(bootstrap_symbol_namespace_id())\n\n {}\n\n\n\n explicit symbol_namespace(naming::id_type const& id)\n\n : base_type(id)\n", "file_path": "hpx/runtime/agas/symbol_namespace.hpp", "rank": 47, "score": 221417.92290988984 }, { "content": "struct component_namespace\n\n : components::client_base<component_namespace, stubs::component_namespace>\n\n{\n\n // {{{ nested types\n\n typedef components::client_base<\n\n component_namespace, stubs::component_namespace\n\n > base_type;\n\n\n\n typedef server::component_namespace server_type;\n\n\n\n component_namespace()\n\n : base_type(bootstrap_component_namespace_id())\n\n {}\n\n\n\n explicit component_namespace(naming::id_type const& id)\n\n : base_type(id)\n\n {}\n\n\n\n response service(\n\n request const& req\n", "file_path": "hpx/runtime/agas/component_namespace.hpp", "rank": 48, "score": 221417.92290988984 }, { "content": "struct primary_namespace\n\n : components::client_base<primary_namespace, stubs::primary_namespace>\n\n{\n\n typedef components::client_base<primary_namespace, stubs::primary_namespace>\n\n base_type;\n\n\n\n typedef server::primary_namespace server_type;\n\n\n\n primary_namespace()\n\n : base_type(bootstrap_primary_namespace_id())\n\n {}\n\n\n\n explicit primary_namespace(naming::id_type const& id)\n\n : base_type(id)\n\n {}\n\n\n\n response service(\n\n request const& req\n\n , threads::thread_priority priority = threads::thread_priority_default\n\n , error_code& ec = throws\n", "file_path": "hpx/runtime/agas/primary_namespace.hpp", "rank": 49, "score": 221417.92290988984 }, { "content": "struct locality_namespace\n\n : components::client_base<locality_namespace, stubs::locality_namespace>\n\n{\n\n typedef components::client_base<locality_namespace, stubs::locality_namespace>\n\n base_type;\n\n\n\n typedef server::locality_namespace server_type;\n\n\n\n locality_namespace()\n\n : base_type(bootstrap_locality_namespace_id())\n\n {}\n\n\n\n explicit locality_namespace(naming::id_type const& id)\n\n : base_type(id)\n\n {}\n\n\n\n response service(\n\n request const& req\n\n , threads::thread_priority priority = threads::thread_priority_default\n\n , error_code& ec = throws\n", "file_path": "hpx/runtime/agas/locality_namespace.hpp", "rank": 50, "score": 221417.92290988984 }, { "content": " class cancellation_token<detail::no_data, std::less_equal<detail::no_data> >\n\n {\n\n private:\n\n typedef boost::atomic<bool> flag_type;\n\n boost::shared_ptr<flag_type> was_cancelled_;\n\n\n\n public:\n\n cancellation_token()\n\n : was_cancelled_(boost::make_shared<flag_type>(false))\n\n {}\n\n\n\n bool was_cancelled() const BOOST_NOEXCEPT\n\n {\n\n return was_cancelled_->load(boost::memory_order_relaxed);\n\n }\n\n\n\n void cancel() BOOST_NOEXCEPT\n\n {\n\n was_cancelled_->store(true, boost::memory_order_relaxed);\n\n }\n\n };\n\n}}}\n\n\n\n#endif\n", "file_path": "hpx/parallel/util/cancellation_token.hpp", "rank": 51, "score": 221112.89627897757 }, { "content": "/// \\brief AGAS's primary namespace maps 128-bit global identifiers (GIDs) to\n\n/// resolved addresses.\n\n///\n\n/// \\note The layout of the address space is implementation defined, and\n\n/// subject to change. Never write application code that relies on the internal\n\n/// layout of GIDs. AGAS only guarantees that all assigned GIDs will be unique.\n\n///\n\n/// The following is the canonical description of the partitioning of AGAS's\n\n/// primary namespace.\n\n///\n\n/// |-----MSB------||------LSB-----|\n\n/// BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n\n/// |prefix||RC||----identifier----|\n\n///\n\n/// MSB - Most significant bits (bit 64 to bit 127)\n\n/// LSB - Least significant bits (bit 0 to bit 63)\n\n/// prefix - Highest 32 bits (bit 96 to bit 127) of the MSB. Each\n\n/// locality is assigned a prefix. This creates a 96-bit\n\n/// address space for each locality.\n\n/// RC - Bit 88 to bit 92 of the MSB. This is the log2 of the number\n\n/// of reference counting credits on the GID.\n\n/// Bit 93 is used by the locking scheme for gid_types.\n\n/// Bit 94 is a flag which is set if the credit value is valid.\n\n/// Bit 95 is a flag that is set if a GID's credit count is\n\n/// ever split (e.g. if the GID is ever passed to another\n\n/// locality).\n\n/// identifier - Bit 64 to bit 87 of the MSB, and the entire LSB. The\n\n/// content of these bits depends on the component type of\n\n/// the underlying object. For all user-defined components,\n\n/// these bits contain a unique 88-bit number which is\n\n/// assigned sequentially for each locality. For\n\n/// \\a hpx#components#component_runtime_support and\n\n/// \\a hpx#components#component_memory, the high 24 bits are\n\n/// zeroed and the low 64 bits hold the LVA of the component.\n\n///\n\n/// The following address ranges are reserved. Some are either explicitly or\n\n/// implicitly protected by AGAS. The letter x represents a single-byte\n\n/// wild card.\n\n///\n\n/// 00000000xxxxxxxxxxxxxxxxxxxxxxxx\n\n/// Historically unused address space reserved for future use.\n\n/// xxxxxxxxxxxx0000xxxxxxxxxxxxxxxx\n\n/// Address space for LVA-encoded GIDs.\n\n/// 00000001xxxxxxxxxxxxxxxxxxxxxxxx\n\n/// Prefix of the bootstrap AGAS locality.\n\n/// 00000001000000010000000000000001\n\n/// Address of the primary_namespace component on the bootstrap AGAS\n\n/// locality.\n\n/// 00000001000000010000000000000002\n\n/// Address of the component_namespace component on the bootstrap AGAS\n\n/// locality.\n\n/// 00000001000000010000000000000003\n\n/// Address of the symbol_namespace component on the bootstrap AGAS\n\n/// locality.\n\n/// 00000001000000010000000000000004\n\n/// Address of the locality_namespace component on the bootstrap AGAS\n\n/// locality.\n\n/// 00000001000000010000000000000005\n\n/// Address of the root-CA component\n\n/// xxxxxxxx000000010000000000000006\n\n/// Address of the locality based sub-CA, xxxxxxxx is replaced with the\n\n/// correct locality id\n\n///\n\nstruct HPX_EXPORT primary_namespace\n\n : components::fixed_component_base<primary_namespace>\n\n{\n\n // {{{ nested types\n\n typedef lcos::local::spinlock mutex_type;\n\n typedef components::fixed_component_base<primary_namespace> base_type;\n\n\n\n typedef boost::int32_t component_type;\n\n\n\n typedef std::pair<gva, naming::gid_type> gva_table_data_type;\n\n typedef std::map<naming::gid_type, gva_table_data_type> gva_table_type;\n\n typedef std::map<naming::gid_type, boost::int64_t> refcnt_table_type;\n\n\n\n typedef boost::fusion::vector3<naming::gid_type, gva, naming::gid_type>\n\n resolved_type;\n\n // }}}\n\n\n\n private:\n\n // REVIEW: Separate mutexes might reduce contention here. This has to be\n\n // investigated carefully.\n", "file_path": "hpx/runtime/agas/server/primary_namespace.hpp", "rank": 52, "score": 220604.37227754208 }, { "content": "struct HPX_EXPORT locality_namespace\n\n : components::fixed_component_base<locality_namespace>\n\n{\n\n // {{{ nested types\n\n typedef lcos::local::spinlock mutex_type;\n\n typedef components::fixed_component_base<locality_namespace> base_type;\n\n\n\n typedef boost::int32_t component_type;\n\n\n\n // stores the locality endpoints, and number of OS-threads running on this locality\n\n typedef boost::fusion::vector2<\n\n parcelset::endpoints_type, boost::uint32_t>\n\n partition_type;\n\n\n\n typedef std::map<boost::uint32_t, partition_type> partition_table_type;\n\n // }}}\n\n\n\n private:\n\n // REVIEW: Separate mutexes might reduce contention here. This has to be\n\n // investigated carefully.\n", "file_path": "hpx/runtime/agas/server/locality_namespace.hpp", "rank": 53, "score": 220584.05160577758 }, { "content": "struct HPX_EXPORT primary_namespace\n\n{\n\n typedef server::primary_namespace server_type;\n\n typedef server::primary_namespace server_component_type;\n\n\n\n ///////////////////////////////////////////////////////////////////////////\n\n template <typename Result>\n\n static lcos::future<Result> service_async(\n\n naming::id_type const& gid\n\n , request const& req\n\n , threads::thread_priority priority = threads::thread_priority_default\n\n );\n\n\n\n /// Fire-and-forget semantics.\n\n ///\n\n /// \\note This is placed out of line to avoid including applier headers.\n\n static void service_non_blocking(\n\n naming::id_type const& gid\n\n , request const& req\n\n , threads::thread_priority priority = threads::thread_priority_default\n", "file_path": "hpx/runtime/agas/stubs/primary_namespace.hpp", "rank": 54, "score": 220584.05160577758 }, { "content": "struct HPX_EXPORT locality_namespace\n\n{\n\n typedef server::locality_namespace server_type;\n\n typedef server::locality_namespace server_component_type;\n\n\n\n ///////////////////////////////////////////////////////////////////////////\n\n template <typename Result>\n\n static lcos::future<Result> service_async(\n\n naming::id_type const& gid\n\n , request const& req\n\n , threads::thread_priority priority = threads::thread_priority_default\n\n );\n\n\n\n /// Fire-and-forget semantics.\n\n ///\n\n /// \\note This is placed out of line to avoid including applier headers.\n\n static void service_non_blocking(\n\n naming::id_type const& gid\n\n , request const& req\n\n , threads::thread_priority priority = threads::thread_priority_default\n", "file_path": "hpx/runtime/agas/stubs/locality_namespace.hpp", "rank": 55, "score": 220584.05160577758 }, { "content": "struct HPX_EXPORT symbol_namespace\n\n : components::fixed_component_base<symbol_namespace>\n\n{\n\n // {{{ nested types\n\n typedef lcos::local::spinlock mutex_type;\n\n typedef components::fixed_component_base<symbol_namespace> base_type;\n\n\n\n // FIXME: This signature should use id_type, not gid_type\n\n typedef hpx::util::function<\n\n void(std::string const&, naming::gid_type const&)\n\n > iterate_names_function_type;\n\n\n\n typedef std::map<std::string, boost::shared_ptr<naming::gid_type> >\n\n gid_table_type;\n\n\n\n typedef std::multimap<\n\n std::pair<std::string, namespace_action_code>, hpx::id_type\n\n > on_event_data_map_type;\n\n // }}}\n\n\n", "file_path": "hpx/runtime/agas/server/symbol_namespace.hpp", "rank": 56, "score": 220584.05160577758 }, { "content": "struct HPX_EXPORT component_namespace\n\n : components::fixed_component_base<component_namespace>\n\n{\n\n // {{{ nested types\n\n typedef lcos::local::spinlock mutex_type;\n\n typedef components::fixed_component_base<component_namespace> base_type;\n\n\n\n typedef hpx::util::function<\n\n void(std::string const&, components::component_type)\n\n > iterate_types_function_type;\n\n\n\n typedef components::component_type component_id_type;\n\n\n\n typedef std::set<boost::uint32_t> prefixes_type;\n\n\n\n typedef boost::bimap<std::string, component_id_type> component_id_table_type;\n\n\n\n typedef std::map<component_id_type, prefixes_type> factory_table_type;\n\n // }}}\n\n\n", "file_path": "hpx/runtime/agas/server/component_namespace.hpp", "rank": 57, "score": 220584.05160577758 }, { "content": "struct HPX_EXPORT symbol_namespace\n\n{\n\n typedef server::symbol_namespace server_type;\n\n typedef server::symbol_namespace server_component_type;\n\n\n\n typedef server_type::iterate_names_function_type\n\n iterate_names_function_type;\n\n\n\n ///////////////////////////////////////////////////////////////////////////\n\n template <typename Result>\n\n static lcos::future<Result> service_async(\n\n naming::id_type const& gid\n\n , request const& req\n\n , threads::thread_priority priority = threads::thread_priority_default\n\n );\n\n\n\n template <typename Result>\n\n static lcos::future<Result> service_async(\n\n std::string const& key\n\n , request const& req\n", "file_path": "hpx/runtime/agas/stubs/symbol_namespace.hpp", "rank": 58, "score": 220584.05160577758 }, { "content": " class x86_linux_context_impl_base : detail::context_impl_base\n\n {\n\n public:\n\n x86_linux_context_impl_base() {}\n\n\n\n void prefetch() const\n\n {\n\n#if defined(__x86_64__)\n\n HPX_ASSERT(sizeof(void*) == 8);\n\n#else\n\n HPX_ASSERT(sizeof(void*) == 4);\n\n#endif\n\n\n\n __builtin_prefetch (m_sp, 1, 3);\n\n __builtin_prefetch (m_sp, 0, 3);\n\n __builtin_prefetch (static_cast<void**>(m_sp)+64/sizeof(void*), 1, 3);\n\n __builtin_prefetch (static_cast<void**>(m_sp)+64/sizeof(void*), 0, 3);\n\n#if !defined(__x86_64__)\n\n __builtin_prefetch (static_cast<void**>(m_sp)+32/sizeof(void*), 1, 3);\n\n __builtin_prefetch (static_cast<void**>(m_sp)+32/sizeof(void*), 0, 3);\n", "file_path": "hpx/util/coroutine/detail/context_linux_x86.hpp", "rank": 59, "score": 220064.1712527158 }, { "content": " class secret_key\n\n {\n\n public:\n\n secret_key(public_key & public_key)\n\n {\n\n crypto_sign_keypair(public_key.bytes_.c_array(), bytes_.c_array());\n\n }\n\n\n\n template <typename T>\n\n signed_type<T> sign(T const & type, error_code& ec = throws) const\n\n {\n\n signed_type<T> signed_type;\n\n unsigned long long signed_type_length;\n\n\n\n if (crypto_sign(\n\n signed_type.begin(),\n\n &signed_type_length,\n\n type.begin(),\n\n type.size(),\n\n bytes_.data()) != 0)\n", "file_path": "hpx/components/security/secret_key.hpp", "rank": 60, "score": 219722.3621931764 }, { "content": " class public_key\n\n {\n\n public:\n\n template <typename T>\n\n bool verify(signed_type<T> const & signed_type) const\n\n {\n\n unsigned char type[sizeof signed_type];\n\n unsigned long long type_length;\n\n\n\n return crypto_sign_open(\n\n type,\n\n &type_length,\n\n signed_type.begin(),\n\n signed_type.size(),\n\n bytes_.data()) == 0;\n\n }\n\n\n\n friend std::ostream & operator<<(std::ostream & os,\n\n public_key const & public_key)\n\n {\n", "file_path": "hpx/components/security/public_key.hpp", "rank": 61, "score": 219722.3621931764 }, { "content": " class key_pair\n\n {\n\n public:\n\n key_pair()\n\n : secret_key_(public_key_)\n\n {\n\n }\n\n\n\n public_key const & get_public_key() const\n\n {\n\n return public_key_;\n\n }\n\n\n\n template <typename T>\n\n signed_type<T> sign(T const & type, error_code& ec = throws) const\n\n {\n\n return secret_key_.sign(type, ec);\n\n }\n\n\n\n template <typename T>\n", "file_path": "hpx/components/security/key_pair.hpp", "rank": 62, "score": 219722.3621931764 }, { "content": " class unordered_map\n\n : hpx::components::client_base<\n\n unordered_map<Key, T, Hash, KeyEqual>,\n\n hpx::components::server::distributed_metadata_base<\n\n server::unordered_map_config_data> >,\n\n detail::unordered_base<Hash, KeyEqual>\n\n {\n\n public:\n\n typedef std::allocator<T> allocator_type;\n\n\n\n typedef std::size_t size_type;\n\n typedef std::ptrdiff_t difference_type;\n\n\n\n typedef T value_type;\n\n typedef T reference;\n\n typedef T const const_reference;\n\n\n\n#if (defined(HPX_GCC_VERSION) && HPX_GCC_VERSION < 40700) || defined(HPX_NATIVE_MIC)\n\n typedef T* pointer;\n\n typedef T const* const_pointer;\n", "file_path": "hpx/components/containers/unordered/unordered_map.hpp", "rank": 63, "score": 215531.51029871695 }, { "content": " class unordered_map;\n\n\n\n namespace detail\n\n {\n\n ///////////////////////////////////////////////////////////////////////\n\n template <typename Key, typename T, typename Hash, typename KeyEqual>\n\n struct unordered_map_value_proxy\n\n {\n\n unordered_map_value_proxy(\n\n hpx::unordered_map<Key, T, Hash, KeyEqual>& um,\n\n Key const& key)\n\n : um_(um), key_(key)\n\n {}\n\n\n\n operator T() const\n\n {\n\n return um_.get_value_sync(key_);\n\n }\n\n\n\n template <typename T_>\n", "file_path": "hpx/components/containers/unordered/unordered_map.hpp", "rank": 64, "score": 215531.51029871695 }, { "content": " ///////////////////////////////////////////////////////////////////////////\n\n class void_continuation;\n\n\n\n template <typename Future>\n\n inline typename shared_state_ptr<void>::type\n\n make_void_continuation(Future& future);\n\n\n\n ///////////////////////////////////////////////////////////////////////////\n\n template <typename Derived, typename R>\n", "file_path": "hpx/lcos/future.hpp", "rank": 65, "score": 214338.18552248468 }, { "content": " class array\n\n {\n\n public:\n\n typedef T value_type;\n\n\n\n array(value_type* t, std::size_t s):\n\n m_t(t),\n\n m_element_count(s)\n\n {}\n\n\n\n value_type* address() const\n\n {\n\n return m_t;\n\n }\n\n\n\n std::size_t count() const\n\n {\n\n return m_element_count;\n\n }\n\n\n", "file_path": "hpx/runtime/serialization/array.hpp", "rank": 66, "score": 214191.1467954843 }, { "content": " class access\n\n {\n\n template <class T>\n", "file_path": "hpx/runtime/serialization/access.hpp", "rank": 67, "score": 214191.1467954843 }, { "content": " class promise : public detail::promise_base<R>\n\n {\n\n HPX_MOVABLE_BUT_NOT_COPYABLE(promise);\n\n\n\n typedef detail::promise_base<R> base_type;\n\n\n\n public:\n\n // Effects: constructs a promise object and a shared state.\n\n promise()\n\n : base_type()\n\n {}\n\n\n\n // Effects: constructs a new promise object and transfers ownership of\n\n // the shared state of other (if any) to the newly-\n\n // constructed object.\n\n // Postcondition: other has no shared state.\n\n promise(promise&& other) BOOST_NOEXCEPT\n\n : base_type(std::move(other))\n\n {}\n\n\n", "file_path": "hpx/lcos/local/promise.hpp", "rank": 68, "score": 214037.25664937688 }, { "content": "struct format_write {\n\n typedef typename formatter_base::ptr_type formatter_ptr;\n\n typedef typename destination_base::ptr_type destination_ptr;\n\n\n\n typedef typename use_default<apply_format_and_write, ::hpx::util::logging::format_and_write::simple<typename formatter_base::raw_param> > ::type apply_format_and_write_type;\n\n\n\n typedef typename hpx::util::logging::detail::to_override<formatter_base>::type override_;\n\n typedef typename use_default<lock_resource, typename hpx::util::logging::types<override_>::lock_resource > ::type lock_resource_type;\n\n\n\n typedef formatter_base formatter_base_type;\n\n typedef destination_base destination_base_type;\n\n\n\n\n\n format_write() : m_router(m_formatters, m_destinations) {}\n\n\n\n\n\nprivate:\n\n\n\n // non-generic\n\n template<class formatter> void add_formatter_impl(formatter fmt, const boost::false_type& ) {\n", "file_path": "hpx/util/logging/detail/format_write_detail.hpp", "rank": 69, "score": 212814.8088386536 }, { "content": "///////////////////////////////////////////////////////////////////////////////\n\n// Concrete\n\nstruct A : hpx::components::managed_component_base<A>\n\n{\n\n A() { a_ctor = true; }\n\n virtual ~A() { a_dtor = true; }\n\n\n\n virtual std::string test0() const { return \"A\"; }\n\n std::string test0_nonvirt() const { return test0(); }\n\n HPX_DEFINE_COMPONENT_ACTION(A, test0_nonvirt, test0_action);\n\n};\n\n\n\ntypedef hpx::components::managed_component<A> serverA_type;\n\nHPX_REGISTER_COMPONENT(serverA_type, A);\n\n\n\ntypedef A::test0_action test0_action;\n\nHPX_REGISTER_ACTION_DECLARATION(test0_action);\n\nHPX_REGISTER_ACTION(test0_action);\n\n\n", "file_path": "tests/unit/components/inheritance_3_classes_concrete.cpp", "rank": 70, "score": 211744.05249464494 }, { "content": "///////////////////////////////////////////////////////////////////////////////\n\n// Concrete\n\nstruct A : hpx::components::managed_component_base<A>\n\n{\n\n A() { a_ctor = true; }\n\n virtual ~A() { a_dtor = true; }\n\n\n\n virtual std::string test0() const { return \"A\"; }\n\n std::string test0_nonvirt() const { return test0(); }\n\n HPX_DEFINE_COMPONENT_ACTION(A, test0_nonvirt, test0_action);\n\n};\n\n\n\ntypedef hpx::components::managed_component<A> serverA_type;\n\nHPX_REGISTER_COMPONENT(serverA_type, A);\n\n\n\ntypedef A::test0_action test0_action;\n\nHPX_REGISTER_ACTION_DECLARATION(test0_action);\n\nHPX_REGISTER_ACTION(test0_action);\n\n\n", "file_path": "tests/unit/components/inheritance_2_classes_concrete.cpp", "rank": 71, "score": 211744.05249464494 }, { "content": " class destination_base,\n", "file_path": "hpx/util/logging/detail/format_write_detail.hpp", "rank": 72, "score": 210962.16710110116 }, { "content": " class formatter_base,\n", "file_path": "hpx/util/logging/detail/format_write_detail.hpp", "rank": 73, "score": 210962.16710110116 }, { "content": "struct to_hwnd : destination::class_<to_hwnd, destination::implement_op_equal::has_context> {\n\n HWND h;\n\n to_hwnd(HWND h) : h(h) {}\n\n\n\n bool operator==(const to_hwnd& other) { return h == other.h; }\n\n\n\n // param = const std::string&\n\n // (in other words, it's the arg_type from your destination base class)\n\n void operator()(param msg) const {\n\n ::SetWindowText(h, msg.c_str());\n\n }\n\n};\n\n@endcode\n\n\n\n\n\n\n\n\\n\\n\\n\n\n@section manipulator_share_data Sharing data for manipulator classes\n\n\n\nWhen you implement your own %manipulator (%formatter or %destination) class, you must make sure that\n\nit behaves like an STL function: <b>it needs to contain data as constant.</b>\n\n\n\nAs long as data is constant, it's all ok - that is, no matter what functions get called, all the data in the formatter/destination\n\nmust remain constant. We need constant functors - just like in STL - because internally, we copy formatters/destinations: that is, we keep\n\nseveral copies of a certain object - they all need to be syncronized. In case the objects' data is constant, that's no problem.\n\n\n\nIn case the data needs to be changed - it needs to be shared. Several copies of the same instance must point to the same data.\n\nI've already provided a class you can derive from , when this is the case: the non_const_context class.\n\n\n\n@code\n", "file_path": "hpx/util/logging/detail/manipulator.hpp", "rank": 74, "score": 210700.06080494664 }, { "content": "struct time {\n\n time() : val( ::time(0) ) {}\n\n ::time_t val;\n\n};\n\n@endcode\n\n\n\nThey only allow holding the context, and making sure you can get to it - when doing formatting. You can of course add your own tag clases.\n\n\n\n\n\n\n\n@subsection tag_tag_holder Tag Holder - holding the tags\n\n\n\nNow, you have to decide what tags you need. You will use templated class tag::holder:\n\n- first param: the string class\n\n- the next params: the tags you need\n\n\n\nYou will replace your old <tt>HPX_LOG_FORMAT_MSG(string_class)</tt> usage, with tags. In case you don't have a HPX_LOG_FORMAT_MSG in your\n\napplication, the string_class is std::(w)string.\n\n\n\n@code\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 75, "score": 210692.7243883913 }, { "content": "struct ts {\n\n ts() : m_enabled(true) {}\n\n bool is_enabled() const {\n\n threading::scoped_lock lk(m_cs);\n\n return m_enabled;\n\n }\n\n void set_enabled(bool enabled) {\n\n threading::scoped_lock lk(m_cs);\n\n m_enabled = enabled;\n\n }\n\nprivate:\n\n bool m_enabled;\n\n mutable threading::mutex m_cs;\n\n};\n\n\n\n\n\n\n\n\n\n#ifndef HPX_HAVE_LOG_NO_TSS\n\n\n", "file_path": "hpx/util/logging/detail/filter.hpp", "rank": 76, "score": 210692.7243883913 }, { "content": "struct no_gather {\n\n const char * m_msg;\n\n no_gather() : m_msg(0) {}\n\n const char * msg() const { return m_msg; }\n\n void out(const char* msg) { m_msg = msg; }\n\n void out(const std::string& msg) { m_msg = msg.c_str(); }\n\n};\n\n\n\ntypedef logger< no_gather, destination::cout > app_log_type;\n\n\n\n#define LAPP_ HPX_LOG_USE_SIMPLE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() )\n\n@endcode\n\n\n\nSee @ref defining_logger_macros for more details\n\n\n\n\n\n\n\n\\n\\n\n\n@subsection macros_set_formatters Setting formatter/destination strings\n\n\n", "file_path": "hpx/util/logging/detail/macros.hpp", "rank": 77, "score": 210692.7243883913 }, { "content": "struct has_swap\n\n : has_swap_::has_swap_impl<T>::type\n\n{};\n\n#if defined(BOOST_MSVC)\n\n# pragma warning(pop)\n\n#endif\n\n\n\n}}}\n\n\n\n#endif // include guard\n", "file_path": "hpx/util/coroutine/detail/has_swap.hpp", "rank": 78, "score": 210692.7243883913 }, { "content": "struct is_generic {\n\n virtual ~is_generic() {}\n\n\n\n /** @brief Override this if you want to allow configuration through scripting\n\n\n\n That is, this allows configuration of your manipulator (formatter/destination) at run-time.\n\n */\n\n virtual void configure(const hold_string_type& ) {}\n\n};\n\n\n\nnamespace detail {\n\n\n\n // holds the generic manipulator, and forwards to it\n\n template<class generic_type, class manipulator_base> struct generic_holder\n\n : class_<\n\n generic_holder<generic_type,manipulator_base>,\n\n implement_op_equal::has_context,\n\n manipulator_base > {\n\n typedef typename manipulator_base::param param;\n\n\n", "file_path": "hpx/util/logging/detail/manipulator.hpp", "rank": 79, "score": 210692.7243883913 }, { "content": "struct no_ts {\n\n no_ts() : m_enabled(true) {}\n\n bool is_enabled() const { return m_enabled; }\n\n void set_enabled(bool enabled) { m_enabled = enabled; }\n\nprivate:\n\n bool m_enabled;\n\n};\n\n\n\n\n\n/**\n\n @brief Filter that is always enabled\n\n*/\n", "file_path": "hpx/util/logging/detail/filter.hpp", "rank": 80, "score": 210692.7243883913 }, { "content": "struct B: A<T>\n\n{\n\n int b = 0;\n\n\n\n explicit B(int b):\n\n A<T>(b-1),\n\n b(b)\n\n {\n\n }\n\n B() = default;\n\n\n\n virtual void foo() const{}\n\n\n\n template <class Ar>\n\n void serialize(Ar& ar, unsigned)\n\n {\n\n std::cout << __PRETTY_FUNCTION__ << std::endl;\n\n ar & hpx::serialization::base_object<A<T> >(*this);\n\n ar & b;\n\n }\n", "file_path": "tests/unit/serialization/polymorphic/serialization_polymorphic_template.cpp", "rank": 81, "score": 210489.67333680982 }, { "content": "struct dump_default_levels {\n\n static const char_type * dump(::hpx::util::logging::level::type lvl) {\n\n using namespace ::hpx::util::logging::level;\n\n switch ( lvl) {\n\n case debug: return HPX_LOG_STR(\"[debug] \");\n\n case info: return HPX_LOG_STR(\"[info] \");\n\n case warning: return HPX_LOG_STR(\"[warn] \");\n\n case error: return HPX_LOG_STR(\"[ERROR] \");\n\n case fatal: return HPX_LOG_STR(\"[FATAL] \");\n\n default: return HPX_LOG_STR(\"\");\n\n }\n\n }\n\n};\n\n\n\n/**\n\n Specifies the class that will dump the levels. Used by formatter::tag::level class.\n\n*/\n\ntemplate<class T = override> struct dump_level {\n\n typedef dump_default_levels type;\n\n};\n", "file_path": "hpx/util/logging/detail/format_fwd_detail.hpp", "rank": 82, "score": 209050.3182654832 }, { "content": "///////////////////////////////////////////////////////////////////////////////\n\n// Abstract\n\nstruct A : hpx::components::abstract_managed_component_base<A>\n\n{\n\n A() { a_ctor = true; }\n\n virtual ~A() { a_dtor = true; }\n\n\n\n virtual std::string test0() const = 0;\n\n std::string test0_nonvirt() const { return test0(); }\n\n HPX_DEFINE_COMPONENT_ACTION(A, test0_nonvirt, test0_action);\n\n};\n\n\n\nHPX_DEFINE_GET_COMPONENT_TYPE(A);\n\n\n\ntypedef A::test0_action test0_action;\n\nHPX_REGISTER_ACTION_DECLARATION(test0_action);\n\nHPX_REGISTER_ACTION(test0_action);\n\n\n", "file_path": "tests/unit/components/inheritance_2_classes_abstract.cpp", "rank": 83, "score": 208149.17907950724 }, { "content": "///////////////////////////////////////////////////////////////////////////////\n\n// Abstract\n\nstruct A : hpx::components::abstract_managed_component_base<A>\n\n{\n\n A() { a_ctor = true; }\n\n virtual ~A() { a_dtor = true; }\n\n\n\n virtual std::string test0() const = 0;\n\n std::string test0_nonvirt() const { return test0(); }\n\n HPX_DEFINE_COMPONENT_ACTION(A, test0_nonvirt, test0_action);\n\n};\n\n\n\nHPX_DEFINE_GET_COMPONENT_TYPE(A);\n\n\n\ntypedef A::test0_action test0_action;\n\nHPX_REGISTER_ACTION_DECLARATION(test0_action);\n\nHPX_REGISTER_ACTION(test0_action);\n\n\n", "file_path": "tests/unit/components/inheritance_3_classes_2_abstract.cpp", "rank": 84, "score": 208149.17907950724 }, { "content": "///////////////////////////////////////////////////////////////////////////////\n\n// Abstract\n\nstruct A : hpx::components::abstract_managed_component_base<A>\n\n{\n\n A() { a_ctor = true; }\n\n virtual ~A() { a_dtor = true; }\n\n\n\n virtual std::string test0() const = 0;\n\n std::string test0_nonvirt() const { return test0(); }\n\n HPX_DEFINE_COMPONENT_ACTION(A, test0_nonvirt, test0_action);\n\n};\n\n\n\nHPX_DEFINE_GET_COMPONENT_TYPE(A);\n\n\n\ntypedef A::test0_action test0_action;\n\nHPX_REGISTER_ACTION_DECLARATION(test0_action);\n\nHPX_REGISTER_ACTION(test0_action);\n\n\n", "file_path": "tests/unit/components/inheritance_3_classes_1_abstract.cpp", "rank": 85, "score": 208149.17907950724 }, { "content": " class gather = default_,\n", "file_path": "hpx/util/logging/detail/format_fwd_detail.hpp", "rank": 86, "score": 207525.58907314975 }, { "content": " class promise<R&> : public detail::promise_base<R&>\n\n {\n\n HPX_MOVABLE_BUT_NOT_COPYABLE(promise);\n\n\n\n typedef detail::promise_base<R&> base_type;\n\n\n\n public:\n\n // Effects: constructs a promise object and a shared state.\n\n promise()\n\n : base_type()\n\n {}\n\n\n\n // Effects: constructs a new promise object and transfers ownership of\n\n // the shared state of other (if any) to the newly-\n\n // constructed object.\n\n // Postcondition: other has no shared state.\n\n promise(promise&& other) BOOST_NOEXCEPT\n\n : base_type(std::move(other))\n\n {}\n\n\n", "file_path": "hpx/lcos/local/promise.hpp", "rank": 87, "score": 206286.3683939388 }, { "content": "struct always_disabled {\n\n static bool is_enabled() { return false; }\n\n};\n\n\n\n\n\n/**\n\n @brief Filter that is enabled in debug mode\n\n*/\n", "file_path": "hpx/util/logging/detail/filter.hpp", "rank": 88, "score": 206015.01004270773 }, { "content": "struct file_line {\n\n file_line(const char * val = \"\") : val(val) {}\n\n const char * val;\n\n};\n\n\n", "file_path": "hpx/util/logging/detail/tags.hpp", "rank": 89, "score": 206015.01004270773 }, { "content": "struct debug_enabled {\n\n#ifndef NDEBUG\n\n static bool is_enabled() { return true; }\n\n#else\n\n static bool is_enabled() { return false; }\n\n#endif\n\n};\n\n\n\n\n\n/**\n\n @brief Filter that is enabled in release mode\n\n*/\n", "file_path": "hpx/util/logging/detail/filter.hpp", "rank": 90, "score": 206015.01004270773 }, { "content": "struct release_enabled {\n\n#ifdef NDEBUG\n\n static bool is_enabled() { return true; }\n\n#else\n\n static bool is_enabled() { return false; }\n\n#endif\n\n};\n\n\n\n\n\n/**\n\n @brief Thread-safe filter. Manages is_enabled/set_enabled in a thread-safe way.\n\n\n\n However, it manages it rather ineffiently - always locking before asking.\n\n*/\n", "file_path": "hpx/util/logging/detail/filter.hpp", "rank": 91, "score": 206015.01004270773 }, { "content": "struct always_enabled {\n\n static bool is_enabled() { return true; }\n\n};\n\n\n\n\n\n/**\n\n @brief Filter that is always disabled\n\n*/\n", "file_path": "hpx/util/logging/detail/filter.hpp", "rank": 92, "score": 206015.01004270773 }, { "content": " class partition_unordered_map\n\n : public components::client_base<\n\n partition_unordered_map<Key, T, Hash, KeyEqual>,\n\n server::partition_unordered_map<Key, T, Hash, KeyEqual>\n\n >\n\n {\n\n private:\n\n typedef hpx::server::partition_unordered_map<Key, T, Hash, KeyEqual>\n\n server_type;\n\n typedef hpx::components::client_base<\n\n partition_unordered_map<Key, T, Hash, KeyEqual>,\n\n server::partition_unordered_map<Key, T, Hash, KeyEqual>\n\n > base_type;\n\n\n\n public:\n\n partition_unordered_map() {}\n\n\n\n partition_unordered_map(id_type const& gid)\n\n : base_type(gid)\n\n {}\n", "file_path": "hpx/components/containers/unordered/partition_unordered_map_component.hpp", "rank": 93, "score": 204201.9991946832 }, { "content": " class dll\n\n {\n\n public:\n\n dll()\n\n : dll_handle(NULL)\n\n {}\n\n\n\n dll(dll const& rhs)\n\n : dll_name(rhs.dll_name), map_name(rhs.map_name), dll_handle(NULL)\n\n {}\n\n\n\n dll(std::string const& libname)\n\n : dll_name(libname), map_name(\"\"), dll_handle(NULL)\n\n {\n\n // map_name defaults to dll base name\n\n namespace fs = boost::filesystem;\n\n\n\n#if BOOST_FILESYSTEM_VERSION == 2\n\n fs::path dll_path(dll_name, fs::native);\n\n#else\n", "file_path": "hpx/util/plugin/detail/dll_windows.hpp", "rank": 94, "score": 204156.80251862077 }, { "content": " class function_base\n\n {\n\n HPX_MOVABLE_BUT_NOT_COPYABLE(function_base);\n\n\n\n static VTablePtr const empty_table;\n\n\n\n public:\n\n function_base() BOOST_NOEXCEPT\n\n : vptr(&empty_table)\n\n , object(0)\n\n {\n\n vtable::default_construct<empty_function<Sig> >(&object);\n\n }\n\n\n\n function_base(function_base&& other) BOOST_NOEXCEPT\n\n : vptr(other.vptr)\n\n , object(other.object) // move-construct\n\n {\n\n other.vptr = &empty_table;\n\n vtable::default_construct<empty_function<Sig> >(&other.object);\n", "file_path": "hpx/util/detail/basic_function.hpp", "rank": 95, "score": 204156.80251862077 }, { "content": " ///////////////////////////////////////////////////////////////////////\n\n class tss_storage;\n\n\n\n HPX_EXPORT tss_storage* create_tss_storage();\n\n HPX_EXPORT void delete_tss_storage(tss_storage*& storage);\n\n\n\n HPX_EXPORT std::size_t get_tss_thread_data(tss_storage* storage);\n\n HPX_EXPORT std::size_t set_tss_thread_data(tss_storage* storage, std::size_t);\n\n }\n\n\n\n ///////////////////////////////////////////////////////////////////////////\n\n struct null_thread_id_exception : exception_base {};\n\n}}}\n\n\n\n#endif\n\n\n\n\n", "file_path": "hpx/util/coroutine/detail/tss.hpp", "rank": 96, "score": 204156.80251862077 }, { "content": "#include <hpx/runtime/serialization/map.hpp>\n\n#include <hpx/runtime/serialization/array.hpp>\n\n#include <hpx/traits/is_bitwise_serializable.hpp>\n\n\n\nnamespace hpx { namespace serialization\n\n{\n\n template <typename Archive, typename Sequence>\n\n void serialize_sequence(Archive& ar, Sequence& seq);\n\n\n\n namespace detail\n\n {\n\n /// serialization support for a boost::fusion::sequence\n\n struct serialize_sequence_loop\n\n {\n\n template <typename Archive, typename Element>\n\n static void serialize_element(Archive & ar, Element & e, boost::mpl::false_)\n\n {\n\n ar & e;\n\n }\n\n\n", "file_path": "hpx/runtime/serialization/serialize_sequence.hpp", "rank": 97, "score": 65.9242312869054 } ]
C++
native-library/src/util_classes/accessor_base.hpp
AVSystem/Anjay-java
c8f8c5e0ac5a086db4ca183155eed07374fc6585
#pragma once #include "../jni_wrapper.hpp" #include <optional> #include <string> #include <type_traits> #include <unordered_map> #include "./exception.hpp" #include "./optional_tag.hpp" namespace utils { namespace detail { template <class T> struct dependent_false : std::false_type {}; template <typename T> struct ArrayTypeExtractor : std::false_type {}; template <typename T> struct ArrayTypeExtractor<T[]> { typedef T type; }; } template <typename Peer> class AccessorBase { protected: jni::JNIEnv &env_; jni::Global<jni::Object<Peer>> instance_; jni::Global<jni::Class<Peer>> class_; AccessorBase(AccessorBase &) = delete; AccessorBase &operator=(AccessorBase &) = delete; template <typename JType> auto get_impl(const char *field_name) { return instance_.Get(env_, class_.template GetField<JType>(env_, field_name)); } template <typename JType, typename T> void set_impl(const char *field_name, const T &value) { instance_.Set(env_, class_.template GetField<JType>(env_, field_name), value); } template <typename R, typename... Args> auto get_method_impl(jni::Method<Peer, R(Args...)> &&method) { return [&, method = std::move(method)](const Args &... args) { return instance_.Call(env_, method, args...); }; } template <typename R, typename... Args> static auto get_static_method_impl(jni::JNIEnv &env, jni::Local<jni::Class<Peer>> &&clazz, jni::StaticMethod<Peer, R(Args...)> &&method) { return [&, clazz = std::move(clazz), method = std::move(method)](const Args &... args) { return clazz.Call(env, method, args...); }; } public: explicit AccessorBase(jni::JNIEnv &env, const jni::Object<Peer> &instance) : env_(env), instance_(jni::NewGlobal(env, instance)), class_(jni::NewGlobal(env, jni::Class<Peer>::Find(env))) {} jni::JNIEnv &get_env() { return env_; } template <typename Signature> auto get_method(const char *name) { return get_method_impl( class_.template GetMethod<Signature>(env_, name)); } template <typename Signature> static auto get_static_method(jni::JNIEnv &env, const char *name) { auto clazz = jni::Class<Peer>::Find(env); auto method = clazz.template GetStaticMethod<Signature>(env, name); return get_static_method_impl(env, std::move(clazz), std::move(method)); } template <typename T> auto get_nullable_value(const char *field_name) { if constexpr (std::is_same<T, std::string>::value) { auto str = get_impl<jni::String>(field_name); if (!str.get()) { return std::optional<std::string>{}; } return std::optional<std::string>{ jni::Make<std::string>(env_, str) }; } else if constexpr (std::is_array<T>::value && std::is_arithmetic< typename detail::ArrayTypeExtractor< T>::type>::value) { using Item = typename detail::ArrayTypeExtractor<T>::type; using RetT = typename std::vector<Item>; auto arr = get_impl<jni::Array<Item>>(field_name); auto vec = jni::Make<RetT>(env_, arr); return std::optional<RetT>{ vec }; } else { static_assert(detail::dependent_false<T>::value, "Not implemented"); } } template <typename T> std::optional<T> get_optional_integer(const char *field_name) { auto value = get_optional_value<jni::IntegerTag>(field_name); if (!value) { return {}; } auto unboxed = jni::Unbox(get_env(), *value); T casted = static_cast<T>(unboxed); if (static_cast<int64_t>(casted) != static_cast<int64_t>(unboxed)) { avs_throw(IllegalArgumentException( env_, std::string{ field_name } + " field has value that is out of range " + std::to_string(std::numeric_limits<T>::min()) + " - " + std::to_string(std::numeric_limits<T>::max()))); } return std::make_optional(casted); } template <typename T> std::optional<std::vector<T>> get_optional_array(const char *field_name) { if constexpr (std::is_arithmetic<T>::value) { auto optional_value = get_impl<jni::Object<OptionalTag>>(field_name); auto accessor = AccessorBase<OptionalTag>{ env_, optional_value }; if (!accessor.template get_method<jni::jboolean()>("isPresent")()) { return {}; } auto object = accessor.template get_method<jni::Object<>()>("get")(); jni::Local<jni::Array<T>> casted{ env_, jni::Cast(env_, jni::Class<jni::ArrayTag<T>>::Find(env_), object) .release() }; std::vector<T> result = jni::Make<std::vector<T>>(env_, casted); return { result }; } else { static_assert(detail::dependent_false<T>::value, "Not implemented"); } } template <typename T> auto get_value(const char *field_name) { if constexpr (std::is_same<T, size_t>::value) { auto value = get_impl<jni::jlong>(field_name); if (value < 0) { avs_throw(IllegalArgumentException( env_, "size_t field " + std::string{ field_name } + " has value that is negative")); } else if (static_cast<uint64_t>(value) > std::numeric_limits<size_t>::max()) { avs_throw(IllegalArgumentException( env_, "size_t field " + std::string{ field_name } + " has value that is too large")); } return static_cast<size_t>(value); } else if constexpr (std::is_same<T, uint16_t>::value) { auto value = get_impl<jni::jint>(field_name); if (value < 0) { avs_throw(IllegalArgumentException( env_, "uint16_t field " + std::string{ field_name } + " has value that is negative")); } else if (static_cast<uint32_t>(value) > std::numeric_limits<uint16_t>::max()) { avs_throw(IllegalArgumentException( env_, "uint16_t field " + std::string{ field_name } + " has value that is too large")); } return static_cast<uint16_t>(value); } else if constexpr (std::is_same<T, bool>::value) { return static_cast<bool>(get_impl<jni::jboolean>(field_name)); } else if constexpr (std::is_same<T, char>::value) { auto value = get_impl<jni::jchar>(field_name); if (value > std::numeric_limits<char>::max()) { avs_throw(IllegalArgumentException( env_, "char field " + std::string{ field_name } + " has value that is too large")); } else if (value < std::numeric_limits<char>::min()) { avs_throw(IllegalArgumentException( env_, "char field " + std::string{ field_name } + " has value that is negative")); } return static_cast<char>(value); } else { return get_impl<T>(field_name); } } template <typename T> auto get_optional_value(const char *field_name) { auto optional_value = get_impl<jni::Object<OptionalTag>>(field_name); auto accessor = AccessorBase<OptionalTag>{ env_, optional_value }; if (!accessor.template get_method<jni::jboolean()>("isPresent")()) { return std::optional<jni::Local<jni::Object<T>>>{}; } auto value = accessor.template get_method<jni::Object<>()>("get")(); auto casted = jni::Cast(env_, jni::Class<T>::Find(env_), value); return std::make_optional(std::move(casted)); } template <typename JavaT, typename NativeT> auto get_enum_value(const char *field_name, const std::unordered_map<std::string, NativeT> &mapping) { struct Enum { static constexpr auto Name() { return "java/lang/Enum"; } }; auto field_value = get_value<jni::Object<JavaT>>(field_name); if (!jni::IsInstanceOf(env_, field_value.get(), *jni::Class<Enum>::Find(env_))) { avs_throw(ClassCastException(env_, "Field " + std::string{ field_name } + " is not a Java Enum")); } auto accessor = AccessorBase<JavaT>{ env_, field_value }; auto value = jni::Make<std::string>( env_, accessor.template get_method<jni::String()>("name")()); auto mapped_to = mapping.find(value); if (mapped_to == mapping.end()) { avs_throw(IllegalArgumentException(env_, "Unsupported enum value: " + value)); } return mapped_to->second; } template <typename T> void set_value(const char *field_name, const T &value) { if constexpr (std::is_same<T, int32_t>::value) { set_impl<jni::jint>(field_name, static_cast<jni::jint>(value)); } else if constexpr (std::is_same<T, int64_t>::value) { set_impl<jni::jlong>(field_name, static_cast<jni::jlong>(value)); } else if constexpr (std::is_same<T, bool>::value) { set_impl<jni::jboolean>(field_name, static_cast<jni::jboolean>(value)); } else if constexpr (std::is_same<T, float>::value) { set_impl<jni::jfloat>(field_name, value); } else if constexpr (std::is_same<T, double>::value) { set_impl<jni::jdouble>(field_name, value); } else if constexpr (std::is_same<T, std::string>::value) { set_impl<jni::String>(field_name, jni::Make<jni::String>(env_, value)); } else { set_impl<jni::Object<T>>(field_name, value.into_object(env_)); } } }; }
#pragma once #include "../jni_wrapper.hpp" #include <optional> #include <string> #include <type_traits> #include <unordered_map> #include "./exception.hpp" #include "./optional_tag.hpp" namespace utils { namespace detail { template <class T> struct dependent_false : std::false_type {}; template <typename T> struct ArrayTypeExtractor : std::false_type {}; template <typename T> struct ArrayTypeExtractor<T[]> { typedef T type; }; } template <typename Peer> class AccessorBase { protected: jni::JNIEnv &env_; jni::Global<jni::Object<Peer>> instance_; jni::Global<jni::Class<Peer>> class_; AccessorBase(AccessorBase &) = delete; AccessorBase &operator=(AccessorBase &) = delete; template <typename JType> auto get_impl(const char *field_name) { return instance_.Get(env_, class_.template GetField<JType>(env_, field_name)); } template <typename JType, typename T> void set_impl(const char *field_name, const T &value) { instance_.Set(env_, class_.template GetField<JType>(env_, field_name), value); } template <typename R, typename... Args> auto get_method_impl(jni::Method<Peer, R(Args...)> &&method) { return [&, method = std::move(method)](const Args &... args) { return instance_.Call(env_, method, args...); }; } template <typename R, typename... Args> static auto get_static_method_impl(jni::JNIEnv &env, jni::Local<jni::Class<Peer>> &&clazz, jni::StaticMethod<Peer, R(Args...)> &&method) { return [&, clazz = std::move(clazz), method = std::move(method)](const Args &... args) { return clazz.Call(env, method, args...); }; } public: explicit AccessorBase(jni::JNIEnv &env, const jni::Object<Peer> &instance) : env_(env), instance_(jni::NewGlobal(env, instance)), class_(jni::NewGlobal(env, jni::Class<Peer>::Find(env))) {} jni::JNIEnv &get_env() { return env_; } template <typename Signature> auto get_method(const char *name) { return get_method_impl( class_.template GetMethod<Signature>(env_, name)); } template <typename Signature> static auto get_static_method(jni::JNIEnv &env, const char *name) { auto clazz = jni::Class<Peer>::Find(env); auto method = clazz.template GetStaticMethod<Signature>(env, name); return get_static_method_impl(env, std::move(clazz), std::move(method)); } template <typename T> auto get_nullable_value(const char *field_name) { if constexpr (std::is_same<T, std::string>::value) { auto str = get_impl<jni::String>(field_name); if (!str.get()) { return std::optional<std::string>{}; } return std::optional<std::string>{ jni::Make<std::string>(env_, str) }; } else if constexpr (std::is_array<T>::value && std::is_arithmetic< typename detail::ArrayTypeExtractor< T>::type>::value) { using Item = typename detail::ArrayTypeExtractor<T>::type; using RetT = typename std::vector<Item>; auto arr = get_impl<jni::Array<Item>>(field_name); auto vec = jni::Make<RetT>(env_, arr); return std::optional<RetT>{ vec }; } else { static_assert(detail::dependent_false<T>::value, "Not implemented"); } } template <typename T> std::optional<T> get_optional_integer(const char *field_name) { auto value = get_optional_value<jni::IntegerTag>(field_name); if (!value) { return {}; } auto unboxed = jni::Unbox(get_env(), *value); T casted = static_cast<T>(unboxed); if (static_cast<int64_t>(casted) != static_cast<int64_t>(unboxed)) { avs_throw(IllegalArgumentException( env_, std::string{ field_name } + " field has value that is out of range " + std::to_string(std::numeric_limits<T>::min()) + " - " + std::to_string(std::numeric_limits<T>::max()))); } return std::make_optional(casted); } template <typename T>
template <typename T> auto get_value(const char *field_name) { if constexpr (std::is_same<T, size_t>::value) { auto value = get_impl<jni::jlong>(field_name); if (value < 0) { avs_throw(IllegalArgumentException( env_, "size_t field " + std::string{ field_name } + " has value that is negative")); } else if (static_cast<uint64_t>(value) > std::numeric_limits<size_t>::max()) { avs_throw(IllegalArgumentException( env_, "size_t field " + std::string{ field_name } + " has value that is too large")); } return static_cast<size_t>(value); } else if constexpr (std::is_same<T, uint16_t>::value) { auto value = get_impl<jni::jint>(field_name); if (value < 0) { avs_throw(IllegalArgumentException( env_, "uint16_t field " + std::string{ field_name } + " has value that is negative")); } else if (static_cast<uint32_t>(value) > std::numeric_limits<uint16_t>::max()) { avs_throw(IllegalArgumentException( env_, "uint16_t field " + std::string{ field_name } + " has value that is too large")); } return static_cast<uint16_t>(value); } else if constexpr (std::is_same<T, bool>::value) { return static_cast<bool>(get_impl<jni::jboolean>(field_name)); } else if constexpr (std::is_same<T, char>::value) { auto value = get_impl<jni::jchar>(field_name); if (value > std::numeric_limits<char>::max()) { avs_throw(IllegalArgumentException( env_, "char field " + std::string{ field_name } + " has value that is too large")); } else if (value < std::numeric_limits<char>::min()) { avs_throw(IllegalArgumentException( env_, "char field " + std::string{ field_name } + " has value that is negative")); } return static_cast<char>(value); } else { return get_impl<T>(field_name); } } template <typename T> auto get_optional_value(const char *field_name) { auto optional_value = get_impl<jni::Object<OptionalTag>>(field_name); auto accessor = AccessorBase<OptionalTag>{ env_, optional_value }; if (!accessor.template get_method<jni::jboolean()>("isPresent")()) { return std::optional<jni::Local<jni::Object<T>>>{}; } auto value = accessor.template get_method<jni::Object<>()>("get")(); auto casted = jni::Cast(env_, jni::Class<T>::Find(env_), value); return std::make_optional(std::move(casted)); } template <typename JavaT, typename NativeT> auto get_enum_value(const char *field_name, const std::unordered_map<std::string, NativeT> &mapping) { struct Enum { static constexpr auto Name() { return "java/lang/Enum"; } }; auto field_value = get_value<jni::Object<JavaT>>(field_name); if (!jni::IsInstanceOf(env_, field_value.get(), *jni::Class<Enum>::Find(env_))) { avs_throw(ClassCastException(env_, "Field " + std::string{ field_name } + " is not a Java Enum")); } auto accessor = AccessorBase<JavaT>{ env_, field_value }; auto value = jni::Make<std::string>( env_, accessor.template get_method<jni::String()>("name")()); auto mapped_to = mapping.find(value); if (mapped_to == mapping.end()) { avs_throw(IllegalArgumentException(env_, "Unsupported enum value: " + value)); } return mapped_to->second; } template <typename T> void set_value(const char *field_name, const T &value) { if constexpr (std::is_same<T, int32_t>::value) { set_impl<jni::jint>(field_name, static_cast<jni::jint>(value)); } else if constexpr (std::is_same<T, int64_t>::value) { set_impl<jni::jlong>(field_name, static_cast<jni::jlong>(value)); } else if constexpr (std::is_same<T, bool>::value) { set_impl<jni::jboolean>(field_name, static_cast<jni::jboolean>(value)); } else if constexpr (std::is_same<T, float>::value) { set_impl<jni::jfloat>(field_name, value); } else if constexpr (std::is_same<T, double>::value) { set_impl<jni::jdouble>(field_name, value); } else if constexpr (std::is_same<T, std::string>::value) { set_impl<jni::String>(field_name, jni::Make<jni::String>(env_, value)); } else { set_impl<jni::Object<T>>(field_name, value.into_object(env_)); } } }; }
std::optional<std::vector<T>> get_optional_array(const char *field_name) { if constexpr (std::is_arithmetic<T>::value) { auto optional_value = get_impl<jni::Object<OptionalTag>>(field_name); auto accessor = AccessorBase<OptionalTag>{ env_, optional_value }; if (!accessor.template get_method<jni::jboolean()>("isPresent")()) { return {}; } auto object = accessor.template get_method<jni::Object<>()>("get")(); jni::Local<jni::Array<T>> casted{ env_, jni::Cast(env_, jni::Class<jni::ArrayTag<T>>::Find(env_), object) .release() }; std::vector<T> result = jni::Make<std::vector<T>>(env_, casted); return { result }; } else { static_assert(detail::dependent_false<T>::value, "Not implemented"); } }
function_block-full_function
[ { "content": "struct ClassCastException : public jni::PendingJavaException {\n\n ClassCastException(JNIEnv &env, const char *str)\n\n : jni::PendingJavaException() {\n\n env.ThrowNew(env.FindClass(\"java/lang/ClassCastException\"), str);\n\n }\n\n\n\n ClassCastException(JNIEnv &env, const std::string &str)\n\n : ClassCastException(env, str.c_str()) {}\n\n};\n\n\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 0, "score": 279253.30307684845 }, { "content": "struct OptionalTag {\n\n static constexpr auto Name() {\n\n return \"java/util/Optional\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/optional_tag.hpp", "rank": 3, "score": 236557.12441764842 }, { "content": "struct DownloadResultDetails {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayDownload$ResultDetails\";\n\n }\n\n\n\n static jni::Local<jni::Object<DownloadResultDetails>>\n\n into_java(jni::JNIEnv &env, avs_error_t details) {\n\n if (details.category != AVS_ERRNO_CATEGORY) {\n\n return from_string(env, \"UNKNOWN\");\n\n }\n\n\n\n static std::unordered_map<uint16_t, std::string> MAPPING{\n\n { AVS_EADDRNOTAVAIL, \"DNS_RESOLUTION_FAILED\" },\n\n { AVS_ECONNABORTED, \"REMOTE_RESOURCE_NO_LONGER_VALID\" },\n\n { AVS_ECONNREFUSED, \"SERVER_RESPONDED_WITH_RESET\" },\n\n { AVS_ECONNRESET, \"CONNECTION_LOST\" },\n\n { AVS_EINVAL, \"FAILED_TO_PARSE_RESPONSE\" },\n\n { AVS_EIO, \"INTERNAL_ERROR\" },\n\n { AVS_EMSGSIZE, \"MESSAGE_TOO_LARGE\" },\n\n { AVS_ENOMEM, \"OUT_OF_MEMORY\" },\n", "file_path": "native-library/src/util_classes/download_result_details.hpp", "rank": 4, "score": 232304.10491323943 }, { "content": "struct ObjectInstanceAttrs {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayAttributes$ObjectInstanceAttrs\";\n\n }\n\n\n\n static anjay_dm_oi_attributes_t\n\n into_native(jni::JNIEnv &env,\n\n const jni::Object<ObjectInstanceAttrs> &attrs) {\n\n anjay_dm_oi_attributes_t native_attrs;\n\n auto accessor = AccessorBase<ObjectInstanceAttrs>{ env, attrs };\n\n\n\n native_attrs.min_period = accessor.get_value<int>(\"minPeriod\");\n\n native_attrs.max_period = accessor.get_value<int>(\"maxPeriod\");\n\n native_attrs.min_eval_period = accessor.get_value<int>(\"minEvalPeriod\");\n\n native_attrs.max_eval_period = accessor.get_value<int>(\"maxEvalPeriod\");\n\n\n\n return native_attrs;\n\n }\n\n\n\n static jni::Local<jni::Object<ObjectInstanceAttrs>>\n\n into_java(jni::JNIEnv &env, const anjay_dm_oi_attributes_t *attrs) {\n\n auto clazz = jni::Class<ObjectInstanceAttrs>::Find(env);\n\n auto ctor = clazz.GetConstructor<jni::jint, jni::jint, jni::jint,\n\n jni::jint>(env);\n\n return clazz.New(env, ctor, attrs->min_period, attrs->max_period,\n\n attrs->min_eval_period, attrs->max_eval_period);\n\n }\n\n};\n\n\n", "file_path": "native-library/src/util_classes/attributes.hpp", "rank": 5, "score": 226171.47461423342 }, { "content": "struct CertificateType;\n\n\n\ntemplate <>\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 6, "score": 224353.9493683367 }, { "content": "struct AnjayException : public jni::PendingJavaException {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayException\";\n\n }\n\n\n\n AnjayException(JNIEnv &env, jni::jint error_code, const std::string &str) {\n\n auto java_exception = utils::construct<AnjayException>(\n\n env, error_code, jni::Make<jni::String>(env, str));\n\n env.Throw(reinterpret_cast<::jthrowable>(java_exception.get()));\n\n }\n\n};\n\n\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 7, "score": 224272.26018027271 }, { "content": "struct ObjectInstanceAttrsByReference {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/\"\n\n \"NativeAnjayObject$ObjectInstanceAttrsByReference\";\n\n }\n\n\n\n static jni::Local<jni::Object<ObjectInstanceAttrsByReference>>\n\n New(jni::JNIEnv &env) {\n\n auto clazz = jni::Class<ObjectInstanceAttrsByReference>::Find(env);\n\n auto ctor = clazz.GetConstructor(env);\n\n return clazz.New(env, ctor);\n\n }\n\n\n\n static jni::Local<jni::Object<ObjectInstanceAttrs>>\n\n get_value(jni::JNIEnv &env,\n\n const jni::Object<ObjectInstanceAttrsByReference> &instance) {\n\n auto accessor =\n\n AccessorBase<ObjectInstanceAttrsByReference>{ env, instance };\n\n return accessor.get_value<jni::Object<ObjectInstanceAttrs>>(\"value\");\n\n }\n\n};\n\n\n", "file_path": "native-library/src/util_classes/attributes.hpp", "rank": 8, "score": 223855.35323618428 }, { "content": "struct IllegalStateException : public jni::PendingJavaException {\n\n IllegalStateException(JNIEnv &env, const char *str)\n\n : jni::PendingJavaException() {\n\n env.ThrowNew(env.FindClass(\"java/lang/IllegalStateException\"), str);\n\n }\n\n\n\n IllegalStateException(JNIEnv &env, const std::string &str)\n\n : IllegalStateException(env, str.c_str()) {}\n\n};\n\n\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 9, "score": 222157.13443253236 }, { "content": "struct UnsupportedOperationException : public jni::PendingJavaException {\n\n UnsupportedOperationException(JNIEnv &env, const char *str)\n\n : jni::PendingJavaException() {\n\n env.ThrowNew(env.FindClass(\"java/lang/UnsupportedOperationException\"),\n\n str);\n\n }\n\n\n\n UnsupportedOperationException(JNIEnv &env, const std::string &str)\n\n : UnsupportedOperationException(env, str.c_str()) {}\n\n};\n\n\n\n#define avs_throw(e) \\\n\n throw(::utils::detail::wrap_exception( \\\n\n __FILE__, __LINE__, __PRETTY_FUNCTION__, (e)))\n\n\n\n#define avs_log_and_clear_exception(level) \\\n\n ::utils::detail::avs_log_and_clear_exception_impl( \\\n\n AVS_LOG_##level, __FILE__, __LINE__)\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 10, "score": 222157.13443253236 }, { "content": "struct IllegalArgumentException : public jni::PendingJavaException {\n\n IllegalArgumentException(JNIEnv &env, const char *str)\n\n : jni::PendingJavaException() {\n\n env.ThrowNew(env.FindClass(\"java/lang/IllegalArgumentException\"), str);\n\n }\n\n\n\n IllegalArgumentException(JNIEnv &env, const std::string &str)\n\n : IllegalArgumentException(env, str.c_str()) {}\n\n};\n\n\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 11, "score": 222157.13443253236 }, { "content": " class Accessor : public utils::AccessorBase<Instance> {\n\n public:\n\n explicit Accessor(jni::JNIEnv &env,\n\n const jni::Object<Instance> &instance)\n\n : AccessorBase(env, instance) {}\n\n\n\n anjay_ssid_t get_ssid() {\n\n return get_value<uint16_t>(\"ssid\");\n\n }\n\n\n\n int32_t get_lifetime() {\n\n return get_value<int32_t>(\"lifetime\");\n\n }\n\n\n\n std::optional<int32_t> get_default_min_period() {\n\n return get_optional_integer<int32_t>(\"defaultMinPeriod\");\n\n }\n\n\n\n std::optional<int32_t> get_default_max_period() {\n\n return get_optional_integer<int32_t>(\"defaultMaxPeriod\");\n", "file_path": "native-library/src/native_server_object.hpp", "rank": 12, "score": 221865.49924624848 }, { "content": " class Accessor : public utils::AccessorBase<Instance> {\n\n auto to_optional_std_string(\n\n const std::optional<jni::Local<jni::String>> &value) {\n\n if (!value) {\n\n return std::optional<std::string>{};\n\n }\n\n return std::make_optional(\n\n jni::Make<std::string>(get_env(), *value));\n\n }\n\n\n\n public:\n\n explicit Accessor(jni::JNIEnv &env,\n\n const jni::Object<Instance> &instance)\n\n : AccessorBase(env, instance) {}\n\n\n\n anjay_ssid_t get_ssid() {\n\n return get_value<uint16_t>(\"ssid\");\n\n }\n\n\n\n std::optional<std::string> get_server_uri() {\n", "file_path": "native-library/src/native_security_object.hpp", "rank": 13, "score": 221865.49924624848 }, { "content": "struct CertificateType<avs_crypto_certificate_chain_info_t> {\n\n typedef Certificate Type;\n\n\n\n static auto\n\n array_to_info(const avs_crypto_certificate_chain_info_t entries[],\n\n size_t size) {\n\n return avs_crypto_certificate_chain_info_from_array(entries, size);\n\n }\n\n\n\n static auto from_buffer(jni::jbyte data[], size_t size) {\n\n return avs_crypto_certificate_chain_info_from_buffer(data, size);\n\n }\n\n};\n\n\n\ntemplate <>\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 15, "score": 207992.01672002184 }, { "content": "struct CertificateType<avs_crypto_cert_revocation_list_info_t> {\n\n typedef CertificateRevocationList Type;\n\n\n\n static auto\n\n array_to_info(const avs_crypto_cert_revocation_list_info_t entries[],\n\n size_t size) {\n\n return avs_crypto_cert_revocation_list_info_from_array(entries, size);\n\n }\n\n\n\n static auto from_buffer(jni::jbyte data[], size_t size) {\n\n return avs_crypto_cert_revocation_list_info_from_buffer(data, size);\n\n }\n\n};\n\n\n\n} // namespace detail\n\n\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 16, "score": 205969.84662242988 }, { "content": "class ExceptionWrapper : public T, public OriginAwareException {\n\npublic:\n\n ExceptionWrapper(const char *file,\n\n unsigned line,\n\n const char *function,\n\n T &&e)\n\n : T(std::move(e)), OriginAwareException(file, line, function) {}\n\n};\n\n\n\ntemplate <typename T>\n\nExceptionWrapper<T>\n\nwrap_exception(const char *file, unsigned line, const char *function, T &&e) {\n\n return ExceptionWrapper<T>(file, line, function, std::forward<T>(e));\n\n}\n\n\n\nvoid avs_log_and_clear_exception_impl(avs_log_level_t level,\n\n const char *file,\n\n unsigned line);\n\n\n\n} // namespace detail\n\n\n\n} // namespace utils\n\n\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 17, "score": 202761.164350105 }, { "content": "class Optional {\n\n jni::JNIEnv &env_;\n\n jni::Global<jni::Object<Optional>> self_;\n\n\n\npublic:\n\n static constexpr auto Name() {\n\n return OptionalTag::Name();\n\n }\n\n\n\n operator bool() const {\n\n return is_present();\n\n }\n\n\n\n Optional(jni::JNIEnv &env, const jni::Local<jni::Object<Optional>> &value)\n\n : env_(env), self_(jni::NewGlobal(env, value)) {}\n\n\n\n jni::Local<jni::Object<Optional>> into_java() {\n\n return jni::NewLocal(env_, self_);\n\n }\n\n\n", "file_path": "native-library/src/util_classes/optional.hpp", "rank": 18, "score": 200020.00468899892 }, { "content": "struct NativeUtils {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeUtils\";\n\n }\n\n\n\n struct ReadyState {\n\n bool read;\n\n bool write;\n\n bool accept;\n\n bool connect;\n\n\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeUtils$ReadyState\";\n\n }\n\n\n\n ReadyState()\n\n : read(false), write(false), accept(false), connect(false) {}\n\n\n\n ReadyState(jni::JNIEnv &env, const jni::Object<ReadyState> &state)\n\n : ReadyState() {\n", "file_path": "native-library/src/util_classes/native_utils.hpp", "rank": 19, "score": 191032.4036762672 }, { "content": " class Accessor : public AccessorBase<Configuration> {\n\n public:\n\n explicit Accessor(jni::JNIEnv &env,\n\n const jni::Object<utils::Configuration> &instance)\n\n : AccessorBase(env, instance) {}\n\n\n\n std::optional<std::string> get_endpoint_name() {\n\n return get_nullable_value<std::string>(\"endpointName\");\n\n }\n\n\n\n uint16_t get_udp_listen_port() {\n\n return get_value<uint16_t>(\"udpListenPort\");\n\n }\n\n\n\n size_t get_in_buffer_size() {\n\n return get_value<size_t>(\"inBufferSize\");\n\n }\n\n\n\n size_t get_out_buffer_size() {\n\n return get_value<size_t>(\"outBufferSize\");\n", "file_path": "native-library/src/util_classes/configuration.hpp", "rank": 20, "score": 190628.02944464833 }, { "content": " class Accessor : public AccessorBase<DownloadConfiguration> {\n\n public:\n\n explicit Accessor(\n\n jni::JNIEnv &env,\n\n const jni::Object<utils::DownloadConfiguration> &config)\n\n : AccessorBase(env, config) {}\n\n\n\n std::optional<std::string> get_url() {\n\n return get_nullable_value<std::string>(\"url\");\n\n }\n\n\n\n int get_start_offset() {\n\n return get_value<int>(\"startOffset\");\n\n }\n\n\n\n std::optional<Etag> get_etag() {\n\n auto value = get_optional_array<jni::jbyte>(\"etag\");\n\n if (value) {\n\n return std::make_optional<Etag>(env_, *value);\n\n } else {\n", "file_path": "native-library/src/util_classes/download_configuration.hpp", "rank": 21, "score": 187633.0666360272 }, { "content": " class Accessor : public AccessorBase<NativeAnjayObject> {\n\n public:\n\n explicit Accessor(jni::JNIEnv &env,\n\n const jni::Object<NativeAnjayObject> &instance)\n\n : AccessorBase(env, instance) {}\n\n\n\n anjay_oid_t get_oid() {\n\n return get_method<jni::jint()>(\"oid\")();\n\n }\n\n\n\n std::string get_version() {\n\n return jni::Make<std::string>(env_, get_method<jni::String()>(\n\n \"version\")());\n\n }\n\n\n\n template <typename Func>\n\n int for_each_instance(Func &&func) {\n\n auto array_by_ref = IntegerArrayByReference::New(env_);\n\n int result =\n\n get_method<jni::jint(jni::Object<IntegerArrayByReference>)>(\n", "file_path": "native-library/src/util_classes/native_anjay_object.hpp", "rank": 22, "score": 184758.44850914204 }, { "content": " class Accessor : public AccessorBase<FirmwareUpdateHandlers> {\n\n public:\n\n explicit Accessor(jni::JNIEnv &env,\n\n const jni::Object<FirmwareUpdateHandlers> &handlers)\n\n : AccessorBase(env, handlers) {}\n\n\n\n int stream_open(const char *package_uri,\n\n const anjay_etag_t *package_etag) {\n\n auto make_etag = [&](const anjay_etag_t *etag) {\n\n if (etag) {\n\n std::vector<jni::jbyte> etag_vec(etag->value,\n\n etag->value + etag->size);\n\n return utils::Optional::of(\n\n env_,\n\n jni::Make<jni::Array<jni::jbyte>>(env_, etag_vec));\n\n } else {\n\n return utils::Optional::empty(env_);\n\n }\n\n };\n\n\n", "file_path": "native-library/src/util_classes/firmware_update_handlers.hpp", "rank": 23, "score": 184758.44850914204 }, { "content": " class Accessor : public AccessorBase<NativeTransportSet> {\n\n public:\n\n explicit Accessor(jni::JNIEnv &env,\n\n const jni::Object<NativeTransportSet> &instance)\n\n : AccessorBase(env, instance) {}\n\n\n\n bool get_udp() {\n\n return get_value<bool>(\"udp\");\n\n }\n\n\n\n bool get_tcp() {\n\n return get_value<bool>(\"tcp\");\n\n }\n\n };\n\n\n\n static anjay_transport_set_t\n\n into_transport_set(jni::JNIEnv &env,\n\n jni::Object<NativeTransportSet> &instance) {\n\n anjay_transport_set_t transports{};\n\n auto accessor = Accessor{ env, instance };\n\n transports.udp = accessor.get_udp();\n\n transports.tcp = accessor.get_tcp();\n\n return transports;\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/native_transport_set.hpp", "rank": 24, "score": 184758.44850914204 }, { "content": " class Accessor : public AccessorBase<FirmwareUpdateInitialState> {\n\n public:\n\n explicit Accessor(\n\n jni::JNIEnv &env,\n\n const jni::Object<FirmwareUpdateInitialState> &initial_state)\n\n : AccessorBase(env, initial_state) {}\n\n\n\n std::optional<std::string> get_persisted_uri() {\n\n return get_nullable_value<std::string>(\"persistedUri\");\n\n }\n\n\n\n int get_resume_offset() {\n\n return get_value<int>(\"resumeOffset\");\n\n }\n\n\n\n std::optional<Etag> get_resume_etag() {\n\n auto value = get_optional_array<jni::jbyte>(\"resumeEtag\");\n\n if (value) {\n\n return std::make_optional<Etag>(env_, *value);\n\n } else {\n", "file_path": "native-library/src/util_classes/firmware_update_initial_state.hpp", "rank": 25, "score": 181996.81795575697 }, { "content": "struct Etag {\n\n anjay_etag_t *data;\n\n\n\n Etag(JNIEnv &env, const std::vector<jni::jbyte> &etag) {\n\n uint8_t size = static_cast<uint8_t>(etag.size());\n\n if (size != etag.size()) {\n\n avs_throw(IllegalArgumentException(env, \"etag too long\"));\n\n }\n\n data = anjay_etag_new(size);\n\n if (!data) {\n\n // Out of memory is a pretty serious condition,\n\n // let this degenerate to java.lang.Error\n\n avs_throw(std::runtime_error(\"out of memory\"));\n\n }\n\n memcpy(data->value, etag.data(), size);\n\n }\n\n\n\n ~Etag() {\n\n avs_free(data);\n\n }\n\n\n\n Etag(const Etag &) = delete;\n\n Etag &operator=(const Etag &) = delete;\n\n\n\n Etag(Etag &&) = delete;\n\n Etag &operator=(Etag &&) = delete;\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/etag.hpp", "rank": 26, "score": 180815.4044988451 }, { "content": "struct Throwable {\n\n static constexpr auto Name() {\n\n return \"java/lang/Throwable\";\n\n }\n\n};\n\n\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 27, "score": 180815.4044988451 }, { "content": "struct Objlnk {\n\n anjay_oid_t oid;\n\n anjay_iid_t iid;\n\n\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/Anjay$Objlnk\";\n\n }\n\n\n\n jni::Local<jni::Object<Objlnk>> into_object(jni::JNIEnv &env) const {\n\n auto clazz = jni::Class<Objlnk>::Find(env);\n\n auto ctor = clazz.GetConstructor<jni::jint, jni::jint>(env);\n\n return clazz.New(env, ctor, oid, iid);\n\n }\n\n\n\n static Objlnk into_native(jni::JNIEnv &env,\n\n const jni::Object<Objlnk> &instance) {\n\n auto accessor = AccessorBase<Objlnk>{ env, instance };\n\n auto oid = accessor.get_value<int>(\"oid\");\n\n if (oid < 0 || oid > std::numeric_limits<anjay_oid_t>::max()) {\n\n avs_throw(IllegalArgumentException(env, \"oid out of range\"));\n", "file_path": "native-library/src/util_classes/objlnk.hpp", "rank": 28, "score": 180815.4044988451 }, { "content": "struct Transport {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/Anjay$Transport\";\n\n }\n\n\n\n static jni::Local<jni::Object<Transport>>\n\n New(jni::JNIEnv &env, anjay_socket_transport_t transport) {\n\n auto native_transport_class = jni::Class<Transport>::Find(env);\n\n auto get_enum_instance = [&](const char *name) {\n\n return native_transport_class.Get(\n\n env,\n\n native_transport_class\n\n .GetStaticField<jni::Object<Transport>>(env, name));\n\n };\n\n switch (transport) {\n\n case ANJAY_SOCKET_TRANSPORT_UDP:\n\n return get_enum_instance(\"UDP\");\n\n case ANJAY_SOCKET_TRANSPORT_TCP:\n\n return get_enum_instance(\"TCP\");\n\n default:\n\n avs_throw(IllegalArgumentException(env, \"Unsupported transport\"));\n\n }\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/transport.hpp", "rank": 29, "score": 180815.4044988451 }, { "content": "struct Duration {\n\n static constexpr auto Name() {\n\n return \"java/time/Duration\";\n\n }\n\n\n\n static avs_time_duration_t\n\n into_native(jni::JNIEnv &env, const jni::Object<Duration> &instance) {\n\n auto accessor = AccessorBase<Duration>{ env, instance };\n\n avs_time_duration_t result{};\n\n result.seconds = accessor.get_method<jni::jlong()>(\"getSeconds\")();\n\n result.nanoseconds = accessor.get_method<jni::jint()>(\"getNano\")();\n\n return result;\n\n }\n\n\n\n static jni::Local<jni::Object<Duration>>\n\n into_java(jni::JNIEnv &env, avs_time_duration_t duration) {\n\n if (!avs_time_duration_valid(duration)) {\n\n avs_throw(IllegalArgumentException(env, \"duration is invalid\"));\n\n }\n\n return AccessorBase<Duration>::get_static_method<jni::Object<Duration>(\n\n jni::jlong, jni::jlong)>(env, \"ofSeconds\")(\n\n duration.seconds, duration.nanoseconds);\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/duration.hpp", "rank": 30, "score": 180815.4044988451 }, { "content": "struct Map {\n\n static constexpr auto Name() {\n\n return \"java/util/Map\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/map.hpp", "rank": 31, "score": 180815.4044988451 }, { "content": "struct Logger {\n\n static constexpr auto Name() {\n\n return \"java/util/logging/Logger\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/logger.hpp", "rank": 32, "score": 180815.4044988451 }, { "content": "struct Configuration {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/Anjay$Configuration\";\n\n }\n\n\n", "file_path": "native-library/src/util_classes/configuration.hpp", "rank": 33, "score": 180815.4044988451 }, { "content": "struct Level {\n\n static constexpr auto Name() {\n\n return \"java/util/logging/Level\";\n\n }\n\n\n\n static jni::Local<jni::Object<Level>> from_native(jni::JNIEnv &env,\n\n avs_log_level_t level) {\n\n auto clazz = jni::Class<Level>::Find(env);\n\n auto get_enum_instance = [&](const std::string &name) {\n\n return clazz.Get(env,\n\n clazz.GetStaticField<jni::Object<Level>>(\n\n env, name.c_str()));\n\n };\n\n static std::unordered_map<avs_log_level_t, std::string> MAPPING{\n\n { AVS_LOG_TRACE, \"FINEST\" }, { AVS_LOG_DEBUG, \"FINE\" },\n\n { AVS_LOG_INFO, \"INFO\" }, { AVS_LOG_WARNING, \"WARNING\" },\n\n { AVS_LOG_ERROR, \"SEVERE\" }, { AVS_LOG_QUIET, \"OFF\" }\n\n };\n\n return get_enum_instance(MAPPING[level]);\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/level.hpp", "rank": 34, "score": 180815.4044988451 }, { "content": "struct ResourceAttrs {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayAttributes$ResourceAttrs\";\n\n }\n\n\n\n static anjay_dm_r_attributes_t\n\n into_native(jni::JNIEnv &env, const jni::Object<ResourceAttrs> &attrs) {\n\n anjay_dm_r_attributes_t native_attrs;\n\n auto accessor = AccessorBase<ResourceAttrs>{ env, attrs };\n\n\n\n native_attrs.common = ObjectInstanceAttrs::into_native(\n\n env,\n\n accessor.get_value<jni::Object<ObjectInstanceAttrs>>(\"common\"));\n\n native_attrs.greater_than = accessor.get_value<double>(\"greaterThan\");\n\n native_attrs.less_than = accessor.get_value<double>(\"lessThan\");\n\n native_attrs.step = accessor.get_value<double>(\"step\");\n\n\n\n return native_attrs;\n\n }\n\n\n", "file_path": "native-library/src/util_classes/attributes.hpp", "rank": 35, "score": 178994.08621747344 }, { "content": "struct SelectableChannel {\n\n static constexpr auto Name() {\n\n return \"java/nio/channels/SelectableChannel\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/selectable_channel.hpp", "rank": 36, "score": 177216.49544066406 }, { "content": "struct HashMap {\n\n static constexpr auto Name() {\n\n return \"java/util/HashMap\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/hash_map.hpp", "rank": 37, "score": 177216.49544066406 }, { "content": "struct StackTraceElement {\n\n static constexpr auto Name() {\n\n return \"java/lang/StackTraceElement\";\n\n }\n\n};\n\n\n\ntemplate <typename>\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 38, "score": 177216.49544066406 }, { "content": "struct ResourceKind {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayObject$ResourceKind\";\n\n }\n\n\n\n static anjay_dm_resource_kind_t\n\n into_native(jni::JNIEnv &env, const jni::Object<ResourceKind> &instance) {\n\n static std::unordered_map<std::string, anjay_dm_resource_kind_t>\n\n MAPPING{\n\n { \"R\", ANJAY_DM_RES_R }, { \"W\", ANJAY_DM_RES_W },\n\n { \"RW\", ANJAY_DM_RES_RW }, { \"RM\", ANJAY_DM_RES_RM },\n\n { \"WM\", ANJAY_DM_RES_WM }, { \"RWM\", ANJAY_DM_RES_RWM },\n\n { \"E\", ANJAY_DM_RES_E }, { \"BS_RW\", ANJAY_DM_RES_BS_RW }\n\n };\n\n auto clazz = jni::Class<ResourceKind>::Find(env);\n\n auto value = jni::Make<std::string>(\n\n env, instance.Call(\n\n env, clazz.GetMethod<jni::String()>(env, \"name\")));\n\n auto mapped_to = MAPPING.find(value);\n\n if (mapped_to == MAPPING.end()) {\n\n avs_throw(IllegalArgumentException(env, \"Unsupported enum value: \"\n\n + value));\n\n }\n\n return mapped_to->second;\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/resource_kind.hpp", "rank": 39, "score": 177216.49544066406 }, { "content": "struct NativePointer {\n\n static constexpr auto Name() {\n\n return WrapperType::Name();\n\n }\n\n\n\n static NativeType *into_native(jni::JNIEnv &env,\n\n jni::Object<WrapperType> &instance) {\n\n auto accessor = AccessorBase<WrapperType>{ env, instance };\n\n return reinterpret_cast<NativeType *>(\n\n accessor.template get_value<jni::jlong>(\"pointer\"));\n\n }\n\n\n\n static jni::Local<jni::Object<WrapperType>>\n\n into_object(jni::JNIEnv &env, NativeType *pointer) {\n\n auto clazz = jni::Class<WrapperType>::Find(env);\n\n auto ctor = clazz.template GetConstructor<jni::jlong>(env);\n\n return clazz.New(env, ctor, reinterpret_cast<jni::jlong>(pointer));\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/native_pointer.hpp", "rank": 40, "score": 177216.49544066406 }, { "content": "struct ResourceAttrsByReference {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/\"\n\n \"NativeAnjayObject$ResourceAttrsByReference\";\n\n }\n\n\n\n static jni::Local<jni::Object<ResourceAttrsByReference>>\n\n New(jni::JNIEnv &env) {\n\n auto clazz = jni::Class<ResourceAttrsByReference>::Find(env);\n\n auto ctor = clazz.GetConstructor(env);\n\n return clazz.New(env, ctor);\n\n }\n\n\n\n static jni::Local<jni::Object<ResourceAttrs>>\n\n get_value(jni::JNIEnv &env,\n\n const jni::Object<ResourceAttrsByReference> &instance) {\n\n auto accessor = AccessorBase<ResourceAttrsByReference>{ env, instance };\n\n return accessor.get_value<jni::Object<ResourceAttrs>>(\"value\");\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/attributes.hpp", "rank": 41, "score": 177216.49544066406 }, { "content": "struct Certificate {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjaySecurityInfoCert$Certificate\";\n\n }\n\n};\n\n\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 42, "score": 177216.49544066406 }, { "content": "struct DownloadResult {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayDownload$Result\";\n\n }\n\n\n\n static jni::Local<jni::Object<DownloadResult>>\n\n into_java(jni::JNIEnv &env, anjay_download_result_t result) {\n\n auto clazz = jni::Class<DownloadResult>::Find(env);\n\n auto get_enum_instance = [&](const std::string &name) {\n\n return clazz.Get(env,\n\n clazz.GetStaticField<jni::Object<DownloadResult>>(\n\n env, name.c_str()));\n\n };\n\n static std::unordered_map<anjay_download_result_t, std::string> MAPPING{\n\n { ANJAY_DOWNLOAD_FINISHED, \"FINISHED\" },\n\n { ANJAY_DOWNLOAD_ERR_FAILED, \"FAILED\" },\n\n { ANJAY_DOWNLOAD_ERR_INVALID_RESPONSE, \"INVALID_RESPONSE\" },\n\n { ANJAY_DOWNLOAD_ERR_EXPIRED, \"EXPIRED\" },\n\n { ANJAY_DOWNLOAD_ERR_ABORTED, \"ABORTED\" }\n\n };\n\n return get_enum_instance(MAPPING[result]);\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/download_result.hpp", "rank": 43, "score": 177216.49544066406 }, { "content": "struct DtlsVersion {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/Anjay$DtlsVersion\";\n\n }\n\n\n\n static avs_net_ssl_version_t\n\n into_native(jni::JNIEnv &env, const jni::Object<DtlsVersion> &result) {\n\n static std::unordered_map<std::string, avs_net_ssl_version_t> MAPPING{\n\n { \"DEFAULT\", AVS_NET_SSL_VERSION_DEFAULT },\n\n { \"SSLv2_OR_3\", AVS_NET_SSL_VERSION_SSLv2_OR_3 },\n\n { \"SSLv2\", AVS_NET_SSL_VERSION_SSLv2 },\n\n { \"SSLv3\", AVS_NET_SSL_VERSION_SSLv3 },\n\n { \"TLSv1\", AVS_NET_SSL_VERSION_TLSv1 },\n\n { \"TLSv1_1\", AVS_NET_SSL_VERSION_TLSv1_1 },\n\n { \"TLSv1_2\", AVS_NET_SSL_VERSION_TLSv1_2 }\n\n };\n\n auto clazz = jni::Class<DtlsVersion>::Find(env);\n\n auto value = jni::Make<std::string>(\n\n env,\n\n result.Call(env, clazz.GetMethod<jni::String()>(env, \"name\")));\n", "file_path": "native-library/src/util_classes/dtls_version.hpp", "rank": 44, "score": 177216.49544066406 }, { "content": "struct ResourceDef {\n\n const anjay_rid_t rid;\n\n const anjay_dm_resource_kind_t kind;\n\n const bool present;\n\n\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayObject$ResourceDef\";\n\n }\n\n\n\n static ResourceDef into_native(jni::JNIEnv &env,\n\n const jni::Object<ResourceDef> &instance) {\n\n auto accessor = AccessorBase<ResourceDef>{ env, instance };\n\n return ResourceDef{\n\n static_cast<anjay_rid_t>(accessor.get_value<int>(\"rid\")),\n\n ResourceKind::into_native(\n\n env,\n\n accessor.get_value<jni::Object<utils::ResourceKind>>(\n\n \"kind\")),\n\n accessor.get_value<bool>(\"present\")\n\n };\n\n }\n\n\n\nprivate:\n\n ResourceDef(anjay_rid_t rid, anjay_dm_resource_kind_t kind, bool present)\n\n : rid(rid), kind(kind), present(present) {}\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/resource_def.hpp", "rank": 45, "score": 177216.49544066406 }, { "content": "struct DownloadHandlers {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayDownloadHandlers\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/download_handlers.hpp", "rank": 46, "score": 177216.49544066406 }, { "content": "struct DownloadConfiguration {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayDownload$Configuration\";\n\n }\n\n\n", "file_path": "native-library/src/util_classes/download_configuration.hpp", "rank": 47, "score": 177216.49544066406 }, { "content": "struct FirmwareUpdateResult {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayFirmwareUpdate$Result\";\n\n }\n\n\n\n static anjay_fw_update_result_t\n\n into_native(jni::JNIEnv &env,\n\n const jni::Object<FirmwareUpdateResult> &result) {\n\n static std::unordered_map<std::string, anjay_fw_update_result_t>\n\n MAPPING{ { \"INITIAL\", ANJAY_FW_UPDATE_RESULT_INITIAL },\n\n { \"SUCCESS\", ANJAY_FW_UPDATE_RESULT_SUCCESS },\n\n { \"NOT_ENOUGH_SPACE\",\n\n ANJAY_FW_UPDATE_RESULT_NOT_ENOUGH_SPACE },\n\n { \"OUT_OF_MEMORY\",\n\n ANJAY_FW_UPDATE_RESULT_OUT_OF_MEMORY },\n\n { \"CONNECTION_LOST\",\n\n ANJAY_FW_UPDATE_RESULT_CONNECTION_LOST },\n\n { \"INTEGRITY_FAILURE\",\n\n ANJAY_FW_UPDATE_RESULT_INTEGRITY_FAILURE },\n\n { \"UNSUPPORTED_PACKAGE_TYPE\",\n", "file_path": "native-library/src/util_classes/firmware_update_result.hpp", "rank": 48, "score": 173786.34504079365 }, { "content": "struct CertificateRevocationList {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/\"\n\n \"AnjaySecurityInfoCert$CertificateRevocationList\";\n\n }\n\n};\n\n\n\ntemplate <typename>\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 49, "score": 173786.3450407937 }, { "content": "struct NativeSocketEntry {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeSocketEntry\";\n\n }\n\n\n\n static jni::Local<jni::Object<NativeSocketEntry>>\n\n New(jni::JNIEnv &env, const anjay_socket_entry_t *entry) {\n\n const compat::AvsSocketBase &backend =\n\n *reinterpret_cast<const compat::AvsSocketBase *>(\n\n avs_net_socket_get_system(entry->socket));\n\n\n\n char port[16] = \"0\";\n\n avs_net_socket_get_local_port(entry->socket, port, sizeof(port));\n\n\n\n return construct<NativeSocketEntry>(\n\n env, utils::Transport::New(env, entry->transport),\n\n backend.selectable_channel(),\n\n reinterpret_cast<jni::jlong>(entry->socket),\n\n static_cast<jni::jint>(entry->ssid),\n\n static_cast<jni::jboolean>(entry->queue_mode),\n\n static_cast<jni::jint>(strtol(port, NULL, 10)));\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/native_socket_entry.hpp", "rank": 50, "score": 173786.3450407937 }, { "content": "struct FirmwareUpdateHandlers {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeFirmwareUpdateHandlers\";\n\n }\n\n\n", "file_path": "native-library/src/util_classes/firmware_update_handlers.hpp", "rank": 51, "score": 173786.34504079365 }, { "content": "struct NativeAnjayObject {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeAnjayObject\";\n\n }\n\n\n", "file_path": "native-library/src/util_classes/native_anjay_object.hpp", "rank": 52, "score": 173786.34504079365 }, { "content": "struct NativeTransportSet {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeTransportSet\";\n\n }\n\n\n", "file_path": "native-library/src/util_classes/native_transport_set.hpp", "rank": 53, "score": 173786.34504079365 }, { "content": "struct DtlsHandshakeTimeouts {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/Anjay$DtlsHandshakeTimeouts\";\n\n }\n\n\n\n static avs_net_dtls_handshake_timeouts_t\n\n into_native(jni::JNIEnv &env,\n\n const jni::Object<DtlsHandshakeTimeouts> &instance) {\n\n auto accessor = AccessorBase<DtlsHandshakeTimeouts>{ env, instance };\n\n avs_net_dtls_handshake_timeouts_t result{};\n\n result.min = Duration::into_native(\n\n env, accessor.get_value<jni::Object<Duration>>(\"min\"));\n\n result.max = Duration::into_native(\n\n env, accessor.get_value<jni::Object<Duration>>(\"max\"));\n\n return result;\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/dtls_handshake_timeouts.hpp", "rank": 54, "score": 173786.34504079365 }, { "content": "struct IntegerArrayByReference {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/\"\n\n \"NativeAnjayObject$IntegerArrayByReference\";\n\n }\n\n\n\n static jni::Local<jni::Object<IntegerArrayByReference>>\n\n New(jni::JNIEnv &env) {\n\n auto clazz = jni::Class<IntegerArrayByReference>::Find(env);\n\n auto ctor = clazz.GetConstructor(env);\n\n return clazz.New(env, ctor);\n\n }\n\n\n\n template <typename Func>\n\n static void for_each(jni::JNIEnv &env,\n\n const jni::Object<IntegerArrayByReference> &instance,\n\n Func &&func) {\n\n auto accessor = AccessorBase<IntegerArrayByReference>{ env, instance };\n\n auto value = accessor.get_value<jni::Array<jni::Integer>>(\"value\");\n\n for (jni::jsize i = 0; i < value.Length(env); ++i) {\n\n func(jni::Unbox(env, value.Get(env, i)));\n\n }\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/integer_array_by_reference.hpp", "rank": 55, "score": 173786.3450407937 }, { "content": "struct CoapUdpTxParams {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/Anjay$CoapUdpTxParams\";\n\n }\n\n\n\n static avs_coap_udp_tx_params_t\n\n into_native(jni::JNIEnv &env,\n\n const jni::Object<CoapUdpTxParams> &instance) {\n\n auto accessor = AccessorBase<CoapUdpTxParams>{ env, instance };\n\n avs_coap_udp_tx_params_t result{};\n\n result.ack_timeout = Duration::into_native(\n\n env, accessor.get_value<jni::Object<Duration>>(\"ackTimeout\"));\n\n result.ack_random_factor =\n\n accessor.get_value<double>(\"ackRandomFactor\");\n\n result.max_retransmit = accessor.get_value<int>(\"maxRetransmit\");\n\n result.nstart = accessor.get_value<int>(\"nstart\");\n\n return result;\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/coap_udp_tx_params.hpp", "rank": 56, "score": 170513.3551774904 }, { "content": "struct FirmwareUpdateInitialState {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjayFirmwareUpdate$InitialState\";\n\n }\n\n\n", "file_path": "native-library/src/util_classes/firmware_update_initial_state.hpp", "rank": 57, "score": 170513.3551774904 }, { "content": "struct FirmwareUpdateInitialResult {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/\"\n\n \"AnjayFirmwareUpdate$InitialState$InitialResult\";\n\n }\n\n\n\n static anjay_fw_update_initial_result_t\n\n into_native(jni::JNIEnv &env,\n\n const jni::Object<FirmwareUpdateInitialResult> &instance) {\n\n static std::unordered_map<std::string, anjay_fw_update_initial_result_t>\n\n MAPPING{ { \"UPDATING\", ANJAY_FW_UPDATE_INITIAL_UPDATING },\n\n { \"DOWNLOADED\", ANJAY_FW_UPDATE_INITIAL_DOWNLOADED },\n\n { \"DOWNLOADING\", ANJAY_FW_UPDATE_INITIAL_DOWNLOADING },\n\n { \"NEUTRAL\", ANJAY_FW_UPDATE_INITIAL_NEUTRAL },\n\n { \"SUCCESS\", ANJAY_FW_UPDATE_INITIAL_SUCCESS },\n\n { \"INTEGRITY_FAILURE\",\n\n ANJAY_FW_UPDATE_INITIAL_INTEGRITY_FAILURE },\n\n { \"FAILED\", ANJAY_FW_UPDATE_INITIAL_FAILED } };\n\n auto clazz = jni::Class<FirmwareUpdateInitialResult>::Find(env);\n\n auto value = jni::Make<std::string>(\n", "file_path": "native-library/src/util_classes/firmware_update_initial_result.hpp", "rank": 58, "score": 170513.3551774904 }, { "content": "struct NativeOutputContextPointer\n\n : public NativePointer<NativeOutputContextPointer, anjay_output_ctx_t> {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeOutputContextPointer\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/native_output_context_pointer.hpp", "rank": 59, "score": 170513.3551774904 }, { "content": "struct NativeInputContextPointer\n\n : public NativePointer<NativeInputContextPointer, anjay_input_ctx_t> {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeInputContextPointer\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/native_input_context_pointer.hpp", "rank": 60, "score": 170513.3551774904 }, { "content": "struct ResourceDefArrayByReference {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/\"\n\n \"NativeAnjayObject$ResourceDefArrayByReference\";\n\n }\n\n\n\n static jni::Local<jni::Object<ResourceDefArrayByReference>>\n\n New(jni::JNIEnv &env) {\n\n auto clazz = jni::Class<ResourceDefArrayByReference>::Find(env);\n\n auto ctor = clazz.GetConstructor(env);\n\n return clazz.New(env, ctor);\n\n }\n\n\n\n template <typename Func>\n\n static void\n\n for_each(jni::JNIEnv &env,\n\n const jni::Object<ResourceDefArrayByReference> &instance,\n\n Func &&func) {\n\n auto accessor =\n\n AccessorBase<ResourceDefArrayByReference>{ env, instance };\n", "file_path": "native-library/src/util_classes/resource_def_array_by_reference.hpp", "rank": 61, "score": 170513.3551774904 }, { "content": "struct NativeBytesContextPointer\n\n : public NativePointer<NativeBytesContextPointer,\n\n anjay_ret_bytes_ctx_t> {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeBytesContextPointer\";\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/native_bytes_context_pointer.hpp", "rank": 62, "score": 170513.3551774904 }, { "content": " bool is_present() const {\n\n return AccessorBase<Optional>{ env_, self_ }\n\n .get_method<jni::jboolean()>(\"isPresent\")();\n\n }\n\n\n\n template <typename T>\n\n jni::Local<jni::Object<T>> get() {\n\n return jni::Cast(env_, jni::Class<T>::Find(env_),\n\n AccessorBase<Optional>{ env_, self_ }\n\n .get_method<jni::Object<>()>(\"get\")());\n\n }\n\n\n\n template <typename T>\n\n static Optional of(jni::JNIEnv &env, const T &value) {\n\n return Optional{ env, AccessorBase<Optional>::get_static_method<\n\n jni::Object<Optional>(jni::Object<>)>(\n\n env, \"of\")(value) };\n\n }\n\n\n\n static Optional empty(jni::JNIEnv &env) {\n", "file_path": "native-library/src/util_classes/optional.hpp", "rank": 63, "score": 152071.79851560408 }, { "content": " return Optional{\n\n env,\n\n AccessorBase<Optional>::get_static_method<jni::Object<Optional>()>(\n\n env, \"empty\")()\n\n };\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/optional.hpp", "rank": 64, "score": 152059.9993954392 }, { "content": "/*\n\n * Copyright 2020-2021 AVSystem <[email protected]>\n\n *\n\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n\n * you may not use this file except in compliance with the License.\n\n * You may obtain a copy of the License at\n\n *\n\n * http://www.apache.org/licenses/LICENSE-2.0\n\n *\n\n * Unless required by applicable law or agreed to in writing, software\n\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n * See the License for the specific language governing permissions and\n\n * limitations under the License.\n\n */\n\n\n\n#pragma once\n\n\n\n#include \"../jni_wrapper.hpp\"\n\n\n\n#include \"./accessor_base.hpp\"\n\n#include \"./optional_tag.hpp\"\n\n\n\nnamespace utils {\n\n\n", "file_path": "native-library/src/util_classes/optional.hpp", "rank": 65, "score": 152052.31970718465 }, { "content": "\n\nnamespace utils {\n\n\n\ntemplate <typename T>\n\nT cast_id(JNIEnv &env, jni::jint id) {\n\n T result = static_cast<T>(id);\n\n if (result != id) {\n\n avs_throw(IllegalArgumentException(env, \"id out of range\"));\n\n }\n\n return result;\n\n}\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/cast_id.hpp", "rank": 66, "score": 150218.2760739016 }, { "content": "/*\n\n * Copyright 2020-2021 AVSystem <[email protected]>\n\n *\n\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n\n * you may not use this file except in compliance with the License.\n\n * You may obtain a copy of the License at\n\n *\n\n * http://www.apache.org/licenses/LICENSE-2.0\n\n *\n\n * Unless required by applicable law or agreed to in writing, software\n\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n * See the License for the specific language governing permissions and\n\n * limitations under the License.\n\n */\n\n\n\n#pragma once\n\n\n\n#include \"../jni_wrapper.hpp\"\n\n#include \"./exception.hpp\"\n", "file_path": "native-library/src/util_classes/cast_id.hpp", "rank": 67, "score": 150193.61576465357 }, { "content": "/*\n\n * Copyright 2020-2021 AVSystem <[email protected]>\n\n *\n\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n\n * you may not use this file except in compliance with the License.\n\n * You may obtain a copy of the License at\n\n *\n\n * http://www.apache.org/licenses/LICENSE-2.0\n\n *\n\n * Unless required by applicable law or agreed to in writing, software\n\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n * See the License for the specific language governing permissions and\n\n * limitations under the License.\n\n */\n\n\n\n#pragma once\n\n\n\n#include \"../jni_wrapper.hpp\"\n\n\n\nnamespace utils {\n\n\n", "file_path": "native-library/src/util_classes/optional_tag.hpp", "rank": 68, "score": 150178.24875201844 }, { "content": " auto mapped_to = MAPPING.find(details);\n\n if (mapped_to == MAPPING.end()) {\n\n return from_string(env, \"UNKNOWN\");\n\n }\n\n return from_string(env, mapped_to->second);\n\n }\n\n\n\nprivate:\n\n static jni::Local<jni::Object<DownloadResultDetails>>\n\n from_string(jni::JNIEnv &env, const std::string &name) {\n\n auto clazz = jni::Class<DownloadResultDetails>::Find(env);\n\n return clazz.Get(\n\n env, clazz.GetStaticField<jni::Object<DownloadResultDetails>>(\n\n env, name.c_str()));\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/download_result_details.hpp", "rank": 69, "score": 148405.6303876797 }, { "content": " { AVS_ETIMEDOUT, \"TIMEOUT\" },\n\n };\n\n\n\n auto mapped_to = MAPPING.find(details.code);\n\n if (mapped_to == MAPPING.end()) {\n\n return from_string(env, \"UNKNOWN\");\n\n }\n\n\n\n return from_string(env, mapped_to->second);\n\n }\n\n\n\n static jni::Local<jni::Object<DownloadResultDetails>>\n\n into_java(jni::JNIEnv &env, int details) {\n\n static std::unordered_map<int, std::string> MAPPING{\n\n { 132, \"NOT_FOUND\" },\n\n { 161, \"NOT_IMPLEMENTED\" },\n\n { 404, \"NOT_FOUND\" },\n\n { 501, \"NOT_IMPLEMENTED\" }\n\n };\n\n\n", "file_path": "native-library/src/util_classes/download_result_details.hpp", "rank": 70, "score": 148382.3759328896 }, { "content": "/*\n\n * Copyright 2020-2021 AVSystem <[email protected]>\n\n *\n\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n\n * you may not use this file except in compliance with the License.\n\n * You may obtain a copy of the License at\n\n *\n\n * http://www.apache.org/licenses/LICENSE-2.0\n\n *\n\n * Unless required by applicable law or agreed to in writing, software\n\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n * See the License for the specific language governing permissions and\n\n * limitations under the License.\n\n */\n\n\n\n#pragma once\n\n\n\n#include <unordered_map>\n\n\n\n#include \"../jni_wrapper.hpp\"\n\n\n\n#include \"./accessor_base.hpp\"\n\n\n\n#include <anjay/download.h>\n\n\n\nnamespace utils {\n\n\n", "file_path": "native-library/src/util_classes/download_result_details.hpp", "rank": 71, "score": 148371.37036796965 }, { "content": "struct InputCtx<std::string> {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeInputContext$StringContext\";\n\n }\n\n};\n\n\n\ntemplate <>\n", "file_path": "native-library/src/native_input_context.hpp", "rank": 72, "score": 140725.84560704685 }, { "content": "class ExceptionWrapper;\n\n\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 73, "score": 138780.09240027942 }, { "content": "class ByteBuffer {\n\n jni::JNIEnv &env_;\n\n jni::Global<jni::Object<ByteBuffer>> self_;\n\n\n\n bool is_direct() {\n\n return utils::AccessorBase<ByteBuffer>{ env_, self_ }\n\n .get_method<jni::jboolean()>(\"isDirect\")();\n\n }\n\n\n\npublic:\n\n static constexpr auto Name() {\n\n return \"java/nio/ByteBuffer\";\n\n }\n\n\n\n ByteBuffer(jni::JNIEnv &env, const jni::Local<jni::Object<ByteBuffer>> &buf)\n\n : env_(env), self_(jni::NewGlobal(env_, buf)) {}\n\n\n\n ByteBuffer(jni::JNIEnv &env, size_t size) : env_(env), self_() {\n\n if (size > static_cast<size_t>(std::numeric_limits<jni::jint>::max())) {\n\n avs_throw(IllegalArgumentException(\n", "file_path": "native-library/src/util_classes/byte_buffer.hpp", "rank": 74, "score": 137768.2692742997 }, { "content": "class OutputStream {\n\n static int writer(void *arg, const void *buffer, size_t *inout_size) try {\n\n return GlobalContext::call_with_env([=](jni::UniqueEnv &&env) {\n\n jni::Object<OutputStream> *output_stream =\n\n static_cast<jni::Object<OutputStream> *>(arg);\n\n std::vector<jni::jbyte> data_vec((const uint8_t *) buffer,\n\n (const uint8_t *) buffer\n\n + *inout_size);\n\n utils::AccessorBase<OutputStream>{ *env, *output_stream }\n\n .get_method<void(jni::Array<jni::jbyte>)>(\"write\")(\n\n jni::Make<jni::Array<jni::jbyte>>(*env, data_vec));\n\n return 0;\n\n });\n\n } catch (...) {\n\n avs_log_and_clear_exception(DEBUG);\n\n return -1;\n\n }\n\n\n\npublic:\n\n static constexpr auto Name() {\n", "file_path": "native-library/src/util_classes/output_stream.hpp", "rank": 75, "score": 137768.2692742997 }, { "content": "class BufferView {\n\n BufferView(const BufferView &) = delete;\n\n BufferView(BufferView &&) = delete;\n\n BufferView &operator=(const BufferView &) = delete;\n\n BufferView &&operator=(BufferView &&) = delete;\n\n\n\n ByteBuffer buffer_;\n\n\n\npublic:\n\n /**\n\n * CAUTION: The lifetime of @p native_buffer MUST EXCEED the lifetime\n\n * of an instance of this class and ALL instances returned by\n\n * BufferView::into_java().\n\n *\n\n * IMPORTANT: @p native_buffer is not const, because there is no way\n\n * to guarantee that Java won't attempt to modify the buffer if it's\n\n * passed to it. Use with const pointers (and const_cast) only if you're\n\n * 100% sure Java does not touch the buffer contents, otherwise the behavior\n\n * is undefined.\n\n */\n", "file_path": "native-library/src/util_classes/byte_buffer.hpp", "rank": 77, "score": 137768.2692742997 }, { "content": " class Iterator {\n\n jni::JNIEnv &env_;\n\n jni::Local<jni::Object<Iterator>> self_;\n\n\n\n public:\n\n static constexpr auto Name() {\n\n return \"java/util/Iterator\";\n\n }\n\n\n\n Iterator(jni::JNIEnv &env, const jni::Object<Iterator> &self)\n\n : env_(env), self_(jni::NewLocal(env, self)) {}\n\n\n\n jni::Local<jni::Object<>> next() {\n\n return AccessorBase<Iterator>{ env_, self_ }\n\n .template get_method<jni::Object<>()>(\"next\")();\n\n }\n\n\n\n bool has_next() {\n\n return AccessorBase<Iterator>{ env_, self_ }\n\n .template get_method<jni::jboolean()>(\"hasNext\")();\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 78, "score": 137768.2692742997 }, { "content": "class InputStream {\n\n static int reader(void *arg, void *buffer, size_t *inout_size) try {\n\n return GlobalContext::call_with_env([=](jni::UniqueEnv &&env) {\n\n jni::Object<InputStream> *input_stream =\n\n static_cast<jni::Object<InputStream> *>(arg);\n\n auto arr = jni::Array<jni::jbyte>::New(*env, *inout_size);\n\n int bytes_read =\n\n utils::AccessorBase<utils::InputStream>{ *env,\n\n *input_stream }\n\n .get_method<jni::jint(jni::Array<jni::jbyte>,\n\n jni::jint, jni::jint)>(\n\n \"read\")(arr, 0, *inout_size);\n\n if (bytes_read < 0) {\n\n *inout_size = 0;\n\n } else {\n\n assert(*inout_size >= static_cast<size_t>(bytes_read));\n\n *inout_size = bytes_read;\n\n auto vec = jni::Make<std::vector<jni::jbyte>>(*env, arr);\n\n memcpy(buffer, vec.data(), *inout_size);\n\n }\n", "file_path": "native-library/src/util_classes/input_stream.hpp", "rank": 79, "score": 137768.2692742997 }, { "content": "class OriginAwareException {\n\npublic:\n\n virtual ~OriginAwareException() noexcept {}\n\n\n\n OriginAwareException(const OriginAwareException &) = default;\n\n OriginAwareException &operator=(const OriginAwareException &) = default;\n\n\n\n OriginAwareException(OriginAwareException &&) = default;\n\n OriginAwareException &operator=(OriginAwareException &&) = default;\n\n\n\n std::string get_throw_location() const {\n\n std::stringstream ss;\n\n ss << file_ << \":\" << line_;\n\n if (function_) {\n\n ss << \" (\" << function_ << \")\";\n\n }\n\n return ss.str();\n\n }\n\n\n\nprivate:\n", "file_path": "native-library/src/util_classes/exception.hpp", "rank": 80, "score": 137768.2692742997 }, { "content": "class SecurityConfig {\n\n std::weak_ptr<anjay_t> anjay_;\n\n jni::JNIEnv &env_;\n\n jni::Global<jni::Object<SecurityConfig>> self_;\n\n std::optional<std::variant<SecurityInfoPsk, SecurityInfoCert>> psk_or_cert_;\n\n anjay_security_config_t config_;\n\n bool config_from_dm_;\n\n\n\n struct SecurityInfo {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjaySecurityInfo\";\n\n }\n\n };\n\n\n\n struct SecurityConfigFromUser {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjaySecurityConfig\";\n\n }\n\n };\n\n\n", "file_path": "native-library/src/util_classes/security_config.hpp", "rank": 81, "score": 137768.2692742997 }, { "content": " class CertList {\n\n using CertType = typename detail::CertificateType<T>::Type;\n\n std::list<std::vector<jni::jbyte>> storage_;\n\n std::vector<T> chains_;\n\n\n\n public:\n\n CertList() : storage_(), chains_() {}\n\n\n\n CertList(jni::JNIEnv &env, const jni::Local<jni::Object<List>> &certs)\n\n : CertList() {\n\n if (!certs.get()) {\n\n return;\n\n }\n\n auto list_accessor = AccessorBase<List>{ env, certs };\n\n const int size = list_accessor.get_method<jni::jint()>(\"size\")();\n\n if (size == 0) {\n\n return;\n\n }\n\n\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 82, "score": 136776.47063177847 }, { "content": "class SecurityInfoPsk {\n\n std::vector<jni::jbyte> identity_;\n\n std::vector<jni::jbyte> key_;\n\n\n\npublic:\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjaySecurityInfoPsk\";\n\n }\n\n\n\n SecurityInfoPsk(jni::JNIEnv &env,\n\n const jni::Local<jni::Object<SecurityInfoPsk>> &instance)\n\n : identity_(), key_() {\n\n auto accessor = AccessorBase<SecurityInfoPsk>{ env, instance };\n\n auto identity = accessor.get_value<jni::Array<jni::jbyte>>(\"identity\");\n\n identity_.resize(identity.Length(env));\n\n identity.GetRegion(env, 0, identity_);\n\n\n\n auto key = accessor.get_value<jni::Array<jni::jbyte>>(\"key\");\n\n key_.resize(key.Length(env));\n\n key.GetRegion(env, 0, key_);\n", "file_path": "native-library/src/util_classes/security_info_psk.hpp", "rank": 83, "score": 135804.0759710693 }, { "content": "class SecurityInfoCert {\n\n struct PrivateKey {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/AnjaySecurityInfoCert$PrivateKey\";\n\n }\n\n };\n\n\n\n struct List {\n\n static constexpr auto Name() {\n\n return \"java/util/List\";\n\n }\n\n };\n\n\n\n template <typename T>\n", "file_path": "native-library/src/util_classes/security_info_cert.hpp", "rank": 84, "score": 135804.0759710693 }, { "content": "struct SocketError : public std::exception {\n\n avs_errno_t error_;\n\n std::string description_;\n\n\n\npublic:\n\n SocketError(avs_errno_t error, const std::string &description = {})\n\n : error_(error), description_(description) {}\n\n\n\n virtual ~SocketError() {}\n\n\n\n virtual const char *what() const noexcept {\n\n return description_.c_str();\n\n }\n\n\n\n avs_errno_t error() const noexcept {\n\n return error_;\n\n }\n\n};\n\n\n\n} // namespace compat\n", "file_path": "native-library/src/compat/socket_error.hpp", "rank": 85, "score": 133850.67110270777 }, { "content": "class AvsSocket final : public AvsSocketBase {\n\n SocketChannel<ChannelType> channel_;\n\n\n\npublic:\n\n AvsSocket(const avs_net_socket_configuration_t *config) : channel_() {\n\n if (config && config->reuse_addr) {\n\n channel_.set_reuse_address(true);\n\n }\n\n }\n\n\n\n virtual ~AvsSocket() {\n\n close();\n\n }\n\n\n\n virtual jni::Local<jni::Object<utils::SelectableChannel>>\n\n selectable_channel() const {\n\n return channel_.as_selectable_channel();\n\n }\n\n\n\n virtual void connect(const char *host, const char *port) {\n", "file_path": "native-library/src/compat/avs_net_socket.hpp", "rank": 86, "score": 129990.38032354866 }, { "content": " private final Optional<Double> minRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/Anjay3dIpsoSensor.java", "rank": 87, "score": 127766.91878727243 }, { "content": " private final Optional<Double> maxRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/Anjay3dIpsoSensor.java", "rank": 88, "score": 127766.91878727243 }, { "content": " public Optional<Double> getMinRangeValue() {\n\n return minRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/Anjay3dIpsoSensor.java", "rank": 89, "score": 126453.83706153439 }, { "content": " public Optional<Double> getMaxRangeValue() {\n\n return maxRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/Anjay3dIpsoSensor.java", "rank": 90, "score": 126453.83706153439 }, { "content": " private final Optional<Double> minRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/AnjayBasicIpsoSensor.java", "rank": 91, "score": 125167.47029724065 }, { "content": " private final Optional<Double> maxRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/AnjayBasicIpsoSensor.java", "rank": 92, "score": 125167.47029724065 }, { "content": " public final Optional<Double> getMinRangeValue() {\n\n return minRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/AnjayBasicIpsoSensor.java", "rank": 93, "score": 123907.01142103101 }, { "content": " public final Optional<Double> getMaxRangeValue() {\n\n return maxRangeValue;\n", "file_path": "library/src/main/java/com/avsystem/anjay/AnjayBasicIpsoSensor.java", "rank": 94, "score": 123907.01142103101 }, { "content": "struct InputCtx<utils::Objlnk> {\n\n static constexpr auto Name() {\n\n return \"com/avsystem/anjay/impl/NativeInputContext$ObjlnkContext\";\n\n }\n\n};\n\n\n\ntemplate <>\n", "file_path": "native-library/src/native_input_context.hpp", "rank": 95, "score": 118136.86473749859 }, { "content": " auto accessor = AccessorBase<ReadyState>{ env, state };\n\n read = accessor.get_value<jni::jboolean>(\"read\");\n\n write = accessor.get_value<jni::jboolean>(\"write\");\n\n accept = accessor.get_value<jni::jboolean>(\"accept\");\n\n connect = accessor.get_value<jni::jboolean>(\"connect\");\n\n }\n\n\n\n jni::Local<jni::Object<ReadyState>> into_java(jni::JNIEnv &env) {\n\n return construct<ReadyState>(env, static_cast<jni::jboolean>(read),\n\n static_cast<jni::jboolean>(write),\n\n static_cast<jni::jboolean>(connect),\n\n static_cast<jni::jboolean>(accept));\n\n }\n\n };\n\n\n\n static ReadyState\n\n wait_until_ready(jni::JNIEnv &env,\n\n const jni::Object<SelectableChannel> &channel,\n\n avs_time_duration_t timeout,\n\n ReadyState waitStates) {\n", "file_path": "native-library/src/util_classes/native_utils.hpp", "rank": 96, "score": 108817.48825317416 }, { "content": " return ReadyState(\n\n env,\n\n AccessorBase<NativeUtils>::get_static_method<\n\n jni::Object<ReadyState>(jni::Object<SelectableChannel>,\n\n jni::Object<Duration>,\n\n jni::Object<ReadyState>)>(\n\n env, \"waitUntilReady\")(\n\n channel, Duration::into_java(env, timeout),\n\n waitStates.into_java(env)));\n\n }\n\n};\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/native_utils.hpp", "rank": 97, "score": 108815.89743732604 }, { "content": "/*\n\n * Copyright 2020-2021 AVSystem <[email protected]>\n\n *\n\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n\n * you may not use this file except in compliance with the License.\n\n * You may obtain a copy of the License at\n\n *\n\n * http://www.apache.org/licenses/LICENSE-2.0\n\n *\n\n * Unless required by applicable law or agreed to in writing, software\n\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n * See the License for the specific language governing permissions and\n\n * limitations under the License.\n\n */\n\n\n\n#pragma once\n\n\n\n#include \"../jni_wrapper.hpp\"\n\n\n\n#include <avsystem/commons/avs_time.h>\n\n\n\n#include \"./construct.hpp\"\n\n#include \"./duration.hpp\"\n\n#include \"./selectable_channel.hpp\"\n\n\n\nnamespace utils {\n\n\n", "file_path": "native-library/src/util_classes/native_utils.hpp", "rank": 98, "score": 108812.01804735663 }, { "content": "namespace utils {\n\n\n\ntemplate <typename T, typename... Args>\n\nauto construct(jni::JNIEnv &env, const Args &... args) {\n\n auto clazz = jni::Class<T>::Find(env);\n\n auto ctor = clazz.template GetConstructor<\n\n typename jni::RemoveUnique<Args>::Type...>(env);\n\n return clazz.New(env, ctor, args...);\n\n}\n\n\n\n} // namespace utils\n", "file_path": "native-library/src/util_classes/construct.hpp", "rank": 99, "score": 100751.6497035945 } ]
C++
tools/macpo/tests/integration-tests/itest_harness.cpp
roystgnr/perfexpert
a03b13db9ac83e992e1c5cc3b6e45e52c266fe30
#include <fcntl.h> #include <rose.h> #include <sys/types.h> #include <sys/wait.h> #include <cerrno> #include <fstream> #include <string> #include <vector> #include "generic_defs.h" #include "itest_harness.h" #include "minst.h" bool file_exists(const std::string& filename) { return access(filename.c_str(), F_OK) != -1; } std::string get_src_directory() { return std::string(getenv("srcdir")) + "/tests/integration-tests"; } std::string get_build_directory() { char result[1024]; ssize_t count = readlink("/proc/self/exe", result, 1024); std::string exe_path = std::string(result, (count > 0) ? count : 0); size_t found = exe_path.find_last_of("/"); return exe_path.substr(0, found); } std::string get_tests_directory() { return get_src_directory() + "/test-files"; } std::string instrument_and_link(std::string input_file, string_list_t* special_args, options_t& options) { assert(file_exists(input_file) == true); std::string output_file = std::tmpnam(NULL); string_list_t args; populate_args(args, input_file, output_file, special_args); print_args(args); int pid; switch ((pid = fork())) { default: siginfo_t siginfo; waitid(P_PID, pid, &siginfo, WEXITED | WSTOPPED); break; case 0: { SgProject* project = frontend(args); assert(midend(project, options) == true); assert(backend(project) == 0); delete project; exit(0); } break; case -1: const char* err_msg = strerror(errno); std::cerr << "Failed to spawn child process: " << err_msg << "." << std::endl; break; } return output_file; } bool verify_output(std::string& filename, std::string& binary) { std::string program_output = get_process_stderr(binary); std::string file_contents = get_file_contents(filename); #if 0 std::cout << "program output: " << program_output << std::endl; #endif string_list_t prog_line_list, file_line_list; split(program_output, '\n', prog_line_list); split(file_contents, '\n', file_line_list); size_t file_lines = file_line_list.size(); size_t prog_lines = prog_line_list.size(); if (file_lines == 0 && prog_lines == 0) { return true; } if (file_lines < prog_lines) { std::cout << "File contents smaller than program output: " << file_lines << " v/s " << prog_lines << "!" << std::endl; return false; } size_t ctr = 0; std::string expected_prefix = "[macpo-integration-test]:"; for (string_list_t::iterator it = prog_line_list.begin(); it != prog_line_list.end(); it++) { std::string prog_line = *it; if (prog_line.compare(0, expected_prefix.size(), expected_prefix) == 0) { string_list_t prog_field_list; split(prog_line, ':', prog_field_list); while (ctr < file_lines) { std::string file_line = file_line_list[ctr]; if (file_line.compare(0, expected_prefix.size(), expected_prefix) == 0) break; ctr += 1; } if (ctr == file_lines) { std::cout << "Expected output has fewer test strings than " "program output, was expecting: " << prog_line << std::endl; return false; } string_list_t file_field_list; std::string file_line = file_line_list[ctr]; split(file_line, ':', file_field_list); ctr += 1; size_t prog_fields = prog_field_list.size(); size_t file_fields = file_field_list.size(); assert(prog_fields >= 2); assert(file_fields >= 2); if (prog_fields != file_fields) { std::cout << "Field length mismatch between program output and " "expected output: " << prog_line << " v/s " << file_line << "!" << std::endl; return false; } for (int i = 1; i < prog_fields; i++) { if (prog_field_list[i] != file_field_list[i] && file_field_list[i] != "?") { std::cout << "Field mismatch between program output and " "expected output: " << prog_field_list[i] << " v/s " << file_field_list[i] << "!" << std::endl; return false; } } } } if (ctr >= file_lines || (ctr < file_lines && file_line_list[ctr].compare(0, expected_prefix.size(), expected_prefix) != 0)) { return true; } std::cout << "Remaining entries in expected output, starting with: " << file_line_list[ctr] << "!" << std::endl; return false; } static void print_args(const string_list_t& args) { std::cout << mprefix << "running command:"; for (string_list_t::const_iterator it = args.begin(); it != args.end(); it++) { const std::string& argument = *it; std::cout << " " << argument; } std::cout << std::endl; } static void populate_args(string_list_t& args, std::string& input_file, std::string& output_file, string_list_t* special_args) { args.push_back("cc"); args.push_back(input_file); args.push_back("-o"); args.push_back(output_file); args.push_back("-lstdc++"); std::string mock_include_path = get_src_directory() + "/../libmrt"; args.push_back("-I" + mock_include_path); args.push_back(get_build_directory() + "/mrt.o"); if (special_args) { args.insert(args.end(), special_args->begin(), special_args->end()); } } static std::string get_process_stderr(std::string& binary_name) { int err_pipe[2]; pipe(err_pipe); char arg0[1024]; snprintf(arg0, sizeof(arg0), "%s", binary_name.c_str()); char *args[] = { arg0, NULL }; switch (fork()) { case -1: return ""; case 0: close(err_pipe[0]); if (dup2(err_pipe[1], 1) < 0) { perror("Could not duplicate descriptor"); exit(-1); } if (dup2(err_pipe[1], 2) < 0) { perror("Could not duplicate descriptor"); exit(1); } if (execv(arg0, args) == -1) { std::cout << "Could not execute binary file: " << binary_name << std::endl; perror("execv"); exit(2); } close(err_pipe[1]); exit(0); } wait(NULL); fcntl(err_pipe[0], F_SETFL, O_NONBLOCK | O_ASYNC); const int kLength = 1024; char buffer[kLength]; std::string str_stderr; while (true) { ssize_t read_count = read(err_pipe[0], buffer, kLength-1); if (read_count <= 0 || read_count >= kLength) break; buffer[read_count] = 0; str_stderr += buffer; } close(err_pipe[0]); close(err_pipe[1]); return str_stderr; } static std::string get_file_contents(std::string& filename) { std::string line, contents; std::ifstream fileobj(filename.c_str()); if (fileobj.is_open()) { while (getline(fileobj, line)) contents += line + "\n"; fileobj.close(); } return contents; }
#include <fcntl.h> #include <rose.h> #include <sys/types.h> #include <sys/wait.h> #include <cerrno> #include <fstream> #include <string> #include <vector> #include "generic_defs.h" #include "itest_harness.h" #include "minst.h" bool file_exists(const std::string& filename) { return access(filename.c_str(), F_OK) != -1; } std::string get_src_directory() { return std::string(getenv("srcdir")) + "/tests/integration-tests"; } std::string get_build_directory() { char result[1024]; ssize_t count = readlink("/proc/self/exe", result, 1024); std::string exe_path = std::string(result, (count > 0) ? count : 0); size_t found = exe_path.find_last_of("/"); return exe_path.substr(0, found); } std::string get_tests_directory() { return get_src_directory() + "/test-files"; } std::string instrument_and_link(std::string input_file, string_list_t* special_args, options_t& options) { assert(file_exists(input_file) == true); std::string output_file = std::tmpnam(NULL); string_list_t args; populate_args(args, input_file, output_file, special_args); print_args(args); int pid; switch ((pid = fork())) { default: siginfo_t siginfo; waitid(P_PID, pid, &siginfo, WEXITED | WSTOPPED); break; case 0: { SgProject* project = frontend(args); assert(midend(project, options) == true); assert(backend(project) == 0); delete project; exit(0); } break; case -1: const char* err_msg = strerror(errno); std::cerr << "Failed to spawn child process: " << err_msg << "." << std::endl; break; } return output_file; } bool verify_output(std::string& filename, std::string& binary) { std::string program_output = get_process_stderr(binary); std::string file_contents = get_file_contents(filename); #if 0 std::cout << "program output: " << program_output << std::endl; #endif string_list_t prog_line_list, file_line_list; split(program_output, '\n', prog_line_list); split(file_contents, '\n', file_line_list); size_t file_lines = file_line_list.size(); size_t prog_lines = prog_line_list.size(); if (file_lines == 0 && prog_lines == 0) { return true; } if (file_lines < prog_lines) { std::cout << "File contents smaller than program output: " << file_lines << " v/s " << prog_lines << "!" << std::endl; return false; } size_t ctr = 0; std::string expected_prefix = "[macpo-integration-test]:"; for (string_list_t::iterator it = prog_line_list.begin(); it != prog_line_list.end(); it++) { std::string prog_line = *it; if (prog_line.compare(0, expected_prefix.size(), expected_prefix) == 0) { string_list_t prog_field_list; split(prog_line, ':', prog_field_list); while (ctr < file_lines) { std::string file_line = file_line_list[ctr]; if (file_line.compare(0, expected_prefix.size(), expected_prefix) == 0) break; ctr += 1; } if (ctr == file_lines) { std::cout << "Expected output has fewer test strings than " "program output, was expecting: " << prog_line << std::endl; return false; } string_list_t file_field_list; std::string file_line = file_line_list[ctr]; split(file_line, ':', file_field_list); ctr += 1; size_t prog_fields = prog_field_list.size(); size_t file_fields = file_field_list.size(); assert(prog_fields >= 2); assert(file_fields >= 2); if (prog_fields != file_fields) { std::cout << "Field length mismatch between program output and " "expected output: " << prog_line << " v/s " << file_line << "!" << std::endl; return false; } for (int i = 1; i < prog_fields; i++) { if (prog_field_list[i] != file_field_list[i] && file_field_list[i] != "?") { std::cout << "Field mismatch between program output and " "expected output: " << prog_field_list[i] << " v/s " << file_field_list[i] << "!" << std::endl; return false; } } } } if (ctr >= file_lines || (ctr < file_lines && file_line_list[ctr].compare(0, expected_prefix.size(), expected_prefix) != 0)) { return true; } std::cout << "Remaining entries in expected output, starting with: " << file_line_list[ctr] << "!" << std::endl; return false; } static void print_args(const string_list_t& args) { std::cout << mprefix << "running command:"; for (string_list_t::const_iterator it = args.begin(); it != args.end(); it++) { const std::string& argument = *it; std::cout << " " << argument; } std::cout << std::endl; } static void populate_args(string_list_t& args, std::string& in
.push_back("-o"); args.push_back(output_file); args.push_back("-lstdc++"); std::string mock_include_path = get_src_directory() + "/../libmrt"; args.push_back("-I" + mock_include_path); args.push_back(get_build_directory() + "/mrt.o"); if (special_args) { args.insert(args.end(), special_args->begin(), special_args->end()); } } static std::string get_process_stderr(std::string& binary_name) { int err_pipe[2]; pipe(err_pipe); char arg0[1024]; snprintf(arg0, sizeof(arg0), "%s", binary_name.c_str()); char *args[] = { arg0, NULL }; switch (fork()) { case -1: return ""; case 0: close(err_pipe[0]); if (dup2(err_pipe[1], 1) < 0) { perror("Could not duplicate descriptor"); exit(-1); } if (dup2(err_pipe[1], 2) < 0) { perror("Could not duplicate descriptor"); exit(1); } if (execv(arg0, args) == -1) { std::cout << "Could not execute binary file: " << binary_name << std::endl; perror("execv"); exit(2); } close(err_pipe[1]); exit(0); } wait(NULL); fcntl(err_pipe[0], F_SETFL, O_NONBLOCK | O_ASYNC); const int kLength = 1024; char buffer[kLength]; std::string str_stderr; while (true) { ssize_t read_count = read(err_pipe[0], buffer, kLength-1); if (read_count <= 0 || read_count >= kLength) break; buffer[read_count] = 0; str_stderr += buffer; } close(err_pipe[0]); close(err_pipe[1]); return str_stderr; } static std::string get_file_contents(std::string& filename) { std::string line, contents; std::ifstream fileobj(filename.c_str()); if (fileobj.is_open()) { while (getline(fileobj, line)) contents += line + "\n"; fileobj.close(); } return contents; }
put_file, std::string& output_file, string_list_t* special_args) { args.push_back("cc"); args.push_back(input_file); args
random
[ { "content": "class FooTest : public ::testing::TestWithParam<const char*> {\n\n // You can implement all the usual class fixture members here.\n\n};\n\n\n\n// Then, use the TEST_P macro to define as many parameterized tests\n\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n\n// or \"pattern\", whichever you prefer to think.\n\n\n\nTEST_P(FooTest, DoesBlah) {\n\n // Inside a test, access the test parameter with the GetParam() method\n\n // of the TestWithParam<T> class:\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n ...\n\n}\n\n\n\nTEST_P(FooTest, HasBlahBlah) {\n\n ...\n\n}\n\n\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n", "file_path": "contrib/gtest/include/gtest/gtest-param-test.h", "rank": 0, "score": 197645.3532774296 }, { "content": "class TestPartResult; // Result of a test part.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 1, "score": 170943.85371607804 }, { "content": "struct RemoveConst<const T[N]> {\n\n typedef typename RemoveConst<T>::type type[N];\n\n};\n\n\n\n#if defined(_MSC_VER) && _MSC_VER < 1400\n\n// This is the only specialization that allows VC++ 7.1 to remove const in\n\n// 'const int[3] and 'const int[3][4]'. However, it causes trouble with GCC\n\n// and thus needs to be conditionally compiled.\n\ntemplate <typename T, size_t N>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 2, "score": 169637.18373378454 }, { "content": "class UniversalTersePrinter<const char*> {\n\n public:\n\n static void Print(const char* str, ::std::ostream* os) {\n\n if (str == NULL) {\n\n *os << \"NULL\";\n\n } else {\n\n UniversalPrint(string(str), os);\n\n }\n\n }\n\n};\n\ntemplate <>\n", "file_path": "contrib/gtest/include/gtest/gtest-printers.h", "rank": 3, "score": 165467.91137108803 }, { "content": "class DefaultGlobalTestPartResultReporter;\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 4, "score": 153253.24633265 }, { "content": "class UnitTest; // A collection of test cases.\n\n\n\ntemplate <typename T>\n\n::std::string PrintToString(const T& value);\n\n\n\nnamespace internal {\n\n\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 5, "score": 142412.94783677848 }, { "content": "struct RemoveConst<T[N]> {\n\n typedef typename RemoveConst<T>::type type[N];\n\n};\n\n#endif\n\n\n\n// A handy wrapper around RemoveConst that works when the argument\n\n// T depends on template parameters.\n\n#define GTEST_REMOVE_CONST_(T) \\\n\n typename ::testing::internal::RemoveConst<T>::type\n\n\n\n// Turns const U&, U&, const U, and U all into U.\n\n#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \\\n\n GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))\n\n\n\n// Adds reference to a type if it is not a reference type,\n\n// otherwise leaves it unchanged. This is the same as\n\n// tr1::add_reference, which is not widely available yet.\n\ntemplate <typename T>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 6, "score": 140188.89833423373 }, { "content": "class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n\n // The usual test fixture members go here too.\n\n};\n\n\n\nTEST_F(BaseTest, HasFoo) {\n\n // This is an ordinary non-parameterized test.\n\n}\n\n\n\nTEST_P(DerivedTest, DoesBlah) {\n\n // GetParam works just the same here as if you inherit from TestWithParam.\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n}\n\n\n\n#endif // 0\n\n\n\n#include \"gtest/internal/gtest-port.h\"\n\n\n\n#if !GTEST_OS_SYMBIAN\n\n# include <utility>\n\n#endif\n", "file_path": "contrib/gtest/include/gtest/gtest-param-test.h", "rank": 7, "score": 138712.63285712077 }, { "content": " char *output; // collected via STDOUT\n", "file_path": "common/perfexpert_fork.h", "rank": 8, "score": 132594.38122130441 }, { "content": "class TestCase;\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 9, "score": 131130.6495811001 }, { "content": " char *program;\n", "file_path": "tools/perfexpert/perfexpert_options.h", "rank": 10, "score": 129404.56066564177 }, { "content": "class TestResultAccessor;\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 11, "score": 126503.89974176692 }, { "content": "class Test; // Represents a test.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 12, "score": 125759.7592214566 }, { "content": "# define TEST_P(test_case_name, test_name) \\\n\n class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \\\n\n : public test_case_name { \\\n\n public: \\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \\\n\n virtual void TestBody(); \\\n\n private: \\\n\n static int AddToRegistry() { \\\n\n ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n\n GetTestCasePatternHolder<test_case_name>(\\\n\n #test_case_name, __FILE__, __LINE__)->AddTestPattern(\\\n\n #test_case_name, \\\n\n #test_name, \\\n\n new ::testing::internal::TestMetaFactory< \\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \\\n\n return 0; \\\n\n } \\\n\n static int gtest_registering_dummy_; \\\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \\\n\n }; \\\n", "file_path": "contrib/gtest/include/gtest/gtest-param-test.h", "rank": 13, "score": 124969.56955118482 }, { "content": "// The friend relationship of some of these classes is cyclic.\n\n// If we don't forward declare them the compiler might confuse the classes\n\n// in friendship clauses with same named classes on the scope.\n\nclass Test;\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 14, "score": 124961.13522098429 }, { "content": "// A copyable object representing the result of a test part (i.e. an\n\n// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).\n\n//\n\n// Don't inherit from TestPartResult as its destructor is not virtual.\n\nclass GTEST_API_ TestPartResult {\n\n public:\n\n // The possible outcomes of a test part (i.e. an assertion or an\n\n // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).\n\n enum Type {\n\n kSuccess, // Succeeded.\n\n kNonFatalFailure, // Failed but the test can continue.\n\n kFatalFailure // Failed and the test should be terminated.\n\n };\n\n\n\n // C'tor. TestPartResult does NOT have a default constructor.\n\n // Always use this constructor (with parameters) to create a\n\n // TestPartResult object.\n\n TestPartResult(Type a_type,\n\n const char* a_file_name,\n\n int a_line_number,\n\n const char* a_message)\n\n : type_(a_type),\n\n file_name_(a_file_name == NULL ? \"\" : a_file_name),\n\n line_number_(a_line_number),\n", "file_path": "contrib/gtest/include/gtest/gtest-test-part.h", "rank": 15, "score": 124620.650171013 }, { "content": "// This interface knows how to report a test part result.\n\nclass TestPartResultReporterInterface {\n\n public:\n\n virtual ~TestPartResultReporterInterface() {}\n\n\n\n virtual void ReportTestPartResult(const TestPartResult& result) = 0;\n\n};\n\n\n\nnamespace internal {\n\n\n", "file_path": "contrib/gtest/include/gtest/gtest-test-part.h", "rank": 16, "score": 124614.95022966685 }, { "content": "bool isFileFound(string fileName,ifstream& infile){\n\n infile.open(fileName);\n\n return (infile.is_open()?true:false);\n", "file_path": "tools/vectorization/vecopportunities/systemops.h", "rank": 17, "score": 124321.9143049591 }, { "content": "bool isFileFound(string fileName,ifstream& infile){\n\n infile.open(fileName);\n\n return (infile.is_open()?true:false);\n", "file_path": "tools/vectorization/vecreportparser/systemops.h", "rank": 18, "score": 124321.9143049591 }, { "content": "static std::string get_file_contents(std::string& filename);\n", "file_path": "tools/macpo/tests/integration-tests/itest_harness.h", "rank": 19, "score": 122851.19694971666 }, { "content": " class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \\\n\n : public CaseName<gtest_TypeParam_> { \\\n\n private: \\\n\n typedef CaseName<gtest_TypeParam_> TestFixture; \\\n\n typedef gtest_TypeParam_ TypeParam; \\\n\n virtual void TestBody(); \\\n\n }; \\\n\n bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \\\n\n ::testing::internal::TypeParameterizedTest< \\\n\n CaseName, \\\n\n ::testing::internal::TemplateSel< \\\n\n GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \\\n\n GTEST_TYPE_PARAMS_(CaseName)>::Register(\\\n\n \"\", #CaseName, #TestName, 0); \\\n\n template <typename gtest_TypeParam_> \\\n\n void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()\n\n\n\n#endif // GTEST_HAS_TYPED_TEST\n\n\n\n// Implements type-parameterized tests.\n", "file_path": "contrib/gtest/include/gtest/gtest-typed-test.h", "rank": 20, "score": 122832.32450068997 }, { "content": "// The result of a single Test. This includes a list of\n\n// TestPartResults, a list of TestProperties, a count of how many\n\n// death tests there are in the Test, and how much time it took to run\n\n// the Test.\n\n//\n\n// TestResult is not copyable.\n\nclass GTEST_API_ TestResult {\n\n public:\n\n // Creates an empty TestResult.\n\n TestResult();\n\n\n\n // D'tor. Do not inherit from TestResult.\n\n ~TestResult();\n\n\n\n // Gets the number of all test parts. This is the sum of the number\n\n // of successful test parts and the number of failed test parts.\n\n int total_part_count() const;\n\n\n\n // Returns the number of the test properties.\n\n int test_property_count() const;\n\n\n\n // Returns true iff the test passed (i.e. no test part failed).\n\n bool Passed() const { return !Failed(); }\n\n\n\n // Returns true iff the test failed.\n\n bool Failed() const;\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 21, "score": 122220.90412160594 }, { "content": "// A test case, which consists of a vector of TestInfos.\n\n//\n\n// TestCase is not copyable.\n\nclass GTEST_API_ TestCase {\n\n public:\n\n // Creates a TestCase with the given name.\n\n //\n\n // TestCase does NOT have a default constructor. Always use this\n\n // constructor to create a TestCase object.\n\n //\n\n // Arguments:\n\n //\n\n // name: name of the test case\n\n // a_type_param: the name of the test's type parameter, or NULL if\n\n // this is not a type-parameterized test.\n\n // set_up_tc: pointer to the function that sets up the test case\n\n // tear_down_tc: pointer to the function that tears down the test case\n\n TestCase(const char* name, const char* a_type_param,\n\n Test::SetUpTestCaseFunc set_up_tc,\n\n Test::TearDownTestCaseFunc tear_down_tc);\n\n\n\n // Destructor of TestCase.\n\n virtual ~TestCase();\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 22, "score": 122213.52163555246 }, { "content": " size_t count, l1_conflicts, l2_conflicts;\n", "file_path": "tools/macpo/analyze/include/analysis_defs.h", "rank": 23, "score": 122075.16963193125 }, { "content": "// String - an abstract class holding static string utilities.\n\nclass GTEST_API_ String {\n\n public:\n\n // Static utility methods\n\n\n\n // Clones a 0-terminated C string, allocating memory using new. The\n\n // caller is responsible for deleting the return value using\n\n // delete[]. Returns the cloned string, or NULL if the input is\n\n // NULL.\n\n //\n\n // This is different from strdup() in string.h, which allocates\n\n // memory using malloc().\n\n static const char* CloneCString(const char* c_str);\n\n\n\n#if GTEST_OS_WINDOWS_MOBILE\n\n // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be\n\n // able to pass strings to Win32 APIs on CE we need to convert them\n\n // to 'Unicode', UTF-16.\n\n\n\n // Creates a UTF-16 wide string from the given ANSI string, allocating\n\n // memory using new. The caller is responsible for deleting the return\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 24, "score": 121680.22685241819 }, { "content": "// An array of TestPartResult objects.\n\n//\n\n// Don't inherit from TestPartResultArray as its destructor is not\n\n// virtual.\n\nclass GTEST_API_ TestPartResultArray {\n\n public:\n\n TestPartResultArray() {}\n\n\n\n // Appends the given TestPartResult to the array.\n\n void Append(const TestPartResult& result);\n\n\n\n // Returns the TestPartResult at the given index (0-based).\n\n const TestPartResult& GetTestPartResult(int index) const;\n\n\n\n // Returns the number of TestPartResult objects in the array.\n\n int size() const;\n\n\n\n private:\n\n std::vector<TestPartResult> array_;\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);\n\n};\n\n\n", "file_path": "contrib/gtest/include/gtest/gtest-test-part.h", "rank": 25, "score": 121351.07074650456 }, { "content": "class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {\n\n public:\n\n // ParamType and GeneratorCreationFunc are private types but are required\n\n // for declarations of public methods AddTestPattern() and\n\n // AddTestCaseInstantiation().\n\n typedef typename TestCase::ParamType ParamType;\n\n // A function that returns an instance of appropriate generator type.\n\n typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();\n\n\n\n explicit ParameterizedTestCaseInfo(const char* name)\n\n : test_case_name_(name) {}\n\n\n\n // Test case base name for display purposes.\n\n virtual const string& GetTestCaseName() const { return test_case_name_; }\n\n // Test case id to verify identity.\n\n virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }\n\n // TEST_P macro uses AddTestPattern() to record information\n\n // about a single test in a LocalTestInfo structure.\n\n // test_case_name is the base name of the test case (without invocation\n\n // prefix). test_base_name is the name of an individual test without\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-param-util.h", "rank": 26, "score": 121333.30024584994 }, { "content": "class BaseTest : public ::testing::Test {\n\n // You can inherit all the usual members for a non-parameterized test\n\n // fixture here.\n\n};\n\n\n", "file_path": "contrib/gtest/include/gtest/gtest-param-test.h", "rank": 27, "score": 120683.1105999683 }, { "content": "class FooTest : public testing::Test {\n\n ...\n\n};\n\n\n\n// Next, declare that you will define a type-parameterized test case\n\n// (the _P suffix is for \"parameterized\" or \"pattern\", whichever you\n\n// prefer):\n\nTYPED_TEST_CASE_P(FooTest);\n\n\n\n// Then, use TYPED_TEST_P() to define as many type-parameterized tests\n\n// for this type-parameterized test case as you want.\n\nTYPED_TEST_P(FooTest, DoesBlah) {\n\n // Inside a test, refer to TypeParam to get the type parameter.\n\n TypeParam n = 0;\n\n ...\n\n}\n\n\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n\n\n\n// Now the tricky part: you need to register all test patterns before\n", "file_path": "contrib/gtest/include/gtest/gtest-typed-test.h", "rank": 28, "score": 120683.1105999683 }, { "content": "// A class representing the parsed contents of the\n\n// --gtest_internal_run_death_test flag, as it existed when\n\n// RUN_ALL_TESTS was called.\n\nclass InternalRunDeathTestFlag {\n\n public:\n\n InternalRunDeathTestFlag(const std::string& a_file,\n\n int a_line,\n\n int an_index,\n\n int a_write_fd)\n\n : file_(a_file), line_(a_line), index_(an_index),\n\n write_fd_(a_write_fd) {}\n\n\n\n ~InternalRunDeathTestFlag() {\n\n if (write_fd_ >= 0)\n\n posix::Close(write_fd_);\n\n }\n\n\n\n const std::string& file() const { return file_; }\n\n int line() const { return line_; }\n\n int index() const { return index_; }\n\n int write_fd() const { return write_fd_; }\n\n\n\n private:\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-death-test-internal.h", "rank": 29, "score": 118276.0200848327 }, { "content": "// A concrete DeathTestFactory implementation for normal use.\n\nclass DefaultDeathTestFactory : public DeathTestFactory {\n\n public:\n\n virtual bool Create(const char* statement, const RE* regex,\n\n const char* file, int line, DeathTest** test);\n\n};\n\n\n\n// Returns true if exit_status describes a process that was terminated\n\n// by a signal, or exited normally with a nonzero exit code.\n\nGTEST_API_ bool ExitedUnsuccessfully(int exit_status);\n\n\n\n// Traps C++ exceptions escaping statement and reports them as test\n\n// failures. Note that trapping SEH exceptions is not implemented here.\n\n# if GTEST_HAS_EXCEPTIONS\n\n# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n\n try { \\\n\n GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n\n } catch (const ::std::exception& gtest_exception) { \\\n\n fprintf(\\\n\n stderr, \\\n\n \"\\n%s: Caught std::exception-derived exception escaping the \" \\\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-death-test-internal.h", "rank": 30, "score": 117587.11139711636 }, { "content": " class TestName : public CaseName<gtest_TypeParam_> { \\\n\n private: \\\n\n typedef CaseName<gtest_TypeParam_> TestFixture; \\\n\n typedef gtest_TypeParam_ TypeParam; \\\n\n virtual void TestBody(); \\\n\n }; \\\n\n static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\\\n\n __FILE__, __LINE__, #CaseName, #TestName); \\\n\n } \\\n\n template <typename gtest_TypeParam_> \\\n\n void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()\n\n\n\n# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \\\n\n namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n\n typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \\\n\n } \\\n\n static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\\\n\n __FILE__, __LINE__, #__VA_ARGS__)\n", "file_path": "contrib/gtest/include/gtest/gtest-typed-test.h", "rank": 31, "score": 115310.9305341135 }, { "content": " class FormatForComparison<CharType*, OtherStringType> { \\\n\n public: \\\n\n static ::std::string Format(CharType* value) { \\\n\n return ::testing::PrintToString(value); \\\n\n } \\\n\n }\n\n\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);\n\n\n\n#if GTEST_HAS_GLOBAL_STRING\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);\n\n#endif\n\n\n\n#if GTEST_HAS_GLOBAL_WSTRING\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);\n\n#endif\n\n\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 32, "score": 114900.56562941923 }, { "content": " // A helper class that aborts a death test when it's deleted.\n\n class ReturnSentinel {\n\n public:\n\n explicit ReturnSentinel(DeathTest* test) : test_(test) { }\n\n ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }\n\n private:\n\n DeathTest* const test_;\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);\n\n } GTEST_ATTRIBUTE_UNUSED_;\n\n\n\n // An enumeration of possible roles that may be taken when a death\n\n // test is encountered. EXECUTE means that the death test logic should\n\n // be executed immediately. OVERSEE means that the program should prepare\n\n // the appropriate environment for a child process to execute the death\n\n // test, then wait for it to complete.\n\n enum TestRole { OVERSEE_TEST, EXECUTE_TEST };\n\n\n\n // An enumeration of the three reasons that a test might be aborted.\n\n enum AbortReason {\n\n TEST_ENCOUNTERED_RETURN_STATEMENT,\n\n TEST_THREW_EXCEPTION,\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-death-test-internal.h", "rank": 33, "score": 114422.96237998035 }, { "content": "class TypeParameterizedTestCase {\n\n public:\n\n static bool Register(const char* prefix, const char* case_name,\n\n const char* test_names) {\n\n typedef typename Tests::Head Head;\n\n\n\n // First, register the first test in 'Test' for each type in 'Types'.\n\n TypeParameterizedTest<Fixture, Head, Types>::Register(\n\n prefix, case_name, test_names, 0);\n\n\n\n // Next, recurses (at compile time) with the tail of the test list.\n\n return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>\n\n ::Register(prefix, case_name, SkipComma(test_names));\n\n }\n\n};\n\n\n\n// The base case for the compile time recursion.\n\ntemplate <GTEST_TEMPLATE_ Fixture, typename Types>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 34, "score": 114399.93609907497 }, { "content": "class EqHelper<true> {\n\n public:\n\n // We define two overloaded versions of Compare(). The first\n\n // version will be picked when the second argument to ASSERT_EQ() is\n\n // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or\n\n // EXPECT_EQ(false, a_bool).\n\n template <typename T1, typename T2>\n\n static AssertionResult Compare(\n\n const char* expected_expression,\n\n const char* actual_expression,\n\n const T1& expected,\n\n const T2& actual,\n\n // The following line prevents this overload from being considered if T2\n\n // is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr)\n\n // expands to Compare(\"\", \"\", NULL, my_ptr), which requires a conversion\n\n // to match the Secret* in the other overload, which would otherwise make\n\n // this template match better.\n\n typename EnableIf<!is_pointer<T2>::value>::type* = 0) {\n\n return CmpHelperEQ(expected_expression, actual_expression, expected,\n\n actual);\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 35, "score": 113471.1477734653 }, { "content": "// The abstract class that all tests inherit from.\n\n//\n\n// In Google Test, a unit test program contains one or many TestCases, and\n\n// each TestCase contains one or many Tests.\n\n//\n\n// When you define a test using the TEST macro, you don't need to\n\n// explicitly derive from Test - the TEST macro automatically does\n\n// this for you.\n\n//\n\n// The only time you derive from Test is when defining a test fixture\n\n// to be used a TEST_F. For example:\n\n//\n\n// class FooTest : public testing::Test {\n\n// protected:\n\n// virtual void SetUp() { ... }\n\n// virtual void TearDown() { ... }\n\n// ...\n\n// };\n\n//\n\n// TEST_F(FooTest, Bar) { ... }\n\n// TEST_F(FooTest, Baz) { ... }\n\n//\n\n// Test is not copyable.\n\nclass GTEST_API_ Test {\n\n public:\n\n friend class TestInfo;\n\n\n\n // Defines types for pointers to functions that set up and tear down\n\n // a test case.\n\n typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc;\n\n typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc;\n\n\n\n // The d'tor is virtual as we intend to inherit from Test.\n\n virtual ~Test();\n\n\n\n // Sets up the stuff shared by all tests in this test case.\n\n //\n\n // Google Test will call Foo::SetUpTestCase() before running the first\n\n // test in test case Foo. Hence a sub-class can define its own\n\n // SetUpTestCase() method to shadow the one defined in the super\n\n // class.\n\n static void SetUpTestCase() {}\n\n\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 36, "score": 112945.95526337135 }, { "content": "#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\\\n\nclass GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\\\n\n public:\\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\\\n\n private:\\\n\n virtual void TestBody();\\\n\n static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\\\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\\\n\n};\\\n\n\\\n\n::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\\\n\n ::test_info_ =\\\n\n ::testing::internal::MakeAndRegisterTestInfo(\\\n\n #test_case_name, #test_name, NULL, NULL, \\\n\n (parent_id), \\\n\n parent_class::SetUpTestCase, \\\n\n parent_class::TearDownTestCase, \\\n\n new ::testing::internal::TestFactoryImpl<\\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\\\n\nvoid GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n\n\n#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 37, "score": 112783.013396822 }, { "content": "// This is the default global test part result reporter used in UnitTestImpl.\n\n// This class should only be used by UnitTestImpl.\n\nclass DefaultGlobalTestPartResultReporter\n\n : public TestPartResultReporterInterface {\n\n public:\n\n explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);\n\n // Implements the TestPartResultReporterInterface. Reports the test part\n\n // result in the current test.\n\n virtual void ReportTestPartResult(const TestPartResult& result);\n\n\n\n private:\n\n UnitTestImpl* const unit_test_;\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);\n\n};\n\n\n", "file_path": "contrib/gtest/src/gtest-internal-inl.h", "rank": 38, "score": 112474.01373100533 }, { "content": "// Helper for suppressing false warning from Clang on a const char*\n\n// variable declared in a conditional expression always being NULL in\n\n// the else branch.\n\nstruct GTEST_API_ ConstCharPtr {\n\n ConstCharPtr(const char* str) : value(str) {}\n\n operator bool() const { return true; }\n\n const char* value;\n\n};\n\n\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 39, "score": 111362.86847539643 }, { "content": "struct TupleElement<true, 2, GTEST_10_TUPLE_(T) > {\n\n typedef T2 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 40, "score": 111008.48755829463 }, { "content": "struct TupleElement<true, 1, GTEST_10_TUPLE_(T) > {\n\n typedef T1 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 41, "score": 111006.85553528769 }, { "content": "struct TupleElement<true, 0, GTEST_10_TUPLE_(T) > {\n\n typedef T0 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 42, "score": 111005.26175149335 }, { "content": " class GTestExpectFatalFailureHelper {\\\n\n public:\\\n\n static void Execute() { statement; }\\\n\n };\\\n\n ::testing::TestPartResultArray gtest_failures;\\\n\n ::testing::internal::SingleFailureChecker gtest_checker(\\\n\n &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n\n {\\\n\n ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n\n ::testing::ScopedFakeTestPartResultReporter:: \\\n\n INTERCEPT_ALL_THREADS, &gtest_failures);\\\n\n GTestExpectFatalFailureHelper::Execute();\\\n\n }\\\n\n } while (::testing::internal::AlwaysFalse())\n\n\n\n// A macro for testing Google Test assertions or code that's expected to\n\n// generate Google Test non-fatal failures. It asserts that the given\n\n// statement will cause exactly one non-fatal Google Test failure with 'substr'\n\n// being part of the failure message.\n\n//\n", "file_path": "contrib/gtest/include/gtest/gtest-spi.h", "rank": 43, "score": 110879.36120411396 }, { "content": "// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n\n//\n\n// ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase\n\n// classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P\n\n// macros use it to locate their corresponding ParameterizedTestCaseInfo\n\n// descriptors.\n\nclass ParameterizedTestCaseRegistry {\n\n public:\n\n ParameterizedTestCaseRegistry() {}\n\n ~ParameterizedTestCaseRegistry() {\n\n for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n\n it != test_case_infos_.end(); ++it) {\n\n delete *it;\n\n }\n\n }\n\n\n\n // Looks up or creates and returns a structure containing information about\n\n // tests and instantiations of a particular test case.\n\n template <class TestCase>\n\n ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(\n\n const char* test_case_name,\n\n const char* file,\n\n int line) {\n\n ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;\n\n for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n\n it != test_case_infos_.end(); ++it) {\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-param-util.h", "rank": 44, "score": 110876.86288887524 }, { "content": "class AssertionResult; // Result of an assertion.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 45, "score": 109646.29245777111 }, { "content": "int main() {\n\n return 0;\n", "file_path": "tools/macpo/tests/integration-tests/test-files/file_001.c", "rank": 46, "score": 109563.82349724433 }, { "content": "// This is the default per thread test part result reporter used in\n\n// UnitTestImpl. This class should only be used by UnitTestImpl.\n\nclass DefaultPerThreadTestPartResultReporter\n\n : public TestPartResultReporterInterface {\n\n public:\n\n explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);\n\n // Implements the TestPartResultReporterInterface. The implementation just\n\n // delegates to the current global test part result reporter of *unit_test_.\n\n virtual void ReportTestPartResult(const TestPartResult& result);\n\n\n\n private:\n\n UnitTestImpl* const unit_test_;\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);\n\n};\n\n\n", "file_path": "contrib/gtest/src/gtest-internal-inl.h", "rank": 47, "score": 109101.93627536387 }, { "content": "class TestInfo; // Information about a test.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 48, "score": 108967.68419189227 }, { "content": "class UniversalTersePrinter<char*> {\n\n public:\n\n static void Print(char* str, ::std::ostream* os) {\n\n UniversalTersePrinter<const char*>::Print(str, os);\n\n }\n\n};\n\n\n\n#if GTEST_HAS_STD_WSTRING\n\ntemplate <>\n", "file_path": "contrib/gtest/include/gtest/gtest-printers.h", "rank": 49, "score": 107956.29325189043 }, { "content": "#\n\n\n\n# Dedicated to Ashay, who loves Perl. \n\n\n\nuse Term::ANSIColor;\n\nuse warnings;\n\nuse strict;\n\n\n\nmy $SRCDIR=\".\";\n\n$ENV{PERFEXPERT_SRCDIR}=$SRCDIR;\n\n$ENV{PERFEXPERT_BIN}=\"./tools/perfexpert\";\n\n\n\nforeach my $test (`ls $SRCDIR/tests`) {\n\n chomp($test);\n\n if (\"run_tests.pl.in\" ne $test) {\n\n printf(\"%s $test\\n\", colored(\"Testing\", 'blue'));\n\n if (-x \"$SRCDIR/tests/$test/run\") {\n\n system(\"$SRCDIR/tests/$test/run\");\n\n if ($? eq 0) {\n\n printf(\"%s\\n\\n\", colored(\"Test PASSED!\", 'green'));\n", "file_path": "tests/stampede_run_tests.pl", "rank": 50, "score": 107825.63801348092 }, { "content": " } else {\n\n printf(\"%s\\n\\n\", colored(\"Test FAILED!\", 'red'));\n\n }\n\n } else {\n\n printf(\"%s\\n\\n\", colored(\"Test SKIPED!\", 'magenta'));\n\n }\n\n }\n\n} \n\n\n\n# EOF\n", "file_path": "tests/stampede_run_tests.pl", "rank": 51, "score": 107824.4879756002 }, { "content": "#!/usr/bin/perl\n\n#\n\n# Copyright (c) 2011-2013 University of Texas at Austin. All rights reserved.\n\n#\n\n# $COPYRIGHT$\n\n#\n\n# Additional copyrights may follow\n\n#\n\n# This file is part of PerfExpert.\n\n#\n\n# PerfExpert is free software: you can redistribute it and/or modify it under\n\n# the terms of the The University of Texas at Austin Research License\n\n# \n\n# PerfExpert is distributed in the hope that it will be useful, but WITHOUT ANY\n\n# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n\n# A PARTICULAR PURPOSE.\n\n# \n\n# Authors: Leonardo Fialho and Ashay Rane\n\n#\n\n# $HEADER$\n", "file_path": "tests/stampede_run_tests.pl", "rank": 52, "score": 107813.1063635876 }, { "content": "// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n\n//\n\n// ParameterizedTestCaseInfoBase is a generic interface\n\n// to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase\n\n// accumulates test information provided by TEST_P macro invocations\n\n// and generators provided by INSTANTIATE_TEST_CASE_P macro invocations\n\n// and uses that information to register all resulting test instances\n\n// in RegisterTests method. The ParameterizeTestCaseRegistry class holds\n\n// a collection of pointers to the ParameterizedTestCaseInfo objects\n\n// and calls RegisterTests() on each of them when asked.\n\nclass ParameterizedTestCaseInfoBase {\n\n public:\n\n virtual ~ParameterizedTestCaseInfoBase() {}\n\n\n\n // Base part of test case name for display purposes.\n\n virtual const string& GetTestCaseName() const = 0;\n\n // Test case id to verify identity.\n\n virtual TypeId GetTestCaseTypeId() const = 0;\n\n // UnitTest class invokes this method to register tests in this\n\n // test case right before running them in RUN_ALL_TESTS macro.\n\n // This method should not be called more then once on any single\n\n // instance of a ParameterizedTestCaseInfoBase derived class.\n\n virtual void RegisterTests() = 0;\n\n\n\n protected:\n\n ParameterizedTestCaseInfoBase() {}\n\n\n\n private:\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);\n\n};\n\n\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n\n//\n\n// ParameterizedTestCaseInfo accumulates tests obtained from TEST_P\n\n// macro invocations for a particular test case and generators\n\n// obtained from INSTANTIATE_TEST_CASE_P macro invocations for that\n\n// test case. It registers tests with all values generated by all\n\n// generators when asked.\n\ntemplate <class TestCase>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-param-util.h", "rank": 53, "score": 107555.99871481145 }, { "content": "// This helper class can be used to mock out Google Test failure reporting\n\n// so that we can test Google Test or code that builds on Google Test.\n\n//\n\n// An object of this class appends a TestPartResult object to the\n\n// TestPartResultArray object given in the constructor whenever a Google Test\n\n// failure is reported. It can either intercept only failures that are\n\n// generated in the same thread that created this object or it can intercept\n\n// all generated failures. The scope of this mock object can be controlled with\n\n// the second argument to the two arguments constructor.\n\nclass GTEST_API_ ScopedFakeTestPartResultReporter\n\n : public TestPartResultReporterInterface {\n\n public:\n\n // The two possible mocking modes of this object.\n\n enum InterceptMode {\n\n INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures.\n\n INTERCEPT_ALL_THREADS // Intercepts all failures.\n\n };\n\n\n\n // The c'tor sets this object as the test part result reporter used\n\n // by Google Test. The 'result' parameter specifies where to report the\n\n // results. This reporter will only catch failures generated in the current\n\n // thread. DEPRECATED\n\n explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);\n\n\n\n // Same as above, but you can choose the interception scope of this object.\n\n ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,\n\n TestPartResultArray* result);\n\n\n\n // The d'tor restores the previous test part result reporter.\n", "file_path": "contrib/gtest/include/gtest/gtest-spi.h", "rank": 54, "score": 104423.85463285269 }, { "content": "// State of the definition of a type-parameterized test case.\n\nclass GTEST_API_ TypedTestCasePState {\n\n public:\n\n TypedTestCasePState() : registered_(false) {}\n\n\n\n // Adds the given test name to defined_test_names_ and return true\n\n // if the test case hasn't been registered; otherwise aborts the\n\n // program.\n\n bool AddTestName(const char* file, int line, const char* case_name,\n\n const char* test_name) {\n\n if (registered_) {\n\n fprintf(stderr, \"%s Test %s must be defined before \"\n\n \"REGISTER_TYPED_TEST_CASE_P(%s, ...).\\n\",\n\n FormatFileLocation(file, line).c_str(), test_name, case_name);\n\n fflush(stderr);\n\n posix::Abort();\n\n }\n\n defined_test_names_.insert(test_name);\n\n return true;\n\n }\n\n\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 55, "score": 104419.852887712 }, { "content": "class TypeParameterizedTestCase<Fixture, Templates0, Types> {\n\n public:\n\n static bool Register(const char* /*prefix*/, const char* /*case_name*/,\n\n const char* /*test_names*/) {\n\n return true;\n\n }\n\n};\n\n\n\n#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n\n\n// Returns the current OS stack trace as an std::string.\n\n//\n\n// The maximum number of stack frames to be included is specified by\n\n// the gtest_stack_trace_depth flag. The skip_count parameter\n\n// specifies the number of top frames to be skipped, which doesn't\n\n// count against the number of frames to be included.\n\n//\n\n// For example, if Foo() calls Bar(), which in turn calls\n\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 56, "score": 104408.93139299935 }, { "content": "class UniversalPrinter<T[N]> {\n\n public:\n\n // Prints the given array, omitting some elements when there are too\n\n // many.\n\n static void Print(const T (&a)[N], ::std::ostream* os) {\n\n UniversalPrintArray(a, N, os);\n\n }\n\n};\n\n\n\n// Implements printing a reference type T&.\n\ntemplate <typename T>\n", "file_path": "contrib/gtest/include/gtest/gtest-printers.h", "rank": 57, "score": 103849.72347314154 }, { "content": "class TestWithParam : public Test, public WithParamInterface<T> {\n\n};\n\n\n\n#endif // GTEST_HAS_PARAM_TEST\n\n\n\n// Macros for indicating success/failure in test code.\n\n\n\n// ADD_FAILURE unconditionally adds a failure to the current test.\n\n// SUCCEED generates a success - it doesn't automatically make the\n\n// current test successful, as a test is only successful when it has\n\n// no failure.\n\n//\n\n// EXPECT_* verifies that a certain condition is satisfied. If not,\n\n// it behaves like ADD_FAILURE. In particular:\n\n//\n\n// EXPECT_TRUE verifies that a Boolean condition is true.\n\n// EXPECT_FALSE verifies that a Boolean condition is false.\n\n//\n\n// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except\n\n// that they will also abort the current function on failure. People\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 58, "score": 102635.76951966452 }, { "content": "class UniversalTersePrinter<T[N]> {\n\n public:\n\n static void Print(const T (&value)[N], ::std::ostream* os) {\n\n UniversalPrinter<T[N]>::Print(value, os);\n\n }\n\n};\n\ntemplate <>\n", "file_path": "contrib/gtest/include/gtest/gtest-printers.h", "rank": 59, "score": 101343.63516015209 }, { "content": "struct IteratorTraits<const T*> {\n\n typedef T value_type;\n\n};\n\n\n\n#if GTEST_OS_WINDOWS\n\n# define GTEST_PATH_SEP_ \"\\\\\"\n\n# define GTEST_HAS_ALT_PATH_SEP_ 1\n\n// The biggest signed integer type the compiler supports.\n\ntypedef __int64 BiggestInt;\n\n#else\n\n# define GTEST_PATH_SEP_ \"/\"\n\n# define GTEST_HAS_ALT_PATH_SEP_ 0\n\ntypedef long long BiggestInt; // NOLINT\n\n#endif // GTEST_OS_WINDOWS\n\n\n\n// Utilities for char.\n\n\n\n// isspace(int ch) and friends accept an unsigned char or EOF. char\n\n// may be signed, depending on the compiler (or compiler flags).\n\n// Therefore we need to cast a char to unsigned char before calling\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-port.h", "rank": 60, "score": 101331.60177960148 }, { "content": "class UniversalTersePrinter<const wchar_t*> {\n\n public:\n\n static void Print(const wchar_t* str, ::std::ostream* os) {\n\n if (str == NULL) {\n\n *os << \"NULL\";\n\n } else {\n\n UniversalPrint(::std::wstring(str), os);\n\n }\n\n }\n\n};\n\n#endif\n\n\n\ntemplate <>\n", "file_path": "contrib/gtest/include/gtest/gtest-printers.h", "rank": 61, "score": 101331.60177960148 }, { "content": "class FormatForComparison<ToPrint[N], OtherOperand> {\n\n public:\n\n static ::std::string Format(const ToPrint* value) {\n\n return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);\n\n }\n\n};\n\n\n\n// By default, print C string as pointers to be safe, as we don't know\n\n// whether they actually point to a NUL-terminated string.\n\n\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \\\n\n template <typename OtherOperand> \\\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 62, "score": 100751.21733245216 }, { "content": "struct RemoveConst<const T> { typedef T type; }; // NOLINT\n\n\n\n// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above\n\n// definition to fail to remove the const in 'const int[3]' and 'const\n\n// char[3][4]'. The following specialization works around the bug.\n\ntemplate <typename T, size_t N>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-internal.h", "rank": 63, "score": 97699.78528635167 }, { "content": "class vector_strides_t : public traversal_t {\n\n public:\n\n explicit vector_strides_t(const du_table_t& def_table) :\n\n traversal_t(def_table) {}\n\n\n\n private:\n\n bool instrument_loop(loop_info_t& loop_info);\n\n bool contains_non_linear_reference(const reference_list_t& reference_list);\n\n};\n\n\n\n#endif // TOOLS_MACPO_INST_INCLUDE_VECTOR_STRIDES_H_\n", "file_path": "tools/macpo/libmacpo/include/vector_strides.h", "rank": 64, "score": 92125.15888071405 }, { "content": "// A concrete death test class that forks, then immediately runs the test\n\n// in the child process.\n\nclass NoExecDeathTest : public ForkingDeathTest {\n\n public:\n\n NoExecDeathTest(const char* a_statement, const RE* a_regex) :\n\n ForkingDeathTest(a_statement, a_regex) { }\n\n virtual TestRole AssumeRole();\n\n};\n\n\n\n// The AssumeRole process for a fork-and-run death test. It implements a\n\n// straightforward fork, with a simple pipe to transmit the status byte.\n\nDeathTest::TestRole NoExecDeathTest::AssumeRole() {\n\n const size_t thread_count = GetThreadCount();\n\n if (thread_count != 1) {\n\n GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count);\n\n }\n\n\n\n int pipe_fd[2];\n\n GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);\n\n\n\n DeathTest::set_last_death_test_message(\"\");\n\n CaptureStderr();\n", "file_path": "contrib/gtest/src/gtest-death-test.cc", "rank": 65, "score": 91735.26279503573 }, { "content": "// A concrete death test class that forks and re-executes the main\n\n// program from the beginning, with command-line flags set that cause\n\n// only this specific death test to be run.\n\nclass ExecDeathTest : public ForkingDeathTest {\n\n public:\n\n ExecDeathTest(const char* a_statement, const RE* a_regex,\n\n const char* file, int line) :\n\n ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }\n\n virtual TestRole AssumeRole();\n\n private:\n\n static ::std::vector<testing::internal::string>\n\n GetArgvsForDeathTestChildProcess() {\n\n ::std::vector<testing::internal::string> args = GetInjectableArgvs();\n\n return args;\n\n }\n\n // The name of the file in which the death test is located.\n\n const char* const file_;\n\n // The line number on which the death test is located.\n\n const int line_;\n\n};\n\n\n", "file_path": "contrib/gtest/src/gtest-death-test.cc", "rank": 66, "score": 91733.09355229305 }, { "content": "// ForkingDeathTest provides implementations for most of the abstract\n\n// methods of the DeathTest interface. Only the AssumeRole method is\n\n// left undefined.\n\nclass ForkingDeathTest : public DeathTestImpl {\n\n public:\n\n ForkingDeathTest(const char* statement, const RE* regex);\n\n\n\n // All of these virtual functions are inherited from DeathTest.\n\n virtual int Wait();\n\n\n\n protected:\n\n void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }\n\n\n\n private:\n\n // PID of child process during death test; 0 in the child process itself.\n\n pid_t child_pid_;\n\n};\n\n\n\n// Constructs a ForkingDeathTest.\n\nForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex)\n\n : DeathTestImpl(a_statement, a_regex),\n\n child_pid_(-1) {}\n\n\n", "file_path": "contrib/gtest/src/gtest-death-test.cc", "rank": 67, "score": 91718.76603037315 }, { "content": "struct TupleElement<true, 5, GTEST_10_TUPLE_(T) > {\n\n typedef T5 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 68, "score": 91242.46752308306 }, { "content": "struct TupleElement<true, 9, GTEST_10_TUPLE_(T) > {\n\n typedef T9 type;\n\n};\n\n\n\n} // namespace gtest_internal\n\n\n\ntemplate <>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 69, "score": 91242.46752308306 }, { "content": "struct TupleElement<true, 4, GTEST_10_TUPLE_(T) > {\n\n typedef T4 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 70, "score": 91242.46752308306 }, { "content": "struct TupleElement<true, 6, GTEST_10_TUPLE_(T) > {\n\n typedef T6 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 71, "score": 91242.46752308306 }, { "content": "struct TupleElement<true, 7, GTEST_10_TUPLE_(T) > {\n\n typedef T7 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 72, "score": 91242.46752308306 }, { "content": "struct TupleElement<true, 3, GTEST_10_TUPLE_(T) > {\n\n typedef T3 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 73, "score": 91242.46752308306 }, { "content": "struct TupleElement<true, 8, GTEST_10_TUPLE_(T) > {\n\n typedef T8 type;\n\n};\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 74, "score": 91242.46752308306 }, { "content": "// A struct that encompasses the arguments to the child process of a\n\n// threadsafe-style death test process.\n\nstruct ExecDeathTestArgs {\n\n char* const* argv; // Command-line arguments for the child's call to exec\n\n int close_fd; // File descriptor to close; the read end of a pipe\n\n};\n\n\n\n# if GTEST_OS_MAC\n\ninline char** GetEnviron() {\n\n // When Google Test is built as a framework on MacOS X, the environ variable\n\n // is unavailable. Apple's documentation (man environ) recommends using\n\n // _NSGetEnviron() instead.\n\n return *_NSGetEnviron();\n\n}\n\n# else\n\n// Some POSIX platforms expect you to declare environ. extern \"C\" makes\n\n// it reside in the global namespace.\n\nextern \"C\" char** environ;\n\ninline char** GetEnviron() { return environ; }\n\n# endif // GTEST_OS_MAC\n\n\n\n# if !GTEST_OS_QNX\n", "file_path": "contrib/gtest/src/gtest-death-test.cc", "rank": 75, "score": 90878.62956761943 }, { "content": "/*\n\n * Copyright (c) 2011-2013 University of Texas at Austin. All rights reserved.\n\n *\n\n * $COPYRIGHT$\n\n *\n\n * Additional copyrights may follow\n\n *\n\n * This file is part of PerfExpert.\n\n *\n\n * PerfExpert is free software: you can redistribute it and/or modify it under\n\n * the terms of the The University of Texas at Austin Research License\n\n * \n\n * PerfExpert is distributed in the hope that it will be useful, but WITHOUT ANY\n\n * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n\n * A PARTICULAR PURPOSE.\n\n * \n\n * Authors: Leonardo Fialho and Ashay Rane\n\n *\n\n * $HEADER$\n\n */\n\n\n\n#ifndef TOOLS_MACPO_INST_INCLUDE_VECTOR_STRIDES_H_\n\n#define TOOLS_MACPO_INST_INCLUDE_VECTOR_STRIDES_H_\n\n\n\n#include <rose.h>\n\n\n\n#include \"inst_defs.h\"\n\n#include \"traversal.h\"\n\n\n", "file_path": "tools/macpo/libmacpo/include/vector_strides.h", "rank": 76, "score": 90364.3360841974 }, { "content": "struct ByRef { typedef const T& type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-tuple.h", "rank": 77, "score": 89306.38185299549 }, { "content": "class UnitTestRecordPropertyTestHelper;\n", "file_path": "contrib/gtest/include/gtest/gtest.h", "rank": 78, "score": 89215.83346589356 }, { "content": "bool verify_output(std::string& filename, std::string& binary);\n", "file_path": "tools/macpo/tests/integration-tests/itest_harness.h", "rank": 79, "score": 88555.82591137465 }, { "content": "static void populate_args(string_list_t& args, std::string& input_file,\n", "file_path": "tools/macpo/tests/integration-tests/itest_harness.h", "rank": 80, "score": 88554.52969662425 }, { "content": "static void print_args(const string_list_t& args);\n", "file_path": "tools/macpo/tests/integration-tests/itest_harness.h", "rank": 81, "score": 88554.52969662425 }, { "content": "bool file_exists(const std::string& filename);\n", "file_path": "tools/macpo/tests/integration-tests/itest_harness.h", "rank": 82, "score": 88505.32598517192 }, { "content": " long int pid;\n", "file_path": "tools/ct/ct.h", "rank": 83, "score": 88073.0262152718 }, { "content": " volatile size_t length;\n", "file_path": "common/perfexpert_list.h", "rank": 84, "score": 88068.13148858436 }, { "content": " def Count(self):\n\n \"\"\"Count line in current function body.\"\"\"\n\n if self.in_a_function:\n", "file_path": "scripts/cpplint.py", "rank": 85, "score": 88046.37528652625 }, { "content": " char *program;\n", "file_path": "tools/ct/ct.h", "rank": 86, "score": 88042.95330683165 }, { "content": " unsigned count;\n", "file_path": "common/perfexpert_hash.h", "rank": 87, "score": 88040.76866767477 }, { "content": " char *file;\n", "file_path": "tools/ct/ct.h", "rank": 88, "score": 87948.12991245041 }, { "content": " // Compares two C strings, ignoring case. Returns true iff they\n\n // have the same content.\n\n //\n\n // Unlike strcasecmp(), this function can handle NULL argument(s).\n\n // A NULL C string is considered different to any non-NULL C string,\n\n // including the empty string.\n\n static bool CaseInsensitiveCStringEquals(const char* lhs,\n\n const char* rhs);\n\n\n\n // Compares two wide C strings, ignoring case. Returns true iff they\n\n // have the same content.\n\n //\n\n // Unlike wcscasecmp(), this function can handle NULL argument(s).\n\n // A NULL C string is considered different to any non-NULL wide C string,\n\n // including the empty string.\n\n // NB: The implementations on different platforms slightly differ.\n\n // On windows, this method uses _wcsicmp which compares according to LC_CTYPE\n\n // environment variable. On GNU platform this method uses wcscasecmp\n\n // which compares according to LC_CTYPE category of the current locale.\n\n // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 89, "score": 87211.80007802583 }, { "content": " //\n\n // Unlike strcmp(), this function can handle NULL argument(s). A\n\n // NULL C string is considered different to any non-NULL C string,\n\n // including the empty string.\n\n static bool CStringEquals(const char* lhs, const char* rhs);\n\n\n\n // Converts a wide C string to a String using the UTF-8 encoding.\n\n // NULL will be converted to \"(null)\". If an error occurred during\n\n // the conversion, \"(failed to convert from wide string)\" is\n\n // returned.\n\n static std::string ShowWideCString(const wchar_t* wide_c_str);\n\n\n\n // Compares two wide C strings. Returns true iff they have the same\n\n // content.\n\n //\n\n // Unlike wcscmp(), this function can handle NULL argument(s). A\n\n // NULL C string is considered different to any non-NULL C string,\n\n // including the empty string.\n\n static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);\n\n\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 90, "score": 87211.38324777065 }, { "content": " // current locale.\n\n static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,\n\n const wchar_t* rhs);\n\n\n\n // Returns true iff the given string ends with the given suffix, ignoring\n\n // case. Any string is considered to end with an empty suffix.\n\n static bool EndsWithCaseInsensitive(\n\n const std::string& str, const std::string& suffix);\n\n\n\n // Formats an int value as \"%02d\".\n\n static std::string FormatIntWidth2(int value); // \"%02d\" for width == 2\n\n\n\n // Formats an int value as \"%X\".\n\n static std::string FormatHexInt(int value);\n\n\n\n // Formats a byte as \"%02X\".\n\n static std::string FormatByte(unsigned char value);\n\n\n\n private:\n\n String(); // Not meant to be instantiated.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 91, "score": 87209.8044068217 }, { "content": " // value using delete[]. Returns the wide string, or NULL if the\n\n // input is NULL.\n\n //\n\n // The wide string is created using the ANSI codepage (CP_ACP) to\n\n // match the behaviour of the ANSI versions of Win32 calls and the\n\n // C runtime.\n\n static LPCWSTR AnsiToUtf16(const char* c_str);\n\n\n\n // Creates an ANSI string from the given wide string, allocating\n\n // memory using new. The caller is responsible for deleting the return\n\n // value using delete[]. Returns the ANSI string, or NULL if the\n\n // input is NULL.\n\n //\n\n // The returned string is created using the ANSI codepage (CP_ACP) to\n\n // match the behaviour of the ANSI versions of Win32 calls and the\n\n // C runtime.\n\n static const char* Utf16ToAnsi(LPCWSTR utf16_str);\n\n#endif\n\n\n\n // Compares two C strings. Returns true iff they have the same content.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 92, "score": 87203.11264076167 }, { "content": "#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n\n\n\n#ifdef __BORLANDC__\n\n// string.h is not guaranteed to provide strcpy on C++ Builder.\n\n# include <mem.h>\n\n#endif\n\n\n\n#include <string.h>\n\n#include <string>\n\n\n\n#include \"gtest/internal/gtest-port.h\"\n\n\n\nnamespace testing {\n\nnamespace internal {\n\n\n\n// String - an abstract class holding static string utilities.\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 93, "score": 87192.99126967072 }, { "content": "}; // class String\n\n\n\n// Gets the content of the stringstream's buffer as an std::string. Each '\\0'\n\n// character in the buffer is replaced with \"\\\\0\".\n\nGTEST_API_ std::string StringStreamToString(::std::stringstream* stream);\n\n\n\n} // namespace internal\n\n} // namespace testing\n\n\n\n#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 94, "score": 87191.76851982695 }, { "content": "// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n\n// Authors: [email protected] (Zhanyong Wan), [email protected] (Sean Mcafee)\n\n//\n\n// The Google C++ Testing Framework (Google Test)\n\n//\n\n// This header file declares the String class and functions used internally by\n\n// Google Test. They are subject to change without notice. They should not used\n\n// by code external to Google Test.\n\n//\n\n// This header file is #included by <gtest/internal/gtest-internal.h>.\n\n// It should not be #included by other files.\n\n\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 95, "score": 87185.54976955795 }, { "content": "// Copyright 2005, Google Inc.\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted provided that the following conditions are\n\n// met:\n\n//\n\n// * Redistributions of source code must retain the above copyright\n\n// notice, this list of conditions and the following disclaimer.\n\n// * Redistributions in binary form must reproduce the above\n\n// copyright notice, this list of conditions and the following disclaimer\n\n// in the documentation and/or other materials provided with the\n\n// distribution.\n\n// * Neither the name of Google Inc. nor the names of its\n\n// contributors may be used to endorse or promote products derived from\n\n// this software without specific prior written permission.\n\n//\n\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n", "file_path": "contrib/gtest/include/gtest/internal/gtest-string.h", "rank": 96, "score": 87179.79223100879 } ]
C++
Common/Loader/ssloader_sspj.cpp
SpriteStudio/SpriteStudio6-SDK
f2ad84c8e3ca9d189904da9c3d1114bb4044eecb
#include "ssloader_sspj.h" #include "ssloader_ssae.h" #include "ssloader_ssce.h" #include "ssloader_ssee.h" #include "ssloader_ssqe.h" #include "ssstring_uty.h" #include "../Helper/DebugPrint.h" #include "sscharconverter.h" namespace spritestudio6 { SsString SsProject::getSsceBasepath(){ return getFullPath( m_proj_filepath , settings.cellMapBaseDirectory ); } SsString SsProject::getSsaeBasepath() { return getFullPath( m_proj_filepath , settings.animeBaseDirectory ); } SsString SsProject::getSseeBasepath() { return getFullPath( m_proj_filepath , settings.effectBaseDirectory); } SsString SsProject::getSsqeBasepath() { return getFullPath( m_proj_filepath , settings.animeBaseDirectory ); } SsString SsProject::getImageBasepath() { return getFullPath( m_proj_filepath , settings.imageBaseDirectory ); } SsProject::~SsProject() { for ( SsAnimePackListItr itr = animeList.begin() ; itr != animeList.end() ; itr ++ ) itr->reset(); animeList.clear(); for ( SsSsCellMapList::iterator itr = cellmapList.begin() ; itr != cellmapList.end() ; itr ++ ) itr->reset(); cellmapList.clear(); for ( SsEffectFileList::iterator itr = effectfileList.begin() ; itr != effectfileList.end() ; itr ++ ) itr->reset(); effectfileList.clear(); for ( SsSequencePackList::iterator itr = sequenceList.begin() ; itr != sequenceList.end() ; itr ++ ) itr->reset(); sequenceList.clear(); cellmapNames.clear(); animepackNames.clear(); effectFileNames.clear(); textureList.clear(); sequencepackNames.clear(); } SsAnimePack* SsProject::findAnimationPack( SsString& animePackName ) { SsAnimePack* anime; for ( SsAnimePackListItr itr = animeList.begin() ; itr != animeList.end() ; ++itr ) { anime = itr->get(); if ( anime->name == animePackName ) { return anime; } } return 0; } SsAnimation* SsProject::findAnimation( SsString& animePackName , SsString& AnimeName ) { SsAnimePack* p = findAnimationPack( animePackName ); if ( p ) { return p->findAnimation(AnimeName); } return 0; } SsEffectFile* SsProject::findEffect( SsString& effectName ) { SsEffectFile* effect; for ( SsEffectFileListItr itr = effectfileList.begin() ; itr != effectfileList.end() ; ++itr ) { effect = itr->get(); if ( effect->name == effectName ) { return effect; } } return 0; } SsSequencePack* SsProject::findSequencePack( SsString& sequencePackName ) { SsSequencePack* sequence; for ( SsSequencePackListItr itr = sequenceList.begin() ; itr != sequenceList.end() ; ++itr ) { sequence = itr->get(); if ( sequence->name == sequencePackName ) { return sequence; } } return 0; } SsSequence* SsProject::findSequence( SsString& sequencePackName , SsString& SequenceName ) { SsSequencePack* p = findSequencePack( sequencePackName ); if ( p ) { return p->findSequence(SequenceName); } return 0; } SsProject* ssloader_sspj::Load(const std::string& filename ) { libXML::XMLDocument xml; std::string filenameSSPJ = SsCharConverter::convert_path_string( filename ); if ( libXML::XML_SUCCESS == xml.LoadFile( filenameSSPJ.c_str() ) ) { SsXmlIArchiver ar( xml.GetDocument() , "SpriteStudioProject" ); SsProject* proj = new SsProject(); proj->__Serialize( &ar ); std::string project_filepath = path2dir( filename ); proj->setFilepath( project_filepath ); if ( checkFileVersion(proj->version, SPRITESTUDIO6_SSPJVERSION) == false ) { DEBUG_PRINTF("Project load error : %s", project_filepath.c_str()); DEBUG_PRINTF("sspj old version"); delete proj; return 0; } for ( size_t i = 0 ;i < proj->getAnimePackNum() ; i++ ) { SsString ssaepath = SsCharConverter::convert_path_string(proj->getAnimePackFilePath(i)); SsAnimePack* anime = ssloader_ssae::Load( ssaepath ); if ( ( anime ) && ( checkFileVersion(anime->version, SPRITESTUDIO6_SSAEVERSION) == true ) ) { proj->animeList.push_back( std::move( std::unique_ptr<SsAnimePack>( anime ) ) ); }else{ DEBUG_PRINTF( "Animation load error : %s" , ssaepath.c_str() ); DEBUG_PRINTF( "ssae old version" ); if ( anime ) delete anime; delete proj; return 0; } } std::map<std::string, std::string> textures; for ( size_t i = 0 ;i < proj->getCellMapNum() ; i++ ) { SsString sscepath = SsCharConverter::convert_path_string(proj->getCellMapFilePath(i)); SsCellMap* cell = ssloader_ssce::Load( sscepath ); cell->loadFilepath = proj->getCelMapFileOriginalPath(i); proj->cellmapList.push_back( std::move( std::unique_ptr<SsCellMap>( cell ) ) ); textures[cell->imagePath] = sscepath; } proj->textureList.clear(); for (auto i = textures.begin(); i != textures.end(); i++) { proj->textureList.push_back(i->first); } for ( size_t i = 0 ;i < proj->getEffectFileNum() ; i++ ) { SsString sscepath = SsCharConverter::convert_path_string(proj->getEffectFilePath(i)); SsEffectFile* efile = ssloader_ssee::Load( sscepath ); ssloader_ssee::loadPostProcessing( efile, proj ); proj->effectfileList.push_back( std::move( std::unique_ptr<SsEffectFile>( efile ) ) ); } for ( size_t i = 0 ;i < proj->getSequencePackNum() ; i++ ) { SsString ssqepath = SsCharConverter::convert_path_string(proj->getSequencePackFilePath(i)); SsSequencePack* sequence = ssloader_ssqe::Load( ssqepath ); if ( ( sequence ) && ( checkFileVersion( sequence->version, SPRITESTUDIO6_SSQEVERSION) == true ) ) { proj->sequenceList.push_back( std::move( std::unique_ptr<SsSequencePack>( sequence ) ) ); }else{ DEBUG_PRINTF( "Sequence load error : %s" , ssqepath.c_str() ); DEBUG_PRINTF( "ssqe old version" ); if ( sequence ) delete sequence; delete proj; return 0; } } return proj; } return 0; } SsCellMap* SsProject::findCellMap( SsString& str ) { for ( SsSsCellMapListItr itr = cellmapList.begin() ; itr != cellmapList.end() ; itr ++) { SsCellMap* cellmap = itr->get(); SsString _name = cellmap->loadFilepath; if ( _name == str ) { return cellmap; } } return 0; } }
#include "ssloader_sspj.h" #include "ssloader_ssae.h" #include "ssloader_ssce.h" #include "ssloader_ssee.h" #include "ssloader_ssqe.h" #include "ssstring_uty.h" #include "../Helper/DebugPrint.h" #include "sscharconverter.h" namespace spritestudio6 { SsString SsProject::getSsceBasepath(){ return getFullPath( m_proj_filepath , settings.cellMapBaseDirectory ); } SsString SsProject::getSsaeBasepath() { return getFullPath( m_proj_filepath , settings.animeBaseDirectory ); } SsString SsProject::getSseeBasepath() { return getFullPath( m_proj_filepath , settings.effectBaseDirectory); } SsString SsProject::getSsqeBasepath() { return get
rsion" ); if ( anime ) delete anime; delete proj; return 0; } } std::map<std::string, std::string> textures; for ( size_t i = 0 ;i < proj->getCellMapNum() ; i++ ) { SsString sscepath = SsCharConverter::convert_path_string(proj->getCellMapFilePath(i)); SsCellMap* cell = ssloader_ssce::Load( sscepath ); cell->loadFilepath = proj->getCelMapFileOriginalPath(i); proj->cellmapList.push_back( std::move( std::unique_ptr<SsCellMap>( cell ) ) ); textures[cell->imagePath] = sscepath; } proj->textureList.clear(); for (auto i = textures.begin(); i != textures.end(); i++) { proj->textureList.push_back(i->first); } for ( size_t i = 0 ;i < proj->getEffectFileNum() ; i++ ) { SsString sscepath = SsCharConverter::convert_path_string(proj->getEffectFilePath(i)); SsEffectFile* efile = ssloader_ssee::Load( sscepath ); ssloader_ssee::loadPostProcessing( efile, proj ); proj->effectfileList.push_back( std::move( std::unique_ptr<SsEffectFile>( efile ) ) ); } for ( size_t i = 0 ;i < proj->getSequencePackNum() ; i++ ) { SsString ssqepath = SsCharConverter::convert_path_string(proj->getSequencePackFilePath(i)); SsSequencePack* sequence = ssloader_ssqe::Load( ssqepath ); if ( ( sequence ) && ( checkFileVersion( sequence->version, SPRITESTUDIO6_SSQEVERSION) == true ) ) { proj->sequenceList.push_back( std::move( std::unique_ptr<SsSequencePack>( sequence ) ) ); }else{ DEBUG_PRINTF( "Sequence load error : %s" , ssqepath.c_str() ); DEBUG_PRINTF( "ssqe old version" ); if ( sequence ) delete sequence; delete proj; return 0; } } return proj; } return 0; } SsCellMap* SsProject::findCellMap( SsString& str ) { for ( SsSsCellMapListItr itr = cellmapList.begin() ; itr != cellmapList.end() ; itr ++) { SsCellMap* cellmap = itr->get(); SsString _name = cellmap->loadFilepath; if ( _name == str ) { return cellmap; } } return 0; } }
FullPath( m_proj_filepath , settings.animeBaseDirectory ); } SsString SsProject::getImageBasepath() { return getFullPath( m_proj_filepath , settings.imageBaseDirectory ); } SsProject::~SsProject() { for ( SsAnimePackListItr itr = animeList.begin() ; itr != animeList.end() ; itr ++ ) itr->reset(); animeList.clear(); for ( SsSsCellMapList::iterator itr = cellmapList.begin() ; itr != cellmapList.end() ; itr ++ ) itr->reset(); cellmapList.clear(); for ( SsEffectFileList::iterator itr = effectfileList.begin() ; itr != effectfileList.end() ; itr ++ ) itr->reset(); effectfileList.clear(); for ( SsSequencePackList::iterator itr = sequenceList.begin() ; itr != sequenceList.end() ; itr ++ ) itr->reset(); sequenceList.clear(); cellmapNames.clear(); animepackNames.clear(); effectFileNames.clear(); textureList.clear(); sequencepackNames.clear(); } SsAnimePack* SsProject::findAnimationPack( SsString& animePackName ) { SsAnimePack* anime; for ( SsAnimePackListItr itr = animeList.begin() ; itr != animeList.end() ; ++itr ) { anime = itr->get(); if ( anime->name == animePackName ) { return anime; } } return 0; } SsAnimation* SsProject::findAnimation( SsString& animePackName , SsString& AnimeName ) { SsAnimePack* p = findAnimationPack( animePackName ); if ( p ) { return p->findAnimation(AnimeName); } return 0; } SsEffectFile* SsProject::findEffect( SsString& effectName ) { SsEffectFile* effect; for ( SsEffectFileListItr itr = effectfileList.begin() ; itr != effectfileList.end() ; ++itr ) { effect = itr->get(); if ( effect->name == effectName ) { return effect; } } return 0; } SsSequencePack* SsProject::findSequencePack( SsString& sequencePackName ) { SsSequencePack* sequence; for ( SsSequencePackListItr itr = sequenceList.begin() ; itr != sequenceList.end() ; ++itr ) { sequence = itr->get(); if ( sequence->name == sequencePackName ) { return sequence; } } return 0; } SsSequence* SsProject::findSequence( SsString& sequencePackName , SsString& SequenceName ) { SsSequencePack* p = findSequencePack( sequencePackName ); if ( p ) { return p->findSequence(SequenceName); } return 0; } SsProject* ssloader_sspj::Load(const std::string& filename ) { libXML::XMLDocument xml; std::string filenameSSPJ = SsCharConverter::convert_path_string( filename ); if ( libXML::XML_SUCCESS == xml.LoadFile( filenameSSPJ.c_str() ) ) { SsXmlIArchiver ar( xml.GetDocument() , "SpriteStudioProject" ); SsProject* proj = new SsProject(); proj->__Serialize( &ar ); std::string project_filepath = path2dir( filename ); proj->setFilepath( project_filepath ); if ( checkFileVersion(proj->version, SPRITESTUDIO6_SSPJVERSION) == false ) { DEBUG_PRINTF("Project load error : %s", project_filepath.c_str()); DEBUG_PRINTF("sspj old version"); delete proj; return 0; } for ( size_t i = 0 ;i < proj->getAnimePackNum() ; i++ ) { SsString ssaepath = SsCharConverter::convert_path_string(proj->getAnimePackFilePath(i)); SsAnimePack* anime = ssloader_ssae::Load( ssaepath ); if ( ( anime ) && ( checkFileVersion(anime->version, SPRITESTUDIO6_SSAEVERSION) == true ) ) { proj->animeList.push_back( std::move( std::unique_ptr<SsAnimePack>( anime ) ) ); }else{ DEBUG_PRINTF( "Animation load error : %s" , ssaepath.c_str() ); DEBUG_PRINTF( "ssae old ve
random
[ { "content": "namespace spritestudio6\n\n{\n\n\n\n\n", "file_path": "Common/Animator/ssplayer_types.h", "rank": 0, "score": 87211.16099266979 }, { "content": "namespace spritestudio6\n\n{\n\n\n\n\tconstexpr auto __PI__ = (3.14159265358979323846f);\n\n\t// #define RadianToDegree(Radian) ((double)Radian * (180.0f / __PI__))\n\n\ttemplate<typename T> inline double RadianToDegree(T Radian)\n\n\t{\n\n\t\treturn((double)Radian * (180.0f / __PI__));\n\n\t}\n\n\t// #define DegreeToRadian(Degree) ((double)Degree * (__PI__ / 180.0f))\n\n\ttemplate<typename T> inline double DegreeToRadian(T Degree)\n\n\t{\n\n\t\treturn((double)Degree * (__PI__ / 180.0f));\n\n\t}\n\n\n\n\t#define SPRITESTUDIO6SDK_foreach(T, c, i) for(T::iterator i = c.begin(); i!=c.end(); ++i)\n\n\n", "file_path": "Common/Animator/ssplayer_macro.h", "rank": 1, "score": 87211.16099266979 }, { "content": "namespace spritestudio6\n\n{\n\n\n\nvoid DEBUG_PRINTF( const char* strFormat, ... );\n\n\n\nstruct ThrowErrorMessage{\n\n\tstd::string message;\n\n\tint\terror_no;\n\n\n\n\tThrowErrorMessage( int no , std::string str ){ error_no = no ; message = str; }\n\n};\n\n\n\n// MEMO: 外部名前空間からアクセスされた時の防備で、念のため完全修飾してあります。\n\n#define SPRITESTUDIO6SDK_THROW_ERROR_MESSAGE(str) \\\n\n{\\\n\nspritestudio6::THROW_ERROR_MESSAGE_MAIN( str , __FILE__ , __LINE__ );\\\n\n}\\\n\n\n\nvoid\tTHROW_ERROR_MESSAGE_MAIN( std::string str , char* fname , size_t line );\n\n\n\n\n", "file_path": "Common/Helper/DebugPrint.h", "rank": 2, "score": 87211.16099266979 }, { "content": "#ifndef __SSSTRING_UTY__\n\n#define __SSSTRING_UTY__\n\n\n\n\n\n#include <string>\n\n#include <fstream>\n\n#include <vector>\n\n#include <iostream>\n\n#include <sstream>\n\n#include <fstream>\n\n#include <iterator>\n\n\n\nnamespace spritestudio6\n\n{\n\n\n\n/*\n\n * @brief 文字列を指定のkeyで分割して返します。\n\n *\n\n * @param[in] in_str\t\t分割する文字列\n\n * @param[in] key\t\t\t分割のキーとなる文字列\n", "file_path": "Common/Loader/ssstring_uty.h", "rank": 3, "score": 56257.02276805962 }, { "content": "\t\ttokenIndex++;\n\n\t\treturn !isEnd();\n\n\t}\n\n\n\n\tint\t\ttokenNum()\n\n\t{\n\n\t\treturn tokennum;\n\n\t}\n\n\n\n\tbool\tisEnd()\n\n\t{\n\n\t\treturn (tokennum <= tokenIndex);\n\n\t}\n\n\n\n};\n\n\n\n}\t// namespace spritestudio6\n\n\n\n#endif\n", "file_path": "Common/Loader/ssstring_uty.h", "rank": 4, "score": 56251.299723683194 }, { "content": "\t\tstd::string str = string_array[tokenIndex];\n\n\t\t*out = atoi(str.c_str());\n\n\t\ttokenIndex++;\n\n\t\treturn !isEnd();\n\n\t}\n\n\n\n\tbool\tget(float* out)\n\n\t{\n\n\t\tif (isEnd()) return false;\n\n\t\tstd::string str = string_array[tokenIndex];\n\n\t\t*out = (float)atof(str.c_str());\n\n\t\ttokenIndex++;\n\n\t\treturn !isEnd();\n\n\t}\n\n\n\n\tbool\tget(std::string* str)\n\n\t{\n\n\t\tif (isEnd()) return false;\n\n\t\t*str = string_array[tokenIndex];\n\n\n", "file_path": "Common/Loader/ssstring_uty.h", "rank": 5, "score": 56247.31828538828 }, { "content": " * @param[in] ファイルパス\n\n * @retval ファイルパスからフォルダ名を取り除いた文字列\n\n*/\n\nstd::string path2file(const std::string &path);\n\n\n\n\n\n/*\n\n * @brief 相対パスを絶対パスへ変換する\n\n * param[in] basePath 基準ディレクトリ\n\n * param[int] relPath 相対パス\n\n * retval relpathを絶対パスへ変換した値\n\n*/\n\nstd::string getFullPath( const std::string& basePath , const std::string &relPath);\n\n\n\n\n\nstd::string nomarizeFilename( std::string str );\n\n\n\n/*\n\n* @brief ファイルバージョンチェック\n\n* param[in] fileVersion チェックするファイルのバージョン\n\n* param[in] nowVersion 現在のバージョン\n\n* retval 現在のバージョンより古い場合はfalse\n\n*/\n\nbool checkFileVersion(std::string fileVersion, std::string nowVersion);\n\n\n\n\n\n\n", "file_path": "Common/Loader/ssstring_uty.h", "rank": 6, "score": 56245.72762459477 }, { "content": " * @param[out] out_array\t分割した文字列を格納する文字列リスト\n\n * @retval なし\n\n*/\n\nvoid\tsplit_string( const std::string &in_str , \n\n\t\t\t\t\t\tconst char key, \n\n\t\t\t\t\t\tstd::vector<std::string>& out_array );\n\n\n\n//bool\tis_digit_string( std::string &in_str );\n\nbool\tis_digit_string( std::string &in_str , bool* is_priod = 0 );\n\n\n\n/*\n\n * @brief ファイルのフルパスからフォルダパスのみを取得します。\n\n * @param[in] ファイルパス\n\n * @retval ファイルパスからファイル名を取り除いた文字列\n\n*/\n\nstd::string path2dir(const std::string &path);\n\n\n\n\n\n/*\n\n * @brief ファイルのフルパスからファイル名のみを取得します。\n", "file_path": "Common/Loader/ssstring_uty.h", "rank": 7, "score": 56244.5915111685 }, { "content": "#include \"ssstring_uty.h\"\n\n#include \"sscharconverter.h\"\n\n\n\n#ifdef _WIN32\n\n#include <direct.h>\n\n#include <algorithm>\n\n#else\n\n#include <limits.h>\n\n#include <stdlib.h>\n\n#include <unistd.h>\n\n\n\n#endif\n\n\n\nnamespace spritestudio6\n\n{\n\n\n\n\n\n//=========================================================================================\n\n//! 文字列の切り分け\n\n/*!\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 8, "score": 54301.05851235967 }, { "content": "\t{\n\n\t\tret = false;\n\n\t}\n\n\n\n\treturn ret;\n\n}\n\n\n\n\n\n}\t// namespace spritestudio6\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 9, "score": 54295.62582479541 }, { "content": "\n\n\n\nbool\tis_digit_string( std::string &in_str , bool* is_priod )\n\n{\n\n\tstd::istringstream in(in_str);\n\n\t char c;\n\n\t\n\n\tif ( is_priod != NULL )*is_priod = false;\n\n\n\n\twhile (in)\n\n\t{\n\n\t\tin.get(c);\n\n\t\tif ( c < 0 ) return false;\n\n\n\n\t\tif ( c =='.' )\n\n\t\t{\n\n\t\t\tif ( is_priod != NULL )*is_priod = true;\n\n\t\t}\n\n\t\tif ( !(isdigit( c ) || c =='.' || c=='-' || c=='+' ) )\n\n\t\t{\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 10, "score": 54288.34171591713 }, { "content": "\t検索キーを元に文字列を切り分け、文字列の配列を返します。\n\n\t@param[in] in_str 入力文字列\n\n\t@param[in] key 検索キー\n\n\t@param[out] out_array 出力文字列配列\n\n\t@retval なし\n\n\n\n*/\n\n//=========================================================================================\n\nvoid\tsplit_string( const std::string &in_str , \n\n\t\t\t\t\t\tconst char key, \n\n\t\t\t\t\t\tstd::vector<std::string>& out_array )\n\n{\n\n\tstd::istringstream in(in_str);\n\n\tchar c;\n\n\tout_array.clear();\n\n\twhile (in)\n\n\t{\n\n\t\tstd::string index;\n\n\t\twhile (in.get(c) && (c != key))\tindex.push_back(c);\n\n\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 11, "score": 54287.76637254299 }, { "content": "\t\t\treturn false;\n\n\t\t}\n\n\t}\n\n\treturn true;\n\n}\n\n\n\n\n\nstd::string getFullPath( const std::string& basePath , const std::string &relPath )\n\n{\n\n#ifdef _WIN32\n\n\tchar\tcurPath[_MAX_PATH];\n\n\tchar\tbuffer_[_MAX_PATH];\n\n\tstd::string basePathFs;\n\n\tstd::string relPathFs;\n\n\tif( basePath.size() > 0 )\n\n\t\tbasePathFs = SsCharConverter::convert_path_string( basePath );\n\n\tif( relPath.size() > 0 )\n\n\t\trelPathFs = SsCharConverter::convert_path_string( relPath );\n\n\n\n\t_getcwd( curPath , _MAX_PATH ); \n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 12, "score": 54286.94517413645 }, { "content": " std::string str = curPath;\n\n str+=\"/\";\n\n str+= basePath;\n\n realpath( str.c_str() , curPath2 );\n\n chdir( curPath2 );\n\n std::string temp = relPath;\n\n realpath(temp.c_str(),buffer_ );\n\n //std::string ret_str = relPath + \"/\";\n\n\n\n#if 0\t// MEMO: エンバグしていると困るので、一応まだ残しておく\n\n#else\n\n chdir(curPath);\n\n#endif\n\n return relPath;\n\n }else{\n\n chdir( basePath.c_str());\n\n std::string temp = basePath + relPath;\n\n realpath(temp.c_str(),buffer_ );\n\n }\n\n \n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 13, "score": 54285.80906071018 }, { "content": " \n\n chdir(curPath);\n\n std::string ret_temp;\n\n ret_temp = buffer_;\n\n ret_temp+=\"/\";\n\n return ret_temp;\n\n#endif\n\n\n\n}\n\nstd::string Replace( std::string String1, std::string String2, std::string String3 )\n\n{\n\n std::string::size_type Pos( String1.find( String2 ) );\n\n\n\n while( Pos != std::string::npos )\n\n {\n\n String1.replace( Pos, String2.length(), String3 );\n\n Pos = String1.find( String2, Pos + String3.length() );\n\n }\n\n\n\n return String1;\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 14, "score": 54285.80906071018 }, { "content": "}\n\n\n\nstd::string nomarizeFilename( std::string str )\n\n{\n\n\tstd::string ret = str;\n\n\tret = Replace( str , \"\\\\\\\\\" , \"\\\\\" );\n\n\n\n\treturn ret;\n\n}\n\n\n\nbool checkFileVersion(std::string fileVersion, std::string nowVersion)\n\n{\n\n\tfileVersion = Replace(fileVersion, \".\", \"\" );\n\n\tnowVersion = Replace(nowVersion , \".\", \"\" );\n\n\n\n\tbool ret = true;\n\n\tint fv = std::stoi(fileVersion);\t//確認するファイルのバージョン\n\n\tint nv = std::stoi(nowVersion);\t\t//現在のバージョン\n\n\n\n\tif (fv < nv)\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 15, "score": 54285.80906071018 }, { "content": "\t\tout_array.push_back( index );\n\n\t}\t\n\n\t\t\n\n}\n\n\n\n\n\nstd::string path2dir(const std::string &path) {\n\n\t// MEMO: find_last_ofが未発見時に-1を返すので、maxをsize_tで実体化したらダメ\n\n\tconst std::string::size_type pos = std::max<signed>((signed)path.find_last_of('/'), (signed)path.find_last_of('\\\\'));\n\n\treturn (pos == std::string::npos) ? std::string()\n\n\t\t: path.substr(0, pos + 1);\n\n}\n\n\n\nstd::string path2file(const std::string &path) {\n\n\t// MEMO: find_last_ofが未発見時に-1を返すので、maxをsize_tで実体化したらダメ\n\n\t// ※一度posに入れているのは、C26451の警告回避のため\n\n\tsigned pos = std::max<signed>((signed)path.find_last_of('/'), (signed)path.find_last_of('\\\\')) + 1;\n\n\treturn path.substr((size_t)pos);\n\n}\n\n\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 16, "score": 54285.80906071018 }, { "content": "\t_chdir( basePathFs.c_str() );\n\n\n\n\t_fullpath( buffer_ , relPathFs.c_str() , _MAX_PATH );\n\n\t\n\n\t_chdir( curPath );\n\n\n\n\tstd::string temp( buffer_ );\n\n\ttemp+= \"\\\\\";\n\n\t// MEMO: Windowsの場合、上記API群で返ってくるパスのエンコードはSJISなことに注意\n\n\tstd::string rv = SsCharConverter::sjis_to_utf8( temp );\n\n\n\n\treturn rv;\n\n#else\n\n\tchar\tbuffer_[2048];\n\n\tchar\tcurPath[2048];\n\n\tchar\tcurPath2[2048];\n\n getwd(curPath);\n\n \n\n if ( basePath[0]!='/')\n\n {\n", "file_path": "Common/Loader/ssstring_uty.cpp", "rank": 17, "score": 54285.80906071018 }, { "content": "class SsStringTokenizer\n\n{\n\nprivate:\n\n\tstd::vector<std::string> string_array;\n\n\tint\ttokenIndex;\n\n\tint\ttokennum;\n\n\n\npublic:\n\n\tSsStringTokenizer() {}\n\n\tvirtual ~SsStringTokenizer() {}\n\n\n\n\tSsStringTokenizer(std::string src_str , char token ) {\n\n\t\tsplit_string(src_str, token, string_array);\n\n\t\ttokenIndex = 0;\n\n\t\ttokennum = (int)string_array.size();\n\n\t}\n\n\n\n\tbool\tget(int* out)\n\n\t{\n\n\t\tif (isEnd()) return false;\n", "file_path": "Common/Loader/ssstring_uty.h", "rank": 18, "score": 50750.89287955776 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 19, "score": 42433.34023969911 }, { "content": " int minor;\n", "file_path": "Build/Converter/glad/include/glad/glad.h", "rank": 20, "score": 42433.34023969911 }, { "content": " int major;\n", "file_path": "Build/Converter/glad/include/glad/glad.h", "rank": 21, "score": 42433.34023969911 }, { "content": "static void* get_proc(const char *namez);\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 22, "score": 42090.514949106284 }, { "content": "static int get_exts(void) {\n\n#ifdef _GLAD_IS_SOME_NEW_VERSION\n\n if(max_loaded_major < 3) {\n\n#endif\n\n exts = (const char *)glGetString(GL_EXTENSIONS);\n\n#ifdef _GLAD_IS_SOME_NEW_VERSION\n\n } else {\n\n unsigned int index;\n\n\n\n num_exts_i = 0;\n\n glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i);\n\n if (num_exts_i > 0) {\n\n exts_i = (char **)malloc((size_t)num_exts_i * (sizeof *exts_i));\n\n }\n\n\n\n if (exts_i == NULL) {\n\n return 0;\n\n }\n\n\n\n for(index = 0; index < (unsigned)num_exts_i; index++) {\n\n const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index);\n\n size_t len = strlen(gl_str_tmp);\n\n\n\n char *local_str = (char*)malloc((len+1) * sizeof(char));\n\n if(local_str != NULL) {\n\n memcpy(local_str, gl_str_tmp, (len+1) * sizeof(char));\n\n }\n\n exts_i[index] = local_str;\n\n }\n\n }\n\n#endif\n\n return 1;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 23, "score": 42090.514949106284 }, { "content": "inline const ss::ssfb::ProjectData *GetProjectData(const void *buf) {\n\n return flatbuffers::GetRoot<ss::ssfb::ProjectData>(buf);\n", "file_path": "Build/Converter/ssfb_generated.h", "rank": 24, "score": 42090.514949106284 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 25, "score": 41308.20697950301 }, { "content": " int channel; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 26, "score": 41308.20697950301 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 27, "score": 41308.20697950301 }, { "content": " DWORD cb; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/wglew.h", "rank": 28, "score": 41308.20697950301 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 29, "score": 41308.20697950301 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 30, "score": 41308.20697950301 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 31, "score": 41308.20697950301 }, { "content": " DWORD Flags; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/wglew.h", "rank": 32, "score": 41308.20697950301 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 33, "score": 41308.20697950301 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 34, "score": 41308.20697950301 }, { "content": " char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 35, "score": 40241.199027724935 }, { "content": " int maxWidth; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 36, "score": 40241.199027724935 }, { "content": " int srcHeight; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 37, "score": 40241.199027724935 }, { "content": " int srcWidth; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 38, "score": 40241.199027724935 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 39, "score": 40241.199027724935 }, { "content": " int maxHeight; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 40, "score": 40241.199027724935 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 41, "score": 40241.199027724935 }, { "content": " unsigned int participationType; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 42, "score": 40241.199027724935 }, { "content": " int destHeight; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 43, "score": 40241.199027724935 }, { "content": " unsigned int buffer_mask; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 44, "score": 40241.199027724935 }, { "content": " unsigned int aux_buffer; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 45, "score": 40241.199027724935 }, { "content": " int destWidth; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 46, "score": 40241.199027724935 }, { "content": " CHAR DeviceString[128]; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/wglew.h", "rank": 47, "score": 40241.199027724935 }, { "content": " int YOrigin; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 48, "score": 40241.199027724935 }, { "content": " int timeSlice; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 49, "score": 40241.199027724935 }, { "content": " int networkId; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 50, "score": 40241.199027724935 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 51, "score": 40241.199027724935 }, { "content": " int XOrigin; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/glxew.h", "rank": 52, "score": 40241.199027724935 }, { "content": " CHAR DeviceName[32]; \n", "file_path": "Build/Viewer2/lib/glew-2.1.0/include/GL/wglew.h", "rank": 53, "score": 40241.199027724935 }, { "content": "PFNGLGETFIXEDVPROC __glewGetFixedv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 54, "score": 39916.08437324443 }, { "content": "PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 55, "score": 39916.08437324443 }, { "content": "PFNGLGETINTERNALFORMATI64VPROC __glewGetInternalformati64v = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 56, "score": 39916.08437324443 }, { "content": "PFNGLGETHISTOGRAMPROC __glewGetHistogram = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 57, "score": 39916.08437324443 }, { "content": "PFNGLGETLIGHTXVPROC __glewGetLightxv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 58, "score": 39916.08437324443 }, { "content": "PFNGLGETUNIFORMIVPROC __glewGetUniformiv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 59, "score": 39916.08437324443 }, { "content": "PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 60, "score": 39916.08437324443 }, { "content": "PFNGLGETQUERYIVPROC __glewGetQueryiv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 61, "score": 39916.08437324443 }, { "content": "PFNGLGETINTEGER64VPROC __glewGetInteger64v = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 62, "score": 39916.08437324443 }, { "content": "PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 63, "score": 39916.08437324443 }, { "content": "PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 64, "score": 39916.08437324443 }, { "content": "PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 65, "score": 39916.08437324443 }, { "content": "PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 66, "score": 39916.08437324443 }, { "content": "PFNGLGETUNIFORMFVPROC __glewGetUniformfv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 67, "score": 39916.08437324443 }, { "content": "PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 68, "score": 39916.08437324443 }, { "content": "PFNGLGETUNIFORMDVPROC __glewGetUniformdv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 69, "score": 39916.08437324443 }, { "content": "PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 70, "score": 39916.08437324443 }, { "content": "PFNGLGETFLOATI_VPROC glad_glGetFloati_v = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 71, "score": 39916.08437324443 }, { "content": "const GLubyte * GLEWAPIENTRY glewGetString (GLenum name)\n\n{\n\n static const GLubyte* _glewString[] =\n\n {\n\n (const GLubyte*)NULL,\n\n (const GLubyte*)\"2.1.0\",\n\n (const GLubyte*)\"2\",\n\n (const GLubyte*)\"1\",\n\n (const GLubyte*)\"0\"\n\n };\n\n const size_t max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;\n\n return _glewString[(size_t)name > max_string ? 0 : (size_t)name];\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 72, "score": 39916.08437324443 }, { "content": "PFNGLGETMINMAXPROC __glewGetMinmax = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 73, "score": 39916.08437324443 }, { "content": "PFNGLGETSHADERIVPROC __glewGetShaderiv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 74, "score": 39916.08437324443 }, { "content": "PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 75, "score": 39916.08437324443 }, { "content": "PFNGLGETSYNCIVPROC __glewGetSynciv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 76, "score": 39916.08437324443 }, { "content": "GLboolean GLEWAPIENTRY glewGetExtension (const char* name)\n\n{\n\n GLboolean *enable = _glewGetExtensionString(name);\n\n if (enable)\n\n return *enable;\n\n return GL_FALSE;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 77, "score": 39916.08437324443 }, { "content": "PFNGLGETFLOATI_VPROC __glewGetFloati_v = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 78, "score": 39916.08437324443 }, { "content": "PFNGLGETSTRINGIPROC __glewGetStringi = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 79, "score": 39916.08437324443 }, { "content": "PFNGLGETERRORPROC glad_glGetError = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 80, "score": 39916.08437324443 }, { "content": "PFNGLGETDOUBLEI_VPROC __glewGetDoublei_v = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 81, "score": 39916.08437324443 }, { "content": "PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL;\n", "file_path": "Build/Converter/glad/src/glad.c", "rank": 82, "score": 39916.08437324443 }, { "content": "PFNGLGETMATERIALXVPROC __glewGetMaterialxv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 83, "score": 39916.08437324443 }, { "content": "PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 84, "score": 39916.08437324443 }, { "content": "PFNGLGETPROGRAMIVPROC __glewGetProgramiv = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 85, "score": 39916.08437324443 }, { "content": "PFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ = NULL;\n", "file_path": "Build/Viewer2/lib/glew-2.1.0/src/glew.c", "rank": 86, "score": 39916.08437324443 }, { "content": "#include \"sshScene.h\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n\n\n\n}\t// namespace spritestudio6\n", "file_path": "Common/Helper/sshScene.cpp", "rank": 87, "score": 16.182902609494178 }, { "content": "#include \"sshObject.h\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n\n\n\n\n\n\n\n}\t// namespace spritestudio6\n", "file_path": "Common/Helper/sshObject.cpp", "rank": 88, "score": 16.182902609494178 }, { "content": "#ifndef __SSVALUE__\n\n#define __SSVALUE__\n\n\n\n#include \"ssarchiver.h\"\n\n#include \"ssstring_uty.h\"\n\n#include <map>\n\n#include <vector>\n\n#include <cassert>\n\n\n\nnamespace spritestudio6\n\n{\n\n\n", "file_path": "Common/Loader/ssvalue.h", "rank": 89, "score": 15.40864354032545 }, { "content": "#include \"ssplayer_render.h\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n\nISsRenderer*\tSsCurrentRenderer::m_currentrender = 0;\n\n\n\n}\t// namespace spritestudio6\n", "file_path": "Common/Animator/ssplayer_render.cpp", "rank": 90, "score": 13.38111118111009 }, { "content": "#ifndef __SSLOADER_SSPJ__\n\n#define __SSLOADER_SSPJ__\n\n\n\n#pragma warning(disable : 4819) //\n\n\n\n#include \"sstypes.h\"\n\n#include \"ssarchiver.h\"\n\n#include \"ssstring_uty.h\"\n\n\n\n#include \"ssloader_ssae.h\"\n\n#include \"ssloader_ssce.h\"\n\n#include \"ssloader_ssee.h\"\n\n#include \"ssloader_ssqe.h\"\n\n\n\n#include <memory>\n\n#include <utility>\n\n\n\n#define SPRITESTUDIO6_SSPJVERSION \"2.00.00\"\n\n\n\nnamespace spritestudio6\n", "file_path": "Common/Loader/ssloader_sspj.h", "rank": 92, "score": 12.89186406665624 }, { "content": "#ifndef __SSLOADER_SSAE__\n\n#define __SSLOADER_SSAE__\n\n\n\n#include \"sstypes.h\"\n\n#include \"ssarchiver.h\"\n\n#include \"ssattribute.h\"\n\n\n\n#define SPRITESTUDIO6_SSAEVERSION \"2.00.01\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n", "file_path": "Common/Loader/ssloader_ssae.h", "rank": 93, "score": 12.858833343098645 }, { "content": "#ifndef __SSLOADER_SSCE__\n\n#define __SSLOADER_SSCE__\n\n\n\n#include \"sstypes.h\"\n\n#include \"ssarchiver.h\"\n\n\n\n#define SPRITESTUDIO6_SSCEVERSION \"2.00.00\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n\n///パーツに使用される画素の矩形範囲を示した構造です。\n", "file_path": "Common/Loader/ssloader_ssce.h", "rank": 94, "score": 12.656788229603933 }, { "content": "#ifndef __SSLOADER_SSQE__\n\n#define __SSLOADER_SSQE__\n\n\n\n#include \"sstypes.h\"\n\n#include \"ssarchiver.h\"\n\n\n\n#define SPRITESTUDIO6_SSQEVERSION \"1.00.00\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n", "file_path": "Common/Loader/ssloader_ssqe.h", "rank": 95, "score": 12.656788229603933 }, { "content": "#ifndef __SSEFFECTELEMENT__\n\n#define __SSEFFECTELEMENT__\n\n\n\n\n\n#include \"sstypes.h\"\n\n#include \"ssarchiver.h\"\n\n#include \"SsEffectElement.h\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n", "file_path": "Common/Loader/SsEffectElement.h", "rank": 96, "score": 12.366120687496306 }, { "content": "#ifndef __SSATRIBUTE__\n\n#define __SSATRIBUTE__\n\n\n\n#include \"sstypes.h\"\n\n#include \"ssvalue.h\"\n\n#include \"ssInterpolation.h\"\n\n#include <list>\n\n#include\t<map>\n\n\n\n\n\nnamespace spritestudio6\n\n{\n\n\n\n\n\n//アニメーション中のキーフレームの内容を表現するクラス\n", "file_path": "Common/Loader/ssattribute.h", "rank": 97, "score": 12.36403078952566 }, { "content": "#ifndef __SSPLAYER_CELLMAP__\n\n#define __SSPLAYER_CELLMAP__\n\n\n\n#include \"sstypes.h\"\n\n\n\n#include <memory>\n\n\n\nnamespace spritestudio6\n\n{\n\n\n", "file_path": "Common/Animator/ssplayer_cellmap.h", "rank": 98, "score": 12.304415210072747 }, { "content": "#ifndef __SSLOADER_SSEE__\n\n#define __SSLOADER_SSEE__\n\n\n\n#include \"sstypes.h\"\n\n#include \"ssarchiver.h\"\n\n\n\n#include \"SsEffectBehavior.h\"\n\n\n\n#define SPRITESTUDIO6_SSEEVERSION \"2.00.00\"\n\n\n\nnamespace spritestudio6\n\n{\n\n\n", "file_path": "Common/Loader/ssloader_ssee.h", "rank": 99, "score": 12.283715512248545 } ]
C++
lib/getTunViaUSocket.cpp
xywzwd/VT-Wireless
ec42e742e2be26310df4b25cef9cea873896890b
#include <stdio.h> #include <string.h> #include <signal.h> #include <stdlib.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/wait.h> #include <errno.h> #include <unistd.h> #include "crts/debug.h" #include "getTunViaUSocket.hpp" static int checkHaveRead(int fd, long sec, long usec) { fd_set rfds; struct timeval tv = { .tv_sec = sec, .tv_usec = usec }; int ret; FD_ZERO(&rfds); FD_SET(fd, &rfds); ret = select(fd+1, &rfds, 0, 0, &tv); if(ret > 0) return ret; if(ret == -1) ERROR("select(, fd=%d,,) failed", fd); else WARN("read timed out in %lu %sseconds", sec?sec:usec, sec?"":"micro "); return ret; } static inline int recvfd(int &socket) { struct msghdr msg = {0}; char m_buffer[256]; struct iovec io = { .iov_base = m_buffer, .iov_len = sizeof(m_buffer) }; msg.msg_iov = &io; msg.msg_iovlen = 1; char c_buffer[256]; msg.msg_control = c_buffer; msg.msg_controllen = sizeof(c_buffer); errno = 0; INFO("Calling recvmsg(fd=%d,,,)", socket); if(recvmsg(socket, &msg, 0) < 0) { close(socket); socket = -1; ERROR("Failed to receive file descriptor message"); return -1; } struct cmsghdr * cmsg = CMSG_FIRSTHDR(&msg); unsigned char * data = CMSG_DATA(cmsg); int fd = *((int*) data); INFO("Got from UNIX Socket TUN fd=%d", fd); close(socket); if((fd = dup2(fd, socket)) != socket) { ERROR("dup2() failed"); close(fd); socket = -1; return -1; } socket = -1; INFO("Got TUN duped to fd=%d", fd); return fd; } static inline char *getPathTo_CRTS_mkTUN(void) { const char *mkTUN = "crts_mkTUN"; const size_t addSuffixLen = strlen(mkTUN) + 1; const size_t inc = 128; size_t bufLen = 128; char *buf = (char *) malloc(bufLen); ASSERT(buf, "malloc() failed"); ssize_t rl = readlink("/proc/self/exe", buf, bufLen); ASSERT(rl > 0, "readlink(\"/proc/self/exe\",,) failed"); while( ((size_t) rl) + addSuffixLen >= bufLen) { DASSERT(bufLen < 1024*1024, ""); buf = (char *) realloc(buf, bufLen += inc); ASSERT(buf, "realloc() failed"); rl = readlink("/proc/self/exe", buf, bufLen); ASSERT(rl > 0, "readlink(\"/proc/self/exe\",,) failed"); } buf[rl] = '\0'; --rl; while(rl > 3 && buf[rl] != '/') --rl; ASSERT(buf[rl] == '/', ""); ++rl; strcpy(&buf[rl], mkTUN); return buf; } bool checkSubnetAddress(const char *subnet) { unsigned long val; size_t len = strlen(subnet); const char *s = subnet; if(len > 18 || len < 10) goto fail; if(subnet[len-3] != '/') goto fail; errno = 0; val = strtoul(&subnet[len-2], 0, 10); if(errno || val > 31 || val < 24) goto fail; for(int i=0; i<3; ++i) { val = strtoul(s, 0, 10); if(errno || val > 255) goto fail; while(*s && *s != '.') ++s; if(! *s) goto fail; ++s; } val = strtoul(s, 0, 10); if(errno || val > 255) goto fail; return false; fail: ERROR("\"%s\" is not a safe subnet address\n" "Try something like: \"10.0.0.0/24\"", subnet); return true; } int getTunViaUSocket(const char *subnet) { if(checkSubnetAddress(subnet)) return -1; INFO("Making TUN with subnet \"%s\"", subnet); int sv[2] = { -1, -1 }; int tunFd = -1; pid_t pid = -1; int status = 0; int ret; errno = 0; ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, sv); if(ret) { ERROR("socketpair(AF_UNIX, SOCK_DGRAM, 0,) failed"); goto fail; } DASSERT(sv[0] > -1 && sv[1] > -1, ""); pid = fork(); if(pid < 0) { ERROR("fork() failed"); goto fail; } if(pid == 0) { close(sv[0]); errno = 0; if(1 != dup2(sv[1], 1)) { ERROR("dup2(fd=%d, 0) failed", sv[1]); exit(1); } char *mkTUN = getPathTo_CRTS_mkTUN(); execl(mkTUN, mkTUN, subnet, 0); ERROR("exec(\"%s\", \"%s\", 0) failed", mkTUN, subnet); exit(1); } close(sv[1]); sv[1] = -1; ret = waitpid(pid, &status, 0); if(ret == -1) { ERROR("waitpid(pid=%u,,) failed", pid); goto fail; } INFO("wait(pid=%u,,) returned status=%d", pid, status); if((ret = checkHaveRead(sv[0], 0, 100)) > 0) tunFd = recvfd(sv[0]); return tunFd; fail: if(pid != -1) kill(pid, SIGTERM); if(sv[0] > -1) close(sv[0]); if(sv[1] > -1) close(sv[0]); return -1; }
#include <stdio.h> #include <string.h> #include <signal.h> #include <stdlib.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/wait.h> #include <errno.h> #include <unistd.h> #include "crts/debug.h" #include "getTunViaUSocket.hpp" static int checkHaveRead(int fd, long sec, long usec) { fd_set rfds; struct timeval tv = { .tv_sec = sec, .tv_usec = usec }; int ret; FD_ZERO(&rfds); FD_SET(fd, &rfds); ret = select(fd+1, &rfds, 0, 0, &tv); if(ret > 0) return ret; if(ret == -1) ERROR("select(, fd=%d,,) failed", fd); else WARN("read timed out in %lu %sseconds", sec?sec:usec, sec?"":"micro "); return ret; } static inline int recvfd(int &socket) { struct msghdr msg = {0}; char m_buffer[256]; struct iovec io = { .iov_base = m_buffer, .iov_len = sizeof(m_buffer) }; msg.msg_iov = &io; msg.msg_iovlen = 1; char c_buffer[256]; msg.msg_control = c_buffer; msg.msg_controllen = sizeof(c_buffer); errno = 0; INFO("Calling recvmsg(fd=%d,,,)", socket); if(recvmsg(socket, &msg, 0) < 0) { close(socket); socket = -1; ERROR("Failed to receive file descriptor message"); return -1; } struct cmsghdr * cmsg = CMSG_FIRSTHDR(&msg); unsigned char * data = CMSG_DATA(cmsg
et); const char *s = subnet; if(len > 18 || len < 10) goto fail; if(subnet[len-3] != '/') goto fail; errno = 0; val = strtoul(&subnet[len-2], 0, 10); if(errno || val > 31 || val < 24) goto fail; for(int i=0; i<3; ++i) { val = strtoul(s, 0, 10); if(errno || val > 255) goto fail; while(*s && *s != '.') ++s; if(! *s) goto fail; ++s; } val = strtoul(s, 0, 10); if(errno || val > 255) goto fail; return false; fail: ERROR("\"%s\" is not a safe subnet address\n" "Try something like: \"10.0.0.0/24\"", subnet); return true; } int getTunViaUSocket(const char *subnet) { if(checkSubnetAddress(subnet)) return -1; INFO("Making TUN with subnet \"%s\"", subnet); int sv[2] = { -1, -1 }; int tunFd = -1; pid_t pid = -1; int status = 0; int ret; errno = 0; ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, sv); if(ret) { ERROR("socketpair(AF_UNIX, SOCK_DGRAM, 0,) failed"); goto fail; } DASSERT(sv[0] > -1 && sv[1] > -1, ""); pid = fork(); if(pid < 0) { ERROR("fork() failed"); goto fail; } if(pid == 0) { close(sv[0]); errno = 0; if(1 != dup2(sv[1], 1)) { ERROR("dup2(fd=%d, 0) failed", sv[1]); exit(1); } char *mkTUN = getPathTo_CRTS_mkTUN(); execl(mkTUN, mkTUN, subnet, 0); ERROR("exec(\"%s\", \"%s\", 0) failed", mkTUN, subnet); exit(1); } close(sv[1]); sv[1] = -1; ret = waitpid(pid, &status, 0); if(ret == -1) { ERROR("waitpid(pid=%u,,) failed", pid); goto fail; } INFO("wait(pid=%u,,) returned status=%d", pid, status); if((ret = checkHaveRead(sv[0], 0, 100)) > 0) tunFd = recvfd(sv[0]); return tunFd; fail: if(pid != -1) kill(pid, SIGTERM); if(sv[0] > -1) close(sv[0]); if(sv[1] > -1) close(sv[0]); return -1; }
); int fd = *((int*) data); INFO("Got from UNIX Socket TUN fd=%d", fd); close(socket); if((fd = dup2(fd, socket)) != socket) { ERROR("dup2() failed"); close(fd); socket = -1; return -1; } socket = -1; INFO("Got TUN duped to fd=%d", fd); return fd; } static inline char *getPathTo_CRTS_mkTUN(void) { const char *mkTUN = "crts_mkTUN"; const size_t addSuffixLen = strlen(mkTUN) + 1; const size_t inc = 128; size_t bufLen = 128; char *buf = (char *) malloc(bufLen); ASSERT(buf, "malloc() failed"); ssize_t rl = readlink("/proc/self/exe", buf, bufLen); ASSERT(rl > 0, "readlink(\"/proc/self/exe\",,) failed"); while( ((size_t) rl) + addSuffixLen >= bufLen) { DASSERT(bufLen < 1024*1024, ""); buf = (char *) realloc(buf, bufLen += inc); ASSERT(buf, "realloc() failed"); rl = readlink("/proc/self/exe", buf, bufLen); ASSERT(rl > 0, "readlink(\"/proc/self/exe\",,) failed"); } buf[rl] = '\0'; --rl; while(rl > 3 && buf[rl] != '/') --rl; ASSERT(buf[rl] == '/', ""); ++rl; strcpy(&buf[rl], mkTUN); return buf; } bool checkSubnetAddress(const char *subnet) { unsigned long val; size_t len = strlen(subn
random
[ { "content": "// This is an internal data structure and not a user interface; hence\n\n// it's not called CRTSParameter.\n\nstruct Parameter\n\n{\n\n // called in CRTSController to set the value.\n\n std::function<bool (double)> set;\n\n\n\n // called in CRTSController to poll the value\n\n std::function<double (void)> get;\n\n\n\n // list of callbacks called when the parameter changes.\n\n // TODO: or it had setParameter() called and the value\n\n // may have changed.\n\n std::list<std::function<void (double)>>\n\n getCallbacks;\n\n};\n\n\n\n\n\n\n\n/** CRTSStream is a user interface to set and get attributes of the Stream\n\n * which is the related to the group of Filters that are connected (input\n\n * and output) to each other. There is a pointer to a CRTSStream in the\n\n * CRTSFilter called stream.\n\n */\n", "file_path": "include/crts/Filter.hpp", "rank": 0, "score": 153554.05517006453 }, { "content": "struct timespec AddTimes(const struct timespec a, const struct timespec b)\n\n{\n\n long nsec = a.tv_nsec + b.tv_nsec;\n\n time_t seconds = a.tv_sec + b.tv_sec;\n\n\n\n if(nsec > 1000000000)\n\n {\n\n time_t rem = nsec/1000000000.0F;\n\n seconds += rem;\n\n nsec -= rem * 1000000000;\n\n }\n\n\n\n return\n\n {\n\n seconds,\n\n nsec // nano seconds\n\n };\n\n}\n\n\n\n\n", "file_path": "share/crts/plugins/Filters/throttle.cpp", "rank": 1, "score": 146753.12328453636 }, { "content": " unsigned long int num_bytes_received;\n", "file_path": "liquid-dsp/src/include/liquid.h", "rank": 2, "score": 108979.16829556043 }, { "content": " unsigned int msg_len;\n", "file_path": "liquid-dsp/src/include/liquid.internal.h", "rank": 3, "score": 108963.71128499026 }, { "content": "void liquid_autotest_failed_msg(const char * _file,\n\n unsigned int _line,\n\n const char * _message)\n\n{\n\n if (liquid_autotest_verbose)\n\n printf(\" TEST FAILED: %s line %u : %s\\n\", _file, _line, _message);\n\n liquid_autotest_failed();\n", "file_path": "liquid-dsp/src/autotest/autotestlib.c", "rank": 4, "score": 107634.97510125849 }, { "content": "void liquid_autotest_failed_msg(const char * _file,\n\n unsigned int _line,\n", "file_path": "liquid-dsp/src/autotest/autotest.h", "rank": 5, "score": 107634.97510125849 }, { "content": " unsigned int dec_msg_len;\n", "file_path": "liquid-dsp/src/include/liquid.internal.h", "rank": 6, "score": 107245.51898753275 }, { "content": " unsigned int enc_msg_len;\n", "file_path": "liquid-dsp/src/include/liquid.internal.h", "rank": 7, "score": 107245.51898753275 }, { "content": "// This is not socketIO, it's just a simplified, subset of the socketIO\n\n// \"on\" and \"emit\" like interfaces. The real SocketIO has some nice\n\n// interfaces, but it's very dated and inefficient. It's got too much\n\n// crufty code. I replace it with this much more flexible and 100 line\n\n// piece of code. This is not meant to be compatible with the real\n\n// socketIO.\n\n//\n\n// This takes an object and a corresponding send function and appends the\n\n// two socketIO like methods \"On\" and \"Emit\". We could not use \"on\" and\n\n// \"emit\" because \"on\" is usually already set. In addition this adds the\n\n// CheckForSocketIOMessage() function to the object.\n\n//\n\n// By having the CheckForSocketIOMessage() function we do not restrict how\n\n// the underlying communication layer is used. The use can still just\n\n// send and receive messages of any kind, unlike the real socketIO which\n\n// forces the user to use only the \"emit\" and \"on\" interfaces to send and\n\n// receive data. The same (and more so) can be said about MQTT; it eats\n\n// the whole webSocket, not letting the user even look at it.\n\n//\n\n// The user must call obj.CheckForSocketIOMessage(msg) for each message\n\n// that they think may be a socketIO like message. The passed in msg\n\n// message must be one framed message. This does not do the framing of\n\n// messages. If the msg starts with 'I' we assume that it was intended to\n\n// be consumed by this message parser.\n\n//\n\n//\n\n// We can use this with webSockets, TCP/IP sockets, and likely TLS/TCP/IP\n\n// sockets.\n\n//\n\n\n\n\n\n//\n\nfunction createSocketIOObject(sendFunc, warnFunc=null) {\n\n\n\n // Funcs is the list of \"On\" callback functions with their\n\n // corresponding scope.\n\n var funcs = {};\n\n var obj = {};\n\n\n\n if(warnFunc)\n\n var warn = warnFunc;\n\n else\n\n var warn = console.log;\n\n\n\n\n\n // Like: socketIO.on('name', function(arg0, arg1, arg2, ...) {})\n\n //\n\n obj.On = function(name, func) {\n\n\n\n // Make it be able to be set more than one callback for a given\n\n // name. So if we have an array of functions for a given name\n\n // than there is more than one callback to call.\n\n //\n\n // javaScript is f-ing magic and will save the scope (context) of\n\n // the function, func, too.\n\n\n\n if(funcs[name] === undefined)\n\n funcs[name] = [];\n\n funcs[name].push(func);\n\n };\n\n\n\n // Return true if the message is consumed; that is it should have been\n\n // used up by this interface, even if it failed.\n\n obj.CheckForSocketIOMessage = function(msg) {\n\n\n\n // msg should be like:\n\n //\n\n // msg = I{name: funcName, args: [ arg0, arg1, arg2 ] }\n\n\n\n if(msg.substr(0,1) !== 'I')\n\n return false; // The user may handle this message.\n\n\n\n try {\n\n var json = JSON.parse(msg.substr(1));\n\n } catch {\n\n warn('bad json parse in msg=' + msg);\n\n return true; // fail but handled\n\n }\n\n\n\n if(json.name === undefined) {\n\n warn('No IO name in msg=' + msg);\n\n return true; // fail but handled\n\n }\n\n\n\n\n\n if(json.args === undefined || typeof(json.args) !== 'object' ||\n\n json.args.length === undefined) {\n\n warn('Bad IO json args in: ' + msg);\n\n return true; // fail but handled\n\n }\n\n\n\n if(funcs[json.name] === undefined) {\n\n warn('NO socketIO On \"' + json.name + '\" for message=' + msg);\n\n return true;\n\n }\n\n\n\n //warn('handling (' + funcs[json.name].length +\n\n // ') socketIO On \"' + json.name + '\" message');\n\n\n\n funcs[json.name].forEach(function(func) {\n\n\n\n // Call the callback function with the args:\n\n func(...json.args);\n\n });\n\n\n\n return true; // success and handled\n\n }\n\n\n\n // Like socketIO.emit()\n\n //\n\n // Usage: obj.Emit(name, arg0, arg1, arg2, ...)\n\n //\n\n obj.Emit = function(x) {\n\n\n\n var args = [].slice.call(arguments);\n\n var name = args.shift();\n\n\n\n // Call the users send function which may add EOT char at the end\n\n // of the message in the case that the send protocol does not have\n\n // framing built it. Like for example TCP/IP does not frame\n\n // messages, but webSockets does frame massages.\n\n //\n\n try {\n\n sendFunc('I' + JSON.stringify({ name: name, args: args }));\n\n } catch(e) {\n\n console.log('FAILED to send(name=\"' + name + '\"): ' + e);\n\n }\n\n };\n\n\n\n if(typeof(window) !== 'undefined')\n\n // This is not node JS. We do not need addition\n\n // code for the client browser.\n\n return obj;\n\n\n\n\n\n // This is node JS:\n\n \n\n obj.SetUserName = function(userName) {\n\n obj.userName = userName;\n\n }\n\n\n\n var count = ++createCount;\n\n // Add to list of objects. Needed for Broadcast() and\n\n // BroadcastUser().\n\n sends[count] = sendFunc;\n\n objs[count] = obj;\n\n\n\n // These methods will Broadcast to all but this obj.\n\n obj.BroadcastUser = BroadcastUser;\n\n obj.Broadcast = Broadcast;\n\n\n\n\n\n\n\n obj.Cleanup = function() {\n\n\n\n // Replace this functions with dummies so\n\n // that events that trigger them will not\n\n // really call them any more, and they don't\n\n // try to send() with a closed webSocket.\n\n\n\n delete obj.Cleanup;\n\n obj.CheckForSocketIOMessage = function() {};\n\n obj.Emit = function() {};\n\n obj.On = function() {};\n\n delete sends[count];\n\n };\n\n\n\n return obj;\n\n}\n\n\n\nif(typeof(window) === 'undefined') {\n\n\n\n // Based on typeof(window) === 'undefined' we assume that this is node\n\n // JS code and not browser javaScript. We don't need node's browerify\n\n // if we actually test run the code.\n\n //\n\n\n\n // File scope variables are accessed above:\n\n //\n\n var sends = {}; // list of send functions\n\n var objs = {}; // list of IO objects\n\n var createCount = 0;\n\n\n\n\n\n module.exports = createSocketIOObject;\n\n\n\n // global Broadcast() function\n\n //\n\n Broadcast = function(/* name, args ... */) {\n\n\n\n var myObj = this;\n\n var keys = Object.keys(sends);\n\n if(keys.length < 1) return;\n\n\n\n var args = [].slice.call(arguments);\n\n var name = args.shift();\n\n var msg = 'I' + JSON.stringify({ name: name, args: args });\n\n\n\n // Call the all send functions.\n\n keys.forEach(function(key) {\n\n // if this is part of IO object method than this will\n\n // not emit for this IO object.\n\n if(myObj !== objs[key])\n\n sends[key](msg);\n\n });\n\n };\n\n\n\n // global BroadcastUser() function\n\n //\n\n BroadcastUser = function(/* name, userName, args ...*/) {\n\n\n\n var myObj = this;\n\n var keys = Object.keys(sends);\n\n if(keys.length < 1) return;\n\n\n\n var args = [].slice.call(arguments);\n\n var name = args.shift();\n\n var userName = args.shift();\n\n // The message does not need the user name.\n\n var msg = 'I' + JSON.stringify({ name: name, args: args });\n\n\n\n // Call the users, with this userName, send functions.\n\n keys.forEach(function(key) {\n\n // if this is part of IO object method than this will\n\n // not emit for this IO object.\n\n if(objs[key].userName === userName && myObj !== objs[key])\n\n sends[key](msg);\n\n });\n\n };\n\n\n\n}\n", "file_path": "htdocs/socketIO.js", "rank": 8, "score": 102790.3413329973 }, { "content": "// This is not socketIO, it's just a simplified, subset of the socketIO\n\n// \"on\" and \"emit\" like interfaces. The real SocketIO has some nice\n\n// interfaces, but it's very dated and inefficient. It's got too much\n\n// crufty code. I replace it with this much more flexible and 100 line\n\n// piece of code. This is not meant to be compatible with the real\n\n// socketIO.\n\n//\n\n// This takes an object and a corresponding send function and appends the\n\n// two socketIO like methods \"On\" and \"Emit\". We could not use \"on\" and\n\n// \"emit\" because \"on\" is usually already set. In addition this adds the\n\n// CheckForSocketIOMessage() function to the object.\n\n//\n\n// By having the CheckForSocketIOMessage() function we do not restrict how\n\n// the underlying communication layer is used. The use can still just\n\n// send and receive messages of any kind, unlike the real socketIO which\n\n// forces the user to use only the \"emit\" and \"on\" interfaces to send and\n\n// receive data. The same (and more so) can be said about MQTT; it eats\n\n// the whole webSocket, not letting the user even look at it.\n\n//\n\n// The user must call obj.CheckForSocketIOMessage(msg) for each message\n\n// that they think may be a socketIO like message. The passed in msg\n\n// message must be one framed message. This does not do the framing of\n\n// messages. If the msg starts with 'I' we assume that it was intended to\n\n// be consumed by this message parser.\n\n//\n\n//\n\n// We can use this with webSockets, TCP/IP sockets, and likely TLS/TCP/IP\n\n// sockets.\n\n//\n\n\n\n\n\n//\n\nfunction createSocketIOObject(sendFunc, warnFunc=null) {\n\n\n\n // Funcs is the list of \"On\" callback functions with their\n\n // corresponding scope.\n\n var funcs = {};\n\n var obj = {};\n\n\n\n if(warnFunc)\n\n var warn = warnFunc;\n\n else\n\n var warn = console.log;\n\n\n\n\n\n // Like: socketIO.on('name', function(arg0, arg1, arg2, ...) {})\n\n //\n\n obj.On = function(name, func) {\n\n\n\n // Make it be able to be set more than one callback for a given\n\n // name. So if we have an array of functions for a given name\n\n // than there is more than one callback to call.\n\n //\n\n // javaScript is f-ing magic and will save the scope (context) of\n\n // the function, func, too.\n\n\n\n if(funcs[name] === undefined)\n\n funcs[name] = [];\n\n funcs[name].push(func);\n\n };\n\n\n\n // Return true if the message is consumed; that is it should have been\n\n // used up by this interface, even if it failed.\n\n obj.CheckForSocketIOMessage = function(msg) {\n\n\n\n // msg should be like:\n\n //\n\n // msg = I{name: funcName, args: [ arg0, arg1, arg2 ] }\n\n\n\n if(msg.substr(0,1) !== 'I')\n\n return false; // The user may handle this message.\n\n\n\n try {\n\n var json = JSON.parse(msg.substr(1));\n\n } catch {\n\n warn('bad json parse in msg=' + msg);\n\n return true; // fail but handled\n\n }\n\n\n\n if(json.name === undefined) {\n\n warn('No IO name in msg=' + msg);\n\n return true; // fail but handled\n\n }\n\n\n\n\n\n if(json.args === undefined || typeof(json.args) !== 'object' ||\n\n json.args.length === undefined) {\n\n warn('Bad IO json args in: ' + msg);\n\n return true; // fail but handled\n\n }\n\n\n\n if(funcs[json.name] === undefined) {\n\n warn('NO socketIO On \"' + json.name + '\" for message=' + msg);\n\n return true;\n\n }\n\n\n\n //warn('handling (' + funcs[json.name].length +\n\n // ') socketIO On \"' + json.name + '\" message');\n\n\n\n funcs[json.name].forEach(function(func) {\n\n\n\n // Call the callback function with the args:\n\n func(...json.args);\n\n });\n\n\n\n return true; // success and handled\n\n }\n\n\n\n // Like socketIO.emit()\n\n //\n\n // Usage: obj.Emit(name, arg0, arg1, arg2, ...)\n\n //\n\n obj.Emit = function(x) {\n\n\n\n var args = [].slice.call(arguments);\n\n var name = args.shift();\n\n\n\n // Call the users send function which may add EOT char at the end\n\n // of the message in the case that the send protocol does not have\n\n // framing built it. Like for example TCP/IP does not frame\n\n // messages, but webSockets does frame massages.\n\n //\n\n try {\n\n sendFunc('I' + JSON.stringify({ name: name, args: args }));\n\n } catch(e) {\n\n console.log('FAILED to send(name=\"' + name + '\"): ' + e);\n\n }\n\n };\n\n\n\n if(typeof(window) !== 'undefined')\n\n // This is not node JS. We do not need addition\n\n // code for the client browser.\n\n return obj;\n\n\n\n\n\n // This is node JS:\n\n \n\n obj.SetUserName = function(userName) {\n\n obj.userName = userName;\n\n }\n\n\n\n var count = ++createCount;\n\n // Add to list of objects. Needed for Broadcast() and\n\n // BroadcastUser().\n\n sends[count] = sendFunc;\n\n objs[count] = obj;\n\n\n\n // These methods will Broadcast to all but this obj.\n\n obj.BroadcastUser = BroadcastUser;\n\n obj.Broadcast = Broadcast;\n\n\n\n\n\n\n\n obj.Cleanup = function() {\n\n\n\n // Replace this functions with dummies so\n\n // that events that trigger them will not\n\n // really call them any more, and they don't\n\n // try to send() with a closed webSocket.\n\n\n\n delete obj.Cleanup;\n\n obj.CheckForSocketIOMessage = function() {};\n\n obj.Emit = function() {};\n\n obj.On = function() {};\n\n delete sends[count];\n\n };\n\n\n\n return obj;\n\n}\n\n\n\nif(typeof(window) === 'undefined') {\n\n\n\n // Based on typeof(window) === 'undefined' we assume that this is node\n\n // JS code and not browser javaScript. We don't need node's browerify\n\n // if we actually test run the code.\n\n //\n\n\n\n // File scope variables are accessed above:\n\n //\n\n var sends = {}; // list of send functions\n\n var objs = {}; // list of IO objects\n\n var createCount = 0;\n\n\n\n\n\n module.exports = createSocketIOObject;\n\n\n\n // global Broadcast() function\n\n //\n\n Broadcast = function(/* name, args ... */) {\n\n\n\n var myObj = this;\n\n var keys = Object.keys(sends);\n\n if(keys.length < 1) return;\n\n\n\n var args = [].slice.call(arguments);\n\n var name = args.shift();\n\n var msg = 'I' + JSON.stringify({ name: name, args: args });\n\n\n\n // Call the all send functions.\n\n keys.forEach(function(key) {\n\n // if this is part of IO object method than this will\n\n // not emit for this IO object.\n\n if(myObj !== objs[key])\n\n sends[key](msg);\n\n });\n\n };\n\n\n\n // global BroadcastUser() function\n\n //\n\n BroadcastUser = function(/* name, userName, args ...*/) {\n\n\n\n var myObj = this;\n\n var keys = Object.keys(sends);\n\n if(keys.length < 1) return;\n\n\n\n var args = [].slice.call(arguments);\n\n var name = args.shift();\n\n var userName = args.shift();\n\n // The message does not need the user name.\n\n var msg = 'I' + JSON.stringify({ name: name, args: args });\n\n\n\n // Call the users, with this userName, send functions.\n\n keys.forEach(function(key) {\n\n // if this is part of IO object method than this will\n\n // not emit for this IO object.\n\n if(objs[key].userName === userName && myObj !== objs[key])\n\n sends[key](msg);\n\n });\n\n };\n\n\n\n}\n", "file_path": "lib/socketIO.js", "rank": 9, "score": 102790.3413329973 }, { "content": "unsigned int fec_conv_get_enc_msg_len(unsigned int _dec_msg_len,\n\n unsigned int _K,\n", "file_path": "liquid-dsp/src/include/liquid.internal.h", "rank": 10, "score": 102401.37627550341 }, { "content": "unsigned int fec_block_get_enc_msg_len(unsigned int _dec_msg_len,\n\n unsigned int _m,\n", "file_path": "liquid-dsp/src/include/liquid.internal.h", "rank": 11, "score": 102401.37627550341 }, { "content": "unsigned int fec_rs_get_enc_msg_len(unsigned int _dec_msg_len,\n\n unsigned int _nroots,\n\n unsigned int _nn,\n", "file_path": "liquid-dsp/src/include/liquid.internal.h", "rank": 12, "score": 102401.37627550341 }, { "content": " union {\n\n // coherent demodulator\n\n struct {\n\n /*\n\n nco_crcf nco; // oscillator/phase-locked loop\n\n firpfb_crcf mf; // matched filter\n\n firpfb_crcf dmf; // matched filter (derivative)\n\n */\n\n \n\n firfilt_crcf mf; // matched filter\n\n } coherent;\n\n\n\n // non-coherent demodulator\n\n struct {\n\n firpfb_rrrf mf; // matched filter\n\n firpfb_rrrf dmf; // matched filter (derivative)\n\n eqlms_rrrf equalizer;\n\n } noncoherent;\n", "file_path": "liquid-dsp/src/src/modem/src/cpfskdem.c", "rank": 13, "score": 96723.06551576061 }, { "content": "struct BufferEntry\n\n{\n\n float *buffer;\n\n int num2Floats; // number of pairs of floats\n\n};\n\n\n\n\n", "file_path": "share/crts/plugins/Filters/quickscope.cpp", "rank": 14, "score": 89236.7358358539 }, { "content": "float complex matrixcf_data_ludecomp_A[] = {\n\n 0.455808967352 + 0.239869371057*_Complex_I /* ( 0, 0) */,\n\n 1.076113820076 + 0.303303003311*_Complex_I /* ( 0, 1) */,\n\n -1.174549579620 + -1.593330740929*_Complex_I /* ( 0, 2) */,\n\n 1.428434848785 + -2.108702898026*_Complex_I /* ( 0, 3) */,\n\n 1.944794058800 + 1.039716124535*_Complex_I /* ( 0, 4) */,\n\n -0.003220892511 + -1.070197224617*_Complex_I /* ( 0, 5) */,\n\n 2.282850980759 + 0.567153334618*_Complex_I /* ( 0, 6) */,\n\n 0.677789986134 + -0.110934779048*_Complex_I /* ( 0, 7) */,\n\n -0.541479706764 + 0.508462309837*_Complex_I /* ( 1, 0) */,\n\n 0.659551382065 + 0.341979026794*_Complex_I /* ( 1, 1) */,\n\n 0.422295093536 + -0.748002707958*_Complex_I /* ( 1, 2) */,\n\n 0.991572380066 + -1.739566326141*_Complex_I /* ( 1, 3) */,\n\n -0.973251938820 + -0.314995020628*_Complex_I /* ( 1, 4) */,\n\n -0.348222613335 + 1.216362476349*_Complex_I /* ( 1, 5) */,\n\n -0.444941103458 + -0.435953140259*_Complex_I /* ( 1, 6) */,\n\n 0.664277911186 + 0.398205667734*_Complex_I /* ( 1, 7) */,\n\n 1.578197240829 + -0.245545297861*_Complex_I /* ( 2, 0) */,\n\n -0.734657287598 + -0.314642846584*_Complex_I /* ( 2, 1) */,\n\n -0.185400843620 + 0.411517560482*_Complex_I /* ( 2, 2) */,\n\n -0.141458645463 + 2.540255069733*_Complex_I /* ( 2, 3) */,\n\n -1.887707233429 + 1.261052608490*_Complex_I /* ( 2, 4) */,\n\n 1.356706976891 + -0.073478087783*_Complex_I /* ( 2, 5) */,\n\n 0.382849365473 + 1.176013708115*_Complex_I /* ( 2, 6) */,\n\n 0.088731415570 + -0.000313452416*_Complex_I /* ( 2, 7) */,\n\n 0.694614350796 + 0.107012517750*_Complex_I /* ( 3, 0) */,\n\n -0.541421890259 + -1.525843501091*_Complex_I /* ( 3, 1) */,\n\n 1.210077285767 + -0.249905958772*_Complex_I /* ( 3, 2) */,\n\n 0.051122765988 + 0.576834678650*_Complex_I /* ( 3, 3) */,\n\n 2.360952138901 + -0.439353585243*_Complex_I /* ( 3, 4) */,\n\n 0.927220702171 + 0.293185442686*_Complex_I /* ( 3, 5) */,\n\n -0.235832184553 + -0.484229415655*_Complex_I /* ( 3, 6) */,\n\n -1.589996099472 + 0.180045768619*_Complex_I /* ( 3, 7) */,\n\n 1.345695137978 + -0.080361045897*_Complex_I /* ( 4, 0) */,\n\n -0.245824366808 + -1.841626405716*_Complex_I /* ( 4, 1) */,\n\n 0.978698849678 + 1.369340777397*_Complex_I /* ( 4, 2) */,\n\n -1.106017351151 + -1.615537166595*_Complex_I /* ( 4, 3) */,\n\n 0.627505123615 + 1.024900913239*_Complex_I /* ( 4, 4) */,\n\n 1.808397769928 + -0.614134788513*_Complex_I /* ( 4, 5) */,\n\n -0.322292149067 + -0.765307128429*_Complex_I /* ( 4, 6) */,\n\n -0.674273192883 + 0.044275555760*_Complex_I /* ( 4, 7) */,\n\n -2.861634492874 + 2.582857608795*_Complex_I /* ( 5, 0) */,\n\n -1.920535564423 + -0.081001155078*_Complex_I /* ( 5, 1) */,\n\n -1.339942932129 + -0.246527969837*_Complex_I /* ( 5, 2) */,\n\n 0.540911912918 + 0.283990591764*_Complex_I /* ( 5, 3) */,\n\n -0.800716042519 + 0.764756917953*_Complex_I /* ( 5, 4) */,\n\n 1.206449866295 + 0.518103539944*_Complex_I /* ( 5, 5) */,\n\n -0.377558648586 + 0.065486297011*_Complex_I /* ( 5, 6) */,\n\n -1.090067625046 + 0.741791069508*_Complex_I /* ( 5, 7) */,\n\n -1.424072742462 + 0.091005645692*_Complex_I /* ( 6, 0) */,\n\n 0.340615779161 + 1.995890378952*_Complex_I /* ( 6, 1) */,\n\n -0.395366579294 + 0.685165762901*_Complex_I /* ( 6, 2) */,\n\n 0.367168039083 + -1.265154719353*_Complex_I /* ( 6, 3) */,\n\n 0.716018438339 + 1.003421306610*_Complex_I /* ( 6, 4) */,\n\n -0.648339152336 + 2.441966056824*_Complex_I /* ( 6, 5) */,\n\n 0.788251757622 + 1.254729628563*_Complex_I /* ( 6, 6) */,\n\n -0.776828289032 + -0.615517139435*_Complex_I /* ( 6, 7) */,\n\n 1.112848401070 + -0.297139286995*_Complex_I /* ( 7, 0) */,\n\n 0.366721868515 + 0.650049626827*_Complex_I /* ( 7, 1) */,\n\n 0.072020366788 + -0.518339037895*_Complex_I /* ( 7, 2) */,\n\n 1.033115744591 + -0.196805760264*_Complex_I /* ( 7, 3) */,\n\n -1.083071947098 + -1.565491795540*_Complex_I /* ( 7, 4) */,\n\n 1.409144878387 + 0.992799341679*_Complex_I /* ( 7, 5) */,\n\n 0.387732833624 + -1.445696353912*_Complex_I /* ( 7, 6) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_ludecomp.c", "rank": 15, "score": 70803.49043483878 }, { "content": "float matrixf_data_cgsolve_A[] = {\n\n 12.722920400000 /* ( 0, 0) */,\n\n 0.000000000000 /* ( 0, 1) */,\n\n -7.952912300000 /* ( 0, 2) */,\n\n 0.000000000000 /* ( 0, 3) */,\n\n 4.111499800000 /* ( 0, 4) */,\n\n 0.000000000000 /* ( 0, 5) */,\n\n 0.000000000000 /* ( 0, 6) */,\n\n 0.000000000000 /* ( 0, 7) */,\n\n 0.000000000000 /* ( 1, 0) */,\n\n 0.065151200000 /* ( 1, 1) */,\n\n 0.000000000000 /* ( 1, 2) */,\n\n -0.218259800000 /* ( 1, 3) */,\n\n 0.000000000000 /* ( 1, 4) */,\n\n 0.000000000000 /* ( 1, 5) */,\n\n 0.000000000000 /* ( 1, 6) */,\n\n 0.000000000000 /* ( 1, 7) */,\n\n -7.952912300000 /* ( 2, 0) */,\n\n 0.000000000000 /* ( 2, 1) */,\n\n 5.031585200000 /* ( 2, 2) */,\n\n 0.000000000000 /* ( 2, 3) */,\n\n -2.570038800000 /* ( 2, 4) */,\n\n -0.110545700000 /* ( 2, 5) */,\n\n 0.000000000000 /* ( 2, 6) */,\n\n 0.000000000000 /* ( 2, 7) */,\n\n 0.000000000000 /* ( 3, 0) */,\n\n -0.218259800000 /* ( 3, 1) */,\n\n 0.000000000000 /* ( 3, 2) */,\n\n 0.733045600000 /* ( 3, 3) */,\n\n 0.000000000000 /* ( 3, 4) */,\n\n 0.000000000000 /* ( 3, 5) */,\n\n 0.000000000000 /* ( 3, 6) */,\n\n 0.000000000000 /* ( 3, 7) */,\n\n 4.111499800000 /* ( 4, 0) */,\n\n 0.000000000000 /* ( 4, 1) */,\n\n -2.570038800000 /* ( 4, 2) */,\n\n 0.000000000000 /* ( 4, 3) */,\n\n 1.338132900000 /* ( 4, 4) */,\n\n 0.239381000000 /* ( 4, 5) */,\n\n 0.078430200000 /* ( 4, 6) */,\n\n 0.000000000000 /* ( 4, 7) */,\n\n 0.000000000000 /* ( 5, 0) */,\n\n 0.000000000000 /* ( 5, 1) */,\n\n -0.110545700000 /* ( 5, 2) */,\n\n 0.000000000000 /* ( 5, 3) */,\n\n 0.239381000000 /* ( 5, 4) */,\n\n 7.472388300000 /* ( 5, 5) */,\n\n 1.981894700000 /* ( 5, 6) */,\n\n -1.373365000000 /* ( 5, 7) */,\n\n 0.000000000000 /* ( 6, 0) */,\n\n 0.000000000000 /* ( 6, 1) */,\n\n 0.000000000000 /* ( 6, 2) */,\n\n 0.000000000000 /* ( 6, 3) */,\n\n 0.078430200000 /* ( 6, 4) */,\n\n 1.981894700000 /* ( 6, 5) */,\n\n 3.489272600000 /* ( 6, 6) */,\n\n 0.000000000000 /* ( 6, 7) */,\n\n 0.000000000000 /* ( 7, 0) */,\n\n 0.000000000000 /* ( 7, 1) */,\n\n 0.000000000000 /* ( 7, 2) */,\n\n 0.000000000000 /* ( 7, 3) */,\n\n 0.000000000000 /* ( 7, 4) */,\n\n -1.373365000000 /* ( 7, 5) */,\n\n 0.000000000000 /* ( 7, 6) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_cgsolve.c", "rank": 16, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_chol_A[] = {\n\n 1.020100000000 + 0.000000000000*_Complex_I /* ( 0, 0) */,\n\n -1.434200000000 + -0.252500000000*_Complex_I /* ( 0, 1) */,\n\n 0.323200000000 + 1.242300000000*_Complex_I /* ( 0, 2) */,\n\n -1.030200000000 + -1.030200000000*_Complex_I /* ( 0, 3) */,\n\n -1.434200000000 + 0.252500000000*_Complex_I /* ( 1, 0) */,\n\n 2.328900000000 + 0.000000000000*_Complex_I /* ( 1, 1) */,\n\n 0.243100000000 + -2.056600000000*_Complex_I /* ( 1, 2) */,\n\n 1.543400000000 + 1.208400000000*_Complex_I /* ( 1, 3) */,\n\n 0.323200000000 + -1.242300000000*_Complex_I /* ( 2, 0) */,\n\n 0.243100000000 + 2.056600000000*_Complex_I /* ( 2, 1) */,\n\n 6.353800000000 + 0.000000000000*_Complex_I /* ( 2, 2) */,\n\n -2.742600000000 + 0.135900000000*_Complex_I /* ( 2, 3) */,\n\n -1.030200000000 + 1.030200000000*_Complex_I /* ( 3, 0) */,\n\n 1.543400000000 + -1.208400000000*_Complex_I /* ( 3, 1) */,\n\n -2.742600000000 + -0.135900000000*_Complex_I /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_chol.c", "rank": 17, "score": 70803.49043483878 }, { "content": "float matrixf_data_aug_z[] = {\n\n -0.747572302818 /* ( 0, 0) */,\n\n 1.023007512093 /* ( 0, 1) */,\n\n -0.806419134140 /* ( 0, 2) */,\n\n 1.476346969604 /* ( 0, 3) */,\n\n 0.376702636480 /* ( 0, 4) */,\n\n 0.790158689022 /* ( 0, 5) */,\n\n 2.111151933670 /* ( 0, 6) */,\n\n -0.456311076880 /* ( 1, 0) */,\n\n 1.049571633339 /* ( 1, 1) */,\n\n 0.041211493313 /* ( 1, 2) */,\n\n 0.870350718498 /* ( 1, 3) */,\n\n -0.690664231777 /* ( 1, 4) */,\n\n -0.598035037518 /* ( 1, 5) */,\n\n -0.137144193053 /* ( 1, 6) */,\n\n -0.585918903351 /* ( 2, 0) */,\n\n -2.498867988586 /* ( 2, 1) */,\n\n 1.247432827950 /* ( 2, 2) */,\n\n -1.840264678001 /* ( 2, 3) */,\n\n 1.078616261482 /* ( 2, 4) */,\n\n 0.907722294331 /* ( 2, 5) */,\n\n -0.432205766439 /* ( 2, 6) */,\n\n 0.618996977806 /* ( 3, 0) */,\n\n -1.083691835403 /* ( 3, 1) */,\n\n -1.827050209045 /* ( 3, 2) */,\n\n -0.579039454460 /* ( 3, 3) */,\n\n -1.615019798279 /* ( 3, 4) */,\n\n 0.122782632709 /* ( 3, 5) */,\n\n 1.174023866653 /* ( 3, 6) */,\n\n 1.507880568504 /* ( 4, 0) */,\n\n 1.633087396622 /* ( 4, 1) */,\n\n -0.439950227737 /* ( 4, 2) */,\n\n -0.058893665671 /* ( 4, 3) */,\n\n 0.233828529716 /* ( 4, 4) */,\n\n 0.032883912325 /* ( 4, 5) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_aug.c", "rank": 18, "score": 70803.49043483878 }, { "content": "float matrixf_data_ludecomp_A[] = {\n\n 0.936903119087 /* ( 0, 0) */,\n\n 1.048182249069 /* ( 0, 1) */,\n\n 0.464600890875 /* ( 0, 2) */,\n\n 1.122355699539 /* ( 0, 3) */,\n\n -0.661124527454 /* ( 0, 4) */,\n\n -0.953127145767 /* ( 0, 5) */,\n\n -0.759313285351 /* ( 0, 6) */,\n\n 1.418183445930 /* ( 0, 7) */,\n\n -0.272643178701 /* ( 1, 0) */,\n\n -1.166662335396 /* ( 1, 1) */,\n\n 1.556591391563 /* ( 1, 2) */,\n\n -0.323065608740 /* ( 1, 3) */,\n\n -0.267991930246 /* ( 1, 4) */,\n\n 0.396302074194 /* ( 1, 5) */,\n\n 0.238355115056 /* ( 1, 6) */,\n\n -0.437593698502 /* ( 1, 7) */,\n\n 0.431114047766 /* ( 2, 0) */,\n\n -0.916567981243 /* ( 2, 1) */,\n\n 0.108782351017 /* ( 2, 2) */,\n\n -0.714223206043 /* ( 2, 3) */,\n\n 0.197309300303 /* ( 2, 4) */,\n\n 1.105972766876 /* ( 2, 5) */,\n\n -0.014590717852 /* ( 2, 6) */,\n\n 0.288964867592 /* ( 2, 7) */,\n\n 1.536642432213 /* ( 3, 0) */,\n\n 1.810190558434 /* ( 3, 1) */,\n\n 0.722570478916 /* ( 3, 2) */,\n\n 0.184841006994 /* ( 3, 3) */,\n\n -0.239855647087 /* ( 3, 4) */,\n\n 0.494688391685 /* ( 3, 5) */,\n\n -0.372100114822 /* ( 3, 6) */,\n\n -0.754012823105 /* ( 3, 7) */,\n\n 0.139140784740 /* ( 4, 0) */,\n\n -0.755531311035 /* ( 4, 1) */,\n\n 1.567769289017 /* ( 4, 2) */,\n\n -0.774845600128 /* ( 4, 3) */,\n\n 1.536481976509 /* ( 4, 4) */,\n\n -1.498587012291 /* ( 4, 5) */,\n\n 0.262655615807 /* ( 4, 6) */,\n\n -1.045227766037 /* ( 4, 7) */,\n\n 0.445236086845 /* ( 5, 0) */,\n\n -0.573900520802 /* ( 5, 1) */,\n\n 0.550646543503 /* ( 5, 2) */,\n\n 0.073093712330 /* ( 5, 3) */,\n\n 0.700358152390 /* ( 5, 4) */,\n\n 0.659417688847 /* ( 5, 5) */,\n\n 0.990632474422 /* ( 5, 6) */,\n\n -0.596979260445 /* ( 5, 7) */,\n\n -1.469601035118 /* ( 6, 0) */,\n\n -1.366319775581 /* ( 6, 1) */,\n\n -1.536668300629 /* ( 6, 2) */,\n\n 0.301474511623 /* ( 6, 3) */,\n\n 0.205486327410 /* ( 6, 4) */,\n\n 1.184612751007 /* ( 6, 5) */,\n\n 1.984294533730 /* ( 6, 6) */,\n\n 0.846946001053 /* ( 6, 7) */,\n\n -0.780786097050 /* ( 7, 0) */,\n\n -1.778358221054 /* ( 7, 1) */,\n\n -0.621561229229 /* ( 7, 2) */,\n\n 0.809134125710 /* ( 7, 3) */,\n\n -0.395780056715 /* ( 7, 4) */,\n\n 0.095775716007 /* ( 7, 5) */,\n\n 1.116999864578 /* ( 7, 6) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_ludecomp.c", "rank": 19, "score": 70803.49043483878 }, { "content": "float matrixf_data_aug_x[] = {\n\n -0.747572302818 /* ( 0, 0) */,\n\n 1.023007512093 /* ( 0, 1) */,\n\n -0.806419134140 /* ( 0, 2) */,\n\n 1.476346969604 /* ( 0, 3) */,\n\n -0.456311076880 /* ( 1, 0) */,\n\n 1.049571633339 /* ( 1, 1) */,\n\n 0.041211493313 /* ( 1, 2) */,\n\n 0.870350718498 /* ( 1, 3) */,\n\n -0.585918903351 /* ( 2, 0) */,\n\n -2.498867988586 /* ( 2, 1) */,\n\n 1.247432827950 /* ( 2, 2) */,\n\n -1.840264678001 /* ( 2, 3) */,\n\n 0.618996977806 /* ( 3, 0) */,\n\n -1.083691835403 /* ( 3, 1) */,\n\n -1.827050209045 /* ( 3, 2) */,\n\n -0.579039454460 /* ( 3, 3) */,\n\n 1.507880568504 /* ( 4, 0) */,\n\n 1.633087396622 /* ( 4, 1) */,\n\n -0.439950227737 /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_aug.c", "rank": 20, "score": 70803.49043483878 }, { "content": "float matrixf_data_mul_x[] = {\n\n -0.348304957151 /* ( 0, 0) */,\n\n 1.638695955276 /* ( 0, 1) */,\n\n 0.618153512478 /* ( 0, 2) */,\n\n 0.580581486225 /* ( 0, 3) */,\n\n 1.125966548920 /* ( 1, 0) */,\n\n 0.590879321098 /* ( 1, 1) */,\n\n -0.499333083630 /* ( 1, 2) */,\n\n -0.144607886672 /* ( 1, 3) */,\n\n -0.169909551740 /* ( 2, 0) */,\n\n 1.626509308815 /* ( 2, 1) */,\n\n -0.776567280293 /* ( 2, 2) */,\n\n -1.341656446457 /* ( 2, 3) */,\n\n 0.492572665215 /* ( 3, 0) */,\n\n -0.075633287430 /* ( 3, 1) */,\n\n 1.035362601280 /* ( 3, 2) */,\n\n 0.842321217060 /* ( 3, 3) */,\n\n -0.209287241101 /* ( 4, 0) */,\n\n -0.789002001286 /* ( 4, 1) */,\n\n -0.397730469704 /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_mul.c", "rank": 21, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_linsolve_x[] = {\n\n -0.686784207821 + 0.516409814358*_Complex_I /* ( 0, 0) */,\n\n 0.725918948650 + -0.725804686546*_Complex_I /* ( 1, 0) */,\n\n 0.048043362796 + 1.415739893913*_Complex_I /* ( 2, 0) */,\n\n 1.184294700623 + -1.108955144882*_Complex_I /* ( 3, 0) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_linsolve.c", "rank": 22, "score": 70803.49043483878 }, { "content": "float matrixf_data_linsolve_x[] = {\n\n -0.848446607590 /* ( 0, 0) */,\n\n 1.041861057281 /* ( 1, 0) */,\n\n 0.453321367502 /* ( 2, 0) */,\n\n -0.949143886566 /* ( 3, 0) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_linsolve.c", "rank": 23, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_mul_z[] = {\n\n -3.015598273252 + -3.823225604286*_Complex_I /* ( 0, 0) */,\n\n -6.503138041472 + 2.522251659946*_Complex_I /* ( 0, 1) */,\n\n -3.033435877267 + -2.533375977709*_Complex_I /* ( 0, 2) */,\n\n 1.711291176504 + 0.187568584413*_Complex_I /* ( 1, 0) */,\n\n 0.527484730969 + -0.085346610822*_Complex_I /* ( 1, 1) */,\n\n 2.440625470928 + -0.878385559540*_Complex_I /* ( 1, 2) */,\n\n 0.383559143593 + -1.078745633782*_Complex_I /* ( 2, 0) */,\n\n 0.093675017974 + -1.944126015771*_Complex_I /* ( 2, 1) */,\n\n -1.122987739839 + -1.365514815630*_Complex_I /* ( 2, 2) */,\n\n -3.347645581625 + 0.552152171890*_Complex_I /* ( 3, 0) */,\n\n 0.554058303745 + 4.932442551750*_Complex_I /* ( 3, 1) */,\n\n -3.263304464031 + 0.357861697730*_Complex_I /* ( 3, 2) */,\n\n 2.461434774758 + 3.932854324787*_Complex_I /* ( 4, 0) */,\n\n 1.845966920717 + 2.370697350446*_Complex_I /* ( 4, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_mul.c", "rank": 24, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_aug_x[] = {\n\n -1.383545994759 + 0.803655147552*_Complex_I /* ( 0, 0) */,\n\n -0.918114125729 + -1.194809913635*_Complex_I /* ( 0, 1) */,\n\n 0.090901032090 + 0.484884619713*_Complex_I /* ( 0, 2) */,\n\n 0.109402157366 + 1.450437188148*_Complex_I /* ( 0, 3) */,\n\n -2.269510746002 + -0.606436431408*_Complex_I /* ( 1, 0) */,\n\n -0.195189133286 + 0.416639328003*_Complex_I /* ( 1, 1) */,\n\n 1.940145850182 + 0.895506143570*_Complex_I /* ( 1, 2) */,\n\n -0.784153759480 + -0.345893263817*_Complex_I /* ( 1, 3) */,\n\n 0.652509629726 + 0.994532823563*_Complex_I /* ( 2, 0) */,\n\n -2.253150939941 + 0.327611356974*_Complex_I /* ( 2, 1) */,\n\n 1.012208938599 + -0.677044689655*_Complex_I /* ( 2, 2) */,\n\n -0.700399398804 + -0.330108255148*_Complex_I /* ( 2, 3) */,\n\n -1.175772666931 + 0.248428389430*_Complex_I /* ( 3, 0) */,\n\n 0.412228941917 + -2.519471645355*_Complex_I /* ( 3, 1) */,\n\n -1.667356371880 + -1.187105178833*_Complex_I /* ( 3, 2) */,\n\n 1.243350982666 + -0.736937880516*_Complex_I /* ( 3, 3) */,\n\n 0.033468723297 + 0.131351217628*_Complex_I /* ( 4, 0) */,\n\n -0.617851972580 + 1.434038400650*_Complex_I /* ( 4, 1) */,\n\n -1.009798288345 + 0.758803665638*_Complex_I /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_aug.c", "rank": 25, "score": 70803.49043483878 }, { "content": "float matrixf_data_add_x[] = {\n\n -2.153858900070 /* ( 0, 0) */,\n\n 0.374406367540 /* ( 0, 1) */,\n\n -0.356648415327 /* ( 0, 2) */,\n\n 0.673922061920 /* ( 0, 3) */,\n\n -1.686753273010 /* ( 1, 0) */,\n\n -0.382442235947 /* ( 1, 1) */,\n\n 0.287308961153 /* ( 1, 2) */,\n\n -0.479356884956 /* ( 1, 3) */,\n\n -0.336519986391 /* ( 2, 0) */,\n\n 0.173820436001 /* ( 2, 1) */,\n\n -1.243059277534 /* ( 2, 2) */,\n\n -1.508571028709 /* ( 2, 3) */,\n\n 0.903724849224 /* ( 3, 0) */,\n\n 0.490690946579 /* ( 3, 1) */,\n\n 0.242906242609 /* ( 3, 2) */,\n\n 0.192125678062 /* ( 3, 3) */,\n\n 0.053418140858 /* ( 4, 0) */,\n\n 0.389735013247 /* ( 4, 1) */,\n\n 0.781731247902 /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_add.c", "rank": 26, "score": 70803.49043483878 }, { "content": "float matrixf_data_add_z[] = {\n\n -3.723292708397 /* ( 0, 0) */,\n\n 0.557299107313 /* ( 0, 1) */,\n\n 2.063485652208 /* ( 0, 2) */,\n\n 0.559189930558 /* ( 0, 3) */,\n\n -2.960913181305 /* ( 1, 0) */,\n\n -1.613401770592 /* ( 1, 1) */,\n\n 0.862108796835 /* ( 1, 2) */,\n\n -1.236323416233 /* ( 1, 3) */,\n\n 1.090232938528 /* ( 2, 0) */,\n\n 1.191981017590 /* ( 2, 1) */,\n\n -1.342327684164 /* ( 2, 2) */,\n\n -0.825069963932 /* ( 2, 3) */,\n\n 1.049390435219 /* ( 3, 0) */,\n\n 0.827814489603 /* ( 3, 1) */,\n\n 0.997274011374 /* ( 3, 2) */,\n\n 1.100628733635 /* ( 3, 3) */,\n\n -1.267192382365 /* ( 4, 0) */,\n\n -0.701247900724 /* ( 4, 1) */,\n\n 1.276332199574 /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_add.c", "rank": 27, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_inv_y[] = {\n\n -0.127852678827 + -0.009178191835*_Complex_I /* ( 0, 0) */,\n\n -0.199905444866 + 0.033789259175*_Complex_I /* ( 0, 1) */,\n\n 0.168465876479 + -0.059607902071*_Complex_I /* ( 0, 2) */,\n\n 0.087700609092 + -0.030597427908*_Complex_I /* ( 0, 3) */,\n\n 0.084793376582 + 0.131223765916*_Complex_I /* ( 0, 4) */,\n\n 0.209779356201 + 0.642123753363*_Complex_I /* ( 1, 0) */,\n\n -0.045651767577 + -0.019599459364*_Complex_I /* ( 1, 1) */,\n\n 0.137284052424 + 0.504637287094*_Complex_I /* ( 1, 2) */,\n\n -0.333643348460 + 0.455368743084*_Complex_I /* ( 1, 3) */,\n\n 0.244939020151 + -0.609710193351*_Complex_I /* ( 1, 4) */,\n\n -0.114524820581 + 0.963012925652*_Complex_I /* ( 2, 0) */,\n\n 0.303499486096 + 0.348121666797*_Complex_I /* ( 2, 1) */,\n\n -0.327372880299 + 0.397314645420*_Complex_I /* ( 2, 2) */,\n\n -0.231096370464 + 0.372958732742*_Complex_I /* ( 2, 3) */,\n\n 0.089363987094 + -0.240520272187*_Complex_I /* ( 2, 4) */,\n\n 0.072169240922 + 0.159456098576*_Complex_I /* ( 3, 0) */,\n\n -0.064066539188 + 0.069570707500*_Complex_I /* ( 3, 1) */,\n\n 0.090335627717 + -0.121329478735*_Complex_I /* ( 3, 2) */,\n\n 0.053196220990 + -0.158230982223*_Complex_I /* ( 3, 3) */,\n\n -0.413653285108 + 0.167815066469*_Complex_I /* ( 3, 4) */,\n\n 0.089194647874 + -0.035492413461*_Complex_I /* ( 4, 0) */,\n\n -0.192303472410 + -0.221655891788*_Complex_I /* ( 4, 1) */,\n\n 0.111730542618 + -0.221903756183*_Complex_I /* ( 4, 2) */,\n\n 0.303835472120 + -0.022543572811*_Complex_I /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_inv.c", "rank": 28, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_transmul_x[] = {\n\n 0.897770464420 + -1.137341141701*_Complex_I /* ( 0, 0) */,\n\n 0.816529691219 + -0.575469911098*_Complex_I /* ( 0, 1) */,\n\n 2.407611131668 + 0.901603281498*_Complex_I /* ( 0, 2) */,\n\n -1.024818181992 + -1.785745739937*_Complex_I /* ( 0, 3) */,\n\n 1.494256496429 + -0.826167643070*_Complex_I /* ( 1, 0) */,\n\n -0.908512234688 + 0.119766108692*_Complex_I /* ( 1, 1) */,\n\n -0.215938329697 + -2.537411689758*_Complex_I /* ( 1, 2) */,\n\n -1.348789930344 + -0.935531198978*_Complex_I /* ( 1, 3) */,\n\n -0.398543357849 + 0.101190350950*_Complex_I /* ( 2, 0) */,\n\n -0.083604514599 + 1.493514776230*_Complex_I /* ( 2, 1) */,\n\n 0.477280050516 + -0.074863225222*_Complex_I /* ( 2, 2) */,\n\n -0.283995777369 + 0.336168438196*_Complex_I /* ( 2, 3) */,\n\n -0.030109925196 + -1.602186083794*_Complex_I /* ( 3, 0) */,\n\n 2.220442056656 + -0.208865001798*_Complex_I /* ( 3, 1) */,\n\n 1.889614224434 + -0.896111547947*_Complex_I /* ( 3, 2) */,\n\n -0.317830920219 + 0.215485602617*_Complex_I /* ( 3, 3) */,\n\n -0.945744097233 + -0.822628259659*_Complex_I /* ( 4, 0) */,\n\n -0.238264903426 + 0.054408840835*_Complex_I /* ( 4, 1) */,\n\n 0.532425582409 + 0.438958346844*_Complex_I /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_transmul.c", "rank": 29, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_aug_z[] = {\n\n -1.383545994759 + 0.803655147552*_Complex_I /* ( 0, 0) */,\n\n -0.918114125729 + -1.194809913635*_Complex_I /* ( 0, 1) */,\n\n 0.090901032090 + 0.484884619713*_Complex_I /* ( 0, 2) */,\n\n 0.109402157366 + 1.450437188148*_Complex_I /* ( 0, 3) */,\n\n 0.301848381758 + 0.353115469217*_Complex_I /* ( 0, 4) */,\n\n 0.703616917133 + 0.044240720570*_Complex_I /* ( 0, 5) */,\n\n 0.268176555634 + 1.071476221085*_Complex_I /* ( 0, 6) */,\n\n -2.269510746002 + -0.606436431408*_Complex_I /* ( 1, 0) */,\n\n -0.195189133286 + 0.416639328003*_Complex_I /* ( 1, 1) */,\n\n 1.940145850182 + 0.895506143570*_Complex_I /* ( 1, 2) */,\n\n -0.784153759480 + -0.345893263817*_Complex_I /* ( 1, 3) */,\n\n -0.717849135399 + -0.764326214790*_Complex_I /* ( 1, 4) */,\n\n -0.108926303685 + -0.315297245979*_Complex_I /* ( 1, 5) */,\n\n 0.357895255089 + -1.419853448868*_Complex_I /* ( 1, 6) */,\n\n 0.652509629726 + 0.994532823563*_Complex_I /* ( 2, 0) */,\n\n -2.253150939941 + 0.327611356974*_Complex_I /* ( 2, 1) */,\n\n 1.012208938599 + -0.677044689655*_Complex_I /* ( 2, 2) */,\n\n -0.700399398804 + -0.330108255148*_Complex_I /* ( 2, 3) */,\n\n -0.831380963326 + 1.003911018372*_Complex_I /* ( 2, 4) */,\n\n -0.361211270094 + -0.926369905472*_Complex_I /* ( 2, 5) */,\n\n 2.307183980942 + -0.432167291641*_Complex_I /* ( 2, 6) */,\n\n -1.175772666931 + 0.248428389430*_Complex_I /* ( 3, 0) */,\n\n 0.412228941917 + -2.519471645355*_Complex_I /* ( 3, 1) */,\n\n -1.667356371880 + -1.187105178833*_Complex_I /* ( 3, 2) */,\n\n 1.243350982666 + -0.736937880516*_Complex_I /* ( 3, 3) */,\n\n -0.694230437279 + -1.021739125252*_Complex_I /* ( 3, 4) */,\n\n 0.412434548140 + -1.840429663658*_Complex_I /* ( 3, 5) */,\n\n 0.342358648777 + -1.084336757660*_Complex_I /* ( 3, 6) */,\n\n 0.033468723297 + 0.131351217628*_Complex_I /* ( 4, 0) */,\n\n -0.617851972580 + 1.434038400650*_Complex_I /* ( 4, 1) */,\n\n -1.009798288345 + 0.758803665638*_Complex_I /* ( 4, 2) */,\n\n 1.450994849205 + -0.595933079720*_Complex_I /* ( 4, 3) */,\n\n -0.314995974302 + -0.811702668667*_Complex_I /* ( 4, 4) */,\n\n 0.912520587444 + -2.686280250549*_Complex_I /* ( 4, 5) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_aug.c", "rank": 30, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_qrdecomp_A[] = {\n\n 2.114020000000 + -0.576040000000*_Complex_I /* ( 0, 0) */,\n\n 0.417500000000 + 1.008330000000*_Complex_I /* ( 0, 1) */,\n\n -0.962640000000 + -3.621960000000*_Complex_I /* ( 0, 2) */,\n\n -0.206790000000 + -1.026680000000*_Complex_I /* ( 0, 3) */,\n\n 0.008540000000 + 1.616260000000*_Complex_I /* ( 1, 0) */,\n\n 0.846950000000 + -0.327360000000*_Complex_I /* ( 1, 1) */,\n\n -1.018620000000 + -1.107860000000*_Complex_I /* ( 1, 2) */,\n\n -1.788770000000 + 1.844560000000*_Complex_I /* ( 1, 3) */,\n\n -2.979010000000 + -1.303840000000*_Complex_I /* ( 2, 0) */,\n\n 0.522890000000 + 1.891100000000*_Complex_I /* ( 2, 1) */,\n\n 1.325760000000 + -0.367370000000*_Complex_I /* ( 2, 2) */,\n\n 0.047170000000 + 0.206280000000*_Complex_I /* ( 2, 3) */,\n\n 0.289700000000 + 0.642470000000*_Complex_I /* ( 3, 0) */,\n\n -0.559160000000 + 0.683020000000*_Complex_I /* ( 3, 1) */,\n\n 1.406150000000 + 0.623980000000*_Complex_I /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_qrdecomp.c", "rank": 31, "score": 70803.49043483878 }, { "content": "float matrixf_data_linsolve_A[] = {\n\n 0.359868824482 /* ( 0, 0) */,\n\n -0.821193814278 /* ( 0, 1) */,\n\n -0.267460018396 /* ( 0, 2) */,\n\n 0.886115014553 /* ( 0, 3) */,\n\n 0.153591111302 /* ( 0, 4) */,\n\n 0.298885852098 /* ( 1, 0) */,\n\n -1.239024162292 /* ( 1, 1) */,\n\n -0.948822617531 /* ( 1, 2) */,\n\n -0.779868483543 /* ( 1, 3) */,\n\n -0.334943383932 /* ( 1, 4) */,\n\n -0.071195065975 /* ( 2, 0) */,\n\n 0.763968944550 /* ( 2, 1) */,\n\n 0.294695496559 /* ( 2, 2) */,\n\n 0.060610540211 /* ( 2, 3) */,\n\n 0.016189640388 /* ( 2, 4) */,\n\n 1.150504231453 /* ( 3, 0) */,\n\n -0.605459213257 /* ( 3, 1) */,\n\n 0.055004067719 /* ( 3, 2) */,\n\n 1.185544967651 /* ( 3, 3) */,\n\n 0.555612862110 /* ( 3, 4) */,\n\n 1.054118633270 /* ( 4, 0) */,\n\n -0.494105964899 /* ( 4, 1) */,\n\n -0.824876368046 /* ( 4, 2) */,\n\n 0.667240202427 /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_linsolve.c", "rank": 32, "score": 70803.49043483878 }, { "content": "float matrixf_data_gramschmidt_A[] = {\n\n 1.000000000000 /* ( 0, 0) */,\n\n 2.000000000000 /* ( 0, 1) */,\n\n 1.000000000000 /* ( 0, 2) */,\n\n 0.000000000000 /* ( 1, 0) */,\n\n 2.000000000000 /* ( 1, 1) */,\n\n 0.000000000000 /* ( 1, 2) */,\n\n 2.000000000000 /* ( 2, 0) */,\n\n 3.000000000000 /* ( 2, 1) */,\n\n 1.000000000000 /* ( 2, 2) */,\n\n 1.000000000000 /* ( 3, 0) */,\n\n 1.000000000000 /* ( 3, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_gramschmidt.c", "rank": 33, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_inv_x[] = {\n\n -0.911099433899 + -0.436777323484*_Complex_I /* ( 0, 0) */,\n\n 0.598295390606 + -0.283340752125*_Complex_I /* ( 0, 1) */,\n\n -0.264758616686 + -0.421906232834*_Complex_I /* ( 0, 2) */,\n\n -0.066837862134 + -0.934806823730*_Complex_I /* ( 0, 3) */,\n\n 0.393610686064 + -1.011345505714*_Complex_I /* ( 0, 4) */,\n\n -0.543692529202 + -1.426580429077*_Complex_I /* ( 1, 0) */,\n\n -1.006833553314 + 0.448534607887*_Complex_I /* ( 1, 1) */,\n\n 0.048818156123 + -0.540948212147*_Complex_I /* ( 1, 2) */,\n\n 0.180871278048 + 0.331172674894*_Complex_I /* ( 1, 3) */,\n\n -1.100448012352 + 1.841731786728*_Complex_I /* ( 1, 4) */,\n\n 2.341797351837 + -1.200128436089*_Complex_I /* ( 2, 0) */,\n\n 0.239693909883 + 0.206349417567*_Complex_I /* ( 2, 1) */,\n\n -0.815828502178 + -0.349400132895*_Complex_I /* ( 2, 2) */,\n\n 1.213637232780 + 0.298941820860*_Complex_I /* ( 2, 3) */,\n\n -1.522765398026 + 1.651986479759*_Complex_I /* ( 2, 4) */,\n\n 1.481738448143 + 0.055169839412*_Complex_I /* ( 3, 0) */,\n\n -1.241538286209 + -0.077680915594*_Complex_I /* ( 3, 1) */,\n\n 1.046607017517 + -0.843883395195*_Complex_I /* ( 3, 2) */,\n\n -1.564810752869 + 1.346152186394*_Complex_I /* ( 3, 3) */,\n\n 0.786287426949 + -1.010108113289*_Complex_I /* ( 3, 4) */,\n\n 1.234361886978 + -1.305809140205*_Complex_I /* ( 4, 0) */,\n\n 0.053748749197 + 0.403882414103*_Complex_I /* ( 4, 1) */,\n\n -0.081336200237 + -0.462558329105*_Complex_I /* ( 4, 2) */,\n\n -1.370563983917 + -0.284755766392*_Complex_I /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_inv.c", "rank": 34, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_linsolve_A[] = {\n\n -0.482884645462 + -0.221723198891*_Complex_I /* ( 0, 0) */,\n\n -0.387645065784 + 0.086682170630*_Complex_I /* ( 0, 1) */,\n\n 1.580931067467 + 0.883717715740*_Complex_I /* ( 0, 2) */,\n\n 1.570333838463 + 1.783135294914*_Complex_I /* ( 0, 3) */,\n\n -1.081483244896 + -0.691094517708*_Complex_I /* ( 0, 4) */,\n\n 0.248138338327 + -0.250954031944*_Complex_I /* ( 1, 0) */,\n\n 0.790891706944 + -0.313775628805*_Complex_I /* ( 1, 1) */,\n\n -0.146090522408 + -1.320674061775*_Complex_I /* ( 1, 2) */,\n\n 0.672296106815 + 1.346951484680*_Complex_I /* ( 1, 3) */,\n\n -0.352442741394 + 0.056975554675*_Complex_I /* ( 1, 4) */,\n\n 0.707973957062 + -0.069402769208*_Complex_I /* ( 2, 0) */,\n\n -0.894841134548 + -1.854133605957*_Complex_I /* ( 2, 1) */,\n\n 0.397095054388 + -0.924011290073*_Complex_I /* ( 2, 2) */,\n\n 0.054669041187 + 0.017023870721*_Complex_I /* ( 2, 3) */,\n\n 0.515784740448 + -0.455956429243*_Complex_I /* ( 2, 4) */,\n\n 0.570774257183 + 0.538610219955*_Complex_I /* ( 3, 0) */,\n\n -0.389531791210 + 0.200702637434*_Complex_I /* ( 3, 1) */,\n\n 0.159817531705 + 1.283960223198*_Complex_I /* ( 3, 2) */,\n\n 1.571215510368 + 0.574963092804*_Complex_I /* ( 3, 3) */,\n\n -2.452192783356 + -0.583715677261*_Complex_I /* ( 3, 4) */,\n\n -0.603657603264 + 0.617622077465*_Complex_I /* ( 4, 0) */,\n\n 0.935181498528 + 0.949800848961*_Complex_I /* ( 4, 1) */,\n\n 0.043205004185 + 1.351160168648*_Complex_I /* ( 4, 2) */,\n\n 0.674502849579 + 0.340750336647*_Complex_I /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_linsolve.c", "rank": 35, "score": 70803.49043483878 }, { "content": "float matrixf_data_add_y[] = {\n\n -1.569433808327 /* ( 0, 0) */,\n\n 0.182892739773 /* ( 0, 1) */,\n\n 2.420134067535 /* ( 0, 2) */,\n\n -0.114732131362 /* ( 0, 3) */,\n\n -1.274159908295 /* ( 1, 0) */,\n\n -1.230959534645 /* ( 1, 1) */,\n\n 0.574799835682 /* ( 1, 2) */,\n\n -0.756966531277 /* ( 1, 3) */,\n\n 1.426752924919 /* ( 2, 0) */,\n\n 1.018160581589 /* ( 2, 1) */,\n\n -0.099268406630 /* ( 2, 2) */,\n\n 0.683501064777 /* ( 2, 3) */,\n\n 0.145665585995 /* ( 3, 0) */,\n\n 0.337123543024 /* ( 3, 1) */,\n\n 0.754367768764 /* ( 3, 2) */,\n\n 0.908503055573 /* ( 3, 3) */,\n\n -1.320610523224 /* ( 4, 0) */,\n\n -1.090982913971 /* ( 4, 1) */,\n\n 0.494600951672 /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_add.c", "rank": 36, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_add_z[] = {\n\n 1.020989149809 + -1.222570940852*_Complex_I /* ( 0, 0) */,\n\n 1.956622326747 + 1.303171724081*_Complex_I /* ( 0, 1) */,\n\n 1.820821523666 + 0.925375699997*_Complex_I /* ( 0, 2) */,\n\n -0.606791973114 + -0.378512620926*_Complex_I /* ( 0, 3) */,\n\n -0.301656126976 + -0.272797226906*_Complex_I /* ( 1, 0) */,\n\n 0.775403156877 + -0.039727106690*_Complex_I /* ( 1, 1) */,\n\n -0.921648263931 + -1.438294589520*_Complex_I /* ( 1, 2) */,\n\n 0.185136288404 + -1.732621848583*_Complex_I /* ( 1, 3) */,\n\n 0.271754145622 + -1.168147444725*_Complex_I /* ( 2, 0) */,\n\n 0.315091997385 + -0.198208212852*_Complex_I /* ( 2, 1) */,\n\n -1.469907134771 + -0.986759126186*_Complex_I /* ( 2, 2) */,\n\n -2.923005938530 + -1.180873513222*_Complex_I /* ( 2, 3) */,\n\n 0.882852658629 + -2.654983639717*_Complex_I /* ( 3, 0) */,\n\n 3.279390454292 + 1.307808995247*_Complex_I /* ( 3, 1) */,\n\n -0.576317749918 + -0.053750261664*_Complex_I /* ( 3, 2) */,\n\n 0.336690194905 + -2.192658126354*_Complex_I /* ( 3, 3) */,\n\n -0.207499474287 + 0.349328503013*_Complex_I /* ( 4, 0) */,\n\n 0.504008874297 + -0.954922614619*_Complex_I /* ( 4, 1) */,\n\n -1.156464576721 + -1.144047161564*_Complex_I /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_add.c", "rank": 37, "score": 70803.49043483878 }, { "content": "float matrixf_data_inv_x[] = {\n\n 0.145655393600 /* ( 0, 0) */,\n\n -2.292126655579 /* ( 0, 1) */,\n\n 0.928358852863 /* ( 0, 2) */,\n\n 0.995244622231 /* ( 0, 3) */,\n\n -0.719965457916 /* ( 0, 4) */,\n\n 1.625229239464 /* ( 1, 0) */,\n\n 1.179069876671 /* ( 1, 1) */,\n\n 0.023814691231 /* ( 1, 2) */,\n\n -0.458529949188 /* ( 1, 3) */,\n\n 0.870123147964 /* ( 1, 4) */,\n\n 1.599076509476 /* ( 2, 0) */,\n\n 1.012132167816 /* ( 2, 1) */,\n\n 0.240342438221 /* ( 2, 2) */,\n\n -0.663878023624 /* ( 2, 3) */,\n\n 1.523158550262 /* ( 2, 4) */,\n\n 1.400263786316 /* ( 3, 0) */,\n\n -0.016515849158 /* ( 3, 1) */,\n\n 0.525676131248 /* ( 3, 2) */,\n\n -0.526886940002 /* ( 3, 3) */,\n\n -0.605886101723 /* ( 3, 4) */,\n\n -0.291201651096 /* ( 4, 0) */,\n\n 0.635409533978 /* ( 4, 1) */,\n\n 0.016531571746 /* ( 4, 2) */,\n\n 0.113017730415 /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_inv.c", "rank": 38, "score": 70803.49043483878 }, { "content": "float matrixf_data_cgsolve_x[] = {\n\n 0.162052200000 /* ( 0, 0) */,\n\n -0.012720300000 /* ( 1, 0) */,\n\n 1.043375100000 /* ( 2, 0) */,\n\n 0.006205200000 /* ( 3, 0) */,\n\n 0.878157000000 /* ( 4, 0) */,\n\n 0.146412900000 /* ( 5, 0) */,\n\n 0.782585200000 /* ( 6, 0) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_cgsolve.c", "rank": 39, "score": 70803.49043483878 }, { "content": "float matrixf_data_qrdecomp_A[] = {\n\n 1.000000000000 /* ( 0, 0) */,\n\n 2.000000000000 /* ( 0, 1) */,\n\n 3.000000000000 /* ( 0, 2) */,\n\n 4.000000000000 /* ( 0, 3) */,\n\n 5.000000000000 /* ( 1, 0) */,\n\n 5.000000000000 /* ( 1, 1) */,\n\n 7.000000000000 /* ( 1, 2) */,\n\n 8.000000000000 /* ( 1, 3) */,\n\n 6.000000000000 /* ( 2, 0) */,\n\n 4.000000000000 /* ( 2, 1) */,\n\n 8.000000000000 /* ( 2, 2) */,\n\n 7.000000000000 /* ( 2, 3) */,\n\n 1.000000000000 /* ( 3, 0) */,\n\n 0.000000000000 /* ( 3, 1) */,\n\n 3.000000000000 /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_qrdecomp.c", "rank": 40, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_mul_y[] = {\n\n 0.122429788113 + -1.041572093964*_Complex_I /* ( 0, 0) */,\n\n -1.123313307762 + -1.396123170853*_Complex_I /* ( 0, 1) */,\n\n -0.318034142256 + -0.537796914577*_Complex_I /* ( 0, 2) */,\n\n 0.096901215613 + -0.035752061754*_Complex_I /* ( 1, 0) */,\n\n 0.423960685730 + -0.379842221737*_Complex_I /* ( 1, 1) */,\n\n -0.184147700667 + 0.022100308910*_Complex_I /* ( 1, 2) */,\n\n 0.189968794584 + 0.919595599174*_Complex_I /* ( 2, 0) */,\n\n 0.621766507626 + -0.634516119957*_Complex_I /* ( 2, 1) */,\n\n 0.605251312256 + 1.410223841667*_Complex_I /* ( 2, 2) */,\n\n 0.427330523729 + 0.042397715151*_Complex_I /* ( 3, 0) */,\n\n 0.204851210117 + 0.611065924168*_Complex_I /* ( 3, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_mul.c", "rank": 41, "score": 70803.49043483878 }, { "content": "float matrixf_data_transmul_x[] = {\n\n 1.366575479507 /* ( 0, 0) */,\n\n 1.982354640961 /* ( 0, 1) */,\n\n 0.913504719734 /* ( 0, 2) */,\n\n 0.671039104462 /* ( 0, 3) */,\n\n 0.264611721039 /* ( 1, 0) */,\n\n 0.995791137218 /* ( 1, 1) */,\n\n -1.983934879303 /* ( 1, 2) */,\n\n -0.375840932131 /* ( 1, 3) */,\n\n 0.245937779546 /* ( 2, 0) */,\n\n -0.343152791262 /* ( 2, 1) */,\n\n -0.143777698278 /* ( 2, 2) */,\n\n -1.387172579765 /* ( 2, 3) */,\n\n 0.781192481518 /* ( 3, 0) */,\n\n 1.444583415985 /* ( 3, 1) */,\n\n 0.043851174414 /* ( 3, 2) */,\n\n 0.399744838476 /* ( 3, 3) */,\n\n -0.488068610430 /* ( 4, 0) */,\n\n 0.573721885681 /* ( 4, 1) */,\n\n -1.381630182266 /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_transmul.c", "rank": 42, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_add_x[] = {\n\n 1.366575479507 + -1.463535666466*_Complex_I /* ( 0, 0) */,\n\n 1.982354640961 + 0.090445250273*_Complex_I /* ( 0, 1) */,\n\n 0.913504719734 + -0.689249753952*_Complex_I /* ( 0, 2) */,\n\n 0.671039104462 + -0.184951126575*_Complex_I /* ( 0, 3) */,\n\n 0.264611721039 + 0.204716682434*_Complex_I /* ( 1, 0) */,\n\n 0.995791137218 + -0.192152589560*_Complex_I /* ( 1, 1) */,\n\n -1.983934879303 + -0.306251227856*_Complex_I /* ( 1, 2) */,\n\n -0.375840932131 + -0.751154422760*_Complex_I /* ( 1, 3) */,\n\n 0.245937779546 + -0.470900952816*_Complex_I /* ( 2, 0) */,\n\n -0.343152791262 + 1.205224752426*_Complex_I /* ( 2, 1) */,\n\n -0.143777698278 + -0.457689523697*_Complex_I /* ( 2, 2) */,\n\n -1.387172579765 + 0.225333094597*_Complex_I /* ( 2, 3) */,\n\n 0.781192481518 + -1.102205991745*_Complex_I /* ( 3, 0) */,\n\n 1.444583415985 + 0.660028517246*_Complex_I /* ( 3, 1) */,\n\n 0.043851174414 + 0.049496211112*_Complex_I /* ( 3, 2) */,\n\n 0.399744838476 + -1.435891628265*_Complex_I /* ( 3, 3) */,\n\n -0.488068610430 + -0.211131110787*_Complex_I /* ( 4, 0) */,\n\n 0.573721885681 + 0.016210200265*_Complex_I /* ( 4, 1) */,\n\n -1.381630182266 + -0.026558181271*_Complex_I /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_add.c", "rank": 43, "score": 70803.49043483878 }, { "content": "float matrixf_data_mul_z[] = {\n\n -2.232843128510 /* ( 0, 0) */,\n\n -0.086305075740 /* ( 0, 1) */,\n\n -0.251460714553 /* ( 0, 2) */,\n\n 0.355936096586 /* ( 1, 0) */,\n\n 0.720042365177 /* ( 1, 1) */,\n\n -0.535516414414 /* ( 1, 2) */,\n\n -0.845833288222 /* ( 2, 0) */,\n\n 2.763750941354 /* ( 2, 1) */,\n\n 0.647562038031 /* ( 2, 2) */,\n\n -0.610483740991 /* ( 3, 0) */,\n\n -1.102197535527 /* ( 3, 1) */,\n\n -0.981798103518 /* ( 3, 2) */,\n\n 0.952583633427 /* ( 4, 0) */,\n\n -0.547495051253 /* ( 4, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_mul.c", "rank": 44, "score": 70803.49043483878 }, { "content": "float matrixf_data_inv_y[] = {\n\n 0.123047731616 /* ( 0, 0) */,\n\n 1.264793339850 /* ( 0, 1) */,\n\n -0.888020214878 /* ( 0, 2) */,\n\n 0.146648698334 /* ( 0, 3) */,\n\n -0.484762774689 /* ( 0, 4) */,\n\n 0.031615676756 /* ( 1, 0) */,\n\n -0.041217620573 /* ( 1, 1) */,\n\n 0.486809371567 /* ( 1, 2) */,\n\n -0.307386761818 /* ( 1, 3) */,\n\n 0.980900315396 /* ( 1, 4) */,\n\n 0.456515830075 /* ( 2, 0) */,\n\n -2.168499777786 /* ( 2, 1) */,\n\n 2.469455722213 /* ( 2, 2) */,\n\n 0.010642598564 /* ( 2, 3) */,\n\n 1.737407148356 /* ( 2, 4) */,\n\n 0.690799395919 /* ( 3, 0) */,\n\n 1.532809684521 /* ( 3, 1) */,\n\n -0.611813824735 /* ( 3, 2) */,\n\n -1.028413056396 /* ( 3, 3) */,\n\n 0.595460566672 /* ( 3, 4) */,\n\n 0.078865348162 /* ( 4, 0) */,\n\n -0.290188077617 /* ( 4, 1) */,\n\n 0.609005594780 /* ( 4, 2) */,\n\n -0.399620351004 /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_inv.c", "rank": 45, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_add_y[] = {\n\n -0.345586329699 + 0.240964725614*_Complex_I /* ( 0, 0) */,\n\n -0.025732314214 + 1.212726473808*_Complex_I /* ( 0, 1) */,\n\n 0.907316803932 + 1.614625453949*_Complex_I /* ( 0, 2) */,\n\n -1.277831077576 + -0.193561494350*_Complex_I /* ( 0, 3) */,\n\n -0.566267848015 + -0.477513909340*_Complex_I /* ( 1, 0) */,\n\n -0.220387980342 + 0.152425482869*_Complex_I /* ( 1, 1) */,\n\n 1.062286615372 + -1.132043361664*_Complex_I /* ( 1, 2) */,\n\n 0.560977220535 + -0.981467425823*_Complex_I /* ( 1, 3) */,\n\n 0.025816366076 + -0.697246491909*_Complex_I /* ( 2, 0) */,\n\n 0.658244788647 + -1.403432965279*_Complex_I /* ( 2, 1) */,\n\n -1.326129436493 + -0.529069602489*_Complex_I /* ( 2, 2) */,\n\n -1.535833358765 + -1.406206607819*_Complex_I /* ( 2, 3) */,\n\n 0.101660177112 + -1.552777647972*_Complex_I /* ( 3, 0) */,\n\n 1.834807038307 + 0.647780478001*_Complex_I /* ( 3, 1) */,\n\n -0.620168924332 + -0.103246472776*_Complex_I /* ( 3, 2) */,\n\n -0.063054643571 + -0.756766498089*_Complex_I /* ( 3, 3) */,\n\n 0.280569136143 + 0.560459613800*_Complex_I /* ( 4, 0) */,\n\n -0.069713011384 + -0.971132814884*_Complex_I /* ( 4, 1) */,\n\n 0.225165605545 + -1.117488980293*_Complex_I /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_add.c", "rank": 46, "score": 70803.49043483878 }, { "content": "float matrixf_data_mul_y[] = {\n\n 0.445414155722 /* ( 0, 0) */,\n\n 0.233421698213 /* ( 0, 1) */,\n\n -0.682938814163 /* ( 0, 2) */,\n\n -0.934787094593 /* ( 1, 0) */,\n\n 0.500407993793 /* ( 1, 1) */,\n\n -0.053248234093 /* ( 1, 2) */,\n\n -0.784089267254 /* ( 2, 0) */,\n\n 0.127269089222 /* ( 2, 1) */,\n\n -0.477077603340 /* ( 2, 2) */,\n\n -0.105383664370 /* ( 3, 0) */,\n\n -1.556528329849 /* ( 3, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_mul.c", "rank": 47, "score": 70803.49043483878 }, { "content": "float matrixf_data_cgsolve_b[] = {\n\n -2.625551095190 /* ( 0, 0) */,\n\n -0.002183088520 /* ( 1, 0) */,\n\n 1.687960897575 /* ( 2, 0) */,\n\n 0.007325024691 /* ( 3, 0) */,\n\n -0.743719348831 /* ( 4, 0) */,\n\n 3.874032638311 /* ( 5, 0) */,\n\n 3.089702075189 /* ( 6, 0) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_cgsolve.c", "rank": 48, "score": 70803.49043483878 }, { "content": "float matrixf_data_chol_A[] = {\n\n 1.020100000000 /* ( 0, 0) */,\n\n -1.434200000000 /* ( 0, 1) */,\n\n 0.323200000000 /* ( 0, 2) */,\n\n -1.030200000000 /* ( 0, 3) */,\n\n -1.434200000000 /* ( 1, 0) */,\n\n 2.266400000000 /* ( 1, 1) */,\n\n 0.550600000000 /* ( 1, 2) */,\n\n 1.288400000000 /* ( 1, 3) */,\n\n 0.323200000000 /* ( 2, 0) */,\n\n 0.550600000000 /* ( 2, 1) */,\n\n 4.232500000000 /* ( 2, 2) */,\n\n -1.464600000000 /* ( 2, 3) */,\n\n -1.030200000000 /* ( 3, 0) */,\n\n 1.288400000000 /* ( 3, 1) */,\n\n -1.464600000000 /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_chol.c", "rank": 49, "score": 70803.49043483878 }, { "content": "float matrixf_data_aug_y[] = {\n\n 0.376702636480 /* ( 0, 0) */,\n\n 0.790158689022 /* ( 0, 1) */,\n\n 2.111151933670 /* ( 0, 2) */,\n\n -0.690664231777 /* ( 1, 0) */,\n\n -0.598035037518 /* ( 1, 1) */,\n\n -0.137144193053 /* ( 1, 2) */,\n\n 1.078616261482 /* ( 2, 0) */,\n\n 0.907722294331 /* ( 2, 1) */,\n\n -0.432205766439 /* ( 2, 2) */,\n\n -1.615019798279 /* ( 3, 0) */,\n\n 0.122782632709 /* ( 3, 1) */,\n\n 1.174023866653 /* ( 3, 2) */,\n\n 0.233828529716 /* ( 4, 0) */,\n\n 0.032883912325 /* ( 4, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_aug.c", "rank": 50, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_linsolve_b[] = {\n\n 1.889372086452 + 2.079795053851*_Complex_I /* ( 0, 0) */,\n\n 4.099006087145 + 0.093571115573*_Complex_I /* ( 1, 0) */,\n\n -0.465385431770 + -0.201195243205*_Complex_I /* ( 2, 0) */,\n\n -2.502649126311 + -1.292489487343*_Complex_I /* ( 3, 0) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_linsolve.c", "rank": 51, "score": 70803.49043483878 }, { "content": "float matrixf_data_linsolve_b[] = {\n\n -1.938755917550 /* ( 0, 0) */,\n\n -1.636609601788 /* ( 1, 0) */,\n\n 0.951859625938 /* ( 2, 0) */,\n\n -2.040058038471 /* ( 3, 0) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_linsolve.c", "rank": 52, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_mul_x[] = {\n\n 1.131277322769 + -2.908640623093*_Complex_I /* ( 0, 0) */,\n\n 0.847201466560 + -1.637244105339*_Complex_I /* ( 0, 1) */,\n\n -2.173580169678 + 0.096817605197*_Complex_I /* ( 0, 2) */,\n\n 0.792498826981 + -0.358158409595*_Complex_I /* ( 0, 3) */,\n\n -0.243082717061 + 0.824095964432*_Complex_I /* ( 1, 0) */,\n\n -1.889652967453 + 0.283876717091*_Complex_I /* ( 1, 1) */,\n\n 0.044418141246 + -0.882465064526*_Complex_I /* ( 1, 2) */,\n\n 0.515216410160 + -0.366532146931*_Complex_I /* ( 1, 3) */,\n\n 0.579283773899 + 1.173513293266*_Complex_I /* ( 2, 0) */,\n\n 0.059265002608 + -0.497733235359*_Complex_I /* ( 2, 1) */,\n\n -0.877321839333 + 0.404732406139*_Complex_I /* ( 2, 2) */,\n\n -0.794282734394 + 0.456011295319*_Complex_I /* ( 2, 3) */,\n\n -1.174414634705 + -1.358565688133*_Complex_I /* ( 3, 0) */,\n\n -0.418152034283 + 1.380919337273*_Complex_I /* ( 3, 1) */,\n\n -0.747197151184 + 1.584241986275*_Complex_I /* ( 3, 2) */,\n\n -0.522293865681 + -0.573823392391*_Complex_I /* ( 3, 3) */,\n\n -1.866284489632 + -0.199214607477*_Complex_I /* ( 4, 0) */,\n\n -0.453905433416 + 0.452787637711*_Complex_I /* ( 4, 1) */,\n\n 1.989426016808 + -1.771166682243*_Complex_I /* ( 4, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_mul.c", "rank": 53, "score": 70803.49043483878 }, { "content": "float complex matrixcf_data_aug_y[] = {\n\n 0.301848381758 + 0.353115469217*_Complex_I /* ( 0, 0) */,\n\n 0.703616917133 + 0.044240720570*_Complex_I /* ( 0, 1) */,\n\n 0.268176555634 + 1.071476221085*_Complex_I /* ( 0, 2) */,\n\n -0.717849135399 + -0.764326214790*_Complex_I /* ( 1, 0) */,\n\n -0.108926303685 + -0.315297245979*_Complex_I /* ( 1, 1) */,\n\n 0.357895255089 + -1.419853448868*_Complex_I /* ( 1, 2) */,\n\n -0.831380963326 + 1.003911018372*_Complex_I /* ( 2, 0) */,\n\n -0.361211270094 + -0.926369905472*_Complex_I /* ( 2, 1) */,\n\n 2.307183980942 + -0.432167291641*_Complex_I /* ( 2, 2) */,\n\n -0.694230437279 + -1.021739125252*_Complex_I /* ( 3, 0) */,\n\n 0.412434548140 + -1.840429663658*_Complex_I /* ( 3, 1) */,\n\n 0.342358648777 + -1.084336757660*_Complex_I /* ( 3, 2) */,\n\n -0.314995974302 + -0.811702668667*_Complex_I /* ( 4, 0) */,\n\n 0.912520587444 + -2.686280250549*_Complex_I /* ( 4, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_aug.c", "rank": 54, "score": 70803.49043483878 }, { "content": "float matrixf_data_gramschmidt_V[] = {\n\n 0.408248290464 /* ( 0, 0) */,\n\n 0.235702260396 /* ( 0, 1) */,\n\n 0.666666666667 /* ( 0, 2) */,\n\n 0.000000000000 /* ( 1, 0) */,\n\n 0.942809041582 /* ( 1, 1) */,\n\n -0.333333333333 /* ( 1, 2) */,\n\n 0.816496580928 /* ( 2, 0) */,\n\n 0.000000000000 /* ( 2, 1) */,\n\n 0.000000000000 /* ( 2, 2) */,\n\n 0.408248290464 /* ( 3, 0) */,\n\n -0.235702260396 /* ( 3, 1) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_gramschmidt.c", "rank": 55, "score": 70313.10628980622 }, { "content": "float complex matrixcf_data_transmul_xTx[] = {\n\n 9.323024431917 + 0.000000000000*_Complex_I /* ( 0, 0) */,\n\n 0.563876592623 + 2.570030362211*_Complex_I /* ( 0, 1) */,\n\n 3.226123027525 + 2.636644463529*_Complex_I /* ( 0, 2) */,\n\n 1.129305368076 + -4.064920271606*_Complex_I /* ( 0, 3) */,\n\n 0.563876592623 + -2.570030362211*_Complex_I /* ( 1, 0) */,\n\n 9.108918860377 + 0.000000000000*_Complex_I /* ( 1, 1) */,\n\n 5.467585123601 + 2.017612849734*_Complex_I /* ( 1, 2) */,\n\n 0.956522192172 + 0.211168853425*_Complex_I /* ( 1, 3) */,\n\n 3.226123027525 + -2.636644463529*_Complex_I /* ( 2, 0) */,\n\n 5.467585123601 + -2.017612849734*_Complex_I /* ( 2, 1) */,\n\n 18.177787287820 + 0.000000000000*_Complex_I /* ( 2, 2) */,\n\n -3.137608134941 + -7.366300567700*_Complex_I /* ( 2, 3) */,\n\n 1.129305368076 + 4.064920271606*_Complex_I /* ( 3, 0) */,\n\n 0.956522192172 + -0.211168853425*_Complex_I /* ( 3, 1) */,\n\n -3.137608134941 + 7.366300567700*_Complex_I /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_transmul.c", "rank": 56, "score": 70313.10628980622 }, { "content": "float matrixf_data_qrdecomp_R[] = {\n\n 7.937253933194 /* ( 0, 0) */,\n\n 6.425396041157 /* ( 0, 1) */,\n\n 11.212946032607 /* ( 0, 2) */,\n\n 10.960969717268 /* ( 0, 3) */,\n\n 0.000000000000 /* ( 1, 0) */,\n\n 1.927248223319 /* ( 1, 1) */,\n\n 0.494166211107 /* ( 1, 2) */,\n\n 2.890872334978 /* ( 1, 3) */,\n\n 0.000000000000 /* ( 2, 0) */,\n\n 0.000000000000 /* ( 2, 1) */,\n\n 2.241794153271 /* ( 2, 2) */,\n\n 1.189523428266 /* ( 2, 3) */,\n\n 0.000000000000 /* ( 3, 0) */,\n\n 0.000000000000 /* ( 3, 1) */,\n\n 0.000000000000 /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_qrdecomp.c", "rank": 57, "score": 70313.10628980622 }, { "content": "float complex matrixcf_data_transmul_xHx[] = {\n\n -1.137085237839 + -2.939337742229*_Complex_I /* ( 0, 0) */,\n\n -1.429264118470 + -4.526184217761*_Complex_I /* ( 0, 1) */,\n\n -1.049795781222 + -9.317515018345*_Complex_I /* ( 0, 2) */,\n\n -6.923890470327 + 1.308742276041*_Complex_I /* ( 0, 3) */,\n\n -1.429264118470 + -4.526184217761*_Complex_I /* ( 1, 0) */,\n\n 3.863557186128 + -2.360596346275*_Complex_I /* ( 1, 1) */,\n\n 6.914587648894 + -0.110888488534*_Complex_I /* ( 1, 2) */,\n\n -1.585896210450 + 0.361787209777*_Complex_I /* ( 1, 3) */,\n\n -1.049795781222 + -9.317515018345*_Complex_I /* ( 2, 0) */,\n\n 6.914587648894 + -0.110888488534*_Complex_I /* ( 2, 1) */,\n\n 1.672484488523 + 2.446622681596*_Complex_I /* ( 2, 2) */,\n\n -2.591648390404 + -1.678750072577*_Complex_I /* ( 2, 3) */,\n\n -6.923890470327 + 1.308742276041*_Complex_I /* ( 3, 0) */,\n\n -1.585896210450 + 0.361787209777*_Complex_I /* ( 3, 1) */,\n\n -2.591648390404 + -1.678750072577*_Complex_I /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_transmul.c", "rank": 58, "score": 70313.10628980622 }, { "content": "float complex matrixcf_data_chol_L[] = {\n\n 1.010000000000 + 0.000000000000*_Complex_I /* ( 0, 0) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 0, 1) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 0, 2) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 0, 3) */,\n\n -1.420000000000 + 0.250000000000*_Complex_I /* ( 1, 0) */,\n\n 0.500000000000 + 0.000000000000*_Complex_I /* ( 1, 1) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 1, 2) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 1, 3) */,\n\n 0.320000000000 + -1.230000000000*_Complex_I /* ( 2, 0) */,\n\n 2.010000000000 + 0.780000000000*_Complex_I /* ( 2, 1) */,\n\n 0.300000000000 + 0.000000000000*_Complex_I /* ( 2, 2) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 2, 3) */,\n\n -1.020000000000 + 1.020000000000*_Complex_I /* ( 3, 0) */,\n\n -0.320000000000 + -0.030000000000*_Complex_I /* ( 3, 1) */,\n\n -1.650000000000 + 2.010000000000*_Complex_I /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_chol.c", "rank": 59, "score": 70313.10628980622 }, { "content": "float matrixf_data_transmul_xTx[] = {\n\n 2.846505957177 /* ( 0, 0) */,\n\n 3.736623075087 /* ( 0, 1) */,\n\n 1.396626890644 /* ( 0, 2) */,\n\n 0.874893716720 /* ( 0, 3) */,\n\n 3.736623075087 /* ( 1, 0) */,\n\n 7.455061797501 /* ( 1, 1) */,\n\n -0.844681524592 /* ( 1, 2) */,\n\n 1.908127088099 /* ( 1, 3) */,\n\n 1.396626890644 /* ( 2, 0) */,\n\n -0.844681524592 /* ( 2, 1) */,\n\n 6.701985390860 /* ( 2, 2) */,\n\n 1.819632522483 /* ( 2, 3) */,\n\n 0.874893716720 /* ( 3, 0) */,\n\n 1.908127088099 /* ( 3, 1) */,\n\n 1.819632522483 /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_transmul.c", "rank": 60, "score": 70313.10628980622 }, { "content": "float complex matrixcf_data_qrdecomp_Q[] = {\n\n 0.491706158979 + -0.133982845866*_Complex_I /* ( 0, 0) */,\n\n 0.429660711419 + 0.559833033911*_Complex_I /* ( 0, 1) */,\n\n -0.309333641162 + -0.278321211351*_Complex_I /* ( 0, 2) */,\n\n 0.215207397547 + -0.150957196713*_Complex_I /* ( 0, 3) */,\n\n 0.001986343837 + 0.375930689639*_Complex_I /* ( 1, 0) */,\n\n 0.242768204454 + 0.009257007128*_Complex_I /* ( 1, 1) */,\n\n -0.422306122793 + -0.032511505165*_Complex_I /* ( 1, 2) */,\n\n -0.503566009661 + 0.605534385769*_Complex_I /* ( 1, 3) */,\n\n -0.692896739226 + -0.303263998601*_Complex_I /* ( 2, 0) */,\n\n 0.054111560749 + 0.468071856237*_Complex_I /* ( 2, 1) */,\n\n -0.082147488614 + 0.069653107384*_Complex_I /* ( 2, 2) */,\n\n 0.279669645547 + 0.340721083028*_Complex_I /* ( 2, 3) */,\n\n 0.067382179098 + 0.149433995875*_Complex_I /* ( 3, 0) */,\n\n -0.270466351267 + 0.384428384950*_Complex_I /* ( 3, 1) */,\n\n -0.285071449427 + 0.744704670261*_Complex_I /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_qrdecomp.c", "rank": 61, "score": 70313.10628980622 }, { "content": "float matrixf_data_chol_L[] = {\n\n 1.010000000000 /* ( 0, 0) */,\n\n 0.000000000000 /* ( 0, 1) */,\n\n 0.000000000000 /* ( 0, 2) */,\n\n 0.000000000000 /* ( 0, 3) */,\n\n -1.420000000000 /* ( 1, 0) */,\n\n 0.500000000000 /* ( 1, 1) */,\n\n 0.000000000000 /* ( 1, 2) */,\n\n 0.000000000000 /* ( 1, 3) */,\n\n 0.320000000000 /* ( 2, 0) */,\n\n 2.010000000000 /* ( 2, 1) */,\n\n 0.300000000000 /* ( 2, 2) */,\n\n 0.000000000000 /* ( 2, 3) */,\n\n -1.020000000000 /* ( 3, 0) */,\n\n -0.320000000000 /* ( 3, 1) */,\n\n -1.650000000000 /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_chol.c", "rank": 62, "score": 70313.10628980622 }, { "content": "float matrixf_data_qrdecomp_Q[] = {\n\n 0.125988157670 /* ( 0, 0) */,\n\n 0.617707763884 /* ( 0, 1) */,\n\n 0.571886263590 /* ( 0, 2) */,\n\n 0.524890659168 /* ( 0, 3) */,\n\n 0.629940788349 /* ( 1, 0) */,\n\n 0.494166211107 /* ( 1, 1) */,\n\n -0.137252703262 /* ( 1, 2) */,\n\n -0.583211843520 /* ( 1, 3) */,\n\n 0.755928946018 /* ( 2, 0) */,\n\n -0.444749589997 /* ( 2, 1) */,\n\n -0.114377252718 /* ( 2, 2) */,\n\n 0.466569474816 /* ( 2, 3) */,\n\n 0.125988157670 /* ( 3, 0) */,\n\n -0.420041279441 /* ( 3, 1) */,\n\n 0.800640769025 /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_qrdecomp.c", "rank": 63, "score": 70313.10628980622 }, { "content": "float matrixf_data_transmul_xHx[] = {\n\n 2.846505957177 /* ( 0, 0) */,\n\n 3.736623075087 /* ( 0, 1) */,\n\n 1.396626890644 /* ( 0, 2) */,\n\n 0.874893716720 /* ( 0, 3) */,\n\n 3.736623075087 /* ( 1, 0) */,\n\n 7.455061797501 /* ( 1, 1) */,\n\n -0.844681524592 /* ( 1, 2) */,\n\n 1.908127088099 /* ( 1, 3) */,\n\n 1.396626890644 /* ( 2, 0) */,\n\n -0.844681524592 /* ( 2, 1) */,\n\n 6.701985390860 /* ( 2, 2) */,\n\n 1.819632522483 /* ( 2, 3) */,\n\n 0.874893716720 /* ( 3, 0) */,\n\n 1.908127088099 /* ( 3, 1) */,\n\n 1.819632522483 /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_transmul.c", "rank": 64, "score": 70313.10628980622 }, { "content": "float complex matrixcf_data_qrdecomp_R[] = {\n\n 4.299356356224 + 0.000000000000*_Complex_I /* ( 0, 0) */,\n\n -0.922616273377 + -0.789487259898*_Complex_I /* ( 0, 1) */,\n\n -1.025768821795 + -1.040664085433*_Complex_I /* ( 0, 2) */,\n\n 0.541217397816 + -0.002345615451*_Complex_I /* ( 0, 3) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 1, 0) */,\n\n 2.273733268802 + 0.000000000000*_Complex_I /* ( 1, 1) */,\n\n -2.939502710322 + -2.626579524510*_Complex_I /* ( 1, 2) */,\n\n -1.154743344912 + 0.323209860623*_Complex_I /* ( 1, 3) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 2, 0) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 2, 1) */,\n\n 1.701364174878 + 0.000000000000*_Complex_I /* ( 2, 2) */,\n\n 0.689923063328 + -0.348316412767*_Complex_I /* ( 2, 3) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 3, 0) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 3, 1) */,\n\n 0.000000000000 + 0.000000000000*_Complex_I /* ( 3, 2) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_qrdecomp.c", "rank": 65, "score": 70313.10628980622 }, { "content": "float matrixf_data_transmul_xxH[] = {\n\n 7.082042816423 /* ( 0, 0) */,\n\n 0.271085233449 /* ( 0, 1) */,\n\n -1.406346640934 /* ( 0, 2) */,\n\n 4.239537802168 /* ( 0, 3) */,\n\n -0.910304016309 /* ( 0, 4) */,\n\n 0.271085233449 /* ( 1, 0) */,\n\n 5.138873363454 /* ( 1, 1) */,\n\n 0.529971336750 /* ( 1, 2) */,\n\n 1.407977702482 /* ( 1, 3) */,\n\n 3.249602173055 /* ( 1, 4) */,\n\n -1.406346640934 /* ( 2, 0) */,\n\n 0.529971336750 /* ( 2, 1) */,\n\n 2.123159022134 /* ( 2, 2) */,\n\n -0.864407986864 /* ( 2, 3) */,\n\n 0.126735142361 /* ( 2, 4) */,\n\n 4.239537802168 /* ( 3, 0) */,\n\n 1.407977702482 /* ( 3, 1) */,\n\n -0.864407986864 /* ( 3, 2) */,\n\n 2.858801800305 /* ( 3, 3) */,\n\n 0.316326313589 /* ( 3, 4) */,\n\n -0.910304016309 /* ( 4, 0) */,\n\n 3.249602173055 /* ( 4, 1) */,\n\n 0.126735142361 /* ( 4, 2) */,\n\n 0.316326313589 /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_transmul.c", "rank": 66, "score": 69829.48446176633 }, { "content": "float complex matrixcf_data_transmul_xxT[] = {\n\n 13.946043026996 + 0.000000000000*_Complex_I /* ( 0, 0) */,\n\n 1.715635857916 + 6.831514803023*_Complex_I /* ( 0, 1) */,\n\n -0.628286275869 + 0.653261344190*_Complex_I /* ( 0, 2) */,\n\n 7.410888277177 + 5.014956782605*_Complex_I /* ( 0, 3) */,\n\n 4.776506544166 + -0.740548606324*_Complex_I /* ( 0, 4) */,\n\n 1.715635857916 + -6.831514803023*_Complex_I /* ( 1, 0) */,\n\n 12.934634198959 + 0.000000000000*_Complex_I /* ( 1, 1) */,\n\n -0.268847669275 + 1.016808442009*_Complex_I /* ( 1, 2) */,\n\n 1.329226044140 + -1.905118394989*_Complex_I /* ( 1, 3) */,\n\n -0.115507997317 + -1.823416830395*_Complex_I /* ( 1, 4) */,\n\n -0.628286275869 + -0.653261344190*_Complex_I /* ( 2, 0) */,\n\n -0.268847669275 + -1.016808442009*_Complex_I /* ( 2, 1) */,\n\n 2.833715966403 + 0.000000000000*_Complex_I /* ( 2, 2) */,\n\n 0.483955462699 + 2.897799335427*_Complex_I /* ( 2, 3) */,\n\n -0.036118440085 + -1.523720724413*_Complex_I /* ( 2, 4) */,\n\n 7.410888277177 + -5.014956782605*_Complex_I /* ( 3, 0) */,\n\n 1.329226044140 + 1.905118394989*_Complex_I /* ( 3, 1) */,\n\n 0.483955462699 + -2.897799335427*_Complex_I /* ( 3, 2) */,\n\n 12.063002732969 + 0.000000000000*_Complex_I /* ( 3, 3) */,\n\n 0.988561701830 + -0.460512464248*_Complex_I /* ( 3, 4) */,\n\n 4.776506544166 + 0.740548606324*_Complex_I /* ( 4, 0) */,\n\n -0.115507997317 + 1.823416830395*_Complex_I /* ( 4, 1) */,\n\n -0.036118440085 + 1.523720724413*_Complex_I /* ( 4, 2) */,\n\n 0.988561701830 + 0.460512464248*_Complex_I /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_transmul.c", "rank": 67, "score": 69829.48446176633 }, { "content": "float matrixf_data_transmul_xxT[] = {\n\n 7.082042816423 /* ( 0, 0) */,\n\n 0.271085233449 /* ( 0, 1) */,\n\n -1.406346640934 /* ( 0, 2) */,\n\n 4.239537802168 /* ( 0, 3) */,\n\n -0.910304016309 /* ( 0, 4) */,\n\n 0.271085233449 /* ( 1, 0) */,\n\n 5.138873363454 /* ( 1, 1) */,\n\n 0.529971336750 /* ( 1, 2) */,\n\n 1.407977702482 /* ( 1, 3) */,\n\n 3.249602173055 /* ( 1, 4) */,\n\n -1.406346640934 /* ( 2, 0) */,\n\n 0.529971336750 /* ( 2, 1) */,\n\n 2.123159022134 /* ( 2, 2) */,\n\n -0.864407986864 /* ( 2, 3) */,\n\n 0.126735142361 /* ( 2, 4) */,\n\n 4.239537802168 /* ( 3, 0) */,\n\n 1.407977702482 /* ( 3, 1) */,\n\n -0.864407986864 /* ( 3, 2) */,\n\n 2.858801800305 /* ( 3, 3) */,\n\n 0.316326313589 /* ( 3, 4) */,\n\n -0.910304016309 /* ( 4, 0) */,\n\n 3.249602173055 /* ( 4, 1) */,\n\n 0.126735142361 /* ( 4, 2) */,\n\n 0.316326313589 /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixf_data_transmul.c", "rank": 68, "score": 69829.48446176633 }, { "content": "float complex matrixcf_data_transmul_xxH[] = {\n\n 2.693069394806 + 5.019630491560*_Complex_I /* ( 0, 0) */,\n\n 1.208446246635 + -4.757020341403*_Complex_I /* ( 0, 1) */,\n\n 2.656451825557 + 2.224444954914*_Complex_I /* ( 0, 2) */,\n\n 5.911512147844 + -2.959566260460*_Complex_I /* ( 0, 3) */,\n\n -4.483236639053 + 3.806796594938*_Complex_I /* ( 0, 4) */,\n\n 1.208446246635 + -4.757020341403*_Complex_I /* ( 1, 0) */,\n\n -3.086513006704 + 0.932888319797*_Complex_I /* ( 1, 1) */,\n\n -0.210317709361 + -2.269045302266*_Complex_I /* ( 1, 2) */,\n\n -5.412513485879 + -6.508039464439*_Complex_I /* ( 1, 3) */,\n\n -2.749055759920 + 0.459776624619*_Complex_I /* ( 1, 4) */,\n\n 2.656451825557 + 2.224444954914*_Complex_I /* ( 2, 0) */,\n\n -0.210317709361 + -2.269045302266*_Complex_I /* ( 2, 1) */,\n\n -1.885163224141 + -0.592788922020*_Complex_I /* ( 2, 2) */,\n\n 1.153042421508 + 3.232018360881*_Complex_I /* ( 2, 3) */,\n\n 1.287247559495 + 0.601010412549*_Complex_I /* ( 2, 4) */,\n\n 5.911512147844 + -2.959566260460*_Complex_I /* ( 3, 0) */,\n\n -5.412513485879 + -6.508039464439*_Complex_I /* ( 3, 1) */,\n\n 1.153042421508 + 3.232018360881*_Complex_I /* ( 3, 2) */,\n\n 5.142853158215 + -4.354648092153*_Complex_I /* ( 3, 3) */,\n\n -0.034391537899 + 2.674865932467*_Complex_I /* ( 3, 4) */,\n\n -4.483236639053 + 3.806796594938*_Complex_I /* ( 4, 0) */,\n\n -2.749055759920 + 0.459776624619*_Complex_I /* ( 4, 1) */,\n\n 1.287247559495 + 0.601010412549*_Complex_I /* ( 4, 2) */,\n\n -0.034391537899 + 2.674865932467*_Complex_I /* ( 4, 3) */,\n", "file_path": "liquid-dsp/src/src/matrix/tests/data/matrixcf_data_transmul.c", "rank": 69, "score": 69829.48446176633 }, { "content": "float firdecim_rrrf_data_M5h23x50_y[] = {\n\n 0.003585644662,\n\n -0.019185323038,\n\n 0.023723637517,\n\n -0.016266117610,\n\n -0.039970055370,\n\n -0.037092249176,\n\n 0.027140256398,\n\n 0.025837751181,\n\n 0.028127341349,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M5h23x50.c", "rank": 70, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M2h4x20_y[] = {\n\n 0.006958702881,\n\n -0.000245283250,\n\n -0.009438359685,\n\n -0.024511329437,\n\n -0.025867150062,\n\n -0.004886703086,\n\n -0.011931393613,\n\n -0.007143968697,\n\n 0.022109694637,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M2h4x20.c", "rank": 71, "score": 69824.97026457841 }, { "content": "float complex firfilt_crcf_data_h13x32_x[] = {\n\n -0.150478051517 + 0.011369787230*_Complex_I,\n\n -0.011682362019 + -0.131898855698*_Complex_I,\n\n 0.002241423344 + 0.056583759593*_Complex_I,\n\n -0.059449335305 + 0.187622651747*_Complex_I,\n\n -0.180436000741 + 0.005303426369*_Complex_I,\n\n 0.011260126047 + 0.058406411239*_Complex_I,\n\n 0.104607282644 + 0.079267822272*_Complex_I,\n\n 0.085374933204 + 0.051946754389*_Complex_I,\n\n -0.022910313299 + 0.030414137098*_Complex_I,\n\n 0.088237668857 + -0.149226301695*_Complex_I,\n\n -0.077336181799 + 0.011213633150*_Complex_I,\n\n -0.041671694767 + -0.010591371244*_Complex_I,\n\n -0.072827057153 + 0.029626684791*_Complex_I,\n\n -0.031258311706 + -0.032641520688*_Complex_I,\n\n -0.008154356734 + 0.089595819254*_Complex_I,\n\n 0.008874945980 + 0.055052307581*_Complex_I,\n\n 0.021540988384 + 0.002343360972*_Complex_I,\n\n 0.031406241630 + -0.041565525378*_Complex_I,\n\n -0.186621079183 + -0.055706611874*_Complex_I,\n\n -0.204887932486 + 0.107546397697*_Complex_I,\n\n -0.001299342939 + -0.091725815207*_Complex_I,\n\n 0.098883395599 + -0.042781095000*_Complex_I,\n\n -0.148848628287 + 0.075959712533*_Complex_I,\n\n 0.168232372928 + 0.044377154144*_Complex_I,\n\n 0.162761143249 + -0.111406681457*_Complex_I,\n\n -0.069728838323 + 0.030195226651*_Complex_I,\n\n -0.015037533839 + 0.032270195219*_Complex_I,\n\n 0.047319395233 + -0.049920188058*_Complex_I,\n\n -0.275633692987 + -0.077201329969*_Complex_I,\n\n 0.260550021883 + -0.026872750426*_Complex_I,\n\n 0.154250187563 + -0.051859524539*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_crcf_data_h13x32.c", "rank": 72, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h4x8_x[] = {\n\n 0.035529355081 + -0.025645176804*_Complex_I,\n\n 0.010053327033 + 0.058182925297*_Complex_I,\n\n -0.051911580279 + -0.038455783791*_Complex_I,\n\n 0.087876912441 + -0.008273223193*_Complex_I,\n\n -0.195891631367 + 0.043381908184*_Complex_I,\n\n -0.018068686759 + 0.096890714727*_Complex_I,\n\n 0.072440149482 + 0.119581756000*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h4x8.c", "rank": 73, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h7x16_h[] = {\n\n 0.059672454354 + -0.020066091352*_Complex_I,\n\n -0.074492656514 + -0.047414131969*_Complex_I,\n\n 0.035667494507 + -0.071294810193*_Complex_I,\n\n 0.039143057258 + 0.079656472813*_Complex_I,\n\n -0.014290705994 + -0.119186857470*_Complex_I,\n\n 0.072724115403 + 0.012655052298*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h7x16.c", "rank": 74, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h4x8_y[] = {\n\n -0.001451197592 + 0.000316688892*_Complex_I,\n\n -0.002378879142 + 0.003773758321*_Complex_I,\n\n 0.002248990658 + -0.012660658356*_Complex_I,\n\n 0.013625136077 + 0.016803422304*_Complex_I,\n\n -0.023574746940 + 0.002359815677*_Complex_I,\n\n 0.048100008285 + -0.032526172551*_Complex_I,\n\n -0.047049781567 + 0.010960128197*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h4x8.c", "rank": 75, "score": 69824.97026457841 }, { "content": "float complex firfilt_crcf_data_h13x32_y[] = {\n\n -0.000769529978 + 0.000058143975*_Complex_I,\n\n -0.000855209812 + -0.000614414049*_Complex_I,\n\n 0.017978713542 + -0.001770120683*_Complex_I,\n\n 0.001784905863 + 0.017010423559*_Complex_I,\n\n 0.008329226648 + -0.005905805446*_Complex_I,\n\n -0.000377533572 + -0.013277356194*_Complex_I,\n\n 0.019781654463 + -0.010739936790*_Complex_I,\n\n 0.004673510867 + -0.017536447645*_Complex_I,\n\n -0.018937503016 + 0.001766778181*_Complex_I,\n\n -0.009796095237 + -0.022965903194*_Complex_I,\n\n -0.011542534189 + 0.009647205778*_Complex_I,\n\n -0.026694559597 + 0.028680204257*_Complex_I,\n\n -0.004613286077 + -0.018608161470*_Complex_I,\n\n 0.011559988327 + 0.025425767569*_Complex_I,\n\n 0.015974924004 + 0.005946996608*_Complex_I,\n\n -0.007726490650 + 0.012377335870*_Complex_I,\n\n -0.007714581040 + -0.006039979551*_Complex_I,\n\n 0.018766419009 + -0.012572800123*_Complex_I,\n\n -0.012542031545 + 0.012437887461*_Complex_I,\n\n 0.000458385988 + 0.000571447349*_Complex_I,\n\n 0.016943660061 + 0.007409564688*_Complex_I,\n\n 0.024399758745 + -0.020976831445*_Complex_I,\n\n 0.007946403220 + 0.025133322345*_Complex_I,\n\n -0.012852674380 + -0.005689128468*_Complex_I,\n\n 0.003313037804 + 0.000263249514*_Complex_I,\n\n -0.027377402722 + -0.004127607511*_Complex_I,\n\n -0.026320368186 + 0.009134835527*_Complex_I,\n\n -0.012297987932 + 0.013200852928*_Complex_I,\n\n 0.007101262388 + -0.017149417134*_Complex_I,\n\n 0.000657385901 + 0.001192381502*_Complex_I,\n\n -0.008080139857 + 0.018480645475*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_crcf_data_h13x32.c", "rank": 76, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M4h13x40_x[] = {\n\n -0.006034368030,\n\n -0.171592529075,\n\n -0.063780807965,\n\n 0.013676314399,\n\n 0.116628260211,\n\n 0.119863895134,\n\n 0.111602959230,\n\n 0.130154286756,\n\n 0.038035316610,\n\n 0.059453633879,\n\n -0.109240225614,\n\n 0.077742393809,\n\n -0.021666946122,\n\n 0.067622802572,\n\n -0.058137116614,\n\n -0.069171140610,\n\n 0.067330056503,\n\n 0.087258333681,\n\n 0.042012179512,\n\n -0.025556605587,\n\n -0.111286144010,\n\n -0.040760608600,\n\n 0.127330790275,\n\n 0.033399307914,\n\n -0.005634951089,\n\n 0.043243872564,\n\n 0.038979737383,\n\n -0.045742865035,\n\n -0.193432344744,\n\n -0.020574800494,\n\n -0.065306698326,\n\n -0.101479446471,\n\n -0.016230721248,\n\n 0.000392179194,\n\n -0.065936759641,\n\n 0.032965659365,\n\n 0.057788436776,\n\n -0.268236198963,\n\n -0.077821704788,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M4h13x40.c", "rank": 77, "score": 69824.97026457841 }, { "content": "float firfilt_crcf_data_h13x32_h[] = {\n\n 0.005113901796,\n\n 0.005286268339,\n\n -0.119811540901,\n\n -0.004501609093,\n\n -0.065007372397,\n\n 0.048866593324,\n\n 0.013172470077,\n\n -0.002661385800,\n\n 0.103490232103,\n\n -0.080549511664,\n\n 0.044381828692,\n\n 0.059428974785,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_crcf_data_h13x32.c", "rank": 78, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h7x16_y[] = {\n\n -0.002918789759 + 0.006809782675*_Complex_I,\n\n 0.006276944689 + 0.007455059607*_Complex_I,\n\n 0.010434073117 + -0.001912734754*_Complex_I,\n\n -0.005702292584 + 0.016196656152*_Complex_I,\n\n -0.025081177186 + 0.012200218722*_Complex_I,\n\n 0.003335423652 + 0.014801280201*_Complex_I,\n\n 0.006724005065 + 0.002747460191*_Complex_I,\n\n 0.009525148495 + -0.023079851588*_Complex_I,\n\n -0.004054704111 + 0.027058137376*_Complex_I,\n\n 0.008922503980 + 0.020765026017*_Complex_I,\n\n 0.003379220673 + 0.021621450005*_Complex_I,\n\n 0.008092396331 + -0.009379092265*_Complex_I,\n\n 0.024410342880 + 0.008452609790*_Complex_I,\n\n 0.007947112966 + 0.022079470097*_Complex_I,\n\n -0.003430027671 + -0.018931432282*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h7x16.c", "rank": 79, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h23x64_y[] = {\n\n 0.000464112585 + 0.001562308262*_Complex_I,\n\n -0.021190870009 + -0.005937253959*_Complex_I,\n\n -0.025683625328 + 0.013143026224*_Complex_I,\n\n -0.015326079628 + 0.009211447989*_Complex_I,\n\n 0.006829901541 + 0.076012393531*_Complex_I,\n\n 0.021716854352 + -0.026318353103*_Complex_I,\n\n 0.061035502538 + 0.035739634892*_Complex_I,\n\n 0.020352690891 + -0.042409807844*_Complex_I,\n\n 0.023045428223 + -0.028106571621*_Complex_I,\n\n 0.010032616072 + -0.021662309111*_Complex_I,\n\n 0.022940764323 + 0.032595296512*_Complex_I,\n\n -0.051515604616 + 0.041000933031*_Complex_I,\n\n 0.005746042283 + -0.027665280631*_Complex_I,\n\n 0.029717785937 + 0.005867034288*_Complex_I,\n\n 0.009507729239 + -0.065470886864*_Complex_I,\n\n -0.055592736641 + -0.039847345306*_Complex_I,\n\n -0.019477634830 + -0.054757658494*_Complex_I,\n\n -0.001079490064 + 0.040551530555*_Complex_I,\n\n -0.023105026049 + -0.021489136993*_Complex_I,\n\n -0.013772576463 + -0.059289523063*_Complex_I,\n\n 0.010368064793 + -0.051492201632*_Complex_I,\n\n -0.052573934313 + 0.036913855369*_Complex_I,\n\n -0.029463371581 + 0.017335195435*_Complex_I,\n\n -0.002016229441 + 0.029445890489*_Complex_I,\n\n -0.064174313079 + -0.021020171587*_Complex_I,\n\n 0.046007178326 + -0.038216963612*_Complex_I,\n\n -0.047237084003 + -0.018439493080*_Complex_I,\n\n 0.077901945535 + 0.026803231226*_Complex_I,\n\n -0.160590610173 + -0.048895121067*_Complex_I,\n\n 0.033009384953 + 0.122366292068*_Complex_I,\n\n 0.047500812021 + 0.030446168988*_Complex_I,\n\n 0.027755264333 + 0.023740335853*_Complex_I,\n\n -0.029958186540 + -0.099197879754*_Complex_I,\n\n -0.093565182221 + 0.037118606810*_Complex_I,\n\n 0.037892348897 + 0.081665210582*_Complex_I,\n\n 0.017203419707 + -0.049660120581*_Complex_I,\n\n 0.123469958964 + 0.075552201157*_Complex_I,\n\n 0.075598725500 + -0.068066054148*_Complex_I,\n\n -0.019888756884 + 0.076027214270*_Complex_I,\n\n -0.016956893179 + 0.064628354823*_Complex_I,\n\n 0.054092135963 + 0.231143717249*_Complex_I,\n\n 0.107916203047 + -0.024623113347*_Complex_I,\n\n -0.067826976867 + -0.080607084998*_Complex_I,\n\n -0.084406829425 + 0.006461650420*_Complex_I,\n\n -0.097403134020 + 0.026083051061*_Complex_I,\n\n -0.174546809897 + 0.011876261770*_Complex_I,\n\n 0.073748943090 + -0.055147402729*_Complex_I,\n\n 0.097549181238 + -0.004423842043*_Complex_I,\n\n 0.077466051940 + -0.102440912522*_Complex_I,\n\n -0.159166842272 + -0.050231066222*_Complex_I,\n\n -0.169079556837 + 0.020999784115*_Complex_I,\n\n -0.011606027825 + 0.070186046595*_Complex_I,\n\n 0.059157126631 + -0.011799023310*_Complex_I,\n\n 0.026862671786 + -0.020855448914*_Complex_I,\n\n -0.068295073554 + 0.079282428595*_Complex_I,\n\n -0.048389220558 + -0.036671891516*_Complex_I,\n\n -0.104950395650 + -0.102233724778*_Complex_I,\n\n -0.028973062537 + -0.073361406548*_Complex_I,\n\n 0.093580906591 + -0.063967765018*_Complex_I,\n\n 0.024718362523 + -0.132740996962*_Complex_I,\n\n -0.024359580020 + -0.079781595584*_Complex_I,\n\n -0.073363097948 + -0.031874352056*_Complex_I,\n\n 0.007512286472 + -0.110602957303*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h23x64.c", "rank": 80, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M4h13x40_h[] = {\n\n -0.050178519704,\n\n 0.099634819705,\n\n 0.087767256514,\n\n 0.031474342328,\n\n -0.161835107291,\n\n 0.031896126939,\n\n -0.240761793751,\n\n -0.044460468897,\n\n 0.019656280155,\n\n 0.150308997913,\n\n -0.145260671043,\n\n 0.044691633752,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M4h13x40.c", "rank": 81, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h4x8_h[] = {\n\n -0.031084031859 + -0.013523088141*_Complex_I,\n\n -0.129175459526 + 0.067705781544*_Complex_I,\n\n 0.221460930668 + -0.057515301525*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h4x8.c", "rank": 82, "score": 69824.97026457841 }, { "content": "float complex firdecim_crcf_data_M5h23x50_y[] = {\n\n -0.000415418699 + -0.000241271190*_Complex_I,\n\n 0.009483904304 + 0.033419922261*_Complex_I,\n\n 0.053902979681 + 0.014937609575*_Complex_I,\n\n -0.004064163171 + -0.007100167361*_Complex_I,\n\n 0.027338357030 + 0.015054094814*_Complex_I,\n\n 0.032378938500 + 0.015062971531*_Complex_I,\n\n -0.072114751319 + -0.021601257083*_Complex_I,\n\n -0.000363929634 + -0.002841410024*_Complex_I,\n\n -0.028488318939 + -0.002263371809*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_crcf_data_M5h23x50.c", "rank": 83, "score": 69824.97026457841 }, { "content": "float firdecim_crcf_data_M5h23x50_h[] = {\n\n 0.002280218687,\n\n 0.030259168999,\n\n 0.042315352513,\n\n 0.023335125905,\n\n 0.187877503860,\n\n -0.125992843938,\n\n 0.011263591538,\n\n 0.085275043313,\n\n -0.000421564647,\n\n -0.061084018425,\n\n -0.061455696212,\n\n -0.019398732964,\n\n 0.054084065833,\n\n -0.139019814895,\n\n -0.006954271771,\n\n 0.066739670458,\n\n 0.060380686235,\n\n -0.030379569378,\n\n 0.062093917175,\n\n -0.108597003256,\n\n -0.026039280890,\n\n -0.061515114912,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_crcf_data_M5h23x50.c", "rank": 84, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M2h4x20_x[] = {\n\n 0.098311328839,\n\n -0.051405684088,\n\n -0.097846553674,\n\n 0.070744555579,\n\n -0.092569362020,\n\n 0.125743342560,\n\n -0.015936561579,\n\n 0.092440100110,\n\n -0.007046555447,\n\n -0.011409188742,\n\n 0.065796277764,\n\n 0.121624056526,\n\n 0.001291608019,\n\n -0.103251042400,\n\n -0.067174551288,\n\n -0.069262060525,\n\n 0.038107684731,\n\n -0.091432498375,\n\n 0.094339814736,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M2h4x20.c", "rank": 85, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h23x64_h[] = {\n\n 0.007386483162 + -0.009424072453*_Complex_I,\n\n 0.050423187035 + 0.150124405632*_Complex_I,\n\n 0.243542351374 + 0.080326589069*_Complex_I,\n\n -0.024338280301 + -0.114090910866*_Complex_I,\n\n 0.196460953569 + -0.124970764904*_Complex_I,\n\n -0.105561981596 + 0.041404720111*_Complex_I,\n\n -0.101639566392 + -0.046297689433*_Complex_I,\n\n -0.163657198362 + 0.005526168199*_Complex_I,\n\n -0.112922732770 + 0.063835893419*_Complex_I,\n\n 0.101174309677 + -0.014946487353*_Complex_I,\n\n 0.022730956655 + -0.120281555357*_Complex_I,\n\n 0.098219187560 + -0.193182817593*_Complex_I,\n\n -0.104212145985 + 0.050487269587*_Complex_I,\n\n -0.111765574417 + 0.198335922799*_Complex_I,\n\n -0.176342404298 + 0.020342954856*_Complex_I,\n\n -0.008161867550 + 0.131912314088*_Complex_I,\n\n 0.002095296558 + 0.017356532465*_Complex_I,\n\n -0.048192202598 + -0.033184854044*_Complex_I,\n\n -0.116973286896 + 0.160940600018*_Complex_I,\n\n -0.117776822786 + 0.154916853064*_Complex_I,\n\n -0.054689494037 + -0.147596255159*_Complex_I,\n\n -0.061473756719 + -0.101802249138*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h23x64.c", "rank": 86, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M5h23x50_x[] = {\n\n -0.053013073944,\n\n -0.096057779578,\n\n 0.089544324704,\n\n -0.000543553496,\n\n 0.162822533187,\n\n -0.074585191755,\n\n 0.104404924404,\n\n -0.029558379775,\n\n -0.007349400311,\n\n -0.194774278732,\n\n -0.170758029656,\n\n 0.045377876421,\n\n 0.080652365875,\n\n 0.072939196850,\n\n -0.089654082233,\n\n -0.103982998990,\n\n 0.163030711963,\n\n -0.024228077817,\n\n 0.131281994357,\n\n 0.016327074888,\n\n -0.055411828614,\n\n 0.043034256150,\n\n 0.018076404143,\n\n 0.097676360852,\n\n 0.137184094723,\n\n 0.082482387627,\n\n 0.056634950389,\n\n 0.027836125209,\n\n -0.014908882821,\n\n 0.162327107907,\n\n -0.153015761693,\n\n -0.020845168829,\n\n -0.001125342955,\n\n -0.044310410921,\n\n -0.053090705118,\n\n -0.024619825348,\n\n 0.039550843685,\n\n -0.206275854122,\n\n 0.034696692856,\n\n -0.153816675012,\n\n -0.028473257841,\n\n 0.054242064784,\n\n 0.197473069156,\n\n 0.002233912029,\n\n 0.021458220407,\n\n 0.122982229244,\n\n 0.127458372904,\n\n -0.040153514587,\n\n -0.055390576800,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M5h23x50.c", "rank": 87, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h13x32_h[] = {\n\n -0.016900612660 + -0.094711890552*_Complex_I,\n\n 0.021604417271 + 0.142776429157*_Complex_I,\n\n -0.115236149764 + -0.169153952067*_Complex_I,\n\n -0.104650665737 + -0.070706448696*_Complex_I,\n\n -0.324134992109 + 0.000276600538*_Complex_I,\n\n 0.084579923351 + 0.050862911890*_Complex_I,\n\n 0.037182962083 + -0.060208798591*_Complex_I,\n\n -0.025070759196 + -0.102300651911*_Complex_I,\n\n -0.172106098520 + 0.036477087826*_Complex_I,\n\n -0.104230620945 + -0.026070285900*_Complex_I,\n\n -0.098231380216 + 0.164187739422*_Complex_I,\n\n 0.073260028098 + 0.102435049392*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h13x32.c", "rank": 88, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M4h13x40_y[] = {\n\n 0.000302795655,\n\n -0.014511652270,\n\n 0.029055193091,\n\n -0.025764218622,\n\n -0.000775391175,\n\n 0.028459415706,\n\n 0.024044484393,\n\n -0.040542156850,\n\n 0.012864586577,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M4h13x40.c", "rank": 89, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h23x64_x[] = {\n\n -0.078781393877 + 0.110995541416*_Complex_I,\n\n -0.047869391092 + -0.021406341819*_Complex_I,\n\n 0.037075730398 + 0.142733143372*_Complex_I,\n\n 0.030132814646 + -0.067132734894*_Complex_I,\n\n 0.061282796666 + 0.010485822100*_Complex_I,\n\n 0.102675878253 + -0.033081022766*_Complex_I,\n\n 0.033541370777 + 0.079278562425*_Complex_I,\n\n -0.054593695346 + -0.027854211664*_Complex_I,\n\n 0.145123800751 + -0.056723330167*_Complex_I,\n\n 0.011046150157 + 0.040345229995*_Complex_I,\n\n -0.035136035623 + 0.087660836105*_Complex_I,\n\n 0.016994675402 + 0.012775882535*_Complex_I,\n\n 0.044321746934 + -0.049948987747*_Complex_I,\n\n -0.028623515736 + 0.009984465451*_Complex_I,\n\n -0.047556759717 + 0.018286483908*_Complex_I,\n\n -0.006226807241 + 0.024241509652*_Complex_I,\n\n 0.064579293390 + -0.055779520425*_Complex_I,\n\n 0.006724710050 + -0.045321225291*_Complex_I,\n\n -0.014197864403 + -0.074364241862*_Complex_I,\n\n -0.189692736681 + 0.036236471869*_Complex_I,\n\n -0.043006387932 + 0.015254723104*_Complex_I,\n\n 0.183456865086 + -0.046633999430*_Complex_I,\n\n -0.096745178650 + -0.157866894203*_Complex_I,\n\n 0.049851534577 + -0.011841563370*_Complex_I,\n\n -0.128605225270 + -0.121500740667*_Complex_I,\n\n 0.208521246393 + 0.074928493344*_Complex_I,\n\n 0.015993704716 + -0.142778722944*_Complex_I,\n\n 0.099274527811 + 0.252094407113*_Complex_I,\n\n 0.095595074594 + -0.110420978049*_Complex_I,\n\n -0.160033363989 + 0.021797330986*_Complex_I,\n\n -0.033832678704 + 0.074483735094*_Complex_I,\n\n 0.063099121768 + 0.029430379768*_Complex_I,\n\n 0.073790479995 + 0.116859113625*_Complex_I,\n\n 0.029697732194 + -0.064419571602*_Complex_I,\n\n -0.121376933005 + -0.068190026772*_Complex_I,\n\n 0.157696201880 + 0.013694270490*_Complex_I,\n\n 0.192086239328 + 0.177711736014*_Complex_I,\n\n 0.050443921971 + 0.194189638728*_Complex_I,\n\n 0.104425685379 + 0.145809752108*_Complex_I,\n\n 0.052724394018 + -0.077432998652*_Complex_I,\n\n -0.138821609433 + 0.064732623753*_Complex_I,\n\n -0.091470669189 + 0.063059053083*_Complex_I,\n\n 0.126212251998 + 0.047314249385*_Complex_I,\n\n -0.096047066646 + 0.177236809567*_Complex_I,\n\n 0.052301840404 + -0.008778675600*_Complex_I,\n\n -0.121968378742 + -0.054938313986*_Complex_I,\n\n -0.052829966951 + -0.030310428105*_Complex_I,\n\n 0.018028043678 + -0.025287719529*_Complex_I,\n\n -0.027374857808 + 0.073286356627*_Complex_I,\n\n 0.097021248414 + 0.117164045551*_Complex_I,\n\n 0.041807049929 + -0.087406811774*_Complex_I,\n\n -0.016480216738 + 0.009889058359*_Complex_I,\n\n 0.025179492882 + 0.203064743411*_Complex_I,\n\n 0.157077633956 + -0.037868143998*_Complex_I,\n\n 0.186492422521 + 0.007792322512*_Complex_I,\n\n -0.058684153831 + 0.005148456049*_Complex_I,\n\n 0.043091823396 + 0.043031309641*_Complex_I,\n\n 0.070177096613 + -0.053637529243*_Complex_I,\n\n -0.026547396369 + -0.080476576072*_Complex_I,\n\n -0.001571308583 + -0.035758437403*_Complex_I,\n\n -0.015191595806 + -0.121248560074*_Complex_I,\n\n -0.150343511708 + -0.218457418741*_Complex_I,\n\n 0.214202412315 + -0.062090364159*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h23x64.c", "rank": 90, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M3h7x30_h[] = {\n\n -0.074705344704,\n\n 0.020538592337,\n\n -0.020061495576,\n\n 0.096703320953,\n\n 0.100160540368,\n\n 0.097166994081,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M3h7x30.c", "rank": 91, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h13x32_y[] = {\n\n -0.004147435830 + 0.023256012109*_Complex_I,\n\n -0.002015434559 + -0.044482089545*_Complex_I,\n\n 0.030942859967 + 0.066454518780*_Complex_I,\n\n -0.026911288885 + 0.010771317579*_Complex_I,\n\n 0.095968947613 + 0.038484837745*_Complex_I,\n\n -0.092014317271 + -0.013169924277*_Complex_I,\n\n 0.049198135608 + 0.035484075721*_Complex_I,\n\n -0.025796455461 + 0.044082591823*_Complex_I,\n\n 0.078672781715 + -0.025486364457*_Complex_I,\n\n -0.072129355236 + 0.058152098733*_Complex_I,\n\n 0.060708464475 + -0.020499489129*_Complex_I,\n\n -0.012897457718 + 0.010369404477*_Complex_I,\n\n 0.040569721031 + -0.076402320248*_Complex_I,\n\n -0.061438066081 + 0.022914256728*_Complex_I,\n\n 0.010560216826 + 0.008397165450*_Complex_I,\n\n -0.007466249710 + 0.045405657448*_Complex_I,\n\n 0.045052264644 + -0.014977016558*_Complex_I,\n\n -0.103883227654 + 0.025733650083*_Complex_I,\n\n -0.020931229354 + 0.011790200727*_Complex_I,\n\n -0.082554523156 + 0.082257052415*_Complex_I,\n\n 0.062290900829 + 0.006126149167*_Complex_I,\n\n -0.001939383449 + 0.054104380393*_Complex_I,\n\n -0.080894136635 + -0.026061525625*_Complex_I,\n\n -0.014425095108 + 0.144945090491*_Complex_I,\n\n 0.027136649299 + 0.013953073572*_Complex_I,\n\n -0.004380661218 + -0.036741472069*_Complex_I,\n\n -0.088435984052 + -0.001543185349*_Complex_I,\n\n 0.051743211037 + -0.012397485596*_Complex_I,\n\n -0.019549545189 + 0.010425517862*_Complex_I,\n\n -0.009114204900 + 0.008932656001*_Complex_I,\n\n -0.003773949758 + 0.033245440352*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h13x32.c", "rank": 92, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M3h7x30_y[] = {\n\n 0.005759004645,\n\n -0.007768614835,\n\n 0.013680669269,\n\n 0.019197170461,\n\n 0.020943849985,\n\n -0.009738613503,\n\n 0.013465672357,\n\n -0.028391740957,\n\n -0.041353046024,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M3h7x30.c", "rank": 93, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M2h4x20_h[] = {\n\n 0.070782309250,\n\n -0.114245586699,\n\n 0.008215220382,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M2h4x20.c", "rank": 94, "score": 69824.97026457841 }, { "content": "float complex firdecim_crcf_data_M5h23x50_x[] = {\n\n -0.182183709645 + -0.105810548671*_Complex_I,\n\n -0.119835664561 + 0.052187599214*_Complex_I,\n\n -0.080413311444 + -0.007654126449*_Complex_I,\n\n 0.097423911392 + 0.139994199967*_Complex_I,\n\n 0.227363312459 + 0.148762801146*_Complex_I,\n\n -0.035703226649 + 0.016200983468*_Complex_I,\n\n 0.112245547440 + -0.012233367286*_Complex_I,\n\n 0.048367738935 + -0.084918284786*_Complex_I,\n\n 0.014605478600 + -0.020568647750*_Complex_I,\n\n -0.097889245398 + 0.168068267634*_Complex_I,\n\n 0.049395920002 + 0.049056756925*_Complex_I,\n\n 0.077571659414 + -0.016603490981*_Complex_I,\n\n -0.184216448023 + 0.038356590636*_Complex_I,\n\n -0.001919304196 + 0.044652884985*_Complex_I,\n\n -0.137958101403 + 0.039437297572*_Complex_I,\n\n -0.014249713446 + -0.012873748415*_Complex_I,\n\n 0.080615138558 + 0.010722054400*_Complex_I,\n\n 0.163287071747 + 0.157849778887*_Complex_I,\n\n 0.014760203683 + 0.017904920717*_Complex_I,\n\n -0.023896962586 + -0.167898683088*_Complex_I,\n\n -0.103145190697 + -0.052205104745*_Complex_I,\n\n 0.060639622041 + 0.000262344853*_Complex_I,\n\n -0.103152379379 + 0.094308639066*_Complex_I,\n\n 0.087724817642 + 0.138912843443*_Complex_I,\n\n 0.118286611822 + -0.059245080063*_Complex_I,\n\n 0.072397607400 + 0.055570352604*_Complex_I,\n\n -0.120828136006 + -0.053193491502*_Complex_I,\n\n 0.017568748356 + 0.062747031152*_Complex_I,\n\n -0.173562312809 + 0.024099395003*_Complex_I,\n\n 0.029150371763 + 0.142074561483*_Complex_I,\n\n 0.025859464873 + 0.055295550529*_Complex_I,\n\n 0.033521057962 + 0.015990392806*_Complex_I,\n\n -0.153314777647 + 0.029921210372*_Complex_I,\n\n -0.083426782876 + 0.085727794977*_Complex_I,\n\n -0.082913880724 + 0.118554053112*_Complex_I,\n\n -0.000295266978 + 0.046816730776*_Complex_I,\n\n -0.091635622603 + -0.074886539618*_Complex_I,\n\n 0.187307078036 + 0.079033670911*_Complex_I,\n\n 0.016483267210 + 0.214994027303*_Complex_I,\n\n 0.182841584926 + -0.060579741754*_Complex_I,\n\n 0.098946994244 + 0.014088074701*_Complex_I,\n\n 0.103226498009 + -0.107310190377*_Complex_I,\n\n -0.102346312686 + -0.043967864658*_Complex_I,\n\n 0.003356469485 + 0.080001448898*_Complex_I,\n\n 0.015380876414 + -0.033386312073*_Complex_I,\n\n 0.113435756454 + 0.076011600452*_Complex_I,\n\n 0.222681717597 + -0.048179807062*_Complex_I,\n\n 0.213685265876 + 0.154819154890*_Complex_I,\n\n -0.145263809029 + 0.080441672618*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_crcf_data_M5h23x50.c", "rank": 95, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h7x16_x[] = {\n\n -0.078420841238 + 0.087748743839*_Complex_I,\n\n -0.108100101013 + 0.135812982907*_Complex_I,\n\n -0.084609799993 + -0.122999836505*_Complex_I,\n\n 0.004784051237 + -0.110951409765*_Complex_I,\n\n -0.051782714777 + -0.055641082544*_Complex_I,\n\n -0.152740278646 + 0.078038723137*_Complex_I,\n\n -0.069927868237 + -0.029365176615*_Complex_I,\n\n -0.014589069109 + -0.028292391657*_Complex_I,\n\n -0.001773824861 + 0.092262042610*_Complex_I,\n\n 0.013547386638 + 0.007206123368*_Complex_I,\n\n 0.024099272780 + -0.029680768546*_Complex_I,\n\n -0.084253318229 + -0.003754881467*_Complex_I,\n\n -0.074747526125 + 0.016818234473*_Complex_I,\n\n -0.018741410126 + 0.035601500906*_Complex_I,\n\n -0.022799538279 + 0.052284827296*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h7x16.c", "rank": 96, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M3h7x30_x[] = {\n\n -0.077089593357,\n\n 0.032375219181,\n\n 0.141488397385,\n\n 0.034405467968,\n\n -0.138389144841,\n\n 0.154646756715,\n\n 0.086331166522,\n\n 0.041332691838,\n\n 0.091791117954,\n\n -0.065105465675,\n\n 0.075745848821,\n\n 0.012475523017,\n\n -0.107768670583,\n\n 0.233864631918,\n\n -0.110944430251,\n\n -0.060308141718,\n\n -0.251948448147,\n\n 0.153274083486,\n\n -0.114102376762,\n\n -0.183548035449,\n\n -0.152968693185,\n\n 0.049660839590,\n\n -0.056844064619,\n\n -0.153304122180,\n\n 0.018994945270,\n\n 0.000201893929,\n\n -0.055497296237,\n\n 0.101173781919,\n\n -0.050453255942,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M3h7x30.c", "rank": 97, "score": 69824.97026457841 }, { "content": "float complex firfilt_cccf_data_h13x32_x[] = {\n\n -0.230394652772 + -0.084902186709*_Complex_I,\n\n 0.116521954181 + -0.075921100646*_Complex_I,\n\n -0.037505572140 + 0.050295775262*_Complex_I,\n\n 0.011196490896 + -0.111587364031*_Complex_I,\n\n -0.136496843877 + 0.079379261628*_Complex_I,\n\n 0.119267886716 + -0.106802817114*_Complex_I,\n\n -0.019101973377 + -0.012951763335*_Complex_I,\n\n 0.013025947353 + -0.027697311008*_Complex_I,\n\n -0.019147300547 + 0.101327659435*_Complex_I,\n\n 0.099708276687 + -0.005787000260*_Complex_I,\n\n 0.068401822498 + 0.064073386055*_Complex_I,\n\n -0.037396159261 + -0.075336873450*_Complex_I,\n\n -0.100404642212 + -0.010670539381*_Complex_I,\n\n 0.158140877685 + -0.091346399746*_Complex_I,\n\n -0.014860736865 + -0.063687261938*_Complex_I,\n\n 0.080260238653 + -0.095670107832*_Complex_I,\n\n -0.039374218095 + -0.044034420137*_Complex_I,\n\n -0.064080642555 + -0.070686889846*_Complex_I,\n\n 0.001854749241 + 0.115365376524*_Complex_I,\n\n 0.010746506918 + -0.241675580817*_Complex_I,\n\n 0.000549090314 + -0.105646197984*_Complex_I,\n\n 0.076651038231 + 0.139227636964*_Complex_I,\n\n 0.142025555338 + -0.030479656574*_Complex_I,\n\n 0.052085787214 + 0.049670506263*_Complex_I,\n\n 0.072171078854 + 0.026786779778*_Complex_I,\n\n -0.025753470644 + 0.135280754343*_Complex_I,\n\n -0.021573256842 + -0.151434524956*_Complex_I,\n\n 0.075816838810 + -0.117216580293*_Complex_I,\n\n 0.072760555750 + -0.032730991216*_Complex_I,\n\n -0.066907752810 + -0.020500064860*_Complex_I,\n\n -0.166213598571 + 0.030726287248*_Complex_I,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firfilt_cccf_data_h13x32.c", "rank": 98, "score": 69824.97026457841 }, { "content": "float firdecim_rrrf_data_M5h23x50_h[] = {\n\n -0.067636988306,\n\n -0.129830871935,\n\n -0.096852198413,\n\n -0.101084148415,\n\n -0.099274002866,\n\n 0.068432593779,\n\n -0.123467175510,\n\n 0.053608743344,\n\n 0.062001100783,\n\n -0.186969419240,\n\n 0.089108369240,\n\n -0.007475824870,\n\n 0.163590779858,\n\n 0.097601917788,\n\n 0.092009543577,\n\n -0.041838135753,\n\n -0.056136168702,\n\n 0.003032887982,\n\n 0.009882398914,\n\n 0.074984250657,\n\n -0.019855593061,\n\n -0.060394654408,\n", "file_path": "liquid-dsp/src/src/filter/tests/data/firdecim_rrrf_data_M5h23x50.c", "rank": 99, "score": 69824.97026457841 } ]
C++
iRODS/server/re/src/testMS.cpp
nesi/irods
49eeaf76305fc483f21b1bbfbdd77d540b59cfd2
#include "reGlobalsExtern.hpp" #include "reFuncDefs.hpp" #include "icatHighLevelRoutines.hpp" int print_hello( ruleExecInfo_t *rei ) { RE_TEST_MACRO( "Test for print_hello\n" ); fprintf( stdout, "Hello\n" ); _writeString( "stdout", "Hello\n", rei ); return 0; } int recover_print_hello( ruleExecInfo_t *rei ) { RE_TEST_MACRO( "\b\b\b\b\b \b\b\b\b\b" ); fprintf( stdout, "\b\b\b\b\b \b\b\b\b\b" ); return 0; } int print_doi( dataObjInfo_t *doi ) { if ( reTestFlag == COMMAND_TEST_1 ) { fprintf( stdout, " objPath = %s\n", doi->objPath ); fprintf( stdout, " rescName= %s\n", doi->rescName ); fprintf( stdout, " dataType= %s\n", doi->dataType ); fprintf( stdout, " dataSize= %lld\n", doi->dataSize ); } else if ( reTestFlag == HTML_TEST_1 ) { fprintf( stdout, " <UL>\n" ); fprintf( stdout, " <LI> objPath = %s\n", doi->objPath ); fprintf( stdout, " <LI> rescName= %s\n", doi->rescName ); fprintf( stdout, " <LI> dataType= %s\n", doi->dataType ); fprintf( stdout, " <LI> dataSize= %lld\n", doi->dataSize ); fprintf( stdout, " </UL>\n" ); } else { rodsLog( LOG_NOTICE, " objPath = %s\n", doi->objPath ); rodsLog( LOG_NOTICE, " rescName= %s\n", doi->rescName ); rodsLog( LOG_NOTICE, " dataType= %s\n", doi->dataType ); rodsLog( LOG_NOTICE, " dataSize= %lld\n", doi->dataSize ); } return 0; } int print_uoi( userInfo_t *uoi ) { if ( reTestFlag == COMMAND_TEST_1 ) { fprintf( stdout, " userName = %s\n", uoi->userName ); fprintf( stdout, " rodsZone= %s\n", uoi->rodsZone ); fprintf( stdout, " userType= %s\n", uoi->userType ); } else if ( reTestFlag == HTML_TEST_1 ) { fprintf( stdout, " <UL>\n" ); fprintf( stdout, " <LI> userName= %s\n", uoi->userName ); fprintf( stdout, " <LI> rodsZone= %s\n", uoi->rodsZone ); fprintf( stdout, " <LI> userType= %s\n", uoi->userType ); fprintf( stdout, " </UL>\n" ); } else { rodsLog( LOG_NOTICE, " userName= %s\n", uoi->userName ); rodsLog( LOG_NOTICE, " rodsZone= %s\n", uoi->rodsZone ); rodsLog( LOG_NOTICE, " userType= %s\n", uoi->userType ); } return 0; } int msiAW1( msParam_t* mPIn, msParam_t* mPOut2, ruleExecInfo_t* ) { char *In; In = ( char * ) mPIn->inOutStruct; rodsLog( LOG_NOTICE, "ALPHA: ------> In:%s\n", In ); mPOut2->type = strdup( STR_MS_T ); mPOut2->inOutStruct = strdup( "Microservice_1" ); return 0; } int msiCutBufferInHalf( msParam_t* mPIn, ruleExecInfo_t *rei ) { RE_TEST_MACRO( "Test for msiCutBufferInHalf\n" ); if ( mPIn == NULL || mPIn->inpOutBuf == NULL ) { rodsLog( LOG_ERROR, "msiCutBufferInHalf: input is NULL." ); return USER__NULL_INPUT_ERR; } mPIn->inpOutBuf->len = ( mPIn->inpOutBuf->len ) / 2; return 0; } int msiDoSomething( msParam_t *, msParam_t *outParam, ruleExecInfo_t * rei ) { keyValPair_t *myKeyVal; RE_TEST_MACRO( " Calling msiDoSomething" ) if ( rei == NULL || rei->rsComm == NULL ) { rodsLog( LOG_ERROR, "msiDoSomething: input rei or rsComm is NULL." ); return SYS_INTERNAL_NULL_INPUT_ERR; } myKeyVal = ( keyValPair_t* ) malloc( sizeof( keyValPair_t ) ); memset( myKeyVal, 0, sizeof( keyValPair_t ) ); outParam->type = strdup( KeyValPair_MS_T ); outParam->inOutStruct = ( void* ) myKeyVal; return 0; }
#include "reGlobalsExtern.hpp" #include "reFuncDefs.hpp" #include "icatHighLevelRoutines.hpp" int print_hello( ruleExecInfo_t *rei ) { RE_TEST_MACRO( "Test for print_hello\n" ); fprintf( stdout, "Hello\n" ); _writeString( "stdout", "Hello\n", rei ); return 0; } int recover_print_hello( ruleExecInfo_t *rei ) { RE_TEST_MACRO( "\b\b\b\b\b \b\b\b\b\b" ); fprintf( stdout, "\b\b\b\b\b \b\b\b\b\b" ); return 0; } int print_doi( dataObjInfo_t *doi ) { if ( reTestFlag == COMMAND_TEST_1 ) { fprintf( s
int print_uoi( userInfo_t *uoi ) { if ( reTestFlag == COMMAND_TEST_1 ) { fprintf( stdout, " userName = %s\n", uoi->userName ); fprintf( stdout, " rodsZone= %s\n", uoi->rodsZone ); fprintf( stdout, " userType= %s\n", uoi->userType ); } else if ( reTestFlag == HTML_TEST_1 ) { fprintf( stdout, " <UL>\n" ); fprintf( stdout, " <LI> userName= %s\n", uoi->userName ); fprintf( stdout, " <LI> rodsZone= %s\n", uoi->rodsZone ); fprintf( stdout, " <LI> userType= %s\n", uoi->userType ); fprintf( stdout, " </UL>\n" ); } else { rodsLog( LOG_NOTICE, " userName= %s\n", uoi->userName ); rodsLog( LOG_NOTICE, " rodsZone= %s\n", uoi->rodsZone ); rodsLog( LOG_NOTICE, " userType= %s\n", uoi->userType ); } return 0; } int msiAW1( msParam_t* mPIn, msParam_t* mPOut2, ruleExecInfo_t* ) { char *In; In = ( char * ) mPIn->inOutStruct; rodsLog( LOG_NOTICE, "ALPHA: ------> In:%s\n", In ); mPOut2->type = strdup( STR_MS_T ); mPOut2->inOutStruct = strdup( "Microservice_1" ); return 0; } int msiCutBufferInHalf( msParam_t* mPIn, ruleExecInfo_t *rei ) { RE_TEST_MACRO( "Test for msiCutBufferInHalf\n" ); if ( mPIn == NULL || mPIn->inpOutBuf == NULL ) { rodsLog( LOG_ERROR, "msiCutBufferInHalf: input is NULL." ); return USER__NULL_INPUT_ERR; } mPIn->inpOutBuf->len = ( mPIn->inpOutBuf->len ) / 2; return 0; } int msiDoSomething( msParam_t *, msParam_t *outParam, ruleExecInfo_t * rei ) { keyValPair_t *myKeyVal; RE_TEST_MACRO( " Calling msiDoSomething" ) if ( rei == NULL || rei->rsComm == NULL ) { rodsLog( LOG_ERROR, "msiDoSomething: input rei or rsComm is NULL." ); return SYS_INTERNAL_NULL_INPUT_ERR; } myKeyVal = ( keyValPair_t* ) malloc( sizeof( keyValPair_t ) ); memset( myKeyVal, 0, sizeof( keyValPair_t ) ); outParam->type = strdup( KeyValPair_MS_T ); outParam->inOutStruct = ( void* ) myKeyVal; return 0; }
tdout, " objPath = %s\n", doi->objPath ); fprintf( stdout, " rescName= %s\n", doi->rescName ); fprintf( stdout, " dataType= %s\n", doi->dataType ); fprintf( stdout, " dataSize= %lld\n", doi->dataSize ); } else if ( reTestFlag == HTML_TEST_1 ) { fprintf( stdout, " <UL>\n" ); fprintf( stdout, " <LI> objPath = %s\n", doi->objPath ); fprintf( stdout, " <LI> rescName= %s\n", doi->rescName ); fprintf( stdout, " <LI> dataType= %s\n", doi->dataType ); fprintf( stdout, " <LI> dataSize= %lld\n", doi->dataSize ); fprintf( stdout, " </UL>\n" ); } else { rodsLog( LOG_NOTICE, " objPath = %s\n", doi->objPath ); rodsLog( LOG_NOTICE, " rescName= %s\n", doi->rescName ); rodsLog( LOG_NOTICE, " dataType= %s\n", doi->dataType ); rodsLog( LOG_NOTICE, " dataSize= %lld\n", doi->dataSize ); } return 0; }
function_block-function_prefixed
[ { "content": " def test(self):\n\n self.rods_session.assert_icommand(\"icd\")\n\n self.rods_session.assert_icommand(\"irule -vF \" + rules30dir + rulefile,\n", "file_path": "tests/pydevtest/test_allrules.py", "rank": 0, "score": 117236.89308473901 }, { "content": "myTestRule {\n\n#Input parameters are:\n\n# Location (stdout, stderr)\n\n# Integer\n\n *A = 1;\n\n writeLine(\"stdout\",\"Wrote an integer\");\n\n writePosInt(\"stdout\",*A);\n\n writeLine(\"stdout\",\"\");\n\n}\n\nINPUT null\n\nOUTPUT ruleExecOut\n", "file_path": "iRODS/clients/icommands/test/rules3.0/rulewritePosInt.r", "rank": 1, "score": 114599.52461002299 }, { "content": "myTestRule {\n\n#Input parameters are:\n\n# Name of RDA database access file\n\n# SQL string to be sent to RDA database\n\n# 1-4 Optional bind variables for SQL string\n\n msiRdaToStdout(*rda,*sql,\"null\",\"null\",\"null\",\"null\");\n\n}\n\nINPUT *rda=\"RDA\", *sql=\"select * from t2\"\n\nOUTPUT ruleExecOut\n", "file_path": "iRODS/clients/icommands/test/rules3.0/rulemsiRdaToStdout.r", "rank": 2, "score": 114590.96398576308 }, { "content": "myTestRule {\n\n#Input parameters are:\n\n# Address\n\n# Subject\n\n writeLine(\"stdout\",\"Message from stdout buffer\");\n\n msiSendStdoutAsEmail(*Address,*Subject);\n\n writeLine(\"stdout\",\"Sent e-mail to *Address about *Subject\");\n\n}\n\nINPUT *Address=\"[email protected]\", *Subject=\"Test message\"\n\nOUTPUT ruleExecOut\n", "file_path": "iRODS/clients/icommands/test/rules3.0/rulemsiSendStdoutAsEmail.r", "rank": 3, "score": 111832.06811624282 }, { "content": "myTestRule {\n\n#Input parameter is:\n\n# Buffer holding the status, output and error messages from the command execution\n\n#Output parameter is:\n\n# Buffer holding the output message\n\n#Output from executing the command is\n\n# Output message is Hello World iRODS from irods\n\n msiExecCmd(\"hello\",*ARG,\"\",\"\",\"\",*HELLO_OUT);\n\n\n\n # *HELLO_OUT holds the status, output and error messages\n\n msiGetStdoutInExecCmdOut(*HELLO_OUT,*Out);\n\n writeLine(\"stdout\",\"Output message is *Out\");\n\n}\n\nINPUT *ARG=\"iRODS\"\n\nOUTPUT ruleExecOut\n", "file_path": "iRODS/clients/icommands/test/rules3.0/rulemsiGetStdoutInExecCmdOut.r", "rank": 4, "score": 109195.6687802599 }, { "content": "def mkuser_and_return_session(user_type, username, password, hostname):\n\n service_env = get_service_account_environment_file_contents()\n\n zone_name = service_env['irods_zone']\n\n with make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(['iadmin', 'mkuser', username, user_type])\n\n admin_session.assert_icommand(['iadmin', 'moduser', username, 'password', password])\n\n env_dict = make_environment_dict(username, hostname, zone_name)\n", "file_path": "tests/pydevtest/lib.py", "rank": 5, "score": 109184.89480792604 }, { "content": " int dummyInt;\t/* make it to 64 bit boundary */\n", "file_path": "iRODS/lib/core/include/rodsDef.h", "rank": 6, "score": 106548.612812068 }, { "content": " int intInfo; /* an additional integer info, for API, it is the\n", "file_path": "iRODS/lib/core/include/rodsDef.h", "rank": 7, "score": 106548.612812068 }, { "content": "class TestBase : public ::testing::Test {\n\n\n\n protected:\n\n icatSessionStruct _icss;\n\n rodsEnv _myEnv;\n\n char _msg[1024];\n\n char _sql[1024];\n\n\n\n TestBase();\n\n virtual ~TestBase();\n\n virtual void SetUp();\n\n virtual void setUserPass( const char *user, const char *pass );\n\n virtual void TearDown();\n\n void PrintRows( int stmt );\n\n};\n\n\n", "file_path": "iRODS/server/test/src/TestBase.hpp", "rank": 8, "score": 98965.4649209227 }, { "content": "class TestCllEnv : public ::TestBase {\n\n protected:\n\n virtual void SetUp() {\n\n if ( cllOpenEnv( &_icss ) == SQL_ERROR ) {\n\n // ODBC docs suggest this is a memory allocation error, bail out\n\n cout << \"TestCllEnv::Setup():cllOpenEnv() - out of memory\" << endl;\n\n exit( 1 );\n\n }\n\n }\n\n\n\n virtual void TearDown() {\n\n if ( cllCloseEnv( &_icss ) != 0 ) {\n\n cout << \"TestCllEnv::TearDown():cllCloseEnv() - failed\" << endl;\n\n }\n\n }\n\n};\n\n\n\nTEST_F( TestCllEnv, HandlesNullIcss ) {\n\n EXPECT_NE( 0, cllConnect( NULL ) );\n\n}\n", "file_path": "iRODS/server/test/src/TestCLL.cpp", "rank": 9, "score": 78120.6206032998 }, { "content": "class TestCmlEnv : public ::TestBase {\n\n protected:\n\n virtual void SetUp() {\n\n TestBase::setUserPass( g_argv[1], g_argv[2] );\n\n if ( cmlOpen( &_icss ) == SQL_ERROR ) {\n\n // ODBC docs suggest this is a memory allocation error, bail out\n\n cout << \"TestCmlEnv::Setup():cmlOpen() - out of memory\" << endl;\n\n exit( 1 );\n\n }\n\n }\n\n\n\n virtual void TearDown() {\n\n if ( cmlClose( &_icss ) != 0 ) {\n\n cout << \"TestCmlEnv::TearDown():cmlCloseEnv() - failed\" << endl;\n\n }\n\n }\n\n};\n\n\n\nTEST_F( TestCmlEnv, HandlesRodsEnv ) {\n\n EXPECT_GE( 0, getRodsEnv( &_myEnv ) );\n\n}\n\n\n\nTEST_F( TestCmlEnv, HandlesNullEmptySql ) {\n\n EXPECT_NE( 0, cmlExecuteNoAnswerSql( NULL, &_icss ) );\n\n EXPECT_NE( 0, cmlExecuteNoAnswerSql( \"\", &_icss ) );\n\n}\n\n\n\n/*\n\nTests most calls.\n\n*/\n", "file_path": "iRODS/server/test/src/TestCML.cpp", "rank": 10, "score": 78120.6206032998 }, { "content": "class TestChlEnv : public ::TestBase {\n\n protected:\n\n rsComm_t *_comm;\n\n rodsServerConfig_t _serverConfig;\n\n\n\n virtual void SetUp() {\n\n rodsLogLevel( LOG_NOTICE );\n\n TestBase::setUserPass( g_argv[1], g_argv[2] );\n\n _comm = ( rsComm_t* )malloc( sizeof( rsComm_t ) );\n\n memset( _comm, 0, sizeof( rsComm_t ) );\n\n if ( getRodsEnv( &_myEnv ) < 0 ) {\n\n cerr << \"getRodsEnv() failed\" << endl;\n\n exit( 1 );\n\n }\n\n memset( &_serverConfig, 0, sizeof( _serverConfig ) );\n\n int err;\n\n if ( ( err = readServerConfig( &_serverConfig ) ) != 0 ) {\n\n cerr << \"Failed to read server config: \" << err << endl;\n\n exit( 1 );\n\n }\n", "file_path": "iRODS/server/test/src/TestCHL.cpp", "rank": 11, "score": 78120.6206032998 }, { "content": "class TestCmlFunctions : public ::TestCmlEnv {\n\n protected:\n\n virtual void SetUp() {\n\n TestCmlEnv::SetUp();\n\n // setup the database for our tests\n\n if ( getRodsEnv( &_myEnv ) < 0 ) {\n\n exit( 1 );\n\n }\n\n int i;\n\n\n\n // get next sequence value\n\n int nextseqval = cmlGetNextSeqVal( &_icss );\n\n\n\n // insert a sample row\n\n snprintf( _sql, sizeof( _sql ), \"insert into R_COLL_MAIN (coll_id, \" \\\n\n \"parent_coll_name, coll_name, coll_owner_name, coll_owner_zone) \" \\\n\n \"values (%i, \\'%s\\', \\'%s\\', \\'%s\\', \\'%s\\')\", nextseqval,\n\n PARENT_OF_A, A_VALUE, _myEnv.rodsUserName, _myEnv.rodsZone );\n\n if ( ( i = cmlExecuteNoAnswerSql( _sql, &_icss ) ) ) {\n\n cllGetLastErrorMessage( _msg, sizeof( _msg ) );\n", "file_path": "iRODS/server/test/src/TestCML.cpp", "rank": 12, "score": 77464.67818414087 }, { "content": "class TestCllFunctions : public ::TestCllEnv {\n\n protected:\n\n virtual void SetUp() {\n\n TestCllEnv::SetUp();\n\n TestBase::setUserPass( user, pass );\n\n cllConnect( &_icss );\n\n }\n\n\n\n virtual void TearDown() {\n\n cllDisconnect( &_icss );\n\n TestCllEnv::TearDown();\n\n }\n\n};\n\n\n\nTEST_F( TestCllFunctions, HandlesSQL ) {\n\n // Create a table for testing\n\n EXPECT_EQ( CAT_SUCCESS_BUT_WITH_NO_INFO, cllExecSqlNoResult( &_icss,\n\n \"create table test (i integer, j integer, a varchar(32))\" ) );\n\n\n\n // Populate with test data\n", "file_path": "iRODS/server/test/src/TestCLL.cpp", "rank": 13, "score": 77464.67818414087 }, { "content": "class Test_AllRules(resource_suite.ResourceBase, unittest.TestCase):\n\n __metaclass__ = metaclass_unittest_test_case_generator.MetaclassUnittestTestCaseGenerator\n\n\n\n global rules30dir\n\n currentdir = os.path.dirname(os.path.realpath(__file__))\n\n rules30dir = currentdir + \"/../../iRODS/clients/icommands/test/rules3.0/\"\n\n conf_dir = lib.get_irods_config_dir()\n\n\n\n def setUp(self):\n\n super(Test_AllRules, self).setUp()\n\n\n\n self.rods_session = lib.make_session_for_existing_admin() # some rules hardcode 'rods' and 'tempZone'\n\n\n\n hostname = socket.gethostname()\n\n hostuser = getpass.getuser()\n\n progname = __file__\n\n dir_w = rules30dir + \"..\"\n\n self.rods_session.assert_icommand('icd') # to get into the home directory (for testallrules assumption)\n\n self.rods_session.assert_icommand('iadmin mkuser devtestuser rodsuser')\n\n self.rods_session.assert_icommand('iadmin mkresc testallrulesResc unixfilesystem ' + hostname + ':/tmp/' + hostuser + '/pydevtest_testallrulesResc', 'STDOUT', 'unixfilesystem')\n\n self.rods_session.assert_icommand('imkdir sub1')\n\n self.rods_session.assert_icommand('imkdir sub3')\n\n self.rods_session.assert_icommand('imkdir forphymv')\n\n self.rods_session.assert_icommand('imkdir ruletest')\n\n self.rods_session.assert_icommand('imkdir test')\n\n self.rods_session.assert_icommand('imkdir test/phypathreg')\n\n self.rods_session.assert_icommand('imkdir ruletest/subforrmcoll')\n\n self.rods_session.assert_icommand('iput ' + progname + ' test/foo1')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/dcmetadatatarget')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/mdcopysource')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/mdcopydest')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/foo1')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/foo2')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/foo3')\n\n self.rods_session.assert_icommand('icp test/foo1 forphymv/phymvfile')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/objunlink1')\n\n self.rods_session.assert_icommand('irm sub1/objunlink1') # put it in the trash\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/objunlink2')\n\n self.rods_session.assert_icommand('irepl -R testallrulesResc sub1/objunlink2')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/freebuffer')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/automove')\n\n self.rods_session.assert_icommand('icp test/foo1 test/versiontest.txt')\n\n self.rods_session.assert_icommand('icp test/foo1 test/metadata-target.txt')\n\n self.rods_session.assert_icommand('icp test/foo1 test/ERAtestfile.txt')\n\n self.rods_session.assert_icommand('ichmod read devtestuser test/ERAtestfile.txt')\n\n self.rods_session.assert_icommand('imeta add -d test/ERAtestfile.txt Fun 99 Balloons')\n\n self.rods_session.assert_icommand('icp test/foo1 sub1/for_versioning.txt')\n\n self.rods_session.assert_icommand('imkdir sub1/SaveVersions')\n\n self.rods_session.assert_icommand('iput ' + dir_w + '/misc/devtestuser-account-ACL.txt test')\n\n self.rods_session.assert_icommand('iput ' + dir_w + '/misc/load-metadata.txt test')\n\n self.rods_session.assert_icommand('iput ' + dir_w + '/misc/load-usermods.txt test')\n\n self.rods_session.assert_icommand('iput ' + dir_w + '/misc/sample.email test')\n\n self.rods_session.assert_icommand('iput ' + dir_w + '/misc/email.tag test')\n\n self.rods_session.assert_icommand('iput ' + dir_w + '/misc/sample.email test/sample2.email')\n\n self.rods_session.assert_icommand('iput ' + dir_w + '/misc/email.tag test/email2.tag')\n\n\n\n # setup for rulemsiAdmChangeCoreRE and the likes\n\n empty_core_file_name = 'empty.test.re'\n\n new_core_file_name = 'new.test.re'\n\n with open(self.conf_dir + '/' + empty_core_file_name, 'w'):\n\n pass\n\n shutil.copy(self.conf_dir + \"/core.re\", self.conf_dir + \"/core.re.bckp\") # back up core.re\n\n shutil.copy(self.conf_dir + \"/core.re\", self.conf_dir + \"/\" + new_core_file_name) # copy core.re\n\n\n\n def tearDown(self):\n\n self.rods_session.assert_icommand('icd') # for home directory assumption\n\n self.rods_session.assert_icommand(['ichmod', '-r', 'own', self.rods_session.username, '.'])\n\n self.rods_session.run_icommand(['imcoll', '-U', self.rods_session.home_collection + '/test/phypathreg'])\n\n self.rods_session.run_icommand('irm -rf test ruletest forphymv sub1 sub2 sub3 bagit rules bagit.tar /' + self.rods_session.zone_name + '/bundle/home/' + self.rods_session.username)\n\n self.rods_session.assert_icommand('iadmin rmresc testallrulesResc')\n\n self.rods_session.assert_icommand('iadmin rmuser devtestuser')\n\n self.rods_session.assert_icommand('iqdel -a') # remove all/any queued rules\n\n\n\n # cleanup mods in iRODS config dir\n\n lib.run_command('mv -f {0}/core.re.bckp {0}/core.re'.format(self.conf_dir, self.conf_dir))\n\n lib.run_command('rm -f %s/*.test.re' % self.conf_dir)\n\n\n\n self.rods_session.__exit__()\n\n super(Test_AllRules, self).tearDown()\n\n\n\n def generate_tests_allrules():\n\n\n\n def filter_rulefiles(rulefile):\n\n\n\n # skip rules that handle .irb files\n\n names_to_skip = [\n\n \"rulemsiAdmAppendToTopOfCoreIRB\",\n\n \"rulemsiAdmChangeCoreIRB\",\n\n \"rulemsiGetRulesFromDBIntoStruct\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- RE\"\n\n return False\n\n\n\n # skip rules that fail by design\n\n names_to_skip = [\n\n \"GoodFailure\"\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- failbydesign\"\n\n return False\n\n\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- failbydesign\"\n\n return False\n\n\n\n # skip if an action (run in the core.re), not enough input/output for irule\n\n names_to_skip = [\n\n \"rulemsiAclPolicy\",\n\n \"rulemsiAddUserToGroup\",\n\n \"rulemsiCheckHostAccessControl\",\n\n \"rulemsiCheckOwner\",\n\n \"rulemsiCheckPermission\",\n\n \"rulemsiCommit\",\n\n \"rulemsiCreateCollByAdmin\",\n\n \"rulemsiCreateUser\",\n\n \"rulemsiDeleteCollByAdmin\",\n\n \"rulemsiDeleteDisallowed\",\n\n \"rulemsiDeleteUser\",\n\n \"rulemsiExtractNaraMetadata\",\n\n \"rulemsiOprDisallowed\",\n\n \"rulemsiRegisterData\",\n\n \"rulemsiRenameCollection\",\n\n \"rulemsiRenameLocalZone\",\n\n \"rulemsiRollback\",\n\n \"rulemsiSetBulkPutPostProcPolicy\",\n\n \"rulemsiSetDataObjAvoidResc\",\n\n \"rulemsiSetDataObjPreferredResc\",\n\n \"rulemsiSetDataTypeFromExt\",\n\n \"rulemsiSetDefaultResc\",\n\n \"rulemsiSetGraftPathScheme\",\n\n \"rulemsiSetMultiReplPerResc\",\n\n \"rulemsiSetNoDirectRescInp\",\n\n \"rulemsiSetNumThreads\",\n\n \"rulemsiSetPublicUserOpr\",\n\n \"rulemsiSetRandomScheme\",\n\n \"rulemsiSetRescQuotaPolicy\",\n\n \"rulemsiSetRescSortScheme\",\n\n \"rulemsiSetReServerNumProc\",\n\n \"rulemsiSetResource\",\n\n \"rulemsiSortDataObj\",\n\n \"rulemsiStageDataObj\",\n\n \"rulemsiSysChksumDataObj\",\n\n \"rulemsiSysMetaModify\",\n\n \"rulemsiSysReplDataObj\",\n\n \"rulemsiNoChkFilePathPerm\",\n\n \"rulemsiNoTrashCan\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- input/output\"\n\n return False\n\n\n\n # skip rules we are not yet supporting\n\n names_to_skip = [\n\n \"rulemsiobj\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- msiobj\"\n\n return False\n\n\n\n # ERA\n\n names_to_skip = [\n\n \"rulemsiFlagInfectedObjs\",\n\n \"rulemsiGetAuditTrailInfoByActionID\",\n\n \"rulemsiGetAuditTrailInfoByKeywords\",\n\n \"rulemsiGetAuditTrailInfoByObjectID\",\n\n \"rulemsiGetAuditTrailInfoByTimeStamp\",\n\n \"rulemsiGetAuditTrailInfoByUserID\",\n\n \"rulemsiMergeDataCopies\",\n\n \"rulemsiGetCollectionPSmeta-null\" # marked for removal - iquest now handles this natively\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- ERA\"\n\n return False\n\n\n\n # XMSG\n\n names_to_skip = [\n\n \"rulemsiCreateXmsgInp\",\n\n \"rulemsiRcvXmsg\",\n\n \"rulemsiSendXmsg\",\n\n \"rulemsiXmsgCreateStream\",\n\n \"rulemsiXmsgServerConnect\",\n\n \"rulemsiXmsgServerDisConnect\",\n\n \"rulereadXMsg\",\n\n \"rulewriteXMsg\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- XMSG\"\n\n return False\n\n\n\n # FTP\n\n names_to_skip = [\n\n \"rulemsiFtpGet\",\n\n \"rulemsiTwitterPost\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- FTP\"\n\n return False\n\n\n\n # webservices\n\n names_to_skip = [\n\n \"rulemsiConvertCurrency\",\n\n \"rulemsiGetQuote\",\n\n \"rulemsiIp2location\",\n\n \"rulemsiObjByName\",\n\n \"rulemsiSdssImgCutout_GetJpeg\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- webservices\"\n\n return False\n\n\n\n # XML\n\n names_to_skip = [\n\n \"rulemsiLoadMetadataFromXml\",\n\n \"rulemsiXmlDocSchemaValidate\",\n\n \"rulemsiXsltApply\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- XML\"\n\n return False\n\n\n\n # transition to core microservices only\n\n names_to_skip = [\n\n \"rulemsiAddKeyVal.r\",\n\n \"rulemsiApplyDCMetadataTemplate.r\",\n\n \"rulemsiAssociateKeyValuePairsToObj.r\",\n\n \"rulemsiCollectionSpider.r\",\n\n \"rulemsiCopyAVUMetadata.r\",\n\n \"rulemsiExportRecursiveCollMeta.r\",\n\n \"rulemsiFlagDataObjwithAVU.r\",\n\n \"rulemsiGetCollectionACL.r\",\n\n \"rulemsiGetCollectionContentsReport.r\",\n\n \"rulemsiGetCollectionPSmeta.r\",\n\n \"rulemsiGetCollectionSize.r\",\n\n \"rulemsiGetDataObjACL.r\",\n\n \"rulemsiGetDataObjAIP.r\",\n\n \"rulemsiGetDataObjAVUs.r\",\n\n \"rulemsiGetDataObjPSmeta.r\",\n\n \"rulemsiGetObjectPath.r\",\n\n \"rulemsiGetUserACL.r\",\n\n \"rulemsiGetUserInfo.r\",\n\n \"rulemsiGuessDataType.r\",\n\n \"rulemsiIsColl.r\",\n\n \"rulemsiIsData.r\",\n\n \"rulemsiLoadACLFromDataObj.r\",\n\n \"rulemsiLoadMetadataFromDataObj.r\",\n\n \"rulemsiLoadUserModsFromDataObj.r\",\n\n \"rulemsiPropertiesAdd.r\",\n\n \"rulemsiPropertiesClear.r\",\n\n \"rulemsiPropertiesClone.r\",\n\n \"rulemsiPropertiesExists.r\",\n\n \"rulemsiPropertiesFromString.r\",\n\n \"rulemsiPropertiesGet.r\",\n\n \"rulemsiPropertiesNew.r\",\n\n \"rulemsiPropertiesRemove.r\",\n\n \"rulemsiPropertiesSet.r\",\n\n \"rulemsiRecursiveCollCopy.r\",\n\n \"rulemsiRemoveKeyValuePairsFromObj.r\",\n\n \"rulemsiSetDataType.r\",\n\n \"rulemsiString2KeyValPair.r\",\n\n \"rulemsiStripAVUs.r\",\n\n \"rulemsiStructFileBundle.r\",\n\n \"rulewriteKeyValPairs.r\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- transition to core\"\n\n return False\n\n\n\n # skipping rules requiring additional .re files in community code\n\n names_to_skip = [\n\n \"rulemsiAdmAddAppRuleStruct.r\",\n\n \"rulemsiAdmClearAppRuleStruct.r\",\n\n \"rulemsiAdmInsertRulesFromStructIntoDB.r\",\n\n \"rulemsiAdmReadRulesFromFileIntoStruct.r\",\n\n \"rulemsiAdmRetrieveRulesFromDBIntoStruct.r\",\n\n \"rulemsiAdmWriteRulesFromStructIntoFile.r\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- community\"\n\n return False\n\n\n\n # skipping for now, not sure why it's throwing a stacktrace at the moment\n\n if \"rulemsiPropertiesToString\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- b/c of stacktrace\"\n\n return False\n\n\n\n # misc / other\n\n if \"ruleintegrity\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- integrityChecks\"\n\n return False\n\n if \"z3950\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- z3950\"\n\n return False\n\n if \"rulemsiImage\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- image\"\n\n return False\n\n if \"rulemsiRda\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- RDA\"\n\n return False\n\n if \"rulemsiCollRepl\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- deprecated\"\n\n return False\n\n if \"rulemsiTarFileExtract\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- CAT_NO_ROWS_FOUND - failed in\n\n # call to getDataObjInfoIncSpecColl\"\n\n return False\n\n if \"rulemsiDataObjRsync\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- tested separately\"\n\n return False\n\n\n\n return True\n\n\n\n for rulefile in filter(filter_rulefiles, sorted(os.listdir(rules30dir))):\n\n def make_test(rulefile):\n\n def test(self):\n\n self.rods_session.assert_icommand(\"icd\")\n\n self.rods_session.assert_icommand(\"irule -vF \" + rules30dir + rulefile,\n\n \"STDOUT\", \"completed successfully\")\n\n return test\n\n\n\n yield 'test_' + rulefile.replace('.', '_'), make_test(rulefile)\n\n\n\n def test_rulemsiDataObjRsync(self):\n\n rulefile = 'rulemsiDataObjRsync.r'\n\n src_filename = 'source.txt'\n\n dest_filename = 'dest.txt'\n\n test_dir = '/tmp'\n\n test_coll = self.rods_session.home_collection + '/synctest'\n\n src_file = os.path.join(test_dir, src_filename)\n\n src_obj = test_coll + '/' + src_filename\n\n dest_obj = test_coll + '/' + dest_filename\n\n\n\n # create test collection\n\n self.rods_session.run_icommand(['imkdir', test_coll])\n\n\n\n # create source test file\n\n with open(src_file, 'a') as f:\n\n f.write('blah\\n')\n\n\n\n # upload source test file\n\n self.rods_session.run_icommand(['iput', src_file, test_coll])\n\n\n\n # first rsync rule test\n\n self.rods_session.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDOUT', \"status = 99999992\")\n\n\n\n # modify the source and try again\n\n for i in range(1, 5):\n\n with open(src_file, 'a') as f:\n\n f.write('blah_' + str(i) + '\\n')\n\n\n\n # force upload source\n\n self.rods_session.run_icommand(['iput', '-f', src_file, test_coll])\n\n\n\n # sync test\n\n self.rods_session.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDOUT', \"status = 99999992\")\n\n\n\n # cleanup\n\n self.rods_session.run_icommand(['irm', '-rf', test_coll])\n\n os.remove(src_file)\n\n\n\n def test_rulemsiPhyBundleColl(self):\n\n rulefile = 'rulemsiPhyBundleColl.r'\n\n\n\n # rule test\n\n self.rods_session.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDOUT',\n\n \"Create tar file of collection /tempZone/home/rods/test on resource testallrulesResc\")\n\n\n\n # look for the bundle\n\n bundle_path = '/tempZone/bundle/home/' + self.rods_session.username\n\n output = self.rods_session.run_icommand(['ils', '-L', bundle_path])\n\n\n\n # last token in stdout should be the bundle file's full physical path\n\n bundlefile = output[1].split()[-1]\n\n\n\n # check on the bundle file's name\n\n assert bundlefile.find('test.') >= 0\n\n\n\n # check physical path on resource\n\n assert os.path.isfile(bundlefile)\n\n\n\n # now try as a normal user (expect err msg)\n\n self.user0.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDERR', \"SYS_NO_API_PRIV\")\n\n\n\n # cleanup\n\n self.rods_session.run_icommand(['irm', '-rf', bundle_path])\n\n \n\n def test_str_2528(self):\n", "file_path": "tests/pydevtest/test_allrules.py", "rank": 14, "score": 76130.27090361474 }, { "content": " def startTest(self, test):\n\n # TextTestResult's impl prints as \"test (module.class)\" which prevents copy/paste\n\n print('{0} ... '.format(test.id()), end='', file=self.stream)\n", "file_path": "tests/pydevtest/run_tests.py", "rank": 15, "score": 76130.27090361474 }, { "content": " def test_str_2528(self):\n", "file_path": "tests/pydevtest/test_allrules.py", "rank": 16, "score": 76130.27090361474 }, { "content": "class Test_ixmsg(unittest.TestCase):\n\n serverConfigFile = lib.get_irods_config_dir() + \"/server_config.json\"\n\n xmsgHost = 'localhost'\n\n xmsgPort = 1279\n\n\n\n def setUp(self):\n\n # add Xmsg settings to server_config.json\n\n with open(self.serverConfigFile) as f:\n\n contents = json.load(f)\n\n os.system('cp {0} {0}_orig'.format(self.serverConfigFile))\n\n contents[\"xmsg_host\"] = self.xmsgHost\n\n contents[\"xmsg_port\"] = self.xmsgPort\n\n with open(self.serverConfigFile, 'w') as f:\n\n json.dump(contents, f)\n\n\n\n # apparently needed by the server too...\n\n my_env = os.environ.copy()\n\n my_env['XMSG_HOST'] = self.xmsgHost\n\n my_env['XMSG_PORT'] = str(self.xmsgPort)\n\n\n\n # restart server with Xmsg\n\n lib.restart_irods_server(env=my_env)\n\n\n\n def tearDown(self):\n\n # revert to original server_config.json\n\n os.system(\"mv -f %s_orig %s\" % (self.serverConfigFile, self.serverConfigFile))\n\n\n\n # restart server\n\n my_env = os.environ.copy()\n\n lib.restart_irods_server(env=my_env)\n\n\n\n @unittest.skipIf(configuration.TOPOLOGY_FROM_RESOURCE_SERVER, \"Skip for topology testing from resource server\")\n\n def test_send_and_receive_one_xmsg(self):\n\n message = 'Hello World!'\n\n\n\n # set up Xmsg in client environment\n\n my_env = os.environ.copy()\n\n my_env['XMSG_HOST'] = self.xmsgHost\n\n my_env['XMSG_PORT'] = str(self.xmsgPort)\n\n\n\n # send msg\n\n args = ['/usr/bin/ixmsg', 's', '-M \"{0}\"'.format(message)]\n\n subprocess.Popen(args, env=my_env).communicate()\n\n\n\n # receive msg\n\n args = ['/usr/bin/ixmsg', 'r', '-n 1']\n\n res = subprocess.Popen(args, env=my_env, stdout=subprocess.PIPE).communicate()\n\n\n\n # assertion\n\n print 'looking for \"{0}\" in \"{1}\"'.format(message, res[0].rstrip())\n", "file_path": "tests/pydevtest/test_xmsg.py", "rank": 17, "score": 76130.27090361474 }, { "content": " def make_test(rulefile):\n\n def test(self):\n\n self.rods_session.assert_icommand(\"icd\")\n\n self.rods_session.assert_icommand(\"irule -vF \" + rules30dir + rulefile,\n\n \"STDOUT\", \"completed successfully\")\n", "file_path": "tests/pydevtest/test_allrules.py", "rank": 18, "score": 76130.27090361474 }, { "content": "class Test_iScan(ResourceBase, unittest.TestCase):\n\n def setUp(self):\n\n super(Test_iScan, self).setUp()\n\n\n\n def tearDown(self):\n\n super(Test_iScan, self).tearDown()\n\n\n\n @unittest.skipIf(configuration.TOPOLOGY_FROM_RESOURCE_SERVER, 'Skip for topology testing from resource server: Reads Vault')\n\n def test_iscan_local_file(self):\n\n self.user0.assert_icommand('iscan non_existent_file', 'STDERR', 'ERROR: scanObj: non_existent_file does not exist' )\n\n existent_file = os.path.join( self.user0.local_session_dir, 'existent_file' )\n\n lib.touch( existent_file )\n\n self.user0.assert_icommand('iscan ' + existent_file, 'STDOUT', existent_file + ' is not registered in iRODS' )\n\n self.user0.assert_icommand('iput ' + existent_file );\n\n output = self.user0.run_icommand('''iquest \"SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'\"''' )[1]\n\n data_path = output.strip().strip('-').strip()[12:]\n\n self.user0.assert_icommand('iscan ' + data_path );\n\n self.user0.assert_icommand('irm -f existent_file' );\n\n\n\n @unittest.skipIf(configuration.TOPOLOGY_FROM_RESOURCE_SERVER, 'Skip for topology testing from resource server: Reads Vault')\n\n def test_iscan_data_object(self):\n\n #test that rodsusers can't use iscan -d\n\n self.user0.assert_icommand('iscan -d non_existent_file', 'STDOUT', 'Could not find the requested data object or collection in iRODS.' )\n\n existent_file = os.path.join( self.user0.local_session_dir, 'existent_file' )\n\n lib.make_file( existent_file, 1 )\n\n self.user0.assert_icommand('iput ' + existent_file );\n\n output = self.admin.run_icommand('iquest \"SELECT DATA_PATH WHERE DATA_NAME = \\'existent_file\\'\"' )[1]\n\n data_path = output.strip().strip('-').strip()[12:]\n\n self.user0.assert_icommand('iscan -d existent_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' );\n\n os.remove( data_path )\n\n self.user0.assert_icommand('iscan -d existent_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' );\n\n lib.make_file( data_path, 1 )\n\n self.user0.assert_icommand('irm -f existent_file' );\n\n zero_file = os.path.join( self.user0.local_session_dir, 'zero_file' )\n\n lib.touch( zero_file )\n\n self.user0.assert_icommand('iput ' + zero_file );\n\n self.user0.assert_icommand('iscan -d zero_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' );\n\n self.user0.assert_icommand('irm -f zero_file' );\n\n\n\n #test that rodsadmins can use iscan -d\n\n self.admin.assert_icommand('iscan -d non_existent_file', 'STDOUT', 'Could not find the requested data object or collection in iRODS.' )\n\n existent_file = os.path.join( self.admin.local_session_dir, 'existent_file' )\n\n lib.make_file( existent_file, 1 )\n\n self.admin.assert_icommand('iput ' + existent_file );\n\n output = self.admin.run_icommand('''iquest \"SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'\"''' )[1]\n\n data_path = output.strip().strip('-').strip()[12:]\n\n self.admin.assert_icommand('iscan -d existent_file' );\n\n os.remove( data_path )\n\n self.admin.assert_icommand('iscan -d existent_file', 'STDOUT', 'is missing, corresponding to iRODS object' );\n\n lib.make_file( data_path, 1 )\n\n self.admin.assert_icommand('irm -f existent_file' );\n\n zero_file = os.path.join( self.admin.local_session_dir, 'zero_file' )\n\n lib.touch( zero_file )\n\n self.admin.assert_icommand('iput ' + zero_file );\n\n self.admin.assert_icommand('iscan -d zero_file' );\n", "file_path": "tests/pydevtest/test_iscan.py", "rank": 19, "score": 76130.27090361474 }, { "content": " def test_status(self):\n\n # test grid status\n", "file_path": "tests/pydevtest/test_control_plane.py", "rank": 20, "score": 75301.76127958545 }, { "content": " def test_shutdown(self):\n\n # test shutdown\n\n lib.assert_command('irods-grid shutdown --all', 'STDOUT', 'shutting down')\n\n time.sleep( 2 )\n\n lib.assert_command('ils', 'STDERR', 'USER_SOCK_CONNECT_ERR')\n\n\n", "file_path": "tests/pydevtest/test_control_plane.py", "rank": 21, "score": 75301.76127958545 }, { "content": " def test_phybun_from_devtest(self):\n\n with lib.make_session_for_existing_admin() as rods_admin:\n\n rods_admin.run_icommand(['ichmod', 'own', self.admin.username, '/' + self.admin.zone_name])\n\n\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory containing 20 small files\n\n if not os.path.isdir(mysdir):\n\n os.mkdir(mysdir)\n\n for i in range(20):\n\n mysfile = mysdir + \"/sfile\" + str(i)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # iphybun test\n\n self.admin.assert_icommand(\"iput -rR \" + self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtestp\")\n\n self.admin.assert_icommand(\"iphybun -KR \" + self.anotherresc + \" \" + irodshome + \"/icmdtestp\")\n\n self.admin.assert_icommand(\"itrim -rS \" + self.testresc + \" -N1 \" +\n\n irodshome + \"/icmdtestp\", 'STDOUT', \"files trimmed\")\n\n output = commands.getstatusoutput(\"ils -L \" + irodshome + \"/icmdtestp/sfile1 | tail -n1 | awk '{ print $NF }'\")\n\n print output[1]\n\n bunfile = output[1]\n\n self.admin.assert_icommand(\"irepl --purgec -R \" + self.anotherresc + \" \" + bunfile)\n\n self.admin.assert_icommand(\"itrim -rS \" + self.testresc + \" -N1 \" +\n\n irodshome + \"/icmdtestp\", 'STDOUT', \"files trimmed\")\n\n # get the name of bundle file\n\n self.admin.assert_icommand(\"irm -f --empty \" + bunfile)\n\n # should not be able to remove it because it is not empty\n\n self.admin.assert_icommand(\"ils \" + bunfile, 'STDOUT', bunfile)\n\n self.admin.assert_icommand(\"irm -rvf \" + irodshome + \"/icmdtestp\", 'STDOUT', \"num files done\")\n\n self.admin.assert_icommand(\"irm -f --empty \" + bunfile)\n\n if os.path.exists(dir_w + \"/testp\"):\n\n shutil.rmtree(dir_w + \"/testp\")\n\n shutil.rmtree(mysdir)\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n if os.path.exists(mysdir):\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 22, "score": 75301.76127958545 }, { "content": " def generate_tests_allrules():\n\n\n\n def filter_rulefiles(rulefile):\n\n\n\n # skip rules that handle .irb files\n\n names_to_skip = [\n\n \"rulemsiAdmAppendToTopOfCoreIRB\",\n\n \"rulemsiAdmChangeCoreIRB\",\n\n \"rulemsiGetRulesFromDBIntoStruct\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- RE\"\n\n return False\n\n\n\n # skip rules that fail by design\n\n names_to_skip = [\n\n \"GoodFailure\"\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- failbydesign\"\n\n return False\n\n\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- failbydesign\"\n\n return False\n\n\n\n # skip if an action (run in the core.re), not enough input/output for irule\n\n names_to_skip = [\n\n \"rulemsiAclPolicy\",\n\n \"rulemsiAddUserToGroup\",\n\n \"rulemsiCheckHostAccessControl\",\n\n \"rulemsiCheckOwner\",\n\n \"rulemsiCheckPermission\",\n\n \"rulemsiCommit\",\n\n \"rulemsiCreateCollByAdmin\",\n\n \"rulemsiCreateUser\",\n\n \"rulemsiDeleteCollByAdmin\",\n\n \"rulemsiDeleteDisallowed\",\n\n \"rulemsiDeleteUser\",\n\n \"rulemsiExtractNaraMetadata\",\n\n \"rulemsiOprDisallowed\",\n\n \"rulemsiRegisterData\",\n\n \"rulemsiRenameCollection\",\n\n \"rulemsiRenameLocalZone\",\n\n \"rulemsiRollback\",\n\n \"rulemsiSetBulkPutPostProcPolicy\",\n\n \"rulemsiSetDataObjAvoidResc\",\n\n \"rulemsiSetDataObjPreferredResc\",\n\n \"rulemsiSetDataTypeFromExt\",\n\n \"rulemsiSetDefaultResc\",\n\n \"rulemsiSetGraftPathScheme\",\n\n \"rulemsiSetMultiReplPerResc\",\n\n \"rulemsiSetNoDirectRescInp\",\n\n \"rulemsiSetNumThreads\",\n\n \"rulemsiSetPublicUserOpr\",\n\n \"rulemsiSetRandomScheme\",\n\n \"rulemsiSetRescQuotaPolicy\",\n\n \"rulemsiSetRescSortScheme\",\n\n \"rulemsiSetReServerNumProc\",\n\n \"rulemsiSetResource\",\n\n \"rulemsiSortDataObj\",\n\n \"rulemsiStageDataObj\",\n\n \"rulemsiSysChksumDataObj\",\n\n \"rulemsiSysMetaModify\",\n\n \"rulemsiSysReplDataObj\",\n\n \"rulemsiNoChkFilePathPerm\",\n\n \"rulemsiNoTrashCan\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- input/output\"\n\n return False\n\n\n\n # skip rules we are not yet supporting\n\n names_to_skip = [\n\n \"rulemsiobj\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- msiobj\"\n\n return False\n\n\n\n # ERA\n\n names_to_skip = [\n\n \"rulemsiFlagInfectedObjs\",\n\n \"rulemsiGetAuditTrailInfoByActionID\",\n\n \"rulemsiGetAuditTrailInfoByKeywords\",\n\n \"rulemsiGetAuditTrailInfoByObjectID\",\n\n \"rulemsiGetAuditTrailInfoByTimeStamp\",\n\n \"rulemsiGetAuditTrailInfoByUserID\",\n\n \"rulemsiMergeDataCopies\",\n\n \"rulemsiGetCollectionPSmeta-null\" # marked for removal - iquest now handles this natively\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- ERA\"\n\n return False\n\n\n\n # XMSG\n\n names_to_skip = [\n\n \"rulemsiCreateXmsgInp\",\n\n \"rulemsiRcvXmsg\",\n\n \"rulemsiSendXmsg\",\n\n \"rulemsiXmsgCreateStream\",\n\n \"rulemsiXmsgServerConnect\",\n\n \"rulemsiXmsgServerDisConnect\",\n\n \"rulereadXMsg\",\n\n \"rulewriteXMsg\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- XMSG\"\n\n return False\n\n\n\n # FTP\n\n names_to_skip = [\n\n \"rulemsiFtpGet\",\n\n \"rulemsiTwitterPost\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- FTP\"\n\n return False\n\n\n\n # webservices\n\n names_to_skip = [\n\n \"rulemsiConvertCurrency\",\n\n \"rulemsiGetQuote\",\n\n \"rulemsiIp2location\",\n\n \"rulemsiObjByName\",\n\n \"rulemsiSdssImgCutout_GetJpeg\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- webservices\"\n\n return False\n\n\n\n # XML\n\n names_to_skip = [\n\n \"rulemsiLoadMetadataFromXml\",\n\n \"rulemsiXmlDocSchemaValidate\",\n\n \"rulemsiXsltApply\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- XML\"\n\n return False\n\n\n\n # transition to core microservices only\n\n names_to_skip = [\n\n \"rulemsiAddKeyVal.r\",\n\n \"rulemsiApplyDCMetadataTemplate.r\",\n\n \"rulemsiAssociateKeyValuePairsToObj.r\",\n\n \"rulemsiCollectionSpider.r\",\n\n \"rulemsiCopyAVUMetadata.r\",\n\n \"rulemsiExportRecursiveCollMeta.r\",\n\n \"rulemsiFlagDataObjwithAVU.r\",\n\n \"rulemsiGetCollectionACL.r\",\n\n \"rulemsiGetCollectionContentsReport.r\",\n\n \"rulemsiGetCollectionPSmeta.r\",\n\n \"rulemsiGetCollectionSize.r\",\n\n \"rulemsiGetDataObjACL.r\",\n\n \"rulemsiGetDataObjAIP.r\",\n\n \"rulemsiGetDataObjAVUs.r\",\n\n \"rulemsiGetDataObjPSmeta.r\",\n\n \"rulemsiGetObjectPath.r\",\n\n \"rulemsiGetUserACL.r\",\n\n \"rulemsiGetUserInfo.r\",\n\n \"rulemsiGuessDataType.r\",\n\n \"rulemsiIsColl.r\",\n\n \"rulemsiIsData.r\",\n\n \"rulemsiLoadACLFromDataObj.r\",\n\n \"rulemsiLoadMetadataFromDataObj.r\",\n\n \"rulemsiLoadUserModsFromDataObj.r\",\n\n \"rulemsiPropertiesAdd.r\",\n\n \"rulemsiPropertiesClear.r\",\n\n \"rulemsiPropertiesClone.r\",\n\n \"rulemsiPropertiesExists.r\",\n\n \"rulemsiPropertiesFromString.r\",\n\n \"rulemsiPropertiesGet.r\",\n\n \"rulemsiPropertiesNew.r\",\n\n \"rulemsiPropertiesRemove.r\",\n\n \"rulemsiPropertiesSet.r\",\n\n \"rulemsiRecursiveCollCopy.r\",\n\n \"rulemsiRemoveKeyValuePairsFromObj.r\",\n\n \"rulemsiSetDataType.r\",\n\n \"rulemsiString2KeyValPair.r\",\n\n \"rulemsiStripAVUs.r\",\n\n \"rulemsiStructFileBundle.r\",\n\n \"rulewriteKeyValPairs.r\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- transition to core\"\n\n return False\n\n\n\n # skipping rules requiring additional .re files in community code\n\n names_to_skip = [\n\n \"rulemsiAdmAddAppRuleStruct.r\",\n\n \"rulemsiAdmClearAppRuleStruct.r\",\n\n \"rulemsiAdmInsertRulesFromStructIntoDB.r\",\n\n \"rulemsiAdmReadRulesFromFileIntoStruct.r\",\n\n \"rulemsiAdmRetrieveRulesFromDBIntoStruct.r\",\n\n \"rulemsiAdmWriteRulesFromStructIntoFile.r\",\n\n ]\n\n for n in names_to_skip:\n\n if n in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- community\"\n\n return False\n\n\n\n # skipping for now, not sure why it's throwing a stacktrace at the moment\n\n if \"rulemsiPropertiesToString\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- b/c of stacktrace\"\n\n return False\n\n\n\n # misc / other\n\n if \"ruleintegrity\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- integrityChecks\"\n\n return False\n\n if \"z3950\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- z3950\"\n\n return False\n\n if \"rulemsiImage\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- image\"\n\n return False\n\n if \"rulemsiRda\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- RDA\"\n\n return False\n\n if \"rulemsiCollRepl\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- deprecated\"\n\n return False\n\n if \"rulemsiTarFileExtract\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- CAT_NO_ROWS_FOUND - failed in\n\n # call to getDataObjInfoIncSpecColl\"\n\n return False\n\n if \"rulemsiDataObjRsync\" in rulefile:\n\n # print \"skipping \" + rulefile + \" ----- tested separately\"\n\n return False\n\n\n\n return True\n\n\n\n for rulefile in filter(filter_rulefiles, sorted(os.listdir(rules30dir))):\n\n def make_test(rulefile):\n\n def test(self):\n\n self.rods_session.assert_icommand(\"icd\")\n\n self.rods_session.assert_icommand(\"irule -vF \" + rules30dir + rulefile,\n\n \"STDOUT\", \"completed successfully\")\n\n return test\n\n\n", "file_path": "tests/pydevtest/test_allrules.py", "rank": 23, "score": 75301.76127958545 }, { "content": "class Test_ilsresc(lib.make_sessions_mixin([('otherrods', 'pass')], []), unittest.TestCase):\n\n width = 300\n\n max_depth = 100\n\n filename = 'resourcetree.json'\n\n\n\n def setUp(self):\n\n super(Test_ilsresc, self).setUp()\n\n make_resource_tree.main(self.width, self.max_depth)\n\n\n\n def tearDown(self):\n\n cleanup_resource_tree.main(self.filename)\n\n super(Test_ilsresc, self).tearDown()\n\n\n\n def test_ilsresc_tree(self):\n\n self.admin_sessions[0].assert_icommand('ilsresc --tree', 'STDOUT', 'resc')\n\n\n\n def test_ilsresc_tree_with_ascii_output(self):\n", "file_path": "tests/pydevtest/test_resource_tree.py", "rank": 24, "score": 75301.76127958545 }, { "content": " def test_irsync_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # testing irsync\n\n self.admin.assert_icommand(\"irsync \" + progname + \" i:\" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest/foo100 \" + dir_w + \"/foo100\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest/foo100 i:\" + irodshome + \"/icmdtest/foo200\")\n\n self.admin.assert_icommand(\"irm -f \" + irodshome + \"/icmdtest/foo100 \" + irodshome + \"/icmdtest/foo200\")\n\n self.admin.assert_icommand(\"iput -R \" + self.testresc + \" \" + progname + \" \" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"irsync \" + progname + \" i:\" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"iput -R \" + self.testresc + \" \" + progname + \" \" + irodshome + \"/icmdtest/foo200\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest/foo100 i:\" + irodshome + \"/icmdtest/foo200\")\n\n os.unlink(dir_w + \"/foo100\")\n\n\n\n # cleanup\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 25, "score": 75301.76127958545 }, { "content": "class ChunkyDevTest(ResourceBase):\n\n\n\n def test_beginning_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtest\")\n\n\n\n # test basic informational commands\n\n self.admin.assert_icommand(\"iinit -l\", 'STDOUT', self.admin.username)\n\n self.admin.assert_icommand(\"iinit -l\", 'STDOUT', self.admin.zone_name)\n\n self.admin.assert_icommand(\"iinit -l\", 'STDOUT', self.admin.default_resource)\n\n res = self.admin.run_icommand(['ils', '-V'])\n\n assert res[1].count('irods_host') == 1\n\n assert res[1].count('irods_port') == 1\n\n assert res[1].count('irods_default_resource') == 1\n\n\n\n # begin original devtest\n\n self.admin.assert_icommand(\"ilsresc\", 'STDOUT', self.testresc)\n\n self.admin.assert_icommand(\"ilsresc -l\", 'STDOUT', self.testresc)\n\n self.admin.assert_icommand(\"imiscsvrinfo\", 'STDOUT', [\"relVersion\"])\n\n self.admin.assert_icommand(\"iuserinfo\", 'STDOUT', \"name: \" + username)\n\n self.admin.assert_icommand(\"ienv\", 'STDOUT', \"irods_zone\")\n\n self.admin.assert_icommand(\"ipwd\", 'STDOUT', \"home\")\n\n self.admin.assert_icommand(\"ihelp ils\", 'STDOUT', \"ils\")\n\n self.admin.assert_icommand(\"ierror -14000\", 'STDOUT', \"SYS_API_INPUT_ERR\")\n\n self.admin.assert_icommand(\"iexecmd hello\", 'STDOUT', \"Hello world\")\n\n self.admin.assert_icommand(\"ips -v\", 'STDOUT', \"ips\")\n\n self.admin.assert_icommand(\"iqstat\", 'STDOUT', \"No delayed rules pending for user \" + self.admin.username)\n\n\n\n # put and list basic file information\n\n self.admin.assert_icommand(\"ils -AL\", 'STDOUT', \"home\") # debug\n\n self.admin.assert_icommand(\"iput -K --wlock \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ichksum -f \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', \"performed = 1\")\n\n self.admin.assert_icommand(\"iput -kf \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"foo1\", myssize])\n\n self.admin.assert_icommand(\"iadmin ls \" + irodshome + \"/icmdtest\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"ils -A \" + irodshome + \"/icmdtest/foo1\",\n\n 'STDOUT', username + \"#\" + irodszone + \":own\")\n\n self.admin.assert_icommand(\"ichmod read \" + testuser1 + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils -A \" + irodshome + \"/icmdtest/foo1\",\n\n 'STDOUT', testuser1 + \"#\" + irodszone + \":read\")\n\n # basic replica\n\n self.admin.assert_icommand(\"irepl -B -R \" + self.testresc + \" --rlock \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', self.testresc)\n\n\n\n # overwrite a copy\n\n self.admin.assert_icommand(\"itrim -S \" + irodsdefresource + \" -N1 \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand_fail(\"ils -L \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [irodsdefresource])\n\n self.admin.assert_icommand(\"iphymv -R \" + irodsdefresource + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', irodsdefresource[0:19])\n\n # basic metadata shuffle\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest/foo1 testmeta1 180 cm\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"testmeta1\"])\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"180\"])\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"cm\"])\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/foo1 \" + irodshome + \"/icmdtest/foo2\")\n\n\n\n # test imeta -v\n\n imeta_popen = subprocess.Popen(\n\n 'echo \"ls -d ' + irodshome + '/icmdtest/foo1\" | imeta -v', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)\n\n imeta_output, imeta_err = imeta_popen.communicate()\n\n assert imeta_output.find('testmeta1') > -1\n\n assert imeta_output.find('180') > -1\n\n assert imeta_output.find('cm') > -1\n\n\n\n # new file mode check\n\n self.admin.assert_icommand(\"iget -fK --rlock \" + irodshome + \"/icmdtest/foo2 /tmp/\")\n\n assert oct(stat.S_IMODE(os.stat(\"/tmp/foo2\").st_mode)) == '0640'\n\n os.unlink(\"/tmp/foo2\")\n\n\n\n self.admin.assert_icommand(\"ils \" + irodshome + \"/icmdtest/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest/foo2 \" + irodshome + \"/icmdtest/foo4\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo4\", 'STDOUT', \"foo4\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest/foo4 \" + irodshome + \"/icmdtest/foo2\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"ichksum \" + irodshome + \"/icmdtest/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest/foo2 testmeta1 180 cm\")\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest/foo1 testmeta2 hello\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"testmeta1\"])\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"hello\"])\n\n self.admin.assert_icommand(\"imeta qu -d testmeta1 = 180\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"imeta qu -d testmeta2 = hello\", 'STDOUT', \"dataObj: foo1\")\n\n self.admin.assert_icommand(\"iget -f -K --rlock \" + irodshome + \"/icmdtest/foo2 \" + dir_w)\n\n assert myssize == str(os.stat(dir_w + \"/foo2\").st_size)\n\n os.unlink(dir_w + \"/foo2\")\n\n\n\n # we have foo1 in $irodsdefresource and foo2 in testresource\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n\n\n def test_iput_ibun_gzip_bzip2_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n with lib.make_session_for_existing_admin() as rods_admin:\n\n rods_admin.assert_icommand(['ichmod', 'own', self.admin.username, '/' + self.admin.zone_name])\n\n\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory containing 20 small files\n\n if not os.path.isdir(mysdir):\n\n os.mkdir(mysdir)\n\n for i in range(20):\n\n mysfile = mysdir + \"/sfile\" + str(i)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # we put foo1 in $irodsdefresource and foo2 in testresource\n\n self.admin.assert_icommand(\"iput -K --wlock \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/foo1 \" + irodshome + \"/icmdtest/foo2\")\n\n\n\n self.admin.assert_icommand(\"irepl -B -R \" + self.testresc + \" \" + irodshome + \"/icmdtest/foo1\")\n\n phypath = dir_w + \"/\" + \"foo1.\" + str(random.randrange(10000000))\n\n self.admin.assert_icommand(\"iput -kfR \" + irodsdefresource + \" \" + sfile2 + \" \" + irodshome + \"/icmdtest/foo1\")\n\n # show have 2 different copies\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"foo1\", myssize])\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\",\n\n 'STDOUT', [\"foo1\", str(os.stat(sfile2).st_size)])\n\n # update all old copies\n\n self.admin.assert_icommand(\"irepl -U \" + irodshome + \"/icmdtest/foo1\")\n\n # make sure the old size is not there\n\n self.admin.assert_icommand_fail(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', myssize)\n\n self.admin.assert_icommand(\"itrim -S \" + irodsdefresource + \" \" + irodshome + \"/icmdtest/foo1\")\n\n # bulk test\n\n self.admin.assert_icommand(\"iput -bIvPKr \" + mysdir + \" \" + irodshome + \"/icmdtest\", 'STDOUT', \"Bulk upload\")\n\n # iput with a lot of options\n\n rsfile = dir_w + \"/rsfile\"\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"iput -PkITr -X \" + rsfile + \" --retries 10 \" +\n\n mysdir + \" \" + irodshome + \"/icmdtestw\", 'STDOUT', \"Processing\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestw \" + irodshome + \"/icmdtestw1\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestw1\", 'STDOUT', \"sfile10\")\n\n self.admin.assert_icommand(\"ils -Ar \" + irodshome + \"/icmdtestw1\", 'STDOUT', \"sfile10\")\n\n self.admin.assert_icommand(\"irm -rvf \" + irodshome + \"/icmdtestw1\", 'STDOUT', \"num files done\")\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"iget -vIKPfr -X rsfile --retries 10 \" +\n\n irodshome + \"/icmdtest \" + dir_w + \"/testx\", 'STDOUT', \"opened\")\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n commands.getstatusoutput(\"tar -chf \" + dir_w + \"/testx.tar -C \" + dir_w + \"/testx .\")\n\n self.admin.assert_icommand(\"iput \" + dir_w + \"/testx.tar \" + irodshome + \"/icmdtestx.tar\")\n\n self.admin.assert_icommand(\"ibun -x \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtestx\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestx\", 'STDOUT', [\"foo2\"])\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestx\", 'STDOUT', [\"sfile10\"])\n\n self.admin.assert_icommand(\"ibun -cDtar \" + irodshome + \"/icmdtestx1.tar \" + irodshome + \"/icmdtestx\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtestx1.tar\", 'STDOUT', \"testx1.tar\")\n\n if os.path.exists(dir_w + \"/testx1\"):\n\n shutil.rmtree(dir_w + \"/testx1\")\n\n os.mkdir(dir_w + \"/testx1\")\n\n if os.path.isfile(dir_w + \"/testx1.tar\"):\n\n os.unlink(dir_w + \"/testx1.tar\")\n\n self.admin.assert_icommand(\"iget \" + irodshome + \"/icmdtestx1.tar \" + dir_w + \"/testx1.tar\")\n\n commands.getstatusoutput(\"tar -xvf \" + dir_w + \"/testx1.tar -C \" + dir_w + \"/testx1\")\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testx \" + dir_w + \"/testx1/icmdtestx\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n\n\n # test ibun with gzip\n\n self.admin.assert_icommand(\"ibun -cDgzip \" + irodshome + \"/icmdtestx1.tar.gz \" + irodshome + \"/icmdtestx\")\n\n self.admin.assert_icommand(\"ibun -x \" + irodshome + \"/icmdtestx1.tar.gz \" + irodshome + \"/icmdtestgz\")\n\n if os.path.isfile(\"icmdtestgz\"):\n\n os.unlink(\"icmdtestgz\")\n\n self.admin.assert_icommand(\"iget -vr \" + irodshome + \"/icmdtestgz \" + dir_w + \"\", 'STDOUT', \"icmdtestgz\")\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testx \" + dir_w + \"/icmdtestgz/icmdtestx\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/icmdtestgz\")\n\n self.admin.assert_icommand(\"ibun --add \" + irodshome + \"/icmdtestx1.tar.gz \" + irodshome + \"/icmdtestgz\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestx1.tar.gz \" + irodshome + \"/icmdtestgz\")\n\n\n\n # test ibun with bzip2\n\n self.admin.assert_icommand(\"ibun -cDbzip2 \" + irodshome + \"/icmdtestx1.tar.bz2 \" + irodshome + \"/icmdtestx\")\n\n self.admin.assert_icommand(\"ibun -xb \" + irodshome + \"/icmdtestx1.tar.bz2 \" + irodshome + \"/icmdtestbz2\")\n\n if os.path.isfile(\"icmdtestbz2\"):\n\n os.unlink(\"icmdtestbz2\")\n\n self.admin.assert_icommand(\"iget -vr \" + irodshome + \"/icmdtestbz2 \" + dir_w + \"\", 'STDOUT', \"icmdtestbz2\")\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testx \" + dir_w + \"/icmdtestbz2/icmdtestx\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/icmdtestbz2\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestx1.tar.bz2\")\n\n self.admin.assert_icommand(\"iphybun -R \" + self.anotherresc + \" -Dbzip2 \" + irodshome + \"/icmdtestbz2\")\n\n self.admin.assert_icommand(\"itrim -N1 -S \" + self.testresc + \" -r \" + irodshome + \"/icmdtestbz2\", 'STDOUT', \"Total size trimmed\")\n\n self.admin.assert_icommand(\"itrim -N1 -S \" + irodsdefresource + \" -r \" + irodshome + \"/icmdtestbz2\", 'STDOUT', \"Total size trimmed\")\n\n\n\n # get the name of bundle file\n\n output = commands.getstatusoutput(\n\n \"ils -L \" + irodshome + \"/icmdtestbz2/icmdtestx/foo1 | tail -n1 | awk '{ print $NF }'\")\n\n print output[1]\n\n bunfile = output[1]\n\n self.admin.assert_icommand(\"ils --bundle \" + bunfile, 'STDOUT', \"Subfiles\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestbz2\")\n\n self.admin.assert_icommand(\"irm -f --empty \" + bunfile)\n\n\n\n # cleanup\n\n os.unlink(dir_w + \"/testx1.tar\")\n\n os.unlink(dir_w + \"/testx.tar\")\n\n shutil.rmtree(dir_w + \"/testx1\")\n\n shutil.rmtree(dir_w + \"/testx\")\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n if os.path.exists(mysdir):\n\n shutil.rmtree(mysdir)\n\n\n\n def test_ireg_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory containing 20 small files\n\n if not os.path.isdir(mysdir):\n\n os.mkdir(mysdir)\n\n for i in range(20):\n\n mysfile = mysdir + \"/sfile\" + str(i)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n commands.getstatusoutput(\"mv \" + sfile2 + \" /tmp/sfile2\")\n\n commands.getstatusoutput(\"cp /tmp/sfile2 /tmp/sfile2r\")\n\n # <-- FAILING - REASON FOR SKIPPING\n\n self.admin.assert_icommand(\"ireg -KR \" + self.testresc + \" /tmp/sfile2 \" + irodshome + \"/foo5\")\n\n commands.getstatusoutput(\"cp /tmp/sfile2 /tmp/sfile2r\")\n\n self.admin.assert_icommand(\"ireg -KR \" + self.anotherresc + \" --repl /tmp/sfile2r \" + irodshome + \"/foo5\")\n\n self.admin.assert_icommand(\"iget -fK \" + irodshome + \"/foo5 \" + dir_w + \"/foo5\")\n\n output = commands.getstatusoutput(\"diff /tmp/sfile2 \" + dir_w + \"/foo5\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"ireg -KCR \" + self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtesta\")\n\n if os.path.exists(dir_w + \"/testa\"):\n\n shutil.rmtree(dir_w + \"/testa\")\n\n self.admin.assert_icommand(\"iget -fvrK \" + irodshome + \"/icmdtesta \" + dir_w + \"/testa\", 'STDOUT', \"testa\")\n\n output = commands.getstatusoutput(\"diff -r \" + mysdir + \" \" + dir_w + \"/testa\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/testa\")\n\n # test ireg with normal user\n\n testuser2home = \"/\" + irodszone + \"/home/\" + self.user1.username\n\n commands.getstatusoutput(\"cp /tmp/sfile2 /tmp/sfile2c\")\n\n self.user1.assert_icommand(\"ireg -KR \" + self.testresc + \" /tmp/sfile2c \" +\n\n testuser2home + \"/foo5\", 'STDERR', \"PATH_REG_NOT_ALLOWED\")\n\n self.user1.assert_icommand(\"iput -R \" + self.testresc + \" /tmp/sfile2c \" + testuser2home + \"/foo5\")\n\n self.user1.assert_icommand(\"irm -f \" + testuser2home + \"/foo5\")\n\n\n\n # cleanup\n\n os.unlink(\"/tmp/sfile2c\")\n\n os.unlink(dir_w + \"/foo5\")\n\n\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n if os.path.exists(mysdir):\n\n shutil.rmtree(mysdir)\n\n\n\n def test_mcoll_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n\n\n # make a directory containing 20 small files\n\n if not os.path.isdir(mysdir):\n\n os.mkdir(mysdir)\n\n for i in range(20):\n\n mysfile = mysdir + \"/sfile\" + str(i)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n # we put foo1 in $irodsdefresource and foo2 in testresource\n\n self.admin.assert_icommand(\"iput -K --wlock \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/foo1 \" + irodshome + \"/icmdtest/foo2\")\n\n\n\n # prepare icmdtesta\n\n self.admin.assert_icommand(\"ireg -KCR \" + self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtesta\")\n\n\n\n # mcoll test\n\n self.admin.assert_icommand(\"imcoll -m link \" + irodshome + \"/icmdtesta \" + irodshome + \"/icmdtestb\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestb\", 'STDOUT', \"icmdtestb\")\n\n if os.path.exists(dir_w + \"/testb\"):\n\n shutil.rmtree(dir_w + \"/testb\")\n\n self.admin.assert_icommand(\"iget -fvrK \" + irodshome + \"/icmdtestb \" + dir_w + \"/testb\", 'STDOUT', \"testb\")\n\n output = commands.getstatusoutput(\"diff -r \" + mysdir + \" \" + dir_w + \"/testb\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestb\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestb\")\n\n shutil.rmtree(dir_w + \"/testb\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestm\")\n\n self.admin.assert_icommand(\"imcoll -m filesystem -R \" +\n\n self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtestm\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestm/testmm\")\n\n self.admin.assert_icommand(\"iput \" + progname + \" \" + irodshome + \"/icmdtestm/testmm/foo1\")\n\n self.admin.assert_icommand(\"iput \" + progname + \" \" + irodshome + \"/icmdtestm/testmm/foo11\")\n\n self.admin.assert_icommand(\"imv \" + irodshome +\n\n \"/icmdtestm/testmm/foo1 \" + irodshome + \"/icmdtestm/testmm/foo2\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestm/testmm \" + irodshome + \"/icmdtestm/testmm1\")\n\n\n\n # mv to normal collection\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestm/testmm1/foo2 \" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo100\", 'STDOUT', \"foo100\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestm/testmm1 \" + irodshome + \"/icmdtest/testmm1\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtest/testmm1\", 'STDOUT', \"foo11\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtest/testmm1 \" + irodshome + \"/icmdtest/foo100\")\n\n if os.path.exists(dir_w + \"/testm\"):\n\n shutil.rmtree(dir_w + \"/testm\")\n\n self.admin.assert_icommand(\"iget -fvrK \" + irodshome + \"/icmdtesta \" + dir_w + \"/testm\", 'STDOUT', \"testm\")\n\n output = commands.getstatusoutput(\"diff -r \" + mysdir + \" \" + dir_w + \"/testm\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestm\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestm\")\n\n shutil.rmtree(dir_w + \"/testm\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_mcol\")\n\n # added so icmdtestx.tar exists\n\n self.admin.assert_icommand(\"ibun -c \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtest\")\n\n self.admin.assert_icommand(\"imcoll -m tar \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtestt_mcol\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestt_mcol\", 'STDOUT', [\"foo2\"])\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestt_mcol\", 'STDOUT', [\"foo1\"])\n\n if os.path.exists(dir_w + \"/testt\"):\n\n shutil.rmtree(dir_w + \"/testt\")\n\n if os.path.exists(dir_w + \"/testx\"):\n\n shutil.rmtree(dir_w + \"/testx\")\n\n self.admin.assert_icommand(\"iget -vr \" + irodshome + \"/icmdtest \" + dir_w + \"/testx\", 'STDOUT', \"testx\")\n\n self.admin.assert_icommand(\"iget -vr \" + irodshome +\n\n \"/icmdtestt_mcol/icmdtest \" + dir_w + \"/testt\", 'STDOUT', \"testt\")\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testx \" + dir_w + \"/testt\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_mcol/mydirtt\")\n\n self.admin.assert_icommand(\"iput \" + progname + \" \" + irodshome + \"/icmdtestt_mcol/mydirtt/foo1mt\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestt_mcol/mydirtt/foo1mt \" +\n\n irodshome + \"/icmdtestt_mcol/mydirtt/foo1mtx\")\n\n\n\n # unlink\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestt_mcol\")\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n shutil.rmtree(dir_w + \"/testt\")\n\n shutil.rmtree(dir_w + \"/testx\")\n\n if os.path.exists(mysdir):\n\n shutil.rmtree(mysdir)\n\n\n\n def test_large_dir_and_mcoll_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # we put foo1 in $irodsdefresource and foo2 in testresource\n\n self.admin.assert_icommand(\"iput -K --wlock \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/foo1 \" + irodshome + \"/icmdtest/foo2\")\n\n\n\n # added so icmdtestx.tar exists\n\n self.admin.assert_icommand(\"ibun -c \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtest\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imcoll -m tar \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_large/mydirtt\")\n\n\n\n # make a directory of 2 large files and 2 small files\n\n lfile = dir_w + \"/lfile\"\n\n lfile1 = dir_w + \"/lfile1\"\n\n commands.getstatusoutput(\"echo 012345678901234567890123456789012345678901234567890123456789012 > \" + lfile)\n\n for i in range(6):\n\n commands.getstatusoutput(\"cat \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile +\n\n \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" > \" + lfile1)\n\n os.rename(lfile1, lfile)\n\n os.mkdir(myldir)\n\n for i in range(1, 3):\n\n mylfile = myldir + \"/lfile\" + str(i)\n\n mysfile = myldir + \"/sfile\" + str(i)\n\n if i != 2:\n\n shutil.copyfile(lfile, mylfile)\n\n else:\n\n os.rename(lfile, mylfile)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # test adding a large file to a mounted collection\n\n self.admin.assert_icommand(\"iput \" + myldir + \"/lfile1 \" + irodshome + \"/icmdtestt_large/mydirtt\")\n\n self.admin.assert_icommand(\"iget \" + irodshome + \"/icmdtestt_large/mydirtt/lfile1 \" + dir_w + \"/testt\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestt_large/mydirtt\")\n\n self.admin.assert_icommand(\"imcoll -s \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imcoll -p \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestt_large\")\n\n os.unlink(dir_w + \"/testt\")\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n\n\n def test_phybun_from_devtest(self):\n\n with lib.make_session_for_existing_admin() as rods_admin:\n\n rods_admin.run_icommand(['ichmod', 'own', self.admin.username, '/' + self.admin.zone_name])\n\n\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory containing 20 small files\n\n if not os.path.isdir(mysdir):\n\n os.mkdir(mysdir)\n\n for i in range(20):\n\n mysfile = mysdir + \"/sfile\" + str(i)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # iphybun test\n\n self.admin.assert_icommand(\"iput -rR \" + self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtestp\")\n\n self.admin.assert_icommand(\"iphybun -KR \" + self.anotherresc + \" \" + irodshome + \"/icmdtestp\")\n\n self.admin.assert_icommand(\"itrim -rS \" + self.testresc + \" -N1 \" +\n\n irodshome + \"/icmdtestp\", 'STDOUT', \"files trimmed\")\n\n output = commands.getstatusoutput(\"ils -L \" + irodshome + \"/icmdtestp/sfile1 | tail -n1 | awk '{ print $NF }'\")\n\n print output[1]\n\n bunfile = output[1]\n\n self.admin.assert_icommand(\"irepl --purgec -R \" + self.anotherresc + \" \" + bunfile)\n\n self.admin.assert_icommand(\"itrim -rS \" + self.testresc + \" -N1 \" +\n\n irodshome + \"/icmdtestp\", 'STDOUT', \"files trimmed\")\n\n # get the name of bundle file\n\n self.admin.assert_icommand(\"irm -f --empty \" + bunfile)\n\n # should not be able to remove it because it is not empty\n\n self.admin.assert_icommand(\"ils \" + bunfile, 'STDOUT', bunfile)\n\n self.admin.assert_icommand(\"irm -rvf \" + irodshome + \"/icmdtestp\", 'STDOUT', \"num files done\")\n\n self.admin.assert_icommand(\"irm -f --empty \" + bunfile)\n\n if os.path.exists(dir_w + \"/testp\"):\n\n shutil.rmtree(dir_w + \"/testp\")\n\n shutil.rmtree(mysdir)\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n if os.path.exists(mysdir):\n\n shutil.rmtree(mysdir)\n\n\n\n def test_irsync_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # testing irsync\n\n self.admin.assert_icommand(\"irsync \" + progname + \" i:\" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest/foo100 \" + dir_w + \"/foo100\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest/foo100 i:\" + irodshome + \"/icmdtest/foo200\")\n\n self.admin.assert_icommand(\"irm -f \" + irodshome + \"/icmdtest/foo100 \" + irodshome + \"/icmdtest/foo200\")\n\n self.admin.assert_icommand(\"iput -R \" + self.testresc + \" \" + progname + \" \" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"irsync \" + progname + \" i:\" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"iput -R \" + self.testresc + \" \" + progname + \" \" + irodshome + \"/icmdtest/foo200\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest/foo100 i:\" + irodshome + \"/icmdtest/foo200\")\n\n os.unlink(dir_w + \"/foo100\")\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n\n\n def test_xml_protocol_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n lrsfile = dir_w + \"/lrsfile\"\n\n rsfile = dir_w + \"/rsfile\"\n\n\n\n # do test using xml protocol\n\n os.environ['irodsProt'] = \"1\"\n\n self.admin.assert_icommand(\"ilsresc\", 'STDOUT', self.testresc)\n\n self.admin.assert_icommand(\"imiscsvrinfo\", 'STDOUT', \"relVersion\")\n\n self.admin.assert_icommand(\"iuserinfo\", 'STDOUT', \"name: \" + username)\n\n self.admin.assert_icommand(\"ienv\", 'STDOUT', \"Release Version\")\n\n self.admin.assert_icommand(\"icd \" + irodshome)\n\n self.admin.assert_icommand(\"ipwd\", 'STDOUT', \"home\")\n\n self.admin.assert_icommand(\"ihelp ils\", 'STDOUT', \"ils\")\n\n self.admin.assert_icommand(\"ierror -14000\", 'STDOUT', \"SYS_API_INPUT_ERR\")\n\n self.admin.assert_icommand(\"iexecmd hello\", 'STDOUT', \"Hello world\")\n\n self.admin.assert_icommand(\"ips -v\", 'STDOUT', \"ips\")\n\n self.admin.assert_icommand(\"iqstat\", 'STDOUT', \"No delayed rules\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtest1\")\n\n # make a directory of large files\n\n self.admin.assert_icommand(\"iput -kf \" + progname + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', [\"foo1\", myssize])\n\n self.admin.assert_icommand(\"iadmin ls \" + irodshome + \"/icmdtest1\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"ichmod read \" + self.user0.username + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"ils -A \" + irodshome + \"/icmdtest1/foo1\",\n\n 'STDOUT', self.user0.username + \"#\" + irodszone + \":read\")\n\n self.admin.assert_icommand(\"irepl -B -R \" + self.testresc + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n # overwrite a copy\n\n self.admin.assert_icommand(\"itrim -S \" + irodsdefresource + \" -N1 \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"iphymv -R \" + irodsdefresource + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest1/foo1 testmeta1 180 cm\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', \"testmeta1\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', \"180\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', \"cm\")\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest1/foo1 \" + irodshome + \"/icmdtest1/foo2\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest1/foo2 \" + irodshome + \"/icmdtest1/foo4\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest1/foo4 \" + irodshome + \"/icmdtest1/foo2\")\n\n self.admin.assert_icommand(\"ichksum -K \" + irodshome + \"/icmdtest1/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"iget -f -K \" + irodshome + \"/icmdtest1/foo2 \" + dir_w)\n\n os.unlink(dir_w + \"/foo2\")\n\n self.admin.assert_icommand(\"irsync \" + progname + \" i:\" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest1/foo1 /tmp/foo1\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest1/foo1 i:\" + irodshome + \"/icmdtest1/foo2\")\n\n os.unlink(\"/tmp/foo1\")\n\n os.environ['irodsProt'] = \"0\"\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n\n\n def test_large_files_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory of 2 large files and 2 small files\n\n lfile = dir_w + \"/lfile\"\n\n lfile1 = dir_w + \"/lfile1\"\n\n commands.getstatusoutput(\"echo 012345678901234567890123456789012345678901234567890123456789012 > \" + lfile)\n\n for i in range(6):\n\n commands.getstatusoutput(\"cat \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile +\n\n \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" > \" + lfile1)\n\n os.rename(lfile1, lfile)\n\n os.mkdir(myldir)\n\n for i in range(1, 3):\n\n mylfile = myldir + \"/lfile\" + str(i)\n\n mysfile = myldir + \"/sfile\" + str(i)\n\n if i != 2:\n\n shutil.copyfile(lfile, mylfile)\n\n else:\n\n os.rename(lfile, mylfile)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # do the large files tests\n\n lrsfile = dir_w + \"/lrsfile\"\n\n rsfile = dir_w + \"/rsfile\"\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"iput -vbPKr --retries 10 --wlock -X \" + rsfile + \" --lfrestart \" +\n\n lrsfile + \" -N 2 \" + myldir + \" \" + irodshome + \"/icmdtest/testy\", 'STDOUT', \"New restartFile\")\n\n self.admin.assert_icommand(\"ichksum -rK \" + irodshome + \"/icmdtest/testy\", 'STDOUT', \"Total checksum performed\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"irepl -BvrPT -R \" + self.testresc + \" --rlock \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"icmdtest/testy\")\n\n self.admin.assert_icommand(\"itrim -vrS \" + irodsdefresource + \" --dryrun --age 1 -N 1 \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"This is a DRYRUN\")\n\n self.admin.assert_icommand(\"itrim -vrS \" + irodsdefresource + \" -N 1 \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"a copy trimmed\")\n\n self.admin.assert_icommand(\"icp -vKPTr -N 2 \" + irodshome + \"/icmdtest/testy \" +\n\n irodshome + \"/icmdtest/testz\", 'STDOUT', \"Processing lfile1\")\n\n self.admin.assert_icommand(\"irsync -r i:\" + irodshome + \"/icmdtest/testy i:\" + irodshome + \"/icmdtest/testz\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testy\")\n\n self.admin.assert_icommand(\"iphymv -vrS \" + irodsdefresource + \" -R \" +\n\n self.testresc + \" \" + irodshome + \"/icmdtest/testz\", 'STDOUT', \"icmdtest/testz\")\n\n\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n if os.path.exists(dir_w + \"/testz\"):\n\n shutil.rmtree(dir_w + \"/testz\")\n\n self.admin.assert_icommand(\"iget -vPKr --retries 10 -X \" + rsfile + \" --lfrestart \" + lrsfile +\n\n \" --rlock -N 2 \" + irodshome + \"/icmdtest/testz \" + dir_w + \"/testz\", 'STDOUT', \"testz\")\n\n self.admin.assert_icommand(\"irsync -r \" + dir_w + \"/testz i:\" + irodshome + \"/icmdtest/testz\")\n\n self.admin.assert_icommand(\"irsync -r i:\" + irodshome + \"/icmdtest/testz \" + dir_w + \"/testz\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testz \" + myldir)\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n # test -N0 transfer\n\n self.admin.assert_icommand(\"iput -N0 -R \" + self.testresc + \" \" +\n\n myldir + \"/lfile1 \" + irodshome + \"/icmdtest/testz/lfoo100\")\n\n if os.path.isfile(dir_w + \"/lfoo100\"):\n\n os.unlink(dir_w + \"/lfoo100\")\n\n self.admin.assert_icommand(\"iget -N0 \" + irodshome + \"/icmdtest/testz/lfoo100 \" + dir_w + \"/lfoo100\")\n\n output = commands.getstatusoutput(\"diff \" + myldir + \"/lfile1 \" + dir_w + \"/lfoo100\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/testz\")\n\n os.unlink(dir_w + \"/lfoo100\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testz\")\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n\n\n def test_large_files_with_RBUDP_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory of 2 large files and 2 small files\n\n lfile = dir_w + \"/lfile\"\n\n lfile1 = dir_w + \"/lfile1\"\n\n commands.getstatusoutput(\"echo 012345678901234567890123456789012345678901234567890123456789012 > \" + lfile)\n\n for i in range(6):\n\n commands.getstatusoutput(\"cat \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile +\n\n \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" > \" + lfile1)\n\n os.rename(lfile1, lfile)\n\n os.mkdir(myldir)\n\n for i in range(1, 3):\n\n mylfile = myldir + \"/lfile\" + str(i)\n\n mysfile = myldir + \"/sfile\" + str(i)\n\n if i != 2:\n\n shutil.copyfile(lfile, mylfile)\n\n else:\n\n os.rename(lfile, mylfile)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # do the large files tests using RBUDP\n\n lrsfile = dir_w + \"/lrsfile\"\n\n rsfile = dir_w + \"/rsfile\"\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"iput -vQPKr --retries 10 -X \" + rsfile + \" --lfrestart \" +\n\n lrsfile + \" \" + myldir + \" \" + irodshome + \"/icmdtest/testy\", 'STDOUT', \"icmdtest/testy\")\n\n self.admin.assert_icommand(\"irepl -BQvrPT -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"icmdtest/testy\")\n\n self.admin.assert_icommand(\"itrim -vrS \" + irodsdefresource + \" -N 1 \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"a copy trimmed\")\n\n self.admin.assert_icommand(\"icp -vQKPTr \" + irodshome + \"/icmdtest/testy \" +\n\n irodshome + \"/icmdtest/testz\", 'STDOUT', \"Processing sfile1\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testy\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n if os.path.exists(dir_w + \"/testz\"):\n\n shutil.rmtree(dir_w + \"/testz\")\n\n self.admin.assert_icommand(\"iget -vQPKr --retries 10 -X \" + rsfile + \" --lfrestart \" + lrsfile +\n\n \" \" + irodshome + \"/icmdtest/testz \" + dir_w + \"/testz\", 'STDOUT', \"Processing sfile2\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testz \" + myldir)\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/testz\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testz\")\n\n shutil.rmtree(myldir)\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 26, "score": 75301.76127958545 }, { "content": " def test_mcoll_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n\n\n # make a directory containing 20 small files\n\n if not os.path.isdir(mysdir):\n\n os.mkdir(mysdir)\n\n for i in range(20):\n\n mysfile = mysdir + \"/sfile\" + str(i)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n # we put foo1 in $irodsdefresource and foo2 in testresource\n\n self.admin.assert_icommand(\"iput -K --wlock \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/foo1 \" + irodshome + \"/icmdtest/foo2\")\n\n\n\n # prepare icmdtesta\n\n self.admin.assert_icommand(\"ireg -KCR \" + self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtesta\")\n\n\n\n # mcoll test\n\n self.admin.assert_icommand(\"imcoll -m link \" + irodshome + \"/icmdtesta \" + irodshome + \"/icmdtestb\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestb\", 'STDOUT', \"icmdtestb\")\n\n if os.path.exists(dir_w + \"/testb\"):\n\n shutil.rmtree(dir_w + \"/testb\")\n\n self.admin.assert_icommand(\"iget -fvrK \" + irodshome + \"/icmdtestb \" + dir_w + \"/testb\", 'STDOUT', \"testb\")\n\n output = commands.getstatusoutput(\"diff -r \" + mysdir + \" \" + dir_w + \"/testb\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestb\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestb\")\n\n shutil.rmtree(dir_w + \"/testb\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestm\")\n\n self.admin.assert_icommand(\"imcoll -m filesystem -R \" +\n\n self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtestm\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestm/testmm\")\n\n self.admin.assert_icommand(\"iput \" + progname + \" \" + irodshome + \"/icmdtestm/testmm/foo1\")\n\n self.admin.assert_icommand(\"iput \" + progname + \" \" + irodshome + \"/icmdtestm/testmm/foo11\")\n\n self.admin.assert_icommand(\"imv \" + irodshome +\n\n \"/icmdtestm/testmm/foo1 \" + irodshome + \"/icmdtestm/testmm/foo2\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestm/testmm \" + irodshome + \"/icmdtestm/testmm1\")\n\n\n\n # mv to normal collection\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestm/testmm1/foo2 \" + irodshome + \"/icmdtest/foo100\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo100\", 'STDOUT', \"foo100\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestm/testmm1 \" + irodshome + \"/icmdtest/testmm1\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtest/testmm1\", 'STDOUT', \"foo11\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtest/testmm1 \" + irodshome + \"/icmdtest/foo100\")\n\n if os.path.exists(dir_w + \"/testm\"):\n\n shutil.rmtree(dir_w + \"/testm\")\n\n self.admin.assert_icommand(\"iget -fvrK \" + irodshome + \"/icmdtesta \" + dir_w + \"/testm\", 'STDOUT', \"testm\")\n\n output = commands.getstatusoutput(\"diff -r \" + mysdir + \" \" + dir_w + \"/testm\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestm\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestm\")\n\n shutil.rmtree(dir_w + \"/testm\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_mcol\")\n\n # added so icmdtestx.tar exists\n\n self.admin.assert_icommand(\"ibun -c \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtest\")\n\n self.admin.assert_icommand(\"imcoll -m tar \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtestt_mcol\")\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestt_mcol\", 'STDOUT', [\"foo2\"])\n\n self.admin.assert_icommand(\"ils -lr \" + irodshome + \"/icmdtestt_mcol\", 'STDOUT', [\"foo1\"])\n\n if os.path.exists(dir_w + \"/testt\"):\n\n shutil.rmtree(dir_w + \"/testt\")\n\n if os.path.exists(dir_w + \"/testx\"):\n\n shutil.rmtree(dir_w + \"/testx\")\n\n self.admin.assert_icommand(\"iget -vr \" + irodshome + \"/icmdtest \" + dir_w + \"/testx\", 'STDOUT', \"testx\")\n\n self.admin.assert_icommand(\"iget -vr \" + irodshome +\n\n \"/icmdtestt_mcol/icmdtest \" + dir_w + \"/testt\", 'STDOUT', \"testt\")\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testx \" + dir_w + \"/testt\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_mcol/mydirtt\")\n\n self.admin.assert_icommand(\"iput \" + progname + \" \" + irodshome + \"/icmdtestt_mcol/mydirtt/foo1mt\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtestt_mcol/mydirtt/foo1mt \" +\n\n irodshome + \"/icmdtestt_mcol/mydirtt/foo1mtx\")\n\n\n\n # unlink\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestt_mcol\")\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n shutil.rmtree(dir_w + \"/testt\")\n\n shutil.rmtree(dir_w + \"/testx\")\n\n if os.path.exists(mysdir):\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 27, "score": 75301.76127958545 }, { "content": " def test_ireg_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory containing 20 small files\n\n if not os.path.isdir(mysdir):\n\n os.mkdir(mysdir)\n\n for i in range(20):\n\n mysfile = mysdir + \"/sfile\" + str(i)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n commands.getstatusoutput(\"mv \" + sfile2 + \" /tmp/sfile2\")\n\n commands.getstatusoutput(\"cp /tmp/sfile2 /tmp/sfile2r\")\n\n # <-- FAILING - REASON FOR SKIPPING\n\n self.admin.assert_icommand(\"ireg -KR \" + self.testresc + \" /tmp/sfile2 \" + irodshome + \"/foo5\")\n\n commands.getstatusoutput(\"cp /tmp/sfile2 /tmp/sfile2r\")\n\n self.admin.assert_icommand(\"ireg -KR \" + self.anotherresc + \" --repl /tmp/sfile2r \" + irodshome + \"/foo5\")\n\n self.admin.assert_icommand(\"iget -fK \" + irodshome + \"/foo5 \" + dir_w + \"/foo5\")\n\n output = commands.getstatusoutput(\"diff /tmp/sfile2 \" + dir_w + \"/foo5\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n self.admin.assert_icommand(\"ireg -KCR \" + self.testresc + \" \" + mysdir + \" \" + irodshome + \"/icmdtesta\")\n\n if os.path.exists(dir_w + \"/testa\"):\n\n shutil.rmtree(dir_w + \"/testa\")\n\n self.admin.assert_icommand(\"iget -fvrK \" + irodshome + \"/icmdtesta \" + dir_w + \"/testa\", 'STDOUT', \"testa\")\n\n output = commands.getstatusoutput(\"diff -r \" + mysdir + \" \" + dir_w + \"/testa\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/testa\")\n\n # test ireg with normal user\n\n testuser2home = \"/\" + irodszone + \"/home/\" + self.user1.username\n\n commands.getstatusoutput(\"cp /tmp/sfile2 /tmp/sfile2c\")\n\n self.user1.assert_icommand(\"ireg -KR \" + self.testresc + \" /tmp/sfile2c \" +\n\n testuser2home + \"/foo5\", 'STDERR', \"PATH_REG_NOT_ALLOWED\")\n\n self.user1.assert_icommand(\"iput -R \" + self.testresc + \" /tmp/sfile2c \" + testuser2home + \"/foo5\")\n\n self.user1.assert_icommand(\"irm -f \" + testuser2home + \"/foo5\")\n\n\n\n # cleanup\n\n os.unlink(\"/tmp/sfile2c\")\n\n os.unlink(dir_w + \"/foo5\")\n\n\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n if os.path.exists(mysdir):\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 28, "score": 75301.76127958545 }, { "content": "class RegisteredTestResult(unittest.TextTestResult):\n\n def __init__(self, *args, **kwargs):\n\n super(RegisteredTestResult, self).__init__(*args, **kwargs)\n\n unittest.registerResult(self)\n\n\n\n def startTest(self, test):\n\n # TextTestResult's impl prints as \"test (module.class)\" which prevents copy/paste\n\n print('{0} ... '.format(test.id()), end='', file=self.stream)\n", "file_path": "tests/pydevtest/run_tests.py", "rank": 29, "score": 75301.76127958545 }, { "content": " def test_beginning_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtest\")\n\n\n\n # test basic informational commands\n\n self.admin.assert_icommand(\"iinit -l\", 'STDOUT', self.admin.username)\n\n self.admin.assert_icommand(\"iinit -l\", 'STDOUT', self.admin.zone_name)\n\n self.admin.assert_icommand(\"iinit -l\", 'STDOUT', self.admin.default_resource)\n\n res = self.admin.run_icommand(['ils', '-V'])\n\n assert res[1].count('irods_host') == 1\n\n assert res[1].count('irods_port') == 1\n\n assert res[1].count('irods_default_resource') == 1\n\n\n\n # begin original devtest\n\n self.admin.assert_icommand(\"ilsresc\", 'STDOUT', self.testresc)\n\n self.admin.assert_icommand(\"ilsresc -l\", 'STDOUT', self.testresc)\n\n self.admin.assert_icommand(\"imiscsvrinfo\", 'STDOUT', [\"relVersion\"])\n\n self.admin.assert_icommand(\"iuserinfo\", 'STDOUT', \"name: \" + username)\n\n self.admin.assert_icommand(\"ienv\", 'STDOUT', \"irods_zone\")\n\n self.admin.assert_icommand(\"ipwd\", 'STDOUT', \"home\")\n\n self.admin.assert_icommand(\"ihelp ils\", 'STDOUT', \"ils\")\n\n self.admin.assert_icommand(\"ierror -14000\", 'STDOUT', \"SYS_API_INPUT_ERR\")\n\n self.admin.assert_icommand(\"iexecmd hello\", 'STDOUT', \"Hello world\")\n\n self.admin.assert_icommand(\"ips -v\", 'STDOUT', \"ips\")\n\n self.admin.assert_icommand(\"iqstat\", 'STDOUT', \"No delayed rules pending for user \" + self.admin.username)\n\n\n\n # put and list basic file information\n\n self.admin.assert_icommand(\"ils -AL\", 'STDOUT', \"home\") # debug\n\n self.admin.assert_icommand(\"iput -K --wlock \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ichksum -f \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', \"performed = 1\")\n\n self.admin.assert_icommand(\"iput -kf \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"foo1\", myssize])\n\n self.admin.assert_icommand(\"iadmin ls \" + irodshome + \"/icmdtest\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"ils -A \" + irodshome + \"/icmdtest/foo1\",\n\n 'STDOUT', username + \"#\" + irodszone + \":own\")\n\n self.admin.assert_icommand(\"ichmod read \" + testuser1 + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils -A \" + irodshome + \"/icmdtest/foo1\",\n\n 'STDOUT', testuser1 + \"#\" + irodszone + \":read\")\n\n # basic replica\n\n self.admin.assert_icommand(\"irepl -B -R \" + self.testresc + \" --rlock \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', self.testresc)\n\n\n\n # overwrite a copy\n\n self.admin.assert_icommand(\"itrim -S \" + irodsdefresource + \" -N1 \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand_fail(\"ils -L \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [irodsdefresource])\n\n self.admin.assert_icommand(\"iphymv -R \" + irodsdefresource + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', irodsdefresource[0:19])\n\n # basic metadata shuffle\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest/foo1 testmeta1 180 cm\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"testmeta1\"])\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"180\"])\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"cm\"])\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/foo1 \" + irodshome + \"/icmdtest/foo2\")\n\n\n\n # test imeta -v\n\n imeta_popen = subprocess.Popen(\n\n 'echo \"ls -d ' + irodshome + '/icmdtest/foo1\" | imeta -v', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)\n\n imeta_output, imeta_err = imeta_popen.communicate()\n\n assert imeta_output.find('testmeta1') > -1\n\n assert imeta_output.find('180') > -1\n\n assert imeta_output.find('cm') > -1\n\n\n\n # new file mode check\n\n self.admin.assert_icommand(\"iget -fK --rlock \" + irodshome + \"/icmdtest/foo2 /tmp/\")\n\n assert oct(stat.S_IMODE(os.stat(\"/tmp/foo2\").st_mode)) == '0640'\n\n os.unlink(\"/tmp/foo2\")\n\n\n\n self.admin.assert_icommand(\"ils \" + irodshome + \"/icmdtest/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest/foo2 \" + irodshome + \"/icmdtest/foo4\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo4\", 'STDOUT', \"foo4\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest/foo4 \" + irodshome + \"/icmdtest/foo2\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"ichksum \" + irodshome + \"/icmdtest/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest/foo2 testmeta1 180 cm\")\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest/foo1 testmeta2 hello\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"testmeta1\"])\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest/foo1\", 'STDOUT', [\"hello\"])\n\n self.admin.assert_icommand(\"imeta qu -d testmeta1 = 180\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"imeta qu -d testmeta2 = hello\", 'STDOUT', \"dataObj: foo1\")\n\n self.admin.assert_icommand(\"iget -f -K --rlock \" + irodshome + \"/icmdtest/foo2 \" + dir_w)\n\n assert myssize == str(os.stat(dir_w + \"/foo2\").st_size)\n\n os.unlink(dir_w + \"/foo2\")\n\n\n\n # we have foo1 in $irodsdefresource and foo2 in testresource\n\n\n\n # cleanup\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 30, "score": 75301.76127958545 }, { "content": "def run_fastswap_test():\n", "file_path": "tests/pydevtest/run_tests.py", "rank": 31, "score": 75301.76127958545 }, { "content": "def run_tests_from_names(names, buffer_test_output):\n\n loader = unittest.TestLoader()\n\n suites = [loader.loadTestsFromName(name) for name in names]\n\n super_suite = unittest.TestSuite(suites)\n\n runner = unittest.TextTestRunner(verbosity=2, failfast=True, buffer=buffer_test_output, resultclass=RegisteredTestResult)\n\n results = runner.run(super_suite)\n", "file_path": "tests/pydevtest/run_tests.py", "rank": 32, "score": 75301.76127958545 }, { "content": "#include \"Hasher.hpp\"\n\n#include \"MD5Strategy.hpp\"\n\n#include \"SHA256Strategy.hpp\"\n\n#include \"irods_hasher_factory.hpp\"\n\n\n\n#include <string>\n\n#include <iostream>\n\n#include <fstream>\n\n\n\nusing namespace std;\n\nusing namespace irods;\n\n\n\nvoid\n\ngenerateHash(\n\n const char* filename ) {\n\n // Create hasher\n\n Hasher md5_hasher;\n\n Hasher sha_hasher;\n\n getHasher( MD5_NAME, md5_hasher );\n\n getHasher( SHA256_NAME, sha_hasher );\n", "file_path": "tests/registry/HasherTest.cpp", "rank": 33, "score": 74796.38205189724 }, { "content": " }\n\n}\n\n\n\nint\n\nmain(\n\n int argc,\n\n char* argv[] ) {\n\n int result = 0;\n\n if ( argc != 2 ) {\n\n cerr << \"ERROR: wrong number of arguments: \" << argc << endl;\n\n cerr << \"ERROR: filename must be specified\" << endl;\n\n result = 1;\n\n }\n\n else {\n\n generateHash( argv[1] );\n\n }\n\n return result;\n\n}\n", "file_path": "tests/registry/HasherTest.cpp", "rank": 34, "score": 74795.58368962389 }, { "content": "\n\n // Read the file and hash it\n\n ifstream input( filename, ios_base::in | ios_base::binary );\n\n if ( input.is_open() ) {\n\n char buffer[1024];\n\n while ( !input.eof() ) {\n\n input.read( buffer, 1023 );\n\n int numRead = input.gcount();\n\n md5_hasher.update( std::string( buffer, numRead ) );\n\n sha_hasher.update( std::string( buffer, numRead ) );\n\n }\n\n input.close();\n\n string messageDigest;\n\n md5_hasher.digest( messageDigest );\n\n cout << messageDigest << endl;\n\n sha_hasher.digest( messageDigest );\n\n cout << messageDigest << endl;\n\n }\n\n else {\n\n cerr << \"ERROR: Unable to open file: \" << filename << endl;\n", "file_path": "tests/registry/HasherTest.cpp", "rank": 35, "score": 74792.44010157023 }, { "content": " def test_pause_and_resume(self):\n\n # test pause\n\n lib.assert_command('irods-grid pause --all', 'STDOUT', 'pausing')\n\n\n\n # need a time-out assert icommand for ils here\n\n\n\n # resume the server\n\n lib.assert_command('irods-grid resume --all', 'STDOUT', 'resuming')\n\n\n\n # Make sure server is actually responding\n\n lib.assert_command('ils', 'STDOUT', lib.get_service_account_environment_file_contents()['irods_zone'])\n", "file_path": "tests/pydevtest/test_control_plane.py", "rank": 36, "score": 74491.09050883328 }, { "content": "class Test_Random_Resource(ChunkyDevTest, ResourceSuite, unittest.TestCase):\n\n def setUp(self):\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin modresc demoResc name origResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n admin_session.assert_icommand(\"iadmin mkresc demoResc random\", 'STDOUT', 'random')\n\n admin_session.assert_icommand(\"iadmin mkresc unix1Resc 'unixfilesystem' \" + configuration.HOSTNAME_1 + \":\" + lib.get_irods_top_level_dir() + \"/unix1RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin mkresc unix2Resc 'unixfilesystem' \" + configuration.HOSTNAME_2 + \":\" + lib.get_irods_top_level_dir() + \"/unix2RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin mkresc unix3Resc 'unixfilesystem' \" + configuration.HOSTNAME_3 + \":\" + lib.get_irods_top_level_dir() + \"/unix3RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix2Resc\")\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix3Resc\")\n\n super(Test_Random_Resource, self).setUp()\n\n\n\n def tearDown(self):\n\n super(Test_Random_Resource, self).tearDown()\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix3Resc\")\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix2Resc\")\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix3Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix2Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc demoResc\")\n\n admin_session.assert_icommand(\"iadmin modresc origResc name demoResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix1RescVault\", ignore_errors=True)\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix2RescVault\", ignore_errors=True)\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix3RescVault\", ignore_errors=True)\n\n\n\n @unittest.skip(\"EMPTY_RESC_PATH - no vault path for coordinating resources\")\n\n def test_ireg_as_rodsuser_in_vault(self):\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 37, "score": 74491.09050883328 }, { "content": " def test_irodsFs(self):\n\n # =-=-=-=-=-=-=-\n\n # set up a fuse mount\n\n mount_point = \"fuse_mount_point\"\n\n\n\n if not os.path.isdir(mount_point):\n\n os.mkdir(mount_point)\n\n os.system(\"irodsFs \" + mount_point)\n\n\n\n # =-=-=-=-=-=-=-\n\n # put some test data\n\n cmd = \"iput README foo0\"\n\n output = commands.getstatusoutput(cmd)\n\n\n\n # =-=-=-=-=-=-=-\n\n # see if the data object is actually in the mount point\n\n # using the system ls\n\n cmd = \"ls -l \" + mount_point\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"mount ls results [\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"foo0\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # use system copy to put some data into the mount mount\n\n # and verify that it shows up in the ils\n\n cmd = \"cp README \" + mount_point + \"/baz ; ils -l baz\"\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"baz\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # now irm the file and verify that it is not visible\n\n # via the fuse mount\n\n cmd = \"irm -f baz ; ils -l baz\"\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"baz does not exist\"))\n\n\n\n output = commands.getstatusoutput(\"ls -l \" + mount_point)\n\n out_str = str(output)\n\n print(\"mount ls results [\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"foo0\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # now rm the foo0 file and then verify it doesnt show\n\n # up in the ils\n\n cmd = \"rm \" + mount_point + \"/foo0; ils -l foo0\"\n\n print(\"cmd: [\" + cmd + \"]\")\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"foo0 does not exist\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # now run bonnie++ and then verify it reports a summary\n\n if (os.path.isfile(\"/usr/sbin/bonnie++\")):\n\n # ubuntu and centos\n\n bonniecmd = \"/usr/sbin/bonnie++\"\n\n else:\n\n # suse\n\n bonniecmd = \"/usr/bin/bonnie++\"\n\n cmd = bonniecmd + \" -r 1024 -d \" + mount_point\n\n print(\"cmd: [\" + cmd + \"]\")\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--\"))\n\n assert(-1 != out_str.find(\"-Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--\"))\n\n\n\n # tear down the fuse mount\n\n os.system(\"fusermount -uz \" + mount_point)\n\n if os.path.isdir(mount_point):\n", "file_path": "tests/pydevtest/test_fuse_suite.py", "rank": 38, "score": 74491.09050883328 }, { "content": "class TestControlPlane(unittest.TestCase):\n\n def test_pause_and_resume(self):\n\n # test pause\n\n lib.assert_command('irods-grid pause --all', 'STDOUT', 'pausing')\n\n\n\n # need a time-out assert icommand for ils here\n\n\n\n # resume the server\n\n lib.assert_command('irods-grid resume --all', 'STDOUT', 'resuming')\n\n\n\n # Make sure server is actually responding\n\n lib.assert_command('ils', 'STDOUT', lib.get_service_account_environment_file_contents()['irods_zone'])\n\n lib.assert_command('irods-grid status --all', 'STDOUT', 'hosts')\n\n\n\n def test_status(self):\n\n # test grid status\n\n lib.assert_command('irods-grid status --all', 'STDOUT', 'hosts')\n\n\n\n @unittest.skipIf(configuration.RUN_IN_TOPOLOGY, 'Skip for Topology Testing: No way to restart grid')\n\n def test_shutdown(self):\n\n # test shutdown\n\n lib.assert_command('irods-grid shutdown --all', 'STDOUT', 'shutting down')\n\n time.sleep( 2 )\n\n lib.assert_command('ils', 'STDERR', 'USER_SOCK_CONNECT_ERR')\n\n\n", "file_path": "tests/pydevtest/test_control_plane.py", "rank": 39, "score": 74491.09050883328 }, { "content": " def test_ilsresc_tree(self):\n", "file_path": "tests/pydevtest/test_resource_tree.py", "rank": 40, "score": 74491.09050883328 }, { "content": " def test_iscan_local_file(self):\n\n self.user0.assert_icommand('iscan non_existent_file', 'STDERR', 'ERROR: scanObj: non_existent_file does not exist' )\n\n existent_file = os.path.join( self.user0.local_session_dir, 'existent_file' )\n\n lib.touch( existent_file )\n\n self.user0.assert_icommand('iscan ' + existent_file, 'STDOUT', existent_file + ' is not registered in iRODS' )\n\n self.user0.assert_icommand('iput ' + existent_file );\n\n output = self.user0.run_icommand('''iquest \"SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'\"''' )[1]\n\n data_path = output.strip().strip('-').strip()[12:]\n\n self.user0.assert_icommand('iscan ' + data_path );\n", "file_path": "tests/pydevtest/test_iscan.py", "rank": 41, "score": 74491.09050883328 }, { "content": " def test_iput_with_purgec(self):\n\n # local setup\n\n filename = \"purgecfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'w') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n # put file, but trim 'cache' copy (purgec) (backwards compatibility)\n\n self.admin.assert_icommand(\"iput --purgec \" + filename)\n\n # should not be listed (trimmed first replica)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n # should be listed twice - replica 2 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename])\n\n # should be listed twice - replica 3 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename])\n\n\n\n # local cleanup\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 42, "score": 74491.09050883328 }, { "content": "class Test_Passthru_Resource(ChunkyDevTest, ResourceSuite, unittest.TestCase):\n\n def setUp(self):\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin modresc demoResc name origResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n admin_session.assert_icommand(\"iadmin mkresc demoResc passthru\", 'STDOUT', 'passthru')\n\n admin_session.assert_icommand(\"iadmin mkresc unix1Resc 'unixfilesystem' \" + configuration.HOSTNAME_1 + \":\" + lib.get_irods_top_level_dir() + \"/unix1RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix1Resc\")\n\n super(Test_Passthru_Resource, self).setUp()\n\n\n\n def tearDown(self):\n\n super(Test_Passthru_Resource, self).tearDown()\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc demoResc\")\n\n admin_session.assert_icommand(\"iadmin modresc origResc name demoResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix1RescVault\", ignore_errors=True)\n\n\n\n @unittest.skip(\"EMPTY_RESC_PATH - no vault path for coordinating resources\")\n\n def test_ireg_as_rodsuser_in_vault(self):\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 43, "score": 74491.09050883328 }, { "content": " def test_irepl_with_purgec(self):\n\n # local setup\n\n filename = \"purgecreplfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'wb') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" --purgec \" + filename) # replicate to test resource\n\n # should not be listed (trimmed)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename]) # should be listed 3x - 1 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename]) # should be listed 3x - 2 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 3 \", filename]) # should be listed 3x - 3 of 3\n\n\n\n # local cleanup\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 44, "score": 74491.09050883328 }, { "content": " def test_imv_r(self):\n\n base_name_source = \"test_imv_r_dir_source\"\n\n file_names = set(self.iput_r_large_collection(\n\n self.user0, base_name_source, file_count=1000, file_size=100)[1])\n\n\n\n base_name_target = \"test_imv_r_dir_target\"\n\n self.user0.assert_icommand(\"imv \" + base_name_source + \" \" + base_name_target, \"EMPTY\")\n\n self.user0.assert_icommand(\"ils \" + base_name_source, 'STDERR', \"does not exist\")\n\n self.user0.assert_icommand(\"ils\", 'STDOUT', base_name_target)\n\n rods_files_post_imv = set(lib.ils_output_to_entries(self.user0.run_icommand(['ils', base_name_target])[1]))\n\n self.assertTrue(file_names == rods_files_post_imv,\n\n msg=\"Files missing:\\n\" + str(file_names - rods_files_post_imv) + \"\\n\\n\" +\n\n \"Extra files:\\n\" + str(rods_files_post_imv - file_names))\n\n\n\n vault_files_post_irm_source = set(os.listdir(os.path.join(lib.get_vault_session_path(self.user0),\n\n base_name_source)))\n\n self.assertTrue(len(vault_files_post_irm_source) == 0)\n\n\n\n vault_files_post_irm_target = set(os.listdir(os.path.join(lib.get_vault_session_path(self.user0),\n\n base_name_target)))\n\n self.assertTrue(file_names == vault_files_post_irm_target,\n\n msg=\"Files missing from vault:\\n\" + str(file_names - vault_files_post_irm_target) + \"\\n\\n\" +\n", "file_path": "tests/pydevtest/test_icommands_file_operations.py", "rank": 45, "score": 74491.09050883328 }, { "content": " def test_fusermount_permissions(self):\n\n # Check that fusermount is configured correctly for irodsFs\n\n fusermount_path = distutils.spawn.find_executable('fusermount')\n\n assert fusermount_path is not None, 'fusermount binary not found'\n\n assert os.stat(fusermount_path).st_mode & stat.S_ISUID, 'fusermount setuid bit not set'\n\n p = subprocess.Popen(['fusermount -V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\n\n stdoutdata, stderrdata = p.communicate()\n\n assert p.returncode == 0, '\\n'.join(['fusermount not executable',\n\n 'return code: ' + str(p.returncode),\n\n 'stdout: ' + stdoutdata,\n", "file_path": "tests/pydevtest/test_fuse_suite.py", "rank": 46, "score": 74491.09050883328 }, { "content": " def test_mso_http(self):\n\n test_file_path = self.admin.session_collection\n\n self.admin.assert_icommand('ireg -D mso -R archiveResc \"//http://people.renci.org/~jasonc/irods/http_mso_test_file.txt\" ' +\n\n test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand('iget -f ' + test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand_fail('ils -L ' + test_file_path + '/test_file.txt', 'STDOUT', ' -99 ')\n\n os.remove('test_file.txt')\n\n # unregister the object\n\n self.admin.assert_icommand('irm -U ' + test_file_path + '/test_file.txt')\n", "file_path": "tests/pydevtest/test_mso_suite.py", "rank": 47, "score": 74491.09050883328 }, { "content": "def optparse_callback_topology_test(option, opt_str, value, parser):\n\n import configuration\n\n configuration.RUN_IN_TOPOLOGY = True\n\n configuration.TOPOLOGY_FROM_RESOURCE_SERVER = value == 'resource'\n\n configuration.HOSTNAME_1 = 'resource1.example.org'\n\n configuration.HOSTNAME_2 = 'resource2.example.org'\n\n configuration.HOSTNAME_3 = 'resource3.example.org'\n", "file_path": "tests/pydevtest/run_tests.py", "rank": 48, "score": 74491.09050883328 }, { "content": "class Test_Compound_Resource(ChunkyDevTest, ResourceSuite, unittest.TestCase):\n\n def setUp(self):\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin modresc demoResc name origResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n admin_session.assert_icommand(\"iadmin mkresc demoResc compound\", 'STDOUT', 'compound')\n\n admin_session.assert_icommand(\"iadmin mkresc cacheResc 'unixfilesystem' \" + configuration.HOSTNAME_1 + \":\" + lib.get_irods_top_level_dir() + \"/cacheRescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin mkresc archiveResc 'unixfilesystem' \" + configuration.HOSTNAME_1 + \":\" + lib.get_irods_top_level_dir() + \"/archiveRescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc cacheResc cache\")\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc archiveResc archive\")\n\n super(Test_Compound_Resource, self).setUp()\n\n\n\n def tearDown(self):\n\n super(Test_Compound_Resource, self).tearDown()\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc archiveResc\")\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc cacheResc\")\n\n admin_session.assert_icommand(\"iadmin rmresc archiveResc\")\n\n admin_session.assert_icommand(\"iadmin rmresc cacheResc\")\n\n admin_session.assert_icommand(\"iadmin rmresc demoResc\")\n\n admin_session.assert_icommand(\"iadmin modresc origResc name demoResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/archiveRescVault\", ignore_errors=True)\n\n shutil.rmtree(\"rm -rf \" + lib.get_irods_top_level_dir() + \"/cacheRescVault\", ignore_errors=True)\n\n\n\n def test_irm_specific_replica(self):\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', self.testfile) # should be listed\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + self.testfile) # creates replica\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', self.testfile) # should be listed twice\n\n self.admin.assert_icommand(\"irm -n 0 \" + self.testfile) # remove original from cacheResc only\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', [\"2 \" + self.testresc, self.testfile])\n\n self.admin.assert_icommand_fail(\"ils -L \" + self.testfile, 'STDOUT',\n\n [\"0 \" + self.admin.default_resource, self.testfile]) # replica 0 should be gone\n\n trashpath = \"/\" + self.admin.zone_name + \"/trash/home/\" + self.admin.username + \\\n\n \"/\" + self.admin._session_id\n\n self.admin.assert_icommand_fail(\"ils -L \" + trashpath + \"/\" + self.testfile, 'STDOUT',\n\n [\"0 \" + self.admin.default_resource, self.testfile]) # replica should not be in trash\n\n\n\n @unittest.skip(\"--wlock has possible race condition due to Compound/Replication PDMO\")\n\n def test_local_iput_collision_with_wlock(self):\n\n pass\n\n\n\n @unittest.skip(\"EMPTY_RESC_PATH - no vault path for coordinating resources\")\n\n def test_ireg_as_rodsuser_in_vault(self):\n\n pass\n\n\n\n @unittest.skip(\"TEMPORARY\")\n\n def test_iget_prefer_from_archive__ticket_1660(self):\n\n # define core.re filepath\n\n corefile = lib.get_irods_config_dir() + \"/core.re\"\n\n backupcorefile = corefile + \"--\" + self._testMethodName\n\n\n\n # new file to put and get\n\n filename = \"archivepolicyfile.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n\n\n # manipulate core.re (leave as 'when_necessary' - default)\n\n\n\n # put the file\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n\n\n # manually update the replica in archive vault\n\n output = self.admin.run_icommand('ils -L ' + filename)\n\n archivereplicaphypath = output[1].split()[-1] # split into tokens, get the last one\n\n with open(archivereplicaphypath, 'w') as f:\n\n f.write('MANUALLY UPDATED ON ARCHIVE\\n')\n\n # get file\n\n retrievedfile = \"retrieved.txt\"\n\n os.system(\"rm -f %s\" % retrievedfile)\n\n self.admin.assert_icommand(\"iget -f %s %s\" % (filename, retrievedfile)) # get file from cache\n\n\n\n # confirm retrieved file is same as original\n\n assert 0 == os.system(\"diff %s %s\" % (filepath, retrievedfile))\n\n\n\n # manipulate the core.re to add the new policy\n\n shutil.copy(corefile, backupcorefile)\n\n with open(corefile, 'a') as f:\n\n f.write('pep_resource_resolve_hierarchy_pre(*OUT){*OUT=\"compound_resource_cache_refresh_policy=always\";}\\n')\n\n\n\n # restart the server to reread the new core.re\n\n os.system(lib.get_irods_top_level_dir() + \"/iRODS/irodsctl stop\")\n\n os.system(lib.get_irods_top_level_dir() + \"/tests/zombiereaper.sh\")\n\n os.system(lib.get_irods_top_level_dir() + \"/iRODS/irodsctl start\")\n\n\n\n # manually update the replica in archive vault\n\n output = self.admin.run_icommand('ils -L ' + filename)\n\n archivereplicaphypath = output[1].split()[-1] # split into tokens, get the last one\n\n with open(archivereplicaphypath, 'w') as f:\n\n f.write('MANUALLY UPDATED ON ARCHIVE **AGAIN**\\n')\n\n\n\n # get the file\n\n self.admin.assert_icommand(\"iget -f %s %s\" % (filename, retrievedfile)) # get file from archive\n\n\n\n # confirm this is the new archive file\n\n matchfound = False\n\n with open(retrievedfile) as f:\n\n for line in f:\n\n if \"**AGAIN**\" in line:\n\n matchfound = True\n\n assert matchfound\n\n\n\n # restore the original core.re\n\n shutil.copy(backupcorefile, corefile)\n\n os.remove(backupcorefile)\n\n\n\n # local cleanup\n\n os.remove(filepath)\n\n os.remove(retrievedfile)\n\n\n\n def test_local_iput_with_force_and_destination_resource__ticket_1706(self):\n\n # local setup\n\n filename = \"iputwithforceanddestination.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n doublefile = \"doublefile.txt\"\n\n os.system(\"cat %s %s > %s\" % (filename, filename, doublefile))\n\n doublesize = str(os.stat(doublefile).st_size)\n\n # assertions\n\n # should not be listed\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\")\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n # replicate to test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # debugging\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename)\n\n # overwrite test repl with different data\n\n self.admin.assert_icommand(\"iput -f -R %s %s %s\" % (self.testresc, doublefile, filename))\n\n # default resource cache should have dirty copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" \" + filename])\n\n # default resource archive should have dirty copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" \" + filename])\n\n # default resource cache should not have doublesize file\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" \" + doublesize + \" \", \" \" + filename])\n\n # default resource archive should not have doublesize file\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" \" + doublesize + \" \", \" \" + filename])\n\n # targeted resource should have new double clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" \" + doublesize + \" \", \"& \" + filename])\n\n # local cleanup\n\n os.remove(filepath)\n\n os.remove(doublefile)\n\n\n\n ###################\n\n # irepl\n\n ###################\n\n\n\n def test_irepl_update_replicas(self):\n\n # local setup\n\n filename = \"updatereplicasfile.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n hostname = lib.get_hostname()\n\n hostuser = getpass.getuser()\n\n doublefile = \"doublefile.txt\"\n\n os.system(\"cat %s %s > %s\" % (filename, filename, doublefile))\n\n doublesize = str(os.stat(doublefile).st_size)\n\n\n\n # assertions\n\n self.admin.assert_icommand(\"iadmin mkresc thirdresc unixfilesystem %s:/tmp/%s/thirdrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create third resource\n\n self.admin.assert_icommand(\"iadmin mkresc fourthresc unixfilesystem %s:/tmp/%s/fourthrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create fourth resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n # replicate to test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # replicate to third resource\n\n self.admin.assert_icommand(\"irepl -R thirdresc \" + filename)\n\n # replicate to fourth resource\n\n self.admin.assert_icommand(\"irepl -R fourthresc \" + filename)\n\n # repave overtop test resource\n\n self.admin.assert_icommand(\"iput -f -R \" + self.testresc + \" \" + doublefile + \" \" + filename)\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irepl -U \" + filename) # update last replica\n\n\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irepl -aU \" + filename) # update all replicas\n\n\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irm -f \" + filename) # cleanup file\n\n self.admin.assert_icommand(\"iadmin rmresc thirdresc\") # remove third resource\n\n self.admin.assert_icommand(\"iadmin rmresc fourthresc\") # remove third resource\n\n\n\n # local cleanup\n\n os.remove(filepath)\n\n os.remove(doublefile)\n\n\n\n def test_irepl_over_existing_second_replica__ticket_1705(self):\n\n # local setup\n\n filename = \"secondreplicatest.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n # assertions\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput -R \" + self.testresc + \" \" + filename) # put file\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n # replicate to default resource\n\n self.admin.assert_icommand(\"irepl \" + filename)\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n # replicate overtop default resource\n\n self.admin.assert_icommand(\"irepl \" + filename)\n\n # should not have a replica 3\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # replicate overtop test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # should not have a replica 3\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # local cleanup\n\n os.remove(filepath)\n\n\n\n def test_irepl_over_existing_third_replica__ticket_1705(self):\n\n # local setup\n\n filename = \"thirdreplicatest.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n hostname = lib.get_hostname()\n\n hostuser = getpass.getuser()\n\n # assertions\n\n self.admin.assert_icommand(\"iadmin mkresc thirdresc unixfilesystem %s:/tmp/%s/thirdrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create third resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename) # replicate to test resource\n\n self.admin.assert_icommand(\"irepl -R thirdresc \" + filename) # replicate to third resource\n\n self.admin.assert_icommand(\"irepl \" + filename) # replicate overtop default resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename) # replicate overtop test resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n self.admin.assert_icommand(\"irepl -R thirdresc \" + filename) # replicate overtop third resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n # should not have a replica 4\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n # should not have a replica 5\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 5 \", \" & \" + filename])\n\n self.admin.assert_icommand(\"irm -f \" + filename) # cleanup file\n\n self.admin.assert_icommand(\"iadmin rmresc thirdresc\") # remove third resource\n\n # local cleanup\n\n os.remove(filepath)\n\n\n\n def test_irepl_over_existing_bad_replica__ticket_1705(self):\n\n # local setup\n\n filename = \"reploverwritebad.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n doublefile = \"doublefile.txt\"\n\n os.system(\"cat %s %s > %s\" % (filename, filename, doublefile))\n\n doublesize = str(os.stat(doublefile).st_size)\n\n # assertions\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename) # replicate to test resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n # overwrite default repl with different data\n\n self.admin.assert_icommand(\"iput -f %s %s\" % (doublefile, filename))\n\n # default resource cache should have clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # default resource cache should have new double clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" \" + doublesize + \" \", \" & \" + filename])\n\n # default resource archive should have clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # default resource archive should have new double clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" \" + doublesize + \" \", \" & \" + filename])\n\n # test resource should not have doublesize file\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT',\n\n [\" 2 \" + self.testresc, \" \" + doublesize + \" \", \" \" + filename])\n\n # replicate back onto test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # test resource should have new clean doublesize file\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT',\n\n [\" 2 \" + self.testresc, \" \" + doublesize + \" \", \" & \" + filename])\n\n # should not have a replica 3\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # local cleanup\n\n os.remove(filepath)\n\n os.remove(doublefile)\n\n\n\n def test_iput_with_purgec(self):\n\n # local setup\n\n filename = \"purgecfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'w') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n self.admin.assert_icommand(\"iput --purgec \" + filename) # put file\n\n # should not be listed (trimmed)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n # should be listed once - replica 1\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename])\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename]) # should be listed only once\n\n\n\n # local cleanup\n\n output = commands.getstatusoutput('rm ' + filepath)\n\n\n\n def test_iget_with_purgec(self):\n\n # local setup\n\n filename = \"purgecgetfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'w') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # should be listed\n\n self.admin.assert_icommand(\"iget -f --purgec \" + filename) # get file and purge 'cached' replica\n\n # should not be listed (trimmed)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename]) # should be listed once\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename]) # should not be listed\n\n\n\n # local cleanup\n\n output = commands.getstatusoutput('rm ' + filepath)\n\n\n\n def test_irepl_with_purgec(self):\n\n # local setup\n\n filename = \"purgecreplfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'w') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" --purgec \" + filename) # replicate to test resource\n\n # should not be listed (trimmed)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename]) # should be listed twice - 2 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename]) # should be listed twice - 1 of 3\n\n\n\n # local cleanup\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 49, "score": 74491.09050883328 }, { "content": "class Test_Replication_Resource(ChunkyDevTest, ResourceSuite, unittest.TestCase):\n\n def setUp(self):\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin modresc demoResc name origResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n admin_session.assert_icommand(\"iadmin mkresc demoResc replication\", 'STDOUT', 'replication')\n\n admin_session.assert_icommand(\"iadmin mkresc unix1Resc 'unixfilesystem' \" + configuration.HOSTNAME_1 + \":\" + lib.get_irods_top_level_dir() + \"/unix1RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin mkresc unix2Resc 'unixfilesystem' \" + configuration.HOSTNAME_2 + \":\" + lib.get_irods_top_level_dir() + \"/unix2RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin mkresc unix3Resc 'unixfilesystem' \" + configuration.HOSTNAME_3 + \":\" + lib.get_irods_top_level_dir() + \"/unix3RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix2Resc\")\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix3Resc\")\n\n super(Test_Replication_Resource, self).setUp()\n\n\n\n def tearDown(self):\n\n super(Test_Replication_Resource, self).tearDown()\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix3Resc\")\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix2Resc\")\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix3Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix2Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc demoResc\")\n\n admin_session.assert_icommand(\"iadmin modresc origResc name demoResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix1RescVault\", ignore_errors=True)\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix2RescVault\", ignore_errors=True)\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix3RescVault\", ignore_errors=True)\n\n\n\n def test_irm_specific_replica(self):\n\n # not allowed here - this is a managed replication resource\n\n # should be listed 3x\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', [\" 0 \", \" & \" + self.testfile])\n\n # should be listed 3x\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', [\" 1 \", \" & \" + self.testfile])\n\n # should be listed 3x\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', [\" 2 \", \" & \" + self.testfile])\n\n self.admin.assert_icommand(\"irm -n 1 \" + self.testfile) # try to remove one of the managed replicas\n\n # should be listed 2x\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', [\" 0 \", \" & \" + self.testfile])\n\n # should not be listed\n\n self.admin.assert_icommand_fail(\"ils -L \" + self.testfile, 'STDOUT', [\" 1 \", \" & \" + self.testfile])\n\n # should be listed 2x\n\n self.admin.assert_icommand(\"ils -L \" + self.testfile, 'STDOUT', [\" 2 \", \" & \" + self.testfile])\n\n\n\n @unittest.skip(\"--wlock has possible race condition due to Compound/Replication PDMO\")\n\n def test_local_iput_collision_with_wlock(self):\n\n pass\n\n\n\n @unittest.skip(\"EMPTY_RESC_PATH - no vault path for coordinating resources\")\n\n def test_ireg_as_rodsuser_in_vault(self):\n\n pass\n\n\n\n def test_reliable_iput__ticket_2557(self):\n\n # local setup\n\n # break the second child resource\n\n self.admin.assert_icommand(\"iadmin modresc unix2Resc path /nopes\", 'STDOUT', \"unix2RescVault\")\n\n filename = \"reliableputfile.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand_fail(\"iput \" + filename, 'STDOUT', \"put error\") # put file\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', \"unix1Resc\") # should be listed\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', \"unix3Resc\") # should be listed\n\n\n\n # cleanup\n\n oldvault = lib.get_irods_top_level_dir() + \"/unix2RescVault\"\n\n self.admin.assert_icommand(\"iadmin modresc unix2Resc path \" + oldvault, 'STDOUT', \"/nopes\")\n\n\n\n def test_local_iput_with_force_and_destination_resource__ticket_1706(self):\n\n # local setup\n\n filename = \"iputwithforceanddestination.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n doublefile = \"doublefile.txt\"\n\n os.system(\"cat %s %s > %s\" % (filename, filename, doublefile))\n\n doublesize = str(os.stat(doublefile).st_size)\n\n # assertions\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename) # replicate to test resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename)\n\n # overwrite test repl with different data\n\n self.admin.assert_icommand(\"iput -f -R %s %s %s\" % (self.testresc, doublefile, filename))\n\n # default resource should have dirty copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" \" + filename])\n\n # default resource should have dirty copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" \" + filename])\n\n # default resource should have dirty copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" \" + filename])\n\n # default resource should not have doublesize file\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" \" + doublesize + \" \", \" \" + filename])\n\n # default resource should not have doublesize file\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" \" + doublesize + \" \", \" \" + filename])\n\n # default resource should not have doublesize file\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" \" + doublesize + \" \", \" \" + filename])\n\n # targeted resource should have new double clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" \" + doublesize + \" \", \"& \" + filename])\n\n # local cleanup\n\n os.remove(filepath)\n\n os.remove(doublefile)\n\n\n\n def test_irepl_update_replicas(self):\n\n # local setup\n\n filename = \"updatereplicasfile.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n hostname = lib.get_hostname()\n\n hostuser = getpass.getuser()\n\n doublefile = \"doublefile.txt\"\n\n os.system(\"cat %s %s > %s\" % (filename, filename, doublefile))\n\n doublesize = str(os.stat(doublefile).st_size)\n\n\n\n # assertions\n\n self.admin.assert_icommand(\"iadmin mkresc thirdresc unixfilesystem %s:/tmp/%s/thirdrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create third resource\n\n self.admin.assert_icommand(\"iadmin mkresc fourthresc unixfilesystem %s:/tmp/%s/fourthrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create fourth resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n # replicate to test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # replicate to third resource\n\n self.admin.assert_icommand(\"irepl -R thirdresc \" + filename)\n\n # replicate to fourth resource\n\n self.admin.assert_icommand(\"irepl -R fourthresc \" + filename)\n\n # repave overtop test resource\n\n self.admin.assert_icommand(\"iput -f -R \" + self.testresc + \" \" + doublefile + \" \" + filename)\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand( \"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 5 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irepl -U \" + filename) # update last replica\n\n\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand( \"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand( \"ils -L \" + filename, 'STDOUT', [\" 5 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irepl -aU \" + filename) # update all replicas\n\n\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 5 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irm -f \" + filename) # cleanup file\n\n self.admin.assert_icommand(\"iadmin rmresc thirdresc\") # remove third resource\n\n self.admin.assert_icommand(\"iadmin rmresc fourthresc\") # remove third resource\n\n\n\n # local cleanup\n\n os.remove(filepath)\n\n os.remove(doublefile)\n\n\n\n def test_irepl_over_existing_second_replica__ticket_1705(self):\n\n # local setup\n\n filename = \"secondreplicatest.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n # assertions\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput -R \" + self.testresc + \" \" + filename) # put file\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n # replicate to default resource\n\n self.admin.assert_icommand(\"irepl \" + filename)\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n # replicate overtop default resource\n\n self.admin.assert_icommand(\"irepl \" + filename)\n\n # should not have a replica 3\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n # replicate overtop test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # should not have a replica 3\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n # local cleanup\n\n os.remove(filepath)\n\n\n\n def test_irepl_over_existing_third_replica__ticket_1705(self):\n\n # local setup\n\n filename = \"thirdreplicatest.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n hostname = lib.get_hostname()\n\n hostuser = getpass.getuser()\n\n # assertions\n\n self.admin.assert_icommand(\"iadmin mkresc thirdresc unixfilesystem %s:/tmp/%s/thirdrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create third resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename) # replicate to test resource\n\n self.admin.assert_icommand(\"irepl -R thirdresc \" + filename) # replicate to third resource\n\n self.admin.assert_icommand(\"irepl \" + filename) # replicate overtop default resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename) # replicate overtop test resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n self.admin.assert_icommand(\"irepl -R thirdresc \" + filename) # replicate overtop third resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n # should not have a replica 4\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 5 \", \" & \" + filename])\n\n # should not have a replica 5\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 6 \", \" & \" + filename])\n\n self.admin.assert_icommand(\"irm -f \" + filename) # cleanup file\n\n self.admin.assert_icommand(\"iadmin rmresc thirdresc\") # remove third resource\n\n # local cleanup\n\n os.remove(filepath)\n\n\n\n def test_irepl_over_existing_bad_replica__ticket_1705(self):\n\n # local setup\n\n filename = \"reploverwritebad.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n doublefile = \"doublefile.txt\"\n\n os.system(\"cat %s %s > %s\" % (filename, filename, doublefile))\n\n doublesize = str(os.stat(doublefile).st_size)\n\n # assertions\n\n # should not be listed\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\")\n\n # put file\n\n self.admin.assert_icommand(\"iput \" + filename)\n\n # for debugging\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename)\n\n # replicate to test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # for debugging\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename)\n\n # overwrite default repl with different data\n\n self.admin.assert_icommand(\"iput -f %s %s\" % (doublefile, filename))\n\n # default resource 1 should have clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # default resource 1 should have new double clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" \" + doublesize + \" \", \" & \" + filename])\n\n # default resource 2 should have clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # default resource 2 should have new double clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" \" + doublesize + \" \", \" & \" + filename])\n\n # default resource 3 should have clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # default resource 3 should have new double clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" \" + doublesize + \" \", \" & \" + filename])\n\n # test resource should not have doublesize file\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT',\n\n [\" 3 \" + self.testresc, \" \" + doublesize + \" \", \" \" + filename])\n\n # replicate back onto test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # test resource should have new clean doublesize file\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT',\n\n [\" 3 \" + self.testresc, \" \" + doublesize + \" \", \" & \" + filename])\n\n # should not have a replica 3\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n # local cleanup\n\n os.remove(filepath)\n\n os.remove(doublefile)\n\n\n\n def test_iput_with_purgec(self):\n\n # local setup\n\n filename = \"purgecfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'w') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n # put file, but trim 'cache' copy (purgec) (backwards compatibility)\n\n self.admin.assert_icommand(\"iput --purgec \" + filename)\n\n # should not be listed (trimmed first replica)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n # should be listed twice - replica 2 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename])\n\n # should be listed twice - replica 3 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename])\n\n\n\n # local cleanup\n\n output = commands.getstatusoutput('rm ' + filepath)\n\n\n\n def test_iget_with_purgec(self):\n\n # local setup\n\n filename = \"purgecgetfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'wb') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"iget -f --purgec \" + filename) # get file and purge 'cached' replica\n\n # should not be listed (trimmed)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename]) # should be listed twice - 2 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename]) # should be listed twice - 2 of 3\n\n\n\n # local cleanup\n\n output = commands.getstatusoutput('rm ' + filepath)\n\n\n\n def test_irepl_with_purgec(self):\n\n # local setup\n\n filename = \"purgecreplfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'wb') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" --purgec \" + filename) # replicate to test resource\n\n # should not be listed (trimmed)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename]) # should be listed 3x - 1 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename]) # should be listed 3x - 2 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 3 \", filename]) # should be listed 3x - 3 of 3\n\n\n\n # local cleanup\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 50, "score": 74491.09050883328 }, { "content": "class Test_ireg_Suite(resource_suite.ResourceBase, unittest.TestCase):\n\n def setUp(self):\n\n super(Test_ireg_Suite, self).setUp()\n\n shutil.copy2(ABSPATHTESTDIR + '/test_ireg_suite.py', ABSPATHTESTDIR + '/file0')\n\n shutil.copy2(ABSPATHTESTDIR + '/test_ireg_suite.py', ABSPATHTESTDIR + '/file1')\n\n shutil.copy2(ABSPATHTESTDIR + '/test_ireg_suite.py', ABSPATHTESTDIR + '/file2')\n\n shutil.copy2(ABSPATHTESTDIR + '/test_ireg_suite.py', ABSPATHTESTDIR + '/file3')\n\n\n\n self.admin.assert_icommand('iadmin mkresc r_resc passthru', 'STDOUT', \"Creating\")\n\n self.admin.assert_icommand('iadmin mkresc m_resc passthru', 'STDOUT', \"Creating\")\n\n hostname = socket.gethostname()\n\n self.admin.assert_icommand('iadmin mkresc l_resc unixfilesystem ' + hostname + ':/tmp/l_resc', 'STDOUT', \"Creating\")\n\n\n\n self.admin.assert_icommand(\"iadmin addchildtoresc r_resc m_resc\")\n\n self.admin.assert_icommand(\"iadmin addchildtoresc m_resc l_resc\")\n\n\n\n def tearDown(self):\n\n self.admin.assert_icommand('irm -f ' + self.admin.home_collection + '/file0')\n\n self.admin.assert_icommand('irm -f ' + self.admin.home_collection + '/file1')\n\n self.admin.assert_icommand('irm -f ' + self.admin.home_collection + '/file3')\n\n\n\n self.admin.assert_icommand(\"irmtrash -M\")\n\n self.admin.assert_icommand(\"iadmin rmchildfromresc m_resc l_resc\")\n\n self.admin.assert_icommand(\"iadmin rmchildfromresc r_resc m_resc\")\n\n\n\n self.admin.assert_icommand(\"iadmin rmresc r_resc\")\n\n self.admin.assert_icommand(\"iadmin rmresc m_resc\")\n\n self.admin.assert_icommand(\"iadmin rmresc l_resc\")\n\n\n\n os.remove(ABSPATHTESTDIR + '/file2')\n\n\n\n super(Test_ireg_Suite, self).tearDown()\n\n\n\n def test_ireg_files(self):\n\n self.admin.assert_icommand(\"ireg -R l_resc \" + ABSPATHTESTDIR + '/file0 ' + self.admin.home_collection + 'file0')\n\n self.admin.assert_icommand('ils -l ' + self.admin.home_collection + '/file0', 'STDOUT', \"r_resc;m_resc;l_resc\")\n\n\n\n self.admin.assert_icommand(\"ireg -R l_resc \" + ABSPATHTESTDIR + '/file1 ' + self.admin.home_collection + 'file1')\n\n self.admin.assert_icommand('ils -l ' + self.admin.home_collection + '/file1', 'STDOUT', \"r_resc;m_resc;l_resc\")\n\n\n\n self.admin.assert_icommand(\"ireg -R m_resc \" + ABSPATHTESTDIR +\n\n '/file2 ' + self.admin.home_collection + '/file2', 'STDERR', 'ERROR: regUtil: reg error for')\n\n\n", "file_path": "tests/pydevtest/test_ireg_suite.py", "rank": 51, "score": 74491.09050883328 }, { "content": " def test_iget_with_purgec(self):\n\n # local setup\n\n filename = \"purgecgetfile.txt\"\n\n filepath = os.path.abspath(filename)\n\n with open(filepath, 'wb') as f:\n\n f.write(\"TESTFILE -- [\" + filepath + \"]\")\n\n\n\n # assertions\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', filename) # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n self.admin.assert_icommand(\"iget -f --purgec \" + filename) # get file and purge 'cached' replica\n\n # should not be listed (trimmed)\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", filename])\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", filename]) # should be listed twice - 2 of 3\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", filename]) # should be listed twice - 2 of 3\n\n\n\n # local cleanup\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 52, "score": 74491.09050883328 }, { "content": " def test_irm_r(self):\n\n base_name = \"test_irm_r_dir\"\n\n self.iput_r_large_collection(self.user0, base_name, file_count=1000, file_size=100)\n\n\n\n self.user0.assert_icommand(\"irm -r \" + base_name, \"EMPTY\")\n\n self.user0.assert_icommand(\"ils \" + base_name, 'STDERR', \"does not exist\")\n\n\n\n vault_files_post_irm = os.listdir(os.path.join(lib.get_vault_session_path(self.user0),\n\n base_name))\n\n self.assertTrue(len(vault_files_post_irm) == 0,\n", "file_path": "tests/pydevtest/test_icommands_file_operations.py", "rank": 53, "score": 74491.09050883328 }, { "content": " def test_iput_r(self):\n", "file_path": "tests/pydevtest/test_icommands_file_operations.py", "rank": 54, "score": 74491.09050883328 }, { "content": " def test_large_files_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory of 2 large files and 2 small files\n\n lfile = dir_w + \"/lfile\"\n\n lfile1 = dir_w + \"/lfile1\"\n\n commands.getstatusoutput(\"echo 012345678901234567890123456789012345678901234567890123456789012 > \" + lfile)\n\n for i in range(6):\n\n commands.getstatusoutput(\"cat \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile +\n\n \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" > \" + lfile1)\n\n os.rename(lfile1, lfile)\n\n os.mkdir(myldir)\n\n for i in range(1, 3):\n\n mylfile = myldir + \"/lfile\" + str(i)\n\n mysfile = myldir + \"/sfile\" + str(i)\n\n if i != 2:\n\n shutil.copyfile(lfile, mylfile)\n\n else:\n\n os.rename(lfile, mylfile)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # do the large files tests\n\n lrsfile = dir_w + \"/lrsfile\"\n\n rsfile = dir_w + \"/rsfile\"\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"iput -vbPKr --retries 10 --wlock -X \" + rsfile + \" --lfrestart \" +\n\n lrsfile + \" -N 2 \" + myldir + \" \" + irodshome + \"/icmdtest/testy\", 'STDOUT', \"New restartFile\")\n\n self.admin.assert_icommand(\"ichksum -rK \" + irodshome + \"/icmdtest/testy\", 'STDOUT', \"Total checksum performed\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"irepl -BvrPT -R \" + self.testresc + \" --rlock \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"icmdtest/testy\")\n\n self.admin.assert_icommand(\"itrim -vrS \" + irodsdefresource + \" --dryrun --age 1 -N 1 \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"This is a DRYRUN\")\n\n self.admin.assert_icommand(\"itrim -vrS \" + irodsdefresource + \" -N 1 \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"a copy trimmed\")\n\n self.admin.assert_icommand(\"icp -vKPTr -N 2 \" + irodshome + \"/icmdtest/testy \" +\n\n irodshome + \"/icmdtest/testz\", 'STDOUT', \"Processing lfile1\")\n\n self.admin.assert_icommand(\"irsync -r i:\" + irodshome + \"/icmdtest/testy i:\" + irodshome + \"/icmdtest/testz\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testy\")\n\n self.admin.assert_icommand(\"iphymv -vrS \" + irodsdefresource + \" -R \" +\n\n self.testresc + \" \" + irodshome + \"/icmdtest/testz\", 'STDOUT', \"icmdtest/testz\")\n\n\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n if os.path.exists(dir_w + \"/testz\"):\n\n shutil.rmtree(dir_w + \"/testz\")\n\n self.admin.assert_icommand(\"iget -vPKr --retries 10 -X \" + rsfile + \" --lfrestart \" + lrsfile +\n\n \" --rlock -N 2 \" + irodshome + \"/icmdtest/testz \" + dir_w + \"/testz\", 'STDOUT', \"testz\")\n\n self.admin.assert_icommand(\"irsync -r \" + dir_w + \"/testz i:\" + irodshome + \"/icmdtest/testz\")\n\n self.admin.assert_icommand(\"irsync -r i:\" + irodshome + \"/icmdtest/testz \" + dir_w + \"/testz\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testz \" + myldir)\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n # test -N0 transfer\n\n self.admin.assert_icommand(\"iput -N0 -R \" + self.testresc + \" \" +\n\n myldir + \"/lfile1 \" + irodshome + \"/icmdtest/testz/lfoo100\")\n\n if os.path.isfile(dir_w + \"/lfoo100\"):\n\n os.unlink(dir_w + \"/lfoo100\")\n\n self.admin.assert_icommand(\"iget -N0 \" + irodshome + \"/icmdtest/testz/lfoo100 \" + dir_w + \"/lfoo100\")\n\n output = commands.getstatusoutput(\"diff \" + myldir + \"/lfile1 \" + dir_w + \"/lfoo100\")\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/testz\")\n\n os.unlink(dir_w + \"/lfoo100\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testz\")\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 55, "score": 74491.09050883328 }, { "content": " def test_mso_slink(self):\n\n test_file_path = self.admin.session_collection\n\n self.admin.assert_icommand('iput -fR origResc ../zombiereaper.sh src_file.txt')\n\n self.admin.assert_icommand('ireg -D mso -R archiveResc \"//slink:' +\n\n test_file_path + '/src_file.txt\" ' + test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand('iget -f ' + test_file_path + '/test_file.txt')\n\n\n\n result = os.system(\"diff %s %s\" % ('./test_file.txt', '../zombiereaper.sh'))\n\n assert result == 0\n\n\n\n self.admin.assert_icommand('iput -f ../zombiereaper.sh ' + test_file_path + '/test_file.txt')\n\n\n\n # unregister the object\n", "file_path": "tests/pydevtest/test_mso_suite.py", "rank": 56, "score": 74491.09050883328 }, { "content": " def test_weighted_passthrough(self):\n\n filename = \"some_local_file.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n\n\n self.admin.assert_icommand(\"iput \" + filepath)\n\n self.admin.assert_icommand(\"ils -L\", 'STDOUT', \"local\")\n\n\n\n # repave a copy in the vault to differentiate\n\n vaultpath = os.path.join( lib.get_irods_top_level_dir(), \"unixBVault/home/\" + self.admin.username, os.path.basename( self.admin._session_id ), filename )\n\n subprocess.check_call( \"echo 'THISISBROEKN' | cat > %s\" % (vaultpath),shell=True)\n\n\n\n self.admin.assert_icommand(\"iadmin modresc w_pt context 'write=1.0;read=2.0'\")\n\n self.admin.assert_icommand(\"iget \" + filename + \" - \", 'STDOUT', \"THISISBROEKN\" )\n\n\n\n self.admin.assert_icommand(\"iadmin modresc w_pt context 'write=1.0;read=0.01'\")\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 57, "score": 74491.09050883328 }, { "content": "class Test_MSOSuite(resource_suite.ResourceBase, unittest.TestCase):\n\n def setUp(self):\n\n super(Test_MSOSuite, self).setUp()\n\n hostname = lib.get_hostname()\n\n self.admin.assert_icommand(\"iadmin modresc demoResc name origResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n self.admin.assert_icommand(\"iadmin mkresc demoResc compound\", 'STDOUT', 'compound')\n\n self.admin.assert_icommand(\"iadmin mkresc cacheResc 'unixfilesystem' \" + hostname + \":\" + lib.get_irods_top_level_dir() + \"/cacheRescVault\", 'STDOUT', 'unixfilesystem')\n\n self.admin.assert_icommand(\"iadmin mkresc archiveResc mso \" + hostname + \":/fake/vault/\", 'STDOUT', 'mso')\n\n self.admin.assert_icommand(\"iadmin addchildtoresc demoResc cacheResc cache\")\n\n self.admin.assert_icommand(\"iadmin addchildtoresc demoResc archiveResc archive\")\n\n\n\n def tearDown(self):\n\n super(Test_MSOSuite, self).tearDown()\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc archiveResc\")\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc cacheResc\")\n\n admin_session.assert_icommand(\"iadmin rmresc archiveResc\")\n\n admin_session.assert_icommand(\"iadmin rmresc cacheResc\")\n\n admin_session.assert_icommand(\"iadmin rmresc demoResc\")\n\n admin_session.assert_icommand(\"iadmin modresc origResc name demoResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/cacheRescVault\")\n\n\n\n def test_mso_http(self):\n\n test_file_path = self.admin.session_collection\n\n self.admin.assert_icommand('ireg -D mso -R archiveResc \"//http://people.renci.org/~jasonc/irods/http_mso_test_file.txt\" ' +\n\n test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand('iget -f ' + test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand_fail('ils -L ' + test_file_path + '/test_file.txt', 'STDOUT', ' -99 ')\n\n os.remove('test_file.txt')\n\n # unregister the object\n\n self.admin.assert_icommand('irm -U ' + test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand('ils -L', 'STDOUT', self.admin.zone_name)\n\n\n\n def test_mso_slink(self):\n\n test_file_path = self.admin.session_collection\n\n self.admin.assert_icommand('iput -fR origResc ../zombiereaper.sh src_file.txt')\n\n self.admin.assert_icommand('ireg -D mso -R archiveResc \"//slink:' +\n\n test_file_path + '/src_file.txt\" ' + test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand('iget -f ' + test_file_path + '/test_file.txt')\n\n\n\n result = os.system(\"diff %s %s\" % ('./test_file.txt', '../zombiereaper.sh'))\n\n assert result == 0\n\n\n\n self.admin.assert_icommand('iput -f ../zombiereaper.sh ' + test_file_path + '/test_file.txt')\n\n\n\n # unregister the object\n\n self.admin.assert_icommand('irm -U ' + test_file_path + '/test_file.txt')\n\n\n\n def test_mso_irods(self):\n\n hostname = socket.gethostname()\n\n test_file_path = self.admin.session_collection\n\n self.admin.assert_icommand('iput -fR pydevtest_AnotherResc ../zombiereaper.sh src_file.txt')\n\n self.admin.assert_icommand('ireg -D mso -R archiveResc \"//irods:' + hostname +\n\n ':1247:' + self.admin.username + '@' + self.admin.zone_name + test_file_path + '/src_file.txt\" ' + test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand('iget -f ' + test_file_path + '/test_file.txt')\n\n\n\n result = os.system(\"diff %s %s\" % ('./test_file.txt', '../zombiereaper.sh'))\n\n assert result == 0\n\n\n\n self.admin.assert_icommand('iput -f ../zombiereaper.sh ' + test_file_path + '/test_file.txt')\n\n\n\n # unregister the object\n\n self.admin.assert_icommand('irm -U ' + test_file_path + '/test_file.txt')\n", "file_path": "tests/pydevtest/test_mso_suite.py", "rank": 58, "score": 74491.09050883328 }, { "content": "class Test_iMetaSet(ResourceBase, unittest.TestCase):\n\n def setUp(self):\n\n super(Test_iMetaSet, self).setUp()\n\n\n\n usernames = [s.username for s in itertools.chain(self.admin_sessions, self.user_sessions)]\n\n self.admin.assert_icommand('iadmin lu', 'STDOUT_MULTILINE', usernames)\n\n\n\n for u in usernames:\n\n self.admin.assert_icommand('imeta ls -u ' + u, 'STDOUT', 'None')\n\n\n\n def tearDown(self):\n\n usernames = [s.username for s in itertools.chain(self.admin_sessions, self.user_sessions)]\n\n\n\n for u in usernames:\n\n self.admin.run_icommand(['imeta', 'rmw', '-u', u, '%', '%', '%'])\n\n\n\n super(Test_iMetaSet, self).tearDown()\n\n\n\n def set_avu(self, user_name, a, v, u):\n\n self.admin.assert_icommand('imeta set -u %s %s %s %s' % (user_name, a, v, u))\n\n\n\n def add_avu(self, user_name, a, v, u):\n\n self.admin.assert_icommand('imeta add -u %s %s %s %s' % (user_name, a, v, u))\n\n\n\n def check_avu(self, user_name, a, v, u):\n\n # If setting unit to empty string then ls output should be blank\n\n if u == '\"\"':\n\n u = ''\n\n\n\n a = re.escape(a)\n\n v = re.escape(v)\n\n u = re.escape(u)\n\n\n\n self.admin.assert_icommand('imeta ls -u %s %s' % (user_name, a), 'STDOUT_MULTILINE', ['attribute: ' + a + '$',\n\n 'value: ' + v + '$',\n\n 'units: ' + u + '$'],\n\n use_regex=True)\n\n\n\n def set_and_check_avu(self, user_name, a, v, u):\n\n self.set_avu(user_name, a, v, u)\n\n self.check_avu(user_name, a, v, u)\n\n\n\n def add_and_check_avu(self, user_name, a, v, u):\n\n self.add_avu(user_name, a, v, u)\n\n self.check_avu(user_name, a, v, u)\n\n\n\n def test_imeta_set_single_object_triple(self, user=None):\n\n if user is None:\n\n user = self.user0.username\n\n\n\n self.set_and_check_avu(user, 'att0', 'val0', 'unt0')\n\n self.set_and_check_avu(user, 'att0', 'val1', 'unt1')\n\n\n\n def test_imeta_set_single_object_double(self, user=None):\n\n if user is None:\n\n user = self.user0.username\n\n\n\n self.set_and_check_avu(user, 'att0', 'val0', '')\n\n self.set_and_check_avu(user, 'att0', 'val1', '')\n\n\n\n def test_imeta_set_single_object_double_to_triple(self, user=None):\n\n if user is None:\n\n user = self.user0.username\n\n\n\n self.set_and_check_avu(user, 'att0', 'val0', '')\n\n self.set_and_check_avu(user, 'att0', 'val1', 'unt1')\n\n\n\n def test_imeta_set_single_object_triple_to_double_no_unit(self, user=None):\n\n if user is None:\n\n user = self.user0.username\n\n\n\n self.set_and_check_avu(user, 'att0', 'val0', 'unt0')\n\n self.set_and_check_avu(user, 'att0', 'val1', '')\n\n\n\n self.admin.assert_icommand_fail('imeta ls -u ' + user + ' att0', 'STDOUT', 'units: unt0')\n\n\n\n def test_imeta_set_single_object_triple_to_double_empty_unit(self, user=None):\n\n if user is None:\n\n user = self.user0.username\n\n\n\n self.set_and_check_avu(user, 'att0', 'val0', 'unt0')\n\n self.set_and_check_avu(user, 'att0', 'val1', '\"\"')\n\n\n\n self.admin.assert_icommand_fail('imeta ls -u ' + user + ' att0', 'STDOUT', 'units: unt0')\n\n\n\n def test_imeta_set_multi_object_triple(self):\n\n user1 = self.user0.username\n\n user2 = self.user1.username\n\n\n\n self.test_imeta_set_single_object_triple(user=user1)\n\n self.test_imeta_set_single_object_triple(user=user2)\n\n\n\n def test_imeta_set_multi_object_double(self):\n\n user1 = self.user0.username\n\n user2 = self.user1.username\n\n\n\n self.test_imeta_set_single_object_double(user=user1)\n\n self.test_imeta_set_single_object_double(user=user2)\n\n\n\n def test_imeta_set_multi_object_double_to_triple(self):\n\n user1 = self.user0.username\n\n user2 = self.user1.username\n\n\n\n self.test_imeta_set_single_object_double_to_triple(user=user1)\n\n self.test_imeta_set_single_object_double_to_triple(user=user2)\n\n\n\n def test_imeta_set_multi_object_triple_to_double_no_unit(self):\n\n user1 = self.user0.username\n\n user2 = self.user1.username\n\n\n\n self.test_imeta_set_single_object_triple_to_double_no_unit(user=user1)\n\n self.test_imeta_set_single_object_triple_to_double_no_unit(user=user2)\n\n\n\n def test_imeta_set_multi_object_triple_to_double_empty_unit(self):\n\n user1 = self.user0.username\n\n user2 = self.user1.username\n\n\n\n self.test_imeta_set_single_object_triple_to_double_empty_unit(user=user1)\n\n self.test_imeta_set_single_object_triple_to_double_empty_unit(user=user2)\n\n\n\n def test_imeta_set_single_object_abandoned_avu_triple_to_double_no_unit(self):\n\n user = self.user0.username\n\n\n\n self.set_and_check_avu(user, 'att0', 'val0', 'unt0')\n\n self.admin.assert_icommand('imeta rm -u %s %s %s %s' % (user, 'att0', 'val0', 'unt0'))\n\n self.set_and_check_avu(user, 'att0', 'val0', '')\n\n self.admin.assert_icommand_fail('imeta ls -u ' + user + ' att0', 'STDOUT', 'units: unt0')\n\n\n\n def test_imeta_set_single_object_abandoned_avu_triple_to_double_empty_unit(self):\n\n user = self.user0.username\n\n\n\n self.set_and_check_avu(user, 'att0', 'val0', 'unt0')\n\n self.admin.assert_icommand('imeta rm -u %s %s %s %s' % (user, 'att0', 'val0', 'unt0'))\n\n self.set_and_check_avu(user, 'att0', 'val0', '\"\"')\n\n self.admin.assert_icommand_fail('imeta ls -u ' + user + ' att0', 'STDOUT', 'units: unt0')\n\n\n\n def test_imeta_set_single_object_multi_avu_removal(self):\n\n user = self.user0.username\n\n\n\n original_avus = [('att' + str(i), 'val' + str(i), 'unt' + str(i)) for i in range(30)]\n\n\n\n for avu in original_avus:\n\n self.add_and_check_avu(user, *avu)\n\n\n\n self.set_and_check_avu(user, 'att_new', 'val_new', 'unt_new')\n\n\n\n for a, v, u in original_avus:\n\n self.admin.assert_icommand_fail('imeta ls -u %s %s' % (user, a), 'STDOUT', ['attribute: ' + a + '$'])\n\n self.admin.assert_icommand_fail('imeta ls -u %s %s' % (user, a), 'STDOUT', ['value: ' + v + '$'])\n", "file_path": "tests/pydevtest/test_imeta_set.py", "rank": 59, "score": 74491.09050883328 }, { "content": " def test_ireg_files(self):\n\n self.admin.assert_icommand(\"ireg -R l_resc \" + ABSPATHTESTDIR + '/file0 ' + self.admin.home_collection + 'file0')\n\n self.admin.assert_icommand('ils -l ' + self.admin.home_collection + '/file0', 'STDOUT', \"r_resc;m_resc;l_resc\")\n\n\n\n self.admin.assert_icommand(\"ireg -R l_resc \" + ABSPATHTESTDIR + '/file1 ' + self.admin.home_collection + 'file1')\n\n self.admin.assert_icommand('ils -l ' + self.admin.home_collection + '/file1', 'STDOUT', \"r_resc;m_resc;l_resc\")\n\n\n\n self.admin.assert_icommand(\"ireg -R m_resc \" + ABSPATHTESTDIR +\n\n '/file2 ' + self.admin.home_collection + '/file2', 'STDERR', 'ERROR: regUtil: reg error for')\n\n\n", "file_path": "tests/pydevtest/test_ireg_suite.py", "rank": 60, "score": 74491.09050883328 }, { "content": " def test_iscan_data_object(self):\n\n #test that rodsusers can't use iscan -d\n\n self.user0.assert_icommand('iscan -d non_existent_file', 'STDOUT', 'Could not find the requested data object or collection in iRODS.' )\n\n existent_file = os.path.join( self.user0.local_session_dir, 'existent_file' )\n\n lib.make_file( existent_file, 1 )\n\n self.user0.assert_icommand('iput ' + existent_file );\n\n output = self.admin.run_icommand('iquest \"SELECT DATA_PATH WHERE DATA_NAME = \\'existent_file\\'\"' )[1]\n\n data_path = output.strip().strip('-').strip()[12:]\n\n self.user0.assert_icommand('iscan -d existent_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' );\n\n os.remove( data_path )\n\n self.user0.assert_icommand('iscan -d existent_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' );\n\n lib.make_file( data_path, 1 )\n\n self.user0.assert_icommand('irm -f existent_file' );\n\n zero_file = os.path.join( self.user0.local_session_dir, 'zero_file' )\n\n lib.touch( zero_file )\n\n self.user0.assert_icommand('iput ' + zero_file );\n\n self.user0.assert_icommand('iscan -d zero_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' );\n\n self.user0.assert_icommand('irm -f zero_file' );\n\n\n\n #test that rodsadmins can use iscan -d\n\n self.admin.assert_icommand('iscan -d non_existent_file', 'STDOUT', 'Could not find the requested data object or collection in iRODS.' )\n\n existent_file = os.path.join( self.admin.local_session_dir, 'existent_file' )\n\n lib.make_file( existent_file, 1 )\n\n self.admin.assert_icommand('iput ' + existent_file );\n\n output = self.admin.run_icommand('''iquest \"SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'\"''' )[1]\n\n data_path = output.strip().strip('-').strip()[12:]\n\n self.admin.assert_icommand('iscan -d existent_file' );\n\n os.remove( data_path )\n\n self.admin.assert_icommand('iscan -d existent_file', 'STDOUT', 'is missing, corresponding to iRODS object' );\n\n lib.make_file( data_path, 1 )\n\n self.admin.assert_icommand('irm -f existent_file' );\n\n zero_file = os.path.join( self.admin.local_session_dir, 'zero_file' )\n\n lib.touch( zero_file )\n\n self.admin.assert_icommand('iput ' + zero_file );\n\n self.admin.assert_icommand('iscan -d zero_file' );\n", "file_path": "tests/pydevtest/test_iscan.py", "rank": 61, "score": 74491.09050883328 }, { "content": " def test_mso_irods(self):\n\n hostname = socket.gethostname()\n\n test_file_path = self.admin.session_collection\n\n self.admin.assert_icommand('iput -fR pydevtest_AnotherResc ../zombiereaper.sh src_file.txt')\n\n self.admin.assert_icommand('ireg -D mso -R archiveResc \"//irods:' + hostname +\n\n ':1247:' + self.admin.username + '@' + self.admin.zone_name + test_file_path + '/src_file.txt\" ' + test_file_path + '/test_file.txt')\n\n self.admin.assert_icommand('iget -f ' + test_file_path + '/test_file.txt')\n\n\n\n result = os.system(\"diff %s %s\" % ('./test_file.txt', '../zombiereaper.sh'))\n\n assert result == 0\n\n\n\n self.admin.assert_icommand('iput -f ../zombiereaper.sh ' + test_file_path + '/test_file.txt')\n\n\n\n # unregister the object\n\n self.admin.assert_icommand('irm -U ' + test_file_path + '/test_file.txt')\n", "file_path": "tests/pydevtest/test_mso_suite.py", "rank": 62, "score": 74491.09050883328 }, { "content": " def test_icp_r(self):\n\n base_name_source = \"test_icp_r_dir_source\"\n\n file_names = set(self.iput_r_large_collection(\n\n self.user0, base_name_source, file_count=1000, file_size=100)[1])\n\n\n\n base_name_target = \"test_icp_r_dir_target\"\n\n self.user0.assert_icommand(\"icp -r \" + base_name_source + \" \" + base_name_target, \"EMPTY\")\n\n self.user0.assert_icommand(\"ils\", 'STDOUT', base_name_target)\n\n rods_files_source = set(lib.ils_output_to_entries(self.user0.run_icommand(['ils', base_name_source])[1]))\n\n self.assertTrue(file_names == rods_files_source,\n\n msg=\"Files missing:\\n\" + str(file_names - rods_files_source) + \"\\n\\n\" +\n\n \"Extra files:\\n\" + str(rods_files_source - file_names))\n\n\n\n rods_files_target = set(lib.ils_output_to_entries(self.user0.run_icommand(['ils', base_name_target])[1]))\n\n self.assertTrue(file_names == rods_files_target,\n\n msg=\"Files missing:\\n\" + str(file_names - rods_files_target) + \"\\n\\n\" +\n\n \"Extra files:\\n\" + str(rods_files_target - file_names))\n\n\n\n vault_files_post_icp_source = set(os.listdir(os.path.join(lib.get_vault_session_path(self.user0),\n\n base_name_source)))\n\n\n\n self.assertTrue(file_names == vault_files_post_icp_source,\n\n msg=\"Files missing from vault:\\n\" + str(file_names - vault_files_post_icp_source) + \"\\n\\n\" +\n\n \"Extra files in vault:\\n\" + str(vault_files_post_icp_source - file_names))\n\n\n\n vault_files_post_icp_target = set(os.listdir(os.path.join(lib.get_vault_session_path(self.user0),\n\n base_name_target)))\n\n self.assertTrue(file_names == vault_files_post_icp_target,\n\n msg=\"Files missing from vault:\\n\" + str(file_names - vault_files_post_icp_target) + \"\\n\\n\" +\n", "file_path": "tests/pydevtest/test_icommands_file_operations.py", "rank": 63, "score": 74491.09050883328 }, { "content": "class Test_Deferred_Resource(ChunkyDevTest, ResourceSuite, unittest.TestCase):\n\n def setUp(self):\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin modresc demoResc name origResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n admin_session.assert_icommand(\"iadmin mkresc demoResc deferred\", 'STDOUT', 'deferred')\n\n admin_session.assert_icommand(\"iadmin mkresc unix1Resc 'unixfilesystem' \" + configuration.HOSTNAME_1 + \":\" + lib.get_irods_top_level_dir() + \"/unix1RescVault\", 'STDOUT', 'unixfilesystem')\n\n admin_session.assert_icommand(\"iadmin addchildtoresc demoResc unix1Resc\")\n\n super(Test_Deferred_Resource, self).setUp()\n\n\n\n def tearDown(self):\n\n super(Test_Deferred_Resource, self).tearDown()\n\n with lib.make_session_for_existing_admin() as admin_session:\n\n admin_session.assert_icommand(\"iadmin rmchildfromresc demoResc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc unix1Resc\")\n\n admin_session.assert_icommand(\"iadmin rmresc demoResc\")\n\n admin_session.assert_icommand(\"iadmin modresc origResc name demoResc\", 'STDOUT', 'rename', stdin_string='yes\\n')\n\n shutil.rmtree(lib.get_irods_top_level_dir() + \"/unix1RescVault\", ignore_errors=True)\n\n\n\n @unittest.skip(\"EMPTY_RESC_PATH - no vault path for coordinating resources\")\n\n def test_ireg_as_rodsuser_in_vault(self):\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 64, "score": 74491.09050883328 }, { "content": "class Test_FuseSuite(ResourceBase, unittest.TestCase):\n\n def setUp(self):\n\n super(Test_FuseSuite, self).setUp()\n\n\n\n def tearDown(self):\n\n super(Test_FuseSuite, self).tearDown()\n\n\n\n def test_irodsFs_issue_2252(self):\n\n # =-=-=-=-=-=-=-\n\n # set up a fuse mount\n\n mount_point = \"fuse_mount_point\"\n\n\n\n if not os.path.isdir(mount_point):\n\n os.mkdir(mount_point)\n\n os.system(\"irodsFs \" + mount_point)\n\n\n\n largefilename = \"big_file.txt\"\n\n output = commands.getstatusoutput('dd if=/dev/zero of=' + largefilename + ' bs=1M count=100')\n\n\n\n # =-=-=-=-=-=-=-\n\n # use system copy to put some data into the mount mount\n\n # and verify that it shows up in the ils\n\n cmd = \"cp ./\" + largefilename + \" ./\" + mount_point + \"; ls ./\" + mount_point + \"/\" + largefilename\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n\n\n os.system(\"rm ./\" + largefilename)\n\n os.system(\"rm ./\" + mount_point + \"/\" + largefilename)\n\n\n\n # tear down the fuse mount\n\n os.system(\"fusermount -uz \" + mount_point)\n\n if os.path.isdir(mount_point):\n\n os.rmdir(mount_point)\n\n\n\n assert(-1 != out_str.find(largefilename))\n\n\n\n def test_fusermount_permissions(self):\n\n # Check that fusermount is configured correctly for irodsFs\n\n fusermount_path = distutils.spawn.find_executable('fusermount')\n\n assert fusermount_path is not None, 'fusermount binary not found'\n\n assert os.stat(fusermount_path).st_mode & stat.S_ISUID, 'fusermount setuid bit not set'\n\n p = subprocess.Popen(['fusermount -V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\n\n stdoutdata, stderrdata = p.communicate()\n\n assert p.returncode == 0, '\\n'.join(['fusermount not executable',\n\n 'return code: ' + str(p.returncode),\n\n 'stdout: ' + stdoutdata,\n\n 'stderr: ' + stderrdata])\n\n\n\n def test_irodsFs(self):\n\n # =-=-=-=-=-=-=-\n\n # set up a fuse mount\n\n mount_point = \"fuse_mount_point\"\n\n\n\n if not os.path.isdir(mount_point):\n\n os.mkdir(mount_point)\n\n os.system(\"irodsFs \" + mount_point)\n\n\n\n # =-=-=-=-=-=-=-\n\n # put some test data\n\n cmd = \"iput README foo0\"\n\n output = commands.getstatusoutput(cmd)\n\n\n\n # =-=-=-=-=-=-=-\n\n # see if the data object is actually in the mount point\n\n # using the system ls\n\n cmd = \"ls -l \" + mount_point\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"mount ls results [\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"foo0\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # use system copy to put some data into the mount mount\n\n # and verify that it shows up in the ils\n\n cmd = \"cp README \" + mount_point + \"/baz ; ils -l baz\"\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"baz\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # now irm the file and verify that it is not visible\n\n # via the fuse mount\n\n cmd = \"irm -f baz ; ils -l baz\"\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"baz does not exist\"))\n\n\n\n output = commands.getstatusoutput(\"ls -l \" + mount_point)\n\n out_str = str(output)\n\n print(\"mount ls results [\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"foo0\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # now rm the foo0 file and then verify it doesnt show\n\n # up in the ils\n\n cmd = \"rm \" + mount_point + \"/foo0; ils -l foo0\"\n\n print(\"cmd: [\" + cmd + \"]\")\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"foo0 does not exist\"))\n\n\n\n # =-=-=-=-=-=-=-\n\n # now run bonnie++ and then verify it reports a summary\n\n if (os.path.isfile(\"/usr/sbin/bonnie++\")):\n\n # ubuntu and centos\n\n bonniecmd = \"/usr/sbin/bonnie++\"\n\n else:\n\n # suse\n\n bonniecmd = \"/usr/bin/bonnie++\"\n\n cmd = bonniecmd + \" -r 1024 -d \" + mount_point\n\n print(\"cmd: [\" + cmd + \"]\")\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n assert(-1 != out_str.find(\"-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--\"))\n\n assert(-1 != out_str.find(\"-Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--\"))\n\n\n\n # tear down the fuse mount\n\n os.system(\"fusermount -uz \" + mount_point)\n\n if os.path.isdir(mount_point):\n", "file_path": "tests/pydevtest/test_fuse_suite.py", "rank": 65, "score": 74491.09050883328 }, { "content": " def test_xml_protocol_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n lrsfile = dir_w + \"/lrsfile\"\n\n rsfile = dir_w + \"/rsfile\"\n\n\n\n # do test using xml protocol\n\n os.environ['irodsProt'] = \"1\"\n\n self.admin.assert_icommand(\"ilsresc\", 'STDOUT', self.testresc)\n\n self.admin.assert_icommand(\"imiscsvrinfo\", 'STDOUT', \"relVersion\")\n\n self.admin.assert_icommand(\"iuserinfo\", 'STDOUT', \"name: \" + username)\n\n self.admin.assert_icommand(\"ienv\", 'STDOUT', \"Release Version\")\n\n self.admin.assert_icommand(\"icd \" + irodshome)\n\n self.admin.assert_icommand(\"ipwd\", 'STDOUT', \"home\")\n\n self.admin.assert_icommand(\"ihelp ils\", 'STDOUT', \"ils\")\n\n self.admin.assert_icommand(\"ierror -14000\", 'STDOUT', \"SYS_API_INPUT_ERR\")\n\n self.admin.assert_icommand(\"iexecmd hello\", 'STDOUT', \"Hello world\")\n\n self.admin.assert_icommand(\"ips -v\", 'STDOUT', \"ips\")\n\n self.admin.assert_icommand(\"iqstat\", 'STDOUT', \"No delayed rules\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtest1\")\n\n # make a directory of large files\n\n self.admin.assert_icommand(\"iput -kf \" + progname + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"ils -l \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', [\"foo1\", myssize])\n\n self.admin.assert_icommand(\"iadmin ls \" + irodshome + \"/icmdtest1\", 'STDOUT', \"foo1\")\n\n self.admin.assert_icommand(\"ichmod read \" + self.user0.username + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"ils -A \" + irodshome + \"/icmdtest1/foo1\",\n\n 'STDOUT', self.user0.username + \"#\" + irodszone + \":read\")\n\n self.admin.assert_icommand(\"irepl -B -R \" + self.testresc + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n # overwrite a copy\n\n self.admin.assert_icommand(\"itrim -S \" + irodsdefresource + \" -N1 \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"iphymv -R \" + irodsdefresource + \" \" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"imeta add -d \" + irodshome + \"/icmdtest1/foo1 testmeta1 180 cm\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', \"testmeta1\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', \"180\")\n\n self.admin.assert_icommand(\"imeta ls -d \" + irodshome + \"/icmdtest1/foo1\", 'STDOUT', \"cm\")\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest1/foo1 \" + irodshome + \"/icmdtest1/foo2\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest1/foo2 \" + irodshome + \"/icmdtest1/foo4\")\n\n self.admin.assert_icommand(\"imv \" + irodshome + \"/icmdtest1/foo4 \" + irodshome + \"/icmdtest1/foo2\")\n\n self.admin.assert_icommand(\"ichksum -K \" + irodshome + \"/icmdtest1/foo2\", 'STDOUT', \"foo2\")\n\n self.admin.assert_icommand(\"iget -f -K \" + irodshome + \"/icmdtest1/foo2 \" + dir_w)\n\n os.unlink(dir_w + \"/foo2\")\n\n self.admin.assert_icommand(\"irsync \" + progname + \" i:\" + irodshome + \"/icmdtest1/foo1\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest1/foo1 /tmp/foo1\")\n\n self.admin.assert_icommand(\"irsync i:\" + irodshome + \"/icmdtest1/foo1 i:\" + irodshome + \"/icmdtest1/foo2\")\n\n os.unlink(\"/tmp/foo1\")\n\n os.environ['irodsProt'] = \"0\"\n\n\n\n # cleanup\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 66, "score": 74491.09050883328 }, { "content": " def test_send_and_receive_one_xmsg(self):\n\n message = 'Hello World!'\n\n\n\n # set up Xmsg in client environment\n\n my_env = os.environ.copy()\n\n my_env['XMSG_HOST'] = self.xmsgHost\n\n my_env['XMSG_PORT'] = str(self.xmsgPort)\n\n\n\n # send msg\n\n args = ['/usr/bin/ixmsg', 's', '-M \"{0}\"'.format(message)]\n\n subprocess.Popen(args, env=my_env).communicate()\n\n\n\n # receive msg\n\n args = ['/usr/bin/ixmsg', 'r', '-n 1']\n\n res = subprocess.Popen(args, env=my_env, stdout=subprocess.PIPE).communicate()\n\n\n\n # assertion\n\n print 'looking for \"{0}\" in \"{1}\"'.format(message, res[0].rstrip())\n", "file_path": "tests/pydevtest/test_xmsg.py", "rank": 67, "score": 73697.68858840814 }, { "content": " def test_large_dir_and_mcoll_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # we put foo1 in $irodsdefresource and foo2 in testresource\n\n self.admin.assert_icommand(\"iput -K --wlock \" + progname + \" \" + irodshome + \"/icmdtest/foo1\")\n\n self.admin.assert_icommand(\"icp -K -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/foo1 \" + irodshome + \"/icmdtest/foo2\")\n\n\n\n # added so icmdtestx.tar exists\n\n self.admin.assert_icommand(\"ibun -c \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtest\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imcoll -m tar \" + irodshome + \"/icmdtestx.tar \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imkdir \" + irodshome + \"/icmdtestt_large/mydirtt\")\n\n\n\n # make a directory of 2 large files and 2 small files\n\n lfile = dir_w + \"/lfile\"\n\n lfile1 = dir_w + \"/lfile1\"\n\n commands.getstatusoutput(\"echo 012345678901234567890123456789012345678901234567890123456789012 > \" + lfile)\n\n for i in range(6):\n\n commands.getstatusoutput(\"cat \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile +\n\n \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" > \" + lfile1)\n\n os.rename(lfile1, lfile)\n\n os.mkdir(myldir)\n\n for i in range(1, 3):\n\n mylfile = myldir + \"/lfile\" + str(i)\n\n mysfile = myldir + \"/sfile\" + str(i)\n\n if i != 2:\n\n shutil.copyfile(lfile, mylfile)\n\n else:\n\n os.rename(lfile, mylfile)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # test adding a large file to a mounted collection\n\n self.admin.assert_icommand(\"iput \" + myldir + \"/lfile1 \" + irodshome + \"/icmdtestt_large/mydirtt\")\n\n self.admin.assert_icommand(\"iget \" + irodshome + \"/icmdtestt_large/mydirtt/lfile1 \" + dir_w + \"/testt\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestt_large/mydirtt\")\n\n self.admin.assert_icommand(\"imcoll -s \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imcoll -p \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"imcoll -U \" + irodshome + \"/icmdtestt_large\")\n\n self.admin.assert_icommand(\"irm -rf \" + irodshome + \"/icmdtestt_large\")\n\n os.unlink(dir_w + \"/testt\")\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 68, "score": 73697.68858840814 }, { "content": " def test_ireg_as_rodsuser_in_vault(self):\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 69, "score": 73697.68858840814 }, { "content": " def test_rulemsiPhyBundleColl(self):\n\n rulefile = 'rulemsiPhyBundleColl.r'\n\n\n\n # rule test\n\n self.rods_session.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDOUT',\n\n \"Create tar file of collection /tempZone/home/rods/test on resource testallrulesResc\")\n\n\n\n # look for the bundle\n\n bundle_path = '/tempZone/bundle/home/' + self.rods_session.username\n\n output = self.rods_session.run_icommand(['ils', '-L', bundle_path])\n\n\n\n # last token in stdout should be the bundle file's full physical path\n\n bundlefile = output[1].split()[-1]\n\n\n\n # check on the bundle file's name\n\n assert bundlefile.find('test.') >= 0\n\n\n\n # check physical path on resource\n\n assert os.path.isfile(bundlefile)\n\n\n\n # now try as a normal user (expect err msg)\n\n self.user0.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDERR', \"SYS_NO_API_PRIV\")\n\n\n\n # cleanup\n", "file_path": "tests/pydevtest/test_allrules.py", "rank": 70, "score": 73697.68858840814 }, { "content": " def test_irepl_update_replicas(self):\n\n # local setup\n\n filename = \"updatereplicasfile.txt\"\n\n filepath = lib.create_local_testfile(filename)\n\n hostname = lib.get_hostname()\n\n hostuser = getpass.getuser()\n\n doublefile = \"doublefile.txt\"\n\n os.system(\"cat %s %s > %s\" % (filename, filename, doublefile))\n\n doublesize = str(os.stat(doublefile).st_size)\n\n\n\n # assertions\n\n self.admin.assert_icommand(\"iadmin mkresc thirdresc unixfilesystem %s:/tmp/%s/thirdrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create third resource\n\n self.admin.assert_icommand(\"iadmin mkresc fourthresc unixfilesystem %s:/tmp/%s/fourthrescVault\" %\n\n (hostname, hostuser), 'STDOUT', \"Creating\") # create fourth resource\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDERR', \"does not exist\") # should not be listed\n\n self.admin.assert_icommand(\"iput \" + filename) # put file\n\n # replicate to test resource\n\n self.admin.assert_icommand(\"irepl -R \" + self.testresc + \" \" + filename)\n\n # replicate to third resource\n\n self.admin.assert_icommand(\"irepl -R thirdresc \" + filename)\n\n # replicate to fourth resource\n\n self.admin.assert_icommand(\"irepl -R fourthresc \" + filename)\n\n # repave overtop test resource\n\n self.admin.assert_icommand(\"iput -f -R \" + self.testresc + \" \" + doublefile + \" \" + filename)\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', filename) # for debugging\n\n\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irepl -U \" + filename) # update last replica\n\n\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a dirty copy\n\n self.admin.assert_icommand_fail(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irepl -aU \" + filename) # update all replicas\n\n\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 0 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 1 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 2 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 3 \", \" & \" + filename])\n\n # should have a clean copy\n\n self.admin.assert_icommand(\"ils -L \" + filename, 'STDOUT', [\" 4 \", \" & \" + filename])\n\n\n\n self.admin.assert_icommand(\"irm -f \" + filename) # cleanup file\n\n self.admin.assert_icommand(\"iadmin rmresc thirdresc\") # remove third resource\n\n self.admin.assert_icommand(\"iadmin rmresc fourthresc\") # remove third resource\n\n\n\n # local cleanup\n\n os.remove(filepath)\n", "file_path": "tests/pydevtest/test_resource_types.py", "rank": 71, "score": 73697.68858840814 }, { "content": " def test_large_files_with_RBUDP_from_devtest(self):\n\n # build expected variables with similar devtest names\n\n progname = __file__\n\n myssize = str(os.stat(progname).st_size)\n\n username = self.admin.username\n\n irodszone = self.admin.zone_name\n\n testuser1 = self.user0.username\n\n irodshome = self.admin.session_collection\n\n irodsdefresource = self.admin.default_resource\n\n dir_w = \".\"\n\n sfile2 = dir_w + \"/sfile2\"\n\n commands.getstatusoutput(\"cat \" + progname + \" \" + progname + \" > \" + sfile2)\n\n mysdir = \"/tmp/irodssdir\"\n\n myldir = dir_w + \"/ldir\"\n\n if os.path.exists(myldir):\n\n shutil.rmtree(myldir)\n\n self.admin.assert_icommand(\"imkdir icmdtest\")\n\n\n\n # make a directory of 2 large files and 2 small files\n\n lfile = dir_w + \"/lfile\"\n\n lfile1 = dir_w + \"/lfile1\"\n\n commands.getstatusoutput(\"echo 012345678901234567890123456789012345678901234567890123456789012 > \" + lfile)\n\n for i in range(6):\n\n commands.getstatusoutput(\"cat \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile +\n\n \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" \" + lfile + \" > \" + lfile1)\n\n os.rename(lfile1, lfile)\n\n os.mkdir(myldir)\n\n for i in range(1, 3):\n\n mylfile = myldir + \"/lfile\" + str(i)\n\n mysfile = myldir + \"/sfile\" + str(i)\n\n if i != 2:\n\n shutil.copyfile(lfile, mylfile)\n\n else:\n\n os.rename(lfile, mylfile)\n\n shutil.copyfile(progname, mysfile)\n\n\n\n # do the large files tests using RBUDP\n\n lrsfile = dir_w + \"/lrsfile\"\n\n rsfile = dir_w + \"/rsfile\"\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n self.admin.assert_icommand(\"iput -vQPKr --retries 10 -X \" + rsfile + \" --lfrestart \" +\n\n lrsfile + \" \" + myldir + \" \" + irodshome + \"/icmdtest/testy\", 'STDOUT', \"icmdtest/testy\")\n\n self.admin.assert_icommand(\"irepl -BQvrPT -R \" + self.testresc + \" \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"icmdtest/testy\")\n\n self.admin.assert_icommand(\"itrim -vrS \" + irodsdefresource + \" -N 1 \" +\n\n irodshome + \"/icmdtest/testy\", 'STDOUT', \"a copy trimmed\")\n\n self.admin.assert_icommand(\"icp -vQKPTr \" + irodshome + \"/icmdtest/testy \" +\n\n irodshome + \"/icmdtest/testz\", 'STDOUT', \"Processing sfile1\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testy\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n if os.path.exists(dir_w + \"/testz\"):\n\n shutil.rmtree(dir_w + \"/testz\")\n\n self.admin.assert_icommand(\"iget -vQPKr --retries 10 -X \" + rsfile + \" --lfrestart \" + lrsfile +\n\n \" \" + irodshome + \"/icmdtest/testz \" + dir_w + \"/testz\", 'STDOUT', \"Processing sfile2\")\n\n if os.path.isfile(lrsfile):\n\n os.unlink(lrsfile)\n\n if os.path.isfile(rsfile):\n\n os.unlink(rsfile)\n\n output = commands.getstatusoutput(\"diff -r \" + dir_w + \"/testz \" + myldir)\n\n print \"output is [\" + str(output) + \"]\"\n\n assert output[0] == 0\n\n assert output[1] == \"\", \"diff output was not empty...\"\n\n shutil.rmtree(dir_w + \"/testz\")\n\n self.admin.assert_icommand(\"irm -vrf \" + irodshome + \"/icmdtest/testz\")\n\n shutil.rmtree(myldir)\n\n\n\n # cleanup\n\n os.unlink(sfile2)\n\n if os.path.exists(myldir):\n", "file_path": "tests/pydevtest/test_chunkydevtest.py", "rank": 72, "score": 73697.68858840814 }, { "content": " def test_irodsFs_issue_2252(self):\n\n # =-=-=-=-=-=-=-\n\n # set up a fuse mount\n\n mount_point = \"fuse_mount_point\"\n\n\n\n if not os.path.isdir(mount_point):\n\n os.mkdir(mount_point)\n\n os.system(\"irodsFs \" + mount_point)\n\n\n\n largefilename = \"big_file.txt\"\n\n output = commands.getstatusoutput('dd if=/dev/zero of=' + largefilename + ' bs=1M count=100')\n\n\n\n # =-=-=-=-=-=-=-\n\n # use system copy to put some data into the mount mount\n\n # and verify that it shows up in the ils\n\n cmd = \"cp ./\" + largefilename + \" ./\" + mount_point + \"; ls ./\" + mount_point + \"/\" + largefilename\n\n output = commands.getstatusoutput(cmd)\n\n out_str = str(output)\n\n print(\"results[\" + out_str + \"]\")\n\n\n\n os.system(\"rm ./\" + largefilename)\n\n os.system(\"rm ./\" + mount_point + \"/\" + largefilename)\n\n\n\n # tear down the fuse mount\n\n os.system(\"fusermount -uz \" + mount_point)\n\n if os.path.isdir(mount_point):\n\n os.rmdir(mount_point)\n\n\n", "file_path": "tests/pydevtest/test_fuse_suite.py", "rank": 73, "score": 73697.68858840814 }, { "content": " def test_load_balanced(self):\n\n # =-=-=-=-=-=-=-\n\n # read server_config.json and .odbc.ini\n\n cfg = ServerConfig()\n\n\n\n if cfg.get('catalog_database_type') == \"postgres\":\n\n # =-=-=-=-=-=-=-\n\n # seed load table with fake values - rescA should win\n\n secs = int(time.time())\n\n cfg.exec_sql_cmd(\"insert into r_server_load_digest values ('rescA', 50, %s)\" % secs)\n\n cfg.exec_sql_cmd(\"insert into r_server_load_digest values ('rescB', 75, %s)\" % secs)\n\n cfg.exec_sql_cmd(\"insert into r_server_load_digest values ('rescC', 95, %s)\" % secs)\n\n\n\n # =-=-=-=-=-=-=-\n\n # build a logical path for putting a file\n\n test_file = self.admin.session_collection + \"/test_file.txt\"\n\n\n\n # =-=-=-=-=-=-=-\n\n # put a test_file.txt - should be on rescA given load table values\n\n self.admin.assert_icommand(\"iput -f ./test_load_balanced_suite.py \" + test_file)\n\n self.admin.assert_icommand(\"ils -L \" + test_file, 'STDOUT', \"rescA\")\n\n self.admin.assert_icommand(\"irm -f \" + test_file)\n\n\n\n # =-=-=-=-=-=-=-\n\n # drop rescC to a load of 15 - this should now win\n\n cfg.exec_sql_cmd(\"update r_server_load_digest set load_factor=15 where resc_name='rescC'\")\n\n\n\n # =-=-=-=-=-=-=-\n\n # put a test_file.txt - should be on rescC given load table values\n\n self.admin.assert_icommand(\"iput -f ./test_load_balanced_suite.py \" + test_file)\n\n self.admin.assert_icommand(\"ils -L \" + test_file, 'STDOUT', \"rescC\")\n\n self.admin.assert_icommand(\"irm -f \" + test_file)\n\n\n\n # =-=-=-=-=-=-=-\n\n # clean up our alterations to the load table\n\n cfg.exec_sql_cmd(\"delete from r_server_load_digest where resc_name='rescA'\")\n\n cfg.exec_sql_cmd(\"delete from r_server_load_digest where resc_name='rescB'\")\n\n cfg.exec_sql_cmd(\"delete from r_server_load_digest where resc_name='rescC'\")\n\n else:\n", "file_path": "tests/pydevtest/test_load_balanced_suite.py", "rank": 74, "score": 73697.68858840814 }, { "content": " def test_rulemsiDataObjRsync(self):\n\n rulefile = 'rulemsiDataObjRsync.r'\n\n src_filename = 'source.txt'\n\n dest_filename = 'dest.txt'\n\n test_dir = '/tmp'\n\n test_coll = self.rods_session.home_collection + '/synctest'\n\n src_file = os.path.join(test_dir, src_filename)\n\n src_obj = test_coll + '/' + src_filename\n\n dest_obj = test_coll + '/' + dest_filename\n\n\n\n # create test collection\n\n self.rods_session.run_icommand(['imkdir', test_coll])\n\n\n\n # create source test file\n\n with open(src_file, 'a') as f:\n\n f.write('blah\\n')\n\n\n\n # upload source test file\n\n self.rods_session.run_icommand(['iput', src_file, test_coll])\n\n\n\n # first rsync rule test\n\n self.rods_session.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDOUT', \"status = 99999992\")\n\n\n\n # modify the source and try again\n\n for i in range(1, 5):\n\n with open(src_file, 'a') as f:\n\n f.write('blah_' + str(i) + '\\n')\n\n\n\n # force upload source\n\n self.rods_session.run_icommand(['iput', '-f', src_file, test_coll])\n\n\n\n # sync test\n\n self.rods_session.assert_icommand(\"irule -F \" + rules30dir + rulefile, 'STDOUT', \"status = 99999992\")\n\n\n\n # cleanup\n\n self.rods_session.run_icommand(['irm', '-rf', test_coll])\n", "file_path": "tests/pydevtest/test_allrules.py", "rank": 75, "score": 73697.68858840814 }, { "content": " char *s;\n\n\n\n s = ( char * ) xs->inOutStruct;\n\n RE_TEST_MACRO( s );\n\n fprintf( stdout, \"%s\\n\", s );\n\n return 0;\n\n}\n\n\n\nint\n\nrecover_print_bye( ruleExecInfo_t *rei ) {\n\n RE_TEST_MACRO( \"\\b\\b\\b \\b\\b\\b\" );\n\n fprintf( stdout, \"\\b\\b\\b \\b\\b\\b\" );\n\n return 0;\n\n}\n\n\n\nint\n\nrecover_print_eol( ruleExecInfo_t *rei ) {\n\n RE_TEST_MACRO( \"*\\b\" );\n\n fprintf( stdout, \"*\\b\" );\n\n return 0;\n", "file_path": "iRODS/server/re/src/miscMS.cpp", "rank": 77, "score": 37.221028799616285 }, { "content": "\n\n msiRollback( rei ); /* rolling back */\n\n return 0;\n\n\n\n}\n\nint\n\nprint_bye( ruleExecInfo_t *rei ) {\n\n RE_TEST_MACRO( \"Bye\\n\" );\n\n fprintf( stdout, \"Bye\\n\" );\n\n return 0;\n\n}\n\n\n\nint\n\nprint_eol( ruleExecInfo_t *rei ) {\n\n RE_TEST_MACRO( \"\\n\" );\n\n fprintf( stdout, \"\\n\" );\n\n return 0;\n\n}\n\nint\n\nprint_hello_arg( msParam_t* xs, ruleExecInfo_t *rei ) {\n", "file_path": "iRODS/server/re/src/miscMS.cpp", "rank": 78, "score": 36.051153990177816 }, { "content": " }\n\n fprintf( stdout, \"</TABLE>\\n\" );\n\n fprintf( stdout, \"</BODY>\\n</HTML>\\n\" );\n\n return 0;\n\n}\n\n\n\nint\n\nperformAction( inStruct Sentries ) {\n\n int status;\n\n int c, i, j;\n\n int uFlag = 0;;\n\n char tmpStr[100];\n\n ruleExecInfo_t rei;\n\n char action[100];\n\n char *t1;\n\n char *args[MAX_NUM_OF_ARGS_IN_ACTION];\n\n char configDirEV[200];\n\n char retestflagEV[200];\n\n char reloopbackflagEV[200];\n\n\n", "file_path": "iRODS/server/re/src/ruleAdmin.cpp", "rank": 80, "score": 32.17016614944874 }, { "content": " /**** This is Just a Test Stub ****/\n\n return 0;\n\n}\n\n\n\n\n\nint notExec( msParam_t* xactionList, ruleExecInfo_t *rei ) {\n\n\n\n char *actionList;\n\n\n\n actionList = ( char * ) xactionList->inOutStruct;\n\n\n\n /**** This is Just a Test Stub ****/\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 ) {\n\n fprintf( stdout, \" Initiating Negation Execution for %s \\n\", actionList );\n\n }\n\n else if ( reTestFlag == HTML_TEST_1 ) {\n\n fprintf( stdout, \">>>>Initiating Negation Execution for %s<BR>\\n\", actionList );\n\n }\n\n else if ( reTestFlag == LOG_TEST_1 ) {\n", "file_path": "iRODS/server/re/src/juststubsMS.cpp", "rank": 81, "score": 31.37473458979069 }, { "content": " }\n\n fprintf( stdout, \"<FONT COLOR=#0000FF>Rule Set:</FONT> <FONT COLOR=#FF0000>%s</FONT><BR><HR>\\n\", ruleSet );\n\n strcpy( rei.ruleSet, ruleSet );\n\n /* fprintf(stdout,\"<PRE>\\n\");fflush(stdout);*/\n\n ht1 = gethrtime();\n\n initRuleStruct( NULL, ruleSet, \"core\", \"core\" );\n\n ht2 = gethrtime();\n\n /*** i = applyRule(action, args, 0, &rei, SAVE_REI); ***/\n\n i = applyRuleArgPA( action, args, 0, NULL, &rei, SAVE_REI );\n\n ht3 = gethrtime();\n\n\n\n if ( reTestFlag == COMMAND_TEST_1 || reTestFlag == COMMAND_TEST_MSI ) {\n\n fprintf( stdout, \"Rule Initialization Time = %.2f millisecs\\n\", ( float )( ht2 - ht1 ) / 1000000 );\n\n fprintf( stdout, \"Rule Execution Time = %.2f millisecs\\n\", ( float )( ht3 - ht1 ) / 1000000 );\n\n }\n\n if ( reTestFlag == HTML_TEST_1 || reTestFlag == HTML_TEST_MSI ) {\n\n fprintf( stdout, \"<BR>Rule Initialization Time = %.2f millisecs<BR>\\n\", ( float )( ht2 - ht1 ) / 1000000 );\n\n fprintf( stdout, \"Rule Execution Time = %.2f millisecs<BR>\\n\", ( float )( ht3 - ht1 ) / 1000000 );\n\n }\n\n\n", "file_path": "iRODS/server/re/src/ruleAdmin.cpp", "rank": 82, "score": 30.522393905631894 }, { "content": " if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 ) {\n\n fprintf( stdout, \" Initiating Parallel Execution for %s \\n\", actionList );\n\n }\n\n else if ( reTestFlag == HTML_TEST_1 ) {\n\n fprintf( stdout, \">>>>Initiating Parallel Execution for %s<BR>\\n\", actionList );\n\n }\n\n else if ( reTestFlag == LOG_TEST_1 ) {\n\n rodsLog( LOG_NOTICE, \" Calling msiParallelExecution\\n\" );\n\n rodsLog( LOG_NOTICE, \" For Actions = %s\\n\", actionList );\n\n }\n\n if ( reLoopBackFlag > 0 ) {\n\n return 0;\n\n }\n\n }\n\n /**** This is Just a Test Stub ****/\n\n return 0;\n\n}\n\n\n\nint orExec( msParam_t* xactionList, msParam_t *orSuccNum, ruleExecInfo_t *rei ) {\n", "file_path": "iRODS/server/re/src/juststubsMS.cpp", "rank": 83, "score": 30.105930733798587 }, { "content": "\n\n /*******\n\n i = execMyRule(\"myTestRule||msiDataObjOpen(*A,*X)##msiDataObjCreate(*B,*Y)##msiDataObjClose(*X,*Z1)##msiDataObjClose(*Y,*Z2)\",NULL,rei);\n\n exit(0);\n\n *******/\n\n /****\n\n i = applyRule(argv[optind+1], args, argc - optind-2, rei, SAVE_REI);\n\n ****/\n\n i = applyRuleArgPA( argv[optind + 1], args, argc - optind - 2, NULL, rei, SAVE_REI );\n\n /****/\n\n ht3 = gethrtime();\n\n if ( reTestFlag == COMMAND_TEST_1 || reTestFlag == COMMAND_TEST_MSI ) {\n\n fprintf( stdout, \"Rule Initialization Time = %.2f millisecs\\n\", ( float )( ht2 - ht1 ) / 1000000 );\n\n fprintf( stdout, \"Rule Execution Time = %.2f millisecs\\n\", ( float )( ht3 - ht1 ) / 1000000 );\n\n }\n\n if ( reTestFlag == HTML_TEST_1 || reTestFlag == HTML_TEST_MSI ) {\n\n fprintf( stdout, \"Rule Initialization Time = %.2f millisecs<BR>n\", ( float )( ht2 - ht1 ) / 1000000 );\n\n fprintf( stdout, \"Rule Execution Time = %.2f millisecs<BR>\\n\", ( float )( ht3 - ht1 ) / 1000000 );\n\n }\n\n if ( i != 0 ) {\n", "file_path": "iRODS/server/test/src/reTest.cpp", "rank": 84, "score": 29.205458266673062 }, { "content": " }\n\n if ( reLoopBackFlag > 0 ) {\n\n return 0;\n\n }\n\n }\n\n /**** This is Just a Test Stub ****/\n\n return 0;\n\n}\n\n\n\nint msiAsynchExecution( msParam_t* xactionList, ruleExecInfo_t *rei ) {\n\n char *actionList;\n\n\n\n actionList = ( char * ) xactionList->inOutStruct;\n\n\n\n /**** This is Just a Test Stub ****/\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 ) {\n\n fprintf( stdout, \" Initiating Asynchronous Execution for %s \\n\", actionList );\n\n }\n\n else if ( reTestFlag == HTML_TEST_1 ) {\n", "file_path": "iRODS/server/re/src/juststubsMS.cpp", "rank": 85, "score": 28.896015204710704 }, { "content": " char ruleSet[RULE_SET_DEF_LENGTH];\n\n hrtime_t ht1, ht2, ht3;\n\n\n\n bzero( &rei, sizeof( ruleExecInfo_t ) ); /* June 17. 2009 */\n\n /*\n\n sprintf(configDirEV,\"irodsConfigDir=/scratch/s1/sekar/irods/RODS/server/config\");\n\n sprintf(configDirEV,\"irodsConfigDir=/misc/www/projects/srb-secure/cgi-bin\");\n\n putenv(configDirEV);\n\n */\n\n sprintf( retestflagEV, \"RETESTFLAG=%i\", HTML_TEST_1 );\n\n putenv( retestflagEV );\n\n sprintf( reloopbackflagEV, \"RELOOPBACKFLAG=%i\", LOOP_BACK_1 );\n\n putenv( reloopbackflagEV );\n\n\n\n fprintf( stdout, \"Content-type: text/html%c%c\", 10, 10 );\n\n fflush( stdout );\n\n fprintf( stdout, \"<HTML>\\n<HEAD>\\n<TITLE>iRODS Rule Administration</TITLE>\\n</HEAD>\\n<BODY bgcolor=#FFFFFF>\\n\" );\n\n fprintf( stdout, \"<CENTER> <B><FONT COLOR=#FF0000>iRODS Rule Application</FONT></B></CENTER>\\n\" );\n\n fflush( stdout );\n\n\n", "file_path": "iRODS/server/re/src/ruleAdmin.cpp", "rank": 86, "score": 28.42894931849118 }, { "content": "\n\n\n\n\n\nint\n\nmsiDeleteData( ruleExecInfo_t *rei ) {\n\n\n\n /**** This is Just a Test Stub ****/\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1 ) {\n\n print_doi( rei->doi );\n\n }\n\n else {\n\n rodsLog( LOG_NOTICE, \" Calling chlDelDataObj\\n\" );\n\n print_doi( rei->doi );\n\n }\n\n if ( reLoopBackFlag > 0 ) {\n\n return 0;\n\n }\n\n }\n\n /**** This is Just a Test Stub ****/\n", "file_path": "iRODS/server/re/src/juststubsMS.cpp", "rank": 87, "score": 27.955378477054836 }, { "content": " * \\return integer\n\n * \\retval (i)\n\n * \\pre none\n\n * \\post none\n\n * \\sa none\n\n **/\n\nint msiDeleteCollByAdmin( msParam_t* xparColl, msParam_t* xchildName, ruleExecInfo_t *rei ) {\n\n int i;\n\n collInfo_t collInfo;\n\n char *parColl;\n\n char *childName;\n\n\n\n parColl = ( char * ) xparColl->inOutStruct;\n\n childName = ( char * ) xchildName->inOutStruct;\n\n /**** This is Just a Test Stub ****/\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1 ) {\n\n fprintf( stdout, \" NewCollection =%s/%s\\n\",\n\n parColl, childName );\n\n }\n", "file_path": "iRODS/server/re/src/icatAdminMS.cpp", "rank": 88, "score": 27.802228185633318 }, { "content": " char *errAction = getNodeType( nodei ) == N_APPLICATION ? N_APP_FUNC( nodei )->text : nodei->text;\n\n sprintf( tmpStr, \"executeRuleAction Failed for %s\", errAction );\n\n rodsLogError( LOG_ERROR, RES_ERR_CODE( res ), tmpStr );\n\n rodsLog( LOG_NOTICE, \"executeRuleBody: Microservice or Action %s Failed with status %i\", errAction, RES_ERR_CODE( res ) );\n\n#endif\n\n /* run recovery chain */\n\n if ( RES_ERR_CODE( res ) != RETRY_WITHOUT_RECOVERY_ERR && reco != NULL ) {\n\n int i2;\n\n for ( i2 = reco->degree - 1 < i ? reco->degree - 1 : i; i2 >= 0; i2-- ) {\n\n#ifndef DEBUG\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 || COMMAND_TEST_MSI ) {\n\n fprintf( stdout, \"***RollingBack\\n\" );\n\n }\n\n else if ( reTestFlag == HTML_TEST_1 ) {\n\n fprintf( stdout, \"<FONT COLOR=#FF0000>***RollingBack</FONT><BR>\\n\" );\n\n }\n\n else if ( reTestFlag == LOG_TEST_1 )\n\n if ( rei != NULL && rei->rsComm != NULL && &( rei->rsComm->rError ) != NULL ) {\n\n rodsLog( LOG_NOTICE, \"***RollingBack\\n\" );\n", "file_path": "iRODS/server/re/src/arithmetics.cpp", "rank": 89, "score": 27.793930855695137 }, { "content": "\n\nint main( int argc, char **argv ) {\n\n\n\n inStruct Sentries = ( paramIn* )malloc( sizeof( paramIn ) );\n\n\n\n\n\n /**to print QUERY_STRING remove the blank between STAR and SLASH * /\n\n fprintf(stdout, \"Content-type: text/html%c%c\",10,10);fflush(stdout);\n\n fprintf(stdout, \"<HTML>\\n<HEAD>\\n<TITLE>iRODS Rule Administration</TITLE>\\n</HEAD>\\n<BODY bgcolor=#FFFFFF>\\n\");\n\n fprintf(stdout, \"<CENTER> <B><FONT COLOR=#FF0000>iRODS Rule Base</FONT></B></CENTER>\\n\");\n\n fprintf(stdout, \"QUERY=%s\\n\",getenv(\"QUERY_STRING\"));\n\n fflush(stdout);\n\n fprintf(stdout, \"</BODY></HTML>\\n\");\n\n exit(0);\n\n /****/\n\n /*** make below as comment for commandline\n\n testing by PUTTING space between last star and slash in this line **/\n\n getEntries( Sentries );\n\n /******/\n\n /*** uncomment below for commandline testing of APPLYRULE\n", "file_path": "iRODS/server/re/src/ruleAdmin.cpp", "rank": 90, "score": 27.670555272467077 }, { "content": " memset( ( void* )test, 0, SIZEOFFILENAME );\n\n if ( memcmp( test, fname, SIZEOFFILENAME ) == 0 ) {\n\n return RB_SUCCESS;\n\n }\n\n //otherwise, get the filename\n\n\n\n if ( verbose > 0 ) {\n\n fprintf( stderr, \"Send file %s\\n\", fname );\n\n }\n\n\n\n int fd = open( fname, O_RDONLY );\n\n if ( fd < 0 ) {\n\n fprintf( stderr, \"open file failed.\\n\" );\n\n return FAILED;\n\n }\n\n\n\n off_t lseek_return = lseek( fd, 0, SEEK_END );\n\n int errsv = errno;\n\n if ( ( off_t ) - 1 == lseek_return ) {\n\n fprintf( stderr, \"SEEK_END lseek failed with error %d.\\n\", errsv );\n", "file_path": "iRODS/lib/rbudp/src/QUANTAnet_rbudpSender_c.cpp", "rank": 91, "score": 27.235069587714065 }, { "content": " fprintf( stdout, \">>>>Initiating Asynchronous Execution for %s<BR>\\n\", actionList );\n\n }\n\n else if ( reTestFlag == LOG_TEST_1 ) {\n\n rodsLog( LOG_NOTICE, \" Calling msiAsynchExecution\\n\" );\n\n rodsLog( LOG_NOTICE, \" For Actions = %s\\n\", actionList );\n\n }\n\n if ( reLoopBackFlag > 0 ) {\n\n return 0;\n\n }\n\n }\n\n /**** This is Just a Test Stub ****/\n\n return 0;\n\n}\n\n\n\nint msiParallelExecution( msParam_t* xactionList, ruleExecInfo_t *rei ) {\n\n char *actionList;\n\n\n\n actionList = ( char * ) xactionList->inOutStruct;\n\n\n\n /**** This is Just a Test Stub ****/\n", "file_path": "iRODS/server/re/src/juststubsMS.cpp", "rank": 92, "score": 27.2287646235716 }, { "content": "\n\nint msiOutSource( msParam_t* xremoteHostInfo, msParam_t* xactionList, ruleExecInfo_t *rei ) {\n\n char *remoteHostInfo;\n\n char *actionList;\n\n\n\n remoteHostInfo = ( char * ) xremoteHostInfo->inOutStruct;\n\n actionList = ( char * ) xactionList->inOutStruct;\n\n\n\n /**** This is Just a Test Stub ****/\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 ) {\n\n fprintf( stdout, \" OutSourcing Execution for %s to Host %s \\n\", actionList, remoteHostInfo );\n\n }\n\n else if ( reTestFlag == HTML_TEST_1 ) {\n\n fprintf( stdout, \">>>>OutSourcing Execution of %s to Host %s<BR>\\n\", actionList, remoteHostInfo );\n\n }\n\n else if ( reTestFlag == LOG_TEST_1 ) {\n\n rodsLog( LOG_NOTICE, \" Calling msiOutSource\\n\" );\n\n rodsLog( LOG_NOTICE, \" For Actions = %s\\n\", actionList );\n\n rodsLog( LOG_NOTICE, \" To Host = %s\\n\", remoteHostInfo );\n", "file_path": "iRODS/server/re/src/juststubsMS.cpp", "rank": 93, "score": 27.22655246393585 }, { "content": " if ( GlobalREAuditFlag > 0 ) {\n\n RuleEngineEventParam param;\n\n param.actionName = ruleName;\n\n param.ruleIndex = ruleInx;\n\n reDebug( GOT_RULE, 0, &param, rule, env, rei );\n\n\n\n }\n\n\n\n#ifndef DEBUG\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 ) {\n\n fprintf( stdout, \"+Testing Rule Number:%i for Action:%s\\n\", ruleInx, ruleName );\n\n }\n\n else if ( reTestFlag == HTML_TEST_1 ) {\n\n fprintf( stdout, \"+Testing Rule Number:<FONT COLOR=#FF0000>%i</FONT> for Action:<FONT COLOR=#0000FF>%s</FONT><BR>\\n\", ruleInx, ruleName );\n\n }\n\n else if ( rei != 0 && rei->rsComm != 0 && &( rei->rsComm->rError ) != 0 ) {\n\n rodsLog( LOG_NOTICE, \"+Testing Rule Number:%i for Action:%s\\n\", ruleInx, ruleName );\n\n }\n\n }\n", "file_path": "iRODS/server/re/src/arithmetics.cpp", "rank": 94, "score": 27.071264207949582 }, { "content": "/*** Copyright (c), The Regents of the University of California ***\n\n *** For more information please refer to files in the COPYRIGHT directory ***/\n\n#include \"reGlobalsExtern.hpp\"\n\n#include \"icatHighLevelRoutines.hpp\"\n\n#include \"rsGlobalExtern.hpp\"\n\n#include \"dataObjCreate.hpp\"\n\n#include \"objMetaOpr.hpp\"\n\n#include \"regDataObj.hpp\"\n\n/* #include \"reAction.hpp\" */\n\n#include \"miscServerFunct.hpp\"\n\n\n\n\n\nint\n\nmsiGetClosestResourceToClient( ruleExecInfo_t *rei ) {\n\n /**** This is Just a Test Stub ****/\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == LOG_TEST_1 ) {\n\n rodsLog( LOG_NOTICE, \" Calling GetClosestResourceToClient\\n\" );\n\n }\n\n if ( strlen( rei->uoic->authInfo.host ) != 0 && strcmp( rei->uoic->authInfo.host, \"null\" ) ) {\n", "file_path": "iRODS/server/re/src/juststubsMS.cpp", "rank": 96, "score": 25.91374215505061 }, { "content": "\n\n if ( reTestFlag > 0 ) {\n\n if ( reTestFlag == COMMAND_TEST_1 ) {\n\n fprintf( stdout, \" Sending Email\\n To:%s\\n Subject:%s\\n Body:%s\\n\",\n\n toAddr, subjectLine, body );\n\n }\n\n else if ( reTestFlag == HTML_TEST_1 ) {\n\n fprintf( stdout, \"Sending Email\\n<UL>\\n\" );\n\n fprintf( stdout, \"<LI>To: %s\\n\", toAddr );\n\n fprintf( stdout, \"<LI>subjectLine: %s\\n\", subjectLine );\n\n fprintf( stdout, \"<LI>Body: %s\\n\", body );\n\n fprintf( stdout, \"</UL>\\n\" );\n\n }\n\n else if ( reTestFlag == LOG_TEST_1 )\n\n rodsLog( LOG_NOTICE, \" Calling msiSendMail To:%s Subject %s\\n\",\n\n toAddr, subjectLine );\n\n if ( reLoopBackFlag > 0 ) {\n\n return 0;\n\n }\n\n }\n", "file_path": "iRODS/server/re/src/mailMS.cpp", "rank": 97, "score": 24.58720315452426 }, { "content": " * \\param[in,out] rei - The RuleExecInfo structure that is automatically\n\n * handled by the rule engine. The user does not include rei as a\n\n * parameter in the rule invocation.\n\n *\n\n * \\DolVarDependence none\n\n * \\DolVarModified - rei->MsParamArray->MsParam->ruleExecOut->stdout is modified\n\n * \\iCatAttrDependence none\n\n * \\iCatAttrModified none\n\n * \\sideeffect none\n\n *\n\n * \\return integer\n\n * \\retval 0 on success\n\n * \\pre none\n\n * \\post none\n\n * \\sa msiAdmShowDVM\n\n**/\n\nint msiAdmShowFNM( msParam_t*, ruleExecInfo_t* rei ) {\n\n int i;\n\n\n\n _writeString( \"stdout\", \"----------------------------- FNM -----------------------------\\n\", rei );\n", "file_path": "iRODS/server/re/src/nre.ruleAdminMS.cpp", "rank": 98, "score": 24.449774514625144 }, { "content": "// =-=-=-=-=-=-=-\n\n#include \"msParam.h\"\n\n#include \"reGlobalsExtern.h\"\n\n#include \"irods_ms_plugin.h\"\n\n\n\n// =-=-=-=-=-=-=-\n\n// STL Includes\n\n#include <iostream>\n\n\n\nextern \"C\" {\n\n\n\n // =-=-=-=-=-=-=-\n\n // 1. Write a standard issue microservice\n\n int irods_msvc_test( msParam_t* _a, msParam_t* _b, msParam_t* _c, ruleExecInfo_t* _rei ) {\n\n std::cout << \"irods_msvc_test :: \" << parseMspForStr( _a ) << \" \" << parseMspForStr( _b ) << \" \" << parseMspForStr( _c ) << std::endl;\n\n return 0;\n\n }\n\n\n\n // =-=-=-=-=-=-=-\n\n // 2. Create the plugin factory function which will return a microservice\n", "file_path": "tests/plugins/microservice/msvc_test.cpp", "rank": 99, "score": 24.36052479955692 } ]
C++
src/ukf.cpp
lb5160482/Sensor-Fusion-Unscented-Kalman-Filter
4636755b6a5dcc25f181684796d3ade82cb943f9
#include "ukf.h" #include "Eigen/Dense" #include <iostream> using namespace std; using Eigen::MatrixXd; using Eigen::VectorXd; using std::vector; UKF::UKF() { is_initialized_ = false; use_laser_ = true; use_radar_ = true; x_ = VectorXd(5); x_pred = VectorXd(5); P_ = MatrixXd::Identity(5, 5); P_pred = MatrixXd(5, 5); std_a_ = 2; std_yawdd_ = 0.5; std_laspx_ = 0.15; std_laspy_ = 0.15; std_radr_ = 0.3; std_radphi_ = 0.03; std_radrd_ = 0.3; n_x_ = 5; n_aug_ = 7; n_z_radar_ = 3; n_z_lidar_ = 2; lambda_ = 3 - n_x_; weights_ = VectorXd(2 * n_aug_ + 1); weights_(0) = lambda_ / (lambda_ + n_aug_); for (int i = 1; i < 2 * n_aug_ + 1; ++i) { weights_(i) = 1 / (2 * (lambda_ + n_aug_)); } Xsig_pred_ = MatrixXd(n_x_, 2 * n_aug_ + 1); } UKF::~UKF() {} void UKF::ProcessMeasurement(MeasurementPackage meas_package) { if ((!use_laser_ && meas_package.sensor_type_ == MeasurementPackage::LASER) || (!use_radar_ && meas_package.sensor_type_ == MeasurementPackage::RADAR)) { return; } if (!is_initialized_) { x_.fill(0.0); if (meas_package.sensor_type_ == MeasurementPackage::LASER) { float px = meas_package.raw_measurements_(0); float py = meas_package.raw_measurements_(1); x_(0) = px; x_(1) = py; cout << "Initialization finished with Laser data!" << endl; } else { float rho = meas_package.raw_measurements_(0); float phi = meas_package.raw_measurements_(1); float px = cos(phi) * rho; float py = sin(phi) * rho; x_(0) = px; x_(1) = py; cout << "Initialization finished with Radar data!" << endl; } is_initialized_ = true; time_us_ = meas_package.timestamp_; return; } double dt = (meas_package.timestamp_ - time_us_) / 1000000.0; time_us_ = meas_package.timestamp_; Prediction(dt); if (meas_package.sensor_type_ == MeasurementPackage::RADAR) { UpdateRadar(meas_package); } else { UpdateLidar(meas_package); } } void UKF::Prediction(double dt) { MatrixXd sigAug = GenerateSigmaAug(); SigPrediction(sigAug, dt); MeanAndCovPrediction(); } void UKF::UpdateLidar(MeasurementPackage meas_package) { MatrixXd ZSig = MatrixXd(n_z_lidar_, 2 * n_aug_ + 1); VectorXd zPred = VectorXd(n_z_lidar_); MatrixXd S = MatrixXd(n_z_lidar_,n_z_lidar_); ZSig.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd xPred = Xsig_pred_.col(i); double px = xPred(0); double py = xPred(1); ZSig(0, i) = px; ZSig(1, i) = py; } zPred.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { zPred += weights_(i) * ZSig.col(i); } MatrixXd R = MatrixXd(2, 2); R << std_laspx_ * std_laspx_, 0, 0, std_laspy_ * std_laspy_; S.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diff = ZSig.col(i) - zPred; S += weights_(i) * diff * diff.transpose(); } S += R; MatrixXd Tc = MatrixXd(n_x_, n_z_lidar_); Tc.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diffX = Xsig_pred_.col(i) - x_pred; while (diffX(3) < -M_PI) { diffX(3) += 2 * M_PI; } while (diffX(3) > M_PI) { diffX(3) -= 2 * M_PI; } VectorXd diffZ = ZSig.col(i) - zPred; Tc += weights_(i) * diffX * diffZ.transpose(); } MatrixXd K = Tc * S.inverse(); VectorXd diffZ = meas_package.raw_measurements_ - zPred; this->x_ = this->x_pred + K * diffZ; this->P_ = this->P_pred - K * S * K.transpose(); } void UKF::UpdateRadar(MeasurementPackage meas_package) { MatrixXd ZSig = MatrixXd(n_z_radar_, 2 * n_aug_ + 1); VectorXd zPred = VectorXd(n_z_radar_); MatrixXd S = MatrixXd(n_z_radar_,n_z_radar_); ZSig.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd xPred = Xsig_pred_.col(i); double px = xPred(0); double py = xPred(1); double v = xPred(2); double yaw = xPred(3); double c1 = sqrt(px * px + py * py); ZSig(0, i) = c1; ZSig(1, i) = atan2(py, px); ZSig(2, i) = (px * cos(yaw) * v + py * sin(yaw) * v) / c1; } zPred.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { zPred += weights_(i) * ZSig.col(i); } MatrixXd R = MatrixXd(3, 3); R << std_radr_ * std_radr_, 0, 0, 0, std_radphi_ * std_radphi_, 0, 0, 0, std_radrd_ * std_radrd_ ; S.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diff = ZSig.col(i) - zPred; while (diff(1) < -M_PI) { diff(1) += 2 * M_PI; } while (diff(1) > M_PI) { diff(1) -= 2 * M_PI; } S += weights_(i) * diff * diff.transpose(); } S += R; MatrixXd Tc = MatrixXd(n_x_, n_z_radar_); Tc.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diffX = Xsig_pred_.col(i) - x_pred; while (diffX(3) < -M_PI) { diffX(3) += 2 * M_PI; } while (diffX(3) > M_PI) { diffX(3) -= 2 * M_PI; } VectorXd diffZ = ZSig.col(i) - zPred; while (diffZ(1) < -M_PI) { diffZ(1) += 2 * M_PI; } while (diffZ(1) > M_PI) { diffZ(1) -= 2 * M_PI; } Tc += weights_(i) * diffX * diffZ.transpose(); } MatrixXd K = Tc * S.inverse(); VectorXd diffZ = meas_package.raw_measurements_ - zPred; while (diffZ(1) < -M_PI) { diffZ(1) += 2 * M_PI; } while (diffZ(1) > M_PI) { diffZ(1) -= 2 * M_PI; } this->x_ = this->x_pred + K * diffZ; this->P_ = this->P_pred - K * S * K.transpose(); } MatrixXd UKF::GenerateSigmaAug() { VectorXd xAug = VectorXd(n_aug_); xAug.head(n_x_) = this->x_; xAug[5] = 0; xAug[6] = 0; MatrixXd PAug = MatrixXd::Zero(n_aug_, n_aug_); PAug.fill(0.0); PAug.topLeftCorner(n_x_, n_x_) = this->P_; PAug(5, 5) = std_a_ * std_a_; PAug(6, 6) = std_yawdd_ * std_yawdd_; MatrixXd xSigAUg = MatrixXd(n_aug_, 2 * n_aug_ + 1); MatrixXd sqrtPAug = PAug.llt().matrixL(); xSigAUg.col(0) = xAug; for (int i = 0; i < n_aug_; ++i) { xSigAUg.col(i + 1) = xAug + sqrt(lambda_ + n_aug_) * sqrtPAug.col(i); xSigAUg.col(i + 1 + n_aug_) = xAug - sqrt(lambda_ + n_aug_) * sqrtPAug.col(i); } return xSigAUg; } void UKF::SigPrediction(MatrixXd& sigAug, double dt) { for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd xSigAug = sigAug.col(i); double px = xSigAug(0); double py = xSigAug(1); double v = xSigAug(2); double yaw = xSigAug(3); double yawRate = xSigAug(4); double aV = xSigAug(5); double aYaw = xSigAug(6); if (fabs(yawRate) < 0.001) { this->Xsig_pred_(0, i) = px + v * cos(yaw) * dt + 0.5 * pow(dt, 2) * cos(yaw) * aV; this->Xsig_pred_(1, i) = py + v * sin(yaw) * dt + 0.5 * pow(dt, 2) * sin(yaw) * aV; } else { this->Xsig_pred_(0, i) = px + v / yawRate * (sin(yaw + yawRate * dt) - sin(yaw)) + 0.5 * pow(dt, 2) * cos(yaw) * aV; this->Xsig_pred_(1, i) = py + v / yawRate * (-cos(yaw + yawRate * dt) + cos(yaw)) + 0.5 * pow(dt, 2) * sin(yaw) * aV; } this->Xsig_pred_(2, i) = v + dt * aV; this->Xsig_pred_(3, i) = yaw + yawRate * dt + 0.5 * pow(dt, 2) * aYaw; this->Xsig_pred_(4, i) = yawRate + dt * aYaw; } } void UKF::MeanAndCovPrediction() { this->x_pred.fill(0.0); this->P_pred.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { this->x_pred += weights_(i) * Xsig_pred_.col(i); } for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diff = Xsig_pred_.col(i) - this->x_pred; while (diff(3) < -M_PI) { diff(3) += 2 * M_PI; } while (diff(3) > M_PI) { diff(3) -= 2 * M_PI; } this->P_pred += weights_(i) * diff * diff.transpose(); } }
#include "ukf.h" #include "Eigen/Dense" #include <iostream> using namespace std; using Eigen::MatrixXd; using Eigen::VectorXd; using std::vector; UKF::UKF() { is_initialized_ = false; use_laser_ = true; use_radar_ = true; x_ = VectorXd(5); x_pred = VectorXd(5); P_ = MatrixXd::Identity(5, 5); P_pred = MatrixXd(5, 5); std_a_ = 2; std_yawdd_ = 0.5; std_laspx_ = 0.15; std_laspy_ = 0.15; std_radr_ = 0.3; std_radphi_ = 0.03; std_radrd_ = 0.3; n_x_ = 5; n_aug_ = 7; n_z_radar_ = 3; n_z_lidar_ = 2; lambda_ = 3 - n_x_; weights_ = VectorXd(2 * n_aug_ + 1); weights_(0) = lambda_ / (lambda_ + n_aug_); for (int i = 1; i < 2 * n_aug_ + 1; ++i) { weights_(i) = 1 / (2 * (lambda_ + n_aug_)); } Xsig_pred_ = MatrixXd(n_x_, 2 * n_aug_ + 1); } UKF::~UKF() {} void UKF::ProcessMeasurement(MeasurementPackage meas_package) { if ((!use_laser_ && meas_package.sensor_type_ == MeasurementPackage::LASER) || (!use_radar_ && meas_package.sensor_type_ == MeasurementPackage::RADAR)) { return; } if (!is_initialized_) { x_.fill(0.0); if (meas_package.sensor_type_ == MeasurementPackage::LASER) { float px = meas_package.raw_measurements_(0); float py = meas_package.raw_measurements_(1); x_(0) = px; x_(1) = py; cout << "Initialization finished with Laser data!" << endl; } else { float rho = meas_package.raw_measurements_(0); float phi = meas_package.raw_measurements_(1); float px = cos(phi) * rho; float py = sin(phi) * rho; x_(0) = px; x_(1) = py; cout << "Initialization finished with Radar data!" << endl; } is_initialized_ = true; time_us_ = meas_package.timestamp_; return; } double dt = (meas_package.timestamp_ - time_us_) / 1000000.0; time_us_ = meas_package.timestamp_; Prediction(dt);
} void UKF::Prediction(double dt) { MatrixXd sigAug = GenerateSigmaAug(); SigPrediction(sigAug, dt); MeanAndCovPrediction(); } void UKF::UpdateLidar(MeasurementPackage meas_package) { MatrixXd ZSig = MatrixXd(n_z_lidar_, 2 * n_aug_ + 1); VectorXd zPred = VectorXd(n_z_lidar_); MatrixXd S = MatrixXd(n_z_lidar_,n_z_lidar_); ZSig.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd xPred = Xsig_pred_.col(i); double px = xPred(0); double py = xPred(1); ZSig(0, i) = px; ZSig(1, i) = py; } zPred.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { zPred += weights_(i) * ZSig.col(i); } MatrixXd R = MatrixXd(2, 2); R << std_laspx_ * std_laspx_, 0, 0, std_laspy_ * std_laspy_; S.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diff = ZSig.col(i) - zPred; S += weights_(i) * diff * diff.transpose(); } S += R; MatrixXd Tc = MatrixXd(n_x_, n_z_lidar_); Tc.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diffX = Xsig_pred_.col(i) - x_pred; while (diffX(3) < -M_PI) { diffX(3) += 2 * M_PI; } while (diffX(3) > M_PI) { diffX(3) -= 2 * M_PI; } VectorXd diffZ = ZSig.col(i) - zPred; Tc += weights_(i) * diffX * diffZ.transpose(); } MatrixXd K = Tc * S.inverse(); VectorXd diffZ = meas_package.raw_measurements_ - zPred; this->x_ = this->x_pred + K * diffZ; this->P_ = this->P_pred - K * S * K.transpose(); } void UKF::UpdateRadar(MeasurementPackage meas_package) { MatrixXd ZSig = MatrixXd(n_z_radar_, 2 * n_aug_ + 1); VectorXd zPred = VectorXd(n_z_radar_); MatrixXd S = MatrixXd(n_z_radar_,n_z_radar_); ZSig.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd xPred = Xsig_pred_.col(i); double px = xPred(0); double py = xPred(1); double v = xPred(2); double yaw = xPred(3); double c1 = sqrt(px * px + py * py); ZSig(0, i) = c1; ZSig(1, i) = atan2(py, px); ZSig(2, i) = (px * cos(yaw) * v + py * sin(yaw) * v) / c1; } zPred.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { zPred += weights_(i) * ZSig.col(i); } MatrixXd R = MatrixXd(3, 3); R << std_radr_ * std_radr_, 0, 0, 0, std_radphi_ * std_radphi_, 0, 0, 0, std_radrd_ * std_radrd_ ; S.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diff = ZSig.col(i) - zPred; while (diff(1) < -M_PI) { diff(1) += 2 * M_PI; } while (diff(1) > M_PI) { diff(1) -= 2 * M_PI; } S += weights_(i) * diff * diff.transpose(); } S += R; MatrixXd Tc = MatrixXd(n_x_, n_z_radar_); Tc.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diffX = Xsig_pred_.col(i) - x_pred; while (diffX(3) < -M_PI) { diffX(3) += 2 * M_PI; } while (diffX(3) > M_PI) { diffX(3) -= 2 * M_PI; } VectorXd diffZ = ZSig.col(i) - zPred; while (diffZ(1) < -M_PI) { diffZ(1) += 2 * M_PI; } while (diffZ(1) > M_PI) { diffZ(1) -= 2 * M_PI; } Tc += weights_(i) * diffX * diffZ.transpose(); } MatrixXd K = Tc * S.inverse(); VectorXd diffZ = meas_package.raw_measurements_ - zPred; while (diffZ(1) < -M_PI) { diffZ(1) += 2 * M_PI; } while (diffZ(1) > M_PI) { diffZ(1) -= 2 * M_PI; } this->x_ = this->x_pred + K * diffZ; this->P_ = this->P_pred - K * S * K.transpose(); } MatrixXd UKF::GenerateSigmaAug() { VectorXd xAug = VectorXd(n_aug_); xAug.head(n_x_) = this->x_; xAug[5] = 0; xAug[6] = 0; MatrixXd PAug = MatrixXd::Zero(n_aug_, n_aug_); PAug.fill(0.0); PAug.topLeftCorner(n_x_, n_x_) = this->P_; PAug(5, 5) = std_a_ * std_a_; PAug(6, 6) = std_yawdd_ * std_yawdd_; MatrixXd xSigAUg = MatrixXd(n_aug_, 2 * n_aug_ + 1); MatrixXd sqrtPAug = PAug.llt().matrixL(); xSigAUg.col(0) = xAug; for (int i = 0; i < n_aug_; ++i) { xSigAUg.col(i + 1) = xAug + sqrt(lambda_ + n_aug_) * sqrtPAug.col(i); xSigAUg.col(i + 1 + n_aug_) = xAug - sqrt(lambda_ + n_aug_) * sqrtPAug.col(i); } return xSigAUg; } void UKF::SigPrediction(MatrixXd& sigAug, double dt) { for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd xSigAug = sigAug.col(i); double px = xSigAug(0); double py = xSigAug(1); double v = xSigAug(2); double yaw = xSigAug(3); double yawRate = xSigAug(4); double aV = xSigAug(5); double aYaw = xSigAug(6); if (fabs(yawRate) < 0.001) { this->Xsig_pred_(0, i) = px + v * cos(yaw) * dt + 0.5 * pow(dt, 2) * cos(yaw) * aV; this->Xsig_pred_(1, i) = py + v * sin(yaw) * dt + 0.5 * pow(dt, 2) * sin(yaw) * aV; } else { this->Xsig_pred_(0, i) = px + v / yawRate * (sin(yaw + yawRate * dt) - sin(yaw)) + 0.5 * pow(dt, 2) * cos(yaw) * aV; this->Xsig_pred_(1, i) = py + v / yawRate * (-cos(yaw + yawRate * dt) + cos(yaw)) + 0.5 * pow(dt, 2) * sin(yaw) * aV; } this->Xsig_pred_(2, i) = v + dt * aV; this->Xsig_pred_(3, i) = yaw + yawRate * dt + 0.5 * pow(dt, 2) * aYaw; this->Xsig_pred_(4, i) = yawRate + dt * aYaw; } } void UKF::MeanAndCovPrediction() { this->x_pred.fill(0.0); this->P_pred.fill(0.0); for (int i = 0; i < 2 * n_aug_ + 1; ++i) { this->x_pred += weights_(i) * Xsig_pred_.col(i); } for (int i = 0; i < 2 * n_aug_ + 1; ++i) { VectorXd diff = Xsig_pred_.col(i) - this->x_pred; while (diff(3) < -M_PI) { diff(3) += 2 * M_PI; } while (diff(3) > M_PI) { diff(3) -= 2 * M_PI; } this->P_pred += weights_(i) * diff * diff.transpose(); } }
if (meas_package.sensor_type_ == MeasurementPackage::RADAR) { UpdateRadar(meas_package); } else { UpdateLidar(meas_package); }
if_condition
[ { "content": "struct has_std_result_type {int a[2];};\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 0, "score": 167285.48100387253 }, { "content": "struct has_none {int a[1];};\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 1, "score": 117858.8414467264 }, { "content": "struct has_tr1_result {int a[3];};\n\n\n\ntemplate<typename Func, typename ArgType, int SizeOf=sizeof(has_none)>\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 2, "score": 116982.66867702428 }, { "content": " class NumberFloatType = double,\n\n template<typename U> class AllocatorType = std::allocator,\n\n template<typename T, typename SFINAE = void> class JSONSerializer = adl_serializer\n\n >\n", "file_path": "src/json.hpp", "rank": 3, "score": 107841.60329895356 }, { "content": " static EIGEN_STRONG_INLINE void run(Derived1 &dst, const Derived2 &src)\n", "file_path": "src/Eigen/src/Core/Assign.h", "rank": 4, "score": 99043.3945366029 }, { "content": " inline const Scalar* data() const { return derived().nestedExpression().data(); }\n", "file_path": "src/Eigen/src/Core/Transpose.h", "rank": 5, "score": 98978.76852830077 }, { "content": " class iter_impl : public std::iterator<std::random_access_iterator_tag, U>\n\n {\n\n /// allow basic_json to access private members\n\n friend class basic_json;\n\n\n\n // make sure U is basic_json or const basic_json\n\n static_assert(std::is_same<U, basic_json>::value\n\n or std::is_same<U, const basic_json>::value,\n\n \"iter_impl only accepts (const) basic_json\");\n\n\n\n public:\n\n /// the type of the values when the iterator is dereferenced\n\n using value_type = typename basic_json::value_type;\n\n /// a type to represent differences between iterators\n\n using difference_type = typename basic_json::difference_type;\n\n /// defines a pointer to the type iterated over (value_type)\n\n using pointer = typename std::conditional<std::is_const<U>::value,\n\n typename basic_json::const_pointer,\n\n typename basic_json::pointer>::type;\n\n /// defines a reference to the type iterated over (value_type)\n", "file_path": "src/json.hpp", "rank": 6, "score": 98632.0154449498 }, { "content": " T *data() { return m_data.array; }\n", "file_path": "src/Eigen/src/Core/DenseStorage.h", "rank": 7, "score": 98218.39509366736 }, { "content": " using std::abs;\n", "file_path": "src/Eigen/src/Eigenvalues/EigenSolver.h", "rank": 8, "score": 98165.04233360753 }, { "content": " using std::abs;\n", "file_path": "src/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h", "rank": 9, "score": 97428.36280606539 }, { "content": " using std::abs;\n", "file_path": "src/Eigen/src/QR/FullPivHouseholderQR.h", "rank": 10, "score": 96713.96517053441 }, { "content": " using std::abs;\n", "file_path": "src/Eigen/src/QR/ColPivHouseholderQR.h", "rank": 11, "score": 96713.96517053441 }, { "content": " class vector<__VA_ARGS__, std::allocator<__VA_ARGS__> > \\\n\n : public vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \\\n\n { \\\n\n typedef vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > vector_base; \\\n\n public: \\\n\n typedef __VA_ARGS__ value_type; \\\n\n typedef vector_base::allocator_type allocator_type; \\\n\n typedef vector_base::size_type size_type; \\\n\n typedef vector_base::iterator iterator; \\\n\n explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \\\n\n template<typename InputIterator> \\\n\n vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \\\n\n vector(const vector& c) : vector_base(c) {} \\\n\n explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \\\n\n vector(iterator start, iterator end) : vector_base(start, end) {} \\\n\n vector& operator=(const vector& x) { \\\n\n vector_base::operator=(x); \\\n\n return *this; \\\n\n } \\\n\n }; \\\n", "file_path": "src/Eigen/src/StlSupport/StdVector.h", "rank": 12, "score": 90147.34098685475 }, { "content": " class deque<__VA_ARGS__, std::allocator<__VA_ARGS__> > \\\n\n : public deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \\\n\n { \\\n\n typedef deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > deque_base; \\\n\n public: \\\n\n typedef __VA_ARGS__ value_type; \\\n\n typedef deque_base::allocator_type allocator_type; \\\n\n typedef deque_base::size_type size_type; \\\n\n typedef deque_base::iterator iterator; \\\n\n explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {} \\\n\n template<typename InputIterator> \\\n\n deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : deque_base(first, last, a) {} \\\n\n deque(const deque& c) : deque_base(c) {} \\\n\n explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \\\n\n deque(iterator start, iterator end) : deque_base(start, end) {} \\\n\n deque& operator=(const deque& x) { \\\n\n deque_base::operator=(x); \\\n\n return *this; \\\n\n } \\\n\n }; \\\n", "file_path": "src/Eigen/src/StlSupport/StdDeque.h", "rank": 13, "score": 90147.34098685475 }, { "content": " class list<__VA_ARGS__, std::allocator<__VA_ARGS__> > \\\n\n : public list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \\\n\n { \\\n\n typedef list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > list_base; \\\n\n public: \\\n\n typedef __VA_ARGS__ value_type; \\\n\n typedef list_base::allocator_type allocator_type; \\\n\n typedef list_base::size_type size_type; \\\n\n typedef list_base::iterator iterator; \\\n\n explicit list(const allocator_type& a = allocator_type()) : list_base(a) {} \\\n\n template<typename InputIterator> \\\n\n list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : list_base(first, last, a) {} \\\n\n list(const list& c) : list_base(c) {} \\\n\n explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \\\n\n list(iterator start, iterator end) : list_base(start, end) {} \\\n\n list& operator=(const list& x) { \\\n\n list_base::operator=(x); \\\n\n return *this; \\\n\n } \\\n\n }; \\\n", "file_path": "src/Eigen/src/StlSupport/StdList.h", "rank": 14, "score": 90147.34098685475 }, { "content": "class gebp_traits<std::complex<RealScalar>, std::complex<RealScalar>, _ConjLhs, _ConjRhs >\n\n{\n\npublic:\n\n typedef std::complex<RealScalar> Scalar;\n\n typedef std::complex<RealScalar> LhsScalar;\n\n typedef std::complex<RealScalar> RhsScalar;\n\n typedef std::complex<RealScalar> ResScalar;\n\n \n\n enum {\n\n ConjLhs = _ConjLhs,\n\n ConjRhs = _ConjRhs,\n\n Vectorizable = packet_traits<RealScalar>::Vectorizable\n\n && packet_traits<Scalar>::Vectorizable,\n\n RealPacketSize = Vectorizable ? packet_traits<RealScalar>::size : 1,\n\n ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1,\n\n \n\n nr = 2,\n\n mr = 2 * ResPacketSize,\n\n WorkSpaceFactor = Vectorizable ? 2*nr*RealPacketSize : nr,\n\n\n", "file_path": "src/Eigen/src/Core/products/GeneralBlockPanelKernel.h", "rank": 15, "score": 90112.0267372606 }, { "content": " class StringType = std::string,\n", "file_path": "src/json.hpp", "rank": 16, "score": 89414.23691305207 }, { "content": " class NumberIntegerType = std::int64_t,\n", "file_path": "src/json.hpp", "rank": 17, "score": 88487.69128252404 }, { "content": " class NumberUnsignedType = std::uint64_t,\n", "file_path": "src/json.hpp", "rank": 18, "score": 88487.69128252404 }, { "content": "struct is_compatible_object_type_impl : std::false_type {};\n\n\n\ntemplate<class RealType, class CompatibleObjectType>\n", "file_path": "src/json.hpp", "rank": 19, "score": 86727.06409880464 }, { "content": "struct is_compatible_integer_type_impl : std::false_type {};\n\n\n\ntemplate<typename RealIntegerType, typename CompatibleNumberIntegerType>\n", "file_path": "src/json.hpp", "rank": 20, "score": 86727.06409880464 }, { "content": "struct significant_decimals_default_impl<Scalar, true>\n\n{\n\n static inline int run()\n\n {\n\n return 0;\n\n }\n\n};\n\n\n\ntemplate<typename Scalar>\n", "file_path": "src/Eigen/src/Core/IO.h", "rank": 21, "score": 85865.8977744624 }, { "content": "struct setIdentity_impl<Derived, true>\n\n{\n\n typedef typename Derived::Index Index;\n\n static EIGEN_STRONG_INLINE Derived& run(Derived& m)\n\n {\n\n m.setZero();\n\n const Index size = (std::min)(m.rows(), m.cols());\n\n for(Index i = 0; i < size; ++i) m.coeffRef(i,i) = typename Derived::Scalar(1);\n\n return m;\n\n }\n\n};\n\n\n\n} // end namespace internal\n\n\n\n/** Writes the identity expression (not necessarily square) into *this.\n\n *\n\n * Example: \\include MatrixBase_setIdentity.cpp\n\n * Output: \\verbinclude MatrixBase_setIdentity.out\n\n *\n\n * \\sa class CwiseNullaryOp, Identity(), Identity(Index,Index), isIdentity()\n", "file_path": "src/Eigen/src/Core/CwiseNullaryOp.h", "rank": 22, "score": 85055.65350807254 }, { "content": "struct true_type { enum { value = 1 }; };\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 23, "score": 83594.56890671227 }, { "content": "struct ei_meta_true { enum { ret = 1 }; };\n", "file_path": "src/Eigen/src/Eigen2Support/Meta.h", "rank": 24, "score": 82757.37202333283 }, { "content": "struct is_compatible_object_type_impl<true, RealType, CompatibleObjectType>\n\n{\n\n static constexpr auto value =\n\n std::is_constructible<typename RealType::key_type,\n\n typename CompatibleObjectType::key_type>::value and\n\n std::is_constructible<typename RealType::mapped_type,\n\n typename CompatibleObjectType::mapped_type>::value;\n\n};\n\n\n\ntemplate<class BasicJsonType, class CompatibleObjectType>\n", "file_path": "src/json.hpp", "rank": 25, "score": 81124.55305422665 }, { "content": "struct conservative_resize_like_impl<Derived,OtherDerived,true>\n\n : conservative_resize_like_impl<Derived,OtherDerived,false>\n\n{\n\n using conservative_resize_like_impl<Derived,OtherDerived,false>::run;\n\n \n\n typedef typename Derived::Index Index;\n\n static void run(DenseBase<Derived>& _this, Index size)\n\n {\n\n const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size;\n\n const Index new_cols = Derived::RowsAtCompileTime==1 ? size : 1;\n\n _this.derived().m_storage.conservativeResize(size,new_rows,new_cols);\n\n }\n\n\n\n static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)\n\n {\n\n if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;\n\n\n\n const Index num_new_elements = other.size() - _this.size();\n\n\n\n const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : other.rows();\n\n const Index new_cols = Derived::RowsAtCompileTime==1 ? other.cols() : 1;\n\n _this.derived().m_storage.conservativeResize(other.size(),new_rows,new_cols);\n\n\n\n if (num_new_elements > 0)\n\n _this.tail(num_new_elements) = other.tail(num_new_elements);\n\n }\n\n};\n\n\n\ntemplate<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>\n", "file_path": "src/Eigen/src/Core/PlainObjectBase.h", "rank": 26, "score": 80364.45109234157 }, { "content": " class json_reverse_iterator : public std::reverse_iterator<Base>\n\n {\n\n public:\n\n /// shortcut to the reverse iterator adaptor\n\n using base_iterator = std::reverse_iterator<Base>;\n\n /// the reference type for the pointed-to element\n\n using reference = typename Base::reference;\n\n\n\n /// create reverse iterator from iterator\n\n json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept\n\n : base_iterator(it)\n\n {}\n\n\n\n /// create reverse iterator from base class\n\n json_reverse_iterator(const base_iterator& it) noexcept\n\n : base_iterator(it)\n\n {}\n\n\n\n /// post-increment (it++)\n\n json_reverse_iterator operator++(int)\n", "file_path": "src/json.hpp", "rank": 27, "score": 80104.07114964789 }, { "content": "struct is_compatible_integer_type_impl<true, RealIntegerType, CompatibleNumberIntegerType>\n\n{\n\n // is there an assert somewhere on overflows?\n\n using RealLimits = std::numeric_limits<RealIntegerType>;\n\n using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;\n\n\n\n static constexpr auto value =\n\n std::is_constructible<RealIntegerType,\n\n CompatibleNumberIntegerType>::value and\n\n CompatibleLimits::is_integer and\n\n RealLimits::is_signed == CompatibleLimits::is_signed;\n\n};\n\n\n\ntemplate<typename RealIntegerType, typename CompatibleNumberIntegerType>\n", "file_path": "src/json.hpp", "rank": 28, "score": 79627.69249256462 }, { "content": "class aligned_allocator : public std::allocator<T>\n\n{\n\npublic:\n\n typedef size_t size_type;\n\n typedef std::ptrdiff_t difference_type;\n\n typedef T* pointer;\n\n typedef const T* const_pointer;\n\n typedef T& reference;\n\n typedef const T& const_reference;\n\n typedef T value_type;\n\n\n\n template<class U>\n\n struct rebind\n\n {\n\n typedef aligned_allocator<U> other;\n\n };\n\n\n\n aligned_allocator() : std::allocator<T>() {}\n\n\n\n aligned_allocator(const aligned_allocator& other) : std::allocator<T>(other) {}\n", "file_path": "src/Eigen/src/Core/util/Memory.h", "rank": 29, "score": 79293.91384230394 }, { "content": "struct matrix_swap_impl<MatrixTypeA, MatrixTypeB, true>\n\n{\n\n static inline void run(MatrixTypeA& a, MatrixTypeB& b)\n\n {\n\n static_cast<typename MatrixTypeA::Base&>(a).m_storage.swap(static_cast<typename MatrixTypeB::Base&>(b).m_storage);\n\n }\n\n};\n\n\n\n} // end namespace internal\n\n\n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN_DENSESTORAGEBASE_H\n", "file_path": "src/Eigen/src/Core/PlainObjectBase.h", "rank": 30, "score": 78913.21817644802 }, { "content": "struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, true>\n\n{\n\n typedef JacobiSVD<MatrixType, QRPreconditioner> SVD;\n\n typedef typename SVD::Index Index;\n\n typedef typename MatrixType::Scalar Scalar;\n\n typedef typename MatrixType::RealScalar RealScalar;\n\n static bool run(typename SVD::WorkMatrixType& work_matrix, SVD& svd, Index p, Index q, RealScalar& maxDiagEntry)\n\n {\n\n using std::sqrt;\n\n using std::abs;\n\n using std::max;\n\n Scalar z;\n\n JacobiRotation<Scalar> rot;\n\n RealScalar n = sqrt(numext::abs2(work_matrix.coeff(p,p)) + numext::abs2(work_matrix.coeff(q,p)));\n\n\n\n const RealScalar considerAsZero = (std::numeric_limits<RealScalar>::min)();\n\n const RealScalar precision = NumTraits<Scalar>::epsilon();\n\n\n\n if(n==0)\n\n {\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 31, "score": 78913.21817644802 }, { "content": "struct rotation_base_generic_product_selector<RotationDerived,OtherVectorType,true>\n\n{\n\n enum { Dim = RotationDerived::Dim };\n\n typedef Matrix<typename RotationDerived::Scalar,Dim,1> ReturnType;\n\n static EIGEN_STRONG_INLINE ReturnType run(const RotationDerived& r, const OtherVectorType& v)\n\n {\n\n return r._transformVector(v);\n\n }\n\n};\n\n\n\n} // end namespace internal\n\n\n\n/** \\geometry_module\n\n *\n\n * \\brief Constructs a Dim x Dim rotation matrix from the rotation \\a r\n\n */\n\ntemplate<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>\n\ntemplate<typename OtherDerived>\n\nMatrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>\n\n::Matrix(const RotationBase<OtherDerived,ColsAtCompileTime>& r)\n", "file_path": "src/Eigen/src/Geometry/RotationBase.h", "rank": 32, "score": 78913.21817644802 }, { "content": "struct gemv_static_vector_if<Scalar,Size,Dynamic,true>\n\n{\n\n EIGEN_STRONG_INLINE Scalar* data() { return 0; }\n\n};\n\n\n\ntemplate<typename Scalar,int Size,int MaxSize>\n", "file_path": "src/Eigen/src/Core/GeneralProduct.h", "rank": 33, "score": 78489.98860123819 }, { "content": "struct gemv_static_vector_if<Scalar,Size,MaxSize,true>\n\n{\n\n #if EIGEN_ALIGN_STATICALLY\n\n internal::plain_array<Scalar,EIGEN_SIZE_MIN_PREFER_FIXED(Size,MaxSize),0> m_data;\n\n EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; }\n\n #else\n\n // Some architectures cannot align on the stack,\n\n // => let's manually enforce alignment by allocating more data and return the address of the first aligned element.\n\n enum {\n\n ForceAlignment = internal::packet_traits<Scalar>::Vectorizable,\n\n PacketSize = internal::packet_traits<Scalar>::size\n\n };\n\n internal::plain_array<Scalar,EIGEN_SIZE_MIN_PREFER_FIXED(Size,MaxSize)+(ForceAlignment?PacketSize:0),0> m_data;\n\n EIGEN_STRONG_INLINE Scalar* data() {\n\n return ForceAlignment\n\n ? reinterpret_cast<Scalar*>((reinterpret_cast<size_t>(m_data.array) & ~(size_t(15))) + 16)\n\n : m_data.array;\n\n }\n\n #endif\n\n};\n", "file_path": "src/Eigen/src/Core/GeneralProduct.h", "rank": 34, "score": 77729.8866393531 }, { "content": "class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>\n\n{\n\npublic:\n\n typedef typename MatrixType::Index Index;\n\n\n\n void allocate(const JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd)\n\n {\n\n if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())\n\n {\n\n m_qr.~QRType();\n\n ::new (&m_qr) QRType(svd.rows(), svd.cols());\n\n }\n\n if (svd.m_computeFullU) m_workspace.resize(svd.rows());\n\n else if (svd.m_computeThinU) m_workspace.resize(svd.cols());\n\n }\n\n\n\n bool run(JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n\n {\n\n if(matrix.rows() > matrix.cols())\n\n {\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 35, "score": 74912.63255689063 }, { "content": "class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>\n\n{\n\npublic:\n\n typedef typename MatrixType::Index Index;\n\n typedef typename MatrixType::Scalar Scalar;\n\n enum\n\n {\n\n RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n\n ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n\n MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n\n MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n\n Options = MatrixType::Options\n\n };\n\n\n\n typedef Matrix<Scalar, ColsAtCompileTime, RowsAtCompileTime, Options, MaxColsAtCompileTime, MaxRowsAtCompileTime>\n\n TransposeTypeWithSameStorageOrder;\n\n\n\n void allocate(const JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd)\n\n {\n\n if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 36, "score": 74912.63255689063 }, { "content": "class qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>\n\n{\n\npublic:\n\n typedef typename MatrixType::Index Index;\n\n\n\n void allocate(const JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd)\n\n {\n\n if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())\n\n {\n\n m_qr.~QRType();\n\n ::new (&m_qr) QRType(svd.rows(), svd.cols());\n\n }\n\n if (svd.m_computeFullU) m_workspace.resize(svd.rows());\n\n else if (svd.m_computeThinU) m_workspace.resize(svd.cols());\n\n }\n\n\n\n bool run(JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd, const MatrixType& matrix)\n\n {\n\n if(matrix.rows() > matrix.cols())\n\n {\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 37, "score": 73624.53214988003 }, { "content": "class qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>\n\n{\n\npublic:\n\n typedef typename MatrixType::Index Index;\n\n typedef typename MatrixType::Scalar Scalar;\n\n enum\n\n {\n\n RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n\n ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n\n MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n\n MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n\n Options = MatrixType::Options\n\n };\n\n\n\n typedef Matrix<Scalar, ColsAtCompileTime, RowsAtCompileTime, Options, MaxColsAtCompileTime, MaxRowsAtCompileTime>\n\n TransposeTypeWithSameStorageOrder;\n\n\n\n void allocate(const JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd)\n\n {\n\n if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 38, "score": 73624.53214988003 }, { "content": "class qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true>\n\n{\n\npublic:\n\n typedef typename MatrixType::Index Index;\n\n typedef typename MatrixType::Scalar Scalar;\n\n enum\n\n {\n\n RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n\n ColsAtCompileTime = MatrixType::ColsAtCompileTime,\n\n MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,\n\n MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,\n\n Options = MatrixType::Options\n\n };\n\n typedef Matrix<Scalar, ColsAtCompileTime, RowsAtCompileTime, Options, MaxColsAtCompileTime, MaxRowsAtCompileTime>\n\n TransposeTypeWithSameStorageOrder;\n\n\n\n void allocate(const JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd)\n\n {\n\n if (svd.cols() != m_qr.rows() || svd.rows() != m_qr.cols())\n\n {\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 39, "score": 73624.53214988003 }, { "content": "class qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true>\n\n{\n\npublic:\n\n typedef typename MatrixType::Index Index;\n\n typedef typename MatrixType::Scalar Scalar;\n\n enum\n\n {\n\n RowsAtCompileTime = MatrixType::RowsAtCompileTime,\n\n MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime\n\n };\n\n typedef Matrix<Scalar, 1, RowsAtCompileTime, RowMajor, 1, MaxRowsAtCompileTime> WorkspaceType;\n\n\n\n void allocate(const JacobiSVD<MatrixType, FullPivHouseholderQRPreconditioner>& svd)\n\n {\n\n if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols())\n\n {\n\n m_qr.~QRType();\n\n ::new (&m_qr) QRType(svd.rows(), svd.cols());\n\n }\n\n if (svd.m_computeFullU) m_workspace.resize(svd.rows());\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 40, "score": 73624.53214988003 }, { "content": "class BlockImpl_dense<XprType,BlockRows,BlockCols, InnerPanel,true>\n\n : public MapBase<Block<XprType, BlockRows, BlockCols, InnerPanel> >\n\n{\n\n typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;\n\n public:\n\n\n\n typedef MapBase<BlockType> Base;\n\n EIGEN_DENSE_PUBLIC_INTERFACE(BlockType)\n\n EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl_dense)\n\n\n\n /** Column or Row constructor\n\n */\n\n inline BlockImpl_dense(XprType& xpr, Index i)\n\n : Base(internal::const_cast_ptr(&xpr.coeffRef(\n\n (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0,\n\n (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0)),\n\n BlockRows==1 ? 1 : xpr.rows(),\n\n BlockCols==1 ? 1 : xpr.cols()),\n\n m_xpr(xpr)\n\n {\n", "file_path": "src/Eigen/src/Core/Block.h", "rank": 41, "score": 73347.31673287507 }, { "content": "class BlockImpl<XprType,BlockRows,BlockCols,true,Sparse>\n\n : public SparseMatrixBase<Block<XprType,BlockRows,BlockCols,true> >\n\n{\n\npublic:\n\n typedef Block<XprType, BlockRows, BlockCols, true> BlockType;\n\n enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };\n\nprotected:\n\n typedef typename internal::remove_all<typename XprType::Nested>::type _MatrixTypeNested;\n\n enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };\n\npublic:\n\n EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)\n\n \n", "file_path": "src/Eigen/src/SparseCore/SparseBlock.h", "rank": 42, "score": 73347.31673287507 }, { "content": "struct triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,true> {\n\n static void run(const Lhs&, Rhs&) {}\n\n};\n\n\n\ntemplate<typename Lhs, typename Rhs, int Mode>\n", "file_path": "src/Eigen/src/Core/SolveTriangular.h", "rank": 43, "score": 72830.02932010978 }, { "content": " class GenericSparseBlockInnerIteratorImpl<XprType,BlockRows,BlockCols,InnerPanel,true>\n\n {\n\n public:\n\n typedef Block<XprType, BlockRows, BlockCols, InnerPanel> BlockType;\n\n enum {\n\n IsRowMajor = BlockType::IsRowMajor\n\n };\n\n typedef typename BlockType::Index Index;\n\n typedef typename BlockType::Scalar Scalar;\n\n protected:\n\n typedef typename internal::remove_all<typename XprType::Nested>::type _MatrixTypeNested;\n\n const BlockType& m_block;\n\n Index m_outerPos;\n\n Index m_innerIndex;\n\n Scalar m_value;\n\n Index m_end;\n\n public:\n\n\n\n EIGEN_STRONG_INLINE GenericSparseBlockInnerIteratorImpl(const BlockType& block, Index outer = 0)\n\n : \n", "file_path": "src/Eigen/src/SparseCore/SparseBlock.h", "rank": 44, "score": 70169.71924244838 }, { "content": "class gebp_traits<RealScalar, std::complex<RealScalar>, false, _ConjRhs >\n\n{\n\npublic:\n\n typedef std::complex<RealScalar> Scalar;\n\n typedef RealScalar LhsScalar;\n\n typedef Scalar RhsScalar;\n\n typedef Scalar ResScalar;\n\n\n\n enum {\n\n ConjLhs = false,\n\n ConjRhs = _ConjRhs,\n\n Vectorizable = packet_traits<RealScalar>::Vectorizable\n\n && packet_traits<Scalar>::Vectorizable,\n\n LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n\n RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n\n ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1,\n\n \n\n NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS,\n\n nr = 4,\n\n mr = 2*ResPacketSize,\n", "file_path": "src/Eigen/src/Core/products/GeneralBlockPanelKernel.h", "rank": 45, "score": 69477.94047774008 }, { "content": "class gebp_traits<std::complex<RealScalar>, RealScalar, _ConjLhs, false>\n\n{\n\npublic:\n\n typedef std::complex<RealScalar> LhsScalar;\n\n typedef RealScalar RhsScalar;\n\n typedef typename scalar_product_traits<LhsScalar, RhsScalar>::ReturnType ResScalar;\n\n\n\n enum {\n\n ConjLhs = _ConjLhs,\n\n ConjRhs = false,\n\n Vectorizable = packet_traits<LhsScalar>::Vectorizable && packet_traits<RhsScalar>::Vectorizable,\n\n LhsPacketSize = Vectorizable ? packet_traits<LhsScalar>::size : 1,\n\n RhsPacketSize = Vectorizable ? packet_traits<RhsScalar>::size : 1,\n\n ResPacketSize = Vectorizable ? packet_traits<ResScalar>::size : 1,\n\n \n\n NumberOfRegisters = EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS,\n\n nr = NumberOfRegisters/4,\n\n mr = 2 * LhsPacketSize,\n\n WorkSpaceFactor = nr*RhsPacketSize,\n\n\n", "file_path": "src/Eigen/src/Core/products/GeneralBlockPanelKernel.h", "rank": 46, "score": 69477.94047774008 }, { "content": "struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, RowMajor, true>\n\n{\n\n typedef typename internal::remove_all<SparseLhsType>::type Lhs;\n\n typedef typename internal::remove_all<DenseRhsType>::type Rhs;\n\n typedef typename internal::remove_all<DenseResType>::type Res;\n\n typedef typename Lhs::Index Index;\n\n typedef typename Lhs::InnerIterator LhsInnerIterator;\n\n static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha)\n\n {\n\n for(Index c=0; c<rhs.cols(); ++c)\n\n {\n\n Index n = lhs.outerSize();\n\n for(Index j=0; j<n; ++j)\n\n {\n\n typename Res::Scalar tmp(0);\n\n for(LhsInnerIterator it(lhs,j); it ;++it)\n\n tmp += it.value() * rhs.coeff(it.index(),c);\n\n res.coeffRef(j,c) += alpha * tmp;\n\n }\n\n }\n\n }\n\n};\n\n\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType>\n", "file_path": "src/Eigen/src/SparseCore/SparseDenseProduct.h", "rank": 47, "score": 68466.19237439078 }, { "content": "struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, ColMajor, true>\n\n{\n\n typedef typename internal::remove_all<SparseLhsType>::type Lhs;\n\n typedef typename internal::remove_all<DenseRhsType>::type Rhs;\n\n typedef typename internal::remove_all<DenseResType>::type Res;\n\n typedef typename Lhs::InnerIterator LhsInnerIterator;\n\n typedef typename Lhs::Index Index;\n\n static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha)\n\n {\n\n for(Index c=0; c<rhs.cols(); ++c)\n\n {\n\n for(Index j=0; j<lhs.outerSize(); ++j)\n\n {\n\n typename Res::Scalar rhs_j = alpha * rhs.coeff(j,c);\n\n for(LhsInnerIterator it(lhs,j); it ;++it)\n\n res.coeffRef(it.index(),c) += it.value() * rhs_j;\n\n }\n\n }\n\n }\n\n};\n\n\n\ntemplate<typename SparseLhsType, typename DenseRhsType, typename DenseResType>\n", "file_path": "src/Eigen/src/SparseCore/SparseDenseProduct.h", "rank": 48, "score": 68466.19237439078 }, { "content": "struct special_scalar_op_base<Derived,Scalar,OtherScalar,BaseType,true> : public BaseType\n\n{\n\n const CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived>\n\n operator*(const OtherScalar& scalar) const\n\n {\n\n return CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived>\n\n (*static_cast<const Derived*>(this), scalar_multiple2_op<Scalar,OtherScalar>(scalar));\n\n }\n\n\n\n inline friend const CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived>\n\n operator*(const OtherScalar& scalar, const Derived& matrix)\n\n { return static_cast<const special_scalar_op_base&>(matrix).operator*(scalar); }\n\n};\n\n\n\ntemplate<typename XprType, typename CastType> struct cast_return_type\n\n{\n\n typedef typename XprType::Scalar CurrentScalarType;\n\n typedef typename remove_all<CastType>::type _CastType;\n\n typedef typename _CastType::Scalar NewScalarType;\n\n typedef typename conditional<is_same<CurrentScalarType,NewScalarType>::value,\n", "file_path": "src/Eigen/src/Core/util/XprHelper.h", "rank": 49, "score": 67788.24444627768 }, { "content": "class BlockImpl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true,Sparse>\n\n : public SparseMatrixBase<Block<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true> >\n\n{\n\n typedef SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;\n\n typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _MatrixTypeNested;\n\n typedef Block<const SparseMatrixType, BlockRows, BlockCols, true> ConstBlockType;\n\npublic:\n\n typedef Block<SparseMatrixType, BlockRows, BlockCols, true> BlockType;\n\n enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };\n\n EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)\n\nprotected:\n\n enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };\n\npublic:\n\n \n", "file_path": "src/Eigen/src/SparseCore/SparseBlock.h", "rank": 50, "score": 66320.45549632152 }, { "content": "struct conjunction<B1, Bn...> : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};\n\n\n\ntemplate<class B> struct negation : std::integral_constant < bool, !B::value > {};\n\n\n\n// dispatch utility (taken from ranges-v3)\n\ntemplate<unsigned N> struct priority_tag : priority_tag < N - 1 > {};\n\ntemplate<> struct priority_tag<0> {};\n\n\n\n\n\n//////////////////\n\n// constructors //\n\n//////////////////\n\n\n\ntemplate<value_t> struct external_constructor;\n\n\n\ntemplate<>\n", "file_path": "src/json.hpp", "rank": 51, "score": 66209.3246153198 }, { "content": "class BlockImpl<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true,Sparse>\n\n : public SparseMatrixBase<Block<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true> >\n\n{\n\n typedef SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;\n\n typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _MatrixTypeNested;\n\npublic:\n\n typedef Block<const SparseMatrixType, BlockRows, BlockCols, true> BlockType;\n\n enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };\n\n EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)\n\nprotected:\n\n enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };\n\npublic:\n\n \n", "file_path": "src/Eigen/src/SparseCore/SparseBlock.h", "rank": 52, "score": 64405.54749603927 }, { "content": "class gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, MaxDepth, KcFactor, true>\n\n : public level3_blocking<\n\n typename conditional<StorageOrder==RowMajor,_RhsScalar,_LhsScalar>::type,\n\n typename conditional<StorageOrder==RowMajor,_LhsScalar,_RhsScalar>::type>\n\n{\n\n enum {\n\n Transpose = StorageOrder==RowMajor,\n\n ActualRows = Transpose ? MaxCols : MaxRows,\n\n ActualCols = Transpose ? MaxRows : MaxCols\n\n };\n\n typedef typename conditional<Transpose,_RhsScalar,_LhsScalar>::type LhsScalar;\n\n typedef typename conditional<Transpose,_LhsScalar,_RhsScalar>::type RhsScalar;\n\n typedef gebp_traits<LhsScalar,RhsScalar> Traits;\n\n enum {\n\n SizeA = ActualRows * MaxDepth,\n\n SizeB = ActualCols * MaxDepth,\n\n SizeW = MaxDepth * Traits::WorkSpaceFactor\n\n };\n\n\n\n EIGEN_ALIGN16 LhsScalar m_staticA[SizeA];\n", "file_path": "src/Eigen/src/Core/products/GeneralMatrixMatrix.h", "rank": 53, "score": 62862.26233123605 }, { "content": "struct traits<ReturnByValue<Derived> >\n\n : public traits<typename traits<Derived>::ReturnType>\n\n{\n\n enum {\n\n // We're disabling the DirectAccess because e.g. the constructor of\n\n // the Block-with-DirectAccess expression requires to have a coeffRef method.\n\n // Also, we don't want to have to implement the stride stuff.\n\n Flags = (traits<typename traits<Derived>::ReturnType>::Flags\n\n | EvalBeforeNestingBit) & ~DirectAccessBit\n\n };\n\n};\n\n\n\n/* The ReturnByValue object doesn't even have a coeff() method.\n\n * So the only way that nesting it in an expression can work, is by evaluating it into a plain matrix.\n\n * So internal::nested always gives the plain return matrix type.\n\n *\n\n * FIXME: I don't understand why we need this specialization: isn't this taken care of by the EvalBeforeNestingBit ??\n\n */\n\ntemplate<typename Derived,int n,typename PlainObject>\n", "file_path": "src/Eigen/src/Core/ReturnByValue.h", "rank": 54, "score": 62862.07695772104 }, { "content": "struct nested<ReturnByValue<Derived>, n, PlainObject>\n\n{\n\n typedef typename traits<Derived>::ReturnType type;\n\n};\n\n\n\n} // end namespace internal\n\n\n\ntemplate<typename Derived> class ReturnByValue\n\n : internal::no_assignment_operator, public internal::dense_xpr_base< ReturnByValue<Derived> >::type\n\n{\n\n public:\n\n typedef typename internal::traits<Derived>::ReturnType ReturnType;\n\n\n\n typedef typename internal::dense_xpr_base<ReturnByValue>::type Base;\n\n EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue)\n\n\n\n template<typename Dest>\n\n inline void evalTo(Dest& dst) const\n\n { static_cast<const Derived*>(this)->evalTo(dst); }\n\n inline Index rows() const { return static_cast<const Derived*>(this)->rows(); }\n\n inline Index cols() const { return static_cast<const Derived*>(this)->cols(); }\n\n\n", "file_path": "src/Eigen/src/Core/ReturnByValue.h", "rank": 55, "score": 61603.71542358332 }, { "content": "struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >\n\n{\n\n typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;\n\n typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;\n\n typedef Transform<Scalar,Dim,Projective> ResultType;\n\n static ResultType run(const Lhs& lhs, const Rhs& rhs)\n\n {\n\n ResultType res;\n\n res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();\n\n res.matrix().row(Dim) = rhs.matrix().row(Dim);\n\n return res;\n\n }\n\n};\n\n\n\ntemplate<typename Scalar, int Dim, int LhsOptions, int RhsOptions>\n", "file_path": "src/Eigen/src/Geometry/Transform.h", "rank": 56, "score": 61030.04660931623 }, { "content": "struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >\n\n{\n\n typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;\n\n typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;\n\n typedef Transform<Scalar,Dim,Projective> ResultType;\n\n static ResultType run(const Lhs& lhs, const Rhs& rhs)\n\n {\n\n ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());\n\n res.matrix().col(Dim) += lhs.matrix().col(Dim);\n\n return res;\n\n }\n\n};\n\n\n\n} // end namespace internal\n\n\n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN_TRANSFORM_H\n", "file_path": "src/Eigen/src/Geometry/Transform.h", "rank": 57, "score": 61030.04660931623 }, { "content": "struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >\n\n{\n\n typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;\n\n typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;\n\n typedef Transform<Scalar,Dim,Projective> ResultType;\n\n static ResultType run(const Lhs& lhs, const Rhs& rhs)\n\n {\n\n return ResultType( lhs.matrix() * rhs.matrix() );\n\n }\n\n};\n\n\n\ntemplate<typename Scalar, int Dim, int LhsOptions, int RhsOptions>\n", "file_path": "src/Eigen/src/Geometry/Transform.h", "rank": 58, "score": 60462.41384869636 }, { "content": "class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };\n\n\n\n/** \\internal determines whether the product of two numeric types is allowed and what the return type is */\n\ntemplate<typename T, typename U> struct scalar_product_traits\n\n{\n\n enum { Defined = 0 };\n\n};\n\n\n\ntemplate<typename T> struct scalar_product_traits<T,T>\n\n{\n\n enum {\n\n // Cost = NumTraits<T>::MulCost,\n\n Defined = 1\n\n };\n\n typedef T ReturnType;\n\n};\n\n\n\ntemplate<typename T> struct scalar_product_traits<T,std::complex<T> >\n\n{\n\n enum {\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 59, "score": 58437.773922147935 }, { "content": "class ei_meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };\n\n\n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN2_META_H\n", "file_path": "src/Eigen/src/Eigen2Support/Meta.h", "rank": 60, "score": 57913.72128410919 }, { "content": "struct LazyProductReturnType : public ProductReturnType<Lhs,Rhs,LazyCoeffBasedProductMode>\n\n{};\n\n\n\n/***********************************************************************\n\n* Implementation of Inner Vector Vector Product\n\n***********************************************************************/\n\n\n\n// FIXME : maybe the \"inner product\" could return a Scalar\n\n// instead of a 1x1 matrix ??\n\n// Pro: more natural for the user\n\n// Cons: this could be a problem if in a meta unrolled algorithm a matrix-matrix\n\n// product ends up to a row-vector times col-vector product... To tackle this use\n\n// case, we could have a specialization for Block<MatrixType,1,1> with: operator=(Scalar x);\n\n\n\nnamespace internal {\n\n\n\ntemplate<typename Lhs, typename Rhs>\n", "file_path": "src/Eigen/src/Core/GeneralProduct.h", "rank": 61, "score": 56513.013287513 }, { "content": "\n\ntemplate<typename Derived>\n\ntemplate<typename OtherDerived>\n\nDerived& DenseBase<Derived>::lazyAssign(const ReturnByValue<OtherDerived>& other)\n\n{\n\n other.evalTo(derived());\n\n return derived();\n\n}\n\n\n\n\n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN_RETURNBYVALUE_H\n", "file_path": "src/Eigen/src/Core/ReturnByValue.h", "rank": 62, "score": 54843.469157434876 }, { "content": "// This file is part of Eigen, a lightweight C++ template library\n\n// for linear algebra.\n\n//\n\n// Copyright (C) 2009-2010 Gael Guennebaud <[email protected]>\n\n// Copyright (C) 2009-2010 Benoit Jacob <[email protected]>\n\n//\n\n// This Source Code Form is subject to the terms of the Mozilla\n\n// Public License v. 2.0. If a copy of the MPL was not distributed\n\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n\n#ifndef EIGEN_RETURNBYVALUE_H\n\n#define EIGEN_RETURNBYVALUE_H\n\n\n\nnamespace Eigen {\n\n\n\n/** \\class ReturnByValue\n\n * \\ingroup Core_Module\n\n *\n\n */\n\n\n\nnamespace internal {\n\n\n\ntemplate<typename Derived>\n", "file_path": "src/Eigen/src/Core/ReturnByValue.h", "rank": 63, "score": 54842.73140099004 }, { "content": "struct SparseQRMatrixQReturnType : public EigenBase<SparseQRMatrixQReturnType<SparseQRType> >\n\n{ \n\n typedef typename SparseQRType::Index Index;\n\n typedef typename SparseQRType::Scalar Scalar;\n\n typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix;\n\n SparseQRMatrixQReturnType(const SparseQRType& qr) : m_qr(qr) {}\n\n template<typename Derived>\n\n SparseQR_QProduct<SparseQRType, Derived> operator*(const MatrixBase<Derived>& other)\n\n {\n\n return SparseQR_QProduct<SparseQRType,Derived>(m_qr,other.derived(),false);\n\n }\n\n SparseQRMatrixQTransposeReturnType<SparseQRType> adjoint() const\n\n {\n\n return SparseQRMatrixQTransposeReturnType<SparseQRType>(m_qr);\n\n }\n\n inline Index rows() const { return m_qr.rows(); }\n\n inline Index cols() const { return (std::min)(m_qr.rows(),m_qr.cols()); }\n\n // To use for operations with the transpose of Q\n\n SparseQRMatrixQTransposeReturnType<SparseQRType> transpose() const\n\n {\n", "file_path": "src/Eigen/src/SparseQR/SparseQR.h", "rank": 64, "score": 54510.975739205445 }, { "content": "// This file is part of Eigen, a lightweight C++ template library\n\n// for linear algebra.\n\n//\n\n// Copyright (C) 2009 Gael Guennebaud <[email protected]>\n\n// Copyright (C) 2009 Hauke Heibel <[email protected]>\n\n//\n\n// This Source Code Form is subject to the terms of the Mozilla\n\n// Public License v. 2.0. If a copy of the MPL was not distributed\n\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n\n#ifndef EIGEN_STDVECTOR_H\n\n#define EIGEN_STDVECTOR_H\n\n\n\n#include \"details.h\"\n\n\n\n/**\n\n * This section contains a convenience MACRO which allows an easy specialization of\n\n * std::vector such that for data types with alignment issues the correct allocator\n\n * is used automatically.\n\n */\n\n#define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \\\n\nnamespace std \\\n\n{ \\\n\n template<> \\\n", "file_path": "src/Eigen/src/StlSupport/StdVector.h", "rank": 65, "score": 53879.54596419638 }, { "content": "// This file is part of Eigen, a lightweight C++ template library\n\n// for linear algebra.\n\n//\n\n// Copyright (C) 2009 Hauke Heibel <[email protected]>\n\n//\n\n// This Source Code Form is subject to the terms of the Mozilla\n\n// Public License v. 2.0. If a copy of the MPL was not distributed\n\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n\n#ifndef EIGEN_STDLIST_H\n\n#define EIGEN_STDLIST_H\n\n\n\n#include \"details.h\"\n\n\n\n/**\n\n * This section contains a convenience MACRO which allows an easy specialization of\n\n * std::list such that for data types with alignment issues the correct allocator\n\n * is used automatically.\n\n */\n\n#define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) \\\n\nnamespace std \\\n\n{ \\\n\n template<> \\\n", "file_path": "src/Eigen/src/StlSupport/StdList.h", "rank": 66, "score": 53875.06400189918 }, { "content": "// This file is part of Eigen, a lightweight C++ template library\n\n// for linear algebra.\n\n//\n\n// Copyright (C) 2009 Gael Guennebaud <[email protected]>\n\n// Copyright (C) 2009 Hauke Heibel <[email protected]>\n\n//\n\n// This Source Code Form is subject to the terms of the Mozilla\n\n// Public License v. 2.0. If a copy of the MPL was not distributed\n\n// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\n\n\n#ifndef EIGEN_STDDEQUE_H\n\n#define EIGEN_STDDEQUE_H\n\n\n\n#include \"details.h\"\n\n\n\n/**\n\n * This section contains a convenience MACRO which allows an easy specialization of\n\n * std::deque such that for data types with alignment issues the correct allocator\n\n * is used automatically.\n\n */\n\n#define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) \\\n\nnamespace std \\\n\n{ \\\n\n template<> \\\n", "file_path": "src/Eigen/src/StlSupport/StdDeque.h", "rank": 67, "score": 53874.384562955645 }, { "content": "#ifndef EIGEN_PARSED_BY_DOXYGEN\n\n#define Unusable YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT\n\n class Unusable{\n\n Unusable(const Unusable&) {}\n\n Unusable& operator=(const Unusable&) {return *this;}\n\n };\n\n const Unusable& coeff(Index) const { return *reinterpret_cast<const Unusable*>(this); }\n\n const Unusable& coeff(Index,Index) const { return *reinterpret_cast<const Unusable*>(this); }\n\n Unusable& coeffRef(Index) { return *reinterpret_cast<Unusable*>(this); }\n\n Unusable& coeffRef(Index,Index) { return *reinterpret_cast<Unusable*>(this); }\n\n template<int LoadMode> Unusable& packet(Index) const;\n\n template<int LoadMode> Unusable& packet(Index, Index) const;\n\n#endif\n\n};\n\n\n\ntemplate<typename Derived>\n\ntemplate<typename OtherDerived>\n\nDerived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)\n\n{\n\n other.evalTo(derived());\n\n return derived();\n\n}\n", "file_path": "src/Eigen/src/Core/ReturnByValue.h", "rank": 68, "score": 53873.4242220559 }, { "content": " // workaround MSVC std::list implementation\n\n void push_back(const value_type& x)\n\n { list_base::push_back(x); } \n\n using list_base::insert; \n\n iterator insert(const_iterator position, const value_type& x)\n\n { return list_base::insert(position,x); }\n\n void insert(const_iterator position, size_type new_size, const value_type& x)\n\n { list_base::insert(position, new_size, x); }\n\n#endif\n\n };\n\n}\n\n\n\n#endif // check whether specialization is actually required\n\n\n\n#endif // EIGEN_STDLIST_H\n", "file_path": "src/Eigen/src/StlSupport/StdList.h", "rank": 69, "score": 53868.157773931074 }, { "content": " void push_back(const value_type& x)\n\n { vector_base::push_back(x); } \n\n using vector_base::insert; \n\n iterator insert(const_iterator position, const value_type& x)\n\n { return vector_base::insert(position,x); }\n\n void insert(const_iterator position, size_type new_size, const value_type& x)\n\n { vector_base::insert(position, new_size, x); }\n\n#elif defined(_GLIBCXX_VECTOR) && (!(EIGEN_GNUC_AT_LEAST(4,1)))\n\n /* Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&).\n\n * However, this specialization is still needed to make the above EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION trick to work. */\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n vector_base::resize(new_size,x);\n\n }\n\n#elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)\n\n // workaround GCC std::vector implementation\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n if (new_size < vector_base::size())\n\n vector_base::_M_erase_at_end(this->_M_impl._M_start + new_size);\n", "file_path": "src/Eigen/src/StlSupport/StdVector.h", "rank": 70, "score": 53867.60417324313 }, { "content": " void push_back(const value_type& x)\n\n { deque_base::push_back(x); } \n\n void push_front(const value_type& x)\n\n { deque_base::push_front(x); }\n\n using deque_base::insert; \n\n iterator insert(const_iterator position, const value_type& x)\n\n { return deque_base::insert(position,x); }\n\n void insert(const_iterator position, size_type new_size, const value_type& x)\n\n { deque_base::insert(position, new_size, x); }\n\n#elif defined(_GLIBCXX_DEQUE) && EIGEN_GNUC_AT_LEAST(4,2)\n\n // workaround GCC std::deque implementation\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n if (new_size < deque_base::size())\n\n deque_base::_M_erase_at_end(this->_M_impl._M_start + new_size);\n\n else\n\n deque_base::insert(deque_base::end(), new_size - deque_base::size(), x);\n\n }\n\n#else\n\n // either GCC 4.1 or non-GCC\n", "file_path": "src/Eigen/src/StlSupport/StdDeque.h", "rank": 71, "score": 53866.93498990476 }, { "content": "}\n\n\n\n// check whether we really need the std::deque specialization\n\n#if !(defined(_GLIBCXX_DEQUE) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::deque::resize(size_type,const T&). */\n\n\n\nnamespace std {\n\n\n\n#define EIGEN_STD_DEQUE_SPECIALIZATION_BODY \\\n\n public: \\\n\n typedef T value_type; \\\n\n typedef typename deque_base::allocator_type allocator_type; \\\n\n typedef typename deque_base::size_type size_type; \\\n\n typedef typename deque_base::iterator iterator; \\\n\n typedef typename deque_base::const_iterator const_iterator; \\\n\n explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {} \\\n\n template<typename InputIterator> \\\n\n deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \\\n\n : deque_base(first, last, a) {} \\\n\n deque(const deque& c) : deque_base(c) {} \\\n\n explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \\\n\n deque(iterator start, iterator end) : deque_base(start, end) {} \\\n\n deque& operator=(const deque& x) { \\\n\n deque_base::operator=(x); \\\n\n return *this; \\\n\n }\n\n\n\n template<typename T>\n", "file_path": "src/Eigen/src/StlSupport/StdDeque.h", "rank": 72, "score": 53862.9198273944 }, { "content": "}\n\n\n\n// check whether we really need the std::vector specialization\n\n#if !(defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::list::resize(size_type,const T&). */\n\n\n\nnamespace std\n\n{\n\n\n\n#define EIGEN_STD_LIST_SPECIALIZATION_BODY \\\n\n public: \\\n\n typedef T value_type; \\\n\n typedef typename list_base::allocator_type allocator_type; \\\n\n typedef typename list_base::size_type size_type; \\\n\n typedef typename list_base::iterator iterator; \\\n\n typedef typename list_base::const_iterator const_iterator; \\\n\n explicit list(const allocator_type& a = allocator_type()) : list_base(a) {} \\\n\n template<typename InputIterator> \\\n\n list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \\\n\n : list_base(first, last, a) {} \\\n\n list(const list& c) : list_base(c) {} \\\n\n explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \\\n\n list(iterator start, iterator end) : list_base(start, end) {} \\\n\n list& operator=(const list& x) { \\\n\n list_base::operator=(x); \\\n\n return *this; \\\n\n }\n\n\n\n template<typename T>\n", "file_path": "src/Eigen/src/StlSupport/StdList.h", "rank": 73, "score": 53862.9198273944 }, { "content": " else\n\n vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);\n\n }\n\n#else\n\n // either GCC 4.1 or non-GCC\n\n // default implementation which should always work.\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n if (new_size < vector_base::size())\n\n vector_base::erase(vector_base::begin() + new_size, vector_base::end());\n\n else if (new_size > vector_base::size())\n\n vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);\n\n }\n\n#endif\n\n };\n\n}\n\n\n\n#endif // EIGEN_STDVECTOR_H\n", "file_path": "src/Eigen/src/StlSupport/StdVector.h", "rank": 74, "score": 53862.57215887694 }, { "content": "}\n\n\n\nnamespace std {\n\n\n\n#define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \\\n\n public: \\\n\n typedef T value_type; \\\n\n typedef typename vector_base::allocator_type allocator_type; \\\n\n typedef typename vector_base::size_type size_type; \\\n\n typedef typename vector_base::iterator iterator; \\\n\n typedef typename vector_base::const_iterator const_iterator; \\\n\n explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \\\n\n template<typename InputIterator> \\\n\n vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \\\n\n : vector_base(first, last, a) {} \\\n\n vector(const vector& c) : vector_base(c) {} \\\n\n explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \\\n\n vector(iterator start, iterator end) : vector_base(start, end) {} \\\n\n vector& operator=(const vector& x) { \\\n\n vector_base::operator=(x); \\\n\n return *this; \\\n\n }\n\n\n\n template<typename T>\n", "file_path": "src/Eigen/src/StlSupport/StdVector.h", "rank": 75, "score": 53862.33335456744 }, { "content": " // default implementation which should always work.\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n if (new_size < deque_base::size())\n\n deque_base::erase(deque_base::begin() + new_size, deque_base::end());\n\n else if (new_size > deque_base::size())\n\n deque_base::insert(deque_base::end(), new_size - deque_base::size(), x);\n\n }\n\n#endif\n\n };\n\n}\n\n\n\n#endif // check whether specialization is actually required\n\n\n\n#endif // EIGEN_STDDEQUE_H\n", "file_path": "src/Eigen/src/StlSupport/StdDeque.h", "rank": 76, "score": 53858.514213272305 }, { "content": "struct external_constructor<value_t::number_float>\n\n{\n\n template<typename BasicJsonType>\n\n static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept\n\n {\n\n // replace infinity and NAN by null\n\n if (not std::isfinite(val))\n\n {\n\n j = BasicJsonType{};\n\n }\n\n else\n\n {\n\n j.m_type = value_t::number_float;\n\n j.m_value = val;\n\n }\n\n j.assert_invariant();\n\n }\n\n};\n\n\n\ntemplate<>\n", "file_path": "src/json.hpp", "rank": 77, "score": 52992.047338853365 }, { "content": "struct ProductReturnType\n\n{\n\n // TODO use the nested type to reduce instanciations ????\n\n// typedef typename internal::nested<Lhs,Rhs::ColsAtCompileTime>::type LhsNested;\n\n// typedef typename internal::nested<Rhs,Lhs::RowsAtCompileTime>::type RhsNested;\n\n\n\n typedef GeneralProduct<Lhs/*Nested*/, Rhs/*Nested*/, ProductType> Type;\n\n};\n\n\n\ntemplate<typename Lhs, typename Rhs>\n", "file_path": "src/Eigen/src/Core/GeneralProduct.h", "rank": 78, "score": 52051.02441971988 }, { "content": "class blas_data_mapper\n\n{\n\n public:\n\n blas_data_mapper(Scalar* data, Index stride) : m_data(data), m_stride(stride) {}\n\n EIGEN_STRONG_INLINE Scalar& operator()(Index i, Index j)\n\n { return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; }\n\n protected:\n\n Scalar* EIGEN_RESTRICT m_data;\n\n Index m_stride;\n\n};\n\n\n\n// lightweight helper class to access matrix coefficients (const version)\n\ntemplate<typename Scalar, typename Index, int StorageOrder>\n", "file_path": "src/Eigen/src/Core/util/BlasUtil.h", "rank": 79, "score": 51190.76911248993 }, { "content": "struct extract_data_selector {\n\n static const typename T::Scalar* run(const T& m)\n\n {\n\n return blas_traits<T>::extract(m).data();\n\n }\n\n};\n\n\n\ntemplate<typename T>\n", "file_path": "src/Eigen/src/Core/util/BlasUtil.h", "rank": 80, "score": 51190.76911248993 }, { "content": "struct ProductReturnType;\n\n\n\n// this is a workaround for sun CC\n\ntemplate<typename Lhs, typename Rhs> struct LazyProductReturnType;\n\n\n\nnamespace internal {\n\n\n\n// Provides scalar/packet-wise product and product with accumulation\n\n// with optional conjugation of the arguments.\n\ntemplate<typename LhsScalar, typename RhsScalar, bool ConjLhs=false, bool ConjRhs=false> struct conj_helper;\n\n\n\ntemplate<typename Scalar> struct scalar_sum_op;\n\ntemplate<typename Scalar> struct scalar_difference_op;\n\ntemplate<typename LhsScalar,typename RhsScalar> struct scalar_conj_product_op;\n\ntemplate<typename Scalar> struct scalar_opposite_op;\n\ntemplate<typename Scalar> struct scalar_conjugate_op;\n\ntemplate<typename Scalar> struct scalar_real_op;\n\ntemplate<typename Scalar> struct scalar_imag_op;\n\ntemplate<typename Scalar> struct scalar_abs_op;\n\ntemplate<typename Scalar> struct scalar_abs2_op;\n", "file_path": "src/Eigen/src/Core/util/ForwardDeclarations.h", "rank": 81, "score": 51185.29084819324 }, { "content": "class const_blas_data_mapper\n\n{\n\n public:\n\n const_blas_data_mapper(const Scalar* data, Index stride) : m_data(data), m_stride(stride) {}\n\n EIGEN_STRONG_INLINE const Scalar& operator()(Index i, Index j) const\n\n { return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; }\n\n protected:\n\n const Scalar* EIGEN_RESTRICT m_data;\n\n Index m_stride;\n\n};\n\n\n\n\n\n/* Helper class to analyze the factors of a Product expression.\n\n * In particular it allows to pop out operator-, scalar multiples,\n\n * and conjugate */\n\ntemplate<typename XprType> struct blas_traits\n\n{\n\n typedef typename traits<XprType>::Scalar Scalar;\n\n typedef const XprType& ExtractType;\n\n typedef XprType _ExtractType;\n", "file_path": "src/Eigen/src/Core/util/BlasUtil.h", "rank": 82, "score": 50353.27322167437 }, { "content": "struct extract_data_selector<T,false> {\n\n static typename T::Scalar* run(const T&) { return 0; }\n\n};\n\n\n\ntemplate<typename T> const typename T::Scalar* extract_data(const T& m)\n\n{\n\n return extract_data_selector<T>::run(m);\n\n}\n\n\n\n} // end namespace internal\n\n\n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN_BLASUTIL_H\n", "file_path": "src/Eigen/src/Core/util/BlasUtil.h", "rank": 83, "score": 49542.73957405827 }, { "content": "struct SparseSparseProductReturnType\n\n{\n\n typedef typename internal::traits<Lhs>::Scalar Scalar;\n\n typedef typename internal::traits<Lhs>::Index Index;\n\n enum {\n\n LhsRowMajor = internal::traits<Lhs>::Flags & RowMajorBit,\n\n RhsRowMajor = internal::traits<Rhs>::Flags & RowMajorBit,\n\n TransposeRhs = (!LhsRowMajor) && RhsRowMajor,\n\n TransposeLhs = LhsRowMajor && (!RhsRowMajor)\n\n };\n\n\n\n typedef typename internal::conditional<TransposeLhs,\n\n SparseMatrix<Scalar,0,Index>,\n\n typename internal::nested<Lhs,Rhs::RowsAtCompileTime>::type>::type LhsNested;\n\n\n\n typedef typename internal::conditional<TransposeRhs,\n\n SparseMatrix<Scalar,0,Index>,\n\n typename internal::nested<Rhs,Lhs::RowsAtCompileTime>::type>::type RhsNested;\n\n\n\n typedef SparseSparseProduct<LhsNested, RhsNested> Type;\n\n};\n\n\n\nnamespace internal {\n\ntemplate<typename LhsNested, typename RhsNested>\n", "file_path": "src/Eigen/src/SparseCore/SparseProduct.h", "rank": 84, "score": 49537.43767635143 }, { "content": " class deque<T,EIGEN_ALIGNED_ALLOCATOR<T> >\n\n : public deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n\n Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >\n\n{\n\n typedef deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n\n Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > deque_base;\n\n EIGEN_STD_DEQUE_SPECIALIZATION_BODY\n\n\n\n void resize(size_type new_size)\n\n { resize(new_size, T()); }\n\n\n\n#if defined(_DEQUE_)\n\n // workaround MSVC std::deque implementation\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n if (deque_base::size() < new_size)\n\n deque_base::_Insert_n(deque_base::end(), new_size - deque_base::size(), x);\n\n else if (new_size < deque_base::size())\n\n deque_base::erase(deque_base::begin() + new_size, deque_base::end());\n\n }\n", "file_path": "src/Eigen/src/StlSupport/StdDeque.h", "rank": 85, "score": 48735.24790914155 }, { "content": " class list<T,EIGEN_ALIGNED_ALLOCATOR<T> >\n\n : public list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n\n Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >\n\n {\n\n typedef list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n\n Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > list_base;\n\n EIGEN_STD_LIST_SPECIALIZATION_BODY\n\n\n\n void resize(size_type new_size)\n\n { resize(new_size, T()); }\n\n\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n if (list_base::size() < new_size)\n\n list_base::insert(list_base::end(), new_size - list_base::size(), x);\n\n else\n\n while (new_size < list_base::size()) list_base::pop_back();\n\n }\n\n\n\n#if defined(_LIST_)\n", "file_path": "src/Eigen/src/StlSupport/StdList.h", "rank": 86, "score": 48735.24790914155 }, { "content": " class vector<T,EIGEN_ALIGNED_ALLOCATOR<T> >\n\n : public vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n\n Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >\n\n{\n\n typedef vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),\n\n Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > vector_base;\n\n EIGEN_STD_VECTOR_SPECIALIZATION_BODY\n\n\n\n void resize(size_type new_size)\n\n { resize(new_size, T()); }\n\n\n\n#if defined(_VECTOR_)\n\n // workaround MSVC std::vector implementation\n\n void resize(size_type new_size, const value_type& x)\n\n {\n\n if (vector_base::size() < new_size)\n\n vector_base::_Insert_n(vector_base::end(), new_size - vector_base::size(), x);\n\n else if (new_size < vector_base::size())\n\n vector_base::erase(vector_base::begin() + new_size, vector_base::end());\n\n }\n", "file_path": "src/Eigen/src/StlSupport/StdVector.h", "rank": 87, "score": 48735.24790914155 }, { "content": "namespace Eigen { \n\n\n\n/** \\class CommaInitializer\n\n * \\ingroup Core_Module\n\n *\n\n * \\brief Helper class used by the comma initializer operator\n\n *\n\n * This class is internally used to implement the comma initializer feature. It is\n\n * the return type of MatrixBase::operator<<, and most of the time this is the only\n\n * way it is used.\n\n *\n\n * \\sa \\ref MatrixBaseCommaInitRef \"MatrixBase::operator<<\", CommaInitializer::finished()\n\n */\n\ntemplate<typename XprType>\n\nstruct CommaInitializer\n\n{\n\n typedef typename XprType::Scalar Scalar;\n\n typedef typename XprType::Index Index;\n\n\n\n inline CommaInitializer(XprType& xpr, const Scalar& s)\n\n : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1)\n\n {\n\n m_xpr.coeffRef(0,0) = s;\n\n }\n\n\n\n template<typename OtherDerived>\n\n inline CommaInitializer(XprType& xpr, const DenseBase<OtherDerived>& other)\n\n : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())\n\n {\n\n m_xpr.block(0, 0, other.rows(), other.cols()) = other;\n\n }\n\n\n\n /* Copy/Move constructor which transfers ownership. This is crucial in \n\n * absence of return value optimization to avoid assertions during destruction. */\n\n // FIXME in C++11 mode this could be replaced by a proper RValue constructor\n\n inline CommaInitializer(const CommaInitializer& o)\n\n : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {\n\n // Mark original object as finished. In absence of R-value references we need to const_cast:\n\n const_cast<CommaInitializer&>(o).m_row = m_xpr.rows();\n\n const_cast<CommaInitializer&>(o).m_col = m_xpr.cols();\n\n const_cast<CommaInitializer&>(o).m_currentBlockRows = 0;\n\n }\n\n\n\n /* inserts a scalar value in the target matrix */\n\n CommaInitializer& operator,(const Scalar& s)\n\n {\n\n if (m_col==m_xpr.cols())\n\n {\n\n m_row+=m_currentBlockRows;\n\n m_col = 0;\n\n m_currentBlockRows = 1;\n\n eigen_assert(m_row<m_xpr.rows()\n\n && \"Too many rows passed to comma initializer (operator<<)\");\n\n }\n\n eigen_assert(m_col<m_xpr.cols()\n\n && \"Too many coefficients passed to comma initializer (operator<<)\");\n\n eigen_assert(m_currentBlockRows==1);\n\n m_xpr.coeffRef(m_row, m_col++) = s;\n\n return *this;\n\n }\n\n\n\n /* inserts a matrix expression in the target matrix */\n\n template<typename OtherDerived>\n\n CommaInitializer& operator,(const DenseBase<OtherDerived>& other)\n\n {\n\n if (m_col==m_xpr.cols() && (other.cols()!=0 || other.rows()!=m_currentBlockRows))\n\n {\n\n m_row+=m_currentBlockRows;\n\n m_col = 0;\n\n m_currentBlockRows = other.rows();\n\n eigen_assert(m_row+m_currentBlockRows<=m_xpr.rows()\n\n && \"Too many rows passed to comma initializer (operator<<)\");\n\n }\n\n eigen_assert((m_col + other.cols() <= m_xpr.cols())\n\n && \"Too many coefficients passed to comma initializer (operator<<)\");\n\n eigen_assert(m_currentBlockRows==other.rows());\n\n m_xpr.template block<OtherDerived::RowsAtCompileTime, OtherDerived::ColsAtCompileTime>\n\n (m_row, m_col, other.rows(), other.cols()) = other;\n\n m_col += other.cols();\n\n return *this;\n\n }\n\n\n\n inline ~CommaInitializer()\n\n {\n\n finished();\n\n }\n\n\n\n /** \\returns the built matrix once all its coefficients have been set.\n\n * Calling finished is 100% optional. Its purpose is to write expressions\n\n * like this:\n\n * \\code\n\n * quaternion.fromRotationMatrix((Matrix3f() << axis0, axis1, axis2).finished());\n\n * \\endcode\n\n */\n\n inline XprType& finished() {\n\n eigen_assert(((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr.cols() == 0)\n\n && m_col == m_xpr.cols()\n\n && \"Too few coefficients passed to comma initializer (operator<<)\");\n\n return m_xpr;\n\n }\n\n\n\n XprType& m_xpr; // target expression\n\n Index m_row; // current row id\n\n Index m_col; // current col id\n\n Index m_currentBlockRows; // current block height\n\n};\n\n\n\n/** \\anchor MatrixBaseCommaInitRef\n\n * Convenient operator to set the coefficients of a matrix.\n\n *\n\n * The coefficients must be provided in a row major order and exactly match\n\n * the size of the matrix. Otherwise an assertion is raised.\n\n *\n\n * Example: \\include MatrixBase_set.cpp\n\n * Output: \\verbinclude MatrixBase_set.out\n\n * \n\n * \\note According the c++ standard, the argument expressions of this comma initializer are evaluated in arbitrary order.\n\n *\n\n * \\sa CommaInitializer::finished(), class CommaInitializer\n\n */\n\ntemplate<typename Derived>\n\ninline CommaInitializer<Derived> DenseBase<Derived>::operator<< (const Scalar& s)\n\n{\n\n return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);\n\n}\n\n\n\n/** \\sa operator<<(const Scalar&) */\n\ntemplate<typename Derived>\n\ntemplate<typename OtherDerived>\n\ninline CommaInitializer<Derived>\n\nDenseBase<Derived>::operator<<(const DenseBase<OtherDerived>& other)\n\n{\n\n return CommaInitializer<Derived>(*static_cast<Derived *>(this), other);\n\n}\n\n\n", "file_path": "src/Eigen/src/Core/CommaInitializer.h", "rank": 88, "score": 48028.33273125494 }, { "content": " DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {}\n", "file_path": "src/Eigen/src/Core/DenseStorage.h", "rank": 89, "score": 47997.51333278279 }, { "content": " }\n\n else {\n\n float rho = meas_package.raw_measurements_(0);\n\n float phi = meas_package.raw_measurements_(1);\n\n float px = cos(phi) * rho;\n\n float py = sin(phi) * rho;\n\n x_(0) = px;\n\n x_(1) = py;\n\n cout << \"Initialization finished with Radar data!\" << endl;\n\n }\n\n \n\n // Finish initialization\n\n is_initialized_ = true;\n\n time_us_ = meas_package.timestamp_;\n\n // set weights\n\n weights_(0) = lambda_ / (lambda_ + n_aug_);\n\n for (int i = 1; i < 2 * n_aug_ + 1; ++i) {\n\n weights_(i) = 0.5 / (lambda_ + n_aug_);\n\n }\n\n \n", "file_path": "src/ukfnew.cpp", "rank": 91, "score": 62.90603385897985 }, { "content": "#include \"ukf.h\"\n\n#include \"Eigen/Dense\"\n\n#include <iostream>\n\n\n\nusing namespace std;\n\nusing Eigen::MatrixXd;\n\nusing Eigen::VectorXd;\n\nusing std::vector;\n\n\n\n/**\n\n * Initializes Unscented Kalman filter\n\n * This is scaffolding, do not modify\n\n */\n\nUKF::UKF() {\n\n // if this is false, laser measurements will be ignored (except during init)\n\n use_laser_ = true;\n\n \n\n // if this is false, radar measurements will be ignored (except during init)\n\n use_radar_ = true;\n\n \n", "file_path": "src/ukfnew.cpp", "rank": 92, "score": 48.48146937651897 }, { "content": " }\n\n \n\n /*****************************************************************************\n\n * Initialization\n\n ****************************************************************************/\n\n if (!is_initialized_) {\n\n \n\n x_ << 1, 1, 1, 1, 0.1;\n\n P_ << 0.15, 0, 0, 0, 0,\n\n 0, 0.15, 0, 0, 0,\n\n 0, 0, 1, 0, 0,\n\n 0, 0, 0, 1, 0,\n\n 0, 0, 0, 0, 1;\n\n \n\n if (meas_package.sensor_type_ == MeasurementPackage::LASER) {\n\n float px = meas_package.raw_measurements_(0);\n\n float py = meas_package.raw_measurements_(1);\n\n x_(0) = px;\n\n x_(1) = py;\n\n cout << \"Initialization finished with Laser data!\" << endl;\n", "file_path": "src/ukfnew.cpp", "rank": 95, "score": 40.49281546481277 }, { "content": "#include <uWS/uWS.h>\n\n#include <iostream>\n\n#include \"json.hpp\"\n\n#include <math.h>\n\n#include \"ukf.h\"\n\n#include \"tools.h\"\n\n\n\nusing namespace std;\n\n\n\n// for convenience\n\nusing json = nlohmann::json;\n\n\n\n// Checks if the SocketIO event has JSON data.\n\n// If there is data the JSON object in string format will be returned,\n\n// else the empty string \"\" will be returned.\n\nstd::string hasData(std::string s) {\n\n auto found_null = s.find(\"null\");\n\n auto b1 = s.find_first_of(\"[\");\n\n auto b2 = s.find_first_of(\"]\");\n\n if (found_null != std::string::npos) {\n", "file_path": "src/main.cpp", "rank": 96, "score": 32.51277260230077 }, { "content": " /**\n\n * ProcessMeasurement\n\n * @param meas_package The latest measurement data of either radar or laser\n\n */\n\n void ProcessMeasurement(MeasurementPackage meas_package);\n\n\n\n /**\n\n * Prediction Predicts sigma points, the state, and the state covariance\n\n * matrix\n\n * @param delta_t Time between k and k+1 in s\n\n */\n\n void Prediction(double dt);\n\n\n\n /**\n\n * Updates the state and the state covariance matrix using a laser measurement\n\n * @param meas_package The measurement at k+1\n\n */\n\n void UpdateLidar(MeasurementPackage meas_package);\n\n\n\n /**\n", "file_path": "src/ukf.h", "rank": 97, "score": 29.024133228000622 }, { "content": " }\n\n\n\n /** Returns the threshold that will be used by certain methods such as rank().\n\n *\n\n * See the documentation of setThreshold(const RealScalar&).\n\n */\n\n RealScalar threshold() const\n\n {\n\n eigen_assert(m_isInitialized || m_usePrescribedThreshold);\n\n return m_usePrescribedThreshold ? m_prescribedThreshold\n\n : (std::max<Index>)(1,m_diagSize)*NumTraits<Scalar>::epsilon();\n\n }\n\n\n\n inline Index rows() const { return m_rows; }\n\n inline Index cols() const { return m_cols; }\n\n\n\n private:\n\n void allocate(Index rows, Index cols, unsigned int computationOptions);\n\n \n\n static void check_template_parameters()\n", "file_path": "src/Eigen/src/SVD/JacobiSVD.h", "rank": 99, "score": 27.8175742926905 } ]
C++
wled00/7segmdisp.cpp
imeszaros/ledclock
e739b11608e52a1e2a3dc88c54dcc40dbc1e5793
#include "7segmdisp.h" static CRGB dummy; void LedBasedDisplay::setRowColor(uint8_t row, bool state, CRGB color) { for (uint8_t c = 0, n = columnCount(); c < n; ++c) { setLedColor(row, c, state, color); } } void LedBasedDisplay::setColumnColor(uint8_t column, bool state, CRGB color) { for (uint8_t r = 0, n = rowCount(); r < n; ++r) { setLedColor(r, column, state, color); } } void LedBasedDisplay::setColor(bool state, CRGB color) { for (uint8_t r = 0, rn = rowCount(); r < rn; ++r) { for (uint8_t c = 0, cn = columnCount(); c < cn; ++c) { setLedColor(r, c, state, color); } } } SevenSegmentDisplay::SevenSegmentDisplay(LedBasedDisplayOutput output, uint8_t ledsPerSegment): _output(output), _ledsPerSegment(ledsPerSegment), _value(_7SEG_SYM_EMPTY), _mode(LedBasedDisplayMode::SET_ALL_LEDS) { _offColors = (CRGB*) malloc(7 * _ledsPerSegment * sizeof(CRGB)); _onColors = (CRGB*) malloc(7 * _ledsPerSegment * sizeof(CRGB)); _indices = (uint8_t*) malloc(7 * _ledsPerSegment * sizeof(uint8_t)); _showZero = true; } SevenSegmentDisplay::~SevenSegmentDisplay() { delete _indices; delete _offColors; delete _onColors; } uint8_t SevenSegmentDisplay::rowCount() { return _ledsPerSegment * 2 + 3; } uint8_t SevenSegmentDisplay::columnCount() { return _ledsPerSegment + 2; } uint8_t SevenSegmentDisplay::internalIndex(uint8_t row, uint8_t column) { uint8_t lastRow = (_ledsPerSegment + 1) * 2; if (row < 0 || row > lastRow) { return _7SEG_INDEX_UNDEF; } uint8_t midRow = _ledsPerSegment + 1; bool top = row == 0; bool mid = row == midRow; bool bot = row == lastRow; if (top || mid || bot) { if (column >= 1 && column <= _ledsPerSegment) { if (top) { return _7SEG_IDX(_7SEG_SEG_A, column - 1); } else if (mid) { return _7SEG_IDX(_7SEG_SEG_G, column - 1); } else { return _7SEG_IDX(_7SEG_SEG_D, column - 1); } } } else if (column == 0) { if (row < midRow) { return _7SEG_IDX(_7SEG_SEG_F, row - 1); } else { return _7SEG_IDX(_7SEG_SEG_E, row - midRow - 1); } } else if (column == _ledsPerSegment + 1) { if (row < midRow) { return _7SEG_IDX(_7SEG_SEG_B, row - 1); } else { return _7SEG_IDX(_7SEG_SEG_C, row - midRow - 1); } } return _7SEG_INDEX_UNDEF; } uint8_t SevenSegmentDisplay::indexOfCoords(uint8_t row, uint8_t column) { uint8_t idx = internalIndex(row, column); return idx == _7SEG_INDEX_UNDEF ? idx : _indices[idx]; } Coords SevenSegmentDisplay::coordsOfIndex(uint16_t index) { Coords coords; for (int i = 0, n = 7 * _ledsPerSegment; i < n; ++i) { if (_indices[i] == index) { uint8_t seg = i / _ledsPerSegment; uint8_t idx = i % _ledsPerSegment; switch (seg) { case _7SEG_SEG_A: coords.row = 0; break; case _7SEG_SEG_B: case _7SEG_SEG_F: coords.row = idx + 1; break; case _7SEG_SEG_C: case _7SEG_SEG_E: coords.row = _ledsPerSegment + 1 + idx + 1; break; case _7SEG_SEG_D: coords.row = _ledsPerSegment + 1 + _ledsPerSegment + 1; break; case _7SEG_SEG_G: coords.row = _ledsPerSegment + 1; break; } switch (seg) { case _7SEG_SEG_A: case _7SEG_SEG_D: case _7SEG_SEG_G: coords.col = idx + 1; break; case _7SEG_SEG_B: case _7SEG_SEG_C: coords.col = _ledsPerSegment + 1; break; case _7SEG_SEG_E: case _7SEG_SEG_F: coords.col = 0; break; } return coords; } } return coords; } CRGB* SevenSegmentDisplay::getLedColor(uint8_t row, uint8_t column, bool state) { uint8_t idx = internalIndex(row, column); if (idx == _7SEG_INDEX_UNDEF) { return &dummy; } return &(state ? _onColors : _offColors)[idx]; } void SevenSegmentDisplay::setLedColor(uint8_t row, uint8_t column, bool state, CRGB color) { uint8_t idx = internalIndex(row, column); if (idx == _7SEG_INDEX_UNDEF) { return; } (state ? _onColors : _offColors)[idx] = color; } void SevenSegmentDisplay::update() { uint8_t mask = 0b00000001; for (uint8_t seg = _7SEG_SEG_A; seg <= _7SEG_SEG_G; ++seg) { bool on = _value & mask; if (_7SEG_MODE(_mode, on)) { for (uint8_t i = 0; i < _ledsPerSegment; ++i) { uint8_t segmIdx = _7SEG_IDX(seg, i); CRGB c = (on ? _onColors : _offColors)[segmIdx]; (*_output)(_indices[segmIdx], c.red, c.green, c.blue); } } mask <<= 1; } } void SevenSegmentDisplay::setMode(LedBasedDisplayMode mode) { _mode = mode; } void SevenSegmentDisplay::mapSegment(uint8_t seg, ...) { va_list ap; va_start(ap, seg); for (uint8_t i = 0; i < _ledsPerSegment; i++) { _indices[_7SEG_IDX(seg, i)] = va_arg(ap, int); } va_end(ap); } void SevenSegmentDisplay::setSymbol(uint8_t symbol) { _value = symbol; } void SevenSegmentDisplay::setDigit(uint8_t digit) { switch (digit) { case 0: if (_showZero) setSymbol(_7SEG_SYM_0); else setSymbol(_7SEG_SYM_EMPTY); break; case 1: setSymbol(_7SEG_SYM_1); break; case 2: setSymbol(_7SEG_SYM_2); break; case 3: setSymbol(_7SEG_SYM_3); break; case 4: setSymbol(_7SEG_SYM_4); break; case 5: setSymbol(_7SEG_SYM_5); break; case 6: setSymbol(_7SEG_SYM_6); break; case 7: setSymbol(_7SEG_SYM_7); break; case 8: setSymbol(_7SEG_SYM_8); break; case 9: setSymbol(_7SEG_SYM_9); break; default: setSymbol(_7SEG_SYM_EMPTY); } } void SevenSegmentDisplay::setCharacter(char charcter) { switch (charcter) { case 'a': case 'A': setSymbol(_7SEG_SYM_A); break; case 'b': case 'B': setSymbol(_7SEG_SYM_B); break; case 'c': case 'C': setSymbol(_7SEG_SYM_C); break; case 'd': case 'D': setSymbol(_7SEG_SYM_D); break; case 'e': case 'E': setSymbol(_7SEG_SYM_E); break; case 'f': case 'F': setSymbol(_7SEG_SYM_F); break; case 'g': case 'G': setSymbol(_7SEG_SYM_G); break; case 'h': case 'H': setSymbol(_7SEG_SYM_H); break; case 'i': case 'I': setSymbol(_7SEG_SYM_I); break; case 'j': case 'J': setSymbol(_7SEG_SYM_J); break; case 'k': case 'K': setSymbol(_7SEG_SYM_K); break; case 'l': case 'L': setSymbol(_7SEG_SYM_L); break; case 'm': case 'M': setSymbol(_7SEG_SYM_M); break; case 'n': case 'N': setSymbol(_7SEG_SYM_N); break; case 'o': case 'O': setSymbol(_7SEG_SYM_O); break; case 'p': case 'P': setSymbol(_7SEG_SYM_P); break; case 'q': case 'Q': setSymbol(_7SEG_SYM_Q); break; case 'r': case 'R': setSymbol(_7SEG_SYM_R); break; case 's': case 'S': setSymbol(_7SEG_SYM_S); break; case 't': case 'T': setSymbol(_7SEG_SYM_T); break; case 'u': case 'U': setSymbol(_7SEG_SYM_U); break; case 'v': case 'V': setSymbol(_7SEG_SYM_V); break; case 'w': case 'W': setSymbol(_7SEG_SYM_W); break; case 'x': case 'X': setSymbol(_7SEG_SYM_X); break; case 'y': case 'Y': setSymbol(_7SEG_SYM_Y); break; case 'z': case 'Z': setSymbol(_7SEG_SYM_Z); break; case '-': setSymbol(_7SEG_SYM_DASH); break; case '_': setSymbol(_7SEG_SYM_UNDERSCORE); break; case ' ': default: setSymbol(_7SEG_SYM_EMPTY); } } void SevenSegmentDisplay::setShowZero(boolean showZero) { _showZero = showZero; } SeparatorDisplay::SeparatorDisplay(LedBasedDisplayOutput output): _output(output), _ledCount(0), _mappings(NULL), _state(false), _mode(LedBasedDisplayMode::SET_ALL_LEDS) {} SeparatorDisplay::~SeparatorDisplay() { delete _mappings; } uint8_t SeparatorDisplay::rowCount() { uint8_t max = _mappings[0].row; for (uint8_t i = 1; i < _ledCount; ++i) { if (_mappings[i].row > max) { max = _mappings[i].row; } } return max + 1; } uint8_t SeparatorDisplay::columnCount() { uint8_t max = _mappings[0].column; for (uint8_t i = 1; i < _ledCount; ++i) { if (_mappings[i].column > max) { max = _mappings[i].column; } } return max + 1; } uint8_t SeparatorDisplay::indexOfCoords(uint8_t row, uint8_t column) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].row == row && _mappings[i].column == column) { return _mappings[i].index; } } return _7SEG_INDEX_UNDEF; } Coords SeparatorDisplay::coordsOfIndex(uint16_t index) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].index == index) { return Coords(_mappings[i].row, _mappings[i].column); } } return Coords(); } CRGB* SeparatorDisplay::getLedColor(uint8_t row, uint8_t column, bool state) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].row == row && _mappings[i].column == column) { if (state) { return &_mappings[i].onColor; } else { return &_mappings[i].offColor; } } } return &dummy; } void SeparatorDisplay::setLedColor(uint8_t row, uint8_t column, bool state, CRGB color) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].row == row && _mappings[i].column == column) { if (state) { _mappings[i].onColor = color; } else { _mappings[i].offColor = color; } } } } void SeparatorDisplay::update() { for (uint8_t i = 0; i < _ledCount; ++i) { if (_7SEG_MODE(_mode, _state)) { CRGB c = _state ? _mappings[i].onColor : _mappings[i].offColor; (*_output)(_mappings[i].index, c.red, c.green, c.blue); } } } void SeparatorDisplay::setMode(LedBasedDisplayMode mode) { _mode = mode; } void SeparatorDisplay::map(uint8_t ledCount, ...) { if (_mappings != NULL) { delete _mappings; } _ledCount = ledCount; _mappings = (struct _Mapping*) malloc(ledCount * sizeof(struct _Mapping)); va_list ap; va_start(ap, ledCount); for (uint8_t i = 0; i < ledCount; i++) { _mappings[i].row = va_arg(ap, int); _mappings[i].column = va_arg(ap, int); _mappings[i].index = va_arg(ap, int); } va_end(ap); } void SeparatorDisplay::setState(bool state) { _state = state; } LedBasedRowDisplay::LedBasedRowDisplay(uint8_t displayCount, ...): _displayCount(displayCount), _displays((LedBasedDisplay**) malloc(displayCount * sizeof(LedBasedDisplay*))) { va_list ap; va_start(ap, displayCount); for (uint8_t i = 0; i < displayCount; i++) { _displays[i] = va_arg(ap, LedBasedDisplay*); } va_end(ap); } LedBasedRowDisplay::~LedBasedRowDisplay() { delete _displays; } uint8_t LedBasedRowDisplay::rowCount() { uint8_t rowCount = 0; for (uint8_t i = 0; i < _displayCount; i++) { rowCount = max(rowCount, _displays[i]->rowCount()); } return rowCount; } uint8_t LedBasedRowDisplay::columnCount() { uint8_t columnCount = 0; for (uint8_t i = 0; i < _displayCount; i++) { columnCount += _displays[i]->columnCount(); } return columnCount; } uint8_t LedBasedRowDisplay::indexOfCoords(uint8_t row, uint8_t column) { uint8_t c = column; for (uint8_t i = 0; i < _displayCount; i++) { uint8_t cc = _displays[i]->columnCount(); if (_displays[i]->columnCount() - 1 < c) { c -= cc; } else { return _displays[i]->indexOfCoords(row, c); } } return _7SEG_INDEX_UNDEF; } Coords LedBasedRowDisplay::coordsOfIndex(uint16_t index) { uint8_t columnCount = 0; for (uint8_t i = 0; i < _displayCount; i++) { Coords coords = _displays[i]->coordsOfIndex(index); if (coords.isValid()) { coords.col += columnCount; return coords; } else { columnCount += _displays[i]->columnCount(); } } return Coords(); } CRGB* LedBasedRowDisplay::getLedColor(uint8_t row, uint8_t column, bool state) { uint8_t c = column; for (uint8_t i = 0; i < _displayCount; i++) { uint8_t cc = _displays[i]->columnCount(); if (_displays[i]->columnCount() - 1 < c) { c -= cc; } else { return _displays[i]->getLedColor(row, c, state); } } return &dummy; } void LedBasedRowDisplay::setLedColor(uint8_t row, uint8_t column, bool state, CRGB color) { uint8_t c = column; for (uint8_t i = 0; i < _displayCount; i++) { uint8_t cc = _displays[i]->columnCount(); if (cc - 1 < c) { c -= cc; } else { _displays[i]->setLedColor(row, c, state, color); return; } } } void LedBasedRowDisplay::update() { for (uint8_t i = 0; i < _displayCount; i++) { _displays[i]->update(); } } void LedBasedRowDisplay::setMode(LedBasedDisplayMode mode) { for (uint8_t i = 0; i < _displayCount; i++) { _displays[i]->setMode(mode); } }
#include "7segmdisp.h" static CRGB dummy; void LedBasedDisplay::setRowColor(uint8_t row, bool state, CRGB color) { for (uint8_t c = 0, n = columnCount(); c < n; ++c) { setLedColor(row, c, state, color); } } void LedBasedDisplay::setColumnColor(uint8_t column, bool state, CRGB color) { for (uint8_t r = 0, n = rowCount(); r < n; ++r) { setLedColor(r, column, state, color); } } void LedBasedDisplay::setColor(bool state, CRGB color) { for (uint8_t r = 0, rn = rowCount(); r < rn; ++r) { for (uint8_t c = 0, cn = columnCount(); c < cn; ++c) { setLedColor(r, c, state, color); } } }
SevenSegmentDisplay::~SevenSegmentDisplay() { delete _indices; delete _offColors; delete _onColors; } uint8_t SevenSegmentDisplay::rowCount() { return _ledsPerSegment * 2 + 3; } uint8_t SevenSegmentDisplay::columnCount() { return _ledsPerSegment + 2; } uint8_t SevenSegmentDisplay::internalIndex(uint8_t row, uint8_t column) { uint8_t lastRow = (_ledsPerSegment + 1) * 2; if (row < 0 || row > lastRow) { return _7SEG_INDEX_UNDEF; } uint8_t midRow = _ledsPerSegment + 1; bool top = row == 0; bool mid = row == midRow; bool bot = row == lastRow; if (top || mid || bot) { if (column >= 1 && column <= _ledsPerSegment) { if (top) { return _7SEG_IDX(_7SEG_SEG_A, column - 1); } else if (mid) { return _7SEG_IDX(_7SEG_SEG_G, column - 1); } else { return _7SEG_IDX(_7SEG_SEG_D, column - 1); } } } else if (column == 0) { if (row < midRow) { return _7SEG_IDX(_7SEG_SEG_F, row - 1); } else { return _7SEG_IDX(_7SEG_SEG_E, row - midRow - 1); } } else if (column == _ledsPerSegment + 1) { if (row < midRow) { return _7SEG_IDX(_7SEG_SEG_B, row - 1); } else { return _7SEG_IDX(_7SEG_SEG_C, row - midRow - 1); } } return _7SEG_INDEX_UNDEF; } uint8_t SevenSegmentDisplay::indexOfCoords(uint8_t row, uint8_t column) { uint8_t idx = internalIndex(row, column); return idx == _7SEG_INDEX_UNDEF ? idx : _indices[idx]; } Coords SevenSegmentDisplay::coordsOfIndex(uint16_t index) { Coords coords; for (int i = 0, n = 7 * _ledsPerSegment; i < n; ++i) { if (_indices[i] == index) { uint8_t seg = i / _ledsPerSegment; uint8_t idx = i % _ledsPerSegment; switch (seg) { case _7SEG_SEG_A: coords.row = 0; break; case _7SEG_SEG_B: case _7SEG_SEG_F: coords.row = idx + 1; break; case _7SEG_SEG_C: case _7SEG_SEG_E: coords.row = _ledsPerSegment + 1 + idx + 1; break; case _7SEG_SEG_D: coords.row = _ledsPerSegment + 1 + _ledsPerSegment + 1; break; case _7SEG_SEG_G: coords.row = _ledsPerSegment + 1; break; } switch (seg) { case _7SEG_SEG_A: case _7SEG_SEG_D: case _7SEG_SEG_G: coords.col = idx + 1; break; case _7SEG_SEG_B: case _7SEG_SEG_C: coords.col = _ledsPerSegment + 1; break; case _7SEG_SEG_E: case _7SEG_SEG_F: coords.col = 0; break; } return coords; } } return coords; } CRGB* SevenSegmentDisplay::getLedColor(uint8_t row, uint8_t column, bool state) { uint8_t idx = internalIndex(row, column); if (idx == _7SEG_INDEX_UNDEF) { return &dummy; } return &(state ? _onColors : _offColors)[idx]; } void SevenSegmentDisplay::setLedColor(uint8_t row, uint8_t column, bool state, CRGB color) { uint8_t idx = internalIndex(row, column); if (idx == _7SEG_INDEX_UNDEF) { return; } (state ? _onColors : _offColors)[idx] = color; } void SevenSegmentDisplay::update() { uint8_t mask = 0b00000001; for (uint8_t seg = _7SEG_SEG_A; seg <= _7SEG_SEG_G; ++seg) { bool on = _value & mask; if (_7SEG_MODE(_mode, on)) { for (uint8_t i = 0; i < _ledsPerSegment; ++i) { uint8_t segmIdx = _7SEG_IDX(seg, i); CRGB c = (on ? _onColors : _offColors)[segmIdx]; (*_output)(_indices[segmIdx], c.red, c.green, c.blue); } } mask <<= 1; } } void SevenSegmentDisplay::setMode(LedBasedDisplayMode mode) { _mode = mode; } void SevenSegmentDisplay::mapSegment(uint8_t seg, ...) { va_list ap; va_start(ap, seg); for (uint8_t i = 0; i < _ledsPerSegment; i++) { _indices[_7SEG_IDX(seg, i)] = va_arg(ap, int); } va_end(ap); } void SevenSegmentDisplay::setSymbol(uint8_t symbol) { _value = symbol; } void SevenSegmentDisplay::setDigit(uint8_t digit) { switch (digit) { case 0: if (_showZero) setSymbol(_7SEG_SYM_0); else setSymbol(_7SEG_SYM_EMPTY); break; case 1: setSymbol(_7SEG_SYM_1); break; case 2: setSymbol(_7SEG_SYM_2); break; case 3: setSymbol(_7SEG_SYM_3); break; case 4: setSymbol(_7SEG_SYM_4); break; case 5: setSymbol(_7SEG_SYM_5); break; case 6: setSymbol(_7SEG_SYM_6); break; case 7: setSymbol(_7SEG_SYM_7); break; case 8: setSymbol(_7SEG_SYM_8); break; case 9: setSymbol(_7SEG_SYM_9); break; default: setSymbol(_7SEG_SYM_EMPTY); } } void SevenSegmentDisplay::setCharacter(char charcter) { switch (charcter) { case 'a': case 'A': setSymbol(_7SEG_SYM_A); break; case 'b': case 'B': setSymbol(_7SEG_SYM_B); break; case 'c': case 'C': setSymbol(_7SEG_SYM_C); break; case 'd': case 'D': setSymbol(_7SEG_SYM_D); break; case 'e': case 'E': setSymbol(_7SEG_SYM_E); break; case 'f': case 'F': setSymbol(_7SEG_SYM_F); break; case 'g': case 'G': setSymbol(_7SEG_SYM_G); break; case 'h': case 'H': setSymbol(_7SEG_SYM_H); break; case 'i': case 'I': setSymbol(_7SEG_SYM_I); break; case 'j': case 'J': setSymbol(_7SEG_SYM_J); break; case 'k': case 'K': setSymbol(_7SEG_SYM_K); break; case 'l': case 'L': setSymbol(_7SEG_SYM_L); break; case 'm': case 'M': setSymbol(_7SEG_SYM_M); break; case 'n': case 'N': setSymbol(_7SEG_SYM_N); break; case 'o': case 'O': setSymbol(_7SEG_SYM_O); break; case 'p': case 'P': setSymbol(_7SEG_SYM_P); break; case 'q': case 'Q': setSymbol(_7SEG_SYM_Q); break; case 'r': case 'R': setSymbol(_7SEG_SYM_R); break; case 's': case 'S': setSymbol(_7SEG_SYM_S); break; case 't': case 'T': setSymbol(_7SEG_SYM_T); break; case 'u': case 'U': setSymbol(_7SEG_SYM_U); break; case 'v': case 'V': setSymbol(_7SEG_SYM_V); break; case 'w': case 'W': setSymbol(_7SEG_SYM_W); break; case 'x': case 'X': setSymbol(_7SEG_SYM_X); break; case 'y': case 'Y': setSymbol(_7SEG_SYM_Y); break; case 'z': case 'Z': setSymbol(_7SEG_SYM_Z); break; case '-': setSymbol(_7SEG_SYM_DASH); break; case '_': setSymbol(_7SEG_SYM_UNDERSCORE); break; case ' ': default: setSymbol(_7SEG_SYM_EMPTY); } } void SevenSegmentDisplay::setShowZero(boolean showZero) { _showZero = showZero; } SeparatorDisplay::SeparatorDisplay(LedBasedDisplayOutput output): _output(output), _ledCount(0), _mappings(NULL), _state(false), _mode(LedBasedDisplayMode::SET_ALL_LEDS) {} SeparatorDisplay::~SeparatorDisplay() { delete _mappings; } uint8_t SeparatorDisplay::rowCount() { uint8_t max = _mappings[0].row; for (uint8_t i = 1; i < _ledCount; ++i) { if (_mappings[i].row > max) { max = _mappings[i].row; } } return max + 1; } uint8_t SeparatorDisplay::columnCount() { uint8_t max = _mappings[0].column; for (uint8_t i = 1; i < _ledCount; ++i) { if (_mappings[i].column > max) { max = _mappings[i].column; } } return max + 1; } uint8_t SeparatorDisplay::indexOfCoords(uint8_t row, uint8_t column) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].row == row && _mappings[i].column == column) { return _mappings[i].index; } } return _7SEG_INDEX_UNDEF; } Coords SeparatorDisplay::coordsOfIndex(uint16_t index) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].index == index) { return Coords(_mappings[i].row, _mappings[i].column); } } return Coords(); } CRGB* SeparatorDisplay::getLedColor(uint8_t row, uint8_t column, bool state) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].row == row && _mappings[i].column == column) { if (state) { return &_mappings[i].onColor; } else { return &_mappings[i].offColor; } } } return &dummy; } void SeparatorDisplay::setLedColor(uint8_t row, uint8_t column, bool state, CRGB color) { for (uint8_t i = 0; i < _ledCount; ++i) { if (_mappings[i].row == row && _mappings[i].column == column) { if (state) { _mappings[i].onColor = color; } else { _mappings[i].offColor = color; } } } } void SeparatorDisplay::update() { for (uint8_t i = 0; i < _ledCount; ++i) { if (_7SEG_MODE(_mode, _state)) { CRGB c = _state ? _mappings[i].onColor : _mappings[i].offColor; (*_output)(_mappings[i].index, c.red, c.green, c.blue); } } } void SeparatorDisplay::setMode(LedBasedDisplayMode mode) { _mode = mode; } void SeparatorDisplay::map(uint8_t ledCount, ...) { if (_mappings != NULL) { delete _mappings; } _ledCount = ledCount; _mappings = (struct _Mapping*) malloc(ledCount * sizeof(struct _Mapping)); va_list ap; va_start(ap, ledCount); for (uint8_t i = 0; i < ledCount; i++) { _mappings[i].row = va_arg(ap, int); _mappings[i].column = va_arg(ap, int); _mappings[i].index = va_arg(ap, int); } va_end(ap); } void SeparatorDisplay::setState(bool state) { _state = state; } LedBasedRowDisplay::LedBasedRowDisplay(uint8_t displayCount, ...): _displayCount(displayCount), _displays((LedBasedDisplay**) malloc(displayCount * sizeof(LedBasedDisplay*))) { va_list ap; va_start(ap, displayCount); for (uint8_t i = 0; i < displayCount; i++) { _displays[i] = va_arg(ap, LedBasedDisplay*); } va_end(ap); } LedBasedRowDisplay::~LedBasedRowDisplay() { delete _displays; } uint8_t LedBasedRowDisplay::rowCount() { uint8_t rowCount = 0; for (uint8_t i = 0; i < _displayCount; i++) { rowCount = max(rowCount, _displays[i]->rowCount()); } return rowCount; } uint8_t LedBasedRowDisplay::columnCount() { uint8_t columnCount = 0; for (uint8_t i = 0; i < _displayCount; i++) { columnCount += _displays[i]->columnCount(); } return columnCount; } uint8_t LedBasedRowDisplay::indexOfCoords(uint8_t row, uint8_t column) { uint8_t c = column; for (uint8_t i = 0; i < _displayCount; i++) { uint8_t cc = _displays[i]->columnCount(); if (_displays[i]->columnCount() - 1 < c) { c -= cc; } else { return _displays[i]->indexOfCoords(row, c); } } return _7SEG_INDEX_UNDEF; } Coords LedBasedRowDisplay::coordsOfIndex(uint16_t index) { uint8_t columnCount = 0; for (uint8_t i = 0; i < _displayCount; i++) { Coords coords = _displays[i]->coordsOfIndex(index); if (coords.isValid()) { coords.col += columnCount; return coords; } else { columnCount += _displays[i]->columnCount(); } } return Coords(); } CRGB* LedBasedRowDisplay::getLedColor(uint8_t row, uint8_t column, bool state) { uint8_t c = column; for (uint8_t i = 0; i < _displayCount; i++) { uint8_t cc = _displays[i]->columnCount(); if (_displays[i]->columnCount() - 1 < c) { c -= cc; } else { return _displays[i]->getLedColor(row, c, state); } } return &dummy; } void LedBasedRowDisplay::setLedColor(uint8_t row, uint8_t column, bool state, CRGB color) { uint8_t c = column; for (uint8_t i = 0; i < _displayCount; i++) { uint8_t cc = _displays[i]->columnCount(); if (cc - 1 < c) { c -= cc; } else { _displays[i]->setLedColor(row, c, state, color); return; } } } void LedBasedRowDisplay::update() { for (uint8_t i = 0; i < _displayCount; i++) { _displays[i]->update(); } } void LedBasedRowDisplay::setMode(LedBasedDisplayMode mode) { for (uint8_t i = 0; i < _displayCount; i++) { _displays[i]->setMode(mode); } }
SevenSegmentDisplay::SevenSegmentDisplay(LedBasedDisplayOutput output, uint8_t ledsPerSegment): _output(output), _ledsPerSegment(ledsPerSegment), _value(_7SEG_SYM_EMPTY), _mode(LedBasedDisplayMode::SET_ALL_LEDS) { _offColors = (CRGB*) malloc(7 * _ledsPerSegment * sizeof(CRGB)); _onColors = (CRGB*) malloc(7 * _ledsPerSegment * sizeof(CRGB)); _indices = (uint8_t*) malloc(7 * _ledsPerSegment * sizeof(uint8_t)); _showZero = true; }
function_block-full_function
[ { "content": "const _C = d.querySelector('.container'), N = 4;\n", "file_path": "wled00/data/index.js", "rank": 0, "score": 80796.51181418088 }, { "content": "struct Reader<VariantRef, void> : Reader<char*, void> {\n\n explicit Reader(VariantRef x) : Reader<char*, void>(x.as<const char*>()) {}\n\n};\n\ntemplate <>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 1, "score": 73268.5994131988 }, { "content": "struct Reader<VariantConstRef, void> : Reader<char*, void> {\n\n explicit Reader(VariantConstRef x)\n\n : Reader<char*, void>(x.as<const char*>()) {}\n\n};\n\n} // namespace ARDUINOJSON_NAMESPACE\n\n#if ARDUINOJSON_ENABLE_ARDUINO_STREAM\n\nnamespace ARDUINOJSON_NAMESPACE {\n\ntemplate <typename TSource>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 2, "score": 72225.99849956296 }, { "content": "struct Reader<ElementProxy<TArray>, void> : Reader<char*, void> {\n\n explicit Reader(const ElementProxy<TArray>& x)\n\n : Reader<char*, void>(x.template as<const char*>()) {}\n\n};\n\ntemplate <typename TObject, typename TStringRef>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 3, "score": 69252.20579680463 }, { "content": "struct Converter<bool> {\n\n static bool toJson(bool src, VariantRef dst) {\n\n VariantData* data = getData(dst);\n\n if (!data)\n\n return false;\n\n data->setBoolean(src);\n\n return true;\n\n }\n\n static bool fromJson(VariantConstRef src) {\n\n const VariantData* data = getData(src);\n\n return data ? data->asBoolean() : false;\n\n }\n\n static bool checkJson(VariantConstRef src) {\n\n const VariantData* data = getData(src);\n\n return data && data->isBoolean();\n\n }\n\n};\n\ntemplate <typename T>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 4, "score": 66144.30217308938 }, { "content": "struct IsString<void*> {\n\n static const bool value = false;\n\n};\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 5, "score": 66106.94667312861 }, { "content": "struct Reader<MemberProxy<TObject, TStringRef>, void> : Reader<char*, void> {\n\n explicit Reader(const MemberProxy<TObject, TStringRef>& x)\n\n : Reader<char*, void>(x.template as<const char*>()) {}\n\n};\n\ntemplate <>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 6, "score": 64801.93876755895 }, { "content": "class Writer< ::String, void> {\n\n static const size_t bufferCapacity = ARDUINOJSON_STRING_BUFFER_SIZE;\n\n public:\n\n explicit Writer(::String &str) : _destination(&str) {\n\n _size = 0;\n\n }\n\n ~Writer() {\n\n flush();\n\n }\n\n size_t write(uint8_t c) {\n\n if (_size + 1 >= bufferCapacity)\n\n if (flush() != 0)\n\n return 0;\n\n _buffer[_size++] = static_cast<char>(c);\n\n return 1;\n\n }\n\n size_t write(const uint8_t *s, size_t n) {\n\n for (size_t i = 0; i < n; i++) {\n\n write(s[i]);\n\n }\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 7, "score": 60853.61035929926 }, { "content": "enum class EspalexaDeviceType : uint8_t { onoff = 0, dimmable = 1, whitespectrum = 2, color = 3, extendedcolor = 4 };\n", "file_path": "wled00/src/dependencies/espalexa/EspalexaDevice.h", "rank": 8, "score": 60237.18023079264 }, { "content": "struct is_unsigned : integral_constant<bool,\n\n is_same<typename remove_cv<T>::type, unsigned char>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned short>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned int>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned long>::value ||\n\n#if ARDUINOJSON_HAS_INT64\n\n is_same<typename remove_cv<T>::type, unsigned __int64>::value ||\n\n#endif\n\n#if ARDUINOJSON_HAS_LONG_LONG\n\n is_same<typename remove_cv<T>::type, unsigned long long>::value ||\n\n#endif\n\n is_same<typename remove_cv<T>::type, bool>::value> {};\n\ntemplate <typename T>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 9, "score": 59563.628035319576 }, { "content": "struct is_integral : integral_constant<bool,\n\n is_same<typename remove_cv<T>::type, signed char>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned char>::value ||\n\n is_same<typename remove_cv<T>::type, signed short>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned short>::value ||\n\n is_same<typename remove_cv<T>::type, signed int>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned int>::value ||\n\n is_same<typename remove_cv<T>::type, signed long>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned long>::value ||\n\n#if ARDUINOJSON_HAS_LONG_LONG\n\n is_same<typename remove_cv<T>::type, signed long long>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned long long>::value ||\n\n#endif\n\n#if ARDUINOJSON_HAS_INT64\n\n is_same<typename remove_cv<T>::type, signed __int64>::value ||\n\n is_same<typename remove_cv<T>::type, unsigned __int64>::value ||\n\n#endif\n\n is_same<typename remove_cv<T>::type, char>::value ||\n\n is_same<typename remove_cv<T>::type, bool>::value> {};\n\ntemplate <typename T>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 10, "score": 59563.628035319576 }, { "content": "struct is_signed : integral_constant<bool, \n\n is_same<typename remove_cv<T>::type, char>::value ||\n\n is_same<typename remove_cv<T>::type, signed char>::value ||\n\n is_same<typename remove_cv<T>::type, signed short>::value ||\n\n is_same<typename remove_cv<T>::type, signed int>::value ||\n\n is_same<typename remove_cv<T>::type, signed long>::value ||\n\n#if ARDUINOJSON_HAS_LONG_LONG\n\n is_same<typename remove_cv<T>::type, signed long long>::value ||\n\n#endif\n\n#if ARDUINOJSON_HAS_INT64\n\n is_same<typename remove_cv<T>::type, signed __int64>::value ||\n\n#endif\n\n is_same<typename remove_cv<T>::type, float>::value ||\n\n is_same<typename remove_cv<T>::type, double>::value> {};\n\ntemplate <typename T>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 11, "score": 59563.628035319576 }, { "content": "struct is_array<T[N]> : true_type {};\n\ntemplate <typename TBase, typename TDerived>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 12, "score": 55431.143850278546 }, { "content": "class ArrayCopier2D : public Visitor<void> {\n\n public:\n\n ArrayCopier2D(T (*destination)[N1][N2]) : _destination(destination) {}\n\n void visitArray(const CollectionData& array) {\n\n VariantSlot* slot = array.head();\n\n size_t n = 0;\n\n while (slot != 0 && n < N1) {\n\n ArrayCopier1D<T> copier((*_destination)[n++], N2);\n\n variantAccept(slot->data(), copier);\n\n slot = slot->next();\n\n }\n\n }\n\n private:\n\n T (*_destination)[N1][N2];\n\n size_t _capacity1, _capacity2;\n\n};\n\ntemplate <typename TSource, typename T, size_t N>\n\ninline typename enable_if<!is_array<T>::value, size_t>::type copyArray(\n\n const TSource& src, T (&dst)[N]) {\n\n return copyArray(src, dst, N);\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 13, "score": 54252.019757935035 }, { "content": "struct Reader<const __FlashStringHelper*, void> {\n\n const char* _ptr;\n\n public:\n\n explicit Reader(const __FlashStringHelper* ptr)\n\n : _ptr(reinterpret_cast<const char*>(ptr)) {}\n\n int read() {\n\n return pgm_read_byte(_ptr++);\n\n }\n\n size_t readBytes(char* buffer, size_t length) {\n\n memcpy_P(buffer, _ptr, length);\n\n _ptr += length;\n\n return length;\n\n }\n\n};\n\ntemplate <>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 14, "score": 54252.019757935035 }, { "content": "enum class BufferState : uint8_t {\n\n NONE = 0,\n\n REMAINING_LENGTH = 2,\n\n VARIABLE_HEADER = 3,\n\n PAYLOAD = 4\n\n};\n\n\n", "file_path": "wled00/src/dependencies/async-mqtt-client/AsyncMqttClient/ParsingInformation.hpp", "rank": 15, "score": 54146.861156985426 }, { "content": "enum class EspalexaColorMode : uint8_t { none = 0, ct = 1, hs = 2, xy = 3 };\n", "file_path": "wled00/src/dependencies/espalexa/EspalexaDevice.h", "rank": 16, "score": 53812.116407330686 }, { "content": "struct BoundedReader<const __FlashStringHelper*, void> {\n\n const char* _ptr;\n\n const char* _end;\n\n public:\n\n explicit BoundedReader(const __FlashStringHelper* ptr, size_t size)\n\n : _ptr(reinterpret_cast<const char*>(ptr)), _end(_ptr + size) {}\n\n int read() {\n\n if (_ptr < _end)\n\n return pgm_read_byte(_ptr++);\n\n else\n\n return -1;\n\n }\n\n size_t readBytes(char* buffer, size_t length) {\n\n size_t available = static_cast<size_t>(_end - _ptr);\n\n if (available < length)\n\n length = available;\n\n memcpy_P(buffer, _ptr, length);\n\n _ptr += length;\n\n return length;\n\n }\n\n};\n\n} // namespace ARDUINOJSON_NAMESPACE\n\n#endif\n\n#if ARDUINOJSON_ENABLE_STD_STREAM\n\n#include <istream>\n\nnamespace ARDUINOJSON_NAMESPACE {\n\ntemplate <typename TSource>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 17, "score": 53176.49500844315 }, { "content": "//v2 usermod that allows to change brightness and color using a rotary encoder, \n\n//change between modes by pressing a button (many encoders have one included)\n\nclass RotaryEncoderBrightnessColor : public Usermod\n\n{\n\nprivate:\n\n //Private class members. You can declare variables and functions only accessible to your usermod here\n\n unsigned long lastTime = 0;\n\n unsigned long currentTime;\n\n unsigned long loopTime;\n\n\n\n unsigned char select_state = 0; // 0 = brightness 1 = color\n\n unsigned char button_state = HIGH;\n\n unsigned char prev_button_state = HIGH;\n\n CRGB fastled_col;\n\n CHSV prim_hsv;\n\n int16_t new_val;\n\n\n\n unsigned char Enc_A;\n\n unsigned char Enc_B;\n\n unsigned char Enc_A_prev = 0;\n\n\n\n // private class memebers configurable by Usermod Settings (defaults set inside readFromConfig())\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 18, "score": 52919.62676465036 }, { "content": "#pragma once\n\n\n\n#include \"wled.h\"\n\n\n\n//v2 usermod that allows to change brightness and color using a rotary encoder, \n\n//change between modes by pressing a button (many encoders have one included)\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 19, "score": 52141.653865474174 }, { "content": " /*\n\n * loop() is called continuously. Here you can check for events, read sensors, etc.\n\n * \n\n * Tips:\n\n * 1. You can use \"if (WLED_CONNECTED)\" to check for a successful network connection.\n\n * Additionally, \"if (WLED_MQTT_CONNECTED)\" is available to check for a connection to an MQTT broker.\n\n * \n\n * 2. Try to avoid using the delay() function. NEVER use delays longer than 10 milliseconds.\n\n * Instead, use a timer check as shown here.\n\n */\n\n void loop()\n\n {\n\n currentTime = millis(); // get the current elapsed time\n\n\n\n if (currentTime >= (loopTime + 2)) // 2ms since last check of encoder = 500Hz\n\n {\n\n if(pins[2] >= 0) {\n\n button_state = digitalRead(pins[2]);\n\n if (prev_button_state != button_state)\n\n {\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 20, "score": 52139.41663362139 }, { "content": " if (button_state == LOW)\n\n {\n\n if (select_state == 1)\n\n {\n\n select_state = 0;\n\n }\n\n else\n\n {\n\n select_state = 1;\n\n }\n\n prev_button_state = button_state;\n\n }\n\n else\n\n {\n\n prev_button_state = button_state;\n\n }\n\n }\n\n }\n\n int Enc_A = digitalRead(pins[0]); // Read encoder pins\n\n int Enc_B = digitalRead(pins[1]);\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 21, "score": 52137.86402511143 }, { "content": " * - a single value being missing after boot (e.g. if the cfg.json was manually edited and a value was removed)\n\n * \n\n * If configComplete is false, the default values are already set, and by returning false, WLED now knows it needs to save the defaults by calling addToConfig()\n\n */\n\n bool readFromConfig(JsonObject& root)\n\n {\n\n // set defaults here, they will be set before setup() is called, and if any values parsed from ArduinoJson below are missing, the default will be used instead\n\n fadeAmount = 5;\n\n pins[0] = -1;\n\n pins[1] = -1;\n\n pins[2] = -1;\n\n\n\n JsonObject top = root[\"rotEncBrightness\"];\n\n\n\n bool configComplete = !top.isNull();\n\n configComplete &= getJsonValue(top[\"fadeAmount\"], fadeAmount);\n\n configComplete &= getJsonValue(top[\"pin\"][0], pins[0]);\n\n configComplete &= getJsonValue(top[\"pin\"][1], pins[1]);\n\n configComplete &= getJsonValue(top[\"pin\"][2], pins[2]);\n\n\n\n return configComplete;\n\n }\n\n};\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 22, "score": 52134.85802004395 }, { "content": " prim_hsv.h = (byte)new_val;\n\n hsv2rgb_rainbow(prim_hsv, fastled_col);\n\n col[0] = fastled_col.red;\n\n col[1] = fastled_col.green;\n\n col[2] = fastled_col.blue;\n\n }\n\n }\n\n else if (Enc_B == LOW)\n\n { // B is low so counter-clockwise\n\n if (select_state == 0)\n\n {\n\n if (bri - fadeAmount >= 0)\n\n bri -= fadeAmount; // decrease the brightness, dont go below 0\n\n }\n\n else\n\n {\n\n fastled_col.red = col[0];\n\n fastled_col.green = col[1];\n\n fastled_col.blue = col[2];\n\n prim_hsv = rgb2hsv_approximate(fastled_col);\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 23, "score": 52134.38278478665 }, { "content": " if ((!Enc_A) && (Enc_A_prev))\n\n { // A has gone from high to low\n\n if (Enc_B == HIGH)\n\n { // B is high so clockwise\n\n if (select_state == 0)\n\n {\n\n if (bri + fadeAmount <= 255)\n\n bri += fadeAmount; // increase the brightness, dont go over 255\n\n }\n\n else\n\n {\n\n fastled_col.red = col[0];\n\n fastled_col.green = col[1];\n\n fastled_col.blue = col[2];\n\n prim_hsv = rgb2hsv_approximate(fastled_col);\n\n new_val = (int16_t)prim_hsv.h + fadeAmount;\n\n if (new_val > 255)\n\n new_val -= 255; // roll-over if bigger than 255\n\n if (new_val < 0)\n\n new_val += 255; // roll-over if smaller than 0\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 24, "score": 52134.359084403695 }, { "content": " int8_t pins[3]; // pins[0] = DT from encoder, pins[1] = CLK from encoder, pins[2] = CLK from encoder (optional)\n\n int fadeAmount; // how many points to fade the Neopixel with each step\n\n\n\npublic:\n\n //Functions called by WLED\n\n\n\n /*\n\n * setup() is called once at boot. WiFi is not yet connected at this point.\n\n * You can use it to initialize variables, sensors or similar.\n\n */\n\n void setup()\n\n {\n\n //Serial.println(\"Hello from my usermod!\");\n\n pinMode(pins[0], INPUT_PULLUP);\n\n pinMode(pins[1], INPUT_PULLUP);\n\n if(pins[2] >= 0) pinMode(pins[2], INPUT_PULLUP);\n\n currentTime = millis();\n\n loopTime = currentTime;\n\n }\n\n\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 25, "score": 52134.12708156838 }, { "content": " new_val = (int16_t)prim_hsv.h - fadeAmount;\n\n if (new_val > 255)\n\n new_val -= 255; // roll-over if bigger than 255\n\n if (new_val < 0)\n\n new_val += 255; // roll-over if smaller than 0\n\n prim_hsv.h = (byte)new_val;\n\n hsv2rgb_rainbow(prim_hsv, fastled_col);\n\n col[0] = fastled_col.red;\n\n col[1] = fastled_col.green;\n\n col[2] = fastled_col.blue;\n\n }\n\n }\n\n //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)\n\n // 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa\n\n colorUpdated(CALL_MODE_BUTTON);\n\n updateInterfaces(CALL_MODE_BUTTON);\n\n }\n\n Enc_A_prev = Enc_A; // Store value of A for next time\n\n loopTime = currentTime; // Updates loopTime\n\n }\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 26, "score": 52133.88225297711 }, { "content": " }\n\n\n\n void addToConfig(JsonObject& root)\n\n {\n\n JsonObject top = root.createNestedObject(\"rotEncBrightness\");\n\n top[\"fadeAmount\"] = fadeAmount;\n\n JsonArray pinArray = top.createNestedArray(\"pin\");\n\n pinArray.add(pins[0]);\n\n pinArray.add(pins[1]); \n\n pinArray.add(pins[2]); \n\n }\n\n\n\n /* \n\n * This example uses a more robust method of checking for missing values in the config, and setting back to defaults:\n\n * - The getJsonValue() function copies the value to the variable only if the key requested is present, returning false with no copy if the value isn't present\n\n * - configComplete is used to return false if any value is missing, not just if the main object is missing\n\n * - The defaults are loaded every time readFromConfig() is run, not just once after boot\n\n * \n\n * This ensures that missing values are added to the config, with their default values, in the rare but plauible cases of:\n\n * - a single value being missing at boot, e.g. if the Usermod was upgraded and a new setting was added\n", "file_path": "usermods/usermod_rotary_brightness_color/usermod_rotary_brightness_color.h", "rank": 27, "score": 52133.44612881889 }, { "content": "struct IsString<const char[N]> : true_type {};\n\ninline ConstRamStringAdapter adaptString(const char* str) {\n\n return ConstRamStringAdapter(str);\n\n}\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 28, "score": 52010.38659590209 }, { "content": "struct Comparer<decltype(nullptr), void> : NullComparer {\n\n explicit Comparer(decltype(nullptr)) : NullComparer() {}\n\n};\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 29, "score": 51983.50110320975 }, { "content": "#include \"wled.h\"\n\n\n\n/*\n\n * Color conversion methods\n\n */\n\n\n\nvoid setRandomColor(byte* rgb)\n\n{\n\n lastRandomIndex = strip.get_random_wheel_index(lastRandomIndex);\n\n colorHStoRGB(lastRandomIndex*256,255,rgb);\n\n}\n\n\n\nvoid colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb\n\n{\n\n float h = ((float)hue)/65535.0;\n\n float s = ((float)sat)/255.0;\n\n byte i = floor(h*6);\n\n float f = h * 6-i;\n\n float p = 255 * (1-s);\n\n float q = 255 * (1-f*s);\n", "file_path": "wled00/colors.cpp", "rank": 30, "score": 49940.76222673272 }, { "content": "//so should be used combined with a saturation check (as done by auto-white)\n\n//values from http://www.vendian.org/mncharity/dir3/blackbody/UnstableURLs/bbr_color.html (10deg)\n\n//equation spreadsheet at https://bit.ly/30RkHaN\n\n//accuracy +-50K from 1900K up to 8000K\n\n//minimum returned: 1900K, maximum returned: 10091K (range of 8192)\n\nuint16_t approximateKelvinFromRGB(uint32_t rgb) {\n\n //if not either red or blue is 255, color is dimmed. Scale up\n\n uint8_t r = R(rgb), b = B(rgb);\n\n if (r == b) return 6550; //red == blue at about 6600K (also can't go further if both R and B are 0)\n\n\n\n if (r > b) {\n\n //scale blue up as if red was at 255\n\n uint16_t scale = 0xFFFF / r; //get scale factor (range 257-65535)\n\n b = ((uint16_t)b * scale) >> 8;\n\n //For all temps K<6600 R is bigger than B (for full bri colors R=255)\n\n //-> Use 9 linear approximations for blackbody radiation blue values from 2000-6600K (blue is always 0 below 2000K)\n\n if (b < 33) return 1900 + b *6;\n\n if (b < 72) return 2100 + (b-33) *10;\n\n if (b < 101) return 2492 + (b-72) *14;\n\n if (b < 132) return 2900 + (b-101) *16;\n", "file_path": "wled00/colors.cpp", "rank": 31, "score": 49939.452784987625 }, { "content": " rgb[0] = R(c);\n\n rgb[1] = G(c);\n\n rgb[2] = B(c);\n\n rgb[3] = W(c);\n\n}\n\n\n\n//contrary to the colorFromDecOrHexString() function, this uses the more standard RRGGBB / RRGGBBWW order\n\nbool colorFromHexString(byte* rgb, const char* in) {\n\n if (in == nullptr) return false;\n\n size_t inputSize = strnlen(in, 9);\n\n if (inputSize != 6 && inputSize != 8) return false;\n\n\n\n uint32_t c = strtoul(in, NULL, 16);\n\n\n\n if (inputSize == 6) {\n\n rgb[0] = (c >> 16);\n\n rgb[1] = (c >> 8);\n\n rgb[2] = c ;\n\n } else {\n\n rgb[0] = (c >> 24);\n", "file_path": "wled00/colors.cpp", "rank": 32, "score": 49939.24038628374 }, { "content": "uint32_t colorRGBtoRGBW(uint32_t c)\n\n{\n\n byte rgb[4];\n\n rgb[0] = R(c);\n\n rgb[1] = G(c);\n\n rgb[2] = B(c);\n\n rgb[3] = W(c);\n\n colorRGBtoRGBW(rgb);\n\n return RGBW32(rgb[0], rgb[1], rgb[2], rgb[3]);\n\n}\n\n\n\nvoid colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw). (RGBW_MODE_LEGACY)\n\n{\n\n float low = minf(rgb[0],minf(rgb[1],rgb[2]));\n\n float high = maxf(rgb[0],maxf(rgb[1],rgb[2]));\n\n if (high < 0.1f) return;\n\n float sat = 100.0f * ((high - low) / high); // maximum saturation is 100 (corrected from 255)\n\n rgb[3] = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3);\n\n}\n\n*/\n", "file_path": "wled00/colors.cpp", "rank": 33, "score": 49938.10177824084 }, { "content": " b = 0;\n\n } else {\n\n b = round(138.5177312231 * log((temp - 10)) - 305.0447927307);\n\n }\n\n } else {\n\n r = round(329.698727446 * pow((temp - 60), -0.1332047592));\n\n g = round(288.1221695283 * pow((temp - 60), -0.0755148492));\n\n b = 255;\n\n } \n\n //g += 12; //mod by Aircoookie, a bit less accurate but visibly less pinkish\n\n rgb[0] = (uint8_t) constrain(r, 0, 255);\n\n rgb[1] = (uint8_t) constrain(g, 0, 255);\n\n rgb[2] = (uint8_t) constrain(b, 0, 255);\n\n rgb[3] = 0;\n\n}\n\n\n\nvoid colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb, bins\n\n{\n\n //this is only an approximation using WS2812B with gamma correction enabled\n\n if (mired > 475) {\n", "file_path": "wled00/colors.cpp", "rank": 34, "score": 49937.80412943704 }, { "content": "\n\nbyte correctionRGB[4] = {0,0,0,0};\n\nuint16_t lastKelvin = 0;\n\n\n\n// adjust RGB values based on color temperature in K (range [2800-10200]) (https://en.wikipedia.org/wiki/Color_balance)\n\nuint32_t colorBalanceFromKelvin(uint16_t kelvin, uint32_t rgb)\n\n{\n\n //remember so that slow colorKtoRGB() doesn't have to run for every setPixelColor()\n\n if (lastKelvin != kelvin) colorKtoRGB(kelvin, correctionRGB); // convert Kelvin to RGB\n\n lastKelvin = kelvin;\n\n byte rgbw[4];\n\n rgbw[0] = ((uint16_t) correctionRGB[0] * R(rgb)) /255; // correct R\n\n rgbw[1] = ((uint16_t) correctionRGB[1] * G(rgb)) /255; // correct G\n\n rgbw[2] = ((uint16_t) correctionRGB[2] * B(rgb)) /255; // correct B\n\n rgbw[3] = W(rgb);\n\n return RGBW32(rgbw[0],rgbw[1],rgbw[2],rgbw[3]);\n\n}\n\n\n\n//approximates a Kelvin color temperature from an RGB color.\n\n//this does no check for the \"whiteness\" of the color,\n", "file_path": "wled00/colors.cpp", "rank": 35, "score": 49936.7790228922 }, { "content": " g = 1.0f;\n\n }\n\n } else if (b > r && b > g) {\n\n // blue is biggest\n\n if (b > 1.0f) {\n\n r = r / b;\n\n g = g / b;\n\n b = 1.0f;\n\n }\n\n }\n\n rgb[0] = 255.0*r;\n\n rgb[1] = 255.0*g;\n\n rgb[2] = 255.0*b;\n\n}\n\n\n\nvoid colorRGBtoXY(byte* rgb, float* xy) //rgb to coordinates (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)\n\n{\n\n float X = rgb[0] * 0.664511f + rgb[1] * 0.154324f + rgb[2] * 0.162028f;\n\n float Y = rgb[0] * 0.283881f + rgb[1] * 0.668433f + rgb[2] * 0.047685f;\n\n float Z = rgb[0] * 0.000088f + rgb[1] * 0.072310f + rgb[2] * 0.986039f;\n", "file_path": "wled00/colors.cpp", "rank": 36, "score": 49935.4026385612 }, { "content": " if (b < 159) return 3398 + (b-132) *19;\n\n if (b < 186) return 3906 + (b-159) *22;\n\n if (b < 210) return 4500 + (b-186) *25;\n\n if (b < 230) return 5100 + (b-210) *30;\n\n return 5700 + (b-230) *34;\n\n } else {\n\n //scale red up as if blue was at 255\n\n uint16_t scale = 0xFFFF / b; //get scale factor (range 257-65535)\n\n r = ((uint16_t)r * scale) >> 8;\n\n //For all temps K>6600 B is bigger than R (for full bri colors B=255)\n\n //-> Use 2 linear approximations for blackbody radiation red values from 6600-10091K (blue is always 0 below 2000K)\n\n if (r > 225) return 6600 + (254-r) *50;\n\n uint16_t k = 8080 + (225-r) *86;\n\n return (k > 10091) ? 10091 : k;\n\n }\n\n}\n", "file_path": "wled00/colors.cpp", "rank": 37, "score": 49934.865254080825 }, { "content": " rgb[0]=255;rgb[1]=199;rgb[2]=92;//500\n\n } else if (mired > 425) {\n\n rgb[0]=255;rgb[1]=213;rgb[2]=118;//450\n\n } else if (mired > 375) {\n\n rgb[0]=255;rgb[1]=216;rgb[2]=118;//400\n\n } else if (mired > 325) {\n\n rgb[0]=255;rgb[1]=234;rgb[2]=140;//350\n\n } else if (mired > 275) {\n\n rgb[0]=255;rgb[1]=243;rgb[2]=160;//300\n\n } else if (mired > 225) {\n\n rgb[0]=250;rgb[1]=255;rgb[2]=188;//250\n\n } else if (mired > 175) {\n\n rgb[0]=247;rgb[1]=255;rgb[2]=215;//200\n\n } else {\n\n rgb[0]=237;rgb[1]=255;rgb[2]=239;//150\n\n }\n\n}\n\n\n\n#ifndef WLED_DISABLE_HUESYNC\n\nvoid colorXYtoRGB(float x, float y, byte* rgb) //coordinates to rgb (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)\n", "file_path": "wled00/colors.cpp", "rank": 38, "score": 49934.67819617875 }, { "content": " xy[0] = X / (X + Y + Z);\n\n xy[1] = Y / (X + Y + Z);\n\n}\n\n#endif // WLED_DISABLE_HUESYNC\n\n\n\n//RRGGBB / WWRRGGBB order for hex\n\nvoid colorFromDecOrHexString(byte* rgb, char* in)\n\n{\n\n if (in[0] == 0) return;\n\n char first = in[0];\n\n uint32_t c = 0;\n\n \n\n if (first == '#' || first == 'h' || first == 'H') //is HEX encoded\n\n {\n\n c = strtoul(in +1, NULL, 16);\n\n } else\n\n {\n\n c = strtoul(in, NULL, 10);\n\n }\n\n\n", "file_path": "wled00/colors.cpp", "rank": 39, "score": 49934.34052532643 }, { "content": " float t = 255 * (1-(1-f)*s);\n\n switch (i%6) {\n\n case 0: rgb[0]=255,rgb[1]=t,rgb[2]=p;break;\n\n case 1: rgb[0]=q,rgb[1]=255,rgb[2]=p;break;\n\n case 2: rgb[0]=p,rgb[1]=255,rgb[2]=t;break;\n\n case 3: rgb[0]=p,rgb[1]=q,rgb[2]=255;break;\n\n case 4: rgb[0]=t,rgb[1]=p,rgb[2]=255;break;\n\n case 5: rgb[0]=255,rgb[1]=p,rgb[2]=q;\n\n }\n\n}\n\n\n\n//get RGB values from color temperature in K (https://tannerhelland.com/2012/09/18/convert-temperature-rgb-algorithm-code.html)\n\nvoid colorKtoRGB(uint16_t kelvin, byte* rgb) //white spectrum to rgb, calc\n\n{\n\n float r = 0, g = 0, b = 0;\n\n float temp = kelvin / 100;\n\n if (temp <= 66) {\n\n r = 255;\n\n g = round(99.4708025861 * log(temp) - 161.1195681661);\n\n if (temp <= 19) {\n", "file_path": "wled00/colors.cpp", "rank": 40, "score": 49934.1439488946 }, { "content": " rgb[1] = (c >> 16);\n\n rgb[2] = (c >> 8);\n\n rgb[3] = c ;\n\n }\n\n return true;\n\n}\n\n\n\nfloat minf (float v, float w)\n\n{\n\n if (w > v) return v;\n\n return w;\n\n}\n\n\n\nfloat maxf (float v, float w)\n\n{\n\n if (w > v) return w;\n\n return v;\n\n}\n\n\n\n/*\n", "file_path": "wled00/colors.cpp", "rank": 41, "score": 49926.058766620255 }, { "content": " g = g / b;\n\n b = 1.0f;\n\n }\n\n // Apply gamma correction\n\n r = r <= 0.0031308f ? 12.92f * r : (1.0f + 0.055f) * pow(r, (1.0f / 2.4f)) - 0.055f;\n\n g = g <= 0.0031308f ? 12.92f * g : (1.0f + 0.055f) * pow(g, (1.0f / 2.4f)) - 0.055f;\n\n b = b <= 0.0031308f ? 12.92f * b : (1.0f + 0.055f) * pow(b, (1.0f / 2.4f)) - 0.055f;\n\n\n\n if (r > b && r > g) {\n\n // red is biggest\n\n if (r > 1.0f) {\n\n g = g / r;\n\n b = b / r;\n\n r = 1.0f;\n\n }\n\n } else if (g > b && g > r) {\n\n // green is biggest\n\n if (g > 1.0f) {\n\n r = r / g;\n\n b = b / g;\n", "file_path": "wled00/colors.cpp", "rank": 42, "score": 49926.058766620255 }, { "content": "{\n\n float z = 1.0f - x - y;\n\n float X = (1.0f / y) * x;\n\n float Z = (1.0f / y) * z;\n\n float r = (int)255*(X * 1.656492f - 0.354851f - Z * 0.255038f);\n\n float g = (int)255*(-X * 0.707196f + 1.655397f + Z * 0.036152f);\n\n float b = (int)255*(X * 0.051713f - 0.121364f + Z * 1.011530f);\n\n if (r > b && r > g && r > 1.0f) {\n\n // red is too big\n\n g = g / r;\n\n b = b / r;\n\n r = 1.0f;\n\n } else if (g > b && g > r && g > 1.0f) {\n\n // green is too big\n\n r = r / g;\n\n b = b / g;\n\n g = 1.0f;\n\n } else if (b > r && b > g && b > 1.0f) {\n\n // blue is too big\n\n r = r / b;\n", "file_path": "wled00/colors.cpp", "rank": 43, "score": 49926.058766620255 }, { "content": "struct IsCharOrVoid<const T> : IsCharOrVoid<T> {};\n\ntemplate <typename TSource>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 44, "score": 46187.15568023836 }, { "content": "struct ColorOrderMap {\n\n void add(uint16_t start, uint16_t len, uint8_t colorOrder) {\n\n if (_count >= WLED_MAX_COLOR_ORDER_MAPPINGS) {\n\n return;\n\n }\n\n if (len == 0) {\n\n return;\n\n }\n\n if (colorOrder > COL_ORDER_MAX) {\n\n return;\n\n }\n\n _mappings[_count].start = start;\n\n _mappings[_count].len = len;\n\n _mappings[_count].colorOrder = colorOrder;\n\n _count++;\n\n }\n\n\n\n uint8_t count() const {\n\n return _count;\n\n }\n", "file_path": "wled00/bus_manager.h", "rank": 45, "score": 43412.72294314433 }, { "content": "class LedClockStateKeys {\n\npublic:\n\n static const char *root, *command, *mode, *beep;\n\n\n", "file_path": "wled00/const_ledclock.h", "rank": 46, "score": 41689.018514976386 }, { "content": "enum class AdaState {\n\n Header_A,\n\n Header_d,\n\n Header_a,\n\n Header_CountHi,\n\n Header_CountLo,\n\n Header_CountCheck,\n\n Data_Red,\n\n Data_Green,\n\n Data_Blue,\n\n TPM2_Header_Type,\n\n TPM2_Header_CountHi,\n\n TPM2_Header_CountLo,\n\n};\n\n\n\nuint16_t currentBaud = 1152; //default baudrate 115200 (divided by 100)\n\n\n\nvoid updateBaudRate(uint32_t rate){\n\n uint16_t rate100 = rate/100;\n\n if (rate100 == currentBaud || rate100 < 96) return;\n", "file_path": "wled00/wled_serial.cpp", "rank": 47, "score": 41689.018514976386 }, { "content": "// Defines an LED Strip and its color ordering.\n\nstruct ColorOrderMapEntry {\n\n uint16_t start;\n\n uint16_t len;\n\n uint8_t colorOrder;\n\n};\n\n\n", "file_path": "wled00/bus_manager.h", "rank": 48, "score": 41609.136542645254 }, { "content": "\n\n operator bool() { return ready(); }\n\n};\n\n\n\ntypedef BlynkPeriodic<millis_time_t,blynk_count_millis> BlynkEveryNMillis;\n\ntypedef BlynkPeriodic<uint16_t,blynk_count_seconds16> BlynkEveryNSeconds;\n\ntypedef BlynkPeriodic<uint16_t,blynk_count_minutes16> BlynkEveryNMinutes;\n\ntypedef BlynkPeriodic<uint8_t,blynk_count_hours8> BlynkEveryNHours;\n\n\n\n#define BLYNK_EVERY_N_MILLIS_I(NAME,N) static BlynkEveryNMillis NAME(N); if(NAME)\n\n#define BLYNK_EVERY_N_SECONDS_I(NAME,N) static BlynkEveryNSeconds NAME(N); if(NAME)\n\n#define BLYNK_EVERY_N_MINUTES_I(NAME,N) static BlynkEveryNMinutes NAME(N); if(NAME)\n\n#define BLYNK_EVERY_N_HOURS_I(NAME,N) static BlynkEveryNHours NAME(N); if(NAME)\n\n\n\n#define BLYNK_EVERY_N_MILLIS(N) BLYNK_EVERY_N_MILLIS_I(BLYNK_CONCAT2(PER, __COUNTER__),N)\n\n#define BLYNK_EVERY_N_SECONDS(N) BLYNK_EVERY_N_SECONDS_I(BLYNK_CONCAT2(PER, __COUNTER__),N)\n\n#define BLYNK_EVERY_N_MINUTES(N) BLYNK_EVERY_N_MINUTES_I(BLYNK_CONCAT2(PER, __COUNTER__),N)\n\n#define BLYNK_EVERY_N_HOURS(N) BLYNK_EVERY_N_HOURS_I(BLYNK_CONCAT2(PER, __COUNTER__),N)\n\n\n\n#endif\n", "file_path": "wled00/src/dependencies/blynk/Blynk/BlynkEveryN.h", "rank": 49, "score": 40029.35382010546 }, { "content": "const _C = d.querySelector('.container'), N = 4;\n", "file_path": "wled00/data/index.js", "rank": 50, "score": 40022.69787421626 }, { "content": "#define IR9_C 0xFFC23D\n", "file_path": "wled00/ir_codes.h", "rank": 51, "score": 40022.69787421626 }, { "content": "\n\n#ifndef BLYNKEVERYN_H\n\n#define BLYNKEVERYN_H\n\n\n\n#include \"BlynkDebug.h\"\n\n\n\nmillis_time_t blynk_count_millis() {\n\n const millis_time_t ms = BlynkMillis();\n\n return ms;\n\n}\n\n\n\nuint16_t blynk_count_seconds16() {\n\n const millis_time_t ms = BlynkMillis();\n\n return (ms / 1000);\n\n}\n\n\n\nuint16_t blynk_count_minutes16()\n\n{\n\n const millis_time_t ms = BlynkMillis();\n\n return (ms / (60000L)) & 0xFFFF;\n\n}\n\n\n\nuint8_t blynk_count_hours8()\n\n{\n\n const millis_time_t ms = BlynkMillis();\n\n return (ms / (3600000L)) & 0xFF;\n\n}\n\n\n\ntemplate<typename T, T (*timeGetter)()>\n", "file_path": "wled00/src/dependencies/blynk/Blynk/BlynkEveryN.h", "rank": 52, "score": 40018.884426920864 }, { "content": "var pN = \"\", pI = 0, pNum = 0;\n", "file_path": "wled00/data/index.js", "rank": 53, "score": 40015.25178191435 }, { "content": "struct void_ {\n\n typedef void type;\n\n};\n\ntemplate <typename TSource>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 54, "score": 40005.033017858535 }, { "content": "#define COLOR_CYAN 0x00FFDC\n", "file_path": "wled00/ir_codes.h", "rank": 55, "score": 39939.09611806852 }, { "content": "#define COLOR_REDDISH 0xFF7800\n", "file_path": "wled00/ir_codes.h", "rank": 56, "score": 39939.09611806852 }, { "content": "var colors = [[0,0,0],[0,0,0],[0,0,0]];\n", "file_path": "wled00/data/index.js", "rank": 57, "score": 39939.09611806852 }, { "content": "#define COLOR_TURQUOISE 0x00FFA0\n", "file_path": "wled00/ir_codes.h", "rank": 58, "score": 39939.09611806852 }, { "content": "#define COLOR_COLDWHITE 0xFFFFE9D9\n", "file_path": "wled00/ir_codes.h", "rank": 59, "score": 39939.09611806852 }, { "content": "#define COLOR_GREENISH 0x00FF78\n", "file_path": "wled00/ir_codes.h", "rank": 60, "score": 39939.09611806852 }, { "content": "#define COLOR_PURPLE 0xAA00FF\n", "file_path": "wled00/ir_codes.h", "rank": 61, "score": 39939.09611806852 }, { "content": "#define COLOR_NEUTRALWHITE 0xFFFFD4B4\n", "file_path": "wled00/ir_codes.h", "rank": 62, "score": 39939.09611806852 }, { "content": "#define COLOR_ORANGE 0xFFA000\n", "file_path": "wled00/ir_codes.h", "rank": 63, "score": 39939.09611806852 }, { "content": "#define COLOR_BLUE 0x00A0FF\n", "file_path": "wled00/ir_codes.h", "rank": 64, "score": 39939.09611806852 }, { "content": "#define COLOR_PINK 0xFF00A0\n", "file_path": "wled00/ir_codes.h", "rank": 65, "score": 39939.09611806852 }, { "content": "#define COLOR_YELLOW 0xFFFF00\n", "file_path": "wled00/ir_codes.h", "rank": 66, "score": 39939.09611806852 }, { "content": "#define COLOR_WHITE 0xFFFFFFFF\n", "file_path": "wled00/ir_codes.h", "rank": 67, "score": 39939.09611806852 }, { "content": "#define COLOR_AQUA 0x00C8FF\n", "file_path": "wled00/ir_codes.h", "rank": 68, "score": 39939.09611806852 }, { "content": "#define COLOR_GREEN 0x00FF00\n", "file_path": "wled00/ir_codes.h", "rank": 69, "score": 39939.09611806852 }, { "content": "#define COLOR_COLDWHITE2 0xFFFFFFFF\n\n\n", "file_path": "wled00/ir_codes.h", "rank": 70, "score": 39939.09611806852 }, { "content": "#define COLOR_DEEPBLUE 0x0000FF\n", "file_path": "wled00/ir_codes.h", "rank": 71, "score": 39939.09611806852 }, { "content": "#define COLOR_RED 0xFF0000\n", "file_path": "wled00/ir_codes.h", "rank": 72, "score": 39939.09611806852 }, { "content": "#define COLOR_YELLOWISH 0xFFC800\n", "file_path": "wled00/ir_codes.h", "rank": 73, "score": 39939.09611806852 }, { "content": "#define COLOR_MAGENTA 0xFF00DC\n", "file_path": "wled00/ir_codes.h", "rank": 74, "score": 39939.09611806852 }, { "content": "#define COLOR_WARMWHITE2 0xFFFFAA69\n", "file_path": "wled00/ir_codes.h", "rank": 75, "score": 39939.09611806852 }, { "content": "#define COLOR_WARMWHITE 0xFFFFBF8E\n", "file_path": "wled00/ir_codes.h", "rank": 76, "score": 39939.09611806852 }, { "content": "class DummyWriter {\n\n public:\n\n size_t write(uint8_t) {\n\n return 1;\n\n }\n\n size_t write(const uint8_t*, size_t n) {\n\n return n;\n\n }\n\n};\n\ntemplate <template <typename> class TSerializer, typename TSource>\n\nsize_t measure(const TSource &source) {\n\n DummyWriter dp;\n\n TSerializer<DummyWriter> serializer(dp);\n\n return source.accept(serializer);\n\n}\n\ntemplate <typename TDestination, typename Enable = void>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 77, "score": 38484.68304822725 }, { "content": "struct IsCharOrVoid {\n\n static const bool value =\n\n is_same<T, void>::value || is_same<T, char>::value ||\n\n is_same<T, unsigned char>::value || is_same<T, signed char>::value;\n\n};\n\ntemplate <typename T>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 78, "score": 38466.118479133846 }, { "content": "class LedBasedRowDisplay : public LedBasedDisplay {\n\n\n\n public:\n\n LedBasedRowDisplay(uint8_t displayCount, ...);\n\n\n\n virtual ~LedBasedRowDisplay() override;\n\n\n\n virtual uint8_t rowCount() override;\n\n virtual uint8_t columnCount() override;\n\n\n\n virtual uint8_t indexOfCoords(uint8_t row, uint8_t column) override;\n\n virtual Coords coordsOfIndex(uint16_t index) override;\n\n\n\n virtual CRGB* getLedColor(uint8_t row, uint8_t column, bool state) override;\n\n virtual void setLedColor(uint8_t row, uint8_t column, bool state, CRGB color) override;\n\n\n\n virtual void update() override;\n\n\n\n virtual void setMode(LedBasedDisplayMode mode) override;\n\n\n\n private:\n\n uint8_t _displayCount;\n\n LedBasedDisplay** _displays;\n\n};\n\n\n\n#endif", "file_path": "wled00/7segmdisp.h", "rank": 79, "score": 37059.09299854639 }, { "content": "class StaticStringWriter {\n\n public:\n\n StaticStringWriter(char *buf, size_t size) : end(buf + size), p(buf) {}\n\n size_t write(uint8_t c) {\n\n if (p >= end)\n\n return 0;\n\n *p++ = static_cast<char>(c);\n\n return 1;\n\n }\n\n size_t write(const uint8_t *s, size_t n) {\n\n char *begin = p;\n\n while (p < end && n > 0) {\n\n *p++ = static_cast<char>(*s++);\n\n n--;\n\n }\n\n return size_t(p - begin);\n\n }\n\n private:\n\n char *end;\n\n char *p;\n\n};\n\n} // namespace ARDUINOJSON_NAMESPACE\n\n#if ARDUINOJSON_ENABLE_STD_STRING\n\nnamespace ARDUINOJSON_NAMESPACE {\n\ntemplate <class T>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 80, "score": 37057.57225375235 }, { "content": "class BlynkPeriodic {\n\npublic:\n\n T mPrev;\n\n T mPeriod;\n\n\n\n BlynkPeriodic() { reset(); mPeriod = 1; };\n\n BlynkPeriodic(T period) { reset(); setPeriod(period); };\n\n void setPeriod( T period) { mPeriod = period; };\n\n T getTime() { return (T)(timeGetter()); };\n\n T getPeriod() { return mPeriod; };\n\n T getElapsed() { return getTime() - mPrev; }\n\n T getRemaining() { return mPeriod - getElapsed(); }\n\n T getLastTriggerTime() { return mPrev; }\n\n bool ready() {\n\n bool isReady = (getElapsed() >= mPeriod);\n\n if( isReady ) { reset(); }\n\n return isReady;\n\n }\n\n void reset() { mPrev = getTime(); };\n\n void trigger() { mPrev = getTime() - mPeriod; };\n", "file_path": "wled00/src/dependencies/blynk/Blynk/BlynkEveryN.h", "rank": 81, "score": 37050.67781339368 }, { "content": "const byte flOceanColors_gp[] PROGMEM = {\n\n 0, 9, 9,211,\n\n 17, 6, 6,193,\n\n 34, 39, 39,236,\n\n 51, 0, 0,173,\n\n 68, 0, 0,194,\n\n 85, 0, 0,205,\n\n 102, 46,139, 87,\n\n 119, 0,128,128,\n\n 136, 95,158,160,\n\n 153, 0, 0,255,\n\n 170, 0,139,139,\n\n 187, 100,149,237,\n\n 204, 127,255,212,\n\n 221, 46,139, 87,\n\n 238, 0,255,255,\n", "file_path": "wled00/palettes_ledclock.h", "rank": 82, "score": 36980.1642257198 }, { "content": "const byte flLavaColors_gp[] PROGMEM = {\n\n 0, 219, 0, 0,\n\n 18, 255, 0, 0,\n\n 34, 255,162, 0,\n\n 51, 255,255,255,\n\n 66, 255,162, 0,\n\n 82, 255, 0, 0,\n\n 124, 139, 0, 0,\n\n 164, 255, 0, 0,\n\n 182, 255,165, 0,\n\n 200, 255,255,255,\n\n 219, 255,165, 0,\n\n 237, 255, 0, 0,\n", "file_path": "wled00/palettes_ledclock.h", "rank": 83, "score": 36980.1642257198 }, { "content": "const byte flRainbowColors_gp[] PROGMEM = {\n\n 0, 255, 0, 0,\n\n 17, 235, 47, 0,\n\n 34, 255,128, 0,\n\n 51, 240,180, 0,\n\n 69, 214,214, 0,\n\n 85, 92,230, 0,\n\n 102, 0,255, 0,\n\n 119, 0,213, 42,\n\n 137, 0,219,110,\n\n 153, 0,105,209,\n\n 170, 0, 0,255,\n\n 187, 47, 0,235,\n\n 204, 107, 0,214,\n\n 221, 171, 0,173,\n\n 238, 204, 0,102,\n", "file_path": "wled00/palettes_ledclock.h", "rank": 84, "score": 36980.1642257198 }, { "content": "const byte flCloudColors_gp[] PROGMEM = {\n\n 0, 0, 0,255,\n\n 17, 52, 52,234,\n\n 34, 88,182,254,\n\n 99, 1, 52,254,\n\n 123, 0, 0,255,\n\n 152, 0,129,209,\n\n 170, 135,206,235,\n\n 187, 135,206,235,\n\n 204, 173,216,230,\n\n 221, 255,255,255,\n\n 238, 173,216,230,\n", "file_path": "wled00/palettes_ledclock.h", "rank": 85, "score": 36980.1642257198 }, { "content": "const byte flPartyColors_gp[] PROGMEM = {\n\n 0, 120, 0,240,\n\n 18, 189, 0,176,\n\n 34, 199, 0, 83,\n\n 51, 229, 0, 27,\n\n 68, 232, 23, 0,\n\n 85, 219, 84, 0,\n\n 102, 230,161, 0,\n\n 118, 219,219, 0,\n\n 136, 219,110, 0,\n\n 153, 221, 34, 0,\n\n 170, 242, 0, 14,\n\n 187, 194, 0, 62,\n\n 204, 179, 0,140,\n\n 221, 110, 0,189,\n\n 238, 47, 0,208,\n", "file_path": "wled00/palettes_ledclock.h", "rank": 86, "score": 36980.1642257198 }, { "content": "const byte flForestColors_gp[] PROGMEM = {\n\n 0, 0,153, 0,\n\n 17, 0,138, 0,\n\n 34, 119,180, 14,\n\n 51, 0,100, 0,\n\n 68, 0,128, 0,\n\n 85, 34,139, 34,\n\n 103, 134,187, 27,\n\n 119, 0,128, 0,\n\n 136, 65,200,124,\n\n 153, 102,205,170,\n\n 170, 50,205, 50,\n\n 187, 154,205, 50,\n\n 204, 144,238,144,\n\n 221, 124,252, 0,\n\n 238, 102,205,170,\n", "file_path": "wled00/palettes_ledclock.h", "rank": 87, "score": 36980.1642257198 }, { "content": "const byte flRainbowStripeColors_gp[] PROGMEM = {\n\n 0, 255, 0, 0,\n\n 33, 214, 41, 0,\n\n 34, 171, 85, 0,\n\n 67, 171,128, 0,\n\n 68, 171,171, 0,\n\n 101, 87,212, 0,\n\n 102, 0,255, 0,\n\n 135, 0,214, 41,\n\n 136, 0,171, 85,\n\n 169, 0, 86,169,\n\n 170, 0, 0,255,\n\n 203, 46, 0,210,\n\n 204, 85, 0,171,\n\n 237, 129, 0,127,\n\n 238, 171, 0, 85,\n", "file_path": "wled00/palettes_ledclock.h", "rank": 88, "score": 35664.787564564 }, { "content": "class StaticJsonDocument : public JsonDocument {\n\n static const size_t _capacity =\n\n AddPadding<Max<1, desiredCapacity>::value>::value;\n\n public:\n\n StaticJsonDocument() : JsonDocument(_buffer, _capacity) {}\n\n StaticJsonDocument(const StaticJsonDocument& src)\n\n : JsonDocument(_buffer, _capacity) {\n\n set(src);\n\n }\n\n template <typename T>\n\n StaticJsonDocument(const T& src,\n\n typename enable_if<IsVisitable<T>::value>::type* = 0)\n\n : JsonDocument(_buffer, _capacity) {\n\n set(src);\n\n }\n\n StaticJsonDocument(VariantRef src) : JsonDocument(_buffer, _capacity) {\n\n set(src);\n\n }\n\n StaticJsonDocument operator=(const StaticJsonDocument& src) {\n\n set(src);\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 89, "score": 33351.273544031326 }, { "content": "def shift_color(col, shift=30, sat=1.0, val=1.0):\n\n r = (col & (255 << 16)) >> 16\n\n g = (col & (255 << 8)) >> 8\n\n b = col & 255\n\n hsv = colorsys.rgb_to_hsv(r, g, b)\n\n h = (((hsv[0] * 360) + shift) % 360) / 360\n\n rgb = colorsys.hsv_to_rgb(h, hsv[1] * sat, hsv[2] * val)\n", "file_path": "usermods/JSON_IR_remote/ir_json_maker.py", "rank": 90, "score": 33281.607449886265 }, { "content": "struct Reader<TSource, typename void_<typename TSource::const_iterator>::type>\n\n : IteratorReader<typename TSource::const_iterator> {\n\n explicit Reader(const TSource& source)\n\n : IteratorReader<typename TSource::const_iterator>(source.begin(),\n\n source.end()) {}\n\n};\n\ntemplate <typename T>\n", "file_path": "wled00/src/dependencies/json/ArduinoJson-v6.h", "rank": 91, "score": 28573.592056750294 }, { "content": "# Rotary Encoder (Brightness and Color)\n\n\n\nV2 usermod that allows changing brightness and color using a rotary encoder, \n\nchange between modes by pressing a button (many encoders have one included)\n\n\n\nbut it will wait for AUTOSAVE_SETTLE_MS milliseconds, a \"settle\" \n\nperiod in case there are other changes (any change will \n\nextend the \"settle\" window).\n\n\n\nIt will additionally load preset AUTOSAVE_PRESET_NUM at startup.\n\nduring the first `loop()`. Reasoning below.\n\n\n\nAutoSaveUsermod is standalone, but if FourLineDisplayUsermod is installed, it will notify the user of the saved changes.\n\n\n\nNote: I don't love that WLED doesn't respect the brightness of the preset being auto loaded, so the AutoSaveUsermod will set the AUTOSAVE_PRESET_NUM preset in the first loop, so brightness IS honored. This means WLED will effectively ignore Default brightness and Apply N preset at boot when the AutoSaveUsermod is installed.\n\n\n\n## Installation\n\n\n\ndefine `USERMOD_ROTARY_ENCODER_BRIGHTNESS_COLOR` e.g.\n\n\n\n`#define USERMOD_ROTARY_ENCODER_BRIGHTNESS_COLOR` in my_config.h\n\n\n\nor add `-D USERMOD_ROTARY_ENCODER_BRIGHTNESS_COLOR` to `build_flags` in platformio_override.ini\n\n\n\n### Define Your Options\n\n\n\nOpen Usermod Settings in WLED to change settings:\n\n\n\n`fadeAmount` - how many points to fade the Neopixel with each step of the rotary encoder (default 5)\n\n`pin[3]` - pins to connect to the rotary encoder:\n\n- `pin[0]` is pin A on your rotary encoder\n\n- `pin[1]` is pin B on your rotary encoder\n\n- `pin[2]` is the button on your rotary encoder (optional, set to -1 to disable the button and the rotary encoder will control brightness only)\n\n\n\n### PlatformIO requirements\n\n\n\nNo special requirements.\n\n\n\n## Change Log\n\n\n\n2021-07\n\n* Upgraded to work with the latest WLED code, and make settings configurable in Usermod Settings\n", "file_path": "usermods/usermod_rotary_brightness_color/README.md", "rank": 92, "score": 28535.31410782884 }, { "content": "enum struct PinOwner : uint8_t {\n\n None = 0, // default == legacy == unspecified owner\n\n // High bit is set for all built-in pin owners\n\n Ethernet = 0x81,\n\n BusDigital = 0x82,\n\n BusDigital2 = 0x83,\n\n BusPwm = 0x84, // 'BusP' == PWM output using BusPwm\n\n Button = 0x85, // 'Butn' == button from configuration\n\n IR = 0x86, // 'IR' == IR receiver pin from configuration\n\n Relay = 0x87, // 'Rly' == Relay pin from configuration\n\n SPI_RAM = 0x88, // 'SpiR' == SPI RAM\n\n DebugOut = 0x89, // 'Dbg' == debug output always IO1\n\n DMX = 0x8A, // 'DMX' == hard-coded to IO2\n\n HW_I2C = 0x8B, // 'I2C' == hardware I2C pins (4&5 on ESP8266, 21&22 on ESP32)\n\n // Use UserMod IDs from const.h here\n\n UM_Unspecified = USERMOD_ID_UNSPECIFIED, // 0x01\n\n UM_Example = USERMOD_ID_EXAMPLE, // 0x02 // Usermod \"usermod_v2_example.h\"\n\n UM_Temperature = USERMOD_ID_TEMPERATURE, // 0x03 // Usermod \"usermod_temperature.h\"\n\n // #define USERMOD_ID_FIXNETSERVICES // 0x04 // Usermod \"usermod_Fix_unreachable_netservices.h\" -- Does not allocate pins\n\n UM_PIR = USERMOD_ID_PIRSWITCH, // 0x05 // Usermod \"usermod_PIR_sensor_switch.h\"\n", "file_path": "wled00/pin_manager.h", "rank": 93, "score": 23829.08525560013 }, { "content": "enum class EspalexaDeviceProperty : uint8_t { none = 0, on = 1, off = 2, bri = 3, hs = 4, ct = 5, xy = 6 };\n\n\n", "file_path": "wled00/src/dependencies/espalexa/EspalexaDevice.h", "rank": 94, "score": 16217.579445988678 }, { "content": " void map(uint8_t ledCount, ...);\n\n void setState(bool state);\n\n\n\n private:\n\n struct _Mapping {\n\n uint8_t row;\n\n uint8_t column;\n\n uint8_t index;\n\n CRGB offColor;\n\n CRGB onColor;\n\n };\n\n\n\n LedBasedDisplayOutput _output;\n\n uint8_t _ledCount;\n\n struct _Mapping* _mappings;\n\n bool _state;\n\n LedBasedDisplayMode _mode;\n\n};\n\n\n", "file_path": "wled00/7segmdisp.h", "rank": 99, "score": 36.35274344368029 } ]
C++
lib/src/TypeRegistration.cpp
PrincetonUniversity/mcpib
72a6b7a04288b9707f20699dbbdcdb964a8ca379
#include "mcpib/TypeRegistration.hpp" #include "mcpib/TypeRegistry.hpp" #include "mcpib/WrapperError.hpp" namespace mcpib { void TypeRegistration::registerFromPython(std::unique_ptr<FromPythonFactory> factory) { for (auto const & existing : _from_python) { if (factory->name == existing->name) { return; } } _from_python.push_back(std::move(factory)); } std::unique_ptr<FromPythonConverter> TypeRegistration::lookupFromPython( PyPtr const & p, bool is_lvalue, bool is_pointer ) const { std::unique_ptr<FromPythonConverter> converter; for (auto iter = _from_python.rbegin(); iter != _from_python.rend(); ++iter) { if ((!is_lvalue || (**iter).is_lvalue) && (is_pointer || !(**iter).is_pointer)) { converter = (**iter).apply(p); if (converter) break; } } return converter; } void TypeRegistration::setValueToPython(std::unique_ptr<ToPythonConverter> converter) { _value_to_python = std::move(converter); } void TypeRegistration::setRefToPython(std::unique_ptr<ToPythonConverter> converter) { _ref_to_python = std::move(converter); } void TypeRegistration::setConstRefToPython(std::unique_ptr<ToPythonConverter> converter) { _const_ref_to_python = std::move(converter); } void TypeRegistration::setPointerToPython(std::unique_ptr<ToPythonConverter> converter) { _pointer_to_python = std::move(converter); } void TypeRegistration::setConstPointerToPython(std::unique_ptr<ToPythonConverter> converter) { _const_pointer_to_python = std::move(converter); } void TypeRegistration::_copyInto(TypeRegistration & other, TypeRegistry & registry) const { for (auto const & other_conv : _from_python) { other.registerFromPython(other_conv->clone(registry)); } if (_value_to_python) other.setValueToPython(_value_to_python->clone(registry)); if (_ref_to_python) other.setRefToPython(_ref_to_python->clone(registry)); if (_const_ref_to_python) other.setConstRefToPython(_const_ref_to_python->clone(registry)); if (_pointer_to_python) other.setPointerToPython(_pointer_to_python->clone(registry)); if (_const_pointer_to_python) other.setConstPointerToPython(_const_pointer_to_python->clone(registry)); for (auto const & pair : _derived) { other._derived[pair.first] = registry.require(pair.first); } } ToPythonConverter const & TypeRegistration::getValueToPython() const { if (!_value_to_python) { throw raiseToPythonError("No move/copy to-Python converter found"); } return *_value_to_python; } ToPythonConverter const & TypeRegistration::getRefToPython() const { if (!_ref_to_python) { throw raiseToPythonError("No reference to-Python converter found"); } return *_ref_to_python; } ToPythonConverter const & TypeRegistration::getConstRefToPython() const { if (!_const_ref_to_python) { throw raiseToPythonError("No const reference to-Python converter found"); } return *_const_ref_to_python; } ToPythonConverter const & TypeRegistration::getPointerToPython() const { if (_pointer_to_python) { return *_pointer_to_python; } else if (_ref_to_python) { return *_ref_to_python; } throw raiseToPythonError("No pointer to-Python converter found"); } ToPythonConverter const & TypeRegistration::getConstPointerToPython() const { if (_const_pointer_to_python) { return *_const_pointer_to_python; } else if (_const_ref_to_python) { return *_const_ref_to_python; } throw raiseToPythonError("No const pointer to-Python converter found"); } }
#include "mcpib/TypeRegistration.hpp" #include "mcpib/TypeRegistry.hpp" #include "mcpib/WrapperError.hpp" namespace mcpib { void TypeRegistration::registerFromPython(std::unique_ptr<FromPythonFactory> factory) { for (auto const & existing : _from_python) { if (factory->name == existing->name) { return; } } _from_python.push_back(std::move(factory)); } std::unique_ptr<FromPythonConverter> TypeRegistration::lookupFromPython( PyPtr const & p, bool is_lvalue, bool is_pointer ) const { std::unique_ptr<FromPythonConverter> converter; for (auto iter = _from_python.rbegin(); iter != _from_python.rend(); ++iter) { if ((!is_lvalue || (**iter).is_lvalue) && (is_pointer || !(**iter).is_pointer)) { converter = (**iter).apply(p); if (converter) break; } } return converter; } void TypeRegistration::setValueToPython(std::unique_ptr<ToPythonConverter> converter) { _value_to_python = std::move(converter); } void TypeRegistration::setRefToPython(std::unique_ptr<ToPythonConverter> converter) { _ref_to_python = std::move(converter); } void TypeRegistration::setConstRefToPython(std::unique_ptr<ToPythonConverter> converter) { _const_ref_to_python = std::move(converter); } void TypeRegistration::setPointerToPython(std::unique_ptr<ToPythonConverter> converter) { _pointer_to_python = std::move(converter); } void TypeRegistration::setConstPointerToPython(std::unique_ptr<ToPythonConverter> converter) { _const_pointer_to_python = std::move(converter); } void TypeRegistration::_copyInto(TypeRegistration & other, TypeRegistry & registry) const { for (auto const & other_conv : _from_python) { other.registerFromPython(other_conv->clone(registry)); } if (_value_to_python) other.setValueToPython(_value_to_python->clone(registry)); if (_ref_to_python) other.setRefToPython(_ref_to_python->clone(registry)); if (_const_ref_to_python) other.setConstRefToPython(_const_ref_to_python->clone(registry)); if (_pointer_to_python) other.setPointerToPython(_pointer_to_python->clone(registry)); if (_const_pointer_to_python) other.setConstPointerToPython(_const_pointer_to_python->clone(registry)); for (auto const & pair : _derived) { other._derived[pair.first] = registry.require(pair.first); } } ToPythonConverter const & TypeRegistration::getValueToPython() const { if (!_value_to_python) { throw raiseToPythonError("No move/copy to-Python converter found"); } return *_value_to_python; } ToPythonConverter const & TypeRegistration::getRefToPython() const { if (!_ref_to_python) { throw raiseToPythonError("No reference to-Python converter found"); } return *
}
_ref_to_python; } ToPythonConverter const & TypeRegistration::getConstRefToPython() const { if (!_const_ref_to_python) { throw raiseToPythonError("No const reference to-Python converter found"); } return *_const_ref_to_python; } ToPythonConverter const & TypeRegistration::getPointerToPython() const { if (_pointer_to_python) { return *_pointer_to_python; } else if (_ref_to_python) { return *_ref_to_python; } throw raiseToPythonError("No pointer to-Python converter found"); } ToPythonConverter const & TypeRegistration::getConstPointerToPython() const { if (_const_pointer_to_python) { return *_const_pointer_to_python; } else if (_const_ref_to_python) { return *_const_ref_to_python; } throw raiseToPythonError("No const pointer to-Python converter found"); }
random
[ { "content": "class ReturnConverter<void> {\n\npublic:\n\n\n\n explicit ReturnConverter(TypeRegistry &) {}\n\n\n\n template <typename ArgumentBuilder, typename ...Args>\n\n PyPtr apply(ArgumentBuilder builder, std::function<void(Args...)> const & function) const {\n\n callFunction(builder, function);\n\n return PyPtr::borrow(Py_None);\n\n }\n\n\n\n};\n\n\n\n\n", "file_path": "include/mcpib/CallableOverload.hpp", "rank": 0, "score": 167977.00991093364 }, { "content": "class FromPythonTraits<U const &> {\n\npublic:\n\n static bool const is_lvalue = false;\n\n static bool const is_pointer = false;\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n static U const & adapt(void * converted) { return *reinterpret_cast<U const *>(converted); }\n\n};\n\n\n\n} // namespace mcpib\n\n\n\n#endif // !MCPIB_FromPythonConverter_hpp_INCLUDED\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 1, "score": 130534.62266084529 }, { "content": "class FromPythonTraits<U const> {\n\npublic:\n\n static bool const is_lvalue = false;\n\n static bool const is_pointer = false;\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n static U const adapt(void * converted) { return *reinterpret_cast<U const *>(converted); }\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 2, "score": 130534.62266084529 }, { "content": "class FromPythonTraits<U const *> {\n\npublic:\n\n static bool const is_lvalue = false;\n\n static bool const is_pointer = true;\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n static U const * adapt(void * converted) { return reinterpret_cast<U const *>(converted); }\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 3, "score": 130534.62266084529 }, { "content": "class ReturnConverter {\n\npublic:\n\n\n\n explicit ReturnConverter(TypeRegistry & registry) :\n\n _registration(registry.require(ToPythonTraits<Result>::getTypeInfo()))\n\n {}\n\n\n\n template <typename ArgumentBuilder, typename ...Args>\n\n PyPtr apply(ArgumentBuilder builder, std::function<Result(Args...)> const & function) const {\n\n return _registration->toPython(callFunction(builder, function));\n\n }\n\n\n\nprivate:\n\n std::shared_ptr<TypeRegistration> _registration;\n\n};\n\n\n\n\n\ntemplate <>\n", "file_path": "include/mcpib/CallableOverload.hpp", "rank": 4, "score": 116226.87007681179 }, { "content": "class FromPythonFactory {\n\npublic:\n\n\n\n /*\n\n * Return a converter that maps the given Python object to a C++ object, if possible.\n\n *\n\n * If this factory cannot produce a factory that is likely to work for the given object,\n\n * it should return nullptr.\n\n *\n\n * The returned converter is not guaranteed to work, but it should be a likely enough\n\n * match that the quality of the match can be used to resolve which of several overloads\n\n * of a function should be called.\n\n */\n\n virtual std::unique_ptr<FromPythonConverter> apply(PyPtr const &) const = 0;\n\n\n\n /*\n\n * A unique name for this converter.\n\n *\n\n * This will be used to compare converters when they're registered to prevent duplicates (even\n\n * when the same templated converter is instantiated in different modules).\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 5, "score": 116194.81594719266 }, { "content": "class TypeRegistry;\n\n\n\n/*\n\n * Base class for to-Python conversions.\n\n */\n", "file_path": "include/mcpib/ToPythonConverter.hpp", "rank": 6, "score": 116089.70218676409 }, { "content": "class TypeRegistry;\n\n\n\n/*\n\n * Base class for all from-Python converters.\n\n *\n\n * Derived classes of FromPythonConverter are created via an instance of FromPythonFactory (see\n\n * below). The returned pointer should be null if no conversion is possible. If a conversion is\n\n * possible, the factory should pass whatever information is necessary to complete the conversion\n\n * (usually at least the PyPtr itself) to the derived converter's constructor.\n\n *\n\n * Derived class constructors must pass an integer penalty value to the base class constructor,\n\n * which indicates how appropriate the converter is for the Python object we're attempting to\n\n * convert. A penalty of zero indicates a perfect match, with higher numbers indicating implicit\n\n * conversions (including conversions from a Python object that holds a derived classes when looking\n\n * for a base class reference or pointer; each level of inheritance should correspond to one unit of\n\n * penalty). When converting types for overloaded functions, the maximum penalty value of all\n\n * arguments is used to compare different overloads to detemrine which one will be called.\n\n *\n\n * All derived classes must implement convert() to actually carry out the conversion, and provide a\n\n * non-trivial destructor if needed to clean up the pointer returned by convert(). A postcall()\n\n * method may also be provided, and will be called after the function that used the converter is\n\n * called.\n\n */\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 7, "score": 116089.70218676409 }, { "content": "class ToPythonTraits<U const> {\n\npublic:\n\n\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n\n\n static PyPtr convert(TypeRegistration const & registration, U v) {\n\n return registration.getValueToPython().convert(&v);\n\n }\n\n\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/ToPythonTraits.hpp", "rank": 8, "score": 101888.32370517246 }, { "content": "class ToPythonTraits<U const &> {\n\npublic:\n\n\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n\n\n static PyPtr convert(TypeRegistration const & registration, U const & v) {\n\n return registration.getConstRefToPython().convert(const_cast<U*>(&v));\n\n }\n\n\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/ToPythonTraits.hpp", "rank": 9, "score": 101888.32370517246 }, { "content": "class ToPythonTraits<U const *> {\n\npublic:\n\n\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n\n\n static PyPtr convert(TypeRegistration const & registration, U const * v) {\n\n return registration.getConstPointerToPython().convert(const_cast<U*>(v));\n\n }\n\n\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/ToPythonTraits.hpp", "rank": 10, "score": 101888.32370517246 }, { "content": "class TypeRegistry {\n\npublic:\n\n\n\n // TypeRegistry is not copyable.\n\n TypeRegistry(TypeRegistry const &) = delete;\n\n TypeRegistry & operator=(TypeRegistry const &) = delete;\n\n\n\n // TypeRegistry is moveable.\n\n TypeRegistry(TypeRegistry &&) = default;\n\n TypeRegistry & operator=(TypeRegistry &&) = default;\n\n\n\n /*\n\n * Find the registration for the given type, returning a null pointer if not found.\n\n */\n\n std::shared_ptr<TypeRegistration> lookup(TypeInfo const & t) const;\n\n\n\n /*\n\n * Find the registration for the given type, inserting a new one if not found.\n\n */\n\n std::shared_ptr<TypeRegistration> require(TypeInfo const & t);\n", "file_path": "include/mcpib/TypeRegistry.hpp", "rank": 11, "score": 95241.73204744438 }, { "content": "class FromPythonConverter {\n\npublic:\n\n\n\n explicit FromPythonConverter(Penalty penalty_) : penalty(penalty_) {}\n\n\n\n Penalty const penalty;\n\n\n\n virtual void * convert() = 0;\n\n\n\n virtual void postcall() {}\n\n\n\n virtual ~FromPythonConverter() {}\n\n\n\n};\n\n\n\ntypedef std::vector<std::unique_ptr<FromPythonConverter>> ConverterVector;\n\n\n\n/*\n\n * Factory class for FromPythonConverter.\n\n *\n\n * FromPythonFactory instances held by a TypeRegistration for the C++ type the converters they\n\n * create convert to.\n\n */\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 12, "score": 94969.78068606913 }, { "content": "class ToPythonConverter {\n\npublic:\n\n\n\n /*\n\n * Return a Python object that contains or otherwise represents the given C++ object.\n\n *\n\n * The void pointer argument is guaranteed to point to an instance of the type this\n\n * converter was registered with, so it should be safe to just reinterpret_cast to\n\n * a pointer to that type.\n\n */\n\n virtual PyPtr convert(void *) const = 0;\n\n\n\n // @copydoc FromPythonFactory::clone\n\n virtual std::unique_ptr<ToPythonConverter> clone(TypeRegistry & registry) const = 0;\n\n\n\n virtual ~ToPythonConverter() {}\n\n\n\n};\n\n\n\n} // namespace mcpib\n\n\n\n#endif // !MCPIB_ToPythonConverter_hpp_INCLUDED\n", "file_path": "include/mcpib/ToPythonConverter.hpp", "rank": 13, "score": 94969.78068606913 }, { "content": "\n\n static PyPtr _make();\n\n\n\n // Find the registration for given type, throwing ToPythonError if not found.\n\n std::shared_ptr<TypeRegistration> _lookupToPython(TypeInfo const & t) const;\n\n\n\n TypeRegistry() {}\n\n\n\n void _checkPyType();\n\n\n\n void _import(TypeRegistry const & other);\n\n\n\n PyPtr _py;\n\n};\n\n\n\n} // namespace mcpib\n\n\n\n#endif // !MCPIB_TypeRegistration_hpp_INCLUDED\n", "file_path": "include/mcpib/TypeRegistry.hpp", "rank": 14, "score": 92942.12932534175 }, { "content": "/*\n\n * Copyright (c) 2014, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_TypeRegistry_hpp_INCLUDED\n\n#define MCPIB_TypeRegistry_hpp_INCLUDED\n\n\n\n#include \"mcpib/TypeRegistration.hpp\"\n\n\n\nnamespace mcpib {\n\n\n\ntemplate <typename T> class FromPython;\n\n\n", "file_path": "include/mcpib/TypeRegistry.hpp", "rank": 15, "score": 92938.44180379674 }, { "content": "\n\n /*\n\n * Return a from-Python converter that maps the given Python object to the given C++ type.\n\n *\n\n * This function is defined in FromPython.hpp.\n\n */\n\n template <typename T>\n\n FromPython<T> fromPython(PyPtr const & p) const;\n\n\n\n /*\n\n * Convert a C++ object to Python.\n\n *\n\n * This function is defined in ToPythonTraits.hpp.\n\n */\n\n template <typename T>\n\n PyPtr toPython(T && v) const;\n\n\n\nprivate:\n\n\n\n friend class Module;\n", "file_path": "include/mcpib/TypeRegistry.hpp", "rank": 16, "score": 92930.31711288376 }, { "content": "/*\n\n * Copyright (c) 2014, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_ToPythonConverter_hpp_INCLUDED\n\n#define MCPIB_ToPythonConverter_hpp_INCLUDED\n\n\n\n#include \"mcpib/PyPtr.hpp\"\n\n\n\n#include <memory>\n\n\n\nnamespace mcpib {\n\n\n", "file_path": "include/mcpib/ToPythonConverter.hpp", "rank": 17, "score": 92714.86966762866 }, { "content": "/*\n\n * Copyright (c) 2014, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_FromPythonConverter_hpp_INCLUDED\n\n#define MCPIB_FromPythonConverter_hpp_INCLUDED\n\n\n\n#include \"mcpib/PyPtr.hpp\"\n\n#include \"mcpib/TypeInfo.hpp\"\n\n\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace mcpib {\n\n\n\ntypedef unsigned int Penalty;\n\n\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 18, "score": 92714.54795998502 }, { "content": " * Whether this converter only applies to pointers.\n\n *\n\n * C++ pointers can also be used to pass arrays, so converters that yield array-like\n\n * pointer values should set is_pointer to true so they are not used to convert to\n\n * non-pointer or value C++ types.\n\n */\n\n bool const is_pointer;\n\n\n\n /*\n\n * Return a copy of this converter appropriate for a different registry.\n\n *\n\n * When registries are copied, any converters that hold TypeRegistrations (in order\n\n * to delegate to other converters) must be copied in a way that swaps in new\n\n * TypeRegistrations from the new TypeRegistry. The new TypeRegistry may not be\n\n * fully populated at the time a particular converter is copied, however, so\n\n * implementations of this method should use registry.require() to obtain any\n\n * new TypeRegistrations they require, without assuming anything else about those\n\n * registations at that time.\n\n */\n\n virtual std::unique_ptr<FromPythonFactory> clone(TypeRegistry & registry) const = 0;\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 19, "score": 92713.74170879513 }, { "content": " */\n\n std::string const name;\n\n\n\n /*\n\n * Whether this converter is appropriate for lvalues.\n\n *\n\n * C++ functions that take lvalue arguments (non-const references or pointers)\n\n * require lvalue converters, which allow modifications to those arguments to be transferred\n\n * back to Python. This can reflect either a converter that extracts a C++ object from\n\n * a Python object that holds it, hence truly modifying it in place, or a converter\n\n * that uses the postcall() method to copy temporary state back to a Python object.\n\n *\n\n * Note that some common Python types, including strings and numbers, can never\n\n * be converted by an lvalue converter, because they are intrinsically immutable.\n\n * C++ functions that use output arguments for these types must be converted to\n\n * return multiple values instead.\n\n */\n\n bool const is_lvalue;\n\n\n\n /*\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 20, "score": 92710.40665907663 }, { "content": "\n\n virtual ~FromPythonFactory() {}\n\n\n\nprotected:\n\n FromPythonFactory(std::string const & name_, bool is_lvalue_, bool is_pointer_=false) :\n\n name(name_), is_lvalue(is_lvalue_), is_pointer(is_pointer_)\n\n {}\n\n};\n\n\n\n\n\ntemplate <typename T>\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 21, "score": 92708.30165627843 }, { "content": "class BoolFromPythonConverter :\n\n public IntegerFromPythonConverter<BoolFromPythonConverter,bool,bool> {\n\npublic:\n\n\n\n static bool check(PyPtr const & p) { return PyBool_Check(p.get()); }\n\n\n\n static bool convertIntermediate(PyPtr const & p) { return p.get() == Py_True; }\n\n\n\n // TODO: inherit ctor\n\n BoolFromPythonConverter(PyPtr const & p, Penalty penalty) :\n\n IntegerFromPythonConverter<BoolFromPythonConverter,bool,bool>(p, penalty)\n\n {}\n\n\n\n};\n\n\n\n\n\ntemplate <typename T>\n", "file_path": "python/mcpib/numbers.cpp", "rank": 22, "score": 88640.55621402003 }, { "content": "class IsConvertibleToInt {\n\n private:\n\n typedef char yes[1];\n\n typedef char no[2];\n\n\n\n static const T &get();\n\n\n\n static yes &check(fmt::ULongLong);\n\n static no &check(...);\n\n \n\n public:\n\n enum { value = (sizeof(check(get())) == sizeof(yes)) };\n\n};\n\n\n\n#define FMT_CONVERTIBLE_TO_INT(Type) \\\n\n template <> \\\n", "file_path": "include/mcpib/internal/format.h", "rank": 23, "score": 88572.03350086536 }, { "content": "class TypeRegistry;\n\n\n", "file_path": "include/mcpib/TypeRegistration.hpp", "rank": 24, "score": 85000.86165970254 }, { "content": "struct ArgumentConverter {\n\n\n\n explicit ArgumentConverter(ConverterVector const & converters) : _converters(converters) {}\n\n\n\n template <int N, typename T>\n\n T apply() const {\n\n return FromPythonTraits<T>::adapt(_converters[N]->convert());\n\n }\n\n\n\nprivate:\n\n ConverterVector const & _converters;\n\n};\n\n\n\n\n", "file_path": "include/mcpib/CallableOverload.hpp", "rank": 25, "score": 84795.96326186066 }, { "content": " class IsConvertibleToInt<Type> { \\\n\n public: \\\n\n enum { value = 1 }; \\\n\n }\n\n\n\n// Silence warnings about convering float to int.\n\nFMT_CONVERTIBLE_TO_INT(float);\n\nFMT_CONVERTIBLE_TO_INT(double);\n\nFMT_CONVERTIBLE_TO_INT(long double);\n\n\n\ntemplate<bool B, class T = void>\n", "file_path": "include/mcpib/internal/format.h", "rank": 26, "score": 84795.96326186066 }, { "content": "class FromPythonTraits {\n\npublic:\n\n static bool const is_lvalue = false;\n\n static bool const is_pointer = false;\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<T>(); }\n\n static T adapt(void * converted) { return *reinterpret_cast<T*>(converted); }\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 27, "score": 84795.96326186066 }, { "content": "class PyPtr {\n\npublic:\n\n\n\n typedef ::PyObject element_type;\n\n\n\n constexpr PyPtr() : _p(nullptr) {}\n\n\n\n constexpr PyPtr(std::nullptr_t) : _p(nullptr) {}\n\n\n\n PyPtr(PyPtr const & other) : _p(other._p) { Py_XINCREF(_p); }\n\n\n\n PyPtr(PyPtr && other) : _p(other._p) { other._p = nullptr; }\n\n\n\n ~PyPtr() { Py_XDECREF(_p); }\n\n\n\n PyPtr & operator=(PyPtr const & other) {\n\n PyPtr(other).swap(*this);\n\n return *this;\n\n }\n\n\n", "file_path": "include/mcpib/PyPtr.hpp", "rank": 28, "score": 83613.70569995734 }, { "content": "struct RemoveClass<R(C::*)(A...) const> { using Type = R(A...); };\n\n\n\ntemplate <typename C, typename R, typename ...A>\n", "file_path": "include/mcpib/GetSignature.hpp", "rank": 29, "score": 82197.63432088062 }, { "content": "struct hash<mcpib::TypeInfo> {\n\n typedef mcpib::TypeInfo argument_type;\n\n typedef std::size_t result_type;\n\n\n\n result_type operator()(argument_type const & t) const {\n\n return hash<std::string>()(t.name());\n\n }\n\n};\n\n\n\n} // namespace std\n\n\n\n#endif // !MCPIB_type_id_hpp_INCLUDED\n", "file_path": "include/mcpib/TypeInfo.hpp", "rank": 30, "score": 81728.94985737221 }, { "content": "class FromPythonTraits<U &> {\n\npublic:\n\n static bool const is_lvalue = true;\n\n static bool const is_pointer = false;\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n static U & adapt(void * converted) { return *reinterpret_cast<U *>(converted); }\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 31, "score": 81328.69647138282 }, { "content": "class FromPythonTraits<U *> {\n\npublic:\n\n static bool const is_lvalue = true;\n\n static bool const is_pointer = true;\n\n static TypeInfo getTypeInfo() { return makeTypeInfo<U>(); }\n\n static U * adapt(void * converted) { return reinterpret_cast<U *>(converted); }\n\n};\n\n\n\ntemplate <typename U>\n", "file_path": "include/mcpib/FromPythonConverter.hpp", "rank": 32, "score": 81328.69647138282 }, { "content": "class InstanceFromPythonFactory: public FromPythonFactory {\n\npublic:\n\n\n\n explicit InstanceFromPythonFactory(PyPtr const & cls, std::string const & name) :\n\n FromPythonFactory(name + \".direct\", true, false),\n\n _cls(cls)\n\n {}\n\n\n\n virtual std::unique_ptr<FromPythonConverter> apply(PyPtr const & p) const {\n\n if (Py_TYPE(p.get()) == reinterpret_cast<PyTypeObject*>(_cls.get())) {\n\n return std::unique_ptr<FromPythonConverter>(new InstanceFromPythonConverter<Native,Target>(p));\n\n }\n\n return nullptr;\n\n }\n\n\n\n virtual std::unique_ptr<FromPythonFactory> clone(TypeRegistry & registry) const {\n\n return std::unique_ptr<FromPythonFactory>(new InstanceFromPythonFactory(_cls, name));\n\n }\n\n\n\nprivate:\n\n PyPtr _cls;\n\n};\n\n\n\n\n\n}} // namespace mcpib::detail\n", "file_path": "include/mcpib/detail/InstanceFromPython.hpp", "rank": 33, "score": 80779.76121458264 }, { "content": "class InstanceFromPythonConverter : public FromPythonConverter {\n\npublic:\n\n\n\n explicit InstanceFromPythonConverter(PyPtr const & p) : FromPythonConverter(0), _p(p) {}\n\n\n\n virtual void * convert() {\n\n return static_cast<Target*>(static_cast<Holder<Native>*>(getHolder(_p))->get());\n\n }\n\n\n\nprivate:\n\n PyPtr _p;\n\n};\n\n\n\n\n\ntemplate <typename Native, typename Target=Native>\n", "file_path": "include/mcpib/detail/InstanceFromPython.hpp", "rank": 34, "score": 80419.29016006706 }, { "content": "struct RemoveClass<R(C::*)(A...) const volatile> { using Type = R(A...); };\n\n\n\ntemplate <typename T>\n", "file_path": "include/mcpib/GetSignature.hpp", "rank": 35, "score": 79101.93412080345 }, { "content": "// Converts an integer argument to char for printf.\n\nclass CharConverter : public fmt::internal::ArgVisitor<CharConverter, void> {\n\n private:\n\n fmt::internal::Arg &arg_;\n\n\n\n FMT_DISALLOW_COPY_AND_ASSIGN(CharConverter);\n\n\n\n public:\n\n explicit CharConverter(fmt::internal::Arg &arg) : arg_(arg) {}\n\n\n\n template <typename T>\n\n void visit_any_int(T value) {\n\n arg_.type = Arg::CHAR;\n\n arg_.int_value = static_cast<char>(value);\n\n }\n\n};\n\n\n\n// This function template is used to prevent compile errors when handling\n\n// incompatible string arguments, e.g. handling a wide string in a narrow\n\n// string formatter.\n\ntemplate <typename Char>\n", "file_path": "lib/src/internal/format.cc", "rank": 36, "score": 73743.8139060886 }, { "content": "class ArgConverter : public fmt::internal::ArgVisitor<ArgConverter<T>, void> {\n\n private:\n\n fmt::internal::Arg &arg_;\n\n wchar_t type_;\n\n\n\n FMT_DISALLOW_COPY_AND_ASSIGN(ArgConverter);\n\n\n\n public:\n\n ArgConverter(fmt::internal::Arg &arg, wchar_t type)\n\n : arg_(arg), type_(type) {}\n\n\n\n template <typename U>\n\n void visit_any_int(U value) {\n\n bool is_signed = type_ == 'd' || type_ == 'i';\n\n using fmt::internal::Arg;\n\n if (sizeof(T) <= sizeof(int)) {\n\n // Extra casts are used to silence warnings.\n\n if (is_signed) {\n\n arg_.type = Arg::INT;\n\n arg_.int_value = static_cast<int>(static_cast<T>(value));\n", "file_path": "lib/src/internal/format.cc", "rank": 37, "score": 71116.82338834606 }, { "content": " class Factory : public FromPythonFactory {\n\n public:\n\n\n\n explicit Factory(std::string const & name) : FromPythonFactory(name, false) {}\n\n\n\n virtual std::unique_ptr<FromPythonConverter> apply(PyPtr const & p) const {\n\n if (PyFloat_Check(p.get())) {\n\n return std::unique_ptr<FromPythonConverter>(new FloatFromPythonConverter<Target>(p, 0));\n\n } else if (PyInt_Check(p.get()) || PyLong_Check(p.get())) {\n\n PyPtr p2 = PyPtr::borrow(PyNumber_Float(p.get()));\n\n return std::unique_ptr<FromPythonConverter>(new FloatFromPythonConverter<Target>(p2, 1));\n\n } else {\n\n return std::unique_ptr<FromPythonConverter>();\n\n }\n\n }\n\n\n\n virtual std::unique_ptr<FromPythonFactory> clone(TypeRegistry & registry) const {\n\n return std::unique_ptr<FromPythonFactory>(new Factory(this->name));\n\n }\n\n\n", "file_path": "python/mcpib/numbers.cpp", "rank": 38, "score": 65580.2520225607 }, { "content": " _impl.require();\n\n return FromPythonTraits<T>::adapt(_impl.converter->convert());\n\n }\n\n\n\nprivate:\n\n detail::FromPythonImpl _impl;\n\n};\n\n\n\ntemplate <typename T>\n\nFromPython<T> TypeRegistry::fromPython(PyPtr const & p) {\n\n return FromPython<T>(p, this->lookup(FromPythonTraits<T>::getTypeInfo()));\n\n}\n\n\n\n} // namespace mcpib\n\n\n\n#endif // !MCPIB_FromPython_hpp_INCLUDED\n", "file_path": "include/mcpib/FromPython.hpp", "rank": 39, "score": 61598.336427019625 }, { "content": " Module import(std::string const & module_name);\n\n\n\nprivate:\n\n\n\n friend class Callable;\n\n friend class ClassBase;\n\n\n\n PyPtr _py;\n\n TypeRegistry _registry;\n\n};\n\n\n\n} // namespace mcpib\n\n\n\n#endif // !MCPIB_Module_hpp_INCLUDED\n", "file_path": "include/mcpib/Module.hpp", "rank": 40, "score": 61597.705000633876 }, { "content": "/*\n\n * Copyright (c) 2015, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_Module_hpp_INCLUDED\n\n#define MCPIB_Module_hpp_INCLUDED\n\n\n\n#include \"mcpib/TypeRegistry.hpp\"\n\n#include \"mcpib/Class.hpp\"\n\n\n\n#include <memory>\n\n\n\nnamespace mcpib {\n\n\n", "file_path": "include/mcpib/Module.hpp", "rank": 41, "score": 61597.614546170524 }, { "content": " std::unique_ptr<FromPythonFactory> fromPython(\n\n new detail::InstanceFromPythonFactory<T>(_py, name)\n\n );\n\n registration.registerFromPython(std::move(fromPython));\n\n }\n\n\n\n};\n\n\n\n} // namespace mcpib\n\n\n\n#endif // !MCPIB_Class_hpp_INCLUDED\n", "file_path": "include/mcpib/Class.hpp", "rank": 42, "score": 61597.23526484939 }, { "content": "/*\n\n * Copyright (c) 2014, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_metaprogramming_hpp_INCLUDED\n\n#define MCPIB_metaprogramming_hpp_INCLUDED\n\n\n\n#include \"mcpib/PyPtr.hpp\" // only needed because Python #include needs to come before std library\n\n\n\n#include <tuple>\n\n#include <functional>\n\n\n\nnamespace mcpib {\n\n\n\nnamespace detail {\n\n\n", "file_path": "include/mcpib/metaprogramming.hpp", "rank": 43, "score": 61595.64554348824 }, { "content": "/*\n\n * Copyright (c) 2014, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_FromPython_hpp_INCLUDED\n\n#define MCPIB_FromPython_hpp_INCLUDED\n\n\n\n#include \"mcpib/PyPtr.hpp\"\n\n#include \"mcpib/TypeRegistration.hpp\"\n\n#include \"mcpib/detail/FromPythonImpl.hpp\"\n\n\n\n#include <memory>\n\n\n\nnamespace mcpib {\n\n\n\n/*\n\n * High-level interface for conversion from Python to C++.\n\n *\n\n * Operations that need detailed control over exactly when different aspects of conversion should be\n\n * performed (e.g. argument parsing for overload resolution) should use FromPythonConverters and\n\n * FromPythonTraits directly, but most user code can just use FromPython.\n\n */\n\ntemplate <typename T>\n", "file_path": "include/mcpib/FromPython.hpp", "rank": 44, "score": 61595.430099198864 }, { "content": " return *this;\n\n }\n\n\n\n PyPtr call(PyPtr const & args, PyPtr const & kwds) const;\n\n\n\n std::string const & getName() const;\n\n\n\nprivate:\n\n\n\n friend class Module;\n\n\n\n void _addOverload(std::unique_ptr<CallableOverloadBase> && overload);\n\n\n\n PyPtr _py;\n\n};\n\n\n\n} // namespace mcpib\n\n\n\n#endif // !MCPIB_Callable_hpp_INCLUDED\n", "file_path": "include/mcpib/Callable.hpp", "rank": 45, "score": 61595.15303877256 }, { "content": "/*\n\n * Copyright (c) 2014, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_Class_hpp_INCLUDED\n\n#define MCPIB_Class_hpp_INCLUDED\n\n\n\n#include \"mcpib/TypeInfo.hpp\"\n\n#include \"mcpib/Holder.hpp\"\n\n#include \"mcpib/TypeRegistration.hpp\"\n\n#include \"mcpib/detail/InstanceFromPython.hpp\"\n\n\n\nnamespace mcpib {\n\n\n", "file_path": "include/mcpib/Class.hpp", "rank": 46, "score": 61594.98615586115 }, { "content": "/*\n\n * Copyright (c) 2015, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_Holder_hpp_INCLUDED\n\n#define MCPIB_Holder_hpp_INCLUDED\n\n\n\n#include \"mcpib/PyPtr.hpp\"\n\n#include <memory>\n\n\n\nnamespace mcpib {\n\n\n\n\n", "file_path": "include/mcpib/Holder.hpp", "rank": 47, "score": 61594.9545777198 }, { "content": "/*\n\n * Copyright (c) 2014, Jim Bosch\n\n * All rights reserved.\n\n *\n\n * mcpib is distributed under a simple BSD-like license;\n\n * see the LICENSE file that should be present in the root\n\n * of the source distribution.\n\n */\n\n#ifndef MCPIB_Callable_hpp_INCLUDED\n\n#define MCPIB_Callable_hpp_INCLUDED\n\n\n\n#include \"mcpib/CallableOverload.hpp\"\n\n\n\nnamespace mcpib {\n\n\n", "file_path": "include/mcpib/Callable.hpp", "rank": 48, "score": 61594.79102217886 }, { "content": "\n\n Module & add(std::string const & name, PyPtr const & value);\n\n\n\n template <typename T>\n\n Module & add(Class<T> & cls) {\n\n cls._attachTo(*this, makeTypeInfo<T>());\n\n return *this;\n\n }\n\n\n\n TypeRegistry & getRegistry() { return _registry; }\n\n\n\n TypeRegistry const & getRegistry() const { return _registry; }\n\n\n\n // Import another mcpib module, and merge its TypeRegistry into this module's.\n\n //\n\n // All TypeRegistrations in the imported module will be copied into this module's\n\n // TypeRegistry, or merged with an existing TypeRegistration when one for the\n\n // appropriate type exists.\n\n // The imported module's TypeRegistry will not be affected, and TypeRegistrations are\n\n // never shared between modules.\n", "file_path": "include/mcpib/Module.hpp", "rank": 49, "score": 61593.57737711357 }, { "content": "#include <sstream>\n\n\n\n#if _SECURE_SCL\n\n# include <iterator>\n\n#endif\n\n\n\n#ifdef _MSC_VER\n\n# include <intrin.h> // _BitScanReverse, _BitScanReverse64\n\n\n\nnamespace fmt {\n\nnamespace internal {\n\n# pragma intrinsic(_BitScanReverse)\n\ninline uint32_t clz(uint32_t x) {\n\n unsigned long r = 0;\n\n _BitScanReverse(&r, x);\n\n return 31 - r;\n\n}\n\n# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)\n\n\n\n# ifdef _WIN64\n", "file_path": "include/mcpib/internal/format.h", "rank": 50, "score": 61593.31150425184 }, { "content": " *p-- = '0' + (n & 7);\n\n } while ((n >>= 3) != 0);\n\n break;\n\n }\n\n default:\n\n internal::report_unknown_type(\n\n spec.type(), spec.flag(CHAR_FLAG) ? \"char\" : \"integer\");\n\n break;\n\n }\n\n}\n\n\n\ntemplate <typename Char>\n\ntemplate <typename T>\n\nvoid BasicWriter<Char>::write_double(\n\n T value, const FormatSpec &spec) {\n\n // Check type.\n\n char type = spec.type();\n\n bool upper = false;\n\n switch (type) {\n\n case 0:\n", "file_path": "include/mcpib/internal/format.h", "rank": 51, "score": 61592.29826330356 }, { "content": " */\n\n BasicStringRef(const std::basic_string<Char> &s)\n\n : data_(s.c_str()), size_(s.size()) {}\n\n\n\n /**\n\n Converts a string reference to an `std::string` object.\n\n */\n\n operator std::basic_string<Char>() const {\n\n return std::basic_string<Char>(data_, size());\n\n }\n\n\n\n /**\n\n Returns the pointer to a C string.\n\n */\n\n const Char *c_str() const { return data_; }\n\n\n\n /**\n\n Returns the string size.\n\n */\n\n std::size_t size() const { return size_; }\n", "file_path": "include/mcpib/internal/format.h", "rank": 52, "score": 61592.19305291962 }, { "content": " FMT_VARIADIC_(char, ReturnType, func, return func, __VA_ARGS__)\n\n\n\n#define FMT_VARIADIC_W(ReturnType, func, ...) \\\n\n FMT_VARIADIC_(wchar_t, ReturnType, func, return func, __VA_ARGS__)\n\n\n\nnamespace fmt {\n\nFMT_VARIADIC(std::string, format, StringRef)\n\nFMT_VARIADIC_W(std::wstring, format, WStringRef)\n\nFMT_VARIADIC(void, print, StringRef)\n\nFMT_VARIADIC(void, print, std::FILE *, StringRef)\n\nFMT_VARIADIC(void, print, std::ostream &, StringRef)\n\nFMT_VARIADIC(void, print_colored, Color, StringRef)\n\nFMT_VARIADIC(std::string, sprintf, StringRef)\n\nFMT_VARIADIC(int, printf, StringRef)\n\nFMT_VARIADIC(int, fprintf, std::FILE *, StringRef)\n\n}\n\n\n\n// Restore warnings.\n\n#if FMT_GCC_VERSION >= 406\n\n# pragma GCC diagnostic pop\n", "file_path": "include/mcpib/internal/format.h", "rank": 53, "score": 61591.60232256939 }, { "content": " *\n\n * If this evaluates to false, operator() will definitely throw PythonException.\n\n * If it evaluates to true, operator() still may throw a PythonException, if the\n\n * Python object appeared to be convertible at first but could not be converted\n\n * in detail (for instance, if the target type is an unsigned integer and the\n\n * Python value is a negative integer, OverflowError will be raised).\n\n */\n\n explicit operator bool() const { return _impl.converter; }\n\n\n\n /*\n\n * Complete the conversion, return a C++ object.\n\n *\n\n * If T is a reference or pointer type, the lifetime of the object returned\n\n * is managed by the FromPython instance, and hence may be destroyed when\n\n * the FromPython object goes out of scope.\n\n *\n\n * If !(*this), FromPythonError will be raised (but the messages won't be very\n\n * informative, so it's generally best for calling code to check in advance).\n\n */\n\n T operator()() const {\n", "file_path": "include/mcpib/FromPython.hpp", "rank": 54, "score": 61591.02257780215 }, { "content": "\n\n /** Returns the size of this buffer. */\n\n std::size_t size() const { return size_; }\n\n\n\n /** Returns the capacity of this buffer. */\n\n std::size_t capacity() const { return capacity_; }\n\n\n\n /**\n\n Resizes the buffer. If T is a POD type new elements may not be initialized.\n\n */\n\n void resize(std::size_t new_size) {\n\n if (new_size > capacity_)\n\n grow(new_size);\n\n size_ = new_size;\n\n }\n\n\n\n /** Reserves space to store at least *capacity* elements. */\n\n void reserve(std::size_t capacity) {\n\n if (capacity > capacity_)\n\n grow(capacity);\n", "file_path": "include/mcpib/internal/format.h", "rank": 55, "score": 61589.99582414874 }, { "content": "\n\n virtual void _registerConverters(std::string const & name, TypeRegistration & registration) const = 0;\n\n\n\n PyTypeObject * _getPyTypeObject() const { return reinterpret_cast<PyTypeObject*>(_py.get()); }\n\n\n\n void _attachTo(Module & module, TypeInfo const & ctype);\n\n\n\n PyPtr _py;\n\n};\n\n\n\n\n\ntemplate <typename T>\n", "file_path": "include/mcpib/Class.hpp", "rank": 56, "score": 61589.71188477538 }, { "content": " FMT_WRAP(Char, ReturnType, func, call, 6, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 7, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 8, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 9, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 10, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 11, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 12, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 13, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 14, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 15, __VA_ARGS__)\n\n#endif // FMT_USE_VARIADIC_TEMPLATES\n\n\n\n/**\n\n \\rst\n\n Defines a variadic function with the specified return type, function name\n\n and argument types passed as variable arguments to this macro.\n\n\n\n **Example**::\n\n\n\n void print_error(const char *file, int line, const char *format,\n", "file_path": "include/mcpib/internal/format.h", "rank": 57, "score": 61589.537529168934 }, { "content": "# if defined(FMT_GNUC_LIBSTD_VERSION) && FMT_GNUC_LIBSTD_VERSION <= 402\n\n# define FMT_USE_RVALUE_REFERENCES 0\n\n# else\n\n# define FMT_USE_RVALUE_REFERENCES \\\n\n (FMT_HAS_FEATURE(cxx_rvalue_references) || \\\n\n (FMT_GCC_VERSION >= 403 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1600)\n\n# endif\n\n#endif\n\n\n\n#if FMT_USE_RVALUE_REFERENCES\n\n# include <utility> // for std::move\n\n#endif\n\n\n\n// Define FMT_USE_NOEXCEPT to make C++ Format use noexcept (C++11 feature).\n\n#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \\\n\n (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11)\n\n# define FMT_NOEXCEPT noexcept\n\n#else\n\n# define FMT_NOEXCEPT throw()\n\n#endif\n", "file_path": "include/mcpib/internal/format.h", "rank": 58, "score": 61589.405603053674 }, { "content": " FMT_EXPAND(FMT_CONCAT(FMT_FOR_EACH, N)(f, __VA_ARGS__))\n\n#define FMT_FOR_EACH(f, ...) \\\n\n FMT_EXPAND(FMT_FOR_EACH_(FMT_NARG(__VA_ARGS__), f, __VA_ARGS__))\n\n\n\n#define FMT_ADD_ARG_NAME(type, index) type arg##index\n\n#define FMT_GET_ARG_NAME(type, index) arg##index\n\n\n\n#if FMT_USE_VARIADIC_TEMPLATES\n\n\n\nnamespace fmt {\n\nnamespace internal {\n\ninline void do_set_types(Arg *) {}\n\n\n\ntemplate <typename T, typename... Args>\n\ninline void do_set_types(Arg *args, const T &arg, const Args & ... tail) {\n\n args->type = static_cast<Arg::Type>(MakeValue<T>::type(arg));\n\n do_set_types(args + 1, tail...);\n\n}\n\n\n\ntemplate <typename... Args>\n", "file_path": "include/mcpib/internal/format.h", "rank": 59, "score": 61588.94325759874 }, { "content": " Returns a pointer to the output buffer content with terminating null\n\n character appended.\n\n */\n\n const char *c_str() const {\n\n buffer_[BUFFER_SIZE - 1] = '\\0';\n\n return str_;\n\n }\n\n\n\n /**\n\n Returns the content of the output buffer as an `std::string`.\n\n */\n\n std::string str() const { return std::string(str_, size()); }\n\n};\n\n\n\n// Formats a decimal integer value writing into buffer and returns\n\n// a pointer to the end of the formatted string. This function doesn't\n\n// write a terminating null character.\n\ntemplate <typename T>\n\ninline void format_decimal(char *&buffer, T value) {\n\n typename internal::IntTraits<T>::MainType abs_value = value;\n", "file_path": "include/mcpib/internal/format.h", "rank": 60, "score": 61588.602405295314 }, { "content": " fmt::ArgList args) {\n\n fmt::print(\"{}: {}: \", file, line);\n\n fmt::print(format, args);\n\n }\n\n FMT_VARIADIC(void, print_error, const char *, int, const char *)\n\n\n\n ``FMT_VARIADIC`` is used for compatibility with legacy C++ compilers that\n\n don't implement variadic templates. You don't have to use this macro if\n\n you don't need legacy compiler support and can use variadic templates\n\n directly::\n\n\n\n template <typename... Args>\n\n void print_error(const char *file, int line, const char *format,\n\n const Args & ... args) {\n\n fmt::print(\"{}: {}: \", file, line);\n\n fmt::print(format, args...);\n\n }\n\n \\endrst\n\n */\n\n#define FMT_VARIADIC(ReturnType, func, ...) \\\n", "file_path": "include/mcpib/internal/format.h", "rank": 61, "score": 61588.394277764724 }, { "content": " (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n\n LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n\n ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n */\n\n\n\n#ifndef FMT_FORMAT_H_\n\n#define FMT_FORMAT_H_\n\n\n\n#include <stdint.h>\n\n\n\n#include <cassert>\n\n#include <cmath>\n\n#include <cstddef> // for std::ptrdiff_t\n\n#include <cstdio>\n\n#include <algorithm>\n\n#include <limits>\n\n#include <stdexcept>\n\n#include <string>\n", "file_path": "include/mcpib/internal/format.h", "rank": 62, "score": 61588.389011982006 }, { "content": " type = 'g';\n\n break;\n\n case 'e': case 'f': case 'g': case 'a':\n\n break;\n\n case 'F':\n\n#ifdef _MSC_VER\n\n // MSVC's printf doesn't support 'F'.\n\n type = 'f';\n\n#endif\n\n // Fall through.\n\n case 'E': case 'G': case 'A':\n\n upper = true;\n\n break;\n\n default:\n\n internal::report_unknown_type(type, \"double\");\n\n break;\n\n }\n\n\n\n char sign = 0;\n\n // Use getsign instead of value < 0 because the latter is always\n", "file_path": "include/mcpib/internal/format.h", "rank": 63, "score": 61587.95911048718 }, { "content": " }\n\n\n\n MemoryBuffer &operator=(MemoryBuffer &&other) {\n\n assert(this != &other);\n\n free();\n\n move(other);\n\n return *this;\n\n }\n\n#endif\n\n\n\n // Returns a copy of the allocator associated with this buffer.\n\n Allocator get_allocator() const { return *this; }\n\n};\n\n\n\ntemplate <typename T, std::size_t SIZE, typename Allocator>\n\nvoid MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t size) {\n\n std::size_t new_capacity =\n\n (std::max)(size, this->capacity_ + this->capacity_ / 2);\n\n T *new_ptr = this->allocate(new_capacity);\n\n // The following code doesn't throw, so the raw pointer above doesn't leak.\n", "file_path": "include/mcpib/internal/format.h", "rank": 64, "score": 61587.92007285574 }, { "content": " FMT_MAKE_STR_VALUE(StringRef, STRING)\n\n\n\n#define FMT_MAKE_WSTR_VALUE(Type, TYPE) \\\n\n MakeValue(typename WCharHelper<Type, Char>::Supported value) { \\\n\n set_string(value); \\\n\n } \\\n\n static uint64_t type(Type) { return Arg::TYPE; }\n\n\n\n FMT_MAKE_WSTR_VALUE(wchar_t *, WSTRING)\n\n FMT_MAKE_WSTR_VALUE(const wchar_t *, WSTRING)\n\n FMT_MAKE_WSTR_VALUE(const std::wstring &, WSTRING)\n\n FMT_MAKE_WSTR_VALUE(WStringRef, WSTRING)\n\n\n\n FMT_MAKE_VALUE(void *, pointer, POINTER)\n\n FMT_MAKE_VALUE(const void *, pointer, POINTER)\n\n\n\n template <typename T>\n\n MakeValue(const T &value,\n\n typename EnableIf<!IsConvertibleToInt<T>::value, int>::type = 0) {\n\n custom.value = &value;\n", "file_path": "include/mcpib/internal/format.h", "rank": 65, "score": 61587.808794703305 }, { "content": " if (value < 10) {\n\n *--buffer_end = static_cast<char>('0' + value);\n\n return buffer_end;\n\n }\n\n unsigned index = static_cast<unsigned>(value * 2);\n\n *--buffer_end = internal::Data::DIGITS[index + 1];\n\n *--buffer_end = internal::Data::DIGITS[index];\n\n return buffer_end;\n\n }\n\n\n\n void FormatSigned(LongLong value) {\n\n ULongLong abs_value = static_cast<ULongLong>(value);\n\n bool negative = value < 0;\n\n if (negative)\n\n abs_value = 0 - abs_value;\n\n str_ = format_decimal(abs_value);\n\n if (negative)\n\n *--str_ = '-';\n\n }\n\n\n", "file_path": "include/mcpib/internal/format.h", "rank": 66, "score": 61587.74125689428 }, { "content": "// Defines a wrapper for a function taking __VA_ARGS__ arguments\n\n// and n additional arguments of arbitrary types.\n\n# define FMT_WRAP(Char, ReturnType, func, call, n, ...) \\\n\n template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \\\n\n inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__), \\\n\n FMT_GEN(n, FMT_MAKE_ARG)) { \\\n\n const fmt::internal::Arg args[] = {FMT_GEN(n, FMT_MAKE_REF_##Char)}; \\\n\n call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList( \\\n\n fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), args)); \\\n\n }\n\n\n\n# define FMT_VARIADIC_(Char, ReturnType, func, call, ...) \\\n\n inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__)) { \\\n\n call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList()); \\\n\n } \\\n\n FMT_WRAP(Char, ReturnType, func, call, 1, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 2, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 3, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 4, __VA_ARGS__) \\\n\n FMT_WRAP(Char, ReturnType, func, call, 5, __VA_ARGS__) \\\n", "file_path": "include/mcpib/internal/format.h", "rank": 67, "score": 61587.70212548381 }, { "content": " MakeValue(typename WCharHelper<WStringRef, Char>::Unsupported);\n\n\n\n void set_string(StringRef str) {\n\n string.value = str.c_str();\n\n string.size = str.size();\n\n }\n\n\n\n void set_string(WStringRef str) {\n\n wstring.value = str.c_str();\n\n wstring.size = str.size();\n\n }\n\n\n\n // Formats an argument of a custom type, such as a user-defined class.\n\n template <typename T>\n\n static void format_custom_arg(\n\n void *formatter, const void *arg, void *format_str_ptr) {\n\n format(*static_cast<BasicFormatter<Char>*>(formatter),\n\n *static_cast<const Char**>(format_str_ptr),\n\n *static_cast<const T*>(arg));\n\n }\n", "file_path": "include/mcpib/internal/format.h", "rank": 68, "score": 61587.626928397316 }, { "content": " }\n\n\n\n void clear() FMT_NOEXCEPT { size_ = 0; }\n\n\n\n void push_back(const T &value) {\n\n if (size_ == capacity_)\n\n grow(size_ + 1);\n\n ptr_[size_++] = value;\n\n }\n\n\n\n /** Appends data to the end of the buffer. */\n\n void append(const T *begin, const T *end);\n\n\n\n T &operator[](std::size_t index) { return ptr_[index]; }\n\n const T &operator[](std::size_t index) const { return ptr_[index]; }\n\n};\n\n\n\ntemplate <typename T>\n\nvoid Buffer<T>::append(const T *begin, const T *end) {\n\n std::ptrdiff_t num_elements = end - begin;\n", "file_path": "include/mcpib/internal/format.h", "rank": 69, "score": 61587.51983033387 }, { "content": " // and strings to a char stream. If you want to print a wide string as a\n\n // pointer as std::ostream does, cast it to const void*.\n\n // Do not implement!\n\n void operator<<(typename internal::WCharHelper<wchar_t, Char>::Unsupported);\n\n void operator<<(\n\n typename internal::WCharHelper<const wchar_t *, Char>::Unsupported);\n\n\n\n // Appends floating-point length specifier to the format string.\n\n // The second argument is only used for overload resolution.\n\n void append_float_length(Char *&format_ptr, long double) {\n\n *format_ptr++ = 'L';\n\n }\n\n\n\n template<typename T>\n\n void append_float_length(Char *&, T) {}\n\n\n\n friend class internal::ArgFormatter<Char>;\n\n friend class internal::PrintfFormatter<Char>;\n\n\n\n protected:\n", "file_path": "include/mcpib/internal/format.h", "rank": 70, "score": 61587.441640379344 }, { "content": " /**\n\n Constructs a ``BasicWriter`` object.\n\n */\n\n explicit BasicWriter(Buffer<Char> &b) : buffer_(b) {}\n\n\n\n public:\n\n /**\n\n Destroys a ``BasicWriter`` object.\n\n */\n\n virtual ~BasicWriter() {}\n\n\n\n /**\n\n Returns the total number of characters written.\n\n */\n\n std::size_t size() const { return buffer_.size(); }\n\n\n\n /**\n\n Returns a pointer to the output buffer content. No terminating null\n\n character is appended.\n\n */\n", "file_path": "include/mcpib/internal/format.h", "rank": 71, "score": 61587.277990414346 }, { "content": "\n\n/**\n\n Returns an integer format specifier to format the value in base 16 using\n\n lower-case letters for the digits above 9.\n\n */\n\nIntFormatSpec<int, TypeSpec<'x'> > hex(int value);\n\n\n\n/**\n\n Returns an integer formatter format specifier to format in base 16 using\n\n upper-case letters for the digits above 9.\n\n */\n\nIntFormatSpec<int, TypeSpec<'X'> > hexu(int value);\n\n\n\n/**\n\n \\rst\n\n Returns an integer format specifier to pad the formatted argument with the\n\n fill character to the specified width using the default (right) numeric\n\n alignment.\n\n\n\n **Example**::\n", "file_path": "include/mcpib/internal/format.h", "rank": 72, "score": 61587.218314961065 }, { "content": " // TODO: error if fill is not convertible to Char\n\n write_str(s, std::char_traits<Char>::length(s), spec);\n\n return *this;\n\n }\n\n\n\n void clear() FMT_NOEXCEPT { buffer_.clear(); }\n\n};\n\n\n\ntemplate <typename Char>\n\ntemplate <typename StrChar>\n\ntypename BasicWriter<Char>::CharPtr BasicWriter<Char>::write_str(\n\n const StrChar *s, std::size_t size, const AlignSpec &spec) {\n\n CharPtr out = CharPtr();\n\n if (spec.width() > size) {\n\n out = grow_buffer(spec.width());\n\n Char fill = static_cast<Char>(spec.fill());\n\n if (spec.align() == ALIGN_RIGHT) {\n\n std::fill_n(out, spec.width() - size, fill);\n\n out += spec.width() - size;\n\n } else if (spec.align() == ALIGN_CENTER) {\n", "file_path": "include/mcpib/internal/format.h", "rank": 73, "score": 61587.11605919465 }, { "content": " void _apply2() {\n\n _f.template apply<N,typename std::tuple_element<N,std::tuple<E1...>>::type>();\n\n }\n\n\n\n Func const & _f;\n\n};\n\n\n\n} // namespace detail\n\n\n\n\n\n/*\n\n * Call a std::function-wrapped callable, using a function object with templated apply() methods\n\n * to build its arguments.\n\n *\n\n * The \"ArgumentBuilder\" class that is used to build the arguments should look like this:\n\n *\n\n * struct ArgumentBuilder {\n\n * template <int N, typename T>\n\n * T apply() const {\n\n * ... return the Nth argument, of type T\n\n * }\n\n * };\n\n */\n\ntemplate <typename ArgumentBuilder, typename Result, typename ...Args>\n\nResult callFunction(ArgumentBuilder builder, std::function<Result(Args...)> const & function) {\n\n return detail::callFunctionImpl(builder, function, typename detail::Generate<sizeof...(Args)>::Type());\n\n}\n\n\n\ntemplate <typename ...E>\n", "file_path": "include/mcpib/metaprogramming.hpp", "rank": 74, "score": 61587.07286716685 }, { "content": " const Char *data() const FMT_NOEXCEPT { return &buffer_[0]; }\n\n\n\n /**\n\n Returns a pointer to the output buffer content with terminating null\n\n character appended.\n\n */\n\n const Char *c_str() const {\n\n std::size_t size = buffer_.size();\n\n buffer_.reserve(size + 1);\n\n buffer_[size] = '\\0';\n\n return &buffer_[0];\n\n }\n\n\n\n /**\n\n Returns the content of the output buffer as an `std::string`.\n\n */\n\n std::basic_string<Char> str() const {\n\n return std::basic_string<Char>(&buffer_[0], buffer_.size());\n\n }\n\n\n", "file_path": "include/mcpib/internal/format.h", "rank": 75, "score": 61586.999822803 }, { "content": "#endif\n\n\n\n#ifdef __clang__\n\n# pragma clang diagnostic pop\n\n#endif\n\n\n\n#ifdef FMT_HEADER_ONLY\n\n# include \"format.cc\"\n\n#endif\n\n\n\n#endif // FMT_FORMAT_H_\n", "file_path": "include/mcpib/internal/format.h", "rank": 76, "score": 61586.949592250385 }, { "content": "void print(std::FILE *f, StringRef format_str, ArgList args);\n\n\n\n/**\n\n \\rst\n\n Prints formatted data to ``stdout``.\n\n\n\n **Example**::\n\n\n\n print(\"Elapsed time: {0:.2f} seconds\", 1.23);\n\n \\endrst\n\n */\n\nvoid print(StringRef format_str, ArgList args);\n\n\n\n/**\n\n \\rst\n\n Prints formatted data to the stream *os*.\n\n\n\n **Example**::\n\n\n\n print(cerr, \"Don't {}!\", \"panic\");\n", "file_path": "include/mcpib/internal/format.h", "rank": 77, "score": 61586.92409228199 }, { "content": "\n\n friend bool operator==(BasicStringRef lhs, BasicStringRef rhs) {\n\n return lhs.data_ == rhs.data_;\n\n }\n\n friend bool operator!=(BasicStringRef lhs, BasicStringRef rhs) {\n\n return lhs.data_ != rhs.data_;\n\n }\n\n};\n\n\n\ntypedef BasicStringRef<char> StringRef;\n\ntypedef BasicStringRef<wchar_t> WStringRef;\n\n\n\n/**\n\n A formatting error such as invalid format string.\n\n*/\n", "file_path": "include/mcpib/internal/format.h", "rank": 78, "score": 61586.89438344983 }, { "content": " const Spec &spec, const char *prefix, unsigned prefix_size);\n\n\n\n // Formats an integer.\n\n template <typename T, typename Spec>\n\n void write_int(T value, Spec spec);\n\n\n\n // Formats a floating-point number (double or long double).\n\n template <typename T>\n\n void write_double(T value, const FormatSpec &spec);\n\n\n\n // Writes a formatted string.\n\n template <typename StrChar>\n\n CharPtr write_str(\n\n const StrChar *s, std::size_t size, const AlignSpec &spec);\n\n\n\n template <typename StrChar>\n\n void write_str(\n\n const internal::Arg::StringValue<StrChar> &str, const FormatSpec &spec);\n\n\n\n // This following methods are private to disallow writing wide characters\n", "file_path": "include/mcpib/internal/format.h", "rank": 79, "score": 61586.75643343738 }, { "content": "\n\n// A macro to disallow the copy constructor and operator= functions\n\n// This should be used in the private: declarations for a class\n\n#if FMT_USE_DELETED_FUNCTIONS || FMT_HAS_FEATURE(cxx_deleted_functions) || \\\n\n (FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1800\n\n# define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \\\n\n TypeName(const TypeName&) = delete; \\\n\n TypeName& operator=(const TypeName&) = delete\n\n#else\n\n# define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \\\n\n TypeName(const TypeName&); \\\n\n TypeName& operator=(const TypeName&)\n\n#endif\n\n\n\nnamespace fmt {\n\n\n\n// Fix the warning about long long on older versions of GCC\n\n// that don't support the diagnostic pragma.\n\nFMT_GCC_EXTENSION typedef long long LongLong;\n\nFMT_GCC_EXTENSION typedef unsigned long long ULongLong;\n\n\n\n#if FMT_USE_RVALUE_REFERENCES\n\nusing std::move;\n\n#endif\n\n\n\ntemplate <typename Char>\n", "file_path": "include/mcpib/internal/format.h", "rank": 80, "score": 61586.7495957579 }, { "content": "// for example, visit_int(int).\n\n// Specify the subclass name as the Impl template parameter. Then calling\n\n// ArgVisitor::visit for some argument will dispatch to a visit method\n\n// specific to the argument type. For example, if the argument type is\n\n// double then visit_double(double) method of a subclass will be called.\n\n// If the subclass doesn't contain a method with this signature, then\n\n// a corresponding method of ArgVisitor will be called.\n\n//\n\n// Example:\n\n// class MyArgVisitor : public ArgVisitor<MyArgVisitor, void> {\n\n// public:\n\n// void visit_int(int value) { print(\"{}\", value); }\n\n// void visit_double(double value) { print(\"{}\", value ); }\n\n// };\n\n//\n\n// ArgVisitor uses the curiously recurring template pattern:\n\n// http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern\n\ntemplate <typename Impl, typename Result>\n", "file_path": "include/mcpib/internal/format.h", "rank": 81, "score": 61586.70115093131 }, { "content": " custom.format = &format_custom_arg<T>;\n\n }\n\n\n\n template <typename T>\n\n MakeValue(const T &value,\n\n typename EnableIf<IsConvertibleToInt<T>::value, int>::type = 0) {\n\n int_value = value;\n\n }\n\n\n\n template <typename T>\n\n static uint64_t type(const T &) {\n\n return IsConvertibleToInt<T>::value ? Arg::INT : Arg::CUSTOM;\n\n }\n\n};\n\n\n\n#define FMT_DISPATCH(call) static_cast<Impl*>(this)->call\n\n\n\n// An argument visitor.\n\n// To use ArgVisitor define a subclass that implements some or all of the\n\n// visit methods with the same signatures as the methods in ArgVisitor,\n", "file_path": "include/mcpib/internal/format.h", "rank": 82, "score": 61586.62622095246 }, { "content": " \\endrst\n\n */\n\nvoid print(std::ostream &os, StringRef format_str, ArgList args);\n\n\n\ntemplate <typename Char>\n\nvoid printf(BasicWriter<Char> &w, BasicStringRef<Char> format, ArgList args) {\n\n internal::PrintfFormatter<Char>().format(w, format, args);\n\n}\n\n\n\n/**\n\n \\rst\n\n Formats arguments and returns the result as a string.\n\n\n\n **Example**::\n\n\n\n std::string message = fmt::sprintf(\"The answer is %d\", 42);\n\n \\endrst\n\n*/\n\ninline std::string sprintf(StringRef format, ArgList args) {\n\n MemoryWriter w;\n", "file_path": "include/mcpib/internal/format.h", "rank": 83, "score": 61586.53187719017 }, { "content": "# define FMT_MAKE_TEMPLATE_ARG(n) typename T##n\n\n# define FMT_MAKE_ARG_TYPE(n) T##n\n\n# define FMT_MAKE_ARG(n) const T##n &v##n\n\n# define FMT_MAKE_REF_char(n) fmt::internal::MakeValue<char>(v##n)\n\n# define FMT_MAKE_REF_wchar_t(n) fmt::internal::MakeValue<wchar_t>(v##n)\n\n\n\n#if FMT_USE_VARIADIC_TEMPLATES\n\n// Defines a variadic function returning void.\n\n# define FMT_VARIADIC_VOID(func, arg_type) \\\n\n template <typename... Args> \\\n\n void func(arg_type arg1, const Args & ... args) { \\\n\n const fmt::internal::Arg array[ \\\n\n fmt::internal::NonZero<sizeof...(Args)>::VALUE] = { \\\n\n fmt::internal::MakeValue<Char>(args)... \\\n\n }; \\\n\n func(arg1, ArgList(fmt::internal::make_type(args...), array)); \\\n\n }\n\n\n\n// Defines a variadic constructor.\n\n# define FMT_VARIADIC_CTOR(ctor, func, arg0_type, arg1_type) \\\n", "file_path": "include/mcpib/internal/format.h", "rank": 84, "score": 61586.52183324576 }, { "content": "#endif\n\n\n\n#ifdef __has_cpp_attribute\n\n# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)\n\n#else\n\n# define FMT_HAS_CPP_ATTRIBUTE(x) 0\n\n#endif\n\n\n\n#ifndef FMT_USE_VARIADIC_TEMPLATES\n\n// Variadic templates are available in GCC since version 4.4\n\n// (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++\n\n// since version 2013.\n\n# define FMT_USE_VARIADIC_TEMPLATES \\\n\n (FMT_HAS_FEATURE(cxx_variadic_templates) || \\\n\n (FMT_GCC_VERSION >= 404 && FMT_HAS_GXX_CXX11) || _MSC_VER >= 1800)\n\n#endif\n\n\n\n#ifndef FMT_USE_RVALUE_REFERENCES\n\n// Don't use rvalue references when compiling with clang and an old libstdc++\n\n// as the latter doesn't provide std::move.\n", "file_path": "include/mcpib/internal/format.h", "rank": 85, "score": 61586.506085364934 }, { "content": " :func:`str` methods.\n\n\n\n See also :ref:`syntax`.\n\n \\endrst\n\n */\n\n void write(BasicStringRef<Char> format, ArgList args) {\n\n BasicFormatter<Char>(*this).format(format, args);\n\n }\n\n FMT_VARIADIC_VOID(write, BasicStringRef<Char>)\n\n\n\n BasicWriter &operator<<(int value) {\n\n return *this << IntFormatSpec<int>(value);\n\n }\n\n BasicWriter &operator<<(unsigned value) {\n\n return *this << IntFormatSpec<unsigned>(value);\n\n }\n\n BasicWriter &operator<<(long value) {\n\n return *this << IntFormatSpec<long>(value);\n\n }\n\n BasicWriter &operator<<(unsigned long value) {\n", "file_path": "include/mcpib/internal/format.h", "rank": 86, "score": 61586.426310206785 }, { "content": " double double_value;\n\n long double long_double_value;\n\n const void *pointer;\n\n StringValue<char> string;\n\n StringValue<signed char> sstring;\n\n StringValue<unsigned char> ustring;\n\n StringValue<wchar_t> wstring;\n\n CustomValue custom;\n\n };\n\n\n\n enum Type {\n\n NONE,\n\n // Integer types should go first,\n\n INT, UINT, LONG_LONG, ULONG_LONG, CHAR, LAST_INTEGER_TYPE = CHAR,\n\n // followed by floating-point types.\n\n DOUBLE, LONG_DOUBLE, LAST_NUMERIC_TYPE = LONG_DOUBLE,\n\n CSTRING, STRING, WSTRING, POINTER, CUSTOM\n\n };\n\n Type type;\n\n};\n\n\n\ntemplate <typename T = void>\n", "file_path": "include/mcpib/internal/format.h", "rank": 87, "score": 61586.409438943294 }, { "content": "\n\n MemoryWriter out;\n\n out << \"The answer is \" << 42 << \"\\n\";\n\n out.write(\"({:+f}, {:+f})\", -3.14, 3.14);\n\n\n\n This will write the following output to the ``out`` object:\n\n\n\n .. code-block:: none\n\n\n\n The answer is 42\n\n (-3.140000, +3.140000)\n\n\n\n The output can be converted to an ``std::string`` with ``out.str()`` or\n\n accessed as a C string with ``out.c_str()``.\n\n \\endrst\n\n */\n\ntemplate <typename Char, typename Allocator = std::allocator<Char> >\n", "file_path": "include/mcpib/internal/format.h", "rank": 88, "score": 61586.34350666193 }, { "content": " public:\n\n explicit FormatInt(int value) { FormatSigned(value); }\n\n explicit FormatInt(long value) { FormatSigned(value); }\n\n explicit FormatInt(LongLong value) { FormatSigned(value); }\n\n explicit FormatInt(unsigned value) : str_(format_decimal(value)) {}\n\n explicit FormatInt(unsigned long value) : str_(format_decimal(value)) {}\n\n explicit FormatInt(ULongLong value) : str_(format_decimal(value)) {}\n\n\n\n /**\n\n Returns the number of characters written to the output buffer.\n\n */\n\n std::size_t size() const { return buffer_ - str_ + BUFFER_SIZE - 1; }\n\n\n\n /**\n\n Returns a pointer to the output buffer content. No terminating null\n\n character is appended.\n\n */\n\n const char *data() const { return str_; }\n\n\n\n /**\n", "file_path": "include/mcpib/internal/format.h", "rank": 89, "score": 61586.338085986434 }, { "content": " const fmt::internal::Arg args[] = {FMT_GEN(n, FMT_MAKE_REF)}; \\\n\n func(arg1, fmt::ArgList( \\\n\n fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), args)); \\\n\n }\n\n\n\n// Emulates a variadic function returning void on a pre-C++11 compiler.\n\n# define FMT_VARIADIC_VOID(func, arg_type) \\\n\n inline void func(arg_type arg) { func(arg, fmt::ArgList()); } \\\n\n FMT_WRAP1(func, arg_type, 1) FMT_WRAP1(func, arg_type, 2) \\\n\n FMT_WRAP1(func, arg_type, 3) FMT_WRAP1(func, arg_type, 4) \\\n\n FMT_WRAP1(func, arg_type, 5) FMT_WRAP1(func, arg_type, 6) \\\n\n FMT_WRAP1(func, arg_type, 7) FMT_WRAP1(func, arg_type, 8) \\\n\n FMT_WRAP1(func, arg_type, 9) FMT_WRAP1(func, arg_type, 10)\n\n\n\n# define FMT_CTOR(ctor, func, arg0_type, arg1_type, n) \\\n\n template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \\\n\n ctor(arg0_type arg0, arg1_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \\\n\n const fmt::internal::Arg args[] = {FMT_GEN(n, FMT_MAKE_REF)}; \\\n\n func(arg0, arg1, fmt::ArgList( \\\n\n fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), args)); \\\n", "file_path": "include/mcpib/internal/format.h", "rank": 90, "score": 61586.14255375579 }, { "content": " if (size_ + num_elements > capacity_)\n\n grow(size_ + num_elements);\n\n std::copy(begin, end, internal::make_ptr(ptr_, capacity_) + size_);\n\n size_ += num_elements;\n\n}\n\n\n\nnamespace internal {\n\n\n\n// A memory buffer for POD types with the first SIZE elements stored in\n\n// the object itself.\n\ntemplate <typename T, std::size_t SIZE, typename Allocator = std::allocator<T> >\n", "file_path": "include/mcpib/internal/format.h", "rank": 91, "score": 61586.0878196334 }, { "content": " ++num_digits;\n\n } while ((n >>= 4) != 0);\n\n Char *p = get(prepare_int_buffer(\n\n num_digits, spec, prefix, prefix_size));\n\n n = abs_value;\n\n const char *digits = spec.type() == 'x' ?\n\n \"0123456789abcdef\" : \"0123456789ABCDEF\";\n\n do {\n\n *p-- = digits[n & 0xf];\n\n } while ((n >>= 4) != 0);\n\n break;\n\n }\n\n case 'b': case 'B': {\n\n UnsignedType n = abs_value;\n\n if (spec.flag(HASH_FLAG)) {\n\n prefix[prefix_size++] = '0';\n\n prefix[prefix_size++] = spec.type();\n\n }\n\n unsigned num_digits = 0;\n\n do {\n", "file_path": "include/mcpib/internal/format.h", "rank": 92, "score": 61586.054843408754 }, { "content": " ++num_digits;\n\n } while ((n >>= 1) != 0);\n\n Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size));\n\n n = abs_value;\n\n do {\n\n *p-- = '0' + (n & 1);\n\n } while ((n >>= 1) != 0);\n\n break;\n\n }\n\n case 'o': {\n\n UnsignedType n = abs_value;\n\n if (spec.flag(HASH_FLAG))\n\n prefix[prefix_size++] = '0';\n\n unsigned num_digits = 0;\n\n do {\n\n ++num_digits;\n\n } while ((n >>= 3) != 0);\n\n Char *p = get(prepare_int_buffer(num_digits, spec, prefix, prefix_size));\n\n n = abs_value;\n\n do {\n", "file_path": "include/mcpib/internal/format.h", "rank": 93, "score": 61586.0066514617 }, { "content": " void move(MemoryBuffer &other) {\n\n Allocator &this_alloc = *this, &other_alloc = other;\n\n this_alloc = std::move(other_alloc);\n\n this->size_ = other.size_;\n\n this->capacity_ = other.capacity_;\n\n if (other.ptr_ == other.data_) {\n\n this->ptr_ = data_;\n\n std::copy(other.data_,\n\n other.data_ + this->size_, make_ptr(data_, this->capacity_));\n\n } else {\n\n this->ptr_ = other.ptr_;\n\n // Set pointer to the inline array so that delete is not called\n\n // when freeing.\n\n other.ptr_ = other.data_;\n\n }\n\n }\n\n\n\n public:\n\n MemoryBuffer(MemoryBuffer &&other) {\n\n move(other);\n", "file_path": "include/mcpib/internal/format.h", "rank": 94, "score": 61585.96546899618 }, { "content": "inline void set_types(Arg *array, const Args & ... args) {\n\n do_set_types(array, args...);\n\n array[sizeof...(Args)].type = Arg::NONE;\n\n}\n\n\n\n// Computes the argument array size by adding 1 to N, which is the number of\n\n// arguments, if N is zero, because array of zero size is invalid, or if N\n\n// is greater than ArgList::MAX_PACKED_ARGS to accommodate for an extra\n\n// argument that marks the end of the list.\n\ntemplate <unsigned N>\n", "file_path": "include/mcpib/internal/format.h", "rank": 95, "score": 61585.89576371184 }, { "content": " : types_(types), args_(args) {}\n\n\n\n /** Returns the argument at specified index. */\n\n internal::Arg operator[](unsigned index) const {\n\n using internal::Arg;\n\n Arg arg;\n\n if (index < MAX_PACKED_ARGS) {\n\n Arg::Type arg_type = type(index);\n\n if (arg_type != Arg::NONE)\n\n arg = args_[index];\n\n arg.type = arg_type;\n\n return arg;\n\n }\n\n if (type(MAX_PACKED_ARGS - 1) == Arg::NONE) {\n\n arg.type = Arg::NONE;\n\n return arg;\n\n }\n\n for (unsigned i = MAX_PACKED_ARGS; i <= index; ++i) {\n\n if (args_[i].type == Arg::NONE)\n\n return args_[i];\n\n }\n\n return args_[index];\n\n }\n\n};\n\n\n", "file_path": "include/mcpib/internal/format.h", "rank": 96, "score": 61585.78337742236 }, { "content": " */\n\n template <std::size_t SIZE>\n\n explicit BasicArrayWriter(Char (&array)[SIZE])\n\n : BasicWriter<Char>(buffer_), buffer_(array, SIZE) {}\n\n};\n\n\n\ntypedef BasicArrayWriter<char> ArrayWriter;\n\ntypedef BasicArrayWriter<wchar_t> WArrayWriter;\n\n\n\n// Formats a value.\n\ntemplate <typename Char, typename T>\n\nvoid format(BasicFormatter<Char> &f, const Char *&format_str, const T &value) {\n\n std::basic_ostringstream<Char> os;\n\n os << value;\n\n std::basic_string<Char> str = os.str();\n\n internal::Arg arg = internal::MakeValue<Char>(str);\n\n arg.type = static_cast<internal::Arg::Type>(\n\n internal::MakeValue<Char>::type(str));\n\n format_str = f.format(format_str, arg);\n\n}\n\n\n\n// Reports a system error without throwing an exception.\n\n// Can be used to report errors from destructors.\n\nvoid report_system_error(int error_code, StringRef message) FMT_NOEXCEPT;\n\n\n\n#ifdef _WIN32\n\n\n\n/** A Windows error. */\n", "file_path": "include/mcpib/internal/format.h", "rank": 97, "score": 61585.781398072315 }, { "content": "FMT_DEFINE_INT_FORMATTERS(int)\n\nFMT_DEFINE_INT_FORMATTERS(long)\n\nFMT_DEFINE_INT_FORMATTERS(unsigned)\n\nFMT_DEFINE_INT_FORMATTERS(unsigned long)\n\nFMT_DEFINE_INT_FORMATTERS(LongLong)\n\nFMT_DEFINE_INT_FORMATTERS(ULongLong)\n\n\n\n/**\n\n \\rst\n\n Returns a string formatter that pads the formatted argument with the fill\n\n character to the specified width using the default (left) string alignment.\n\n\n\n **Example**::\n\n\n\n std::string s = str(MemoryWriter() << pad(\"abc\", 8));\n\n // s == \"abc \"\n\n\n\n \\endrst\n\n */\n\ntemplate <typename Char>\n", "file_path": "include/mcpib/internal/format.h", "rank": 98, "score": 61585.654167412744 } ]
C++
ecmascript/napi/test/jsi_test.cpp
openharmony-gitee-mirror/ark_js_runtime
b5ac878349b00b337c45f4702332c23aa82e1e28
#include <cstdint> #include <cstdio> #include <cstring> #include <iostream> #include <memory> #include "ark_js_runtime.h" #include "js_value.h" using OHOS::Ace::Framework::ArkJSRuntime; using OHOS::Ace::Framework::JsRuntime; using OHOS::Ace::Framework::JsValue; using OHOS::Ace::Framework::RegisterFunctionType; using std::shared_ptr; std::string GetLogContent(const shared_ptr<JsRuntime> &runtime, const std::vector<shared_ptr<JsValue>> &argument) { std::string context; for (const auto &value : argument) { context += value->ToString(runtime); } return context; } shared_ptr<JsValue> AppDebugLogPrint(const shared_ptr<JsRuntime> &runtime, const shared_ptr<JsValue> &, const std::vector<shared_ptr<JsValue>> &argument, int32_t) { std::string context = GetLogContent(runtime, argument); std::cout << context.c_str() << std::endl; return runtime->NewObject(); } shared_ptr<JsValue> Setter(const shared_ptr<JsRuntime> &runtime, const shared_ptr<JsValue> &, const std::vector<shared_ptr<JsValue>> &argument, int32_t) { std::string context = GetLogContent(runtime, argument); std::cout << context.c_str() << std::endl; return runtime->NewObject(); } shared_ptr<JsValue> Getter(const shared_ptr<JsRuntime> &runtime, const shared_ptr<JsValue> &, const std::vector<shared_ptr<JsValue>> &argument, int32_t) { std::string context = GetLogContent(runtime, argument); std::cout << "Getter" << std::endl; return runtime->NewObject(); } int PrintLog([[maybe_unused]] int id, [[maybe_unused]] int level, const char *tag, [[maybe_unused]] const char *fmt, const char *message) { std::cout << tag << "::" << message; return 0; } class TestRuntime { public: TestRuntime() { runtime_ = ArkJSRuntime::GetInstance(); runtime_->SetLogPrint(PrintLog); runtime_->Initialize(""); } ~TestRuntime() { runtime_->Reset(); } inline const shared_ptr<JsRuntime> &operator*() const { return runtime_; } inline const shared_ptr<JsRuntime> &operator->() const { return runtime_; } private: shared_ptr<JsRuntime> runtime_; }; int main() { TestRuntime runtime; RegisterFunctionType func = AppDebugLogPrint; shared_ptr<JsValue> global = runtime->GetGlobal(); shared_ptr<JsValue> logFunc = runtime->NewFunction(func); shared_ptr<JsValue> consoleObj = runtime->NewObject(); global->SetProperty(*runtime, "console", consoleObj); consoleObj->SetProperty(*runtime, "log", logFunc); consoleObj->SetProperty(*runtime, "info", logFunc); shared_ptr<JsValue> getSetTest = runtime->NewObject(); shared_ptr<JsValue> setter = runtime->NewFunction(Setter); shared_ptr<JsValue> getter = runtime->NewFunction(Getter); bool getset = getSetTest->SetAccessorProperty(*runtime, "GetSetTest", getter, setter); std::cout << "SetAccessorProperty result: " << getset << std::endl; global->SetProperty(*runtime, "GetSet", getSetTest); std::vector<shared_ptr<JsValue>> arguments; arguments.emplace_back(runtime->NewString("Hello world")); consoleObj = global->GetProperty(*runtime, "console"); logFunc = consoleObj->GetProperty(*runtime, "log"); shared_ptr<JsValue> testObj = logFunc->Call(*runtime, runtime->NewUndefined(), arguments, 1); shared_ptr<JsValue> testArrayValue = runtime->NewString("1"); shared_ptr<JsValue> testValue = runtime->NewArray(); testValue->SetProperty(*runtime, "0", testArrayValue); testValue->SetProperty(*runtime, "1", testArrayValue); std::cout << "GetProperty test: " << testValue->GetArrayLength(*runtime) << std::endl; testObj->SetProperty(*runtime, "test", testValue); shared_ptr<JsValue> result = testObj->GetProperty(*runtime, "test"); std::cout << "GetProperty test: " << result->IsArray(*runtime) << ";" << result->GetArrayLength(*runtime) << std::endl; std::vector<std::string> argument; runtime->ExecuteJsBin("native.aex"); return 0; }
#include <cstdint> #include <cstdio> #include <cstring> #include <iostream> #include <memory> #include "ark_js_runtime.h" #include "js_value.h" using OHOS::Ace::Framework::ArkJSRuntime; using OHOS::Ace::Framework::JsRuntime; using OHOS::Ace::Framework::JsValue; using OHOS::Ace::Framework::RegisterFunctionType; using std::shared_ptr; std::string GetLogContent(const shared_ptr<JsRuntime> &runtime, const std::vector<shared_ptr<JsValue>> &argument) { std::string context; for (const auto &value : argument) { context += value->ToString(runtime); } return context; } shared_ptr<JsValue> AppDebugLogPrint(const shared_ptr<JsRuntime> &runtime, const shared_ptr<JsValue> &, const std::vector<shared_ptr<JsValue>> &argument, int32_t) { std::string context = GetLogContent(runtime, argument); std::cout << context.c_str() << std::endl; return runtime->NewObject(); } shared_ptr<JsValue> Setter(const shared_ptr<JsRuntime> &runtime, const shared_ptr<JsValue> &, const std::vector<shared_ptr<JsValue>> &argument, int32_t) { std::string context = GetLogContent(runtime, argument); std::cout << context.c_str() << std::endl; return runtime->NewObject(); } shared_ptr<JsValue> Getter(const shared_ptr<JsRuntime> &runtime, const shared_ptr<JsValue> &, const std::vector<shared_ptr<JsValue>> &argument, int32_t) { std::string context = GetLogContent(runtime, argument); std::cout << "Getter" << std::endl; return runtime->NewObject(); } int PrintLog([[maybe_unused]] int id, [[maybe_unused]] int level, const char *tag, [[maybe_unused]] const char *fmt, const char *message) { std::cout << tag << "::" << message; return 0; } class TestRuntime { public: TestRuntime() { runtime_ = ArkJSRuntime::GetInstance(); runtime_->SetLogPrint(PrintLog); runtime_->Initialize(""); } ~TestRuntime() { runtime_->Reset(); } inline const shared_ptr<JsRuntime> &operator*() const { return runtime_; } inline const shared_ptr<JsRuntime> &operator->() const { return runtime_; } private: shared_ptr<JsRuntime> runtime_; };
int main() { TestRuntime runtime; RegisterFunctionType func = AppDebugLogPrint; shared_ptr<JsValue> global = runtime->GetGlobal(); shared_ptr<JsValue> logFunc = runtime->NewFunction(func); shared_ptr<JsValue> consoleObj = runtime->NewObject(); global->SetProperty(*runtime, "console", consoleObj); consoleObj->SetProperty(*runtime, "log", logFunc); consoleObj->SetProperty(*runtime, "info", logFunc); shared_ptr<JsValue> getSetTest = runtime->NewObject(); shared_ptr<JsValue> setter = runtime->NewFunction(Setter); shared_ptr<JsValue> getter = runtime->NewFunction(Getter); bool getset = getSetTest->SetAccessorProperty(*runtime, "GetSetTest", getter, setter); std::cout << "SetAccessorProperty result: " << getset << std::endl; global->SetProperty(*runtime, "GetSet", getSetTest); std::vector<shared_ptr<JsValue>> arguments; arguments.emplace_back(runtime->NewString("Hello world")); consoleObj = global->GetProperty(*runtime, "console"); logFunc = consoleObj->GetProperty(*runtime, "log"); shared_ptr<JsValue> testObj = logFunc->Call(*runtime, runtime->NewUndefined(), arguments, 1); shared_ptr<JsValue> testArrayValue = runtime->NewString("1"); shared_ptr<JsValue> testValue = runtime->NewArray(); testValue->SetProperty(*runtime, "0", testArrayValue); testValue->SetProperty(*runtime, "1", testArrayValue); std::cout << "GetProperty test: " << testValue->GetArrayLength(*runtime) << std::endl; testObj->SetProperty(*runtime, "test", testValue); shared_ptr<JsValue> result = testObj->GetProperty(*runtime, "test"); std::cout << "GetProperty test: " << result->IsArray(*runtime) << ";" << result->GetArrayLength(*runtime) << std::endl; std::vector<std::string> argument; runtime->ExecuteJsBin("native.aex"); return 0; }
function_block-full_function
[ { "content": "class JSTaggedValue : public coretypes::TaggedValue {\n\npublic:\n\n static JSTaggedValue Cast(ObjectHeader *object)\n\n {\n\n return JSTaggedValue(object);\n\n }\n\n\n\n JSTaggedValue(void *) = delete;\n\n\n\n constexpr JSTaggedValue() = default;\n\n constexpr explicit JSTaggedValue(coretypes::TaggedType v) : coretypes::TaggedValue(v) {}\n\n constexpr explicit JSTaggedValue(int v) : coretypes::TaggedValue(v) {}\n\n explicit JSTaggedValue(unsigned int v) : coretypes::TaggedValue(v) {}\n\n constexpr explicit JSTaggedValue(bool v) : coretypes::TaggedValue(v) {}\n\n explicit JSTaggedValue(double v) : coretypes::TaggedValue(v) {}\n\n explicit JSTaggedValue(const ObjectHeader *v) : coretypes::TaggedValue(v) {}\n\n explicit JSTaggedValue(const TaggedObject *v) : coretypes::TaggedValue(v) {}\n\n explicit JSTaggedValue(const coretypes::TaggedValue &other) : coretypes::TaggedValue(other.GetRawData()) {}\n\n explicit JSTaggedValue(int64_t v) : coretypes::TaggedValue(v){};\n\n\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 0, "score": 280907.67528649047 }, { "content": "class EcmaScriptDebugApiTest : public testing::TestWithParam<const char *> {\n\npublic:\n\n static void SetUpTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"SetUpTestCase\";\n\n }\n\n\n\n static void TearDownTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"TearDownCase\";\n\n }\n\n\n\n void SetUp() override\n\n {\n\n TestHelper::CreateEcmaVMWithScope(instance, thread, scope);\n\n }\n\n\n\n void TearDown() override\n\n {\n\n TestHelper::DestroyEcmaVMWithScope(instance, scope);\n", "file_path": "ecmascript/tooling/test/launcher.cpp", "rank": 1, "score": 259980.2373394615 }, { "content": "class JSTaggedValueTest : public testing::Test {\n\npublic:\n\n static void SetUpTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"SetUpTestCase\";\n\n }\n\n\n\n static void TearDownTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"TearDownCase\";\n\n }\n\n\n\n void SetUp() override\n\n {\n\n TestHelper::CreateEcmaVMWithScope(instance, thread, scope);\n\n }\n\n\n\n void TearDown() override\n\n {\n\n TestHelper::DestroyEcmaVMWithScope(instance, scope);\n", "file_path": "ecmascript/tests/tagged_value_test.cpp", "rank": 2, "score": 256389.11865908455 }, { "content": "class JSTaggedNumber final : public JSTaggedValue {\n\npublic:\n\n constexpr JSTaggedNumber() = default;\n\n explicit JSTaggedNumber(double v) : JSTaggedValue(v) {}\n\n constexpr explicit JSTaggedNumber(int v) : JSTaggedValue(v) {}\n\n explicit JSTaggedNumber(unsigned int v) : JSTaggedValue(v) {}\n\n explicit JSTaggedNumber(JSTaggedValue v) : JSTaggedValue(v.GetRawData())\n\n {\n\n ASSERT_PRINT(v.IsNumber(), \"can not convert non Number JSTaggedValue to JSTaggedNumber\");\n\n }\n\n\n\n ~JSTaggedNumber() = default;\n\n DEFAULT_COPY_SEMANTIC(JSTaggedNumber);\n\n DEFAULT_MOVE_SEMANTIC(JSTaggedNumber);\n\n\n\n static inline constexpr JSTaggedNumber Exception()\n\n {\n\n return JSTaggedNumber(VALUE_EXCEPTION);\n\n }\n\n\n", "file_path": "ecmascript/js_tagged_number.h", "rank": 3, "score": 253585.05908322765 }, { "content": "class PUBLIC_API PrimitiveRef : public JSValueRef {\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 4, "score": 245945.11774948845 }, { "content": "class PUBLIC_API ObjectRef : public JSValueRef {\n\npublic:\n\n static inline ObjectRef *Cast(JSValueRef *value)\n\n {\n\n // check\n\n return static_cast<ObjectRef *>(value);\n\n }\n\n static Local<ObjectRef> New(const EcmaVM *vm);\n\n bool Set(const EcmaVM *vm, Local<JSValueRef> key, Local<JSValueRef> value);\n\n bool Set(const EcmaVM *vm, uint32_t key, Local<JSValueRef> value);\n\n bool SetAccessorProperty(const EcmaVM *vm, Local<JSValueRef> key, Local<FunctionRef> getter,\n\n Local<FunctionRef> setter, PropertyAttribute attribute = PropertyAttribute::Default());\n\n Local<JSValueRef> Get(const EcmaVM *vm, Local<JSValueRef> key);\n\n Local<JSValueRef> Get(const EcmaVM *vm, int32_t key);\n\n\n\n bool GetOwnProperty(const EcmaVM *vm, Local<JSValueRef> key, PropertyAttribute &property);\n\n Local<ArrayRef> GetOwnPropertyNames(const EcmaVM *vm);\n\n Local<ArrayRef> GetOwnEnumerablePropertyNames(const EcmaVM *vm);\n\n Local<JSValueRef> GetPrototype(const EcmaVM *vm);\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 5, "score": 245945.11774948845 }, { "content": "class OperationResult;\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 6, "score": 245550.99559923058 }, { "content": "class PUBLIC_API NativePointerRef : public JSValueRef {\n\npublic:\n\n static Local<NativePointerRef> New(const EcmaVM *vm, void *nativePointer);\n\n static Local<NativePointerRef> New(const EcmaVM *vm, void *nativePointer, NativePointerCallback callBack,\n\n void *data);\n\n void *Value();\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 7, "score": 241226.68331959553 }, { "content": "class TaggedQueue : public TaggedArray {\n\npublic:\n\n static TaggedQueue *Cast(ObjectHeader *object)\n\n {\n\n return reinterpret_cast<TaggedQueue *>(object);\n\n }\n\n\n\n JSTaggedValue Pop(JSThread *thread);\n\n static TaggedQueue *Push(const JSThread *thread, const JSHandle<TaggedQueue> &queue,\n\n const JSHandle<JSTaggedValue> &value)\n\n {\n\n array_size_t capacity = queue->GetCapacity().GetArrayLength();\n\n if (capacity == 0) {\n\n // If there is no capacity, directly create a queue whose capacity is MIN_CAPACITY. Add elements.\n\n ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();\n\n JSHandle<TaggedQueue> newQueue = factory->NewTaggedQueue(MIN_CAPACITY);\n\n newQueue->Set(thread, 0, value.GetTaggedValue());\n\n newQueue->SetCapacity(thread, JSTaggedValue(MIN_CAPACITY));\n\n newQueue->SetStart(thread, JSTaggedValue(0));\n\n newQueue->SetEnd(thread, JSTaggedValue(1));\n", "file_path": "ecmascript/tagged_queue.h", "rank": 8, "score": 231125.38472036063 }, { "content": "class TaggedArray : public TaggedObject {\n\npublic:\n\n static constexpr array_size_t MAX_ARRAY_INDEX = std::numeric_limits<array_size_t>::max();\n\n static constexpr array_size_t MAX_END_UNUSED = 4;\n\n\n\n inline static TaggedArray *Cast(ObjectHeader *obj)\n\n {\n\n ASSERT(JSTaggedValue(obj).IsTaggedArray());\n\n return static_cast<TaggedArray *>(obj);\n\n }\n\n\n\n array_size_t GetLength() const;\n\n\n\n JSTaggedValue Get(array_size_t idx) const;\n\n\n\n array_size_t GetIdx(const JSTaggedValue &value) const;\n\n\n\n template<typename T>\n\n void Set(const JSThread *thread, array_size_t idx, const JSHandle<T> &value);\n\n\n", "file_path": "ecmascript/tagged_array.h", "rank": 9, "score": 231125.38472036063 }, { "content": "class PUBLIC_API RuntimeOption {\n\npublic:\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 10, "score": 227794.95866671266 }, { "content": "class JSArguments : public JSObject {\n\npublic:\n\n static constexpr int LENGTH_OF_INLINE_PROPERTIES = 4;\n\n static constexpr int LENGTH_INLINE_PROPERTY_INDEX = 0;\n\n static constexpr int ITERATOR_INLINE_PROPERTY_INDEX = 1;\n\n static constexpr int CALLER_INLINE_PROPERTY_INDEX = 2;\n\n static constexpr int CALLEE_INLINE_PROPERTY_INDEX = 3;\n\n\n\n static JSArguments *Cast(ObjectHeader *object)\n\n {\n\n return static_cast<JSArguments *>(object);\n\n }\n\n\n\n // 9.4.4.1 [[GetOwnProperty]] (P)\n\n static bool GetOwnProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key,\n\n PropertyDescriptor &desc);\n\n // 9.4.4.2 [[DefineOwnProperty]] (P, Desc)\n\n static bool DefineOwnProperty(JSThread *thread, const JSHandle<JSArguments> &args,\n\n const JSHandle<JSTaggedValue> &key, const PropertyDescriptor &desc);\n\n // 9.4.4.3 [[Get]] (P, Receiver)\n", "file_path": "ecmascript/js_arguments.h", "rank": 11, "score": 224414.69920590793 }, { "content": "class JSHClass : public TaggedObject {\n\npublic:\n\n static constexpr int TYPE_BITFIELD_NUM = 8;\n\n using ObjectTypeBits = BitField<JSType, 0, TYPE_BITFIELD_NUM>; // 7\n\n using CallableBit = ObjectTypeBits::NextFlag;\n\n using ConstrutorBit = CallableBit::NextFlag; // 9\n\n using BuiltinsCtorBit = ConstrutorBit::NextFlag; // 10\n\n using ExtensibleBit = BuiltinsCtorBit::NextFlag;\n\n using IsPrototypeBit = ExtensibleBit::NextFlag;\n\n using ElementRepresentationBits = IsPrototypeBit::NextField<Representation, 3>; // 3 means next 3 bit\n\n using DictionaryElementBits = ElementRepresentationBits::NextFlag; // 16\n\n using IsDictionaryBit = DictionaryElementBits::NextFlag;\n\n using IsStableElementsBit = IsDictionaryBit::NextFlag;\n\n using NumberOfUnusedInlinedPropsBits = IsStableElementsBit::NextField<uint32_t, 3>; // 3 means next 3 bit\n\n // the max value is 1024, need 11 bits\n\n using NumberOfUnusedNonInlinedPropsBits =\n\n NumberOfUnusedInlinedPropsBits::NextField<uint32_t, PropertyAttributes::OFFSET_BITFIELD_NUM>; // 31\n\n\n\n using HasConstructorBits = NumberOfUnusedNonInlinedPropsBits::NextFlag;\n\n using IsLiteralBit = HasConstructorBits::NextFlag;\n", "file_path": "ecmascript/js_hclass.h", "rank": 12, "score": 224073.67974138947 }, { "content": "class TaggedHashTable : public TaggedArray {\n\npublic:\n\n inline int EntriesCount() const;\n\n\n\n inline int HoleEntriesCount() const;\n\n\n\n inline int Size() const;\n\n\n\n inline void IncreaseEntries(const JSThread *thread);\n\n\n\n inline void IncreaseHoleEntriesCount(const JSThread *thread, int number = 1);\n\n\n\n inline static int ComputeHashTableSize(uint32_t atLeastSize);\n\n\n\n static Derived *GrowHashTable(const JSThread *thread, const JSHandle<Derived> &table, int numOfAddedElements = 1);\n\n\n\n static Derived *Create(const JSThread *thread, int numberOfElements);\n\n\n\n static Derived *Insert(const JSThread *thread, JSHandle<Derived> &table, const JSHandle<JSTaggedValue> &key,\n\n const JSHandle<JSTaggedValue> &value);\n", "file_path": "ecmascript/tagged_hash_table.h", "rank": 13, "score": 223092.79688976431 }, { "content": "class LoadICRuntime : public ICRuntime {\n\npublic:\n\n LoadICRuntime(JSThread *thread, JSHandle<ProfileTypeInfo> profileTypeInfo, uint32_t slotId, ICKind kind)\n\n : ICRuntime(thread, profileTypeInfo, slotId, kind)\n\n {\n\n }\n\n\n\n ~LoadICRuntime() = default;\n\n\n\n JSTaggedValue LoadMiss(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key);\n\n};\n\n\n", "file_path": "ecmascript/ic/ic_runtime.h", "rank": 14, "score": 222819.59045984782 }, { "content": "class StoreICRuntime : public ICRuntime {\n\npublic:\n\n StoreICRuntime(JSThread *thread, JSHandle<ProfileTypeInfo> profileTypeInfo, uint32_t slotId, ICKind kind)\n\n : ICRuntime(thread, profileTypeInfo, slotId, kind)\n\n {\n\n }\n\n\n\n ~StoreICRuntime() = default;\n\n\n\n JSTaggedValue StoreMiss(JSHandle<JSTaggedValue> receiver, JSHandle<JSTaggedValue> key,\n\n JSHandle<JSTaggedValue> value);\n\n};\n\n} // namespace panda::ecmascript\n\n\n\n#endif // ECMASCRIPT_IC_IC_RUNTIME_H\n", "file_path": "ecmascript/ic/ic_runtime.h", "rank": 15, "score": 222819.59045984782 }, { "content": "class JSRuntimeOptions : public RuntimeOptions {\n\npublic:\n\n explicit JSRuntimeOptions(const std::string &exe_path = \"\") : RuntimeOptions(exe_path) {}\n\n ~JSRuntimeOptions() = default;\n\n DEFAULT_COPY_SEMANTIC(JSRuntimeOptions);\n\n DEFAULT_MOVE_SEMANTIC(JSRuntimeOptions);\n\n\n\n void AddOptions(PandArgParser *parser)\n\n {\n\n RuntimeOptions::AddOptions(parser);\n\n parser->Add(&enable_ark_tools_);\n\n parser->Add(&enable_stub_aot_);\n\n parser->Add(&stub_module_file_);\n\n }\n\n\n\n bool IsEnableArkTools() const\n\n {\n\n return enable_ark_tools_.GetValue();\n\n }\n\n\n", "file_path": "ecmascript/js_runtime_options.h", "rank": 16, "score": 222819.59045984782 }, { "content": "class PUBLIC_API EcmaLanguageContext : public LanguageContextBase {\n\npublic:\n\n EcmaLanguageContext() = default;\n\n\n\n DEFAULT_COPY_SEMANTIC(EcmaLanguageContext);\n\n DEFAULT_MOVE_SEMANTIC(EcmaLanguageContext);\n\n\n\n ~EcmaLanguageContext() override = default;\n\n\n\n panda_file::SourceLang GetLanguage() const override\n\n {\n\n return panda_file::SourceLang::ECMASCRIPT;\n\n }\n\n\n\n std::pair<Method *, uint32_t> GetCatchMethodAndOffset(Method *method, ManagedThread *thread) const override;\n\n\n\n PandaVM *CreateVM(Runtime *runtime, const RuntimeOptions &options) const override;\n\n\n\n std::unique_ptr<ClassLinkerExtension> CreateClassLinkerExtension() const override;\n\n\n", "file_path": "ecmascript/ecma_language_context.h", "rank": 17, "score": 222360.52823467238 }, { "content": "class PUBLIC_API JSValueRef {\n\npublic:\n\n static Local<PrimitiveRef> Undefined(const EcmaVM *vm);\n\n static Local<PrimitiveRef> Null(const EcmaVM *vm);\n\n static Local<PrimitiveRef> True(const EcmaVM *vm);\n\n static Local<PrimitiveRef> False(const EcmaVM *vm);\n\n static Local<JSValueRef> Exception(const EcmaVM *vm);\n\n\n\n bool BooleaValue();\n\n int64_t IntegerValue(const EcmaVM *vm);\n\n uint32_t Uint32Value(const EcmaVM *vm);\n\n int32_t Int32Value(const EcmaVM *vm);\n\n\n\n Local<NumberRef> ToNumber(const EcmaVM *vm);\n\n Local<BooleanRef> ToBoolean(const EcmaVM *vm);\n\n Local<StringRef> ToString(const EcmaVM *vm);\n\n Local<ObjectRef> ToObject(const EcmaVM *vm);\n\n Local<NativePointerRef> ToNativePointer(const EcmaVM *vm);\n\n\n\n bool IsUndefined();\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 18, "score": 221923.67560704393 }, { "content": "class Record : public TaggedObject {\n\npublic:\n\n static constexpr size_t SIZE = TaggedObjectSize();\n\n};\n\n} // namespace panda::ecmascript\n\n#endif // ECMASCRIPT_RECORD_H", "file_path": "ecmascript/record.h", "rank": 19, "score": 219969.72445138602 }, { "content": "class TaggedObject : public ObjectHeader {\n\npublic:\n\n static TaggedObject *Cast(ObjectHeader *header)\n\n {\n\n return static_cast<TaggedObject *>(header);\n\n }\n\n\n\n void SetClass(JSHandle<JSHClass> hclass);\n\n\n\n void SynchronizedSetClass(JSHClass *hclass);\n\n JSHClass *SynchronizedGetClass() const;\n\n void SetClass(JSHClass *hclass);\n\n JSHClass *GetClass() const;\n\n\n\n size_t GetObjectSize();\n\n\n\n // Size of object header\n\n static constexpr int TaggedObjectSize()\n\n {\n\n return sizeof(TaggedObject);\n\n }\n\n\n\n JSThread* GetJSThread() const;\n\n};\n\nstatic_assert(TaggedObject::TaggedObjectSize() == sizeof(MarkWordType));\n\n} // namespace panda::ecmascript\n\n\n\n#endif // ECMASCRIPT_TAGGED_OBJECT_HEADER_H\n", "file_path": "ecmascript/mem/tagged_object.h", "rank": 20, "score": 219876.91060021054 }, { "content": "class EnableReturns : public PtBaseReturns {\n\npublic:\n\n explicit EnableReturns(UniqueDebuggerId id) : debuggerId_(std::move(id)) {}\n\n ~EnableReturns() override = default;\n\n\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n EnableReturns() = default;\n\n NO_COPY_SEMANTIC(EnableReturns);\n\n NO_MOVE_SEMANTIC(EnableReturns);\n\n\n\n UniqueDebuggerId debuggerId_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 21, "score": 219581.4629924281 }, { "content": "class RestartFrameReturns : public PtBaseReturns {\n\npublic:\n\n explicit RestartFrameReturns(CVector<std::unique_ptr<CallFrame>> callFrames) : callFrames_(std::move(callFrames))\n\n {}\n\n ~RestartFrameReturns() override = default;\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n RestartFrameReturns() = default;\n\n NO_COPY_SEMANTIC(RestartFrameReturns);\n\n NO_MOVE_SEMANTIC(RestartFrameReturns);\n\n\n\n CVector<std::unique_ptr<CallFrame>> callFrames_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 22, "score": 216057.6590754807 }, { "content": "class SearchInContentReturns : public PtBaseReturns {\n\npublic:\n\n explicit SearchInContentReturns(CVector<std::unique_ptr<SearchMatch>> result) : result_(std::move(result))\n\n {}\n\n ~SearchInContentReturns() override = default;\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n SearchInContentReturns() = default;\n\n NO_COPY_SEMANTIC(SearchInContentReturns);\n\n NO_MOVE_SEMANTIC(SearchInContentReturns);\n\n\n\n CVector<std::unique_ptr<SearchMatch>> result_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 23, "score": 216057.6590754807 }, { "content": "class GetPropertiesReturns : public PtBaseReturns {\n\npublic:\n\n explicit GetPropertiesReturns(CVector<std::unique_ptr<PropertyDescriptor>> descriptor,\n\n std::optional<CVector<std::unique_ptr<InternalPropertyDescriptor>>> internalDescripties = std::nullopt,\n\n std::optional<CVector<std::unique_ptr<PrivatePropertyDescriptor>>> privateProperties = std::nullopt,\n\n std::optional<std::unique_ptr<ExceptionDetails>> exceptionDetails = std::nullopt)\n\n : result_(std::move(descriptor)),\n\n internalPropertyDescripties_(std::move(internalDescripties)),\n\n privateProperties_(std::move(privateProperties)),\n\n exceptionDetails_(std::move(exceptionDetails))\n\n {}\n\n ~GetPropertiesReturns() override = default;\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n GetPropertiesReturns() = default;\n\n NO_COPY_SEMANTIC(GetPropertiesReturns);\n\n NO_MOVE_SEMANTIC(GetPropertiesReturns);\n\n\n\n CVector<std::unique_ptr<PropertyDescriptor>> result_ {};\n\n std::optional<CVector<std::unique_ptr<InternalPropertyDescriptor>>> internalPropertyDescripties_ {};\n\n std::optional<CVector<std::unique_ptr<PrivatePropertyDescriptor>>> privateProperties_ {};\n\n std::optional<std::unique_ptr<ExceptionDetails>> exceptionDetails_ {};\n\n};\n\n} // namespace panda::tooling::ecmascript\n\n#endif", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 24, "score": 216057.6590754807 }, { "content": "class SetBreakpointReturns : public PtBaseReturns {\n\npublic:\n\n explicit SetBreakpointReturns(CString id, std::unique_ptr<Location> location)\n\n : breakpointId_(std::move(id)), location_(std::move(location))\n\n {}\n\n ~SetBreakpointReturns() override = default;\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n SetBreakpointReturns() = default;\n\n NO_COPY_SEMANTIC(SetBreakpointReturns);\n\n NO_MOVE_SEMANTIC(SetBreakpointReturns);\n\n CString breakpointId_ {};\n\n std::unique_ptr<Location> location_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 25, "score": 216057.6590754807 }, { "content": "class ConstantPool : public TaggedArray {\n\npublic:\n\n static ConstantPool *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsTaggedArray());\n\n return static_cast<ConstantPool *>(object);\n\n }\n\n\n\n inline JSTaggedValue GetObjectFromCache(uint32_t index) const;\n\n DECL_DUMP()\n\n};\n\n} // namespace ecmascript\n\n} // namespace panda\n\n#endif // ECMASCRIPT_CLASS_LINKER_PROGRAM_H\n", "file_path": "ecmascript/class_linker/program_object.h", "rank": 26, "score": 215599.8081271341 }, { "content": "class SetScriptSourceReturns : public PtBaseReturns {\n\npublic:\n\n explicit SetScriptSourceReturns(std::optional<CVector<std::unique_ptr<CallFrame>>> callFrames = std::nullopt,\n\n std::optional<bool> stackChanged = std::nullopt,\n\n std::optional<std::unique_ptr<ExceptionDetails>> exceptionDetails = std::nullopt)\n\n : callFrames_(std::move(callFrames)),\n\n stackChanged_(stackChanged),\n\n exceptionDetails_(std::move(exceptionDetails))\n\n {}\n\n ~SetScriptSourceReturns() override = default;\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n SetScriptSourceReturns() = default;\n\n NO_COPY_SEMANTIC(SetScriptSourceReturns);\n\n NO_MOVE_SEMANTIC(SetScriptSourceReturns);\n\n\n\n std::optional<CVector<std::unique_ptr<CallFrame>>> callFrames_ {};\n\n std::optional<bool> stackChanged_ {};\n\n std::optional<std::unique_ptr<ExceptionDetails>> exceptionDetails_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 27, "score": 212704.5145577406 }, { "content": "class SetInstrumentationBreakpointReturns : public PtBaseReturns {\n\npublic:\n\n explicit SetInstrumentationBreakpointReturns(CString id) : breakpointId_(std::move(id))\n\n {}\n\n ~SetInstrumentationBreakpointReturns() override = default;\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n SetInstrumentationBreakpointReturns() = default;\n\n NO_COPY_SEMANTIC(SetInstrumentationBreakpointReturns);\n\n NO_MOVE_SEMANTIC(SetInstrumentationBreakpointReturns);\n\n\n\n CString breakpointId_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 28, "score": 212704.5145577406 }, { "content": "class GetPossibleBreakpointsReturns : public PtBaseReturns {\n\npublic:\n\n explicit GetPossibleBreakpointsReturns(CVector<std::unique_ptr<BreakLocation>> locations)\n\n : locations_(std::move(locations))\n\n {}\n\n ~GetPossibleBreakpointsReturns() override = default;\n\n\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n GetPossibleBreakpointsReturns() = default;\n\n NO_COPY_SEMANTIC(GetPossibleBreakpointsReturns);\n\n NO_MOVE_SEMANTIC(GetPossibleBreakpointsReturns);\n\n\n\n CVector<std::unique_ptr<BreakLocation>> locations_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 29, "score": 212704.5145577406 }, { "content": "class GetScriptSourceReturns : public PtBaseReturns {\n\npublic:\n\n explicit GetScriptSourceReturns(CString scriptSource, std::optional<CString> bytecode = std::nullopt)\n\n : scriptSource_(std::move(scriptSource)), bytecode_(std::move(bytecode))\n\n {}\n\n ~GetScriptSourceReturns() override = default;\n\n\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n GetScriptSourceReturns() = default;\n\n NO_COPY_SEMANTIC(GetScriptSourceReturns);\n\n NO_MOVE_SEMANTIC(GetScriptSourceReturns);\n\n\n\n CString scriptSource_ {};\n\n std::optional<CString> bytecode_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 30, "score": 212704.5145577406 }, { "content": "class EvaluateOnCallFrameReturns : public PtBaseReturns {\n\npublic:\n\n explicit EvaluateOnCallFrameReturns(std::unique_ptr<RemoteObject> result,\n\n std::optional<std::unique_ptr<ExceptionDetails>> exceptionDetails = std::nullopt)\n\n : result_(std::move(result)), exceptionDetails_(std::move(exceptionDetails))\n\n {}\n\n ~EvaluateOnCallFrameReturns() override = default;\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n EvaluateOnCallFrameReturns() = default;\n\n NO_COPY_SEMANTIC(EvaluateOnCallFrameReturns);\n\n NO_MOVE_SEMANTIC(EvaluateOnCallFrameReturns);\n\n\n\n std::unique_ptr<RemoteObject> result_ {};\n\n std::optional<std::unique_ptr<ExceptionDetails>> exceptionDetails_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 31, "score": 212704.5145577406 }, { "content": "class SetBreakpointByUrlReturns : public PtBaseReturns {\n\npublic:\n\n explicit SetBreakpointByUrlReturns(CString id, CVector<std::unique_ptr<Location>> locations)\n\n : id_(std::move(id)), locations_(std::move(locations))\n\n {}\n\n ~SetBreakpointByUrlReturns() override = default;\n\n\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;\n\n\n\nprivate:\n\n SetBreakpointByUrlReturns() = default;\n\n NO_COPY_SEMANTIC(SetBreakpointByUrlReturns);\n\n NO_MOVE_SEMANTIC(SetBreakpointByUrlReturns);\n\n\n\n CString id_ {};\n\n CVector<std::unique_ptr<Location>> locations_ {};\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 32, "score": 212704.5145577406 }, { "content": " enum class PUBLIC_API LOG_LEVEL : uint8_t {\n\n DEBUG = 3,\n\n INFO = 4,\n\n WARN = 5,\n\n ERROR = 6,\n\n FATAL = 7,\n\n };\n\n\n\n void SetGcType(GC_TYPE type)\n\n {\n\n gcType_ = type;\n\n }\n\n\n\n void SetGcPoolSize(uint32_t size)\n\n {\n\n gcPoolSize_ = size;\n\n }\n\n\n\n void SetLogLevel(LOG_LEVEL logLevel)\n\n {\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 33, "score": 210567.2400885294 }, { "content": "class GlobalEnv : public TaggedObject {\n\npublic:\n\n JSTaggedValue GetGlobalObject() const\n\n {\n\n return GetJSGlobalObject().GetTaggedValue();\n\n }\n\n\n\n void InitGlobalObject();\n\n\n\n static GlobalEnv *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsJSGlobalEnv());\n\n return reinterpret_cast<GlobalEnv *>(object);\n\n }\n\n\n\n JSHandle<JSTaggedValue> GetSymbol(JSThread *thread, const JSHandle<JSTaggedValue> &string);\n\n JSHandle<JSTaggedValue> GetStringFunctionByName(JSThread *thread, const char *name);\n\n JSHandle<JSTaggedValue> GetStringPrototypeFunctionByName(JSThread *thread, const char *name);\n\n\n\n enum Field {\n", "file_path": "ecmascript/global_env.h", "rank": 34, "score": 209837.68617925892 }, { "content": "class FreeObject : public TaggedObject {\n\npublic:\n\n static FreeObject *Cast(uintptr_t object)\n\n {\n\n return reinterpret_cast<FreeObject *>(object);\n\n }\n\n static FreeObject *FillFreeObject(EcmaVM *vm, uintptr_t address, size_t size);\n\n\n\n inline bool IsEmpty() const\n\n {\n\n return Available() == 0;\n\n }\n\n\n\n inline uintptr_t GetBegin() const\n\n {\n\n return reinterpret_cast<uintptr_t>(this);\n\n }\n\n\n\n inline uintptr_t GetEnd() const\n\n {\n", "file_path": "ecmascript/free_object.h", "rank": 35, "score": 209837.68617925892 }, { "content": "class LexicalEnv : public TaggedArray {\n\npublic:\n\n static constexpr array_size_t PARENT_ENV_INDEX = 0;\n\n static constexpr array_size_t RESERVED_ENV_LENGTH = 1;\n\n\n\n static LexicalEnv *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsTaggedArray());\n\n return static_cast<LexicalEnv *>(object);\n\n }\n\n\n\n static size_t ComputeSize(uint32_t numSlots)\n\n {\n\n return TaggedArray::ComputeSize(JSTaggedValue::TaggedTypeSize(), numSlots + RESERVED_ENV_LENGTH);\n\n }\n\n\n\n void SetParentEnv(JSThread *thread, JSTaggedValue value)\n\n {\n\n Set(thread, PARENT_ENV_INDEX, value);\n\n }\n", "file_path": "ecmascript/lexical_env.h", "rank": 36, "score": 209837.68617925892 }, { "content": "class EcmaString : public TaggedObject {\n\npublic:\n\n static EcmaString *Cast(ObjectHeader *object);\n\n static const EcmaString *ConstCast(const TaggedObject *object);\n\n\n\n static EcmaString *CreateEmptyString(const EcmaVM *vm);\n\n static EcmaString *CreateFromUtf8(const uint8_t *utf8Data, uint32_t utf8Len, const EcmaVM *vm, bool canBeCompress);\n\n static EcmaString *CreateFromUtf16(const uint16_t *utf16Data, uint32_t utf16Len, const EcmaVM *vm,\n\n bool canBeCompress);\n\n static EcmaString *Concat(const JSHandle<EcmaString> &str1Handle, const JSHandle<EcmaString> &str2Handle,\n\n const EcmaVM *vm);\n\n static EcmaString *FastSubString(const JSHandle<EcmaString> &src, uint32_t start, uint32_t utf16Len,\n\n const EcmaVM *vm);\n\n\n\n static constexpr uint32_t STRING_COMPRESSED_BIT = 0x1;\n\n static constexpr uint32_t STRING_INTERN_BIT = 0x2;\n\n enum CompressedStatus {\n\n STRING_COMPRESSED,\n\n STRING_UNCOMPRESSED,\n\n };\n", "file_path": "ecmascript/ecma_string.h", "rank": 37, "score": 209837.68617925892 }, { "content": "class WeakVector : public TaggedArray {\n\npublic:\n\n static WeakVector *Cast(ObjectHeader *object)\n\n {\n\n return static_cast<WeakVector *>(object);\n\n }\n\n\n\n static constexpr array_size_t DEFALUT_CAPACITY = 4;\n\n static JSHandle<WeakVector> Create(const JSThread *thread, array_size_t capacity = DEFALUT_CAPACITY);\n\n static JSHandle<WeakVector> Grow(const JSThread *thread, const JSHandle<WeakVector> &old, array_size_t newCapacity);\n\n array_size_t PushBack(const JSThread *thread, JSTaggedValue value);\n\n // just set index value to Hole\n\n bool Delete(const JSThread *thread, array_size_t index);\n\n\n\n inline array_size_t GetEnd() const;\n\n\n\n inline bool Full() const;\n\n\n\n inline bool Empty() const;\n\n\n", "file_path": "ecmascript/weak_vector.h", "rank": 38, "score": 209837.68617925892 }, { "content": "class JSSymbol : public TaggedObject {\n\npublic:\n\n static constexpr uint64_t IS_PRIVATE = 1U << 0U;\n\n static constexpr uint64_t IS_WELL_KNOWN_SYMBOL = 1U << 1U;\n\n static constexpr uint64_t IS_IN_PUBLIC_SYMBOL_TABLE = 1U << 2U;\n\n static constexpr uint64_t IS_INTERESTING_SYMBOL = 1U << 3U;\n\n static constexpr uint64_t IS_PRIVATE_NAME = 1U << 4U;\n\n static constexpr uint64_t IS_PRIVATE_BRAND = 1U << 5U;\n\n\n\n static constexpr int SYMBOL_HAS_INSTANCE_TYPE = 0;\n\n static constexpr int SYMBOL_TO_PRIMITIVE_TYPE = 1;\n\n static constexpr int SYMBOL_DEFAULT_TYPE = 2;\n\n\n\n static constexpr const uint32_t LINEAR_X = 1103515245U;\n\n static constexpr const uint32_t LINEAR_Y = 12345U;\n\n static constexpr const uint32_t LINEAR_SEED = 987654321U;\n\n\n\npublic:\n\n static JSSymbol *Cast(ObjectHeader *object)\n\n {\n", "file_path": "ecmascript/js_symbol.h", "rank": 39, "score": 209837.68617925892 }, { "content": "class ECMAObject : public TaggedObject {\n\npublic:\n\n static ECMAObject *Cast(ObjectHeader *object);\n\n void SetBuiltinsCtorMode();\n\n bool IsBuiltinsConstructor() const;\n\n void SetCallable(bool flag);\n\n bool IsCallable() const;\n\n JSMethod *GetCallTarget() const;\n\n\n\n static constexpr size_t HASH_OFFSET = TaggedObjectSize();\n\n static constexpr size_t SIZE = HASH_OFFSET + sizeof(JSTaggedType);\n\n\n\n void SetHash(int32_t hash);\n\n int32_t GetHash() const;\n\n void InitializeHash()\n\n {\n\n Barriers::SetDynPrimitive<JSTaggedType>(this, ECMAObject::HASH_OFFSET, JSTaggedValue(0).GetRawData());\n\n }\n\n\n\n void* GetNativePointerField(int32_t index) const;\n", "file_path": "ecmascript/js_object.h", "rank": 40, "score": 209837.68617925892 }, { "content": "class PtBaseReturns : public PtBaseTypes {\n\npublic:\n\n PtBaseReturns() = default;\n\n ~PtBaseReturns() override = default;\n\n\n\n Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override\n\n {\n\n return NewObject(ecmaVm);\n\n }\n\n\n\nprivate:\n\n NO_COPY_SEMANTIC(PtBaseReturns);\n\n NO_MOVE_SEMANTIC(PtBaseReturns);\n\n};\n\n\n", "file_path": "ecmascript/tooling/base/pt_returns.h", "rank": 41, "score": 208342.0856210505 }, { "content": "class TaggedArray;\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 42, "score": 207092.1077043785 }, { "content": "class OrderTaggedHashTable : public TaggedHashTable<Derived> {\n\npublic:\n\n using HashTableT = TaggedHashTable<Derived>;\n\n static Derived *Cast(TaggedObject *object)\n\n {\n\n return reinterpret_cast<Derived *>(object);\n\n }\n\n // Attempt to shrink the table after deletion of key.\n\n static Derived *Shrink(const JSThread *thread, const JSHandle<Derived> &table)\n\n {\n\n int index = table->GetNextEnumerationIndex();\n\n Derived *newTable = HashTableT::Shrink(thread, table, 0);\n\n newTable->SetNextEnumerationIndex(thread, index);\n\n return newTable;\n\n }\n\n\n\n static Derived *Create(const JSThread *thread, int numberOfElements = DEFAULT_ELEMENTS_NUMBER);\n\n static Derived *PutIfAbsent(const JSThread *thread, const JSHandle<Derived> &table,\n\n const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value,\n\n const PropertyAttributes &metaData);\n", "file_path": "ecmascript/tagged_hash_table.h", "rank": 43, "score": 207075.4460261147 }, { "content": "class PUBLIC_API DateRef : public ObjectRef {\n\npublic:\n\n Local<StringRef> ToString(const EcmaVM *vm);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 44, "score": 206482.49566934427 }, { "content": "class PUBLIC_API MapRef : public ObjectRef {\n\npublic:\n\n int32_t GetSize();\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 45, "score": 206482.49566934427 }, { "content": "class PUBLIC_API BooleanRef : public PrimitiveRef {\n\npublic:\n\n static Local<BooleanRef> New(const EcmaVM *vm, bool input);\n\n bool Value();\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 46, "score": 206482.49566934427 }, { "content": "class PUBLIC_API FunctionRef : public ObjectRef {\n\npublic:\n\n static Local<FunctionRef> New(EcmaVM *vm, FunctionCallback nativeFunc, void *data);\n\n static Local<FunctionRef> New(EcmaVM *vm, FunctionCallback nativeFunc, Deleter deleter, void *data);\n\n static Local<FunctionRef> NewWithProperty(EcmaVM *vm, FunctionCallback nativeFunc, void *data);\n\n static Local<FunctionRef> NewClassFunction(EcmaVM *vm, FunctionCallbackWithNewTarget nativeFunc, Deleter deleter,\n\n void *data);\n\n Local<JSValueRef> Call(const EcmaVM *vm, Local<JSValueRef> thisObj, const Local<JSValueRef> argv[],\n\n int32_t length);\n\n Local<JSValueRef> Constructor(const EcmaVM *vm, const Local<JSValueRef> argv[], int32_t length);\n\n Local<JSValueRef> GetFunctionPrototype(const EcmaVM *vm);\n\n void SetName(const EcmaVM *vm, Local<StringRef> name);\n\n Local<StringRef> GetName(const EcmaVM *vm);\n\n bool IsNative(const EcmaVM *vm);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 47, "score": 206482.49566934427 }, { "content": "class PUBLIC_API SymbolRef : public PrimitiveRef {\n\npublic:\n\n static Local<SymbolRef> New(const EcmaVM *vm, Local<StringRef> description);\n\n Local<StringRef> GetDescription(const EcmaVM *vm);\n\n};\n\n\n\nusing NativePointerCallback = void (*)(void* value, void* hint);\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 48, "score": 206482.49566934427 }, { "content": "class PUBLIC_API SetRef : public ObjectRef {\n\npublic:\n\n int32_t GetSize();\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 49, "score": 206482.49566934427 }, { "content": "class PUBLIC_API NumberRef : public PrimitiveRef {\n\npublic:\n\n static Local<NumberRef> New(const EcmaVM *vm, double input);\n\n double Value();\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 50, "score": 206482.49566934427 }, { "content": "class PUBLIC_API PromiseRef : public ObjectRef {\n\npublic:\n\n Local<PromiseRef> Catch(const EcmaVM *vm, Local<FunctionRef> handler);\n\n Local<PromiseRef> Then(const EcmaVM *vm, Local<FunctionRef> handler);\n\n Local<PromiseRef> Then(const EcmaVM *vm, Local<FunctionRef> onFulfilled, Local<FunctionRef> onRejected);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 51, "score": 206482.49566934427 }, { "content": "class PUBLIC_API IntegerRef : public PrimitiveRef {\n\npublic:\n\n static Local<IntegerRef> New(const EcmaVM *vm, int input);\n\n static Local<IntegerRef> NewFromUnsigned(const EcmaVM *vm, unsigned int input);\n\n int Value();\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 52, "score": 206482.49566934427 }, { "content": "class PUBLIC_API StringRef : public PrimitiveRef {\n\npublic:\n\n static inline StringRef *Cast(JSValueRef *value)\n\n {\n\n // check\n\n return static_cast<StringRef *>(value);\n\n }\n\n static Local<StringRef> NewFromUtf8(const EcmaVM *vm, const char *utf8, int length = -1);\n\n std::string ToString();\n\n int32_t Length();\n\n int32_t Utf8Length();\n\n int WriteUtf8(char *buffer, int length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 53, "score": 206482.49566934427 }, { "content": "class PUBLIC_API ArrayRef : public ObjectRef {\n\npublic:\n\n static Local<ArrayRef> New(const EcmaVM *vm, int32_t length = 0);\n\n int32_t Length(const EcmaVM *vm);\n\n static bool SetValueAt(const EcmaVM *vm, Local<JSValueRef> obj, uint32_t index, Local<JSValueRef> value);\n\n static Local<JSValueRef> GetValueAt(const EcmaVM *vm, Local<JSValueRef> obj, uint32_t index);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 54, "score": 206482.49566934427 }, { "content": "class FunctionCache : public TaggedArray {\n\npublic:\n\n static const array_size_t MAX_FUNC_CACHE_INDEX = std::numeric_limits<uint16_t>::max();\n\n static constexpr uint16_t INVALID_SLOT_INDEX = 0xFF;\n\n static constexpr array_size_t CACHE_MAX_LEN = 8;\n\n static constexpr array_size_t POLY_DEFAULT_LEN = 4;\n\n\n\n static FunctionCache *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsTaggedArray());\n\n return static_cast<FunctionCache *>(object);\n\n }\n\n\n\n static inline FunctionCache *GetCurrent(JSThread *thread)\n\n {\n\n JSTaggedValue funcValue = InterpretedFrameHandler(thread).GetFunction();\n\n JSFunction *func = JSFunction::Cast(funcValue.GetTaggedObject());\n\n return FunctionCache::Cast(func->GetFunctionCache().GetTaggedObject());\n\n }\n\n\n", "file_path": "ecmascript/ic/function_cache.h", "rank": 55, "score": 205250.7912001594 }, { "content": "class MachineCode : public TaggedObject {\n\npublic:\n\n NO_COPY_SEMANTIC(MachineCode);\n\n NO_MOVE_SEMANTIC(MachineCode);\n\n static MachineCode *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsMachineCodeObject());\n\n return static_cast<MachineCode *>(object);\n\n }\n\n\n\n static constexpr size_t INS_SIZE_OFFSET = TaggedObjectSize();\n\n ACCESSORS(InstructionSizeInBytes, INS_SIZE_OFFSET, DATA_OFFSET);\n\n static constexpr size_t SIZE = DATA_OFFSET;\n\n\n\n DECL_DUMP()\n\n\n\n uintptr_t GetDataOffsetAddress(void)\n\n {\n\n return reinterpret_cast<uintptr_t>(this) + DATA_OFFSET;\n\n }\n", "file_path": "ecmascript/mem/machine_code.h", "rank": 56, "score": 205250.7912001594 }, { "content": "class PrototypeHandler : public TaggedObject {\n\npublic:\n\n static PrototypeHandler *Cast(TaggedObject *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsPrototypeHandler());\n\n return static_cast<PrototypeHandler *>(object);\n\n }\n\n\n\n static inline JSHandle<JSTaggedValue> LoadPrototype(const JSThread *thread, const ObjectOperator &op,\n\n const JSHandle<JSHClass> &hclass);\n\n static inline JSHandle<JSTaggedValue> StorePrototype(const JSThread *thread, const ObjectOperator &op,\n\n const JSHandle<JSHClass> &hclass);\n\n\n\n static constexpr size_t HANDLER_INFO_OFFSET = TaggedObjectSize();\n\n\n\n ACCESSORS(HandlerInfo, HANDLER_INFO_OFFSET, PROTO_CELL_OFFSET)\n\n\n\n ACCESSORS(ProtoCell, PROTO_CELL_OFFSET, HOLDER_OFFSET)\n\n\n\n ACCESSORS(Holder, HOLDER_OFFSET, SIZE)\n\n\n\n DECL_VISIT_OBJECT(HANDLER_INFO_OFFSET, SIZE)\n\n DECL_DUMP()\n\n};\n\n} // namespace panda::ecmascript\n\n#endif // ECMASCRIPT_IC_IC_HANDLER_H\n", "file_path": "ecmascript/ic/ic_handler.h", "rank": 57, "score": 205250.7912001594 }, { "content": "class TransitionHandler : public TaggedObject {\n\npublic:\n\n static TransitionHandler *Cast(TaggedObject *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsTransitionHandler());\n\n return static_cast<TransitionHandler *>(object);\n\n }\n\n\n\n static inline JSHandle<JSTaggedValue> StoreTransition(const JSThread *thread, const ObjectOperator &op);\n\n\n\n static constexpr size_t HANDLER_INFO_OFFSET = TaggedObjectSize();\n\n ACCESSORS(HandlerInfo, HANDLER_INFO_OFFSET, TRANSITION_HCLASS_OFFSET)\n\n\n\n ACCESSORS(TransitionHClass, TRANSITION_HCLASS_OFFSET, SIZE)\n\n\n\n DECL_VISIT_OBJECT(HANDLER_INFO_OFFSET, SIZE)\n\n DECL_DUMP()\n\n};\n\n\n", "file_path": "ecmascript/ic/ic_handler.h", "rank": 58, "score": 205250.7912001594 }, { "content": "class PropertyBox : public TaggedObject {\n\npublic:\n\n static PropertyBox *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsPropertyBox());\n\n return static_cast<PropertyBox *>(object);\n\n }\n\n\n\n void Clear(const JSThread *thread);\n\n\n\n inline bool IsInvalid() const\n\n {\n\n return GetValue().IsHole();\n\n }\n\n\n\n static constexpr size_t VALUE_OFFSET = TaggedObjectSize();\n\n ACCESSORS(Value, VALUE_OFFSET, SIZE);\n\n\n\n DECL_VISIT_OBJECT(VALUE_OFFSET, SIZE)\n\n DECL_DUMP()\n\n};\n\n} // namespace ecmascript\n\n} // namespace panda\n\n\n\n#endif", "file_path": "ecmascript/ic/property_box.h", "rank": 59, "score": 205250.7912001594 }, { "content": "class JsArgumentsTest : public testing::Test {\n\npublic:\n\n static void SetUpTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"SetUpTestCase\";\n\n }\n\n\n\n static void TearDownTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"TearDownCase\";\n\n }\n\n\n\n void SetUp() override\n\n {\n\n TestHelper::CreateEcmaVMWithScope(instance, thread, scope);\n\n }\n\n\n\n void TearDown() override\n\n {\n\n TestHelper::DestroyEcmaVMWithScope(instance, scope);\n", "file_path": "ecmascript/tests/js_arguments_test.cpp", "rank": 60, "score": 202901.9062293449 }, { "content": "class PUBLIC_API DataViewRef : public ObjectRef {\n\npublic:\n\n static Local<DataViewRef> New(const EcmaVM *vm, Local<ArrayBufferRef> arrayBuffer, int32_t byteOffset,\n\n int32_t byteLength);\n\n int32_t ByteLength();\n\n int32_t ByteOffset();\n\n Local<ArrayBufferRef> GetArrayBuffer(const EcmaVM *vm);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 61, "score": 202785.87699963385 }, { "content": "class PUBLIC_API RegExpRef : public ObjectRef {\n\npublic:\n\n Local<StringRef> GetOriginalSource(const EcmaVM *vm);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 62, "score": 202785.87699963385 }, { "content": "class PUBLIC_API PromiseCapabilityRef : public ObjectRef {\n\npublic:\n\n static Local<PromiseCapabilityRef> New(const EcmaVM *vm);\n\n bool Resolve(const EcmaVM *vm, Local<JSValueRef> value);\n\n bool Reject(const EcmaVM *vm, Local<JSValueRef> reason);\n\n Local<PromiseRef> GetPromise(const EcmaVM *vm);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 63, "score": 202785.87699963385 }, { "content": "class PUBLIC_API TypedArrayRef : public ObjectRef {\n\npublic:\n\n int32_t ByteLength(const EcmaVM *vm);\n\n int32_t ByteOffset(const EcmaVM *vm);\n\n int32_t ArrayLength(const EcmaVM *vm);\n\n Local<ArrayBufferRef> GetArrayBuffer(const EcmaVM *vm);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 64, "score": 202785.87699963385 }, { "content": "class PUBLIC_API ArrayBufferRef : public ObjectRef {\n\npublic:\n\n static Local<ArrayBufferRef> New(const EcmaVM *vm, int32_t length);\n\n static Local<ArrayBufferRef> New(const EcmaVM *vm, void *buffer, int32_t length, const Deleter &deleter,\n\n void *data);\n\n\n\n int32_t ByteLength(const EcmaVM *vm);\n\n void *GetBuffer();\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 65, "score": 202785.87699963385 }, { "content": "class NumberDictionary : public OrderTaggedHashTable<NumberDictionary> {\n\npublic:\n\n using OrderHashTableT = OrderTaggedHashTable<NumberDictionary>;\n\n inline static int GetKeyIndex(int entry)\n\n {\n\n return OrderHashTableT::TABLE_HEADER_SIZE + entry * GetEntrySize() + ENTRY_KEY_INDEX;\n\n }\n\n inline static int GetValueIndex(int entry)\n\n {\n\n return OrderHashTableT::TABLE_HEADER_SIZE + entry * GetEntrySize() + ENTRY_VALUE_INDEX;\n\n }\n\n inline static int GetEntryIndex(int entry)\n\n {\n\n return OrderHashTableT::TABLE_HEADER_SIZE + entry * GetEntrySize();\n\n }\n\n inline static int GetEntrySize()\n\n {\n\n return ENTRY_SIZE;\n\n }\n\n static int Hash(const JSTaggedValue &key);\n", "file_path": "ecmascript/tagged_dictionary.h", "rank": 66, "score": 202732.62080040976 }, { "content": "class NameDictionary : public OrderTaggedHashTable<NameDictionary> {\n\npublic:\n\n using OrderHashTableT = OrderTaggedHashTable<NameDictionary>;\n\n inline static int GetKeyIndex(int entry)\n\n {\n\n return OrderHashTableT::TABLE_HEADER_SIZE + entry * GetEntrySize() + ENTRY_KEY_INDEX;\n\n }\n\n inline static int GetValueIndex(int entry)\n\n {\n\n return OrderHashTableT::TABLE_HEADER_SIZE + entry * GetEntrySize() + ENTRY_VALUE_INDEX;\n\n }\n\n inline static int GetEntryIndex(int entry)\n\n {\n\n return OrderHashTableT::TABLE_HEADER_SIZE + entry * GetEntrySize();\n\n }\n\n inline static int GetEntrySize()\n\n {\n\n return ENTRY_SIZE;\n\n }\n\n static int Hash(const JSTaggedValue &key);\n", "file_path": "ecmascript/tagged_dictionary.h", "rank": 67, "score": 202732.62080040976 }, { "content": "class JSTaggedNumber;\n\ntemplate<typename T>\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 68, "score": 202183.20764177537 }, { "content": "class SetPropertyByValueStub : public Stub {\n\npublic:\n\n // 4 : 4 means argument counts\n\n explicit SetPropertyByValueStub(Circuit *circuit) : Stub(\"FastSetPropertyByValue\", 4, circuit)\n\n {\n\n circuit->SetFrameType(panda::ecmascript::FrameType::OPTIMIZED_ENTRY_FRAME);\n\n }\n\n ~SetPropertyByValueStub() = default;\n\n NO_MOVE_SEMANTIC(SetPropertyByValueStub);\n\n NO_COPY_SEMANTIC(SetPropertyByValueStub);\n\n void GenerateCircuit() override;\n\n};\n\n\n", "file_path": "ecmascript/compiler/fast_stub.h", "rank": 69, "score": 201001.14426931133 }, { "content": "class GetPropertyByValueStub : public Stub {\n\npublic:\n\n // 3 : 3 means argument counts\n\n explicit GetPropertyByValueStub(Circuit *circuit) : Stub(\"FastGetPropertyByValue\", 3, circuit)\n\n {\n\n circuit->SetFrameType(panda::ecmascript::FrameType::OPTIMIZED_ENTRY_FRAME);\n\n }\n\n ~GetPropertyByValueStub() = default;\n\n NO_MOVE_SEMANTIC(GetPropertyByValueStub);\n\n NO_COPY_SEMANTIC(GetPropertyByValueStub);\n\n void GenerateCircuit() override;\n\n};\n\n\n", "file_path": "ecmascript/compiler/fast_stub.h", "rank": 70, "score": 201001.14426931133 }, { "content": "class LinkedHashTable : public TaggedArray {\n\npublic:\n\n static const int MIN_CAPACITY = 4;\n\n static const int NUMBER_OF_ELEMENTS_INDEX = 0;\n\n static const int NUMBER_OF_DELETED_ELEMENTS_INDEX = 1;\n\n static const int CAPACITY_INDEX = 2;\n\n static const int NEXT_TABLE_INDEX = 3;\n\n static const int ELEMENTS_START_INDEX = 4;\n\n // Don't shrink a HashTable below this capacity.\n\n static const int MIN_SHRINK_CAPACITY = 16;\n\n\n\n static Derived *Create(const JSThread *thread, int numberOfElements);\n\n\n\n static Derived *Insert(const JSThread *thread, const JSHandle<Derived> &table, const JSHandle<JSTaggedValue> &key,\n\n const JSHandle<JSTaggedValue> &value);\n\n\n\n static Derived *InsertWeakRef(const JSThread *thread, const JSHandle<Derived> &table,\n\n const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &value);\n\n\n\n static Derived *GrowCapacity(const JSThread *thread, const JSHandle<Derived> &table, int numberOfAddedElements = 1);\n", "file_path": "ecmascript/linked_hash_table.h", "rank": 71, "score": 200944.26449782058 }, { "content": "class PUBLIC_API Uint16ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Uint16ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset,\n\n int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 72, "score": 199275.6911046385 }, { "content": "class PUBLIC_API Int16ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Int16ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset, int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 73, "score": 199275.6911046385 }, { "content": "class PUBLIC_API Float64ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Float64ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset,\n\n int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 74, "score": 199275.6911046385 }, { "content": "class PUBLIC_API Uint32ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Uint32ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset,\n\n int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 75, "score": 199275.6911046385 }, { "content": "class PUBLIC_API Int32ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Int32ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset, int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 76, "score": 199275.6911046385 }, { "content": "class PUBLIC_API Float32ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Float32ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset,\n\n int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 77, "score": 199275.6911046385 }, { "content": "class PUBLIC_API Int8ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Int8ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset, int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 78, "score": 199275.6911046385 }, { "content": "class PUBLIC_API Uint8ArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Uint8ArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset, int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 79, "score": 199275.6911046385 }, { "content": "class ProtoChangeDetails : public TaggedObject {\n\npublic:\n\n static constexpr int UNREGISTERED = -1;\n\n static ProtoChangeDetails *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsProtoChangeDetails());\n\n return static_cast<ProtoChangeDetails *>(object);\n\n }\n\n\n\n static constexpr size_t CHANGE_LISTENER_OFFSET = TaggedObjectSize();\n\n ACCESSORS(ChangeListener, CHANGE_LISTENER_OFFSET, REGISTER_INDEX_OFFSET);\n\n ACCESSORS(RegisterIndex, REGISTER_INDEX_OFFSET, SIZE);\n\n\n\n DECL_VISIT_OBJECT(CHANGE_LISTENER_OFFSET, SIZE)\n\n DECL_DUMP()\n\n};\n\n\n", "file_path": "ecmascript/ic/proto_change_details.h", "rank": 80, "score": 196893.1626446013 }, { "content": "class ProfileTypeInfo : public TaggedArray {\n\npublic:\n\n static const array_size_t MAX_FUNC_CACHE_INDEX = std::numeric_limits<uint32_t>::max();\n\n static constexpr uint32_t INVALID_SLOT_INDEX = 0xFF;\n\n\n\n static ProfileTypeInfo *Cast(TaggedObject *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsTaggedArray());\n\n return static_cast<ProfileTypeInfo *>(object);\n\n }\n\n};\n\n\n\n\n", "file_path": "ecmascript/ic/profile_type_info.h", "rank": 81, "score": 196893.1626446013 }, { "content": "class ProtoChangeMarker : public TaggedObject {\n\npublic:\n\n\n\n using HasChangedField = BitField<bool, 0, 1>;\n\n static ProtoChangeMarker *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsProtoChangeMarker());\n\n return static_cast<ProtoChangeMarker *>(object);\n\n }\n\n\n\n static constexpr size_t HAS_CHANGED_OFFSET = TaggedObjectSize();\n\n SET_GET_PRIMITIVE_FIELD(HasChanged, bool, HAS_CHANGED_OFFSET, SIZE);\n\n DECL_DUMP()\n\n};\n\n\n", "file_path": "ecmascript/ic/proto_change_details.h", "rank": 82, "score": 196893.1626446013 }, { "content": "class PUBLIC_API Uint8ClampedArrayRef : public TypedArrayRef {\n\npublic:\n\n static Local<Uint8ClampedArrayRef> New(const EcmaVM *vm, Local<ArrayBufferRef> buffer, int32_t byteOffset,\n\n int32_t length);\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 83, "score": 195937.82876474655 }, { "content": "class JSTaggedQueueTest : public testing::Test {\n\npublic:\n\n static void SetUpTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"SetUpTestCase\";\n\n }\n\n\n\n static void TearDownTestCase()\n\n {\n\n GTEST_LOG_(INFO) << \"TearDownCase\";\n\n }\n\n\n\n void SetUp() override\n\n {\n\n TestHelper::CreateEcmaVMWithScope(instance, thread, scope);\n\n }\n\n\n\n void TearDown() override\n\n {\n\n TestHelper::DestroyEcmaVMWithScope(instance, scope);\n", "file_path": "ecmascript/tests/js_tagged_queue_test.cpp", "rank": 84, "score": 195889.98065660195 }, { "content": "class PUBLIC_API EscapeLocalScope final : public LocalScope {\n\npublic:\n\n explicit EscapeLocalScope(const EcmaVM *vm);\n\n ~EscapeLocalScope() override = default;\n\n\n\n DISALLOW_COPY(EscapeLocalScope);\n\n DISALLOW_MOVE(EscapeLocalScope);\n\n\n\n template<typename T>\n\n inline Local<T> Escape(Local<T> current)\n\n {\n\n ASSERT(!alreadyEscape_);\n\n alreadyEscape_ = true;\n\n *(reinterpret_cast<T *>(escapeHandle_)) = **current;\n\n return Local<T>(escapeHandle_);\n\n }\n\n\n\nprivate:\n\n bool alreadyEscape_ = false;\n\n uintptr_t escapeHandle_ = 0U;\n\n};\n\n\n", "file_path": "ecmascript/napi/include/jsnapi.h", "rank": 85, "score": 194683.77375244332 }, { "content": "class PropertyDescriptor;\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 86, "score": 193312.7319684071 }, { "content": "class JSThread;\n\n\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 87, "score": 193312.7319684071 }, { "content": "class JSObject;\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 88, "score": 193312.7319684071 }, { "content": "class JSHandle;\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 89, "score": 193312.7319684071 }, { "content": "class JSTaggedValue;\n\n\n\nusing CString = std::basic_string<char, std::char_traits<char>, CAddressAllocator<char>>;\n\nusing CStringStream = std::basic_stringstream<char, std::char_traits<char>, CAddressAllocator<char>>;\n\n\n", "file_path": "ecmascript/mem/c_string.h", "rank": 90, "score": 193312.7319684071 }, { "content": "class EcmaString;\n", "file_path": "ecmascript/js_tagged_value.h", "rank": 91, "score": 193312.7319684071 }, { "content": "class CharOpCode : public RegExpOpCode {\n\npublic:\n\n CharOpCode() : RegExpOpCode(OP_CHAR, RegExpOpCode::OP_SIZE_THREE) {}\n\n uint32_t EmitOpCode(DynChunk *buf, uint32_t para) const;\n\n ~CharOpCode() override = default;\n\n NO_COPY_SEMANTIC(CharOpCode);\n\n NO_MOVE_SEMANTIC(CharOpCode);\n\n uint32_t DumpOpCode(std::ostream &out, const DynChunk &buf, uint32_t offset) const override;\n\n};\n\n\n", "file_path": "ecmascript/regexp/regexp_opcode.h", "rank": 92, "score": 193213.50471211784 }, { "content": " class ConstPoolValue {\n\n public:\n\n ConstPoolValue(ConstPoolType type, uint32_t index)\n\n : value_(ConstPoolIndexField::Encode(index) | ConstPoolTypeField::Encode(type))\n\n {\n\n }\n\n\n\n explicit ConstPoolValue(uint64_t v) : value_(v) {}\n\n ~ConstPoolValue() = default;\n\n NO_COPY_SEMANTIC(ConstPoolValue);\n\n NO_MOVE_SEMANTIC(ConstPoolValue);\n\n\n\n inline uint64_t GetValue() const\n\n {\n\n return value_;\n\n }\n\n\n\n inline uint32_t GetConstpoolIndex() const\n\n {\n\n return ConstPoolIndexField::Get(value_);\n", "file_path": "ecmascript/class_linker/panda_file_translator.h", "rank": 93, "score": 193190.46345321962 }, { "content": "class ObjectOperator;\n\n\n", "file_path": "ecmascript/ic/ic_runtime.h", "rank": 94, "score": 193165.64671720733 }, { "content": "class JSFunctionExtraInfo : public TaggedObject {\n\npublic:\n\n static JSFunctionExtraInfo *Cast(ObjectHeader *object)\n\n {\n\n ASSERT(JSTaggedValue(object).IsJSFunctionExtraInfo());\n\n return static_cast<JSFunctionExtraInfo *>(object);\n\n }\n\n\n\n static constexpr size_t CALL_BACK_OFFSET = TaggedObjectSize();\n\n ACCESSORS(Callback, CALL_BACK_OFFSET, DATA_OFFSET);\n\n ACCESSORS(Data, DATA_OFFSET, SIZE);\n\n\n\n DECL_VISIT_OBJECT(CALL_BACK_OFFSET, SIZE)\n\n DECL_DUMP()\n\n};\n\n} // namespace panda::ecmascript\n\n#endif\n", "file_path": "ecmascript/js_function_extra_info.h", "rank": 95, "score": 193075.4158383279 }, { "content": "class RegExpExecResultCache : public TaggedArray {\n\npublic:\n\n enum CacheType {\n\n REPLACE_TYPE,\n\n SPLIT_TYPE,\n\n MATCH_TYPE,\n\n EXEC_TYPE\n\n };\n\n static RegExpExecResultCache *Cast(TaggedObject *object)\n\n {\n\n return reinterpret_cast<RegExpExecResultCache *>(object);\n\n }\n\n static JSTaggedValue CreateCacheTable(JSThread *thread);\n\n JSTaggedValue FindCachedResult(JSThread *thread, const JSHandle<JSTaggedValue> &patten,\n\n const JSHandle<JSTaggedValue> &flags, const JSHandle<JSTaggedValue> &input,\n\n CacheType type, const JSHandle<JSTaggedValue> &regexp);\n\n void AddResultInCache(JSThread *thread, const JSHandle<JSTaggedValue> &patten, const JSHandle<JSTaggedValue> &flags,\n\n const JSHandle<JSTaggedValue> &input, JSTaggedValue resultArray, CacheType type,\n\n uint32_t lastIndex);\n\n\n", "file_path": "ecmascript/builtins/builtins_regexp.h", "rank": 96, "score": 193075.4158383279 }, { "content": "class TransitionsDictionary : public TaggedHashTable<TransitionsDictionary> {\n\npublic:\n\n using HashTableT = TaggedHashTable<TransitionsDictionary>;\n\n static inline bool IsMatch([[maybe_unused]] const JSTaggedValue &key,\n\n [[maybe_unused]] const JSTaggedValue &otherKey)\n\n {\n\n UNREACHABLE();\n\n }\n\n static inline int Hash([[maybe_unused]] const JSTaggedValue &key)\n\n {\n\n UNREACHABLE();\n\n }\n\n\n\n static inline bool IsMatch(const JSTaggedValue &key, const JSTaggedValue &metaData, const JSTaggedValue &otherKey,\n\n const JSTaggedValue &otherDetails)\n\n {\n\n return key == otherKey && metaData == otherDetails;\n\n }\n\n\n\n static inline int Hash(const JSTaggedValue &key, const JSTaggedValue &metaData)\n", "file_path": "ecmascript/transitions_dictionary.h", "rank": 97, "score": 191452.98325289565 }, { "content": "class SymbolTable : public TaggedHashTable<SymbolTable> {\n\npublic:\n\n using HashTable = TaggedHashTable<SymbolTable>;\n\n static SymbolTable *Cast(ObjectHeader *object)\n\n {\n\n return reinterpret_cast<SymbolTable *>(object);\n\n }\n\n inline static int GetKeyIndex(int entry)\n\n {\n\n return HashTable::TABLE_HEADER_SIZE + entry * GetEntrySize() + ENTRY_KEY_INDEX;\n\n }\n\n inline static int GetValueIndex(int entry)\n\n {\n\n return HashTable::TABLE_HEADER_SIZE + entry * GetEntrySize() + ENTRY_VALUE_INDEX;\n\n }\n\n inline static int GetEntryIndex(int entry)\n\n {\n\n return HashTable::TABLE_HEADER_SIZE + entry * GetEntrySize();\n\n }\n\n inline static int GetEntrySize()\n", "file_path": "ecmascript/symbol_table.h", "rank": 98, "score": 191452.98325289565 }, { "content": "class TemplateMap : public TaggedHashTable<TemplateMap> {\n\npublic:\n\n using HashTable = TaggedHashTable<TemplateMap>;\n\n static inline bool IsMatch(const JSTaggedValue &key, const JSTaggedValue &other)\n\n {\n\n return key == other;\n\n }\n\n static inline int Hash(const JSTaggedValue &obj)\n\n {\n\n ASSERT(obj.IsJSArray());\n\n JSArray *array = JSArray::Cast(obj.GetHeapObject());\n\n uint32_t len = array->GetArrayLength();\n\n return len;\n\n }\n\n inline static int GetKeyIndex(int entry)\n\n {\n\n return HashTable::TABLE_HEADER_SIZE + entry * GetEntrySize() + ENTRY_KEY_INDEX;\n\n }\n\n inline static int GetValueIndex(int entry)\n\n {\n", "file_path": "ecmascript/template_map.h", "rank": 99, "score": 191452.98325289565 } ]
C++
sourceCode/dotNet4.6/ndp/fx/src/data/native/sni/include/sni_servicebindings.hpp
csoap/csoap.github.io
2a8db44eb63425deff147652b65c5912f065334e
#ifndef _SNI_SERVICE_BINDINGS_07_15_2009_ #define _SNI_SERVICE_BINDINGS_07_15_2009_ #include "sni_spn.hpp" class SNI_ServiceBindings { public: static DWORD SetHostNamesAndAcceptedSPNs(__in_ecount_opt(dwcAllowedSPNs) WCHAR **pwszAcceptedSPNs, DWORD dwcAcceptedSPNs); static DWORD SetClusterAddresses(__in ADDRINFOW *paiwClusterAddresses); static DWORD SetClusterNames(__in_z LPWSTR wszClusterHostName); static DWORD MatchSPN(__in_z LPWSTR wszClientSuppliedSPN, __out SNIAuthErrStates *pSSPIFailureState); static void Release(); #ifndef SNIX private: static volatile LONG s_lClusterAddressesInitialized; static bool s_fClusterHostNamesInitialized; static bool s_fWSAStarted; static struct in_addr *s_piaIPv4Address; static DWORD s_dwcIPv4Address; static struct in6_addr *s_pi6aIPv6Address; static DWORD s_dwcIPv6Address; static LPWSTR *s_pwszHostNames; static DWORD s_dwcHostNames; static LPWSTR *s_pwszSPN; static DWORD s_dwcSPN; static DWORD MatchHostOrIPv4Address(__in_z LPWSTR wszHost, __out SNIAuthErrStates *pSSPIFailureState); static DWORD MatchIPv6Address(__in_z LPWSTR wszHost, __out SNIAuthErrStates *pSSPIFailureState); static DWORD MatchApprovedList(__in_z LPWSTR wszSPN); static DWORD MatchAgainstNameList(__in_z LPWSTR wszHost); static DWORD MatchAgainstIpv4AddressList(__in PSOCKADDR_STORAGE psaIpv4Address); static DWORD MatchAgainstIpv6AddressList(__in PSOCKADDR_STORAGE psaIpv6Address); static DWORD InitializeWSA(); static DWORD GetBackConnectionHostNames(__deref_out __nullnullterminated WCHAR **pwszBackConnectionHostNames); static DWORD AllocAndSetHostname(COMPUTER_NAME_FORMAT NameType); static DWORD RepackSzIntoWsz(__in_z LPCSTR szMbcsString); static void ReleaseIPs(); static void ReleaseNames(); inline static void BidTraceAddedIPv4Address(__in struct in_addr *psin_addr); inline static void BidTraceAddedIPv6Address(__in struct in6_addr *psin6_addr); inline static bool IsIn4AddrLoopback(const PSOCKADDR_IN psaiAddress); inline static bool IsIn6AddrLoopback(const PSOCKADDR_IN6 psai6Address); #endif }; #endif
#ifndef _SNI_SERVICE_BINDINGS_07_15_2009_ #define _SNI_SERVICE_BINDINGS_07_15_2009_ #include "sni_spn.hpp" class SNI_ServiceBindings { public: static DWORD SetHostNamesAndAcceptedSPNs(__in_ecount_opt(dwcAllowedSPNs) WCHAR **pwszAcceptedSPNs, DWORD dwcAcceptedSPNs); static DWORD SetClusterAddresses(__in ADDRINFOW *paiwClusterAddresses); static DWORD SetClusterNames(__in_z LPWSTR wszClusterHostName); static DWORD MatchSPN(__in_z LPWSTR ws
stNames); static DWORD AllocAndSetHostname(COMPUTER_NAME_FORMAT NameType); static DWORD RepackSzIntoWsz(__in_z LPCSTR szMbcsString); static void ReleaseIPs(); static void ReleaseNames(); inline static void BidTraceAddedIPv4Address(__in struct in_addr *psin_addr); inline static void BidTraceAddedIPv6Address(__in struct in6_addr *psin6_addr); inline static bool IsIn4AddrLoopback(const PSOCKADDR_IN psaiAddress); inline static bool IsIn6AddrLoopback(const PSOCKADDR_IN6 psai6Address); #endif }; #endif
zClientSuppliedSPN, __out SNIAuthErrStates *pSSPIFailureState); static void Release(); #ifndef SNIX private: static volatile LONG s_lClusterAddressesInitialized; static bool s_fClusterHostNamesInitialized; static bool s_fWSAStarted; static struct in_addr *s_piaIPv4Address; static DWORD s_dwcIPv4Address; static struct in6_addr *s_pi6aIPv6Address; static DWORD s_dwcIPv6Address; static LPWSTR *s_pwszHostNames; static DWORD s_dwcHostNames; static LPWSTR *s_pwszSPN; static DWORD s_dwcSPN; static DWORD MatchHostOrIPv4Address(__in_z LPWSTR wszHost, __out SNIAuthErrStates *pSSPIFailureState); static DWORD MatchIPv6Address(__in_z LPWSTR wszHost, __out SNIAuthErrStates *pSSPIFailureState); static DWORD MatchApprovedList(__in_z LPWSTR wszSPN); static DWORD MatchAgainstNameList(__in_z LPWSTR wszHost); static DWORD MatchAgainstIpv4AddressList(__in PSOCKADDR_STORAGE psaIpv4Address); static DWORD MatchAgainstIpv6AddressList(__in PSOCKADDR_STORAGE psaIpv6Address); static DWORD InitializeWSA(); static DWORD GetBackConnectionHostNames(__deref_out __nullnullterminated WCHAR **pwszBackConnectionHo
random
[]
C++
src/red4ext/FlightSettings.cpp
jackhumbert/flight_control
02938f5a26b3a299ef3d9b9e4d40e9294872a7ee
#include "FlightSettings.hpp" #include "FlightModule.hpp" #include "Utils.hpp" #include "stdafx.hpp" namespace FlightSettings { RED4ext::TTypedClass<FlightSettings> cls("FlightSettings"); RED4ext::CClass *FlightSettings::GetNativeType() { return &cls; } RED4ext::HashMap<RED4ext::CName, float> floats; void GetFloat(RED4ext::IScriptable *aContext, RED4ext::CStackFrame *aFrame, float *aOut, int64_t a4) { RED4ext::CName name; RED4ext::GetParameter(aFrame, &name); aFrame->code++; if (aOut) { *aOut = *floats.Get(name); } } void SetFloat(RED4ext::IScriptable *aContext, RED4ext::CStackFrame *aFrame, void *aOut, int64_t a4) { RED4ext::CName name; float value; RED4ext::GetParameter(aFrame, &name); RED4ext::GetParameter(aFrame, &value); aFrame->code++; floats.InsertOrAssign(name, value); } bool Setup(RED4ext::CGameApplication *aApp) { auto allocator = new RED4ext::Memory::DefaultAllocator(); floats = RED4ext::HashMap<RED4ext::CName, float>(allocator); floats.Insert("airResistance", 0.001); floats.Insert("angularBrakeFactor", 10.0); floats.Insert("angularDampFactor", 3.0); floats.Insert("brakeFactor", 1.2); floats.Insert("brakeOffset", 0.0); floats.Insert("collisionRecoveryDelay", 0.8); floats.Insert("collisionRecoveryDuration", 0.8); floats.Insert("defaultHoverHeight", 3.50); floats.Insert("distance", 0.0); floats.Insert("distanceEase", 0.1); floats.Insert("fwtfCorrection", 0.0); floats.Insert("hoverClamp", 10.0); floats.Insert("hoverFactor", 20.0); floats.Insert("liftFactor", 8.0); floats.Insert("liftFactorDrone", 40.0); floats.Insert("lookAheadMax", 10.0); floats.Insert("lookAheadMin", 1.0); floats.Insert("maxHoverHeight", 7.0); floats.Insert("minHoverHeight", 1.0); floats.Insert("normalEase", 0.3); floats.Insert("pitchAeroCorrectionFactor", 0.25); floats.Insert("pitchCorrectionFactor", 3.0); floats.Insert("pitchDirectionalityFactor", 80.0); floats.Insert("pitchFactorDrone", 5.0); floats.Insert("pitchWithLift", 0.0); floats.Insert("pitchWithSurge", 0.0); floats.Insert("referenceZ", 0.0); floats.Insert("rollCorrectionFactor", 15.0); floats.Insert("rollFactorDrone", 12.0); floats.Insert("rollWithYaw", 0.15); floats.Insert("secondCounter", 0.0); floats.Insert("surgeFactor", 15.0); floats.Insert("surgeOffset", 0.5); floats.Insert("swayFactor", 5.0); floats.Insert("swayWithYaw", 0.5); floats.Insert("thrusterFactor", 0.05); floats.Insert("yawCorrectionFactor", 0.25); floats.Insert("yawD", 3.0); floats.Insert("yawDirectionalityFactor", 50.0); floats.Insert("yawFactor", 5.0); floats.Insert("yawFactorDrone", 5.0); return true; } struct FlightSettingsModule : FlightModule { void Load(const RED4ext::Sdk *aSdk, RED4ext::PluginHandle aHandle) { RED4ext::GameState runningState; runningState.OnEnter = nullptr; runningState.OnUpdate = &Setup; runningState.OnExit = nullptr; aSdk->gameStates->Add(aHandle, RED4ext::EGameStateType::Running, &runningState); } void RegisterTypes() { cls.flags = {.isNative = true}; RED4ext::CRTTISystem::Get()->RegisterType(&cls); } void PostRegisterTypes() { auto rtti = RED4ext::CRTTISystem::Get(); auto scriptable = rtti->GetClass("IScriptable"); cls.parent = scriptable; auto getFloat = RED4ext::CClassStaticFunction::Create(&cls, "GetFloat", "GetFloat", &GetFloat, {.isNative = true, .isStatic = true}); cls.RegisterFunction(getFloat); auto setFloat = RED4ext::CClassStaticFunction::Create(&cls, "SetFloat", "SetFloat", &SetFloat, {.isNative = true, .isStatic = true}); cls.RegisterFunction(setFloat); } }; REGISTER_FLIGHT_MODULE(FlightSettingsModule); }
#include "FlightSettings.hpp" #include "FlightModule.hpp" #include "Utils.hpp" #include "stdafx.hpp" namespace FlightSettings { RED4ext::TTypedClass<FlightSettings> cls("FlightSettings"); RED4ext::CClass *FlightSettings::GetNativeType() { return &cls; } RED4ext::HashMap<RED4ext::CName, float> floats; void GetFloat(RED4ext::IScriptable *aContext, RED4ext::CStackFrame *aFrame, float *aOut, int64_t a4) { RED4ext::CName name; RED4ext::GetParameter(aFrame, &name); aFrame->code++; if (aOut) { *aOut = *floats.Get(name); } } void SetFloat(RED4ext::IScriptable *aContext, RED4ext::CStackFrame *aFrame, void *aOut, int64_t a4) { RED4ext::CName name; float value; RED4ext::GetParameter(aFrame, &name); RED4ext::GetParameter(aFrame, &value); aFrame->code++; floats.InsertOrAssign(name, value); } bool Setup(RED4ext::CGameApplication *aApp) { auto allocator = new RED4ext::Memory::DefaultAllocator(); floats = RED4ext::HashMap<RED4ext::CName, float>(allocator); floats.Insert("airResistance", 0.001); floats.Insert("angularBrakeFactor", 10.0); floats.Insert("angularDampFactor", 3.0); floats.Insert("brakeFactor", 1.2); floats.Insert("brakeOffset", 0.0); floats.Insert("collisionRecoveryDelay", 0.8); floats.Insert("collisionRecoveryDuration", 0.8); floats.Insert("defaultHoverHeight", 3.50); floats.Insert("distance", 0.0); floats.Insert("distanceEase", 0.1); floats.Insert("fwtfCorrection", 0.0); floats.Insert("hoverClamp", 10.0); floats.Insert("hoverFactor", 20.0); floats.Insert("liftFactor", 8.0); floats.Insert("liftFactorDrone", 40.0); floats.Insert("lookAheadMax", 10.0); floats.Insert("lookAheadMin", 1.0); floats.Insert("maxHoverHeight", 7.0); floats.Insert("minHoverHeight", 1.0); floats.Insert("normalEase", 0.3); floats.Insert("pitchAeroCorrectionFactor", 0.25); floats.Insert("pitchCorrectionFactor", 3.0); floats.Insert("pitchDirectionalityFactor", 80.0); floats.Insert("pitchFactorDrone", 5.0); floats.Insert("pitchWithLift", 0.0); floats.Insert("pitchWithSurge", 0.0); floats.Insert("referenceZ", 0.0); floats.Insert("rollCorrectionFactor", 15.0); floats.Insert("rollFactorDrone", 12.0); floats.Insert("rollWithYaw", 0.15); floats.Insert("secondCounter", 0.0); floats.Insert("surgeFactor", 15.0); floats.Insert("surgeOffset", 0.5); floats.Insert("swayFactor", 5.0); floats.Insert("swayWithYaw", 0.5); floats.Insert("thrusterFactor", 0.05); floats.Insert("yawCorrectionFactor", 0.25); floats.Insert("yawD", 3.0); floats.Insert("yawDirectionalityFactor", 50.0); floats.Insert("yawFactor", 5.0); floats.Insert("yawF
auto setFloat = RED4ext::CClassStaticFunction::Create(&cls, "SetFloat", "SetFloat", &SetFloat, {.isNative = true, .isStatic = true}); cls.RegisterFunction(setFloat); } }; REGISTER_FLIGHT_MODULE(FlightSettingsModule); }
actorDrone", 5.0); return true; } struct FlightSettingsModule : FlightModule { void Load(const RED4ext::Sdk *aSdk, RED4ext::PluginHandle aHandle) { RED4ext::GameState runningState; runningState.OnEnter = nullptr; runningState.OnUpdate = &Setup; runningState.OnExit = nullptr; aSdk->gameStates->Add(aHandle, RED4ext::EGameStateType::Running, &runningState); } void RegisterTypes() { cls.flags = {.isNative = true}; RED4ext::CRTTISystem::Get()->RegisterType(&cls); } void PostRegisterTypes() { auto rtti = RED4ext::CRTTISystem::Get(); auto scriptable = rtti->GetClass("IScriptable"); cls.parent = scriptable; auto getFloat = RED4ext::CClassStaticFunction::Create(&cls, "GetFloat", "GetFloat", &GetFloat, {.isNative = true, .isStatic = true}); cls.RegisterFunction(getFloat);
random
[ { "content": " FMOD_DSP_ALLOC_FUNC alloc;\n", "file_path": "deps/fmod/include/fmod_dsp.h", "rank": 0, "score": 130866.68190463846 }, { "content": " FMOD_CODEC_ALLOC_FUNC alloc;\n", "file_path": "deps/fmod/include/fmod_codec.h", "rank": 1, "score": 130866.68190463846 }, { "content": " FMOD_OUTPUT_ALLOC_FUNC alloc;\n", "file_path": "deps/fmod/include/fmod_output.h", "rank": 2, "score": 130866.68190463846 }, { "content": " const char *name;\n", "file_path": "deps/fmod/include/fmod_output.h", "rank": 3, "score": 130832.9306903423 }, { "content": " char *name;\n", "file_path": "deps/fmod/include/fmod_common.h", "rank": 4, "score": 130832.9306903423 }, { "content": " const char* name;\n", "file_path": "deps/fmod/include/fmod_codec.h", "rank": 5, "score": 130832.9306903423 }, { "content": " char name[32];\n", "file_path": "deps/fmod/include/fmod_dsp.h", "rank": 6, "score": 130832.9306903423 }, { "content": "SPDLOG_INLINE void swap(logger &a, logger &b)\n", "file_path": "deps/spdlog/include/spdlog/logger-inl.h", "rank": 7, "score": 128131.08152506922 }, { "content": " const char *name;\n", "file_path": "deps/fmod/include/fmod_studio_common.h", "rank": 8, "score": 128094.7908227854 }, { "content": "struct formatter<void*, Char> : formatter<const void*, Char> {\n\n template <typename FormatContext>\n\n auto format(void* val, FormatContext& ctx) const -> decltype(ctx.out()) {\n\n return formatter<const void*, Char>::format(val, ctx);\n\n }\n\n};\n\n\n\ntemplate <typename Char, size_t N>\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/format.h", "rank": 9, "score": 117683.959935009 }, { "content": "struct is_convertible_to_any_format_string : std::integral_constant<bool, is_convertible_to_basic_format_string<T, char>::value ||\n\n is_convertible_to_basic_format_string<T, wchar_t>::value>\n\n{};\n\n\n\n#if defined(SPDLOG_NO_ATOMIC_LEVELS)\n\nusing level_t = details::null_atomic_int;\n\n#else\n\nusing level_t = std::atomic<int>;\n\n#endif\n\n\n\n#define SPDLOG_LEVEL_TRACE 0\n\n#define SPDLOG_LEVEL_DEBUG 1\n\n#define SPDLOG_LEVEL_INFO 2\n\n#define SPDLOG_LEVEL_WARN 3\n\n#define SPDLOG_LEVEL_ERROR 4\n\n#define SPDLOG_LEVEL_CRITICAL 5\n\n#define SPDLOG_LEVEL_OFF 6\n\n\n\n#if !defined(SPDLOG_ACTIVE_LEVEL)\n\n# define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO\n\n#endif\n\n\n\n// Log level enum\n\nnamespace level {\n", "file_path": "deps/spdlog/include/spdlog/common.h", "rank": 10, "score": 116491.17075711288 }, { "content": "struct field_type<T, enable_if_t<detail::is_named_arg<T>::value>> {\n\n using type = remove_cvref_t<decltype(T::value)>;\n\n};\n\n\n\ntemplate <typename T, typename Args, size_t END_POS, int ARG_INDEX, int NEXT_ID,\n\n typename S>\n\nconstexpr auto parse_replacement_field_then_tail(S format_str) {\n\n using char_type = typename S::char_type;\n\n constexpr auto str = basic_string_view<char_type>(format_str);\n\n constexpr char_type c = END_POS != str.size() ? str[END_POS] : char_type();\n\n if constexpr (c == '}') {\n\n return parse_tail<Args, END_POS + 1, NEXT_ID>(\n\n field<char_type, typename field_type<T>::type, ARG_INDEX>(),\n\n format_str);\n\n } else if constexpr (c == ':') {\n\n constexpr auto result = parse_specs<typename field_type<T>::type>(\n\n str, END_POS + 1, NEXT_ID == manual_indexing_id ? 0 : NEXT_ID);\n\n return parse_tail<Args, result.end, result.next_arg_id>(\n\n spec_field<char_type, typename field_type<T>::type, ARG_INDEX>{\n\n result.fmt},\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/compile.h", "rank": 11, "score": 111959.50912576412 }, { "content": " class ResultValueBase<void> : public ResultBase {\n\n protected:\n\n using ResultBase::ResultBase;\n\n };\n\n\n\n template<typename T = void>\n", "file_path": "deps/detours/tests/catch.hpp", "rank": 12, "score": 104164.46280701284 }, { "content": " class ResultValueBase<void> : public ResultBase {\n\n protected:\n\n using ResultBase::ResultBase;\n\n };\n\n\n\n template<typename T = void>\n", "file_path": "deps/spdlog/tests/catch.hpp", "rank": 13, "score": 104164.46280701284 }, { "content": "enum class arg_id_kind { none, index, name };\n\n\n\n// An argument reference.\n\ntemplate <typename Char> struct arg_ref {\n\n FMT_CONSTEXPR arg_ref() : kind(arg_id_kind::none), val() {}\n\n\n\n FMT_CONSTEXPR explicit arg_ref(int index)\n\n : kind(arg_id_kind::index), val(index) {}\n\n FMT_CONSTEXPR explicit arg_ref(basic_string_view<Char> name)\n\n : kind(arg_id_kind::name), val(name) {}\n\n\n\n FMT_CONSTEXPR auto operator=(int idx) -> arg_ref& {\n\n kind = arg_id_kind::index;\n\n val.index = idx;\n\n return *this;\n\n }\n\n\n\n arg_id_kind kind;\n\n union value {\n\n FMT_CONSTEXPR value(int id = 0) : index{id} {}\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/core.h", "rank": 14, "score": 95847.7705573118 }, { "content": "struct auto_id {};\n\n\n\n// A format specifier handler that sets fields in basic_format_specs.\n\ntemplate <typename Char> class specs_setter {\n\n protected:\n\n basic_format_specs<Char>& specs_;\n\n\n\n public:\n\n explicit FMT_CONSTEXPR specs_setter(basic_format_specs<Char>& specs)\n\n : specs_(specs) {}\n\n\n\n FMT_CONSTEXPR specs_setter(const specs_setter& other)\n\n : specs_(other.specs_) {}\n\n\n\n FMT_CONSTEXPR void on_align(align_t align) { specs_.align = align; }\n\n FMT_CONSTEXPR void on_fill(basic_string_view<Char> fill) {\n\n specs_.fill = fill;\n\n }\n\n FMT_CONSTEXPR void on_sign(sign_t s) { specs_.sign = s; }\n\n FMT_CONSTEXPR void on_hash() { specs_.alt = true; }\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/core.h", "rank": 15, "score": 91427.75711609198 }, { "content": "struct float_specs {\n\n int precision;\n\n float_format format : 8;\n\n sign_t sign : 8;\n\n bool upper : 1;\n\n bool locale : 1;\n\n bool binary32 : 1;\n\n bool use_grisu : 1;\n\n bool showpoint : 1;\n\n};\n\n\n\ntemplate <typename ErrorHandler = error_handler, typename Char>\n\nFMT_CONSTEXPR auto parse_float_type_spec(const basic_format_specs<Char>& specs,\n\n ErrorHandler&& eh = {})\n\n -> float_specs {\n\n auto result = float_specs();\n\n result.showpoint = specs.alt;\n\n result.locale = specs.localized;\n\n switch (specs.type) {\n\n case 0:\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/core.h", "rank": 16, "score": 91424.5301060864 }, { "content": "struct is_named_arg<named_arg<Char, T>> : std::true_type {};\n\n\n\ntemplate <typename Char, typename T, typename... Tail,\n\n FMT_ENABLE_IF(!is_named_arg<T>::value)>\n\nvoid init_named_args(named_arg_info<Char>* named_args, int arg_count,\n\n int named_arg_count, const T&, const Tail&... args) {\n\n init_named_args(named_args, arg_count + 1, named_arg_count, args...);\n\n}\n\n\n\ntemplate <typename Char, typename T, typename... Tail,\n\n FMT_ENABLE_IF(is_named_arg<T>::value)>\n\nvoid init_named_args(named_arg_info<Char>* named_args, int arg_count,\n\n int named_arg_count, const T& arg, const Tail&... args) {\n\n named_args[named_arg_count++] = {arg.name, arg_count};\n\n init_named_args(named_args, arg_count + 1, named_arg_count, args...);\n\n}\n\n\n\ntemplate <typename... Args>\n\nFMT_CONSTEXPR FMT_INLINE void init_named_args(std::nullptr_t, int, int,\n\n const Args&...) {}\n\n\n\ntemplate <bool B = false> constexpr auto count() -> size_t { return B ? 1 : 0; }\n\ntemplate <bool B1, bool B2, bool... Tail> constexpr auto count() -> size_t {\n\n return (B1 ? 1 : 0) + count<B2, Tail...>();\n\n}\n\n\n\ntemplate <typename... Args> constexpr auto count_named_args() -> size_t {\n\n return count<is_named_arg<Args>::value...>();\n\n}\n\n\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/core.h", "rank": 17, "score": 89700.51777740041 }, { "content": " const char* const *fileNames;\n", "file_path": "deps/fmod/include/fsbank.h", "rank": 18, "score": 88489.83348496826 }, { "content": "struct is_statically_named_arg<statically_named_arg<T, Char, N, Str>>\n\n : std::true_type {};\n\n\n\ntemplate <typename Char, size_t N,\n\n fmt::detail_exported::fixed_string<Char, N> Str>\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/format.h", "rank": 19, "score": 87761.21443046468 }, { "content": "struct statically_named_arg : view {\n\n static constexpr auto name = Str.data;\n\n\n\n const T& value;\n\n statically_named_arg(const T& v) : value(v) {}\n\n};\n\n\n\ntemplate <typename T, typename Char, size_t N,\n\n fmt::detail_exported::fixed_string<Char, N> Str>\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/format.h", "rank": 20, "score": 85751.69361741137 }, { "content": "struct is_named_arg<statically_named_arg<T, Char, N, Str>> : std::true_type {};\n\n\n\ntemplate <typename T, typename Char, size_t N,\n\n fmt::detail_exported::fixed_string<Char, N> Str>\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/format.h", "rank": 21, "score": 84130.27127776438 }, { "content": "// A floating-point presentation format.\n\nenum class float_format : unsigned char {\n\n general, // General: exponent notation or fixed point based on magnitude.\n\n exp, // Exponent notation with the default precision of 6, e.g. 1.2e-3.\n\n fixed, // Fixed point with the default precision of 6, e.g. 0.0012.\n\n hex\n\n};\n\n\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/core.h", "rank": 22, "score": 83198.8498691823 }, { "content": "FMT_BEGIN_NAMESPACE\n\nnamespace detail {\n\ntemplate <typename T>\n\nusing is_exotic_char = bool_constant<!std::is_same<T, char>::value>;\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/xchar.h", "rank": 23, "score": 83194.16348462536 }, { "content": " int value;\n", "file_path": "deps/spdlog/include/spdlog/details/null_mutex.h", "rank": 24, "score": 83188.35054971158 }, { "content": " const char *name_or_data;\n", "file_path": "deps/fmod/include/fmod_studio_common.h", "rank": 25, "score": 83177.92021901482 }, { "content": "class name_formatter final : public flag_formatter\n\n{\n\npublic:\n\n explicit name_formatter(padding_info padinfo)\n\n : flag_formatter(padinfo)\n\n {}\n\n\n\n void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override\n\n {\n\n ScopedPadder p(msg.logger_name.size(), padinfo_, dest);\n\n fmt_helper::append_string_view(msg.logger_name, dest);\n\n }\n\n};\n\n\n\n// log level appender\n\ntemplate<typename ScopedPadder>\n", "file_path": "deps/spdlog/include/spdlog/pattern_formatter-inl.h", "rank": 26, "score": 80754.1445444935 }, { "content": "FMT_MODULE_EXPORT_END\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/xchar.h", "rank": 27, "score": 78482.9486515227 }, { "content": "FMT_MODULE_EXPORT_END\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/ranges.h", "rank": 28, "score": 78482.9486515227 }, { "content": "class RandomFloatingGenerator final : public IGenerator<Float> {\n\n Catch::SimplePcg32& m_rng;\n\n std::uniform_real_distribution<Float> m_dist;\n\n Float m_current_number;\n\npublic:\n\n\n\n RandomFloatingGenerator(Float a, Float b):\n\n m_rng(rng()),\n\n m_dist(a, b) {\n\n static_cast<void>(next());\n\n }\n\n\n\n Float const& get() const override {\n\n return m_current_number;\n\n }\n\n bool next() override {\n\n m_current_number = m_dist(m_rng);\n\n return true;\n\n }\n\n};\n\n\n\ntemplate <typename Integer>\n", "file_path": "deps/spdlog/tests/catch.hpp", "rank": 29, "score": 74877.83812900784 }, { "content": "class RandomFloatingGenerator final : public IGenerator<Float> {\n\n Catch::SimplePcg32& m_rng;\n\n std::uniform_real_distribution<Float> m_dist;\n\n Float m_current_number;\n\npublic:\n\n\n\n RandomFloatingGenerator(Float a, Float b):\n\n m_rng(rng()),\n\n m_dist(a, b) {\n\n static_cast<void>(next());\n\n }\n\n\n\n Float const& get() const override {\n\n return m_current_number;\n\n }\n\n bool next() override {\n\n m_current_number = m_dist(m_rng);\n\n return true;\n\n }\n\n};\n\n\n\ntemplate <typename Integer>\n", "file_path": "deps/detours/tests/catch.hpp", "rank": 30, "score": 74877.83812900784 }, { "content": "struct is_locale<T, void_t<decltype(T::classic())>> : std::true_type {};\n\n} // namespace detail\n\n\n\nFMT_MODULE_EXPORT_BEGIN\n\n\n\n// The number of characters to store in the basic_memory_buffer object itself\n\n// to avoid dynamic memory allocation.\n\nenum { inline_buffer_size = 500 };\n\n\n\n/**\n\n \\rst\n\n A dynamically growing memory buffer for trivially copyable/constructible types\n\n with the first ``SIZE`` elements stored in the object itself.\n\n\n\n You can use the ``memory_buffer`` type alias for ``char`` instead.\n\n\n\n **Example**::\n\n\n\n fmt::memory_buffer out;\n\n format_to(out, \"The answer is {}.\", 42);\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/format.h", "rank": 31, "score": 74276.72101325178 }, { "content": "struct is_compiled_format<runtime_named_field<Char>> : std::true_type {};\n\n\n\n// A replacement field that refers to argument N and has format specifiers.\n\ntemplate <typename Char, typename T, int N> struct spec_field {\n\n using char_type = Char;\n\n formatter<T, Char> fmt;\n\n\n\n template <typename OutputIt, typename... Args>\n\n constexpr FMT_INLINE OutputIt format(OutputIt out,\n\n const Args&... args) const {\n\n const auto& vargs =\n\n fmt::make_format_args<basic_format_context<OutputIt, Char>>(args...);\n\n basic_format_context<OutputIt, Char> ctx(out, vargs);\n\n return fmt.format(get_arg_checked<T, N>(args...), ctx);\n\n }\n\n};\n\n\n\ntemplate <typename Char, typename T, int N>\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/compile.h", "rank": 32, "score": 74262.21883596478 }, { "content": "struct is_contiguous<basic_memory_buffer<T, SIZE, Allocator>> : std::true_type {\n\n};\n\n\n\nnamespace detail {\n\nFMT_API void print(std::FILE*, string_view);\n\n}\n\n\n\n/** A formatting error such as invalid format string. */\n\nFMT_CLASS_API\n", "file_path": "deps/spdlog/include/spdlog/fmt/bundled/format.h", "rank": 33, "score": 72333.7162049133 }, { "content": " class EnumValuesRegistry : public IMutableEnumValuesRegistry {\n\n\n\n std::vector<std::unique_ptr<EnumInfo>> m_enumInfos;\n\n\n\n EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override;\n\n };\n\n\n\n std::vector<StringRef> parseEnums( StringRef enums );\n\n\n\n } // Detail\n\n\n\n} // Catch\n\n\n\n// end catch_enum_values_registry.h\n\n\n\n#include <map>\n\n#include <cassert>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "deps/spdlog/tests/catch.hpp", "rank": 34, "score": 56331.19321772481 }, { "content": " class EnumValuesRegistry : public IMutableEnumValuesRegistry {\n\n\n\n std::vector<std::unique_ptr<EnumInfo>> m_enumInfos;\n\n\n\n EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override;\n\n };\n\n\n\n std::vector<StringRef> parseEnums( StringRef enums );\n\n\n\n } // Detail\n\n\n\n} // Catch\n\n\n\n// end catch_enum_values_registry.h\n\n\n\n#include <map>\n\n#include <cassert>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "deps/detours/tests/catch.hpp", "rank": 35, "score": 56331.19321772481 }, { "content": " class ExeName : public ComposableParserImpl<ExeName> {\n\n std::shared_ptr<std::string> m_name;\n\n std::shared_ptr<BoundValueRefBase> m_ref;\n\n\n\n template<typename LambdaT>\n\n static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {\n\n return std::make_shared<BoundLambda<LambdaT>>( lambda) ;\n\n }\n\n\n\n public:\n\n ExeName() : m_name( std::make_shared<std::string>( \"<executable>\" ) ) {}\n\n\n\n explicit ExeName( std::string &ref ) : ExeName() {\n\n m_ref = std::make_shared<BoundValueRef<std::string>>( ref );\n\n }\n\n\n\n template<typename LambdaT>\n\n explicit ExeName( LambdaT const& lambda ) : ExeName() {\n\n m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );\n\n }\n", "file_path": "deps/detours/tests/catch.hpp", "rank": 36, "score": 56317.27778362777 }, { "content": " class ExeName : public ComposableParserImpl<ExeName> {\n\n std::shared_ptr<std::string> m_name;\n\n std::shared_ptr<BoundValueRefBase> m_ref;\n\n\n\n template<typename LambdaT>\n\n static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {\n\n return std::make_shared<BoundLambda<LambdaT>>( lambda) ;\n\n }\n\n\n\n public:\n\n ExeName() : m_name( std::make_shared<std::string>( \"<executable>\" ) ) {}\n\n\n\n explicit ExeName( std::string &ref ) : ExeName() {\n\n m_ref = std::make_shared<BoundValueRef<std::string>>( ref );\n\n }\n\n\n\n template<typename LambdaT>\n\n explicit ExeName( LambdaT const& lambda ) : ExeName() {\n\n m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );\n\n }\n", "file_path": "deps/spdlog/tests/catch.hpp", "rank": 37, "score": 56317.27778362777 }, { "content": "-- registerForEvent('onInit', function()\n\n\n\n-- TweakDB:SetFlat('Vehicle.Peugeot.enumComment', '')\n\n-- TweakDB:SetFlat('Vehicle.Peugeot.enumName', 'Peugeot')\n\n \n\n-- TweakDB:SetFlat('Vehicle.Spinner.enumComment','') \n\n-- TweakDB:SetFlat('Vehicle.Spinner.enumName','Spinner') \n\n\n\n-- TweakDB:SetFlat('UIIcon.Peugeot.atlasPartName','peugeot')\n\n-- TweakDB:SetFlat('UIIcon.Peugeot.atlasResourcePath',RaRefCResource.new(11880208925820980408)) \n\n \n\n-- TweakDB:SetFlat('UIIcon.peugeot_spinner__basic.atlasPartName','peugeot_spinner__basic')\n\n-- TweakDB:SetFlat('UIIcon.peugeot_spinner__basic.atlasResourcePath',RaRefCResource.new(16104769032458085763))\n\n\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.affiliation', TweakDBID.new(\"Factions.Unaffiliated\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.appearanceName',\"None\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.archetypeName', \"vehicle\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.attachmentSlots', ArrayTweakDBID.new(\"AttachmentSlots.Engine1\", \"AttachmentSlots.Engine2\", \"AttachmentSlots.Engine3\", \"AttachmentSlots.Engine4\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.audioResourceName','')\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.brakelightColor', ArrayInt32.new())\n", "file_path": "experiments/new_vehicle.lua", "rank": 38, "score": 55581.42105508801 }, { "content": "-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehEngineData', TweakDBID.new(\"Vehicle.VehicleEngineData_4_Sport\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehImpactTraffic', TweakDBID.new(\"Driving.VehicleImpactTraffic_DefaultParams\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassCombatL_FPPCameraParams', TweakDBID.new(\"Vehicle.VehiclePassengerLCombatFPPCameraParamsDefault\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassCombatL_ProceduralFPPCameraParams', TweakDBID.new(\"Camera.VehicleProceduralFPPCamera_DefaultCombatParams\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassCombatR_FPPCameraParams', TweakDBID.new(\"Vehicle.VehiclePassengerRCombatFPPCameraParamsDefault\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassCombatR_ProceduralFPPCameraParams', TweakDBID.new(\"Camera.VehicleProceduralFPPCamera_DefaultCombatParams\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassL_FPPCameraParams', TweakDBID.new(\"Vehicle.VehiclePassengerLFPPCameraParamsDefault\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassL_ProceduralFPPCameraParams', TweakDBID.new(\"Camera.VehicleProceduralFPPCamera_DefaultParams\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassR_FPPCameraParams', TweakDBID.new(\"Vehicle.VehiclePassengerRFPPCameraParamsDefault\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehPassR_ProceduralFPPCameraParams', TweakDBID.new(\"Camera.VehicleProceduralFPPCamera_DefaultParams\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehWheelDimensionsSetup', TweakDBID.new(\"Vehicle.v_sport2_peugeot_spinner_inline2\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehicleUIData', TweakDBID.new(\"Vehicle.VehicleQuadraType66UIData\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.visualDestruction', TweakDBID.new(\"Vehicle.VehicleVisualDestructionParamsDefault\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.visualTags', ArrayCName.new(\"Standard\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.weakspots', ArrayTweakDBID.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.weapons', ArrayTweakDBID.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.widgetStyleSheetPath', RaRefCResource.new(0))\n\n\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.animVars', ArrayCName.new(\"sport2_vehicle_seat_front_left\", \"sport2_vehicle_seat_front_right\", \"sport2_vehicle_seat_back_left\", \"sport2_vehicle_seat_back_right\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.barnDoorsTailgate',false)\n", "file_path": "experiments/new_vehicle.lua", "rank": 39, "score": 55578.45630442597 }, { "content": "-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.cameraManagerParams', TweakDBID.new('Camera.VehicleCameraManager_Default'))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.crackLockDifficulty', \"HARD\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.crowdMemberSettings', TweakDBID.new(\"Crowds.Sport_DrivingPackage\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.curvesPath',RaRefCResource.new(14783903123043989255))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.destroyedAppearance',\"quadra_type66__basic_burnt_01\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.destruction', TweakDBID.new(\"Vehicle.VehicleDestructionParamsQuadraType66\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.displayName,gamedataLocKeyWrapper,1618 ')\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.driving', TweakDBID.new(\"Driving.Default_4w\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.effectors', ArrayTweakDBID.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.enableDestruction',true)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.entityTemplatePath', RaRefCResource.new(13101370074149372271))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.fxCollision', TweakDBID.new(\"Vehicle.FxCollision_Default\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.fxWheelsDecals', TweakDBID.new(\"Vehicle.FxWheels_Sport_XL\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.fxWheelsParticles', TweakDBID.new(\"Vehicle.FxWheelsParticles_Default\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.headlightColor', ArrayInt32.new(255, 255, 255, 255 ))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.hijackDifficulty', \"HARD\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.icon', TweakDBID.new(\"UIIcon.peugeot_spinner__basic\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.interiorColor',ArrayInt32.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.interiorDamageColor',ArrayInt32.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.leftBackCamber', 3)\n", "file_path": "experiments/new_vehicle.lua", "rank": 40, "score": 55578.05840791994 }, { "content": "-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.leftBackCamberOffset',Vector3( 0.0199999996, 0, 0 ))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.leftBlinkerlightColor',ArrayInt32.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.leftFrontCamber', 3)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.leftFrontCamberOffset',Vector3( 0.0199999996, 0, 0 ))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.manufacturer', TweakDBID.new(\"Vehicle.Quadra\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.model', TweakDBID.new(\"Vehicle.Type66\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.multiplayerTemplatePaths', ArrayRaRefCResource( ))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.objectActions', ArrayTweakDBID.new( \"VehicleActions.VehicleHijackFrontLeft\", \"VehicleActions.VehicleHijackFrontRight\", \"VehicleActions.VehicleMountFrontLeft\", \"VehicleActions.VehicleMountFrontRight\", \"VehicleActions.VehicleMountBackLeft\", \"VehicleActions.VehicleMountBackRight\", \"VehicleActions.VehicleCrackLockFrontLeft\", \"VehicleActions.VehicleCrackLockFrontRight\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.persistentName',\"None\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.player_audio_resource', \"v_car_quadra_type_66\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.priority', TweakDBID.new(\"SpawnableObjectPriority.Regular\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.queryOnlyExceptions', ArrayCName.new(\"trunk_a\", \"trunk_b\", \"hood_a\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.randomPassengers', ArrayTweakDBID.new( \"Passengers.NightLifeDriverEntry\", \"Passengers.NightLifePassengerFrontEntry\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.reverselightColor',ArrayInt32.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.rightBLinkerlightColor',ArrayInt32.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.rightBackCamber',-3)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.rightBackCamberOffset',Vector3( -0.0199999996, 0, 0 ))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.rightFrontCamber',-3)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.rightFrontCamberOffset',Vector3( -0.0199999996, 0, 0 ))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.savable',false)\n", "file_path": "experiments/new_vehicle.lua", "rank": 41, "score": 55577.834424839944 }, { "content": "-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.statModifierGroups', ArrayTweakDBID.new( \"VehicleStatPreset.BaseCar\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.statModifiers', ArrayTweakDBID.new( \"Vehicle.v_sport2_peugeot_spinner_inline1\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.statPools', ArrayTweakDBID.new( \"BaseStatPools.VehicleHealth\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.tags', ArrayCName.new(\"InteractiveTrunk\", \"Sport\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.tppCameraParams', TweakDBID.new(\"Camera.VehicleTPP_DefaultParams\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.tppCameraPresets', ArrayTweakDBID.new( \"Camera.VehicleTPP_4w_Quadra66_Low_Close\", \"Camera.VehicleTPP_4w_Quadra66_High_Close\", \"Camera.VehicleTPP_4w_Quadra66_Low_Far\", \"Camera.VehicleTPP_4w_Quadra66_High_Far\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.traffic_audio_resource', \"v_car_quadra_type_66_traffic\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.type', TweakDBID.new(\"Vehicle.Car\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.unmountOffsetPosition',Vector3( 1.64999998, 5, 2.5 ))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehAirControl', TweakDBID.new(\"Vehicle.VehicleAirControlCar\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehAirControlAI', TweakDBID.new(\"Vehicle.VehicleAirControlCarAI\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehBehaviorData', TweakDBID.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDataPackage', TweakDBID.new(\"Vehicle.v_sport2_peugeot_spinner_inline0\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDefaultState', TweakDBID.new(\"Vehicle.Veh4WDefaultState\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDriveModelData', TweakDBID.new(\"Vehicle.VehicleDriveModelData_Type66\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDriveModelDataAI', TweakDBID.new())\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDriverCombat_FPPCameraParams', TweakDBID.new(\"Vehicle.VehicleDriverCombatFPPCameraParamsDefault\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDriverCombat_ProceduralFPPCameraParams', TweakDBID.new(\"Camera.VehicleProceduralFPPCamera_DefaultCombatParams\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDriver_FPPCameraParams', TweakDBID.new(\"Vehicle.v_sport2_peugeot_spinner_inline5\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner.vehDriver_ProceduralFPPCameraParams', TweakDBID.new(\"Camera.VehicleProceduralFPPCamera_DefaultParams\"))\n", "file_path": "experiments/new_vehicle.lua", "rank": 42, "score": 55577.74260033424 }, { "content": "-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.spoilerSpeedToDeploy',20)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.spoilerSpeedToRetract',10)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.stealing',3.70000005)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.stealing_open',3.29999995)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.supportsCombat',true)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.switchSeats',1.54999995)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.toCombat',0.699999988)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.vehSeatSet', TweakDBID.new(\"Vehicle.Vehicle2SeatSetDefault\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline1.modifierType',\"Additive\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline1.statType', TweakDBID.new(\"BaseStats.PowerLevel\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline1.value',5)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline2.backPreset', TweakDBID.new(\"Vehicle.v_sport2_peugeot_spinner_inline4\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline2.frontPreset', TweakDBID.new(\"Vehicle.v_sport2_peugeot_spinner_inline3\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline3.rimRadius',0.239999995)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline3.tireRadius',0.400000006)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline3.tireWidth',0.300000012)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline3.wheelOffset',0.0500000007)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline4.rimRadius',0.239999995)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline4.tireRadius',0.409999996)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline4.tireWidth',0.439999998)\n", "file_path": "experiments/new_vehicle.lua", "rank": 43, "score": 55575.98157290922 }, { "content": "-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.boneNames', ArrayCName.new(\"seat_front_left\", \"seat_front_right\", \"seat_back_left\", \"seat_back_right\"))\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.canStoreBody',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.disableSwitchSeats',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.entering',2.4000001)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.exitDelay',0.400000006)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.fppCameraOverride',\"None\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.fromCombat',0.800000012)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.hasSiren',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.hasSpoiler',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.hasTurboCharger',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.interactiveHood',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.interactiveTrunk',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.knockOffForce',13)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.normal_open',1.70000005)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.open_close_duration',1.20000005)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.parkingAngle',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.seatingTemplateOverride',\"sport2_vehicle\")\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.slideDuration',0.800000012)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.slidingRearDoors',false)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline0.speedToClose',2)\n", "file_path": "experiments/new_vehicle.lua", "rank": 44, "score": 55574.546204850885 }, { "content": "-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline4.wheelOffset',0.0500000007)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.forward_offset_value',0.100000001)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.is_forward_offset',1)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.is_paralax',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.is_pitch_off',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.is_yaw_off',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_offset_vertical',0.0500000007)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_pitch_forward_down_ratio',1)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_pitch_forward_offset',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_yaw_left_offset',0.150000006)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_yaw_left_up_offset',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_yaw_offset_active_angle',30)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_yaw_right_offset',0.150000006)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.lookat_yaw_right_up_offset',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.paralax_forward_offset',0.100000001)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.paralax_radius',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.upperbody_pitch_weight',0)\n\n-- TweakDB:SetFlat('Vehicle.v_sport2_peugeot_spinner_inline5.upperbody_yaw_weight',0)\n\n\n\n-- end)", "file_path": "experiments/new_vehicle.lua", "rank": 45, "score": 55572.14135821905 }, { "content": "\n\n#if __cplusplus >= 201402L // C++14 and beyond\n\nusing std::make_unique;\n\n#else\n\ntemplate<typename T, typename... Args>\n\nstd::unique_ptr<T> make_unique(Args &&...args)\n\n{\n\n static_assert(!std::is_array<T>::value, \"arrays not supported\");\n\n return std::unique_ptr<T>(new T(std::forward<Args>(args)...));\n\n}\n\n#endif\n\n} // namespace details\n\n} // namespace spdlog\n\n\n\n#ifdef SPDLOG_HEADER_ONLY\n\n# include \"common-inl.h\"\n\n#endif\n", "file_path": "deps/spdlog/include/spdlog/common.h", "rank": 46, "score": 51884.796320291854 }, { "content": " virtual void sink_it_(const details::log_msg &msg);\n\n virtual void flush_();\n\n void dump_backtrace_();\n\n bool should_flush_(const details::log_msg &msg);\n\n\n\n // handle errors during logging.\n\n // default handler prints the error to stderr at max rate of 1 message/sec.\n\n void err_handler_(const std::string &msg);\n\n};\n\n\n\nvoid swap(logger &a, logger &b);\n\n\n\n} // namespace spdlog\n\n\n\n#ifdef SPDLOG_HEADER_ONLY\n\n# include \"logger-inl.h\"\n\n#endif\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 47, "score": 51880.361685382304 }, { "content": " {\n\n return FMOD5_DSP_SetParameterFloat(this.handle, index, value);\n\n }\n\n public RESULT setParameterInt(int index, int value)\n\n {\n\n return FMOD5_DSP_SetParameterInt(this.handle, index, value);\n\n }\n\n public RESULT setParameterBool(int index, bool value)\n\n {\n\n return FMOD5_DSP_SetParameterBool(this.handle, index, value);\n\n }\n\n public RESULT setParameterData(int index, byte[] data)\n\n {\n\n return FMOD5_DSP_SetParameterData(this.handle, index, Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), (uint)data.Length);\n\n }\n\n public RESULT getParameterFloat(int index, out float value)\n\n {\n\n return FMOD5_DSP_GetParameterFloat(this.handle, index, out value, IntPtr.Zero, 0);\n\n }\n\n public RESULT getParameterInt(int index, out int value)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 48, "score": 51879.51971560973 }, { "content": " void log(level::level_enum lvl, fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename T>\n\n void log(level::level_enum lvl, const T &msg)\n\n {\n\n log(source_loc{}, lvl, msg);\n\n }\n\n\n\n // T can be statically converted to string_view\n\n template<class T, typename std::enable_if<std::is_convertible<const T &, spdlog::string_view_t>::value, int>::type = 0>\n\n void log(source_loc loc, level::level_enum lvl, const T &msg)\n\n {\n\n log(loc, lvl, string_view_t{msg});\n\n }\n\n\n\n // T cannot be statically converted to format string (including string_view)\n\n template<class T, typename std::enable_if<!is_convertible_to_any_format_string<const T &>::value, int>::type = 0>\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 49, "score": 51879.21063254474 }, { "content": " FMOD_RESULT F_API getOutput (int index, DSP **output, DSPConnection **outputconnection);\n\n\n\n // DSP unit control.\n\n FMOD_RESULT F_API setActive (bool active);\n\n FMOD_RESULT F_API getActive (bool *active);\n\n FMOD_RESULT F_API setBypass (bool bypass);\n\n FMOD_RESULT F_API getBypass (bool *bypass);\n\n FMOD_RESULT F_API setWetDryMix (float prewet, float postwet, float dry);\n\n FMOD_RESULT F_API getWetDryMix (float *prewet, float *postwet, float *dry);\n\n FMOD_RESULT F_API setChannelFormat (FMOD_CHANNELMASK channelmask, int numchannels, FMOD_SPEAKERMODE source_speakermode);\n\n FMOD_RESULT F_API getChannelFormat (FMOD_CHANNELMASK *channelmask, int *numchannels, FMOD_SPEAKERMODE *source_speakermode);\n\n FMOD_RESULT F_API getOutputChannelFormat (FMOD_CHANNELMASK inmask, int inchannels, FMOD_SPEAKERMODE inspeakermode, FMOD_CHANNELMASK *outmask, int *outchannels, FMOD_SPEAKERMODE *outspeakermode);\n\n FMOD_RESULT F_API reset ();\n\n\n\n // DSP parameter control.\n\n FMOD_RESULT F_API setParameterFloat (int index, float value);\n\n FMOD_RESULT F_API setParameterInt (int index, int value);\n\n FMOD_RESULT F_API setParameterBool (int index, bool value);\n\n FMOD_RESULT F_API setParameterData (int index, void *data, unsigned int length);\n\n FMOD_RESULT F_API getParameterFloat (int index, float *value, char *valuestr, int valuestrlen);\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 50, "score": 51879.0976040828 }, { "content": " byte[] encodedBuffer = new byte[128];\n\n char[] decodedBuffer = new char[128];\n\n bool inUse;\n\n GCHandle gcHandle;\n\n\n\n public bool InUse() { return inUse; }\n\n public void SetInUse() { inUse = true; }\n\n\n\n private int roundUpPowerTwo(int number)\n\n {\n\n int newNumber = 1;\n\n while (newNumber <= number)\n\n {\n\n newNumber *= 2;\n\n }\n\n\n\n return newNumber;\n\n }\n\n\n\n public byte[] byteFromStringUTF8(string s)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 51, "score": 51878.40396256471 }, { "content": " template<typename T>\n\n void warn(const T &msg)\n\n {\n\n log(level::warn, msg);\n\n }\n\n\n\n template<typename T>\n\n void error(const T &msg)\n\n {\n\n log(level::err, msg);\n\n }\n\n\n\n template<typename T>\n\n void critical(const T &msg)\n\n {\n\n log(level::critical, msg);\n\n }\n\n\n\n // return true logging is enabled for the given level.\n\n bool should_log(level::level_enum msg_level) const\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 52, "score": 51877.99501358142 }, { "content": "\n\n // create new logger with same sinks and configuration.\n\n virtual std::shared_ptr<logger> clone(std::string logger_name);\n\n\n\nprotected:\n\n std::string name_;\n\n std::vector<sink_ptr> sinks_;\n\n spdlog::level_t level_{level::info};\n\n spdlog::level_t flush_level_{level::off};\n\n err_handler custom_err_handler_{nullptr};\n\n details::backtracer tracer_;\n\n\n\n // common implementation for after templated public api has been resolved\n\n template<typename... Args>\n\n void log_(source_loc loc, level::level_enum lvl, string_view_t fmt, Args &&...args)\n\n {\n\n bool log_enabled = should_log(lvl);\n\n bool traceback_enabled = tracer_.enabled();\n\n if (!log_enabled && !traceback_enabled)\n\n {\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 53, "score": 51877.98964519279 }, { "content": " bool log_enabled = should_log(lvl);\n\n bool traceback_enabled = tracer_.enabled();\n\n if (!log_enabled && !traceback_enabled)\n\n {\n\n return;\n\n }\n\n\n\n details::log_msg log_msg(loc, name_, lvl, msg);\n\n log_it_(log_msg, log_enabled, traceback_enabled);\n\n }\n\n\n\n void log(level::level_enum lvl, string_view_t msg)\n\n {\n\n log(source_loc{}, lvl, msg);\n\n }\n\n\n\n template<typename... Args>\n\n void trace(fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::trace, fmt, std::forward<Args>(args)...);\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 54, "score": 51876.3246310818 }, { "content": " FMOD_RESULT F_API getParameterInt (int index, int *value, char *valuestr, int valuestrlen);\n\n FMOD_RESULT F_API getParameterBool (int index, bool *value, char *valuestr, int valuestrlen);\n\n FMOD_RESULT F_API getParameterData (int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);\n\n FMOD_RESULT F_API getNumParameters (int *numparams);\n\n FMOD_RESULT F_API getParameterInfo (int index, FMOD_DSP_PARAMETER_DESC **desc);\n\n FMOD_RESULT F_API getDataParameterIndex (int datatype, int *index);\n\n FMOD_RESULT F_API showConfigDialog (void *hwnd, bool show);\n\n\n\n // DSP attributes.\n\n FMOD_RESULT F_API getInfo (char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);\n\n FMOD_RESULT F_API getType (FMOD_DSP_TYPE *type);\n\n FMOD_RESULT F_API getIdle (bool *idle);\n\n\n\n // Userdata set/get.\n\n FMOD_RESULT F_API setUserData (void *userdata);\n\n FMOD_RESULT F_API getUserData (void **userdata);\n\n\n\n // Metering.\n\n FMOD_RESULT F_API setMeteringEnabled (bool inputEnabled, bool outputEnabled);\n\n FMOD_RESULT F_API getMeteringEnabled (bool *inputEnabled, bool *outputEnabled);\n\n FMOD_RESULT F_API getMeteringInfo (FMOD_DSP_METERING_INFO *inputInfo, FMOD_DSP_METERING_INFO *outputInfo);\n\n FMOD_RESULT F_API getCPUUsage (unsigned int *exclusive, unsigned int *inclusive);\n\n };\n\n\n\n\n\n /*\n\n 'DSPConnection' API\n\n */\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 55, "score": 51875.8509503888 }, { "content": " FLOAT,\n\n STRING,\n\n STRING_UTF16,\n\n STRING_UTF16BE,\n\n STRING_UTF8,\n\n\n\n MAX\n\n }\n\n\n\n [StructLayout(LayoutKind.Sequential)]\n\n public struct TAG\n\n {\n\n public TAGTYPE type;\n\n public TAGDATATYPE datatype;\n\n public StringWrapper name;\n\n public IntPtr data;\n\n public uint datalen;\n\n public bool updated;\n\n }\n\n\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 56, "score": 51875.756135988835 }, { "content": " FMOD_RESULT F_API setVolume (float volume);\n\n FMOD_RESULT F_API getVolume (float *volume);\n\n FMOD_RESULT F_API stop ();\n\n\n\n // Information only functions.\n\n FMOD_RESULT F_API getName (char *name, int namelen);\n\n FMOD_RESULT F_API getNumSounds (int *numsounds);\n\n FMOD_RESULT F_API getSound (int index, Sound **sound);\n\n FMOD_RESULT F_API getNumPlaying (int *numplaying);\n\n\n\n // Userdata set/get.\n\n FMOD_RESULT F_API setUserData (void *userdata);\n\n FMOD_RESULT F_API getUserData (void **userdata);\n\n };\n\n\n\n /*\n\n 'DSP' API\n\n */\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 57, "score": 51875.083171211736 }, { "content": " RESULT getReverbProperties (int instance, out float wet);\n\n RESULT setLowPassGain (float gain);\n\n RESULT getLowPassGain (out float gain);\n\n RESULT setMode (MODE mode);\n\n RESULT getMode (out MODE mode);\n\n RESULT setCallback (CHANNELCONTROL_CALLBACK callback);\n\n RESULT isPlaying (out bool isplaying);\n\n\n\n // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.\n\n RESULT setPan (float pan);\n\n RESULT setMixLevelsOutput (float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);\n\n RESULT setMixLevelsInput (float[] levels, int numlevels);\n\n RESULT setMixMatrix (float[] matrix, int outchannels, int inchannels, int inchannel_hop);\n\n RESULT getMixMatrix (float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);\n\n\n\n // Clock based functionality.\n\n RESULT getDSPClock (out ulong dspclock, out ulong parentclock);\n\n RESULT setDelay (ulong dspclock_start, ulong dspclock_end, bool stopchannels);\n\n RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end);\n\n RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels);\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 58, "score": 51874.8233424621 }, { "content": " {\n\n return msg_level >= level_.load(std::memory_order_relaxed);\n\n }\n\n\n\n // return true if backtrace logging is enabled.\n\n bool should_backtrace() const\n\n {\n\n return tracer_.enabled();\n\n }\n\n\n\n void set_level(level::level_enum log_level);\n\n\n\n level::level_enum level() const;\n\n\n\n const std::string &name() const;\n\n\n\n // set formatting for the sinks in this logger.\n\n // each sink will get a separate instance of the formatter object.\n\n void set_formatter(std::unique_ptr<formatter> f);\n\n\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 59, "score": 51874.76545636532 }, { "content": " void log(source_loc loc, level::level_enum lvl, const T &msg)\n\n {\n\n log(loc, lvl, \"{}\", msg);\n\n }\n\n\n\n void log(log_clock::time_point log_time, source_loc loc, level::level_enum lvl, string_view_t msg)\n\n {\n\n bool log_enabled = should_log(lvl);\n\n bool traceback_enabled = tracer_.enabled();\n\n if (!log_enabled && !traceback_enabled)\n\n {\n\n return;\n\n }\n\n\n\n details::log_msg log_msg(log_time, loc, name_, lvl, msg);\n\n log_it_(log_msg, log_enabled, traceback_enabled);\n\n }\n\n\n\n void log(source_loc loc, level::level_enum lvl, string_view_t msg)\n\n {\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 60, "score": 51874.7599478627 }, { "content": " FMOD_RESULT F_API getPolygonAttributes (int index, float *directocclusion, float *reverbocclusion, bool *doublesided);\n\n\n\n // Object manipulation.\n\n FMOD_RESULT F_API setActive (bool active);\n\n FMOD_RESULT F_API getActive (bool *active);\n\n FMOD_RESULT F_API setRotation (const FMOD_VECTOR *forward, const FMOD_VECTOR *up);\n\n FMOD_RESULT F_API getRotation (FMOD_VECTOR *forward, FMOD_VECTOR *up);\n\n FMOD_RESULT F_API setPosition (const FMOD_VECTOR *position);\n\n FMOD_RESULT F_API getPosition (FMOD_VECTOR *position);\n\n FMOD_RESULT F_API setScale (const FMOD_VECTOR *scale);\n\n FMOD_RESULT F_API getScale (FMOD_VECTOR *scale);\n\n FMOD_RESULT F_API save (void *data, int *datasize);\n\n\n\n // Userdata set/get.\n\n FMOD_RESULT F_API setUserData (void *userdata);\n\n FMOD_RESULT F_API getUserData (void **userdata);\n\n };\n\n\n\n\n\n /*\n\n 'Reverb' API\n\n */\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 61, "score": 51874.66999771017 }, { "content": " 'ChannelControl' API\n\n */\n\n interface IChannelControl\n\n {\n\n RESULT getSystemObject (out System system);\n\n\n\n // General control functionality for Channels and ChannelGroups.\n\n RESULT stop ();\n\n RESULT setPaused (bool paused);\n\n RESULT getPaused (out bool paused);\n\n RESULT setVolume (float volume);\n\n RESULT getVolume (out float volume);\n\n RESULT setVolumeRamp (bool ramp);\n\n RESULT getVolumeRamp (out bool ramp);\n\n RESULT getAudibility (out float audibility);\n\n RESULT setPitch (float pitch);\n\n RESULT getPitch (out float pitch);\n\n RESULT setMute (bool mute);\n\n RESULT getMute (out bool mute);\n\n RESULT setReverbProperties (int instance, float wet);\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 62, "score": 51874.66700380716 }, { "content": "#endif\n\n\n\n template<typename T>\n\n void trace(const T &msg)\n\n {\n\n log(level::trace, msg);\n\n }\n\n\n\n template<typename T>\n\n void debug(const T &msg)\n\n {\n\n log(level::debug, msg);\n\n }\n\n\n\n template<typename T>\n\n void info(const T &msg)\n\n {\n\n log(level::info, msg);\n\n }\n\n\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 63, "score": 51874.6019693625 }, { "content": " {\n\n int decodedLength = encoding.GetCharCount(encodedBuffer, 0, nativeLen);\n\n if (decodedLength > decodedBuffer.Length)\n\n {\n\n decodedBuffer = new char[roundUpPowerTwo(decodedLength)];\n\n }\n\n }\n\n\n\n int charCount = encoding.GetChars(encodedBuffer, 0, nativeLen, decodedBuffer, 0);\n\n\n\n return new String(decodedBuffer, 0, charCount);\n\n }\n\n\n\n public void Dispose()\n\n {\n\n if (gcHandle.IsAllocated)\n\n {\n\n gcHandle.Free();\n\n }\n\n lock (encoders)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 64, "score": 51874.58164242964 }, { "content": " FMOD_RESULT F_API set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);\n\n FMOD_RESULT F_API get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume);\n\n FMOD_RESULT F_API set3DCustomRolloff (FMOD_VECTOR *points, int numpoints);\n\n FMOD_RESULT F_API get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints);\n\n FMOD_RESULT F_API getSubSound (int index, Sound **subsound);\n\n FMOD_RESULT F_API getSubSoundParent (Sound **parentsound);\n\n FMOD_RESULT F_API getName (char *name, int namelen);\n\n FMOD_RESULT F_API getLength (unsigned int *length, FMOD_TIMEUNIT lengthtype);\n\n FMOD_RESULT F_API getFormat (FMOD_SOUND_TYPE *type, FMOD_SOUND_FORMAT *format, int *channels, int *bits);\n\n FMOD_RESULT F_API getNumSubSounds (int *numsubsounds);\n\n FMOD_RESULT F_API getNumTags (int *numtags, int *numtagsupdated);\n\n FMOD_RESULT F_API getTag (const char *name, int index, FMOD_TAG *tag);\n\n FMOD_RESULT F_API getOpenState (FMOD_OPENSTATE *openstate, unsigned int *percentbuffered, bool *starving, bool *diskbusy);\n\n FMOD_RESULT F_API readData (void *buffer, unsigned int length, unsigned int *read);\n\n FMOD_RESULT F_API seekData (unsigned int pcm);\n\n\n\n FMOD_RESULT F_API setSoundGroup (SoundGroup *soundgroup);\n\n FMOD_RESULT F_API getSoundGroup (SoundGroup **soundgroup);\n\n\n\n // Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks.\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 65, "score": 51874.43434717767 }, { "content": " FMOD_RESULT F_API getAudibility (float *audibility);\n\n FMOD_RESULT F_API setPitch (float pitch);\n\n FMOD_RESULT F_API getPitch (float *pitch);\n\n FMOD_RESULT F_API setMute (bool mute);\n\n FMOD_RESULT F_API getMute (bool *mute);\n\n FMOD_RESULT F_API setReverbProperties (int instance, float wet);\n\n FMOD_RESULT F_API getReverbProperties (int instance, float *wet);\n\n FMOD_RESULT F_API setLowPassGain (float gain);\n\n FMOD_RESULT F_API getLowPassGain (float *gain);\n\n FMOD_RESULT F_API setMode (FMOD_MODE mode);\n\n FMOD_RESULT F_API getMode (FMOD_MODE *mode);\n\n FMOD_RESULT F_API setCallback (FMOD_CHANNELCONTROL_CALLBACK callback);\n\n FMOD_RESULT F_API isPlaying (bool *isplaying);\n\n\n\n // Panning and level adjustment.\n\n // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.\n\n FMOD_RESULT F_API setPan (float pan);\n\n FMOD_RESULT F_API setMixLevelsOutput (float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);\n\n FMOD_RESULT F_API setMixLevelsInput (float *levels, int numlevels);\n\n FMOD_RESULT F_API setMixMatrix (float *matrix, int outchannels, int inchannels, int inchannel_hop = 0);\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 66, "score": 51874.182068074144 }, { "content": " return;\n\n }\n\n SPDLOG_TRY\n\n {\n\n // format to wmemory_buffer and convert to utf8\n\n fmt::wmemory_buffer wbuf;\n\n fmt::detail::vformat_to(wbuf, fmt, fmt::make_format_args<fmt::wformat_context>(args...));\n\n memory_buf_t buf;\n\n details::os::wstr_to_utf8buf(wstring_view_t(wbuf.data(), wbuf.size()), buf);\n\n details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));\n\n log_it_(log_msg, log_enabled, traceback_enabled);\n\n }\n\n SPDLOG_LOGGER_CATCH(loc)\n\n }\n\n\n\n // T can be statically converted to wstring_view, and no formatting needed.\n\n template<class T, typename std::enable_if<std::is_convertible<const T &, spdlog::wstring_view_t>::value, int>::type = 0>\n\n void log_(source_loc loc, level::level_enum lvl, const T &msg)\n\n {\n\n bool log_enabled = should_log(lvl);\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 67, "score": 51874.06942705999 }, { "content": " return;\n\n }\n\n SPDLOG_TRY\n\n {\n\n memory_buf_t buf;\n\n fmt::detail::vformat_to(buf, fmt, fmt::make_format_args(args...));\n\n details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));\n\n log_it_(log_msg, log_enabled, traceback_enabled);\n\n }\n\n SPDLOG_LOGGER_CATCH(loc)\n\n }\n\n\n\n#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT\n\n template<typename... Args>\n\n void log_(source_loc loc, level::level_enum lvl, wstring_view_t fmt, Args &&...args)\n\n {\n\n bool log_enabled = should_log(lvl);\n\n bool traceback_enabled = tracer_.enabled();\n\n if (!log_enabled && !traceback_enabled)\n\n {\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 68, "score": 51874.04573867619 }, { "content": " }\n\n public RESULT getActive(out bool active)\n\n {\n\n return FMOD5_DSP_GetActive(this.handle, out active);\n\n }\n\n public RESULT setBypass(bool bypass)\n\n {\n\n return FMOD5_DSP_SetBypass(this.handle, bypass);\n\n }\n\n public RESULT getBypass(out bool bypass)\n\n {\n\n return FMOD5_DSP_GetBypass(this.handle, out bypass);\n\n }\n\n public RESULT setWetDryMix(float prewet, float postwet, float dry)\n\n {\n\n return FMOD5_DSP_SetWetDryMix(this.handle, prewet, postwet, dry);\n\n }\n\n public RESULT getWetDryMix(out float prewet, out float postwet, out float dry)\n\n {\n\n return FMOD5_DSP_GetWetDryMix(this.handle, out prewet, out postwet, out dry);\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 69, "score": 51873.76912030585 }, { "content": " FMOD_RESULT F_API set3DAttributes (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel);\n\n FMOD_RESULT F_API get3DAttributes (FMOD_VECTOR *pos, FMOD_VECTOR *vel);\n\n FMOD_RESULT F_API set3DMinMaxDistance (float mindistance, float maxdistance);\n\n FMOD_RESULT F_API get3DMinMaxDistance (float *mindistance, float *maxdistance);\n\n FMOD_RESULT F_API set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);\n\n FMOD_RESULT F_API get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume);\n\n FMOD_RESULT F_API set3DConeOrientation (FMOD_VECTOR *orientation);\n\n FMOD_RESULT F_API get3DConeOrientation (FMOD_VECTOR *orientation);\n\n FMOD_RESULT F_API set3DCustomRolloff (FMOD_VECTOR *points, int numpoints);\n\n FMOD_RESULT F_API get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints);\n\n FMOD_RESULT F_API set3DOcclusion (float directocclusion, float reverbocclusion);\n\n FMOD_RESULT F_API get3DOcclusion (float *directocclusion, float *reverbocclusion);\n\n FMOD_RESULT F_API set3DSpread (float angle);\n\n FMOD_RESULT F_API get3DSpread (float *angle);\n\n FMOD_RESULT F_API set3DLevel (float level);\n\n FMOD_RESULT F_API get3DLevel (float *level);\n\n FMOD_RESULT F_API set3DDopplerLevel (float level);\n\n FMOD_RESULT F_API get3DDopplerLevel (float *level);\n\n FMOD_RESULT F_API set3DDistanceFilter (bool custom, float customLevel, float centerFreq);\n\n FMOD_RESULT F_API get3DDistanceFilter (bool *custom, float *customLevel, float *centerFreq);\n\n\n\n // Userdata set/get.\n\n FMOD_RESULT F_API setUserData (void *userdata);\n\n FMOD_RESULT F_API getUserData (void **userdata);\n\n };\n\n\n\n /*\n\n 'Channel' API.\n\n */\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 70, "score": 51873.59985691029 }, { "content": " return result;\n\n }\n\n public RESULT getDataParameterIndex(int datatype, out int index)\n\n {\n\n return FMOD5_DSP_GetDataParameterIndex(this.handle, datatype, out index);\n\n }\n\n public RESULT showConfigDialog(IntPtr hwnd, bool show)\n\n {\n\n return FMOD5_DSP_ShowConfigDialog(this.handle, hwnd, show);\n\n }\n\n\n\n // DSP attributes.\n\n public RESULT getInfo(out string name, out uint version, out int channels, out int configwidth, out int configheight)\n\n {\n\n IntPtr nameMem = Marshal.AllocHGlobal(32);\n\n\n\n RESULT result = FMOD5_DSP_GetInfo(this.handle, nameMem, out version, out channels, out configwidth, out configheight);\n\n using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())\n\n {\n\n name = encoder.stringFromNative(nameMem);\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 71, "score": 51873.548963865745 }, { "content": " private static extern RESULT FMOD5_Channel_Get3DDistanceFilter (IntPtr channel, out bool custom, out float customLevel, out float centerFreq);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_Channel_SetUserData (IntPtr channel, IntPtr userdata);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_Channel_GetUserData (IntPtr channel, out IntPtr userdata);\n\n #endregion\n\n\n\n #region wrapperinternal\n\n\n\n public IntPtr handle;\n\n\n\n public Channel(IntPtr ptr) { this.handle = ptr; }\n\n public bool hasHandle() { return this.handle != IntPtr.Zero; }\n\n public void clearHandle() { this.handle = IntPtr.Zero; }\n\n\n\n #endregion\n\n }\n\n\n\n /*\n\n 'ChannelGroup' API\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 72, "score": 51873.5239304048 }, { "content": " bool traceback_enabled = tracer_.enabled();\n\n if (!log_enabled && !traceback_enabled)\n\n {\n\n return;\n\n }\n\n SPDLOG_TRY\n\n {\n\n memory_buf_t buf;\n\n details::os::wstr_to_utf8buf(msg, buf);\n\n details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));\n\n log_it_(log_msg, log_enabled, traceback_enabled);\n\n }\n\n SPDLOG_LOGGER_CATCH(loc)\n\n }\n\n\n\n#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT\n\n\n\n // log the given message (if the given log level is high enough),\n\n // and save backtrace (if backtrace is enabled).\n\n void log_it_(const details::log_msg &log_msg, bool log_enabled, bool traceback_enabled);\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 73, "score": 51873.46972579623 }, { "content": " FMOD_RESULT F_API getReverbProperties (int instance, FMOD_REVERB_PROPERTIES *prop);\n\n\n\n // System level DSP functionality.\n\n FMOD_RESULT F_API lockDSP ();\n\n FMOD_RESULT F_API unlockDSP ();\n\n\n\n // Recording API.\n\n FMOD_RESULT F_API getRecordNumDrivers (int *numdrivers, int *numconnected);\n\n FMOD_RESULT F_API getRecordDriverInfo (int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels, FMOD_DRIVER_STATE *state);\n\n FMOD_RESULT F_API getRecordPosition (int id, unsigned int *position);\n\n FMOD_RESULT F_API recordStart (int id, Sound *sound, bool loop);\n\n FMOD_RESULT F_API recordStop (int id);\n\n FMOD_RESULT F_API isRecording (int id, bool *recording);\n\n\n\n // Geometry API.\n\n FMOD_RESULT F_API createGeometry (int maxpolygons, int maxvertices, Geometry **geometry);\n\n FMOD_RESULT F_API setGeometrySettings (float maxworldsize);\n\n FMOD_RESULT F_API getGeometrySettings (float *maxworldsize);\n\n FMOD_RESULT F_API loadGeometry (const void *data, int datasize, Geometry **geometry);\n\n FMOD_RESULT F_API getGeometryOcclusion (const FMOD_VECTOR *listener, const FMOD_VECTOR *source, float *direct, float *reverb);\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 74, "score": 51873.25778250737 }, { "content": " [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_SetBypass (IntPtr dsp, bool bypass);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetBypass (IntPtr dsp, out bool bypass);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_SetWetDryMix (IntPtr dsp, float prewet, float postwet, float dry);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetWetDryMix (IntPtr dsp, out float prewet, out float postwet, out float dry);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_SetChannelFormat (IntPtr dsp, CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetChannelFormat (IntPtr dsp, out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetOutputChannelFormat (IntPtr dsp, CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_Reset (IntPtr dsp);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_SetParameterFloat (IntPtr dsp, int index, float value);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_SetParameterInt (IntPtr dsp, int index, int value);\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 75, "score": 51873.233504588534 }, { "content": " [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_SetParameterBool (IntPtr dsp, int index, bool value);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_SetParameterData (IntPtr dsp, int index, IntPtr data, uint length);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetParameterFloat (IntPtr dsp, int index, out float value, IntPtr valuestr, int valuestrlen);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetParameterInt (IntPtr dsp, int index, out int value, IntPtr valuestr, int valuestrlen);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetParameterBool (IntPtr dsp, int index, out bool value, IntPtr valuestr, int valuestrlen);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetParameterData (IntPtr dsp, int index, out IntPtr data, out uint length, IntPtr valuestr, int valuestrlen);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetNumParameters (IntPtr dsp, out int numparams);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetParameterInfo (IntPtr dsp, int index, out IntPtr desc);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_GetDataParameterIndex (IntPtr dsp, int datatype, out int index);\n\n [DllImport(VERSION.dll)]\n\n private static extern RESULT FMOD5_DSP_ShowConfigDialog (IntPtr dsp, IntPtr hwnd, bool show);\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 76, "score": 51873.1707272957 }, { "content": " }\n\n\n\n template<typename... Args>\n\n void debug(fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::debug, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void info(fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::info, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void warn(fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::warn, fmt, std::forward<Args>(args)...);\n\n }\n\n\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 77, "score": 51873.15192214722 }, { "content": " template<typename... Args>\n\n void error(fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::err, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void critical(fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::critical, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT\n\n template<typename... Args>\n\n void log(level::level_enum lvl, fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n\n log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 78, "score": 51873.09171253565 }, { "content": " void log(source_loc loc, level::level_enum lvl, fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n\n log_(loc, lvl, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void trace(fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::trace, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void debug(fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::debug, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void info(fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 79, "score": 51872.97320445541 }, { "content": " log(level::info, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void warn(fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::warn, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void error(fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::err, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n\n void critical(fmt::wformat_string<Args...> fmt, Args &&...args)\n\n {\n\n log(level::critical, fmt, std::forward<Args>(args)...);\n\n }\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 80, "score": 51872.78100704474 }, { "content": " return FMOD5_System_Update(this.handle);\n\n }\n\n public RESULT setSpeakerPosition(SPEAKER speaker, float x, float y, bool active)\n\n {\n\n return FMOD5_System_SetSpeakerPosition(this.handle, speaker, x, y, active);\n\n }\n\n public RESULT getSpeakerPosition(SPEAKER speaker, out float x, out float y, out bool active)\n\n {\n\n return FMOD5_System_GetSpeakerPosition(this.handle, speaker, out x, out y, out active);\n\n }\n\n public RESULT setStreamBufferSize(uint filebuffersize, TIMEUNIT filebuffersizetype)\n\n {\n\n return FMOD5_System_SetStreamBufferSize(this.handle, filebuffersize, filebuffersizetype);\n\n }\n\n public RESULT getStreamBufferSize(out uint filebuffersize, out TIMEUNIT filebuffersizetype)\n\n {\n\n return FMOD5_System_GetStreamBufferSize(this.handle, out filebuffersize, out filebuffersizetype);\n\n }\n\n public RESULT set3DSettings(float dopplerscale, float distancefactor, float rolloffscale)\n\n {\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 81, "score": 51872.7651771291 }, { "content": " return FMOD5_Geometry_SetPolygonVertex(this.handle, index, vertexindex, ref vertex);\n\n }\n\n public RESULT getPolygonVertex(int index, int vertexindex, out VECTOR vertex)\n\n {\n\n return FMOD5_Geometry_GetPolygonVertex(this.handle, index, vertexindex, out vertex);\n\n }\n\n public RESULT setPolygonAttributes(int index, float directocclusion, float reverbocclusion, bool doublesided)\n\n {\n\n return FMOD5_Geometry_SetPolygonAttributes(this.handle, index, directocclusion, reverbocclusion, doublesided);\n\n }\n\n public RESULT getPolygonAttributes(int index, out float directocclusion, out float reverbocclusion, out bool doublesided)\n\n {\n\n return FMOD5_Geometry_GetPolygonAttributes(this.handle, index, out directocclusion, out reverbocclusion, out doublesided);\n\n }\n\n\n\n // Object manipulation.\n\n public RESULT setActive(bool active)\n\n {\n\n return FMOD5_Geometry_SetActive(this.handle, active);\n\n }\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 82, "score": 51872.671412002936 }, { "content": " {\n\n return FMOD5_Channel_GetVolumeRamp(this.handle, out ramp);\n\n }\n\n public RESULT getAudibility(out float audibility)\n\n {\n\n return FMOD5_Channel_GetAudibility(this.handle, out audibility);\n\n }\n\n public RESULT setPitch(float pitch)\n\n {\n\n return FMOD5_Channel_SetPitch(this.handle, pitch);\n\n }\n\n public RESULT getPitch(out float pitch)\n\n {\n\n return FMOD5_Channel_GetPitch(this.handle, out pitch);\n\n }\n\n public RESULT setMute(bool mute)\n\n {\n\n return FMOD5_Channel_SetMute(this.handle, mute);\n\n }\n\n public RESULT getMute(out bool mute)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 83, "score": 51872.65251389431 }, { "content": "// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.\n\n// Distributed under the MIT License (http://opensource.org/licenses/MIT)\n\n\n\n#pragma once\n\n\n\n#include <spdlog/fmt/fmt.h>\n\n#include <spdlog/details/log_msg.h>\n\n\n\nnamespace spdlog {\n\n\n", "file_path": "deps/spdlog/include/spdlog/formatter.h", "rank": 84, "score": 51872.641985323055 }, { "content": " {\n\n return FMOD5_ChannelGroup_Set3DLevel(this.handle, level);\n\n }\n\n public RESULT get3DLevel(out float level)\n\n {\n\n return FMOD5_ChannelGroup_Get3DLevel(this.handle, out level);\n\n }\n\n public RESULT set3DDopplerLevel(float level)\n\n {\n\n return FMOD5_ChannelGroup_Set3DDopplerLevel(this.handle, level);\n\n }\n\n public RESULT get3DDopplerLevel(out float level)\n\n {\n\n return FMOD5_ChannelGroup_Get3DDopplerLevel(this.handle, out level);\n\n }\n\n public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq)\n\n {\n\n return FMOD5_ChannelGroup_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq);\n\n }\n\n public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 85, "score": 51872.5289625131 }, { "content": " {\n\n return FMOD5_Channel_SetPaused(this.handle, paused);\n\n }\n\n public RESULT getPaused(out bool paused)\n\n {\n\n return FMOD5_Channel_GetPaused(this.handle, out paused);\n\n }\n\n public RESULT setVolume(float volume)\n\n {\n\n return FMOD5_Channel_SetVolume(this.handle, volume);\n\n }\n\n public RESULT getVolume(out float volume)\n\n {\n\n return FMOD5_Channel_GetVolume(this.handle, out volume);\n\n }\n\n public RESULT setVolumeRamp(bool ramp)\n\n {\n\n return FMOD5_Channel_SetVolumeRamp(this.handle, ramp);\n\n }\n\n public RESULT getVolumeRamp(out bool ramp)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 86, "score": 51872.519998091266 }, { "content": " {\n\n return FMOD5_Channel_Get3DLevel(this.handle, out level);\n\n }\n\n public RESULT set3DDopplerLevel(float level)\n\n {\n\n return FMOD5_Channel_Set3DDopplerLevel(this.handle, level);\n\n }\n\n public RESULT get3DDopplerLevel(out float level)\n\n {\n\n return FMOD5_Channel_Get3DDopplerLevel(this.handle, out level);\n\n }\n\n public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq)\n\n {\n\n return FMOD5_Channel_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq);\n\n }\n\n public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq)\n\n {\n\n return FMOD5_Channel_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq);\n\n }\n\n\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 87, "score": 51872.49747125653 }, { "content": " {\n\n return FMOD5_ChannelGroup_Stop(this.handle);\n\n }\n\n public RESULT setPaused(bool paused)\n\n {\n\n return FMOD5_ChannelGroup_SetPaused(this.handle, paused);\n\n }\n\n public RESULT getPaused(out bool paused)\n\n {\n\n return FMOD5_ChannelGroup_GetPaused(this.handle, out paused);\n\n }\n\n public RESULT setVolume(float volume)\n\n {\n\n return FMOD5_ChannelGroup_SetVolume(this.handle, volume);\n\n }\n\n public RESULT getVolume(out float volume)\n\n {\n\n return FMOD5_ChannelGroup_GetVolume(this.handle, out volume);\n\n }\n\n public RESULT setVolumeRamp(bool ramp)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 88, "score": 51872.468049341136 }, { "content": "\n\n // Logger with sinks init list\n\n logger(std::string name, sinks_init_list sinks)\n\n : logger(std::move(name), sinks.begin(), sinks.end())\n\n {}\n\n\n\n virtual ~logger() = default;\n\n\n\n logger(const logger &other);\n\n logger(logger &&other) SPDLOG_NOEXCEPT;\n\n logger &operator=(logger other) SPDLOG_NOEXCEPT;\n\n void swap(spdlog::logger &other) SPDLOG_NOEXCEPT;\n\n\n\n template<typename... Args>\n\n void log(source_loc loc, level::level_enum lvl, fmt::format_string<Args...> fmt, Args &&...args)\n\n {\n\n log_(loc, lvl, fmt, std::forward<Args>(args)...);\n\n }\n\n\n\n template<typename... Args>\n", "file_path": "deps/spdlog/include/spdlog/logger.h", "rank": 89, "score": 51872.43398222901 }, { "content": " RESULT set3DConeOrientation (ref VECTOR orientation);\n\n RESULT get3DConeOrientation (out VECTOR orientation);\n\n RESULT set3DCustomRolloff (ref VECTOR points, int numpoints);\n\n RESULT get3DCustomRolloff (out IntPtr points, out int numpoints);\n\n RESULT set3DOcclusion (float directocclusion, float reverbocclusion);\n\n RESULT get3DOcclusion (out float directocclusion, out float reverbocclusion);\n\n RESULT set3DSpread (float angle);\n\n RESULT get3DSpread (out float angle);\n\n RESULT set3DLevel (float level);\n\n RESULT get3DLevel (out float level);\n\n RESULT set3DDopplerLevel (float level);\n\n RESULT get3DDopplerLevel (out float level);\n\n RESULT set3DDistanceFilter (bool custom, float customLevel, float centerFreq);\n\n RESULT get3DDistanceFilter (out bool custom, out float customLevel, out float centerFreq);\n\n\n\n // Userdata set/get.\n\n RESULT setUserData (IntPtr userdata);\n\n RESULT getUserData (out IntPtr userdata);\n\n }\n\n\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 90, "score": 51872.40526370504 }, { "content": " {\n\n return FMOD5_ChannelGroup_SetVolumeRamp(this.handle, ramp);\n\n }\n\n public RESULT getVolumeRamp(out bool ramp)\n\n {\n\n return FMOD5_ChannelGroup_GetVolumeRamp(this.handle, out ramp);\n\n }\n\n public RESULT getAudibility(out float audibility)\n\n {\n\n return FMOD5_ChannelGroup_GetAudibility(this.handle, out audibility);\n\n }\n\n public RESULT setPitch(float pitch)\n\n {\n\n return FMOD5_ChannelGroup_SetPitch(this.handle, pitch);\n\n }\n\n public RESULT getPitch(out float pitch)\n\n {\n\n return FMOD5_ChannelGroup_GetPitch(this.handle, out pitch);\n\n }\n\n public RESULT setMute(bool mute)\n", "file_path": "deps/fmod/include/fmod.cs", "rank": 91, "score": 51872.292905755035 }, { "content": "/* ======================================================================================== */\n\n/* FMOD Core API - C++ header file. */\n\n/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2021. */\n\n/* */\n\n/* Use this header in conjunction with fmod_common.h (which contains all the constants / */\n\n/* callbacks) to develop using the C++ language. */\n\n/* */\n\n/* For more detail visit: */\n\n/* https://fmod.com/resources/documentation-api?version=2.0&page=core-api.html */\n\n/* ======================================================================================== */\n\n#ifndef _FMOD_HPP\n\n#define _FMOD_HPP\n\n\n\n#include \"fmod_common.h\"\n\n#include \"fmod.h\"\n\n\n\n/*\n\n FMOD Namespace\n\n*/\n\nnamespace FMOD\n\n{\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 92, "score": 51872.262623245086 }, { "content": " FMOD_RESULT F_API setOutputByPlugin (unsigned int handle);\n\n FMOD_RESULT F_API getOutputByPlugin (unsigned int *handle);\n\n FMOD_RESULT F_API createDSPByPlugin (unsigned int handle, DSP **dsp);\n\n FMOD_RESULT F_API getDSPInfoByPlugin (unsigned int handle, const FMOD_DSP_DESCRIPTION **description);\n\n FMOD_RESULT F_API registerCodec (FMOD_CODEC_DESCRIPTION *description, unsigned int *handle, unsigned int priority = 0);\n\n FMOD_RESULT F_API registerDSP (const FMOD_DSP_DESCRIPTION *description, unsigned int *handle);\n\n FMOD_RESULT F_API registerOutput (const FMOD_OUTPUT_DESCRIPTION *description, unsigned int *handle);\n\n\n\n // Init/Close.\n\n FMOD_RESULT F_API init (int maxchannels, FMOD_INITFLAGS flags, void *extradriverdata);\n\n FMOD_RESULT F_API close ();\n\n\n\n // General post-init system functions.\n\n FMOD_RESULT F_API update (); /* IMPORTANT! CALL THIS ONCE PER FRAME! */\n\n\n\n FMOD_RESULT F_API setSpeakerPosition (FMOD_SPEAKER speaker, float x, float y, bool active);\n\n FMOD_RESULT F_API getSpeakerPosition (FMOD_SPEAKER speaker, float *x, float *y, bool *active);\n\n FMOD_RESULT F_API setStreamBufferSize (unsigned int filebuffersize, FMOD_TIMEUNIT filebuffersizetype);\n\n FMOD_RESULT F_API getStreamBufferSize (unsigned int *filebuffersize, FMOD_TIMEUNIT *filebuffersizetype);\n\n FMOD_RESULT F_API set3DSettings (float dopplerscale, float distancefactor, float rolloffscale);\n", "file_path": "deps/fmod/include/fmod.hpp", "rank": 93, "score": 51871.95069931389 }, { "content": " auto params = hpsb->params;\n\n\n\n if (aOut) {\n\n *aOut = params.comOffset;\n\n }\n\n}\n\n\n\n#include \"LoadResRef.hpp\"\n\n#include <RED4ext/Scripting/Natives/Generated/world/Effect.hpp>\n\n\n\nvoid EffectSpawnerAddEffect(RED4ext::IScriptable *aContext, RED4ext::CStackFrame *aFrame, void *aOut, int64_t a4) {\n\n // RED4ext::red::ResourceReferenceScriptToken value;\n\n // RED4ext::CName name;\n\n // bool valid;\n\n // RED4ext::GetParameter(aFrame, &value);\n\n // RED4ext::GetParameter(aFrame, &name);\n\n aFrame->code++; // skip ParamEnd\n\n\n\n spdlog::info(\"[EffectSpawnerComponent] Adding New Effect\");\n\n\n", "file_path": "src/red4ext/Main.cpp", "rank": 95, "score": 32.666545267785914 }, { "content": "} // namespace Catch\n\n\n\n// end catch_matchers_string.h\n\n// start catch_matchers_vector.h\n\n\n\n#include <algorithm>\n\n\n\nnamespace Catch {\n\nnamespace Matchers {\n\n\n\n namespace Vector {\n\n template<typename T, typename Alloc>\n\n struct ContainsElementMatcher : MatcherBase<std::vector<T, Alloc>> {\n\n\n\n ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {}\n\n\n\n bool match(std::vector<T, Alloc> const &v) const override {\n\n for (auto const& el : v) {\n\n if (el == m_comparator) {\n\n return true;\n", "file_path": "deps/spdlog/tests/catch.hpp", "rank": 96, "score": 30.823023996140662 }, { "content": "} // namespace Catch\n\n\n\n// end catch_matchers_string.h\n\n// start catch_matchers_vector.h\n\n\n\n#include <algorithm>\n\n\n\nnamespace Catch {\n\nnamespace Matchers {\n\n\n\n namespace Vector {\n\n template<typename T, typename Alloc>\n\n struct ContainsElementMatcher : MatcherBase<std::vector<T, Alloc>> {\n\n\n\n ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {}\n\n\n\n bool match(std::vector<T, Alloc> const &v) const override {\n\n for (auto const& el : v) {\n\n if (el == m_comparator) {\n\n return true;\n", "file_path": "deps/detours/tests/catch.hpp", "rank": 97, "score": 30.823023996140662 }, { "content": " }\n\n\n\n auto operator <=( bool value ) -> ExprLhs<bool> {\n\n return ExprLhs<bool>{ value };\n\n }\n\n };\n\n\n\n} // end namespace Catch\n\n\n\n#ifdef _MSC_VER\n\n#pragma warning(pop)\n\n#endif\n\n\n\n// end catch_decomposer.h\n\n// start catch_interfaces_capture.h\n\n\n\n#include <string>\n\n#include <chrono>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "deps/detours/tests/catch.hpp", "rank": 98, "score": 30.26177723412783 }, { "content": " }\n\n\n\n auto operator <=( bool value ) -> ExprLhs<bool> {\n\n return ExprLhs<bool>{ value };\n\n }\n\n };\n\n\n\n} // end namespace Catch\n\n\n\n#ifdef _MSC_VER\n\n#pragma warning(pop)\n\n#endif\n\n\n\n// end catch_decomposer.h\n\n// start catch_interfaces_capture.h\n\n\n\n#include <string>\n\n#include <chrono>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "deps/spdlog/tests/catch.hpp", "rank": 99, "score": 30.261777234127834 } ]
C++
diffkemp/simpll/Utils.cpp
tmalecova/diffkemp
226166cec9044ff23753e7d74b49d2272677c0d6
#include "Utils.h" #include "Config.h" #include <llvm/IR/Instructions.h> #include <llvm/IR/Module.h> #include <llvm/IR/Operator.h> #include <llvm/Support/LineIterator.h> #include <llvm/Support/MemoryBuffer.h> #include <llvm/Support/Path.h> #include <llvm/Support/raw_ostream.h> #include <set> #include <iostream> #include <llvm/IR/PassManager.h> #include <llvm/Passes/PassBuilder.h> #include <llvm/Transforms/Scalar/DCE.h> #include <llvm/Transforms/Scalar/NewGVN.h> #include <llvm/Transforms/Scalar/SimplifyCFG.h> #include <llvm/Transforms/Utils/Cloning.h> const Function *getCalledFunction(const Value *CalledValue) { const Function *fun = dyn_cast<Function>(CalledValue); if (!fun) { if (auto BitCast = dyn_cast<BitCastOperator>(CalledValue)) { fun = dyn_cast<Function>(BitCast->getOperand(0)); } } return fun; } std::string typeName(const Type *Type) { std::string result; raw_string_ostream rso(result); Type->print(rso); rso.str(); result.erase(std::remove(result.begin(), result.end(), ' '), result.end()); std::replace(result.begin(), result.end(), '(', '$'); std::replace(result.begin(), result.end(), ')', '$'); std::replace(result.begin(), result.end(), ',', '_'); return result; } void deleteAliasToFun(Module &Mod, Function *Fun) { std::vector<GlobalAlias *> toRemove; for (auto &alias : Mod.aliases()) { if (alias.getAliasee() == Fun) toRemove.push_back(&alias); } for (auto &alias : toRemove) { alias->replaceAllUsesWith(Fun); alias->eraseFromParent(); } } bool hasSuffix(std::string Name) { size_t dotPos = Name.find_last_of('.'); return dotPos != std::string::npos && Name.find_last_not_of("0123456789.") < dotPos; } std::string dropSuffix(std::string Name) { return Name.substr(0, Name.find_last_of('.')); } std::string joinPath(StringRef DirName, StringRef FileName) { return FileName.startswith(DirName) ? FileName.str() : DirName.str() + sys::path::get_separator().str() + FileName.str(); } std::string getFileForFun(Function *Fun) { if (auto *SubProgram = Fun->getSubprogram()) { if (auto *File = SubProgram->getFile()) return joinPath(File->getDirectory(), File->getFilename()); } return ""; } bool searchCallStackRec(Function *Src, Function *Dest, CallStack &callStack, std::set<Function *> &visited) { visited.insert(Src); for (auto &BB : *Src) { for (auto &Inst : BB) { std::vector<Function *> calledFuns; if (CallInst *Call = dyn_cast<CallInst>(&Inst)) { if (auto c = Call->getCalledFunction()) calledFuns.push_back(c); } for (auto &Op : Inst.operands()) { if (isa<Function>(Op)) calledFuns.push_back(dyn_cast<Function>(Op)); } for (Function *called : calledFuns) { if (called && visited.find(called) == visited.end()) { auto loc = Inst.getDebugLoc(); if (!loc) continue; callStack.push_back(CallInfo(called->getName().str(), getFileForFun(Src), loc.getLine())); if (called == Dest) return true; else { bool found = searchCallStackRec(called, Dest, callStack, visited); if (found) return true; else callStack.pop_back(); } } } } } return false; } CallStack getCallStack(Function &Src, Function &Dest) { CallStack callStack; std::set<Function *> visited; searchCallStackRec(&Src, &Dest, callStack, visited); return callStack; } bool hasSideEffect(const Function &Fun, std::set<const Function *> &Visited) { if (Fun.isDeclaration()) { return !(Fun.getIntrinsicID() == Intrinsic::dbg_declare || Fun.getIntrinsicID() == Intrinsic::dbg_value || Fun.getIntrinsicID() == Intrinsic::expect); } Visited.insert(&Fun); for (auto &BB : Fun) { for (auto &Inst : BB) { if (isa<StoreInst>(&Inst)) return true; if (auto Call = dyn_cast<CallInst>(&Inst)) { const Function *called = Call->getCalledFunction(); if (!called) return true; if (Visited.find(called) != Visited.end()) continue; if (hasSideEffect(*called, Visited)) return true; } } } return false; } bool hasSideEffect(const Function &Fun) { std::set<const Function *> visited; return hasSideEffect(Fun, visited); } bool isAllocFunction(const Function &Fun) { return Fun.getName() == "kzalloc" || Fun.getName() == "__kmalloc" || Fun.getName() == "kmalloc"; } std::string valueAsString(const Constant *Val) { if (auto *IntVal = dyn_cast<ConstantInt>(Val)) { return std::to_string(IntVal->getSExtValue()); } return ""; } StructType *getStructType(const Value *Value) { StructType *Type = nullptr; if (auto PtrTy = dyn_cast<PointerType>(Value->getType())) { if (auto *StructTy = dyn_cast<StructType>(PtrTy->getElementType())) { Type = StructTy; } else if (auto *BitCast = dyn_cast<BitCastInst>(Value)) { if (auto *SrcPtrTy = dyn_cast<PointerType>(BitCast->getSrcTy())) { if (auto *SrcStructTy = dyn_cast<StructType>(SrcPtrTy->getElementType())) Type = SrcStructTy; } } } else Type = dyn_cast<StructType>(Value->getType()); return Type; } void simplifyFunction(Function *Fun) { PassBuilder pb; FunctionPassManager fpm(false); FunctionAnalysisManager fam(false); pb.registerFunctionAnalyses(fam); fpm.addPass(SimplifyCFGPass {}); fpm.addPass(DCEPass {}); fpm.addPass(NewGVNPass {}); fpm.run(*Fun, fam); } AttributeList cleanAttributeList(AttributeList AL) { AttributeList NewAttrList; std::vector<AttributeList::AttrIndex> indices { AttributeList::FirstArgIndex, AttributeList::FunctionIndex, AttributeList::ReturnIndex }; for (AttributeList::AttrIndex i : indices) { AttributeSet AttrSet = AL.getAttributes(i); if (AttrSet.getNumAttributes() != 0) { AttrBuilder AB; for (const Attribute &A : AttrSet) AB.addAttribute(A); NewAttrList = NewAttrList.addAttributes( AL.getContext(), i, AB); } } return NewAttrList; } CallInst *findCallInst(const CallInst *Call, Function *Fun) { if (!Call) return nullptr; for (auto &BB : *Fun) { for (auto &Inst : BB) { if (&Inst == Call) return dyn_cast<CallInst>(&Inst); } } return nullptr; } std::string getSourceFilePath(DIScope *Scope) { return joinPath(Scope->getDirectory(), Scope->getFilename()); } bool isValidCharForIdentifier(char ch) { if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_') return true; else return false; } bool isValidCharForIdentifierStart(char ch) { if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || ch == '_') return true; else return false; } void findAndReplace(std::string &input, std::string find, std::string replace) { int position = 0; while ((position = input.find(find, position)) != std::string::npos) { input.replace(position, find.length(), replace); position += replace.length(); } }
#include "Utils.h" #include "Config.h" #include <llvm/IR/Instructions.h> #include <llvm/IR/Module.h> #include <llvm/IR/Operator.h> #include <llvm/Support/LineIterator.h> #include <llvm/Support/MemoryBuffer.h> #include <llvm/Support/Path.h> #include <llvm/Support/raw_ostream.h> #include <set> #include <iostream> #include <llvm/IR/PassManager.h> #include <llvm/Passes/PassBuilder.h> #include <llvm/Transforms/Scalar/DCE.h> #include <llvm/Transforms/Scalar/NewGVN.h> #include <llvm/Transforms/Scalar/SimplifyCFG.h> #include <llvm/Transforms/Utils/Cloning.h> const Function *getCalledFunction(const Value *CalledValue) { const Function *fun = dyn_cast<Function>(CalledValue); if (!fun) { if (auto BitCast = dyn_cast<BitCastOperator>(CalledValue)) { fun = dyn_cast<Function>(BitCast->getOperand(0)); } } return fun; } std::string typeName(const Type *Type) { std::string result; raw_string_ostream rso(result); Type->print(rso); rso.str(); result.erase(std::remove(result.begin(), result.end(), ' '), result.end()); std::replace(result.begin(), result.end(), '(', '$'); std::replace(result.begin(), result.end(), ')', '$'); std::replace(result.begin(), result.end(), ',', '_'); return result; } void deleteAliasToFun(Module &Mod, Function *Fun) { std::vector<GlobalAlias *> toRemove; for (auto &alias : Mod.aliases()) { if (alias.getAliasee() == Fun) toRemove.push_back(&alias); } for (auto &alias : toRemove) { alias->replaceAllUsesWith(Fun); alias->eraseFromParent(); } } bool hasSuffix(std::string Name) { size_t dotPos = Name.find_last_of('.'); return dotPos != std::string::npos && Name.find_last_not_of("0123456789.") < dotPos; } std::string dropSuffix(std::string Name) { return Name.substr(0, Name.find_last_of('.')); } std::string joinPath(StringRef DirName, StringRef FileName) { return FileName.startswith(DirName) ? FileName.str() : DirName.str() + sys::path::get_separator().str() + FileName.str(); } std::string getFileForFun(Function *Fun) { if (auto *SubProgram = Fun->getSubprogram()) { if (auto *File = SubProgram->getFile()) return joinPath(File->getDirectory(), File->getFilename()); } return ""; } bool searchCallStackRec(Function *Src, Function *Dest, CallStack &callStack, std::set<Function *> &visited) { visited.insert(Src); for (auto &BB : *Src) { for (auto &Inst : BB) { std::vector<Function *> calledFuns; if (CallInst *Call = dyn_cast<CallInst>(&Inst)) { if (auto c = Call->getCalledFunction()) calledFuns.push_back(c); } for (auto &Op : Inst.operands()) { if (isa<Function>(Op)) calledFuns.push_back(dyn_cast<Function>(Op)); } for (Function *called : calledFuns) { if (called && visited.find(called) == visited.end()) { auto loc = Inst.getDebugLoc(); if (!loc) continue; callStack.push_back(CallInfo(called->getName().str(), getFileForFun(Src), loc.getLine())); if (called == Dest) return true; else { bool found = searchCallStackRec(called, Dest, callStack, visited); if (found) return true; else callStack.pop_back(); } } } } } return false; } CallStack getCallStack(Function &Src, Function &Dest) { CallStack callStack; std::set<Function *> visited; searchCallStackRec(&Src, &Dest, callStack, visited); return callStack; } bool hasSideEffect(const Function &Fun, std::set<const Function *> &Visited) { if (Fun.isDeclaration()) { return !(Fun.getIntrinsicID() == Intrinsic::dbg_declare || Fun.getIntrinsicID() == Intrinsic::dbg_value || Fun.getIntrinsicID() == Intrinsic::expect); } Visited.insert(&Fun); for (auto &BB : Fun) { for (auto &Inst : BB) { if (isa<StoreInst>(&Inst)) return true; if (auto Call = dyn_cast<CallInst>(&Inst)) { const Function *called = Call->getCalledFunction(); if (!called) return true; if (Visited.find(called) != Visited.end()) continue; if (hasSideEffect(*called, Visited)) return true; } } } return false; } bool hasSideEffect(const Function &Fun) { std::set<const Function *> visited; return hasSideEffect(Fun, visited); } bool isAllocFunction(const Function &Fun) { return Fun.getName() == "kzalloc" || Fun.getName() == "__kmalloc" || Fun.getName() == "kmalloc"; } std::string valueAsString(const Constant *Val) { if (auto *IntVal = dyn_cast<ConstantInt>(Val)) { return std::to_string(IntVal->getSExtValue()); } return ""; } StructType *getStructType(const Value *Value) { StructType *Type = nullptr;
return Type; } void simplifyFunction(Function *Fun) { PassBuilder pb; FunctionPassManager fpm(false); FunctionAnalysisManager fam(false); pb.registerFunctionAnalyses(fam); fpm.addPass(SimplifyCFGPass {}); fpm.addPass(DCEPass {}); fpm.addPass(NewGVNPass {}); fpm.run(*Fun, fam); } AttributeList cleanAttributeList(AttributeList AL) { AttributeList NewAttrList; std::vector<AttributeList::AttrIndex> indices { AttributeList::FirstArgIndex, AttributeList::FunctionIndex, AttributeList::ReturnIndex }; for (AttributeList::AttrIndex i : indices) { AttributeSet AttrSet = AL.getAttributes(i); if (AttrSet.getNumAttributes() != 0) { AttrBuilder AB; for (const Attribute &A : AttrSet) AB.addAttribute(A); NewAttrList = NewAttrList.addAttributes( AL.getContext(), i, AB); } } return NewAttrList; } CallInst *findCallInst(const CallInst *Call, Function *Fun) { if (!Call) return nullptr; for (auto &BB : *Fun) { for (auto &Inst : BB) { if (&Inst == Call) return dyn_cast<CallInst>(&Inst); } } return nullptr; } std::string getSourceFilePath(DIScope *Scope) { return joinPath(Scope->getDirectory(), Scope->getFilename()); } bool isValidCharForIdentifier(char ch) { if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_') return true; else return false; } bool isValidCharForIdentifierStart(char ch) { if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || ch == '_') return true; else return false; } void findAndReplace(std::string &input, std::string find, std::string replace) { int position = 0; while ((position = input.find(find, position)) != std::string::npos) { input.replace(position, find.length(), replace); position += replace.length(); } }
if (auto PtrTy = dyn_cast<PointerType>(Value->getType())) { if (auto *StructTy = dyn_cast<StructType>(PtrTy->getElementType())) { Type = StructTy; } else if (auto *BitCast = dyn_cast<BitCastInst>(Value)) { if (auto *SrcPtrTy = dyn_cast<PointerType>(BitCast->getSrcTy())) { if (auto *SrcStructTy = dyn_cast<StructType>(SrcPtrTy->getElementType())) Type = SrcStructTy; } } } else Type = dyn_cast<StructType>(Value->getType());
if_condition
[ { "content": "class CalledFunctionsAnalysis\n\n : public AnalysisInfoMixin<CalledFunctionsAnalysis> {\n\n public:\n\n using Result = std::set<const Function *>;\n\n Result run(Module &Mod,\n\n AnalysisManager<Module, Function *> &mam,\n\n Function *Main);\n\n\n\n protected:\n\n /// Collect all functions called by Fun.\n\n /// \\param Fun\n\n /// \\param Called Resulting set of collected functions.\n\n void collectCalled(const Function *Fun, Result &Called);\n\n\n\n private:\n\n friend AnalysisInfoMixin<CalledFunctionsAnalysis>;\n\n static AnalysisKey Key;\n\n};\n\n\n\n#endif //DIFFKEMP_SIMPLL_CALLEDFUNCTIONSANALYSIS_H", "file_path": "diffkemp/simpll/passes/CalledFunctionsAnalysis.h", "rank": 0, "score": 91367.89146103877 }, { "content": "/// A pass that transforms functions returning some value to void in case their\n\n/// return value is never used.\n\nclass RemoveUnusedReturnValuesPass\n\n : public PassInfoMixin<RemoveUnusedReturnValuesPass> {\n\n public:\n\n PreservedAnalyses run(Module &Mod, AnalysisManager<Module, Function *> &mam,\n\n Function *Main, Module *ModOther);\n\n};\n\n\n\n#endif //DIFFKEMP_SIMPLL_REMOVEUNUSEDRETURNVALUESPASS_H\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.h", "rank": 1, "score": 88328.70821215016 }, { "content": "class SimplifyKernelFunctionCallsPass\n\n : public PassInfoMixin<SimplifyKernelFunctionCallsPass> {\n\n public:\n\n PreservedAnalyses run(Function &Fun, FunctionAnalysisManager &fam);\n\n};\n\n\n\n#endif //DIFFKEMP_SIMPLL_SIMPLIFYKERNELFUNCTIONCALLSPASS_H", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.h", "rank": 2, "score": 85963.20066867486 }, { "content": "class Result:\n\n \"\"\"\n\n Result of a difference analysis.\n\n Contains the compared entities (functions, params, etc.) and optionally\n\n contains a list of results of underlying entities (e.g. called functions).\n\n \"\"\"\n\n class Kind(IntEnum):\n\n \"\"\"\n\n Enumeration type for possible kinds of analysis results.\n\n Sorted by priority for result aggregation.\n\n \"\"\"\n\n NONE = 0\n\n EQUAL_SYNTAX = 1\n\n EQUAL = 2\n\n EQUAL_UNDER_ASSUMPTIONS = 3\n\n NOT_EQUAL = 4\n\n UNKNOWN = 5\n\n TIMEOUT = 6\n\n ERROR = 7\n\n\n\n def __str__(self):\n\n return self.name.lower().replace(\"_\", \" \")\n\n\n\n class Entity:\n\n \"\"\"\n\n Compared entity information. This can be e.g. a function, a module,\n\n or a parameter.\n\n If it is a function, it contains the file of the function.\n\n \"\"\"\n\n def __init__(self, name, filename=None, line=None, callstack=None,\n\n is_syn_diff=False, covered_by_syn_diff=False):\n\n self.name = name\n\n self.filename = filename\n\n self.line = line\n\n self.callstack = callstack\n\n self.is_syn_diff = is_syn_diff\n\n self.covered_by_syn_diff = covered_by_syn_diff\n\n\n\n def __init__(self, kind, first_name, second_name):\n\n self.kind = kind\n\n self.first = Result.Entity(first_name)\n\n self.second = Result.Entity(second_name)\n\n self.diff = None\n\n self.macro_diff = None\n\n self.inner = dict()\n\n\n\n def __str__(self):\n\n return str(self.kind)\n\n\n\n def add_inner(self, result):\n\n \"\"\"\n\n Add result of an inner entity.\n\n The overall current result is updated based on the entity result.\n\n \"\"\"\n\n self.inner[result.first.name] = result\n\n # The current result is joined with the inner result (the result with\n\n # a higher priority is chosen from the two).\n\n self.kind = Result.Kind(max(int(self.kind), int(result.kind)))\n\n\n\n def report_stat(self, show_errors=False):\n\n \"\"\"\n\n Report statistics.\n\n Print numbers of equal, non-equal, unknown, and error results with\n\n percentage that each has from the total results.\n\n \"\"\"\n\n total = len(self.inner)\n\n eq_syn = len([r for r in iter(self.inner.values())\n\n if r.kind == Result.Kind.EQUAL_SYNTAX])\n\n eq = len([r for r in iter(self.inner.values())\n\n if r.kind in [Result.Kind.EQUAL,\n\n Result.Kind.EQUAL_UNDER_ASSUMPTIONS]]) + eq_syn\n\n neq = len([r for r in iter(self.inner.values())\n\n if r.kind == Result.Kind.NOT_EQUAL])\n\n unkwn = len([r for r in iter(self.inner.values())\n\n if r.kind == Result.Kind.UNKNOWN])\n\n errs = len([r for r in iter(self.inner.values())\n\n if r.kind in [Result.Kind.ERROR, Result.Kind.TIMEOUT]])\n\n empty_diff = len([r for r in iter(self.inner.values()) if all(map(\n\n lambda x: x.diff == \"\", r.inner.values())) and\n\n r.kind == Result.Kind.NOT_EQUAL])\n\n if total > 0:\n\n print(\"Total params: {}\".format(total))\n\n print(\"Equal: {0} ({1:.0f}%)\".format(eq, eq / total * 100))\n\n print(\" same syntax: {0}\".format(eq_syn))\n\n print(\"Not equal: {0} ({1:.0f}%)\".format(\n\n neq, neq / total * 100))\n\n print(\"(empty diff): {0} ({1:.0f}%)\".format(\n\n empty_diff, empty_diff / total * 100))\n\n print(\"Unknown: {0} ({1:.0f}%)\".format(unkwn,\n\n unkwn / total * 100))\n\n print(\"Errors: {0} ({1:.0f}%)\".format(errs,\n\n errs / total * 100))\n\n\n\n if show_errors:\n\n if unkwn > 0:\n\n print(\"\\nFunctions that are unknown: \")\n\n for f, r in iter(self.inner.items()):\n\n if r.kind == Result.Kind.UNKNOWN:\n\n print(f)\n\n print()\n\n if errs > 0:\n\n print(\"\\nFunctions whose comparison ended with an error: \")\n\n for f, r in iter(self.inner.items()):\n\n if r.kind == Result.Kind.ERROR:\n\n print(f)\n", "file_path": "diffkemp/semdiff/result.py", "rank": 3, "score": 78948.3828985226 }, { "content": "//===----- CalledFunctionsAnalysis.h - Abstracting non-function calls -----===//\n\n//\n\n// SimpLL - Program simplifier for analysis of semantic difference //\n\n//\n\n// This file is published under Apache 2.0 license. See LICENSE for details.\n\n// Author: Viktor Malik, [email protected]\n\n//===----------------------------------------------------------------------===//\n\n///\n\n/// \\file\n\n/// This file contains the declaration of the CalledFunctionsAnalysis pass that\n\n/// collects all functions potentially called by the main function.\n\n///\n\n//===----------------------------------------------------------------------===//\n\n\n\n#ifndef DIFFKEMP_SIMPLL_CALLEDFUNCTIONSANALYSIS_H\n\n#define DIFFKEMP_SIMPLL_CALLEDFUNCTIONSANALYSIS_H\n\n\n\n#include <llvm/IR/PassManager.h>\n\n#include <set>\n\n\n\nusing namespace llvm;\n\n\n", "file_path": "diffkemp/simpll/passes/CalledFunctionsAnalysis.h", "rank": 4, "score": 77920.79422829821 }, { "content": "//===--- RemoveUnusedReturnValuesPass.h - Transforming functions to void --===//\n\n//\n\n// SimpLL - Program simplifier for analysis of semantic difference //\n\n//\n\n// This file is published under Apache 2.0 license. See LICENSE for details.\n\n// Author: Tomas Glozar, [email protected]\n\n//===----------------------------------------------------------------------===//\n\n///\n\n/// \\file\n\n/// This file contains the declaration of the RemoveUnusedReturnValues pass.\n\n///\n\n//===----------------------------------------------------------------------===//\n\n\n\n#ifndef DIFFKEMP_SIMPLL_REMOVEUNUSEDRETURNVALUESPASS_H\n\n#define DIFFKEMP_SIMPLL_REMOVEUNUSEDRETURNVALUESPASS_H\n\n\n\n#include <llvm/IR/PassManager.h>\n\n\n\nusing namespace llvm;\n\n\n\n/// A pass that transforms functions returning some value to void in case their\n\n/// return value is never used.\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.h", "rank": 5, "score": 75975.89855933654 }, { "content": " for (auto &Inst : BB) {\n\n if (auto Call = dyn_cast<CallInst>(&Inst)) {\n\n if (auto *CalledFun =\n\n getCalledFunction(Call->getCalledValue())) {\n\n collectCalled(CalledFun, Called);\n\n }\n\n }\n\n for (auto &Op : Inst.operands()) {\n\n if (auto *CalledFun = getCalledFunction(Op))\n\n collectCalled(CalledFun, Called);\n\n }\n\n }\n\n }\n\n}", "file_path": "diffkemp/simpll/passes/CalledFunctionsAnalysis.cpp", "rank": 6, "score": 75907.92079018246 }, { "content": "CalledFunctionsAnalysis::Result CalledFunctionsAnalysis::run(\n\n Module &Mod,\n\n AnalysisManager<Module, Function *> &mam,\n\n Function *Main) {\n\n Result result;\n\n collectCalled(Main, result);\n\n return result;\n\n}\n\n\n\n/// Recursively collect all functions potentially called by Fun and add them to\n\n/// the Called set. All functions called by 'call' instructions and used as\n\n/// operands to some instructions in Fun are collected.\n\nvoid CalledFunctionsAnalysis::collectCalled(const Function *Fun,\n\n Result &Called) {\n\n if (Called.find(Fun) != Called.end())\n\n return;\n\n\n\n Called.insert(Fun);\n\n\n\n for (auto &BB : *Fun) {\n", "file_path": "diffkemp/simpll/passes/CalledFunctionsAnalysis.cpp", "rank": 7, "score": 75907.1350173429 }, { "content": "//===----- CalledFunctionsAnalysis.h - Abstracting non-function calls -----===//\n\n//\n\n// SimpLL - Program simplifier for analysis of semantic difference //\n\n//\n\n// This file is published under Apache 2.0 license. See LICENSE for details.\n\n// Author: Viktor Malik, [email protected]\n\n//===----------------------------------------------------------------------===//\n\n///\n\n/// \\file\n\n/// This file contains the implementation of the CalledFunctionsAnalysis pass\n\n/// that collects all functions potentially called by the main function.\n\n///\n\n//===----------------------------------------------------------------------===//\n\n\n\n#include \"CalledFunctionsAnalysis.h\"\n\n#include \"Utils.h\"\n\n#include <llvm/IR/Instructions.h>\n\n\n\nAnalysisKey CalledFunctionsAnalysis::Key;\n\n\n", "file_path": "diffkemp/simpll/passes/CalledFunctionsAnalysis.cpp", "rank": 8, "score": 75886.04662044527 }, { "content": "void deleteAliasToFun(Module &Mod, Function *Fun);\n", "file_path": "diffkemp/simpll/Utils.h", "rank": 9, "score": 74296.76538987312 }, { "content": "class GetElementPtrInst;\n\n\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 10, "score": 74168.59347533394 }, { "content": " };\n\n\n\n auto &CalledFuns = mam.getResult<CalledFunctionsAnalysis>(Mod, Main);\n\n\n\n // Old functions ought to be deleted after iteration\n\n std::vector<Function *> functionsToDelete;\n\n\n\n for (Function &Fun : Mod) {\n\n if (Fun.getIntrinsicID() != llvm::Intrinsic::not_intrinsic)\n\n continue;\n\n\n\n if (Fun.getReturnType()->isVoidTy())\n\n continue;\n\n\n\n if (!ModOther->getFunction(Fun.getName()))\n\n continue;\n\n\n\n if (!ModOther->getFunction(Fun.getName())->getReturnType()->isVoidTy())\n\n continue;\n\n\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 11, "score": 74121.82444072717 }, { "content": "CallInst *findCallInst(const CallInst *Call, Function *Fun);\n", "file_path": "diffkemp/simpll/Utils.h", "rank": 12, "score": 74117.06338529281 }, { "content": " if (CalledFuns.find(&Fun) == CalledFuns.end())\n\n continue;\n\n\n\n bool can_replace = true;\n\n DEBUG_WITH_TYPE(DEBUG_SIMPLL,\n\n dbgs() << \"Changing function: \" << Fun.getName()\n\n << \" to void\\n\");\n\n for (Use &U : Fun.uses()) {\n\n // Figure out whether the return value is used after each call\n\n\n\n if (auto CI = dyn_cast<CallInst>(U.getUser())) {\n\n if (CI->getCalledFunction() != &Fun)\n\n // Different function is called, Fun is an argument\n\n can_replace = false;\n\n DEBUG_WITH_TYPE(DEBUG_SIMPLL, {\n\n CI->print(dbgs());\n\n for (Use &UU : CI->uses()) {\n\n dbgs() << \" \";\n\n UU.getUser()->print(dbgs());\n\n }\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 13, "score": 74114.67151215764 }, { "content": " Fun_New->removeAttribute(AttributeList::ReturnIndex, AK);\n\n Fun_New->removeAttribute(AttributeList::FunctionIndex, AK);\n\n }\n\n Fun_New->setAttributes(\n\n cleanAttributeList(Fun_New->getAttributes()));\n\n\n\n // Set the right function name and subprogram\n\n Fun_New->takeName(&Fun);\n\n Fun_New->setSubprogram(Fun.getSubprogram());\n\n\n\n // Set the names of all arguments of the new function\n\n for (Function::arg_iterator AI = Fun.arg_begin(),\n\n AE = Fun.arg_end(), NAI = Fun_New->arg_begin();\n\n AI != AE;\n\n ++AI, ++NAI) {\n\n NAI->takeName(AI);\n\n }\n\n\n\n // Copy the function body (currently not used, because function with\n\n // a body are ignored)\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 14, "score": 74100.72436614303 }, { "content": "//===--- RemoveUnusedReturnValuesPass.h - Transforming functions to void --===//\n\n//\n\n// SimpLL - Program simplifier for analysis of semantic difference //\n\n//\n\n// This file is published under Apache 2.0 license. See LICENSE for details.\n\n// Author: Tomas Glozar, [email protected]\n\n//===----------------------------------------------------------------------===//\n\n///\n\n/// \\file\n\n/// This file contains the declaration of the RemoveUnusedReturnValues pass.\n\n///\n\n//===----------------------------------------------------------------------===//\n\n\n\n#include \"CalledFunctionsAnalysis.h\"\n\n#include \"RemoveUnusedReturnValuesPass.h\"\n\n#include \"Utils.h\"\n\n#include <llvm/IR/Instructions.h>\n\n#include <Config.h>\n\n\n\nPreservedAnalyses RemoveUnusedReturnValuesPass::run(\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 15, "score": 74099.01515013576 }, { "content": " });\n\n if (!CI->use_empty())\n\n // The return value is actually used\n\n can_replace = false;\n\n } else if (auto II = dyn_cast<InvokeInst>(U.getUser())) {\n\n if (II->getCalledFunction() != &Fun)\n\n // Different function is called, Fun is an argument\n\n can_replace = false;\n\n DEBUG_WITH_TYPE(DEBUG_SIMPLL, {\n\n II->print(dbgs());\n\n for (Use &UU : II->uses()) {\n\n dbgs() << \" \";\n\n UU.getUser()->print(dbgs());\n\n }\n\n });\n\n if (!II->use_empty())\n\n // The return value is actually used\n\n can_replace = false;\n\n } else\n\n // The function is used somewhere as an argument, therefore\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 16, "score": 74098.99253605203 }, { "content": " // it ought not to be replaced\n\n can_replace = false;\n\n }\n\n\n\n if (can_replace) {\n\n // Create the header of the new function\n\n std::vector<Type *> FAT_New(Fun.getFunctionType()->param_begin(),\n\n Fun.getFunctionType()->param_end());\n\n FunctionType *FT_New = FunctionType::get(\n\n Type::getVoidTy(Fun.getContext()),\n\n FAT_New, Fun.isVarArg());\n\n Function *Fun_New = Function::Create(FT_New,\n\n Fun.getLinkage(),\n\n Fun.getName(),\n\n Fun.getParent());\n\n\n\n // Copy the attributes from the old function and delete the ones\n\n // related to the return value\n\n Fun_New->copyAttributesFrom(&Fun);\n\n for (Attribute::AttrKind AK : badAttributes) {\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 17, "score": 74098.6940512416 }, { "content": " CI);\n\n\n\n // Copy additional properties\n\n CI_New->setAttributes(CI->getAttributes());\n\n for (Attribute::AttrKind AK : badAttributes) {\n\n // Remove incompatibile attributes\n\n CI_New->removeAttribute(\n\n AttributeList::ReturnIndex, AK);\n\n CI_New->removeAttribute(\n\n AttributeList::FunctionIndex, AK);\n\n }\n\n CI_New->setAttributes(\n\n cleanAttributeList(CI_New->getAttributes()));\n\n CI_New->setDebugLoc(CI->getDebugLoc());\n\n CI_New->setCallingConv(CI->getCallingConv());\n\n if (CI->isTailCall())\n\n CI_New->setTailCall();\n\n DEBUG_WITH_TYPE(DEBUG_SIMPLL,\n\n dbgs() << \"Replacing :\" << *CI << \" with \"\n\n << *CI_New << \"\\n\");\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 18, "score": 74096.45543462032 }, { "content": " Fun_New->getBasicBlockList().splice(Fun_New->begin(),\n\n Fun.getBasicBlockList());\n\n\n\n // Replace return instructions on ends of basic blocks with ret void\n\n // (currently not used because function with a body are ignored)\n\n for (BasicBlock &B : *Fun_New)\n\n if (dyn_cast<ReturnInst>(B.getTerminator())) {\n\n B.getInstList().pop_back();\n\n ReturnInst *Term_New = ReturnInst::Create(\n\n B.getContext());\n\n B.getInstList().push_back(Term_New);\n\n\n\n // Simplify the function to remove any code that became dead\n\n simplifyFunction(Fun_New);\n\n }\n\n\n\n // Replace all uses of the old arguments\n\n for (Function::arg_iterator I = Fun.arg_begin(),\n\n E = Fun.arg_end(), NI = Fun_New->arg_begin();\n\n I != E;\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 19, "score": 74095.73345994423 }, { "content": " // Copy additional properties\n\n II_New->setAttributes(II->getAttributes());\n\n for (Attribute::AttrKind AK : badAttributes) {\n\n // Remove incompatibile attributes\n\n II_New->removeAttribute(\n\n AttributeList::ReturnIndex, AK);\n\n II_New->removeAttribute(\n\n AttributeList::FunctionIndex, AK);\n\n }\n\n II_New->setAttributes(\n\n cleanAttributeList(II_New->getAttributes()));\n\n II_New->setDebugLoc(II->getDebugLoc());\n\n II_New->setCallingConv(II->getCallingConv());\n\n DEBUG_WITH_TYPE(DEBUG_SIMPLL,\n\n dbgs() << \"Replacing :\" << *II << \" with \"\n\n << *II_New << \"\\n\");\n\n // Erase the old instruction\n\n II->eraseFromParent();\n\n }\n\n }\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 20, "score": 74095.51991566815 }, { "content": " ++I, ++NI) {\n\n I->replaceAllUsesWith(NI);\n\n }\n\n\n\n // For call or invoke instructions a new instruction has to be\n\n // created and the old one replaced\n\n for (Use &U : Fun.uses()) {\n\n if (CallInst *CI = dyn_cast<CallInst>(U.getUser())) {\n\n // First copy all arguments to an array\n\n // and create the new instruction\n\n std::vector<Value *> Args;\n\n\n\n for (Value *A : CI->arg_operands()) {\n\n Args.push_back(A);\n\n }\n\n\n\n ArrayRef<Value *> Args_AR(Args);\n\n\n\n // Insert the new instruction next to the old one\n\n CallInst *CI_New = CallInst::Create(Fun_New, Args_AR, \"\",\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 21, "score": 74093.73826972343 }, { "content": " // Erase the old instruction\n\n CI->eraseFromParent();\n\n } else if (InvokeInst *II = dyn_cast<InvokeInst>(U.getUser())) {\n\n // First copy all arguments to an array and create\n\n // the new instruction\n\n std::vector<Value *> Args;\n\n\n\n for (Value *A : II->arg_operands()) {\n\n Args.push_back(A);\n\n }\n\n\n\n ArrayRef<Value *> Args_AR(Args);\n\n\n\n // Insert the new instruction next to the old one\n\n InvokeInst *II_New = InvokeInst::Create(\n\n Fun_New,\n\n II->getNormalDest(),\n\n II->getUnwindDest(),\n\n Args_AR, \"\", II);\n\n\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 22, "score": 74091.85651973145 }, { "content": " Module &Mod,\n\n AnalysisManager<Module, Function *> &mam,\n\n Function *Main,\n\n Module *ModOther) {\n\n\n\n // These attributes are invalid for void functions\n\n Attribute::AttrKind badAttributes[] = {\n\n Attribute::AttrKind::ByVal,\n\n Attribute::AttrKind::InAlloca,\n\n Attribute::AttrKind::Nest,\n\n Attribute::AttrKind::NoAlias,\n\n Attribute::AttrKind::NoCapture,\n\n Attribute::AttrKind::NonNull,\n\n Attribute::AttrKind::ReadNone,\n\n Attribute::AttrKind::ReadOnly,\n\n Attribute::AttrKind::SExt,\n\n Attribute::AttrKind::StructRet,\n\n Attribute::AttrKind::ZExt,\n\n Attribute::AttrKind::Dereferenceable,\n\n Attribute::AttrKind::DereferenceableOrNull\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 23, "score": 74091.24660133696 }, { "content": " DEBUG_WITH_TYPE(DEBUG_SIMPLL, Fun_New->print(dbgs()));\n\n // Delete function after iteration\n\n functionsToDelete.push_back(&Fun);\n\n }\n\n }\n\n\n\n // Delete replaced functions\n\n for (Function *F : functionsToDelete)\n\n F->removeFromParent();\n\n\n\n return PreservedAnalyses();\n\n}\n", "file_path": "diffkemp/simpll/passes/RemoveUnusedReturnValuesPass.cpp", "rank": 24, "score": 74087.6499150495 }, { "content": "//= SimplifyKernelFunctionCallsPass.h - Simplifying kernel-specific functions //\n\n//\n\n// SimpLL - Program simplifier for analysis of semantic difference //\n\n//\n\n// This file is published under Apache 2.0 license. See LICENSE for details.\n\n// Author: Viktor Malik, [email protected]\n\n//===----------------------------------------------------------------------===//\n\n///\n\n/// \\file\n\n/// This file contains the declaration of the SimplifyKernelFunctionCallsPass\n\n/// that removes arguments of some kernel functions that do not affect semantics\n\n/// of the program.\n\n///\n\n//===----------------------------------------------------------------------===//\n\n\n\n#ifndef DIFFKEMP_SIMPLL_SIMPLIFYKERNELFUNCTIONCALLSPASS_H\n\n#define DIFFKEMP_SIMPLL_SIMPLIFYKERNELFUNCTIONCALLSPASS_H\n\n\n\n#include <llvm/ADT/StringSet.h>\n\n#include <llvm/IR/PassManager.h>\n\n\n\nusing namespace llvm;\n\n\n", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.h", "rank": 25, "score": 73955.60332831142 }, { "content": " def _file_name(self, suffix, ext, name=None):\n\n \"\"\"\n\n Get name of a task file having the given name, suffix, and extension.\n\n \"\"\"\n\n return os.path.join(self.task_dir,\n", "file_path": "tests/regression/task_spec.py", "rank": 26, "score": 72450.8036593757 }, { "content": " def get_by_name(self, name):\n\n \"\"\"Get module for the function with the given name.\"\"\"\n", "file_path": "diffkemp/function_list.py", "rank": 27, "score": 72327.23824450577 }, { "content": " CalledFun,\n\n {ConstantPointerNull::get(OpType),\n\n ConstantPointerNull::get(OpType)},\n\n \"\", &Instr);\n\n newCall->setDebugLoc(CallInstr->getDebugLoc());\n\n CallInstr->replaceAllUsesWith(newCall);\n\n toRemove.push_back(&Instr);\n\n } else if (CalledFun->getName() == \"_dev_info\" ||\n\n CalledFun->getName() == \"dev_warn\" ||\n\n CalledFun->getName() == \"dev_err\" ||\n\n CalledFun->getName() == \"sprintf\") {\n\n // Functions with 2 mandatory arguments\n\n auto Op0Type = dyn_cast<PointerType>(\n\n CallInstr->getOperand(0)->getType());\n\n auto Op1Type = dyn_cast<PointerType>(\n\n CallInstr->getOperand(1)->getType());\n\n auto newCall = CallInst::Create(\n\n CalledFun,\n\n {ConstantPointerNull::get(Op0Type),\n\n ConstantPointerNull::get(Op1Type)},\n", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.cpp", "rank": 28, "score": 72148.30310583976 }, { "content": " auto CalledVal = CallInstr->getCalledValue();\n\n if (auto Asm = dyn_cast<InlineAsm>(CalledVal)) {\n\n if (Asm->getAsmString().find(\"__bug_table\")\n\n != std::string::npos) {\n\n replaceArgByNull(CallInstr, 0);\n\n replaceArgByZero(CallInstr, 1);\n\n }\n\n }\n\n continue;\n\n }\n\n\n\n // Remove arguments of printing functions\n\n if (CalledFun->getName() == \"printk\") {\n\n // Functions with 1 mandatory argument\n\n auto OpType = dyn_cast<PointerType>(\n\n CallInstr->getOperand(0)->getType());\n\n // An additional void pointer is added to the operand list\n\n // so the instruction can be compared as equal even when the\n\n // other one is one of the functions listed in the other if\n\n auto newCall = CallInst::Create(\n", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.cpp", "rank": 29, "score": 72145.13828142591 }, { "content": " if (OldArg->getType()->isPointerTy()) {\n\n Call->setArgOperand(index,\n\n ConstantPointerNull::get(dyn_cast<PointerType>(\n\n OldArg->getType())));\n\n }\n\n}\n\n\n\nPreservedAnalyses SimplifyKernelFunctionCallsPass::run(\n\n Function &Fun,\n\n FunctionAnalysisManager &fam) {\n\n std::vector<Instruction *> toRemove;\n\n for (auto &BB : Fun) {\n\n for (auto &Instr : BB) {\n\n if (auto CallInstr = dyn_cast<CallInst>(&Instr)) {\n\n auto CalledFun = CallInstr->getCalledFunction();\n\n\n\n if (!CalledFun) {\n\n // For inline asm containing __bug_table:\n\n // - replace the first argument byt null (is a file name)\n\n // - replace the second argument by 0 (is a line number)\n", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.cpp", "rank": 30, "score": 72143.75072180785 }, { "content": "#include \"SimplifyKernelFunctionCallsPass.h\"\n\n#include <llvm/IR/Constants.h>\n\n#include <llvm/IR/InlineAsm.h>\n\n#include <llvm/IR/Instructions.h>\n\n\n\n/// Replace an argument of a call instruction by 0.\n\n/// Checks if the argument is of integer type.\n\nvoid replaceArgByZero(CallInst *Call, unsigned index) {\n\n auto OldArg = dyn_cast<ConstantInt>(Call->getArgOperand(index));\n\n if (OldArg->getType()->isIntegerTy()) {\n\n Call->setArgOperand(index, ConstantInt::get(OldArg->getType(),\n\n APInt(OldArg->getBitWidth(),\n\n 0)));\n\n }\n\n}\n\n\n\n/// Replace an argument of a call instruction by 0.\n\n/// Checks if the argument is of integer type.\n\nvoid replaceArgByNull(CallInst *Call, unsigned index) {\n\n auto OldArg = Call->getArgOperand(index);\n", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.cpp", "rank": 31, "score": 72139.24552684769 }, { "content": " \"\", &Instr);\n\n newCall->setDebugLoc(CallInstr->getDebugLoc());\n\n CallInstr->replaceAllUsesWith(newCall);\n\n toRemove.push_back(&Instr);\n\n }\n\n\n\n // Replace the second argument of a call to warn_slowpath_null\n\n // by 0 (it is a line number).\n\n if (CalledFun->getName() == \"warn_slowpath_null\" ||\n\n CalledFun->getName() == \"warn_slowpath_fmt\" ||\n\n CalledFun->getName() == \"__might_sleep\" ||\n\n CalledFun->getName() == \"acpi_ut_predefined_warning\") {\n\n replaceArgByNull(CallInstr, 0);\n\n replaceArgByZero(CallInstr, 1);\n\n }\n\n }\n\n }\n\n }\n\n for (auto i : toRemove)\n\n i->eraseFromParent();\n\n toRemove.clear();\n\n\n\n return PreservedAnalyses();\n\n}", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.cpp", "rank": 32, "score": 72130.79323433193 }, { "content": "const Function *getCalledFunction(const Value *CalledValue);\n", "file_path": "diffkemp/simpll/Utils.h", "rank": 33, "score": 72120.87800530311 }, { "content": "// SimplifyKernelFunctionCallsPass.cpp - Simplifying kernel-specific functions//\n\n//\n\n// SimpLL - Program simplifier for analysis of semantic difference //\n\n//\n\n// This file is published under Apache 2.0 license. See LICENSE for details.\n\n// Author: Viktor Malik, [email protected]\n\n//===----------------------------------------------------------------------===//\n\n///\n\n/// \\file\n\n/// This file contains the definition of the SimplifyKernelFunctionCallsPass.\n\n/// Applied transformations:\n\n/// 1. Remove all arguments of calls to printing functions (printk, _dev_info,\n\n/// dev_warn, dev_err, sprintf).\n\n/// 2. Remove the second argument of all calls to warn_slowpath_null. This\n\n/// argument is a line number.\n\n/// 3. Remove the second argument of inline assemblies containing the\n\n/// __bug_table string. The argument is a line number.\n\n///\n\n//===----------------------------------------------------------------------===//\n\n\n", "file_path": "diffkemp/simpll/passes/SimplifyKernelFunctionCallsPass.cpp", "rank": 34, "score": 72115.18710335052 }, { "content": " def old_src_file(self, name=None):\n\n \"\"\"Name of the old C file in the task dir.\"\"\"\n", "file_path": "tests/regression/task_spec.py", "rank": 35, "score": 70742.53313935807 }, { "content": " def new_src_file(self, name=None):\n\n \"\"\"Name of the new C file in the task dir.\"\"\"\n", "file_path": "tests/regression/task_spec.py", "rank": 36, "score": 70742.53313935807 }, { "content": " def get_functions_called_by(self, fun_name):\n\n \"\"\"\n\n Find names of all functions (recursively) called by one of functions\n\n in the given set.\n\n \"\"\"\n\n result = set()\n\n self.parse_module()\n\n llvm_fun = self.llvm_module.get_named_function(fun_name)\n\n if llvm_fun:\n\n self._get_functions_called_by_rec(llvm_fun, result)\n", "file_path": "diffkemp/llvm_ir/kernel_module.py", "rank": 37, "score": 67129.75112099519 }, { "content": "def mod(source):\n\n \"\"\"Create kernel module shared among multiple tests.\"\"\"\n", "file_path": "tests/unit_tests/kernel_module_test.py", "rank": 38, "score": 66545.17896691995 }, { "content": "def mod():\n\n \"\"\"\n\n Build LlvmSysctlModule for net.core.* sysctl options shared among tests.\n\n \"\"\"\n\n source = KernelSource(\"kernel/linux-3.10.0-862.el7\", True)\n\n kernel_module = source.get_module_from_source(\"net/core/sysctl_net_core.c\")\n\n yield LlvmSysctlModule(kernel_module, \"net_core_table\")\n", "file_path": "tests/unit_tests/llvm_sysctl_module_test.py", "rank": 39, "score": 65728.90622922979 }, { "content": " def _get_functions_called_by_rec(llvm_fun, result):\n\n \"\"\"\n\n Find names of all functions that are (recursively) called by the given\n\n function. Found names are stored in the 'result' list.\n\n \"\"\"\n\n for bb in llvm_fun.iter_basic_blocks():\n\n for instr in bb.iter_instructions():\n\n if instr.get_instruction_opcode() == Call:\n\n called = instr.get_called()\n\n if called.get_kind() == ConstantExprValueKind:\n\n # Called function may be inside a bitcast\n\n called = called.get_operand(0)\n\n called_name = called.get_name().decode(\"utf-8\")\n\n # Collect all unsupported functions that are called\n\n if (called.get_kind() == FunctionValueKind and\n\n called_name and\n\n not supported_kernel_fun(called) and\n\n called_name not in result):\n\n result.add(called_name)\n\n # Recursively call the method on the called function\n\n LlvmKernelModule._get_functions_called_by_rec(\n\n called, result)\n\n\n\n # Collect also functions that are passed as parameters to\n\n # instructions. For these, do not descend recursively since\n\n # their body will not be analysed.\n\n for opIndex in range(0, instr.get_num_operands()):\n\n op = instr.get_operand(opIndex)\n\n\n\n op_name = op.get_name().decode(\"utf-8\")\n\n if (op.get_kind() == FunctionValueKind and\n\n op_name and\n\n not supported_kernel_fun(op) and\n\n op_name not in result):\n", "file_path": "diffkemp/llvm_ir/kernel_module.py", "rank": 40, "score": 65619.7316060198 }, { "content": "def test_get_functions_called_by(mod):\n\n \"\"\"Test finding functions recursively called by a function.\"\"\"\n\n funs = mod.get_functions_called_by(\"alsa_sound_exit\")\n\n assert funs == {\"snd_info_done\", \"unregister_chrdev\",\n", "file_path": "tests/unit_tests/kernel_module_test.py", "rank": 41, "score": 64158.865294207244 }, { "content": "class DifferentialFunctionComparator : public FunctionComparator {\n\n public:\n\n DifferentialFunctionComparator(const Function *F1,\n\n const Function *F2,\n\n bool controlFlowOnly,\n\n GlobalNumberState *GN,\n\n const DebugInfo *DI,\n\n ModuleComparator *MC)\n\n : FunctionComparator(F1, F2, GN), DI(DI),\n\n controlFlowOnly(controlFlowOnly),\n\n LayoutL(F1->getParent()->getDataLayout()),\n\n LayoutR(F2->getParent()->getDataLayout()),\n\n ModComparator(MC) {}\n\n\n\n protected:\n\n /// Specific comparison of GEP instructions/operators.\n\n /// Handles situation when there is an offset between matching GEP indices\n\n /// in the compared modules (when a struct type has different fields).\n\n int cmpGEPs(const GEPOperator *GEPL,\n\n const GEPOperator *GEPR) const override;\n", "file_path": "diffkemp/simpll/DifferentialFunctionComparator.h", "rank": 42, "score": 47814.27967116892 }, { "content": "/// FunctionComparator - Compares two functions to determine whether or not\n\n/// they will generate machine code with the same behaviour. DataLayout is\n\n/// used if available. The comparator always fails conservatively (erring on the\n\n/// side of claiming that two functions are different).\n\nclass FunctionComparator {\n\npublic:\n\n FunctionComparator(const Function *F1, const Function *F2,\n\n GlobalNumberState* GN)\n\n : FnL(F1), FnR(F2), GlobalNumbers(GN) {}\n\n\n\n /// Test whether the two functions have equivalent behaviour.\n\n int compare();\n\n /// Hash a function. Equivalent functions will have the same hash, and unequal\n\n /// functions will have different hashes with high probability.\n\n typedef uint64_t FunctionHash;\n\n static FunctionHash functionHash(Function &);\n\n\n\nprotected:\n\n /// Start the comparison.\n\n void beginCompare() {\n\n sn_mapL.clear();\n\n sn_mapR.clear();\n\n }\n\n\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 43, "score": 46768.93397256769 }, { "content": "/// Pass for removing llvm.lifetime.start and llvm.lifetime.end functions\n\nclass RemoveLifetimeCallsPass\n\n : public PassInfoMixin<RemoveLifetimeCallsPass> {\n\n public:\n\n PreservedAnalyses run(Module &Mod, ModuleAnalysisManager &mam);\n\n};\n\n\n\n#endif // DIFFKEMP_SIMPLL_REMOVELIFETIMECALLSPASS_H", "file_path": "diffkemp/simpll/passes/RemoveLifetimeCallsPass.h", "rank": 44, "score": 45386.25205461104 }, { "content": "/// Generates abstractions for indirect function calls and for inline assemblies\n\n/// Implemented as a Function pass.\n\nclass FunctionAbstractionsGenerator\n\n : public AnalysisInfoMixin<FunctionAbstractionsGenerator> {\n\n public:\n\n typedef std::unordered_map<std::string, Function *> FunMap;\n\n struct Result {\n\n FunMap funAbstractions;\n\n StringMap<StringRef> asmValueMap;\n\n };\n\n\n\n Result run(Module &Mod,\n\n AnalysisManager<Module, Function *> &mam,\n\n Function *Main);\n\n\n\n protected:\n\n /// Hash of the abstraction function to be used in the function map.\n\n /// \\param Fun Called value (can be a value or an inline assembly).\n\n std::string funHash(Value *Fun);\n\n\n\n /// Prefix of the abstraction function.\n\n /// \\param Fun Called value (can be a value or an inline assembly).\n", "file_path": "diffkemp/simpll/passes/FunctionAbstractionsGenerator.h", "rank": 45, "score": 44568.047794247075 }, { "content": "class FunctionList:\n\n def __init__(self, root_dir):\n\n self.root_dir = root_dir\n\n self.functions = dict()\n\n\n\n def add(self, name, llvm_mod):\n\n \"\"\"\n\n Add function to the list.\n\n :param name: Name of the function.\n\n :param llvm_mod: LLVM module with the function definition.\n\n \"\"\"\n\n self.functions[name] = llvm_mod\n\n\n\n def modules(self):\n\n \"\"\"Get the set of all modules.\"\"\"\n\n return set(self.functions.values())\n\n\n\n def get_by_name(self, name):\n\n \"\"\"Get module for the function with the given name.\"\"\"\n\n return self.functions[name] if name in self.functions else None\n\n\n\n def from_yaml(self, yaml_file):\n\n \"\"\"\n\n Load the list from YAML file. Paths are assumed to be relative to the\n\n root directory.\n\n :param yaml_file: Contents of the YAML file.\n\n \"\"\"\n\n funs = yaml.safe_load(yaml_file)\n\n for f in funs:\n\n self.add(f[\"name\"],\n\n LlvmKernelModule(os.path.join(self.root_dir, f[\"llvm\"])))\n\n\n\n def to_yaml(self):\n\n \"\"\"\n\n Dump the list as a YAML string. Paths to files are given relative to\n\n the root directory.\n\n :return: YAML string.\n\n \"\"\"\n\n yaml_dict = [\n\n {\"name\": name, \"llvm\": os.path.relpath(mod.llvm, self.root_dir)}\n\n for name, mod in self.functions.items()]\n\n return yaml.dump(yaml_dict)\n\n\n\n def filter(self, functions):\n", "file_path": "diffkemp/function_list.py", "rank": 46, "score": 44559.06417254622 }, { "content": "def functions_semdiff(first, second, fun_first, fun_second, config):\n\n \"\"\"\n\n Compare two functions for semantic equality.\n\n\n\n Functions are compared under various assumptions, each having some\n\n 'assumption level'. The higher the level is, the more strong assumption has\n\n been made. Level 0 indicates no assumption. These levels are determined\n\n from differences of coupled functions that are set as a parameter of the\n\n analysis. The analysis tries all assumption levels in increasing manner\n\n until functions are proven to be equal or no assumptions remain.\n\n\n\n :param first: File with the first LLVM module\n\n :param second: File with the second LLVM module\n\n :param fun_first: Function from the first module to be compared\n\n :param fun_second: Function from the second module to be compared\n\n :param config: Configuration.\n\n \"\"\"\n\n if fun_first == fun_second:\n\n fun_str = fun_first\n\n else:\n\n fun_str = fun_second\n\n sys.stdout.write(\" Semantic diff of {}\".format(fun_str))\n\n sys.stdout.write(\"...\")\n\n sys.stdout.flush()\n\n\n\n # Run the actual analysis\n\n if config.semdiff_tool == \"llreve\":\n\n called_first = first.get_functions_called_by(fun_first)\n\n called_second = second.get_functions_called_by(fun_second)\n\n called_couplings = [(f, s) for f in called_first for s in called_second\n\n if f == s]\n\n result = _run_llreve_z3(first.llvm, second.llvm, fun_first, fun_second,\n\n called_couplings, config.timeout,\n\n config.verbosity)\n\n first.clean_module()\n\n second.clean_module()\n", "file_path": "diffkemp/semdiff/function_diff.py", "rank": 47, "score": 43884.86584730605 }, { "content": "def functions_diff(mod_first, mod_second,\n\n fun_first, fun_second,\n\n glob_var, config):\n\n \"\"\"\n\n Compare two functions for equality.\n\n\n\n First, functions are simplified and compared for syntactic equality using\n\n the SimpLL tool. If they are not syntactically equal, SimpLL prints a list\n\n of functions that the syntactic equality depends on. These are then\n\n compared for semantic equality.\n\n :param mod_first: First LLVM module\n\n :param mod_second: Second LLVM module\n\n :param fun_first: Function from the first module to be compared\n\n :param fun_second: Function from the second module to be compared\n\n :param glob_var: Global variable whose effect on the functions to compare\n\n :param config: Configuration\n\n \"\"\"\n\n result = Result(Result.Kind.NONE, fun_first, fun_second)\n\n try:\n\n if config.verbosity:\n\n if fun_first == fun_second:\n\n fun_str = fun_first\n\n else:\n\n fun_str = \"{} and {}\".format(fun_first, fun_second)\n\n print(\"Syntactic diff of {} (in {})\".format(fun_str,\n\n mod_first.llvm))\n\n\n\n simplify = True\n\n while simplify:\n\n simplify = False\n\n # Simplify modules\n\n first_simpl, second_simpl, objects_to_compare, missing_defs, \\\n\n syndiff_bodies = \\\n\n simplify_modules_diff(mod_first.llvm, mod_second.llvm,\n\n fun_first, fun_second,\n\n glob_var.name if glob_var else None,\n\n glob_var.name if glob_var else \"simpl\",\n\n config.control_flow_only,\n\n config.verbosity)\n\n funs_to_compare = list([o for o in objects_to_compare\n\n if not o[0].is_syn_diff])\n\n if funs_to_compare and missing_defs:\n\n # If there are missing function definitions, try to find\n\n # implementing them, link those to the current modules, and\n\n # rerun the simplification.\n\n for fun_pair in missing_defs:\n\n if \"first\" in fun_pair:\n\n try:\n\n new_mod = config.source_first \\\n\n .get_module_for_symbol(fun_pair[\"first\"])\n\n if mod_first.link_modules([new_mod]):\n\n simplify = True\n\n new_mod.clean_module()\n\n except SourceNotFoundException:\n\n pass\n\n if \"second\" in fun_pair:\n\n try:\n\n new_mod = config.source_second \\\n\n .get_module_for_symbol(fun_pair[\"second\"])\n\n if mod_second.link_modules([new_mod]):\n\n simplify = True\n\n new_mod.clean_module()\n\n except SourceNotFoundException:\n\n pass\n\n mod_first.restore_unlinked_llvm()\n\n mod_second.restore_unlinked_llvm()\n\n\n\n if not objects_to_compare:\n\n result.kind = Result.Kind.EQUAL_SYNTAX\n\n else:\n\n # If the functions are not syntactically equal, objects_to_compare\n\n # contains a list of functions and macros that are different.\n\n for fun_pair in objects_to_compare:\n\n if (not fun_pair[0].is_syn_diff and\n\n config.semdiff_tool is not None):\n\n # If a semantic diff tool is set, use it for further\n\n # comparison of non-equal functions\n\n fun_result = functions_semdiff(first_simpl, second_simpl,\n\n fun_pair[0].name,\n\n fun_pair[1].name,\n\n config)\n\n else:\n\n fun_result = Result(Result.Kind.NOT_EQUAL, \"\", \"\")\n\n fun_result.first = fun_pair[0]\n\n fun_result.second = fun_pair[1]\n\n if (fun_result.kind == Result.Kind.NOT_EQUAL and\n\n config.show_diff):\n\n if not fun_result.first.is_syn_diff:\n\n # Get the syntactic diff of functions\n\n fun_result.diff = syntax_diff(\n\n fun_result.first.filename,\n\n fun_result.second.filename,\n\n fun_result.first.name,\n\n fun_pair[0].line,\n\n fun_pair[1].line)\n\n else:\n\n # Find the syntax differences and append the left and\n\n # right value to create the resulting diff\n\n found = None\n\n for sd in syndiff_bodies:\n\n if sd[\"name\"] == fun_result.first.name:\n\n found = sd\n\n break\n\n if found is not None:\n\n fun_result.diff = \" {}\\n\\n {}\\n\".format(\n\n sd[\"left-value\"], sd[\"right-value\"])\n\n result.add_inner(fun_result)\n\n if config.verbosity:\n\n print(\" {}\".format(result))\n\n except SimpLLException as e:\n\n if config.verbosity:\n\n print(e)\n\n result.kind = Result.Kind.ERROR\n", "file_path": "diffkemp/semdiff/function_diff.py", "rank": 48, "score": 43882.15989810695 }, { "content": "/// A pass that transforms functions returning some value to void in case their\n\n/// return value is never used.\n\nclass ReduceFunctionMetadataPass\n\n : public PassInfoMixin<ReduceFunctionMetadataPass> {\n\n public:\n\n PreservedAnalyses run(Function &Fun, FunctionAnalysisManager &fam);\n\n};\n\n\n\n#endif //DIFFKEMP_SIMPLL_REDUCEFUNCTIONMETADATAPASS_H\n", "file_path": "diffkemp/simpll/passes/ReduceFunctionMetadataPass.h", "rank": 49, "score": 43219.304329155966 }, { "content": "def test_function_diff(task_spec):\n\n \"\"\"Test comparison of semantic difference of functions.\"\"\"\n\n for fun_spec in task_spec.functions.values():\n\n if fun_spec.result != Result.Kind.TIMEOUT:\n\n result = functions_diff(\n\n mod_first=fun_spec.old_module,\n\n mod_second=fun_spec.new_module,\n\n fun_first=fun_spec.name, fun_second=fun_spec.name,\n\n glob_var=None, config=task_spec.config)\n", "file_path": "tests/regression/functions_test.py", "rank": 50, "score": 43205.214553600556 }, { "content": " /// bitcastable. So if C is pointer, it could be bitcasted to A and to B.\n\n /// So any constant equal or bitcastable to A is equal or bitcastable to B.\n\n /// QED.\n\n ///\n\n /// In another words, for pointers and vectors, we ignore top-level type and\n\n /// look at their particular properties (bit-width for vectors, and\n\n /// address space for pointers).\n\n /// If these properties are equal - compare their contents.\n\n virtual int cmpConstants(const Constant *L, const Constant *R) const;\n\n\n\n /// Compares two global values by number. Uses the GlobalNumbersState to\n\n /// identify the same gobals across function calls.\n\n virtual int cmpGlobalValues(GlobalValue *L, GlobalValue *R) const;\n\n\n\n /// Assign or look up previously assigned numbers for the two values, and\n\n /// return whether the numbers are equal. Numbers are assigned in the order\n\n /// visited.\n\n /// Comparison order:\n\n /// Stage 0: Value that is function itself is always greater then others.\n\n /// If left and right values are references to their functions, then\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 51, "score": 40166.76406320926 }, { "content": " /// Sets \\p needToCmpOperands to true if the operands of the instructions\n\n /// still must be compared afterwards. In this case it's already guaranteed\n\n /// that both instructions have the same number of operands.\n\n virtual int cmpOperations(const Instruction *L, const Instruction *R,\n\n bool &needToCmpOperands) const;\n\n\n\n /// cmpType - compares two types,\n\n /// defines total ordering among the types set.\n\n ///\n\n /// Return values:\n\n /// 0 if types are equal,\n\n /// -1 if Left is less than Right,\n\n /// +1 if Left is greater than Right.\n\n ///\n\n /// Description:\n\n /// Comparison is broken onto stages. Like in lexicographical comparison\n\n /// stage coming first has higher priority.\n\n /// On each explanation stage keep in mind total ordering properties.\n\n ///\n\n /// 0. Before comparison we coerce pointer types of 0 address space to\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 52, "score": 40163.1739349783 }, { "content": " /// Stage 1: Types that satisfies isFirstClassType conditions are always\n\n /// greater then others.\n\n /// Stage 2: Vector is greater then non-vector.\n\n /// If both types are vectors, then vector with greater bitwidth is\n\n /// greater.\n\n /// If both types are vectors with the same bitwidth, then types\n\n /// are bitcastable, and we can skip other stages, and go to contents\n\n /// comparison.\n\n /// Stage 3: Pointer types are greater than non-pointers. If both types are\n\n /// pointers of the same address space - go to contents comparison.\n\n /// Different address spaces: pointer with greater address space is\n\n /// greater.\n\n /// Stage 4: Types are neither vectors, nor pointers. And they differ.\n\n /// We don't know how to bitcast them. So, we better don't do it,\n\n /// and return types comparison result (so it determines the\n\n /// relationship among constants we don't know how to bitcast).\n\n ///\n\n /// Just for clearance, let's see how the set of constants could look\n\n /// on single dimension axis:\n\n ///\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 53, "score": 40159.81800346626 }, { "content": " virtual int cmpOperandBundlesSchema(const Instruction *L, const Instruction *R) const;\n\n\n\n /// Compare two GEPs for equivalent pointer arithmetic.\n\n /// Parts to be compared for each comparison stage,\n\n /// most significant stage first:\n\n /// 1. Address space. As numbers.\n\n /// 2. Constant offset, (using GEPOperator::accumulateConstantOffset method).\n\n /// 3. Pointer operand type (using cmpType method).\n\n /// 4. Number of operands.\n\n /// 5. Compare operands, using cmpValues method.\n\n virtual int cmpGEPs(const GEPOperator *GEPL, const GEPOperator *GEPR) const;\n\n int cmpGEPs(const GetElementPtrInst *GEPL,\n\n const GetElementPtrInst *GEPR) const {\n\n return cmpGEPs(cast<GEPOperator>(GEPL), cast<GEPOperator>(GEPR));\n\n }\n\n\n\n /// Assign serial numbers to values from left function, and values from\n\n /// right function.\n\n /// Explanation:\n\n /// Being comparing functions we need to compare values we meet at left and\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 54, "score": 40159.01381518604 }, { "content": " /// integer.\n\n /// We also don't bother with same type at left and right, so\n\n /// just return 0 in this case.\n\n ///\n\n /// 1. If types are of different kind (different type IDs).\n\n /// Return result of type IDs comparison, treating them as numbers.\n\n /// 2. If types are integers, check that they have the same width. If they\n\n /// are vectors, check that they have the same count and subtype.\n\n /// 3. Types have the same ID, so check whether they are one of:\n\n /// * Void\n\n /// * Float\n\n /// * Double\n\n /// * X86_FP80\n\n /// * FP128\n\n /// * PPC_FP128\n\n /// * Label\n\n /// * Metadata\n\n /// We can treat these types as equal whenever their IDs are same.\n\n /// 4. If Left and Right are pointers, return result of address space\n\n /// comparison (numbers comparison). We can treat pointer types of same\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 55, "score": 40158.8723594544 }, { "content": " /// Compares the signature and other general attributes of the two functions.\n\n virtual int compareSignature() const;\n\n\n\n /// Test whether two basic blocks have equivalent behaviour.\n\n virtual int cmpBasicBlocks(const BasicBlock *BBL, const BasicBlock *BBR) const;\n\n\n\n /// Constants comparison.\n\n /// Its analog to lexicographical comparison between hypothetical numbers\n\n /// of next format:\n\n /// <bitcastability-trait><raw-bit-contents>\n\n ///\n\n /// 1. Bitcastability.\n\n /// Check whether L's type could be losslessly bitcasted to R's type.\n\n /// On this stage method, in case when lossless bitcast is not possible\n\n /// method returns -1 or 1, thus also defining which type is greater in\n\n /// context of bitcastability.\n\n /// Stage 0: If types are equal in terms of cmpTypes, then we can go straight\n\n /// to the contents comparison.\n\n /// If types differ, remember types comparison result and check\n\n /// whether we still can bitcast types.\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 56, "score": 40158.642529241166 }, { "content": "#include \"llvm/IR/Function.h\"\n\n#include \"llvm/IR/Operator.h\"\n\n#include \"llvm/IR/ValueMap.h\"\n\n#include \"llvm/Support/AtomicOrdering.h\"\n\n#include \"llvm/Support/Casting.h\"\n\n#include <cstdint>\n\n#include <tuple>\n\n\n\nnamespace llvm {\n\n\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 57, "score": 40158.40324794495 }, { "content": " /// result to the operation comparison result and exit from method.\n\n /// Otherwise we proceed to the next stage.\n\n /// Stages:\n\n /// 1. Operations opcodes. Compared as numbers.\n\n /// 2. Number of operands.\n\n /// 3. Operation types. Compared with cmpType method.\n\n /// 4. Compare operation subclass optional data as stream of bytes:\n\n /// just convert it to integers and call cmpNumbers.\n\n /// 5. Compare in operation operand types with cmpType in\n\n /// most significant operand first order.\n\n /// 6. Last stage. Check operations for some specific attributes.\n\n /// For example, for Load it would be:\n\n /// 6.1.Load: volatile (as boolean flag)\n\n /// 6.2.Load: alignment (as integer numbers)\n\n /// 6.3.Load: ordering (as underlying enum class value)\n\n /// 6.4.Load: synch-scope (as integer numbers)\n\n /// 6.5.Load: range metadata (as integer ranges)\n\n /// On this stage its better to see the code, since its not more than 10-15\n\n /// strings for particular instruction, and could change sometimes.\n\n ///\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 58, "score": 40157.92870625343 }, { "content": "//===- FunctionComparator.h - Function Comparator ---------------*- C++ -*-===//\n\n//\n\n// The LLVM Compiler Infrastructure\n\n//\n\n// This file is distributed under the University of Illinois Open Source\n\n// License. See LICENSE.TXT for details.\n\n//\n\n//===----------------------------------------------------------------------===//\n\n//\n\n// This file defines the FunctionComparator and GlobalNumberState classes which\n\n// are used by the MergeFunctions pass for comparing functions.\n\n//\n\n//===----------------------------------------------------------------------===//\n\n\n\n#ifndef LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H\n\n#define LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H\n\n\n\n#include \"llvm/ADT/APFloat.h\"\n\n#include \"llvm/ADT/DenseMap.h\"\n\n#include \"llvm/ADT/StringRef.h\"\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 59, "score": 40157.75945759661 }, { "content": " /// they are equal.\n\n /// Stage 1: Constants are greater than non-constants.\n\n /// If both left and right are constants, then the result of\n\n /// cmpConstants is used as cmpValues result.\n\n /// Stage 2: InlineAsm instances are greater than others. If both left and\n\n /// right are InlineAsm instances, InlineAsm* pointers casted to\n\n /// integers and compared as numbers.\n\n /// Stage 3: For all other cases we compare order we meet these values in\n\n /// their functions. If right value was met first during scanning,\n\n /// then left value is greater.\n\n /// In another words, we compare serial numbers, for more details\n\n /// see comments for sn_mapL and sn_mapR.\n\n virtual int cmpValues(const Value *L, const Value *R) const;\n\n\n\n /// Compare two Instructions for equivalence, similar to\n\n /// Instruction::isSameOperationAs.\n\n ///\n\n /// Stages are listed in \"most significant stage first\" order:\n\n /// On each stage below, we do comparison between some left and right\n\n /// operation parts. If parts are non-equal, we assign parts comparison\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 60, "score": 40157.58449800802 }, { "content": " /// right sides.\n\n /// Its easy to sort things out for external values. It just should be\n\n /// the same value at left and right.\n\n /// But for local values (those were introduced inside function body)\n\n /// we have to ensure they were introduced at exactly the same place,\n\n /// and plays the same role.\n\n /// Let's assign serial number to each value when we meet it first time.\n\n /// Values that were met at same place will be with same serial numbers.\n\n /// In this case it would be good to explain few points about values assigned\n\n /// to BBs and other ways of implementation (see below).\n\n ///\n\n /// 1. Safety of BB reordering.\n\n /// It's safe to change the order of BasicBlocks in function.\n\n /// Relationship with other functions and serial numbering will not be\n\n /// changed in this case.\n\n /// As follows from FunctionComparator::compare(), we do CFG walk: we start\n\n /// from the entry, and then take each terminator. So it doesn't matter how in\n\n /// fact BBs are ordered in function. And since cmpValues are called during\n\n /// this walk, the numbering depends only on how BBs located inside the CFG.\n\n /// So the answer is - yes. We will get the same numbering.\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 61, "score": 40157.584075369276 }, { "content": " /// Bitcastable constants.\n\n /// Let's assume, that some constant, belongs to some group of\n\n /// \"so-called-equal\" values with different types, and at the same time\n\n /// belongs to another group of constants with equal types\n\n /// and \"really\" equal values.\n\n ///\n\n /// Now, prove that this is impossible:\n\n ///\n\n /// If constant A with type TyA is bitcastable to B with type TyB, then:\n\n /// 1. All constants with equal types to TyA, are bitcastable to B. Since\n\n /// those should be vectors (if TyA is vector), pointers\n\n /// (if TyA is pointer), or else (if TyA equal to TyB), those types should\n\n /// be equal to TyB.\n\n /// 2. All constants with non-equal, but bitcastable types to TyA, are\n\n /// bitcastable to B.\n\n /// Once again, just because we allow it to vectors and pointers only.\n\n /// This statement could be expanded as below:\n\n /// 2.1. All vectors with equal bitwidth to vector A, has equal bitwidth to\n\n /// vector B, and thus bitcastable to B as well.\n\n /// 2.2. All pointers of the same address space, no matter what they point to,\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 62, "score": 40157.095712594484 }, { "content": " /// [NFCT], [FCT, \"others\"], [FCT, pointers], [FCT, vectors]\n\n /// Where: NFCT - Not a FirstClassType\n\n /// FCT - FirstClassTyp:\n\n ///\n\n /// 2. Compare raw contents.\n\n /// It ignores types on this stage and only compares bits from L and R.\n\n /// Returns 0, if L and R has equivalent contents.\n\n /// -1 or 1 if values are different.\n\n /// Pretty trivial:\n\n /// 2.1. If contents are numbers, compare numbers.\n\n /// Ints with greater bitwidth are greater. Ints with same bitwidths\n\n /// compared by their contents.\n\n /// 2.2. \"And so on\". Just to avoid discrepancies with comments\n\n /// perhaps it would be better to read the implementation itself.\n\n /// 3. And again about overall picture. Let's look back at how the ordered set\n\n /// of constants will look like:\n\n /// [NFCT], [FCT, \"others\"], [FCT, pointers], [FCT, vectors]\n\n ///\n\n /// Now look, what could be inside [FCT, \"others\"], for example:\n\n /// [FCT, \"others\"] =\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 63, "score": 40156.16478374716 }, { "content": " /// [\n\n /// [double 0.1], [double 1.23],\n\n /// [i32 1], [i32 2],\n\n /// { double 1.0 }, ; StructTyID, NumElements = 1\n\n /// { i32 1 }, ; StructTyID, NumElements = 1\n\n /// { double 1, i32 1 }, ; StructTyID, NumElements = 2\n\n /// { i32 1, double 1 } ; StructTyID, NumElements = 2\n\n /// ]\n\n ///\n\n /// Let's explain the order. Float numbers will be less than integers, just\n\n /// because of cmpType terms: FloatTyID < IntegerTyID.\n\n /// Floats (with same fltSemantics) are sorted according to their value.\n\n /// Then you can see integers, and they are, like a floats,\n\n /// could be easy sorted among each others.\n\n /// The structures. Structures are grouped at the tail, again because of their\n\n /// TypeID: StructTyID > IntegerTyID > FloatTyID.\n\n /// Structures with greater number of elements are greater. Structures with\n\n /// greater elements going first are greater.\n\n /// The same logic with vectors, arrays and other possible complex types.\n\n ///\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 64, "score": 40151.520391238475 }, { "content": " /// address space as equal.\n\n /// 5. If types are complex.\n\n /// Then both Left and Right are to be expanded and their element types will\n\n /// be checked with the same way. If we get Res != 0 on some stage, return it.\n\n /// Otherwise return 0.\n\n /// 6. For all other cases put llvm_unreachable.\n\n virtual int cmpTypes(Type *TyL, Type *TyR) const;\n\n\n\n virtual int cmpNumbers(uint64_t L, uint64_t R) const;\n\n virtual int cmpAPInts(const APInt &L, const APInt &R) const;\n\n virtual int cmpAPFloats(const APFloat &L, const APFloat &R) const;\n\n virtual int cmpMem(StringRef L, StringRef R) const;\n\n\n\n // The two functions undergoing comparison.\n\n const Function *FnL, *FnR;\n\n\n\n virtual int cmpOrderings(AtomicOrdering L, AtomicOrdering R) const;\n\n virtual int cmpInlineAsm(const InlineAsm *L, const InlineAsm *R) const;\n\n virtual int cmpAttrs(const AttributeList L, const AttributeList R) const;\n\n virtual int cmpRangeMetadata(const MDNode *L, const MDNode *R) const;\n", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 65, "score": 40151.45211504218 }, { "content": " ///\n\n /// 2. Impossibility to use dominance properties of values.\n\n /// If we compare two instruction operands: first is usage of local\n\n /// variable AL from function FL, and second is usage of local variable AR\n\n /// from FR, we could compare their origins and check whether they are\n\n /// defined at the same place.\n\n /// But, we are still not able to compare operands of PHI nodes, since those\n\n /// could be operands from further BBs we didn't scan yet.\n\n /// So it's impossible to use dominance properties in general.\n\n mutable DenseMap<const Value*, int> sn_mapL, sn_mapR;\n\n\n\nprivate:\n\n // The global state we will use\n\n GlobalNumberState* GlobalNumbers;\n\n};\n\n\n\n} // end namespace llvm\n\n\n\n#endif // LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H", "file_path": "diffkemp/simpll/FunctionComparator.h", "rank": 66, "score": 40149.40843562024 }, { "content": "// Overall report: contains pairs of different (non-equal) functions\n\nstruct ResultReport {\n\n std::vector<DiffFunPair> diffFuns;\n\n std::vector<MissingDefPair> missingDefs;\n\n std::vector<SyndiffBody> syndiffBodies;\n\n};\n\n\n\n// Report to YAML\n\nnamespace llvm::yaml {\n\ntemplate<>\n", "file_path": "diffkemp/simpll/Output.cpp", "rank": 67, "score": 40051.44775785422 }, { "content": "int FunctionComparator::cmpConstants(const Constant *L,\n\n const Constant *R) const {\n\n\n\n Type *TyL = L->getType();\n\n Type *TyR = R->getType();\n\n\n\n // Check whether types are bitcastable. This part is just re-factored\n\n // Type::canLosslesslyBitCastTo method, but instead of returning true/false,\n\n // we also pack into result which type is \"less\" for us.\n\n int TypesRes = cmpTypes(TyL, TyR);\n\n if (TypesRes != 0) {\n\n // Types are different, but check whether we can bitcast them.\n\n if (!TyL->isFirstClassType()) {\n\n if (TyR->isFirstClassType())\n\n return -1;\n\n // Neither TyL nor TyR are values of first class type. Return the result\n\n // of comparing the types\n\n return TypesRes;\n\n }\n\n if (!TyR->isFirstClassType()) {\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 68, "score": 39066.794413411386 }, { "content": " int cmpBasicBlocks(const BasicBlock *BBL, const BasicBlock *BBR)\n\n const override;\n\n /// Specific comparing of values. Handles values generated from macros\n\n /// whose value changed and values where at least one of them is a cast.\n\n int cmpValues(const Value *L, const Value *R) const override;\n\n /// Specific comparing of constants. If one of them (or both) is a cast\n\n /// constant expression, compare its operand.\n\n int cmpConstants(const Constant *L, const Constant *R) const override;\n\n /// Specific comarison of memcpy instructions\n\n int cmpMemset(const CallInst *CL, const CallInst *CR) const;\n\n /// Comparing of a structure size with a constant\n\n int cmpStructTypeSizeWithConstant(StructType *Type,\n\n const Value *Const) const;\n\n\n\n private:\n\n const DebugInfo *DI;\n\n bool controlFlowOnly;\n\n\n\n const DataLayout &LayoutL, &LayoutR;\n\n\n", "file_path": "diffkemp/simpll/DifferentialFunctionComparator.h", "rank": 69, "score": 39065.71553217466 }, { "content": " BasicBlock::const_iterator InstL = BBL->begin(), InstLE = BBL->end();\n\n BasicBlock::const_iterator InstR = BBR->begin(), InstRE = BBR->end();\n\n\n\n do {\n\n bool needToCmpOperands = true;\n\n if (int Res = cmpOperations(&*InstL, &*InstR, needToCmpOperands))\n\n return Res;\n\n if (needToCmpOperands) {\n\n assert(InstL->getNumOperands() == InstR->getNumOperands());\n\n\n\n for (unsigned i = 0, e = InstL->getNumOperands(); i != e; ++i) {\n\n Value *OpL = InstL->getOperand(i);\n\n Value *OpR = InstR->getOperand(i);\n\n if (int Res = cmpValues(OpL, OpR))\n\n return Res;\n\n // cmpValues should ensure this is true.\n\n assert(cmpTypes(OpL->getType(), OpR->getType()) == 0);\n\n }\n\n }\n\n\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 70, "score": 39064.65974954591 }, { "content": "// target of calls and the constants used in the function, which makes it useful\n\n// when possibly merging functions which are the same modulo constants and call\n\n// targets.\n\nFunctionComparator::FunctionHash FunctionComparator::functionHash(Function &F) {\n\n HashAccumulator64 H;\n\n H.add(F.isVarArg());\n\n H.add(F.arg_size());\n\n\n\n SmallVector<const BasicBlock *, 8> BBs;\n\n SmallSet<const BasicBlock *, 16> VisitedBBs;\n\n\n\n // Walk the blocks in the same order as FunctionComparator::cmpBasicBlocks(),\n\n // accumulating the hash of the function \"structure.\" (BB and opcode sequence)\n\n BBs.push_back(&F.getEntryBlock());\n\n VisitedBBs.insert(BBs[0]);\n\n while (!BBs.empty()) {\n\n const BasicBlock *BB = BBs.pop_back_val();\n\n // This random value acts as a block header, as otherwise the partition of\n\n // opcodes into BBs wouldn't affect the hash, only the order of the opcodes\n\n H.add(45798);\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 71, "score": 39061.19605919452 }, { "content": " for (auto &Inst : *BB) {\n\n H.add(Inst.getOpcode());\n\n }\n\n const TerminatorInst *Term = BB->getTerminator();\n\n for (unsigned i = 0, e = Term->getNumSuccessors(); i != e; ++i) {\n\n if (!VisitedBBs.insert(Term->getSuccessor(i)).second)\n\n continue;\n\n BBs.push_back(Term->getSuccessor(i));\n\n }\n\n }\n\n return H.getHash();\n\n}\n\n\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 72, "score": 39059.63394096386 }, { "content": " bool &needToCmpOperands) const {\n\n needToCmpOperands = true;\n\n if (int Res = cmpValues(L, R))\n\n return Res;\n\n\n\n // Differences from Instruction::isSameOperationAs:\n\n // * replace type comparison with calls to cmpTypes.\n\n // * we test for I->getRawSubclassOptionalData (nuw/nsw/tail) at the top.\n\n // * because of the above, we don't test for the tail bit on calls later on.\n\n if (int Res = cmpNumbers(L->getOpcode(), R->getOpcode()))\n\n return Res;\n\n\n\n if (const GetElementPtrInst *GEPL = dyn_cast<GetElementPtrInst>(L)) {\n\n needToCmpOperands = false;\n\n const GetElementPtrInst *GEPR = cast<GetElementPtrInst>(R);\n\n if (int Res =\n\n cmpValues(GEPL->getPointerOperand(), GEPR->getPointerOperand()))\n\n return Res;\n\n return cmpGEPs(GEPL, GEPR);\n\n }\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 73, "score": 39058.566843995664 }, { "content": "\n\n if (L->isNullValue() && R->isNullValue())\n\n return TypesRes;\n\n if (L->isNullValue() && !R->isNullValue())\n\n return 1;\n\n if (!L->isNullValue() && R->isNullValue())\n\n return -1;\n\n\n\n auto GlobalValueL = const_cast<GlobalValue*>(dyn_cast<GlobalValue>(L));\n\n auto GlobalValueR = const_cast<GlobalValue*>(dyn_cast<GlobalValue>(R));\n\n if (GlobalValueL && GlobalValueR) {\n\n return cmpGlobalValues(GlobalValueL, GlobalValueR);\n\n }\n\n\n\n if (int Res = cmpNumbers(L->getValueID(), R->getValueID()))\n\n return Res;\n\n\n\n if (const auto *SeqL = dyn_cast<ConstantDataSequential>(L)) {\n\n const auto *SeqR = cast<ConstantDataSequential>(R);\n\n // This handles ConstantDataArray and ConstantDataVector. Note that we\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 74, "score": 39056.70587024481 }, { "content": " // compare the two raw data arrays, which might differ depending on the host\n\n // endianness. This isn't a problem though, because the endiness of a module\n\n // will affect the order of the constants, but this order is the same\n\n // for a given input module and host platform.\n\n return cmpMem(SeqL->getRawDataValues(), SeqR->getRawDataValues());\n\n }\n\n\n\n switch (L->getValueID()) {\n\n case Value::UndefValueVal:\n\n case Value::ConstantTokenNoneVal:\n\n return TypesRes;\n\n case Value::ConstantIntVal: {\n\n const APInt &LInt = cast<ConstantInt>(L)->getValue();\n\n const APInt &RInt = cast<ConstantInt>(R)->getValue();\n\n return cmpAPInts(LInt, RInt);\n\n }\n\n case Value::ConstantFPVal: {\n\n const APFloat &LAPF = cast<ConstantFP>(L)->getValueAPF();\n\n const APFloat &RAPF = cast<ConstantFP>(R)->getValueAPF();\n\n return cmpAPFloats(LAPF, RAPF);\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 75, "score": 39056.58394396907 }, { "content": "// Pair of different functions that will be reported\n\nstruct DiffFunPair {\n\n FunctionInfo first, second;\n\n};\n\n\n\n// DiffFunPair to YAML\n\nnamespace llvm::yaml {\n\ntemplate<>\n", "file_path": "diffkemp/simpll/Output.cpp", "rank": 76, "score": 39056.339708436186 }, { "content": " }\n\n case Value::ConstantArrayVal: {\n\n const ConstantArray *LA = cast<ConstantArray>(L);\n\n const ConstantArray *RA = cast<ConstantArray>(R);\n\n uint64_t NumElementsL = cast<ArrayType>(TyL)->getNumElements();\n\n uint64_t NumElementsR = cast<ArrayType>(TyR)->getNumElements();\n\n if (int Res = cmpNumbers(NumElementsL, NumElementsR))\n\n return Res;\n\n for (uint64_t i = 0; i < NumElementsL; ++i) {\n\n if (int Res = cmpConstants(cast<Constant>(LA->getOperand(i)),\n\n cast<Constant>(RA->getOperand(i))))\n\n return Res;\n\n }\n\n return 0;\n\n }\n\n case Value::ConstantStructVal: {\n\n const ConstantStruct *LS = cast<ConstantStruct>(L);\n\n const ConstantStruct *RS = cast<ConstantStruct>(R);\n\n unsigned NumElementsL = cast<StructType>(TyL)->getNumElements();\n\n unsigned NumElementsR = cast<StructType>(TyR)->getNumElements();\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 77, "score": 39056.04862883242 }, { "content": "//===- FunctionComparator.h - Function Comparator -------------------------===//\n\n//\n\n// The LLVM Compiler Infrastructure\n\n//\n\n// This file is distributed under the University of Illinois Open Source\n\n// License. See LICENSE.TXT for details.\n\n//\n\n//===----------------------------------------------------------------------===//\n\n//\n\n// This file implements the FunctionComparator and GlobalNumberState classes\n\n// which are used by the MergeFunctions pass for comparing functions.\n\n//\n\n//===----------------------------------------------------------------------===//\n\n\n\n#include \"FunctionComparator.h\"\n\n#include \"llvm/ADT/SmallSet.h\"\n\n#include \"llvm/IR/CallSite.h\"\n\n#include \"llvm/IR/InlineAsm.h\"\n\n#include \"llvm/IR/Instructions.h\"\n\n#include \"llvm/IR/Module.h\"\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 78, "score": 39055.91718770891 }, { "content": " /// Specific comparison of attribute lists.\n\n /// Attributes that do not affect the semantics of functions are removed.\n\n int cmpAttrs(const AttributeList L, const AttributeList R) const override;\n\n /// Compare CallInsts using cmpAllocs.\n\n int cmpOperations(const Instruction *L, const Instruction *R,\n\n bool &needToCmpOperands) const override;\n\n /// Handle comparing of memory allocation function in cases where the size\n\n /// of the composite type is different.\n\n int cmpAllocs(const CallInst *CL, const CallInst *CR) const;\n\n /// Compare two function calls where one has an extra argument.\n\n /// Such calls are compared as equal if they only differ in the last\n\n /// argument which is 0 or NULL.\n\n int cmpCallsWithExtraArg(const CallInst *CL, const CallInst *CR) const;\n\n /// Compares array types with equivalent element types and all integer types\n\n /// as equal when comparing the control flow only.\n\n int cmpTypes(Type *L, Type *R) const override;\n\n /// Do not compare bitwidth when comparing the control flow only.\n\n int cmpAPInts(const APInt &L, const APInt &R) const override;\n\n /// Detect cast instructions and ignore them when comparing the control flow\n\n /// only. (The rest is the same as in LLVM.)\n", "file_path": "diffkemp/simpll/DifferentialFunctionComparator.h", "rank": 79, "score": 39055.21934244135 }, { "content": " for (size_t I = 0; I < L->getNumOperands(); ++I) {\n\n ConstantInt *LLow = mdconst::extract<ConstantInt>(L->getOperand(I));\n\n ConstantInt *RLow = mdconst::extract<ConstantInt>(R->getOperand(I));\n\n if (int Res = cmpAPInts(LLow->getValue(), RLow->getValue()))\n\n return Res;\n\n }\n\n return 0;\n\n}\n\n\n\nint FunctionComparator::cmpOperandBundlesSchema(const Instruction *L,\n\n const Instruction *R) const {\n\n ImmutableCallSite LCS(L);\n\n ImmutableCallSite RCS(R);\n\n\n\n assert(LCS && RCS && \"Must be calls or invokes!\");\n\n assert(LCS.isCall() == RCS.isCall() && \"Can't compare otherwise!\");\n\n\n\n if (int Res =\n\n cmpNumbers(LCS.getNumOperandBundles(), RCS.getNumOperandBundles()))\n\n return Res;\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 80, "score": 39054.93922250702 }, { "content": "\n\n for (unsigned i = 0, e = LCS.getNumOperandBundles(); i != e; ++i) {\n\n auto OBL = LCS.getOperandBundleAt(i);\n\n auto OBR = RCS.getOperandBundleAt(i);\n\n\n\n if (int Res = OBL.getTagName().compare(OBR.getTagName()))\n\n return Res;\n\n\n\n if (int Res = cmpNumbers(OBL.Inputs.size(), OBR.Inputs.size()))\n\n return Res;\n\n }\n\n\n\n return 0;\n\n}\n\n\n\n/// Constants comparison:\n\n/// 1. Check whether type of L constant could be losslessly bitcasted to R\n\n/// type.\n\n/// 2. Compare constant contents.\n\n/// For more details see declaration comments.\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 81, "score": 39054.005403522366 }, { "content": " if (int Res = cmpNumbers(NumElementsL, NumElementsR))\n\n return Res;\n\n for (unsigned i = 0; i != NumElementsL; ++i) {\n\n if (int Res = cmpConstants(cast<Constant>(LS->getOperand(i)),\n\n cast<Constant>(RS->getOperand(i))))\n\n return Res;\n\n }\n\n return 0;\n\n }\n\n case Value::ConstantVectorVal: {\n\n const ConstantVector *LV = cast<ConstantVector>(L);\n\n const ConstantVector *RV = cast<ConstantVector>(R);\n\n unsigned NumElementsL = cast<VectorType>(TyL)->getNumElements();\n\n unsigned NumElementsR = cast<VectorType>(TyR)->getNumElements();\n\n if (int Res = cmpNumbers(NumElementsL, NumElementsR))\n\n return Res;\n\n for (uint64_t i = 0; i < NumElementsL; ++i) {\n\n if (int Res = cmpConstants(cast<Constant>(LV->getOperand(i)),\n\n cast<Constant>(RV->getOperand(i))))\n\n return Res;\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 82, "score": 39053.35583787862 }, { "content": " }\n\n return 0;\n\n }\n\n\n\n case Type::FunctionTyID: {\n\n FunctionType *FTyL = cast<FunctionType>(TyL);\n\n FunctionType *FTyR = cast<FunctionType>(TyR);\n\n if (FTyL->getNumParams() != FTyR->getNumParams())\n\n return cmpNumbers(FTyL->getNumParams(), FTyR->getNumParams());\n\n\n\n if (FTyL->isVarArg() != FTyR->isVarArg())\n\n return cmpNumbers(FTyL->isVarArg(), FTyR->isVarArg());\n\n\n\n if (int Res = cmpTypes(FTyL->getReturnType(), FTyR->getReturnType()))\n\n return Res;\n\n\n\n for (unsigned i = 0, e = FTyL->getNumParams(); i != e; ++i) {\n\n if (int Res = cmpTypes(FTyL->getParamType(i), FTyR->getParamType(i)))\n\n return Res;\n\n }\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 83, "score": 39052.74170684043 }, { "content": " }\n\n return 0;\n\n }\n\n case Value::ConstantExprVal: {\n\n const ConstantExpr *LE = cast<ConstantExpr>(L);\n\n const ConstantExpr *RE = cast<ConstantExpr>(R);\n\n unsigned NumOperandsL = LE->getNumOperands();\n\n unsigned NumOperandsR = RE->getNumOperands();\n\n if (int Res = cmpNumbers(NumOperandsL, NumOperandsR))\n\n return Res;\n\n for (unsigned i = 0; i < NumOperandsL; ++i) {\n\n if (int Res = cmpConstants(cast<Constant>(LE->getOperand(i)),\n\n cast<Constant>(RE->getOperand(i))))\n\n return Res;\n\n }\n\n return 0;\n\n }\n\n case Value::BlockAddressVal: {\n\n const BlockAddress *LBA = cast<BlockAddress>(L);\n\n const BlockAddress *RBA = cast<BlockAddress>(R);\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 84, "score": 39052.51422526339 }, { "content": " if (int Res = cmpValues(LBA->getFunction(), RBA->getFunction()))\n\n return Res;\n\n if (LBA->getFunction() == RBA->getFunction()) {\n\n // They are BBs in the same function. Order by which comes first in the\n\n // BB order of the function. This order is deterministic.\n\n Function* F = LBA->getFunction();\n\n BasicBlock *LBB = LBA->getBasicBlock();\n\n BasicBlock *RBB = RBA->getBasicBlock();\n\n if (LBB == RBB)\n\n return 0;\n\n for(BasicBlock &BB : F->getBasicBlockList()) {\n\n if (&BB == LBB) {\n\n assert(&BB != RBB);\n\n return -1;\n\n }\n\n if (&BB == RBB)\n\n return 1;\n\n }\n\n llvm_unreachable(\"Basic Block Address does not point to a basic block in \"\n\n \"its function.\");\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 85, "score": 39052.36950823812 }, { "content": " ModuleComparator *ModComparator;\n\n\n\n /// Looks for inline assembly differences between the certain values.\n\n /// Note: passing the parent function is necessary in order to properly\n\n /// generate the SyntaxDifference object.\n\n std::vector<SyntaxDifference> findAsmDifference(const Value *L,\n\n const Value *R, const Function *ParentL, const Function *ParentR)\n\n const;\n\n};\n\n\n\n#endif //DIFFKEMP_SIMPLL_DIFFERENTIALFUNCTIONCOMPARATOR_H\n", "file_path": "diffkemp/simpll/DifferentialFunctionComparator.h", "rank": 86, "score": 39052.14305924589 }, { "content": " return Res;\n\n }\n\n\n\n if (int Res = cmpNumbers(FnL->hasSection(), FnR->hasSection()))\n\n return Res;\n\n\n\n if (FnL->hasSection()) {\n\n if (int Res = cmpMem(FnL->getSection(), FnR->getSection()))\n\n return Res;\n\n }\n\n\n\n if (int Res = cmpNumbers(FnL->isVarArg(), FnR->isVarArg()))\n\n return Res;\n\n\n\n // TODO: if it's internal and only used in direct calls, we could handle this\n\n // case too.\n\n if (int Res = cmpNumbers(FnL->getCallingConv(), FnR->getCallingConv()))\n\n return Res;\n\n\n\n if (int Res = cmpTypes(FnL->getFunctionType(), FnR->getFunctionType()))\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 87, "score": 39051.93254017615 }, { "content": " return -1;\n\n } else {\n\n // cmpValues said the functions are the same. So because they aren't\n\n // literally the same pointer, they must respectively be the left and\n\n // right functions.\n\n assert(LBA->getFunction() == FnL && RBA->getFunction() == FnR);\n\n // cmpValues will tell us if these are equivalent BasicBlocks, in the\n\n // context of their respective functions.\n\n return cmpValues(LBA->getBasicBlock(), RBA->getBasicBlock());\n\n }\n\n }\n\n default: // Unknown constant, abort.\n\n DEBUG(dbgs() << \"Looking at valueID \" << L->getValueID() << \"\\n\");\n\n llvm_unreachable(\"Constant ValueID not recognized.\");\n\n return -1;\n\n }\n\n}\n\n\n\nint FunctionComparator::cmpGlobalValues(GlobalValue *L, GlobalValue *R) const {\n\n uint64_t LNumber = GlobalNumbers->getNumber(L);\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 88, "score": 39051.74508380494 }, { "content": "\n\n if (int Res = compareSignature())\n\n return Res;\n\n\n\n // We do a CFG-ordered walk since the actual ordering of the blocks in the\n\n // linked list is immaterial. Our walk starts at the entry block for both\n\n // functions, then takes each block from each terminator in order. As an\n\n // artifact, this also means that unreachable blocks are ignored.\n\n SmallVector<const BasicBlock *, 8> FnLBBs, FnRBBs;\n\n SmallPtrSet<const BasicBlock *, 32> VisitedBBs; // in terms of F1.\n\n\n\n FnLBBs.push_back(&FnL->getEntryBlock());\n\n FnRBBs.push_back(&FnR->getEntryBlock());\n\n\n\n VisitedBBs.insert(FnLBBs[0]);\n\n while (!FnLBBs.empty()) {\n\n const BasicBlock *BBL = FnLBBs.pop_back_val();\n\n const BasicBlock *BBR = FnRBBs.pop_back_val();\n\n\n\n if (int Res = cmpValues(BBL, BBR))\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 89, "score": 39051.36265678246 }, { "content": " return -1;\n\n }\n\n if (R == FnR) {\n\n if (L == FnL)\n\n return 0;\n\n return 1;\n\n }\n\n\n\n const Constant *ConstL = dyn_cast<Constant>(L);\n\n const Constant *ConstR = dyn_cast<Constant>(R);\n\n if (ConstL && ConstR) {\n\n if (L == R)\n\n return 0;\n\n return cmpConstants(ConstL, ConstR);\n\n }\n\n\n\n if (ConstL)\n\n return 1;\n\n if (ConstR)\n\n return -1;\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 90, "score": 39051.14161383785 }, { "content": "#include \"llvm/Support/Debug.h\"\n\n#include \"llvm/Support/raw_ostream.h\"\n\n\n\nusing namespace llvm;\n\n\n\n#define DEBUG_TYPE \"functioncomparator\"\n\n\n\nint FunctionComparator::cmpNumbers(uint64_t L, uint64_t R) const {\n\n if (L < R) return -1;\n\n if (L > R) return 1;\n\n return 0;\n\n}\n\n\n\nint FunctionComparator::cmpOrderings(AtomicOrdering L, AtomicOrdering R) const {\n\n if ((int)L < (int)R) return -1;\n\n if ((int)L > (int)R) return 1;\n\n return 0;\n\n}\n\n\n\nint FunctionComparator::cmpAPInts(const APInt &L, const APInt &R) const {\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 91, "score": 39051.12719648609 }, { "content": "\n\n for (unsigned i = 0, e = GEPL->getNumOperands(); i != e; ++i) {\n\n if (int Res = cmpValues(GEPL->getOperand(i), GEPR->getOperand(i)))\n\n return Res;\n\n }\n\n\n\n return 0;\n\n}\n\n\n\nint FunctionComparator::cmpInlineAsm(const InlineAsm *L,\n\n const InlineAsm *R) const {\n\n // InlineAsm's are uniqued. If they are the same pointer, obviously they are\n\n // the same, otherwise compare the fields.\n\n if (L == R)\n\n return 0;\n\n if (int Res = cmpTypes(L->getFunctionType(), R->getFunctionType()))\n\n return Res;\n\n if (int Res = cmpMem(L->getAsmString(), R->getAsmString()))\n\n return Res;\n\n if (int Res = cmpMem(L->getConstraintString(), R->getConstraintString()))\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 92, "score": 39050.87592141034 }, { "content": " return 0;\n\n }\n\n\n\n case Type::ArrayTyID:\n\n case Type::VectorTyID: {\n\n auto *STyL = cast<SequentialType>(TyL);\n\n auto *STyR = cast<SequentialType>(TyR);\n\n if (STyL->getNumElements() != STyR->getNumElements())\n\n return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());\n\n return cmpTypes(STyL->getElementType(), STyR->getElementType());\n\n }\n\n }\n\n}\n\n\n\n// Determine whether the two operations are the same except that pointer-to-A\n\n// and pointer-to-B are equivalent. This should be kept in sync with\n\n// Instruction::isSameOperationAs.\n\n// Read method declaration comments for more details.\n\nint FunctionComparator::cmpOperations(const Instruction *L,\n\n const Instruction *R,\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 93, "score": 39050.64185385315 }, { "content": " if (int Res = cmpNumbers(APFloat::semanticsSizeInBits(SL),\n\n APFloat::semanticsSizeInBits(SR)))\n\n return Res;\n\n return cmpAPInts(L.bitcastToAPInt(), R.bitcastToAPInt());\n\n}\n\n\n\nint FunctionComparator::cmpMem(StringRef L, StringRef R) const {\n\n // Prevent heavy comparison, compare sizes first.\n\n if (int Res = cmpNumbers(L.size(), R.size()))\n\n return Res;\n\n\n\n // Compare strings lexicographically only when it is necessary: only when\n\n // strings are equal in size.\n\n return L.compare(R);\n\n}\n\n\n\nint FunctionComparator::cmpAttrs(const AttributeList L,\n\n const AttributeList R) const {\n\n if (int Res = cmpNumbers(L.getNumAttrSets(), R.getNumAttrSets()))\n\n return Res;\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 94, "score": 39050.4538066202 }, { "content": " return Res;\n\n\n\n if (int Res = cmpBasicBlocks(BBL, BBR))\n\n return Res;\n\n\n\n const TerminatorInst *TermL = BBL->getTerminator();\n\n const TerminatorInst *TermR = BBR->getTerminator();\n\n\n\n assert(TermL->getNumSuccessors() == TermR->getNumSuccessors());\n\n for (unsigned i = 0, e = TermL->getNumSuccessors(); i != e; ++i) {\n\n if (!VisitedBBs.insert(TermL->getSuccessor(i)).second)\n\n continue;\n\n\n\n FnLBBs.push_back(TermL->getSuccessor(i));\n\n FnRBBs.push_back(TermR->getSuccessor(i));\n\n }\n\n }\n\n return 0;\n\n}\n\n\n\nnamespace {\n\n\n\n// Accumulate the hash of a sequence of 64-bit integers. This is similar to a\n\n// hash of a sequence of 64bit ints, but the entire input does not need to be\n\n// available at once. This interface is necessary for functionHash because it\n\n// needs to accumulate the hash as the structure of the function is traversed\n\n// without saving these values to an intermediate buffer. This form of hashing\n\n// is not often needed, as usually the object to hash is just read from a\n\n// buffer.\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 95, "score": 39050.20809914679 }, { "content": " if (int Res = cmpNumbers(TyL->getTypeID(), TyR->getTypeID()))\n\n return Res;\n\n\n\n switch (TyL->getTypeID()) {\n\n default:\n\n llvm_unreachable(\"Unknown type!\");\n\n // Fall through in Release mode.\n\n LLVM_FALLTHROUGH;\n\n case Type::IntegerTyID:\n\n return cmpNumbers(cast<IntegerType>(TyL)->getBitWidth(),\n\n cast<IntegerType>(TyR)->getBitWidth());\n\n // TyL == TyR would have returned true earlier, because types are uniqued.\n\n case Type::VoidTyID:\n\n case Type::FloatTyID:\n\n case Type::DoubleTyID:\n\n case Type::X86_FP80TyID:\n\n case Type::FP128TyID:\n\n case Type::PPC_FP128TyID:\n\n case Type::LabelTyID:\n\n case Type::MetadataTyID:\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 96, "score": 39050.12212113513 }, { "content": " }\n\n if (const StoreInst *SI = dyn_cast<StoreInst>(L)) {\n\n if (int Res =\n\n cmpNumbers(SI->isVolatile(), cast<StoreInst>(R)->isVolatile()))\n\n return Res;\n\n if (int Res =\n\n cmpNumbers(SI->getAlignment(), cast<StoreInst>(R)->getAlignment()))\n\n return Res;\n\n if (int Res =\n\n cmpOrderings(SI->getOrdering(), cast<StoreInst>(R)->getOrdering()))\n\n return Res;\n\n return cmpNumbers(SI->getSyncScopeID(),\n\n cast<StoreInst>(R)->getSyncScopeID());\n\n }\n\n if (const CmpInst *CI = dyn_cast<CmpInst>(L))\n\n return cmpNumbers(CI->getPredicate(), cast<CmpInst>(R)->getPredicate());\n\n if (const CallInst *CI = dyn_cast<CallInst>(L)) {\n\n if (int Res = cmpNumbers(CI->getCallingConv(),\n\n cast<CallInst>(R)->getCallingConv()))\n\n return Res;\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 97, "score": 39049.94119468989 }, { "content": " uint64_t RNumber = GlobalNumbers->getNumber(R);\n\n return cmpNumbers(LNumber, RNumber);\n\n}\n\n\n\n/// cmpType - compares two types,\n\n/// defines total ordering among the types set.\n\n/// See method declaration comments for more details.\n\nint FunctionComparator::cmpTypes(Type *TyL, Type *TyR) const {\n\n PointerType *PTyL = dyn_cast<PointerType>(TyL);\n\n PointerType *PTyR = dyn_cast<PointerType>(TyR);\n\n\n\n const DataLayout &DL = FnL->getParent()->getDataLayout();\n\n if (PTyL && PTyL->getAddressSpace() == 0)\n\n TyL = DL.getIntPtrType(TyL);\n\n if (PTyR && PTyR->getAddressSpace() == 0)\n\n TyR = DL.getIntPtrType(TyR);\n\n\n\n if (TyL == TyR)\n\n return 0;\n\n\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 98, "score": 39049.48628307433 }, { "content": " cast<InvokeInst>(R)->getMetadata(LLVMContext::MD_range));\n\n }\n\n if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(L)) {\n\n ArrayRef<unsigned> LIndices = IVI->getIndices();\n\n ArrayRef<unsigned> RIndices = cast<InsertValueInst>(R)->getIndices();\n\n if (int Res = cmpNumbers(LIndices.size(), RIndices.size()))\n\n return Res;\n\n for (size_t i = 0, e = LIndices.size(); i != e; ++i) {\n\n if (int Res = cmpNumbers(LIndices[i], RIndices[i]))\n\n return Res;\n\n }\n\n return 0;\n\n }\n\n if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(L)) {\n\n ArrayRef<unsigned> LIndices = EVI->getIndices();\n\n ArrayRef<unsigned> RIndices = cast<ExtractValueInst>(R)->getIndices();\n\n if (int Res = cmpNumbers(LIndices.size(), RIndices.size()))\n\n return Res;\n\n for (size_t i = 0, e = LIndices.size(); i != e; ++i) {\n\n if (int Res = cmpNumbers(LIndices[i], RIndices[i]))\n", "file_path": "diffkemp/simpll/FunctionComparator.cpp", "rank": 99, "score": 39049.485595200225 } ]
C++
src/EDepSimModuleBuilder.hh
andrewmogan/edep-sim
4e9923ccba8b2f65f47b72cbb41ed683f19f1123
#ifndef EDepSim_ModuleBuilder_hh_seen #define EDepSim_ModuleBuilder_hh_seen #include <sstream> #include <G4ThreeVector.hh> class G4LogicalVolume; #include "EDepSimBuilder.hh" #include "EDepSimComponentBuilder.hh" namespace EDepSim {class ModuleBuilder;} class EDepSim::ModuleBuilder : public EDepSim::Builder { public: ModuleBuilder(G4String n, EDepSim::UserDetectorConstruction* c) : EDepSim::Builder(n,c) {Init();}; ModuleBuilder(G4String n, EDepSim::Builder* p) : EDepSim::Builder(n,p) { Init();}; virtual ~ModuleBuilder(); virtual G4LogicalVolume *GetPiece(void); void SetWidth(double w) {fWidth = w;} double GetWidth(void) {return fWidth;} void SetHeight(double w) {fHeight = w;} double GetHeight(void) {return fHeight;} double GetLength(void) {return fLength;}; void ClearComponentList(void); void AddComponent(G4String m); void SetRepetitions(int r, int c); void SetModuleCompTrans(int m, int cPerM, int c, double transX, double transY); void SetTargetLength(double w) {fTargetLength = w;} double GetTargetLength(void) {return fTargetLength;} void SetFixLength(bool f) {fFixLength = f;} bool GetFixLength(void) {return fFixLength;} void SetXPosition(double x) {xPosition = x;} double GetXPosition() {return xPosition;} void SetYPosition(double y) {yPosition = y;} double GetYPosition() {return yPosition;} double GetXmaxTranslation() {return xmax;} double GetXminTranslation() {return xmin;} double GetYmaxTranslation() {return ymax;} double GetYminTranslation() {return ymin;} private: double fWidth; double fHeight; double fLength; double fTargetLength; bool fFixLength; double xPosition; double yPosition; std::pair<double, double> fPair; typedef std::vector<EDepSim::ComponentBuilder*> PartsList; PartsList* fPartsList; typedef std::vector<std::pair<double, double> > TransList; TransList* fTransList; G4double xmax, xmin, ymax, ymin; void Init(void); }; namespace EDepSim {class ModuleBuilderMessenger;} class EDepSim::ModuleBuilderMessenger: public EDepSim::BuilderMessenger { private: EDepSim::ModuleBuilder* fBuilder; G4UIcmdWithoutParameter* fClearCMD; G4UIcmdWithAString* fAddCMD; G4UIcommand* fRepeatCMD; G4UIcmdWithADoubleAndUnit* fWidthCMD; G4UIcmdWithADoubleAndUnit* fHeightCMD; public: ModuleBuilderMessenger(EDepSim::ModuleBuilder* c, const char* guide=NULL) : EDepSim::BuilderMessenger(c,guide), fBuilder(c) { fClearCMD = new G4UIcmdWithoutParameter(CommandName("clear"),this); fClearCMD->SetGuidance("Clear the component list for the FG tracker."); fAddCMD = new G4UIcmdWithAString(CommandName("add"),this); fAddCMD->SetGuidance("Add the named component to the module." " Components are added from upstream" " to downstream."); fAddCMD->SetParameterName("Component", false); fRepeatCMD = new G4UIcommand(CommandName("repeat"),this); fRepeatCMD->SetGuidance("Times to repeat the last components."); G4UIparameter* repParam = new G4UIparameter('i'); repParam->SetParameterName("Repetitions"); fRepeatCMD->SetParameter(repParam); G4UIparameter* cntParam = new G4UIparameter('i'); cntParam->SetParameterName("Count"); fRepeatCMD->SetParameter(cntParam); fWidthCMD = new G4UIcmdWithADoubleAndUnit(CommandName("width"),this); fWidthCMD->SetGuidance("Set the width of the module."); fWidthCMD->SetParameterName("Width",false); fWidthCMD->SetUnitCategory("Length"); fHeightCMD = new G4UIcmdWithADoubleAndUnit(CommandName("height"),this); fHeightCMD->SetGuidance("Set the height of the module."); fHeightCMD->SetParameterName("Height",false); fHeightCMD->SetUnitCategory("Length"); }; virtual ~ModuleBuilderMessenger() { delete fClearCMD; delete fAddCMD; delete fRepeatCMD; delete fWidthCMD; delete fHeightCMD; }; void SetNewValue(G4UIcommand *cmd, G4String val) { if (cmd==fClearCMD) { fBuilder->ClearComponentList(); } else if (cmd==fAddCMD) { fBuilder->AddComponent(val); } else if (cmd==fRepeatCMD) { int repetitions; int count = 1; std::istringstream inputs((char*)val.c_str()); inputs >> repetitions >> count; fBuilder->SetRepetitions(repetitions,count); } else if (cmd==fWidthCMD) { fBuilder->SetWidth(fWidthCMD->GetNewDoubleValue(val)); } else if (cmd==fHeightCMD) { fBuilder->SetHeight(fHeightCMD->GetNewDoubleValue(val)); } else { EDepSim::BuilderMessenger::SetNewValue(cmd,val); } }; }; #endif
#ifndef EDepSim_ModuleBuilder_hh_seen #define EDepSim_ModuleBuilder_hh_seen #include <sstream> #include <G4ThreeVector.hh> class G4LogicalVolume; #include "EDepSimBuilder.hh" #include "EDepSimComponentBuilder.hh" namespace EDepSim {class ModuleBuilder;} class EDepSim::ModuleBuilder : public EDepSim::Builder { public: ModuleBuilder(G4String n, EDepSim::UserDetectorConstruction* c) : EDepSim::Builder(n,c) {Init();}; ModuleBuilder(G4String n, EDepSim::Builder* p) : EDepSim::Builder(n,p) { Init();}; virtual ~ModuleBuilder(); virtual G4LogicalVolume *GetPiece(void); void SetWidth(double w) {fWidth = w;} double GetWidth(void) {return fWidth;} void SetHeight(double w) {fHeight = w;} double GetHeight(void) {return fHeight;} double GetLength(void) {return fLength;}; void ClearComponentList(void); void AddComponent(G4String m); void SetRepetitions(int r, int c); void SetModuleCompTrans(int m, int cPerM, int c, double transX, double transY); void SetTargetLength(double w) {fTargetLength = w;} double GetTargetLength(void) {return fTargetLength;} void SetFixLength(bool f) {fFixLength = f;} bool GetFixLength(void) {return fFixLength;} void SetXPosition(double x) {xPosition = x;} double GetXPosition() {return xPosition;} void SetYPosition(double y) {yPosition = y;} double GetYPosition() {return yPosition;} double GetXmaxTranslation() {return xmax;} double GetXminTranslation() {return xmin;} double GetYmaxTranslation() {return ymax;} double GetYminTranslation() {return ymin;} private: double fWidth; double fHeight; double fLength; double fTargetLength; bool fFixLength; double xPosition; double yPosition; std::pair<double, double> fPair; typedef std::vector<EDepSim::ComponentBuilder*> PartsList; PartsList* fPartsList; typedef std::vector<std::pair<double, double> > TransList; TransList* fTransList; G4double xmax, xmin, ymax, ymin; void Init(void); }; namespace EDepSim {class ModuleBuilderMessenger;} class EDepSim::ModuleBuilderMessenger: public EDepSim::BuilderMessenger { private: EDepSim::ModuleBuilder* fBuilder; G4UIcmdWithoutParameter* fClearCMD; G4UIcmdWithAString* fAddCMD; G4UIcommand* fRepeatCMD; G4UIcmdWithADoubleAndUnit* fWidthCMD; G4UIcmdWithADoubleAndUnit* fHeightCMD; public:
; virtual ~ModuleBuilderMessenger() { delete fClearCMD; delete fAddCMD; delete fRepeatCMD; delete fWidthCMD; delete fHeightCMD; }; void SetNewValue(G4UIcommand *cmd, G4String val) { if (cmd==fClearCMD) { fBuilder->ClearComponentList(); } else if (cmd==fAddCMD) { fBuilder->AddComponent(val); } else if (cmd==fRepeatCMD) { int repetitions; int count = 1; std::istringstream inputs((char*)val.c_str()); inputs >> repetitions >> count; fBuilder->SetRepetitions(repetitions,count); } else if (cmd==fWidthCMD) { fBuilder->SetWidth(fWidthCMD->GetNewDoubleValue(val)); } else if (cmd==fHeightCMD) { fBuilder->SetHeight(fHeightCMD->GetNewDoubleValue(val)); } else { EDepSim::BuilderMessenger::SetNewValue(cmd,val); } }; }; #endif
ModuleBuilderMessenger(EDepSim::ModuleBuilder* c, const char* guide=NULL) : EDepSim::BuilderMessenger(c,guide), fBuilder(c) { fClearCMD = new G4UIcmdWithoutParameter(CommandName("clear"),this); fClearCMD->SetGuidance("Clear the component list for the FG tracker."); fAddCMD = new G4UIcmdWithAString(CommandName("add"),this); fAddCMD->SetGuidance("Add the named component to the module." " Components are added from upstream" " to downstream."); fAddCMD->SetParameterName("Component", false); fRepeatCMD = new G4UIcommand(CommandName("repeat"),this); fRepeatCMD->SetGuidance("Times to repeat the last components."); G4UIparameter* repParam = new G4UIparameter('i'); repParam->SetParameterName("Repetitions"); fRepeatCMD->SetParameter(repParam); G4UIparameter* cntParam = new G4UIparameter('i'); cntParam->SetParameterName("Count"); fRepeatCMD->SetParameter(cntParam); fWidthCMD = new G4UIcmdWithADoubleAndUnit(CommandName("width"),this); fWidthCMD->SetGuidance("Set the width of the module."); fWidthCMD->SetParameterName("Width",false); fWidthCMD->SetUnitCategory("Length"); fHeightCMD = new G4UIcmdWithADoubleAndUnit(CommandName("height"),this); fHeightCMD->SetGuidance("Set the height of the module."); fHeightCMD->SetParameterName("Height",false); fHeightCMD->SetUnitCategory("Length"); }
function_block-full_function
[ { "content": "class EDepSim::DokeBirks : public G4VRestDiscreteProcess //class definition\n\n{\n\npublic:\n\n\n\n DokeBirks(const G4String& processName = \"Doke-Birks\",\n\n G4ProcessType type = fElectromagnetic);\n\n ~DokeBirks();\n\n\n\n /// Determine which particles this process should be applied too.\n\n G4bool IsApplicable(const G4ParticleDefinition& aParticleType);\n\n \n\n /// Don't limit the step since this process doesn't actually change the\n\n /// energy deposit (it returns infinity). The process does set the\n\n /// 'StronglyForced' condition so the DoIt is invoked at every step.\n\n G4double GetMeanFreePath(const G4Track& aTrack,\n\n G4double ,\n\n G4ForceCondition* );\n\n\n\n /// Don't limit the step since this process doesn't actually change the\n\n /// energy deposit (it returns infinity). The process does set the\n", "file_path": "src/EDepSimDokeBirks.hh", "rank": 0, "score": 143936.2630208872 }, { "content": "/// Construct the cryostat. This builds the vessel, as well as the argon gas\n\n/// and liquid inside. This builds the vessel directly and fills it with\n\n/// argon gas. The liquid argon is build by a separate constructor which will\n\n/// contain the TPC.\n\n/// \n\n/// \\bug The current class is an extremely simplistic model. I think the\n\n/// cryostat is multi-walled, but I don't have the design documents right now.\n\n/// The invariants for this class are the inner diameter and inner heights\n\n/// which define the cold volume. The outer diameter and height should be\n\n/// calculated.\n\nclass CaptCryostatBuilder : public EDepSim::Builder {\n\npublic:\n\n CaptCryostatBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~CaptCryostatBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Get (or set) the distance from the flange to the top of the liquid\n\n /// argon.\n\n /// @{\n\n double GetArgonDepth() const {return fArgonDepth;}\n\n void SetArgonDepth(double v) {fArgonDepth = v;}\n\n /// @}\n\n\n\n /// Get (or set) the distance from the flange to the TPC center.\n", "file_path": "src/captain/CaptCryostatBuilder.hh", "rank": 1, "score": 142875.99899959634 }, { "content": "/// EDepSim specific trajectory class to save internal bookkeeping\n\n/// information. This keeps track of information about a particular particle\n\n/// track. Important information kept includes how much energy this\n\n/// trajectory has deposited in sensitive detectors, and it can query it's\n\n/// children to find out how much energy they deposited. It also keeps track\n\n/// of the process that created the trajectory, the total length in the\n\n/// sensitive detectors, and points along the trajectory.\n\nclass EDepSim::Trajectory : public G4VTrajectory {\n\npublic:\n\n Trajectory();\n\n\n\n Trajectory(const G4Track* aTrack);\n\n Trajectory(EDepSim::Trajectory &);\n\n virtual ~Trajectory();\n\n\n\n inline void* operator new(size_t);\n\n inline void operator delete(void*);\n\n inline int operator == (const EDepSim::Trajectory& right) const {\n\n return (this==&right);\n\n }\n\n\n\n /// Get the track id described by this trajectory.\n\n inline G4int GetTrackID() const {return fTrackID;}\n\n\n\n /// Get the track id of the parent of the track described by this\n\n /// trajectory.\n\n inline G4int GetParentID() const {return fParentID;}\n", "file_path": "src/EDepSimTrajectory.hh", "rank": 2, "score": 142874.97225528472 }, { "content": "/// Construct the exposed part of the CAPTAIN detector. This builds exposed\n\n/// parts of the TPC that are in the argon gas. The exposed volume is\n\n/// returned as a cylinder filled with liquid argon.\n\nclass CaptImmersedBuilder : public EDepSim::Builder {\n\npublic:\n\n CaptImmersedBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~CaptImmersedBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Return the offset of the intended origin of the volume relative to the\n\n /// center of the logical volume. To get the origin at the right location\n\n /// (say originPosition), the logical volume should be positioned at\n\n /// originPosition-GetOffset(). The offset is defined by the bottom of\n\n /// the wire plane assembly (a decision will be made in the future as to\n\n /// whether this is the bottom of the grid, or the bottom of the V plane.\n\n /// This means that the wires for the V plane are at a (very) small\n\n /// positive z coordinate.\n", "file_path": "src/captain/CaptImmersedBuilder.hh", "rank": 3, "score": 142872.30952918527 }, { "content": "/// Construct the exposed part of the CAPTAIN detector. This builds exposed\n\n/// parts of the TPC that are in the argon gas. The exposed volume is\n\n/// returned as a cylinder filled with liquid argon.\n\nclass CaptExposedBuilder : public EDepSim::Builder {\n\npublic:\n\n CaptExposedBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~CaptExposedBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Return the offset of the intended origin of the volume relative to the\n\n /// center of the logical volume. To get the origin at the right location\n\n /// (say originPosition), the logical volume should be positioned at\n\n /// originPosition-GetOffset(). The offset is defined by the bottom of\n\n /// the wire plane assembly (a decision will be made in the future as to\n\n /// whether this is the bottom of the grid, or the bottom of the V plane.\n\n /// This means that the wires for the V plane are at a (very) small\n\n /// positive z coordinate.\n", "file_path": "src/captain/CaptExposedBuilder.hh", "rank": 4, "score": 142872.30952918527 }, { "content": "/// Construct an unrotated PMT. In the local coordinate system, the\n\n/// PMT points along the positive Z direction.\n\nclass CaptPMTBuilder : public EDepSim::Builder {\n\npublic:\n\n CaptPMTBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~CaptPMTBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Get or set the length of the base. The base length measures from the\n\n /// face of the photocathode to the back of the PMT. \n\n /// @{\n\n void SetBaseLength(double v) {fBaseLength = v;}\n\n double GetBaseLength() const {return fBaseLength;}\n\n /// @}\n\n\n\n /// Set the size of the PMT.\n", "file_path": "src/captain/CaptPMTBuilder.hh", "rank": 5, "score": 142867.78620424675 }, { "content": "/// Construct the world volume. The origin is located at the center of the\n\n/// detector coordinate system. The world is mostly filled with air.\n\nclass CaptWorldBuilder : public EDepSim::Builder {\n\npublic:\n\n CaptWorldBuilder(G4String n, EDepSim::UserDetectorConstruction* c)\n\n : EDepSim::Builder(n,c) {Init();};\n\n virtual ~CaptWorldBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Set the length of the world\n\n void SetLength(double v) {fLength = v;}\n\n\n\n /// Set the width of the world\n\n void SetWidth(double v) {fWidth = v;}\n\n \n\n /// Set the height of the world\n\n void SetHeight(double v) {fHeight = v;}\n", "file_path": "src/captain/CaptWorldBuilder.hh", "rank": 6, "score": 142867.78620424675 }, { "content": "class EDepSim::ComponentBuilder : public EDepSim::Builder {\n\npublic:\n\n ComponentBuilder(G4String n, EDepSim::UserDetectorConstruction* c)\n\n : EDepSim::Builder(n,c), fLength(0.0), \n\n fMaximumWidth(0.0), fMaximumHeight(0.0) {}\n\n ComponentBuilder(G4String n, EDepSim::Builder* p)\n\n : EDepSim::Builder(n,p), fLength(0.0),\n\n fMaximumWidth(0.0), fMaximumHeight(0.0) {}\n\n virtual ~ComponentBuilder() {;};\n\n\n\n /// Set the width of the component. This is the X dimension of the space\n\n /// available for the component and may be relative to the outside geometry.\n\n /// The width is set by the EDepSim::ModuleBuilder object which will\n\n /// contain this component, so it should not be directly set in user code.\n\n /// The actual constructed component width must be less than the width set\n\n /// by the owning EDepSim::ModuleBuilder.\n\n virtual void SetWidth(double w) {fWidth = w;}\n\n\n\n /// Get the width of the component. This is the X dimension of the space\n\n /// available for the component and may be relative to the outside geometry.\n", "file_path": "src/EDepSimComponentBuilder.hh", "rank": 7, "score": 142620.24260973308 }, { "content": "class EDepSim::BuilderMessenger: public G4UImessenger {\n\nprivate:\n\n EDepSim::Builder* fBuilder;\n\n\n\n /// The UI directory for this messenger.\n\n G4UIdirectory* fDirectory;\n\n\n\n /// The directory name for this messenger\n\n G4String fDirName;\n\n\n\n G4UIcmdWithADouble* fOpacityCMD;\n\n G4UIcmdWithADouble* fDaughterOpacityCMD;\n\n G4UIcmdWithABool* fCheckCMD;\n\n G4UIcommand* fSensitiveCMD;\n\n G4UIcmdWithADoubleAndUnit* fMaximumHitSagittaCMD;\n\n G4UIcmdWithADoubleAndUnit* fMaximumHitLengthCMD;\n\n\n\npublic:\n\n BuilderMessenger(EDepSim::Builder* c, const char* guide=NULL);\n\n virtual ~BuilderMessenger();\n", "file_path": "src/EDepSimBuilder.hh", "rank": 9, "score": 141324.2568305615 }, { "content": "class EDepSim::NoMoreEvents : public EDepSim::Exception {\n\npublic:\n\n NoMoreEvents() {}\n\n ~NoMoreEvents() throw() {}\n\n const char* what(void) const throw() {return \"EDepSim::NoMoreEvents\";}\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimVKinematicsGenerator.hh", "rank": 10, "score": 141257.61315319367 }, { "content": "class EDepSim::Exception : public std::exception {\n\npublic:\n\n Exception() {}\n\n virtual ~Exception() throw() {}\n\n const char* what(void) const throw() {return \"EDepSim::Exception\";}\n\n};\n\n\n\n/// Print an error message, and then throw an exception.\n\n#define EDepSimThrow(message) {EDepSimError(message);throw EDepSim::Exception();} \n\n#endif\n", "file_path": "src/EDepSimException.hh", "rank": 11, "score": 140011.1067023923 }, { "content": "class EDepSim::ComponentBuilderMessenger: public EDepSim::BuilderMessenger {\n\nprivate:\n\n EDepSim::ComponentBuilder* fBuilder;\n\n G4UIcmdWithADoubleAndUnit* fWidthCMD;\n\n G4UIcmdWithADoubleAndUnit* fHeightCMD;\n\n G4UIcmdWithADoubleAndUnit* fMaxWidthCMD;\n\n G4UIcmdWithADoubleAndUnit* fMaxHeightCMD;\n\n\n\npublic:\n\n ComponentBuilderMessenger(EDepSim::ComponentBuilder* c,\n\n const char* guide) \n\n : EDepSim::BuilderMessenger(c,guide),\n\n fBuilder(c) {\n\n\n\n fWidthCMD = new G4UIcmdWithADoubleAndUnit(CommandName(\"width\"),this);\n\n fWidthCMD->SetGuidance(\"Set the width of the component.\");\n\n fWidthCMD->SetParameterName(\"Width\",false);\n\n fWidthCMD->SetUnitCategory(\"Length\");\n\n\n\n fHeightCMD = new G4UIcmdWithADoubleAndUnit(CommandName(\"height\"),this);\n", "file_path": "src/EDepSimComponentBuilder.hh", "rank": 12, "score": 139948.25980188115 }, { "content": "/// Construct the drift region of the TPC. The wire planes are located at the\n\n/// top of the drift region, with the first wire for each plane located at the\n\n/// most negative X coordinate. The U plane runs from negative Y to positive\n\n/// Y. The V plane runs from positive Y to negative Y. The planes are\n\n/// oriented from top to bottom X, U, V (in otherwords, the first plane seen\n\n/// by the electrons is the V plane). The X plane is the collection plane.\n\nclass CaptDriftRegionBuilder : public EDepSim::Builder {\n\npublic:\n\n CaptDriftRegionBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~CaptDriftRegionBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Get the total height of the drift region.\n\n double GetHeight();\n\n\n\n /// Set the radius of the largest cylinder that can be contained in the\n\n /// drift region.\n\n /// @{\n\n void SetApothem(double v) {fApothem = v;}\n\n double GetApothem() {return fApothem;}\n", "file_path": "src/captain/CaptDriftRegionBuilder.hh", "rank": 14, "score": 139850.0919251943 }, { "content": "/// Construct an unrotated wire plane. In the local coordinate system, the\n\n/// wires are oriented along the Y axis, and the wire number increases from\n\n/// negative X to positive X. The electric field points along the Z axis, or\n\n/// in other words, into the drift region, and electrons drift from positive Z\n\n/// toward the planes (i.e. in the negative Z direction).\n\n/// \n\n/// The wires are not \"tubes\", but are boxes that represent the area overwhich\n\n/// the wire will measure charge. The name of the wire planes is significant\n\n/// since captevent will assigned a geometry identifier based on the name\n\n/// \"XPlane\", \"UPlane\", \"VPlane\". There can only be one with each name.\n\n///\n\nclass CaptWirePlaneBuilder : public EDepSim::Builder {\n\npublic:\n\n CaptWirePlaneBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~CaptWirePlaneBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Get the total height (thickness) of the drift region.\n\n /// @{\n\n void SetHeight(double v) {fHeight = v;}\n\n double GetHeight() const {return fHeight;}\n\n /// @}\n\n\n\n /// Set the radius of the largest cylinder that can be contained in the\n\n /// hexagonal wire plane. This is the maximum local X dimension. \n", "file_path": "src/captain/CaptWirePlaneBuilder.hh", "rank": 15, "score": 139849.78356958844 }, { "content": "/// Construct the immersed part of the mini CAPTAIN detector. This builds\n\n/// immersed parts of the TPC that are in the argon liquid. The exposed\n\n/// volume is returned as a cylinder filled with liquid argon.\n\nclass MiniCaptImmersedBuilder : public EDepSim::Builder {\n\npublic:\n\n MiniCaptImmersedBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~MiniCaptImmersedBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Return the offset of the intended origin of the volume relative to the\n\n /// center of the logical volume. To get the origin at the right location\n\n /// (say originPosition), the logical volume should be positioned at\n\n /// originPosition-GetOffset(). The offset is defined by the bottom of\n\n /// the wire plane assembly (a decision will be made in the future as to\n\n /// whether this is the bottom of the grid, or the bottom of the V plane.\n\n /// This means that the wires for the V plane are at a (very) small\n\n /// positive z coordinate.\n", "file_path": "src/captain/MiniCaptImmersedBuilder.hh", "rank": 16, "score": 139849.32173846144 }, { "content": "/// Construct the exposed part of the miniCAPTAIN detector. This builds\n\n/// exposed parts of the TPC that are in the argon gas. The exposed volume is\n\n/// returned as a cylinder filled with liquid argon.\n\nclass MiniCaptExposedBuilder : public EDepSim::Builder {\n\npublic:\n\n MiniCaptExposedBuilder(G4String name, EDepSim::Builder* parent)\n\n : EDepSim::Builder(name,parent) {Init();};\n\n virtual ~MiniCaptExposedBuilder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void);\n\n\n\n /// Return the offset of the intended origin of the volume relative to the\n\n /// center of the logical volume. To get the origin at the right location\n\n /// (say originPosition), the logical volume should be positioned at\n\n /// originPosition-GetOffset(). The offset is defined by the bottom of\n\n /// the wire plane assembly (a decision will be made in the future as to\n\n /// whether this is the bottom of the grid, or the bottom of the V plane.\n\n /// This means that the wires for the V plane are at a (very) small\n\n /// positive z coordinate.\n", "file_path": "src/captain/MiniCaptExposedBuilder.hh", "rank": 17, "score": 139849.32173846144 }, { "content": "class EDepSim::UniformField : public G4ElectricField\n\n{\n\n public:\n\n\n\n UniformField();\n\n\n\n /// Define a uniform magnetic field. The electric field will be set to\n\n /// zero. This is equivalent to G4UniformMagneticField().\n\n UniformField(const G4ThreeVector bField);\n\n\n\n /// Define a uniform magnetic and electric field.\n\n UniformField(const G4ThreeVector bField, const G4ThreeVector eField);\n\n\n\n virtual ~UniformField() ;\n\n\n\n // Copy constructor and assignment operator\n\n UniformField(const UniformField &p);\n\n UniformField& operator = (const UniformField &p);\n\n\n\n /// Provide the field value at a point [x,y,z,t]. The field follows the\n", "file_path": "src/EDepSimUniformField.hh", "rank": 18, "score": 139844.83617485652 }, { "content": "class EDepSim::PersistencyMessenger: public G4UImessenger {\n\npublic:\n\n PersistencyMessenger(EDepSim::PersistencyManager* persistencyMgr);\n\n virtual ~PersistencyMessenger();\n\n\n\n void SetNewValue(G4UIcommand* command,G4String newValues);\n\n G4String GetCurrentValue(G4UIcommand* command);\n\n\n\nprivate:\n\n EDepSim::PersistencyManager* fPersistencyManager;\n\n\n\n G4UIdirectory* fPersistencyDIR;\n\n G4UIdirectory* fPersistencySetDIR;\n\n G4UIcmdWithAString* fOpenCMD;\n\n G4UIcmdWithoutParameter* fCloseCMD;\n\n G4UIcmdWithADoubleAndUnit* fGammaThresholdCMD;\n\n G4UIcmdWithADoubleAndUnit* fNeutronThresholdCMD;\n\n G4UIcmdWithADoubleAndUnit* fLengthThresholdCMD;\n\n G4UIcmdWithABool* fSaveAllPrimaryTrajectoriesCMD;\n\n G4UIcmdWithADoubleAndUnit* fTrajectoryPointAccuracyCMD;\n\n G4UIcmdWithADoubleAndUnit* fTrajectoryPointDepositCMD;\n\n G4UIcmdWithAString* fTrajectoryBoundaryCMD;\n\n G4UIcmdWithoutParameter* fClearBoundariesCMD;\n\n\n\n};\n\n#endif\n", "file_path": "src/EDepSimPersistencyMessenger.hh", "rank": 19, "score": 139844.83617485652 }, { "content": "class EDepSim::DetectorMessenger: public G4UImessenger {\n\npublic:\n\n DetectorMessenger(EDepSim::UserDetectorConstruction*);\n\n virtual ~DetectorMessenger();\n\n\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\nprivate:\n\n EDepSim::UserDetectorConstruction* fConstruction;\n\n\n\n G4UIdirectory* fEDepSimDir;\n\n\n\n G4UIcmdWithoutParameter* fUpdateCmd;\n\n G4UIcmdWithAString* fPrintMassCmd;\n\n G4UIcmdWithoutParameter* fValidateCmd;\n\n G4UIcmdWithAString* fExportCmd;\n\n G4UIcommand* fControlCmd;\n\n G4UIcommand* fHitSagittaCmd;\n\n G4UIcommand* fHitLengthCmd;\n\n G4UIcommand* fHitExcludedCmd;\n", "file_path": "src/EDepSimDetectorMessenger.hh", "rank": 20, "score": 139844.83617485652 }, { "content": "class EDepSim::HitSegment : public G4VHit {\n\npublic:\n\n /// Create a new hit segment with a maximum allowed sagitta and length.\n\n /// The default values are set so that normally, a scintillator element\n\n /// will only have a single hit for a through going track (& delta-rays).\n\n HitSegment(double maxSagitta = 1*CLHEP::mm,\n\n double maxLength = 5*CLHEP::mm);\n\n \n\n HitSegment(const EDepSim::HitSegment& rhs);\n\n virtual ~HitSegment();\n\n\n\n typedef G4THitsCollection<EDepSim::HitSegment> HitSegmentCollection;\n\n \n\n inline void* operator new(size_t);\n\n inline void operator delete(void*);\n\n \n\n /// Add the effects of a part of a step to this hit.\n\n virtual void AddStep(G4Step* theStep);\n\n\n\n /// Hits for the same primary particle, in the same physical volume belong\n", "file_path": "src/EDepSimHitSegment.hh", "rank": 21, "score": 139844.83617485652 }, { "content": "class EDepSim::TrajectoryPoint : public G4TrajectoryPoint {\n\npublic:\n\n TrajectoryPoint();\n\n TrajectoryPoint(const G4Track* aTrack);\n\n TrajectoryPoint(const G4Step* aStep);\n\n TrajectoryPoint(const EDepSim::TrajectoryPoint &right);\n\n virtual ~TrajectoryPoint();\n\n\n\n inline void *operator new(size_t);\n\n inline void operator delete(void *aTrajectoryPoint);\n\n inline int operator==(const EDepSim::TrajectoryPoint& right) const\n\n { return (this==&right); };\n\n\n\n /// Get the time that the particle passed this trajectory point.\n\n G4double GetTime() const { return fTime; }\n\n\n\n /// Get the 3-momentum of the particle at this trajectory point.\n\n const G4ThreeVector GetMomentum() const { return fMomentum; }\n\n\n\n /// Get the G4 stepping status of the interaction that instigated this\n", "file_path": "src/EDepSimTrajectoryPoint.hh", "rank": 22, "score": 139844.83617485652 }, { "content": "class EDepSim::RootPersistencyManager : public EDepSim::PersistencyManager {\n\npublic:\n\n /// Creates a root persistency manager. Through the \"magic\" of\n\n /// G4VPersistencyManager the ultimate base class, this declared to the G4\n\n /// persistency management system. You can only have one active\n\n /// persistency class at any give moment.\n\n RootPersistencyManager();\n\n virtual ~RootPersistencyManager();\n\n\n\n /// Return true if the ROOT output file is active. This means that the\n\n /// output file is open and ready to accept data.\n\n bool IsOpen();\n\n\n\n /// Return a pointer to the current TFile.\n\n TFile* GetTFile() const {return fOutput;}\n\n\n\n /// Stores an event to the output file.\n\n virtual G4bool Store(const G4Event* anEvent);\n\n virtual G4bool Store(const G4Run* aRun);\n\n virtual G4bool Store(const G4VPhysicalVolume* aWorld);\n", "file_path": "src/EDepSimRootPersistencyManager.hh", "rank": 23, "score": 138689.11798035982 }, { "content": "class EDepSim::SegmentSD : public G4VSensitiveDetector\n\n{\n\n \n\npublic:\n\n SegmentSD(G4String name);\n\n virtual ~SegmentSD();\n\n \n\n void Initialize(G4HCofThisEvent*);\n\n G4bool ProcessHits(G4Step*, G4TouchableHistory*);\n\n void EndOfEvent(G4HCofThisEvent*);\n\n\n\n /// Set the maximum sagitta for the EDepSim::HitSegment objects created by\n\n /// this sensitive detector.\n\n void SetMaximumHitSagitta(double sagitta) {\n\n EDepSimLog(\"Set max segment sagitta to \" << sagitta\n\n << \" for \" << GetName());\n\n fMaximumHitSagitta = sagitta;\n\n }\n\n double GetMaximumHitSagitta(void) {return fMaximumHitSagitta;}\n\n\n", "file_path": "src/EDepSimSegmentSD.hh", "rank": 24, "score": 138425.61147041954 }, { "content": "class EDepSim::PersistencyManager : public G4VPersistencyManager {\n\npublic:\n\n /// Creates a root persistency manager. Through the \"magic\" of\n\n /// G4VPersistencyManager the ultimate base class, this declared to the G4\n\n /// persistency management system. You can only have one active\n\n /// persistency class at any give moment.\n\n PersistencyManager();\n\n virtual ~PersistencyManager();\n\n\n\n /// stores anEvent and the associated objects into database.\n\n virtual G4bool Store(const G4Event* anEvent);\n\n virtual G4bool Store(const G4Run* aRun);\n\n virtual G4bool Store(const G4VPhysicalVolume* aWorld);\n\n\n\n /// Retrieve information from a file. These are not implemented.\n\n virtual G4bool Retrieve(G4Event *&e) {e=NULL; return false;}\n\n virtual G4bool Retrieve(G4Run* &r) {r=NULL; return false;}\n\n virtual G4bool Retrieve(G4VPhysicalVolume* &w) {w=NULL; return false;}\n\n\n\n /// A public accessor to the summarized event. The primaries are\n", "file_path": "src/EDepSimPersistencyManager.hh", "rank": 25, "score": 138425.61147041954 }, { "content": "class EDepSim::ExtraPhysics: public G4VPhysicsConstructor {\n\npublic:\n\n\n\n /// Construct the extra physics lists. The argument is the default\n\n /// recombination for argon. If the value is negative, then use NEST.\n\n explicit ExtraPhysics();\n\n virtual ~ExtraPhysics();\n\n\n\n virtual void ConstructParticle();\n\n virtual void ConstructProcess();\n\n\n\n /// Set the ionization model to be use. The ionization model calculates\n\n /// the amount of total deposited energy that will be visible as\n\n /// ionization. Because of how G4 works, the total energy deposited and\n\n /// the non-ionization energy are tabulated. The implemented models are:\n\n /// 0) Use NEST to make a detailed calculation. 1) Use\n\n /// EDepSim::SimpleScintillation to make a quick calculation.\n\n void SetIonizationModel(int m) {fIonizationModel=m;}\n\n \n\nprivate:\n\n\n\n int fIonizationModel;\n\n};\n\n#endif\n", "file_path": "src/EDepSimExtraPhysics.hh", "rank": 26, "score": 138425.61147041954 }, { "content": "class EDepSim::PrimaryGenerator: public G4VPrimaryGenerator {\n\npublic:\n\n PrimaryGenerator(EDepSim::VKinematicsGenerator* kine,\n\n EDepSim::VCountGenerator* count,\n\n EDepSim::VPositionGenerator* position,\n\n EDepSim::VTimeGenerator* time);\n\n virtual ~PrimaryGenerator();\n\n\n\n /// A pure virtual method to generate the actual primary particles which\n\n /// must be implemented in each derived class.\n\n virtual void GeneratePrimaryVertex(G4Event* evt);\n\n \n\n /// Return the name of this generator.\n\n G4String GetName();\n\n \n\n /// Return the kinematics generator;\n\n const EDepSim::VKinematicsGenerator* GetKinematicsGenerator() const {\n\n return fKinematics;\n\n }\n\n\n", "file_path": "src/kinem/EDepSimPrimaryGenerator.hh", "rank": 27, "score": 137062.98201388013 }, { "content": "class EDepSim::ArbMagField : public G4MagneticField\n\n{\n\n public:\n\n ArbMagField();\n\n\n\n bool ReadFile(const std::string& fname);\n\n void PrintInfo() const;\n\n virtual void GetFieldValue(const G4double pos[4], G4double* field) const;\n\n\n\n private:\n\n std::string m_filename;\n\n std::array<double, 3> m_offset;\n\n std::array<double, 3> m_delta;\n\n std::vector<std::vector<std::vector<double>>> m_field_x;\n\n std::vector<std::vector<std::vector<double>>> m_field_y;\n\n std::vector<std::vector<std::vector<double>>> m_field_z;\n\n};\n\n\n\n#endif\n", "file_path": "src/EDepSimArbMagField.hh", "rank": 28, "score": 137062.98201388013 }, { "content": "class EDepSim::ArbElecField : public G4ElectricField\n\n{\n\n public:\n\n ArbElecField();\n\n\n\n bool ReadFile(const std::string& fname);\n\n void PrintInfo() const;\n\n virtual void GetFieldValue(const G4double pos[4], G4double* field) const;\n\n\n\n private:\n\n std::string m_filename;\n\n std::array<double, 3> m_offset;\n\n std::array<double, 3> m_delta;\n\n std::vector<std::vector<std::vector<double>>> m_field_x;\n\n std::vector<std::vector<std::vector<double>>> m_field_y;\n\n std::vector<std::vector<std::vector<double>>> m_field_z;\n\n};\n\n\n\n#endif\n", "file_path": "src/EDepSimArbElecField.hh", "rank": 29, "score": 137062.98201388013 }, { "content": "class EDepSim::PhysicsList: public G4VModularPhysicsList {\n\npublic:\n\n\n\n /// Construct the physics list. If physName is a valid list, then it will\n\n /// be used. Otherwise, the physics list will be read first from the\n\n /// macro file, and then from the PHYSLIST environment variable. If all\n\n /// of thoses methods fail, then a G4 provided default will be used.\n\n explicit PhysicsList(G4String physName);\n\n\n\n virtual ~PhysicsList();\n\n\n\n /// Set the physics list name to be used (this is used by the physics list\n\n /// messenger.\n\n void SetPhysicsListName(G4String pName);\n\n\n\n /// Used by GEANT4 to set the cuts defined below.\n\n virtual void SetCuts();\n\n\n\n /// Set the range cut for photons.\n\n void SetCutForGamma(G4double);\n", "file_path": "src/EDepSimPhysicsList.hh", "rank": 30, "score": 137062.98201388013 }, { "content": "class EDepSim::CombinationGenerator: public G4VPrimaryGenerator {\n\npublic:\n\n CombinationGenerator(int src, int dest, bool relative);\n\n virtual ~CombinationGenerator();\n\n\n\n /// A pure virtual method to generate the actual primary particles which\n\n /// must be implemented in each derived class.\n\n virtual void GeneratePrimaryVertex(G4Event* evt);\n\n \n\n /// Return the name of this generator.\n\n G4String GetName();\n\n\n\nprivate:\n\n /// The index of the source vertex to copy from.\n\n int fSource;\n\n\n\n /// The index of the destination vertex to copy to.\n\n int fDestination;\n\n\n\n /// A flag to indicate if the new vertex position is a direct copy of the\n\n /// source, or simply relative to the source.\n\n bool fRelative;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimCombinationGenerator.hh", "rank": 31, "score": 137062.98201388013 }, { "content": "class EDepSim::VTimeFactory : public EDepSim::VPrimaryFactory {\n\npublic:\n\n VTimeFactory(G4String name, \n\n EDepSim::UserPrimaryGeneratorMessenger* fParent,\n\n bool makeDirectory=true);\n\n virtual ~VTimeFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VTimeGenerator* GetGenerator() = 0;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimVTimeFactory.hh", "rank": 32, "score": 136310.34243574188 }, { "content": "class EDepSim::VCountFactory : public EDepSim::VPrimaryFactory {\n\npublic:\n\n VCountFactory(G4String name, \n\n EDepSim::UserPrimaryGeneratorMessenger* fParent,\n\n bool makeDirectory=true);\n\n virtual ~VCountFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VCountGenerator* GetGenerator() = 0;\n\n\n\n /// Set the intensity\n\n void SetIntensity(double v) {fIntensity = v;}\n\n \n\n /// Get the intensity. For a beam spill MC, this will represent the\n\n /// protons per pulse.\n\n double GetIntensity() const { return fIntensity;}\n\n\n\n /// Handle messages from the UI processor.\n", "file_path": "src/kinem/EDepSimVCountFactory.hh", "rank": 33, "score": 136310.34243574188 }, { "content": "class EDepSim::GPSKinematicsFactory : public EDepSim::VKinematicsFactory {\n\npublic:\n\n GPSKinematicsFactory(EDepSim::UserPrimaryGeneratorMessenger* fParent);\n\n virtual ~GPSKinematicsFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VKinematicsGenerator* GetGenerator();\n\n\n\nprivate:\n\n /// The GPS G4VPrimaryGenerator that will be used for this kinematics\n\n /// generator. This must be created when the factory is constructed so\n\n /// that the GPS can add it's commands to the UI. There can be only one.\n\n G4VPrimaryGenerator* fGenerator;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimGPSKinematicsFactory.hh", "rank": 34, "score": 136310.34243574188 }, { "content": "class EDepSim::FreePositionGenerator : public EDepSim::VPositionGenerator {\n\npublic:\n\n FreePositionGenerator(const G4String& name);\n\n virtual ~FreePositionGenerator();\n\n\n\n /// Return a candidate vertex (a dummy routine for\n\n /// EDepSim::FreePositionGenerator).\n\n virtual G4LorentzVector GetPosition();\n\n\n\n /// Flag if the vertex should be forced to the candidate vertex returned\n\n /// by GetPosition().\n\n virtual bool ForcePosition();\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimFreePositionGenerator.hh", "rank": 35, "score": 136310.34243574188 }, { "content": "class EDepSim::FixedCountGenerator : public EDepSim::VCountGenerator {\n\npublic:\n\n FixedCountGenerator(G4String name, int count, double intensity);\n\n virtual ~FixedCountGenerator();\n\n\n\n /// Return the number of events to generate.\n\n int GetCount();\n\n\n\nprivate:\n\n /// The number of events to generate.\n\n int fCount;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimFixedCountGenerator.hh", "rank": 36, "score": 136310.34243574188 }, { "content": "class EDepSim::FixedCountFactory : public EDepSim::VCountFactory {\n\npublic:\n\n FixedCountFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~FixedCountFactory();\n\n\n\n /// Return the fixed count generator.\n\n EDepSim::VCountGenerator* GetGenerator();\n\n\n\n /// Set the count to be generated.\n\n void SetNumber(int count) {fNumber = count;}\n\n\n\n /// Get the count to be generated.\n\n int GetNumber() const {return fNumber;}\n\n\n\n /// Handle messages from the UI processor.\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\nprivate:\n\n /// The count of particles to generate.\n\n int fNumber;\n\n\n\n G4UIcmdWithAnInteger* fNumberCMD;\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimFixedCountFactory.hh", "rank": 37, "score": 136310.34243574188 }, { "content": "class EDepSim::MeanCountFactory : public EDepSim::VCountFactory {\n\npublic:\n\n MeanCountFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~MeanCountFactory();\n\n\n\n /// Return the mean count generator.\n\n EDepSim::VCountGenerator* GetGenerator();\n\n\n\n /// Set the count to be generated.\n\n void SetNumber(double mean) {fNumber = mean;}\n\n\n\n /// Get the count to be generated.\n\n double GetNumber() const {return fNumber;}\n\n\n\n /// Handle messages from the UI processor.\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\nprivate:\n\n /// The count of particles to generate.\n\n double fNumber;\n\n\n\n G4UIcmdWithADouble* fNumberCMD;\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimMeanCountFactory.hh", "rank": 38, "score": 136310.34243574188 }, { "content": "class EDepSim::VKinematicsFactory : public EDepSim::VPrimaryFactory {\n\npublic:\n\n VKinematicsFactory(G4String name,\n\n EDepSim::UserPrimaryGeneratorMessenger* fParent,\n\n bool makeDirectory=true);\n\n virtual ~VKinematicsFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VKinematicsGenerator* GetGenerator() = 0;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimVKinematicsFactory.hh", "rank": 39, "score": 136310.34243574188 }, { "content": "class EDepSim::MeanCountGenerator : public EDepSim::VCountGenerator {\n\npublic:\n\n MeanCountGenerator(G4String name, double mean, double intensity);\n\n virtual ~MeanCountGenerator();\n\n\n\n /// Return the number of events to generate.\n\n int GetCount();\n\n\n\nprivate:\n\n /// The number of events to generate.\n\n double fMean;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimMeanCountGenerator.hh", "rank": 40, "score": 136310.34243574188 }, { "content": "class EDepSim::FixedPositionGenerator : public EDepSim::VPositionGenerator {\n\npublic:\n\n FixedPositionGenerator(const G4String& name, \n\n const G4ThreeVector& pos);\n\n virtual ~FixedPositionGenerator();\n\n\n\n /// Return a candidate vertex.\n\n virtual G4LorentzVector GetPosition();\n\n\n\n /// Set the position for the vertex.\n\n virtual void SetPosition(const G4ThreeVector& pos);\n\n\n\n /// Flag if the vertex should be forced to the candidate vertex returned\n\n /// by GetPosition().\n\n virtual bool ForcePosition();\n\n\n\nprivate:\n\n /// The position for this generator.\n\n G4LorentzVector fPosition;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimFixedPositionGenerator.hh", "rank": 41, "score": 136310.34243574188 }, { "content": "class EDepSim::SpillTimeGenerator : public EDepSim::VTimeGenerator {\n\npublic:\n\n /// Create the generatory. The name is for documentation, the spillTime\n\n /// gives the start time of the first bunch at the center of the EDepSim::\n\n /// hall, the bunchSeparation is the time between bunch starts, and the\n\n /// bunchLength is the time length of a bunch with respect to it's start\n\n /// time.\n\n SpillTimeGenerator(G4String name, \n\n double spillTime,\n\n double bunchSeparation,\n\n double bunchLength,\n\n const std::vector<double>& bunchPower);\n\n virtual ~SpillTimeGenerator();\n\n\n\n /// Return the time of the event to be generated.\n\n double GetTime(const G4LorentzVector& vertex);\n\n\n\n /// Flag if the time should be forced. This tells the calling routine\n\n /// that the time returned by this generator should override any times\n\n /// found in the original vertex. This returns true, so that the\n", "file_path": "src/kinem/EDepSimSpillTimeGenerator.hh", "rank": 42, "score": 136310.34243574188 }, { "content": "class EDepSim::VPositionFactory : public EDepSim::VPrimaryFactory {\n\npublic:\n\n VPositionFactory(G4String name, \n\n EDepSim::UserPrimaryGeneratorMessenger* fParent,\n\n bool makeDirectory = true);\n\n virtual ~VPositionFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VPositionGenerator* GetGenerator() = 0;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimVPositionFactory.hh", "rank": 43, "score": 136310.34243574188 }, { "content": "/// Create a generator that leaves the time of the vertex free. The vertex\n\n/// time will either be zero, or will be set by the Kinematics generator.\n\nclass EDepSim::FreeTimeFactory : public EDepSim::VTimeFactory {\n\npublic:\n\n FreeTimeFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~FreeTimeFactory();\n\n\n\n /// Return the time generator.\n\n EDepSim::VTimeGenerator* GetGenerator();\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimFreeTimeFactory.hh", "rank": 44, "score": 136310.34243574188 }, { "content": "class EDepSim::FixedPositionFactory : public EDepSim::VPositionFactory {\n\npublic:\n\n FixedPositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~FixedPositionFactory();\n\n\n\n /// Return the fixed vertex generator.\n\n EDepSim::VPositionGenerator* GetGenerator();\n\n\n\n /// Return the position for the next generator.\n\n G4ThreeVector GetPosition() {return fPosition;}\n\n\n\n /// Set the position for the next generator.\n\n void SetPosition(const G4ThreeVector& pos) {fPosition = pos;}\n\n\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\nprivate:\n\n G4ThreeVector fPosition;\n\n\n\n G4UIcmdWith3VectorAndUnit* fPositionCMD;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimFixedPositionFactory.hh", "rank": 45, "score": 136310.34243574188 }, { "content": "class EDepSim::FreePositionFactory : public EDepSim::VPositionFactory {\n\npublic:\n\n FreePositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~FreePositionFactory();\n\n\n\n /// Return the fixed vertex generator.\n\n EDepSim::VPositionGenerator* GetGenerator();\n\n\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimFreePositionFactory.hh", "rank": 46, "score": 136310.34243574188 }, { "content": "class EDepSim::GPSKinematicsGenerator : public EDepSim::VKinematicsGenerator {\n\npublic:\n\n GPSKinematicsGenerator(const G4String& name,\n\n G4VPrimaryGenerator* gps);\n\n virtual ~GPSKinematicsGenerator();\n\n\n\n /// Add a primary vertex to the event.\n\n virtual GeneratorStatus\n\n GeneratePrimaryVertex(G4Event* evt,\n\n const G4LorentzVector& position);\n\n\n\nprivate:\n\n G4VPrimaryGenerator* fGenerator;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimGPSKinematicsGenerator.hh", "rank": 47, "score": 136310.34243574188 }, { "content": "class EDepSim::FixedTimeGenerator : public EDepSim::VTimeGenerator {\n\npublic:\n\n FixedTimeGenerator(G4String name, double time);\n\n virtual ~FixedTimeGenerator();\n\n\n\n /// Return the number of events to generate.\n\n double GetTime(const G4LorentzVector& vertex);\n\n\n\n /// Flag if the time should be forced.\n\n virtual bool ForceTime();\n\n\n\nprivate:\n\n /// The number of events to generate.\n\n double fTime;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimFixedTimeGenerator.hh", "rank": 48, "score": 136310.34243574188 }, { "content": "/// Generate a \"Free\" time. This means that the default time of the vertex\n\n/// will be zero, but it is expected to be overridden by the kinematics\n\n/// generator.\n\nclass EDepSim::FreeTimeGenerator : public EDepSim::VTimeGenerator {\n\npublic:\n\n FreeTimeGenerator(G4String name);\n\n virtual ~FreeTimeGenerator();\n\n\n\n /// Return the time of events to generate.\n\n double GetTime(const G4LorentzVector& vertex);\n\n\n\n /// Flag if the time should be forced (returns false).\n\n virtual bool ForceTime();\n\n\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimFreeTimeGenerator.hh", "rank": 49, "score": 136310.34243574188 }, { "content": "class EDepSim::FixedTimeFactory : public EDepSim::VTimeFactory {\n\npublic:\n\n FixedTimeFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~FixedTimeFactory();\n\n\n\n /// Return the fixed time generator.\n\n EDepSim::VTimeGenerator* GetGenerator();\n\n\n\n /// Set the time to be generated.\n\n void SetTime(double time) {fTime = time;}\n\n\n\n /// Get the time to be generated.\n\n double GetTime() const {return fTime;}\n\n\n\n /// Handle messages from the UI processor.\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\nprivate:\n\n /// The time of particles to generate.\n\n double fTime;\n\n\n\n G4UIcmdWithADoubleAndUnit* fTimeCMD;\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimFixedTimeFactory.hh", "rank": 50, "score": 136310.34243574188 }, { "content": "class EDepSim::SpillTimeFactory : public EDepSim::VTimeFactory {\n\npublic:\n\n SpillTimeFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~SpillTimeFactory();\n\n\n\n /// Return the spill time generator. The spill parameters must be set\n\n /// before this is called.\n\n EDepSim::VTimeGenerator* GetGenerator();\n\n\n\n /// Set the spill time. The spill time is the offset of start of the\n\n /// first bunch with respect to zero. This is the time that the bunch\n\n /// will cross the center of the EDepSim:: hall.\n\n void SetSpillTime(double spillTime) {fSpillTime=spillTime;}\n\n \n\n /// Set the number of bunchs (and reset the bunch power) in a spill.\n\n void SetBunchCount(int bunchs);\n\n \n\n /// Set the bunch separation. This is the time between the start of\n\n /// successive bunches.\n\n void SetBunchSeparation(double sep) {fBunchSeparation=sep;}\n", "file_path": "src/kinem/EDepSimSpillTimeFactory.hh", "rank": 51, "score": 136310.34243574188 }, { "content": "class EDepSim::HEPEVTKinematicsFactory : public EDepSim::VKinematicsFactory {\n\npublic:\n\n HEPEVTKinematicsFactory(EDepSim::UserPrimaryGeneratorMessenger* fParent);\n\n virtual ~HEPEVTKinematicsFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VKinematicsGenerator* GetGenerator();\n\n\n\n /// Set the input file to read.\n\n virtual void SetInputFile(const G4String& name) {fInputFile=name;}\n\n\n\n /// Get the input file to read.\n\n virtual const G4String& GetInputFile() const {return fInputFile;}\n\n\n\n /// Set the amount of output from G4HEPEvtInterface.\n\n virtual void SetVerbose(int v) {fVerbosity = v;}\n\n\n\n /// Get the expected level of output from G4HEPEvtInterface.\n", "file_path": "src/kinem/EDepSimHEPEVTKinematicsFactory.hh", "rank": 52, "score": 136310.34243574188 }, { "content": "class EDepSim::UserEventAction : public G4UserEventAction {\n\npublic:\n\n UserEventAction();\n\n virtual ~UserEventAction();\n\n \n\n void BeginOfEventAction(const G4Event*);\n\n void EndOfEventAction(const G4Event*);\n\n \n\n};\n\n\n\n#endif\n\n\n\n \n", "file_path": "src/EDepSimUserEventAction.hh", "rank": 53, "score": 135753.62866256764 }, { "content": "class EDepSim::UserRunAction : public G4UserRunAction {\n\npublic:\n\n UserRunAction();\n\n virtual ~UserRunAction();\n\n \n\npublic:\n\n void BeginOfRunAction(const G4Run*);\n\n void EndOfRunAction(const G4Run*);\n\n const G4Timer* GetRunTimer(void) const {return fTimer;};\n\n\n\n /// Set the seed to a new value. This takes a long since the low-level\n\n /// random generate expects a long seed.\n\n void SetSeed(long);\n\n\n\n /// Get the seed that started the low level random generator.\n\n long GetSeed(void) const;\n\n\n\n /// Build a seed for the generator based on the system time.\n\n void SetTimeSeed();\n\n\n", "file_path": "src/EDepSimUserRunAction.hh", "rank": 54, "score": 135753.62866256764 }, { "content": "class EDepSim::VertexInfo : public G4VUserPrimaryVertexInformation {\n\npublic:\n\n explicit VertexInfo();\n\n virtual ~VertexInfo();\n\n\n\n /// Set the generator name. This is set in EDepSim::PrimaryGenerator after\n\n /// the vertex is generated so it should not be set when the vertex is\n\n /// created in a kinematics generator.\n\n void SetName(const G4String& name) {fName = name;}\n\n\n\n /// Get the generator name. The name has the format of\n\n /// <kine>:<count>@<pos>-<time> where <kine> is the kinematics generator,\n\n /// <count> is the count generator, <pos> is the position generator, and\n\n /// <time> is the time generator.\n\n G4String GetName() const {return fName;}\n\n\n\n /// Set reaction that created this vertex. This is defined by each\n\n /// kinematics generator.\n\n /// \\todo We need to define a standard format for the reaction names.\n\n void SetReaction(const G4String& r) {fReaction = r;}\n", "file_path": "src/EDepSimVertexInfo.hh", "rank": 55, "score": 135753.62866256764 }, { "content": "class EDepSim::UserTrackingAction : public G4UserTrackingAction\n\n{\n\n public:\n\n UserTrackingAction();\n\n virtual ~UserTrackingAction();\n\n\n\n virtual void PreUserTrackingAction(const G4Track*);\n\n};\n\n#endif\n", "file_path": "src/EDepSimUserTrackingAction.hh", "rank": 56, "score": 135753.62866256764 }, { "content": "class EDepSim::ArbEMField : public G4ElectroMagneticField\n\n{\n\n public:\n\n ArbEMField();\n\n ArbEMField(G4Field* efield_in, G4Field* bfield_in);\n\n\n\n ArbEMField(const ArbEMField& cpy);\n\n ArbEMField& operator=(const ArbEMField& rhs);\n\n\n\n virtual ~ArbEMField();\n\n\n\n virtual void GetFieldValue(const G4double pos[4], G4double *field) const;\n\n virtual G4bool DoesFieldChangeEnergy() const { return true; };\n\n\n\n void SetEField(G4Field* efield_in) { efield = efield_in; };\n\n void SetBField(G4Field* bfield_in) { bfield = bfield_in; };\n\n\n\n private:\n\n G4Field* efield;\n\n G4Field* bfield;\n\n};\n\n\n\n#endif\n", "file_path": "src/EDepSimArbEMField.hh", "rank": 57, "score": 135753.62866256764 }, { "content": "class EDepSim::UserStackingAction : public G4UserStackingAction {\n\npublic:\n\n UserStackingAction();\n\n virtual ~UserStackingAction();\n\n\n\n /// Check if a new track should be tracked.\n\n virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track*);\n\n};\n\n#endif\n", "file_path": "src/EDepSimUserStackingAction.hh", "rank": 58, "score": 135753.62866256764 }, { "content": "class EDepSim::VPrimaryFactory : public G4UImessenger {\n\npublic:\n\n VPrimaryFactory(G4String subdir, G4String name,\n\n EDepSim::UserPrimaryGeneratorMessenger* parent,\n\n bool makeDirectory);\n\n virtual ~VPrimaryFactory();\n\n\n\n /// Return the full path for the factory. This returns the full name of\n\n /// the EDepSim::VPrimaryFactory. It should be used as a prefix for any\n\n /// messenger commands. The full path for the factory is constructed as\n\n /// \"<parent>/<subdir>/<localname>/\".\n\n G4String GetPath() const;\n\n\n\n /// Return the short name of this factory. This is used to identify it in\n\n /// other messenger commands. The full path for the factory is\n\n /// constructed as \"<parent>/<subdir>/<name>/\".\n\n G4String GetName() const;\n\n\n\n /// Return the subdirectory name for this factory. The full path for the\n\n /// factory is constructed as \"<parent>/<subdir>/<name>/\".\n", "file_path": "src/kinem/EDepSimVPrimaryFactory.hh", "rank": 59, "score": 135753.62866256764 }, { "content": "class EDepSim::DensityPositionGenerator : public EDepSim::VConstrainedPositionGenerator {\n\npublic:\n\n DensityPositionGenerator(const G4String& name);\n\n virtual ~DensityPositionGenerator();\n\n\n\n /// Return a candidate vertex.\n\n virtual G4LorentzVector GetPosition();\n\n\n\n /// Flag if the vertex should be forced to the candidate vertex returned\n\n /// by GetPosition().\n\n virtual bool ForcePosition();\n\n\n\nprivate:\n\n /// The maximum density in the detector.\n\n double fMaximumDensity;\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimDensityPositionGenerator.hh", "rank": 60, "score": 135185.64980924438 }, { "content": "class EDepSim::UniformPositionFactory : public EDepSim::VConstrainedPositionFactory {\n\npublic:\n\n UniformPositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~UniformPositionFactory();\n\n\n\n /// Return the uniform vertex generator. This must call\n\n /// EDepSim::VConstrainedPositionFactory::GetGenerator().\n\n EDepSim::VPositionGenerator* GetGenerator();\n\n\n\n /// Create a new uniform vertex generator. The newly created vertex\n\n /// generator will be initialized by the factory.\n\n EDepSim::VPositionGenerator* CreateGenerator();\n\n\n\n /// Handle messages from the UI processor.\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimUniformPositionFactory.hh", "rank": 61, "score": 135185.64980924438 }, { "content": "class EDepSim::DensityPositionFactory : public EDepSim::VConstrainedPositionFactory {\n\npublic:\n\n DensityPositionFactory(EDepSim::UserPrimaryGeneratorMessenger* parent);\n\n virtual ~DensityPositionFactory();\n\n\n\n /// Return the density vertex generator. This must call\n\n /// EDepSim::VConstrainedPositionFactory::GetGenerator().\n\n EDepSim::VPositionGenerator* GetGenerator();\n\n\n\n /// Create a new density vertex generator. The newly created vertex\n\n /// generator will be initialized by the factory.\n\n EDepSim::VPositionGenerator* CreateGenerator();\n\n\n\n /// Handle messages from the UI processor.\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\n};\n\n\n\n#endif\n", "file_path": "src/kinem/EDepSimDensityPositionFactory.hh", "rank": 62, "score": 135185.64980924438 }, { "content": "class EDepSim::UniformPositionGenerator : public EDepSim::VConstrainedPositionGenerator {\n\npublic:\n\n UniformPositionGenerator(const G4String& name);\n\n virtual ~UniformPositionGenerator();\n\n\n\n /// Return a candidate vertex.\n\n virtual G4LorentzVector GetPosition();\n\n\n\n /// Flag if the vertex should be forced to the candidate vertex returned\n\n /// by GetPosition().\n\n virtual bool ForcePosition();\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimUniformPositionGenerator.hh", "rank": 63, "score": 135185.64980924438 }, { "content": "/// Construct the EDepSim detector geometry. This handles two methods of\n\n/// construction. In the first, the geometry is read from a GDML file which\n\n/// is expected to contain the SensDet, EField and BField auxiliary types for\n\n/// logical volumes that are sensitive, have an electric field, and have a\n\n/// magnetic field (respectively). The alternative is to define a builder\n\nclass EDepSim::UserDetectorConstruction : public G4VUserDetectorConstruction {\n\npublic:\n\n UserDetectorConstruction();\n\n virtual ~UserDetectorConstruction();\n\n\n\n /// The required method to construct the detector and define the world\n\n /// volume.\n\n virtual G4VPhysicalVolume* Construct();\n\n\n\n /// The method to setup the sensitive detectors and fields. In a multi\n\n /// thread application, this is called per thread.\n\n virtual void ConstructSDandField();\n\n\n\n /// Return the detector construction messenger\n\n virtual EDepSim::DetectorMessenger* GetMessenger(void) {\n\n return fDetectorMessenger;\n\n };\n\n\n\n /// Update the geometry information to match stuff read from the macro\n\n /// file.\n", "file_path": "src/EDepSimUserDetectorConstruction.hh", "rank": 64, "score": 134498.4082450647 }, { "content": "class EDepSim::UserEventInformation : public G4VUserEventInformation {\n\npublic:\n\n UserEventInformation();\n\n virtual ~UserEventInformation();\n\n \n\n /// Print information about the event.\n\n virtual void Print() const;\n\n\n\n /// Reset for a new event. This is needed since some event generators\n\n /// start creating an event, and then later decide to reject it. This\n\n /// allows the user information to be reset to the default values.\n\n void InitializeEvent(void);\n\n\n\nprivate:\n\n};\n\n#endif\n", "file_path": "src/EDepSimUserEventInformation.hh", "rank": 65, "score": 134494.48684104628 }, { "content": "class EDepSim::UserRunActionMessenger: public G4UImessenger {\n\npublic:\n\n UserRunActionMessenger(EDepSim::UserRunAction*);\n\n virtual ~UserRunActionMessenger();\n\n\n\n /// Handle messages from the UI processor.\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\n /// Get the base directory for the messenger commands.\n\n G4String GetPath();\n\n\n\nprivate:\n\n // need primary generator action to change the seed\n\n EDepSim::UserRunAction* fUserRunAction; \n\n \n\n G4UIdirectory* fDir;\n\n G4UIcmdWithAnInteger* fRandomSeedCmd;\n\n G4UIcmdWithoutParameter* fTimeRandomSeedCmd;\n\n G4UIcmdWithoutParameter* fShowRandomSeedCmd;\n\n G4UIcmdWithAnInteger* fDetSimRunIdCmd;\n\n G4UIcmdWithAnInteger* fDetSimSubrunIdCmd;\n\n\n\n};\n\n#endif\n", "file_path": "src/EDepSimUserRunActionMessenger.hh", "rank": 66, "score": 134494.48684104628 }, { "content": "class EDepSim::UserPrimaryGeneratorMessenger: public G4UImessenger {\n\npublic:\n\n UserPrimaryGeneratorMessenger(EDepSim::UserPrimaryGeneratorAction*);\n\n virtual ~UserPrimaryGeneratorMessenger();\n\n\n\n /// Handle messages from the UI processor.\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\n /// Get the base directory for the messenger commands.\n\n G4String GetPath();\n\n\n\n /// Add a new kinematics factory to the messenger.\n\n void AddKinematicsFactory(EDepSim::VKinematicsFactory* factory);\n\n\n\n /// Set the current kinematics factory for the messenger.\n\n void SetKinematicsFactory(const G4String& factory);\n\n\n\n /// Get the list of kinematics factories available to the messenger.\n\n G4String GetKinematicsFactories();\n\n\n", "file_path": "src/EDepSimUserPrimaryGeneratorMessenger.hh", "rank": 67, "score": 134494.48684104628 }, { "content": "class G4UIcmdWithADoubleAndUnit;\n\n\n\nnamespace EDepSim {class PersistencyManager;}\n\n\n\nnamespace EDepSim {class PersistencyMessenger;}\n", "file_path": "src/EDepSimPersistencyMessenger.hh", "rank": 68, "score": 134251.85388787618 }, { "content": "class G4UIcmdWithADoubleAndUnit;\n", "file_path": "src/EDepSimDetectorMessenger.hh", "rank": 69, "score": 134251.85388787618 }, { "content": "class EDepSim::RooTrackerKinematicsGenerator : public EDepSim::VKinematicsGenerator {\n\npublic:\n\n /// Construct a new generator. The name is the name of the generator\n\n /// (e.g. NEUT, GENIE, &c). The fileName is the name of the root file\n\n /// containing the tree of kinematic information. The treeName is the\n\n /// path of the rooTracker tree in the input file. The order is a string\n\n /// specifying the order that events in the input files should be used.\n\n /// The current legal values are \"consecutive\", \"stride\", or\n\n /// \"random\". The firstEvent is the first event to use in the file.\n\n ///\n\n /// While NEUT and GENIE produce files with single interactions in each\n\n /// event, the individual events can be built into spill using another\n\n /// program (a so called overlay program). The divisions between the\n\n /// spills can be specified by adding in a fake event that has a single\n\n /// particle with a HepStatus value of -1. The fake event will be\n\n /// dropped from generation, so it should not contain a real particle.\n\n RooTrackerKinematicsGenerator(const G4String& name, \n\n const G4String& fileName,\n\n const G4String& treeName,\n\n const G4String& order,\n", "file_path": "src/kinem/EDepSimRooTrackerKinematicsGenerator.hh", "rank": 70, "score": 134101.01497977405 }, { "content": "class EDepSim::VConstrainedPositionFactory : public EDepSim::VPositionFactory {\n\npublic:\n\n VConstrainedPositionFactory(G4String name, \n\n EDepSim::UserPrimaryGeneratorMessenger* fParent,\n\n bool makeDirectory = true);\n\n virtual ~VConstrainedPositionFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes, but the derived generator must return the value from\n\n /// EDepSim::VConstrainedPositionFactory::GetGenerator().\n\n virtual EDepSim::VPositionGenerator* GetGenerator();\n\n\n\n /// Create a new generator that can be initialized. This is a pure\n\n /// virtual function so it must be implemented in the derived class.\n\n virtual EDepSim::VPositionGenerator* CreateGenerator() = 0;\n\n\n\n void SetNewValue(G4UIcommand*, G4String);\n\n\n\nprivate:\n", "file_path": "src/kinem/EDepSimVConstrainedPositionFactory.hh", "rank": 71, "score": 134101.01497977405 }, { "content": "class EDepSim::RooTrackerKinematicsFactory : public EDepSim::VKinematicsFactory {\n\npublic:\n\n RooTrackerKinematicsFactory(EDepSim::UserPrimaryGeneratorMessenger* fParent);\n\n virtual ~RooTrackerKinematicsFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VKinematicsGenerator* GetGenerator();\n\n\n\n /// Set the input file to read.\n\n virtual void SetInputFile(const G4String& name) {fInputFile=name;}\n\n\n\n /// Get the input file to read.\n\n virtual const G4String& GetInputFile() const {return fInputFile;}\n\n \n\n /// Set the generator name. This is the name of the program that\n\n /// generated the rooTracker tree, and will be saved as documentation in\n\n /// the output file.\n\n virtual void SetGeneratorName(const G4String& name) {fGeneratorName = name;}\n", "file_path": "src/kinem/EDepSimRooTrackerKinematicsFactory.hh", "rank": 72, "score": 134101.01497977405 }, { "content": "class EDepSim::VConstrainedPositionGenerator : public EDepSim::VPositionGenerator {\n\npublic:\n\n VConstrainedPositionGenerator(const G4String& name);\n\n virtual ~VConstrainedPositionGenerator();\n\n\n\n /// Flag if the vertex should be forced to the candidate vertex returned\n\n /// by GetPosition().\n\n virtual bool ForcePosition();\n\n\n", "file_path": "src/kinem/EDepSimVConstrainedPositionGenerator.hh", "rank": 73, "score": 134101.01497977405 }, { "content": "class G4UIcmdWithADoubleAndUnit;\n", "file_path": "src/EDepSimPhysicsListMessenger.hh", "rank": 74, "score": 132559.03871023937 }, { "content": "class EDepSim::NuMIRockKinematicsFactory : public EDepSim::VKinematicsFactory {\n\npublic:\n\n NuMIRockKinematicsFactory(EDepSim::UserPrimaryGeneratorMessenger* fParent);\n\n virtual ~NuMIRockKinematicsFactory();\n\n\n\n /// Return a new generator enclosing the current factory state. The new\n\n /// generator method is pure virtual so it must be implemented by derived\n\n /// classes.\n\n virtual EDepSim::VKinematicsGenerator* GetGenerator();\n\n\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimNuMIRockKinematicsFactory.hh", "rank": 75, "score": 132043.6527671926 }, { "content": "class EDepSim::NuMIRockKinematicsGenerator : public EDepSim::VKinematicsGenerator {\n\npublic:\n\n /// Construct a new generator. The name is the name of the generator\n\n /// (e.g. GENIE, rock, &c). The fluxName is the name of the neutrino\n\n /// spectrum.\n\n NuMIRockKinematicsGenerator(const G4String& name, \n\n const G4String& fluxName);\n\n virtual ~NuMIRockKinematicsGenerator();\n\n\n\n /// Add a primary vertex to the event. \n\n virtual GeneratorStatus GeneratePrimaryVertex(G4Event* evt,\n\n const G4LorentzVector& position);\n\n\n\nprivate:\n\n /// The static part of the file name field.\n\n std::string fFluxName;\n\n\n\n};\n\n#endif\n", "file_path": "src/kinem/EDepSimNuMIRockKinematicsGenerator.hh", "rank": 76, "score": 132043.6527671926 }, { "content": "/// A class to save a G4 trajectory into a root output file without linking to\n\n/// geant. A trajectory is the truth information about the path of a particle\n\n/// through the G4 simulation. It saves the parent trajectory that generated\n\n/// this particle, the initial momentum of the particle, and the path followed\n\n/// by the particle in the detector. \n\nclass TG4Trajectory : public TObject {\n\n friend class EDepSim::PersistencyManager;\n\npublic:\n\n typedef std::vector<TG4TrajectoryPoint> TrajectoryPoints;\n\n \n\n TG4Trajectory(void)\n\n : TrackId(-1), ParentId(-1), \n\n Name(\"none\"), PDGCode(0),\n\n InitialMomentum(0,0,0,0) {}\n\n\n\n virtual ~TG4Trajectory();\n\n\n\n /// The TrackId of this trajectory.\n\n int GetTrackId() const {return TrackId;}\n\n \n\n /// The unique Id of the parent trajectory (The TrackId of the parent).\n\n int GetParentId() const {return ParentId;}\n\n \n\n /// The name of the particle.\n\n const char* GetName() const {return Name.c_str();}\n", "file_path": "io/TG4Trajectory.h", "rank": 77, "score": 130975.55830540063 }, { "content": "class TG4Event : public TObject {\n\npublic:\n\n TG4Event(void) {}\n\n virtual ~TG4Event();\n\n\n\n /// The run number\n\n int RunId;\n\n \n\n /// The event number\n\n int EventId;\n\n\n\n /// A container of primary vertices (a vector). Sometimes, there is only\n\n /// one element, but you need to be careful since some neutrino events\n\n /// don't have any primary particles (e.g. neutral current events where\n\n /// the scattered nucleon is absorbed by the nucleus). It's also likely\n\n /// that an event will have multiple vertices (i.e. more than one\n\n /// interaction per spill). When no primary was provided, then a fake\n\n /// primary vertex will be inserted so that an empty event is generated.\n\n TG4PrimaryVertexContainer Primaries;\n\n\n", "file_path": "io/TG4Event.h", "rank": 78, "score": 130971.42481191613 }, { "content": "/// A class to save a G4 trajectory point into a root output file without\n\n/// linking to geant. The trajectory point is saved in a TG4Trajectory as a\n\n/// way to record the path of a particle through the detector. This is the\n\n/// truth information about the particles which were tracked, but is not a\n\n/// good record of the energy deposition. Use the TG4HitSegment objects for a\n\n/// record of the energy deposition.\n\nclass TG4TrajectoryPoint : public TObject {\n\n friend class EDepSim::PersistencyManager;\n\npublic:\n\n TG4TrajectoryPoint()\n\n : Position(0,0,0,0), Momentum(0,0,0),\n\n Process(0), Subprocess(0) {}\n\n \n\n virtual ~TG4TrajectoryPoint();\n\n\n\n /// Process types copied from the G4 definitions so that this can be\n\n /// compiled without having geant4 installed. Check the exact definitions\n\n /// are in the geant4 documentation, but the (important) names are pretty\n\n /// self explanatory. The definitions can be found in the geant4 include\n\n /// file named G4ProcessType.hh.\n\n enum G4ProcessType {\n\n kProcessNotDefined = 0,\n\n kProcessTransportation = 1,\n\n kProcessElectromagetic = 2 ,\n\n kProcessOptical = 3,\n\n kProcessHadronic = 4,\n", "file_path": "io/TG4Trajectory.h", "rank": 79, "score": 128942.47779934105 }, { "content": "/// A class to save a G4 primary vertex into a root output file without linking\n\n/// to geant.\n\nclass TG4PrimaryVertex : public TObject {\n\n friend class EDepSim::PersistencyManager;\n\npublic:\n\n typedef std::vector<TG4PrimaryParticle> PrimaryParticles;\n\n\n\n TG4PrimaryVertex(void)\n\n : Position(0,0,0,0), GeneratorName(\"none\"),\n\n InteractionNumber(0), CrossSection(0.0), DiffCrossSection(0.0),\n\n Weight(0.0), Probability(0.0) {}\n\n virtual ~TG4PrimaryVertex();\n\n\n\n /// The initial position of the particle.\n\n const TLorentzVector& GetPosition() const {return Position ;}\n\n\n\n /// The name of the generator that created this vertex.\n\n const char* GetGeneratorName() const {return GeneratorName.c_str();}\n\n\n\n /// The reaction that created this vertex.\n\n const char* GetReaction() const {return Reaction.c_str();}\n\n\n", "file_path": "io/TG4PrimaryVertex.h", "rank": 80, "score": 127006.99229888675 }, { "content": "/// A class to save a G4 primary particle into a root output file without\n\n/// linking to geant.\n\nclass TG4PrimaryParticle : public TObject {\n\n friend class EDepSim::PersistencyManager;\n\npublic:\n\n TG4PrimaryParticle(void)\n\n : TrackId(-1), PDGCode(0), Momentum(0,0,0,0) {}\n\n virtual ~TG4PrimaryParticle();\n\n\n\n /// The Track Id of the matching trajectory. Particles that are not\n\n /// tracked will have negative track id values.\n\n int GetTrackId() const {return TrackId;}\n\n\n\n /// The name of the particle.\n\n const char* GetName() const {return Name.c_str();}\n\n \n\n /// The PDG code of the particle.\n\n int GetPDGCode() const {return PDGCode;}\n\n\n\n /// The initial momentum of the particle\n\n const TLorentzVector& GetMomentum() const {return Momentum;}\n\n\n", "file_path": "io/TG4PrimaryVertex.h", "rank": 81, "score": 127006.99229888675 }, { "content": "/// Save the amount and location of energy deposition. It contains the global\n\n/// position of the starting point and stopping point of the track segment\n\n/// that created the hit. The energy should be assumed to be deposited\n\n/// uniformly between the two points (the length of the segment can, and\n\n/// should, be limited in G4, so that shouldn't be a bad assumption). Both\n\n/// the total and secondary energy deposition is saved. The definition of the\n\n/// secondary energy depends on the configuration of the simulation, but\n\n/// generally, it refers to the amount of energy going into scintillation.\n\nclass TG4HitSegment : public TObject {\n\n friend class EDepSim::PersistencyManager;\n\npublic:\n\n typedef std::vector<Int_t> Contributors;\n\n \n\n TG4HitSegment() \n\n : PrimaryId(0), EnergyDeposit(0), SecondaryDeposit(0),\n\n TrackLength(0), Start(0,0,0,0), Stop(0,0,0,0) {}\n\n virtual ~TG4HitSegment();\n\n \n\n /// The track id of the most important particle associated with this hit\n\n /// segment.\n\n int GetPrimaryId() const {return PrimaryId;}\n\n\n\n /// The total energy deposit in this hit. \n\n double GetEnergyDeposit() const {return EnergyDeposit;}\n\n\n\n /// The \"secondary\" energy deposit in this hit. Generally, this is used to\n\n /// help simulate the amount of energy emitted as scintillation light,\n\n /// i.e. opticalphotons, and is part of the total energy deposit. The\n", "file_path": "io/TG4HitSegment.h", "rank": 82, "score": 127002.1932294367 }, { "content": "// this entire file is adapted from G4Scintillation.hh from Geant4.9.4\n\nclass G4S1Light : public G4VRestDiscreteProcess //class definition\n\n{\n\n // Class inherits publicly from G4VRestDiscreteProcess\n\nprivate:\n\npublic: // constructor and destructor\n\n\n\n G4S1Light(const G4String& processName = \"S1\",\n\n\t\t G4ProcessType type = fElectromagnetic);\n\n\t~G4S1Light();\n\n\n\npublic: // methods, with descriptions\n\n G4bool IsApplicable(const G4ParticleDefinition& aParticleType);\n\n // Returns true -> 'is applicable', for any particle type except for an\n\n // 'opticalphoton' and for short-lived particles\n\n\n\n\tG4double GetMeanFreePath(const G4Track& aTrack,\n\n\t\t\t\t G4double ,\n\n G4ForceCondition* );\n\n // Returns infinity; i. e. the process does not limit the step, but\n\n // sets the 'StronglyForced' condition for the DoIt to be invoked at\n", "file_path": "src/NESTVersion098/G4S1Light.hh", "rank": 83, "score": 125945.52752695954 }, { "content": "// this entire file is adapted from G4Scintillation.hh from Geant4.9.4\n\nclass G4S2Light : public G4VRestDiscreteProcess //class definition\n\n{\n\n // Class inherits publicly from G4VRestDiscreteProcess\n\nprivate:\n\n \n\npublic: // constructor and destructor\n\n\n\n G4S2Light(const G4String& processName = \"S2\",\n\n\t G4ProcessType type = fElectromagnetic);\n\n\t~G4S2Light();\n\n\n\npublic: // methods, with descriptions\n\n\n\n G4bool IsApplicable(const G4ParticleDefinition& aParticleType);\n\n // Returns true -> 'is applicable', only for thermalelectrons\n\n \n\n\tG4double GetMeanFreePath(const G4Track& aTrack,\n\n\t\t\t\t G4double ,\n\n G4ForceCondition* );\n\n\n", "file_path": "src/NESTVersion098/G4S2Light.hh", "rank": 84, "score": 125945.52752695954 }, { "content": "class G4ThermalElectron : public G4ParticleDefinition\n\n{\n\n private:\n\n static G4ThermalElectron* theInstance;\n\n G4ThermalElectron(){}\n\n ~G4ThermalElectron(){}\n\n\n\n public:\n\n static G4ThermalElectron* Definition();\n\n static G4ThermalElectron* ThermalElectronDefinition();\n\n static G4ThermalElectron* ThermalElectron();\n\n};\n\n\n\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "file_path": "src/NESTVersion098/G4ThermalElectron.hh", "rank": 85, "score": 120095.73815685487 }, { "content": "class G4UIcmdWithABool;\n", "file_path": "src/EDepSimPersistencyMessenger.hh", "rank": 86, "score": 100690.79496264386 }, { "content": "class G4MagInt_Driver;\n\n\n\nnamespace EDepSim {class EMFieldSetup;}\n\n\n", "file_path": "src/EDepSimEMFieldSetup.hh", "rank": 87, "score": 98928.95800211417 }, { "content": "class G4UIcmdWithABool;\n", "file_path": "src/EDepSimPhysicsListMessenger.hh", "rank": 88, "score": 98919.52425186252 }, { "content": "class G4UIcmdWithABool;\n\n\n\nnamespace EDepSim {class UserPrimaryGeneratorMessenger;}\n", "file_path": "src/EDepSimUserPrimaryGeneratorMessenger.hh", "rank": 89, "score": 97226.70907422571 }, { "content": "class EDepSim::Builder {\n\npublic:\n\n Builder(G4String n, EDepSim::UserDetectorConstruction* c);\n\n Builder(G4String n, EDepSim::Builder* parent);\n\n virtual ~Builder();\n\n\n\n /// Construct and return a G4 volume for the object. This is a pure\n\n /// virtual function, which means it must be implemented by the inheriting\n\n /// classes. This returns an unplaced logical volume which faces along\n\n /// the Z axis.\n\n virtual G4LogicalVolume *GetPiece(void) = 0;\n\n\n\n /// Return the base name of the object that this builds.\n\n G4String GetName(void);\n\n\n\n /// Return the base name of the object that this builds.\n\n G4String GetLocalName(void) {return fLocalName;};\n\n\n\n /// Set the base name of the logical volume that this builds.\n\n void SetLocalName(const G4String& name);\n", "file_path": "src/EDepSimBuilder.hh", "rank": 90, "score": 90285.89154669574 }, { "content": "class EDepSim::Cubic\n\n{\n\n public:\n\n Cubic();\n\n\n\n double interpolate(\n\n const double* point,\n\n const std::vector<std::vector<std::vector<double>>>& g,\n\n const double* delta, const double* offset) const;\n\n double interpolate(\n\n double x, double y, double z,\n\n const std::vector<std::vector<std::vector<double>>>& g,\n\n double hx, double hy, double hz, double xo, double yo, double zo)\n\n const;\n\n\n\n private:\n\n double conv_kernel(double s) const;\n\n};\n\n\n\n#endif\n", "file_path": "src/EDepSimInterpolator.hh", "rank": 91, "score": 90285.89154669574 }, { "content": "class EDepSim::LogManager {\n\npublic:\n\n ~LogManager();\n\n\n\n typedef enum {SilentLevel,\n\n ErrorLevel,\n\n SevereLevel,\n\n WarnLevel,\n\n DebugLevel,\n\n TraceLevel} ErrorPriority;\n\n\n\n typedef enum {QuietLevel,\n\n LogLevel,\n\n InfoLevel,\n\n VerboseLevel} LogPriority;\n\n\n\n /// Cause the logging and error output streams to be initialized.\n\n /// Basic configuration for logging occurs automatically, so this need not\n\n /// be called. If this is called, then it first trys to read the\n\n /// edeplog.config file in the current directory. If Configure is called\n", "file_path": "src/EDepSimLog.hh", "rank": 92, "score": 89370.95822285423 }, { "content": "/// A class to provide a unique identifier for all physical volumes. One of\n\n/// the features of G4 is that physical volumes are identified by their\n\n/// position in the volume tree. This has many advantages, but it means that\n\n/// it can be quite trick to figure out if two physical volume pointers refer\n\n/// to the same physical volume, or different replicas of the same physical\n\n/// volume. (Consider the case where a you have an unreplicated sub-volume of\n\n/// a replicated parent). This class provides a unique comparable object that\n\n/// allows an equality test between volumes taking into account the full\n\n/// position in the hierarchy. It is similar in function to\n\n/// G4TouchableHandle, but provides better comparison operators.\n\nclass EDepSim::VolumeId {\n\npublic:\n\n /// Construct a new volume Id.\n\n VolumeId(const G4TouchableHandle& handle);\n\n /// Construct an empty volume Id.\n\n VolumeId();\n\n ~VolumeId();\n\n\n\n /// Explicitly add a new volume to the volume Id.\n\n void AddVolume(G4VPhysicalVolume* fHandle,int fReplica);\n\n\n\n bool operator !() {\n\n return (fVolumes.size()==0);\n\n };\n\n\n\n EDepSim::VolumeId& operator = (const G4TouchableHandle& handle);\n\n EDepSim::VolumeId& operator = (const EDepSim::VolumeId& id);\n\n\n\n friend bool ::operator ==(const EDepSim::VolumeId& x, \n\n const G4TouchableHandle& y);\n", "file_path": "src/EDepSimVolumeId.hh", "rank": 93, "score": 88501.91444710296 }, { "content": "class EDepSim::TrajectoryMap {\n\npublic:\n\n ~TrajectoryMap() {}\n\n\n\n /// Provide a map between the track id and the trajectory object.\n\n static G4VTrajectory* Get(int trackId);\n\n\n\n /// Add a trajectory to the map.\n\n static void Add(G4VTrajectory* traj);\n\n\n\n /// Clear the trajectory map. This must be done in the\n\n /// EDepSim::UserEventAction::BeginOfEventAction() method.\n\n static void Clear();\n\n\n\n /// Find the primary track ID for the current track. This is the primary\n\n /// that is the ultimate parent of the current track.\n\n static int FindPrimaryId(int trackId);\n\n\n\nprivate:\n\n /// A map to the trajectories information indexed the the track id. Be\n", "file_path": "src/EDepSimTrajectoryMap.hh", "rank": 94, "score": 88497.46820268696 }, { "content": "class EDepSim::SDFactory {\n\npublic:\n\n /// Build a factory to build sensitive detectors specified by \"type\".\n\n SDFactory(G4String type);\n\n virtual ~SDFactory();\n\n\n\n /// Get pointer to a sensitive detector built by this factory, but return\n\n /// null if the detector doesn't exist.\n\n G4VSensitiveDetector* GetSD(G4String name);\n\n\n\n /// Get pointer to a sensitive detector built by this factory, and create\n\n /// a new sensitive detector if required.\n\n G4VSensitiveDetector* MakeSD(G4String name);\n\n \n\nprivate:\n\n /// The type of sensitive detector that this will build.\n\n G4String fType;\n\n\n\n};\n\n#endif\n", "file_path": "src/EDepSimSDFactory.hh", "rank": 95, "score": 88497.46820268696 }, { "content": "class EDepSim::KinemPassThrough {\n\npublic:\n\n /// for relating input tree pointers to the input file.\n\n typedef std::map<const TTree *, int> TreeToInt;\n\n\n\n ~KinemPassThrough();\n\n\n\n /// Returns (or initialises if first time) the instance \n\n /// of the singleton.\n\n static EDepSim::KinemPassThrough * GetInstance();\n\n\n\n /// Add an input tree to the TChain of input trees that rootracker\n\n /// entries will be copied from. A map between the tree pointer that\n\n /// detsim is using and the correct segment of the TChain is also made.\n\n bool AddInputTree(const TTree * inputTreePtr,\n\n const char * inputFileName, \n\n const char* generatorName);\n\n\n\n /// Copy the i'th entry from segment of the TChain corresponding to the\n\n /// input tree pointed at (in detsim) by inputTreePtr.\n", "file_path": "src/kinem/EDepSimKinemPassThrough.hh", "rank": 96, "score": 87662.6679913736 }, { "content": "/// A class for control of the Electric Field of the detector.\n\n///\n\n/// The field for this case is uniform.\n\n/// It is simply a 'setup' class that creates the field and necessary\n\n/// other parts\n\nclass EDepSim::EMFieldSetup\n\n{\n\npublic:\n\n /// Create a new field. The first argument is a general EM field (for\n\n /// example, G4UniformMagneticField, or G4UniformElectricField. The\n\n /// second argument is the field manager to setup.\n\n EMFieldSetup(G4ElectroMagneticField* field, G4FieldManager* m=0);\n\n\n\n /// Create a zero field for the field manager.\n\n EMFieldSetup(G4FieldManager* m=0);\n\n\n\n virtual ~EMFieldSetup();\n\n\n\n void SetStepperType(G4int i) { fStepperType = i ; }\n\n\n\n void SetStepper();\n\n\n\n void SetMinStep(G4double s) { fMinStep = s ; }\n\n\n\nprotected:\n", "file_path": "src/EDepSimEMFieldSetup.hh", "rank": 97, "score": 86869.59297160956 }, { "content": "class EDepSim::PhysicsListMessenger\n\n : public G4UImessenger {\n\npublic:\n\n \n\n PhysicsListMessenger(EDepSim::PhysicsList* );\n\n virtual ~PhysicsListMessenger();\n\n \n\n virtual void SetNewValue(G4UIcommand*, G4String);\n\n\n\nprivate:\n\n\n\n EDepSim::PhysicsList* fPhysicsList;\n\n \n\n G4UIdirectory* fDirectory;\n\n G4UIdirectory* fDecayDirectory;\n\n\n\n G4UIcmdWithADoubleAndUnit* fGammaCutCMD;\n\n G4UIcmdWithADoubleAndUnit* fElectCutCMD;\n\n G4UIcmdWithADoubleAndUnit* fPosCutCMD;\n\n G4UIcmdWithADoubleAndUnit* fAllCutCMD;\n\n G4UIcmdWithABool* fIonizationModelCMD;\n\n\n\n};\n\n#endif\n", "file_path": "src/EDepSimPhysicsListMessenger.hh", "rank": 98, "score": 86864.04273213395 }, { "content": "class EDepSim::RootGeometryManager {\n\n typedef struct {\n\n int color;\n\n int fill;\n\n float alpha;\n\n } DrawAttributes;\n\n typedef std::map<G4String,DrawAttributes> AttributeMap;\n\n\n\npublic:\n\n virtual ~RootGeometryManager();\n\n\n\n /// If a persistency manager has not been created, create one.\n\n static EDepSim::RootGeometryManager* Get(void);\n\n\n\n /// Export the geometry to a file.\n\n void Export(const char *file);\n\n\n\n /// Update the root geometry to match the g4 geometry\n\n void Update(const G4VPhysicalVolume* aWorld, bool validate);\n\n\n", "file_path": "src/EDepSimRootGeometryManager.hh", "rank": 99, "score": 86864.04273213395 } ]
C++
Classes/Bmob/baseobject/bmobobject.cpp
isuhao/RaidenFree
1811a79d6704fb58e2abc58fb3feaad79af33841
#include "bmobobject.h" #include "network/HttpClient.h" #include "network/HttpResponse.h" #include "../util/bmobstrutil.h" using namespace network; BmobObject::BmobObject(){ this->m_pSaveDelegate = NULL; this->m_pUpdateDelegate = NULL; this->m_pSaveDelegate = NULL; } BmobObject::BmobObject(string tableName){ this->m_tableName = tableName; this->m_pSaveDelegate = NULL; this->m_pUpdateDelegate = NULL; this->m_pSaveDelegate = NULL; } BmobObject::~BmobObject(){ } void BmobObject::save(BmobSaveDelegate* delegate){ if (!BmobSDKInit::isInitialize()) { return ; } _opType = HTTP_OP_Type::_bHTTP_SAVE; this->m_pSaveDelegate = delegate; this->m_url = BmobSDKInit::URL + m_tableName; this->send(); } void BmobObject::increment(string column,int value ){ } void BmobObject::setValue(string key,cocos2d::Ref *object){ this->enParamsToHttp(key,object); } void BmobObject::setValue(string key,__Array* array){ if (array == NULL || key.empty()) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "AddUnique"; dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(array,"objects"); this->enParamsToHttp(key,dict); } void BmobObject::update(BmobUpdateDelegate* delegate){ this->update(this->getObjectId(),delegate); } void BmobObject::update(string objectId,BmobUpdateDelegate* delegate){ if (objectId.empty()) { return ; } _opType = HTTP_OP_Type::_bHTTP_UPDATE; this->m_pUpdateDelegate = delegate; this->m_url = BmobSDKInit::URL + m_tableName ; if (!objectId.empty()) { this->m_url += + "/" + objectId; } this->send(HttpRequest::Type::PUT); } void BmobObject::remove(string name){ if (name.empty()) { return ; } this->clear(); __Dictionary* pDict = __Dictionary::create(); __String* pValue2 = __String::create("Delete"); pDict->setObject(pValue2, "__op"); this->enParamsToHttp(name,pDict); } void BmobObject::removeAll(string name,__Array* array){ if (array == NULL) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "Remove"; dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(array,"objects"); this->enParamsToHttp(name,dict); } void BmobObject::del(BmobDeleteDelegate* delegate){ _opType = HTTP_OP_Type::_bHTTP_DELETE; this->m_pDeleteDelegate = delegate; this->m_url = BmobSDKInit::URL + m_tableName + "/" + m_objectId; this->send(HttpRequest::Type::DELETE); } void BmobObject::del(string objectId,BmobDeleteDelegate* delegate){ this->m_objectId = objectId; this->del(delegate); } void BmobObject::add(string column,Ref* object){ if (object == NULL) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "Add"; __Array* array = __Array::create(); array->addObject(object); dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(array,"objects"); this->enParamsToHttp(column,dict); } void BmobObject::add(string column,__Array* array){ if (column.empty() || array == NULL) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "Add"; dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(array,"objects"); this->enParamsToHttp(column,dict); } void BmobObject::enParamsToHttp(string key,cocos2d::Ref *object){ this->m_mapData.insert(pair<string, Ref *>(key, object)); } Ref* BmobObject::getParams(string key){ std::map<string, Ref *>::iterator it = m_mapData.find(key); if (it!=m_mapData.end()) { return it->second; } return NULL; } void BmobObject::setHeader(vector<string> v){ this->m_header = v; } vector<string> BmobObject::getHeader(){ if (this->m_header.empty()) { vector<string> header_list; header_list.push_back("X-Bmob-Application-Id:"+BmobSDKInit::APP_ID); header_list.push_back("X-Bmob-REST-API-Key:"+BmobSDKInit::APP_KEY); header_list.push_back("Content-Type: application/json"); if (strcmp(m_tableName.c_str(),BmobSDKInit::USER_TABLE.c_str()) == 0) { if (!m_session.empty()) { string se = "X-Bmob-Session-Token:" + m_session; header_list.push_back(se); } } this->m_header = header_list; } return this->m_header; } void BmobObject::enJson(Json::Value* value){ BmobJsonUtil::dictionary2Json(value, &(this->m_mapData)); } void BmobObject::deJson(Json::Value* value){ this->clear(); BmobJsonUtil::json2Dictionary(value, &(this->m_mapData)); this->m_objectId = (*value)["objectId"].asString(); this->m_createdAt = (*value)["createdAt"].asString(); this->m_updatedAt = (*value)["updatedAt"].asString(); } void BmobObject::send(){ this->send(HttpRequest::Type::POST); } void BmobObject::send(HttpRequest::Type type){ HttpRequest* req = new HttpRequest; req->setUrl(this->m_url.c_str()); req->setResponseCallback(this, cocos2d::SEL_CallFuncND(&BmobObject::onHttpRequestCompleted)); req->setRequestType(type); req->setHeaders(getHeader()); Json::Value params; std::string data; this->enJson(&params); data = params.toStyledString(); req->setRequestData(data.c_str(), strlen(data.c_str())); cout<<"request data is:"<<data<<endl; HttpClient::getInstance()->setTimeoutForConnect(3000); HttpClient::getInstance()->setTimeoutForRead(3000); HttpClient::getInstance()->send(req); req->release(); } void BmobObject::onHttpRequestCompleted(cocos2d::Node *pSender,void *data){ HttpResponse *response = (HttpResponse *)data; if (!response->isSucceed()) { int errorCode = response->getResponseCode(); string errorInfo = response->getErrorBuffer(); switch(_opType){ case HTTP_OP_Type::_bHTTP_SAVE:{ if (m_pSaveDelegate != NULL) { this->m_pSaveDelegate->onSaveError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_UPDATE:{ if (m_pUpdateDelegate != NULL) { this->m_pUpdateDelegate->onUpdateError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_DELETE:{ if (m_pDeleteDelegate != NULL) { this->m_pDeleteDelegate->onDeleteError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET:{ if (m_pResetDelegate != NULL) { this->m_pResetDelegate->onResetError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_REQUEST_CODE:{ if(m_pRequestSMSCodeDelegate != NULL){ this->m_pRequestSMSCodeDelegate->onRequestDone(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET_BY_CODE:{ if(m_pResetByMSMCodeDelegate != NULL){ this->m_pResetByMSMCodeDelegate->onResetDone(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_EMAIL_VERIFY:{ if (m_pEmailVerifyDelegate != NULL) { this->m_pEmailVerifyDelegate->onEmailVerifyError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_LOGIN:{ if(m_pLoginDelegate != NULL){ this->m_pLoginDelegate->onLoginDone(errorCode,errorInfo.c_str()); } }break; default:break; } return; }else{ std::vector<char> *buffer = response->getResponseData(); std::string str((*buffer).begin(),(*buffer).end()); cout<<"request sucess "<<str<<endl; Json::Reader reader; Json::Value value; if (!reader.parse(str, value)) { }else{ switch(_opType){ case HTTP_OP_Type::_bHTTP_SAVE:{ if (strcmp(m_tableName.c_str(),BmobSDKInit::USER_TABLE.c_str()) == 0) { string objectId = value["objectId"].asString(); string session = value["sessionToken"].asString(); UserDefault::getInstance()->setStringForKey("user_id",objectId); UserDefault::getInstance()->setStringForKey("user_session",session); } if (m_pSaveDelegate != NULL) { this->m_pSaveDelegate->onSaveSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_UPDATE:{ if (m_pUpdateDelegate != NULL) { this->m_pUpdateDelegate->onUpdateSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_DELETE:{ if (m_pDeleteDelegate != NULL) { this->m_pDeleteDelegate->onDeleteSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET:{ if (m_pResetDelegate != NULL) { this->m_pResetDelegate->onResetSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_REQUEST_CODE:{ if(m_pRequestSMSCodeDelegate != NULL){ this->m_pRequestSMSCodeDelegate->onRequestDone(200,str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET_BY_CODE:{ if(m_pResetByMSMCodeDelegate != NULL){ this->m_pResetByMSMCodeDelegate->onResetDone(200,str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_EMAIL_VERIFY:{ if (m_pEmailVerifyDelegate != NULL) { this->m_pEmailVerifyDelegate->onEmailVerifySucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_LOGIN:{ if(m_pLoginDelegate != NULL){ this->m_pLoginDelegate->onLoginDone(200,str.c_str()); } }break; default:break; } } } }
#include "bmobobject.h" #include "network/HttpClient.h" #include "network/HttpResponse.h" #include "../util/bmobstrutil.h" using namespace network; BmobObject::BmobObject(){ this->m_pSaveDelegate = NULL; this->m_pUpdateDelegate = NULL; this->m_pSaveDelegate = NULL; } BmobObject::BmobObject(string tableName){ this->m_tableName = tableName; this->m_pSaveDelegate = NULL; this->m_pUpdateDelegate = NULL; this->m_pSaveDelegate = NULL; } BmobObject::~BmobObject(){ } void BmobObject::save(BmobSaveDelegate* delegate){ if (!BmobSDKInit::isInitialize()) { return ; } _opType = HTTP_OP_Type::_bHTTP_SAVE; this->m_pSaveDelegate = delegate; this->m_url = BmobSDKInit::URL + m_tableName; this->send(); } void BmobObject::increment(string column,int value ){ } void BmobObject::setValue(string key,cocos2d::Ref *object){ this->enParamsToHttp(key,object); } void BmobObject::setValue(string key,__Array* array){ if (array == NULL || key.empty()) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "AddUnique"; dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(array,"objects"); this->enParamsToHttp(key,dict); } void BmobObject::update(BmobUpdateDelegate* delegate){ this->update(this->getObjectId(),delegate); } void BmobObject::update(string objectId,BmobUpdateDelegate* delegate){ if (objectId.empty()) { return ; } _opType = HTTP_OP_Type::_bHTTP_UPDATE; this->m_pUpdateDelegate = delegate; this->m_url = BmobSDKInit::URL + m_tableName ; if (!objectId.empty()) { this->m_url += + "/" + objectId; } this->send(HttpRequest::Type::PUT); } void BmobObject::remove(string name){ if (name.empty()) { return ; } this->clear(); __Dictionary* pDict = __Dictionary::create(); __String* pValue2 = __String::create("Delete"); pDict->setObject(pValue2, "__op"); this->enParamsToHttp(name,pDict); } void BmobObject::removeAll(string name,__Array* array){
y,"objects"); this->enParamsToHttp(name,dict); } void BmobObject::del(BmobDeleteDelegate* delegate){ _opType = HTTP_OP_Type::_bHTTP_DELETE; this->m_pDeleteDelegate = delegate; this->m_url = BmobSDKInit::URL + m_tableName + "/" + m_objectId; this->send(HttpRequest::Type::DELETE); } void BmobObject::del(string objectId,BmobDeleteDelegate* delegate){ this->m_objectId = objectId; this->del(delegate); } void BmobObject::add(string column,Ref* object){ if (object == NULL) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "Add"; __Array* array = __Array::create(); array->addObject(object); dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(array,"objects"); this->enParamsToHttp(column,dict); } void BmobObject::add(string column,__Array* array){ if (column.empty() || array == NULL) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "Add"; dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(array,"objects"); this->enParamsToHttp(column,dict); } void BmobObject::enParamsToHttp(string key,cocos2d::Ref *object){ this->m_mapData.insert(pair<string, Ref *>(key, object)); } Ref* BmobObject::getParams(string key){ std::map<string, Ref *>::iterator it = m_mapData.find(key); if (it!=m_mapData.end()) { return it->second; } return NULL; } void BmobObject::setHeader(vector<string> v){ this->m_header = v; } vector<string> BmobObject::getHeader(){ if (this->m_header.empty()) { vector<string> header_list; header_list.push_back("X-Bmob-Application-Id:"+BmobSDKInit::APP_ID); header_list.push_back("X-Bmob-REST-API-Key:"+BmobSDKInit::APP_KEY); header_list.push_back("Content-Type: application/json"); if (strcmp(m_tableName.c_str(),BmobSDKInit::USER_TABLE.c_str()) == 0) { if (!m_session.empty()) { string se = "X-Bmob-Session-Token:" + m_session; header_list.push_back(se); } } this->m_header = header_list; } return this->m_header; } void BmobObject::enJson(Json::Value* value){ BmobJsonUtil::dictionary2Json(value, &(this->m_mapData)); } void BmobObject::deJson(Json::Value* value){ this->clear(); BmobJsonUtil::json2Dictionary(value, &(this->m_mapData)); this->m_objectId = (*value)["objectId"].asString(); this->m_createdAt = (*value)["createdAt"].asString(); this->m_updatedAt = (*value)["updatedAt"].asString(); } void BmobObject::send(){ this->send(HttpRequest::Type::POST); } void BmobObject::send(HttpRequest::Type type){ HttpRequest* req = new HttpRequest; req->setUrl(this->m_url.c_str()); req->setResponseCallback(this, cocos2d::SEL_CallFuncND(&BmobObject::onHttpRequestCompleted)); req->setRequestType(type); req->setHeaders(getHeader()); Json::Value params; std::string data; this->enJson(&params); data = params.toStyledString(); req->setRequestData(data.c_str(), strlen(data.c_str())); cout<<"request data is:"<<data<<endl; HttpClient::getInstance()->setTimeoutForConnect(3000); HttpClient::getInstance()->setTimeoutForRead(3000); HttpClient::getInstance()->send(req); req->release(); } void BmobObject::onHttpRequestCompleted(cocos2d::Node *pSender,void *data){ HttpResponse *response = (HttpResponse *)data; if (!response->isSucceed()) { int errorCode = response->getResponseCode(); string errorInfo = response->getErrorBuffer(); switch(_opType){ case HTTP_OP_Type::_bHTTP_SAVE:{ if (m_pSaveDelegate != NULL) { this->m_pSaveDelegate->onSaveError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_UPDATE:{ if (m_pUpdateDelegate != NULL) { this->m_pUpdateDelegate->onUpdateError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_DELETE:{ if (m_pDeleteDelegate != NULL) { this->m_pDeleteDelegate->onDeleteError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET:{ if (m_pResetDelegate != NULL) { this->m_pResetDelegate->onResetError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_REQUEST_CODE:{ if(m_pRequestSMSCodeDelegate != NULL){ this->m_pRequestSMSCodeDelegate->onRequestDone(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET_BY_CODE:{ if(m_pResetByMSMCodeDelegate != NULL){ this->m_pResetByMSMCodeDelegate->onResetDone(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_EMAIL_VERIFY:{ if (m_pEmailVerifyDelegate != NULL) { this->m_pEmailVerifyDelegate->onEmailVerifyError(errorCode,errorInfo.c_str()); } }break; case HTTP_OP_Type::_bHTTP_LOGIN:{ if(m_pLoginDelegate != NULL){ this->m_pLoginDelegate->onLoginDone(errorCode,errorInfo.c_str()); } }break; default:break; } return; }else{ std::vector<char> *buffer = response->getResponseData(); std::string str((*buffer).begin(),(*buffer).end()); cout<<"request sucess "<<str<<endl; Json::Reader reader; Json::Value value; if (!reader.parse(str, value)) { }else{ switch(_opType){ case HTTP_OP_Type::_bHTTP_SAVE:{ if (strcmp(m_tableName.c_str(),BmobSDKInit::USER_TABLE.c_str()) == 0) { string objectId = value["objectId"].asString(); string session = value["sessionToken"].asString(); UserDefault::getInstance()->setStringForKey("user_id",objectId); UserDefault::getInstance()->setStringForKey("user_session",session); } if (m_pSaveDelegate != NULL) { this->m_pSaveDelegate->onSaveSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_UPDATE:{ if (m_pUpdateDelegate != NULL) { this->m_pUpdateDelegate->onUpdateSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_DELETE:{ if (m_pDeleteDelegate != NULL) { this->m_pDeleteDelegate->onDeleteSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET:{ if (m_pResetDelegate != NULL) { this->m_pResetDelegate->onResetSucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_REQUEST_CODE:{ if(m_pRequestSMSCodeDelegate != NULL){ this->m_pRequestSMSCodeDelegate->onRequestDone(200,str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_RESET_BY_CODE:{ if(m_pResetByMSMCodeDelegate != NULL){ this->m_pResetByMSMCodeDelegate->onResetDone(200,str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_EMAIL_VERIFY:{ if (m_pEmailVerifyDelegate != NULL) { this->m_pEmailVerifyDelegate->onEmailVerifySucess(str.c_str()); } }break; case HTTP_OP_Type::_bHTTP_LOGIN:{ if(m_pLoginDelegate != NULL){ this->m_pLoginDelegate->onLoginDone(200,str.c_str()); } }break; default:break; } } } }
if (array == NULL) { return ; } __Dictionary* dict = __Dictionary::create(); string op = "Remove"; dict->setObject(__String::createWithFormat("%s",op.c_str()),"__op"); dict->setObject(arra
function_block-random_span
[ { "content": "class DefaultValueArrayAllocator : public ValueArrayAllocator\n\n{\n\npublic: // overridden from ValueArrayAllocator\n\n virtual ~DefaultValueArrayAllocator()\n\n {\n\n }\n\n\n\n virtual ValueInternalArray *newArray()\n\n {\n\n return new ValueInternalArray();\n\n }\n\n\n\n virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n\n {\n\n return new ValueInternalArray( other );\n\n }\n\n\n\n virtual void destruct( ValueInternalArray *array )\n\n {\n\n delete array;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 0, "score": 156247.01437462567 }, { "content": " class JSON_API ValueArrayAllocator\n\n {\n\n public:\n\n virtual ~ValueArrayAllocator();\n\n virtual ValueInternalArray *newArray() = 0;\n\n virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0;\n\n virtual void destructArray( ValueInternalArray *array ) = 0;\n\n /** \\brief Reallocate array page index.\n\n * Reallocates an array of pointer on each page.\n\n * \\param indexes [input] pointer on the current index. May be \\c NULL.\n\n * [output] pointer on the new index of at least \n\n * \\a minNewIndexCount pages. \n\n * \\param indexCount [input] current number of pages in the index.\n\n * [output] number of page the reallocated index can handle.\n\n * \\b MUST be >= \\a minNewIndexCount.\n\n * \\param minNewIndexCount Minimum number of page the new index must be able to\n\n * handle.\n\n */\n\n virtual void reallocateArrayPageIndex( Value **&indexes, \n\n ValueInternalArray::PageIndex &indexCount,\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 1, "score": 144782.39697626472 }, { "content": " class JSON_API ValueInternalArray\n\n {\n\n friend class Value;\n\n friend class ValueIteratorBase;\n\n public:\n\n enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo.\n\n typedef Value::ArrayIndex ArrayIndex;\n\n typedef unsigned int PageIndex;\n\n\n\n# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n struct IteratorState // Must be a POD\n\n {\n\n IteratorState() \n\n : array_(0)\n\n , currentPageIndex_(0)\n\n , currentItemIndex_(0) \n\n {\n\n }\n\n ValueInternalArray *array_;\n\n Value **currentPageIndex_;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 2, "score": 144782.39697626472 }, { "content": "#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n# ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n class CZString \n\n {\n\n public:\n\n enum DuplicationPolicy \n\n {\n\n noDuplication = 0,\n\n duplicate,\n\n duplicateOnCopy\n\n };\n\n CZString( int index );\n\n CZString( const char *cstr, DuplicationPolicy allocate );\n\n CZString( const CZString &other );\n\n ~CZString();\n\n CZString &operator =( const CZString &other );\n\n bool operator<( const CZString &other ) const;\n\n bool operator==( const CZString &other ) const;\n\n int index() const;\n\n const char *c_str() const;\n\n bool isStaticString() const;\n\n private:\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 3, "score": 144024.09356813808 }, { "content": " class ValueInternalArray;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 4, "score": 139186.97581346406 }, { "content": " class JSON_API StaticString\n\n {\n\n public:\n\n explicit StaticString( const char *czstring )\n\n : str_( czstring )\n\n {\n\n }\n\n\n\n operator const char *() const\n\n {\n\n return str_;\n\n }\n\n\n\n const char *c_str() const\n\n {\n\n return str_;\n\n }\n\n\n\n private:\n\n const char *str_;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 5, "score": 134659.00537125964 }, { "content": " class ValueAllocator\n\n {\n\n public:\n\n enum { unknown = (unsigned)-1 };\n\n\n\n virtual ~ValueAllocator();\n\n\n\n virtual char *makeMemberName( const char *memberName ) = 0;\n\n virtual void releaseMemberName( char *memberName ) = 0;\n\n virtual char *duplicateStringValue( const char *value, \n\n unsigned int length = unknown ) = 0;\n\n virtual void releaseStringValue( char *value ) = 0;\n\n };\n\n\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n /** \\brief Allocator to customize Value internal map.\n\n * Below is an example of a simple implementation (default implementation actually\n\n * use memory pool for speed).\n\n * \\code\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 6, "score": 109631.16589849422 }, { "content": " class ValueIteratorBase\n\n {\n\n public:\n\n typedef unsigned int size_t;\n\n typedef int difference_type;\n\n typedef ValueIteratorBase SelfType;\n\n\n\n ValueIteratorBase();\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n explicit ValueIteratorBase( const Value::ObjectValues::iterator &current );\n\n#else\n\n ValueIteratorBase( const ValueInternalArray::IteratorState &state );\n\n ValueIteratorBase( const ValueInternalMap::IteratorState &state );\n\n#endif\n\n\n\n bool operator ==( const SelfType &other ) const\n\n {\n\n return isEqual( other );\n\n }\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 7, "score": 106673.5940163951 }, { "content": " class JSON_API Value \n\n {\n\n friend class ValueIteratorBase;\n\n# ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n friend class ValueInternalLink;\n\n friend class ValueInternalMap;\n\n# endif\n\n public:\n\n typedef std::vector<std::string> Members;\n\n typedef ValueIterator iterator;\n\n typedef ValueConstIterator const_iterator;\n\n typedef Json::UInt UInt;\n\n typedef Json::Int Int;\n\n typedef UInt ArrayIndex;\n\n\n\n static const Value null;\n\n static const Int minInt;\n\n static const Int maxInt;\n\n static const UInt maxUInt;\n\n\n\n private:\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 8, "score": 106673.5940163951 }, { "content": " class ValueIterator : public ValueIteratorBase\n\n {\n\n friend class Value;\n\n public:\n\n typedef unsigned int size_t;\n\n typedef int difference_type;\n\n typedef Value &reference;\n\n typedef Value *pointer;\n\n typedef ValueIterator SelfType;\n\n\n\n ValueIterator();\n\n ValueIterator( const ValueConstIterator &other );\n\n ValueIterator( const ValueIterator &other );\n\n private:\n\n /*! \\internal Use by Value to create an iterator.\n\n */\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n explicit ValueIterator( const Value::ObjectValues::iterator &current );\n\n#else\n\n ValueIterator( const ValueInternalArray::IteratorState &state );\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 9, "score": 106058.02130327135 }, { "content": " class ValueConstIterator : public ValueIteratorBase\n\n {\n\n friend class Value;\n\n public:\n\n typedef unsigned int size_t;\n\n typedef int difference_type;\n\n typedef const Value &reference;\n\n typedef const Value *pointer;\n\n typedef ValueConstIterator SelfType;\n\n\n\n ValueConstIterator();\n\n private:\n\n /*! \\internal Use by Value to create an iterator.\n\n */\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n explicit ValueConstIterator( const Value::ObjectValues::iterator &current );\n\n#else\n\n ValueConstIterator( const ValueInternalArray::IteratorState &state );\n\n ValueConstIterator( const ValueInternalMap::IteratorState &state );\n\n#endif\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 10, "score": 103838.99321550029 }, { "content": " /// \\pre type() is objectValue or nullValue\n\n /// \\post type() is unchanged\n\n Value removeMember( const char* key );\n\n /// Same as removeMember(const char*)\n\n Value removeMember( const std::string &key );\n\n\n\n /// Return true if the object has a member named key.\n\n bool isMember( const char *key ) const;\n\n /// Return true if the object has a member named key.\n\n bool isMember( const std::string &key ) const;\n\n# ifdef JSON_USE_CPPTL\n\n /// Return true if the object has a member named key.\n\n bool isMember( const CppTL::ConstString &key ) const;\n\n# endif\n\n\n\n /// \\brief Return a list of the member names.\n\n ///\n\n /// If null, return an empty list.\n\n /// \\pre type() is objectValue or nullValue\n\n /// \\post if type() was nullValue, it remains nullValue\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 11, "score": 103123.91038317265 }, { "content": " /// Access an object value by name, create a null member if it does not exist.\n\n Value &operator[]( const CppTL::ConstString &key );\n\n /// Access an object value by name, returns null if there is no member with that name.\n\n const Value &operator[]( const CppTL::ConstString &key ) const;\n\n# endif\n\n /// Return the member named key if it exist, defaultValue otherwise.\n\n Value get( const char *key, \n\n const Value &defaultValue ) const;\n\n /// Return the member named key if it exist, defaultValue otherwise.\n\n Value get( const std::string &key,\n\n const Value &defaultValue ) const;\n\n# ifdef JSON_USE_CPPTL\n\n /// Return the member named key if it exist, defaultValue otherwise.\n\n Value get( const CppTL::ConstString &key,\n\n const Value &defaultValue ) const;\n\n# endif\n\n /// \\brief Remove and return the named member. \n\n ///\n\n /// Do nothing if it did not exist.\n\n /// \\return the removed Value, or null.\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 12, "score": 103122.86196565829 }, { "content": " Value &operator[]( const char *key );\n\n /// Access an object value by name, returns null if there is no member with that name.\n\n const Value &operator[]( const char *key ) const;\n\n /// Access an object value by name, create a null member if it does not exist.\n\n Value &operator[]( const std::string &key );\n\n /// Access an object value by name, returns null if there is no member with that name.\n\n const Value &operator[]( const std::string &key ) const;\n\n /** \\brief Access an object value by name, create a null member if it does not exist.\n\n\n\n * If the object as no entry for that name, then the member name used to store\n\n * the new entry is not duplicated.\n\n * Example of use:\n\n * \\code\n\n * Json::Value object;\n\n * static const StaticString code(\"code\");\n\n * object[code] = 1234;\n\n * \\endcode\n\n */\n\n Value &operator[]( const StaticString &key );\n\n# ifdef JSON_USE_CPPTL\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 13, "score": 103122.13418315077 }, { "content": " void swap( CZString &other );\n\n const char *cstr_;\n\n int index_;\n\n };\n\n\n\n public:\n\n# ifndef JSON_USE_CPPTL_SMALLMAP\n\n typedef std::map<CZString, Value> ObjectValues;\n\n# else\n\n typedef CppTL::SmallMap<CZString, Value> ObjectValues;\n\n# endif // ifndef JSON_USE_CPPTL_SMALLMAP\n\n# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n\n\n public:\n\n /** \\brief Create a default Value of the given type.\n\n\n\n This is a very useful constructor.\n\n To create an empty array, pass arrayValue.\n\n To create an empty object, pass objectValue.\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 14, "score": 103121.87129186836 }, { "content": " /// otherwise, false.\n\n bool empty() const;\n\n\n\n /// Return isNull()\n\n bool operator!() const;\n\n\n\n /// Remove all object members and array elements.\n\n /// \\pre type() is arrayValue, objectValue, or nullValue\n\n /// \\post type() is unchanged\n\n void clear();\n\n\n\n /// Resize the array to size elements. \n\n /// New elements are initialized to null.\n\n /// May only be called on nullValue or arrayValue.\n\n /// \\pre type() is arrayValue or nullValue\n\n /// \\post type() is arrayValue\n\n void resize( UInt size );\n\n\n\n /// Access an array element (zero based index ).\n\n /// If the array contains less than index element, then null value are inserted\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 15, "score": 103120.60347492366 }, { "content": " double asDouble() const;\n\n bool asBool() const;\n\n\n\n bool isNull() const;\n\n bool isBool() const;\n\n bool isInt() const;\n\n bool isUInt() const;\n\n bool isIntegral() const;\n\n bool isDouble() const;\n\n bool isNumeric() const;\n\n bool isString() const;\n\n bool isArray() const;\n\n bool isObject() const;\n\n\n\n bool isConvertibleTo( ValueType other ) const;\n\n\n\n /// Number of values in array or object\n\n UInt size() const;\n\n\n\n /// \\brief Return true if empty array, empty object, or null;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 16, "score": 103119.40357471243 }, { "content": " void makePath( const std::string &path,\n\n const InArgs &in );\n\n void addPathInArg( const std::string &path, \n\n const InArgs &in, \n\n InArgs::const_iterator &itInArg, \n\n PathArgument::Kind kind );\n\n void invalidPath( const std::string &path, \n\n int location );\n\n\n\n Args args_;\n\n };\n\n\n\n /** \\brief Experimental do not use: Allocator to customize member name and string value memory management done by Value.\n\n *\n\n * - makeMemberName() and releaseMemberName() are called to respectively duplicate and\n\n * free an Json::objectValue member name.\n\n * - duplicateStringValue() and releaseStringValue() are called similarly to\n\n * duplicate and free a Json::stringValue value.\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 17, "score": 103119.26680501482 }, { "content": " };\n\n\n\n /** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n\n *\n\n * This class is a discriminated union wrapper that can represents a:\n\n * - signed integer [range: Value::minInt - Value::maxInt]\n\n * - unsigned integer (range: 0 - Value::maxUInt)\n\n * - double\n\n * - UTF-8 string\n\n * - boolean\n\n * - 'null'\n\n * - an ordered list of Value\n\n * - collection of name/value pairs (javascript object)\n\n *\n\n * The type of the held value is represented by a #ValueType and \n\n * can be obtained using type().\n\n *\n\n * values of an #objectValue or #arrayValue can be accessed using operator[]() methods. \n\n * Non const methods will automatically create the a #nullValue element \n\n * if it does not exist. \n\n * The sequence of an #arrayValue will be automatically resize and initialized \n\n * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.\n\n *\n\n * The get() methods can be used to obtanis default value in the case the required element\n\n * does not exist.\n\n *\n\n * It is possible to iterate over the list of a #objectValue values using \n\n * the getMemberNames() method.\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 18, "score": 103119.09303471715 }, { "content": " };\n\n\n\n //struct MemberNamesTransform\n\n //{\n\n // typedef const char *result_type;\n\n // const char *operator()( const CZString &name ) const\n\n // {\n\n // return name.c_str();\n\n // }\n\n //};\n\n\n\n union ValueHolder\n\n {\n\n Int int_;\n\n UInt uint_;\n\n double real_;\n\n bool bool_;\n\n char *string_;\n\n# ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n ValueInternalArray *array_;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 19, "score": 103119.06229588267 }, { "content": " Members getMemberNames() const;\n\n\n\n//# ifdef JSON_USE_CPPTL\n\n// EnumMemberNames enumMemberNames() const;\n\n// EnumValues enumValues() const;\n\n//# endif\n\n\n\n /// Comments must be //... or /* ... */\n\n void setComment( const char *comment,\n\n CommentPlacement placement );\n\n /// Comments must be //... or /* ... */\n\n void setComment( const std::string &comment,\n\n CommentPlacement placement );\n\n bool hasComment( CommentPlacement placement ) const;\n\n /// Include delimiters and embedded newlines.\n\n std::string getComment( CommentPlacement placement ) const;\n\n\n\n std::string toStyledString() const;\n\n\n\n const_iterator begin() const;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 20, "score": 103118.81335282366 }, { "content": " Value &deref() const;\n\n\n\n void increment();\n\n\n\n void decrement();\n\n\n\n difference_type computeDistance( const SelfType &other ) const;\n\n\n\n bool isEqual( const SelfType &other ) const;\n\n\n\n void copy( const SelfType &other );\n\n\n\n private:\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n Value::ObjectValues::iterator current_;\n\n // Indicates that iterator is for a null value.\n\n bool isNull_;\n\n#else\n\n union\n\n {\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 21, "score": 103118.48847706114 }, { "content": "#ifndef CPPTL_JSON_H_INCLUDED\n\n# define CPPTL_JSON_H_INCLUDED\n\n\n\n# include \"forwards.h\"\n\n# include <string>\n\n# include <vector>\n\n\n\n# ifndef JSON_USE_CPPTL_SMALLMAP\n\n# include <map>\n\n# else\n\n# include <cpptl/smallmap.h>\n\n# endif\n\n# ifdef JSON_USE_CPPTL\n\n# include <cpptl/forwards.h>\n\n# endif\n\n\n\n/** \\brief JSON (JavaScript Object Notation).\n\n */\n\nnamespace Json {\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 22, "score": 103116.45113880956 }, { "content": " Another Value can then be set to this one by assignment.\n\n\tThis is useful since clear() and resize() will not alter types.\n\n\n\n Examples:\n\n\t\\code\n\n\tJson::Value null_value; // null\n\n\tJson::Value arr_value(Json::arrayValue); // []\n\n\tJson::Value obj_value(Json::objectValue); // {}\n\n\t\\endcode\n\n */\n\n Value( ValueType type = nullValue );\n\n Value( Int value );\n\n Value( UInt value );\n\n Value( double value );\n\n Value( const char *value );\n\n Value( const char *beginValue, const char *endValue );\n\n /** \\brief Constructs a value from a static string.\n\n\n\n * Like other value string constructor but do not duplicate the string for\n\n * internal storage. The given string must remain alive after the call to this\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 23, "score": 103116.45048592043 }, { "content": " /// in the array so that its size is index+1.\n\n /// (You may need to say 'value[0u]' to get your compiler to distinguish\n\n /// this from the operator[] which takes a string.)\n\n Value &operator[]( UInt index );\n\n /// Access an array element (zero based index )\n\n /// (You may need to say 'value[0u]' to get your compiler to distinguish\n\n /// this from the operator[] which takes a string.)\n\n const Value &operator[]( UInt index ) const;\n\n /// If the array contains at least index+1 elements, returns the element value, \n\n /// otherwise returns defaultValue.\n\n Value get( UInt index, \n\n const Value &defaultValue ) const;\n\n /// Return true if index < size().\n\n bool isValidIndex( UInt index ) const;\n\n /// \\brief Append value to array at the end.\n\n ///\n\n /// Equivalent to jsonvalue[jsonvalue.size()] = value;\n\n Value &append( const Value &value );\n\n\n\n /// Access an object value by name, create a null member if it does not exist.\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 24, "score": 103116.25164897746 }, { "content": " /** \\brief Type of the value held by a Value object.\n\n */\n\n enum ValueType\n\n {\n\n nullValue = 0, ///< 'null' value\n\n intValue, ///< signed integer value\n\n uintValue, ///< unsigned integer value\n\n realValue, ///< double value\n\n stringValue, ///< UTF-8 string value\n\n booleanValue, ///< bool value\n\n arrayValue, ///< array value (ordered list)\n\n objectValue ///< object value (collection of name/value pairs).\n\n };\n\n\n\n enum CommentPlacement\n\n {\n\n commentBefore = 0, ///< a comment placed on the line before a value\n\n commentAfterOnSameLine, ///< a comment just after a value on the same line\n\n commentAfter, ///< a comment on the line after a value (only make sense for root value)\n\n numberOfCommentPlacement\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 25, "score": 103116.206887006 }, { "content": " bool operator !=( const SelfType &other ) const\n\n {\n\n return !isEqual( other );\n\n }\n\n\n\n difference_type operator -( const SelfType &other ) const\n\n {\n\n return computeDistance( other );\n\n }\n\n\n\n /// Return either the index or the member name of the referenced value as a Value.\n\n Value key() const;\n\n\n\n /// Return the index of the referenced Value. -1 if it is not an arrayValue.\n\n UInt index() const;\n\n\n\n /// Return the member name of the referenced Value. \"\" if it is not an objectValue.\n\n const char *memberName() const;\n\n\n\n protected:\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 26, "score": 103116.04974527753 }, { "content": " ValueInternalArray::PageIndex minNewIndexCount ) = 0;\n\n virtual void releaseArrayPageIndex( Value **indexes, \n\n ValueInternalArray::PageIndex indexCount ) = 0;\n\n virtual Value *allocateArrayPage() = 0;\n\n virtual void releaseArrayPage( Value *value ) = 0;\n\n };\n\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n\n\n\n\n /** \\brief base class for Value iterators.\n\n *\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 27, "score": 103115.40291271936 }, { "content": " };\n\n\n\n//# ifdef JSON_USE_CPPTL\n\n// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;\n\n// typedef CppTL::AnyEnumerator<const Value &> EnumValues;\n\n//# endif\n\n\n\n /** \\brief Lightweight wrapper to tag static string.\n\n *\n\n * Value constructor and objectValue member assignement takes advantage of the\n\n * StaticString and avoid the cost of string duplication when storing the\n\n * string or the member name.\n\n *\n\n * Example of usage:\n\n * \\code\n\n * Json::Value aValue( StaticString(\"some text\") );\n\n * Json::Value object;\n\n * static const StaticString code(\"code\");\n\n * object[code] = 1234;\n\n * \\endcode\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 28, "score": 103114.04288182003 }, { "content": " * constructor.\n\n * Example of usage:\n\n * \\code\n\n * Json::Value aValue( StaticString(\"some text\") );\n\n * \\endcode\n\n */\n\n Value( const StaticString &value );\n\n Value( const std::string &value );\n\n# ifdef JSON_USE_CPPTL\n\n Value( const CppTL::ConstString &value );\n\n# endif\n\n Value( bool value );\n\n Value( const Value &other );\n\n ~Value();\n\n\n\n Value &operator=( const Value &other );\n\n /// Swap values.\n\n /// \\note Currently, comments are intentionally not swapped, for\n\n /// both logic and efficiency.\n\n void swap( Value &other );\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 29, "score": 103113.88803717366 }, { "content": " unsigned int currentItemIndex_;\n\n };\n\n# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n\n\n ValueInternalArray();\n\n ValueInternalArray( const ValueInternalArray &other );\n\n ValueInternalArray &operator =( const ValueInternalArray &other );\n\n ~ValueInternalArray();\n\n void swap( ValueInternalArray &other );\n\n\n\n void clear();\n\n void resize( ArrayIndex newSize );\n\n\n\n Value &resolveReference( ArrayIndex index );\n\n\n\n Value *find( ArrayIndex index ) const;\n\n\n\n ArrayIndex size() const;\n\n\n\n int compare( const ValueInternalArray &other ) const;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 30, "score": 103113.42042485323 }, { "content": "\n\n private:\n\n static bool equals( const IteratorState &x, const IteratorState &other );\n\n static void increment( IteratorState &iterator );\n\n static void decrement( IteratorState &iterator );\n\n static Value &dereference( const IteratorState &iterator );\n\n static Value &unsafeDereference( const IteratorState &iterator );\n\n static int distance( const IteratorState &x, const IteratorState &y );\n\n static ArrayIndex indexOf( const IteratorState &iterator );\n\n void makeBeginIterator( IteratorState &it ) const;\n\n void makeEndIterator( IteratorState &it ) const;\n\n void makeIterator( IteratorState &it, ArrayIndex index ) const;\n\n\n\n void makeIndexValid( ArrayIndex index );\n\n\n\n Value **pages_;\n\n ArrayIndex size_;\n\n PageIndex pageCount_;\n\n };\n\n\n\n /** \\brief Experimental: do not use. Allocator to customize Value internal array.\n\n * Below is an example of a simple implementation (actual implementation use\n\n * memory pool).\n\n \\code\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 31, "score": 103113.1926603262 }, { "content": " ValueInternalMap *map_;\n\n#else\n\n ObjectValues *map_;\n\n# endif\n\n } value_;\n\n ValueType type_ : 8;\n\n int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.\n\n# ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.\n\n int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.\n\n# endif\n\n CommentInfo *comments_;\n\n };\n\n\n\n\n\n /** \\brief Experimental and untested: represents an element of the \"path\" to access a node.\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 32, "score": 103112.86390511983 }, { "content": " inline bool isMemberNameStatic() const\n\n {\n\n return memberNameIsStatic_ == 0;\n\n }\n\n\n\n inline void setMemberNameIsStatic( bool isStatic )\n\n {\n\n memberNameIsStatic_ = isStatic ? 1 : 0;\n\n }\n\n# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n\n\n private:\n\n struct CommentInfo\n\n {\n\n CommentInfo();\n\n ~CommentInfo();\n\n\n\n void setComment( const char *text );\n\n\n\n char *comment_;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 33, "score": 103112.40086496697 }, { "content": " }\n\n\n\n virtual Value *allocateArrayPage()\n\n {\n\n return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );\n\n }\n\n\n\n virtual void releaseArrayPage( Value *value )\n\n {\n\n if ( value )\n\n free( value );\n\n }\n\n};\n\n \\endcode\n\n */ \n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 34, "score": 103111.84348177143 }, { "content": "\n\n ValueType type() const;\n\n\n\n bool operator <( const Value &other ) const;\n\n bool operator <=( const Value &other ) const;\n\n bool operator >=( const Value &other ) const;\n\n bool operator >( const Value &other ) const;\n\n\n\n bool operator ==( const Value &other ) const;\n\n bool operator !=( const Value &other ) const;\n\n\n\n int compare( const Value &other );\n\n\n\n const char *asCString() const;\n\n std::string asString() const;\n\n# ifdef JSON_USE_CPPTL\n\n CppTL::ConstString asConstString() const;\n\n# endif\n\n Int asInt() const;\n\n UInt asUInt() const;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 35, "score": 103110.98475420049 }, { "content": " }\n\n\n\n virtual void reallocateArrayPageIndex( Value **&indexes, \n\n ValueInternalArray::PageIndex &indexCount,\n\n ValueInternalArray::PageIndex minNewIndexCount )\n\n {\n\n ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n\n if ( minNewIndexCount > newIndexCount )\n\n newIndexCount = minNewIndexCount;\n\n void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n\n if ( !newIndexes )\n\n throw std::bad_alloc();\n\n indexCount = newIndexCount;\n\n indexes = static_cast<Value **>( newIndexes );\n\n }\n\n virtual void releaseArrayPageIndex( Value **indexes, \n\n ValueInternalArray::PageIndex indexCount )\n\n {\n\n if ( indexes )\n\n free( indexes );\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 36, "score": 103110.35517618415 }, { "content": " const_iterator end() const;\n\n\n\n iterator begin();\n\n iterator end();\n\n\n\n private:\n\n Value &resolveReference( const char *key, \n\n bool isStatic );\n\n\n\n# ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n inline bool isItemAvailable() const\n\n {\n\n return itemIsUsed_ == 0;\n\n }\n\n\n\n inline void setItemUsed( bool isUsed = true )\n\n {\n\n itemIsUsed_ = isUsed ? 1 : 0;\n\n }\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 37, "score": 103110.15150390175 }, { "content": " };\n\n\n\n /** \\brief Experimental and untested: represents a \"path\" to access a node.\n\n *\n\n * Syntax:\n\n * - \".\" => root node\n\n * - \".[n]\" => elements at index 'n' of root node (an array value)\n\n * - \".name\" => member named 'name' of root node (an object value)\n\n * - \".name1.name2.name3\"\n\n * - \".[0][1][2].name1[3]\"\n\n * - \".%\" => member name is provided as parameter\n\n * - \".[%]\" => index is provied as parameter\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 38, "score": 103109.61149132642 }, { "content": " ValueInternalArray::IteratorState array_;\n\n ValueInternalMap::IteratorState map_;\n\n } iterator_;\n\n bool isArray_;\n\n#endif\n\n };\n\n\n\n /** \\brief const iterator for object and array value.\n\n *\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 39, "score": 103107.94411057125 }, { "content": " private:\n\n ValueInternalLink *buckets_;\n\n ValueInternalLink *tailLink_;\n\n BucketIndex bucketsSize_;\n\n BucketIndex itemCount_;\n\n };\n\n\n\n /** \\brief A simplified deque implementation used internally by Value.\n\n * \\internal\n\n * It is based on a list of fixed \"page\", each page contains a fixed number of items.\n\n * Instead of using a linked-list, a array of pointer is used for fast item look-up.\n\n * Look-up for an element is as follow:\n\n * - compute page index: pageIndex = itemIndex / itemsPerPage\n\n * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]\n\n *\n\n * Insertion is amortized constant time (only the array containing the index of pointers\n\n * need to be reallocated when items are appended).\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 40, "score": 103107.09994948326 }, { "content": " return new ValueInternalLink[size];\n\n }\n\n\n\n virtual void releaseMapBuckets( ValueInternalLink *links )\n\n {\n\n delete [] links;\n\n }\n\n\n\n virtual ValueInternalLink *allocateMapLink()\n\n {\n\n return new ValueInternalLink();\n\n }\n\n\n\n virtual void releaseMapLink( ValueInternalLink *link )\n\n {\n\n delete link;\n\n }\n\n };\n\n * \\endcode\n\n */ \n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 41, "score": 103105.93087922108 }, { "content": " BucketIndex itemIndex_;\n\n BucketIndex bucketIndex_;\n\n };\n\n# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n\n\n ValueInternalMap();\n\n ValueInternalMap( const ValueInternalMap &other );\n\n ValueInternalMap &operator =( const ValueInternalMap &other );\n\n ~ValueInternalMap();\n\n\n\n void swap( ValueInternalMap &other );\n\n\n\n BucketIndex size() const;\n\n\n\n void clear();\n\n\n\n bool reserveDelta( BucketIndex growth );\n\n\n\n bool reserve( BucketIndex newItemCount );\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 42, "score": 103105.43752476244 }, { "content": " const Value *find( const char *key ) const;\n\n\n\n Value *find( const char *key );\n\n\n\n Value &resolveReference( const char *key, \n\n bool isStatic );\n\n\n\n void remove( const char *key );\n\n\n\n void doActualRemove( ValueInternalLink *link, \n\n BucketIndex index,\n\n BucketIndex bucketIndex );\n\n\n\n ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );\n\n\n\n Value &setNewItem( const char *key, \n\n bool isStatic, \n\n ValueInternalLink *link, \n\n BucketIndex index );\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 43, "score": 103105.23215399694 }, { "content": " Value &unsafeAdd( const char *key, \n\n bool isStatic, \n\n HashKey hashedKey );\n\n\n\n HashKey hash( const char *key ) const;\n\n\n\n int compare( const ValueInternalMap &other ) const;\n\n\n\n private:\n\n void makeBeginIterator( IteratorState &it ) const;\n\n void makeEndIterator( IteratorState &it ) const;\n\n static bool equals( const IteratorState &x, const IteratorState &other );\n\n static void increment( IteratorState &iterator );\n\n static void incrementBucket( IteratorState &iterator );\n\n static void decrement( IteratorState &iterator );\n\n static const char *key( const IteratorState &iterator );\n\n static const char *key( const IteratorState &iterator, bool &isStatic );\n\n static Value &value( const IteratorState &iterator );\n\n static int distance( const IteratorState &x, const IteratorState &y );\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 44, "score": 103104.94013431235 }, { "content": " return *this;\n\n }\n\n\n\n SelfType &operator++()\n\n {\n\n increment();\n\n return *this;\n\n }\n\n\n\n reference operator *() const\n\n {\n\n return deref();\n\n }\n\n };\n\n\n\n\n\n /** \\brief Iterator for object and array value.\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 45, "score": 103104.92028178835 }, { "content": " SelfType &operator--()\n\n {\n\n decrement();\n\n return *this;\n\n }\n\n\n\n SelfType &operator++()\n\n {\n\n increment();\n\n return *this;\n\n }\n\n\n\n reference operator *() const\n\n {\n\n return deref();\n\n }\n\n };\n\n\n\n\n\n} // namespace Json\n\n\n\n\n\n#endif // CPPTL_JSON_H_INCLUDED\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 46, "score": 103104.05115827319 }, { "content": " /** \\brief A linked page based hash-table implementation used internally by Value.\n\n * \\internal ValueInternalMap is a tradional bucket based hash-table, with a linked\n\n * list in each bucket to handle collision. There is an addional twist in that\n\n * each node of the collision linked list is a page containing a fixed amount of\n\n * value. This provides a better compromise between memory usage and speed.\n\n * \n\n * Each bucket is made up of a chained list of ValueInternalLink. The last\n\n * link of a given bucket can be found in the 'previous_' field of the following bucket.\n\n * The last link of the last bucket is stored in tailLink_ as it has no following bucket.\n\n * Only the last link of a bucket may contains 'available' item. The last link always\n\n * contains at least one element unless is it the bucket one very first link.\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 47, "score": 103101.77925782024 }, { "content": " ValueIterator( const ValueInternalMap::IteratorState &state );\n\n#endif\n\n public:\n\n\n\n SelfType &operator =( const SelfType &other );\n\n\n\n SelfType operator++( int )\n\n {\n\n SelfType temp( *this );\n\n ++*this;\n\n return temp;\n\n }\n\n\n\n SelfType operator--( int )\n\n {\n\n SelfType temp( *this );\n\n --*this;\n\n return temp;\n\n }\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 48, "score": 103100.00862876361 }, { "content": " public:\n\n SelfType &operator =( const ValueIteratorBase &other );\n\n\n\n SelfType operator++( int )\n\n {\n\n SelfType temp( *this );\n\n ++*this;\n\n return temp;\n\n }\n\n\n\n SelfType operator--( int )\n\n {\n\n SelfType temp( *this );\n\n --*this;\n\n return temp;\n\n }\n\n\n\n SelfType &operator--()\n\n {\n\n decrement();\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 49, "score": 103098.78017228084 }, { "content": " class DefaultValueMapAllocator : public ValueMapAllocator\n\n {\n\n public: // overridden from ValueMapAllocator\n\n virtual ValueInternalMap *newMap()\n\n {\n\n return new ValueInternalMap();\n\n }\n\n\n\n virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n\n {\n\n return new ValueInternalMap( other );\n\n }\n\n\n\n virtual void destructMap( ValueInternalMap *map )\n\n {\n\n delete map;\n\n }\n\n\n\n virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n\n {\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 50, "score": 101720.777151539 }, { "content": " class JSON_API ValueInternalMap\n\n {\n\n friend class ValueIteratorBase;\n\n friend class Value;\n\n public:\n\n typedef unsigned int HashKey;\n\n typedef unsigned int BucketIndex;\n\n\n\n# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n struct IteratorState\n\n {\n\n IteratorState() \n\n : map_(0)\n\n , link_(0)\n\n , itemIndex_(0)\n\n , bucketIndex_(0) \n\n {\n\n }\n\n ValueInternalMap *map_;\n\n ValueInternalLink *link_;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 51, "score": 101231.63482193093 }, { "content": " class JSON_API ValueInternalLink\n\n {\n\n public:\n\n enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.\n\n enum InternalFlags { \n\n flagAvailable = 0,\n\n flagUsed = 1\n\n };\n\n\n\n ValueInternalLink();\n\n\n\n ~ValueInternalLink();\n\n\n\n Value items_[itemPerLink];\n\n char *keys_[itemPerLink];\n\n ValueInternalLink *previous_;\n\n ValueInternalLink *next_;\n\n };\n\n\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 52, "score": 101231.63482193093 }, { "content": " class JSON_API ValueMapAllocator\n\n {\n\n public:\n\n virtual ~ValueMapAllocator();\n\n virtual ValueInternalMap *newMap() = 0;\n\n virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0;\n\n virtual void destructMap( ValueInternalMap *map ) = 0;\n\n virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0;\n\n virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;\n\n virtual ValueInternalLink *allocateMapLink() = 0;\n\n virtual void releaseMapLink( ValueInternalLink *link ) = 0;\n\n };\n\n\n\n /** \\brief ValueInternalMap hash-map bucket chain link (for internal use only).\n\n * \\internal previous_ & next_ allows for bidirectional traversal.\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 53, "score": 101231.63482193093 }, { "content": " class Value;\n\n\n\n /** \\brief Abstract class for writers.\n\n */\n", "file_path": "Classes/Bmob/jsoncpp/include/writer.h", "rank": 54, "score": 99384.87087265935 }, { "content": " class Value;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 55, "score": 99384.87087265935 }, { "content": " class Path\n\n {\n\n public:\n\n Path( const std::string &path,\n\n const PathArgument &a1 = PathArgument(),\n\n const PathArgument &a2 = PathArgument(),\n\n const PathArgument &a3 = PathArgument(),\n\n const PathArgument &a4 = PathArgument(),\n\n const PathArgument &a5 = PathArgument() );\n\n\n\n const Value &resolve( const Value &root ) const;\n\n Value resolve( const Value &root, \n\n const Value &defaultValue ) const;\n\n /// Creates the \"path\" to access the specified node and returns a reference on the node.\n\n Value &make( Value &root ) const;\n\n\n\n private:\n\n typedef std::vector<const PathArgument *> InArgs;\n\n typedef std::vector<PathArgument> Args;\n\n\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 56, "score": 99384.87087265935 }, { "content": " class StaticString;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 57, "score": 96080.68258705632 }, { "content": "#ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n class ValueAllocator;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 58, "score": 95943.82669853218 }, { "content": " class ValueIterator;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 59, "score": 95932.67173153802 }, { "content": " class PathArgument\n\n {\n\n public:\n\n friend class Path;\n\n\n\n PathArgument();\n\n PathArgument( UInt index );\n\n PathArgument( const char *key );\n\n PathArgument( const std::string &key );\n\n\n\n private:\n\n enum Kind\n\n {\n\n kindNone = 0,\n\n kindIndex,\n\n kindKey\n\n };\n\n std::string key_;\n\n UInt index_;\n\n Kind kind_;\n", "file_path": "Classes/Bmob/jsoncpp/include/value.h", "rank": 60, "score": 95932.67173153802 }, { "content": " class ValueConstIterator;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 61, "score": 92712.2504679537 }, { "content": " class ValueInternalMap;\n\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n\n\n} // namespace Json\n\n\n\n\n\n#endif // JSON_FORWARDS_H_INCLUDED\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 62, "score": 92712.2504679537 }, { "content": " class ValueInternalLink;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 63, "score": 92712.2504679537 }, { "content": " class ValueMapAllocator;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 64, "score": 92712.2504679537 }, { "content": " class ValueIteratorBase;\n", "file_path": "Classes/Bmob/jsoncpp/include/forwards.h", "rank": 65, "score": 92712.2504679537 }, { "content": " int op; /* Constraining operation */\n", "file_path": "Classes/Common/sqlite3.c", "rank": 66, "score": 88586.15019856204 }, { "content": " unsigned char op; /* Constraint operator */\n", "file_path": "Classes/Common/sqlite3.h", "rank": 67, "score": 88586.15019856204 }, { "content": "", "file_path": "Classes/Aircraft.h", "rank": 68, "score": 87068.98711405475 }, { "content": "", "file_path": "Classes/GameObject.h", "rank": 69, "score": 66131.5533320459 }, { "content": " @Override\n\n public String toString() {\n\n return \"{ color: \" + configAttribs[3] + configAttribs[2] + configAttribs[1] + configAttribs[0] +\n\n \"; depth: \" + configAttribs[4] + \"; stencil: \" + configAttribs[5] + \";}\";\n", "file_path": "proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java", "rank": 70, "score": 63124.47787649972 }, { "content": "class DefaultValueAllocator : public ValueAllocator\n\n{\n\npublic:\n\n virtual ~DefaultValueAllocator()\n\n {\n\n }\n\n\n\n virtual char *makeMemberName( const char *memberName )\n\n {\n\n return duplicateStringValue( memberName );\n\n }\n\n\n\n virtual void releaseMemberName( char *memberName )\n\n {\n\n releaseStringValue( memberName );\n\n }\n\n\n\n virtual char *duplicateStringValue( const char *value, \n\n unsigned int length = unknown )\n\n {\n", "file_path": "Classes/Bmob/jsoncpp/src/json_value.cpp", "rank": 71, "score": 61999.7780649368 }, { "content": "", "file_path": "Classes/GameObject.h", "rank": 72, "score": 61800.87074981917 }, { "content": "class BmobLoginDelegate{\n\npublic:\n\n\t/**\n\n\t*\n\n\t*/\n\n\tvirtual void onLoginDone(int code,const void* data) = 0;\n\n};\n\n\n\n#endif", "file_path": "Classes/Bmob/delegate/bmoblogindelegate.h", "rank": 73, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobclouddelegate.h", "rank": 74, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobsavedelegate.h", "rank": 75, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobcountdelegate.h", "rank": 76, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobupdatedelegate.h", "rank": 77, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobstaticsdelegate.h", "rank": 78, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobgetdelegate.h", "rank": 79, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobdeletedelegate.h", "rank": 80, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobfinddelegate.h", "rank": 81, "score": 61750.799967111154 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobemailverifydelegate.h", "rank": 82, "score": 60401.94866681025 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobresetpassworddelegate.h", "rank": 83, "score": 60401.94866681025 }, { "content": "class AppDelegate : private cocos2d::Application\n\n{\n\npublic:\n\n AppDelegate();\n\n virtual ~AppDelegate();\n\n\n\n virtual void initGLContextAttrs();\n\n\n\n /**\n\n @brief Implement Director and Scene init code here.\n\n @return true Initialize success, app continue.\n\n @return false Initialize failed, app terminate.\n\n */\n\n virtual bool applicationDidFinishLaunching();\n\n\n\n /**\n\n @brief The function be called when the application enter background\n\n @param the pointer of the application\n\n */\n\n virtual void applicationDidEnterBackground();\n", "file_path": "Classes/AppDelegate.h", "rank": 84, "score": 60401.94866681025 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobresetpasswordbycodedelegate.h", "rank": 85, "score": 59110.764874769025 }, { "content": "", "file_path": "Classes/Bmob/delegate/bmobrequestSMScodedelegate.h", "rank": 86, "score": 56687.213550104796 }, { "content": "", "file_path": "Classes/GameObject.h", "rank": 87, "score": 55837.96997482224 }, { "content": "", "file_path": "Classes/GameObject.h", "rank": 88, "score": 55826.06907450938 }, { "content": "#ifndef _APP_DELEGATE_H_\n\n#define _APP_DELEGATE_H_\n\n\n\n#include \"cocos2d.h\"\n\n\n\n/**\n\n@brief The cocos2d Application.\n\n\n\nThe reason for implement as private inheritance is to hide some interface call by Director.\n\n*/\n", "file_path": "Classes/AppDelegate.h", "rank": 89, "score": 55785.7365826379 }, { "content": "\n\n /**\n\n @brief The function be called when the application enter foreground\n\n @param the pointer of the application\n\n */\n\n virtual void applicationWillEnterForeground();\n\n};\n\n\n\n#endif // _APP_DELEGATE_H_\n\n\n", "file_path": "Classes/AppDelegate.h", "rank": 90, "score": 55784.485401840364 }, { "content": "", "file_path": "Classes/GameObject.cpp", "rank": 91, "score": 53673.14227060684 }, { "content": "#include \"bmobquery.h\"\n\n#include \"network/HttpClient.h\"\n\n#include \"network/HttpResponse.h\"\n\n#include \"network/HttpRequest.h\"\n\n#include \"../util/bmobstrutil.h\"\n\n\n\n\n\nusing namespace network;\n\n\n\nBmobQuery::BmobQuery(string tableName):\n\nBmobQueryInterafce(tableName){\n\n\n\n}\n\n\n\nBmobQuery::~BmobQuery(){\n\n\n\n}\n\n\n\nvoid BmobQuery::findObjects(BmobFindDelegate* delegate){\n\n if (!BmobSDKInit::isInitialize())\n", "file_path": "Classes/Bmob/baseobject/bmobquery.cpp", "rank": 94, "score": 35.991825812590676 }, { "content": " {\n\n /* code */\n\n return ;\n\n }\n\n __Dictionary* pDict = __Dictionary::create();\n\n __Array* array = __Array::create();\n\n array->addObject(object);\n\n pDict->setObject(array, \"$nin\");\n\n this->m_whereData.insert(pair<string,Ref*>(seg,pDict));\n\n}\n\n\n\nvoid BmobQuery::addWhereGreatorThan(string seg,Ref *object){\n\n\n\n}\n\n\n\nvoid BmobQuery::addWhereLessThan(string seg,Ref *object){\n\n __Integer* value = dynamic_cast<__Integer*>(object);\n\n if (!value)\n\n {\n\n /* code */\n", "file_path": "Classes/Bmob/baseobject/bmobquery.cpp", "rank": 99, "score": 30.217184918776724 } ]
C++
Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow.cpp
AnasKhedr/Smart-Home-2017
b847baa26fbd12b831e2f4325f74d0aa1a766dad
#include "../gui/writewindow.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'writewindow.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.3.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_WriteWindow_t { QByteArrayData data[10]; char stringdata[213]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_WriteWindow_t, stringdata) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_WriteWindow_t qt_meta_stringdata_WriteWindow = { { QT_MOC_LITERAL(0, 0, 11), QT_MOC_LITERAL(1, 12, 25), QT_MOC_LITERAL(2, 38, 0), QT_MOC_LITERAL(3, 39, 5), QT_MOC_LITERAL(4, 45, 28), QT_MOC_LITERAL(5, 74, 4), QT_MOC_LITERAL(6, 79, 38), QT_MOC_LITERAL(7, 118, 29), QT_MOC_LITERAL(8, 148, 32), QT_MOC_LITERAL(9, 181, 31) }, "WriteWindow\0on_dial_temp_valueChanged\0" "\0value\0on_spinBox_temp_valueChanged\0" "arg1\0on_horizontalSlider_light_valueChanged\0" "on_spinBox_light_valueChanged\0" "on_pushButton_send_light_clicked\0" "on_pushButton_send_temp_clicked" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_WriteWindow[] = { 7, 0, 0, 0, 6, 14, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 44, 2, 0x08 , 4, 1, 47, 2, 0x08 , 6, 1, 50, 2, 0x08 , 7, 1, 53, 2, 0x08 , 8, 0, 56, 2, 0x08 , 9, 0, 57, 2, 0x08 , QMetaType::Void, QMetaType::Int, 3, QMetaType::Void, QMetaType::Int, 5, QMetaType::Void, QMetaType::Int, 3, QMetaType::Void, QMetaType::Int, 5, QMetaType::Void, QMetaType::Void, 0 }; void WriteWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { WriteWindow *_t = static_cast<WriteWindow *>(_o); switch (_id) { case 0: _t->on_dial_temp_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: _t->on_spinBox_temp_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: _t->on_horizontalSlider_light_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: _t->on_spinBox_light_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: _t->on_pushButton_send_light_clicked(); break; case 5: _t->on_pushButton_send_temp_clicked(); break; default: ; } } } const QMetaObject WriteWindow::staticMetaObject = { { &QDialog::staticMetaObject, qt_meta_stringdata_WriteWindow.data, qt_meta_data_WriteWindow, qt_static_metacall, 0, 0} }; const QMetaObject *WriteWindow::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *WriteWindow::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_WriteWindow.stringdata)) return static_cast<void*>(const_cast< WriteWindow*>(this)); return QDialog::qt_metacast(_clname); } int WriteWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 6) qt_static_metacall(this, _c, _id, _a); _id -= 6; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 6) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 6; } return _id; } QT_END_MOC_NAMESPACE
#include "../gui/writewindow.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'writewindow.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.3.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_WriteWindow_t { QByteArrayData data[10]; char stringdata[213]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_
2), QT_MOC_LITERAL(9, 181, 31) }, "WriteWindow\0on_dial_temp_valueChanged\0" "\0value\0on_spinBox_temp_valueChanged\0" "arg1\0on_horizontalSlider_light_valueChanged\0" "on_spinBox_light_valueChanged\0" "on_pushButton_send_light_clicked\0" "on_pushButton_send_temp_clicked" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_WriteWindow[] = { 7, 0, 0, 0, 6, 14, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 44, 2, 0x08 , 4, 1, 47, 2, 0x08 , 6, 1, 50, 2, 0x08 , 7, 1, 53, 2, 0x08 , 8, 0, 56, 2, 0x08 , 9, 0, 57, 2, 0x08 , QMetaType::Void, QMetaType::Int, 3, QMetaType::Void, QMetaType::Int, 5, QMetaType::Void, QMetaType::Int, 3, QMetaType::Void, QMetaType::Int, 5, QMetaType::Void, QMetaType::Void, 0 }; void WriteWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { WriteWindow *_t = static_cast<WriteWindow *>(_o); switch (_id) { case 0: _t->on_dial_temp_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: _t->on_spinBox_temp_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: _t->on_horizontalSlider_light_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: _t->on_spinBox_light_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: _t->on_pushButton_send_light_clicked(); break; case 5: _t->on_pushButton_send_temp_clicked(); break; default: ; } } } const QMetaObject WriteWindow::staticMetaObject = { { &QDialog::staticMetaObject, qt_meta_stringdata_WriteWindow.data, qt_meta_data_WriteWindow, qt_static_metacall, 0, 0} }; const QMetaObject *WriteWindow::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *WriteWindow::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_WriteWindow.stringdata)) return static_cast<void*>(const_cast< WriteWindow*>(this)); return QDialog::qt_metacast(_clname); } int WriteWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 6) qt_static_metacall(this, _c, _id, _a); _id -= 6; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 6) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 6; } return _id; } QT_END_MOC_NAMESPACE
ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_WriteWindow_t, stringdata) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_WriteWindow_t qt_meta_stringdata_WriteWindow = { { QT_MOC_LITERAL(0, 0, 11), QT_MOC_LITERAL(1, 12, 25), QT_MOC_LITERAL(2, 38, 0), QT_MOC_LITERAL(3, 39, 5), QT_MOC_LITERAL(4, 45, 28), QT_MOC_LITERAL(5, 74, 4), QT_MOC_LITERAL(6, 79, 38), QT_MOC_LITERAL(7, 118, 29), QT_MOC_LITERAL(8, 148, 3
random
[ { "content": "struct qt_meta_stringdata_ReadWindow_t {\n\n QByteArrayData data[5];\n\n char stringdata[80];\n\n};\n\n#define QT_MOC_LITERAL(idx, ofs, len) \\\n\n Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n\n qptrdiff(offsetof(qt_meta_stringdata_ReadWindow_t, stringdata) + ofs \\\n\n - idx * sizeof(QByteArrayData)) \\\n\n )\n\nstatic const qt_meta_stringdata_ReadWindow_t qt_meta_stringdata_ReadWindow = {\n\n {\n\nQT_MOC_LITERAL(0, 0, 10),\n\nQT_MOC_LITERAL(1, 11, 31),\n\nQT_MOC_LITERAL(2, 43, 0),\n\nQT_MOC_LITERAL(3, 44, 5),\n\nQT_MOC_LITERAL(4, 50, 29)\n\n },\n\n \"ReadWindow\\0on_comboBox_currentIndexChanged\\0\"\n\n \"\\0index\\0on_pushButton_refresh_clicked\"\n\n};\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow.cpp", "rank": 1, "score": 100526.26104505044 }, { "content": "struct qt_meta_stringdata_MainWindow_t {\n\n QByteArrayData data[6];\n\n char stringdata[120];\n\n};\n\n#define QT_MOC_LITERAL(idx, ofs, len) \\\n\n Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n\n qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata) + ofs \\\n\n - idx * sizeof(QByteArrayData)) \\\n\n )\n\nstatic const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = {\n\n {\n\nQT_MOC_LITERAL(0, 0, 10),\n\nQT_MOC_LITERAL(1, 11, 26),\n\nQT_MOC_LITERAL(2, 38, 0),\n\nQT_MOC_LITERAL(3, 39, 27),\n\nQT_MOC_LITERAL(4, 67, 26),\n\nQT_MOC_LITERAL(5, 94, 25)\n\n },\n\n \"MainWindow\\0on_pushButton_exit_clicked\\0\"\n\n \"\\0on_pushButton_write_clicked\\0\"\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_mainwindow.cpp", "rank": 2, "score": 100526.26104505044 }, { "content": "struct qt_meta_stringdata_LogWindow_t {\n\n QByteArrayData data[1];\n\n char stringdata[10];\n\n};\n\n#define QT_MOC_LITERAL(idx, ofs, len) \\\n\n Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n\n qptrdiff(offsetof(qt_meta_stringdata_LogWindow_t, stringdata) + ofs \\\n\n - idx * sizeof(QByteArrayData)) \\\n\n )\n\nstatic const qt_meta_stringdata_LogWindow_t qt_meta_stringdata_LogWindow = {\n\n {\n\nQT_MOC_LITERAL(0, 0, 9)\n\n },\n\n \"LogWindow\"\n\n};\n\n#undef QT_MOC_LITERAL\n\n\n\nstatic const uint qt_meta_data_LogWindow[] = {\n\n\n\n // content:\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_logwindow.cpp", "rank": 3, "score": 100526.26104505044 }, { "content": "struct qt_meta_stringdata_ReadWindow_Hall_t {\n\n QByteArrayData data[5];\n\n char stringdata[85];\n\n};\n\n#define QT_MOC_LITERAL(idx, ofs, len) \\\n\n Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n\n qptrdiff(offsetof(qt_meta_stringdata_ReadWindow_Hall_t, stringdata) + ofs \\\n\n - idx * sizeof(QByteArrayData)) \\\n\n )\n\nstatic const qt_meta_stringdata_ReadWindow_Hall_t qt_meta_stringdata_ReadWindow_Hall = {\n\n {\n\nQT_MOC_LITERAL(0, 0, 15),\n\nQT_MOC_LITERAL(1, 16, 31),\n\nQT_MOC_LITERAL(2, 48, 0),\n\nQT_MOC_LITERAL(3, 49, 5),\n\nQT_MOC_LITERAL(4, 55, 29)\n\n },\n\n \"ReadWindow_Hall\\0on_comboBox_currentIndexChanged\\0\"\n\n \"\\0index\\0on_pushButton_refresh_clicked\"\n\n};\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow_hall.cpp", "rank": 4, "score": 96730.82500968657 }, { "content": "struct qt_meta_stringdata_WriteWindow_Hall_t {\n\n QByteArrayData data[12];\n\n char stringdata[270];\n\n};\n\n#define QT_MOC_LITERAL(idx, ofs, len) \\\n\n Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n\n qptrdiff(offsetof(qt_meta_stringdata_WriteWindow_Hall_t, stringdata) + ofs \\\n\n - idx * sizeof(QByteArrayData)) \\\n\n )\n\nstatic const qt_meta_stringdata_WriteWindow_Hall_t qt_meta_stringdata_WriteWindow_Hall = {\n\n {\n\nQT_MOC_LITERAL(0, 0, 16),\n\nQT_MOC_LITERAL(1, 17, 31),\n\nQT_MOC_LITERAL(2, 49, 0),\n\nQT_MOC_LITERAL(3, 50, 32),\n\nQT_MOC_LITERAL(4, 83, 25),\n\nQT_MOC_LITERAL(5, 109, 5),\n\nQT_MOC_LITERAL(6, 115, 28),\n\nQT_MOC_LITERAL(7, 144, 4),\n\nQT_MOC_LITERAL(8, 149, 38),\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow_hall.cpp", "rank": 5, "score": 96730.82500968657 }, { "content": "/****************************************************************************\n\n** Meta object code from reading C++ file 'readwindow.h'\n\n**\n\n** Created by: The Qt Meta Object Compiler version 67 (Qt 5.3.2)\n\n**\n\n** WARNING! All changes made in this file will be lost!\n\n*****************************************************************************/\n\n\n\n#include \"../gui/readwindow.h\"\n\n#include <QtCore/qbytearray.h>\n\n#include <QtCore/qmetatype.h>\n\n#if !defined(Q_MOC_OUTPUT_REVISION)\n\n#error \"The header file 'readwindow.h' doesn't include <QObject>.\"\n\n#elif Q_MOC_OUTPUT_REVISION != 67\n\n#error \"This file was generated using the moc from 5.3.2. It\"\n\n#error \"cannot be used with the include files from this version of Qt.\"\n\n#error \"(The moc has changed too much.)\"\n\n#endif\n\n\n\nQT_BEGIN_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow.cpp", "rank": 6, "score": 31005.250194771506 }, { "content": "/****************************************************************************\n\n** Meta object code from reading C++ file 'logwindow.h'\n\n**\n\n** Created by: The Qt Meta Object Compiler version 67 (Qt 5.3.2)\n\n**\n\n** WARNING! All changes made in this file will be lost!\n\n*****************************************************************************/\n\n\n\n#include \"../gui/logwindow.h\"\n\n#include <QtCore/qbytearray.h>\n\n#include <QtCore/qmetatype.h>\n\n#if !defined(Q_MOC_OUTPUT_REVISION)\n\n#error \"The header file 'logwindow.h' doesn't include <QObject>.\"\n\n#elif Q_MOC_OUTPUT_REVISION != 67\n\n#error \"This file was generated using the moc from 5.3.2. It\"\n\n#error \"cannot be used with the include files from this version of Qt.\"\n\n#error \"(The moc has changed too much.)\"\n\n#endif\n\n\n\nQT_BEGIN_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_logwindow.cpp", "rank": 7, "score": 31005.250194771506 }, { "content": "/****************************************************************************\n\n** Meta object code from reading C++ file 'mainwindow.h'\n\n**\n\n** Created by: The Qt Meta Object Compiler version 67 (Qt 5.3.2)\n\n**\n\n** WARNING! All changes made in this file will be lost!\n\n*****************************************************************************/\n\n\n\n#include \"../gui/mainwindow.h\"\n\n#include <QtCore/qbytearray.h>\n\n#include <QtCore/qmetatype.h>\n\n#if !defined(Q_MOC_OUTPUT_REVISION)\n\n#error \"The header file 'mainwindow.h' doesn't include <QObject>.\"\n\n#elif Q_MOC_OUTPUT_REVISION != 67\n\n#error \"This file was generated using the moc from 5.3.2. It\"\n\n#error \"cannot be used with the include files from this version of Qt.\"\n\n#error \"(The moc has changed too much.)\"\n\n#endif\n\n\n\nQT_BEGIN_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_mainwindow.cpp", "rank": 8, "score": 31005.250194771506 }, { "content": "\n\nconst QMetaObject LogWindow::staticMetaObject = {\n\n { &QDialog::staticMetaObject, qt_meta_stringdata_LogWindow.data,\n\n qt_meta_data_LogWindow, qt_static_metacall, 0, 0}\n\n};\n\n\n\n\n\nconst QMetaObject *LogWindow::metaObject() const\n\n{\n\n return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;\n\n}\n\n\n\nvoid *LogWindow::qt_metacast(const char *_clname)\n\n{\n\n if (!_clname) return 0;\n\n if (!strcmp(_clname, qt_meta_stringdata_LogWindow.stringdata))\n\n return static_cast<void*>(const_cast< LogWindow*>(this));\n\n return QDialog::qt_metacast(_clname);\n\n}\n\n\n\nint LogWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n _id = QDialog::qt_metacall(_c, _id, _a);\n\n if (_id < 0)\n\n return _id;\n\n return _id;\n\n}\n\nQT_END_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_logwindow.cpp", "rank": 11, "score": 30979.109208593403 }, { "content": " if (_id < 0)\n\n return _id;\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n if (_id < 2)\n\n qt_static_metacall(this, _c, _id, _a);\n\n _id -= 2;\n\n } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n\n if (_id < 2)\n\n *reinterpret_cast<int*>(_a[0]) = -1;\n\n _id -= 2;\n\n }\n\n return _id;\n\n}\n\nQT_END_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow.cpp", "rank": 13, "score": 30977.785262488476 }, { "content": "#undef QT_MOC_LITERAL\n\n\n\nstatic const uint qt_meta_data_ReadWindow[] = {\n\n\n\n // content:\n\n 7, // revision\n\n 0, // classname\n\n 0, 0, // classinfo\n\n 2, 14, // methods\n\n 0, 0, // properties\n\n 0, 0, // enums/sets\n\n 0, 0, // constructors\n\n 0, // flags\n\n 0, // signalCount\n\n\n\n // slots: name, argc, parameters, tag, flags\n\n 1, 1, 24, 2, 0x08 /* Private */,\n\n 4, 0, 27, 2, 0x08 /* Private */,\n\n\n\n // slots: parameters\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow.cpp", "rank": 14, "score": 30977.68170106453 }, { "content": " qt_meta_data_ReadWindow, qt_static_metacall, 0, 0}\n\n};\n\n\n\n\n\nconst QMetaObject *ReadWindow::metaObject() const\n\n{\n\n return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;\n\n}\n\n\n\nvoid *ReadWindow::qt_metacast(const char *_clname)\n\n{\n\n if (!_clname) return 0;\n\n if (!strcmp(_clname, qt_meta_stringdata_ReadWindow.stringdata))\n\n return static_cast<void*>(const_cast< ReadWindow*>(this));\n\n return QDialog::qt_metacast(_clname);\n\n}\n\n\n\nint ReadWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n _id = QDialog::qt_metacall(_c, _id, _a);\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow.cpp", "rank": 15, "score": 30977.53341070641 }, { "content": " \"on_pushButton_read_clicked\\0\"\n\n \"on_pushButton_log_clicked\"\n\n};\n\n#undef QT_MOC_LITERAL\n\n\n\nstatic const uint qt_meta_data_MainWindow[] = {\n\n\n\n // content:\n\n 7, // revision\n\n 0, // classname\n\n 0, 0, // classinfo\n\n 4, 14, // methods\n\n 0, 0, // properties\n\n 0, 0, // enums/sets\n\n 0, 0, // constructors\n\n 0, // flags\n\n 0, // signalCount\n\n\n\n // slots: name, argc, parameters, tag, flags\n\n 1, 0, 34, 2, 0x08 /* Private */,\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_mainwindow.cpp", "rank": 16, "score": 30977.483812455088 }, { "content": "{\n\n if (!_clname) return 0;\n\n if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata))\n\n return static_cast<void*>(const_cast< MainWindow*>(this));\n\n return QMainWindow::qt_metacast(_clname);\n\n}\n\n\n\nint MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n _id = QMainWindow::qt_metacall(_c, _id, _a);\n\n if (_id < 0)\n\n return _id;\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n if (_id < 4)\n\n qt_static_metacall(this, _c, _id, _a);\n\n _id -= 4;\n\n } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n\n if (_id < 4)\n\n *reinterpret_cast<int*>(_a[0]) = -1;\n\n _id -= 4;\n\n }\n\n return _id;\n\n}\n\nQT_END_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_mainwindow.cpp", "rank": 17, "score": 30977.479094060865 }, { "content": " case 2: _t->on_pushButton_read_clicked(); break;\n\n case 3: _t->on_pushButton_log_clicked(); break;\n\n default: ;\n\n }\n\n }\n\n Q_UNUSED(_a);\n\n}\n\n\n\nconst QMetaObject MainWindow::staticMetaObject = {\n\n { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow.data,\n\n qt_meta_data_MainWindow, qt_static_metacall, 0, 0}\n\n};\n\n\n\n\n\nconst QMetaObject *MainWindow::metaObject() const\n\n{\n\n return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;\n\n}\n\n\n\nvoid *MainWindow::qt_metacast(const char *_clname)\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_mainwindow.cpp", "rank": 19, "score": 30977.059317168456 }, { "content": " QMetaType::Void, QMetaType::Int, 3,\n\n QMetaType::Void,\n\n\n\n 0 // eod\n\n};\n\n\n\nvoid ReadWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n ReadWindow *_t = static_cast<ReadWindow *>(_o);\n\n switch (_id) {\n\n case 0: _t->on_comboBox_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n\n case 1: _t->on_pushButton_refresh_clicked(); break;\n\n default: ;\n\n }\n\n }\n\n}\n\n\n\nconst QMetaObject ReadWindow::staticMetaObject = {\n\n { &QDialog::staticMetaObject, qt_meta_stringdata_ReadWindow.data,\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow.cpp", "rank": 21, "score": 30975.98556209581 }, { "content": " 7, // revision\n\n 0, // classname\n\n 0, 0, // classinfo\n\n 0, 0, // methods\n\n 0, 0, // properties\n\n 0, 0, // enums/sets\n\n 0, 0, // constructors\n\n 0, // flags\n\n 0, // signalCount\n\n\n\n 0 // eod\n\n};\n\n\n\nvoid LogWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n Q_UNUSED(_o);\n\n Q_UNUSED(_id);\n\n Q_UNUSED(_c);\n\n Q_UNUSED(_a);\n\n}\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_logwindow.cpp", "rank": 22, "score": 30973.694912673196 }, { "content": " 3, 0, 35, 2, 0x08 /* Private */,\n\n 4, 0, 36, 2, 0x08 /* Private */,\n\n 5, 0, 37, 2, 0x08 /* Private */,\n\n\n\n // slots: parameters\n\n QMetaType::Void,\n\n QMetaType::Void,\n\n QMetaType::Void,\n\n QMetaType::Void,\n\n\n\n 0 // eod\n\n};\n\n\n\nvoid MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n MainWindow *_t = static_cast<MainWindow *>(_o);\n\n switch (_id) {\n\n case 0: _t->on_pushButton_exit_clicked(); break;\n\n case 1: _t->on_pushButton_write_clicked(); break;\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_mainwindow.cpp", "rank": 23, "score": 30973.045463156977 }, { "content": "/****************************************************************************\n\n** Meta object code from reading C++ file 'writewindow_hall.h'\n\n**\n\n** Created by: The Qt Meta Object Compiler version 67 (Qt 5.3.2)\n\n**\n\n** WARNING! All changes made in this file will be lost!\n\n*****************************************************************************/\n\n\n\n#include \"../gui/writewindow_hall.h\"\n\n#include <QtCore/qbytearray.h>\n\n#include <QtCore/qmetatype.h>\n\n#if !defined(Q_MOC_OUTPUT_REVISION)\n\n#error \"The header file 'writewindow_hall.h' doesn't include <QObject>.\"\n\n#elif Q_MOC_OUTPUT_REVISION != 67\n\n#error \"This file was generated using the moc from 5.3.2. It\"\n\n#error \"cannot be used with the include files from this version of Qt.\"\n\n#error \"(The moc has changed too much.)\"\n\n#endif\n\n\n\nQT_BEGIN_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow_hall.cpp", "rank": 25, "score": 30179.221083327517 }, { "content": "/****************************************************************************\n\n** Meta object code from reading C++ file 'readwindow_hall.h'\n\n**\n\n** Created by: The Qt Meta Object Compiler version 67 (Qt 5.3.2)\n\n**\n\n** WARNING! All changes made in this file will be lost!\n\n*****************************************************************************/\n\n\n\n#include \"../gui/readwindow_hall.h\"\n\n#include <QtCore/qbytearray.h>\n\n#include <QtCore/qmetatype.h>\n\n#if !defined(Q_MOC_OUTPUT_REVISION)\n\n#error \"The header file 'readwindow_hall.h' doesn't include <QObject>.\"\n\n#elif Q_MOC_OUTPUT_REVISION != 67\n\n#error \"This file was generated using the moc from 5.3.2. It\"\n\n#error \"cannot be used with the include files from this version of Qt.\"\n\n#error \"(The moc has changed too much.)\"\n\n#endif\n\n\n\nQT_BEGIN_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow_hall.cpp", "rank": 26, "score": 30179.221083327517 }, { "content": "QT_MOC_LITERAL(9, 188, 29),\n\nQT_MOC_LITERAL(10, 218, 24),\n\nQT_MOC_LITERAL(11, 243, 26)\n\n },\n\n \"WriteWindow_Hall\\0on_pushButton_send_temp_clicked\\0\"\n\n \"\\0on_pushButton_send_light_clicked\\0\"\n\n \"on_dial_temp_valueChanged\\0value\\0\"\n\n \"on_spinBox_temp_valueChanged\\0arg1\\0\"\n\n \"on_horizontalSlider_light_valueChanged\\0\"\n\n \"on_spinBox_light_valueChanged\\0\"\n\n \"on_tv_state_valueChanged\\0\"\n\n \"on_door_state_valueChanged\"\n\n};\n\n#undef QT_MOC_LITERAL\n\n\n\nstatic const uint qt_meta_data_WriteWindow_Hall[] = {\n\n\n\n // content:\n\n 7, // revision\n\n 0, // classname\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow_hall.cpp", "rank": 27, "score": 30158.325971582603 }, { "content": "void *WriteWindow_Hall::qt_metacast(const char *_clname)\n\n{\n\n if (!_clname) return 0;\n\n if (!strcmp(_clname, qt_meta_stringdata_WriteWindow_Hall.stringdata))\n\n return static_cast<void*>(const_cast< WriteWindow_Hall*>(this));\n\n return QDialog::qt_metacast(_clname);\n\n}\n\n\n\nint WriteWindow_Hall::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n _id = QDialog::qt_metacall(_c, _id, _a);\n\n if (_id < 0)\n\n return _id;\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n if (_id < 8)\n\n qt_static_metacall(this, _c, _id, _a);\n\n _id -= 8;\n\n } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n\n if (_id < 8)\n\n *reinterpret_cast<int*>(_a[0]) = -1;\n\n _id -= 8;\n\n }\n\n return _id;\n\n}\n\nQT_END_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow_hall.cpp", "rank": 28, "score": 30153.90316982097 }, { "content": " case 4: _t->on_horizontalSlider_light_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n\n case 5: _t->on_spinBox_light_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n\n case 6: _t->on_tv_state_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n\n case 7: _t->on_door_state_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n\n default: ;\n\n }\n\n }\n\n}\n\n\n\nconst QMetaObject WriteWindow_Hall::staticMetaObject = {\n\n { &QDialog::staticMetaObject, qt_meta_stringdata_WriteWindow_Hall.data,\n\n qt_meta_data_WriteWindow_Hall, qt_static_metacall, 0, 0}\n\n};\n\n\n\n\n\nconst QMetaObject *WriteWindow_Hall::metaObject() const\n\n{\n\n return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;\n\n}\n\n\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow_hall.cpp", "rank": 29, "score": 30152.494158334095 }, { "content": " if (_id < 0)\n\n return _id;\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n if (_id < 2)\n\n qt_static_metacall(this, _c, _id, _a);\n\n _id -= 2;\n\n } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n\n if (_id < 2)\n\n *reinterpret_cast<int*>(_a[0]) = -1;\n\n _id -= 2;\n\n }\n\n return _id;\n\n}\n\nQT_END_MOC_NAMESPACE\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow_hall.cpp", "rank": 30, "score": 30152.18688253536 }, { "content": "#undef QT_MOC_LITERAL\n\n\n\nstatic const uint qt_meta_data_ReadWindow_Hall[] = {\n\n\n\n // content:\n\n 7, // revision\n\n 0, // classname\n\n 0, 0, // classinfo\n\n 2, 14, // methods\n\n 0, 0, // properties\n\n 0, 0, // enums/sets\n\n 0, 0, // constructors\n\n 0, // flags\n\n 0, // signalCount\n\n\n\n // slots: name, argc, parameters, tag, flags\n\n 1, 1, 24, 2, 0x08 /* Private */,\n\n 4, 0, 27, 2, 0x08 /* Private */,\n\n\n\n // slots: parameters\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow_hall.cpp", "rank": 31, "score": 30152.032722091564 }, { "content": " qt_meta_data_ReadWindow_Hall, qt_static_metacall, 0, 0}\n\n};\n\n\n\n\n\nconst QMetaObject *ReadWindow_Hall::metaObject() const\n\n{\n\n return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;\n\n}\n\n\n\nvoid *ReadWindow_Hall::qt_metacast(const char *_clname)\n\n{\n\n if (!_clname) return 0;\n\n if (!strcmp(_clname, qt_meta_stringdata_ReadWindow_Hall.stringdata))\n\n return static_cast<void*>(const_cast< ReadWindow_Hall*>(this));\n\n return QDialog::qt_metacast(_clname);\n\n}\n\n\n\nint ReadWindow_Hall::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n _id = QDialog::qt_metacall(_c, _id, _a);\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow_hall.cpp", "rank": 32, "score": 30151.795693818603 }, { "content": " QMetaType::Void, QMetaType::Int, 3,\n\n QMetaType::Void,\n\n\n\n 0 // eod\n\n};\n\n\n\nvoid ReadWindow_Hall::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n ReadWindow_Hall *_t = static_cast<ReadWindow_Hall *>(_o);\n\n switch (_id) {\n\n case 0: _t->on_comboBox_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n\n case 1: _t->on_pushButton_refresh_clicked(); break;\n\n default: ;\n\n }\n\n }\n\n}\n\n\n\nconst QMetaObject ReadWindow_Hall::staticMetaObject = {\n\n { &QDialog::staticMetaObject, qt_meta_stringdata_ReadWindow_Hall.data,\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_readwindow_hall.cpp", "rank": 33, "score": 30150.247779354693 }, { "content": " QMetaType::Void,\n\n QMetaType::Void, QMetaType::Int, 5,\n\n QMetaType::Void, QMetaType::Int, 7,\n\n QMetaType::Void, QMetaType::Int, 5,\n\n QMetaType::Void, QMetaType::Int, 7,\n\n QMetaType::Void, QMetaType::Int, 5,\n\n QMetaType::Void, QMetaType::Int, 5,\n\n\n\n 0 // eod\n\n};\n\n\n\nvoid WriteWindow_Hall::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n\n{\n\n if (_c == QMetaObject::InvokeMetaMethod) {\n\n WriteWindow_Hall *_t = static_cast<WriteWindow_Hall *>(_o);\n\n switch (_id) {\n\n case 0: _t->on_pushButton_send_temp_clicked(); break;\n\n case 1: _t->on_pushButton_send_light_clicked(); break;\n\n case 2: _t->on_dial_temp_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n\n case 3: _t->on_spinBox_temp_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow_hall.cpp", "rank": 34, "score": 30149.456725101387 }, { "content": " 0, 0, // classinfo\n\n 8, 14, // methods\n\n 0, 0, // properties\n\n 0, 0, // enums/sets\n\n 0, 0, // constructors\n\n 0, // flags\n\n 0, // signalCount\n\n\n\n // slots: name, argc, parameters, tag, flags\n\n 1, 0, 54, 2, 0x08 /* Private */,\n\n 3, 0, 55, 2, 0x08 /* Private */,\n\n 4, 1, 56, 2, 0x08 /* Private */,\n\n 6, 1, 59, 2, 0x08 /* Private */,\n\n 8, 1, 62, 2, 0x08 /* Private */,\n\n 9, 1, 65, 2, 0x08 /* Private */,\n\n 10, 1, 68, 2, 0x08 /* Private */,\n\n 11, 1, 71, 2, 0x08 /* Private */,\n\n\n\n // slots: parameters\n\n QMetaType::Void,\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/moc_writewindow_hall.cpp", "rank": 35, "score": 30145.12536081912 }, { "content": "#include <unistd.h>\t\t\t//to use usleep()\n\n#include <stdio.h>\t\t\t//to use printf()\n\n#include <RF24/RF24.h>\t\t//to use nRF24 module\n\n#include <iostream>\t\t\t//to use << and using std\n\n#include <ctime>\t\t\t//to get the time now\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <string.h>\t\t\t//to used strcmp()\n\n#include <sstream>\t\t\t//to use string stream\n\n#include <stdlib.h> \t//to use system, NULL, EXIT_FAILURE\n\n\n\n//#include <sys/stat.h> \t//for mkfifo()\n\n\n\nusing namespace std;\n\n\n\n/*\n\n//fifo creation\n\nint fifo_state;\n\nFILE *fp;\n\nchar fifo_name[] = \"readings_file\";\n\nchar read_buffer[40];\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 36, "score": 16.219661316854545 }, { "content": "#include <unistd.h>\t\t\t//to use usleep()\n\n#include <stdio.h>\t\t\t//to use printf()\n\n#include <RF24/RF24.h>\t\t//to use nRF24 module\n\n#include <iostream>\t\t\t//to use << and using std\n\n#include <ctime>\t\t\t//to get the time now\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <string.h>\t\t\t//to used strcmp()\n\n#include <sstream>\t\t\t//to use string stream\n\n#include <stdlib.h> \t//to use system, NULL, EXIT_FAILURE\n\n\n\n//#include <sys/stat.h> //for mkfifo()\n\n\n\nusing namespace std;\n\n\n\n/*\n\n//fifo creation\n\nint fifo_state;\n\nFILE *fp;\n\nchar fifo_name[] = \"readings_file\";\n\nchar read_buffer[40];\n", "file_path": "Raspberry Pi/Code/collector_get_readings_startup.cpp", "rank": 37, "score": 16.219661316854545 }, { "content": "#include \"readwindow.h\"\n\n#include \"ui_readwindow.h\"\n\n#include <fstream>\n\n#include <iostream>\n\n#include <QFile>\n\n#include <string>\n\n#include <QTextStream>\n\n\n\nusing namespace std ;\n\n/*\n\nint fifo_state;\n\nFILE *fp;\n\nchar fifo_name[] = \"readings_file\";\n\nchar read_buffer[40];\n\nchar temp[40];\n\n*/\n\n\n\n\n\nifstream data_file;\n\n//QFile data_file(\"/home/pi/Desktop/data_on_zero/New/'C++ GPIO'/nRF24/guiReadings.txt\");\n", "file_path": "Raspberry Pi/GUI raw/readwindow.cpp", "rank": 38, "score": 15.757357904665534 }, { "content": "/********************************************************************************\n\n** Form generated from reading UI file 'readwindow.ui'\n\n**\n\n** Created by: Qt User Interface Compiler version 5.3.2\n\n**\n\n** WARNING! All changes made in this file will be lost when recompiling UI file!\n\n********************************************************************************/\n\n\n\n#ifndef UI_READWINDOW_H\n\n#define UI_READWINDOW_H\n\n\n\n#include <QtCore/QVariant>\n\n#include <QtWidgets/QAction>\n\n#include <QtWidgets/QApplication>\n\n#include <QtWidgets/QButtonGroup>\n\n#include <QtWidgets/QDialog>\n\n#include <QtWidgets/QFrame>\n\n#include <QtWidgets/QHBoxLayout>\n\n#include <QtWidgets/QHeaderView>\n\n#include <QtWidgets/QLabel>\n\n#include <QtWidgets/QPushButton>\n\n#include <QtWidgets/QVBoxLayout>\n\n#include <QtWidgets/QWidget>\n\n\n\nQT_BEGIN_NAMESPACE\n\n\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/ui_readwindow.h", "rank": 39, "score": 15.572178056796758 }, { "content": "/********************************************************************************\n\n** Form generated from reading UI file 'readwindow_hall.ui'\n\n**\n\n** Created by: Qt User Interface Compiler version 5.3.2\n\n**\n\n** WARNING! All changes made in this file will be lost when recompiling UI file!\n\n********************************************************************************/\n\n\n\n#ifndef UI_READWINDOW_HALL_H\n\n#define UI_READWINDOW_HALL_H\n\n\n\n#include <QtCore/QVariant>\n\n#include <QtWidgets/QAction>\n\n#include <QtWidgets/QApplication>\n\n#include <QtWidgets/QButtonGroup>\n\n#include <QtWidgets/QDialog>\n\n#include <QtWidgets/QFrame>\n\n#include <QtWidgets/QHBoxLayout>\n\n#include <QtWidgets/QHeaderView>\n\n#include <QtWidgets/QLabel>\n\n#include <QtWidgets/QPushButton>\n\n#include <QtWidgets/QVBoxLayout>\n\n#include <QtWidgets/QWidget>\n\n\n\nQT_BEGIN_NAMESPACE\n\n\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/ui_readwindow_hall.h", "rank": 40, "score": 15.440713614421849 }, { "content": "/********************************************************************************\n\n** Form generated from reading UI file 'writewindow.ui'\n\n**\n\n** Created by: Qt User Interface Compiler version 5.3.2\n\n**\n\n** WARNING! All changes made in this file will be lost when recompiling UI file!\n\n********************************************************************************/\n\n\n\n#ifndef UI_WRITEWINDOW_H\n\n#define UI_WRITEWINDOW_H\n\n\n\n#include <QtCore/QVariant>\n\n#include <QtWidgets/QAction>\n\n#include <QtWidgets/QApplication>\n\n#include <QtWidgets/QButtonGroup>\n\n#include <QtWidgets/QDial>\n\n#include <QtWidgets/QDialog>\n\n#include <QtWidgets/QHBoxLayout>\n\n#include <QtWidgets/QHeaderView>\n\n#include <QtWidgets/QLabel>\n\n#include <QtWidgets/QPushButton>\n\n#include <QtWidgets/QSlider>\n\n#include <QtWidgets/QSpinBox>\n\n#include <QtWidgets/QVBoxLayout>\n\n#include <QtWidgets/QWidget>\n\n\n\nQT_BEGIN_NAMESPACE\n\n\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/ui_writewindow.h", "rank": 41, "score": 15.297433939889292 }, { "content": "/********************************************************************************\n\n** Form generated from reading UI file 'mainwindow.ui'\n\n**\n\n** Created by: Qt User Interface Compiler version 5.3.2\n\n**\n\n** WARNING! All changes made in this file will be lost when recompiling UI file!\n\n********************************************************************************/\n\n\n\n#ifndef UI_MAINWINDOW_H\n\n#define UI_MAINWINDOW_H\n\n\n\n#include <QtCore/QVariant>\n\n#include <QtWidgets/QAction>\n\n#include <QtWidgets/QApplication>\n\n#include <QtWidgets/QButtonGroup>\n\n#include <QtWidgets/QComboBox>\n\n#include <QtWidgets/QHBoxLayout>\n\n#include <QtWidgets/QHeaderView>\n\n#include <QtWidgets/QMainWindow>\n\n#include <QtWidgets/QMenu>\n\n#include <QtWidgets/QMenuBar>\n\n#include <QtWidgets/QPushButton>\n\n#include <QtWidgets/QStatusBar>\n\n#include <QtWidgets/QToolBar>\n\n#include <QtWidgets/QWidget>\n\n\n\nQT_BEGIN_NAMESPACE\n\n\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/ui_mainwindow.h", "rank": 42, "score": 15.181277693343723 }, { "content": "/********************************************************************************\n\n** Form generated from reading UI file 'logwindow.ui'\n\n**\n\n** Created by: Qt User Interface Compiler version 5.3.2\n\n**\n\n** WARNING! All changes made in this file will be lost when recompiling UI file!\n\n********************************************************************************/\n\n\n\n#ifndef UI_LOGWINDOW_H\n\n#define UI_LOGWINDOW_H\n\n\n\n#include <QtCore/QVariant>\n\n#include <QtWidgets/QAction>\n\n#include <QtWidgets/QApplication>\n\n#include <QtWidgets/QButtonGroup>\n\n#include <QtWidgets/QCheckBox>\n\n#include <QtWidgets/QComboBox>\n\n#include <QtWidgets/QDialog>\n\n#include <QtWidgets/QHBoxLayout>\n\n#include <QtWidgets/QHeaderView>\n\n#include <QtWidgets/QLabel>\n\n#include <QtWidgets/QPushButton>\n\n#include <QtWidgets/QSpinBox>\n\n#include <QtWidgets/QTextBrowser>\n\n#include <QtWidgets/QVBoxLayout>\n\n#include <QtWidgets/QWidget>\n\n\n\nQT_BEGIN_NAMESPACE\n\n\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/ui_logwindow.h", "rank": 43, "score": 15.07720453918482 }, { "content": "/********************************************************************************\n\n** Form generated from reading UI file 'writewindow_hall.ui'\n\n**\n\n** Created by: Qt User Interface Compiler version 5.3.2\n\n**\n\n** WARNING! All changes made in this file will be lost when recompiling UI file!\n\n********************************************************************************/\n\n\n\n#ifndef UI_WRITEWINDOW_HALL_H\n\n#define UI_WRITEWINDOW_HALL_H\n\n\n\n#include <QtCore/QVariant>\n\n#include <QtWidgets/QAction>\n\n#include <QtWidgets/QApplication>\n\n#include <QtWidgets/QButtonGroup>\n\n#include <QtWidgets/QDial>\n\n#include <QtWidgets/QDialog>\n\n#include <QtWidgets/QHBoxLayout>\n\n#include <QtWidgets/QHeaderView>\n\n#include <QtWidgets/QLabel>\n\n#include <QtWidgets/QPushButton>\n\n#include <QtWidgets/QSlider>\n\n#include <QtWidgets/QSpinBox>\n\n#include <QtWidgets/QSplitter>\n\n#include <QtWidgets/QVBoxLayout>\n\n#include <QtWidgets/QWidget>\n\n\n\nQT_BEGIN_NAMESPACE\n\n\n", "file_path": "Raspberry Pi/build-GUI_app-Desktop-Debug/ui_writewindow_hall.h", "rank": 44, "score": 15.077204539184821 }, { "content": "#include <iostream>\t\t\t//to use << and using std\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <ctime>\t\t\t//to get the time now\n\n#include <stdio.h>\t\t\t//to use printf()\n\n#include <string.h>\t\t\t//to used strcmp()\n\n#include <unistd.h>\t\t\t//to use usleep()\n\n#include <cstdlib> \t\t\t//to use system, NULL, EXIT_FAILURE\n\n#include <stdlib.h>\t\t\t//header of cstdlib (update: unnecessary include)\n\n#include <sstream>\t\t\t//to use string stream\n\n\n\nusing namespace std;\n\n\n\n//guard data\n\nint count = 0;\n\nbool inQueue = 0;\n\nint num_in_queue;\n\nint time_to_wait = 1;\n\nifstream myfile;\n\nstring str[10];\n\n\n", "file_path": "Raspberry Pi/Code/guard.cpp", "rank": 45, "score": 12.108337799308838 }, { "content": "#include <unistd.h> \t\t//to use usleep()\n\n#include <stdio.h> \t\t//to use printf()\n\n#include <cstdlib> \t\t//to use atof , atoi or atol\n\n#include <string.h> \t\t//to used strcmp()\n\n#include \"RF24/RF24.h\"\t\t//to use nRF24 module\n\n#include <RF24/printf.h>\t//to print wirless detailes\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <iostream>\t\t\t//to use cout and <<\n\n#include <ctime>\t\t\t//to get the time now\n\n#include <sstream>\t\t\t//to use stringstream\n\n\n\nusing namespace std;\n\n\n\nconst uint8_t pipes[][6] = {\"MSTR2\",\"SLV2\"};\n\n\n\n//RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ); //pin numbers are physical\n\nRF24 radio(22,0);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Setup for GPIO 22(#15) CE and GPIO8(#24)(CE0) CSN with SPI Speed @ 8Mhz\n\n\n\nchar Open[40] = \"openGarageDoor\";\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//command to be sent to arduino to open the garage door (agreed upon with arduino)\n\nchar Close[40] = \"closeGarageDoor\";\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//command to be sent to arduino to close the garage door (agreed upon with arduino)\n", "file_path": "Raspberry Pi/Code/write_door.cpp", "rank": 46, "score": 11.803260985904345 }, { "content": "#include \"readwindow_hall.h\"\n\n#include \"ui_readwindow_hall.h\"\n\n#include <fstream>\n\n#include <iostream>\n\n#include <QFile>\n\n#include <string>\n\n#include <QTextStream>\n\n\n\nusing namespace std ;\n\n\n\nifstream data_file_h;\n\n\n\nReadWindow_Hall::ReadWindow_Hall(QWidget *parent) :\n\n QDialog(parent),\n\n ui(new Ui::ReadWindow_Hall)\n\n{\n\n ui->setupUi(this);\n\n}\n\n\n\nReadWindow_Hall::~ReadWindow_Hall()\n", "file_path": "Raspberry Pi/GUI raw/readwindow_hall.cpp", "rank": 47, "score": 10.722279227856719 }, { "content": "#ifndef MAINWINDOW_H\n\n#define MAINWINDOW_H\n\n\n\n#include <QMainWindow>\n\n#include \"readwindow.h\"\n\n#include \"writewindow.h\"\n\n#include \"logwindow.h\"\n\n#include \"readwindow_hall.h\"\n\n#include \"writewindow_hall.h\"\n\n\n\n#include <QString>\n\n\n\n#include <sstream>\n\n#include <unistd.h> \t\t//to use usleep()\n\n#include <stdio.h> \t\t//to use printf()\n\n#include <cstdlib> \t\t//to use atof , atoi or atol\n\n#include <string.h> \t\t//to used strcmp()\n\n\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <iostream>\t\t\t//to use << and using std\n\n#include <ctime>\t\t\t//to get the time now\n\n\n\nnamespace Ui {\n", "file_path": "Raspberry Pi/GUI raw/mainwindow.h", "rank": 48, "score": 9.765562872220986 }, { "content": "#include <unistd.h> \t\t//to use usleep()\n\n#include <stdio.h> \t\t//to use printf()\n\n#include <cstdlib> \t\t//to use atof , atoi or atol also use rand()\n\n#include <string.h> \t\t//to used strcmp()\n\n#include \"RF24/RF24.h\"\t\t//to use nRF24 module\n\n#include <RF24/printf.h>\t//to print wirless detailes\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <iostream>\t\t\t//to use cout and <<\n\n#include <ctime>\t\t\t//to get the time now\n\n#include <unistd.h>\t\t\t//to use sleep()\n\n#include <sstream>\t\t\t//to use stringstream\n\n//#include <math.h>\n\n\n\nusing namespace std;\n\n\n\nconst uint8_t pipes[][6] = {\"MSTR2\",\"SLV2\"};\n\n\n\n// Setup for GPIO 22(#15) CE and CE0 (#24) CSN with SPI Speed @ 8Mhz\n\n//RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ); //pin numbers are physical\n\nRF24 radio(22,0);\n", "file_path": "Raspberry Pi/Code/write_tv.cpp", "rank": 49, "score": 9.648559794341956 }, { "content": "#include <unistd.h> \t\t//to use usleep()\n\n#include <stdio.h> \t\t//to use printf()\n\n#include <cstdlib> \t\t//to use atof , atoi or atol\n\n#include <string.h> \t\t//to used strcmp()\n\n#include \"RF24/RF24.h\"\t\t//to use nRF24 module\n\n#include <RF24/printf.h>\t//to print wirless detailes\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <iostream>\t\t\t//to use << and using std\n\n#include <ctime>\t\t\t//to get the time now\n\n#include <sstream>\t\t\t//to use stringstream\n\n\n\nusing namespace std;\n\n\n\nconst uint8_t pipes[][6] = {\"MSTR\",\"SLV1\"};\n\nconst uint8_t pipes2[][6] = {\"MSTR2\",\"SLV2\"};\n\n\n\n// Setup for GPIO 22(#15) CE and CE0 (#24) CSN with SPI Speed @ 8Mhz\n\n//RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ); //pin numbers are physical\n\nRF24 radio(22,0);\n\n\n", "file_path": "Raspberry Pi/Code/collector_temp.cpp", "rank": 50, "score": 9.498147904063648 }, { "content": "#include <unistd.h> \t\t//to use usleep()\n\n#include <stdio.h> \t\t//to use printf()\n\n#include <cstdlib> \t\t//to use atof , atoi or atol\n\n#include <string.h> \t\t//to used strcmp()\n\n#include \"RF24/RF24.h\"\t\t//to use nRF24 module\n\n#include <RF24/printf.h>\t//to print wirless detailes\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <iostream>\t\t\t//to use << and using std\n\n#include <ctime>\t\t\t//to get the time now\n\n#include <sstream>\t\t\t//to use stringstream\n\n\n\nusing namespace std;\n\n\n\nconst uint8_t pipes[][6] = {\"MSTR\",\"SLV1\"};\n\nconst uint8_t pipes2[][6] = {\"MSTR2\",\"SLV2\"};\n\n\n\n// Setup for GPIO 22(#15) CE and CE0 (#24) CSN with SPI Speed @ 8Mhz\n\n//RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ); //pin numbers are physical\n\nRF24 radio(22,0);\n\n\n", "file_path": "Raspberry Pi/Code/collector_light.cpp", "rank": 51, "score": 9.498147904063648 }, { "content": "/*\n\n * respond as in respond to server call\n\n * respond program is designed to call other program using system()\n\n * respond is only designed for handling server calls\n\n*/\n\n\n\n#include <iostream>\t\t//to use cout\n\n#include <stdio.h>\t\t//to use printf()\n\n#include <string.h>\t\t//to used strcmp()\n\n#include <sstream>\t\t//to use stringstream\n\n#include <stdlib.h> //to use system, NULL, EXIT_FAILURE\n\n\n\nusing namespace std; // for stringstream\n\n\n\nint ret;\n\nfloat light_ref_percentage;\n\nfloat light_ref_volt;\n\n//light sid = 1\n\n//temp sid = 3\n\n\n", "file_path": "Raspberry Pi/Code/respond.cpp", "rank": 52, "score": 9.257366457718952 }, { "content": "#include <string.h> \t\t//to used strcmp()\n\n#include <fstream>\t\t\t//to write to text file\n\n#include <iostream>\t\t\t//to use << and using std\n\n\n\nusing namespace std;\n\n\n\nint count = 0;\n\nbool inQueue = 0;\n\nint num_in_queue;\n\nint time_to_wait = 1;\n\n\n\nifstream myfile;\n\nstring str[10];\n\n\n\nint main(){\n\n\tmyfile.open(\"queue.txt\", ios::in); //open test2 to read\n\n while (getline(myfile, str[count])) { //count number of lines and store them in str\n\n count++;\n\n }\n\n\t\n", "file_path": "Raspberry Pi/Code/remover.cpp", "rank": 53, "score": 8.408631443892151 }, { "content": "\t\tlogFile<<\"sending mode: \"<<Close<<endl;\t\t\t\t\t\t\t\t\t\t\t\t//print to log file that user wants to close door\n\n\t\tret = radio.write(&Close,sizeof(char[40]));\t\t\t\t\t\t\t\t\t\t\t//send close command to arduino\n\n\t\tradio.startListening();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//start listening for incoming message\n\n\t}\n\n\telse if(garageState == 1){ //1 means open the garage\t\t\t\t\t\t\t\t\t//if user wants to open garage door\n\n\t\tprintf(\"sending mode: %s\\n\",Open);\n\n\t\tlogFile<<\"sending mode: \"<<Open<<endl;\t\t\t\t\t\t\t\t\t\t\t\t//print to log file that user wants to open door\n\n\t\tret = radio.write(&Open,sizeof(char[40]));\t\t\t\t\t\t\t\t\t\t\t//send open command to arduino\n\n\t\tradio.startListening();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//start listening for incoming message\n\n\t}\n\n\t\n\n\tif(!ret){ \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if Rpi failed to send request to arduino\n\n\t\tprintf(\"failed to send request to arduino\\n\");\t\t\t\t\t\t\t\t\t\t\n\n\t\tlogFile<<\"failed to send request to arduino\\n\";\t\t\t\t\t\t\t\t\t\t//print in log file that Rpi failed to send request to arduino\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\t\t\t\t\t\t\t\t\t\t\t\t//print in log execution time of this program so far\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//close log file\n\n\t\treturn 1;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//exit loop with error flag\n\n\t}\n\n\t\n", "file_path": "Raspberry Pi/Code/write_door.cpp", "rank": 54, "score": 8.268861956218338 }, { "content": "\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\t\n\n\tif(timeout){\n\n\t\tprintf(\"timeout, failed to receive.\\n\");\n\n\t\tlogFile<<\"timeout, failed to receive.\\n\";\n\n\t\tradio.read(&incoming,sizeof(char[40]));\n\n\t\tprintf(\"in buffer: %s\\n\",incoming);\n\n\t\tlogFile<<\"in buffer: \"<<incoming<<endl;\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t}\n\n\t\n\n\telse{\n\n\t\twhile(radio.available()){\n\n\t\t\tradio.read(&incoming,sizeof(char[40])); // arduino should send us ACK if everything is ok\n\n\t\t}\n", "file_path": "Raspberry Pi/Code/collector_temp.cpp", "rank": 55, "score": 8.102631045153453 }, { "content": "\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\t\n\n\tif(timeout){\n\n\t\tprintf(\"timeout, failed to receive.\\n\");\n\n\t\tlogFile<<\"timeout, failed to receive.\\n\";\n\n\t\tradio.read(&incoming,sizeof(char[40]));\n\n\t\tprintf(\"in buffer: %s\\n\",incoming);\n\n\t\tlogFile<<\"in buffer: \"<<incoming<<endl;\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t}\n\n\t\n\n\telse{\n\n\t\twhile(radio.available()){\n\n\t\t\tradio.read(&incoming,sizeof(char[40])); // arduino should send us ACK if everything is ok\n\n\t\t}\n", "file_path": "Raspberry Pi/Code/collector_light.cpp", "rank": 56, "score": 8.102631045153453 }, { "content": "#include \"mainwindow.h\"\n\n#include <QApplication>\n\n\n\n\n\nint main(int argc, char *argv[])\n\n{\n\n QApplication a(argc, argv);\n\n MainWindow w;\n\n w.show();\n\n\n\n return a.exec();\n\n}\n", "file_path": "Raspberry Pi/GUI raw/main.cpp", "rank": 57, "score": 7.788579558860617 }, { "content": "\t\t\telse{\n\n\t\t\t\tprintf(\"unexpected respond: %s\\n\",incoming);\n\n\t\t\t\tlogFile<<\"unexpected respond: \"<<incoming<<endl;\n\n\t\t\t}\n\n\t\t}\n\n\t\t\n\n\t}\n\n\n\n\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile<<\"*****************************************\\n\";\n\n\tlogFile.close();\n\n\treturn 0;\n\n\t\n\n}\n\n\n\n\n\nint main(int argc, char ** argv){\n\n\tint success=0;\n\n\tint return_slv;\n", "file_path": "Raspberry Pi/Code/write_tv.cpp", "rank": 58, "score": 7.733990405988353 }, { "content": "#include <stdlib.h> //to use system, NULL, EXIT_FAILURE\n\n#include <unistd.h>\t\t//to use sleep\n\n\n\nint main(){\n\n\n\n\twhile(1){\n\n\t\tsleep(5);\n\n\t\tsystem(\"sudo ./collector_get_readings server\");\n\n\t\tsystem(\"yes | cp /var/www/html/rpi/guiReadings.txt /home/pi/build-GUI_app-Desktop-Debug/\");\n\n\t}\n\n}\n", "file_path": "Raspberry Pi/Code/read_loop.cpp", "rank": 59, "score": 7.730599151822716 }, { "content": "\t//write to arduino\n\n\tif(tvState == 0){ //0 measns close the tv\n\n\t\tprintf(\"sending mode: %s\\n\",Close);\n\n\t\tlogFile<<\"sending mode: \"<<Close<<endl;\n\n\t\tret = radio.write(&Close,sizeof(char[40]));\n\n\t\tradio.startListening();\n\n\t}\n\n\telse if(tvState == 1){ //1 means open the tv\n\n\t\tprintf(\"sending mode: %s\\n\",Open);\n\n\t\tlogFile<<\"sending mode: \"<<Open<<endl;\n\n\t\tret = radio.write(&Open,sizeof(char[40]));\n\n\t\tradio.startListening();\n\n\t}\n\n\t\n\n\tif(!ret){ \t\t\t\t\t//if Rpi failed to send request to arduino\n\n\t\tprintf(\"failed to send request to arduino\\n\");\n\n\t\tlogFile<<\"failed to send request to arduino\\n\";\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n", "file_path": "Raspberry Pi/Code/write_tv.cpp", "rank": 60, "score": 7.425013685075294 }, { "content": "\n\nchar Open[40] = \"tvOn\";\n\nchar Close[40] = \"tvOff\";\n\nchar ACK[40] = \"ACK\";\n\n//char NACK[40]= \"NACK\";\t\t\t\t//not used\n\nchar UC[40] = \"No such command\";\n\nchar incoming[40];\n\nfloat onRef;\n\ntime_t time_now = time(0);\n\n\n\nint current_time;\n\nbool timeout;\n\nbool ret = false;\t\t\t//to know if Rpi wrote reqest to arduino successfully or not\n\n\n\nint num1;\n\nint num2;\n\nint retry = 0;\n\nint tvState;\n\n\n\n//guard data\n", "file_path": "Raspberry Pi/Code/write_tv.cpp", "rank": 61, "score": 7.3651399214150395 }, { "content": "\n\nvoid remover()\n\n{\n\n\tcout<<\"removing myself from queue\"<<endl;\n\n ofstream myfile;\n\n myfile.open(\"queue.txt\", ios::out);\n\n for (int i = 1; i < count; i++) {\n\n cout << \"inputing: \" << str[i] << endl;\n\n myfile << str[i] << endl;\n\n }\n\n //myfile<<endl;\n\n myfile.close();\n\n}\n\n\n\nusing namespace std;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n\nint readSLV(int retry){\t\t//used to read all data from slv\n\n\tofstream logFile;\n\n\tlogFile.open(\"safty_readings.log\", ios::app);\n\n\t\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 62, "score": 7.152632757708125 }, { "content": "\t\t\tlogFile.close();\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t\tcout<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t}\n\n\telse{\n\n\t\tlogFile<<ctime(&time_now);\n\n\t\tlogFile<<\"*****************************************\\n\";\n\n\t}\n\n\t\n\n\tret = radio.write(&send,sizeof(char[40]));\n\n\tif(ret == false){\n\n\t\tprintf(\"failed to send request to SLV1\\n\");\n\n\t\tlogFile<<\"failed to send request to SLV1\\n\";\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t\t//exit(1);\n", "file_path": "Raspberry Pi/Code/collector_get_readings_startup.cpp", "rank": 63, "score": 7.141664221297514 }, { "content": "\tif(retry != 0){\n\n\t\tif(retry == 4){\n\n\t\t\tlogFile<<\"failed to send request to SLV1 after 4 attempts\\n\";\n\n\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n\n\t\t\tlogFile.close();\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t\tcout<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t}\n\n\telse{\n\n\t\tlogFile<<ctime(&time_now);\n\n\t\tlogFile<<\"*****************************************\\n\";\n\n\t}\n\n\t\n\n\tret = radio.write(&send,sizeof(char[40]));\n\n\tif(ret == false){\n\n\t\tprintf(\"failed to send request to SLV1\\n\");\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 64, "score": 7.114276011346158 }, { "content": "\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t}\n\n\t\n\n\telse{\n\n\t\twhile(radio.available()){\n\n\t\t\tradio.read(&incoming,sizeof(char[40])); // arduino should send us ACK if everything\n\n\t\t}\n\n\t\tprintf(\"incoming: %s\\n\",incoming);\n\n\t\tlogFile<<\"incoming: \"<<incoming<<endl;\n\n\t\t\n\n\t\tnum1 = strcmp(incoming , ACK);\n\n\t\tif(num1 != 0){\n\n\t\t\tnum2 = strcmp(incoming , UC);\n\n\t\t\tif(num2 == 0){\n\n\t\t\t\tprintf(\"recived \\\"unknown command\\\"\\n\");\n\n\t\t\t\tlogFile<<\"recived \\\"unknown command\\\"\\n\";\n\n\t\t\t}\n", "file_path": "Raspberry Pi/Code/write_tv.cpp", "rank": 65, "score": 7.082655964589925 }, { "content": "\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n\n\t\t\tlogFile.close();\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV2. attempt number: \"<<retry<<endl;\n\n\t\tcout<<\"Reattempting to send request to SLV2. attempt number: \"<<retry<<endl;\n\n\t}\n\n\telse\n\n\t\tlogFile<<ctime(&time_now);\n\n\t\n\n\tret = radio.write(&send2,sizeof(char[40]));\n\n\t//radio.startListening();\n\n\tif(ret == false){\n\n\t\tprintf(\"failed to send request to SLV2\\n\");\n\n\t\tlogFile<<\"failed to send request to SLV2\\n\";\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n", "file_path": "Raspberry Pi/Code/collector_get_readings_startup.cpp", "rank": 66, "score": 7.071222347793151 }, { "content": "\t\t}\n\n\t}\n\n\n\n\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile.close();\n\n\treturn 0;\n\n}\n\n\n\n\n\nint main(int argc, char ** argv){\n\n\tint success=0;\n\n\tint return_slv;\n\n\t\n\n\t\n\n\tif(argc < 3){\n\n\t\tprintf(\"wrong command.\\ncommand should be the following: sudo ./collector_temp <room name> <temperature>\\n\");\n\n\t\tprintf(\"room name is hall or room1.\\n\");\n\n\t\t//exit(1);\n\n\t\treturn 1;\n", "file_path": "Raspberry Pi/Code/collector_temp.cpp", "rank": 67, "score": 7.017216898168658 }, { "content": "\t\t}\n\n\t}\n\n\t\n\n\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile.close();\n\n\treturn 0;\n\n\t\n\n}\n\n\n\n\n\nint main(int argc, char ** argv){\n\n\tint success=0;\n\n\tint return_slv;\n\n\t\n\n\t\n\n\tif(argc < 3){\n\n\t\tprintf(\"wrong command.\\ncommand should be the following: sudo ./collector_temp <room name> <temperature>\\n\");\n\n\t\tprintf(\"room name is hall or room1.\\n\");\n\n\t\t//exit(1);\n", "file_path": "Raspberry Pi/Code/collector_light.cpp", "rank": 68, "score": 7.017216898168658 }, { "content": "\t\tcout<<\"sudo ./collector_temp room1 \"<< argv[3]<<endl;\t\t\t\t//print the command to terminal\n\n\t\tcommand<<\"sudo ./collector_temp room1 \"<< argv[3];\t\t\t\t\t//construct the command and save it in a string stream called command to call it later\n\n\t\tret = system(command.str().c_str());\t\t\t\t\t\t\t\t//call the command that we constructed\n\n\t\tcommand.str(\"\");\t\t\t\t\t\t\t\t\t\t\t\t\t//empty the string stream named command that we used to call the command we constructed\n\n\t\tprintf(\"system call return = %d\\n\",ret);\t\t\t\t\t\t\t//print the return of the system call system(), used for debugging and to know if the program we called was not executed correctly\n\n\t}\n\n\telse{\n\n\t\tprintf(\"undefined sensor: %s\\n\",argv[1]);\t\t\t\t\t\t\t//if the sid is not one of the above then print an error message stating that sensor is not defined or used in Arduino.\n\n\t\tcout<<\"--------------------------------------\"<<endl;\n\n\t\treturn 1;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//exit with error flag, server sent an id for a sensor that we didn't use.\n\n\t}\n\n\tcout<<\"--------------------------------------\"<<endl;\n\n\treturn 0;\n\n}\n", "file_path": "Raspberry Pi/Code/respond.cpp", "rank": 69, "score": 7.00406232515822 }, { "content": "\t\n\n\tret = radio.write(&send2,sizeof(char[40]));\n\n\t//radio.startListening();\n\n\tif(ret == false){\n\n\t\tprintf(\"failed to send request to SLV2\\n\");\n\n\t\tlogFile<<\"failed to send request to SLV2\\n\";\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t\t//exit(1);\n\n\t}\n\n\telse{\n\n\t\tprintf(\"read request was sent to SLV2\\n\");\n\n\t\tlogFile<<\"read request was sent to SLV2\\n\";\n\n\t}\n\n\tradio.startListening();\n\n\t\n\n\t// get lightVoltage2\n\n\tcurrent_time = millis();\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 70, "score": 6.916842356329152 }, { "content": "#include \"writewindow.h\"\n\n#include \"ui_writewindow.h\"\n\n#include <sstream>\n\n\n\nWriteWindow::WriteWindow(QWidget *parent) :\n\n QDialog(parent),\n\n ui(new Ui::WriteWindow)\n\n{\n\n ui->setupUi(this);\n\n}\n\n\n\nWriteWindow::~WriteWindow()\n\n{\n\n delete ui;\n\n}\n\n\n\nvoid WriteWindow::on_dial_temp_valueChanged(int value)\n\n{\n\n ui->spinBox_temp->setValue(value);\n\n}\n", "file_path": "Raspberry Pi/GUI raw/writewindow.cpp", "rank": 71, "score": 6.8425284481448605 }, { "content": "\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t}\n\n\t\n\n\telse{\n\n\t\twhile(radio.available()){\n\n\t\t\tradio.read(&incoming,sizeof(char[40])); // arduino should send us ACK if everything is ok NACK if it failed\n\n\t\t}\n\n\t\tprintf(\"incoming: %s\\n\",incoming);\n\n\t\tlogFile<<\"incoming: \"<<incoming<<endl;\n\n\t\t\n\n\t\tnum1 = strcmp(incoming , ACK);\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if the incomming is ACK\n\n\t\tif(num1 != 0){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if incoming is not ACK\n\n\t\t\tnum2 = strcmp(incoming , UC);\t\t\t\t\t\t\t\t\t\t\t\t\t//check to see if it's unknowen command\n\n\t\t\tif(num2 == 0){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if it's unknown command\n\n\t\t\t\tprintf(\"recived \\\"unknown command\\\"\\n\");\n\n\t\t\t\tlogFile<<\"recived \\\"unknown command\\\"\\n\";\n\n\t\t\t}\n", "file_path": "Raspberry Pi/Code/write_door.cpp", "rank": 72, "score": 6.671034474968087 }, { "content": "\t\t//exit(1);\n\n\t\t//goto reset;\n\n\t}\n\n\t//cout<<\"exited water\"<<endl;\n\n\n\n\t\n\n\t//logFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile.close();\n\n\tdanger_slv1 = !gasState || fireState || !waterLeakageState;\n\n\tif(danger_slv1)\n\n\t\tprintf(\"danger in slv1\\n\");\n\n\treturn 0;\n\n}\n\n//---------------------------------------------------------------------------------------------------\n\n//---------------------------------------------------------------------------------------------------\n\n\n\nint readSLV2(int retry){\t//used to read all data from slv2\n\n\tradio.stopListening();\n\n\tradio.closeReadingPipe(1);\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 73, "score": 6.668525866123417 }, { "content": "//---------------------------------------------------- \n\n\n\n// CE , CSN , speed = 8MHZ \n\n//RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ); //physical pin 15 and 24\n\nRF24 radio(22,0); //GPIO22 and CE0\n\nuint8_t pipes[][6] = {\"MSTR\" ,\"SLV1\"};\n\nuint8_t pipes2[][6] = {\"MSTR2\" , \"SLV2\" };\n\n\n\nusing namespace std;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n\nint readSLV(int retry){\n\n\tofstream logFile;\n\n\tlogFile.open(\"safty_readings.log\", ios::app);\n\n\t\n\n\tif(retry != 0){\n\n\t\tif(retry == 4){\n\n\t\t\tlogFile<<\"failed to send request to SLV1 after 4 attempts\\n\";\n\n\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n", "file_path": "Raspberry Pi/Code/collector_get_readings_startup.cpp", "rank": 74, "score": 6.594733260554323 }, { "content": "\t\tlogFile<<ctime(&time_now);\n\n\t\tlogFile<<\"*****************************************\\n\";\n\n\t}\n\n\t\n\n\tprintf(\"server sent on reference: %f\\n\",onRef);\n\n\tlogFile<<\"server sent on reference: \"<<onRef<<endl;\n\n\t\n\n\t//write to arduino\n\n\tprintf(\"sending mode: %s\\n\",ref);\n\n\tlogFile<<\"sending mode: \"<<ref<<endl;\n\n\tradio.write(&ref,sizeof(char[40]));\t\t\t//send request to update reference\n\n\tradio.startListening();\n\n\t\n\n\t\n\n\t//receive from arduino\n\n\ttimeout = false;\n\n\tcurrent_time = millis();\n\n\twhile(!radio.available()){\n\n\t\tif(millis()-current_time > 1000){\t\t\t//wait for 1 second for incominc\n\n\t\t\ttimeout = true;\n", "file_path": "Raspberry Pi/Code/collector_light.cpp", "rank": 75, "score": 6.5216130842433255 }, { "content": "\t\tlogFile<<ctime(&time_now);\n\n\t\tlogFile<<\"*****************************************\\n\";\n\n\t}\n\n\t\n\n\tprintf(\"server sent temperature reference: %f\\n\",tempRef);\n\n\tlogFile<<\"server sent temperature reference: \"<<tempRef<<endl;\n\n\t\n\n\t//write to arduino\n\n\tprintf(\"sending mode: %s\\n\",ref);\n\n\tlogFile<<\"sending mode: \"<<ref<<endl;\n\n\tradio.write(&ref,sizeof(char[40]));\n\n\tradio.startListening();\n\n\t\n\n\t\n\n\t//receive from arduino\n\n\ttimeout = false;\n\n\tcurrent_time = millis();\n\n\twhile(!radio.available()){\n\n\t\tif(millis()-current_time > 1000){ \t\t//wait for a second for arduino to respond\n\n\t\t\ttimeout = true;\n", "file_path": "Raspberry Pi/Code/collector_temp.cpp", "rank": 76, "score": 6.4902540690099375 }, { "content": "\t\treturn 1;\n\n\t}\n\n\t\n\n\t\n\n\t//receive from arduino\n\n\ttimeout = false;\n\n\tcurrent_time = millis();\n\n\twhile(!radio.available()){\n\n\t\tif(millis()-current_time > 400){ //wait for 400ms\n\n\t\t\ttimeout = true;\n\n\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\t\n\n\tif(timeout){\n\n\t\tprintf(\"timeout, failed to receive.\\n\");\n\n\t\tlogFile<<\"timeout, failed to receive.\\n\";\n\n\t\tradio.read(&incoming,sizeof(char[40]));\n\n\t\tprintf(\"in buffer: %s\\n\",incoming);\n\n\t\tlogFile<<\"in buffer: \"<<incoming<<endl;\n", "file_path": "Raspberry Pi/Code/write_tv.cpp", "rank": 77, "score": 6.489018859689162 }, { "content": "\t\n\n\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile<<\"*****************************************\\n\";\n\n\tlogFile.close();\n\n\treturn 0;\n\n}\n\n//---------------------------------------------------------------------------------------------------\n\n//---------------------------------------------------------------------------------------------------\n\n\n\nvoid setGUIReadings(){ //updating the file that GUI program uses to update its readings\n\n\tofstream gui;\t\t//to store readings of SLV1\n\n\tofstream gui2;\t\t//to store readings of SLV2\n\n\tgui.open(\"guiReadings.txt\", ios::in | ios::out);\n\n\tgui2.open(\"guiReadings2.txt\", ios::in | ios::out);\n\n\t//for SLV1\n\n\tgui<<lightVoltage<<endl;\n\n\tgui<<refVoltage<<endl;\n\n\tgui<<gasVoltage<<endl;\n\n\tgui<<lightState<<endl;\n", "file_path": "Raspberry Pi/Code/collector_get_readings_startup.cpp", "rank": 78, "score": 6.474688028520449 }, { "content": " float val_voltage = val_percentag * (5.0/100.0); //the light is represented in this GUI as percentage but the program that called arduino takes the parameter as voltage\n\n stream << \"cd /var/www/html/rpi/ && sudo ./collector_light room1 \"<<val_voltage; //this is pushing the command to a string that will be then sent to the terminal(using system()) to be executed. the first command is changing the current directory to the directory of the program then && to indicate there is another command which calls the write program with the reference we want\n\n system(stream.str().c_str()); //first convert the stream to string [.str()] then convert the string to character array (char[]) [c_str()] because system() only take char[] as a parameter\n\n}\n\n\n\nvoid WriteWindow::on_pushButton_send_temp_clicked()\n\n{\n\n std::stringstream stream;\n\n float val_celsius = ui->spinBox_temp->value();\n\n stream<< \"cd /var/www/html/rpi/ && sudo ./collector_temp room1 \"<<val_celsius;\n\n system(stream.str().c_str());\n\n}\n", "file_path": "Raspberry Pi/GUI raw/writewindow.cpp", "rank": 79, "score": 6.462532985009217 }, { "content": "\n\nReadWindow::ReadWindow(QWidget *parent) :\n\n QDialog(parent),\n\n ui(new Ui::ReadWindow)\n\n{\n\n ui->setupUi(this);\n\n\n\n// QFile data_file(\"/home/pi/Desktop/data_on_zero/New/'C++ GPIO'/nRF24/guiReadings.txt\");\n\n// data_file.open(QIODevice::ReadOnly | QIODevice::Text);\n\n\n\n}\n\n\n\nReadWindow::~ReadWindow()\n\n{\n\n delete ui;\n\n}\n\n\n\nvoid ReadWindow::on_comboBox_currentIndexChanged(int index)\n\n{\n\n if(index == 0){\n", "file_path": "Raspberry Pi/GUI raw/readwindow.cpp", "rank": 80, "score": 6.168903690206259 }, { "content": "\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\t\t\t\t\t\t\t\t\t\t\t//print the total execution time of this program to log file\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n\n\t\t\tlogFile.close();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//close log file\n\n\t\t\treturn 1;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//exit program with error\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\t\t//if not last try print try number in log file\n\n\t\tcout<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\t\t//print the try number to terminal\n\n\t}\n\n\telse{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if this is the first try\n\n\t\tlogFile<<ctime(&time_now);\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//print the calendar time in log file\n\n\t\tlogFile<<\"*****************************************\\n\";\n\n\t}\n\n\t\n\n\tprintf(\"server sent garage State: %d\\n\",garageState);\t\t\t\t\t\t\t\t\t//print the garage state you'll sent, open or close to terminal\n\n\tlogFile<<\"server sent garage State: \"<<garageState<<endl;\t\t\t\t\t\t\t\t//print the garage state you'll sent, open or close to log\n\n\t\n\n\t//write to arduino\n\n\tif(garageState == 0){ //0 measns close the door\t\t\t\t\t\t\t\t\t\t\t//if user wants to close door\n\n\t\tprintf(\"sending mode: %s\\n\",Close);\n", "file_path": "Raspberry Pi/Code/write_door.cpp", "rank": 81, "score": 6.091579641552261 }, { "content": "\t//usleep(3000);\n\n\t//unlink(fifo_name);\n\n}\n\n*/\n\n\n\n\n\nint main(int argc, char* argv[]){\n\n\tint return_slv;\n\n\tbool success = 0;\n\n\t\n\n\tsrand(time(NULL));\t\t\t\t\t\t//set the seed for random (it uses psudorandom), not setting the seed will always gives you the same number\n\n\tid = rand();\t\t\t\t\t\t\t//generate a random number\n\n\tidentifier_str<<\"collector_get_readings\"<<id;\n\nstart:\n\n\tfor(int i =0; i<10; i++){\n\n\t\tstr[i] = \"\";\n\n\t}\n\n\tcount = 0;\n\n myfile.open(\"queue.txt\", ios::in); //open test2 to read\n\n\t\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 82, "score": 5.1761042664247 }, { "content": "\t\n\n\t//receive from arduino\n\n\ttimeout = false;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//reset timeout\n\n\tcurrent_time = millis();\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//get time from begining of execution in ms\n\n\tcout<<\"entered waiting loop for 50 seconds\\n\";\n\n\twhile(!radio.available()){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//wait for 50 seconds for arduino finish execution command and send ACK or NACK\n\n\t\tif(millis()-current_time > 50000){ \t\t\t\t\t\t\t\t\t\t\t\t\t//wait for 50 seconds\n\n\t\t\tprintf(\"50 second passed\\n\");\t\t\t\t\t\t\t\t\t\t\t\t\t//for debugging\n\n\t\t\ttimeout = true;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if 50 second passed without ACK or NACK then set timeout\n\n\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tcout<<\"exited waiting loop\\n\";\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//for debugging\n\n\t\n\n\tif(timeout){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if timeout happend then print what happend to terminal and log file\n\n\t\tprintf(\"timeout, failed to receive.\\n\");\n\n\t\tlogFile<<\"timeout, failed to receive.\\n\";\n\n\t\tradio.read(&incoming,sizeof(char[40]));\n\n\t\tprintf(\"in buffer: %s\\n\",incoming);\n\n\t\tlogFile<<\"in buffer: \"<<incoming<<endl;\n", "file_path": "Raspberry Pi/Code/write_door.cpp", "rank": 83, "score": 4.9607754008183385 }, { "content": " ui->pushButton_refresh->setEnabled(false);\n\n/*\n\n// printf(\"entered condition for change index to 1\\n\");\n\n// system(\"cd /home/pi/Desktop/data_on_zero/New/'C++ GPIO'/nRF24\");\n\n// fifo_state = mkfifo(fifo_name,0666);\n\n\n\n//// if(fifo_state < 0){ //file already exists\n\n//// unlink(fifo_name);//delete the file\n\n//// }\n\n\n\n// fp = fopen(fifo_name , \"r\"); //fopen returns null if error happend, else it returns the pointer\n\n\n\n\n\n//// while(1){\n\n// if(ui->comboBox->currentIndex() != 1){\n\n// printf(\"exiting for if\\n\");\n\n// fclose(fp);\n\n// unlink(fifo_name);\n\n// //break;\n\n// }\n", "file_path": "Raspberry Pi/GUI raw/readwindow.cpp", "rank": 84, "score": 4.908411293754833 }, { "content": "\n\nint main(int argc, char ** argv){\n\n\tint success=0;\n\n\tint return_slv;\n\n\t\n\n\tif(argc < 2){\n\n\t\tprintf(\"wrong command.\\ncommand should be the following: sudo ./write_door <door state>\\n\");\n\n\t\tprintf(\"door state is 0 for close and 1 for open.\\n\");\n\n\t\t//exit(1);\n\n\t\treturn 1;\n\n\t}\n\n\t\n\n\tsrand(time(NULL));\t\t\t\t\t\t//set the seed for random (it uses psudorandom), not setting the seed will always gives you the same number\n\n\tid = rand();\t\t\t\t\t\t\t//generate a random number\n\n\tidentifier_str<<\"write_door\"<<id;\n\n\t//identifier_str.str(\"\");\t\t//for debugging\n\n\t//identifier_str<<\"write_door\"; //for debugging\n\n\t\n\n\tstart:\n\n\tfor(int i =0; i<10; i++){\n", "file_path": "Raspberry Pi/Code/write_door.cpp", "rank": 85, "score": 4.83311943498253 }, { "content": " stream<< \"cd /var/www/html/rpi/ && sudo ./collector_temp hall \"<<val_celsius;\n\n system(stream.str().c_str());\n\n}\n\n\n\nvoid WriteWindow_Hall::on_pushButton_send_light_clicked()\n\n{\n\n std::stringstream stream;\n\n int val_percentag = ui->spinBox_light->value(); //get the value in the spin Box of light\n\n float val_voltage = val_percentag * (5.0/100.0); //the light is represented in this GUI as percentage but the program that called arduino takes the parameter as voltage\n\n stream << \"cd /var/www/html/rpi/ && sudo ./collector_light hall \"<<val_voltage; //this is pushing the command to a string that will be then sent to the terminal(using system()) to be executed. the first command is changing the current directory to the directory of the program then && to indicate there is another command which calls the write program with the reference we want\n\n system(stream.str().c_str());\n\n}\n\n\n\nvoid WriteWindow_Hall::on_dial_temp_valueChanged(int value)\n\n{\n\n ui->spinBox_temp->setValue(value);\n\n}\n\n\n\nvoid WriteWindow_Hall::on_spinBox_temp_valueChanged(int arg1)\n\n{\n", "file_path": "Raspberry Pi/GUI raw/writewindow_hall.cpp", "rank": 86, "score": 4.82006314914322 }, { "content": "\t\tprintf(\"incoming: %s\\n\",incoming);\n\n\t\tlogFile<<\"incoming: \"<<incoming<<endl;\n\n\t\t\n\n\t\tnum1 = strcmp(incoming , ACK);\n\n\t\tif(num1 != 0){\n\n\t\t\tnum2 = strcmp(incoming , UC);\n\n\t\t\tif(num2 == 0){\n\n\t\t\t\tprintf(\"recived \\\"unknown command\\\"\\n\");\n\n\t\t\t\tlogFile<<\"recived \\\"unknown command\\\"\\n\";\n\n\t\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\t\tlogFile.close();\n\n\t\t\t\treturn 1;\n\n\t\t\t}\n\n\t\t\telse{\n\n\t\t\t\tprintf(\"unexpected respond: %s\\n\",incoming);\n\n\t\t\t\tlogFile<<\"unexpected respond: \"<<incoming<<endl;\n\n\t\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\t\tlogFile.close();\n", "file_path": "Raspberry Pi/Code/collector_light.cpp", "rank": 87, "score": 4.73886705510469 }, { "content": "\t\tprintf(\"incoming: %s\\n\",incoming);\n\n\t\tlogFile<<\"incoming: \"<<incoming<<endl;\n\n\t\t\n\n\t\tnum1 = strcmp(incoming , ACK);\n\n\t\tif(num1 != 0){\n\n\t\t\tnum2 = strcmp(incoming , UC);\n\n\t\t\tif(num2 == 0){\n\n\t\t\t\tprintf(\"recived \\\"unknown command\\\"\\n\");\n\n\t\t\t\tlogFile<<\"recived \\\"unknown command\\\"\\n\";\n\n\t\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\t\tlogFile.close();\n\n\t\t\t\treturn 1;\n\n\t\t\t}\n\n\t\t\telse{\n\n\t\t\t\tprintf(\"unexpected respond: %s\\n\",incoming);\n\n\t\t\t\tlogFile<<\"unexpected respond: \"<<incoming<<endl;\n\n\t\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\t\tlogFile.close();\n", "file_path": "Raspberry Pi/Code/collector_temp.cpp", "rank": 88, "score": 4.73886705510469 }, { "content": "\tif(retry != 0){\n\n\t\tif(retry == 4){\n\n\t\t\tlogFile<<\"failed to send request to SLV1 after 4 attempts\\n\";\n\n\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n\n\t\t\tlogFile.close();\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t\tcout<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t}\n\n\telse{\n\n\t\tlogFile<<ctime(&time_now);\n\n\t\tlogFile<<\"*****************************************\\n\";\n\n\t}\n\n\t\n\n\tprintf(\"server sent tv State: %d\\n\",tvState);\n\n\tlogFile<<\"server sent tv State: \"<<tvState<<endl;\n\n\t\n", "file_path": "Raspberry Pi/Code/write_tv.cpp", "rank": 89, "score": 4.691590274560572 }, { "content": "char ref[40] = \"lightReference\";\n\nchar ACK[40] = \"ACK\";\n\nchar NACK[40]= \"NACK\";\n\nchar UC[40] = \"No such command\";\n\nchar incoming[40];\n\nfloat onRef;\n\ntime_t time_now = time(0);\n\n\n\nint current_time;\n\nbool timeout;\n\nint write_success;\n\n\n\nint num1;\n\nint num2;\n\nbool ret = false;\n\nint retry = 0;\n\n\n\n//guard data\n\nint count = 0;\n\nbool inQueue = 0;\n", "file_path": "Raspberry Pi/Code/collector_light.cpp", "rank": 90, "score": 4.6623053726713675 }, { "content": "}\n\n\n\nint loop(int retry){\n\n\tradio.stopListening();\n\n\t\n\n\tofstream logFile;\n\n\tlogFile.open(\"log_server.log\", ios::app);\n\n\tif(retry != 0){\n\n\t\tif(retry == 4){\n\n\t\t\tlogFile<<\"failed to send request to SLV1 after 4 attempts\\n\";\n\n\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n\n\t\t\tlogFile.close();\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t\tcout<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t}\n\n\telse{\n", "file_path": "Raspberry Pi/Code/collector_temp.cpp", "rank": 91, "score": 4.652430571585042 }, { "content": "\n\n\n\nint loop(int retry){\n\n\tradio.stopListening();\n\n\t\n\n\tofstream logFile;\n\n\tlogFile.open(\"log_server.log\", ios::app);\n\n\tif(retry != 0){\n\n\t\tif(retry == 4){\n\n\t\t\tlogFile<<\"failed to send request to SLV1 after 4 attempts\\n\";\n\n\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n\n\t\t\tlogFile.close();\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t\tcout<<\"Reattempting to send request to SLV1. attempt number: \"<<retry<<endl;\n\n\t}\n\n\telse{\n", "file_path": "Raspberry Pi/Code/collector_light.cpp", "rank": 92, "score": 4.652430571585042 }, { "content": "char ref[40] = \"tempReference\";\n\nchar ACK[40] = \"ACK\";\n\nchar NACK[40]= \"NACK\";\n\nchar UC[40] = \"No such command\";\n\nchar incoming[40];\n\nfloat tempRef;\n\ntime_t time_now = time(0);\n\n\n\nint current_time;\n\nbool timeout;\n\nint write_success;\n\n\n\nint num1;\n\nint num2;\n\nbool ret = false;\n\nint retry = 0;\n\n\n\n//guard data\n\nint count = 0;\n\nbool inQueue = 0;\n", "file_path": "Raspberry Pi/Code/collector_temp.cpp", "rank": 93, "score": 4.649139521940034 }, { "content": "\t\tprintf(\"failed to rececive temperature Outside 2 (timeout)\\n\");\n\n\t\tlogFile<<\"failed to rececive temperature Outside 2 (timeout)\\n\";\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t\t//perror(\"failed to rececive temperature Outside 2 (timeout)\\n\");\n\n\t\t//exit(1);\n\n\t\t//goto reset;\n\n\t}\n\n\t\n\n\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile<<\"*****************************************\\n\";\n\n\tlogFile.close();\n\n\tdanger_slv2 = PIRState2;\n\n\tif(danger_slv2)\n\n\t\tcout<<\"danger in slv2 \"<<endl;\n\n\treturn 0;\n\n}\n\n\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 94, "score": 4.641977917447933 }, { "content": "\t//radio.openReadingPipe(2,pipes2[1]);\n\n\tradio.openWritingPipe(pipes2[0]);\n\n\tradio.openReadingPipe(1,pipes2[1]);\n\n\t\n\n\tofstream logFile;\n\n\tlogFile.open(\"safty_readings.log\", ios::app);\n\n\tif(retry != 0){\n\n\t\tif(retry == 4){\n\n\t\t\tlogFile<<\"failed to send request to SLV2\\n\";\n\n\t\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\t\tlogFile<<\"*****************************************\\n\";\n\n\t\t\tlogFile.close();\n\n\t\t\treturn 1;\n\n\t\t}\n\n\t\tlogFile<<\"Reattempting to send request to SLV2. attempt number: \"<<retry<<endl;\n\n\t\tcout<<\"Reattempting to send request to SLV2. attempt number: \"<<retry<<endl;\n\n\t}\n\n\telse\n\n\t\tlogFile<<ctime(&time_now);\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 95, "score": 4.630002665152731 }, { "content": "\t\t\telse if(strcmp(incoming, NACK) == 0){\t\t\t\t\t\t\t\t\t\t\t//if it's NACK\n\n\t\t\t\tprintf(\"recived \\\"NACK\\\", Arduino failed to complete request\\n\");\n\n\t\t\t\tlogFile<<\"recived \\\"NACK\\\", Arduino failed to complete request\\n\";\n\n\t\t\t}\n\n\t\t\telse{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//if it's something else\n\n\t\t\t\tprintf(\"unexpected respond: %s\\n\",incoming);\n\n\t\t\t\tlogFile<<\"unexpected respond: \"<<incoming<<endl;\n\n\t\t\t}\n\n\t\t}\n\n\t\t\n\n\t}\n\n\n\n\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile<<\"*****************************************\\n\";\n\n\tlogFile.close();\n\n\treturn 0;\n\n\t\n\n}\n\n\n", "file_path": "Raspberry Pi/Code/write_door.cpp", "rank": 96, "score": 4.616755043665703 }, { "content": "\t//logFile<<\"runtime: \"<<clock()<<endl;\n\n\tlogFile<<\"-----------------------------------------\\n\";\n\n\tlogFile.close();\n\n\treturn 0;\n\n}\n\n//---------------------------------------------------------------------------------------------------\n\n//---------------------------------------------------------------------------------------------------\n\n\n\nint readSLV2(int retry){\n\n\tradio.stopListening();\n\n\tradio.closeReadingPipe(1);\n\n\t//radio.openReadingPipe(2,pipes2[1]);\n\n\tradio.openWritingPipe(pipes2[0]);\n\n\tradio.openReadingPipe(1,pipes2[1]);\n\n\t\n\n\tofstream logFile;\n\n\tlogFile.open(\"safty_readings.log\", ios::app);\n\n\tif(retry != 0){\n\n\t\tif(retry == 4){\n\n\t\t\tlogFile<<\"failed to send request to SLV2\\n\";\n", "file_path": "Raspberry Pi/Code/collector_get_readings_startup.cpp", "rank": 97, "score": 4.452825558971234 }, { "content": " string line_;\n\n QString line;\n\n for(int linenum = 0; linenum <= 11 ; linenum ++){\n\n getline(data_file_h,line_);\n\n line = QString::fromStdString(line_); //convert string to Qstring cuz label only accepts Qsting (stupid rule qt!!)\n\n //cout<<line_<<endl;\n\n switch (linenum){\n\n case 0:\n\n ui->label_photo_resistor_volt->setText(line);\n\n break;\n\n case 1:\n\n ui->label_photo_resistor_ref->setText(line);\n\n\n\n break;\n\n case 2:\n\n ui->label_light_state->setText(line);\n\n\n\n break;\n\n case 3:\n\n ui->label_room_temp->setText(line);\n", "file_path": "Raspberry Pi/GUI raw/readwindow_hall.cpp", "rank": 98, "score": 4.408003705775075 }, { "content": "\t\tlogFile<<\"failed to send request to SLV1\\n\";\n\n\t\tlogFile<<\"runtime: \"<<clock()<<endl;\n\n\t\tlogFile<<\"-----------------------------------------\\n\";\n\n\t\tlogFile.close();\n\n\t\treturn 1;\n\n\t\t//exit(1);\n\n\t}\n\n\telse{\n\n\t\tprintf(\"read request was sent to SLV1\\n\");\n\n\t\tlogFile<<\"read request was sent to SLV1\\n\";\n\n\t}\n\n\tradio.startListening();\n\n\t//reset:\n\n\t\n\n\t// get lightVoltage\n\n\tcurrent_time = millis();\n\n\ttimeout = false;\n\n\twhile(!radio.available()){\n\n\t\tif(millis() - current_time > 500){\t\t\t\t//wait for 500ms to receive from arduino\n\n\t\t\ttimeout = true;\n", "file_path": "Raspberry Pi/Code/collector_get_readings.cpp", "rank": 99, "score": 4.36500299953752 } ]
C++
src/canoe/phrasetable_filter_joint.cc
nrc-cnrc/Portage-SMT-TAS
73f5a65de4adfa13008ea9a01758385c97526059
#include "phrasetable_filter_joint.h" #include "soft_filter_tm_visitor.h" #include "hard_filter_tm_visitor.h" #include "logging.h" using namespace Portage; Logging::logger ptLogger_filter_joint(Logging::getLogger("debug.canoe.phraseTable_filter_joint")); PhraseTableFilterJoint::PhraseTableFilterJoint(bool limitPhrases, VocabFilter &tgtVocab, const pruningStyle* const pruning_style, const string& pruningTypeStr, const vector<double>& forwardWeights, const vector<double>& transWeights, bool tm_hard_limit, bool appendJointCounts) : Parent(limitPhrases, tgtVocab, pruningTypeStr, appendJointCounts) , visitor(NULL) , tgtTable(NULL) , pruning_style(pruning_style) , online_filter_output(NULL) { assert(pruning_style); if (tm_hard_limit) { visitor = new Joint_Filtering::hardFilterTMVisitor(*this, log_almost_0, pruningTypeStr, forwardWeights, transWeights); } else { visitor = new Joint_Filtering::softFilterTMVisitor(*this, log_almost_0, pruningTypeStr); } assert(visitor); LOG_VERBOSE1(ptLogger_filter_joint, "Creating/Using PhraseTableFilterJoint %s mode", visitor->style.c_str()); } PhraseTableFilterJoint::~PhraseTableFilterJoint() { if (online_filter_output) delete online_filter_output; online_filter_output = NULL; if (visitor) delete visitor; visitor = NULL; if (tgtTable) delete tgtTable; tgtTable = NULL; } void PhraseTableFilterJoint::outputForOnlineProcessing(const string& filtered_TM_filename) { online_filter_output = new oSafeMagicStream(filtered_TM_filename); assert(online_filter_output); tgtTable = new TargetPhraseTable; assert(tgtTable); LOG_VERBOSE2(ptLogger_filter_joint, "Setting output for online processing: %s, %s", filtered_TM_filename.c_str(), pruning_style->description().c_str()); } float PhraseTableFilterJoint::convertFromRead(float value) const { return value; } float PhraseTableFilterJoint::convertToWrite(float value) const { return value; } void PhraseTableFilterJoint::filter(const string& filtered_TM_filename) { assert(visitor); assert(pruning_style); LOG_VERBOSE2(ptLogger_filter_joint, "Applying %s filter_joint to: %s, pruningStyle=%s, n=%d", visitor->style.c_str(), filtered_TM_filename.c_str(), pruning_style->description().c_str(), numTextTransModels); visitor->set(pruning_style, numTextTransModels); visitor->numKeptEntry = 0; textTable.traverse(*visitor); oSafeMagicStream multi(filtered_TM_filename); write(multi); fprintf(stderr, "There are %d entries left after applying %s filtering\n", visitor->numKeptEntry, visitor->style.c_str()); visitor->display(cerr); } Uint PhraseTableFilterJoint::processTargetPhraseTable(const string& src, Uint src_word_count, TargetPhraseTable* tgtTable) { assert(visitor); if (!tgtTable) return 0; if (!online_filter_output) return 0; assert(pruning_style); const Uint L = (*pruning_style)(src_word_count); LOG_VERBOSE3(ptLogger_filter_joint, "Online processing of one entry (%s) L=%d n=%d", visitor->style.c_str(), L, tgtTable->begin()->second.backward.size()); const Uint numBeforeFiltering(tgtTable->size()); visitor->set(L, tgtTable->begin()->second.backward.size()); (*visitor)(*tgtTable); write(*online_filter_output, src, *tgtTable); const Uint numKeptEntry(tgtTable->size()); tgtTable->clear(); return numBeforeFiltering - numKeptEntry; } TargetPhraseTable* PhraseTableFilterJoint::getTargetPhraseTable(PhraseTableEntry& entry, bool limitPhrases) { if (!online_filter_output || tgtVocab.getNumSourceSents() > 0) { return PhraseTable::getTargetPhraseTable(entry, limitPhrases); } else { assert(tgtTable); tgtTable->clear(); return tgtTable; } }
#include "phrasetable_filter_joint.h" #include "soft_filter_tm_visitor.h" #include "hard_filter_tm_visitor.h" #include "logging.h" using namespace Portage; Logging::logger ptLogger_filter_joint(Logging::getLogger("debug.canoe.phraseTable_filter_joint")); PhraseTableFilterJoint::PhraseTableFilterJoint(bool limitPhrases, VocabFilter &tgtVocab, const pruningStyle* const pruning_style, const string& pruningTypeStr, const vector<double>& forwardWeights, const vector<double>& transWeights, bool tm_hard_limit, bool appendJointCounts) : Parent(limitPhrases, tgtVocab, pruningTypeStr, appendJointCounts) , visitor(NULL) , tgtTable(NULL) , pruning_style(pruning_style) , online_filter_output(NULL) { assert(pruning_style); if (tm_hard_limit) { visitor = new Joint_Filtering::hardFilterTMVisitor(*this, log_almost_0, pruningTypeStr, forwardWeights, transWeights); } else { visitor = new Joint_Filtering::softFilterTMVisitor(*this, log_almost_0, pruningTypeStr); } assert(visitor); LOG_VERBOSE1(ptLogger_filter_joint, "Creating/Using PhraseTableFilterJoint %s mode", visitor->style.c_str()); } PhraseTableFilterJoint::~PhraseTableFilterJoint() { if (online_filter_output) delete online_filter_output; online_filter_output = NULL; if (visitor) delete visitor; visitor = NULL; if (tgtTable) delete tgtTable; tgtTable = NULL; } void PhraseTableFilterJoint::outputForOnlineProcessing(const string& filtered_TM_filename) { online_filter_output = new oSafeMagicStream(filtered_TM_filename); assert(online_filter_output); tgtTable = new TargetPhraseTable; assert(tgtTable); LOG_VERBOSE2(ptLogger_filter_joint, "Setting output for online processing: %s, %s", filtered_TM_filename.c_str(), pruning_style->description().c_str()); } float PhraseTableFilterJoint::convertFromRead(float value) const { return value; } float PhraseTableFilterJoint::convertToWrite(float value) const { return value; } void PhraseTableFilterJoint::filter(const string& filtered_TM_filename) { assert(visitor); assert(pruning_style); LOG_VERBOSE2(ptLogger_filter_joint, "Applying %s filter_joint to: %s, pruningStyle=%s, n=%d", visitor->style.c_str(), filtered_TM_filename.c_str(), pruning_style->description().c_str(), numTextTransModels); visitor->set(pruning_style, numTextTransModels); visitor->numKeptEntry = 0; textTable.traverse(*visitor); oSafeMagicStream multi(filtered_TM_filename); write(multi); fprintf(stderr, "There are %d entries left after applying %s filtering\n", visitor->numKeptEntry, visitor->style.c_str()); visitor->display(cerr); } Uint PhraseTableFilterJoint::processTargetPhraseTable(const string& src, Uint src_word_count, TargetPhraseTable* tgtTable) { assert(visitor); if (!tgtTable) return 0; if (!online_filter_output) return 0; assert(pruning_style); const Uint L = (*pruning_style)(src_word_count);
; const Uint numBeforeFiltering(tgtTable->size()); visitor->set(L, tgtTable->begin()->second.backward.size()); (*visitor)(*tgtTable); write(*online_filter_output, src, *tgtTable); const Uint numKeptEntry(tgtTable->size()); tgtTable->clear(); return numBeforeFiltering - numKeptEntry; } TargetPhraseTable* PhraseTableFilterJoint::getTargetPhraseTable(PhraseTableEntry& entry, bool limitPhrases) { if (!online_filter_output || tgtVocab.getNumSourceSents() > 0) { return PhraseTable::getTargetPhraseTable(entry, limitPhrases); } else { assert(tgtTable); tgtTable->clear(); return tgtTable; } }
LOG_VERBOSE3(ptLogger_filter_joint, "Online processing of one entry (%s) L=%d n=%d", visitor->style.c_str(), L, tgtTable->begin()->second.backward.size())
call_expression
[ { "content": "struct null_deleter\n\n{\n\n void operator()(T const *) const {}\n\n};\n\n\n\n\n\nptr_FF FeatureFunctionSet::create(const string& name,\n\n const string& arg,\n\n const char* fileff_prefix,\n\n bool isDynamic,\n\n bool useNullDeleter,\n\n bool loadModels)\n\n{\n\n FeatureFunction* ff;\n\n\n\n if (name == \"FileFF\") {\n\n const string fileff_arg = fileff_prefix ? fileff_prefix + arg : arg;\n\n // TODO what happens when we have /path/ff.file.arg, where does the prefix fit?\n\n // now it will yield fileff_prefix/path/ff.file.arg\n\n\n", "file_path": "src/rescoring/featurefunction_set.cc", "rank": 0, "score": 183710.84024388317 }, { "content": " class hash<const char*>\n\n {\n\n public:\n\n /// Generate a hash value for a c string\n\n std::size_t operator()(const char* s) const {\n\n // Stable - this is part of the documented interface for\n\n // boost::hash, and what boost::hash<std::string> uses.\n\n return boost::hash_range(s, s+strlen(s));\n\n\n\n // Yuk - memory allocation crazy\n\n //return hash<std::string>()(s);\n\n\n\n // Yuk, uses internals of implementation\n\n //return _Fnv_hash<>::hash(s, strlen(s));\n\n\n\n // Yuk, still uses obsolete headers\n\n //return __gnu_cxx::hash<const char*>()(s);\n\n }\n\n };\n\n } // tr1\n", "file_path": "src/utils/string_hash.h", "rank": 1, "score": 166121.3818762853 }, { "content": "class Mode(object):\n\n none = 0\n\n train = 1\n\n trans = 2\n", "file_path": "src/rescoring/rescore.py", "rank": 2, "score": 165276.28000673527 }, { "content": " ostream& toJSON(ostream& out) const;\n", "file_path": "src/canoe/marked_translation.h", "rank": 3, "score": 165260.0629141478 }, { "content": "sub logValue { # get/set field values\n\n my ($log, $field, $value)=@_;\n\n # This is sometimes called between lockLog() and unlockLog(), not allowed to die.\n\n #die \"Error: Invalid log field name $field\" unless exists $log->{$field};\n\n $log->{$field} = $value if defined $value;\n\n return $log->{$field};\n\n}\n\n\n", "file_path": "src/utils/plog.pl", "rank": 4, "score": 162515.69684889022 }, { "content": " vector< pair<string,string> > attr_vals; ///< list of attribute/value pairs.\n", "file_path": "src/utils/parse_xmlish_markup.h", "rank": 5, "score": 161738.6485572184 }, { "content": " # param src_string: input to translate\n\n # param context: model to use for translation\n\n # param newline: what is the interpretation of newline in the input\n\n # param xtags: Transfer tags\n\n # param useCE: Should we use confidence estimation?\n\n public function translate($src_string, $context, $newline, $xtags, $useCE)\n\n {\n\n #$this->checkIsThisXML($src_string);\n\n if (!isset($newline))\n\n throw new SoapFault(\"PortageBadArgs\", \"You must defined newline.\\n\"\n\n . \"Allowed newline types are: s, p or w\");\n\n\n\n if (!($newline == \"s\" or $newline == \"p\" or $newline == \"w\"))\n\n throw new SoapFault(\"PortageBadArgs\", \"Illegal newline type \" . $newline\n\n . \"\\nAllowed newline types are: s, p or w\");\n\n\n\n $i = $this->getContextInfo($context);\n\n $this->validateContext($i, $useCE);\n\n\n\n $options = \" -verbose\";\n\n $options .= ($useCE ? \" -with-ce\" : \" -decode-only\");\n\n $options .= ($xtags ? \" -xtags\" : \"\");\n\n $options .= \" -nl=\" . $newline;\n\n\n\n # PTGSH-197\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 6, "score": 154187.18040418238 }, { "content": "// Predicate to compare an edge's inside-outside score to some pre-determined threshold\n\nstruct inOutThreshold : public std::unary_function<const LatticeEdge&,bool>\n\n{\n\nprivate:\n\n const double threshold;\n\n const map<Uint,double>& inOutScores;\n\npublic:\n\n inOutThreshold(const map<Uint,double>& inOut,double thresh)\n\n :threshold(thresh), inOutScores(inOut){}\n\n bool operator () (const LatticeEdge& value) {\n\n map<Uint,double>::const_iterator it = inOutScores.find(value.id());\n\n assert (it!=inOutScores.end());\n\n return it->second + 1e-12 >= threshold;\n\n }\n\n};\n\n\n\ntemplate<typename Pred>\n\nUint\n\nSimpleOverlay::\n\nprint_lattice( ostream& file, PrintFunc & print, Pred pred)\n\n{\n", "file_path": "src/canoe/simple_overlay.cc", "rank": 7, "score": 152110.88975092818 }, { "content": "// Always true predicate, for when we want to print the entire lattice\n\nstruct alwaysTrue : public std::unary_function<const LatticeEdge&,bool>\n\n{\n\n bool operator () (const LatticeEdge& value) {return true;}\n\n};\n\n\n", "file_path": "src/canoe/simple_overlay.cc", "rank": 8, "score": 149159.68544529332 }, { "content": "struct null_deleter\n\n{\n\n /// Fakes deletion of a pointer.\n\n void operator()(T const *) const {}\n\n};\n\n\n\ndouble writeWordGraph(ostream *out, ostream *covout, PrintFunc &print,\n\n const vector<DecoderState *> &finalStates, bool backwards, bool bMasse)\n\n{\n\n assert(!finalStates.empty());\n\n double dMasseTotale(0.0f);\n\n SEEN stateMap(maxID(finalStates)+1);\n\n // inline factory for MasseVu\n\n MasseVu_ptr mv(bMasse ? new MasseVu : static_cast<MasseVu*>(0), null_deleter<MasseVu>());\n\n if (out) {\n\n if (backwards) {\n\n *out << \"0\\n\";\n\n } else {\n\n *out << \"FINAL\\n\";\n\n }\n", "file_path": "src/canoe/wordgraph.cc", "rank": 9, "score": 138543.93829906252 }, { "content": " # This function would be nice to use but we have case aka \"a<1>b</1>\" is not\n\n # valid xml since tag aren't allowed to start with digits.\n\n private function checkIsThisXML($string)\n\n {\n\n $test = \"<?xml version='1.0'\" . \"?\" . \">\\n<document>\" . $string . \"</document>\";\n\n #$test = \"<document>\" . $string . \"</document>\";\n\n if (simplexml_load_string($test) == FALSE) {\n\n throw new SoapFault(\"PortageNotXML\", \"This is invalid xml.\\n\"\n\n . htmlspecialchars($string) . htmlspecialchars($test));\n\n }\n\n }\n\n\n\n\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 10, "score": 134649.24068178044 }, { "content": " class const_value_iterator {\n\n private:\n\n const uint32_t* value; //< What key/value is this iterator pointing at.\n\n const MMMap& map; //< A reference to the map to be able to retrieve the key/value.\n\n public:\n\n /**\n\n * Default constructor.\n\n *\n\n * @param e the entry that the iterator is pointing at.\n\n * @param map the map that the e points into.\n\n */\n\n const_value_iterator(const uint32_t* v, const MMMap& map)\n\n : value(v)\n\n , map(map)\n\n {\n\n assert(value != NULL);\n\n }\n\n\n\n const char* const operator*() const {\n\n return map.getValue(*value);\n", "file_path": "src/utils/mm_map.h", "rank": 11, "score": 133632.16824839468 }, { "content": "namespace Portage {\n\n\n\n/**\n\n * Watches, in the background, for the presence of a pid, if not present, does a\n\n * exit(45).\n\n * NOTE: this function will start a thread and return immediately.\n\n * WARNING: the variable containing the pid must exist long enough for the\n\n * thread to start and read the value. This is why the pid is passed as const\n\n * reference to this function.\n\n * @param pid the pid to look for.\n\n */\n\nvoid process_bind(pid_t& pid);\n\n\n", "file_path": "src/utils/process_bind.h", "rank": 12, "score": 131479.94416984735 }, { "content": " class hash<std::string>\n\n {\n\n public:\n\n /**\n\n * Generates a hash value for a string\n\n * @param s string to hash\n\n * @return Returns a hash value for s\n\n */\n\n unsigned int operator()(const std::string &s) const {\n\n return hash<const char *>()(s.c_str());\n\n } // operator()\n\n }; // hash<string>\n\n} // __gnu_cxx\n\n\n\nnamespace Portage {\n\n // Import hash_map and hash from __gnu_cxx namespace into Portage namespace\n\n using __gnu_cxx::hash_map;\n\n using __gnu_cxx::hash;\n\n\n\n /**\n", "file_path": "src/utils/string_hash.h", "rank": 13, "score": 130484.8650281337 }, { "content": "# Return the small value between two.\n\nsub min ($$) { return $_[0] <= $_[1] ? $_[0] : $_[1] }\n\n\n\n\n\nuse Getopt::Long;\n\n# Note to programmer: Getopt::Long automatically accepts unambiguous\n\n# abbreviations for all options.\n\nmy $verbose = 1;\n\nGetOptions(\n\n help => sub { usage },\n\n verbose => sub {$VERBOSE=\"-v\" },\n\n debug => \\$DEBUG,\n\n\n\n n => \\$NOEXEC,\n\n F => \\$FORCE_OVERWRITE,\n\n\n\n w => sub { $WORDFEAT = \"-w\" },\n\n\n\n \"s=s\" => \\$SPROXY,\n\n \"p=s\" => \\$PREF,\n\n \"a=s\" => \\$ALIGFILE,\n", "file_path": "src/rescoring/gen-features-parallel.pl", "rank": 14, "score": 128443.99845903747 }, { "content": "sub process($$$$) {\n\n my ($nbest, $ffvals, $addnbest, $addffvals) = @_;\n\n print STDERR \"Appending $nbest, $ffvals, $addnbest, $addffvals\\n\" if ($debug);\n\n for ( $nbest, $ffvals, $addnbest, $addffvals ) {\n\n defined $_ or die \"Error: append-uniq.pl: -nbest, -ffvals, -addnbest and -addffvals are all required.\\n\";\n\n -r $_ or die \"Error: append-uniq.pl: Can't open $_ for reading: $!\\n\";\n\n }\n\n\n\n open(NBEST, \"gzip -cqfd $nbest |\") or die \"Error: Can't open $nbest for reading: $!\\n\";\n\n open(FFVALS, \"gzip -cqfd $ffvals |\") or die \"Error: Can't open $ffvals for reading: $!\\n\";\n\n\n\n# hash of hashes: $seen{$line1}{$line2} exists if $line1 exists in $file1 at\n\n# the same position as $line2 in $file2.\n\n my %seen;\n\n my $iniLine = 0;\n\n my $iniDup = 0;\n\n my $n;\n\n my $f;\n\n while (defined($n = <NBEST>) and defined($f = <FFVALS>)) {\n\n chomp($n);\n", "file_path": "src/textutils/append-uniq.pl", "rank": 15, "score": 128429.84826454395 }, { "content": "namespace Portage {\n\n/// Namespace to hold all relevant code to joint filtering\n\nnamespace Joint_Filtering {\n\n/**\n\n * Interface of a callable entity for soft and hard filtering of phrase tables\n\n */\n\nstruct filterTMVisitor : private NonCopyable\n\n{\n\n /**\n\n * Yet another PhraseInfo which will be used for filter_joint.\n\n */\n\n struct PhraseInfo4filtering : public PhraseInfo\n\n {\n\n /// holds a pointer to the entry this was constructed from to later,\n\n /// during filter_joint, rewrite the original object.\n\n const pair<const Phrase, TScore>* ref;\n\n\n\n /**\n\n * Default constructor.\n\n * Keeps a pointer to the original object since after filter_joint, we\n\n * will need the original to rewrite a reduced target table.\n\n * @param ref reference on the original object used to construct this\n\n */\n\n PhraseInfo4filtering(const pair<const Phrase, TScore>* ref)\n\n : ref(ref)\n\n { assert(ref); }\n\n\n\n /**\n\n * Converts probs to their log values.\n\n * @param convertedProbs returned log probs\n\n * @param originalProbs orignal probs\n\n * @param numTextTransModels number of text translation models. We need\n\n * this information since not all entries have the same size, we need to\n\n * make them the same size=> the same number of probs for each (forward\n\n * and/or backward).\n\n * @param log_almost_0 user defined 0\n\n */\n\n void MakeLogProbs(vector<float>& convertedProbs, const vector<float>& originalProbs,\n\n Uint numTextTransModels, double log_almost_0) const\n\n {\n\n // EJJ Nov 2010: the following assertion is no longer appropropriate,\n\n // since we now allow multi prob tables with empty 3rd columns.\n\n //assert(originalProbs.size() > 0);\n\n convertedProbs.resize(numTextTransModels, log_almost_0);\n\n for (Uint i(0); i<originalProbs.size(); ++i) {\n\n if (originalProbs[i] <= 0.0f)\n\n convertedProbs[i] = log_almost_0;\n\n else\n\n convertedProbs[i] = log(originalProbs[i]);\n\n }\n\n }\n\n\n\n /**\n\n * Prints the content of this for debugging purpose.\n\n * @param index since this refers to one entry in the target table, we print its index\n\n */\n\n void print(Uint index) const {\n\n cerr << index << \" | \";\n\n copy(forward_trans_probs.begin(), forward_trans_probs.end(), ostream_iterator<double>(cerr, \" \"));\n\n cerr << \"| \";\n\n copy(phrase_trans_probs.begin(), phrase_trans_probs.end(), ostream_iterator<double>(cerr, \" \"));\n\n cerr << \"| \";\n\n cerr << forward_trans_prob << \" | \" << phrase_trans_prob << \" | \";\n\n copy(phrase.begin(), phrase.end(), ostream_iterator<Uint>(cerr, \" \"));\n\n cerr << endl;\n\n }\n\n };\n\n\n\n const PhraseTable &parent; ///< parent PhraseTable object\n\n Uint L; ///< filtering length\n\n const PhraseTable::PhraseScorePairLessThan phraseLessThan; ///< to order item for dynamic filtering algo\n\n const PhraseTable::PhraseScorePairGreaterThan phraseGreaterThan; ///< to order item for dynamic filtering algo\n\n Uint numTextTransModels; ///< number of text translation models, known after all models were loaded\n\n const double log_almost_0; ///< log(0), almost\n\n const string style; ///< Should indicate hard or soft filtering\n\n Uint numKeptEntry; ///< Keeps track of how many entries were kept\n\n\n\n /// reference on the pruning style.\n\n const pruningStyle* pruning_style;\n\n\n\n /// Gathers stats on number leaves and number of entries per leaves.\n\n SimpleHistogram<Uint>* stats_unfiltered;\n\n /// Gathers stats on number leaves and number of entries per leaves.\n\n SimpleHistogram<Uint>* stats_filtered;\n\n\n\n /**\n\n * Default constructor.\n\n * @param parent phrase table from which the leaf is filtered from.\n\n * @param log_almost_0 value of what will be considered log(-0)\n\n * @param style a string representing the derived class type for generic msg printing\n\n */\n\n filterTMVisitor(const PhraseTable &parent, double log_almost_0, const string& style)\n\n : parent(parent)\n\n , L(0)\n\n , phraseLessThan()\n\n , phraseGreaterThan()\n\n , numTextTransModels(0)\n\n , log_almost_0(log_almost_0)\n\n , style(style)\n\n , numKeptEntry(0)\n\n , pruning_style(NULL)\n\n , stats_unfiltered(NULL)\n\n , stats_filtered(NULL)\n\n {}\n\n\n\n virtual ~filterTMVisitor()\n\n {\n\n if (stats_unfiltered) delete stats_unfiltered;\n\n if (stats_filtered) delete stats_filtered;\n\n }\n\n\n\n /**\n\n * Simply sets the pruning style and the number of text translation models.\n\n * @param _pruning_style pruning style.\n\n * @param n number of text translation models.\n\n */\n\n void set(const pruningStyle* const _pruning_style, Uint n)\n\n {\n\n pruning_style = _pruning_style;\n\n set(Uint(0), n);\n\n }\n\n\n\n /**\n\n * Simply sets the limit and the number of text translation models.\n\n * @param Limit filtering length\n\n * @param n number of text translation models.\n\n */\n\n void set(Uint Limit, Uint n)\n\n {\n\n L = Limit;\n\n numTextTransModels = n;\n\n\n\n if (stats_unfiltered) delete stats_unfiltered;\n\n stats_unfiltered = new SimpleHistogram<Uint>(new fixBinner(300));\n\n assert(stats_unfiltered);\n\n\n\n if (stats_filtered) delete stats_filtered;\n\n stats_filtered = new SimpleHistogram<Uint>(new fixBinner(30));\n\n assert(stats_filtered);\n\n }\n\n\n\n /**\n\n * Displays the histogram values of before filtering and after filtering.\n\n * @param out where to output the histograms\n\n */\n\n void display(ostream& out) const\n\n {\n\n out << \"Histogram before filtering\" << endl;\n\n stats_unfiltered->display(out, \" \");\n\n out << \"Histogram after filtering\" << endl;\n\n stats_filtered->display(out, \" \");\n\n }\n\n\n\n /**\n\n * Transforms the phraseTable in a visitor to filter \"30\" the trie leaves.\n\n * Gets called by trie_node.traverse.\n\n * @param key_stack representation of the trie key\n\n * @param tgtTable leaf of the trie to filter\n\n */\n\n void operator()(const vector<Uint>& key_stack, TargetPhraseTable& tgtTable)\n\n {\n\n // There is no need to process an empty leaf.\n\n if (tgtTable.empty()) return;\n\n\n\n // DEBUGGING\n\n //copy(key_stack.begin(), key_stack.end(), ostream_iterator<Uint>(cerr, \" \")); cerr << endl;\n\n\n\n // Gather stats of unfiltered leaves\n\n stats_unfiltered->add(tgtTable.size());\n\n\n\n // Calculate the proper L for the given source phrase.\n\n if (pruning_style != NULL) {\n\n L = (*pruning_style)(key_stack.size());\n\n }\n\n\n\n operator()(tgtTable);\n\n numKeptEntry += tgtTable.size();\n\n\n\n // Gather stats of filtered leaves\n\n stats_filtered->add(tgtTable.size());\n\n }\n\n\n\n /**\n\n * Transforms the phraseTable in a visitor to filter \"30\" the trie leaves.\n\n * @param tgtTable leaf of the trie to filter\n\n */\n\n virtual void operator()(TargetPhraseTable& tgtTable) = 0;\n", "file_path": "src/canoe/filter_tm_visitor.h", "rank": 16, "score": 128090.16829600855 }, { "content": "#!/usr/bin/env python2\n\n# -*- coding: utf-8 -*- \n\n\n\n# @file apply_ar_tweet_oov_rules.py\n\n# @brief Apply new Arabic tweet preprocessing rules to raw Arabic OOVs.\n\n#\n\n# @author Darlene A. Stewart\n\n#\n\n# Traitement multilingue de textes / Multilingual Text Processing\n\n# Tech. de l'information et des communications / Information and Communications Tech.\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2016, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2016, Her Majesty in Right of Canada\n\n\n\n\"\"\"\n\nThis script applies rules to transform OOVs found in Arabic tweet data into\n\nproper Arabic text.\n\n\n\napply_ar_tweet_oov_rules.py implements a refined set of rules. This updated set\n\nof rules was defined based on an analysis of applying the previous implementation\n\n(rules_tagger_fixed.py) and Norah Alkharashi's analysis of the application\n\nof Mo Al-Digeil's original implementation (rules_tagger_old.py) to OOVs\n\nobtained from a set of Arabic tweets.\n\n\n\nThis script can be used to aid in assessing the effectiveness of the rules in\n\naddressing problems found in Arabic tweets and reducing the number of OOVs.\n\n\"\"\"\n\n\n\nfrom __future__ import print_function, unicode_literals, division, absolute_import\n\n\n\nimport sys\n\nfrom argparse import ArgumentParser, FileType\n\nimport codecs\n\nimport re\n\nimport os\n\nimport subprocess\n\nimport json\n\n\n\n# Make sure the location of portage_utils is in your PYTHONPATH.\n\nfrom portage_utils import *\n\n\n\ndef get_args():\n\n \"\"\"Command line argument processing.\"\"\"\n\n\n\n usage=\"apply_ar_tweet_oov_rules.py [options] [infile [outfile]]\"\n\n help=\"\"\"\n\n Apply Arabic tweet preprocessing rules to Arabic OOVs in either the original\n\n Arabic text or buckwalter transliterated text.\n\n \n\n The script can also produce a rules output file in which each OOV is\n\n identified by word count, each rule applied is identified by the rule ID,\n\n and both the original and transformed text are output.\n\n \"\"\"\n\n\n\n # Use the argparse module, not the deprecated optparse module.\n\n parser = ArgumentParser(usage=usage, description=help, add_help=False)\n\n\n\n # Use our standard help, verbose and debug support.\n\n parser.add_argument(\"-h\", \"-help\", \"--help\", action=HelpAction)\n\n parser.add_argument(\"-v\", \"--verbose\", action=VerboseAction)\n\n parser.add_argument(\"-d\", \"--debug\", action=DebugAction)\n\n\n\n translit = parser.add_mutually_exclusive_group()\n\n translit.add_argument('-bw', '--buckwalter', dest=\"buckwalter\",\n\n action='store_true', default=True,\n\n help=\"Select buckwalter transliteration. [True]\")\n\n translit.add_argument('-ar', '--arabic', dest=\"buckwalter\",\n\n action='store_false', default=True,\n\n help=\"Select raw Arabic text. [False]\")\n\n\n\n parser.add_argument(\"-oov\", \"-t\", \"--oovtags\", dest=\"oov_tags\",\n\n action='store_true', default=False,\n\n help='''OOVs are marked up in the input by XML tags,\n\n i.e.<oov>oov-phrase</oov>. OOV tags are removed in\n\n the output. [%(default)s]''')\n\n\n\n parser.add_argument(\"-r\", \"--rules\", dest=\"rulesfile\", nargs='?',\n\n type=FileType('w'), const=sys.stderr, default=None,\n\n help='''File to output applied rules info to.\n\n [None if no option, sys.stderr if no filename]''')\n\n\n\n parser.add_argument(\"-m\", \"--map\", dest=\"mapfile\", type=str, default=None,\n\n help='''MADA Map file to use with -bw.\n\n [search plugins + PERL5LIB for tokenize/Arabic/Data.pm]''')\n\n\n\n # The following use the portage_utils version of open to open files.\n\n parser.add_argument(\"infile\", nargs='?', type=open, default=sys.stdin,\n\n help=\"input file [sys.stdin]\")\n\n parser.add_argument(\"outfile\", nargs='?', type=lambda f: open(f,'w'),\n\n default=sys.stdout,\n\n help=\"output file [sys.stdout]\")\n\n\n\n cmd_args = parser.parse_args()\n\n\n\n return cmd_args\n\n\n\nword2morpho = {} # Name chosen to parallel Perl code usage.\n\n\n\ndef loadMappingData(mapfile):\n\n \"\"\"Loaded the MADA Map data from the specified file or the Perl\n\n tokenize/Arabic/Data.pm module.\n\n\n\n mapfile: MADA Map file pathname; None triggers searching the plugins and\n\n PERL5LIB for tokenize/Arabic/Data.pm. If the mapfile ends in '.json' then\n\n it is treated as a pure JSON file, not a Perl module with a __Data__ tag.\n\n \"\"\"\n\n global word2morpho\n\n if mapfile is None:\n\n # First look for the map relative to the plugins location, then in PERL5LIB\n\n which_cmd = 'which tokenize_plugin_ar 2> /dev/null; exit 0'\n\n perl5lib = [os.path.dirname(subprocess.check_output(which_cmd, shell=True))]\n\n perl5lib += os.environ['PERL5LIB'].split(':')\n\n for libdir in perl5lib:\n\n if not libdir: continue\n\n mapfile = os.path.join(libdir, \"tokenize\", \"Arabic\", \"Data.pm\")\n\n if os.path.exists(mapfile):\n\n break\n\n else:\n\n error(\"tokenize/Arabic/Data.pm module not found.\")\n\n else:\n\n if mapfile == '/dev/null':\n\n info(\"Not using MADA Map (/dev/null).\")\n\n return\n\n info(\"Using MADA Map:\", mapfile)\n\n if mapfile.endswith(\".json\"):\n\n data_pipe = open(mapfile)\n\n else:\n\n # The JSON data follows the __DATA__ tag in the Data.pm file.\n\n cmd = \"sed -e '1,/__DATA__/d' \" + mapfile\n\n data_pipe = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout\n\n word2morpho = json.load(data_pipe)\n\n data_pipe.close()\n\n\n\ndef main():\n\n cmd_args = get_args()\n\n\n\n # Allow the file streams to handle non-ascii characters.\n\n infile = codecs.getreader(\"utf-8\")(cmd_args.infile)\n\n outfile = codecs.getwriter(\"utf-8\")(cmd_args.outfile)\n\n if cmd_args.rulesfile is None:\n\n rulesfile = None\n\n else:\n\n rulesfile = codecs.getwriter(\"utf-8\")(cmd_args.rulesfile)\n\n sys.stderr = codecs.getwriter(\"utf-8\")(sys.stderr)\n\n\n\n if cmd_args.buckwalter:\n\n loadMappingData(cmd_args.mapfile)\n\n\n\n # New rule 1.0 is old rule 2-1.\n\n # New rule 2.0 is old rule 2-2.\n\n # New rule 3.0 is old (fixed) rule 2-3.\n\n # New rule 3.1 handles words of old rules 2-6/2-8 with old (fixed) rule 2-3 placement.\n\n # New rule 3.2 handles words of old rules 2-5/2-7 with old (fixed) rule 2-3 placement.\n\n # New rule 3.3 adds handling of vocative particle using old (fixed) rule 2-3 placement.\n\n # New rule 3.4 adds handling of pronoun (this) using old (fixed) rule 2-3 placement.\n\n # New rule 4.0 is old (fixed) rule 2-4.\n\n # New rule 5.0 extends old (fixed) rules 3-1/3-2 to all Arabic letters repeated >2 times.\n\n # New rule 5.1 extends old (fixed) rules 3-1/3-2 to a particular repeated letter-pair (LAM + ALIF).\n\n # New rule 5.2 extends old (fixed) rules 3-1/3-2 to long vowels YEH as well as WAW\n\n # repeated twice or more. (ALIF is moved to rule 5.3)\n\n # New rule 5.3 is rule 5.2 for ALIF.\n\n # Notes: not-start-of-word: (?<!^)(?<! ) not-end-of-word: (?! )(?!$)\n\n\n\n # Using a literal initializer for pat_ar doesn't work very well because we\n\n # end up with the lines displaying left to right in some tools.\n\n # Assignment statements with only a single, short Arabic word display\n\n # left-to-right, as expected.\n\n # pat_ar = {\n\n # \"1.0\": ( \"ى\", \"ء\", \"ئ\", \"ة\", ),\n\n # \"2.0\": ( \"ال\", ),\n\n # \"3.0\": ( \"لا\", \"و\", ),\n\n # \"3.1\": ( \"إذا\", \"لذا\", \"ما\", ),\n\n # \"3.2\": ( \"اً\", \"أن\",),\n\n # \"3.3\": ( \"يا\", ),\n\n # \"3.4\": ( \"هذا\", ),\n\n # \"4.0\": ( \"د\", \"ذ\", \"ر\", \"ز\", \"و\", ),\n\n # \"5.1\": ( \"لا\", ),\n\n # \"5.2\": ( \"و\", \"ي\", ),\n\n # \"5.3\": ( \"ا\", ),\n\n # }\n\n\n\n pat_ar = {}\n\n ar = pat_ar[\"1.0\"] = [\"\"] * 4\n\n ar[0] = \"ى\"\n\n ar[1] = \"ء\"\n\n ar[2] = \"ئ\"\n\n ar[3] = \"ة\"\n\n ar = pat_ar[\"2.0\"] = [\"\"] * 1\n\n ar[0] = \"ال\"\n\n ar = pat_ar[\"3.0\"] = [\"\"] * 2\n\n ar[0] = \"و\"\n\n ar[1] = \"لا\"\n\n ar = pat_ar[\"3.1\"] = [\"\"] * 3\n\n ar[0] = \"إذا\"\n\n ar[1] = \"لذا\"\n\n ar[2] = \"ما\"\n\n ar = pat_ar[\"3.2\"] = [\"\"] * 2\n\n ar[0] = \"اً\"\n\n ar[1] = \"أنا\"\n\n ar = pat_ar[\"3.3\"] = [\"\"] * 1\n\n ar[0] = \"يا\"\n\n ar = pat_ar[\"3.4\"] = [\"\"] * 1\n\n ar[0] = \"هذا\"\n\n ar = pat_ar[\"4.0\"] = [\"\"] * 5\n\n ar[0] = \"د\"\n\n ar[1] = \"ذ\"\n\n ar[2] = \"ر\"\n\n ar[3] = \"ز\"\n\n ar[4] = \"و\"\n\n pat_ar[\"5.0\"] = [\"[\\u0620-\\u064A]\"]\n\n ar = pat_ar[\"5.1\"] = [\"\"] * 1\n\n ar[0] = \"لا\"\n\n ar = pat_ar[\"5.2\"] = [\"\"] * 2\n\n ar[0] = \"و\"\n\n ar[1] = \"ي\"\n\n ar = pat_ar[\"5.3\"] = [\"\"] * 1\n\n ar[0] = \"ا\"\n\n\n\n # Buckwalter pattern notes:\n\n # - We must escape characters with special meaning in Python re patterns,\n\n # hence the use of raw strings and '\\' before some characters.\n\n # - We expect the buckwalter characters '<' and '>' to be backslash\n\n # escaped; we handle the backslashes outside the rules.\n\n pat_bw = {\n\n \"1.0\": ( \"Y\", \"'\", r\"\\}\", \"p\", ),\n\n \"2.0\": ( \"Al\", ),\n\n \"3.0\": ( \"w\", \"lA\", ),\n\n \"3.1\": ( r\"<\\*A\", r\"l\\*A\", \"mA\", ),\n\n \"3.2\": ( \"AF\", \">nA\", ),\n\n \"3.3\": ( \"yA\", ),\n\n \"3.4\": ( r\"h\\*A\", ),\n\n \"4.0\": ( \"d\", r\"\\*\", \"r\", \"z\", \"w\", ),\n\n \"5.0\": ( \"[a-zA-Z$&'*<>_`{|}~]\", ),\n\n \"5.1\": ( \"lA\", ),\n\n \"5.2\": ( \"w\", \"y\", ),\n\n \"5.3\": ( \"A\", ),\n\n }\n\n\n\n pat_txt = pat_bw if cmd_args.buckwalter else pat_ar\n\n\n\n pat = {}\n\n\n\n # Rules 1.0 and 2.0 need to be applied only once, where the matched text\n\n # occurs in the middle of a token.\n\n for rule_id in (\"1.0\", \"2.0\"):\n\n pat[rule_id] = \"(?<!^)(?<! )(\" + '|'.join(pat_txt[rule_id]) + \")(?! )(?!$)\"\n\n\n\n # Rules 3.* are applied repeatedly to tokens where the matched text is preceded\n\n # by at most 1 character in the word and followed by at least two characters.\n\n for rule_id in (\"3.0\", \"3.1\", \"3.2\", \"3.3\", \"3.4\"):\n\n pat[rule_id] = \"(?<![^ ]{2})(\" + '|'.join(pat_txt[rule_id]) + \")(?=[^ ]{2})\"\n\n\n\n # For application of rule 4.0, the updated OOV text is retokenized, and the\n\n # substitution is applied only to tokens of length > 7 characters.\n\n pat[\"4.0\"] = \"(?<!^)(\" + '|'.join(pat_txt[\"4.0\"]) + \")(?!$)\"\n\n\n\n # Rules 5.* merely remove repeated characters, thus have no tokenization effect.\n\n pat[\"5.0\"] = \"(\" + '|'.join(pat_txt[\"5.0\"]) + r\")\\1\\1+\"\n\n for rule_id in (\"5.1\", \"5.2\", \"5.3\"):\n\n pat[rule_id] = \"(\" + '|'.join(pat_txt[rule_id]) + r\")\\1+\"\n\n\n\n rules = {\n\n \"1.0\": (re.compile(pat[\"1.0\"]), r\"\\1 \"),\n\n \"2.0\": (re.compile(pat[\"2.0\"]), r\" \\1\"),\n\n \"3.0\": (re.compile(pat[\"3.0\"]), r\"\\1 \"),\n\n \"3.1\": (re.compile(pat[\"3.1\"]), r\"\\1 \"),\n\n \"3.2\": (re.compile(pat[\"3.2\"]), r\"\\1 \"),\n\n \"3.3\": (re.compile(pat[\"3.3\"]), r\"\\1 \"),\n\n \"3.4\": (re.compile(pat[\"3.4\"]), r\"\\1 \"),\n\n \"4.0\": (re.compile(pat[\"4.0\"]), r\"\\1 \"),\n\n \"5.0\": (re.compile(pat[\"5.0\"]), r\"\\1\"),\n\n \"5.1\": (re.compile(pat[\"5.1\"]), r\"\\1\"),\n\n \"5.2\": (re.compile(pat[\"5.2\"]), r\"\\1\"),\n\n \"5.3\": (re.compile(pat[\"5.3\"]), r\"\\1\"),\n\n }\n\n\n\n # The rules are applied in order according to the cat_N_rules lists.\n\n # Category 1 rules are applied first, each applied once.\n\n # Category 2 rules are then applied repeatedly until no more changes result;\n\n # at most 1 letter precede and at least 2 letters follow the matched text.\n\n # Category 1b exists to postpone the application of rule 5 for double Alif\n\n # until after category 2 rules are applied, which may split the double Alif.\n\n # Category 3 rules are applied last, each applied once to tokens of length > 7.\n\n cat_1_rules = (\"5.0\", \"5.1\", \"5.2\", \"1.0\", \"2.0\",)\n\n cat_2_rules = (\"3.0\", \"3.1\", \"3.2\", \"3.3\", \"3.4\",)\n\n cat_1b_rules = (\"5.3\",)\n\n cat_3_rules = (\"4.0\",)\n\n\n\n rule_cnts_oov = {}\n\n rule_cnts_appl = {}\n\n rule_cnts_all = {}\n\n for rule_id in rules:\n\n rule_cnts_oov[rule_id] = 0\n\n rule_cnts_appl[rule_id] = 0\n\n rule_cnts_all[rule_id] = 0\n\n\n\n def print_rule(rule_id, text):\n\n if rulesfile is not None:\n\n print(oov_count, 'm', rule_id, ' ', text, sep='', file=rulesfile)\n\n\n\n def apply_rule(rule_id, text, update_oov_cnt, do_print):\n\n \"\"\"\n\n Apply the specified rule to some text, printing the result if requested.\n\n\n\n rule_id: ID of the rule to apply, e.g. \"3.1\"\n\n text: text string to apply the rule to; can contain one or more words.\n\n update_oov_cnt: update the OOV count for the rule if True.\n\n do_print: outputs rule tag and updated text if True.\n\n returns a tuple consisting of the updated text and the number of changes.\n\n \"\"\"\n\n pat, repl = rules[rule_id]\n\n updated_text, n = re.subn(pat, repl, text)\n\n if n > 0:\n\n if do_print:\n\n print_rule(rule_id, updated_text)\n\n if update_oov_cnt: rule_cnts_oov[rule_id] += 1\n\n rule_cnts_appl[rule_id] += 1\n\n rule_cnts_all[rule_id] += n\n\n return updated_text, n\n\n\n\n def apply_rules(oov):\n\n \"\"\"Apply rules to an OOV returning the updated oov text.\"\"\"\n\n print_rule('0.0', oov)\n\n updated_text = oov\n\n\n\n # For buckwalter text, temporarily remove the XML escapes, so letter\n\n # counts for rules will be correct.\n\n # i.e. '&gt;' -> '>', '&lt;' -> '<', &amp;' -> '&'.\n\n if cmd_args.buckwalter and cmd_args.oov_tags:\n\n updated_text, n_esc_gt = re.subn('&gt;', '>', updated_text)\n\n updated_text, n_esc_lt = re.subn('&lt;', '<', updated_text)\n\n updated_text, n_esc_amp = re.subn('&amp;', '&', updated_text)\n\n\n\n # Category 1 rules need to be applied only once.\n\n for rule_id in cat_1_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, True, True)\n\n\n\n # Category 2 rules need to be re-applied until no more changes occur.\n\n num_changes = -1\n\n first_time = True\n\n while first_time or num_changes != 0:\n\n num_changes = 0\n\n for rule_id in cat_2_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, first_time, True)\n\n num_changes += n\n\n first_time = False\n\n\n\n # Category 1b rules need to be applied only once.\n\n for rule_id in cat_1b_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, True, True)\n\n\n\n # Category 3 rules need to be applied once only to words with length > 7.\n\n upd_wrds = split(updated_text)\n\n for rule_id in cat_3_rules:\n\n pat, repl = rules[rule_id]\n\n num_changes = 0\n\n for i, wrd in enumerate(upd_wrds):\n\n if len(wrd) > 7:\n\n upd_wrds[i], n = apply_rule(rule_id, wrd, num_changes==0, False)\n\n num_changes += n\n\n if num_changes > 0:\n\n updated_text = ' '.join(upd_wrds)\n\n print_rule(rule_id, updated_text)\n\n\n\n # Re-apply the MADA Map if operating on buckwalter transliterated text.\n\n if cmd_args.buckwalter and updated_text != oov:\n\n updated_text = ' '.join(word2morpho.get(wrd, wrd) for wrd in split(updated_text))\n\n\n\n # For buckwalter text, restore previously removed XML escapes\n\n # i.e. '&gt;' -> '>', '&lt;' -> '<', &amp;' -> '&'.\n\n if cmd_args.buckwalter and cmd_args.oov_tags:\n\n updated_text, n = re.subn('&', '&amp;', updated_text)\n\n updated_text, n = re.subn('>', '&gt;', updated_text)\n\n updated_text, n = re.subn('<', '&lt;', updated_text)\n\n\n\n print_rule('X.X', updated_text)\n\n return updated_text\n\n\n\n line_number = 0;\n\n oov_count=0\n\n\n\n for line in infile:\n\n line_number += 1\n\n out_line = []\n\n if not cmd_args.oov_tags:\n\n oov_count += 1\n\n out_line.append(apply_rules(line.strip()))\n\n else:\n\n oov_start = oov_end = False\n\n for token in split(line):\n\n if token.startswith(\"<oov>\"):\n\n token = token[5:]\n\n oov_start = True\n\n if token.endswith(\"</oov>\"):\n\n token = token[:-6]\n\n oov_end = True\n\n if not oov_start:\n\n out_line.append(token)\n\n else:\n\n if len(token) > 0:\n\n oov_count += 1\n\n out_line.append(apply_rules(token))\n\n if oov_end:\n\n oov_start = oov_end = False\n\n if oov_start:\n\n error(\"Missing </oov> for oov\", oov_count, \"in line\", line_number)\n\n print(*out_line, file=outfile)\n\n\n\n # Print the stats\n\n verbose(\"Rules applied (# OOV words)\")\n\n for rule_id in sorted(rule_cnts_oov.keys()):\n\n verbose(rule_id, \": \", rule_cnts_oov[rule_id], sep='')\n\n verbose(\"Rules applied (# rule applications)\")\n\n for rule_id in sorted(rule_cnts_appl.keys()):\n\n verbose(rule_id, \": \", rule_cnts_appl[rule_id], sep='')\n\n verbose(\"Rules applied (total # changes)\")\n\n for rule_id in sorted(rule_cnts_all.keys()):\n\n verbose(rule_id, \": \", rule_cnts_all[rule_id], sep='')\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "file_path": "src/textutils/apply_ar_tweet_oov_rules.py", "rank": 17, "score": 127378.35629965505 }, { "content": " public function incrAddSentence($context = NULL,\n\n $document_model_id = NULL,\n\n $source_sentence = NULL,\n\n $target_sentence = NULL,\n\n $extra_data = NULL)\n\n {\n\n if (!isset($source_sentence) || empty($source_sentence)) {\n\n throw new SoapFault(\"PortageBadArgs\", \"You must provide a source sentence.\");\n\n }\n\n\n\n if (!isset($target_sentence) || empty($target_sentence)) {\n\n throw new SoapFault(\"PortageBadArgs\", \"You must provide a target sentence.\");\n\n }\n\n\n\n if (!isset($context) || empty($context)) {\n\n throw new SoapFault(\"PortageBadArgs\", \"You must provide a valid context.\");\n\n }\n\n\n\n # TODO: Validate that the document_model_id is a valid one.\n\n if (!isset($document_model_id) || empty($document_model_id)) {\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 18, "score": 126516.24596612547 }, { "content": " # Run $command, giving it $src_string as input, using context info $i.\n\n # Returns the STDOUT of $command.\n\n # Throws SoapFault (faultcode=\"PortageServer\") if there is a problem.\n\n # If $command has a non-zero exit status:\n\n # If $exit_status is NULL, throws SoapFault(faultcode=\"PortageServer\")\n\n # If $exit_status is not NULL, set $exit_status to $command's exit status.\n\n # If $wantoutput is false, STDERR and STDOUT are discarded; required to\n\n # launch a background job using &, for example.\n\n # $work_dir is not NULL, STDERR will be sent to $work_dir/trace.\n\n protected function runCommand($command, $src_string, &$i,\n\n &$exit_status = NULL, $wantoutput = true,\n\n $work_dir = NULL)\n\n {\n\n global $error_output_dir;\n\n $cwd = \"/tmp\";\n\n global $base_portage_dir;\n\n $context_dir = $i[\"context_dir\"];\n\n if (php_sapi_name() === 'cli' or php_sapi_name() === 'cli-server')\n\n $env = NULL;\n\n else\n\n $env = array(\n\n 'PORTAGE' => \"$base_portage_dir\",\n\n 'LD_LIBRARY_PATH' => \"$context_dir/lib:$base_portage_dir/lib:/lib:/usr/lib\",\n\n 'PATH' => \"$context_dir/bin:$i[context_dir]:$base_portage_dir/bin\"\n\n . \":/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\",\n\n 'PERL5LIB' => \"$context_dir/lib:$base_portage_dir/lib\",\n\n 'PYTHONPATH' => \"$context_dir/lib:$base_portage_dir/lib\",\n\n 'PORTAGE_INTERNAL_CALL' => 1\n\n );\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 19, "score": 124905.01707620431 }, { "content": "namespace Portage {\n\n/// Namespace to hold all relevant code to joint filtering\n\nnamespace Joint_Filtering {\n\n/**\n\n * Callable entity that implements the hard filter_joint per leaf of the trie.\n\n */\n\nstruct hardFilterTMVisitor : public filterTMVisitor\n\n{\n\n /**\n\n * Yet another PhraseInfo which will be used for hard filter_joint.\n\n */\n\n struct PhraseInfo4HardFiltering : public filterTMVisitor::PhraseInfo4filtering\n\n {\n\n /// Definition of the inherited Parent\n\n typedef filterTMVisitor::PhraseInfo4filtering Parent;\n\n\n\n /**\n\n * Default constructor.\n\n * Keeps a pointer to the original object since after filter_joint, we\n\n * will need the original to rewrite a reduced target table.\n\n * @param ref pointer to the original object used to construct this\n\n * @param numTextTransModels number of text translation models. We need\n\n * this information since not all entries have the same size, we need to\n\n * make them the same size=> the same number of probs for each (forward\n\n * and/or backward).\n\n * @param log_almost_0 user defined 0\n\n * @param hard_filter_forward_weights phrasetable weights for filtering forward scores\n\n * @param hard_filter_backward_weights phrasetable weights for filtering backward scores\n\n * @param combined: if true, use the log-linear sum of both backward and forward\n\n * score, not just forward, as primary filtering score.\n\n */\n\n PhraseInfo4HardFiltering(const pair<const Phrase, TScore>* ref, \n\n const Uint numTextTransModels, \n\n double log_almost_0, \n\n const vector<double>& hard_filter_forward_weights,\n\n const vector<double>& hard_filter_backward_weights,\n\n bool combined);\n\n };\n\n\n\n /// Definition of the Parent inherited\n\n typedef filterTMVisitor Parent;\n\n\n\n vector<double> hard_filter_forward_weights; ///< Weights for hard filtering forward scores\n\n vector<double> hard_filter_backward_weights; ///< Weights for hard filtering backward scores\n\n bool combined; ///< true iff type was \"combined\" or \"full\"\n\n\n\n /**\n\n * Constructor.\n\n * @param parent The parent phrase table, whose getStringPhrase\n\n * function will be used to convert Uint sequence to\n\n * readable, and lexicographically comparable, text.\n\n * @param log_almost_0\n\n * @param pruningTypeStr pruning type: \"forward-weights\", \"backward-weights\",\n\n * \"combined\" or \"full\"\n\n * @param forwardWeights The decoder's forward weights (c.forwardWeights)\n\n * @param backwardWeights The decoder's backward weights (c.transWeights)\n\n */\n\n hardFilterTMVisitor(const PhraseTable &parent, double log_almost_0,\n\n const string& pruningTypeStr,\n\n vector<double> forwardWeights,\n\n const vector<double>& transWeights);\n\n\n\n virtual void operator()(TargetPhraseTable& tgtTable);\n\n};\n\n}; // ends namespace Joint_Filtering\n", "file_path": "src/canoe/hard_filter_tm_visitor.h", "rank": 20, "score": 124877.31687289065 }, { "content": "namespace Portage {\n\n/// Namespace to hold all relevant code to joint filtering\n\nnamespace Joint_Filtering {\n\n/**\n\n * Callable entity that implements the soft filter_joint per leaf of the trie.\n\n */\n\nstruct softFilterTMVisitor : public filterTMVisitor\n\n{\n\n /**\n\n * Yet another PhraseInfo which will be used for soft filter_joint.\n\n */\n\n struct PhraseInfo4SoftFiltering : public filterTMVisitor::PhraseInfo4filtering\n\n {\n\n /// Definition of the inherited Parent\n\n typedef filterTMVisitor::PhraseInfo4filtering Parent;\n\n\n\n /**\n\n * Default constructor.\n\n * Keeps a pointer to the original object since after filter_joint, we\n\n * will need the original to rewrite a reduced target table.\n\n * @param ref pointer to the original object used to construct this\n\n * @param numTextTransModels number of text translation models. We need\n\n * this information since not all entries have the same size, we need to\n\n * make them the same size=> the same number of probs for each (forward\n\n * and/or backward).\n\n * @param log_almost_0 user defined 0\n\n */\n\n PhraseInfo4SoftFiltering(const pair<const Phrase, TScore>* ref, Uint numTextTransModels, double log_almost_0);\n\n\n\n };\n\n\n\n /// Definition of the inherited Parent\n\n typedef filterTMVisitor Parent;\n\n\n\n /// true iff filtering is in \"combined\" or \"full\" mode, i.e., look at all TM models,\n\n /// not just forward ones.\n\n bool combined;\n\n\n\n /**\n\n * Constructor.\n\n * @param parent The parent phrase table, whose getStringPhrase\n\n * function will be used to convert Uint sequence to\n\n * readable, and lexicographically comparable, text\n\n * @param log_almost_0\n\n * @param pruningTypeStr pruning type: \"forward-weights\", \"backward-weights\",\n\n * \"combined\" or \"full\"\n\n */\n\n softFilterTMVisitor(const PhraseTable &parent, double log_almost_0, const string& pruningTypeStr);\n\n\n\n virtual void operator()(TargetPhraseTable& tgtTable);\n\n\n\n /**\n\n * Implements the lessdot from the paper.\n\n * @param in left-hand side operand\n\n * @param jn right-hand side operand\n\n * return Returns true if in is less than jn\n\n */\n\n bool lessdot(PhraseInfo& in, PhraseInfo& jn) const;\n\n\n\n};\n\n}; // ends namespace Joint_Filtering\n", "file_path": "src/canoe/soft_filter_tm_visitor.h", "rank": 21, "score": 124877.31687289065 }, { "content": "def set_debug(flag):\n\n \"\"\"Set value of the debug flag to control printing of debug messages.\"\"\"\n\n global debug_flag\n", "file_path": "src/utils/portage_utils.py", "rank": 22, "score": 124875.17126443278 }, { "content": "def set_verbose(flag):\n\n \"\"\"Set value of the verbose flag to control printing of debug messages.\"\"\"\n\n global verbose_flag\n", "file_path": "src/utils/portage_utils.py", "rank": 23, "score": 124875.17126443278 }, { "content": " /// Object to encapsulate the handling of implicit nulls in src_toks.\n\n /// Implicit nulls make everything more complicated. We hide that\n\n /// complexity using this class, which explicitly represents nullWord().\n\n class StringVecWithExplicitNull {\n\n vector<string> storage;\n\n const vector<string>& toks_with_null;\n\n public:\n\n StringVecWithExplicitNull(const vector<string>& toks, bool implicitNull);\n\n size_t size() { return toks_with_null.size(); }\n\n bool empty() { return toks_with_null.empty(); }\n\n\n\n typedef vector<string>::const_iterator const_iterator;\n\n const_iterator begin() const { return toks_with_null.begin(); }\n\n const_iterator end() const { return toks_with_null.end(); }\n\n\n\n const string& operator[](size_t i) { return toks_with_null[i]; }\n\n /// Implicit conversion to a const vector<string>& so these can be\n\n /// easily passed to the many methods expecting such vectors.\n\n operator const vector<string>& () { return toks_with_null; }\n\n };\n\n\n\n /// Private data structure and helper for count_symmetrized()\n\n struct count_symmetrized_helper {\n", "file_path": "src/word_align/hmm_aligner.h", "rank": 24, "score": 124826.62836720287 }, { "content": " class Entry; // a wrapper for the value of each node in the trie\n", "file_path": "src/tp_models/tplm.h", "rank": 25, "score": 124808.16230888174 }, { "content": "sub processLogiTransOutput {\n\n my ($parser, $elt) = @_;\n\n\n\n # Extracts source segments to be translated.\n\n sub processQuery {\n\n my ($parser, $OriginalText) = @_;\n\n\n\n # Skip Queries that are a repeat of some other Query.\n\n return if (defined($OriginalText->parent()->{att}{'repeated-from'}));\n\n\n\n # Get the query for id\n\n my $query_id = $OriginalText->parent()->{att}{id};\n\n die \"Error: Each query should have its mandatory id.\" unless defined $query_id;\n\n debug(\"query_id: %s\\n\", $query_id);\n\n\n\n my $source = $OriginalText->xml_string();\n\n $parser->{seg_id} = ixAdd($parser->{ix}, $source, $query_id);\n\n ++$parser->{seg_count};\n\n\n\n xmlFlush($parser);\n", "file_path": "src/confidence/ce_tmx.pl", "rank": 26, "score": 124774.42553761968 }, { "content": " public function incrAddTextBlock($context = NULL,\n\n $document_model_id = NULL,\n\n $source_block = NULL,\n\n $target_block = NULL,\n\n $extra_data = NULL)\n\n {\n\n if (!isset($context) || empty($context)) {\n\n throw new SoapFault(\"PortageBadArgs\", \"You must provide a valid context.\");\n\n }\n\n\n\n # TODO: Validate that the document_model_id is a valid one.\n\n if (!isset($document_model_id) || empty($document_model_id)) {\n\n throw new SoapFault(\"PortageBadArgs\", \"You must provide a valid document_model_id.\");\n\n }\n\n\n\n if (!isset($source_block) || empty($source_block)) {\n\n throw new SoapFault(\"PortageBadArgs\", \"You must provide a source text block.\");\n\n }\n\n\n\n if (!isset($target_block) || empty($target_block)) {\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 27, "score": 124247.18839758508 }, { "content": " # ==========================================================\n\n # Deprecated functions kept for backwards compatibility only\n\n # ==========================================================\n\n public function getTranslation($src_string, $newline, $xtags)\n\n {\n\n if (!isset($newline)) $newline = \"p\"; # newline arg was added in PortageII 2.1\n\n if (!isset($xtags)) $xtags = false; # xtags arg was added in PortageII 2.1\n\n return $this->translate($src_string, \"context\", $newline, $xtags, false);\n\n }\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 28, "score": 121820.50053699804 }, { "content": "// Here's the menu:\n\nclass Sentence; // string of chars + vector<string> of toks\n", "file_path": "src/eval/basic_data_structure.h", "rank": 29, "score": 121225.80847786707 }, { "content": "using namespace std;\n", "file_path": "src/eval/wer.h", "rank": 30, "score": 120160.55123599319 }, { "content": " public function incrStatus($context, $document_model_id = NULL)\n\n {\n\n //error_log(\"incrStatus call: ($context , $document_model_id)\");\n\n if (!isset($context) || empty($context)) {\n\n throw new SoapFault(\"PortageBadArgs\",\n\n \"You must provide a valid context.\");\n\n }\n\n\n\n if (!isset($document_model_id) || empty($document_model_id)) {\n\n throw new SoapFault(\"PortageBadArgs\",\n\n \"You must provide a valid document_model_id.\");\n\n }\n\n\n\n $work_dir = $this->getDocumentModelWorkDir($context, $document_model_id);\n\n\n\n if (! is_dir($work_dir))\n\n return \"N/A\";\n\n\n\n # Check if an update is in progress.\n\n $update_in_progress = false;\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 31, "score": 119420.15155512704 }, { "content": " public function getTranslation2($src_string, $context, $newline, $xtags)\n\n {\n\n if (!isset($newline)) $newline = \"p\"; # newline arg was added in PortageII 2.1\n\n if (!isset($xtags)) $xtags = false; # xtags arg was added in PortageII 2.1\n\n return $this->translate($src_string, $context, $newline, $xtags, false);\n\n }\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 32, "score": 118919.7807231872 }, { "content": "using namespace Portage;\n", "file_path": "src/utils/trie-cc.h", "rank": 33, "score": 116441.40004920677 }, { "content": "using namespace std;\n", "file_path": "src/rescoring/powell-cc.h", "rank": 34, "score": 116441.40004920677 }, { "content": "using namespace Portage;\n", "file_path": "src/canoe/canoe_utils.h", "rank": 35, "score": 116441.40004920677 }, { "content": "using namespace std;\n", "file_path": "src/rescoring/rescoring_general.h", "rank": 36, "score": 116441.40004920677 }, { "content": " def apply_rule(rule_id, text, update_oov_cnt, do_print):\n\n \"\"\"\n\n Apply the specified rule to some text, printing the result if requested.\n\n\n\n rule_id: ID of the rule to apply, e.g. \"3.1\"\n\n text: text string to apply the rule to; can contain one or more words.\n\n update_oov_cnt: update the OOV count for the rule if True.\n\n do_print: outputs rule tag and updated text if True.\n\n returns a tuple consisting of the updated text and the number of changes.\n\n \"\"\"\n\n pat, repl = rules[rule_id]\n\n updated_text, n = re.subn(pat, repl, text)\n\n if n > 0:\n\n if do_print:\n\n print_rule(rule_id, updated_text)\n\n if update_oov_cnt: rule_cnts_oov[rule_id] += 1\n\n rule_cnts_appl[rule_id] += 1\n\n rule_cnts_all[rule_id] += n\n", "file_path": "src/textutils/apply_ar_tweet_oov_rules.py", "rank": 37, "score": 116419.37049932011 }, { "content": " def apply_rules(oov):\n\n \"\"\"Apply rules to an OOV returning the updated oov text.\"\"\"\n\n print_rule('0.0', oov)\n\n updated_text = oov\n\n\n\n # For buckwalter text, temporarily remove the XML escapes, so letter\n\n # counts for rules will be correct.\n\n # i.e. '&gt;' -> '>', '&lt;' -> '<', &amp;' -> '&'.\n\n if cmd_args.buckwalter and cmd_args.oov_tags:\n\n updated_text, n_esc_gt = re.subn('&gt;', '>', updated_text)\n\n updated_text, n_esc_lt = re.subn('&lt;', '<', updated_text)\n\n updated_text, n_esc_amp = re.subn('&amp;', '&', updated_text)\n\n\n\n # Category 1 rules need to be applied only once.\n\n for rule_id in cat_1_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, True, True)\n\n\n\n # Category 2 rules need to be re-applied until no more changes occur.\n\n num_changes = -1\n\n first_time = True\n\n while first_time or num_changes != 0:\n\n num_changes = 0\n\n for rule_id in cat_2_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, first_time, True)\n\n num_changes += n\n\n first_time = False\n\n\n\n # Category 1b rules need to be applied only once.\n\n for rule_id in cat_1b_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, True, True)\n\n\n\n # Category 3 rules need to be applied once only to words with length > 7.\n\n upd_wrds = split(updated_text)\n\n for rule_id in cat_3_rules:\n\n pat, repl = rules[rule_id]\n\n num_changes = 0\n\n for i, wrd in enumerate(upd_wrds):\n\n if len(wrd) > 7:\n\n upd_wrds[i], n = apply_rule(rule_id, wrd, num_changes==0, False)\n\n num_changes += n\n\n if num_changes > 0:\n\n updated_text = ' '.join(upd_wrds)\n\n print_rule(rule_id, updated_text)\n\n\n\n # Re-apply the MADA Map if operating on buckwalter transliterated text.\n\n if cmd_args.buckwalter and updated_text != oov:\n\n updated_text = ' '.join(word2morpho.get(wrd, wrd) for wrd in split(updated_text))\n\n\n\n # For buckwalter text, restore previously removed XML escapes\n\n # i.e. '&gt;' -> '>', '&lt;' -> '<', &amp;' -> '&'.\n\n if cmd_args.buckwalter and cmd_args.oov_tags:\n\n updated_text, n = re.subn('&', '&amp;', updated_text)\n\n updated_text, n = re.subn('>', '&gt;', updated_text)\n\n updated_text, n = re.subn('<', '&lt;', updated_text)\n\n\n\n print_rule('X.X', updated_text)\n", "file_path": "src/textutils/apply_ar_tweet_oov_rules.py", "rank": 38, "score": 116411.18855231581 }, { "content": " public function getTranslationCE($src_string, $context, $newline, $xtags)\n\n {\n\n if (!isset($newline)) $newline = \"p\"; # newline arg was added in PortageII 2.1\n\n if (!isset($xtags)) $xtags = false; # xtags arg was added in PortageII 2.1\n\n return $this->translate($src_string, $context, $newline, $xtags, true);\n\n }\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 39, "score": 116157.84937910002 }, { "content": "// typedef-like definition for the commonly needed PhraseTableGen<Uint> case.\n\nclass PhraseTableUint : public PhraseTableGen<Uint> {};\n\n\n\n} // namespace Portage\n\n\n\n#include \"phrase_table-cc.h\"\n\n\n\n#endif\n", "file_path": "src/tm/phrase_table.h", "rank": 40, "score": 115655.07286994871 }, { "content": " public function incrClearDocumentModelWorkdir($context, $document_model_id = NULL)\n\n {\n\n error_log('Not yet properly implemented');\n\n assert(False);\n\n\n\n if (!isset($context) || empty($context)) {\n\n throw new SoapFault(\"PortageBadArgs\",\n\n \"You must provide a valid context.\");\n\n }\n\n\n\n if (!isset($document_model_id) || empty($document_model_id)) {\n\n throw new SoapFault(\"PortageBadArgs\",\n\n \"You must provide a valid document_model_id.\");\n\n }\n\n\n\n $work_dir = $this->getDocumentModelWorkDir($context, $document_model_id);\n\n\n\n if (! is_dir($work_dir))\n\n throw new SoapFault(\"PortageServer\", \"$document_model_id doesn't have \"\n\n . \"a workdir: $work_dir\");\n\n\n\n if (! rmdir($work_dir))\n\n throw new SoapFault(\"PortageServer\", \"can't remove temp work dir for \"\n\n . \"$document_model_id: $work_dir\");\n\n\n\n return $work_dir;\n\n }\n\n\n\n\n\n\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 41, "score": 113501.73026104977 }, { "content": "/// string of chars + vector<string> of toks.\n\nclass Sentence : public string\n\n{\n\nprivate:\n\n mutable Tokens m_tokens;\n\npublic:\n\n /// Constructor.\n\n /// @param s string representing the sentence.\n\n Sentence(const string& s = \"\") : string(s) {}\n\n /**\n\n * Split the current sentence in a sequence of tokens.\n\n * @return Returns a white space split representation of this sentence.\n\n */\n\n const Tokens& getTokens() const\n\n {\n\n if (size() && m_tokens.empty()) {\n\n split(string(*this), m_tokens);\n\n }\n\n return m_tokens;\n\n }\n\n /**\n\n * Clear the token list.\n\n */\n\n void clearTokens() {\n\n m_tokens.clear();\n\n }\n\n};\n\n/// A set of sentences.\n\ntypedef vector<Sentence> Sentences;\n\n\n\n\n", "file_path": "src/eval/basic_data_structure.h", "rank": 42, "score": 113182.06901648533 }, { "content": "char* strdup_new(const char* in);\n", "file_path": "src/utils/str_utils.h", "rank": 43, "score": 112972.6719148115 }, { "content": "def apply_case(case, tgt, cased_src):\n\n \"\"\"Apply the specified casing to the target text using cased_src as a\n\n reference for resolving the case of OOVs.\n\n \n\n case: case to apply, which can be \"upper\", \"lower\", or None\n\n tgt: target text\n\n cased_src: corresponding true-cased source text\n\n returns: cased target text\n\n \"\"\"\n\n debug(\"apply_case: case:\", case, \"tgt:\", tgt, \"cased_src:\", cased_src)\n\n tgt_toks = rm_toks_re.findall(tgt)\n\n if cased_src is None:\n\n cased_src = tgt\n\n cased_src_toks = rm_toks_re.findall(cased_src)\n\n for i,tok in enumerate(tgt_toks):\n\n oov_match = oov_re.match(tok)\n\n if oov_match:\n\n # OOVs will be expanded later.\n\n if not oov_match.group(1): # add src attribute to OOV if needed\n\n # Find the corresponding source token.\n\n tgt_tok = oov_match.group(2)\n\n look_fwd = i < len(tgt_toks)/2\n\n for esc_src_tok in cased_src_toks if look_fwd else reversed(cased_src_toks):\n\n src_tok = unescape_all(esc_src_tok)\n\n if src_tok.lower() == tgt_tok:\n\n # For later OOV expansion\n\n tgt_toks[i] = '<OOV src=\"{0}\">{1}</OOV>'.format(esc_src_tok, tgt_tok)\n\n break\n\n elif case == \"upper\":\n\n tgt_toks[i] = tok.upper()\n\n elif case == \"title\":\n\n tgt_toks[i] = capitalize_token(tok)\n\n debug(\"apply_case returning:\", *tgt_toks)\n", "file_path": "src/truecasing/casemark.py", "rank": 44, "score": 112959.76826043439 }, { "content": " def float_str(arg):\n\n try:\n\n value = float(arg)\n\n except ValueError:\n\n raise ArgumentTypeError(\"invalid float value: '{0}'\".format(arg))\n", "file_path": "src/rescoring/rescore.py", "rank": 45, "score": 112949.39094501942 }, { "content": " Uint64 mem_used =\n\n static_cast<Uint64>(\n\n sizeof(PTrie<LeafDataT, InternalDataT, NeedDtor>))\n\n + intl_nodes * sizeof(TrieNode<LeafDataT, InternalDataT, NeedDtor>)\n\n + (intl_nodes - roots.size()) * sizeof(Uint)\n", "file_path": "src/utils/trie-cc.h", "rank": 46, "score": 112948.27270722347 }, { "content": "using namespace std;\n", "file_path": "src/tpt/ugMemTable.h", "rank": 47, "score": 112945.56366346774 }, { "content": "inline void\n\nsplitString(const string& s, vector<string>& dest, const string& sep = \" \") {\n", "file_path": "src/utils/str_utils.h", "rank": 48, "score": 112938.84375178053 }, { "content": " BucketTuple(Uint new_bucket, TrieKeyT new_key,\n\n Uint old_bucket, Uint old_pos)\n\n : new_bucket(new_bucket), new_key(new_key)\n\n , old_bucket(old_bucket), old_pos(old_pos) {}\n\n /// Less than, defined for sorting on new_bucket first, then new_key.\n\n bool operator<(const BucketTuple &x) const {\n", "file_path": "src/utils/trie-cc.h", "rank": 49, "score": 112935.89264894064 }, { "content": " else return new_key < x.new_key;\n", "file_path": "src/utils/trie-cc.h", "rank": 50, "score": 112935.89264894064 }, { "content": " vector<string> markString; ///< translation provided on input\n", "file_path": "src/canoe/marked_translation.h", "rank": 51, "score": 112926.75432950197 }, { "content": " def set_encoding(self, encoding):\n\n \"\"\"Set the character encoding.\"\"\"\n", "file_path": "src/truecasing/casemark.py", "rank": 52, "score": 112924.67702993375 }, { "content": "class OutputLayer(object):\n\n def __init__(self, x, y, n_in, n_out, bias=False):\n\n \"\"\"\n\n Output layer class\n\n :type x: T.TensorType\n\n :param x: symbolic variable that describes inputs\n\n\n\n :type y: T.TensorTYpe\n\n :param y: symbolic variable that describes outputs\n\n\n\n :type n_in: int\n\n :param n_in: input space dimension\n\n\n\n :type n_out: int\n\n :param n_out: output space dimension\n\n\n\n :type bias: bool\n\n :param bias: include bias term if true\n\n \"\"\"\n\n self.w = theano.shared(rng.uniform(-0.05,0.05, (n_in,n_out)).astype(theano.config.floatX), name=\"w\") # weights: number of features n_in x number of classes n_out\n\n init_b = numpy.empty(n_out)\n\n if bias:\n\n init_b.fill(numpy.log(1.0/n_out)) # Output weights initially log(sum(exp))=0\n\n else:\n\n init_b.fill(0.0)\n\n self.b = theano.shared(init_b.astype(theano.config.floatX), name = 'b')\n\n self.s = T.dot(x, self.w)+self.b\n\n sMax = T.max(self.s, axis = 1, keepdims = True)\n\n self.norm = T.log(T.sum(T.exp(self.s-sMax), axis = 1, keepdims = True)) + sMax # expose the norm for self normalization\n\n self.log_p_y_given_x = self.s - self.norm\n\n logp = self.log_p_y_given_x[T.arange(y.shape[0]), y] # probs for correct label\n\n self.nll = -logp # negative log likelihood\n\n self.params = [self.w]\n", "file_path": "src/nn/multilayers.py", "rank": 53, "score": 112906.26847672042 }, { "content": "program outputs the C<FILE> field on the standard output.\n\n\n\nThe second form (C<plog.pl -update>) is used to update the C<STATUS>,\n\nC<WORDS_IN> and C<WORDS_OUT> fields of the given entry. C<log_file> is\n\nthe file name returned by the C<plog.pl -create> command; C<status>\n\nshould either be \"success\" or \"failure\"; C<words_in> is the number of\n\nsource words submitted to translation; and C<words_out> is the actual\n\nnumber of source-words translated (not filtered out by confidence\n\nestimation) -- if not given, it is assumed to be the same as\n\nC<words_in>.\n\n\n\nBoth the first and second forms accept an optional C<-comment> switch,\n\nby which the caller may add a textual comment to the log entry. Note\n\nthat a comment specified in the C<-update> form, even empty, will\n\noverwrite a comment given with the C<-create> form.\n\n\n\nThe third form is used either to extract entries (C<-extract>) or to\n\ncompute global statistics on these entries (C<-stats>). By default\n\n(no C<period> argument), all log entries are considered. The C<period>\n\nargument can be used to specify a time period: C<YYYY> for a complete\n", "file_path": "src/utils/plog.pl", "rank": 54, "score": 110111.65444834961 }, { "content": "def optimizeOnlineLMIRA(iter, wts, args, logfile):\n\n \"\"\"Optimize weights using lattice MIRA over lattices generated online.\"\"\"\n\n C = \"0.01\" # learning rate\n\n decay = \"0.999\" # effective number of context sentences\n\n bg = \"Oracle\" # BLEU background=Oracle|Model|Orange\n\n density = \"1000\" # density to which lattices will be pruned\n\n combineCounts = False # should we combine BLEU counts at the end of each epoch?\n\n args_vals = args.split()\n\n if len(args_vals) > 0: C = args_vals[0]\n\n if len(args_vals) > 1: decay = args_vals[1]\n\n if len(args_vals) > 2: bg = args_vals[2]\n\n if len(args_vals) > 3: density = args_vals[3]\n\n if len(args_vals) > 4: combineCounts = args_vals[4] in ['true', 'True', 'TRUE']\n\n if len(args_vals) > 5:\n\n print >> logfile, \"warning: ignoring values past first 3 tokens in \" + args\n\n dec_cfg = \"decode-config\"\n\n miraConfig = [shardAnnotate(workdir+\"/mira-config\",\"xx\",shard) for shard in range(opts.numpar)]\n\n #Create src filenames and refglobs for each shard\n\n refPrefixes = [(workdir+\"/ref.\"+str(i)) for i in range(len(refs))]\n\n srcShards = list(shardAnnotate(workdir+\"/src\",\"xx\",i) for i in range(opts.numpar))\n\n shardRefList = [[shardAnnotate(pref,\"xx\",i) for pref in refPrefixes] for i in range(opts.numpar)]\n\n shardRefglob = [\",\".join(shardRef) for shardRef in shardRefList]\n\n logfile.flush()\n\n #Shard corpus on first iteration, and set up shard-specific initial config files\n\n if iter==0 :\n\n #Shard source, save shard names\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ShardCorpus\", src]\n\n cmd.extend(srcShards)\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"src sharding failed: {}\".format(' '.join(cmd)))\n\n #Shard refs, save ref names\n\n refShardList = [[shardAnnotate(pref,\"xx\",i) for i in range(opts.numpar)] for pref in refPrefixes]\n\n for i in range(len(refs)):\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ShardCorpus\", refs[i]]\n\n cmd.extend(refShardList[i])\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"ref sharding failed: {}\".format(' '.join(cmd)))\n\n # create shard-specific initial config files\n\n for i in range(opts.numpar):\n\n run(\"configtool rep-sparse-models-local:.\" + str(i) + \" \" + dec_cfg + \" > \" + shardAnnotate(dec_cfg, \"ni\", i))\n\n #Write config files for each shard\n\n model=workdir+\"/mira.model\"\n\n avg=workdir+\"/mira.avg.model\"\n\n count=workdir+\"/mira.count\"\n\n lat = workdir+\"/lat\"\n\n portageIniWeights = optimizer_in\n\n for shard in range(opts.numpar):\n\n input_decodeConfig = shardAnnotate(dec_cfg, \"ni\", shard)\n\n decodeConfig = shardAnnotate(dec_cfg,\"xx\",shard)\n\n modelIn = \"empty\" if iter==0 else shardAnnotate(model,iter-1,\"xx\") \n\n modelOut = shardAnnotate(model,iter,shard)\n\n bleuCountIn = \"empty\" if iter==0 else (shardAnnotate(count,iter-1,shard)\n\n if not combineCounts else shardAnnotate(count,iter-1,\"xx\"))\n\n bleuCountOut = shardAnnotate(count,iter,shard)\n\n sparse = \"-sfvals\" if opts.sparse else \"-ffvals\"\n\n decodeCmd = \"canoe -f \" + decodeConfig + \" \" + sparse + \" -palign -lattice \" + shardAnnotate(lat,\"xx\",shard)+\".gz\"\n\n weightCmd = \" \".join(wts2decoderConfigStr(decodeConfig, input_decodeConfig))\n\n latticeTmpFile = shardAnnotate(lat,\"xx\",shard)+\".0000.gz\"\n\n srcFile = srcShards[shard]\n\n refFiles = shardRefglob[shard]\n\n with open(miraConfig[shard], 'w') as ofile:\n\n ofile.write(\"modelInFile = \" + modelIn + \"\\n\")\n\n ofile.write(\"modelOutFile = \" + modelOut + \"\\n\")\n\n ofile.write(\"portageIniWeights = \" + portageIniWeights + \"\\n\")\n\n ofile.write(\"bleuCountInFile = \" + bleuCountIn + \"\\n\")\n\n ofile.write(\"bleuCountOutFile = \" + bleuCountOut + \"\\n\")\n\n ofile.write(\"decodeCmd = \" + decodeCmd + \"\\n\")\n\n ofile.write(\"weightCmd = \" + weightCmd + \"\\n\")\n\n ofile.write(\"srcFile = \" + srcFile + \"\\n\")\n\n ofile.write(\"refFiles = \" + refFiles + \"\\n\")\n\n ofile.write(\"latticeTmpFile = \" + latticeTmpFile + \"\\n\")\n\n ofile.write(\"C = \" + C + \"\\n\")\n\n ofile.write(\"decay = \" + decay + \"\\n\")\n\n ofile.write(\"background = \" + bg + \"\\n\")\n\n ofile.write(\"density = \" + density + \"\\n\")\n\n #Run run-parallel\n\n rpcmds = workdir + \"/rpcmds\"\n\n with open(rpcmds,\"w\") as rpfile :\n\n for conf in miraConfig :\n\n rpfile.write(\" \".join([\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"MiraLatticeStep\", conf, str(iter),\"\\n\"]))\n\n cmd = [\"run-parallel.sh\",\"-nolocal\",\"-psub\",\"-4\",\"-psub\", \"-memmap 4\", rpcmds,str(opts.numpar)]\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"run-parallel failed: {}\".format(' '.join(cmd)))\n\n #Merge configs into a combined file for next iteration\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"CombineModels\", shardAnnotate(model,iter,\"xx\")]\n\n cmd.extend([shardAnnotate(model,iter,shard) for shard in range(opts.numpar)])\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"merge failed: {}\".format(' '.join(cmd)))\n\n #Average combined file into a Portage-consumable framework\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"AverageModel\", portageIniWeights, shardAnnotate(model,iter,\"xx\"), optimizer_out]\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"averaging failed: {}\".format(' '.join(cmd)))\n\n normalize(olmiraModel2wts(optimizer_out), wts)\n\n #Combine background BLEU counts\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"CombineBleuCounts\", shardAnnotate(count,iter,\"xx\")]\n\n cmd.extend([shardAnnotate(count,iter,shard) for shard in range(opts.numpar)])\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"bleu combination failed: {}\".format(' '.join(cmd)))\n\n #Use combined background BLEU to get a score estimate\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ScoreCountFile\", shardAnnotate(count,iter,\"xx\")]\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n try:\n\n toks = check_output(cmd, stderr=logfile).split()\n\n except CalledProcessError, (num, errstr):\n\n error(\"ScoreCountFile failed for optimizeOnlineLMIRA\", ' '.join(cmd), num, errstr)\n\n except OSError, err:\n\n error(\"Command not found \", ' '.join(cmd), err)\n", "file_path": "src/rescoring/tune.py", "rank": 55, "score": 109670.2852369651 }, { "content": " def write_entry():\n\n \"\"\" Helper function that make sure counts are kept in sync when printing an entry.\"\"\"\n\n ngram_counts[order] += 1\n", "file_path": "src/lm/lm-filter.py", "rank": 56, "score": 109651.93636541211 }, { "content": "inline void\n\nsplitStringZ(const string& s, vector<string>& dest, const string& sep = \" \") {\n", "file_path": "src/utils/str_utils.h", "rank": 57, "score": 109647.81779273118 }, { "content": "namespace ugdiss \n\n{\n\n namespace tsa\n\n {\n\n // template<typename TOKEN>\n\n class\n\n // TSA<TOKEN>::\n\n ArrayEntry : public ttrack::Position\n\n {\n\n public:\n\n char const* pos;\n\n char const* next;\n\n ArrayEntry();\n\n\n\n ArrayEntry(char const* p);\n\n \n\n template<typename TSA_TYPE>\n\n ArrayEntry(TSA_TYPE const* S, char const* p);\n\n\n\n // TOKEN const* suffixStart(TSA<TOKEN> const* S) const;\n\n // TOKEN const* suffixEnd(TSA<TOKEN> const* S) const;\n\n };\n\n\n\n //---------------------------------------------------------------------------\n\n\n\n //---------------------------------------------------------------------------\n\n\n\n template<typename TSA_TYPE>\n\n ArrayEntry::\n\n ArrayEntry(TSA_TYPE const* S, char const* p)\n\n {\n\n S->readEntry(p,*this);\n\n }\n\n\n\n#if 0\n\n //---------------------------------------------------------------------------\n\n\n\n template<typename TOKEN>\n\n TOKEN const*\n\n TSA<TOKEN>::\n\n ArrayEntry::\n\n suffixStart(TSA<TOKEN> const* S) const\n\n {\n\n if (!pos) return NULL;\n\n return S->corpus->sntStart(sid)+offset;\n\n }\n\n\n\n //---------------------------------------------------------------------------\n\n\n\n template<typename TOKEN>\n\n TOKEN const*\n\n TSA<TOKEN>::\n\n ArrayEntry::\n\n suffixEnd(TSA<TOKEN> const* S) const\n\n {\n\n if (!pos) return NULL;\n\n return S->corpus->sntEnd(sid);\n\n }\n\n#endif\n", "file_path": "src/tpt/ug_tsa_array_entry.h", "rank": 58, "score": 109645.69030294115 }, { "content": "namespace ugdiss\n\n{\n\n using namespace std;\n\n\n\n // Pure virtual base class that all ValWriters must be derived from\n\n template<typename T>\n\n class\n\n ValWriterBaseClass\n\n {\n\n public:\n\n virtual void operator()(ostream& out, T const& value) const = 0;\n\n\n\n // returns false if conversion to filepos_type is not supported or failed,\n\n // true otherwise\n\n virtual bool operator()(filepos_type& dest, T const& value) const = 0;\n\n };\n\n\n\n template<typename T>\n\n class\n\n ValReaderBaseClass\n\n {\n\n public:\n\n virtual void operator()(istream& in, T& value) const = 0;\n\n virtual char const* operator()(char const* p, T& value) const = 0;\n\n };\n\n\n\n // Basic Writer and Reader for count types:\n\n template<typename T>\n\n class\n\n GenericValueWriter : public ValWriterBaseClass<T>\n\n {\n\n public:\n\n void operator()(ostream& out, T const& value) const;\n\n bool operator()(filepos_type& dest, T const& value) const;\n\n filepos_type operator()(T const& value) const;\n\n };\n\n\n\n template<typename T>\n\n void\n\n GenericValueWriter<T>::\n\n operator()(ostream& out, T const& value) const\n\n {\n\n out.write(reinterpret_cast<char const*>(&value),sizeof(T));\n", "file_path": "src/tpt/ugReadWriteValues.h", "rank": 59, "score": 109642.03961630039 }, { "content": "#!/usr/bin/env python2\n\n# coding=utf-8\n\n\n\n# @file portage_utils.py\n\n# @brief Useful common Python classes and functions\n\n#\n\n# @author Darlene Stewart & Samuel Larkin & Eric Joanis\n\n#\n\n# Technologies langagieres interactives / Interactive Language Technologies\n\n# Inst. de technologie de l'information / Institute for Information Technology\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2011, 2022, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2011, 2022, Her Majesty in Right of Canada\n\n\n\n# The portage_utils.py library is used by both Python 2.7 scripts (in Portage-SMT-TAS)\n\n# and Python 3 scripts (in PortageTextProcessing and Portage-SMT-TAS), so we keep it\n\n# working for both versions.\n\n\n\nfrom __future__ import print_function, unicode_literals, division, absolute_import\n\n\n\nimport io\n\nimport sys\n\nimport argparse\n\nimport re\n\n\n\nif sys.version_info[0] < 3:\n\n import __builtin__ as builtins\n\nelse:\n\n import builtins\n\nfrom subprocess import Popen, PIPE\n\n\n\n__all__ = [\"printCopyright\",\n\n \"HelpAction\", \"VerboseAction\", \"VerboseMultiAction\", \"DebugAction\",\n\n \"set_debug\", \"set_verbose\",\n\n \"error\", \"fatal_error\", \"warn\", \"info\", \"debug\", \"verbose\",\n\n \"open\", \"split\",\n\n ]\n\n\n\ncurrent_year = 2022\n\n\n\ndef printCopyright(program_name, start_year):\n\n \"\"\"Print the standard NRC Copyright notice.\n\n\n\n The Crown Copyright will be asserted for start_year to latest release year.\n\n\n\n program_name: name of the program\n\n start_year: the first year of Copyright for the program;\n\n \"\"\"\n\n # Just like in sh_utils.sh, we don't actually bother with the Copyright\n\n # statement within Portage.\n\n pass\n\n\n\n\n\nclass HelpAction(argparse.Action):\n\n \"\"\"argparse action class for displaying the help message to stderr.\n\n e.g: parser.add_argument(\"-h\", \"-help\", \"--help\", action=HelpAction)\n\n \"\"\"\n\n def __init__(self, option_strings, dest, help=\"print this help message to stderr and exit\"):\n\n super(HelpAction, self).__init__(option_strings, dest, nargs=0,\n\n default=argparse.SUPPRESS,\n\n required=False, help=help)\n\n def __call__(self, parser, namespace, values, option_string=None):\n\n parser.print_help(file=sys.stderr)\n\n sys.exit()\n\n\n\nclass VerboseAction(argparse.Action):\n\n \"\"\"argparse action class for turning on verbose output.\n\n e.g: parser.add_argument(\"-v\", \"--verbose\", action=VerboseAction)\n\n \"\"\"\n\n def __init__(self, option_strings, dest, help=\"print verbose output to stderr [False]\"):\n\n super(VerboseAction, self).__init__(option_strings, dest, nargs=0,\n\n const=True, default=False,\n\n required=False, help=help)\n\n\n\n def __call__(self, parser, namespace, values, option_string=None):\n\n setattr(namespace, self.dest, True)\n\n set_verbose(True)\n\n\n\nclass VerboseMultiAction(argparse.Action):\n\n \"\"\"argparse action class increase level of verbosity in output.\n\n e.g: parser.add_argument(\"-v\", \"--verbose\", action=VerboseMultiAction)\n\n Using multiple flags increase the verbosity multiple levels.\n\n \"\"\"\n\n def __init__(self, option_strings, dest,\n\n help=\"increase level of verbosity output to stderr [0]\"):\n\n super(VerboseMultiAction, self).__init__(option_strings, dest, nargs=0,\n\n type=int, default=0,\n\n required=False, help=help)\n\n\n\n def __call__(self, parser, namespace, values, option_string=None):\n\n setattr(namespace, self.dest, getattr(namespace, self.dest, 0) + 1)\n\n set_verbose(True)\n\n\n\nclass DebugAction(argparse.Action):\n\n \"\"\"argparse action class for turning on verbose output.\n\n e.g: parser.add_argument(\"-d\", \"--debug\", action=DebugAction)\n\n \"\"\"\n\n def __init__(self, option_strings, dest, help=\"print debug output to stderr [False]\"):\n\n super(DebugAction, self).__init__(option_strings, dest, nargs=0,\n\n const=True, default=False,\n\n required=False, help=help)\n\n\n\n def __call__(self, parser, namespace, values, option_string=None):\n\n setattr(namespace, self.dest, True)\n\n set_debug(True)\n\n\n\n\n\nverbose_flag = False\n\ndebug_flag = False\n\n\n\ndef set_debug(flag):\n\n \"\"\"Set value of the debug flag to control printing of debug messages.\"\"\"\n\n global debug_flag\n\n debug_flag = flag\n\n\n\ndef set_verbose(flag):\n\n \"\"\"Set value of the verbose flag to control printing of debug messages.\"\"\"\n\n global verbose_flag\n\n verbose_flag = flag\n\n\n\ndef error(*args, **kwargs):\n\n \"\"\"Print an error message to stderr.\"\"\"\n\n print(\"Error:\", *args, file=sys.stderr, **kwargs)\n\n return\n\n\n\ndef fatal_error(*args, **kwargs):\n\n \"\"\"Print a fatal error message to stderr and exit with code 1.\"\"\"\n\n print(\"Fatal error:\", *args, file=sys.stderr, **kwargs)\n\n sys.exit(1)\n\n\n\ndef warn(*args, **kwargs):\n\n \"\"\"Print an warning message to stderr.\"\"\"\n\n print(\"Warning:\", *args, file=sys.stderr, **kwargs)\n\n return\n\n\n\ndef info(*args, **kwargs):\n\n \"\"\"Print information output to stderr.\"\"\"\n\n print(*args, file=sys.stderr, **kwargs)\n\n\n\ndef debug(*args, **kwargs):\n\n \"\"\"Print debug output to stderr if debug_flag (-d) is set.\"\"\"\n\n if debug_flag:\n\n print(\"Debug:\", *args, file=sys.stderr, **kwargs)\n\n\n\ndef verbose(*args, **kwargs):\n\n \"\"\"Print verbose output to stderr if verbose_flag (-v) or debug_flag (-d) is set.\"\"\"\n\n if verbose_flag or debug_flag:\n\n print(*args, file=sys.stderr, **kwargs)\n\n\n\ndef open_python2(filename, mode='r', quiet=True):\n\n \"\"\"Transparently open files that are stdin, stdout, plain text, compressed or pipes.\n\n\n\n This version of open() is optimized for python2, with its limited options.\n\n\n\n examples: open(\"-\")\n\n open(\"file.txt\")\n\n open(\"file.gz\")\n\n open(\"zcat file.gz | grep a |\")\n\n\n\n filename: name of the file to open\n\n mode: open mode\n\n quiet: suppress \"zcat: stdout: Broken pipe\" messages.\n\n return: file handle to the open file.\n\n \"\"\"\n\n filename.strip()\n\n #debug(\"open: \", filename, \" in \", mode, \" mode\")\n\n if len(filename) == 0:\n\n fatal_error(\"You must provide a filename\")\n\n\n\n if filename == \"-\":\n\n if mode == 'r':\n\n theFile = sys.stdin\n\n elif mode == 'w':\n\n theFile = sys.stdout\n\n else:\n\n fatal_error(\"Unsupported mode.\")\n\n elif filename.endswith('|'):\n\n theFile = Popen(filename[:-1], shell=True, executable=\"/bin/bash\", stdout=PIPE).stdout\n\n elif filename.startswith('|'):\n\n theFile = Popen(filename[1:], shell=True, executable=\"/bin/bash\", stdin=PIPE).stdin\n\n elif filename.endswith(\".gz\"):\n\n #theFile = gzip.open(filename, mode+'b')\n\n if mode == 'r':\n\n if quiet:\n\n theFile = Popen([\"zcat\", \"-f\", filename], stdout=PIPE, stderr=open('/dev/null', 'w')).stdout\n\n else:\n\n theFile = Popen([\"zcat\", \"-f\", filename], stdout=PIPE).stdout\n\n elif mode == 'w':\n\n internal_file = builtins.open(filename, mode)\n\n theFile = Popen([\"gzip\"], close_fds=True, stdin=PIPE, stdout=internal_file).stdin\n\n else:\n\n fatal_error(\"Unsupported mode for gz files.\")\n\n else:\n\n theFile = builtins.open(filename, mode)\n\n\n\n return theFile\n\n\n\nDEFAULT_ENCODING_VALUE=object() # Sentinel object so we know encoding was not specified\n\ndef open_python3(filename, mode='r', quiet=True, encoding=DEFAULT_ENCODING_VALUE, newline=None):\n\n \"\"\"Transparently open files that are stdin, stdout, plain text, compressed or pipes.\n\n\n\n This version of open() is optimized for Python 3, and supports the encoding\n\n and newline parameters.\n\n\n\n examples: open(\"-\")\n\n open(\"file.txt\", encoding=\"latin1\")\n\n open(\"file.gz\", newline=\"\\n\")\n\n open(\"zcat file.gz | grep a |\")\n\n\n\n filename: name of the file to open\n\n mode: open mode\n\n quiet: suppress \"zcat: stdout: Broken pipe\" messages.\n\n encoding: same as in builtins.open() but defaults to \"utf8\" for text modes\n\n newline: same as in builtins.open()\n\n return: file handle to the open file.\n\n \"\"\"\n\n\n\n if encoding is DEFAULT_ENCODING_VALUE:\n\n encoding = None if \"b\" in mode else \"utf-8\"\n\n if \"b\" in mode and encoding is not None:\n\n fatal_error(\"Cannot specify encoding with binary files\")\n\n\n\n filename.strip()\n\n #debug(\"open: \", filename, \" in \", mode, \" mode\")\n\n if len(filename) == 0:\n\n fatal_error(\"You must provide a filename\")\n\n\n\n if filename == \"-\":\n\n if mode in ('r', 'rt'):\n\n # Notes on this solution: the now more standard\n\n # sys.stdin.reconfigure(encoding='utf-8')\n\n # only works since Python 3.7 and we want to support older versions with\n\n # this very generic library. And io.TextIOWrapper does not work on\n\n # stdin/stdout (at least not with 3.6).\n\n theFile = builtins.open(sys.stdin.fileno(), mode, encoding=encoding, newline=newline)\n\n elif mode == \"rb\":\n\n theFile = sys.stdin\n\n elif mode in ('w', 'wt'):\n\n theFile = builtins.open(sys.stdout.fileno(), mode, encoding=encoding, newline=newline)\n\n elif mode == \"wb\":\n\n theFile = sys.stdout\n\n else:\n\n fatal_error(\"Unsupported mode.\")\n\n elif filename.endswith('|'):\n\n theFile = Popen(filename[:-1], shell=True, executable=\"/bin/bash\", stdout=PIPE).stdout\n\n if \"b\" not in mode:\n\n theFile = io.TextIOWrapper(theFile, encoding=encoding, newline=newline)\n\n elif filename.startswith('|'):\n\n theFile = Popen(filename[1:], shell=True, executable=\"/bin/bash\", stdin=PIPE).stdin\n\n if \"b\" not in mode:\n\n theFile = io.TextIOWrapper(theFile, encoding=encoding, newline=newline)\n\n elif filename.endswith(\".gz\"):\n\n #theFile = gzip.open(filename, mode+'b')\n\n if mode in ('r', 'rt', 'rb'):\n\n if quiet:\n\n theFile = Popen([\"zcat\", \"-f\", filename], stdout=PIPE,\n\n stderr=open('/dev/null', 'w')).stdout\n\n else:\n\n theFile = Popen([\"zcat\", \"-f\", filename], stdout=PIPE).stdout\n\n if \"b\" not in mode:\n\n theFile = io.TextIOWrapper(theFile, encoding=encoding, newline=newline)\n\n elif mode in ('w', 'wt', 'wb'):\n\n internal_file = builtins.open(filename, \"wb\")\n\n theFile = Popen([\"gzip\"], close_fds=True, stdin=PIPE, stdout=internal_file).stdin\n\n if \"b\" not in mode:\n\n theFile = io.TextIOWrapper(theFile, encoding=encoding, newline=newline)\n\n else:\n\n fatal_error(\"Unsupported mode for gz files.\")\n\n else:\n\n theFile = builtins.open(filename, mode, encoding=encoding, newline=newline)\n\n\n\n return theFile\n\n\n\nif sys.version_info[0] < 3:\n\n open = open_python2\n\nelse:\n\n open = open_python3\n\n\n\n# Regular expression to match whitespace the same way that split() in\n\n# str_utils.cc does, i.e. sequence of spaces, tabs, and/or newlines.\n\nsplit_re = re.compile('[ \\t\\n]+')\n\n\n\ndef split(s):\n\n \"\"\"Split s into tokens the same way split() in str_utils.cc does, i.e.\n\n using any sequence of spaces, tabs, and/or newlines as a delimiter, and\n\n ignoring leading and trailing whitespace.\n\n\n\n s: string to be split into token\n\n returns: list of string tokens\n\n \"\"\"\n\n ss = s.strip(' \\t\\n')\n\n return [] if len(ss) == 0 else split_re.split(ss)\n\n\n\n\n\nif __name__ == '__main__':\n\n pass\n", "file_path": "src/utils/portage_utils.py", "rank": 60, "score": 108422.39190249688 }, { "content": "/// Phrase stored in a regular, unpacked vector.\n\n/// VectorPhrase and CompactPhrase are designed to be fully interchangeable\n\n/// and support automatic conversions in both directions.\n\nclass VectorPhrase : public vector<Uint> {\n\n public:\n\n using vector<Uint>::operator=;\n\n VectorPhrase& operator=(const VectorPhrase& other)\n\n { vector<Uint>::operator=(other); return *this; }\n\n VectorPhrase& operator=(const CompactPhrase& cPhrase)\n\n { cPhrase.toPhrase(*this); return *this; }\n\n VectorPhrase(const CompactPhrase& cPhrase) { cPhrase.toPhrase(*this); }\n\n VectorPhrase(const VectorPhrase& other) { *this = other; }\n\n VectorPhrase(size_t size, Uint default_val = 0)\n\n : vector<Uint>(size,default_val) {}\n\n template <class InputIterator>\n\n VectorPhrase(InputIterator first, InputIterator last)\n\n : vector<Uint>(first, last) {}\n\n VectorPhrase() {}\n\n}; // VectorPhrase\n\n\n\n/**\n\n * Convert a phrase from a Uint sequence (VectorPhrase or CompactPhrase) to a\n\n * space separated string.\n", "file_path": "src/utils/compact_phrase.h", "rank": 61, "score": 107288.50320895025 }, { "content": " class random_param : public vector<string>\n\n {\n\n private:\n\n /// Default random distribution's string representation\n\n static const string default_value; // = \"U(-1.0,1.0)\";\n\n public:\n\n /**\n\n * Converts the internal string representation to the proper random\n\n * distribution. If user didn't specify all random distribution, then\n\n * this will return a default predefined random distribution.\n\n * Note that for better randomness each returned distribution should be seed.\n\n * Note that this returns a new object each time that needs to be deleted.\n\n * @param index of random distriubtion's string to convert.\n\n * @return Returns a random distribution object.\n\n */\n\n rnd_distribution* get(Uint index) const;\n\n };\n\n\n\npublic:\n\n\n", "file_path": "src/canoe/config_io.h", "rank": 62, "score": 107254.61836439942 }, { "content": " def statusString(self):\n\n if self.cowlog_exists:\n\n msg = \"\" if self.canoe_wts_exist else \"cow not finished\"\n\n else:\n\n msg = \"no local cow\" if self.canoe_wts_exist else \"cow not run\"\n\n if self.cow_iter or msg:\n\n return \"({0})\".format(\"; \".join(s for s in (self.cow_iter, msg) if s))\n", "file_path": "src/utils/summarize-canoe-results.py", "rank": 63, "score": 106530.19548693005 }, { "content": "struct newSrcSentInfo {\n\n\n\n /// The BasicModel for this source sentence, as soon as it's known.\n\n BasicModel* model;\n\n\n\n /// A unique index for source sentences as internally processed by this\n\n /// instance of canoe. Must correspond sequentially to the order in which\n\n /// that instance of canoe has processed each sentence.\n\n Uint internal_src_sent_seq;\n\n\n\n /// The external source sentence ID, typically the line number in the input\n\n /// file to, say, canoe-parallel.sh. Used to create output file names.\n\n /// May be used by models to select the appropriate line in any data files\n\n /// line-aligned with the global input. Zero-based.\n\n Uint external_src_sent_id;\n\n\n\n /// The source sentence.\n\n vector<string> src_sent;\n\n\n\n /// Marked translation options available.\n", "file_path": "src/canoe/new_src_sent_info.h", "rank": 64, "score": 105850.29859450454 }, { "content": " Uint cptTrieDataUsed = list_alloc;\n", "file_path": "src/utils/trie_node-cc.h", "rank": 65, "score": 103615.914525665 }, { "content": "using namespace std;\n", "file_path": "src/tpt/ugMemTreeNode_preorder_iterator.h", "rank": 66, "score": 103613.42931682101 }, { "content": "def main():\n\n cmd_args = get_args()\n\n\n\n # Allow the file streams to handle non-ascii characters.\n\n infile = codecs.getreader(\"utf-8\")(cmd_args.infile)\n\n outfile = codecs.getwriter(\"utf-8\")(cmd_args.outfile)\n\n if cmd_args.rulesfile is None:\n\n rulesfile = None\n\n else:\n\n rulesfile = codecs.getwriter(\"utf-8\")(cmd_args.rulesfile)\n\n sys.stderr = codecs.getwriter(\"utf-8\")(sys.stderr)\n\n\n\n if cmd_args.buckwalter:\n\n loadMappingData(cmd_args.mapfile)\n\n\n\n # New rule 1.0 is old rule 2-1.\n\n # New rule 2.0 is old rule 2-2.\n\n # New rule 3.0 is old (fixed) rule 2-3.\n\n # New rule 3.1 handles words of old rules 2-6/2-8 with old (fixed) rule 2-3 placement.\n\n # New rule 3.2 handles words of old rules 2-5/2-7 with old (fixed) rule 2-3 placement.\n\n # New rule 3.3 adds handling of vocative particle using old (fixed) rule 2-3 placement.\n\n # New rule 3.4 adds handling of pronoun (this) using old (fixed) rule 2-3 placement.\n\n # New rule 4.0 is old (fixed) rule 2-4.\n\n # New rule 5.0 extends old (fixed) rules 3-1/3-2 to all Arabic letters repeated >2 times.\n\n # New rule 5.1 extends old (fixed) rules 3-1/3-2 to a particular repeated letter-pair (LAM + ALIF).\n\n # New rule 5.2 extends old (fixed) rules 3-1/3-2 to long vowels YEH as well as WAW\n\n # repeated twice or more. (ALIF is moved to rule 5.3)\n\n # New rule 5.3 is rule 5.2 for ALIF.\n\n # Notes: not-start-of-word: (?<!^)(?<! ) not-end-of-word: (?! )(?!$)\n\n\n\n # Using a literal initializer for pat_ar doesn't work very well because we\n\n # end up with the lines displaying left to right in some tools.\n\n # Assignment statements with only a single, short Arabic word display\n\n # left-to-right, as expected.\n\n # pat_ar = {\n\n # \"1.0\": ( \"ى\", \"ء\", \"ئ\", \"ة\", ),\n\n # \"2.0\": ( \"ال\", ),\n\n # \"3.0\": ( \"لا\", \"و\", ),\n\n # \"3.1\": ( \"إذا\", \"لذا\", \"ما\", ),\n\n # \"3.2\": ( \"اً\", \"أن\",),\n\n # \"3.3\": ( \"يا\", ),\n\n # \"3.4\": ( \"هذا\", ),\n\n # \"4.0\": ( \"د\", \"ذ\", \"ر\", \"ز\", \"و\", ),\n\n # \"5.1\": ( \"لا\", ),\n\n # \"5.2\": ( \"و\", \"ي\", ),\n\n # \"5.3\": ( \"ا\", ),\n\n # }\n\n\n\n pat_ar = {}\n\n ar = pat_ar[\"1.0\"] = [\"\"] * 4\n\n ar[0] = \"ى\"\n\n ar[1] = \"ء\"\n\n ar[2] = \"ئ\"\n\n ar[3] = \"ة\"\n\n ar = pat_ar[\"2.0\"] = [\"\"] * 1\n\n ar[0] = \"ال\"\n\n ar = pat_ar[\"3.0\"] = [\"\"] * 2\n\n ar[0] = \"و\"\n\n ar[1] = \"لا\"\n\n ar = pat_ar[\"3.1\"] = [\"\"] * 3\n\n ar[0] = \"إذا\"\n\n ar[1] = \"لذا\"\n\n ar[2] = \"ما\"\n\n ar = pat_ar[\"3.2\"] = [\"\"] * 2\n\n ar[0] = \"اً\"\n\n ar[1] = \"أنا\"\n\n ar = pat_ar[\"3.3\"] = [\"\"] * 1\n\n ar[0] = \"يا\"\n\n ar = pat_ar[\"3.4\"] = [\"\"] * 1\n\n ar[0] = \"هذا\"\n\n ar = pat_ar[\"4.0\"] = [\"\"] * 5\n\n ar[0] = \"د\"\n\n ar[1] = \"ذ\"\n\n ar[2] = \"ر\"\n\n ar[3] = \"ز\"\n\n ar[4] = \"و\"\n\n pat_ar[\"5.0\"] = [\"[\\u0620-\\u064A]\"]\n\n ar = pat_ar[\"5.1\"] = [\"\"] * 1\n\n ar[0] = \"لا\"\n\n ar = pat_ar[\"5.2\"] = [\"\"] * 2\n\n ar[0] = \"و\"\n\n ar[1] = \"ي\"\n\n ar = pat_ar[\"5.3\"] = [\"\"] * 1\n\n ar[0] = \"ا\"\n\n\n\n # Buckwalter pattern notes:\n\n # - We must escape characters with special meaning in Python re patterns,\n\n # hence the use of raw strings and '\\' before some characters.\n\n # - We expect the buckwalter characters '<' and '>' to be backslash\n\n # escaped; we handle the backslashes outside the rules.\n\n pat_bw = {\n\n \"1.0\": ( \"Y\", \"'\", r\"\\}\", \"p\", ),\n\n \"2.0\": ( \"Al\", ),\n\n \"3.0\": ( \"w\", \"lA\", ),\n\n \"3.1\": ( r\"<\\*A\", r\"l\\*A\", \"mA\", ),\n\n \"3.2\": ( \"AF\", \">nA\", ),\n\n \"3.3\": ( \"yA\", ),\n\n \"3.4\": ( r\"h\\*A\", ),\n\n \"4.0\": ( \"d\", r\"\\*\", \"r\", \"z\", \"w\", ),\n\n \"5.0\": ( \"[a-zA-Z$&'*<>_`{|}~]\", ),\n\n \"5.1\": ( \"lA\", ),\n\n \"5.2\": ( \"w\", \"y\", ),\n\n \"5.3\": ( \"A\", ),\n\n }\n\n\n\n pat_txt = pat_bw if cmd_args.buckwalter else pat_ar\n\n\n\n pat = {}\n\n\n\n # Rules 1.0 and 2.0 need to be applied only once, where the matched text\n\n # occurs in the middle of a token.\n\n for rule_id in (\"1.0\", \"2.0\"):\n\n pat[rule_id] = \"(?<!^)(?<! )(\" + '|'.join(pat_txt[rule_id]) + \")(?! )(?!$)\"\n\n\n\n # Rules 3.* are applied repeatedly to tokens where the matched text is preceded\n\n # by at most 1 character in the word and followed by at least two characters.\n\n for rule_id in (\"3.0\", \"3.1\", \"3.2\", \"3.3\", \"3.4\"):\n\n pat[rule_id] = \"(?<![^ ]{2})(\" + '|'.join(pat_txt[rule_id]) + \")(?=[^ ]{2})\"\n\n\n\n # For application of rule 4.0, the updated OOV text is retokenized, and the\n\n # substitution is applied only to tokens of length > 7 characters.\n\n pat[\"4.0\"] = \"(?<!^)(\" + '|'.join(pat_txt[\"4.0\"]) + \")(?!$)\"\n\n\n\n # Rules 5.* merely remove repeated characters, thus have no tokenization effect.\n\n pat[\"5.0\"] = \"(\" + '|'.join(pat_txt[\"5.0\"]) + r\")\\1\\1+\"\n\n for rule_id in (\"5.1\", \"5.2\", \"5.3\"):\n\n pat[rule_id] = \"(\" + '|'.join(pat_txt[rule_id]) + r\")\\1+\"\n\n\n\n rules = {\n\n \"1.0\": (re.compile(pat[\"1.0\"]), r\"\\1 \"),\n\n \"2.0\": (re.compile(pat[\"2.0\"]), r\" \\1\"),\n\n \"3.0\": (re.compile(pat[\"3.0\"]), r\"\\1 \"),\n\n \"3.1\": (re.compile(pat[\"3.1\"]), r\"\\1 \"),\n\n \"3.2\": (re.compile(pat[\"3.2\"]), r\"\\1 \"),\n\n \"3.3\": (re.compile(pat[\"3.3\"]), r\"\\1 \"),\n\n \"3.4\": (re.compile(pat[\"3.4\"]), r\"\\1 \"),\n\n \"4.0\": (re.compile(pat[\"4.0\"]), r\"\\1 \"),\n\n \"5.0\": (re.compile(pat[\"5.0\"]), r\"\\1\"),\n\n \"5.1\": (re.compile(pat[\"5.1\"]), r\"\\1\"),\n\n \"5.2\": (re.compile(pat[\"5.2\"]), r\"\\1\"),\n\n \"5.3\": (re.compile(pat[\"5.3\"]), r\"\\1\"),\n\n }\n\n\n\n # The rules are applied in order according to the cat_N_rules lists.\n\n # Category 1 rules are applied first, each applied once.\n\n # Category 2 rules are then applied repeatedly until no more changes result;\n\n # at most 1 letter precede and at least 2 letters follow the matched text.\n\n # Category 1b exists to postpone the application of rule 5 for double Alif\n\n # until after category 2 rules are applied, which may split the double Alif.\n\n # Category 3 rules are applied last, each applied once to tokens of length > 7.\n\n cat_1_rules = (\"5.0\", \"5.1\", \"5.2\", \"1.0\", \"2.0\",)\n\n cat_2_rules = (\"3.0\", \"3.1\", \"3.2\", \"3.3\", \"3.4\",)\n\n cat_1b_rules = (\"5.3\",)\n\n cat_3_rules = (\"4.0\",)\n\n\n\n rule_cnts_oov = {}\n\n rule_cnts_appl = {}\n\n rule_cnts_all = {}\n\n for rule_id in rules:\n\n rule_cnts_oov[rule_id] = 0\n\n rule_cnts_appl[rule_id] = 0\n\n rule_cnts_all[rule_id] = 0\n\n\n\n def print_rule(rule_id, text):\n\n if rulesfile is not None:\n\n print(oov_count, 'm', rule_id, ' ', text, sep='', file=rulesfile)\n\n\n\n def apply_rule(rule_id, text, update_oov_cnt, do_print):\n\n \"\"\"\n\n Apply the specified rule to some text, printing the result if requested.\n\n\n\n rule_id: ID of the rule to apply, e.g. \"3.1\"\n\n text: text string to apply the rule to; can contain one or more words.\n\n update_oov_cnt: update the OOV count for the rule if True.\n\n do_print: outputs rule tag and updated text if True.\n\n returns a tuple consisting of the updated text and the number of changes.\n\n \"\"\"\n\n pat, repl = rules[rule_id]\n\n updated_text, n = re.subn(pat, repl, text)\n\n if n > 0:\n\n if do_print:\n\n print_rule(rule_id, updated_text)\n\n if update_oov_cnt: rule_cnts_oov[rule_id] += 1\n\n rule_cnts_appl[rule_id] += 1\n\n rule_cnts_all[rule_id] += n\n\n return updated_text, n\n\n\n\n def apply_rules(oov):\n\n \"\"\"Apply rules to an OOV returning the updated oov text.\"\"\"\n\n print_rule('0.0', oov)\n\n updated_text = oov\n\n\n\n # For buckwalter text, temporarily remove the XML escapes, so letter\n\n # counts for rules will be correct.\n\n # i.e. '&gt;' -> '>', '&lt;' -> '<', &amp;' -> '&'.\n\n if cmd_args.buckwalter and cmd_args.oov_tags:\n\n updated_text, n_esc_gt = re.subn('&gt;', '>', updated_text)\n\n updated_text, n_esc_lt = re.subn('&lt;', '<', updated_text)\n\n updated_text, n_esc_amp = re.subn('&amp;', '&', updated_text)\n\n\n\n # Category 1 rules need to be applied only once.\n\n for rule_id in cat_1_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, True, True)\n\n\n\n # Category 2 rules need to be re-applied until no more changes occur.\n\n num_changes = -1\n\n first_time = True\n\n while first_time or num_changes != 0:\n\n num_changes = 0\n\n for rule_id in cat_2_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, first_time, True)\n\n num_changes += n\n\n first_time = False\n\n\n\n # Category 1b rules need to be applied only once.\n\n for rule_id in cat_1b_rules:\n\n updated_text, n = apply_rule(rule_id, updated_text, True, True)\n\n\n\n # Category 3 rules need to be applied once only to words with length > 7.\n\n upd_wrds = split(updated_text)\n\n for rule_id in cat_3_rules:\n\n pat, repl = rules[rule_id]\n\n num_changes = 0\n\n for i, wrd in enumerate(upd_wrds):\n\n if len(wrd) > 7:\n\n upd_wrds[i], n = apply_rule(rule_id, wrd, num_changes==0, False)\n\n num_changes += n\n\n if num_changes > 0:\n\n updated_text = ' '.join(upd_wrds)\n\n print_rule(rule_id, updated_text)\n\n\n\n # Re-apply the MADA Map if operating on buckwalter transliterated text.\n\n if cmd_args.buckwalter and updated_text != oov:\n\n updated_text = ' '.join(word2morpho.get(wrd, wrd) for wrd in split(updated_text))\n\n\n\n # For buckwalter text, restore previously removed XML escapes\n\n # i.e. '&gt;' -> '>', '&lt;' -> '<', &amp;' -> '&'.\n\n if cmd_args.buckwalter and cmd_args.oov_tags:\n\n updated_text, n = re.subn('&', '&amp;', updated_text)\n\n updated_text, n = re.subn('>', '&gt;', updated_text)\n\n updated_text, n = re.subn('<', '&lt;', updated_text)\n\n\n\n print_rule('X.X', updated_text)\n\n return updated_text\n\n\n\n line_number = 0;\n\n oov_count=0\n\n\n\n for line in infile:\n\n line_number += 1\n\n out_line = []\n\n if not cmd_args.oov_tags:\n\n oov_count += 1\n\n out_line.append(apply_rules(line.strip()))\n\n else:\n\n oov_start = oov_end = False\n\n for token in split(line):\n\n if token.startswith(\"<oov>\"):\n\n token = token[5:]\n\n oov_start = True\n\n if token.endswith(\"</oov>\"):\n\n token = token[:-6]\n\n oov_end = True\n\n if not oov_start:\n\n out_line.append(token)\n\n else:\n\n if len(token) > 0:\n\n oov_count += 1\n\n out_line.append(apply_rules(token))\n\n if oov_end:\n\n oov_start = oov_end = False\n\n if oov_start:\n\n error(\"Missing </oov> for oov\", oov_count, \"in line\", line_number)\n\n print(*out_line, file=outfile)\n\n\n\n # Print the stats\n\n verbose(\"Rules applied (# OOV words)\")\n\n for rule_id in sorted(rule_cnts_oov.keys()):\n\n verbose(rule_id, \": \", rule_cnts_oov[rule_id], sep='')\n\n verbose(\"Rules applied (# rule applications)\")\n\n for rule_id in sorted(rule_cnts_appl.keys()):\n\n verbose(rule_id, \": \", rule_cnts_appl[rule_id], sep='')\n\n verbose(\"Rules applied (total # changes)\")\n\n for rule_id in sorted(rule_cnts_all.keys()):\n", "file_path": "src/textutils/apply_ar_tweet_oov_rules.py", "rank": 67, "score": 103605.54286372798 }, { "content": " def get_unquoted_value(self, key):\n\n value = self[key]\n\n if len(value) > 1 and value[0] in \"'\\\"\" and value[0] == value[-1]:\n\n return value[1:-1]\n", "file_path": "src/utils/incr-init-model.py", "rank": 68, "score": 103602.58597419965 }, { "content": " def in_test_sets_to_list(test_set):\n\n \"\"\"Return true if the named test_set should be listed in the results.\"\"\"\n", "file_path": "src/utils/summarize-canoe-results.py", "rank": 69, "score": 103600.91982978425 }, { "content": " def getTestSets(self):\n\n \"\"\"Return the names of test sets with scores in this DirInfo object.\"\"\"\n", "file_path": "src/utils/summarize-canoe-results.py", "rank": 70, "score": 103600.80030994599 }, { "content": " private function validLanguagesToString()\n\n {\n\n return '{' . implode(\", \", array_keys($this->validLanguages)) . '}';\n\n }\n\n\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 71, "score": 102152.29854119959 }, { "content": "def get_args():\n\n \"\"\"Command line argument processing.\"\"\"\n\n\n\n usage=\"apply_ar_tweet_oov_rules.py [options] [infile [outfile]]\"\n\n help=\"\"\"\n\n Apply Arabic tweet preprocessing rules to Arabic OOVs in either the original\n\n Arabic text or buckwalter transliterated text.\n\n \n\n The script can also produce a rules output file in which each OOV is\n\n identified by word count, each rule applied is identified by the rule ID,\n\n and both the original and transformed text are output.\n\n \"\"\"\n\n\n\n # Use the argparse module, not the deprecated optparse module.\n\n parser = ArgumentParser(usage=usage, description=help, add_help=False)\n\n\n\n # Use our standard help, verbose and debug support.\n\n parser.add_argument(\"-h\", \"-help\", \"--help\", action=HelpAction)\n\n parser.add_argument(\"-v\", \"--verbose\", action=VerboseAction)\n\n parser.add_argument(\"-d\", \"--debug\", action=DebugAction)\n\n\n\n translit = parser.add_mutually_exclusive_group()\n\n translit.add_argument('-bw', '--buckwalter', dest=\"buckwalter\",\n\n action='store_true', default=True,\n\n help=\"Select buckwalter transliteration. [True]\")\n\n translit.add_argument('-ar', '--arabic', dest=\"buckwalter\",\n\n action='store_false', default=True,\n\n help=\"Select raw Arabic text. [False]\")\n\n\n\n parser.add_argument(\"-oov\", \"-t\", \"--oovtags\", dest=\"oov_tags\",\n\n action='store_true', default=False,\n\n help='''OOVs are marked up in the input by XML tags,\n\n i.e.<oov>oov-phrase</oov>. OOV tags are removed in\n\n the output. [%(default)s]''')\n\n\n\n parser.add_argument(\"-r\", \"--rules\", dest=\"rulesfile\", nargs='?',\n\n type=FileType('w'), const=sys.stderr, default=None,\n\n help='''File to output applied rules info to.\n\n [None if no option, sys.stderr if no filename]''')\n\n\n\n parser.add_argument(\"-m\", \"--map\", dest=\"mapfile\", type=str, default=None,\n\n help='''MADA Map file to use with -bw.\n\n [search plugins + PERL5LIB for tokenize/Arabic/Data.pm]''')\n\n\n\n # The following use the portage_utils version of open to open files.\n\n parser.add_argument(\"infile\", nargs='?', type=open, default=sys.stdin,\n\n help=\"input file [sys.stdin]\")\n\n parser.add_argument(\"outfile\", nargs='?', type=lambda f: open(f,'w'),\n\n default=sys.stdout,\n\n help=\"output file [sys.stdout]\")\n\n\n\n cmd_args = parser.parse_args()\n\n\n", "file_path": "src/textutils/apply_ar_tweet_oov_rules.py", "rank": 72, "score": 100835.09697941104 }, { "content": " def print_rule(rule_id, text):\n\n if rulesfile is not None:\n", "file_path": "src/textutils/apply_ar_tweet_oov_rules.py", "rank": 73, "score": 100828.55430329157 }, { "content": "class cacheValue {\n\n friend class test_cacheValue;\n\n\n\n private:\n\n const Uint min; /// Minimum value for which we hold a value.\n\n const Uint max; /// Maximum value for which we hold a value.\n\n FUNC func; /// Function we want to precompute.\n\n vector<T> values; /// Precomputed values.\n\n\n\n public:\n\n /**\n\n * Default constructor.\n\n * @param func function that we want to precompute.\n\n * @param min minimum value we want to precompute.\n\n * @param max maximum value we want to precompute.\n\n */\n\n cacheValue(FUNC func, Uint max, Uint min = 0)\n\n : min(min)\n\n , max(max)\n\n , func(func)\n", "file_path": "src/utils/cache_value.h", "rank": 74, "score": 100733.12823928439 }, { "content": "/// Set of integers with constant-time on clear()\n\nclass QuickSet {\n\n\n\n /// The elements in the set, in order of insertion.\n\n vector<Uint> list;\n\n\n\n /// Map for constant-time verification of set membership. For each element e\n\n /// in the set, map[e] contains the index of e in list, ie list[map[e]] == e.\n\n /// If this doesn't hold, or if it's undefined due to size violations, then\n\n /// e is not in the set.\n\n vector<Uint> map;\n\n\n\npublic:\n\n\n\n /// Number of elements in the set.\n\n Uint size() { return list.size(); }\n\n\n\n /// Set is empty.\n\n bool empty() { return list.empty(); }\n\n\n\n /**\n", "file_path": "src/utils/quick_set.h", "rank": 75, "score": 100715.32475836089 }, { "content": "def loadMappingData(mapfile):\n\n \"\"\"Loaded the MADA Map data from the specified file or the Perl\n\n tokenize/Arabic/Data.pm module.\n\n\n\n mapfile: MADA Map file pathname; None triggers searching the plugins and\n\n PERL5LIB for tokenize/Arabic/Data.pm. If the mapfile ends in '.json' then\n\n it is treated as a pure JSON file, not a Perl module with a __Data__ tag.\n\n \"\"\"\n\n global word2morpho\n\n if mapfile is None:\n\n # First look for the map relative to the plugins location, then in PERL5LIB\n\n which_cmd = 'which tokenize_plugin_ar 2> /dev/null; exit 0'\n\n perl5lib = [os.path.dirname(subprocess.check_output(which_cmd, shell=True))]\n\n perl5lib += os.environ['PERL5LIB'].split(':')\n\n for libdir in perl5lib:\n\n if not libdir: continue\n\n mapfile = os.path.join(libdir, \"tokenize\", \"Arabic\", \"Data.pm\")\n\n if os.path.exists(mapfile):\n\n break\n\n else:\n\n error(\"tokenize/Arabic/Data.pm module not found.\")\n\n else:\n\n if mapfile == '/dev/null':\n\n info(\"Not using MADA Map (/dev/null).\")\n\n return\n\n info(\"Using MADA Map:\", mapfile)\n\n if mapfile.endswith(\".json\"):\n\n data_pipe = open(mapfile)\n\n else:\n\n # The JSON data follows the __DATA__ tag in the Data.pm file.\n\n cmd = \"sed -e '1,/__DATA__/d' \" + mapfile\n\n data_pipe = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout\n\n word2morpho = json.load(data_pipe)\n", "file_path": "src/textutils/apply_ar_tweet_oov_rules.py", "rank": 76, "score": 98196.54566317772 }, { "content": " # Load models in memory\n\n public function primeModels($context, $PrimeMode)\n\n {\n\n $rc = 0;\n\n $i = $this->getContextInfo($context);\n\n $this->validateContext($i);\n\n $command = \"prime.sh $PrimeMode\";\n\n $this->runCommand($command, \"\", $i, $rc, false);\n\n\n\n if ($rc != 0)\n\n throw new SoapFault(\"PortagePrimeError\",\n\n \"Failed to prime, something went wrong in prime.sh.\\n\"\n\n . \"rc=$rc; Command=$command\");\n\n\n\n return true;\n\n }\n\n\n", "file_path": "PortageLive/www/PortageLiveLib.php", "rank": 77, "score": 97281.78036792608 }, { "content": " /// Forward IBM1Deletion\n\n class IBM1DeletionTgtGivenSrc: public IBM1DeletionBase {\n\n public:\n\n /// Constructor.\n\n /// @param args arguments.\n\n IBM1DeletionTgtGivenSrc(const string &args) : IBM1DeletionBase(args) {}\n\n \n\n virtual double value(Uint k) {\n\n return computeValue((*src_sents)[s].getTokens(), (*nbest)[k].getTokens());\n\n }\n\n }; // IBM1DeletionTgtGivenSrc\n\n \n", "file_path": "src/rescoring/ibm1del.h", "rank": 78, "score": 96690.80535899653 }, { "content": " /// Backward IBM1Deletion\n\n class IBM1DeletionSrcGivenTgt: public IBM1DeletionBase {\n\n public:\n\n /// Constructor.\n\n /// @param args arguments.\n\n IBM1DeletionSrcGivenTgt(const string &args) : IBM1DeletionBase(args) {}\n\n \n\n virtual double value(Uint k) {\n\n return computeValue((*nbest)[k].getTokens(), (*src_sents)[s].getTokens());\n\n }\n\n }; // IBM1DeletionSrcGivenTgt\n\n} // Portage\n\n\n\n#endif // IBM1DELETION_FF_H\n", "file_path": "src/rescoring/ibm1del.h", "rank": 79, "score": 96690.80535899653 }, { "content": "#include \"voc.h\"\n\n#include <vector>\n\n#include <string>\n\n#include <boost/shared_ptr.hpp>\n\n\n\n\n\nnamespace Portage {\n\n\n\nusing namespace std;\n\n\n\n// Forward declaration\n", "file_path": "src/canoe/new_src_sent_info.h", "rank": 80, "score": 96078.29502513986 }, { "content": " external_src_sent_id = 0;\n\n src_sent.clear();\n\n marks.clear();\n\n potential_phrases = NULL;\n\n tgt_sent = NULL;\n\n tgt_sent_ids.clear();\n\n oovs = NULL;\n\n walls.clear();\n\n zones.clear();\n\n local_walls.clear();\n\n }\n\n\n\n /**\n\n * Converts the string representation of the target sentence to a uint\n\n * representation of that target sentence.\n\n * @param voc the vocabulary to use to convert the target sentence.\n\n */\n\n void convertTargetSentence(const Voc& voc)\n\n {\n\n if (tgt_sent != NULL) {\n", "file_path": "src/canoe/new_src_sent_info.h", "rank": 81, "score": 96076.73285776436 }, { "content": " voc.index(*tgt_sent, tgt_sent_ids);\n\n }\n\n }\n\n\n\n /// Prints the content of the newSrcSentInfo.\n\n /// @param out stream to output the content of newSrcSentInfo.\n\n void print(ostream& out = cerr) const\n\n {\n\n out << \"internal_src_sent_seq: \" << internal_src_sent_seq << endl;\n\n out << \"external_src_sent_id: \" << external_src_sent_id << endl;\n\n out << join(src_sent) << endl;\n\n if (tgt_sent != NULL)\n\n out << join(*tgt_sent) << endl;\n\n if (!tgt_sent_ids.empty())\n\n out << join(tgt_sent_ids) << endl;\n\n if (oovs != NULL)\n\n out << join(*oovs) << endl;\n\n }\n\n\n\n void printTriangularArrayAsCPT(ostream& out = cerr) const;\n\n\n\n ostream& toJSON(ostream& out = cerr, Voc const * const voc = NULL) const;\n\n}; // ends newSrcSentInfo\n\n\n\ntypedef boost::shared_ptr<newSrcSentInfo> PSrcSent;\n\n\n", "file_path": "src/canoe/new_src_sent_info.h", "rank": 82, "score": 96075.03720710971 }, { "content": " /// contains an out-of-vocabulary word.\n\n vector<bool>* oovs;\n\n\n\n /// List of walls\n\n vector<SrcWall> walls;\n\n /// List of zones\n\n vector<SrcZone> zones;\n\n /// List of local walls\n\n vector<SrcLocalWall> local_walls;\n\n\n\n /// Default constructor initializes everything to NULL/0/empty.\n\n newSrcSentInfo() { clear(); }\n\n /// Destructor NULLs all the pointers, just to be safe\n\n ~newSrcSentInfo() { clear(); }\n\n\n\n /// Resets this new source sentence info to an empty state.\n\n void clear()\n\n {\n\n model = NULL;\n\n internal_src_sent_seq = 0;\n", "file_path": "src/canoe/new_src_sent_info.h", "rank": 83, "score": 96074.1171702546 }, { "content": " vector<MarkedTranslation> marks;\n\n\n\n /// Optional tags for src sent (either empty or one per token in src_sent).\n\n vector<string> src_sent_tags;\n\n\n\n /// Triangular array of the candidate target phrases.\n\n /// Filled by BasicModelGenerator::createModel.\n\n vector<PhraseInfo *>** potential_phrases;\n\n\n\n /// Optional target sentence, for Levenshtein and NGramMatch features.\n\n /// Provided by the user of canoe.\n\n const vector<string>* tgt_sent;\n\n\n\n /// Optional Uint representation of the target sentence.\n\n /// Filled by BasicModelGenerator::createModel.\n\n vector<Uint> tgt_sent_ids;\n\n\n\n /// Optional out-of-vocabulary\n\n /// Filled by BasicModelGenerator::createAllPhraseInfos.\n\n /// If not NULL, will be set to true for each position in src_sent that\n", "file_path": "src/canoe/new_src_sent_info.h", "rank": 84, "score": 96070.55378658697 }, { "content": "/**\n\n * @author Samuel Larkin\n\n * @file new_src_sent_info.h\n\n * Groups all the information about a source sentence needed by a decoder feature.\n\n *\n\n *\n\n * COMMENTS:\n\n *\n\n * Technologies langagieres interactives / Interactive Language Technologies\n\n * Inst. de technologie de l'information / Institute for Information Technology\n\n * Conseil national de recherches Canada / National Research Council Canada\n\n * Copyright 2008, Sa Majeste la Reine du Chef du Canada /\n\n * Copyright 2008, Her Majesty in Right of Canada\n\n */\n\n\n\n#ifndef __NEW_SOURCE_SENTENCE_INFO__H__\n\n#define __NEW_SOURCE_SENTENCE_INFO__H__\n\n\n\n#include \"portage_defs.h\"\n\n#include \"marked_translation.h\"\n", "file_path": "src/canoe/new_src_sent_info.h", "rank": 85, "score": 96066.28280684294 }, { "content": "#!/usr/bin/env python2\n\n# -*- coding: utf-8 -*-\n\n\n\n# @file prog.py\n\n# @brief Briefly describe your script here.\n\n#\n\n# @author Write your name here\n\n#\n\n# Traitement multilingue de textes / Multilingual Text Processing\n\n# Centre de recherche en technologies numériques / Digital Technologies Research Centre\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2020, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2020, Her Majesty in Right of Canada\n\n\n\n\"\"\"\n\nThis program shows how to:\n\n - turn on Python 3 features, including the print function\n\n - import portage_utils\n\n - use the argparse.ArgumentParser to handle various types of arguments\n\n - generate verbose or debug output\n\n - handle errors\n\n - open compressed files transparently\n\n - use codecs to handle different file encodings such as utf-8\n\n - call external programs\n\n - structure your code as a Python module\n\n\"\"\"\n\n\n\n# We encourage use of Python 3 features such as the print function.\n\nfrom __future__ import print_function, unicode_literals, division, absolute_import\n\n\n\nimport sys\n\nimport os.path\n\nfrom argparse import ArgumentParser\n\nimport codecs\n\nfrom subprocess import call, check_output, CalledProcessError\n\n\n\n# If this script is run from within src/ rather than from the installed bin\n\n# directory, we add src/utils to the Python module include path (sys.path)\n\n# to arrange that portage_utils will be imported from src/utils.\n\nif sys.argv[0] not in ('', '-c'):\n\n bin_path = os.path.dirname(sys.argv[0])\n\n if os.path.basename(bin_path) != \"bin\":\n\n sys.path.insert(1, os.path.normpath(os.path.join(bin_path, \"..\", \"utils\")))\n\n\n\n# portage_utils provides a bunch of useful and handy functions, including:\n\n# HelpAction, VerboseAction, DebugAction (helpers for argument processing)\n\n# printCopyright\n\n# info, verbose, debug, warn, error, fatal_error\n\n# open (transparently open stdin, stdout, plain text files, compressed files or pipes)\n\nfrom portage_utils import *\n\n\n\n\n\ndef get_args():\n\n \"\"\"Command line argument processing.\"\"\"\n\n\n\n usage=\"prog [options] mandatoryFile1 mandatoryFile2 [infile [outfile]]\"\n\n help=\"\"\"\n\n A brief description of what this program does. (Don't bother trying to format\n\n this text by including blank lines, etc: ArgumentParser is a control freak and\n\n will reformat to suit its tastes.)\n\n \"\"\"\n\n\n\n # Use the argparse module, not the deprecated optparse module.\n\n parser = ArgumentParser(usage=usage, description=help, add_help=False)\n\n\n\n # Use our standard help, verbose and debug support.\n\n parser.add_argument(\"-h\", \"-help\", \"--help\", action=HelpAction)\n\n parser.add_argument(\"-v\", \"--verbose\", action=VerboseAction)\n\n parser.add_argument(\"-d\", \"--debug\", action=DebugAction)\n\n\n\n parser.add_argument(\"-g\", \"--flag\", dest=\"someFlag\", action='store_true', default=False,\n\n help=\"some flag option [%(default)s]\")\n\n\n\n parser.add_argument(\"-s\", dest=\"str_opt\", type=str, default=\"\",\n\n help=\"some string option [%(default)s]\")\n\n parser.add_argument(\"-i\", dest=\"int_opt\", type=int, default=1,\n\n help=\"some integer option [%(default)s]\")\n\n parser.add_argument(\"-f\", dest=\"float_opt\", type=float, default=1.0,\n\n help=\"some float option [%(default)s]\")\n\n parser.add_argument(\"-l\", dest=\"list_opt\", nargs=\"*\", type=str, default=[],\n\n help=\"list of string operands [%(default)s]\")\n\n parser.add_argument(\"-c\", dest=\"choice_opt\", nargs=\"?\",\n\n choices=(\"choice1\",\"choice2\"), const=\"choice1\", default=None,\n\n help=\"one of choice1, choice2; -c alone implies %(const)s \"\n\n \"[%(default)s]\")\n\n parser.add_argument(\"-enc\", \"--encoding\", nargs='?', default=\"utf-8\",\n\n help=\"file encoding [%(default)s]\")\n\n\n\n parser.add_argument(\"mandatoryFile1\", type=open, help=\"file 1\")\n\n parser.add_argument(\"mandatoryFile2\", type=open, help=\"file 2\")\n\n\n\n # The following use the portage_utils version of open to open files.\n\n parser.add_argument(\"infile\", nargs='?', type=open, default=sys.stdin,\n\n help=\"input file [sys.stdin]\")\n\n parser.add_argument(\"outfile\", nargs='?', type=lambda f: open(f,'w'),\n\n default=sys.stdout,\n\n help=\"output file [sys.stdout]\")\n\n\n\n cmd_args = parser.parse_args()\n\n\n\n # info, verbose, debug all print to stderr.\n\n info(\"arguments are:\")\n\n for arg in cmd_args.__dict__:\n\n info(\" {0} = {1}\".format(arg, getattr(cmd_args, arg)))\n\n verbose(\"verbose flag is set.\") # printed only if verbose flag is set by -v.\n\n debug(\"debug flag is set.\") # printed only if debug flag is set by -d.\n\n return cmd_args\n\n\n\ndef main():\n\n os.environ['PORTAGE_INTERNAL_CALL'] = '1'; # add this if needed\n\n\n\n cmd_args = get_args()\n\n\n\n # Handle file encodings:\n\n try:\n\n codecs.lookup(cmd_args.encoding)\n\n except LookupError:\n\n fatal_error(\"Illegal encoding specified for -enc (--encoding) option: '{0}'\".format(cmd_args.encoding))\n\n\n\n infile = codecs.getreader(cmd_args.encoding)(cmd_args.infile)\n\n outfile = codecs.getwriter(cmd_args.encoding)(cmd_args.outfile)\n\n # The following allows stderr to handle non-ascii characters:\n\n sys.stderr = codecs.getwriter(cmd_args.encoding)(sys.stderr)\n\n\n\n # Call an external program without invoking a shell and checking the return code:\n\n verbose(\"Calling 'ls xxxx' not using a shell.\")\n\n ret_code = call([\"ls\", \"xxxx\"])\n\n if ret_code is not 0:\n\n warn(\"program xxxx not found.\")\n\n\n\n # Call an external program invoking a shell and checking the return code:\n\n verbose(\"Calling 'ls | wc -l' using a shell.\")\n\n ret_code = call(\"ls | wc -l\", shell=True)\n\n if ret_code is not 0:\n\n error(\"'ls | wc -l' failed, returned:\", ret_code)\n\n\n\n # Call an external program not invoking a shell and checking the output:\n\n verbose(\"Calling 'ls .' checking the output.\")\n\n try:\n\n contents = check_output([\"ls\", \".\"])\n\n except CalledProcessError as err:\n\n fatal_error(\"'ls .' failed, returned:\", err.returncode)\n\n info(\"ls returned:\", contents.replace('\\n',' '))\n\n\n\n # Copy the infile to outfile\n\n verbose(\"Copying infile to outfile.\")\n\n for line in infile:\n\n print(line, file=outfile, end='')\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "file_path": "src/utils/prog.py", "rank": 86, "score": 95709.56947576939 }, { "content": "#!/usr/bin/env python2\n\n# -*- coding: utf-8 -*-\n\n\n\n# @file msgd.py\n\n# @brief Mini-batch SGD for Theano.\n\n#\n\n# @author Colin Cherry\n\n#\n\n# Traitement multilingue de textes / Multilingual Text Processing\n\n# Centre de recherche en technologies numériques / Digital Technologies Research Centre\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2014, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2014, Her Majesty in Right of Canada\n\n\n\nimport time\n\nimport sys\n\nimport os\n\n\n\nimport math\n\nimport numpy\n\nimport theano\n\nimport theano.tensor as T\n\n\n\n\"\"\"Mini-batch SGD for Theano\n\n\n\nIdea: provide only theao formulas and variables, SGD will handle the rest.\n\n\n\n:type x: theano.tensor.TensorType\n\n:param x: symbolic variable that describes the input to the model\n\n\n\n:type y: theano.tensor.TensorType\n\n:param y: symbolic variable that describes the model output;\n\nused only to represent the gold standard in any formulas\n\n\n\n:type cost: theano.tensor.TensorVariable\n\n:param cost: symbolic variable representing the cost or loss function of\n\n the learner; will usually reference x and y\n\n\n\n:type params: list theano.tensor.SharedVariable\n\n:param params: list of shared variables representing model parameters\n\n\n\n:type train_set: (data_x, data_y) where data_x can feed a function expecting x,\n\n and data_y can feed a function expeting y\n\n:param train_set: (data_x, data_y) pair to be used in training\n\n\n\n:type valid_set: (data_x, data_y)\n\n:param valid_set: Validation set to determine early stopping\n\n\n\n:type test_set: (data_x, data_y)\n\n:param test_set: Test set to be evaluated at each potentially best model\n\n\n\n:type error: theano.tensor.TensorVariable\n\n:param error: symbolic variable representing the error function for the learner\n\n if this is missing, cost will be used in its place\n\n\n\n:type eta_0: double\n\n:param eta_0: Initial learning rate\n\n\n\n:type eta_params: list double\n\n:param eta_params: list of parameter-specific learning rate modifiers\n\n\n\n:type n_epochs: int\n\n:param n_epochs: Maximum number of passes through the training set\n\n\n\n:type batch_size: int\n\n:param batch_size: Size of each mini-batch, will truncate to size of training set\n\n\n\n:type val_batch_size: int\n\n:param val_batch_size: Size of batches in which to divide val and test sets when\n\n calculating error, to avoid memory overflow; this does not affect results\n\n\n\n:type decay: double (0<=decay<=1)\n\n:param decay: learning rate decay is raised to this exponent: 1=fastest, 0=no decay\n\n\n\n:type epsilon: double\n\n:param epsilon: scale-free sensitivity to model improvements for early stopping\n\n\n\n:type print_interval: int\n\n:param print_interval: print status every x epochs\n\n\n\n:type shuffle: bool\n\n:param shuffle: shuffle data before training\n\n\n\n:type quiet: bool\n\n:param quiet: no noise, even at end of training\n\n\n\n\"\"\"\n\n\n\ndef optimize(\n\n x,\n\n y,\n\n cost,\n\n params,\n\n train_set,\n\n valid_set=None,\n\n test_set=None,\n\n error=None,\n\n eta_0=1,\n\n eta_params=None,\n\n n_epochs=10000,\n\n batch_size=100,\n\n val_batch_size=50000,\n\n valid_n=5,\n\n decay=1,\n\n epsilon=1e-6,\n\n print_interval=1000,\n\n update_cap=None,\n\n shuffle=True,\n\n quiet=False):\n\n\n\n \"\"\"\n\n Encapsulate mini-batch SGD into a function\n\n \"\"\"\n\n\n\n num_samples = train_set[0].shape[0]\n\n if batch_size > num_samples:\n\n print >> sys.stderr, \"truncating batch size to data size\"\n\n batch_size = num_samples\n\n\n\n if decay < 0 or decay > 1:\n\n print >> sys.stderr, \"invalid decay:\",decay\n\n sys.quit()\n\n\n\n if eta_params is None:\n\n eta_params = [1. for p in params]\n\n if len(eta_params)!=len(params):\n\n print sys.stderr, \"invalid number of parameter-specific learning rates: \",len(eta_params)\n\n sys.quit()\n\n\n\n ################\n\n # Prepare Data #\n\n ################\n\n\n\n if not quiet: print >> sys.stderr, \"... moving data to shared memory\"\n\n\n\n # compute number of minibatches for training\n\n n_train_batches = int(math.ceil(num_samples / float(batch_size)))\n\n\n\n rng = numpy.random\n\n perm_train_set = shuffle_in_unison(train_set,rng) if shuffle else train_set\n\n train_set_x, train_set_y = shared_dataset(x, y, perm_train_set)\n\n\n\n # if error is missing, then use cost\n\n if error is None:\n\n error = cost\n\n\n\n # compiling a Theano function that computes the mistakes that are made by\n\n # the model on a test or validation set\n\n\n\n vb_beg_index = T.lscalar('vb_beg_index') # start index to a devtest batch\n\n vb_end_index = T.lscalar('vb_end_index') # end index to a devtest batch\n\n\n\n if test_set is not None:\n\n test_set_x, test_set_y = shared_dataset(x, y, test_set)\n\n test_model = theano.function(\n\n inputs=[vb_beg_index, vb_end_index],\n\n outputs=error,\n\n givens={\n\n x: test_set_x[vb_beg_index:vb_end_index],\n\n y: test_set_y[vb_beg_index:vb_end_index]})\n\n\n\n if valid_set is not None:\n\n valid_set_x, valid_set_y = shared_dataset(x, y, valid_set)\n\n validate_model = theano.function(\n\n inputs=[vb_beg_index, vb_end_index],\n\n outputs=error,\n\n givens={\n\n x: valid_set_x[vb_beg_index:vb_end_index],\n\n y: valid_set_y[vb_beg_index:vb_end_index]})\n\n\n\n ###############\n\n # Build Model #\n\n ###############\n\n\n\n if not quiet: print >> sys.stderr, '... building the model'\n\n\n\n index = T.lscalar('index') # index to a [mini]batch\n\n itern = theano.shared(numpy.asarray(0., dtype=theano.config.floatX), name='itern')\n\n eta = eta_0 / ((1. + eta_0*itern)**decay) # learning rate\n\n\n\n # specify how to update the parameters of the model as a list of\n\n # (variable, update expression) pairs.\n\n if update_cap is not None:\n\n updates = [ (p, p - T.minimum(update_cap, T.maximum(-update_cap, eta * ep * T.grad(cost, p))))\n\n for p, ep in zip(params, eta_params) ]\n\n else:\n\n updates = [ (p, p - eta * ep * T.grad(cost, p))\n\n for p, ep in zip(params, eta_params) ]\n\n # Not sure automatic learning rate reductions are the way to go, especially for MNIST\n\n # updates.append( (itern, itern+1) )\n\n\n\n # Function to trigger learning rate reduction on a failure to improve\n\n update_eta = theano.function(inputs=[], outputs=[itern], updates=[(itern, itern+1)])\n\n\n\n # compiling a Theano function `train_model` that returns the cost, but in\n\n # the same time updates the parameter of the model based on the rules\n\n # defined in `updates`\n\n train_model = theano.function(\n\n inputs=[index],\n\n outputs=[cost,eta],\n\n updates=updates,\n\n givens={\n\n x: train_set_x[index * batch_size:(index + 1) * batch_size],\n\n y: train_set_y[index * batch_size:(index + 1) * batch_size]})\n\n\n\n ###############\n\n # TRAIN MODEL #\n\n ###############\n\n if not quiet: print >> sys.stderr, '... training the model'\n\n best = None\n\n bestLoss = None\n\n willingToWait=10\n\n start_time = time.clock()\n\n\n\n done_looping = False\n\n epoch = 0\n\n while (epoch < n_epochs) and (not done_looping):\n\n epoch = epoch + 1\n\n loss = 0\n\n if shuffle:\n\n g = rng.permutation(xrange(n_train_batches))\n\n else:\n\n g = xrange(n_train_batches)\n\n\n\n iter = 0\n\n valid_mean = 0\n\n valid_i = 0\n\n valid_check = n_train_batches - calc_valid_check(valid_i, valid_n)\n\n for minibatch_index in g:\n\n minibatch_avg_cost, eta = train_model(minibatch_index)\n\n loss = loss + minibatch_avg_cost\n\n # iteration number\n\n iter = iter + 1\n\n # Following Jacob's README, get the mean of 5 validation checks\n\n if valid_set is not None and iter == valid_check:\n\n valid_i = valid_i + 1\n\n valid = calc_error_by_batches(validate_model, valid_set[0].shape[0],\n\n val_batch_size)\n\n valid_mean = valid_mean + (valid - valid_mean) / valid_i\n\n valid_check = n_train_batches - calc_valid_check(valid_i, valid_n)\n\n loss = loss / n_train_batches\n\n\n\n # Check to reduce learning rate\n\n if (bestLoss is None) or ( (bestLoss - loss) / abs(bestLoss) > epsilon):\n\n bestLoss = loss\n\n else:\n\n update_eta()\n\n\n\n # Calculate stopping criterion\n\n if valid_set is not None:\n\n obj = valid_mean\n\n else:\n\n obj = loss\n\n\n\n # Check stopping criterion\n\n if (best is None) or ( (best - obj) / abs(best) > epsilon):\n\n best = obj\n\n finalLoss = loss\n\n if valid_set is not None:\n\n best_validation_loss = obj\n\n if test_set is not None:\n\n test_score = calc_error_by_batches(test_model, test_set[0].shape[0],\n\n val_batch_size)\n\n waitingForBest=0\n\n elif waitingForBest<willingToWait:\n\n waitingForBest=waitingForBest+1\n\n else:\n\n break\n\n\n\n if epoch%print_interval==0:\n\n print >> sys.stderr, ('{:4d}'.format(epoch) +\n\n ' %0.4f'%(eta) +\n\n ' %f'%(loss) +\n\n '{valid}'.format(valid=' %f'%(obj) if valid_set is not None else '' ))\n\n\n\n end_time = time.clock()\n\n if not quiet:\n\n print >> sys.stderr, ('Optimization complete with final loss of %f' % (loss))\n\n if valid_set is not None:\n\n print >> sys.stderr, ('Best validation score is: %f' % (best_validation_loss))\n\n if test_set is not None:\n\n print >> sys.stderr, ('Test score of final model is %f' % (test_score ))\n\n print >> sys.stderr, 'Ran for %d epochs, with %f epochs/sec' % (\n\n epoch, 1. * epoch / (end_time - start_time))\n\n print >> sys.stderr, ('The code for file ' +\n\n os.path.split(__file__)[1] +\n\n ' ran for %.1fs' % ((end_time - start_time)))\n\n\n\n return loss, \\\n\n best_validation_loss if valid_set else 0, \\\n\n test_score if test_set else 0\n\n\n\ndef shared_dataset(x, y, data_xy, borrow=True):\n\n \"\"\" Function that loads the dataset into shared variables\n\n\n\n The reason we store our dataset in shared variables is to allow\n\n Theano to copy it into the GPU memory (when code is run on GPU).\n\n Since copying data into the GPU is slow, copying a minibatch everytime\n\n is needed (the default behaviour if the data is not in a shared\n\n variable) would lead to a large decrease in performance.\n\n \"\"\"\n\n data_x, data_y = data_xy\n\n shared_x = theano.shared(numpy.asarray(data_x,\n\n dtype=theano.config.floatX),\n\n borrow=borrow)\n\n shared_y = theano.shared(numpy.asarray(data_y,\n\n dtype=theano.config.floatX),\n\n borrow=borrow)\n\n # When storing data on the GPU it has to be stored as floats\n\n # therefore we will store the labels as ``floatX`` as well\n\n # (``shared_y`` does exactly that). But during our computations\n\n # we need them as ints (we use labels as index, and if they are\n\n # floats it doesn't make sense) therefore instead of returning\n\n # ``shared_y`` we will have to cast it to int. This little hack\n\n # lets ous get around this issue\n\n return T.cast(shared_x, x.dtype), T.cast(shared_y, y.dtype)\n\n\n\ndef shuffle_in_unison(data_xy, rng):\n\n data_x, data_y = data_xy\n\n assert len(data_x)==len(data_y), \"%s!=%s\"%(len(data_x),len(data_y))\n\n p = rng.permutation(len(data_x))\n\n return [data_x[p], data_y[p]]\n\n\n\ndef calc_error_by_batches(model, data_size, batch_size):\n\n \"\"\"Calculate error in batches using the given valid/test model.\"\"\"\n\n err = 0.0\n\n beg = 0\n\n while (beg < data_size):\n\n end = min(beg+batch_size, data_size)\n\n err += model(beg,end) * (end-beg)\n\n beg = end\n\n return err / data_size\n\n\n\ndef calc_valid_check(i, n):\n\n \"\"\"Calculate the iteration number of the i'th validation check out of n checks.\"\"\"\n\n if n==1: return 0\n\n else: return ((n-1)-i)*(100/(n-1))\n", "file_path": "src/nn/msgd.py", "rank": 87, "score": 95704.62193027056 }, { "content": "#!/usr/bin/env python2\n\n# -*- coding: utf-8 -*-\n\n\n\n# @file unpickle.py\n\n# @brief Transform a pickle file from train-nnjm into a gzipped text file.\n\n#\n\n# @author Colin Cherry and Samuel Larkin\n\n#\n\n# Traitement multilingue de textes / Multilingual Text Processing\n\n# Centre de recherche en technologies numériques / Digital Technologies Research Centre\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2014 - 2017, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2014 - 2017, Her Majesty in Right of Canada\n\n\n\n\"\"\"\n\nTransform a pickle file produced by train-nnjm into a human-readable gzipped\n\ntext file. This should be run immediately after train-nnjm, as the data\n\nstructures inside the nnjm pickle will not necessarily be unpickle-able in\n\nlater versions of Theano.\n\n\n\nFormat of layer is to have #input rows and #output columns\n\n\n\nHidden layers are listed with the bottom layer (connected to embeddings) first\n\nand output layer last.\n\n\n\nVersion 1.1\n\n\"\"\"\n\n\n\n# Taken from portage_utils.py\n\nfrom __future__ import print_function\n\nfrom __future__ import unicode_literals\n\nfrom __future__ import division\n\nfrom __future__ import absolute_import\n\nimport __builtin__\n\nfrom subprocess import Popen\n\nfrom subprocess import PIPE\n\n\n\nimport sys\n\nimport cPickle\n\nfrom argparse import ArgumentParser\n\nimport operator\n\nimport json\n\nfrom functools import partial\n\n\n\n# MKL_THREADING_LAYER=GNU is always required, so set it in here, before importing Theano\n\nimport os\n\nos.environ[\"MKL_THREADING_LAYER\"] = \"GNU\"\n\n\n\nimport theano\n\nimport numpy\n\nfrom theano import pp\n\nfrom theano import tensor as T\n\n\n\n\n\nclass Layer:\n\n def __init__(self, w, b, act):\n\n self.w = w\n\n self.b = b\n\n self.act = act\n\n\n\nclass Embed:\n\n def __init__(self, voc_n, vec_size, words, embed):\n\n self.voc_n = voc_n\n\n self.vec_size = vec_size\n\n self.words = words\n\n self.embed = embed\n\n\n\ndef get_args():\n\n \"\"\"Command line argument processing.\"\"\"\n\n\n\n usage=\"unpickle [options] model.pkl model.out\"\n\n help=\"\"\"\n\n Transform a pickle file produced by train-nnjm into a human-readable\n\n gzipped txt file or a Portage binary file. Should be run immediately after\n\n train-nnjm, as the data structures inside the nnjm pickle will not\n\n necessarily be unpickle-able in later versions of theano\n\n\n\n Format of layer is to have #input rows and #output columns\n\n\n\n Hidden layers are listed with the bottom layer (connected to embeddings) first\n\n and output layer last.\n\n \"\"\"\n\n\n\n # Use the argparse module, not the deprecated optparse module.\n\n parser = ArgumentParser(usage=usage, description=help)\n\n\n\n parser.add_argument(\"-t\", \"--text\", dest=\"textMode\", action='store_true', default=False,\n\n help=\"write in text format [%(default)s]\")\n\n\n\n parser.add_argument(\"-d\", \"--describe\", dest=\"describe\", action='store_true', default=False,\n\n help=\"describe the current model [%(default)s]\")\n\n\n\n parser.add_argument(\"--summary\", type=open, help=\"Blocks NNJM summary JSON file\")\n\n\n\n parser.add_argument(\"modelIn\", type=open, help=\"NNJM pickled model file.\")\n\n\n\n parser.add_argument(\"modelOut\", nargs='?', type=lambda f: open(f,'w'),\n\n default=sys.stdout,\n\n help=\"output model file [sys.stdout]\")\n\n\n\n cmd_args = parser.parse_args()\n\n return cmd_args\n\n\n\ndef loadBlocksNNJM(modelIn, jsummary):\n\n zfiles = numpy.load(modelIn)\n\n summary = json.load(jsummary)\n\n\n\n expected_in_size = 0\n\n\n\n # Source embedding, if any\n\n sembed = None\n\n if 'sources' in summary['embeds']:\n\n s = summary['sources']\n\n sembed = Embed(s['voc_size'],s['embed_size'],s['window_size'],zfiles[s['file']])\n\n expected_in_size += sembed.vec_size * sembed.words\n\n\n\n # Target embedding, if any\n\n tembed = None\n\n if 'targets' in summary['embeds']:\n\n s = summary['targets']\n\n tembed = Embed(s['voc_size'],s['embed_size'],s['window_size'],zfiles[s['file']])\n\n expected_in_size += tembed.vec_size * tembed.words\n\n\n\n # Hidden layers\n\n hlayers = [Layer(zfiles[s['files'][0]],zfiles[s['files'][1]],s['activation'])\n\n for s in summary['layers']]\n\n\n\n\n\n # Output is the last hidden layer\n\n out = hlayers[-1]\n\n hlayers = hlayers[:-1]\n\n out_voc_n = summary['layers'][-1]['output_dim']\n\n\n\n # Layer sanity check\n\n i=1\n\n for l in hlayers:\n\n if l.w.shape[0]!=expected_in_size:\n\n print(\"Error: expected input size {} for layer {} but got {}\".format(expected_in_size,i,l.w.shape[0]))\n\n quit()\n\n expected_in_size = l.w.shape[1]\n\n i=i+1\n\n\n\n return sembed, tembed, hlayers, out_voc_n, out\n\n\n\ndef loadNNJMModel(modelIn):\n\n (stvec, ovec, out, sbed, tbed, st_x, hidden_layers) = cPickle.load(modelIn)\n\n\n\n # Output layer\n\n out = Layer(out.w.get_value(), out.b.get_value(), \"none\")\n\n o_voc_n = numpy.shape(out.w)[1]\n\n\n\n # Source embeddings\n\n s_embed = sbed.lookup.get_value()\n\n # Number of source words is size of source vector divided by size of embedding vector\n\n s_vec_size = numpy.shape(s_embed)[1]\n\n s_voc_n = numpy.shape(s_embed)[0]\n\n s_words = int(sbed.x_size / s_vec_size)\n\n\n\n # Target embeddings\n\n t_embed = tbed.lookup.get_value()\n\n # Number of target words is size of target vector divided by size of embedding vector\n\n t_vec_size = numpy.shape(t_embed)[1]\n\n t_voc_n = numpy.shape(t_embed)[0]\n\n t_words = int(tbed.x_size / t_vec_size)\n\n assert s_vec_size == t_vec_size, \"source lookup size({}) is not the same as target lookup size({})\".fomrat(s_vec_size, t_vec_size)\n\n\n\n # Hidden layers\n\n h = []\n\n # Layer 0 is bottom layer, connects to embeddings\n\n expected_in_size = (s_words+t_words)*s_vec_size\n\n for i,m in enumerate(hidden_layers):\n\n layer = Layer(m.w.get_value(), m.b.get_value(), m.output)\n\n h.append(layer)\n\n assert numpy.shape(layer.w)[0] == expected_in_size, \"hidden layer {} error\".format(i)\n\n expected_in_size = numpy.shape(layer.w)[1]\n\n # Layer -1 is top layer, connects to output\n\n assert numpy.shape(out.w)[0] == expected_in_size, \"out size error\"\n\n\n\n return s_voc_n, s_vec_size, s_words, sbed, t_voc_n, t_vec_size, t_words, tbed, hidden_layers, o_voc_n, out\n\n\n\n\n\n\n\ndef describeModelFile(modelIn):\n\n stvec, ovec, out, sbed, tbed, st_x, hidden_layers = cPickle.load(modelIn)\n\n describeModel(stvec, ovec, out, sbed, tbed, st_x, hidden_layers)\n\n\n\n\n\n\n\ndef describeModel(stvec, ovec, out, sbed, tbed, st_x, hidden_layers):\n\n def matrixSize(matrix):\n\n sizes = numpy.shape(matrix.get_value())\n\n return \" x \".join(str(x) for x in sizes)\n\n\n\n print('Architecture')\n\n print('source input vector size: ', sbed.windowSize())\n\n print('target input vector size: ', tbed.windowSize())\n\n print('input vector size: ', sbed.windowSize() + tbed.windowSize())\n\n print('src win embedding size: ', sbed.x_size)\n\n print('tgt win embedding size: ', tbed.x_size)\n\n print('input layer size: ', sbed.x_size + tbed.x_size)\n\n for i, h in enumerate(hidden_layers):\n\n print(\"hidden layer\", i+1, \"size:\", numpy.shape(h.w.get_value())[1], \", plus input bias\" if h.b is not None else \"\")\n\n print(\"output layer size:\", numpy.shape(out.w.get_value())[1], \", plus input bias\" if out.b is not None else \"\")\n\n\n\n print('Weights')\n\n print(\"src embedding parameters: \", matrixSize(sbed.lookup))\n\n print(\"tgt embedding parameters: \", matrixSize(tbed.lookup))\n\n for i, h in enumerate(hidden_layers):\n\n print(\"hidden layer {} parameters: {}\".format(i+1, matrixSize(h.w)))\n\n if h.b is not None:\n\n print('hidden_layer {} bias: {}'.format(i+1, matrixSize(h.b)))\n\n print('output layer parameters: ', matrixSize(out.w))\n\n print(\"output layer parameters: \", matrixSize(out.b))\n\n params = sbed.params + tbed.params + out.params\n\n for layer in hidden_layers:\n\n params += layer.params\n\n nparams = 0\n\n for p in params:\n\n nparams += reduce(operator.mul, p.get_value().shape, 1)\n\n print('total number or parameters: ', nparams)\n\n\n\n\n\n\n\ndef writeModelToFile(modelOut, textMode, source_embeddings, target_embeddings, hidden_layers, o_voc_n, out):\n\n with modelOut as f:\n\n myPrint = partial(print, file=f)\n\n\n\n def writeTextFile(source_embeddings, target_embeddings, hidden_layers, o_voc_n, out):\n\n \"\"\" Write to a text file.\"\"\"\n\n def printStrVec(vec):\n\n \"\"\" Transform a vector to a string \"\"\"\n\n myPrint(\" \".join(['%.17f' % m for m in vec]))\n\n\n\n #Source embeddings\n\n if source_embeddings is not None:\n\n myPrint(\"[source]\", source_embeddings.voc_n, source_embeddings.vec_size, source_embeddings.words)\n\n for vec in source_embeddings.embed:\n\n printStrVec(vec)\n\n\n\n #Target embeddings\n\n if target_embeddings is not None:\n\n myPrint(\"[target]\", target_embeddings.voc_n, target_embeddings.vec_size, target_embeddings.words)\n\n for vec in target_embeddings.embed:\n\n printStrVec(vec)\n\n\n\n #Hidden layers\n\n for l in hidden_layers:\n\n myPrint(\"[hidden]\", l.act, numpy.shape(l.w)[1])\n\n printStrVec(l.b)\n\n for vec in l.w:\n\n printStrVec(vec)\n\n\n\n #Output layer\n\n myPrint(\"[output]\", \"none\", o_voc_n)\n\n printStrVec(out.b)\n\n for vec in out.w:\n\n printStrVec(vec)\n\n\n\n def writeBinFile(source_embeddings, target_embeddings, hidden_layers, o_voc_n, out):\n\n \"\"\" Write in binary format.\"\"\"\n\n def printVectorToFile(vec):\n\n \"\"\" Make sure we write double for Portage.\"\"\"\n\n vec.astype('float64').tofile(f, format='%d')\n\n\n\n #Source embeddings\n\n if source_embeddings is not None:\n\n myPrint(\"[source]\", source_embeddings.voc_n, source_embeddings.vec_size, source_embeddings.words)\n\n printVectorToFile(source_embeddings.embed)\n\n\n\n #Target embeddings\n\n if target_embeddings is not None:\n\n myPrint(\"[target]\", target_embeddings.voc_n, target_embeddings.vec_size, target_embeddings.words)\n\n printVectorToFile(target_embeddings.embed)\n\n\n\n #Hidden layers\n\n for l in hidden_layers:\n\n myPrint(\"[hidden]\", l.act, numpy.shape(l.w)[1])\n\n printVectorToFile(l.b)\n\n printVectorToFile(l.w)\n\n\n\n #Output layer\n\n myPrint(\"[output]\", \"none\", o_voc_n)\n\n printVectorToFile(out.b)\n\n printVectorToFile(out.w)\n\n\n\n\n\n if textMode:\n\n writeTextFile(source_embeddings, target_embeddings, hidden_layers, o_voc_n, out)\n\n else:\n\n writeBinFile(source_embeddings, target_embeddings, hidden_layers, o_voc_n, out)\n\n\n\n\n\n\n\n\n\ndef main():\n\n cmd_args = get_args()\n\n\n\n if cmd_args.describe:\n\n if cmd_args.summary is not None:\n\n print(\"Describe model not implemented for Blocks, model description is in {}\".format(cmd_args.summary.name))\n\n else:\n\n describeModelFile(cmd_args.modelIn)\n\n exit()\n\n\n\n def loadModel(modelIn):\n\n s_voc_n, s_vec_size, s_words, sbed, t_voc_n, t_vec_size, t_words, tbed, hidden_layers, o_voc_n, out = loadNNJMModel(modelIn)\n\n s_embed = sbed.lookup.get_value()\n\n t_embed = tbed.lookup.get_value()\n\n h = [Layer(m.w.get_value(), m.b.get_value(), m.output) for m in hidden_layers]\n\n return Embed(s_voc_n, s_vec_size, s_words, s_embed), Embed(t_voc_n, t_vec_size, t_words, t_embed), h, o_voc_n, out\n\n\n\n if cmd_args.summary is None:\n\n s, t, h, o_voc_n, out = loadModel(cmd_args.modelIn)\n\n else:\n\n s, t, h, o_voc_n, out = loadBlocksNNJM(cmd_args.modelIn, cmd_args.summary)\n\n\n\n writeModelToFile(cmd_args.modelOut, cmd_args.textMode, s, t, h, o_voc_n, out)\n\n\n\n\n\n\n\n# Taken from portage_utils.py\n\ndef fatal_error(*args, **kwargs):\n\n \"\"\"Print a fatal error message to stderr and exit with code 1.\"\"\"\n\n print(\"Fatal error:\", *args, file=sys.stderr, **kwargs)\n\n sys.exit(1)\n\n\n\n# Taken from portage_utils.py\n\ndef open(filename, mode='r', quiet=True):\n\n \"\"\"Transparently open files that are stdin, stdout, plain text, compressed or pipes.\n\n\n\n examples: open(\"-\")\n\n open(\"file.txt\")\n\n open(\"file.gz\")\n\n open(\"zcat file.gz | grep a |\")\n\n\n\n filename: name of the file to open\n\n mode: open mode\n\n quiet: suppress \"zcat: stdout: Broken pipe\" messages.\n\n return: file handle to the open file.\n\n \"\"\"\n\n filename.strip()\n\n #debug(\"open: \", filename, \" in \", mode, \" mode\")\n\n if len(filename) is 0:\n\n fatal_error(\"You must provide a filename\")\n\n\n\n if filename == \"-\":\n\n if mode == 'r':\n\n theFile = sys.stdin\n\n elif mode == 'w':\n\n theFile = sys.stdout\n\n else:\n\n fatal_error(\"Unsupported mode.\")\n\n elif filename.endswith('|'):\n\n theFile = Popen(filename[:-1], shell=True, stdout=PIPE).stdout\n\n elif filename.startswith('|'):\n\n theFile = Popen(filename[1:], shell=True, stdin=PIPE).stdin\n\n elif filename.endswith(\".gz\"):\n\n #theFile = gzip.open(filename, mode+'b')\n\n if mode == 'r':\n\n if quiet:\n\n theFile = Popen([\"zcat\", \"-f\", filename], stdout=PIPE, stderr=open('/dev/null', 'w')).stdout\n\n else:\n\n theFile = Popen([\"zcat\", \"-f\", filename], stdout=PIPE).stdout\n\n elif mode == 'w':\n\n internal_file = __builtin__.open(filename, mode)\n\n theFile = Popen([\"gzip\"], close_fds=True, stdin=PIPE, stdout=internal_file).stdin\n\n else:\n\n fatal_error(\"Unsupported mode for gz files.\")\n\n else:\n\n theFile = __builtin__.open(filename, mode)\n\n\n\n return theFile\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n\n\n\n## --Emacs trickery--\n\n## Local Variables:\n\n## mode:python\n\n## python-indent:3\n\n## End:\n", "file_path": "src/nn/unpickle.py", "rank": 88, "score": 95695.56037669226 }, { "content": "#!/usr/bin/env python2\n\n\n\n# @file tune.py\n\n# @brief Generic MT tuning loop.\n\n# \n\n# @author George Foster\n\n# \n\n# Technologies langagieres interactives / Interactive Language Technologies\n\n# Inst. de technologie de l'information / Institute for Information Technology\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2011, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2011, Her Majesty in Right of Canada\n\n\n\nimport sys\n\nimport os\n\nimport shutil\n\nimport errno\n\nimport gzip\n\nimport time\n\nimport re\n\nfrom subprocess import call, check_output, CalledProcessError\n\nfrom subprocess import Popen, PIPE, STDOUT\n\nfrom optparse import OptionParser\n\n\n\n\n\nusage=\"tune.py [options] src ref1 [ref2...] [ref1_al ref2_al...]\"\n\nhelp=\"\"\"\n\nGeneric SMT tuning loop. Call with a source text and one or more reference\n\ntranslations.\n\n\"\"\"\n\n\n\n# workaround for Java writing locale-sensitive numbers by default\n\nos.environ['LC_ALL'] = 'C'\n\n\n\n# constants\n\n\n\njav = \"java\"\n\njar=os.path.abspath(os.path.dirname(sys.argv[0]))+\"/structpred.jar\"\n\n\n\nlogdir = \"logs\"\n\n\n\ndecoder_log = logdir + \"/log.decode\"\n\neval_log = logdir + \"/log.eval\"\n\naggr_log = logdir + \"/log.aggregate\"\n\noptimizer_log = logdir + \"/log.optimize\"\n\nall_logs = (decoder_log, eval_log, aggr_log, optimizer_log)\n\n\n\nhistory = \"summary\"\n\nhistory_wts = \"summary.wts\"\n\n\n\n# arguments\n\n\n\ndef maxmem():\n\n \"\"\"This function should automatically calculate the maximum available memory.\"\"\"\n\n return \"16000\"\n\n\n\nparser = OptionParser(usage=usage, description=help)\n\nparser.add_option(\"--postLattice\", dest=\"postProcessorLattice\", type=\"string\", default=None,\n\n help=\"Apply post processing to the lattice before optimizing [%default]\")\n\nparser.add_option(\"--post\", dest=\"postProcessor\", type=\"string\", default=None,\n\n help=\"Apply post processing to the nbest lists before optimizing [%default]\")\n\nparser.add_option(\"--workdir\", dest=\"workdir\", type=\"string\", default=\"foos\",\n\n help=\"Change the working directory [%default]\")\n\nparser.add_option(\"--clean\", dest=\"clean\", action=\"store_true\", default=False,\n\n help=\"Remove the working directory after successful completion [%default]\")\n\nparser.add_option(\"--debug\", dest=\"debug\", action=\"store_true\", default=False,\n\n help=\"write debug output to stderr [%default]\")\n\nparser.add_option(\"-v\", dest=\"verbose\", action=\"store_true\", default=False,\n\n help=\"write verbose output to stderr [%default]\")\n\nparser.add_option(\"-r\", dest=\"sparse\", action=\"store_true\", default=False,\n\n help=\"use sparse feature representation for nbest hyps; \" + \\\n\n \"if SparseModel(s) are included, tune component weights [%default]\")\n\nparser.add_option(\"-f\", dest=\"config\", type=\"string\", default=\"canoe.ini\",\n\n help=\"initial decoder configuration file, including weights [%default]\")\n\nparser.add_option(\"-o\", dest=\"configout\", type=\"string\", default=\"canoe.tune\",\n\n help=\"output decoder configuration file [%default]\")\n\nparser.add_option(\"-n\", dest=\"nbsize\", type=\"int\", default=100,\n\n help=\"nbest list size [%default]\")\n\nparser.add_option(\"-p\", dest=\"numpar\", type=\"int\", default=30,\n\n help=\"number of parallel decoding jobs (-n arg to canoe-parallel.sh) [%default]\")\n\nparser.add_option(\"-c\", dest=\"numcpus\", type=\"int\", default=1,\n\n help=\"number of cpus per decoding job [%default]\")\n\nparser.add_option(\"--cpopts\", dest=\"cpopts\", type=\"string\", default=\"\",\n\n help=\"additional options for canoe-parallel.sh [%default]\")\n\nparser.add_option(\"-j\", dest=\"jmem\", type=\"string\", default=maxmem(),\n\n help=\"java memory - depends on 'cpus' for tune.py job (eg 16000 for 4) [%default]\")\n\nparser.add_option(\"-d\", dest=\"decodeopts\", type=\"string\", default=\"\",\n\n help=\"general canoe decoding options [%default]\")\n\nparser.add_option(\"-a\", dest=\"optcmd\", type=\"string\", default=\"powell\",\n\n help=\"optimizer algorithm and argument string, one of: \" + \\\n\n \"powell [switches], \" \\\n\n \"mira [C [I [E]]]], \" \\\n\n \"pro [alg [curwt [bleucol [orig [reg]]]]], \" \\\n\n \"svm [C [B [A]]], \" \\\n\n \"lmira [--options], \" \\\n\n \"expsb [L bleucol] \"\\\n\n \"[%default]\")\n\n# \"olmira [C decay bg density combineCounts(t/f)], \"\n\n#parser.add_option(\"-b\", dest=\"bestbleu\", type=\"string\", default=\"1\",\n\n# help=\"type of nbest BLEU calculation for mira: \" + \\\n\n# \"1 - smoothed sentence-level, 1x - same as 1, but scaled by \" + \\\n\n# \"source-sent len, 2 - oracle substitution, -1 internal BLEU [%default]\")\n\nparser.add_option(\"-m\", dest=\"maxiters\", type=\"int\", default=15,\n\n help=\"maximum number of iterations (decoder calls) [%default]\")\n\nparser.add_option(\"-l\", dest=\"lastiter\", action=\"store_true\", default=False,\n\n help=\"choose final weights from last iter rather than best [%default]\")\n\nparser.add_option(\"-s\", dest=\"seed\", type=\"int\", default=0,\n\n help=\"start seed for random number generator [%default]\")\n\nparser.add_option(\"--no_ag\", dest=\"no_ag\", action=\"store_true\", default=False,\n\n help=\"turn off n-best aggregation [%default]\")\n\nparser.add_option(\"--density\", dest=\"density\", type=\"float\", default=75,\n\n help=\"density prune lattices in canoe (-1 for no pruning) [%default]\")\n\nparser.add_option(\"--bleuOrder\", dest=\"bleuOrder\", type=\"int\", default=4,\n\n help=\"(l)mira optimizes BLEU using this order of ngrams [%default]\")\n\n(opts, args) = parser.parse_args()\n\n\n\nif len(args) < 2:\n\n parser.error(\"Expecting at least two arguments.\")\n\n\n\nworkdir = opts.workdir\n\ndecoder_1best = workdir + \"/out\"\n\nallnb = workdir + \"/allnbests.gz\" # cumulative nbest lists\n\nallbleus = workdir + \"/allbleus.gz\"\n\nallnb_new = workdir + \"/allnbests-new.gz\"\n\nnbpattern = workdir + \"/nbest.%04d.%dbest.gz\"\n\nhierarchy = \" -no-hierarchy \"\n\n\n\npowellwts = workdir + \"/powellwts.\" # iter-specific wt record\n\noptimizer_in = workdir + \"/curmodel.ini\" # dummy model in\n\noptimizer_in0 = workdir + \"/curmodel0.ini\" # initial dummy model in, with weights\n\noptimizer_out = workdir + \"/curmodel.out\" # best model out\n\nhypmem = workdir + \"/hypmem.txt\" # lmira fake lattice aggregation\n\n\n\nsrc = args[0]\n\nrefs = args[1:]\n\n\n\nalg = opts.optcmd.split()[0]\n\nif opts.bleuOrder!=4 and not(alg!=\"mira\" or alg!=\"lmira\"):\n\n parser.error(\"bleuOrder only works with mira and lmira\")\n\n\n\n# allff is the aggregated feature-value file output from canoe, in sparse or\n\n# dense format \n\nif opts.sparse:\n\n allff = workdir + \"/allsfvals.gz\"\n\nelse:\n\n allff = workdir + \"/allffvals.gz\"\n\n\n\nopts.bestbleu = \"1\"\n\nif opts.bestbleu not in (\"1\", \"1x\", \"2\", \"-1\"):\n\n parser.error(\"bad value for -b switch: \" + opts.bestbleu)\n\n\n\nif alg not in (\"powell\", \"mira\", \"pro\", \"svm\", \"lmira\", \"olmira\", \"expsb\"):\n\n parser.error(\"unknown optimization algorithm: \" + alg)\n\n\n\nif not os.path.isfile(src):\n\n parser.error(\"source file \" + src + \" doesn't exist\")\n\nfor f in refs:\n\n if not os.path.isfile(f):\n\n parser.error(\"reference file \" + f + \" doesn't exist\")\n\nif not os.path.isfile(opts.config):\n\n parser.error(\"decoder config file \" + opts.config + \" doesn't exist\")\n\n\n\nif not opts.jmem.startswith(\"-\"):\n\n opts.jmem = \"-Xmx\" + opts.jmem + \"m\"\n\n\n\n# utilities\n\n\n\ndef print_timing(func):\n\n def wrapper(*arg):\n\n t1 = time.time()\n\n res = func(*arg)\n\n t2 = time.time()\n\n print >> sys.stderr, '%s took %0.3f s' % (func.func_name, (t2-t1))\n\n return res\n\n return wrapper\n\n\n\ndef warn(str):\n\n print >> sys.stderr, \"Warning: \", str\n\n\n\ndef error(str, *args):\n\n print >> sys.stderr, \"Error: \", str, args\n\n sys.exit(1)\n\n\n\ndef log(str, *files):\n\n \"\"\"Write a line to a log file(s).\"\"\"\n\n for file in files:\n\n f = open(file, \"a\")\n\n print >> f, str\n\n f.close()\n\n\n\ndef init(*files):\n\n \"\"\"Make files exist but be empty.\"\"\"\n\n for file in files:\n\n f = open(file, \"w\")\n\n f.close()\n\n\n\ndef run(cmd):\n\n \"\"\"Run a system command, and fail with an error if it fails.\"\"\"\n\n if os.system(cmd) != 0:\n\n error(\"command failed: \" + cmd)\n\n\n\ndef getOptimizedScore(find_what):\n\n \"\"\"Extract from the optimize log the last iteration's best score.\n\n Must be from the jar's output.\n\n \"\"\"\n\n with open(optimizer_log) as f:\n\n score = [ m.group(1) for l in list(f) for m in (find_what(l),) if m]\n\n if not len(score):\n\n error(\"Can't find any score in the optimize log file.\")\n\n return score[-1]\n\n\n\nclass NBReader:\n\n \"\"\"Manage lookahead for cumulative nbest/ffvals files, for aggregation.\"\"\"\n\n def __init__(self, nbfile, fffile):\n\n self.nbfile = nbfile\n\n self.fffile = fffile\n\n self.hyp, self.val, self.pal = \"\",\"\",\"\"\n\n def get_next(self, index):\n\n if self.hyp != \"\":\n\n hyp, val, pal = self.hyp, self.val, self.pal\n\n self.hyp, self.val, self.pal = \"\",\"\",\"\"\n\n return (hyp, (val, pal))\n\n (s1, tab, hyp) = self.nbfile.readline().partition('\\t')\n\n (s2, tab, val) = self.fffile.readline().partition('\\t')\n\n if s1 != s2:\n\n error(\"inconsistent nbest/ffvals files\")\n\n\n\n pal = \"\"\n\n if s1 != str(index): # includes empty-file case\n\n self.hyp = hyp\n\n self.val = val\n\n self.pal = pal\n\n return None\n\n else:\n\n return (hyp, (val, pal))\n\n\n\n@print_timing\n\ndef aggregate_nbests(ns):\n\n \"\"\"Add novel contents (only) of nbest/ffvals files to cumulative lists.\"\"\"\n\n\n\n if alg == \"lmira\":\n\n if opts.postProcessorLattice != None:\n\n latpattern = workdir + \"/lat.%04d.gz\"\n\n for i in range(ns): # for each source sentence\n\n try:\n\n cmd = \"zcat {f} | {p} | gzip > {f}.tmp && mv {f}.tmp {f}\".format(f=latpattern%i, p=opts.postProcessorLattice)\n\n if opts.debug:\n\n print >> sys.stderr, \"lattice: \", latpattern%i\n\n print >> sys.stderr, \"cmd: \", cmd\n\n if call(cmd, shell=True) is not 0:\n\n error(\"Problems while post processing the nbest lists with {}\".format(' '.join(cmd)))\n\n except CalledProcessError, err:\n\n error(\"Problem running configtool\", err)\n\n except OSError, err:\n\n error(\"configtool program not found \", err)\n\n return -1\n\n if alg == \"lmira\" or alg == \"olmira\":\n\n return -1\n\n\n\n logfile = open(aggr_log, 'a')\n\n\n\n if opts.sparse:\n\n allff_new = workdir + \"/allsfvals-new.gz\"\n\n ffpattern = workdir + \"/nbest.%04d.%dbest.sfvals.gz\"\n\n else:\n\n allff_new = workdir + \"/allffvals-new.gz\"\n\n ffpattern = workdir + \"/nbest.%04d.%dbest.ffvals.gz\"\n\n\n\n if opts.no_ag:\n\n open(allnb, 'w').close()\n\n open(allff, 'w').close()\n\n\n\n allnbfile = gzip.open(allnb)\n\n allfffile = gzip.open(allff)\n\n allnbfile_new = gzip.open(allnb_new, 'w')\n\n allfffile_new = gzip.open(allff_new, 'w')\n\n nbr = NBReader(allnbfile, allfffile)\n\n num_cur_hyps = 0\n\n num_new_hyps = 0\n\n\n\n if opts.postProcessor != None:\n\n try:\n\n nbpattern = workdir + \"/post%04d\"\n\n cmd = \"zcat {w}/nbest.*best.gz | {p} | split -d -a4 -l {n} - {w}/post\".format(w=workdir, p=opts.postProcessor, n=opts.nbsize)\n\n if opts.debug:\n\n print >> sys.stderr, \"nbpattern: \", nbpattern\n\n print >> sys.stderr, \"cmd: \", cmd\n\n if call(cmd, shell=True) is not 0:\n\n error(\"Problems while post processing the nbest lists with {}\".format(' '.join(cmd)))\n\n except CalledProcessError, err:\n\n error(\"Problem running configtool\", err)\n\n except OSError, err:\n\n error(\"configtool program not found \", err)\n\n else:\n\n nbpattern = workdir + \"/nbest.%04d.%dbest.gz\"\n\n\n\n for i in range(ns): # for each source sentence\n\n\n\n print >> logfile, \"sent \", i+1, \":\",\n\n\n\n # record new hyps for this sent in dict: hyp -> [vals1, vals2, ..]\n\n\n\n if opts.postProcessor != None:\n\n nbname = nbpattern % (i)\n\n nbfile = open(nbname)\n\n else:\n\n nbname = nbpattern % (i, opts.nbsize)\n\n nbfile = gzip.open(nbname)\n\n if opts.debug:\n\n print >> sys.stderr, \"Aggregating \", nbfile\n\n ffname = ffpattern % (i, opts.nbsize)\n\n fffile = gzip.open(ffname)\n\n\n\n nbset = {}\n\n for hyp in nbfile:\n\n vals = fffile.readline()\n\n pals = \"\"\n\n if (hyp == \"\\n\"): # lists are padded with blank lines\n\n break\n\n nbset.setdefault(hyp, []).append((vals, pals))\n\n nbfile.close()\n\n fffile.close()\n\n os.remove(nbname) # clean up; we're done with these files\n\n os.remove(ffname)\n\n\n\n # read/write existing hyps, removing them from nbset if they're there\n\n\n\n n = 0\n\n while True:\n\n hypval = nbr.get_next(i)\n\n if hypval == None:\n\n break\n\n n += 1\n\n print >> allnbfile_new, str(i) + \"\\t\" + hypval[0],\n\n print >> allfffile_new, str(i) + \"\\t\" + hypval[1][0],\n\n val_list = nbset.get(hypval[0])\n\n if val_list != None:\n\n try: val_list.remove(hypval[1])\n\n except ValueError: pass\n\n if len(val_list) == 0:\n\n del nbset[hypval[0]]\n\n print >> logfile, n, \"existing hyps +\",\n\n\n\n # write remaining new hyps in nbset\n\n\n\n nn = 0\n\n for hyp,vals_pals in nbset.iteritems():\n\n for vp in vals_pals:\n\n nn += 1\n\n val = vp[0]\n\n print >> allnbfile_new, str(i) + \"\\t\" + hyp,\n\n print >> allfffile_new, str(i) + \"\\t\" + val,\n\n print >> logfile, nn, \"novel hyps =\", n+nn, \"total\"\n\n num_cur_hyps += n\n\n num_new_hyps += nn\n\n\n\n print >> logfile, \"total size: \", num_cur_hyps, \"existing hyps + \", \\\n\n num_new_hyps, \"novel hyps = \", num_cur_hyps + num_new_hyps\n\n\n\n logfile.close()\n\n allnbfile.close()\n\n allfffile.close()\n\n allnbfile_new.close()\n\n allfffile_new.close()\n\n os.rename(allnb_new, allnb)\n\n os.rename(allff_new, allff)\n\n\n\n return num_new_hyps\n\n\n\n\n\ndef normalize(wts, norm_wts):\n\n assert len(wts) == len(norm_wts)\n\n mx = max(abs(min(wts)), abs(max(wts)))\n\n if mx == 0: mx = 1.0\n\n for i in range(len(wts)):\n\n norm_wts[i] = wts[i] / mx\n\n\n\ndef avg_diff(wts1, wts2):\n\n ll = len(wts1) if len(wts1) else 1\n\n return sum(map(abs, [a[0]-a[1] for a in zip(wts1, wts2)])) / float(ll)\n\n\n\ndef sfvals2ffvals(num_features):\n\n \"\"\"Convert allsfvals.gz file to allffvals.gz\"\"\"\n\n assert opts.sparse\n\n fi = gzip.open(workdir + \"/allsfvals.gz\", 'r')\n\n fo = gzip.open(workdir + \"/allffvals.gz\", 'w')\n\n for line in fi:\n\n (ind, tab, ffs) = line.partition('\\t')\n\n newvals = ['0'] * len(wts)\n\n for tok in ffs.split():\n\n (f,v) = tok.split(':');\n\n newvals[int(f)] = v\n\n print >> fo, ind + '\\t' + '\\t'.join(newvals)\n\n fi.close()\n\n fo.close()\n\n\n\n# wrapper functions\n\n\n\ndef decoderConfig2wts(config):\n\n \"\"\"Convert a decoder config file into a weight vector.\"\"\"\n\n if opts.sparse: configtool_cmd = \"get-all-wts:x\" \n\n else: configtool_cmd = \"rescore-model:x\" \n\n try:\n\n toks = check_output([\"configtool\", configtool_cmd, config]).split()\n\n return [float(toks[i]) for i in range(1, len(toks), 2)]\n\n except CalledProcessError, err:\n\n error(\"Problem running configtool\", err)\n\n except OSError, err:\n\n error(\"configtool program not found \", err)\n\n\n\ndef wts2decoderConfigStr(config, input_config = opts.config):\n\n \"\"\"Helper for wts2decoderConfig\"\"\"\n\n if opts.sparse: configtool_cmd = \"set-all-wts:-\"\n\n else: configtool_cmd = \"set-weights-rm:-\"\n\n return [\"configtool\", configtool_cmd, input_config, config]\n\n\n\ndef wts2decoderConfig(wts, config):\n\n \"\"\"Convert a weight vector into a decoder config file.\"\"\"\n\n s = \"\"\n\n for w in wts:\n\n s += \"x \" + str(w) + \"\\n\"\n\n Popen(wts2decoderConfigStr(config), stdin=PIPE).communicate(s)\n\n if opts.debug:\n\n call([\"cat\", config])\n\n\n\ndef shardAnnotate(s, iter, shard) :\n\n \"\"\"Append iteration and shard number to str\"\"\"\n\n return s+\".i\"+str(iter).zfill(2) +\".s\"+str(shard).zfill(2)\n\n\n\n@print_timing \n\ndef decode(wts):\n\n \"\"\"Decode current source file using given weight vector.\"\"\"\n\n wts2decoderConfig(wts, \"decode-config\")\n\n cmd = [\"set -o pipefail;\", \"canoe-parallel.sh\", \"-cleanup\",\n\n \"-psub\", \"-\" + str(opts.numcpus), \"-n\", str(opts.numpar)]\n\n if opts.cpopts != \"\":\n\n cmd.extend(opts.cpopts.split())\n\n cmd.extend([\"canoe\", hierarchy, \"-v\", \"1\", \"-f\", \"decode-config\"])\n\n if opts.sparse: \n\n cmd.append(\"-sfvals\")\n\n else: \n\n cmd.append(\"-ffvals\")\n\n outcmd = [\"nbest2rescore.pl\", \"-canoe\"]\n\n if alg == \"lmira\":\n\n cmd.extend([\"-palign\", \"-lattice\", workdir+\"/lat.gz\"])\n\n if opts.density > 0 :\n\n cmd.extend([\"-lattice-output-options\", \"overlay\", \"-lattice-density\", str(opts.density)])\n\n elif alg == \"olmira\" :\n\n cmd.extend([\"\"]) # intentionally blank, only need sentences\n\n else:\n\n cmd.extend([\"-nbest\", workdir+\"/nbest.gz:\"+str(opts.nbsize)])\n\n if opts.decodeopts != \"\": # (may need to do more than split for general case)\n\n cmd.extend(opts.decodeopts.split())\n\n logfile = open(decoder_log, 'a')\n\n srcfile = open(src)\n\n outfile = open(decoder_1best, 'w')\n\n if opts.debug: print >> sys.stderr, ' '.join(cmd)\n\n if opts.debug: print >> sys.stderr, ' '.join(outcmd)\n\n cmd.append(\"|\")\n\n cmd.extend(outcmd)\n\n if call(' '.join(cmd), stdin=srcfile, stdout=outfile, stderr=logfile, shell=True, close_fds=True, executable=\"/bin/bash\") is not 0:\n\n error(\"decoder failed: {}\".format(' '.join(cmd)))\n\n\n\n@print_timing\n\ndef eval():\n\n \"\"\"Evaluate decoder 1best and nbest output. Return 1best.\"\"\"\n\n\n\n try:\n\n score_string=\"BLEU score\"\n\n cmd = [\"bleumain\", \"-y\", str(opts.bleuOrder), decoder_1best] + refs\n\n\n\n if opts.debug: print >> sys.stderr, ' '.join(cmd)\n\n\n\n s = check_output(cmd, stderr=STDOUT).split(\"\\n\")\n\n logfile = open(eval_log, 'a')\n\n score = None\n\n for line in s:\n\n print >> logfile, line\n\n if line.startswith(score_string):\n\n score = line.split()[2]\n\n\n\n if alg not in [\"powell\", \"lmira\", \"olmira\"]:\n\n cmd = [\"bestbleu\", \"-y\", str(opts.bleuOrder), \"-dyn\", \"-o\", \"nbest\", allnb] + refs\n\n # if opts.bestbleu == \"1\": cmd[1:1] = [\"-s\", \"2\"]\n\n # if opts.bestbleu == \"1x\": cmd[1:1] = [\"-x\"]\n\n\n\n allbleus_file = gzip.open(allbleus, 'w')\n\n if opts.debug: print >> sys.stderr, ' '.join(cmd)\n\n for line in check_output(cmd, stderr=logfile).split(\"\\n\"):\n\n if line != \"\":\n\n (s, bleu1, bleu2) = line.split(\" \")\n\n print >> allbleus_file, s, bleu1 if opts.bestbleu.startswith(\"1\") else bleu2\n\n allbleus_file.close()\n\n\n\n logfile.close()\n\n return score\n\n except CalledProcessError, err:\n\n error(\"Problem running \", ' '.join(cmd), err)\n\n except OSError, err:\n\n error(\"Command not found \", ' '.join(cmd), err)\n\n\n\ndef optimizerModel2wts(model):\n\n \"\"\"Convert an optimizer model file into a flat weight vector.\"\"\"\n\n wts = []\n\n with open(model) as f:\n\n for line in f:\n\n wts.append(float(line.partition(' ')[2]))\n\n return wts\n\n\n\ndef olmiraModel2wts(model):\n\n \"\"\"Convert a model file (any whitespace) into a weight vector.\"\"\"\n\n wts = []\n\n with open(model) as f:\n\n for line in f:\n\n wts.append(float(line.split()[1]))\n\n return wts\n\n\n\n@print_timing\n\ndef optimize(iter, wts):\n\n \"\"\"Run the selected optimizer (according to opts.optcmd).\n\n iter -- current iteration in main loop\n\n wts -- weights from previous iteration; set to new wts on return\n\n return -- optimizer score\n\n \"\"\"\n\n (alg, sep, args) = opts.optcmd.partition(' ')\n\n logfile = open(optimizer_log, 'a')\n\n if iter == 0 and alg != \"powell\":\n\n shutil.copyfile(optimizer_in0, optimizer_in)\n\n call([\"which\", jav], stdout=logfile, stderr=logfile)\n\n call([jav, opts.jmem, \"-version\"], stdout=logfile, stderr=logfile)\n\n\n\n if alg == \"powell\":\n\n ret = optimizePowell(iter, wts, args, logfile)\n\n elif alg == \"mira\":\n\n ret = optimizeMIRA(iter, args, logfile)\n\n elif alg == \"pro\":\n\n ret = optimizePRO(iter, args, logfile)\n\n elif alg == \"expsb\":\n\n ret = optimizeExpSentBleu(iter, args, logfile)\n\n elif alg == \"svm\":\n\n ret = optimizeSVM(iter, args, logfile)\n\n elif alg == \"lmira\":\n\n ret = optimizeLMIRA(iter, args, logfile)\n\n elif alg == \"olmira\":\n\n ret = optimizeOnlineLMIRA(iter, wts, args, logfile)\n\n else:\n\n assert 0 # has already been checked\n\n logfile.close()\n\n\n\n # all these algs write their output to 'optimizer_out', so read this file\n\n # to get optimized wts and (optionally) feda_wts\n\n if alg in [\"mira\", \"pro\", \"expsb\", \"svm\", \"lmira\"]:\n\n f = open(optimizer_out)\n\n for i in range(len(wts)):\n\n wts[i] = float(f.readline().partition(' ')[2])\n\n normalize(wts, wts)\n\n f.close()\n\n\n\n if alg != \"powell\":\n\n shutil.copyfile(optimizer_out, optimizer_in)\n\n\n\n return ret\n\n\n\n\n\ndef optimizePowell(iter, wts, args, logfile):\n\n \"\"\"Optimize weights using Powell's over current aggregate nbest lists.\"\"\"\n\n seed = str(opts.seed * 10000 + iter)\n\n wo_file = powellwts + str(iter+1)\n\n if opts.sparse: sfvals2ffvals(len(wts))\n\n cmd = [\"time-mem\", \"rescore_train\", \"-n\", \"-r\", \"15\", \"-dyn\", \"-win\", \"5\", \"-s\", seed, \\\n\n \"-wi\", powellwts + str(iter), \"-wo\", wo_file] + args.split() + \\\n\n [optimizer_in, optimizer_out, src, allnb] + refs\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=STDOUT) is not 0:\n\n error(\"optimizer failed with cmd: {}\".format(' '.join(cmd)))\n\n wts[:] = optimizerModel2wts(optimizer_out)\n\n with open(wo_file) as f:\n\n s = float(f.readline().split()[2])\n\n return s\n\n\n\ndef optimizeMIRA(iter, args, logfile):\n\n \"\"\"Optimize weights using MIRA over current aggregate nbest lists.\"\"\"\n\n C = \"1e-02\" # learning rate; 1e-4 recommended fomr B=1, 1e-8 for B=2\n\n I = \"30\" # number of iterations\n\n E = \"1\" # number of neg examples\n\n B = \"-4\" # if >0, col to find BLEU in allbleus file\n\n H = \"true\" # hope update?\n\n O = \"Oracle\" # use Model, Oracle or Orange as background\n\n D = \"0.999\" # Rate at which to decay Model or Oracle BG\n\n seed = \"1\" # Random seed\n\n if(opts.seed>0): seed = str(opts.seed * 10000 + iter)\n\n args_vals = args.split()\n\n if len(args_vals) > 0: C = args_vals[0]\n\n if len(args_vals) > 1: I = args_vals[1]\n\n if len(args_vals) > 2: E = args_vals[2]\n\n if len(args_vals) > 3: B = args_vals[3]\n\n if len(args_vals) > 4: H = args_vals[4]\n\n if len(args_vals) > 5: O = args_vals[5]\n\n if len(args_vals) > 6: D = args_vals[6]\n\n if len(args_vals) > 7:\n\n print >> logfile, \"warning: ignoring values past first 3 tokens in \" + args\n\n refglob = ','.join(refs)\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"MiraTrainNbestDecay\", optimizer_in, \\\n\n allff, allbleus, allnb, refglob, C, I, E, B, H, O, D, str(opts.bleuOrder), seed]\n\n outfile = open(optimizer_out, 'w')\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=outfile, stderr=logfile) is not 0:\n\n error(\"optimizer failed with cmd: {}\".format(' '.join(cmd)))\n\n outfile.close()\n\n return getOptimizedScore(re.compile('Best BLEU found on it# \\d+, score ([\\d\\.]+)').search)\n\n\n\ndef optimizeSVM(iter, args, logfile):\n\n \"\"\"Optimize weights as multiclass SVM training over current aggregate nbest lists.\"\"\"\n\n C = \"1e-03\" # C-parameter, turn up for lower losses, less regularization\n\n B = \"-1\" # if >0, col to find BLEU in allbleus file; if < 0, internal metric\n\n A = \"cut\" # values are [cut=cutting plan] and [full=full multiclass on n-best list]\n\n args_vals = args.split();\n\n if len(args_vals) > 0 : C = args_vals[0]\n\n if len(args_vals) > 1 : B = args_vals[1]\n\n if len(args_vals) > 2 : A = args_vals[2]\n\n if len(args_vals) > 3 :\n\n print >> logfile, \"warning: ignoring values past first 3 tokens in \" + args\n\n refglob = ','.join(refs)\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"SvmTrainNbest\", optimizer_in, \\\n\n allff, allbleus, allnb, refglob, C, B, A]\n\n outfile = open(optimizer_out, 'w')\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=outfile, stderr=logfile) is not 0:\n\n error(\"optimizer failed: {}\".format(' '.join(cmd)))\n\n outfile.close()\n\n return getOptimizedScore(re.compile('Best obj found on it# \\d+, score it \\d+ : BLEU = ([\\d\\.]+)').search)\n\n\n\ndef optimizeExpSentBleu(iter, args, logfile):\n\n \"\"\"Optimize weights according to expected sum of sentence-level BLEU scores\"\"\"\n\n L = \"50\"\n\n BleuCol = \"-2\"\n\n Eps = \"1e-4\"\n\n MaxIter = \"100\"\n\n seed = \"1\"\n\n if(opts.seed>0): seed = str(opts.seed * 10000 + iter)\n\n args_vals = args.split();\n\n if len(args_vals) > 0 : L = args_vals[0]\n\n if len(args_vals) > 1 : BleuCol = args_vals[1]\n\n if len(args_vals) > 2 : Eps = args_vals[2]\n\n if len(args_vals) > 3 : MaxIter = args_vals[3]\n\n if len(args_vals) > 4 : \n\n print >> logfile, \"warning, ignoring values past first token in \" + args\n\n refglob = \",\".join(refs)\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ExpLinGainNbest\", optimizer_in, \\\n\n allff, allbleus, allnb, refglob, L, BleuCol, Eps, MaxIter, seed]\n\n outfile = open(optimizer_out, 'w')\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=outfile, stderr=logfile) is not 0:\n\n error(\"optimizer failed: {}\".format(' '.join(cmd)))\n\n outfile.close()\n\n return getOptimizedScore(re.compile('([\\d\\.]+$)').search)\n\n\n\ndef optimizePRO(iter, args, logfile):\n\n \"\"\"Optimize weights using PRO over current aggregate nbest lists.\"\"\"\n\n alg = \"MaxentZero\" # values are SVM, MIRA, Pagasos (=SVM), MegaM (not on cluster), \n\n # Maxent (regularizes to initializer), MaxentZero (regularizes to 0)\n\n curwt = \"0.1\" # interp coeff on current wts vs prev\n\n b = \"-2\" # if 1, column if bestbleus file; if < 0, internal metric\n\n o = \"false\" # switch to true to switch off multiple samples\n\n r = \"1e-4\" # regularization parameter, C for SVM, Pegasos, Maxent*; ignored for others\n\n args_vals = args.split()\n\n if len(args_vals) > 0: alg = args_vals[0]\n\n if len(args_vals) > 1: curwt = args_vals[1]\n\n if len(args_vals) > 2: b = args_vals[2]\n\n if len(args_vals) > 3: o = args_vals[3]\n\n if len(args_vals) > 4: r = args_vals[4]\n\n if len(args_vals) > 5:\n\n print >> logfile, \"warning: ignoring values past fourth token in \" + args\n\n refglob = ','.join(refs)\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ProTrainNbest\", optimizer_in, \\\n\n allff, allbleus, allnb, refglob, alg, o, curwt, \\\n\n b, r, str(iter), optimizer_out]\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"optimizer failed: {}\".format(' '.join(cmd)))\n\n return getOptimizedScore(re.compile('Best BLEU found \\(samp=\\d+\\) : ([\\d\\.]+)').search)\n\n\n\ndef optimizeLMIRA(iter, args, logfile):\n\n \"\"\"Optimize weights using lattice MIRA over current lattices.\"\"\"\n\n seed = \"1\"\n\n if(opts.seed>0): seed = str(opts.seed * 10000 + iter)\n\n args_vals = args.split()\n\n refglob = ','.join(refs)\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-cp\", jar, \"ca.nrc.ict.nlp.structpred.SMT.SMTMiraLatticeTrain\", \\\n\n \"--modelIn\", optimizer_in, \\\n\n \"--lats\", workdir, \\\n\n \"--refs\", refglob, \\\n\n \"--src\", src, \\\n\n \"--mem\", hypmem, \\\n\n \"--seed\", seed, \\\n\n \"--bleuOrder\", str(opts.bleuOrder)]\n\n cmd.extend(args_vals)\n\n outfile = open(optimizer_out, 'w')\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=outfile, stderr=logfile) is not 0:\n\n error(\"optimizer failed: {}\".format(' '.join(cmd)))\n\n outfile.close()\n\n return getOptimizedScore(re.compile('Best BLEU found on it# \\d+, score ([\\d\\.]+)').search)\n\n\n\ndef optimizeOnlineLMIRA(iter, wts, args, logfile):\n\n \"\"\"Optimize weights using lattice MIRA over lattices generated online.\"\"\"\n\n C = \"0.01\" # learning rate\n\n decay = \"0.999\" # effective number of context sentences\n\n bg = \"Oracle\" # BLEU background=Oracle|Model|Orange\n\n density = \"1000\" # density to which lattices will be pruned\n\n combineCounts = False # should we combine BLEU counts at the end of each epoch?\n\n args_vals = args.split()\n\n if len(args_vals) > 0: C = args_vals[0]\n\n if len(args_vals) > 1: decay = args_vals[1]\n\n if len(args_vals) > 2: bg = args_vals[2]\n\n if len(args_vals) > 3: density = args_vals[3]\n\n if len(args_vals) > 4: combineCounts = args_vals[4] in ['true', 'True', 'TRUE']\n\n if len(args_vals) > 5:\n\n print >> logfile, \"warning: ignoring values past first 3 tokens in \" + args\n\n dec_cfg = \"decode-config\"\n\n miraConfig = [shardAnnotate(workdir+\"/mira-config\",\"xx\",shard) for shard in range(opts.numpar)]\n\n #Create src filenames and refglobs for each shard\n\n refPrefixes = [(workdir+\"/ref.\"+str(i)) for i in range(len(refs))]\n\n srcShards = list(shardAnnotate(workdir+\"/src\",\"xx\",i) for i in range(opts.numpar))\n\n shardRefList = [[shardAnnotate(pref,\"xx\",i) for pref in refPrefixes] for i in range(opts.numpar)]\n\n shardRefglob = [\",\".join(shardRef) for shardRef in shardRefList]\n\n logfile.flush()\n\n #Shard corpus on first iteration, and set up shard-specific initial config files\n\n if iter==0 :\n\n #Shard source, save shard names\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ShardCorpus\", src]\n\n cmd.extend(srcShards)\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"src sharding failed: {}\".format(' '.join(cmd)))\n\n #Shard refs, save ref names\n\n refShardList = [[shardAnnotate(pref,\"xx\",i) for i in range(opts.numpar)] for pref in refPrefixes]\n\n for i in range(len(refs)):\n\n cmd = [\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ShardCorpus\", refs[i]]\n\n cmd.extend(refShardList[i])\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"ref sharding failed: {}\".format(' '.join(cmd)))\n\n # create shard-specific initial config files\n\n for i in range(opts.numpar):\n\n run(\"configtool rep-sparse-models-local:.\" + str(i) + \" \" + dec_cfg + \" > \" + shardAnnotate(dec_cfg, \"ni\", i))\n\n #Write config files for each shard\n\n model=workdir+\"/mira.model\"\n\n avg=workdir+\"/mira.avg.model\"\n\n count=workdir+\"/mira.count\"\n\n lat = workdir+\"/lat\"\n\n portageIniWeights = optimizer_in\n\n for shard in range(opts.numpar):\n\n input_decodeConfig = shardAnnotate(dec_cfg, \"ni\", shard)\n\n decodeConfig = shardAnnotate(dec_cfg,\"xx\",shard)\n\n modelIn = \"empty\" if iter==0 else shardAnnotate(model,iter-1,\"xx\") \n\n modelOut = shardAnnotate(model,iter,shard)\n\n bleuCountIn = \"empty\" if iter==0 else (shardAnnotate(count,iter-1,shard)\n\n if not combineCounts else shardAnnotate(count,iter-1,\"xx\"))\n\n bleuCountOut = shardAnnotate(count,iter,shard)\n\n sparse = \"-sfvals\" if opts.sparse else \"-ffvals\"\n\n decodeCmd = \"canoe -f \" + decodeConfig + \" \" + sparse + \" -palign -lattice \" + shardAnnotate(lat,\"xx\",shard)+\".gz\"\n\n weightCmd = \" \".join(wts2decoderConfigStr(decodeConfig, input_decodeConfig))\n\n latticeTmpFile = shardAnnotate(lat,\"xx\",shard)+\".0000.gz\"\n\n srcFile = srcShards[shard]\n\n refFiles = shardRefglob[shard]\n\n with open(miraConfig[shard], 'w') as ofile:\n\n ofile.write(\"modelInFile = \" + modelIn + \"\\n\")\n\n ofile.write(\"modelOutFile = \" + modelOut + \"\\n\")\n\n ofile.write(\"portageIniWeights = \" + portageIniWeights + \"\\n\")\n\n ofile.write(\"bleuCountInFile = \" + bleuCountIn + \"\\n\")\n\n ofile.write(\"bleuCountOutFile = \" + bleuCountOut + \"\\n\")\n\n ofile.write(\"decodeCmd = \" + decodeCmd + \"\\n\")\n\n ofile.write(\"weightCmd = \" + weightCmd + \"\\n\")\n\n ofile.write(\"srcFile = \" + srcFile + \"\\n\")\n\n ofile.write(\"refFiles = \" + refFiles + \"\\n\")\n\n ofile.write(\"latticeTmpFile = \" + latticeTmpFile + \"\\n\")\n\n ofile.write(\"C = \" + C + \"\\n\")\n\n ofile.write(\"decay = \" + decay + \"\\n\")\n\n ofile.write(\"background = \" + bg + \"\\n\")\n\n ofile.write(\"density = \" + density + \"\\n\")\n\n #Run run-parallel\n\n rpcmds = workdir + \"/rpcmds\"\n\n with open(rpcmds,\"w\") as rpfile :\n\n for conf in miraConfig :\n\n rpfile.write(\" \".join([\"time-mem\", jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"MiraLatticeStep\", conf, str(iter),\"\\n\"]))\n\n cmd = [\"run-parallel.sh\",\"-nolocal\",\"-psub\",\"-4\",\"-psub\", \"-memmap 4\", rpcmds,str(opts.numpar)]\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"run-parallel failed: {}\".format(' '.join(cmd)))\n\n #Merge configs into a combined file for next iteration\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"CombineModels\", shardAnnotate(model,iter,\"xx\")]\n\n cmd.extend([shardAnnotate(model,iter,shard) for shard in range(opts.numpar)])\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"merge failed: {}\".format(' '.join(cmd)))\n\n #Average combined file into a Portage-consumable framework\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"AverageModel\", portageIniWeights, shardAnnotate(model,iter,\"xx\"), optimizer_out]\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"averaging failed: {}\".format(' '.join(cmd)))\n\n normalize(olmiraModel2wts(optimizer_out), wts)\n\n #Combine background BLEU counts\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"CombineBleuCounts\", shardAnnotate(count,iter,\"xx\")]\n\n cmd.extend([shardAnnotate(count,iter,shard) for shard in range(opts.numpar)])\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n if call(cmd, stdout=logfile, stderr=logfile) is not 0:\n\n error(\"bleu combination failed: {}\".format(' '.join(cmd)))\n\n #Use combined background BLEU to get a score estimate\n\n cmd = [jav, opts.jmem, \"-enableassertions\", \"-jar\", jar, \"ScoreCountFile\", shardAnnotate(count,iter,\"xx\")]\n\n print >> logfile, ' '.join(cmd)\n\n logfile.flush()\n\n try:\n\n toks = check_output(cmd, stderr=logfile).split()\n\n except CalledProcessError, (num, errstr):\n\n error(\"ScoreCountFile failed for optimizeOnlineLMIRA\", ' '.join(cmd), num, errstr)\n\n except OSError, err:\n\n error(\"Command not found \", ' '.join(cmd), err)\n\n return float(toks[0])\n\n\n\n# initialize\n\n\n\ntry: os.mkdir(workdir)\n\nexcept OSError, (num, errstr):\n\n if num == errno.EEXIST:\n\n warn(\"work directory already exists - will overwrite contents\")\n\n else: raise\n\ntry: os.mkdir(logdir)\n\nexcept OSError, (num, errstr):\n\n if num == errno.EEXIST: pass\n\n else: raise\n\n\n\nwts = decoderConfig2wts(opts.config)\n\nwith open(optimizer_in, 'w') as f:\n\n for i in range(len(wts)):\n\n print >> f, \"FileFF:\" + workdir + \"/allffvals.gz,\" + str(i+1)\n\nwith open(optimizer_in0, 'w') as f:\n\n for i in range(len(wts)):\n\n print >> f, \"FileFF:\" + workdir + \"/allffvals.gz,\" + str(i+1) + \" \" + str(wts[i])\n\n# Create the files that we need.\n\ninit(allnb, allff, powellwts + \"0\", history, history_wts, *all_logs)\n\nnum_srclines = sum(1 for line in open(src))\n\n\n\nbest_iter = 0\n\nbest_score = -1.0\n\nbest_wts = []\n\nold_wts = []\n\nopt_score = 0\n\naggr_nbest_size = 0\n\n\n\n# main loop\n\n\n\nfor i in range(opts.maxiters):\n\n\n\n log(\"starting loop \" + str(i+1), *all_logs)\n\n decode(wts)\n\n num_new_hyps = aggregate_nbests(num_srclines)\n\n score = eval()\n\n\n\n info = \"decode-score=\" + str(score) + \\\n\n \" prev-optimizer-score=\" + str(opt_score) + \\\n\n \" prev-nbest-size=\" + str(aggr_nbest_size) + \\\n\n \" avg-wt-diff=\" + str(avg_diff(wts, old_wts))\n\n log(info, history)\n\n log(' '.join(map(str, wts)), history_wts)\n\n \n\n if (score > best_score):\n\n best_iter = i\n\n best_score = score\n\n best_wts[:] = wts\n\n\n\n if num_new_hyps == 0:\n\n print \"Stopping - no new hypotheses found on iteration\", i+1\n\n break\n\n elif i+1 == opts.maxiters:\n\n print \"Maximum iterations (\" + str(opts.maxiters) +\") reached.\"\n\n break\n\n\n\n aggr_nbest_size += max(num_new_hyps,0)\n\n old_wts[:] = wts\n\n opt_score = optimize(i, wts)\n\n\n\n# wrap up\n\n\n\nprint \"Best score (from iter \" + str(best_iter+1) + \") =\", best_score\n\nprint \"Best weights:\", ' '.join([str(w) for w in best_wts])\n\nif opts.lastiter:\n\n print \"Using last-iteration weights for \" + opts.configout\n\n best_wts = wts\n\nwts2decoderConfig(best_wts, opts.configout)\n\n\n\nif opts.clean and os.path.exists(workdir):\n\n shutil.rmtree(workdir)\n", "file_path": "src/rescoring/tune.py", "rank": 89, "score": 95689.47143431837 }, { "content": "#!/usr/bin/env python2\n\n# -*- coding: utf-8 -*-\n\n\n\n# @file madamira.py\n\n# @brief Wrapper for MADAMIRA with OSPL input/output\n\n#\n\n# @author Samuel Larkin\n\n#\n\n# Note: requires xmltodict - run \"pip install xmltodict\" to install\n\n\n\n# We encourage use of Python 3 features such as the print function.\n\nfrom __future__ import print_function, unicode_literals, division, absolute_import\n\n\n\n# curl --data @/opt/MADAMIRA-release-20160516-2.1/samples/xml/SampleInputFile.xml http://localhost:8223\n\n\n\nimport requests\n\nimport codecs\n\nimport sys\n\nimport os.path\n\nfrom argparse import ArgumentParser\n\nimport xmltodict\n\nimport json\n\nimport re\n\n\n\n# If this script is run from within src/ rather than from the installed bin\n\n# directory, we add src/utils to the Python module include path (sys.path)\n\n# to arrange that portage_utils will be imported from src/utils.\n\nif sys.argv[0] not in ('', '-c'):\n\n bin_path = os.path.dirname(sys.argv[0])\n\n if os.path.basename(bin_path) != \"bin\":\n\n sys.path.insert(1, os.path.normpath(os.path.join(bin_path, \"..\", \"utils\")))\n\n\n\n# portage_utils provides a bunch of useful and handy functions, including:\n\n# HelpAction, VerboseAction, DebugAction (helpers for argument processing)\n\n# printCopyright\n\n# info, verbose, debug, warn, error, fatal_error\n\n# open (transparently open stdin, stdout, plain text files, compressed files or pipes)\n\nfrom portage_utils import *\n\n\n\n\n\ndef get_args():\n\n \"\"\"Command line argument processing.\"\"\"\n\n\n\n usage=\"madamira.py [options] [infile [outfile]]\"\n\n help=\"\"\"\n\n Takes OSPL input, wraps it in xml as required by Madamira's server, sends\n\n the request and extract the resulting tokenized sentences.\n\n\n\n Sample call:\n\n ridbom.sh < $MADAMIRA_HOME/samples/raw/SampleTextInput.txt | madamira.py --config $MADAMIRA_HOME/samples/sampleConfigFile.xml\n\n \"\"\"\n\n\n\n # Use the argparse module, not the deprecated optparse module.\n\n parser = ArgumentParser(usage=usage, description=help, add_help=False)\n\n\n\n # Use our standard help, verbose and debug support.\n\n parser.add_argument(\"-h\", \"-help\", \"--help\", action=HelpAction)\n\n parser.add_argument(\"-v\", \"--verbose\", action=VerboseAction)\n\n parser.add_argument(\"-d\", \"--debug\", action=DebugAction)\n\n\n\n parser.add_argument(\"-n\", dest=\"markNonArabic\", action='store_true', default=False,\n\n help=\"Mark non Arabic words. [%(default)s]\")\n\n\n\n parser.add_argument(\"-m\", dest=\"xmlishifyHashtags\", action='store_true', default=False,\n\n help=\"xmlishify hashtags. [%(default)s]\")\n\n\n\n parser.add_argument(\"-w\", dest=\"removeWaw\", action='store_true', default=False,\n\n help=\"Remove beginning of sentence's w+. [%(default)s]\")\n\n\n\n parser.add_argument(\"-enc\", \"--encoding\", nargs='?', default=\"utf-8\",\n\n help=\"file encoding [%(default)s]\")\n\n\n\n parser.add_argument(\"-c\", '--config', dest=\"config\", type=str, default=\"\",\n\n help=\"madamira config filename [%(default)s]\")\n\n\n\n parser.add_argument(\"-u\", '--url', dest=\"url\", type=str, default=\"http://localhost:8223\",\n\n help=\"madamira server's url [%(default)s]\")\n\n\n\n parser.add_argument(\"-s\", '--scheme', dest=\"scheme\", type=str, default=\"ATB\",\n\n help=\"scheme from config [%(default)s]\")\n\n\n\n parser.add_argument(\"-f\", '--form', dest=\"form\", type=str, default=\"form0\",\n\n help=\"form from config [%(default)s]\")\n\n\n\n # The following use the portage_utils version of open to open files.\n\n parser.add_argument(\"infile\", nargs='?', type=open, default=sys.stdin,\n\n help=\"input file [sys.stdin]\")\n\n parser.add_argument(\"outfile\", nargs='?', type=lambda f: open(f,'w'),\n\n default=sys.stdout,\n\n help=\"output file [sys.stdout]\")\n\n\n\n cmd_args = parser.parse_args()\n\n\n\n return cmd_args\n\n\n\n\n\n\"\"\"\n\n\"\"\"\n\ndef tokenize(xml_request, url='http://localhost:8223'):\n\n # The headers are used to send the request but also to prime MADAMIRA server.\n\n headers = {'Content-Type': 'application/xml'} # set what your server accepts\n\n\n\n def startMADAMIRA():\n\n print('Starting a MADAMIRA server.', file=sys.stderr)\n\n import subprocess\n\n import os\n\n # How to start madamira\n\n # bash -c \"exec -a MADAMIRA java ...\" is a way of renaming a process to facilitate killing it later.\n\n # ( export PORTAGE=/opt/PortageII; bash -c \"exec -a MADAMIRA java -Xmx5000m -Xms5000m -XX:NewRatio=3 -DPORTAGE_LOGS=$PORTAGE/logs -jar $PORTAGE/bin/MADAMIRA-release-20160516-2.1/MADAMIRA-release-20160516-2.1.jar -s\"; )\n\n portage = os.environ.get('PORTAGE', '/opt/PortageII')\n\n madamira_home = os.environ.get('MADAMIRA_HOME', None)\n\n madamira_jar = madamira_home + '/MADAMIRA-release-20160516-2.1.jar'\n\n if not os.path.exists(madamira_jar):\n\n fatal_error(\"Can't find madamira at specified location: \" + madamira_jar)\n\n\n\n cmd = ['java', '-Xmx5000m', '-Xms5000m', '-XX:NewRatio=3', '-DPORTAGE_LOGS='+portage+'/logs', '-jar', 'MADAMIRA-release-20160516-2.1.jar', '-s']\n\n subprocess.Popen(cmd,\n\n stdout=open('/dev/null'),\n\n stderr=open('/dev/null'),\n\n cwd=madamira_home, # MADAMIRA wants to be run from its installed directory.\n\n env={'PORTAGE': portage}, # Doesn't look like it's working for our command.\n\n preexec_fn=os.setpgrp) # This will detach madamira from this process group.\n\n\n\n def waitMADAMIRA():\n\n from time import sleep\n\n # MADAMIRA takes about 11 seconds to load; longer on the GPSC.\n\n packager = RequestPackager(None)\n\n xml_request = packager(['Priming.'])\n\n max_num_retries = 10\n\n for _ in xrange(max_num_retries):\n\n try:\n\n response = requests.post(url, data=xml_request, headers=headers, timeout=5)\n\n # TODO: Should we fatal_error if we can't start MADAMIRA server instead?\n\n if response.status_code == 200:\n\n break\n\n except requests.exceptions.ConnectionError:\n\n print('Waiting for MADAMIRA server...', file=sys.stderr)\n\n sleep(4)\n\n except:\n\n print('WHAT!? some unforseen event occured', file=sys.stderr)\n\n\n\n response = None\n\n try:\n\n response = requests.post(url, data=xml_request, headers=headers)\n\n except requests.exceptions.ConnectionError:\n\n # Can't connect to MADAMIRA server, may be it is not running, let's start it.\n\n startMADAMIRA()\n\n waitMADAMIRA()\n\n response = requests.post(url, data=xml_request, headers=headers)\n\n except Exception as e:\n\n fatal_error(str(e))\n\n finally:\n\n if response == None:\n\n fatal_error('Unable to connect to madamira server.')\n\n\n\n if response.status_code != 200:\n\n raise Exception('Something went wrong communicating with madamira server.')\n\n # The server does NOT return the encoding thus a quick hack is to set it\n\n # ourself and the rest of the code works fine.\n\n # https://github.com/kennethreitz/requests/issues/1604\n\n response.encoding = 'utf-8'\n\n\n\n return response\n\n\n\n\n\n# The xml parser could have been untangle or BeautifulSoup but I chose\n\n# xmltodict for its ability to parse and produce xml.\n\n# https://github.com/stchris/untangle\n\n# https://www.crummy.com/software/BeautifulSoup/\n\n\"\"\"\n\nGiven a MADAMIRA response, TokenizedSentenceExtractor will produce one\n\nsentence per line for the tokenized Arabic.\n\n\"\"\"\n\nclass TokenizedSentenceExtractor():\n\n def __init__(self, scheme='ATB', form='form0', removeWaw=False, xmlishifyHashtags=False):\n\n self.scheme = scheme\n\n self.form = '@' + form\n\n self.removeWaw = removeWaw\n\n self.xmlishifyHashtags = xmlishifyHashtags\n\n self.re_latin_characters = re.compile(r'[a-zA-Z]')\n\n\n\n def _markNonArabic(self, token):\n\n \"\"\"\n\n Token/word containing at least one latin letter is prefixed with `__ascii__`\n\n \"\"\"\n\n if self.re_latin_characters.search(token) != None:\n\n token = '__ascii__' + token\n\n return token\n\n\n\n def _extractDocument(self, docs):\n\n \"\"\"\n\n <out_doc id=\"ExampleDocument\">\n\n <out_seg id=\"SENT1\"> ... </out_seg>\n\n ...\n\n <out_seg id=\"SENTN\"> ... </out_seg>\n\n </out_doc>\n\n \"\"\"\n\n if isinstance(docs, dict):\n\n docs = [docs]\n\n for doc in docs:\n\n self._extractSegments(doc['out_seg'])\n\n\n\n def _extractSegments(self, segs):\n\n \"\"\"\n\n <out_seg id=\"SENT1\">\n\n ...\n\n <word_info>\n\n <word id=\"0\" word=\"word1\"> ... </word>\n\n ...\n\n <word id=\"n\" word=\"wordn\"> ... </word>\n\n </word_info>\n\n </out_seg>\n\n \"\"\"\n\n if isinstance(segs, dict):\n\n segs = [segs]\n\n for seg in segs:\n\n word_info = seg['word_info']\n\n sentence = self._extractWords(word_info['word'])\n\n print(' '.join(sentence))\n\n\n\n def _extractWords(self, words):\n\n \"\"\"\n\n <word id=\"0\" word=\"word1\">\n\n ...\n\n <tokenized scheme=\"ATB\"> ... </tokenized>\n\n <tokenized scheme=\"MyD3\"> ... </tokenized>\n\n </word>\n\n \"\"\"\n\n if isinstance(words, dict):\n\n words = [words]\n\n tokens = []\n\n for word in words:\n\n tokenized = word['tokenized']\n\n if isinstance(tokenized, dict):\n\n tokenized = [tokenized]\n\n # Find the element with the desired scheme\n\n sc = next((t for t in tokenized if t['@scheme'] == self.scheme), None)\n\n tokens.extend(self._extractTokens(sc))\n\n if self.removeWaw and tokens[0] == u'و+':\n\n tokens = tokens[1:]\n\n if self.xmlishifyHashtags:\n\n for i, tok in enumerate(tokens):\n\n if tok not in (\"<hashtag>\", \"</hashtag>\"):\n\n tok = re.sub(\"&(?![a-zA-Z]+;)\",\"&amp;\",tok)\n\n tok = re.sub(\"<\",\"&lt;\",tok)\n\n tok = re.sub(\">\",\"&gt;\",tok)\n\n tokens[i] = tok\n\n return tokens\n\n\n\n def _extractTokens(self, tokens):\n\n \"\"\"\n\n <tokenized scheme=\"MyD3\">\n\n <tok id=\"0\" form0=\"tok0_form0\"/>\n\n <tok id=\"1\" form0=\"tok1_form0\"/>\n\n </tokenized>\n\n \"\"\"\n\n if tokens == None:\n\n fatal_error(\"We can find scheme={} in MADAMIRA's response\".format(self.scheme))\n\n toks = tokens['tok']\n\n if isinstance(toks, dict):\n\n toks = [toks]\n\n return map(lambda t: t[self.form], toks)\n\n #return map(lambda t: self._markNonArabic(t[self.form]), toks)\n\n\n\n def __call__(self, response):\n\n \"\"\"\n\n <madamira_output xmlns=\"urn:edu.columbia.ccls.madamira.configuration:0.1\">\n\n <out_doc id=\"ExampleDocument\">\n\n ...\n\n </out_doc>\n\n </madamira_output>\n\n \"\"\"\n\n if response == None:\n\n fatal_error(\"There nothing to extract from madamira\")\n\n madamira = xmltodict.parse(response.text)\n\n docs = madamira['madamira_output']['out_doc']\n\n try:\n\n self._extractDocument(docs)\n\n except TypeError as e:\n\n print(json.dumps(docs), file=sys.stderr)\n\n import traceback\n\n traceback.print_exc()\n\n raise e\n\n\n\n\n\n\"\"\"\n\n\"\"\"\n\nclass RequestPackager():\n\n def __init__(self, config_filename, markNonArabic=False, xmlishifyHashtags=False):\n\n \"\"\"\n\n markNonArabic = True => prefix words containing at least one [a-zA-Z] with `__ascii`.\n\n xmlishifyHashtags = True => wraps hashtag that were not marked with `__ascii__` in <hashtag> your hashtag </hashtag>\n\n \"\"\"\n\n self.config_filename = config_filename\n\n self.markNonArabic = markNonArabic\n\n self.xmlishifyHashtags = xmlishifyHashtags\n\n # According to Mada's rules to mark latin words with \\@\\@LAT\n\n self.re_latin_characters = re.compile(r'[a-zA-Z]')\n\n self.re_hashtag = re.compile(ur'(?<!__ascii__)#([^ #]+)')\n\n #self.re_hashtag = re.compile(ur'#([^ ]+)')\n\n #self.re_hashtag = re.compile(r'#([^ a-zA-Z]+)')\n\n\n\n self.config = None\n\n if self.config_filename != None and self.config_filename != '':\n\n with open(self.config_filename, 'r') as config_file:\n\n self.config = xmltodict.parse(config_file.read())\n\n\n\n def _escapeAscii(self, word):\n\n \"\"\"\n\n If word contains at least on [a-zA-Z], prefix it with `__ascii__`.\n\n \"\"\"\n\n if self.re_latin_characters.search(word) != None:\n\n word = u'__ascii__' + word\n\n return word\n\n\n\n def _escapeHashtags(self, sentence):\n\n \"\"\"\n\n \"\"\"\n\n if self.markNonArabic == False and self.xmlishifyHashtags == False:\n\n return sentence\n\n\n\n sentence = sentence.split()\n\n if self.markNonArabic:\n\n sentence = map(self._escapeAscii, sentence)\n\n if self.xmlishifyHashtags:\n\n sentence = map(lambda w: self.re_hashtag.sub(lambda x:\n\n ' <hashtag> ' + re.sub('_', ' ', x.group(1)) + ' </hashtag> ', w), sentence)\n\n\n\n return ' '.join(sentence)\n\n\n\n def __call__(self, sentence_file):\n\n \"\"\"\n\n Given a file containing one-sentence-per-line, assemble a valid xml\n\n request that can be send to MADAMIRA's server.\n\n \"\"\"\n\n request = {\n\n 'madamira_input' : {\n\n '@xmlns' : \"urn:edu.columbia.ccls.madamira.configuration:0.1\"\n\n }\n\n }\n\n\n\n if self.config != None:\n\n request['madamira_input'].update(self.config)\n\n #print(json.dumps(request, indent=2))\n\n\n\n in_seg = []\n\n for i, sentence in enumerate(sentence_file):\n\n sentence = sentence.strip()\n\n sentence = self._escapeHashtags(sentence)\n\n in_seg.append({'@id': 'SENT{}'.format(i), '#text': sentence})\n\n\n\n if len(in_seg) == 0:\n\n warn('There is no sentence in your input.')\n\n\n\n request['madamira_input']['in_doc'] = {\n\n '@id': 'PortageLive',\n\n 'in_seg': in_seg\n\n }\n\n\n\n return request\n\n\n\n\n\ndef main():\n\n os.environ['PORTAGE_INTERNAL_CALL'] = '1'; # add this if needed\n\n\n\n cmd_args = get_args()\n\n\n\n # Handle file encodings:\n\n try:\n\n codecs.lookup(cmd_args.encoding)\n\n except LookupError:\n\n fatal_error(\"Illegal encoding specified for -enc (--encoding) option: '{0}'\".format(cmd_args.encoding))\n\n\n\n sys.stdin = codecs.getreader(cmd_args.encoding)(sys.stdin)\n\n sys.stdout = codecs.getwriter(cmd_args.encoding)(sys.stdout)\n\n cmd_args.infile = codecs.getreader(cmd_args.encoding)(cmd_args.infile)\n\n # The following allows stderr to handle non-ascii characters:\n\n sys.stderr = codecs.getwriter(cmd_args.encoding)(sys.stderr)\n\n\n\n packager = RequestPackager(cmd_args.config, cmd_args.markNonArabic, cmd_args.xmlishifyHashtags)\n\n request = packager(cmd_args.infile)\n\n\n\n if cmd_args.debug:\n\n print('MADAMIRA request:\\n', xmltodict.unparse(request, pretty=True), file=sys.stderr)\n\n\n\n xml_request = xmltodict.unparse(request).encode('utf-8-sig')\n\n response = tokenize(xml_request, cmd_args.url)\n\n\n\n if cmd_args.debug:\n\n print('MADAMIRA response:\\n', response.text, file=sys.stderr)\n\n\n\n extractor = TokenizedSentenceExtractor(cmd_args.scheme, cmd_args.form, cmd_args.removeWaw, cmd_args.xmlishifyHashtags)\n\n extractor(response)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "file_path": "src/preprocessing/madamira.py", "rank": 90, "score": 95689.47143431837 }, { "content": "#!/usr/bin/env python2\n\n\n\n# @file resecore.py\n\n# @brief Driver script to train, or translate with, a rescoring model.\n\n# \n\n# @author Darlene Stewart\n\n# \n\n# Traitement multilingue de textes / Multilingual Text Processing\n\n# Tech. de l'information et des communications / Information and Communications Tech.\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2014, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2014, Her Majesty in Right of Canada\n\n\n\nfrom __future__ import print_function, unicode_literals, division, absolute_import\n\n\n\nimport sys\n\nimport os.path\n\nfrom argparse import ArgumentParser, RawDescriptionHelpFormatter, ArgumentTypeError\n\nimport codecs\n\nfrom subprocess import call, check_output, CalledProcessError\n\nfrom datetime import datetime\n\nimport time\n\nimport glob\n\nimport re\n\nimport shutil\n\nimport tempfile\n\nimport shlex\n\n\n\n\n\n# If this script is run from within src/ rather than from the installed bin\n\n# directory, we add src/utils to the Python module include path (sys.path)\n\n# to arrange that portage_utils will be imported from src/utils.\n\nif sys.argv[0] not in ('', '-c'):\n\n bin_path = os.path.dirname(sys.argv[0])\n\n if os.path.basename(bin_path) != \"bin\":\n\n sys.path.insert(1, os.path.normpath(os.path.join(bin_path, \"..\", \"utils\")))\n\n\n\nfrom portage_utils import *\n\n\n\ndef prog_name():\n\n if sys.argv[0] in ('', '-c'):\n\n return \"rescore.py\"\n\n return os.path.basename(sys.argv[0])\n\n\n\ndef prog_dir():\n\n if sys.argv[0] in ('', '-c'):\n\n return \".\"\n\n return os.path.dirname(sys.argv[0])\n\n\n\n\n\ndef is_readable_file(f):\n\n return os.path.isfile(f) and os.access(f, os.R_OK)\n\n\n\ndef is_writable_file(f):\n\n return os.path.isfile(f) and os.access(f, os.W_OK)\n\n\n\ndef is_writable_dir(d):\n\n return os.path.isdir(d) and os.access(d, os.W_OK)\n\n\n\n\n\nmaster_start_time = time.time()\n\n\n\ndef print_master_wall_time():\n\n info(\"Master-Wall-Time \", int(time.time() - master_start_time + .5), \"s\", sep='')\n\n\n\n\n\ndef run_command(cmd, descriptor=\"\", time_it=False, *popenargs, **kwargs):\n\n # Put quotes around arguments that don't start with a single or double quote.\n\n quoted_cmd = ['\"{0}\"'.format(arg) if (' ' in arg and arg[0] not in \"\\\"'\")\n\n else arg for arg in cmd]\n\n verbose(\"Running\", descriptor, \"command:\", ' '.join(quoted_cmd))\n\n if time_it:\n\n (mon_fd, mon_file) = tempfile.mkstemp(prefix=\"mon.run_cmd.{0}.\".format(cmd[0]), \n\n dir=workdir)\n\n os.close(mon_fd)\n\n do_tm = \"time-mem -mon {0} \".format(mon_file) if time_it else \"\"\n\n try:\n\n if kwargs.get('shell') or len(popenargs) > 7 and popenargs[7]:\n\n rc = call(do_tm + ' '.join(quoted_cmd), *popenargs, **kwargs)\n\n else:\n\n if not time_it:\n\n rc = call(cmd, *popenargs, **kwargs)\n\n else:\n\n rc = call(do_tm + ' '.join(quoted_cmd), shell=True, *popenargs, **kwargs)\n\n except os.error as e:\n\n print_master_wall_time()\n\n fatal_error(descriptor, \"command failed (error:{0}): \".format(e), ' '.join(cmd))\n\n if rc is not 0:\n\n print_master_wall_time()\n\n fatal_error(descriptor, \"command failed (rc={0}):\".format(rc), ' '.join(cmd))\n\n\n\n\n\nclass Mode(object):\n\n none = 0\n\n train = 1\n\n trans = 2\n\n ffgen = 3\n\n\n\ndef pos_int(arg):\n\n \"\"\"Positive integer type for argparse\"\"\"\n\n try:\n\n value = int(arg)\n\n if value < 1: raise ValueError()\n\n except ValueError:\n\n raise ArgumentTypeError(\"invalid positive int value: '{0}'\".format(arg))\n\n return value\n\n\n\ndef get_args():\n\n \"\"\"Parse the command line arguments.\n\n \n\n Return the parsed arguments in an argparse.Namespace object.\n\n \"\"\"\n\n \n\n usage=\"rescore.py (-train|-trans|-ffgen) [options] MODEL SRC [REFS...]\"\n\n help=\"\"\"\n\n Train, or translate with, a rescoring model. First generate nbest lists and\n\n ffvals for a given source file, then generate external the feature files\n\n required for rescoring. Finally, unless in -ffgen mode, either train a model\n\n using reference texts (-train), or use an existing model to translate the\n\n source text (-trans). Note: parallelized decoding and feature generation are\n\n used.\n\n \n\n All intermediate files are written to a working directory, either specified\n\n by -w or created below the current directory with a name derived from the\n\n arguments.\n\n \n\n Note: any existing intermediate files will not be overwritten unless -F is\n\n specified; thus, when one adds extra features to an existing model, only\n\n the new features are calculated.\n\n \"\"\"\n\n model_epilog=\"\"\"Rescoring MODEL File Format:\n\n Use rescore_train -h for a description of the rescoring model syntax, and\n\n rescore_train -H for a list of features. If training, the final model is\n\n written to MODEL.rat. rescore.py automatically generates a file 'ffvals'\n\n containing all decoder feature values, so entries like 'FileFF:ffvals,i'\n\n can be used in MODEL to refer to columns in this file.\n\n rescore.py gives special interpretation to five magic tags within MODEL:\n\n <src> will be replaced by SRC's basename. This can be used to\n\n specify feature arguments that depend on the current\n\n source file.\n\n <ffval-wts> designates an automatically-generated rescoring model\n\n that contains decoder features and their weights. This\n\n is required by the nbest* features.\n\n <pfx> will be replaced by the prefix for all intermediate files,\n\n WORKDIR/PFX (where WORKDIR is the work directory, and PFX is \n\n the argument to -pfx). This can be used for features like the\n\n nbest* ones, which need to access intermediate files.\n\n <nbest> will be replaced by the nbest list file generated by rescore.py.\n\n <NP> will be replaced by the number of processors specified by -n.\n\n This is mainly intended for the SCRIPT features.\n\n \"\"\"\n\n\n\n # Use the argparse module, not the deprecated optparse module.\n\n parser = ArgumentParser(usage=usage, description=help, epilog=model_epilog,\n\n formatter_class=RawDescriptionHelpFormatter, add_help=False)\n\n\n\n grp_mode = parser.add_argument_group(\"mode selection options (one required)\")\n\n modes = grp_mode.add_mutually_exclusive_group(required=True)\n\n modes.add_argument('-train', '--train', dest=\"mode\",\n\n action='store_const', const=Mode.train,\n\n help='''Select training mode. In training mode, one or\n\n more reference texts must be provided.''')\n\n modes.add_argument('-trans', '--trans', dest=\"mode\",\n\n action='store_const', const=Mode.trans,\n\n help='''Select translation mode. In translation mode, the\n\n rescored translation is written to the file MSRC.rat\n\n (where MSRC is the argument to -msrc).''')\n\n modes.add_argument('-ffgen', '--ffgen', dest=\"mode\",\n\n action='store_const', const=Mode.ffgen,\n\n help='''Select feature file generation mode, i.e. stop\n\n after feature file generation, don't rescore.''')\n\n\n\n parser.add_argument(\"model\", type=str, metavar=\"MODEL\",\n\n help=\"Rescoring model (see below for detailed description).\")\n\n parser.add_argument(\"src\", type=str, metavar=\"SRC\",\n\n help=\"Source text file name.\")\n\n parser.add_argument(\"refs\", type=str, nargs=\"*\", default=[], metavar=\"REFS\",\n\n help=\"File names of one or more reference translations.\")\n\n\n\n grp_cp = parser.add_argument_group(\"decoding options\")\n\n grp_cp.add_argument(\"-f\", \"--canoe-config\", dest=\"canoe_config\", type=str,\n\n default=\"canoe.ini\", metavar=\"CONFIG\",\n\n help='''Canoe config file. (To use a configmap file, \n\n specify it as the -f option in CP_OPTS.)\n\n [%(default)s]''')\n\n grp_cp.add_argument(\"--cp-opts\", type=str, action=\"append\", default=[],\n\n metavar=\"CP-OPTS\",\n\n help='''Options for canoe-parallel.sh (e.g. '-cleanup').\n\n Only those options that come before the 'canoe'\n\n keyword to canoe-parallel.sh are legal here.\n\n CP-OPTS must be quoted if it includes whitespace.\n\n Multiple --cp-opts options are permitted.''')\n\n grp_cp.add_argument(\"-p\", \"--cp-numpar\", dest=\"cp_n\", type=pos_int,\n\n metavar=\"CP-NUMPAR\",\n\n help='''Maximum number of parallel decoding jobs for nbest\n\n list generation (-n option to canoe-parallel.sh).\n\n [None: canoe-parallel.sh -n default]''')\n\n grp_cp.add_argument(\"-c\", \"--cp-ncpus\", dest=\"cp_ncpus\", type=pos_int,\n\n default=1, metavar=\"CP-NCPUS\",\n\n help='''Number of cpus per decoding job. [%(default)s]''')\n\n grp_cp.add_argument(\"-n\", \"--nbest-size\", dest=\"nbsize\", type=pos_int, default=1000,\n\n help=\"Size of nbest lists. [%(default)s]\")\n\n grp_cp.add_argument(\"-msrc\", \"--marked-src\", dest=\"msrc\", type=str,\n\n help='''A version of the source file marked up with\n\n rule-based translations, used for canoe input but\n\n not for feature generation [SRC]''')\n\n grp_cp.add_argument(\"--check-dep\", action='store_true', default=False,\n\n help='''Check that the nbest is more recent than the\n\n canoe CONFIG, and regenerate it if not. Similarly, \n\n feature functions are regenerated unless they are\n\n more recent than the nbest list. This mimics \"make\"\n\n because the nbest depends on the canoe CONFIG.\n\n [don't regenerate existing files]''')\n\n\n\n grp_fg = parser.add_argument_group(\"feature generation options\")\n\n grp_fg.add_argument(\"-F\", \"--force-overwrite\", action='store_true', default=False,\n\n help='''Force overwrite of existing feature function files.\n\n [don't overwrite]''')\n\n grp_fg.add_argument(\"-pg\", \"--gfp-numpar\", dest=\"gfp_n\", type=pos_int,\n\n metavar=\"GFP-NUMPAR\",\n\n help='''Maximum number of parallel jobs for feature generation. \n\n [-p CP-NUMPAR value if specified, else 3]''')\n\n grp_fg.add_argument(\"-cg\", \"--gfp-ncpus\", dest=\"gfp_ncpus\", type=pos_int,\n\n metavar=\"GFP-NCPUS\",\n\n help='''Number of cpus per decoding job. [-c CP-NCPUS value]''')\n\n grp_fg.add_argument(\"--gfp-opts\", type=str, action=\"append\", default=[],\n\n metavar=\"GFP-OPTS\",\n\n help='''Options for gen-features-parallel.pl (e.g. '-J 30').\n\n Most options are automatically set by rescore.py.\n\n GFP-OPTS must be quoted if it includes whitespace.\n\n Multiple --gfp-opts options are permitted.''')\n\n grp_fg.add_argument(\"-sproxy\", \"--src-proxy\", dest=\"sproxy\", type=str,\n\n default=\"\", metavar=\"SPROXY\",\n\n help='''Use SPROXY instead of SRC when substituting for\n\n <src> tag in MODEL.''')\n\n\n\n grp_rt = parser.add_argument_group(\"rescore -train/-trans options\")\n\n grp_rt.add_argument(\"-a\", \"--algorithm\", type=str, metavar=\"ALG+ARGS\",\n\n help='''In train mode, \n\n optimizer algorithm+arguments string, one of:\n\n powell [rescore_train-opts], \n\n mira [C [I [E [B [H [O [D]]]]]]].\n\n [powell]''')\n\n grp_rt.add_argument(\"-o\", \"--model-out\", type=str, metavar=\"MODEL-OUT\",\n\n help='''In train mode (-train), write the final model to\n\n MODEL_OUT [MODEL.rat]''')\n\n grp_rt.add_argument(\"-s\", \"--seed\", type=int, default=0,\n\n help='''Start seed for random number generator in mira.\n\n [%(default)s]''')\n\n grp_rt.add_argument(\"--bleu-order\", type=pos_int, default=4, metavar=\"ORDER\",\n\n help=\"N-gram order used when optimizing BLEU. [%(default)s]\")\n\n grp_rt.add_argument(\"--rtrans-opts\", type=str, action=\"append\", default=[],\n\n metavar=\"OPTS\",\n\n help='''Options for rescore_translate.\n\n OPTS must be quoted if it includes whitespace.\n\n Multiple --rtrans-opts options are permitted.''')\n\n\n\n grp_gen = parser.add_argument_group(\"general options\")\n\n grp_gen.add_argument(\"-w\", \"--workdir\", type=str,\n\n help='''Work directory to use for rescoring.\n\n [workdir-MSRC-NBbest]''')\n\n grp_gen.add_argument(\"-pfx\", \"--prefix\", dest=\"pfx\", type=str, default=\"\",\n\n help='''Prefix for all intermediate files (1best, nbest,\n\n ffvals, pal, feature files) within the working\n\n directory. This switch can be used to store results\n\n from several different runs in the same working\n\n directory. If PFX is non-empty, the output in\n\n translation mode is named PFXrat. [\"%(default)s\"]''')\n\n # Use our standard help, verbose and debug support.\n\n grp_gen.add_argument(\"-h\", \"-help\", \"--help\", action=HelpAction)\n\n grp_gen.add_argument(\"-v\", \"--verbose\", action=VerboseMultiAction)\n\n grp_gen.add_argument(\"-d\", \"--debug\", action=DebugAction)\n\n\n\n try:\n\n cmd_args = parser.parse_args()\n\n except IOError as e:\n\n fatal_error(\"cannot open: '{0}': {1}\".format(e.filename, e))\n\n\n\n # Set some argument defaults\n\n \n\n if cmd_args.mode is Mode.train:\n\n cmd_args.model_out = cmd_args.model_out or os.path.basename(cmd_args.model) + '.rat'\n\n elif cmd_args.model_out is not None:\n\n fatal_error(\"-o is not valid only for --trans/--ffgen (valid only for --train).\")\n\n\n\n if cmd_args.mode is Mode.train and len(cmd_args.refs) == 0:\n\n fatal_error(\"Reference texts are needed for training (--train).\")\n\n \n\n if cmd_args.mode is Mode.train:\n\n cmd_args.algorithm = cmd_args.algorithm or 'powell'\n\n elif cmd_args.algorithm is not None:\n\n fatal_error(\"-a is not valid for --trans/--ffgen (valid only for --train).\")\n\n\n\n cmd_args.msrc = cmd_args.msrc or cmd_args.src\n\n \n\n cmd_args.gfp_n = cmd_args.gfp_n or cmd_args.cp_n or 3\n\n cmd_args.gfp_ncpus = cmd_args.gfp_ncpus or cmd_args.cp_ncpus\n\n\n\n cmd_args.workdir = cmd_args.workdir or \\\n\n \"workdir-{0}-{1}best\".format(os.path.basename(cmd_args.msrc),\n\n cmd_args.nbsize)\n\n\n\n verbose(\" \".join(sys.argv))\n\n debug(cmd_args)\n\n \n\n # Validate file arguments\n\n ferror = False\n\n\n\n def file_error(f, type=\"\", mode='r'):\n\n error(\" \", type, \" file '\", f, \"' is not a \", \n\n \"writable\" if mode == 'w' else \"readable\", \" file.\", sep='')\n\n return True\n\n\n\n if not is_readable_file(cmd_args.model):\n\n ferror = file_error(cmd_args.model, \"Rescoring MODEL\")\n\n\n\n if not is_readable_file(cmd_args.src):\n\n ferror = file_error(cmd_args.src, \"SRC\")\n\n\n\n for f in cmd_args.refs:\n\n if not is_readable_file(f):\n\n ferror = file_error(f, \"Reference\")\n\n\n\n if not is_readable_file(cmd_args.canoe_config):\n\n ferror = file_error(cmd_args.canoe_config, \"Canoe CONFIG\")\n\n\n\n if not is_readable_file(cmd_args.msrc):\n\n ferror = file_error(cmd_args.msrc, \"MSRC\")\n\n\n\n if cmd_args.mode is Mode.train:\n\n if os.path.exists(cmd_args.model_out) and not is_writable_file(cmd_args.model_out) \\\n\n or not is_writable_dir(os.path.dirname(cmd_args.model_out) or \".\"):\n\n ferror = file_error(cmd_args.model_out, \"MODEL_OUT\", 'w')\n\n \n\n if ferror: fatal_error(\"Aborting due to file errors.\")\n\n\n\n return cmd_args\n\n\n\ndef get_algorithm_args(alg_plus_args):\n\n \"\"\"Parse the -a algorithm+arguments string for train mode.\n\n\n\n The algorithm+arguments string may be one of:\n\n powell [rescore-opts]\n\n mira [C [I [E [B [H [O [D]]]]]]]\n\n\n\n alg_plus_args: algorithm+arguments string to parse\n\n returns: parsed arguments in an argparse.Namespace object.\n\n \"\"\"\n\n\n\n def float_str(arg):\n\n try:\n\n value = float(arg)\n\n except ValueError:\n\n raise ArgumentTypeError(\"invalid float value: '{0}'\".format(arg))\n\n return arg\n\n\n\n prog = '{0} ... -a'.format(prog_name())\n\n\n\n parser = ArgumentParser(prog=prog,add_help=False)\n\n subparsers = parser.add_subparsers(dest='algorithm')\n\n parser_powell = subparsers.add_parser('powell', add_help=False,\n\n usage=\"{0} 'powell [rescore_train-opts]'\".format(prog))\n\n parser_mira = subparsers.add_parser('mira', add_help=False,\n\n usage=\"{0} 'mira [C [I [E [B [H [O [D]]]]]]]'\".format(prog))\n\n parser_mira.add_argument('C', type=float_str, nargs='?', default='1e-02',\n\n help='learning rate; 1e-4 recommended for B=1, 1e-8 for B=2')\n\n parser_mira.add_argument('I', type=int, nargs='?', default=30, \n\n help='number of iterations')\n\n parser_mira.add_argument('E', type=int, nargs='?', default=1, \n\n help='number of neg examples')\n\n parser_mira.add_argument('B', type=int, nargs='?', default=-4,\n\n help='if >0, col to find BLEU in allbleus file')\n\n parser_mira.add_argument('H', choices=['true', 'false'], nargs='?',\n\n default='true', help='hope update?')\n\n parser_mira.add_argument('O', choices=['Model', 'Oracle', 'Orange'], \n\n nargs='?', default='Oracle',\n\n help='use Model, Oracle or Orange as background')\n\n parser_mira.add_argument('D', type=float_str, nargs='?', default='0.999',\n\n help='Rate at which to decay Model or Oracle BG')\n\n\n\n alg_args, extra_args = parser.parse_known_args(shlex.split(alg_plus_args))\n\n\n\n if alg_args.algorithm == 'mira':\n\n if len(extra_args) is not 0:\n\n parser_mira.error(\"unrecognized arguments: \" + ' '.join(extra_args))\n\n else:\n\n alg_args.rtrain_opts = extra_args\n\n\n\n return alg_args\n\n\n\ndef convert_rescore_model(model_in, model_rat_out, model_out):\n\n \"\"\"Transform the trained rescore-model from RAT syntax to normal syntax.\n\n \n\n This transfers the scores from the rat_out_model to orig_model, outputting\n\n the result in out-model.\n\n \n\n model_in: original input rescore_model file (with/without scores)\n\n model_rat_out: trained rescore_model file in RAT syntax\n\n model_out: output rescore_model file with scores from model_rat_out and\n\n feature names from model_in\n\n \"\"\"\n\n ff_wt_re = re.compile(r'(.*?)(?:\\s+((?:-?[0-9]*\\.?[0-9]*)(?:[Ee]-?[0-9]+)?))?$')\n\n with open(model_in, 'r') as model_in_file:\n\n with open(model_rat_out, 'r') as model_rat_out_file:\n\n with open(model_out, 'w') as model_out_file:\n\n for line_num, model_in_line in enumerate(model_in_file, start=1):\n\n model_line = model_in_line.strip()\n\n model_match = ff_wt_re.match(model_line)\n\n wts_line = model_rat_out_file.readline().strip()\n\n wts_match = ff_wt_re.match(wts_line)\n\n # Sanity check\n\n if not model_match.group(1):\n\n error(\"No feature in model at line\", line_num)\n\n debug(\"model_line:\", model_line)\n\n debug(\"model group 1 match:\", model_match.group(1))\n\n debug(\"model group 2 match:\", model_match.group(2))\n\n if not wts_match.group(2):\n\n error(\"Missing weight at line\", line_num)\n\n debug(\"wts_line:\", wts_line)\n\n debug(\"wts group 1 match:\", wts_match.group(1))\n\n debug(\"wts group 2 match:\", wts_match.group(2))\n\n if model_line.startswith(\"#\"): # comment\n\n wts_start = model_line\n\n elif model_line.startswith(\"FileFF:\"): # FileFF:ffvals,N\n\n wts_start = model_match.group(1)\n\n else: # featName:...\n\n wts_start = \"FileFF:ff.\" + model_match.group(1).split(':', 1)[0]\n\n if not wts_match.group(1).startswith(wts_start):\n\n warn(\"Possible model-weight mismatch at line\", line_num)\n\n debug(\"model_line:\", model_line)\n\n debug(\"model group 1 match:\", model_match.group(1))\n\n debug(\"model group 2 match:\", model_match.group(2))\n\n debug(\"wts_line:\", wts_line)\n\n debug(\"wts group 1 match:\", wts_match.group(1))\n\n debug(\"wts group 2 match:\", wts_match.group(2))\n\n # Write out the original feature function name and its weight\n\n print(model_match.group(1), wts_match.group(2), file=model_out_file)\n\n if model_rat_out_file.readline():\n\n fatal_error(model_rat_out, \"contains more lines than\", model_in)\n\n\n\n\n\ndef main():\n\n printCopyright(prog_name(), 2013);\n\n os.environ['PORTAGE_INTERNAL_CALL'] = '1'; # add this if needed\n\n\n\n cmd_args = get_args()\n\n \n\n verbose(\"rescore.py starting on\", datetime.today(), \"\\n\")\n\n\n\n # Create the workdir, store its name globally so run_command can use it.\n\n global workdir\n\n if cmd_args.workdir:\n\n workdir = cmd_args.workdir\n\n else:\n\n workdir = \"workdir-{0}-{1}best\".format(os.path.basename(cmd_args.msrc),\n\n cmd_args.nbsize)\n\n if not os.path.isdir(workdir):\n\n try:\n\n os.mkdir(workdir)\n\n except os.error as e:\n\n fatal_error(\" Cannot create workdir '\", workdir, \"': \", e, sep='')\n\n\n\n orig_pfx = cmd_args.pfx or os.path.basename(cmd_args.msrc) + \".\"\n\n pfx = os.path.join(workdir, cmd_args.pfx)\n\n\n\n # Step 1. Run canoe to generate Nbest lists, ffvals and pal files.\n\n verbose(\"Generating {0}best lists:\".format(cmd_args.nbsize))\n\n\n\n # Like tune.py, filtering is expected to be done already (e.g. by the framework).\n\n\n\n # Check that the Nbest is more recent than the canoe.ini.\n\n nb_str = \"{0}best\".format(cmd_args.nbsize)\n\n nbest = None\n\n deleted_nb = 0\n\n for ext in [\"\", \".gz\"]:\n\n nb = \"{0}{1}{2}\".format(pfx, nb_str, ext)\n\n if not os.path.exists(nb): continue\n\n if not is_readable_file(nb):\n\n ferror = file_error(nb, nb_str)\n\n if cmd_args.check_dep and \\\n\n os.path.getmtime(nb) < os.path.getmtime(cmd_args.canoe_config):\n\n warn(\"Removing old Nbest file:\", nb)\n\n os.unlink(nb)\n\n deleted_nb += 1\n\n else:\n\n nbest = nb\n\n if deleted_nb:\n\n if not nbest:\n\n warn(\"Regenerating Nbest since it was older than\", cmd_args.canoe_config)\n\n else:\n\n warn(\"Not regenerating Nbest since there is an Nbest newer than\", cmd_args.canoe_config)\n\n\n\n pal = \"{0}pal.gz\".format(pfx)\n\n ffvals = \"{0}ffvals.gz\".format(pfx)\n\n if nbest:\n\n info(\"NBest file\", nbest, \"exists - skipping\", nb_str, \n\n \"and ffvals and pal generation.\")\n\n if not os.path.exists(pal):\n\n pal = \"{0}pal\".format(pfx)\n\n if not os.path.exists(ffvals):\n\n ffvals = \"{0}ffvals\".format(pfx)\n\n else:\n\n if os.path.exists(pal):\n\n warn(\"Phrase alignment file \", pal, \"exists already - overwriting it!\")\n\n os.unlink(pal)\n\n if os.path.exists(ffvals):\n\n warn(\"ffvals file \", ffvals, \"exists already - overwriting it!\")\n\n os.unlink(ffvals)\n\n\n\n warned = False\n\n for ff in glob.iglob(\"{0}ff.*\".format(pfx)):\n\n if not warned:\n\n warn(\"Generating a new Nbest list makes all previous ff files \"\n\n \"irrelevant - deleting them.\")\n\n warned = True\n\n os.unlink(ff)\n\n\n\n # Check the validity of the canoe config file.\n\n verbose(\"Checking canoe config\")\n\n cmd = [\"configtool\", \"check\", cmd_args.canoe_config]\n\n run_command(cmd, \"config file check\")\n\n\n\n # Run canoe to produce the Nbest lists, pal, and ffval files.\n\n # Note: We need a filename prefix for -nbest for canoe-parallel.sh to\n\n # work correctly because `basename dir/` is \"dir\", so we use 'nb.'\n\n cmd = [\"set\", \"-o\", \"pipefail\", \";\"]\n\n cmd.append(\"canoe-parallel.sh\")\n\n if cmd_args.debug: cmd.append(\"-d\")\n\n cmd.append(\"-lb-by-sent\")\n\n if cmd_args.cp_n:\n\n cmd.extend((\"-n\", str(cmd_args.cp_n)))\n\n cmd.extend((\"-psub\", \"-{0}\".format(cmd_args.cp_ncpus)))\n\n cmd.extend(shlex.split(' '.join(cmd_args.cp_opts).encode('utf8')))\n\n cmd.extend((\"canoe\", \"-append\", \"-v\", str(cmd_args.verbose),\n\n \"-f\", cmd_args.canoe_config,\n\n \"-nbest\", \"{0}nb..gz:{1}\".format(pfx, cmd_args.nbsize),\n\n \"-ffvals\", \"-palign\", \n\n \"<\", cmd_args.msrc))\n\n cmd.extend((\"|\", \"nbest2rescore.pl\", \"-canoe\", \">\", \"{0}1best\".format(pfx)))\n\n run_command(cmd, \"decoder\", shell=True)\n\n \n\n nbest = \"{0}{1}.gz\".format(pfx, nb_str)\n\n # Rename nb.nbest.gz file to e.g. 1000best.gz;\n\n # also nb.ffvals.gz to ffvals.gz, and nb.pal.gz to pal.gz.\n\n if os.path.exists(\"{0}nb.nbest.gz\".format(pfx)):\n\n os.rename(\"{0}nb.nbest.gz\".format(pfx), nbest)\n\n if os.path.exists(\"{0}nb.ffvals.gz\".format(pfx)):\n\n os.rename(\"{0}nb.ffvals.gz\".format(pfx), ffvals)\n\n if os.path.exists(\"{0}nb.pal.gz\".format(pfx)):\n\n os.rename(\"{0}nb.pal.gz\".format(pfx), pal)\n\n\n\n # Sanity Checks\n\n if not os.path.exists(nbest):\n\n fatal_error(\"Failed to generate nbest file:\", nbest)\n\n if not os.path.exists(ffvals):\n\n fatal_error(\"Failed to generate ffvals file:\", ffvals)\n\n if not os.path.exists(pal):\n\n fatal_error(\"Failed to generate pal file:\", pal)\n\n\n\n # Step 2. Generate feature values for Nbest lists\n\n verbose(\"Generating feature files:\")\n\n\n\n # -trans mode might have .rat extension, -ffgen might not, -train won't\n\n # We always want .ff or .ff.rat, never .rat.ff\n\n model_base, model_ext = os.path.splitext(os.path.basename(cmd_args.model))\n\n if model_ext != \".rat\":\n\n model_base += model_ext\n\n model_ext = \"\"\n\n model_rat_in = os.path.join(workdir, \"{0}.ff{1}\".format(model_base, model_ext))\n\n model_rat_out = \"{0}.rat\".format(model_rat_in) # used only by -train\n\n\n\n cmd = [\"gen-features-parallel.pl\"]\n\n if cmd_args.debug: cmd.append(\"-d\")\n\n if cmd_args.verbose: cmd.append(\"-v\")\n\n if cmd_args.force_overwrite: cmd.append(\"-F\")\n\n cmd.extend((\"-N\", str(cmd_args.gfp_n)))\n\n cmd.extend((\"-rpopts\", \"-psub -{0}\".format(cmd_args.gfp_ncpus)))\n\n cmd.extend((\"-o\", model_rat_in, \"-c\", cmd_args.canoe_config, \"-a\", pal, \"-p\", pfx))\n\n if cmd_args.sproxy: cmd.extend((\"-s\", cmd_args.sproxy))\n\n cmd.extend(shlex.split(' '.join(cmd_args.gfp_opts).encode('utf8')))\n\n cmd.extend((cmd_args.model, cmd_args.src, nbest))\n\n run_command(cmd, \"feature generation\")\n\n\n\n # Step 3. Train or translate with the rescoring model\n\n if cmd_args.mode is Mode.train:\n\n verbose(\"Training rescoring model:\")\n\n alg_args = get_algorithm_args(cmd_args.algorithm.encode('utf8'))\n\n if alg_args.algorithm == 'mira':\n\n mira_data = \"{0}matrix4mira\".format(pfx)\n\n cmd = [\"rescore_translate\", \"-p\", pfx, \"-dump-for-mira\", mira_data,\n\n model_rat_in, cmd_args.src, nbest]\n\n run_command(cmd, \"training\", time_it=True)\n\n seed = str(cmd_args.seed * 10000 + 1)\n\n cmd = [\"java\", \"-Xmx16000m\", \"-enableassertions\", \n\n \"-jar\", os.path.join(prog_dir(), \"structpred.jar\"),\n\n \"MiraTrainNbestDecay\", model_rat_in, mira_data+\".allffvals.gz\",\n\n mira_data+\".allbleus.gz\", mira_data+\".allnbest.gz\", \n\n ','.join(cmd_args.refs), alg_args.C, str(alg_args.I),\n\n str(alg_args.E), str(alg_args.B), alg_args.H, alg_args.O,\n\n alg_args.D, str(cmd_args.bleu_order), seed, \n\n \">\", model_rat_out]\n\n run_command(cmd, \"training\", time_it=True, shell=True)\n\n else:\n\n cmd = [\"rescore_train\"]\n\n if cmd_args.verbose: cmd.append(\"-v\")\n\n cmd.extend((\"-n\", \"-bleu\", \"-p\", pfx))\n\n cmd.extend(alg_args.rtrain_opts)\n\n cmd.extend((model_rat_in, model_rat_out, cmd_args.src, nbest))\n\n cmd.extend(cmd_args.refs)\n\n run_command(cmd, \"training\", time_it=True)\n\n\n\n elif cmd_args.mode is Mode.trans:\n\n verbose(\"Translating with rescoring model:\")\n\n # We want the results outside the working dir\n\n cmd = [\"rescore_translate\"]\n\n if cmd_args.verbose: cmd.append(\"-v\")\n\n cmd.extend((\"-p\", pfx))\n\n cmd.extend(shlex.split(' '.join(cmd_args.rtrans_opts).encode('utf8')))\n\n cmd.extend([model_rat_in, cmd_args.src, nbest])\n\n cmd.extend([\">\", \"{0}rat\".format(orig_pfx)])\n\n run_command(cmd, \"translate\", time_it=True, shell=True)\n\n\n\n # Transform the trained rescore-model from RAT syntax to normal syntax\n\n if cmd_args.mode is Mode.train:\n\n verbose(\"Transforming trained rescore-model to normal syntax:\")\n\n convert_rescore_model(cmd_args.model, model_rat_out, cmd_args.model_out)\n\n\n\n # Evaluate the translation results, if references provided for -trans mode\n\n elif cmd_args.mode is Mode.trans:\n\n if len(cmd_args.refs) > 0:\n\n info(\"Evaluation of 1-best output from canoe:\")\n\n cmd = [\"bleumain\", \"-c\", \"-y\", str(cmd_args.bleu_order), \"{0}1best\".format(pfx)]\n\n cmd.extend(cmd_args.refs)\n\n run_command(cmd, \"canoe output evaluation\")\n\n \n\n info(\"Evaluation of rescoring output:\")\n\n cmd = [\"bleumain\", \"-c\", \"-y\", str(cmd_args.bleu_order), \"{0}rat\".format(orig_pfx)]\n\n cmd.extend(cmd_args.refs)\n\n run_command(cmd, \"rescored output evaluation\")\n\n\n\n verbose(\"rescore.py completed on\", datetime.today(), \"\\n\")\n\n print_master_wall_time()\n\n\n\nif __name__ == '__main__':\n\n main()\n", "file_path": "src/rescoring/rescore.py", "rank": 91, "score": 95689.47143431837 }, { "content": "#!/usr/bin/env python2\n\n# -*- coding: utf-8 -*-\n\n\n\n# @file embed.py\n\n# @brief Embedding layer to map integer class indexes to a real-valued features.\n\n#\n\n# @author George Foster\n\n#\n\n# Traitement multilingue de textes / Multilingual Text Processing\n\n# Centre de recherche en technologies numériques / Digital Technologies Research Centre\n\n# Conseil national de recherches Canada / National Research Council Canada\n\n# Copyright 2014, Sa Majeste la Reine du Chef du Canada /\n\n# Copyright 2014, Her Majesty in Right of Canada\n\n\n\nimport sys\n\nimport numpy\n\nimport numpy.random as rng\n\nimport theano\n\nfrom theano import config, shared, tensor as T\n\n\n\nimport msgd\n\nimport multilayers\n\n\n\nclass EmbedLayer(object):\n\n def __init__(self, v, vsize, nclasses, nfeats_per_class, vstart = 0, bias=False):\n\n \"\"\"\n\n Layer to map integer class indexes to a real-valued features.\n\n\n\n Args:\n\n v: symbolic input matrix, one integer vector per row\n\n vsize: number of elements to use from each row of v\n\n nclasses: 1 + max size of elements in v\n\n nfeats_per_class: number of real-valued features to represent each class\n\n vstart: index of first element to use in each row of v\n\n bias: should we add a bias term to each position?\n\n \"\"\"\n\n self.x_size = vsize * nfeats_per_class # size of each output vector\n\n self.lookup = shared(rng.uniform(-0.05,0.05,size=(nclasses, nfeats_per_class)).astype(config.floatX),\n\n name=\"lookup\")\n\n if bias:\n\n self.b = shared(numpy.zeros(self.x_size,dtype=theano.config.floatX),name='b')\n\n # x is lookup[r[0]] ... lookup[r[-1]] for each row r in v:\n\n # self.x = theano.map(lambda r, lk: T.flatten(lk[r[vstart:vstart+vsize]]), [v], [self.lookup])[0]\n\n self.x = T.flatten(self.lookup[v[:,vstart:vstart+vsize]], 2)\n\n if bias: self.x += self.b\n\n self.params = [self.lookup]\n\n if bias: self.params.append(self.b)\n\n\n\n def vocabularySize(self):\n\n return numpy.shape(self.lookup.get_value())[0]\n\n\n\n def embeddingSize(self):\n\n return numpy.shape(self.lookup.get_value())[1]\n\n\n\n def windowSize(self):\n\n return self.x_size / self.embeddingSize()\n\n\n\n\n\n\n\n# Test EmbedLayer in a maxent setup.\n\n\n\nif __name__ == \"__main__\":\n\n\n\n rng.seed(1)\n\n\n\n N = 1000 # number of examples\n\n vsize = 4 # size of class vectors\n\n nclasses_in = 50 # number of input classes\n\n nfeats_per_class = 5\n\n nclasses_out = 8 # number of output classes\n\n reg = 0.01 # reg wt\n\n\n\n v = T.imatrix(\"v\") # input vectors: N x vsize\n\n y = T.ivector(\"y\") # output classes: N x 1\n\n\n\n inputs = EmbedLayer(v, vsize, nclasses_in, nfeats_per_class)\n\n outputs = multilayers.OutputLayer(inputs.x, y, inputs.x_size, nclasses_out)\n\n\n\n reg_nll = outputs.nll.mean() + \\\n\n reg * ((outputs.w**2).sum() + (inputs.lookup**2).sum()) # regularized loss\n\n\n\n D = (numpy.int32(rng.randint(size=(N,vsize), low=0, high=nclasses_in)),\n\n numpy.int32(rng.randint(size=N, low=0, high=nclasses_out)))\n\n\n\n msgd.optimize(v, y, reg_nll, inputs.params+outputs.params, D, error=outputs.nll, print_interval=100)\n", "file_path": "src/nn/embed.py", "rank": 92, "score": 95689.47143431837 }, { "content": "#!/usr/bin/env python2\n\n# -*- coding: utf-8 -*-\n\n\n\n# @file stanseg.py\n\n# @brief Wrapper for the Stanford Segmenter with our customized handling for hashtags and wa\n\n#\n\n# @author Eric Joanis\n\n\n\n# We encourage use of Python 3 features such as the print function.\n\nfrom __future__ import print_function, unicode_literals, division, absolute_import\n\n\n\nimport os\n\nimport sys\n\nimport codecs\n\nimport re\n\nfrom argparse import ArgumentParser\n\nfrom portage_utils import *\n\nfrom subprocess import *\n\n\n\ndef get_args():\n\n \"\"\"Command line argument processing.\"\"\"\n\n\n\n usage=\"stanseg.py [options] [infile [outfile]]\"\n\n help=\"\"\"\n\n Takes OSPL input, pass it through the Stanford Segmenter with some\n\n additional conditional processing.\n\n \"\"\"\n\n\n\n # Use the argparse module, not the deprecated optparse module.\n\n parser = ArgumentParser(usage=usage, description=help, add_help=False)\n\n\n\n # Use our standard help, verbose and debug support.\n\n parser.add_argument(\"-h\", \"-help\", \"--help\", action=HelpAction)\n\n parser.add_argument(\"-v\", \"--verbose\", action=VerboseAction)\n\n parser.add_argument(\"-d\", \"--debug\", action=DebugAction)\n\n\n\n parser.add_argument(\"-m\", dest=\"xmlishifyHashtags\", action='store_true', default=False,\n\n help=\"xmlishify hashtags. [%(default)s]\")\n\n\n\n parser.add_argument(\"-w\", dest=\"removeWaw\", action='store_true', default=False,\n\n help=\"Remove beginning of sentence's w+. [%(default)s]\")\n\n\n\n # The following use the portage_utils version of open to open files.\n\n parser.add_argument(\"infile\", nargs='?', type=open, default=sys.stdin,\n\n help=\"input file [sys.stdin]\")\n\n parser.add_argument(\"outfile\", nargs='?', type=lambda f: open(f,'w'),\n\n default=sys.stdout,\n\n help=\"output file [sys.stdout]\")\n\n\n\n cmd_args = parser.parse_args()\n\n\n\n return cmd_args\n\n\n\nclass RequestPostprocessor():\n\n def __init__(self, removeWaw=False, xmlishifyHashtags=False, unescapeHandles=False):\n\n self.removeWaw = removeWaw\n\n self.xmlishifyHashtags = xmlishifyHashtags\n\n self.unescapeHandles = unescapeHandles\n\n self.re_escaped_handle = re.compile(ur'^TWITTERHANDLEZA[a-zA-Z]+$')\n\n self.re_handle_reverse_dict = {\n\n 'A': '@', 'U': '_', 'Z': 'Z',\n\n 'a': '0', 'b': '1', 'c': '2', 'd': '3', 'e': '4',\n\n 'f': '5', 'g': '6', 'h': '7', 'i': '8', 'j': '9',\n\n }\n\n\n\n def _escapeXMLChars(self, sentence):\n\n # < hashtag > -> <hashtag> and </ hashtag > -> </hashtag> since Stan Seg toks them\n\n sentence = re.sub(\"(^| )<(/|) hashtag >($| )\", \"\\g<1><\\g<2>hashtag>\\g<3>\", sentence)\n\n # We need to run this RE sub twice because the first misses a < hashtag >\n\n # immediately after a </ hashtag >\n\n sentence = re.sub(\"(^| )<(/|) hashtag >($| )\", \"\\g<1><\\g<2>hashtag>\\g<3>\", sentence)\n\n\n\n tokens = sentence.split()\n\n for i, tok in enumerate(tokens):\n\n if tok not in (\"<hashtag>\", \"</hashtag>\"):\n\n tok = re.sub(\"&(?![a-zA-Z]+;)\",\"&amp;\",tok)\n\n tok = re.sub(\"<\",\"&lt;\",tok)\n\n tok = re.sub(\">\",\"&gt;\",tok)\n\n tokens[i] = tok\n\n return ' '.join(tokens)\n\n\n\n def _unescapeTwitterHandle(self, sentence):\n\n tokens = sentence.split()\n\n prefix_len = len(\"TWITTERHANDLE\")\n\n for i, tok in enumerate(tokens):\n\n if self.re_escaped_handle.match(tok):\n\n #print(\"unescape {}\".format(tok), file=sys.stderr)\n\n tokens[i] = re.sub('Z(.)',\n\n lambda m: self.re_handle_reverse_dict.get(m.group(1), m.group(1)),\n\n tok[prefix_len:])\n\n return ' '.join(tokens)\n\n\n\n def _removeWaw(self, sentence):\n\n return re.sub(u'^و\\+ ', '', sentence)\n\n\n\n def __call__(self, sentence):\n\n if self.xmlishifyHashtags:\n\n sentence = self._escapeXMLChars(sentence)\n\n if self.removeWaw:\n\n sentence = self._removeWaw(sentence)\n\n if self.unescapeHandles:\n\n sentence = self._unescapeTwitterHandle(sentence)\n\n return sentence\n\n\n\ndef run_normalize(infile):\n\n \"\"\"\n\n Pass the input through normalize-unicode.pl ar since the Stanford Segmenter\n\n does not recognize characters in their presentation form, only in their\n\n canonical form.\n\n \"\"\"\n\n norm_cmd = \"normalize-unicode.pl ar\"\n\n p = Popen(norm_cmd, shell=True, stdin=infile, stdout=PIPE).stdout\n\n return p\n\n\n\ndef run_prepro(infile, xmlishifyHashtags):\n\n \"\"\"\n\n Run the preprocessing in a separate script before calling the stanford\n\n segmenter itself. The code might have been placed in a child process in this\n\n script by using os.fork(), but writing a separate script is simpler (and\n\n lazier, I know...)\n\n \"\"\"\n\n pre_cmd = \"stanseg-pre.py\"\n\n if xmlishifyHashtags:\n\n pre_cmd += \" -m\"\n\n p = Popen(pre_cmd, shell=True, stdin=infile, stdout=PIPE).stdout\n\n return p\n\n\n\ndef run_stan_seg(infile):\n\n \"\"\"Run the Stanford Segmenter itself\"\"\"\n\n stanseg_home = os.environ.get('STANFORD_SEGMENTER_HOME', None)\n\n stanseg_classifier = \"arabic-segmenter-atb+bn+arztrain.ser.gz\"\n\n stanseg_cmd = \"java -mx4g \" + \\\n\n \"edu.stanford.nlp.international.arabic.process.ArabicSegmenter \" + \\\n\n \"-loadClassifier \" + stanseg_home + \"/data/\" + stanseg_classifier + \\\n\n \" -prefixMarker + -suffixMarker + -domain arz -nthreads 1\"\n\n p = Popen(stanseg_cmd, shell=True, stdin=infile, stdout=PIPE).stdout\n\n #print(p)\n\n #print(p[0])\n\n return p\n\n\n\ndef main():\n\n os.environ['PORTAGE_INTERNAL_CALL'] = '1'; # add this if needed\n\n\n\n print(\"DEPRECATED WARNING: stanseg.py was the first attempt to wrap the Stanford Segmenter and is somewhat buggy. It's here for development and documentation purposes only. Use stanseg.pl instead.\\n\", file=sys.stderr)\n\n\n\n cmd_args = get_args()\n\n\n\n pipe1 = run_normalize(cmd_args.infile)\n\n pipe2 = run_prepro(pipe1, cmd_args.xmlishifyHashtags)\n\n pipe3 = codecs.getreader('utf-8')(run_stan_seg(pipe2))\n\n\n\n outfile = codecs.getwriter('utf-8')(cmd_args.outfile)\n\n\n\n post = RequestPostprocessor(cmd_args.removeWaw, cmd_args.xmlishifyHashtags,\n\n unescapeHandles=True)\n\n for line in pipe3:\n\n print(post(line.rstrip()), file=outfile)\n\n\n\n\n\nif __name__ == '__main__':\n\n main()\n", "file_path": "src/preprocessing/stanseg.py", "rank": 93, "score": 95689.47143431837 }, { "content": " * Sets the output filename for online processing.\n\n * @param filtered_TM_filename output filename\n\n */\n\n void outputForOnlineProcessing(const string& filtered_TM_filename);\n\n\n\n virtual float convertFromRead(float value) const;\n\n virtual float convertToWrite(float value) const;\n\n\n\n virtual Uint processTargetPhraseTable(const string& src, Uint src_word_count, TargetPhraseTable* tgtTable);\n\n virtual TargetPhraseTable* getTargetPhraseTable(PhraseTableEntry& entry, bool limitPhrases);\n\n\n\n}; // ends class PhraseTableFilterJoint\n\n}; // ends namespace Portage\n\n\n\n#endif // __PHRASE_TABLE_FILTER_JOINT_H__\n\n\n", "file_path": "src/canoe/phrasetable_filter_joint.h", "rank": 94, "score": 70.16807229139597 }, { "content": "#include \"ibm1del.h\"\n\n#include <ttablewithmax.h>\n\n#include <vector>\n\n#include <string>\n\n\n\nusing namespace std;\n\nusing namespace Portage;\n\n\n\nIBM1DeletionBase::IBM1DeletionBase(const string& args)\n\n: FeatureFunction(args)\n\n, table(NULL)\n\n, thr(0.1f)\n\n, ttable_file(args.substr(0, args.find(\"#\")))\n\n{}\n\n\n\nbool IBM1DeletionBase::loadModelsImpl()\n\n{\n\n table = new TTableWithMax(ttable_file); \n\n assert(table);\n\n return table != NULL;\n", "file_path": "src/rescoring/ibm1del.cc", "rank": 95, "score": 54.6282778668024 }, { "content": " }\n\n\n\n /// Set value from string.\n\n /// @param s new value\n\n void set(const string& s);\n\n /// Set this bool parameter's value\n\n /// @param value new value\n\n /// @pre tconv == \"bool\"\n\n void set(bool value);\n\n\n\n /// Get string representation of current value\n\n /// @param pretty make the string pretty (caution: not necessarily\n\n /// reversible using set())\n\n /// @return Returns a string representation of current value.\n\n string get(bool pretty = false);\n\n };\n\n\n\n static const Uint precision = 10; ///< significant digits for weights\n\n\n\n vector<ParamInfo> param_infos; ///< main parameter list\n", "file_path": "src/canoe/config_io.h", "rank": 98, "score": 52.3457889191665 }, { "content": "#include \"gfstats.h\"\n\n#include \"quick_set.h\"\n\n#include \"word_align.h\"\n\n\n\nusing namespace Portage;\n\n\n\n// is intersection between two sets of integers non-empty?\n\n\n\nstatic bool intersectionNotNull(QuickSet& qs, vector<Uint>& vs)\n\n{\n\n for (Uint i = 0; i < vs.size(); ++i)\n\n if (qs.find(vs[i]) != qs.size())\n\n return true;\n\n return false;\n\n}\n\n\n\nvoid WordAligner::close(vector< vector<Uint> >& sets1, vector< vector<Uint> >& csets)\n\n{\n\n csets.clear();\n\n\n", "file_path": "src/word_align/word_align.cc", "rank": 99, "score": 51.02688376856353 } ]
C++
cpp/test/main.cc
yjhatfdu/zstd-codec
f3f52dd801df1ece0d6cdbc9445dcb2a00973e37
#include <algorithm> #include <cstdio> #include <fstream> #include <functional> #include <iterator> #include <iostream> #include <string> #include "zstd-codec.h" #include "zstd-dict.h" #include "zstd-stream.h" #define CATCH_CONFIG_MAIN #include "catch.hpp" class FileResource : public Resource<FILE> { public: FileResource(const std::string& path, const char* mode) : FileResource(path.c_str(), mode) { } FileResource(const char* path, const char* mode) : Resource(fopen(path, mode), fclose) { } }; static std::string fixturePath(const char* name) { static const std::string kFixturePath("test/fixtures"); return kFixturePath + "/" + name; } static std::string tempPath(const char* name) { static const std::string kTempPath("test/tmp"); return kTempPath + "/" + name; } static Vec<u8> loadFixture(const char* name) { const auto path = fixturePath(name); std::ifstream stream(path.c_str(), std::ios::in | std::ios::binary); return Vec<u8>((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>()); } TEST_CASE("Zstd-Dictionary-Interfaces", "[zstd][compress][decompress][dictionary]") { const auto dict_bytes = loadFixture("sample-dict"); const auto sample_books = loadFixture("sample-books.json"); const auto compression_level = 5; ZstdCompressionDict cdict(dict_bytes, compression_level); ZstdDecompressionDict ddict(dict_bytes); ZstdCodec codec; Vec<u8> compressed_bytes(codec.CompressBound(sample_books.size())); auto rc = codec.CompressUsingDict(compressed_bytes, sample_books, cdict); REQUIRE(rc >= 0); REQUIRE(rc < sample_books.size()); compressed_bytes.resize(rc); REQUIRE(codec.ContentSize(compressed_bytes) == sample_books.size()); Vec<u8> decompressed_bytes(sample_books.size() * 2); rc = codec.DecompressUsingDict(decompressed_bytes, compressed_bytes, ddict); REQUIRE(rc >= 0); REQUIRE(rc == sample_books.size()); decompressed_bytes.resize(rc); REQUIRE(decompressed_bytes == sample_books); rc = codec.Decompress(decompressed_bytes, compressed_bytes); REQUIRE(rc < 0); } TEST_CASE("Stream using dictionary", "[zstd][compress][decompress][dictionary][stream]") { const auto dict_bytes = loadFixture("sample-dict"); const auto sample_books = loadFixture("sample-books.json"); const auto compression_level = 5; ZstdCompressionDict cdict(dict_bytes, compression_level); ZstdDecompressionDict ddict(dict_bytes); Vec<u8> compressed_bytes; compressed_bytes.reserve(1 * 1024 * 1024); const auto append_bytes = [](Vec<u8>& dest, const Vec<u8>& src) { std::copy(std::begin(src), std::end(src), std::back_inserter(dest)); }; const StreamCallback cstream_callback = [&append_bytes, &compressed_bytes](const Vec<u8>& compressed) { append_bytes(compressed_bytes, compressed); }; ZstdCompressStream cstream; REQUIRE(cstream.Begin(cdict)); REQUIRE(cstream.Transform(sample_books, cstream_callback)); REQUIRE(cstream.End(cstream_callback)); REQUIRE(compressed_bytes.size() < sample_books.size()); Vec<u8> content_bytes; content_bytes.reserve(1 * 1024 * 1024); const StreamCallback dstream_callback = [&append_bytes, &content_bytes](const Vec<u8>& decompressed) { append_bytes(content_bytes, decompressed); }; ZstdDecompressStream dstream; REQUIRE(dstream.Begin(ddict)); REQUIRE(dstream.Transform(compressed_bytes, dstream_callback)); REQUIRE(dstream.End(dstream_callback)); REQUIRE(compressed_bytes.size() < content_bytes.size()); REQUIRE(content_bytes == sample_books); } TEST_CASE("ZstdCompressStream", "[zstd][compress][stream]") { const auto block_size = 1024; size_t read_size; Vec<u8> read_buff(block_size); Vec<u8> content_bytes; content_bytes.reserve(1 * 1024 * 1024); Vec<u8> result_bytes; result_bytes.reserve(1 * 1024 * 1024); const StreamCallback callback = [&result_bytes](const Vec<u8>& compressed) { std::copy(std::begin(compressed), std::end(compressed), std::back_inserter(result_bytes)); }; ZstdCompressStream stream; REQUIRE(stream.Begin(3)); FileResource bmp_file(fixturePath("dance_yorokobi_mai_man.bmp"), "rb"); while ((read_size = fread(&read_buff[0], 1, read_buff.size(), bmp_file.get()))) { read_buff.resize(read_size); REQUIRE(stream.Transform(read_buff, callback)); std::copy(std::begin(read_buff), std::end(read_buff), std::back_inserter(content_bytes)); read_buff.resize(read_buff.capacity()); } REQUIRE(stream.End(callback)); REQUIRE(result_bytes.size() < content_bytes.size()); bmp_file.Close(); ZstdCodec codec; Vec<u8> decompressed_bytes(content_bytes.size()); REQUIRE(codec.Decompress(decompressed_bytes, result_bytes) == content_bytes.size()); REQUIRE(decompressed_bytes == content_bytes); FileResource result_file(tempPath("dance_yorokobi_mai_man.bmp.zst"), "wb"); fwrite(&result_bytes[0], result_bytes.size(), 1, result_file.get()); result_file.Close(); } TEST_CASE("ZstdDecompressStream", "[zstd][decompress][stream]") { const auto block_size = 1024; size_t read_size; Vec<u8> read_buff(block_size); Vec<u8> compressed_bytes; compressed_bytes.reserve(1 * 1024 * 1024); Vec<u8> result_bytes; result_bytes.reserve(1 * 1024 * 1024); const StreamCallback callback = [&result_bytes](const Vec<u8>& decompressed) { std::copy(std::begin(decompressed), std::end(decompressed), std::back_inserter(result_bytes)); }; ZstdDecompressStream stream; REQUIRE(stream.Begin()); FileResource zst_file(fixturePath("dance_yorokobi_mai_woman.bmp.zst"), "rb"); while ((read_size = fread(&read_buff[0], 1, read_buff.size(), zst_file.get()))) { read_buff.resize(read_size); REQUIRE(stream.Transform(read_buff, callback)); std::copy(std::begin(read_buff), std::end(read_buff), std::back_inserter(compressed_bytes)); read_buff.resize(read_buff.capacity()); } REQUIRE(stream.End(callback)); REQUIRE(result_bytes.size() > compressed_bytes.size()); zst_file.Close(); ZstdCodec codec; const auto content_size = codec.ContentSize(compressed_bytes); REQUIRE(result_bytes.size() == content_size); Vec<u8> content_bytes(content_size); REQUIRE(codec.Decompress(content_bytes, compressed_bytes) == content_size); REQUIRE(content_bytes == result_bytes); FileResource result_file(tempPath("dance_yorokobi_mai_woman.bmp"), "wb"); fwrite(&result_bytes[0], result_bytes.size(), 1, result_file.get()); result_file.Close(); }
#include <algorithm> #include <cstdio> #include <fstream> #include <functional> #include <iterator> #include <iostream> #include <string> #include "zstd-codec.h" #include "zstd-dict.h" #include "zstd-stream.h" #define CATCH_CONFIG_MAIN #include "catch.hpp" class FileResource : public Resource<FILE> { public: FileResource(const std::string& path, const char* mode) : FileResource(path.c_str(), mode) { } FileResource(const char* path, const char* mode) : Resource(fopen(path, mode), fclose) { } }; static std::string fixturePath(const char* name) { static const std::string kFixturePath("test/fixtures"); return kFixturePath + "/" + name; } static std::string tempPath(const char* name) { static const std::string kTempPath("test/tmp"); return kTempPath + "/" + name; } static Vec<u8> loadFixture(const char* name) {
TEST_CASE("Zstd-Dictionary-Interfaces", "[zstd][compress][decompress][dictionary]") { const auto dict_bytes = loadFixture("sample-dict"); const auto sample_books = loadFixture("sample-books.json"); const auto compression_level = 5; ZstdCompressionDict cdict(dict_bytes, compression_level); ZstdDecompressionDict ddict(dict_bytes); ZstdCodec codec; Vec<u8> compressed_bytes(codec.CompressBound(sample_books.size())); auto rc = codec.CompressUsingDict(compressed_bytes, sample_books, cdict); REQUIRE(rc >= 0); REQUIRE(rc < sample_books.size()); compressed_bytes.resize(rc); REQUIRE(codec.ContentSize(compressed_bytes) == sample_books.size()); Vec<u8> decompressed_bytes(sample_books.size() * 2); rc = codec.DecompressUsingDict(decompressed_bytes, compressed_bytes, ddict); REQUIRE(rc >= 0); REQUIRE(rc == sample_books.size()); decompressed_bytes.resize(rc); REQUIRE(decompressed_bytes == sample_books); rc = codec.Decompress(decompressed_bytes, compressed_bytes); REQUIRE(rc < 0); } TEST_CASE("Stream using dictionary", "[zstd][compress][decompress][dictionary][stream]") { const auto dict_bytes = loadFixture("sample-dict"); const auto sample_books = loadFixture("sample-books.json"); const auto compression_level = 5; ZstdCompressionDict cdict(dict_bytes, compression_level); ZstdDecompressionDict ddict(dict_bytes); Vec<u8> compressed_bytes; compressed_bytes.reserve(1 * 1024 * 1024); const auto append_bytes = [](Vec<u8>& dest, const Vec<u8>& src) { std::copy(std::begin(src), std::end(src), std::back_inserter(dest)); }; const StreamCallback cstream_callback = [&append_bytes, &compressed_bytes](const Vec<u8>& compressed) { append_bytes(compressed_bytes, compressed); }; ZstdCompressStream cstream; REQUIRE(cstream.Begin(cdict)); REQUIRE(cstream.Transform(sample_books, cstream_callback)); REQUIRE(cstream.End(cstream_callback)); REQUIRE(compressed_bytes.size() < sample_books.size()); Vec<u8> content_bytes; content_bytes.reserve(1 * 1024 * 1024); const StreamCallback dstream_callback = [&append_bytes, &content_bytes](const Vec<u8>& decompressed) { append_bytes(content_bytes, decompressed); }; ZstdDecompressStream dstream; REQUIRE(dstream.Begin(ddict)); REQUIRE(dstream.Transform(compressed_bytes, dstream_callback)); REQUIRE(dstream.End(dstream_callback)); REQUIRE(compressed_bytes.size() < content_bytes.size()); REQUIRE(content_bytes == sample_books); } TEST_CASE("ZstdCompressStream", "[zstd][compress][stream]") { const auto block_size = 1024; size_t read_size; Vec<u8> read_buff(block_size); Vec<u8> content_bytes; content_bytes.reserve(1 * 1024 * 1024); Vec<u8> result_bytes; result_bytes.reserve(1 * 1024 * 1024); const StreamCallback callback = [&result_bytes](const Vec<u8>& compressed) { std::copy(std::begin(compressed), std::end(compressed), std::back_inserter(result_bytes)); }; ZstdCompressStream stream; REQUIRE(stream.Begin(3)); FileResource bmp_file(fixturePath("dance_yorokobi_mai_man.bmp"), "rb"); while ((read_size = fread(&read_buff[0], 1, read_buff.size(), bmp_file.get()))) { read_buff.resize(read_size); REQUIRE(stream.Transform(read_buff, callback)); std::copy(std::begin(read_buff), std::end(read_buff), std::back_inserter(content_bytes)); read_buff.resize(read_buff.capacity()); } REQUIRE(stream.End(callback)); REQUIRE(result_bytes.size() < content_bytes.size()); bmp_file.Close(); ZstdCodec codec; Vec<u8> decompressed_bytes(content_bytes.size()); REQUIRE(codec.Decompress(decompressed_bytes, result_bytes) == content_bytes.size()); REQUIRE(decompressed_bytes == content_bytes); FileResource result_file(tempPath("dance_yorokobi_mai_man.bmp.zst"), "wb"); fwrite(&result_bytes[0], result_bytes.size(), 1, result_file.get()); result_file.Close(); } TEST_CASE("ZstdDecompressStream", "[zstd][decompress][stream]") { const auto block_size = 1024; size_t read_size; Vec<u8> read_buff(block_size); Vec<u8> compressed_bytes; compressed_bytes.reserve(1 * 1024 * 1024); Vec<u8> result_bytes; result_bytes.reserve(1 * 1024 * 1024); const StreamCallback callback = [&result_bytes](const Vec<u8>& decompressed) { std::copy(std::begin(decompressed), std::end(decompressed), std::back_inserter(result_bytes)); }; ZstdDecompressStream stream; REQUIRE(stream.Begin()); FileResource zst_file(fixturePath("dance_yorokobi_mai_woman.bmp.zst"), "rb"); while ((read_size = fread(&read_buff[0], 1, read_buff.size(), zst_file.get()))) { read_buff.resize(read_size); REQUIRE(stream.Transform(read_buff, callback)); std::copy(std::begin(read_buff), std::end(read_buff), std::back_inserter(compressed_bytes)); read_buff.resize(read_buff.capacity()); } REQUIRE(stream.End(callback)); REQUIRE(result_bytes.size() > compressed_bytes.size()); zst_file.Close(); ZstdCodec codec; const auto content_size = codec.ContentSize(compressed_bytes); REQUIRE(result_bytes.size() == content_size); Vec<u8> content_bytes(content_size); REQUIRE(codec.Decompress(content_bytes, compressed_bytes) == content_size); REQUIRE(content_bytes == result_bytes); FileResource result_file(tempPath("dance_yorokobi_mai_woman.bmp"), "wb"); fwrite(&result_bytes[0], result_bytes.size(), 1, result_file.get()); result_file.Close(); }
const auto path = fixturePath(name); std::ifstream stream(path.c_str(), std::ios::in | std::ios::binary); return Vec<u8>((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>()); }
function_block-function_prefix_line
[ { "content": " class NamePattern : public Pattern {\n\n public:\n\n NamePattern( std::string const& name );\n\n virtual ~NamePattern();\n\n virtual bool matches( TestCaseInfo const& testCase ) const override;\n\n private:\n\n WildcardPattern m_wildcardPattern;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 0, "score": 127744.1417159292 }, { "content": " class ExeName : public ComposableParserImpl<ExeName> {\n\n std::shared_ptr<std::string> m_name;\n\n std::shared_ptr<BoundRefBase> m_ref;\n\n\n\n template<typename LambdaT>\n\n static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundRefBase> {\n\n return std::make_shared<BoundLambda<LambdaT>>( lambda) ;\n\n }\n\n\n\n public:\n\n ExeName() : m_name( std::make_shared<std::string>( \"<executable>\" ) ) {}\n\n\n\n explicit ExeName( std::string &ref ) : ExeName() {\n\n m_ref = std::make_shared<BoundRef<std::string>>( ref );\n\n }\n\n\n\n template<typename LambdaT>\n\n explicit ExeName( LambdaT const& lambda ) : ExeName() {\n\n m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 1, "score": 120774.40118966685 }, { "content": " class TestInvokerAsFunction : public ITestInvoker {\n\n void(*m_testAsFunction)();\n\n public:\n\n TestInvokerAsFunction( void(*testAsFunction)() ) noexcept;\n\n\n\n void invoke() const override;\n\n };\n\n\n\n std::string extractClassName( std::string const& classOrQualifiedMethodName );\n\n\n\n ///////////////////////////////////////////////////////////////////////////\n\n\n\n} // end namespace Catch\n\n\n\n// end catch_test_case_registry_impl.h\n\n// start catch_reporter_registry.h\n\n\n\n#include <map>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 2, "score": 120136.52365472523 }, { "content": " class RunContext : public IResultCapture, public IRunner {\n\n\n\n public:\n\n RunContext( RunContext const& ) = delete;\n\n RunContext& operator =( RunContext const& ) = delete;\n\n\n\n explicit RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter);\n\n\n\n virtual ~RunContext();\n\n\n\n void testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount);\n\n void testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount);\n\n\n\n Totals runTest(TestCase const& testCase);\n\n\n\n IConfigPtr config() const;\n\n IStreamingReporter& reporter() const;\n\n\n\n private: // IResultCapture\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 3, "score": 103031.25076320826 }, { "content": " class Config : public IConfig {\n\n public:\n\n\n\n Config() = default;\n\n Config( ConfigData const& data );\n\n virtual ~Config() = default;\n\n\n\n std::string const& getFilename() const;\n\n\n\n bool listTests() const;\n\n bool listTestNamesOnly() const;\n\n bool listTags() const;\n\n bool listReporters() const;\n\n\n\n std::string getProcessName() const;\n\n\n\n std::vector<std::string> const& getReporterNames() const;\n\n std::vector<std::string> const& getSectionsToRun() const override;\n\n\n\n virtual TestSpec const& testSpec() const override;\n", "file_path": "cpp/test/catch.hpp", "rank": 4, "score": 100998.02676742001 }, { "content": " class Spacer : public Column {\n\n\n\n public:\n\n explicit Spacer( size_t spaceWidth ) : Column( \"\" ) {\n\n width( spaceWidth );\n\n }\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 5, "score": 100998.02676742001 }, { "content": " class RegistryHub : public IRegistryHub, public IMutableRegistryHub,\n\n private NonCopyable {\n\n\n\n public: // IRegistryHub\n\n RegistryHub() = default;\n\n IReporterRegistry const& getReporterRegistry() const override {\n\n return m_reporterRegistry;\n\n }\n\n ITestCaseRegistry const& getTestCaseRegistry() const override {\n\n return m_testCaseRegistry;\n\n }\n\n IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() override {\n\n return m_exceptionTranslatorRegistry;\n\n }\n\n ITagAliasRegistry const& getTagAliasRegistry() const override {\n\n return m_tagAliasRegistry;\n\n }\n\n StartupExceptionRegistry const& getStartupExceptionRegistry() const override {\n\n return m_exceptionRegistry;\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 6, "score": 98987.82188724432 }, { "content": " class TagPattern : public Pattern {\n\n public:\n\n TagPattern( std::string const& tag );\n\n virtual ~TagPattern();\n\n virtual bool matches( TestCaseInfo const& testCase ) const override;\n\n private:\n\n std::string m_tag;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 7, "score": 98092.66344691449 }, { "content": " class DebugOutStream : public IStream {\n\n std::unique_ptr<StreamBufBase> m_streamBuf;\n\n mutable std::ostream m_os;\n\n public:\n\n DebugOutStream();\n\n ~DebugOutStream() override = default;\n\n\n\n public: // IStream\n\n std::ostream& stream() const override;\n\n };\n\n}\n\n\n\n// end catch_stream.h\n\n\n\n#include <memory>\n\n#include <vector>\n\n#include <string>\n\n\n\n#ifndef CATCH_CONFIG_CONSOLE_WIDTH\n\n#define CATCH_CONFIG_CONSOLE_WIDTH 80\n", "file_path": "cpp/test/catch.hpp", "rank": 8, "score": 98092.66344691449 }, { "content": " class TrackerBase : public ITracker {\n\n protected:\n\n enum CycleState {\n\n NotStarted,\n\n Executing,\n\n ExecutingChildren,\n\n NeedsAnotherRun,\n\n CompletedSuccessfully,\n\n Failed\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 9, "score": 98092.66344691449 }, { "content": " class FileStream : public IStream {\n\n mutable std::ofstream m_ofs;\n\n public:\n\n FileStream( std::string const& filename );\n\n ~FileStream() override = default;\n\n public: // IStream\n\n std::ostream& stream() const override;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 10, "score": 98092.66344691449 }, { "content": " class ExcludedPattern : public Pattern {\n\n public:\n\n ExcludedPattern( PatternPtr const& underlyingPattern );\n\n virtual ~ExcludedPattern();\n\n virtual bool matches( TestCaseInfo const& testCase ) const override;\n\n private:\n\n PatternPtr m_underlyingPattern;\n\n };\n\n\n\n struct Filter {\n\n std::vector<PatternPtr> m_patterns;\n\n\n\n bool matches( TestCaseInfo const& testCase ) const;\n\n };\n\n\n\n public:\n\n bool hasFilters() const;\n\n bool matches( TestCaseInfo const& testCase ) const;\n\n\n\n private:\n", "file_path": "cpp/test/catch.hpp", "rank": 11, "score": 98092.66344691449 }, { "content": " class CoutStream : public IStream {\n\n mutable std::ostream m_os;\n\n public:\n\n CoutStream();\n\n ~CoutStream() override = default;\n\n\n\n public: // IStream\n\n std::ostream& stream() const override;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 12, "score": 98092.66344691449 }, { "content": " class ReporterRegistry : public IReporterRegistry {\n\n\n\n public:\n\n\n\n ~ReporterRegistry() override;\n\n\n\n IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override;\n\n\n\n void registerReporter( std::string const& name, IReporterFactoryPtr const& factory );\n\n void registerListener( IReporterFactoryPtr const& factory );\n\n\n\n FactoryMap const& getFactories() const override;\n\n Listeners const& getListeners() const override;\n\n\n\n private:\n\n FactoryMap m_factories;\n\n Listeners m_listeners;\n\n };\n\n}\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 13, "score": 95450.09205844105 }, { "content": " class MultipleReporters : public IStreamingReporter {\n\n using Reporters = std::vector<IStreamingReporterPtr>;\n\n Reporters m_reporters;\n\n\n\n public:\n\n void add( IStreamingReporterPtr&& reporter );\n\n\n\n public: // IStreamingReporter\n\n\n\n ReporterPreferences getPreferences() const override;\n\n\n\n void noMatchingTestCases( std::string const& spec ) override;\n\n\n\n static std::set<Verbosity> getSupportedVerbosities();\n\n\n\n void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override;\n\n void benchmarkEnded( BenchmarkStats const& benchmarkStats ) override;\n\n\n\n void testRunStarting( TestRunInfo const& testRunInfo ) override;\n\n void testGroupStarting( GroupInfo const& groupInfo ) override;\n", "file_path": "cpp/test/catch.hpp", "rank": 14, "score": 95450.09205844105 }, { "content": " class SectionTracker : public TrackerBase {\n\n std::vector<std::string> m_filters;\n\n public:\n\n SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );\n\n\n\n bool isSectionTracker() const override;\n\n\n\n static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation );\n\n\n\n void tryOpen();\n\n\n\n void addInitialFilters( std::vector<std::string> const& filters );\n\n void addNextFilters( std::vector<std::string> const& filters );\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 15, "score": 95450.09205844105 }, { "content": " class ReporterFactory : public IReporterFactory {\n\n\n\n virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {\n\n return std::unique_ptr<T>( new T( config ) );\n\n }\n\n\n\n virtual std::string getDescription() const override {\n\n return T::getDescription();\n\n }\n\n };\n\n\n\n public:\n\n\n\n ReporterRegistrar( std::string const& name ) {\n\n getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );\n\n }\n\n };\n\n\n\n template<typename T>\n", "file_path": "cpp/test/catch.hpp", "rank": 16, "score": 95450.09205844105 }, { "content": " class UnaryExpr : public ITransientExpression {\n\n LhsT m_lhs;\n\n\n\n auto isBinaryExpression() const -> bool override { return false; }\n\n auto getResult() const -> bool override { return m_lhs ? true : false; }\n\n\n\n void streamReconstructedExpression( std::ostream &os ) const override {\n\n os << Catch::Detail::stringify( m_lhs );\n\n }\n\n\n\n public:\n\n UnaryExpr( LhsT lhs ) : m_lhs( lhs ) {}\n\n };\n\n\n\n // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)\n\n template<typename LhsT, typename RhsT>\n\n auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return lhs == rhs; };\n\n template<typename T>\n\n auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }\n\n template<typename T>\n", "file_path": "cpp/test/catch.hpp", "rank": 17, "score": 95450.09205844105 }, { "content": " class BinaryExpr : public ITransientExpression {\n\n bool m_result;\n\n LhsT m_lhs;\n\n StringRef m_op;\n\n RhsT m_rhs;\n\n\n\n auto isBinaryExpression() const -> bool override { return true; }\n\n auto getResult() const -> bool override { return m_result; }\n\n\n\n void streamReconstructedExpression( std::ostream &os ) const override {\n\n formatReconstructedExpression\n\n ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) );\n\n }\n\n\n\n public:\n\n BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs )\n\n : m_result( comparisonResult ),\n\n m_lhs( lhs ),\n\n m_op( op ),\n\n m_rhs( rhs )\n\n {}\n\n };\n\n\n\n template<typename LhsT>\n", "file_path": "cpp/test/catch.hpp", "rank": 18, "score": 95450.09205844105 }, { "content": " class OcMethod : public ITestInvoker {\n\n\n\n public:\n\n OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {}\n\n\n\n virtual void invoke() const {\n\n id obj = [[m_cls alloc] init];\n\n\n\n performOptionalSelector( obj, @selector(setUp) );\n\n performOptionalSelector( obj, m_sel );\n\n performOptionalSelector( obj, @selector(tearDown) );\n\n\n\n arcSafeRelease( obj );\n\n }\n\n private:\n\n virtual ~OcMethod() {}\n\n\n\n Class m_cls;\n\n SEL m_sel;\n\n };\n", "file_path": "cpp/test/catch.hpp", "rank": 19, "score": 95450.09205844105 }, { "content": " class MatchExpr : public ITransientExpression {\n\n ArgT const& m_arg;\n\n MatcherT m_matcher;\n\n StringRef m_matcherString;\n\n bool m_result;\n\n public:\n\n MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString )\n\n : m_arg( arg ),\n\n m_matcher( matcher ),\n\n m_matcherString( matcherString ),\n\n m_result( matcher.match( arg ) )\n\n {}\n\n\n\n auto isBinaryExpression() const -> bool override { return true; }\n\n auto getResult() const -> bool override { return m_result; }\n\n\n\n void streamReconstructedExpression( std::ostream &os ) const override {\n\n auto matcherAsString = m_matcher.toString();\n\n os << Catch::Detail::stringify( m_arg ) << ' ';\n\n if( matcherAsString == Detail::unprintableString )\n", "file_path": "cpp/test/catch.hpp", "rank": 20, "score": 95450.09205844105 }, { "content": " class ListenerFactory : public IReporterFactory {\n\n\n\n virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {\n\n return std::unique_ptr<T>( new T( config ) );\n\n }\n\n virtual std::string getDescription() const override {\n\n return std::string();\n\n }\n\n };\n\n\n\n public:\n\n\n\n ListenerRegistrar() {\n\n getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() );\n\n }\n\n };\n\n}\n\n\n\n#if !defined(CATCH_CONFIG_DISABLE)\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 21, "score": 95450.09205844105 }, { "content": " class ExceptionTranslator : public IExceptionTranslator {\n\n public:\n\n\n\n ExceptionTranslator( std::string(*translateFunction)( T& ) )\n\n : m_translateFunction( translateFunction )\n\n {}\n\n\n\n std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override {\n\n try {\n\n if( it == itEnd )\n\n std::rethrow_exception(std::current_exception());\n\n else\n\n return (*it)->translate( it+1, itEnd );\n\n }\n\n catch( T& ex ) {\n\n return m_translateFunction( ex );\n\n }\n\n }\n\n\n\n protected:\n", "file_path": "cpp/test/catch.hpp", "rank": 22, "score": 95450.09205844105 }, { "content": " class IndexTracker : public TrackerBase {\n\n int m_size;\n\n int m_index = -1;\n\n public:\n\n IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size );\n\n\n\n bool isIndexTracker() const override;\n\n void close() override;\n\n\n\n static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size );\n\n\n\n int index() const;\n\n\n\n void moveNext();\n\n };\n\n\n\n} // namespace TestCaseTracking\n\n\n\nusing TestCaseTracking::ITracker;\n\nusing TestCaseTracking::TrackerContext;\n", "file_path": "cpp/test/catch.hpp", "rank": 23, "score": 95450.09205844105 }, { "content": "function zstd_lib_name()\n\n if os.istarget(\"macosx\") then\n\n return 'libzstd.dylib'\n\n else\n\n return 'libzstd.so'\n\n end\n\nend\n\n\n\n\n\nworkspace \"zstd-codec\"\n\n configurations {\"Debug\", \"Release\"}\n\n\n\n filter \"configurations:Debug\"\n\n defines { \"DEBUG\" }\n\n symbols \"On\"\n\n\n\n filter \"configurations:Release\"\n\n defines { \"NDEBUG\" }\n\n optimize \"Full\"\n\n\n", "file_path": "cpp/premake5.lua", "rank": 24, "score": 93994.2347912363 }, { "content": " class iterator {\n\n friend Columns;\n\n struct EndTag {};\n\n\n\n std::vector<Column> const& m_columns;\n\n std::vector<Column::iterator> m_iterators;\n\n size_t m_activeIterators;\n\n\n\n iterator( Columns const& columns, EndTag )\n\n : m_columns( columns.m_columns ),\n\n m_activeIterators( 0 )\n\n {\n\n m_iterators.reserve( m_columns.size() );\n\n\n\n for( auto const& col : m_columns )\n\n m_iterators.push_back( col.end() );\n\n }\n\n\n\n public:\n\n explicit iterator( Columns const& columns )\n", "file_path": "cpp/test/catch.hpp", "rank": 25, "score": 93735.81380598604 }, { "content": "class TestInvokerAsMethod : public ITestInvoker {\n\n void (C::*m_testAsMethod)();\n\npublic:\n\n TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {}\n\n\n\n void invoke() const override {\n\n C obj;\n\n (obj.*m_testAsMethod)();\n\n }\n\n};\n\n\n\nauto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*;\n\n\n\ntemplate<typename C>\n\nauto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* {\n\n return new(std::nothrow) TestInvokerAsMethod<C>( testAsMethod );\n\n}\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 26, "score": 93036.20077767051 }, { "content": " class ComposableParserImpl : public ParserBase {\n\n public:\n\n template<typename T>\n\n auto operator|( T const &other ) const -> Parser;\n\n };\n\n\n\n // Common code and state for Args and Opts\n\n template<typename DerivedT>\n", "file_path": "cpp/test/catch.hpp", "rank": 27, "score": 93036.20077767051 }, { "content": " class TestCase : public TestCaseInfo {\n\n public:\n\n\n\n TestCase( ITestInvoker* testCase, TestCaseInfo const& info );\n\n\n\n TestCase withName( std::string const& _newName ) const;\n\n\n\n void invoke() const;\n\n\n\n TestCaseInfo const& getTestCaseInfo() const;\n\n\n\n bool operator == ( TestCase const& other ) const;\n\n bool operator < ( TestCase const& other ) const;\n\n\n\n private:\n\n std::shared_ptr<ITestInvoker> test;\n\n };\n\n\n\n TestCase makeTestCase( ITestInvoker* testCase,\n\n std::string const& className,\n", "file_path": "cpp/test/catch.hpp", "rank": 28, "score": 93036.20077767051 }, { "content": " class Win32ColourImpl : public IColourImpl {\n\n public:\n\n Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )\n\n {\n\n CONSOLE_SCREEN_BUFFER_INFO csbiInfo;\n\n GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo );\n\n originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY );\n\n originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );\n\n }\n\n\n\n virtual void use( Colour::Code _colourCode ) override {\n\n switch( _colourCode ) {\n\n case Colour::None: return setTextAttribute( originalForegroundAttributes );\n\n case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );\n\n case Colour::Red: return setTextAttribute( FOREGROUND_RED );\n\n case Colour::Green: return setTextAttribute( FOREGROUND_GREEN );\n\n case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE );\n\n case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN );\n\n case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN );\n\n case Colour::Grey: return setTextAttribute( 0 );\n", "file_path": "cpp/test/catch.hpp", "rank": 29, "score": 93036.20077767051 }, { "content": " // use POSIX/ ANSI console terminal codes\n\n // Thanks to Adam Strzelecki for original contribution\n\n // (http://github.com/nanoant)\n\n // https://github.com/philsquared/Catch/pull/131\n\n class PosixColourImpl : public IColourImpl {\n\n public:\n\n virtual void use( Colour::Code _colourCode ) override {\n\n switch( _colourCode ) {\n\n case Colour::None:\n\n case Colour::White: return setColour( \"[0m\" );\n\n case Colour::Red: return setColour( \"[0;31m\" );\n\n case Colour::Green: return setColour( \"[0;32m\" );\n\n case Colour::Blue: return setColour( \"[0;34m\" );\n\n case Colour::Cyan: return setColour( \"[0;36m\" );\n\n case Colour::Yellow: return setColour( \"[0;33m\" );\n\n case Colour::Grey: return setColour( \"[1;30m\" );\n\n\n\n case Colour::LightGrey: return setColour( \"[0;37m\" );\n\n case Colour::BrightRed: return setColour( \"[1;31m\" );\n\n case Colour::BrightGreen: return setColour( \"[1;32m\" );\n\n case Colour::BrightWhite: return setColour( \"[1;37m\" );\n\n\n\n case Colour::Bright: CATCH_INTERNAL_ERROR( \"not a colour\" );\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 30, "score": 93036.20077767051 }, { "content": " class TestRegistry : public ITestCaseRegistry {\n\n public:\n\n virtual ~TestRegistry() = default;\n\n\n\n virtual void registerTest( TestCase const& testCase );\n\n\n\n std::vector<TestCase> const& getAllTests() const override;\n\n std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const override;\n\n\n\n private:\n\n std::vector<TestCase> m_functions;\n\n mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;\n\n mutable std::vector<TestCase> m_sortedFunctions;\n\n std::size_t m_unnamedCount = 0;\n\n std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised\n\n };\n\n\n\n ///////////////////////////////////////////////////////////////////////////\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 31, "score": 93036.20077767051 }, { "content": " class ResultValueBase : public ResultBase {\n\n public:\n\n auto value() const -> T const & {\n\n enforceOk();\n\n return m_value;\n\n }\n\n\n\n protected:\n\n ResultValueBase( Type type ) : ResultBase( type ) {}\n\n\n\n ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) {\n\n if( m_type == ResultBase::Ok )\n\n new( &m_value ) T( other.m_value );\n\n }\n\n\n\n ResultValueBase( Type, T const &value ) : ResultBase( Ok ) {\n\n new( &m_value ) T( value );\n\n }\n\n\n\n auto operator=( ResultValueBase const &other ) -> ResultValueBase & {\n", "file_path": "cpp/test/catch.hpp", "rank": 32, "score": 93036.20077767051 }, { "content": " class TagAliasRegistry : public ITagAliasRegistry {\n\n public:\n\n ~TagAliasRegistry() override;\n\n TagAlias const* find( std::string const& alias ) const override;\n\n std::string expandAliases( std::string const& unexpandedTestSpec ) const override;\n\n void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo );\n\n\n\n private:\n\n std::map<std::string, TagAlias> m_registry;\n\n };\n\n\n\n} // end namespace Catch\n\n\n\n// end catch_tag_alias_registry.h\n\n// start catch_startup_exception_registry.h\n\n\n\n#include <vector>\n\n#include <exception>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 34, "score": 90822.5367909636 }, { "content": " class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {\n\n public:\n\n ~ExceptionTranslatorRegistry();\n\n virtual void registerTranslator( const IExceptionTranslator* translator );\n\n virtual std::string translateActiveException() const override;\n\n std::string tryTranslators() const;\n\n\n\n private:\n\n std::vector<std::unique_ptr<IExceptionTranslator const>> m_translators;\n\n };\n\n}\n\n\n\n// end catch_exception_translator_registry.h\n\n#ifdef __OBJC__\n\n#import \"Foundation/Foundation.h\"\n\n#endif\n\n\n\nnamespace Catch {\n\n\n\n ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() {\n", "file_path": "cpp/test/catch.hpp", "rank": 35, "score": 90822.5367909636 }, { "content": " class StreamBufImpl : public StreamBufBase {\n\n char data[bufferSize];\n\n WriterF m_writer;\n\n\n\n public:\n\n StreamBufImpl() {\n\n setp( data, data + sizeof(data) );\n\n }\n\n\n\n ~StreamBufImpl() noexcept {\n\n StreamBufImpl::sync();\n\n }\n\n\n\n private:\n\n int overflow( int c ) override {\n\n sync();\n\n\n\n if( c != EOF ) {\n\n if( pbase() == epptr() )\n\n m_writer( std::string( 1, static_cast<char>( c ) ) );\n", "file_path": "cpp/test/catch.hpp", "rank": 36, "score": 90822.5367909636 }, { "content": "#if USE_DEBUG_ERROR_HANDLER\n\nclass DebugErrorHandler : public IErrorHandler\n\n{\n\npublic:\n\n virtual void OnZstdError(size_t rc)\n\n {\n\n printf(\"## zstd error: %s\\n\", ZSTD_getErrorName(rc));\n\n }\n\n\n\n virtual void OnSizeError(size_t rc)\n\n {\n\n printf(\"## size error: %s\\n\", ZSTD_getErrorName(rc));\n\n }\n\n};\n\n\n\n\n\nstatic DebugErrorHandler s_debug_handler;\n\n\n\n#endif // USE_DEBUG_ERROR_HANDLER\n\n\n\n\n", "file_path": "cpp/src/zstd-codec.cc", "rank": 37, "score": 90822.5367909636 }, { "content": " class TrackerHasName {\n\n NameAndLocation m_nameAndLocation;\n\n public:\n\n TrackerHasName( NameAndLocation const& nameAndLocation );\n\n bool operator ()( ITrackerPtr const& tracker ) const;\n\n };\n\n\n\n using Children = std::vector<ITrackerPtr>;\n\n NameAndLocation m_nameAndLocation;\n\n TrackerContext& m_ctx;\n\n ITracker* m_parent;\n\n Children m_children;\n\n CycleState m_runState = NotStarted;\n\n\n\n public:\n\n TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );\n\n\n\n NameAndLocation const& nameAndLocation() const override;\n\n bool isComplete() const override;\n\n bool isSuccessfullyCompleted() const override;\n", "file_path": "cpp/test/catch.hpp", "rank": 38, "score": 90126.18239108662 }, { "content": " /// A non-owning string class (similar to the forthcoming std::string_view)\n\n /// Note that, because a StringRef may be a substring of another string,\n\n /// it may not be null terminated. c_str() must return a null terminated\n\n /// string, however, and so the StringRef will internally take ownership\n\n /// (taking a copy), if necessary. In theory this ownership is not externally\n\n /// visible - but it does mean (substring) StringRefs should not be shared between\n\n /// threads.\n\n class StringRef {\n\n friend struct StringRefTestAccess;\n\n\n\n using size_type = std::size_t;\n\n\n\n char const* m_start;\n\n size_type m_size;\n\n\n\n char* m_data = nullptr;\n\n\n\n void takeOwnership();\n\n\n\n public: // construction/ assignment\n\n StringRef() noexcept;\n\n StringRef( StringRef const& other ) noexcept;\n\n StringRef( StringRef&& other ) noexcept;\n\n StringRef( char const* rawChars ) noexcept;\n\n StringRef( char const* rawChars, size_type size ) noexcept;\n\n StringRef( std::string const& stdString ) noexcept;\n\n ~StringRef() noexcept;\n", "file_path": "cpp/test/catch.hpp", "rank": 39, "score": 90112.25852944826 }, { "content": " class StringData;\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 40, "score": 90102.44012459666 }, { "content": " class Context : public IMutableContext, NonCopyable {\n\n\n\n public: // IContext\n\n virtual IResultCapture* getResultCapture() override {\n\n return m_resultCapture;\n\n }\n\n virtual IRunner* getRunner() override {\n\n return m_runner;\n\n }\n\n\n\n virtual IConfigPtr getConfig() const override {\n\n return m_config;\n\n }\n\n\n\n virtual ~Context() override;\n\n\n\n public: // IMutableContext\n\n virtual void setResultCapture( IResultCapture* resultCapture ) override {\n\n m_resultCapture = resultCapture;\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 41, "score": 88660.46038344901 }, { "content": " class Arg : public ParserRefImpl<Arg> {\n\n public:\n\n using ParserRefImpl::ParserRefImpl;\n\n\n\n auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override {\n\n auto validationResult = validate();\n\n if( !validationResult )\n\n return InternalParseResult( validationResult );\n\n\n\n auto remainingTokens = tokens;\n\n auto const &token = *remainingTokens;\n\n if( token.type != TokenType::Argument )\n\n return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );\n\n\n\n auto result = m_ref->setValue( remainingTokens->token );\n\n if( !result )\n\n return InternalParseResult( result );\n\n else\n\n return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 42, "score": 88660.46038344901 }, { "content": " class StreamBufBase : public std::streambuf {\n\n public:\n\n virtual ~StreamBufBase();\n\n };\n\n}\n\n\n\n// end catch_streambuf.h\n\n#include <streambuf>\n\n#include <ostream>\n\n#include <fstream>\n\n#include <memory>\n\n\n\nnamespace Catch {\n\n\n\n std::ostream& cout();\n\n std::ostream& cerr();\n\n std::ostream& clog();\n\n\n\n struct IStream {\n\n virtual ~IStream();\n\n virtual std::ostream& stream() const = 0;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 43, "score": 88660.46038344901 }, { "content": " class Opt : public ParserRefImpl<Opt> {\n\n protected:\n\n std::vector<std::string> m_optNames;\n\n\n\n public:\n\n template<typename LambdaT>\n\n explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared<BoundFlagLambda<LambdaT>>( ref ) ) {}\n\n\n\n explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared<BoundFlagRef>( ref ) ) {}\n\n\n\n template<typename LambdaT>\n\n Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {}\n\n\n\n template<typename T>\n\n Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {}\n\n\n\n auto operator[]( std::string const &optName ) -> Opt & {\n\n m_optNames.push_back( optName );\n\n return *this;\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 44, "score": 88660.46038344901 }, { "content": " class ResultValueBase<void> : public ResultBase {\n\n protected:\n\n using ResultBase::ResultBase;\n\n };\n\n\n\n template<typename T = void>\n", "file_path": "cpp/test/catch.hpp", "rank": 45, "score": 86446.79639674211 }, { "content": " class BasicResult : public ResultValueBase<T> {\n\n public:\n\n template<typename U>\n\n explicit BasicResult( BasicResult<U> const &other )\n\n : ResultValueBase<T>( other.type() ),\n\n m_errorMessage( other.errorMessage() )\n\n {\n\n assert( type() != ResultBase::Ok );\n\n }\n\n\n\n template<typename U>\n\n static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; }\n\n static auto ok() -> BasicResult { return { ResultBase::Ok }; }\n\n static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; }\n\n static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; }\n\n\n\n explicit operator bool() const { return m_type == ResultBase::Ok; }\n\n auto type() const -> ResultBase::Type { return m_type; }\n\n auto errorMessage() const -> std::string { return m_errorMessage; }\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 46, "score": 86446.79639674211 }, { "content": "class CompressContext : public Resource<ZSTD_CCtx>\n\n{\n\npublic:\n\n CompressContext()\n\n : Resource(ZSTD_createCCtx(), CloseContext)\n\n {\n\n }\n\n\n\n bool fail() const\n\n {\n\n return get() == nullptr;\n\n }\n\n\n\nprivate:\n\n static void CloseContext(ZSTD_CCtx* cctx)\n\n {\n\n ZSTD_freeCCtx(cctx);\n\n }\n\n};\n\n\n\n\n", "file_path": "cpp/src/zstd-codec.cc", "rank": 47, "score": 84409.43912491974 }, { "content": "class ZstdDecompressionDict : public Resource<ZSTD_DDict_s>\n\n{\n\npublic:\n\n ZstdDecompressionDict(const Vec<u8>& dict_bytes);\n\n\n\n bool fail() const;\n\n};\n\n\n", "file_path": "cpp/src/zstd-dict.h", "rank": 48, "score": 84409.43912491974 }, { "content": "class ZstdCompressionDict : public Resource<ZSTD_CDict_s>\n\n{\n\npublic:\n\n ZstdCompressionDict(const Vec<u8>& dict_bytes, int compression_level);\n\n\n\n bool fail() const;\n\n};\n\n\n\n\n", "file_path": "cpp/src/zstd-dict.h", "rank": 49, "score": 84409.43912491974 }, { "content": " class XmlReporter : public StreamingReporterBase<XmlReporter> {\n\n public:\n\n XmlReporter( ReporterConfig const& _config )\n\n : StreamingReporterBase( _config ),\n\n m_xml(_config.stream())\n\n {\n\n m_reporterPrefs.shouldRedirectStdOut = true;\n\n }\n\n\n\n ~XmlReporter() override;\n\n\n\n static std::string getDescription() {\n\n return \"Reports test results as an XML document\";\n\n }\n\n\n\n virtual std::string getStylesheetRef() const {\n\n return std::string();\n\n }\n\n\n\n void writeSourceInfo( SourceLineInfo const& sourceInfo ) {\n", "file_path": "cpp/test/catch.hpp", "rank": 50, "score": 84409.43912491974 }, { "content": "class DecompressContext : public Resource<ZSTD_DCtx>\n\n{\n\npublic:\n\n DecompressContext()\n\n : Resource(ZSTD_createDCtx(), CloseContext)\n\n {\n\n }\n\n\n\n bool fail() const\n\n {\n\n return get() == nullptr;\n\n }\n\n\n\nprivate:\n\n static void CloseContext(ZSTD_DCtx* dctx)\n\n {\n\n ZSTD_freeDCtx(dctx);\n\n }\n\n};\n\n\n", "file_path": "cpp/src/zstd-codec.cc", "rank": 51, "score": 84409.43912491974 }, { "content": " class JunitReporter : public CumulativeReporterBase<JunitReporter> {\n\n public:\n\n JunitReporter( ReporterConfig const& _config )\n\n : CumulativeReporterBase( _config ),\n\n xml( _config.stream() )\n\n {\n\n m_reporterPrefs.shouldRedirectStdOut = true;\n\n }\n\n\n\n ~JunitReporter() override;\n\n\n\n static std::string getDescription() {\n\n return \"Reports test results in an XML format that looks like Ant's junitreport target\";\n\n }\n\n\n\n void noMatchingTestCases( std::string const& /*spec*/ ) override {}\n\n\n\n void testRunStarting( TestRunInfo const& runInfo ) override {\n\n CumulativeReporterBase::testRunStarting( runInfo );\n\n xml.startElement( \"testsuites\" );\n", "file_path": "cpp/test/catch.hpp", "rank": 52, "score": 84409.43912491974 }, { "content": " class ParserRefImpl : public ComposableParserImpl<DerivedT> {\n\n protected:\n\n Optionality m_optionality = Optionality::Optional;\n\n std::shared_ptr<BoundRefBase> m_ref;\n\n std::string m_hint;\n\n std::string m_description;\n\n\n\n explicit ParserRefImpl( std::shared_ptr<BoundRefBase> const &ref ) : m_ref( ref ) {}\n\n\n\n public:\n\n template<typename T>\n\n ParserRefImpl( T &ref, std::string const &hint )\n\n : m_ref( std::make_shared<BoundRef<T>>( ref ) ),\n\n m_hint( hint )\n\n {}\n\n\n\n template<typename LambdaT>\n\n ParserRefImpl( LambdaT const &ref, std::string const &hint )\n\n : m_ref( std::make_shared<BoundLambda<LambdaT>>( ref ) ),\n\n m_hint(hint)\n", "file_path": "cpp/test/catch.hpp", "rank": 53, "score": 82528.13236186348 }, { "content": "function zstd_lib_dir()\n\n return string.format(\"%s/lib\", zstd_root_dir())\n\nend\n\n\n\n\n", "file_path": "cpp/premake5.lua", "rank": 54, "score": 61239.7597374348 }, { "content": "function zstd_root_dir()\n\n if _OPTIONS[\"with-zstd-dir\"] then\n\n return _OPTIONS[\"with-zstd-dir\"]\n\n else\n\n return './zstd'\n\n end\n\nend\n\n\n\n\n", "file_path": "cpp/premake5.lua", "rank": 55, "score": 61239.7597374348 }, { "content": "const path = require('path');\n", "file_path": "js/lib/__tests__/zstd-codec.js", "rank": 56, "score": 60081.923175793054 }, { "content": "const path = require('path');\n", "file_path": "js/lib/__tests__/zstd-stream.js", "rank": 57, "score": 60081.923175793054 }, { "content": " class Columns {\n\n std::vector<Column> m_columns;\n\n\n\n public:\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 58, "score": 59141.059273092585 }, { "content": "class Resource\n\n{\n\npublic:\n\n using CloseHandler = std::function<void(T*)>;\n\n\n\n Resource(T* resource, CloseHandler close_handler)\n\n : resource_(resource)\n\n , close_handler_(close_handler)\n\n {\n\n }\n\n\n\n ~Resource()\n\n {\n\n Close();\n\n }\n\n\n\n T* get() const { return resource_; }\n\n\n\n void Close()\n\n {\n", "file_path": "cpp/src/raii-resource.h", "rank": 59, "score": 59141.059273092585 }, { "content": " // Transport for raw args (copied from main args, or supplied via init list for testing)\n\n class Args {\n\n friend TokenStream;\n\n std::string m_exeName;\n\n std::vector<std::string> m_args;\n\n\n\n public:\n\n Args( int argc, char *argv[] ) {\n\n m_exeName = argv[0];\n\n for( int i = 1; i < argc; ++i )\n\n m_args.push_back( argv[i] );\n\n }\n\n\n\n Args( std::initializer_list<std::string> args )\n\n : m_exeName( *args.begin() ),\n\n m_args( args.begin()+1, args.end() )\n\n {}\n\n\n\n auto exeName() const -> std::string {\n\n return m_exeName;\n\n }\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 60, "score": 59141.059273092585 }, { "content": " class Column {\n\n std::vector<std::string> m_strings;\n\n size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH;\n\n size_t m_indent = 0;\n\n size_t m_initialIndent = std::string::npos;\n\n\n\n public:\n", "file_path": "cpp/test/catch.hpp", "rank": 61, "score": 59141.059273092585 }, { "content": " class Option {\n\n public:\n\n Option() : nullableValue( nullptr ) {}\n\n Option( T const& _value )\n\n : nullableValue( new( storage ) T( _value ) )\n\n {}\n\n Option( Option const& _other )\n\n : nullableValue( _other ? new( storage ) T( *_other ) : nullptr )\n\n {}\n\n\n\n ~Option() {\n\n reset();\n\n }\n\n\n\n Option& operator= ( Option const& _other ) {\n\n if( &_other != this ) {\n\n reset();\n\n if( _other )\n\n nullableValue = new( storage ) T( *_other );\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 62, "score": 59141.059273092585 }, { "content": " class Columns;\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 63, "score": 59141.059273092585 }, { "content": " class Approx {\n\n private:\n\n bool equalityComparisonImpl(double other) const;\n\n\n\n public:\n\n explicit Approx ( double value );\n\n\n\n static Approx custom();\n\n\n\n template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n\n Approx operator()( T const& value ) {\n\n Approx approx( static_cast<double>(value) );\n\n approx.epsilon( m_epsilon );\n\n approx.margin( m_margin );\n\n approx.scale( m_scale );\n\n return approx;\n\n }\n\n\n\n template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n\n explicit Approx( T const& value ): Approx(static_cast<double>(value))\n", "file_path": "cpp/test/catch.hpp", "rank": 64, "score": 59141.059273092585 }, { "content": " class Duration {\n", "file_path": "cpp/test/catch.hpp", "rank": 65, "score": 59141.059273092585 }, { "content": " class Timer {\n\n uint64_t m_nanoseconds = 0;\n\n public:\n\n void start();\n\n auto getElapsedNanoseconds() const -> unsigned int;\n\n auto getElapsedMicroseconds() const -> unsigned int;\n\n auto getElapsedMilliseconds() const -> unsigned int;\n\n auto getElapsedSeconds() const -> double;\n\n };\n\n\n\n} // namespace Catch\n\n\n\n// end catch_timer.h\n\n#include <string>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 66, "score": 59141.059273092585 }, { "content": " // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled\n\n class TokenStream {\n\n using Iterator = std::vector<std::string>::const_iterator;\n\n Iterator it;\n\n Iterator itEnd;\n\n std::vector<Token> m_tokenBuffer;\n\n\n\n void loadBuffer() {\n\n m_tokenBuffer.resize( 0 );\n\n\n\n // Skip any empty strings\n\n while( it != itEnd && it->empty() )\n\n ++it;\n\n\n\n if( it != itEnd ) {\n\n auto const &next = *it;\n\n if( isOptPrefix( next[0] ) ) {\n\n auto delimiterPos = next.find_first_of( \" :=\" );\n\n if( delimiterPos != std::string::npos ) {\n\n m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } );\n\n m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } );\n", "file_path": "cpp/test/catch.hpp", "rank": 67, "score": 57375.82375168055 }, { "content": " class StreamRedirect {\n\n\n\n public:\n\n StreamRedirect(std::ostream& stream, std::string& targetString);\n\n\n\n ~StreamRedirect();\n\n\n\n private:\n\n std::ostream& m_stream;\n\n std::streambuf* m_prevBuf;\n\n std::ostringstream m_oss;\n\n std::string& m_targetString;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 68, "score": 57371.707337285115 }, { "content": " class IsStreamInsertable {\n\n template<typename SS, typename TT>\n\n static auto test(int)\n\n -> decltype(std::declval<SS&>() << std::declval<TT>(), std::true_type());\n\n\n\n template<typename, typename>\n\n static auto test(...)->std::false_type;\n\n\n\n public:\n\n static const bool value = decltype(test<std::ostream, const T&>(0))::value;\n\n };\n\n\n\n } // namespace Detail\n\n\n\n // If we decide for C++14, change these to enable_if_ts\n\n template <typename T>\n\n struct StringMaker {\n\n template <typename Fake = T>\n\n static\n\n typename std::enable_if<::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>::type\n", "file_path": "cpp/test/catch.hpp", "rank": 69, "score": 57371.707337285115 }, { "content": " class AssertionResult {\n\n public:\n\n AssertionResult() = delete;\n\n AssertionResult( AssertionInfo const& info, AssertionResultData const& data );\n\n\n\n bool isOk() const;\n\n bool succeeded() const;\n\n ResultWas::OfType getResultType() const;\n\n bool hasExpression() const;\n\n bool hasMessage() const;\n\n std::string getExpression() const;\n\n std::string getExpressionInMacro() const;\n\n bool hasExpandedExpression() const;\n\n std::string getExpandedExpression() const;\n\n std::string getMessage() const;\n\n SourceLineInfo getSourceInfo() const;\n\n std::string getTestMacroName() const;\n\n\n\n //protected:\n\n AssertionInfo m_info;\n", "file_path": "cpp/test/catch.hpp", "rank": 70, "score": 57371.707337285115 }, { "content": " class ScopedElement {\n\n public:\n\n ScopedElement( XmlWriter* writer );\n\n\n\n ScopedElement( ScopedElement&& other ) noexcept;\n\n ScopedElement& operator=( ScopedElement&& other ) noexcept;\n\n\n\n ~ScopedElement();\n\n\n\n ScopedElement& writeText( std::string const& text, bool indent = true );\n\n\n\n template<typename T>\n\n ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {\n\n m_writer->writeAttribute( name, attribute );\n\n return *this;\n\n }\n\n\n\n private:\n\n mutable XmlWriter* m_writer = nullptr;\n\n };\n", "file_path": "cpp/test/catch.hpp", "rank": 71, "score": 57371.707337285115 }, { "content": " class ErrnoGuard {\n\n public:\n\n ErrnoGuard();\n\n ~ErrnoGuard();\n\n private:\n\n int m_oldErrno;\n\n };\n\n\n\n}\n\n\n\n// end catch_errno_guard.h\n\n// start catch_windows_h_proxy.h\n\n\n\n\n\n#if defined(CATCH_PLATFORM_WINDOWS)\n\n\n\n#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX)\n\n# define CATCH_DEFINED_NOMINMAX\n\n# define NOMINMAX\n\n#endif\n", "file_path": "cpp/test/catch.hpp", "rank": 72, "score": 57371.707337285115 }, { "content": " class XmlWriter {\n\n public:\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 73, "score": 57371.707337285115 }, { "content": " class ParserBase {\n\n public:\n\n virtual ~ParserBase() = default;\n\n virtual auto validate() const -> Result { return Result::ok(); }\n\n virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0;\n\n virtual auto cardinality() const -> size_t { return 1; }\n\n\n\n auto parse( Args const &args ) const -> InternalParseResult {\n\n return parse( args.exeName(), TokenStream( args ) );\n\n }\n\n };\n\n\n\n template<typename DerivedT>\n", "file_path": "cpp/test/catch.hpp", "rank": 74, "score": 57371.707337285115 }, { "content": " class ExprLhs {\n\n LhsT m_lhs;\n\n public:\n\n ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}\n\n\n\n template<typename RhsT>\n\n auto operator == ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n\n return BinaryExpr<LhsT, RhsT const&>( compareEqual( m_lhs, rhs ), m_lhs, \"==\", rhs );\n\n }\n\n auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const {\n\n return BinaryExpr<LhsT, bool>( m_lhs == rhs, m_lhs, \"==\", rhs );\n\n }\n\n\n\n template<typename RhsT>\n\n auto operator != ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n\n return BinaryExpr<LhsT, RhsT const&>( compareNotEqual( m_lhs, rhs ), m_lhs, \"!=\", rhs );\n\n }\n\n auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const {\n\n return BinaryExpr<LhsT, bool>( m_lhs != rhs, m_lhs, \"!=\", rhs );\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 75, "score": 57371.707337285115 }, { "content": " class AssertionHandler {\n\n AssertionInfo m_assertionInfo;\n\n bool m_shouldDebugBreak = false;\n\n bool m_shouldThrow = false;\n\n bool m_inExceptionGuard = false;\n\n\n\n public:\n\n AssertionHandler\n\n ( StringRef macroName,\n\n SourceLineInfo const& lineInfo,\n\n StringRef capturedExpression,\n\n ResultDisposition::Flags resultDisposition );\n\n ~AssertionHandler();\n\n\n\n void handle( ITransientExpression const& expr );\n\n\n\n template<typename T>\n\n void handle( ExprLhs<T> const& expr ) {\n\n handle( expr.makeUnaryExpr() );\n\n }\n", "file_path": "cpp/test/catch.hpp", "rank": 76, "score": 57371.707337285115 }, { "content": " class TestCase;\n\n struct IConfig;\n\n\n\n std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases );\n\n bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );\n\n\n\n void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions );\n\n\n\n std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );\n\n std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 77, "score": 57371.707337285115 }, { "content": " class TrackerContext {\n\n\n\n enum RunState {\n\n NotStarted,\n\n Executing,\n\n CompletedCycle\n\n };\n\n\n\n ITrackerPtr m_rootTracker;\n\n ITracker* m_currentTracker = nullptr;\n\n RunState m_runState = NotStarted;\n\n\n\n public:\n\n\n\n static TrackerContext& instance();\n\n\n\n ITracker& startRun();\n\n void endRun();\n\n\n\n void startCycle();\n\n void completeCycle();\n\n\n\n bool completedCycle() const;\n\n ITracker& currentTracker();\n\n void setCurrentTracker( ITracker* tracker );\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 78, "score": 57371.707337285115 }, { "content": " class TestSpec;\n\n\n\n struct IConfig : NonCopyable {\n\n\n\n virtual ~IConfig();\n\n\n\n virtual bool allowThrows() const = 0;\n\n virtual std::ostream& stream() const = 0;\n\n virtual std::string name() const = 0;\n\n virtual bool includeSuccessfulResults() const = 0;\n\n virtual bool shouldDebugBreak() const = 0;\n\n virtual bool warnAboutMissingAssertions() const = 0;\n\n virtual int abortAfter() const = 0;\n\n virtual bool showInvisibles() const = 0;\n\n virtual ShowDurations::OrNot showDurations() const = 0;\n\n virtual TestSpec const& testSpec() const = 0;\n\n virtual RunTests::InWhatOrder runOrder() const = 0;\n\n virtual unsigned int rngSeed() const = 0;\n\n virtual int benchmarkResolutionMultiple() const = 0;\n\n virtual UseColour::YesOrNo useColour() const = 0;\n", "file_path": "cpp/test/catch.hpp", "rank": 79, "score": 57371.707337285115 }, { "content": " class TokenStream;\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 80, "score": 57371.707337285115 }, { "content": " class BenchmarkLooper {\n\n\n\n std::string m_name;\n\n std::size_t m_count = 0;\n\n std::size_t m_iterationsToRun = 1;\n\n uint64_t m_resolution;\n\n Timer m_timer;\n\n\n\n static auto getResolution() -> uint64_t;\n\n public:\n\n // Keep most of this inline as it's on the code path that is being timed\n\n BenchmarkLooper( StringRef name )\n\n : m_name( name ),\n\n m_resolution( getResolution() )\n\n {\n\n reportStart();\n\n m_timer.start();\n\n }\n\n\n\n explicit operator bool() {\n", "file_path": "cpp/test/catch.hpp", "rank": 81, "score": 57371.707337285115 }, { "content": " class AssertionPrinter {\n\n public:\n\n AssertionPrinter& operator= ( AssertionPrinter const& ) = delete;\n\n AssertionPrinter( AssertionPrinter const& ) = delete;\n\n AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )\n\n : stream( _stream ),\n\n stats( _stats ),\n\n result( _stats.assertionResult ),\n\n colour( Colour::None ),\n\n message( result.getMessage() ),\n\n messages( _stats.infoMessages ),\n\n printInfoMessages( _printInfoMessages )\n\n {\n\n switch( result.getResultType() ) {\n\n case ResultWas::Ok:\n\n colour = Colour::Success;\n\n passOrFail = \"PASSED\";\n\n //if( result.hasMessage() )\n\n if( _stats.infoMessages.size() == 1 )\n\n messageLabel = \"with message\";\n", "file_path": "cpp/test/catch.hpp", "rank": 82, "score": 57371.707337285115 }, { "content": " class TestSpec {\n\n struct Pattern {\n\n virtual ~Pattern();\n\n virtual bool matches( TestCaseInfo const& testCase ) const = 0;\n\n };\n\n using PatternPtr = std::shared_ptr<Pattern>;\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 83, "score": 57371.707337285115 }, { "content": " class AssertionResult;\n\n struct AssertionInfo;\n\n struct SectionInfo;\n\n struct SectionEndInfo;\n\n struct MessageInfo;\n\n struct Counts;\n\n struct BenchmarkInfo;\n\n struct BenchmarkStats;\n\n\n\n struct IResultCapture {\n\n\n\n virtual ~IResultCapture();\n\n\n\n virtual void assertionStarting( AssertionInfo const& info ) = 0;\n\n virtual void assertionEnded( AssertionResult const& result ) = 0;\n\n virtual bool sectionStarted( SectionInfo const& sectionInfo,\n\n Counts& assertions ) = 0;\n\n virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;\n\n virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 84, "score": 57371.707337285115 }, { "content": " class LazyExpression {\n\n friend class AssertionHandler;\n\n friend struct AssertionStats;\n\n\n\n ITransientExpression const* m_transientExpression = nullptr;\n\n bool m_isNegated;\n\n public:\n\n LazyExpression( bool isNegated );\n\n LazyExpression( LazyExpression const& other );\n\n LazyExpression& operator = ( LazyExpression const& ) = delete;\n\n\n\n explicit operator bool() const;\n\n\n\n friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 85, "score": 57371.707337285115 }, { "content": " class ParseState {\n\n public:\n\n\n\n ParseState( ParseResultType type, TokenStream const &remainingTokens )\n\n : m_type(type),\n\n m_remainingTokens( remainingTokens )\n\n {}\n\n\n\n auto type() const -> ParseResultType { return m_type; }\n\n auto remainingTokens() const -> TokenStream { return m_remainingTokens; }\n\n\n\n private:\n\n ParseResultType m_type;\n\n TokenStream m_remainingTokens;\n\n };\n\n\n\n using Result = BasicResult<void>;\n\n using ParserResult = BasicResult<ParseResultType>;\n\n using InternalParseResult = BasicResult<ParseState>;\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 86, "score": 57371.707337285115 }, { "content": " class ReporterRegistrar {\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 87, "score": 57371.707337285115 }, { "content": " class NonCopyable {\n\n NonCopyable( NonCopyable const& ) = delete;\n\n NonCopyable( NonCopyable && ) = delete;\n\n NonCopyable& operator = ( NonCopyable const& ) = delete;\n\n NonCopyable& operator = ( NonCopyable && ) = delete;\n\n\n\n protected:\n\n NonCopyable();\n\n virtual ~NonCopyable();\n\n };\n\n\n\n struct SourceLineInfo {\n\n\n\n SourceLineInfo() = delete;\n\n SourceLineInfo( char const* _file, std::size_t _line ) noexcept;\n\n\n\n SourceLineInfo( SourceLineInfo const& other ) = default;\n\n SourceLineInfo( SourceLineInfo && ) = default;\n\n SourceLineInfo& operator = ( SourceLineInfo const& ) = default;\n\n SourceLineInfo& operator = ( SourceLineInfo && ) = default;\n", "file_path": "cpp/test/catch.hpp", "rank": 88, "score": 57371.707337285115 }, { "content": " class WildcardPattern {\n\n enum WildcardPosition {\n\n NoWildcard = 0,\n\n WildcardAtStart = 1,\n\n WildcardAtEnd = 2,\n\n WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd\n\n };\n\n\n\n public:\n\n\n\n WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity );\n\n virtual ~WildcardPattern() = default;\n\n virtual bool matches( std::string const& str ) const;\n\n\n\n private:\n\n std::string adjustCase( std::string const& str ) const;\n\n CaseSensitive::Choice m_caseSensitivity;\n\n WildcardPosition m_wildcard = NoWildcard;\n\n std::string m_pattern;\n\n };\n\n}\n\n\n\n// end catch_wildcard_pattern.h\n\n#include <string>\n\n#include <vector>\n\n#include <memory>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 89, "score": 57371.707337285115 }, { "content": " class XmlEncode {\n\n public:\n\n enum ForWhat { ForTextNodes, ForAttributes };\n\n\n\n XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes );\n\n\n\n void encodeTo( std::ostream& os ) const;\n\n\n\n friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode );\n\n\n\n private:\n\n std::string m_str;\n\n ForWhat m_forWhat;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 90, "score": 57371.707337285115 }, { "content": " class ResultBase {\n\n public:\n\n enum Type {\n\n Ok, LogicError, RuntimeError\n\n };\n\n\n\n protected:\n\n ResultBase( Type type ) : m_type( type ) {}\n\n virtual ~ResultBase() = default;\n\n\n\n virtual void enforceOk() const = 0;\n\n\n\n Type m_type;\n\n };\n\n\n\n template<typename T>\n", "file_path": "cpp/test/catch.hpp", "rank": 91, "score": 57371.707337285115 }, { "content": " class ScopedMessage {\n\n public:\n\n ScopedMessage( MessageBuilder const& builder );\n\n ~ScopedMessage();\n\n\n\n MessageInfo m_info;\n\n };\n\n\n\n} // end namespace Catch\n\n\n\n// end catch_message.h\n\n// start catch_interfaces_capture.h\n\n\n\n#include <string>\n\n\n\nnamespace Catch {\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 92, "score": 57371.707337285115 }, { "content": " class ListenerRegistrar {\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 93, "score": 57371.707337285115 }, { "content": " class TablePrinter {\n\n std::ostream& m_os;\n\n std::vector<ColumnInfo> m_columnInfos;\n\n std::ostringstream m_oss;\n\n int m_currentColumn = -1;\n\n bool m_isOpen = false;\n\n\n\n public:\n\n TablePrinter( std::ostream& os, std::vector<ColumnInfo> const& columnInfos )\n\n : m_os( os ),\n\n m_columnInfos( columnInfos )\n\n {}\n\n\n\n auto columnInfos() const -> std::vector<ColumnInfo> const& {\n\n return m_columnInfos;\n\n }\n\n\n\n void open() {\n\n if( !m_isOpen ) {\n\n m_isOpen = true;\n", "file_path": "cpp/test/catch.hpp", "rank": 94, "score": 57371.707337285115 }, { "content": "\n\nnamespace Catch { namespace clara {\n\nnamespace detail {\n\n\n\n // Traits for extracting arg and return type of lambdas (for single argument lambdas)\n\n template<typename L>\n\n struct UnaryLambdaTraits : UnaryLambdaTraits<decltype( &L::operator() )> {};\n\n\n\n template<typename ClassT, typename ReturnT, typename... Args>\n\n struct UnaryLambdaTraits<ReturnT( ClassT::* )( Args... ) const> {\n\n static const bool isValid = false;\n\n };\n\n\n\n template<typename ClassT, typename ReturnT, typename ArgT>\n\n struct UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> {\n\n static const bool isValid = true;\n\n using ArgType = typename std::remove_const<typename std::remove_reference<ArgT>::type>::type;;\n\n using ReturnType = ReturnT;\n\n };\n\n\n", "file_path": "cpp/test/catch.hpp", "rank": 97, "score": 17.213412116647206 }, { "content": "\n\n std::string extractClassName( std::string const& classOrQualifiedMethodName ) {\n\n std::string className = classOrQualifiedMethodName;\n\n if( startsWith( className, '&' ) )\n\n {\n\n std::size_t lastColons = className.rfind( \"::\" );\n\n std::size_t penultimateColons = className.rfind( \"::\", lastColons-1 );\n\n if( penultimateColons == std::string::npos )\n\n penultimateColons = 1;\n\n className = className.substr( penultimateColons, lastColons-penultimateColons );\n\n }\n\n return className;\n\n }\n\n\n\n} // end namespace Catch\n\n// end catch_test_case_registry_impl.cpp\n\n// start catch_test_case_tracker.cpp\n\n\n\n#include <algorithm>\n\n#include <assert.h>\n", "file_path": "cpp/test/catch.hpp", "rank": 98, "score": 15.96533110869183 }, { "content": " return ::Catch::StringMaker<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::convert(e);\n\n }\n\n\n\n } // namespace Detail\n\n\n\n // Some predefined specializations\n\n\n\n template<>\n\n struct StringMaker<std::string> {\n\n static std::string convert(const std::string& str);\n\n };\n\n template<>\n\n struct StringMaker<std::wstring> {\n\n static std::string convert(const std::wstring& wstr);\n\n };\n\n\n\n template<>\n\n struct StringMaker<char const *> {\n\n static std::string convert(char const * str);\n\n };\n", "file_path": "cpp/test/catch.hpp", "rank": 99, "score": 15.51166036728916 } ]
C++
WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/glib/WebKitWebResource.cpp
mlcldh/appleWebKit2
39cc42a4710c9319c8da269621844493ab2ccdd6
#include "config.h" #include "WebKitWebResource.h" #include "APIData.h" #include "WebFrameProxy.h" #include "WebKitURIRequest.h" #include "WebKitWebResourcePrivate.h" #include <glib/gi18n-lib.h> #include <wtf/glib/GRefPtr.h> #include <wtf/glib/WTFGType.h> #include <wtf/text/CString.h> using namespace WebKit; enum { SENT_REQUEST, RECEIVED_DATA, FINISHED, FAILED, FAILED_WITH_TLS_ERRORS, LAST_SIGNAL }; enum { PROP_0, PROP_URI, PROP_RESPONSE }; struct _WebKitWebResourcePrivate { RefPtr<WebFrameProxy> frame; CString uri; GRefPtr<WebKitURIResponse> response; bool isMainResource; }; WEBKIT_DEFINE_TYPE(WebKitWebResource, webkit_web_resource, G_TYPE_OBJECT) static guint signals[LAST_SIGNAL] = { 0, }; static void webkitWebResourceGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) { WebKitWebResource* resource = WEBKIT_WEB_RESOURCE(object); switch (propId) { case PROP_URI: g_value_set_string(value, webkit_web_resource_get_uri(resource)); break; case PROP_RESPONSE: g_value_set_object(value, webkit_web_resource_get_response(resource)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); } } static void webkit_web_resource_class_init(WebKitWebResourceClass* resourceClass) { GObjectClass* objectClass = G_OBJECT_CLASS(resourceClass); objectClass->get_property = webkitWebResourceGetProperty; g_object_class_install_property(objectClass, PROP_URI, g_param_spec_string("uri", _("URI"), _("The current active URI of the resource"), 0, WEBKIT_PARAM_READABLE)); g_object_class_install_property(objectClass, PROP_RESPONSE, g_param_spec_object("response", _("Response"), _("The response of the resource"), WEBKIT_TYPE_URI_RESPONSE, WEBKIT_PARAM_READABLE)); signals[SENT_REQUEST] = g_signal_new( "sent-request", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, nullptr, nullptr, g_cclosure_marshal_generic, G_TYPE_NONE, 2, WEBKIT_TYPE_URI_REQUEST, WEBKIT_TYPE_URI_RESPONSE); signals[RECEIVED_DATA] = g_signal_new( "received-data", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, nullptr, nullptr, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_UINT64); signals[FINISHED] = g_signal_new("finished", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, 0, 0, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); signals[FAILED] = g_signal_new( "failed", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, 0, 0, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, G_TYPE_ERROR | G_SIGNAL_TYPE_STATIC_SCOPE); signals[FAILED_WITH_TLS_ERRORS] = g_signal_new("failed-with-tls-errors", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, nullptr, nullptr, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_TLS_CERTIFICATE, G_TYPE_TLS_CERTIFICATE_FLAGS); } static void webkitWebResourceUpdateURI(WebKitWebResource* resource, const CString& requestURI) { if (resource->priv->uri == requestURI) return; resource->priv->uri = requestURI; g_object_notify(G_OBJECT(resource), "uri"); } WebKitWebResource* webkitWebResourceCreate(WebFrameProxy* frame, WebKitURIRequest* request, bool isMainResource) { ASSERT(frame); WebKitWebResource* resource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL)); resource->priv->frame = frame; resource->priv->uri = webkit_uri_request_get_uri(request); resource->priv->isMainResource = isMainResource; return resource; } void webkitWebResourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse) { webkitWebResourceUpdateURI(resource, webkit_uri_request_get_uri(request)); g_signal_emit(resource, signals[SENT_REQUEST], 0, request, redirectResponse); } void webkitWebResourceSetResponse(WebKitWebResource* resource, WebKitURIResponse* response) { resource->priv->response = response; g_object_notify(G_OBJECT(resource), "response"); } void webkitWebResourceNotifyProgress(WebKitWebResource* resource, guint64 bytesReceived) { g_signal_emit(resource, signals[RECEIVED_DATA], 0, bytesReceived); } void webkitWebResourceFinished(WebKitWebResource* resource) { g_signal_emit(resource, signals[FINISHED], 0, NULL); } void webkitWebResourceFailed(WebKitWebResource* resource, GError* error) { g_signal_emit(resource, signals[FAILED], 0, error); g_signal_emit(resource, signals[FINISHED], 0, NULL); } void webkitWebResourceFailedWithTLSErrors(WebKitWebResource* resource, GTlsCertificateFlags tlsErrors, GTlsCertificate* certificate) { g_signal_emit(resource, signals[FAILED_WITH_TLS_ERRORS], 0, certificate, tlsErrors); g_signal_emit(resource, signals[FINISHED], 0, nullptr); } WebFrameProxy* webkitWebResourceGetFrame(WebKitWebResource* resource) { return resource->priv->frame.get(); } const char* webkit_web_resource_get_uri(WebKitWebResource* resource) { g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); return resource->priv->uri.data(); } WebKitURIResponse* webkit_web_resource_get_response(WebKitWebResource* resource) { g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); return resource->priv->response.get(); } struct ResourceGetDataAsyncData { RefPtr<API::Data> webData; }; WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ResourceGetDataAsyncData) static void resourceDataCallback(API::Data* wkData, GTask* task) { ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); data->webData = wkData; g_task_return_boolean(task, TRUE); } void webkit_web_resource_get_data(WebKitWebResource* resource, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) { g_return_if_fail(WEBKIT_IS_WEB_RESOURCE(resource)); GTask* task = g_task_new(resource, cancellable, callback, userData); g_task_set_task_data(task, createResourceGetDataAsyncData(), reinterpret_cast<GDestroyNotify>(destroyResourceGetDataAsyncData)); if (resource->priv->isMainResource) resource->priv->frame->getMainResourceData([task](API::Data* data, CallbackBase::Error) { resourceDataCallback(data, adoptGRef(task).get()); }); else { String url = String::fromUTF8(resource->priv->uri.data()); resource->priv->frame->getResourceData(API::URL::create(url).ptr(), [task](API::Data* data, CallbackBase::Error) { resourceDataCallback(data, adoptGRef(task).get()); }); } } guchar* webkit_web_resource_get_data_finish(WebKitWebResource* resource, GAsyncResult* result, gsize* length, GError** error) { g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); g_return_val_if_fail(g_task_is_valid(result, resource), 0); GTask* task = G_TASK(result); if (!g_task_propagate_boolean(task, error)) return 0; ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); if (length) *length = data->webData->size(); return static_cast<guchar*>(g_memdup(data->webData->bytes(), data->webData->size())); }
#include "config.h" #include "WebKitWebResource.h" #include "APIData.h" #include "WebFrameProxy.h" #include "WebKitURIRequest.h" #include "WebKitWebResourcePrivate.h" #include <glib/gi18n-lib.h> #include <wtf/glib/GRefPtr.h> #include <wtf/glib/WTFGType.h> #include <wtf/text/CString.h> using namespace WebKit; enum { SENT_REQUEST, RECEIVED_DATA, FINISHED, FAILED, FAILED_WITH_TLS_ERRORS, LAST_SIGNAL }; enum { PROP_0, PROP_URI, PROP_RESPONSE }; struct _WebKitWebResourcePrivate { RefPtr<WebFrameProxy> frame; CString uri; GRefPtr<WebKitURIResponse> response; bool isMainResource; }; WEBKIT_DEFINE_TYPE(WebKitWebResource, webkit_web_resource, G_TYPE_OBJECT) static guint signals[LAST_SIGNAL] = { 0, }; static void webkitWebResourceGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) { WebKitWebResource* resource = WEBKIT_WEB_RESOURCE(object); switch (propId) { case PROP_URI: g_value_set_string(value, webkit_web_resource_get_uri(resource)); break; case PROP_RESPONSE: g_value_set_object(value, webkit_web_resource_get_response(resource)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); } } static void webkit_web_resource_class_init(WebKitWebResourceClass* resourceClass) { GObjectClass* objectClass = G_OBJECT_CLASS(resourceClass); objectClass->get_property = webkitWebResourceGetProperty; g_object_class_install_property(objectClass, PROP_URI, g_param_spec_string("uri",
Errors(WebKitWebResource* resource, GTlsCertificateFlags tlsErrors, GTlsCertificate* certificate) { g_signal_emit(resource, signals[FAILED_WITH_TLS_ERRORS], 0, certificate, tlsErrors); g_signal_emit(resource, signals[FINISHED], 0, nullptr); } WebFrameProxy* webkitWebResourceGetFrame(WebKitWebResource* resource) { return resource->priv->frame.get(); } const char* webkit_web_resource_get_uri(WebKitWebResource* resource) { g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); return resource->priv->uri.data(); } WebKitURIResponse* webkit_web_resource_get_response(WebKitWebResource* resource) { g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); return resource->priv->response.get(); } struct ResourceGetDataAsyncData { RefPtr<API::Data> webData; }; WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ResourceGetDataAsyncData) static void resourceDataCallback(API::Data* wkData, GTask* task) { ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); data->webData = wkData; g_task_return_boolean(task, TRUE); } void webkit_web_resource_get_data(WebKitWebResource* resource, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData) { g_return_if_fail(WEBKIT_IS_WEB_RESOURCE(resource)); GTask* task = g_task_new(resource, cancellable, callback, userData); g_task_set_task_data(task, createResourceGetDataAsyncData(), reinterpret_cast<GDestroyNotify>(destroyResourceGetDataAsyncData)); if (resource->priv->isMainResource) resource->priv->frame->getMainResourceData([task](API::Data* data, CallbackBase::Error) { resourceDataCallback(data, adoptGRef(task).get()); }); else { String url = String::fromUTF8(resource->priv->uri.data()); resource->priv->frame->getResourceData(API::URL::create(url).ptr(), [task](API::Data* data, CallbackBase::Error) { resourceDataCallback(data, adoptGRef(task).get()); }); } } guchar* webkit_web_resource_get_data_finish(WebKitWebResource* resource, GAsyncResult* result, gsize* length, GError** error) { g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0); g_return_val_if_fail(g_task_is_valid(result, resource), 0); GTask* task = G_TASK(result); if (!g_task_propagate_boolean(task, error)) return 0; ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); if (length) *length = data->webData->size(); return static_cast<guchar*>(g_memdup(data->webData->bytes(), data->webData->size())); }
_("URI"), _("The current active URI of the resource"), 0, WEBKIT_PARAM_READABLE)); g_object_class_install_property(objectClass, PROP_RESPONSE, g_param_spec_object("response", _("Response"), _("The response of the resource"), WEBKIT_TYPE_URI_RESPONSE, WEBKIT_PARAM_READABLE)); signals[SENT_REQUEST] = g_signal_new( "sent-request", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, nullptr, nullptr, g_cclosure_marshal_generic, G_TYPE_NONE, 2, WEBKIT_TYPE_URI_REQUEST, WEBKIT_TYPE_URI_RESPONSE); signals[RECEIVED_DATA] = g_signal_new( "received-data", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, nullptr, nullptr, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_UINT64); signals[FINISHED] = g_signal_new("finished", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, 0, 0, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); signals[FAILED] = g_signal_new( "failed", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, 0, 0, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, G_TYPE_ERROR | G_SIGNAL_TYPE_STATIC_SCOPE); signals[FAILED_WITH_TLS_ERRORS] = g_signal_new("failed-with-tls-errors", G_TYPE_FROM_CLASS(objectClass), G_SIGNAL_RUN_LAST, 0, nullptr, nullptr, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_TLS_CERTIFICATE, G_TYPE_TLS_CERTIFICATE_FLAGS); } static void webkitWebResourceUpdateURI(WebKitWebResource* resource, const CString& requestURI) { if (resource->priv->uri == requestURI) return; resource->priv->uri = requestURI; g_object_notify(G_OBJECT(resource), "uri"); } WebKitWebResource* webkitWebResourceCreate(WebFrameProxy* frame, WebKitURIRequest* request, bool isMainResource) { ASSERT(frame); WebKitWebResource* resource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL)); resource->priv->frame = frame; resource->priv->uri = webkit_uri_request_get_uri(request); resource->priv->isMainResource = isMainResource; return resource; } void webkitWebResourceSentRequest(WebKitWebResource* resource, WebKitURIRequest* request, WebKitURIResponse* redirectResponse) { webkitWebResourceUpdateURI(resource, webkit_uri_request_get_uri(request)); g_signal_emit(resource, signals[SENT_REQUEST], 0, request, redirectResponse); } void webkitWebResourceSetResponse(WebKitWebResource* resource, WebKitURIResponse* response) { resource->priv->response = response; g_object_notify(G_OBJECT(resource), "response"); } void webkitWebResourceNotifyProgress(WebKitWebResource* resource, guint64 bytesReceived) { g_signal_emit(resource, signals[RECEIVED_DATA], 0, bytesReceived); } void webkitWebResourceFinished(WebKitWebResource* resource) { g_signal_emit(resource, signals[FINISHED], 0, NULL); } void webkitWebResourceFailed(WebKitWebResource* resource, GError* error) { g_signal_emit(resource, signals[FAILED], 0, error); g_signal_emit(resource, signals[FINISHED], 0, NULL); } void webkitWebResourceFailedWithTLS
random
[ { "content": "struct external_constructor<value_t::object>\n\n{\n\n template<typename BasicJsonType>\n\n static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)\n\n {\n\n j.m_type = value_t::object;\n\n j.m_value = obj;\n\n j.assert_invariant();\n\n }\n\n\n\n template<typename BasicJsonType, typename CompatibleObjectType,\n\n enable_if_t<not std::is_same<CompatibleObjectType,\n\n typename BasicJsonType::object_t>::value,\n\n int> = 0>\n\n static void construct(BasicJsonType& j, const CompatibleObjectType& obj)\n\n {\n\n using std::begin;\n\n using std::end;\n\n\n\n j.m_type = value_t::object;\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/NetworkProcess/capture/json.hpp", "rank": 0, "score": 263351.89229509747 }, { "content": "struct external_constructor<value_t::object>\n\n{\n\n template<typename BasicJsonType>\n\n static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)\n\n {\n\n j.m_type = value_t::object;\n\n j.m_value = obj;\n\n j.assert_invariant();\n\n }\n\n\n\n template<typename BasicJsonType, typename CompatibleObjectType,\n\n enable_if_t<not std::is_same<CompatibleObjectType,\n\n typename BasicJsonType::object_t>::value,\n\n int> = 0>\n\n static void construct(BasicJsonType& j, const CompatibleObjectType& obj)\n\n {\n\n using std::begin;\n\n using std::end;\n\n\n\n j.m_type = value_t::object;\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/capture/json.hpp", "rank": 1, "score": 263351.89229509747 }, { "content": "WEBKIT_API JSCValue *\n\nwebkit_frame_get_js_value_for_dom_object (WebKitFrame *frame,\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h", "rank": 2, "score": 224636.11308566888 }, { "content": "WEBKIT_API JSCValue *\n\nwebkit_frame_get_js_value_for_dom_object (WebKitFrame *frame,\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h", "rank": 3, "score": 224636.11308566888 }, { "content": "WEBKIT_API JSCValue *\n\nwebkit_frame_get_js_value_for_dom_object_in_script_world (WebKitFrame *frame,\n\n WebKitDOMObject *dom_object,\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h", "rank": 4, "score": 218869.75272659239 }, { "content": "WEBKIT_API JSCValue *\n\nwebkit_frame_get_js_value_for_dom_object_in_script_world (WebKitFrame *frame,\n\n WebKitDOMObject *dom_object,\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h", "rank": 5, "score": 218869.75272659239 }, { "content": "class WebFrameProxy : public API::ObjectImpl<API::Object::Type::Frame> {\n\npublic:\n\n static Ref<WebFrameProxy> create(WebPageProxy* page, uint64_t frameID)\n\n {\n\n return adoptRef(*new WebFrameProxy(page, frameID));\n\n }\n\n\n\n virtual ~WebFrameProxy();\n\n\n\n uint64_t frameID() const { return m_frameID; }\n\n WebPageProxy* page() const { return m_page; }\n\n\n\n void webProcessWillShutDown();\n\n\n\n bool isMainFrame() const;\n\n\n\n void setIsFrameSet(bool value) { m_isFrameSet = value; }\n\n bool isFrameSet() const { return m_isFrameSet; }\n\n\n\n FrameLoadState& frameLoadState() { return m_frameLoadState; }\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/WebFrameProxy.h", "rank": 6, "score": 202177.86452772294 }, { "content": "class WebFrameProxy : public API::ObjectImpl<API::Object::Type::Frame> {\n\npublic:\n\n static Ref<WebFrameProxy> create(WebPageProxy* page, uint64_t frameID)\n\n {\n\n return adoptRef(*new WebFrameProxy(page, frameID));\n\n }\n\n\n\n virtual ~WebFrameProxy();\n\n\n\n uint64_t frameID() const { return m_frameID; }\n\n WebPageProxy* page() const { return m_page; }\n\n\n\n void webProcessWillShutDown();\n\n\n\n bool isMainFrame() const;\n\n\n\n void setIsFrameSet(bool value) { m_isFrameSet = value; }\n\n bool isFrameSet() const { return m_isFrameSet; }\n\n\n\n FrameLoadState& frameLoadState() { return m_frameLoadState; }\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/WebFrameProxy.h", "rank": 7, "score": 202177.86452772294 }, { "content": "enum class DidWrap : bool;\n\n}\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/WebPage/FindController.h", "rank": 8, "score": 200965.46420135646 }, { "content": "enum class DidWrap : bool;\n\n}\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/WebPage/FindController.h", "rank": 9, "score": 200965.46420135646 }, { "content": " // The manual stream state. This is used so we can deliver a manual stream to a plug-in\n\n // when it is initialized.\n\n enum class ManualStreamState { Initial, HasReceivedResponse, Finished, Failed };\n\n ManualStreamState m_manualStreamState { ManualStreamState::Initial };\n\n\n\n WebCore::ResourceResponse m_manualStreamResponse;\n\n WebCore::ResourceError m_manualStreamError;\n\n RefPtr<WebCore::SharedBuffer> m_manualStreamData;\n\n\n\n // This snapshot is used to avoid side effects should the plugin run JS during painting.\n\n RefPtr<ShareableBitmap> m_transientPaintingSnapshot;\n\n // This timer is used when plugin snapshotting is enabled, to capture a plugin placeholder.\n\n WebCore::DeferrableOneShotTimer m_pluginSnapshotTimer;\n\n#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) || PLATFORM(COCOA)\n\n unsigned m_countSnapshotRetries { 0 };\n\n#endif\n\n bool m_didReceiveUserInteraction { false };\n\n\n\n double m_pageScaleFactor { 1 };\n\n\n\n bool m_pluginIsPlayingAudio { false };\n\n};\n\n\n\n} // namespace WebKit\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/Plugins/PluginView.h", "rank": 10, "score": 200349.26565036376 }, { "content": " // The manual stream state. This is used so we can deliver a manual stream to a plug-in\n\n // when it is initialized.\n\n enum class ManualStreamState { Initial, HasReceivedResponse, Finished, Failed };\n\n ManualStreamState m_manualStreamState { ManualStreamState::Initial };\n\n\n\n WebCore::ResourceResponse m_manualStreamResponse;\n\n WebCore::ResourceError m_manualStreamError;\n\n RefPtr<WebCore::SharedBuffer> m_manualStreamData;\n\n\n\n // This snapshot is used to avoid side effects should the plugin run JS during painting.\n\n RefPtr<ShareableBitmap> m_transientPaintingSnapshot;\n\n // This timer is used when plugin snapshotting is enabled, to capture a plugin placeholder.\n\n WebCore::DeferrableOneShotTimer m_pluginSnapshotTimer;\n\n#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) || PLATFORM(COCOA)\n\n unsigned m_countSnapshotRetries { 0 };\n\n#endif\n\n bool m_didReceiveUserInteraction { false };\n\n\n\n double m_pageScaleFactor { 1 };\n\n\n\n bool m_pluginIsPlayingAudio { false };\n\n};\n\n\n\n} // namespace WebKit\n\n\n\n#endif // PluginView_h\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/Plugins/PluginView.h", "rank": 11, "score": 200349.26565036376 }, { "content": "struct conjunction<B1, Bn...> : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};\n\n\n\ntemplate<class B> struct negation : std::integral_constant < bool, !B::value > {};\n\n\n\n// dispatch utility (taken from ranges-v3)\n\ntemplate<unsigned N> struct priority_tag : priority_tag < N - 1 > {};\n\ntemplate<> struct priority_tag<0> {};\n\n\n\n\n\n//////////////////\n\n// constructors //\n\n//////////////////\n\n\n\ntemplate<value_t> struct external_constructor;\n\n\n\ntemplate<>\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/capture/json.hpp", "rank": 12, "score": 200093.46939293318 }, { "content": "struct conjunction<B1, Bn...> : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};\n\n\n\ntemplate<class B> struct negation : std::integral_constant < bool, !B::value > {};\n\n\n\n// dispatch utility (taken from ranges-v3)\n\ntemplate<unsigned N> struct priority_tag : priority_tag < N - 1 > {};\n\ntemplate<> struct priority_tag<0> {};\n\n\n\n\n\n//////////////////\n\n// constructors //\n\n//////////////////\n\n\n\ntemplate<value_t> struct external_constructor;\n\n\n\ntemplate<>\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/NetworkProcess/capture/json.hpp", "rank": 13, "score": 200093.46939293316 }, { "content": " enum class ShouldPreprocess : bool {\n\n No = false,\n\n Yes = true\n\n };\n\n\n\n NetworkDataTaskCurl(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation);\n\n\n\n void suspend() override;\n\n void cancel() override;\n\n void resume() override;\n\n void invalidateAndCancel() override;\n\n NetworkDataTask::State state() const override;\n\n\n\n Ref<WebCore::CurlRequest> createCurlRequest(const WebCore::ResourceRequest&, ShouldPreprocess);\n\n void curlDidSendData(WebCore::CurlRequest&, unsigned long long, unsigned long long) override;\n\n void curlDidReceiveResponse(WebCore::CurlRequest&, const WebCore::CurlResponse&) override;\n\n void curlDidReceiveBuffer(WebCore::CurlRequest&, Ref<WebCore::SharedBuffer>&&) override;\n\n void curlDidComplete(WebCore::CurlRequest&) override;\n\n void curlDidFailWithError(WebCore::CurlRequest&, const WebCore::ResourceError&) override;\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/curl/NetworkDataTaskCurl.h", "rank": 14, "score": 198770.86843621093 }, { "content": "struct ObjectStorage {\n\n T* get() { return reinterpret_cast<T*>(&data); }\n\n T& operator*() { return *reinterpret_cast<T*>(&data); }\n\n T* operator->() { return reinterpret_cast<T*>(&data); }\n\n\n\n typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type data;\n\n};\n\n\n\nAPI::Object* unwrap(void*);\n\nvoid* wrap(API::Object*);\n\n\n\n}\n\n\n\n@protocol WKObject <NSObject>\n\n\n\n@property (readonly) API::Object& _apiObject;\n\n\n\n@end\n\n\n\n@interface WKObject : NSProxy <WKObject>\n\n\n\n- (NSObject *)_web_createTarget NS_RETURNS_RETAINED;\n\n\n\n@end\n\n\n\n#endif // WK_API_ENABLED\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Shared/Cocoa/WKObject.h", "rank": 15, "score": 198670.86768681658 }, { "content": "struct ObjectStorage {\n\n T* get() { return reinterpret_cast<T*>(&data); }\n\n T& operator*() { return *reinterpret_cast<T*>(&data); }\n\n T* operator->() { return reinterpret_cast<T*>(&data); }\n\n\n\n typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type data;\n\n};\n\n\n\nAPI::Object* unwrap(void*);\n\nvoid* wrap(API::Object*);\n\n\n\n}\n\n\n\n@protocol WKObject <NSObject>\n\n\n\n@property (readonly) API::Object& _apiObject;\n\n\n\n@end\n\n\n\n@interface WKObject : NSProxy <WKObject>\n\n\n\n- (NSObject *)_web_createTarget NS_RETURNS_RETAINED;\n\n\n\n@end\n\n\n\n#endif // WK_API_ENABLED\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Shared/Cocoa/WKObject.h", "rank": 16, "score": 198670.86768681658 }, { "content": "struct FrameInfoData {\n\n void encode(IPC::Encoder&) const;\n\n static bool decode(IPC::Decoder&, FrameInfoData&);\n\n\n\n bool isMainFrame { false };\n\n WebCore::ResourceRequest request;\n\n WebCore::SecurityOriginData securityOrigin;\n\n uint64_t frameID { 0 };\n\n};\n\n\n\n}\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Shared/FrameInfoData.h", "rank": 17, "score": 196388.15012076552 }, { "content": "struct FrameInfoData {\n\n void encode(IPC::Encoder&) const;\n\n static bool decode(IPC::Decoder&, FrameInfoData&);\n\n\n\n bool isMainFrame { false };\n\n WebCore::ResourceRequest request;\n\n WebCore::SecurityOriginData securityOrigin;\n\n uint64_t frameID { 0 };\n\n};\n\n\n\n}\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Shared/FrameInfoData.h", "rank": 18, "score": 196388.15012076552 }, { "content": "struct NPObject;\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/Plugins/Netscape/JSNPObject.h", "rank": 19, "score": 194397.7648653093 }, { "content": "struct NPObject;\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/Plugins/Netscape/JSNPObject.h", "rank": 20, "score": 194397.7648653093 }, { "content": "struct NPObject;\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7534.57.7/WebKit2-7534.57.7/WebProcess/Plugins/Netscape/JSNPObject.h", "rank": 21, "score": 194397.7648653093 }, { "content": "enum ResourceLoadPrevalence {\n\n Low = 1 << 0,\n\n High = 1 << 1,\n\n VeryHigh = 1 << 2,\n\n};\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Platform/classifier/ResourceLoadStatisticsClassifier.h", "rank": 22, "score": 192654.08805004752 }, { "content": "struct ResourceLoadStatistics;\n\n}\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Platform/classifier/ResourceLoadStatisticsClassifier.h", "rank": 23, "score": 192393.91711522735 }, { "content": "struct ResourceLoadStatistics;\n\n}\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Platform/classifier/ResourceLoadStatisticsClassifier.h", "rank": 24, "score": 192393.91711522735 }, { "content": "struct FrameInfoData;\n\n}\n\n\n\nnamespace API {\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/APIFrameInfo.h", "rank": 25, "score": 192246.16711403133 }, { "content": "struct FrameInfoData;\n\n}\n\n\n\nnamespace API {\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/APIFrameInfo.h", "rank": 26, "score": 192246.16711403133 }, { "content": "struct FrameInfoData;\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/WebPage/WebFrame.h", "rank": 27, "score": 192246.16711403133 }, { "content": "struct FrameInfoData;\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/WebPage/WebFrame.h", "rank": 28, "score": 192246.16711403133 }, { "content": "struct ResourceLoadStatistics;\n\n}\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/WebResourceLoadStatisticsStore.h", "rank": 29, "score": 190412.4536312026 }, { "content": "struct ResourceLoadStatistics;\n\n}\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/ResourceLoadStatisticsMemoryStore.h", "rank": 30, "score": 190412.4536312026 }, { "content": "struct ResourceLoadStatistics;\n\n}\n\n\n\nnamespace WebKit {\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/WebResourceLoadStatisticsStore.h", "rank": 31, "score": 190412.4536312026 }, { "content": "struct NPObject;\n\ntypedef struct _NPVariant NPVariant;\n\n\n\nnamespace JSC {\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h", "rank": 32, "score": 190375.81612532123 }, { "content": "struct NPObject;\n\ntypedef struct _NPVariant NPVariant;\n\n\n\nnamespace JSC {\n", "file_path": "WebKit2-7534.57.7/WebKit2-7534.57.7/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h", "rank": 33, "score": 190375.81612532123 }, { "content": "struct NPObject;\n\ntypedef struct _NPVariant NPVariant;\n\n\n\nnamespace JSC {\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h", "rank": 34, "score": 190375.81612532123 }, { "content": "struct PrevalentResourceTelemetry {\n\n unsigned numberOfTimesDataRecordsRemoved;\n\n bool hasHadUserInteraction;\n\n unsigned daysSinceUserInteraction;\n\n unsigned subframeUnderTopFrameOrigins;\n\n unsigned subresourceUnderTopFrameOrigins;\n\n unsigned subresourceUniqueRedirectsTo;\n\n};\n\n\n\nstatic Vector<PrevalentResourceTelemetry> sortedPrevalentResourceTelemetry(const WebResourceLoadStatisticsStore& store)\n\n{\n\n ASSERT(!RunLoop::isMain());\n\n Vector<PrevalentResourceTelemetry> sorted;\n\n store.processStatistics([&sorted] (auto& statistic) {\n\n if (!statistic.isPrevalentResource)\n\n return;\n\n\n\n unsigned daysSinceUserInteraction = statistic.mostRecentUserInteractionTime <= WallTime() ? 0 : std::floor((WallTime::now() - statistic.mostRecentUserInteractionTime) / 24_h);\n\n sorted.append(PrevalentResourceTelemetry {\n\n statistic.dataRecordsRemoved,\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/WebResourceLoadStatisticsTelemetry.cpp", "rank": 35, "score": 188488.1364537878 }, { "content": "struct SecurityOriginData;\n\n\n", "file_path": "WebKit2-7534.57.7/WebKit2-7534.57.7/WebProcess/ResourceCache/WebResourceCacheManager.h", "rank": 36, "score": 188488.1364537878 }, { "content": "struct PrevalentResourceTelemetry {\n\n unsigned numberOfTimesDataRecordsRemoved;\n\n bool hasHadUserInteraction;\n\n unsigned daysSinceUserInteraction;\n\n unsigned subframeUnderTopFrameOrigins;\n\n unsigned subresourceUnderTopFrameOrigins;\n\n unsigned subresourceUniqueRedirectsTo;\n\n unsigned timesAccessedAsFirstPartyDueToUserInteraction;\n\n unsigned timesAccessedAsFirstPartyDueToStorageAccessAPI;\n\n};\n\n\n\nstatic Vector<PrevalentResourceTelemetry> sortedPrevalentResourceTelemetry(const ResourceLoadStatisticsMemoryStore& store)\n\n{\n\n ASSERT(!RunLoop::isMain());\n\n Vector<PrevalentResourceTelemetry> sorted;\n\n store.processStatistics([&sorted] (auto& statistic) {\n\n if (!statistic.isPrevalentResource)\n\n return;\n\n\n\n unsigned daysSinceUserInteraction = statistic.mostRecentUserInteractionTime <= WallTime() ? 0 : std::floor((WallTime::now() - statistic.mostRecentUserInteractionTime) / 24_h);\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/WebResourceLoadStatisticsTelemetry.cpp", "rank": 37, "score": 188488.1364537878 }, { "content": "class FrameHandle : public ObjectImpl<Object::Type::FrameHandle> {\n\npublic:\n\n static Ref<FrameHandle> create(uint64_t frameID);\n\n static Ref<FrameHandle> createAutoconverting(uint64_t frameID);\n\n\n\n explicit FrameHandle(uint64_t frameID, bool isAutoconverting);\n\n virtual ~FrameHandle();\n\n\n\n uint64_t frameID() const { return m_frameID; }\n\n bool isAutoconverting() const { return m_isAutoconverting; }\n\n\n\n void encode(IPC::Encoder&) const;\n\n static bool decode(IPC::Decoder&, RefPtr<Object>&);\n\n\n\nprivate:\n\n const uint64_t m_frameID;\n\n const bool m_isAutoconverting;\n\n};\n\n\n\n} // namespace API\n\n\n\n#endif // APIFrameHandle_h\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Shared/API/APIFrameHandle.h", "rank": 38, "score": 186177.97258009156 }, { "content": "class FrameHandle : public ObjectImpl<Object::Type::FrameHandle> {\n\npublic:\n\n static Ref<FrameHandle> create(uint64_t frameID);\n\n static Ref<FrameHandle> createAutoconverting(uint64_t frameID);\n\n\n\n explicit FrameHandle(uint64_t frameID, bool isAutoconverting);\n\n virtual ~FrameHandle();\n\n\n\n uint64_t frameID() const { return m_frameID; }\n\n bool isAutoconverting() const { return m_isAutoconverting; }\n\n\n\n void encode(IPC::Encoder&) const;\n\n static bool decode(IPC::Decoder&, RefPtr<Object>&);\n\n\n\nprivate:\n\n const uint64_t m_frameID;\n\n const bool m_isAutoconverting;\n\n};\n\n\n\n} // namespace API\n\n\n\n#endif // APIFrameHandle_h\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Shared/API/APIFrameHandle.h", "rank": 39, "score": 186177.97258009156 }, { "content": "struct FrameState {\n\n void encode(IPC::Encoder&) const;\n\n static std::optional<FrameState> decode(IPC::Decoder&);\n\n\n\n String urlString;\n\n String originalURLString;\n\n String referrer;\n\n String target;\n\n\n\n Vector<String> documentState;\n\n std::optional<Vector<uint8_t>> stateObjectData;\n\n\n\n int64_t documentSequenceNumber { 0 };\n\n int64_t itemSequenceNumber { 0 };\n\n\n\n WebCore::IntPoint scrollPosition;\n\n bool shouldRestoreScrollPosition { true };\n\n float pageScaleFactor { 0 };\n\n\n\n std::optional<HTTPBody> httpBody;\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Shared/SessionState.h", "rank": 40, "score": 185089.83939628938 }, { "content": "struct FrameState {\n\n void encode(IPC::Encoder&) const;\n\n static bool decode(IPC::Decoder&, FrameState&);\n\n\n\n String urlString;\n\n String originalURLString;\n\n String referrer;\n\n String target;\n\n\n\n Vector<String> documentState;\n\n std::optional<Vector<uint8_t>> stateObjectData;\n\n\n\n int64_t documentSequenceNumber { 0 };\n\n int64_t itemSequenceNumber { 0 };\n\n\n\n WebCore::IntPoint scrollPosition;\n\n bool shouldRestoreScrollPosition { true };\n\n float pageScaleFactor { 0 };\n\n\n\n std::optional<HTTPBody> httpBody;\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Shared/SessionState.h", "rank": 41, "score": 185089.83939628938 }, { "content": "struct SecurityOriginData;\n\n\n", "file_path": "WebKit2-7534.57.7/WebKit2-7534.57.7/WebProcess/KeyValueStorage/WebKeyValueStorageManager.h", "rank": 42, "score": 184913.68483462493 }, { "content": "struct _WebKitURIRequestPrivate {\n\n WebCore::ResourceRequest resourceRequest;\n\n CString uri;\n\n const char* httpMethod;\n\n GUniquePtr<SoupMessageHeaders> httpHeaders;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitURIRequest, webkit_uri_request, G_TYPE_OBJECT)\n\n\n\nstatic void webkitURIRequestGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)\n\n{\n\n WebKitURIRequest* request = WEBKIT_URI_REQUEST(object);\n\n\n\n switch (propId) {\n\n case PROP_URI:\n\n g_value_set_string(value, webkit_uri_request_get_uri(request));\n\n break;\n\n default:\n\n G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);\n\n }\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Shared/API/glib/WebKitURIRequest.cpp", "rank": 43, "score": 184893.38968083428 }, { "content": "struct _WebKitURIResponsePrivate {\n\n ResourceResponse resourceResponse;\n\n CString uri;\n\n CString mimeType;\n\n CString suggestedFilename;\n\n GUniquePtr<SoupMessageHeaders> httpHeaders;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitURIResponse, webkit_uri_response, G_TYPE_OBJECT)\n\n\n\nstatic void webkitURIResponseGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)\n\n{\n\n WebKitURIResponse* response = WEBKIT_URI_RESPONSE(object);\n\n\n\n switch (propId) {\n\n case PROP_URI:\n\n g_value_set_string(value, webkit_uri_response_get_uri(response));\n\n break;\n\n case PROP_STATUS_CODE:\n\n g_value_set_uint(value, webkit_uri_response_get_status_code(response));\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Shared/API/glib/WebKitURIResponse.cpp", "rank": 44, "score": 184893.38968083428 }, { "content": "struct _WebKitURIResponsePrivate {\n\n ResourceResponse resourceResponse;\n\n CString uri;\n\n CString mimeType;\n\n CString suggestedFilename;\n\n GUniquePtr<SoupMessageHeaders> httpHeaders;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitURIResponse, webkit_uri_response, G_TYPE_OBJECT)\n\n\n\nstatic void webkitURIResponseGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)\n\n{\n\n WebKitURIResponse* response = WEBKIT_URI_RESPONSE(object);\n\n\n\n switch (propId) {\n\n case PROP_URI:\n\n g_value_set_string(value, webkit_uri_response_get_uri(response));\n\n break;\n\n case PROP_STATUS_CODE:\n\n g_value_set_uint(value, webkit_uri_response_get_status_code(response));\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Shared/API/glib/WebKitURIResponse.cpp", "rank": 45, "score": 184893.38968083428 }, { "content": "struct _WebKitURIRequestPrivate {\n\n WebCore::ResourceRequest resourceRequest;\n\n CString uri;\n\n const char* httpMethod;\n\n GUniquePtr<SoupMessageHeaders> httpHeaders;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitURIRequest, webkit_uri_request, G_TYPE_OBJECT)\n\n\n\nstatic void webkitURIRequestGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)\n\n{\n\n WebKitURIRequest* request = WEBKIT_URI_REQUEST(object);\n\n\n\n switch (propId) {\n\n case PROP_URI:\n\n g_value_set_string(value, webkit_uri_request_get_uri(request));\n\n break;\n\n default:\n\n G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);\n\n }\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Shared/API/glib/WebKitURIRequest.cpp", "rank": 46, "score": 184893.38968083428 }, { "content": "struct _WebPageAccessibilityObject {\n\n AtkPlug parent;\n\n WebKit::WebPage* m_page;\n\n};\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/WebPage/atk/WebPageAccessibilityObject.h", "rank": 47, "score": 184765.46851503276 }, { "content": "struct _WebPageAccessibilityObject {\n\n AtkPlug parent;\n\n WebKit::WebPage* m_page;\n\n};\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/WebPage/atk/WebPageAccessibilityObject.h", "rank": 48, "score": 184765.46851503276 }, { "content": "struct _WebKitWebResourcePrivate {\n\n RefPtr<WebFrameProxy> frame;\n\n CString uri;\n\n GRefPtr<WebKitURIResponse> response;\n\n bool isMainResource;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitWebResource, webkit_web_resource, G_TYPE_OBJECT)\n\n\n\nstatic guint signals[LAST_SIGNAL] = { 0, };\n\n\n\nstatic void webkitWebResourceGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)\n\n{\n\n WebKitWebResource* resource = WEBKIT_WEB_RESOURCE(object);\n\n\n\n switch (propId) {\n\n case PROP_URI:\n\n g_value_set_string(value, webkit_web_resource_get_uri(resource));\n\n break;\n\n case PROP_RESPONSE:\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/glib/WebKitWebResource.cpp", "rank": 51, "score": 183033.38567334044 }, { "content": "struct ResourceGetDataAsyncData {\n\n RefPtr<API::Data> webData;\n\n};\n\nWEBKIT_DEFINE_ASYNC_DATA_STRUCT(ResourceGetDataAsyncData)\n\n\n\nstatic void resourceDataCallback(API::Data* wkData, CallbackBase::Error error, GTask* task)\n\n{\n\n if (error != CallbackBase::Error::None) {\n\n // This fails when the page is closed or frame is destroyed, so we can just cancel the operation.\n\n g_task_return_new_error(task, G_IO_ERROR, G_IO_ERROR_CANCELLED, _(\"Operation was cancelled\"));\n\n return;\n\n }\n\n ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task));\n\n data->webData = wkData;\n\n g_task_return_boolean(task, TRUE);\n\n}\n\n\n\n/**\n\n * webkit_web_resource_get_data:\n\n * @resource: a #WebKitWebResource\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/glib/WebKitWebResource.cpp", "rank": 52, "score": 183033.38567334044 }, { "content": "struct _WebPageAccessibilityObjectClass {\n\n AtkPlugClass parentClass;\n\n};\n\n\n\nGType web_page_accessibility_object_get_type();\n\n\n\nWebPageAccessibilityObject* webPageAccessibilityObjectNew(WebKit::WebPage*);\n\n\n\nvoid webPageAccessibilityObjectRefresh(WebPageAccessibilityObject*);\n\n\n\nG_END_DECLS\n\n\n\n#endif\n\n#endif // WebPageAccessibilityObject_h\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/WebPage/atk/WebPageAccessibilityObject.h", "rank": 53, "score": 182998.3115050139 }, { "content": "struct _WebPageAccessibilityObjectClass {\n\n AtkPlugClass parentClass;\n\n};\n\n\n\nGType web_page_accessibility_object_get_type();\n\n\n\nWebPageAccessibilityObject* webPageAccessibilityObjectNew(WebKit::WebPage*);\n\n\n\nvoid webPageAccessibilityObjectRefresh(WebPageAccessibilityObject*);\n\n\n\nG_END_DECLS\n\n\n\n#endif\n\n#endif // WebPageAccessibilityObject_h\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/WebPage/atk/WebPageAccessibilityObject.h", "rank": 54, "score": 182998.3115050139 }, { "content": "struct _WebKitFramePrivate {\n\n RefPtr<WebFrame> webFrame;\n\n\n\n CString uri;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitFrame, webkit_frame, G_TYPE_OBJECT)\n\n\n\nstatic void webkit_frame_class_init(WebKitFrameClass*)\n\n{\n\n}\n\n\n\nWebKitFrame* webkitFrameCreate(WebFrame* webFrame)\n\n{\n\n WebKitFrame* frame = WEBKIT_FRAME(g_object_new(WEBKIT_TYPE_FRAME, NULL));\n\n frame->priv->webFrame = webFrame;\n\n return frame;\n\n}\n\n\n\nWebFrame* webkitFrameGetWebFrame(WebKitFrame* frame)\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp", "rank": 55, "score": 182893.51636434908 }, { "content": "struct _WebKitFramePrivate {\n\n RefPtr<WebFrame> webFrame;\n\n\n\n CString uri;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitFrame, webkit_frame, G_TYPE_OBJECT)\n\n\n\nstatic void webkit_frame_class_init(WebKitFrameClass*)\n\n{\n\n}\n\n\n\nWebKitFrame* webkitFrameCreate(WebFrame* webFrame)\n\n{\n\n WebKitFrame* frame = WEBKIT_FRAME(g_object_new(WEBKIT_TYPE_FRAME, NULL));\n\n frame->priv->webFrame = webFrame;\n\n return frame;\n\n}\n\n\n\nWebFrame* webkitFrameGetWebFrame(WebKitFrame* frame)\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp", "rank": 56, "score": 182893.51636434908 }, { "content": "struct NPObject;\n\n\n\nnamespace CoreIPC {\n", "file_path": "WebKit2-7534.57.7/WebKit2-7534.57.7/WebProcess/Plugins/Plugin.h", "rank": 57, "score": 182648.35154706272 }, { "content": "struct NPObject;\n\n\n\nnamespace IPC {\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/Plugins/Plugin.h", "rank": 58, "score": 182648.35154706272 }, { "content": "struct NPObject;\n\n\n\nnamespace IPC {\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/Plugins/Plugin.h", "rank": 59, "score": 182648.35154706272 }, { "content": "struct DOMObjectCacheData {\n\n DOMObjectCacheData(GObject* wrapper)\n\n : object(wrapper)\n\n , cacheReferences(1)\n\n {\n\n }\n\n\n\n void clearObject()\n\n {\n\n ASSERT(object);\n\n ASSERT(cacheReferences >= 1);\n\n ASSERT(object->ref_count >= 1);\n\n\n\n // Make sure we don't unref more than the references the object actually has. It can happen that user\n\n // unreffed a reference owned by the cache.\n\n cacheReferences = std::min(static_cast<unsigned>(object->ref_count), cacheReferences);\n\n GRefPtr<GObject> protect(object);\n\n do {\n\n g_object_unref(object);\n\n } while (--cacheReferences);\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/glib/DOM/DOMObjectCache.cpp", "rank": 60, "score": 181278.99671488197 }, { "content": "struct DOMObjectCacheData {\n\n DOMObjectCacheData(GObject* wrapper)\n\n : object(wrapper)\n\n , cacheReferences(1)\n\n {\n\n }\n\n\n\n void clearObject()\n\n {\n\n ASSERT(object);\n\n ASSERT(cacheReferences >= 1);\n\n ASSERT(object->ref_count >= 1);\n\n\n\n // Make sure we don't unref more than the references the object actually has. It can happen that user\n\n // unreffed a reference owned by the cache.\n\n cacheReferences = std::min(static_cast<unsigned>(object->ref_count), cacheReferences);\n\n GRefPtr<GObject> protect(object);\n\n do {\n\n g_object_unref(object);\n\n } while (--cacheReferences);\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/InjectedBundle/API/gtk/DOM/DOMObjectCache.cpp", "rank": 61, "score": 181278.99671488197 }, { "content": "class FrameInfo final : public ObjectImpl<Object::Type::FrameInfo> {\n\npublic:\n\n static Ref<FrameInfo> create(const WebKit::FrameInfoData&, WebKit::WebPageProxy*);\n\n static Ref<FrameInfo> create(const WebKit::WebFrameProxy&, const WebCore::SecurityOrigin&);\n\n virtual ~FrameInfo();\n\n\n\n bool isMainFrame() const { return m_isMainFrame; }\n\n const WebCore::ResourceRequest& request() const { return m_request; }\n\n SecurityOrigin& securityOrigin() { return m_securityOrigin.get(); }\n\n API::FrameHandle& handle() { return m_handle.get(); }\n\n WebKit::WebPageProxy* page() { return m_page.get(); }\n\n\n\n void clearPage();\n\n\n\nprivate:\n\n FrameInfo(const WebKit::FrameInfoData&, WebKit::WebPageProxy*);\n\n\n\n bool m_isMainFrame;\n\n WebCore::ResourceRequest m_request;\n\n Ref<SecurityOrigin> m_securityOrigin;\n\n Ref<FrameHandle> m_handle;\n\n RefPtr<WebKit::WebPageProxy> m_page;\n\n};\n\n\n\n} // namespace API\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/APIFrameInfo.h", "rank": 62, "score": 181011.2507989555 }, { "content": "class FrameInfo final : public ObjectImpl<Object::Type::FrameInfo> {\n\npublic:\n\n static Ref<FrameInfo> create(const WebKit::FrameInfoData&, WebKit::WebPageProxy*);\n\n static Ref<FrameInfo> create(const WebKit::WebFrameProxy&, const WebCore::SecurityOrigin&);\n\n virtual ~FrameInfo();\n\n\n\n bool isMainFrame() const { return m_isMainFrame; }\n\n const WebCore::ResourceRequest& request() const { return m_request; }\n\n SecurityOrigin& securityOrigin() { return m_securityOrigin.get(); }\n\n API::FrameHandle& handle() { return m_handle.get(); }\n\n WebKit::WebPageProxy* page() { return m_page.get(); }\n\n\n\n void clearPage();\n\n\n\nprivate:\n\n FrameInfo(const WebKit::FrameInfoData&, WebKit::WebPageProxy*);\n\n\n\n bool m_isMainFrame;\n\n WebCore::ResourceRequest m_request;\n\n Ref<SecurityOrigin> m_securityOrigin;\n\n Ref<FrameHandle> m_handle;\n\n RefPtr<WebKit::WebPageProxy> m_page;\n\n};\n\n\n\n} // namespace API\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/APIFrameInfo.h", "rank": 63, "score": 181011.2507989555 }, { "content": "struct static_const\n\n{\n\n static constexpr T value{};\n\n};\n\n\n\ntemplate<typename T>\n\nconstexpr T static_const<T>::value;\n\n} // namespace detail\n\n\n\n\n\n/// namespace to hold default `to_json` / `from_json` functions\n\nnamespace\n\n{\n\nconstexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value;\n\nconstexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value;\n\n}\n\n\n\n\n\n/*!\n\n@brief default JSONSerializer template argument\n\n\n\nThis serializer ignores the template arguments and uses ADL\n\n([argument-dependent lookup](http://en.cppreference.com/w/cpp/language/adl))\n\nfor serialization.\n\n*/\n\ntemplate<typename = void, typename = void>\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/NetworkProcess/capture/json.hpp", "rank": 64, "score": 180364.5358032924 }, { "content": "struct static_const\n\n{\n\n static constexpr T value{};\n\n};\n\n\n\ntemplate<typename T>\n\nconstexpr T static_const<T>::value;\n\n} // namespace detail\n\n\n\n\n\n/// namespace to hold default `to_json` / `from_json` functions\n\nnamespace\n\n{\n\nconstexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value;\n\nconstexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value;\n\n}\n\n\n\n\n\n/*!\n\n@brief default JSONSerializer template argument\n\n\n\nThis serializer ignores the template arguments and uses ADL\n\n([argument-dependent lookup](http://en.cppreference.com/w/cpp/language/adl))\n\nfor serialization.\n\n*/\n\ntemplate<typename = void, typename = void>\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/capture/json.hpp", "rank": 65, "score": 180364.5358032924 }, { "content": "struct NPObject;\n\ntypedef struct _NPVariant NPVariant;\n\ntypedef void* NPIdentifier;\n\n\n\nnamespace WebCore {\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/Plugins/PluginController.h", "rank": 66, "score": 180206.3315768327 }, { "content": "struct NPObject;\n\ntypedef struct _NPVariant NPVariant;\n\ntypedef void* NPIdentifier;\n\n\n\nnamespace WebCore {\n", "file_path": "WebKit2-7534.57.7/WebKit2-7534.57.7/WebProcess/Plugins/PluginController.h", "rank": 67, "score": 180206.3315768327 }, { "content": "struct NPObject;\n\ntypedef struct _NPVariant NPVariant;\n\ntypedef void* NPIdentifier;\n\n\n\nnamespace WTF {\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/Plugins/PluginController.h", "rank": 68, "score": 180206.3315768327 }, { "content": "struct WebsitePolicies;\n\n\n\ntypedef GenericCallback<API::Data*> DataCallback;\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/WebFrameProxy.h", "rank": 69, "score": 180115.78296502572 }, { "content": "void webkitWebResourceFailed(WebKitWebResource*, GError*);\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/glib/WebKitWebResourcePrivate.h", "rank": 70, "score": 180009.6950565758 }, { "content": "void webkitWebResourceFailed(WebKitWebResource*, GError*);\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/glib/WebKitWebResourcePrivate.h", "rank": 71, "score": 180009.69505657576 }, { "content": "void webkitWebResourceFinished(WebKitWebResource*);\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/glib/WebKitWebResourcePrivate.h", "rank": 72, "score": 180006.0070594159 }, { "content": "void webkitWebResourceFinished(WebKitWebResource*);\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/glib/WebKitWebResourcePrivate.h", "rank": 73, "score": 180006.0070594159 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/wpe/WebKitWebResource.h", "rank": 74, "score": 179983.15660416623 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/gtk/WebKitWebResource.h", "rank": 75, "score": 179983.15660416623 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/wpe/WebKitWebResource.h", "rank": 76, "score": 179983.15660416623 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/gtk/WebKitWebResource.h", "rank": 77, "score": 179983.15660416623 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h", "rank": 78, "score": 179849.01132961622 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h", "rank": 79, "score": 179849.01132961622 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h", "rank": 80, "score": 179849.01132961622 }, { "content": "WEBKIT_API const gchar *\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h", "rank": 81, "score": 179849.01132961622 }, { "content": "struct _WebKitURISchemeRequestPrivate {\n\n WebKitWebContext* webContext;\n\n LegacyCustomProtocolManagerProxy* manager;\n\n RefPtr<WebPageProxy> initiatingPage;\n\n uint64_t requestID;\n\n CString uri;\n\n GUniquePtr<SoupURI> soupURI;\n\n\n\n GRefPtr<GInputStream> stream;\n\n uint64_t streamLength;\n\n GRefPtr<GCancellable> cancellable;\n\n char readBuffer[gReadBufferSize];\n\n uint64_t bytesRead;\n\n CString mimeType;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitURISchemeRequest, webkit_uri_scheme_request, G_TYPE_OBJECT)\n\n\n\nstatic void webkit_uri_scheme_request_class_init(WebKitURISchemeRequestClass*)\n\n{\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/API/glib/WebKitURISchemeRequest.cpp", "rank": 82, "score": 179729.44327107133 }, { "content": "struct _WebKitURISchemeRequestPrivate {\n\n WebKitWebContext* webContext;\n\n LegacyCustomProtocolManagerProxy* manager;\n\n RefPtr<WebPageProxy> initiatingPage;\n\n uint64_t requestID;\n\n CString uri;\n\n GUniquePtr<SoupURI> soupURI;\n\n\n\n GRefPtr<GInputStream> stream;\n\n uint64_t streamLength;\n\n GRefPtr<GCancellable> cancellable;\n\n char readBuffer[gReadBufferSize];\n\n uint64_t bytesRead;\n\n CString mimeType;\n\n};\n\n\n\nWEBKIT_DEFINE_TYPE(WebKitURISchemeRequest, webkit_uri_scheme_request, G_TYPE_OBJECT)\n\n\n\nstatic void webkit_uri_scheme_request_class_init(WebKitURISchemeRequestClass*)\n\n{\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/API/glib/WebKitURISchemeRequest.cpp", "rank": 83, "score": 179729.44327107133 }, { "content": "struct NetworkResourceLoader::SynchronousLoadData {\n\n SynchronousLoadData(Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply&& reply)\n\n : delayedReply(WTFMove(reply))\n\n {\n\n ASSERT(delayedReply);\n\n }\n\n ResourceRequest currentRequest;\n\n Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply delayedReply;\n\n ResourceResponse response;\n\n ResourceError error;\n\n};\n\n\n\nstatic void sendReplyToSynchronousRequest(NetworkResourceLoader::SynchronousLoadData& data, const SharedBuffer* buffer)\n\n{\n\n ASSERT(data.delayedReply);\n\n ASSERT(!data.response.isNull() || !data.error.isNull());\n\n\n\n Vector<char> responseBuffer;\n\n if (buffer && buffer->size())\n\n responseBuffer.append(buffer->data(), buffer->size());\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/NetworkResourceLoader.cpp", "rank": 84, "score": 179364.39059192466 }, { "content": "struct NetworkResourceLoader::SynchronousLoadData {\n\n SynchronousLoadData(RefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>&& reply)\n\n : delayedReply(WTFMove(reply))\n\n {\n\n ASSERT(delayedReply);\n\n }\n\n ResourceRequest currentRequest;\n\n RefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply> delayedReply;\n\n ResourceResponse response;\n\n ResourceError error;\n\n};\n\n\n\nstatic void sendReplyToSynchronousRequest(NetworkResourceLoader::SynchronousLoadData& data, const SharedBuffer* buffer)\n\n{\n\n ASSERT(data.delayedReply);\n\n ASSERT(!data.response.isNull() || !data.error.isNull());\n\n\n\n Vector<char> responseBuffer;\n\n if (buffer && buffer->size())\n\n responseBuffer.append(buffer->data(), buffer->size());\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/NetworkProcess/NetworkResourceLoader.cpp", "rank": 85, "score": 179364.39059192466 }, { "content": "struct has_non_default_from_json\n\n{\n\n private:\n\n template <\n\n typename U,\n\n typename = enable_if_t<std::is_same<\n\n T, decltype(uncvref_t<U>::from_json(std::declval<BasicJsonType>()))>::value >>\n\n static int detect(U&&);\n\n static void detect(...);\n\n\n\n public:\n\n static constexpr bool value = std::is_integral<decltype(detect(\n\n std::declval<typename BasicJsonType::template json_serializer<T, void>>()))>::value;\n\n};\n\n\n\n// This trait checks if BasicJsonType::json_serializer<T>::to_json exists\n\ntemplate<typename BasicJsonType, typename T>\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/capture/json.hpp", "rank": 86, "score": 177997.2349152788 }, { "content": "struct has_non_default_from_json\n\n{\n\n private:\n\n template <\n\n typename U,\n\n typename = enable_if_t<std::is_same<\n\n T, decltype(uncvref_t<U>::from_json(std::declval<BasicJsonType>()))>::value >>\n\n static int detect(U&&);\n\n static void detect(...);\n\n\n\n public:\n\n static constexpr bool value = std::is_integral<decltype(detect(\n\n std::declval<typename BasicJsonType::template json_serializer<T, void>>()))>::value;\n\n};\n\n\n\n// This trait checks if BasicJsonType::json_serializer<T>::to_json exists\n\ntemplate<typename BasicJsonType, typename T>\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/NetworkProcess/capture/json.hpp", "rank": 87, "score": 177997.2349152788 }, { "content": "struct FinishedEvent;\n\n\n\nusing CaptureEvent = WTF::Variant<RequestSentEvent, ResponseReceivedEvent, RedirectReceivedEvent, RedirectSentEvent, DataReceivedEvent, FinishedEvent>;\n\nusing OptionalCaptureEvent = std::optional<CaptureEvent>;\n\nusing CaptureEvents = Vector<CaptureEvent>;\n\nusing CaptureClockType = WTF::MonotonicTime;\n\nusing CaptureTimeType = WTF::MonotonicTime;\n\nusing KeyValuePair = std::pair<String, String>;\n\nusing Headers = Vector<KeyValuePair>;\n\n\n\nstd::string eventToString(const CaptureEvent&);\n\nOptionalCaptureEvent stringToEvent(const char*);\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/capture/NetworkCaptureEvent.h", "rank": 88, "score": 177987.07685461658 }, { "content": "struct FinishedEvent;\n\n\n\nusing CaptureEvent = WTF::Variant<RequestSentEvent, ResponseReceivedEvent, RedirectReceivedEvent, RedirectSentEvent, DataReceivedEvent, FinishedEvent>;\n\nusing OptionalCaptureEvent = std::optional<CaptureEvent>;\n\nusing CaptureEvents = Vector<CaptureEvent>;\n\nusing CaptureClockType = WTF::MonotonicTime;\n\nusing CaptureTimeType = WTF::MonotonicTime;\n\nusing KeyValuePair = std::pair<String, String>;\n\nusing Headers = Vector<KeyValuePair>;\n\n\n\nstd::string eventToString(const CaptureEvent&);\n\nOptionalCaptureEvent stringToEvent(const char*);\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/NetworkProcess/capture/NetworkCaptureEvent.h", "rank": 89, "score": 177987.07685461658 }, { "content": "struct ResourceLoadStatistics;\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/Shared/WebCoreArgumentCoders.h", "rank": 90, "score": 177882.47535512177 }, { "content": "struct ResourceLoadStatistics;\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/Shared/WebCoreArgumentCoders.h", "rank": 91, "score": 177882.47535512177 }, { "content": "struct is_compatible_object_type\n\n{\n\n static auto constexpr value = is_compatible_object_type_impl <\n\n conjunction<negation<std::is_same<void, CompatibleObjectType>>,\n\n has_mapped_type<CompatibleObjectType>,\n\n has_key_type<CompatibleObjectType>>::value,\n\n typename BasicJsonType::object_t, CompatibleObjectType >::value;\n\n};\n\n\n\ntemplate<typename BasicJsonType, typename T>\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/NetworkProcess/capture/json.hpp", "rank": 92, "score": 177852.7179663259 }, { "content": "struct is_compatible_object_type\n\n{\n\n static auto constexpr value = is_compatible_object_type_impl <\n\n conjunction<negation<std::is_same<void, CompatibleObjectType>>,\n\n has_mapped_type<CompatibleObjectType>,\n\n has_key_type<CompatibleObjectType>>::value,\n\n typename BasicJsonType::object_t, CompatibleObjectType >::value;\n\n};\n\n\n\ntemplate<typename BasicJsonType, typename T>\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/NetworkProcess/capture/json.hpp", "rank": 93, "score": 177852.7179663259 }, { "content": "struct FrameInfoData;\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/WebPageProxy.h", "rank": 94, "score": 177763.8083814814 }, { "content": "struct FrameState;\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/LegacySessionStateCoding.h", "rank": 95, "score": 177763.8083814814 }, { "content": "struct WebsitePoliciesData;\n\n\n\ntypedef GenericCallback<API::Data*> DataCallback;\n\n\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/WebFrameProxy.h", "rank": 96, "score": 177763.8083814814 }, { "content": "struct FrameState;\n", "file_path": "WebKit2-7606.2.104.1.1/WebKit2-7606.2.104.1.1/UIProcess/LegacySessionStateCoding.h", "rank": 97, "score": 177763.8083814814 }, { "content": "struct FrameInfoData;\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/WebPageProxy.h", "rank": 98, "score": 177763.8083814814 }, { "content": "struct WebsitePolicies;\n\n\n", "file_path": "WebKit2-7604.1.38.0.7/WebKit2-7604.1.38.0.7/UIProcess/WebFrameListenerProxy.h", "rank": 99, "score": 177763.8083814814 } ]
C++
core/src/love/DrawDataFrame.hpp
castle-games/castle-client
7fb34759b164d8de1d83b43bc00ff200a5086e2e
#ifndef DrawDataFrame_hpp #define DrawDataFrame_hpp #define _USE_MATH_DEFINES #include <stdio.h> #include <functional> #include <memory> #include "GhostTypes.hpp" namespace love { class DrawData; struct DrawDataLayer; class DrawDataFrame { public: bool isLinked; PathDataList pathDataList; Bounds fillImageBounds; bool _graphicsNeedsReset = true; ToveGraphicsHolder *_graphics = NULL; DrawDataLayer *_parentLayer = NULL; image::ImageData *fillImageData = NULL; graphics::Image *fillImage = NULL; graphics::Canvas *pathsCanvas = NULL; std::optional<std::string> fillPng; std::optional<std::string> base64Png; inline static double nextRenderTime = 0; double lastRenderTime = 0; DrawDataFrame() = default; DrawDataFrame(bool isLinked_, DrawDataLayer *parentLayer_) : isLinked(isLinked_) , _parentLayer(parentLayer_) { fillImageBounds.maxX = 0; fillImageBounds.maxY = 0; fillImageBounds.minX = 0; fillImageBounds.minY = 0; } DrawDataFrame(const DrawDataFrame &other) = delete; ~DrawDataFrame() { releaseRenderData(); if (pathsCanvas) { pathsCanvas->release(); } } void releaseRenderData() { if (_graphics || fillImageData || fillImage) { std::printf("releasing %p\n", (void *)this); } if (_graphics) { delete _graphics; _graphics = nullptr; } if (fillImageData) { fillImageData->release(); fillImageData = nullptr; } if (fillImage) { fillImage->release(); fillImage = nullptr; } } void read(Archive::Reader &archive) { isLinked = archive.boolean("isLinked", false); archive.arr("pathDataList", [&]() { for (auto i = 0; i < archive.size(); i++) { std::shared_ptr<PathData> pathData = std::make_shared<PathData>(); archive.obj(i, *pathData); if (pathData->isValid()) { pathDataList.push_back(pathData); } } }); archive.obj("fillImageBounds", fillImageBounds); fillPng = archive.str("fillPng", ""); } void write(Archive::Writer &archive) { archive.boolean("isLinked", isLinked); archive.arr("pathDataList", [&]() { for (size_t i = 0; i < pathDataList.size(); i++) { if (pathDataList[i]->isValid()) { archive.obj(*pathDataList[i]); } } }); archive.obj("fillImageBounds", fillImageBounds); if (fillImageData) { love::filesystem::FileData *fileData = fillImageData->encode( love::image::FormatHandler::EncodedFormat::ENCODED_PNG, "Image.png", false); const char *fileDataString = (const char *)fileData->getData(); size_t fileDataSize = fileData->getSize(); size_t dstlen = 0; char *result = data::encode(data::ENCODE_BASE64, fileDataString, fileDataSize, dstlen, 0); archive.str("fillPng", std::string(result)); delete result; fileData->release(); } else if (fillPng && fillPng->length() > 0) { archive.str("fillPng", *fillPng); } } static graphics::Canvas *newCanvas(int width, int height); static love::image::ImageData *newImageData(graphics::Canvas *canvas); static void renderToCanvas(graphics::Canvas *canvas, const std::function<void()> &lambda); static std::string encodeBase64Png(love::image::ImageData *imageData); static std::string encodeBase64Png(graphics::Canvas *canvas); bool arePathDatasMergable(PathData pd1, PathData pd2); float round(float num, int numDecimalPlaces); std::vector<float> roundFloatArray(std::vector<float> a); void cleanUpPaths(); Bounds getPathDataBounds(std::optional<Bounds> bounds); Bounds getPathDataBoundsInPixelCoordinates(); Bounds getFillImageBoundsInPathCoordinates(); void resetGraphics(); ToveGraphicsHolder *graphics(); void render(); void renderFill(); std::optional<std::string> renderPreviewPng(int size); static graphics::Image *imageDataToImage(image::ImageData *); void resizeFillImageDataToPathBounds(); graphics::Image *getFillImage(); void updateFillImageWithFillImageData(); void compressFillCanvas(); bool floodFill(float x, float y, Colorf color); bool floodClear(float x, float y, float radius); void resetFill(); void updatePathsCanvas(); void deserializeFill(); image::ImageData *canvasToImageData(graphics::Canvas *canvas); DrawDataLayer *parentLayer() { return _parentLayer; } void setParentLayer(DrawDataLayer *l) { _parentLayer = l; } }; typedef std::string DrawDataLayerId; struct DrawDataLayer { std::string title; DrawDataLayerId id; bool isVisible = true; bool isBitmap = false; DrawData *_parent = NULL; std::vector<std::shared_ptr<DrawDataFrame>> frames; DrawDataLayer() = default; DrawDataLayer(std::string title_, DrawDataLayerId id_) : title(title_) , id(id_) { } void read(Archive::Reader &archive) { title = archive.str("title", ""); id = archive.str("id", ""); isVisible = archive.boolean("isVisible", true); isBitmap = archive.boolean("isBitmap", false); archive.arr("frames", [&]() { for (auto i = 0; i < archive.size(); i++) { auto frame = std::make_shared<DrawDataFrame>(); archive.obj(i, *frame); frames.push_back(std::move(frame)); } }); } void write(Archive::Writer &archive) { archive.str("title", title); archive.str("id", id); archive.boolean("isVisible", isVisible); archive.boolean("isBitmap", isBitmap); archive.arr("frames", [&]() { for (size_t i = 0; i < frames.size(); i++) { archive.obj(*frames[i]); } }); } DrawData *parent() { return _parent; } void setParent(DrawData *d) { _parent = d; for (auto &frame : frames) { frame->setParentLayer(this); } } }; } #endif
#ifndef DrawDataFrame_hpp #define DrawDataFrame_hpp #define _USE_MATH_DEFINES #include <stdio.h> #include <functional> #include <memory> #include "GhostTypes.hpp" namespace love { class DrawData; struct DrawDataLayer; class DrawDataFrame { public: bool isLinked; PathDataList pathDataList; Bounds fillImageBounds; bool _graphicsNeedsReset = true; ToveGraphicsHolder *_graphics = NULL; DrawDataLayer *_parentLayer = NULL; image::ImageData *fillImageData = NULL; graphics::Image *fillImage = NULL; graphics::Canvas *pathsCanvas = NULL; std::optional<std::string> fillPng; std::optional<std::string> base64Png; inline static double nextRenderTime = 0; double lastRenderTime = 0; DrawDataFrame() = default; DrawDataFrame(bool isLinked_, DrawDataLayer *parentLayer_) : isLinked(isLinked_) , _parentLayer(parentLayer_) { fillImageBounds.maxX = 0; fillImageBounds.maxY = 0; fillImageBounds.minX = 0; fillImageBounds.minY = 0; } DrawDataFrame(const DrawDataFrame &other) = delete; ~DrawDataFrame() { releaseRenderData(); if (pathsCanvas) { pathsCanvas->release(); } } void releaseRenderData() { if (_graphics || fillImageData || fillImage) { std::printf("releasing %p\n", (void *)this); } if (_graphics) { delete _graphics; _graphics = nullptr; } if (fillImageData) { fillImageData->release(); fillImageData = nullptr; } if (fillImage) { fillImage->release(); fillImage = nullptr; } } void read(Archive::Reader &archive) { isLinked = archive.boolean("isLinked", false); archive.arr("pathDataList", [&]() { for (auto i = 0; i < archive.size(); i++) { std::shared_ptr<PathData> pathData = std::make_shared<PathData>(); archive.obj(i, *pathData); if (pathData->isValid()) { pathDataList.push_back(pathData); } } }); archive.obj("fillImageBounds", fillImageBounds); fillPng = archive.str("fillPng", ""); } void write(Archive::Writer &archive) { archive.boolean("isLinked", isLinked); archive.arr("pathDataList", [&]() { for (size_t i = 0; i < pathDataList.size(); i++) { if (pathDataList[i]->isValid()) { archive.obj(*pathDataList[i]); } } }); archive.obj("fillImageBounds", fillImageBounds); if (fillImageData) {
const char *fileDataString = (const char *)fileData->getData(); size_t fileDataSize = fileData->getSize(); size_t dstlen = 0; char *result = data::encode(data::ENCODE_BASE64, fileDataString, fileDataSize, dstlen, 0); archive.str("fillPng", std::string(result)); delete result; fileData->release(); } else if (fillPng && fillPng->length() > 0) { archive.str("fillPng", *fillPng); } } static graphics::Canvas *newCanvas(int width, int height); static love::image::ImageData *newImageData(graphics::Canvas *canvas); static void renderToCanvas(graphics::Canvas *canvas, const std::function<void()> &lambda); static std::string encodeBase64Png(love::image::ImageData *imageData); static std::string encodeBase64Png(graphics::Canvas *canvas); bool arePathDatasMergable(PathData pd1, PathData pd2); float round(float num, int numDecimalPlaces); std::vector<float> roundFloatArray(std::vector<float> a); void cleanUpPaths(); Bounds getPathDataBounds(std::optional<Bounds> bounds); Bounds getPathDataBoundsInPixelCoordinates(); Bounds getFillImageBoundsInPathCoordinates(); void resetGraphics(); ToveGraphicsHolder *graphics(); void render(); void renderFill(); std::optional<std::string> renderPreviewPng(int size); static graphics::Image *imageDataToImage(image::ImageData *); void resizeFillImageDataToPathBounds(); graphics::Image *getFillImage(); void updateFillImageWithFillImageData(); void compressFillCanvas(); bool floodFill(float x, float y, Colorf color); bool floodClear(float x, float y, float radius); void resetFill(); void updatePathsCanvas(); void deserializeFill(); image::ImageData *canvasToImageData(graphics::Canvas *canvas); DrawDataLayer *parentLayer() { return _parentLayer; } void setParentLayer(DrawDataLayer *l) { _parentLayer = l; } }; typedef std::string DrawDataLayerId; struct DrawDataLayer { std::string title; DrawDataLayerId id; bool isVisible = true; bool isBitmap = false; DrawData *_parent = NULL; std::vector<std::shared_ptr<DrawDataFrame>> frames; DrawDataLayer() = default; DrawDataLayer(std::string title_, DrawDataLayerId id_) : title(title_) , id(id_) { } void read(Archive::Reader &archive) { title = archive.str("title", ""); id = archive.str("id", ""); isVisible = archive.boolean("isVisible", true); isBitmap = archive.boolean("isBitmap", false); archive.arr("frames", [&]() { for (auto i = 0; i < archive.size(); i++) { auto frame = std::make_shared<DrawDataFrame>(); archive.obj(i, *frame); frames.push_back(std::move(frame)); } }); } void write(Archive::Writer &archive) { archive.str("title", title); archive.str("id", id); archive.boolean("isVisible", isVisible); archive.boolean("isBitmap", isBitmap); archive.arr("frames", [&]() { for (size_t i = 0; i < frames.size(); i++) { archive.obj(*frames[i]); } }); } DrawData *parent() { return _parent; } void setParent(DrawData *d) { _parent = d; for (auto &frame : frames) { frame->setParentLayer(this); } } }; } #endif
love::filesystem::FileData *fileData = fillImageData->encode( love::image::FormatHandler::EncodedFormat::ENCODED_PNG, "Image.png", false);
assignment_statement
[]
C++
plugins/CleverbotPlugin/CleverbotPlugin/CleverbotPlugin.cpp
daemon/monkeybot
50bf65674daefa12bfc002771243360bb1d07481
#include "api/Api.h" #include "plugin/Plugin.h" #include "CleverbotHTTP.h" #include <algorithm> #include <future> #include <thread> #include <queue> #include <iostream> #include <string> #include <random> #include <atomic> #include <chrono> #include <curl/curl.h> namespace { const long Timeout = 12000; const ChatMessage::Type ChatType = ChatMessage::Type::Public; const int Channel = 2; const double BaseRespondChance = 0.1; } namespace Random { std::random_device dev; std::mt19937 gen(dev()); double GetReal() { std::uniform_real_distribution<double> dist(0, 1); return dist(gen); } } std::string strtolower(std::string str) { std::transform(str.begin(), str.end(), str.begin(), tolower); return str; } class CleverbotQueue { private: std::shared_ptr<CleverbotHTTP> m_Cleverbot; std::shared_ptr<std::thread> m_Thread; std::queue<std::string> m_Queue; std::mutex m_Mutex; api::Bot* m_Bot; std::atomic<bool> m_Running; ChatMessage::Type m_Type; int m_Channel; void StripEntities(std::string& str) { using namespace std; while (true) { size_t begin = str.find("&"); size_t end = str.find(";"); if (begin == string::npos || end == string::npos || begin >= end) return; str.erase(begin, end - begin + 1); } } bool Contains(std::string str, const std::string& find) { std::string find_lower = strtolower(find); str = strtolower(str); return str.find(find_lower) != std::string::npos; } std::string EraseName(std::string thought) { std::string bot_name = strtolower(m_Bot->GetName()); thought = strtolower(thought); if (thought.compare(bot_name) == 0) return thought; std::size_t pos = thought.find(bot_name); if (pos != std::string::npos) thought.erase(pos, bot_name.length()); if (thought.length() > pos && thought[pos] == ' ') thought.erase(pos, 1); return thought; } void HandleResponse(std::string response) { static const std::vector<std::string> filter = { "clever", "ios app" }; std::cout << "Response: " << response << std::endl; if (response.length() > 0) { if (response.at(0) == '*') response.insert(response.begin(), '.'); for (const std::string& str : filter) if (Contains(response, str)) return; StripEntities(response); std::string to_send; switch (m_Type) { case ChatMessage::Type::Channel: to_send = ";"; if (Channel > 1) to_send += std::to_string(m_Channel) + ";"; break; case ChatMessage::Type::Team: to_send = "'"; break; } to_send += response; m_Bot->SendMessage(to_send); } } void Run() { m_Running = true; while (m_Running) { if (!m_Cleverbot) m_Cleverbot = std::make_shared<CleverbotHTTP>(Timeout); m_Mutex.lock(); if (m_Queue.empty()) { m_Mutex.unlock(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); continue; } std::string thought = m_Queue.front(); m_Queue.pop(); m_Mutex.unlock(); thought = EraseName(thought); std::cout << "Thinking: " << thought << std::endl; std::future<std::string> future = std::async(std::launch::async, std::bind(&CleverbotHTTP::Think, m_Cleverbot.get(), thought)); if (future.wait_for(std::chrono::milliseconds(Timeout)) != std::future_status::ready) { std::cout << "Timeout." << std::endl; continue; } HandleResponse(future.get()); } } public: CleverbotQueue(api::Bot* bot, ChatMessage::Type type, int channel) : m_Bot(bot), m_Queue(), m_Mutex(), m_Type(type), m_Channel(channel) { m_Thread = std::make_shared<std::thread>(&CleverbotQueue::Run, this); } ~CleverbotQueue() { m_Running = false; m_Thread->join(); } void Enqueue(const std::string& str) { std::lock_guard<std::mutex> lock(m_Mutex); if (m_Queue.size() < 2) m_Queue.push(str); } }; class CleverbotPlugin : public Plugin { private: typedef std::chrono::system_clock::rep Timestamp; api::Bot* m_Bot; std::shared_ptr<CleverbotQueue> m_CBQ; bool m_LastReference; struct Message { std::string player; std::string message; Message(ChatMessage* mesg) : player(mesg->GetPlayer()), message(mesg->GetMessage()) { } }; struct StoredMessage { Message message; Timestamp timestamp; StoredMessage(ChatMessage* mesg, Timestamp timestamp) : message(mesg), timestamp(timestamp) { } }; typedef std::deque<StoredMessage> ChatQueue; ChatQueue m_ChatQueue; public: CleverbotPlugin(api::Bot* bot) : m_Bot(bot), m_LastReference(false) { } int OnCreate() { m_CBQ = std::make_shared<CleverbotQueue>(m_Bot, ChatType, Channel); std::string version = m_Bot->GetVersion().GetString(); std::cout << "Cleverbot loaded for monkeybot version " << version << std::endl; return 0; } Timestamp GetTime() const { using namespace std::chrono; auto duration = system_clock::now().time_since_epoch(); return duration_cast<milliseconds>(duration).count(); } int OnUpdate(unsigned long dt) { return 0; } int OnDestroy() { return 0; } void PurgeMessages() { const Timestamp AliveTime = 1000 * 60 * 3; const Timestamp timestamp = GetTime(); while (!m_ChatQueue.empty()) { StoredMessage message = m_ChatQueue.front(); if (timestamp - message.timestamp < AliveTime) break; m_ChatQueue.pop_front(); } } std::size_t GetReferenceCount() const { ChatQueue::const_iterator iter = m_ChatQueue.begin(); std::string name = strtolower(m_Bot->GetName()); std::size_t references = 0; while (iter != m_ChatQueue.end()) { std::string message = strtolower(iter->message.message); if (message.find(name) != std::string::npos) ++references; ++iter; } return references; } std::size_t GetChatterCount() const { std::size_t chatters = m_ChatQueue.size(); return chatters; } double GetRespondChance() const { std::size_t chatters = GetChatterCount(); if (chatters <= 1 || m_LastReference) return 1.0; std::size_t references = GetReferenceCount(); return BaseRespondChance + (1.0 / (chatters * 1.75)) + ((references / (double)chatters) * .50); } void OnChatMessage(ChatMessage* mesg) { using namespace std; if (mesg->GetType() != ChatType) return; if (ChatType == ChatMessage::Type::Channel && mesg->GetChannel() != Channel) return; if (mesg->GetPlayer().compare(m_Bot->GetName()) == 0) return; PurgeMessages(); string message = strtolower(mesg->GetMessage()); string name = strtolower(m_Bot->GetName()); double respond_chance = GetRespondChance(); bool contains_name = message.find(name) != string::npos; StoredMessage stored(mesg, GetTime()); bool push = m_ChatQueue.empty() || (!m_ChatQueue.empty() && m_ChatQueue.back().message.player.compare(mesg->GetPlayer()) != 0); if (push) m_ChatQueue.push_back(stored); std::cout << "Chatters: " << GetChatterCount() << " References: " << GetReferenceCount() << " Respond Chance: " << respond_chance << std::endl; if (contains_name || Random::GetReal() <= respond_chance) m_CBQ->Enqueue(mesg->GetMessage()); m_LastReference = contains_name; } }; extern "C" { PLUGIN_FUNC Plugin* CreatePlugin(api::Bot* bot) { curl_global_init(CURL_GLOBAL_ALL); return new CleverbotPlugin(bot); } PLUGIN_FUNC void DestroyPlugin(Plugin* plugin) { delete plugin; curl_global_cleanup(); } PLUGIN_FUNC const char* GetPluginName() { return "CleverbotPlugin"; } }
#include "api/Api.h" #include "plugin/Plugin.h" #include "CleverbotHTTP.h" #include <algorithm> #include <future> #include <thread> #include <queue> #include <iostream> #include <string> #include <random> #include <atomic> #include <chrono> #include <curl/curl.h> namespace { const long Timeout = 12000; const ChatMessage::Type ChatType = ChatMessage::Type::Public; const int Channel = 2; const double BaseRespondChance = 0.1; } namespace Random { std::random_device dev; std::mt19937 gen(dev()); double GetReal() { std::uniform_real_distribution<double> dist(0, 1); return dist(gen); } } std::string strtolower(std::string str) { std::transform(str.begin(), str.end(), str.begin(), tolower); return str; } class CleverbotQueue { private: std::shared_ptr<CleverbotHTTP> m_Cleverbot; std::shared_ptr<std::thread> m_Thread; std::queue<std::string> m_Queue; std::mutex m_Mutex; api::Bot* m_Bot; std::atomic<bool> m_Running; ChatMessage::Type m_Type; int m_Channel;
bool Contains(std::string str, const std::string& find) { std::string find_lower = strtolower(find); str = strtolower(str); return str.find(find_lower) != std::string::npos; } std::string EraseName(std::string thought) { std::string bot_name = strtolower(m_Bot->GetName()); thought = strtolower(thought); if (thought.compare(bot_name) == 0) return thought; std::size_t pos = thought.find(bot_name); if (pos != std::string::npos) thought.erase(pos, bot_name.length()); if (thought.length() > pos && thought[pos] == ' ') thought.erase(pos, 1); return thought; } void HandleResponse(std::string response) { static const std::vector<std::string> filter = { "clever", "ios app" }; std::cout << "Response: " << response << std::endl; if (response.length() > 0) { if (response.at(0) == '*') response.insert(response.begin(), '.'); for (const std::string& str : filter) if (Contains(response, str)) return; StripEntities(response); std::string to_send; switch (m_Type) { case ChatMessage::Type::Channel: to_send = ";"; if (Channel > 1) to_send += std::to_string(m_Channel) + ";"; break; case ChatMessage::Type::Team: to_send = "'"; break; } to_send += response; m_Bot->SendMessage(to_send); } } void Run() { m_Running = true; while (m_Running) { if (!m_Cleverbot) m_Cleverbot = std::make_shared<CleverbotHTTP>(Timeout); m_Mutex.lock(); if (m_Queue.empty()) { m_Mutex.unlock(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); continue; } std::string thought = m_Queue.front(); m_Queue.pop(); m_Mutex.unlock(); thought = EraseName(thought); std::cout << "Thinking: " << thought << std::endl; std::future<std::string> future = std::async(std::launch::async, std::bind(&CleverbotHTTP::Think, m_Cleverbot.get(), thought)); if (future.wait_for(std::chrono::milliseconds(Timeout)) != std::future_status::ready) { std::cout << "Timeout." << std::endl; continue; } HandleResponse(future.get()); } } public: CleverbotQueue(api::Bot* bot, ChatMessage::Type type, int channel) : m_Bot(bot), m_Queue(), m_Mutex(), m_Type(type), m_Channel(channel) { m_Thread = std::make_shared<std::thread>(&CleverbotQueue::Run, this); } ~CleverbotQueue() { m_Running = false; m_Thread->join(); } void Enqueue(const std::string& str) { std::lock_guard<std::mutex> lock(m_Mutex); if (m_Queue.size() < 2) m_Queue.push(str); } }; class CleverbotPlugin : public Plugin { private: typedef std::chrono::system_clock::rep Timestamp; api::Bot* m_Bot; std::shared_ptr<CleverbotQueue> m_CBQ; bool m_LastReference; struct Message { std::string player; std::string message; Message(ChatMessage* mesg) : player(mesg->GetPlayer()), message(mesg->GetMessage()) { } }; struct StoredMessage { Message message; Timestamp timestamp; StoredMessage(ChatMessage* mesg, Timestamp timestamp) : message(mesg), timestamp(timestamp) { } }; typedef std::deque<StoredMessage> ChatQueue; ChatQueue m_ChatQueue; public: CleverbotPlugin(api::Bot* bot) : m_Bot(bot), m_LastReference(false) { } int OnCreate() { m_CBQ = std::make_shared<CleverbotQueue>(m_Bot, ChatType, Channel); std::string version = m_Bot->GetVersion().GetString(); std::cout << "Cleverbot loaded for monkeybot version " << version << std::endl; return 0; } Timestamp GetTime() const { using namespace std::chrono; auto duration = system_clock::now().time_since_epoch(); return duration_cast<milliseconds>(duration).count(); } int OnUpdate(unsigned long dt) { return 0; } int OnDestroy() { return 0; } void PurgeMessages() { const Timestamp AliveTime = 1000 * 60 * 3; const Timestamp timestamp = GetTime(); while (!m_ChatQueue.empty()) { StoredMessage message = m_ChatQueue.front(); if (timestamp - message.timestamp < AliveTime) break; m_ChatQueue.pop_front(); } } std::size_t GetReferenceCount() const { ChatQueue::const_iterator iter = m_ChatQueue.begin(); std::string name = strtolower(m_Bot->GetName()); std::size_t references = 0; while (iter != m_ChatQueue.end()) { std::string message = strtolower(iter->message.message); if (message.find(name) != std::string::npos) ++references; ++iter; } return references; } std::size_t GetChatterCount() const { std::size_t chatters = m_ChatQueue.size(); return chatters; } double GetRespondChance() const { std::size_t chatters = GetChatterCount(); if (chatters <= 1 || m_LastReference) return 1.0; std::size_t references = GetReferenceCount(); return BaseRespondChance + (1.0 / (chatters * 1.75)) + ((references / (double)chatters) * .50); } void OnChatMessage(ChatMessage* mesg) { using namespace std; if (mesg->GetType() != ChatType) return; if (ChatType == ChatMessage::Type::Channel && mesg->GetChannel() != Channel) return; if (mesg->GetPlayer().compare(m_Bot->GetName()) == 0) return; PurgeMessages(); string message = strtolower(mesg->GetMessage()); string name = strtolower(m_Bot->GetName()); double respond_chance = GetRespondChance(); bool contains_name = message.find(name) != string::npos; StoredMessage stored(mesg, GetTime()); bool push = m_ChatQueue.empty() || (!m_ChatQueue.empty() && m_ChatQueue.back().message.player.compare(mesg->GetPlayer()) != 0); if (push) m_ChatQueue.push_back(stored); std::cout << "Chatters: " << GetChatterCount() << " References: " << GetReferenceCount() << " Respond Chance: " << respond_chance << std::endl; if (contains_name || Random::GetReal() <= respond_chance) m_CBQ->Enqueue(mesg->GetMessage()); m_LastReference = contains_name; } }; extern "C" { PLUGIN_FUNC Plugin* CreatePlugin(api::Bot* bot) { curl_global_init(CURL_GLOBAL_ALL); return new CleverbotPlugin(bot); } PLUGIN_FUNC void DestroyPlugin(Plugin* plugin) { delete plugin; curl_global_cleanup(); } PLUGIN_FUNC const char* GetPluginName() { return "CleverbotPlugin"; } }
void StripEntities(std::string& str) { using namespace std; while (true) { size_t begin = str.find("&"); size_t end = str.find(";"); if (begin == string::npos || end == string::npos || begin >= end) return; str.erase(begin, end - begin + 1); } }
function_block-full_function
[ { "content": "class int_generator {\n\n public:\n\n typedef typename concurrency::scoped_lock_type scoped_lock_type;\n\n typedef typename concurrency::mutex_type mutex_type;\n\n\n\n /// constructor\n\n //mac TODO: figure out if signed types present a range problem\n\n int_generator() {}\n\n\n\n /// advances the engine's state and returns the generated value\n\n int_type operator()() {\n\n scoped_lock_type guard(m_lock);\n\n return m_dis(m_rng);\n\n }\n\n private:\n\n\n\n\n\n lib::random_device m_rng;\n\n lib::uniform_int_distribution<int_type> m_dis;\n\n\n\n mutex_type m_lock;\n\n};\n\n\n\n} // namespace random_device\n\n} // namespace random\n\n} // namespace websocketpp\n\n\n\n#endif //WEBSOCKETPP_RANDOM_RANDOM_DEVICE_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/random/random_device.hpp", "rank": 0, "score": 200667.4710801523 }, { "content": "class int_generator {\n\n public:\n\n int_generator() {}\n\n\n\n /// advances the engine's state and returns the generated value\n\n int_type operator()() {\n\n return 0;\n\n }\n\n};\n\n\n\n} // namespace none\n\n} // namespace random\n\n} // namespace websocketpp\n\n\n\n#endif //WEBSOCKETPP_RANDOM_NONE_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/random/none.hpp", "rank": 1, "score": 192258.2632730718 }, { "content": "#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n class CZString {\n\n public:\n\n enum DuplicationPolicy {\n\n noDuplication = 0,\n\n duplicate,\n\n duplicateOnCopy\n\n };\n\n CZString(ArrayIndex index);\n\n CZString(const char* cstr, DuplicationPolicy allocate);\n\n CZString(const CZString& other);\n\n ~CZString();\n\n CZString &operator=(const CZString &other);\n\n bool operator<(const CZString& other) const;\n\n bool operator==(const CZString& other) const;\n\n ArrayIndex index() const;\n\n const char* c_str() const;\n\n bool isStaticString() const;\n\n\n\n private:\n\n void swap(CZString& other);\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 2, "score": 165176.6196584789 }, { "content": "class StaticString;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 3, "score": 165176.6196584789 }, { "content": "class ValueConstIterator;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 4, "score": 161184.40451268633 }, { "content": "class JSON_API StaticString {\n\npublic:\n\n explicit StaticString(const char* czstring) : str_(czstring) {}\n\n\n\n operator const char*() const { return str_; }\n\n\n\n const char* c_str() const { return str_; }\n\n\n\nprivate:\n\n const char* str_;\n\n};\n\n\n\n/** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n\n *\n\n * This class is a discriminated union wrapper that can represents a:\n\n * - signed integer [range: Value::minInt - Value::maxInt]\n\n * - unsigned integer (range: 0 - Value::maxUInt)\n\n * - double\n\n * - UTF-8 string\n\n * - boolean\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 5, "score": 152963.75982878596 }, { "content": " enum class Type { Public, Private, Team, Channel, Other, Arena };\n\n\n\nprivate:\n\n std::string m_Message;\n\n std::string m_Player;\n\n Type m_Type;\n\n int m_Channel;\n\n\n\npublic:\n\n ChatMessage() : m_Type(Type::Other), m_Channel(0) { }\n\n\n\n const std::string& GetMessage() const { return m_Message; }\n\n const std::string& GetPlayer() const { return m_Player; }\n\n Type GetType() const { return m_Type; }\n\n int GetChannel() const { return m_Channel; }\n\n\n\n void SetMessage(const std::string& mesg) { m_Message = mesg; }\n\n void SetPlayer(const std::string& player) { m_Player = player; }\n\n void SetType(Type t) { m_Type = t; }\n\n void SetChannel(int channel) { m_Channel = channel; }\n\n};\n\n\n\n#endif\n", "file_path": "screenbot/Messages/ChatMessage.h", "rank": 6, "score": 150688.69805586388 }, { "content": "class endpoint {\n\npublic:\n\n /// Type of this endpoint transport component\n\n typedef endpoint type;\n\n /// Type of a pointer to this endpoint transport component\n\n typedef lib::shared_ptr<type> ptr;\n\n\n\n /// Type of this endpoint's concurrency policy\n\n typedef typename config::concurrency_type concurrency_type;\n\n /// Type of this endpoint's error logging policy\n\n typedef typename config::elog_type elog_type;\n\n /// Type of this endpoint's access logging policy\n\n typedef typename config::alog_type alog_type;\n\n\n\n /// Type of this endpoint transport component's associated connection\n\n /// transport component.\n\n typedef iostream::connection<config> transport_con_type;\n\n /// Type of a shared pointer to this endpoint transport component's\n\n /// associated connection transport component\n\n typedef typename transport_con_type::ptr transport_con_ptr;\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/iostream/endpoint.hpp", "rank": 7, "score": 150372.2063708805 }, { "content": "class MessageQueue {\n\nprivate:\n\n std::list<MessageDispatcher*> m_Dispatchers;\n\n\n\n MessageQueue() { }\n\n ~MessageQueue() { }\n\n\n\npublic:\n\n static MessageQueue& GetInstance();\n\n void RegisterDispatcher(MessageDispatcher* dispatcher);\n\n void Dispatch();\n\n void Discard();\n\n void Reset();\n\n\n\n template <class T>\n\n void PushMessage(T* mesg) {\n\n MessageDispatcherImpl<T>::GetInstance().PushMessage(mesg);\n\n }\n\n};\n\n\n\n#define MQueue MessageQueue::GetInstance()\n\n\n\n#endif\n", "file_path": "screenbot/MessageQueue.h", "rank": 8, "score": 138029.6531354267 }, { "content": "class JSON_API ValueConstIterator : public ValueIteratorBase {\n\n friend class Value;\n\n\n\npublic:\n\n typedef const Value value_type;\n\n typedef unsigned int size_t;\n\n typedef int difference_type;\n\n typedef const Value& reference;\n\n typedef const Value* pointer;\n\n typedef ValueConstIterator SelfType;\n\n\n\n ValueConstIterator();\n\n\n\nprivate:\n\n/*! \\internal Use by Value to create an iterator.\n\n */\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n explicit ValueConstIterator(const Value::ObjectValues::iterator& current);\n\n#else\n\n ValueConstIterator(const ValueInternalArray::IteratorState& state);\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 9, "score": 131083.60647883028 }, { "content": "class PriorityQueue {\n\nprivate:\n\n Container m_Container;\n\n Compare m_Comp;\n\n\n\npublic:\n\n void Push(T item) {\n\n m_Container.push_back(item);\n\n std::push_heap(m_Container.begin(), m_Container.end(), m_Comp);\n\n }\n\n\n\n T Pop() {\n\n T item = m_Container.front();\n\n std::pop_heap(m_Container.begin(), m_Container.end(), m_Comp);\n\n m_Container.pop_back();\n\n return item;\n\n }\n\n\n\n void Update() {\n\n std::make_heap(m_Container.begin(), m_Container.end(), m_Comp);\n\n }\n\n\n\n bool Empty() const { return m_Container.empty(); }\n\n};\n\n\n", "file_path": "screenbot/Pathing.h", "rank": 10, "score": 129940.70778106082 }, { "content": "class Message {\n\npublic:\n\n virtual ~Message() { }\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "screenbot/MessageQueue.h", "rank": 11, "score": 129940.70778106082 }, { "content": "/// iostream transport error category\n\nclass category : public lib::error_category {\n\n public:\n\n category() {}\n\n\n\n char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {\n\n return \"websocketpp.transport.iostream\";\n\n }\n\n\n\n std::string message(int value) const {\n\n switch(value) {\n\n case general:\n\n return \"Generic iostream transport policy error\";\n\n case invalid_num_bytes:\n\n return \"async_read_at_least call requested more bytes than buffer can store\";\n\n case double_read:\n\n return \"Async read already in progress\";\n\n case output_stream_required:\n\n return \"An output stream to be set before async_write can be used\";\n\n case bad_stream:\n\n return \"A stream operation returned ios::bad\";\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/iostream/base.hpp", "rank": 12, "score": 128252.84917112062 }, { "content": "class MessageDispatcher {\n\npublic:\n\n virtual void Dispatch() = 0;\n\n virtual void Discard() = 0;\n\n virtual void Reset() = 0;\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "screenbot/MessageQueue.h", "rank": 13, "score": 126802.3029050569 }, { "content": "class MessageHandler {\n\nprotected:\n\n MessageHandler() {\n\n MessageDispatcherImpl<T>::GetInstance().RegisterHandler(this);\n\n }\n\n\n\npublic:\n\n virtual ~MessageHandler() {\n\n MessageDispatcherImpl<T>::GetInstance().UnregisterHandler(this);\n\n }\n\n virtual void HandleMessage(T* message) = 0;\n\n};\n\n\n", "file_path": "screenbot/MessageQueue.h", "rank": 14, "score": 126802.3029050569 }, { "content": "class MessageDispatcherImpl;\n\n\n", "file_path": "screenbot/MessageQueue.h", "rank": 15, "score": 123856.36037824201 }, { "content": "class Value;\n\n\n\n/**\n\n\n\nUsage:\n\n\\code\n\n using namespace Json;\n\n void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {\n\n std::unique_ptr<StreamWriter> const writer(\n\n factory.newStreamWriter());\n\n writer->write(value, &std::cout);\n\n std::cout << std::endl; // add lf and flush\n\n }\n\n\\endcode\n\n*/\n", "file_path": "jsoncpp-0.8.0/include/json/writer.h", "rank": 16, "score": 121036.90800119977 }, { "content": " class Factory {\n\n public:\n\n /** \\brief Allocate a CharReader via operator new().\n\n * \\throw std::exception if something goes wrong (e.g. invalid settings)\n\n */\n\n virtual CharReader* newCharReader() const = 0;\n\n }; // Factory\n\n}; // CharReader\n\n\n\n/** \\brief Build a CharReader implementation.\n\n\n\n \\deprecated This is experimental and will be altered before the next release.\n\n\n\nUsage:\n\n\\code\n\n using namespace Json;\n\n CharReaderBuilder builder;\n\n builder.settings_[\"collectComments\"] = false;\n\n Value value;\n\n std::string errs;\n\n bool ok = parseFromStream(builder, std::cin, &value, &errs);\n\n\\endcode\n\n*/\n", "file_path": "jsoncpp-0.8.0/include/json/reader.h", "rank": 17, "score": 121036.90800119977 }, { "content": "class Value;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 18, "score": 121036.90800119977 }, { "content": "// features.h\n\nclass Features;\n\n\n\n// value.h\n\ntypedef unsigned int ArrayIndex;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 19, "score": 121036.90800119977 }, { "content": "// reader.h\n\nclass Reader;\n\n\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 20, "score": 121036.90800119977 }, { "content": " class Token {\n\n public:\n\n TokenType type_;\n\n Location start_;\n\n Location end_;\n\n };\n\n\n", "file_path": "jsoncpp-0.8.0/include/json/reader.h", "rank": 21, "score": 121036.90800119977 }, { "content": "class Path;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 22, "score": 121036.90800119977 }, { "content": "class connection : public lib::enable_shared_from_this< connection<config> > {\n\npublic:\n\n /// Type of this connection transport component\n\n typedef connection<config> type;\n\n /// Type of a shared pointer to this connection transport component\n\n typedef lib::shared_ptr<type> ptr;\n\n\n\n /// transport concurrency policy\n\n typedef typename config::concurrency_type concurrency_type;\n\n /// Type of this transport's access logging policy\n\n typedef typename config::alog_type alog_type;\n\n /// Type of this transport's error logging policy\n\n typedef typename config::elog_type elog_type;\n\n\n\n // Concurrency policy types\n\n typedef typename concurrency_type::scoped_lock_type scoped_lock_type;\n\n typedef typename concurrency_type::mutex_type mutex_type;\n\n\n\n typedef lib::shared_ptr<timer> timer_ptr;\n\n\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/iostream/connection.hpp", "rank": 23, "score": 119449.30002382597 }, { "content": "class PrivateFrequencyEnforcer {\n\nprivate:\n\n api::Bot* m_Bot;\n\n bool m_JoinFriends;\n\n bool m_Override;\n\n\n\n api::PlayerPtr FindFriend() {\n\n api::PlayerList players = m_Bot->GetMemorySensor().GetPlayers();\n\n api::PlayerList::iterator iter;\n\n \n\n for (iter = players.begin(); iter != players.end(); ++iter) {\n\n api::PlayerPtr player = *iter;\n\n std::string name = player->GetName();\n\n\n\n if (player->GetShip() == api::Ship::Spectator || player->GetFreq() < 100) continue;\n\n\n\n for (std::string f : Friends) {\n\n if (f.compare(name) == 0)\n\n return player;\n\n }\n", "file_path": "plugins/Hyperspace/Hyperspace/main.cpp", "rank": 24, "score": 118499.58410306531 }, { "content": " class ErrorInfo {\n\n public:\n\n Token token_;\n\n std::string message_;\n\n Location extra_;\n\n };\n\n\n\n typedef std::deque<ErrorInfo> Errors;\n\n\n\n bool readToken(Token& token);\n\n void skipSpaces();\n\n bool match(Location pattern, int patternLength);\n\n bool readComment();\n\n bool readCStyleComment();\n\n bool readCppStyleComment();\n\n bool readString();\n\n void readNumber();\n\n bool readValue();\n\n bool readObject(Token& token);\n\n bool readArray(Token& token);\n", "file_path": "jsoncpp-0.8.0/include/json/reader.h", "rank": 25, "score": 118267.74659266618 }, { "content": "// writer.h\n\nclass FastWriter;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 26, "score": 118267.74659266618 }, { "content": "class ValueIterator;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 27, "score": 118267.74659266618 }, { "content": "class PathArgument;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 28, "score": 118267.74659266618 }, { "content": "class StyledWriter;\n\n\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 29, "score": 118267.74659266618 }, { "content": "class ValueInternalArray;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 30, "score": 115663.35157566261 }, { "content": "class ValueInternalLink;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 31, "score": 115663.35157566261 }, { "content": "#ifdef JSON_VALUE_USE_INTERNAL_MAP\n\nclass ValueMapAllocator;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 32, "score": 115663.35157566261 }, { "content": "class ValueInternalMap;\n\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n\n\n} // namespace Json\n\n\n\n#endif // JSON_FORWARDS_H_INCLUDED\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 33, "score": 115663.35157566261 }, { "content": "class ValueIteratorBase;\n", "file_path": "jsoncpp-0.8.0/include/json/forwards.h", "rank": 34, "score": 115663.35157566261 }, { "content": "class uri {\n\npublic:\n\n explicit uri(std::string const & uri_string) : m_valid(false) {\n\n std::string::const_iterator it;\n\n std::string::const_iterator temp;\n\n\n\n int state = 0;\n\n\n\n it = uri_string.begin();\n\n\n\n if (std::equal(it,it+6,\"wss://\")) {\n\n m_secure = true;\n\n m_scheme = \"wss\";\n\n it += 6;\n\n } else if (std::equal(it,it+5,\"ws://\")) {\n\n m_secure = false;\n\n m_scheme = \"ws\";\n\n it += 5;\n\n } else if (std::equal(it,it+7,\"http://\")) {\n\n m_secure = false;\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/uri.hpp", "rank": 36, "score": 113209.4422878402 }, { "content": "class connection\n\n : public config::transport_type::transport_con_type\n\n , public config::connection_base\n\n{\n\npublic:\n\n /// Type of this connection\n\n typedef connection<config> type;\n\n /// Type of a shared pointer to this connection\n\n typedef lib::shared_ptr<type> ptr;\n\n /// Type of a weak pointer to this connection\n\n typedef lib::weak_ptr<type> weak_ptr;\n\n\n\n /// Type of the concurrency component of this connection\n\n typedef typename config::concurrency_type concurrency_type;\n\n /// Type of the access logging policy\n\n typedef typename config::alog_type alog_type;\n\n /// Type of the error logging policy\n\n typedef typename config::elog_type elog_type;\n\n\n\n /// Type of the transport component of this connection\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/connection.hpp", "rank": 37, "score": 113209.4422878402 }, { "content": "class JSON_API Writer {\n\npublic:\n\n virtual ~Writer();\n\n\n\n virtual std::string write(const Value& root) = 0;\n\n};\n\n\n\n/** \\brief Outputs a Value in <a HREF=\"http://www.json.org\">JSON</a> format\n\n *without formatting (not human friendly).\n\n *\n\n * The JSON document is written in a single line. It is not intended for 'human'\n\n *consumption,\n\n * but may be usefull to support feature such as RPC where bandwith is limited.\n\n * \\sa Reader, Value\n\n * \\deprecated Use StreamWriterBuilder.\n\n */\n", "file_path": "jsoncpp-0.8.0/include/json/writer.h", "rank": 38, "score": 111219.25891157024 }, { "content": "class JSON_API Path {\n\npublic:\n\n Path(const std::string& path,\n\n const PathArgument& a1 = PathArgument(),\n\n const PathArgument& a2 = PathArgument(),\n\n const PathArgument& a3 = PathArgument(),\n\n const PathArgument& a4 = PathArgument(),\n\n const PathArgument& a5 = PathArgument());\n\n\n\n const Value& resolve(const Value& root) const;\n\n Value resolve(const Value& root, const Value& defaultValue) const;\n\n /// Creates the \"path\" to access the specified node and returns a reference on\n\n /// the node.\n\n Value& make(Value& root) const;\n\n\n\nprivate:\n\n typedef std::vector<const PathArgument*> InArgs;\n\n typedef std::vector<PathArgument> Args;\n\n\n\n void makePath(const std::string& path, const InArgs& in);\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 39, "score": 111219.25891157024 }, { "content": "class JSON_API Reader {\n\npublic:\n\n typedef char Char;\n\n typedef const Char* Location;\n\n\n\n /** \\brief Constructs a Reader allowing all features\n\n * for parsing.\n\n */\n\n Reader();\n\n\n\n /** \\brief Constructs a Reader allowing the specified feature set\n\n * for parsing.\n\n */\n\n Reader(const Features& features);\n\n\n\n /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n\n * document.\n\n * \\param document UTF-8 encoded string containing the document to read.\n\n * \\param root [out] Contains the root value of the document if it was\n\n * successfully parsed.\n", "file_path": "jsoncpp-0.8.0/include/json/reader.h", "rank": 40, "score": 111219.25891157024 }, { "content": " class JSON_API Factory {\n\n public:\n\n virtual ~Factory();\n\n /** \\brief Allocate a CharReader via operator new().\n\n * \\throw std::exception if something goes wrong (e.g. invalid settings)\n\n */\n\n virtual StreamWriter* newStreamWriter() const = 0;\n\n }; // Factory\n\n}; // StreamWriter\n\n\n\n/** \\brief Write into stringstream, then return string, for convenience.\n\n * A StreamWriter will be created from the factory, used, and then deleted.\n\n */\n\nstd::string writeString(StreamWriter::Factory const& factory, Value const& root);\n\n\n\n\n\n/** \\brief Build a StreamWriter implementation.\n\n\n\nUsage:\n\n\\code\n", "file_path": "jsoncpp-0.8.0/include/json/writer.h", "rank": 41, "score": 111219.25891157024 }, { "content": "class JSON_API Value {\n\n friend class ValueIteratorBase;\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n friend class ValueInternalLink;\n\n friend class ValueInternalMap;\n\n#endif\n\npublic:\n\n typedef std::vector<std::string> Members;\n\n typedef ValueIterator iterator;\n\n typedef ValueConstIterator const_iterator;\n\n typedef Json::UInt UInt;\n\n typedef Json::Int Int;\n\n#if defined(JSON_HAS_INT64)\n\n typedef Json::UInt64 UInt64;\n\n typedef Json::Int64 Int64;\n\n#endif // defined(JSON_HAS_INT64)\n\n typedef Json::LargestInt LargestInt;\n\n typedef Json::LargestUInt LargestUInt;\n\n typedef Json::ArrayIndex ArrayIndex;\n\n\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 42, "score": 111219.25891157024 }, { "content": "class JSON_API Features {\n\npublic:\n\n /** \\brief A configuration that allows all features and assumes all strings\n\n * are UTF-8.\n\n * - C & C++ comments are allowed\n\n * - Root object can be any JSON value\n\n * - Assumes Value strings are encoded in UTF-8\n\n */\n\n static Features all();\n\n\n\n /** \\brief A configuration that is strictly compatible with the JSON\n\n * specification.\n\n * - Comments are forbidden.\n\n * - Root object must be either an array or an object value.\n\n * - Assumes Value strings are encoded in UTF-8\n\n */\n\n static Features strictMode();\n\n\n\n /** \\brief Initialize the configuration like JsonConfig::allFeatures;\n\n */\n", "file_path": "jsoncpp-0.8.0/include/json/features.h", "rank": 43, "score": 111219.25891157024 }, { "content": "/// Provides streaming UTF8 validation functionality\n\nclass validator {\n\npublic:\n\n /// Construct and initialize the validator\n\n validator() : m_state(utf8_accept),m_codepoint(0) {}\n\n\n\n /// Advance the state of the validator with the next input byte\n\n /**\n\n * @param byte The byte to advance the validation state with\n\n * @return Whether or not the byte resulted in a validation error.\n\n */\n\n bool consume (uint8_t byte) {\n\n if (utf8_validator::decode(&m_state,&m_codepoint,byte) == utf8_reject) {\n\n return false;\n\n }\n\n return true;\n\n }\n\n\n\n /// Advance validator state with input from an iterator pair\n\n /**\n\n * @param begin Input iterator to the start of the input range\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/utf8_validator.hpp", "rank": 44, "score": 110893.34204170166 }, { "content": "/// Concurrency policy that uses std::mutex / boost::mutex\n\nclass basic {\n\npublic:\n\n typedef lib::mutex mutex_type;\n\n typedef lib::lock_guard<mutex_type> scoped_lock_type;\n\n};\n\n\n\n} // namespace concurrency\n\n} // namespace websocketpp\n\n\n\n#endif // WEBSOCKETPP_CONCURRENCY_BASIC_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/concurrency/basic.hpp", "rank": 45, "score": 110893.34204170166 }, { "content": "class processor {\n\npublic:\n\n typedef processor<config> type;\n\n typedef typename config::request_type request_type;\n\n typedef typename config::response_type response_type;\n\n typedef typename config::message_type::ptr message_ptr;\n\n typedef std::pair<lib::error_code,std::string> err_str_pair;\n\n\n\n explicit processor(bool secure, bool p_is_server)\n\n : m_secure(secure)\n\n , m_server(p_is_server)\n\n , m_max_message_size(config::max_message_size)\n\n {}\n\n\n\n virtual ~processor() {}\n\n\n\n /// Get the protocol version of this processor\n\n virtual int get_version() const = 0;\n\n\n\n /// Get maximum message size\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/processors/processor.hpp", "rank": 46, "score": 110893.34204170166 }, { "content": "class none {\n\npublic:\n\n /// The type of a mutex primitive\n\n /**\n\n * std::mutex is an example.\n\n */\n\n typedef none_impl::fake_mutex mutex_type;\n\n\n\n /// The type of a scoped/RAII lock primitive.\n\n /**\n\n * The scoped lock constructor should take a mutex_type as a parameter,\n\n * acquire that lock, and release it in its destructor. std::lock_guard is\n\n * an example.\n\n */\n\n typedef none_impl::fake_lock_guard scoped_lock_type;\n\n};\n\n\n\n} // namespace concurrency\n\n} // namespace websocketpp\n\n\n\n#endif // WEBSOCKETPP_CONCURRENCY_ASYNC_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/concurrency/none.hpp", "rank": 47, "score": 110893.34204170166 }, { "content": "class parser {\n\npublic:\n\n parser()\n\n : m_body_bytes_needed(0)\n\n , m_body_bytes_max(max_body_size)\n\n , m_body_encoding(body_encoding::unknown) {}\n\n \n\n /// Get the HTTP version string\n\n /**\n\n * @return The version string for this parser\n\n */\n\n std::string const & get_version() const {\n\n return m_version;\n\n }\n\n\n\n /// Set HTTP parser Version\n\n /**\n\n * Input should be in format: HTTP/x.y where x and y are positive integers.\n\n * @todo Does this method need any validation?\n\n *\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/http/parser.hpp", "rank": 48, "score": 110893.34204170166 }, { "content": "class basic {\n\npublic:\n\n basic<concurrency,names>(channel_type_hint::value h =\n\n channel_type_hint::access)\n\n : m_static_channels(0xffffffff)\n\n , m_dynamic_channels(0)\n\n , m_out(h == channel_type_hint::error ? &std::cerr : &std::cout) {}\n\n\n\n basic<concurrency,names>(std::ostream * out)\n\n : m_static_channels(0xffffffff)\n\n , m_dynamic_channels(0)\n\n , m_out(out) {}\n\n\n\n basic<concurrency,names>(level c, channel_type_hint::value h =\n\n channel_type_hint::access)\n\n : m_static_channels(c)\n\n , m_dynamic_channels(0)\n\n , m_out(h == channel_type_hint::error ? &std::cerr : &std::cout) {}\n\n\n\n basic<concurrency,names>(level c, std::ostream * out)\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/logger/basic.hpp", "rank": 49, "score": 110893.34204170166 }, { "content": "/// Stub logger that ignores all input\n\nclass stub {\n\npublic:\n\n /// Construct the logger\n\n /**\n\n * @param hint A channel type specific hint for how to construct the logger\n\n */\n\n explicit stub(channel_type_hint::value) {}\n\n\n\n /// Construct the logger\n\n /**\n\n * @param default_channels A set of channels to statically enable\n\n * @param hint A channel type specific hint for how to construct the logger\n\n */\n\n stub(level, channel_type_hint::value) {}\n\n _WEBSOCKETPP_CONSTEXPR_TOKEN_ stub() {}\n\n\n\n /// Dynamically enable the given list of channels\n\n /**\n\n * All operations on the stub logger are no-ops and all arguments are\n\n * ignored\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/logger/stub.hpp", "rank": 50, "score": 110893.34204170166 }, { "content": "class JSON_API StreamWriter {\n\nprotected:\n\n std::ostream* sout_; // not owned; will not delete\n\npublic:\n\n StreamWriter();\n\n virtual ~StreamWriter();\n\n /** Write Value into document as configured in sub-class.\n\n Do not take ownership of sout, but maintain a reference during function.\n\n \\pre sout != NULL\n\n \\return zero on success\n\n \\throw std::exception possibly, depending on configuration\n\n */\n\n virtual int write(Value const& root, std::ostream* sout) = 0;\n\n\n\n /** \\brief A simple abstract factory.\n\n */\n", "file_path": "jsoncpp-0.8.0/include/json/writer.h", "rank": 51, "score": 108765.34962374782 }, { "content": "class JSON_API CharReader {\n\npublic:\n\n virtual ~CharReader() {}\n\n /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n\n document.\n\n * The document must be a UTF-8 encoded string containing the document to read.\n\n *\n\n * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n\n document to read.\n\n * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n\n document to read.\n\n * Must be >= beginDoc.\n\n * \\param root [out] Contains the root value of the document if it was\n\n * successfully parsed.\n\n * \\param errs [out] Formatted error messages (if not NULL)\n\n * a user friendly string that lists errors in the parsed\n\n * document.\n\n * \\return \\c true if the document was successfully parsed, \\c false if an\n\n error occurred.\n\n */\n\n virtual bool parse(\n\n char const* beginDoc, char const* endDoc,\n\n Value* root, std::string* errs) = 0;\n\n\n", "file_path": "jsoncpp-0.8.0/include/json/reader.h", "rank": 52, "score": 108765.34962374782 }, { "content": "class JSON_API PathArgument {\n\npublic:\n\n friend class Path;\n\n\n\n PathArgument();\n\n PathArgument(ArrayIndex index);\n\n PathArgument(const char* key);\n\n PathArgument(const std::string& key);\n\n\n\nprivate:\n\n enum Kind {\n\n kindNone = 0,\n\n kindIndex,\n\n kindKey\n\n };\n\n std::string key_;\n\n ArrayIndex index_;\n\n Kind kind_;\n\n};\n\n\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 53, "score": 108765.34962374782 }, { "content": "/// Stub for user supplied base class.\n\nclass endpoint_base {};\n\n\n\n} // namespace websocketpp\n\n\n\n#endif // WEBSOCKETPP_ENDPOINT_BASE_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/endpoint_base.hpp", "rank": 54, "score": 108709.28198419782 }, { "content": "/// Stub for user supplied base class.\n\nclass connection_base {};\n\n\n\n} // namespace websocketpp\n\n\n\n#endif // WEBSOCKETPP_CONNECTION_BASE_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/connection_base.hpp", "rank": 55, "score": 108709.28198419782 }, { "content": "class endpoint {\n\npublic:\n\n /// Type of this endpoint transport component\n\n typedef endpoint type;\n\n /// Type of a pointer to this endpoint transport component\n\n typedef lib::shared_ptr<type> ptr;\n\n\n\n /// Type of this endpoint's concurrency policy\n\n typedef typename config::concurrency_type concurrency_type;\n\n /// Type of this endpoint's error logging policy\n\n typedef typename config::elog_type elog_type;\n\n /// Type of this endpoint's access logging policy\n\n typedef typename config::alog_type alog_type;\n\n\n\n /// Type of this endpoint transport component's associated connection\n\n /// transport component.\n\n typedef stub::connection<config> transport_con_type;\n\n /// Type of a shared pointer to this endpoint transport component's\n\n /// associated connection transport component\n\n typedef typename transport_con_type::ptr transport_con_ptr;\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/stub/endpoint.hpp", "rank": 56, "score": 108703.75908124946 }, { "content": "class endpoint;\n\n\n\ntypedef lib::function<void(lib::asio::error_code const &)>\n\n socket_shutdown_handler;\n\n\n\ntypedef lib::function<void (lib::asio::error_code const & ec,\n\n size_t bytes_transferred)> async_read_handler;\n\n\n\ntypedef lib::function<void (lib::asio::error_code const & ec,\n\n size_t bytes_transferred)> async_write_handler;\n\n\n\ntypedef lib::function<void (lib::error_code const & ec)> pre_init_handler;\n\n\n\n// handle_timer: dynamic parameters, multiple copies\n\n// handle_proxy_write\n\n// handle_proxy_read\n\n// handle_async_write\n\n// handle_pre_init\n\n\n\n\n\n/// Asio transport errors\n\nnamespace error {\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/asio/base.hpp", "rank": 57, "score": 108703.75908124946 }, { "content": "class endpoint {\n\npublic:\n\n /// Type of this endpoint transport component\n\n typedef endpoint type;\n\n /// Type of a pointer to this endpoint transport component\n\n typedef lib::shared_ptr<type> ptr;\n\n\n\n /// Type of this endpoint's concurrency policy\n\n typedef typename config::concurrency_type concurrency_type;\n\n /// Type of this endpoint's error logging policy\n\n typedef typename config::elog_type elog_type;\n\n /// Type of this endpoint's access logging policy\n\n typedef typename config::alog_type alog_type;\n\n\n\n /// Type of this endpoint transport component's associated connection\n\n /// transport component.\n\n typedef debug::connection<config> transport_con_type;\n\n /// Type of a shared pointer to this endpoint transport component's\n\n /// associated connection transport component\n\n typedef typename transport_con_type::ptr transport_con_ptr;\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/debug/endpoint.hpp", "rank": 58, "score": 108703.75908124946 }, { "content": "/// A fake mutex implementation that does nothing\n\nclass fake_mutex {\n\npublic:\n\n fake_mutex() {}\n\n ~fake_mutex() {}\n\n};\n\n\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/concurrency/none.hpp", "rank": 59, "score": 108703.75908124946 }, { "content": "class message {\n\npublic:\n\n typedef lib::shared_ptr<message> ptr;\n\n\n\n typedef typename con_msg_manager::weak_ptr con_msg_man_ptr;\n\n\n\n message(con_msg_man_ptr manager, size_t size = 128)\n\n : m_manager(manager)\n\n , m_payload(size) {}\n\n\n\n frame::opcode::value get_opcode() const {\n\n return m_opcode;\n\n }\n\n const std::string& get_header() const {\n\n return m_header;\n\n }\n\n const std::string& get_extension_data() const {\n\n return m_extension_data;\n\n }\n\n const std::string& get_payload() const {\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/message_buffer/pool.hpp", "rank": 60, "score": 108703.75908124946 }, { "content": "class message {\n\npublic:\n\n typedef lib::shared_ptr<message> ptr;\n\n\n\n typedef con_msg_manager<message> con_msg_man_type;\n\n typedef typename con_msg_man_type::ptr con_msg_man_ptr;\n\n typedef typename con_msg_man_type::weak_ptr con_msg_man_weak_ptr;\n\n\n\n /// Construct an empty message\n\n /**\n\n * Construct an empty message\n\n */\n\n message(const con_msg_man_ptr manager)\n\n : m_manager(manager)\n\n , m_prepared(false)\n\n , m_fin(true)\n\n , m_terminal(false)\n\n , m_compressed(false) {}\n\n\n\n /// Construct a message and fill in some values\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/message_buffer/message.hpp", "rank": 61, "score": 108703.75908124946 }, { "content": "class MessageDispatcherImpl : public MessageDispatcher {\n\nprivate:\n\n typedef T MessageImpl;\n\n typedef std::vector<std::shared_ptr<MessageImpl>> MessageVector;\n\n typedef MessageHandler<T> MessageHandlerImpl;\n\n typedef std::vector<MessageHandlerImpl*> MessageHandlerVector;\n\n\n\n MessageVector m_Messages;\n\n MessageHandlerVector m_Handlers;\n\n\n\n MessageDispatcherImpl() {\n\n MessageQueue::GetInstance().RegisterDispatcher(this);\n\n }\n\n\n\n virtual ~MessageDispatcherImpl() { }\n\n\n\npublic:\n\n static MessageDispatcherImpl& GetInstance() {\n\n static MessageDispatcherImpl instance;\n\n return instance;\n", "file_path": "screenbot/MessageQueue.h", "rank": 62, "score": 108246.11353045437 }, { "content": "// Class to manage the memory to be used for handler-based custom allocation.\n\n// It contains a single block of memory which may be returned for allocation\n\n// requests. If the memory is in use when an allocation request is made, the\n\n// allocator delegates allocation to the global heap.\n\nclass handler_allocator {\n\npublic:\n\n static const size_t size = 1024;\n\n \n\n handler_allocator() : m_in_use(false) {}\n\n\n\n#ifdef _WEBSOCKETPP_DEFAULT_DELETE_FUNCTIONS_\n\n\thandler_allocator(handler_allocator const & cpy) = delete;\n\n\thandler_allocator & operator =(handler_allocator const &) = delete;\n\n#endif\n\n\n\n void * allocate(std::size_t memsize) {\n\n if (!m_in_use && memsize < size) {\n\n m_in_use = true;\n\n return static_cast<void*>(&m_storage);\n\n } else {\n\n return ::operator new(memsize);\n\n }\n\n }\n\n\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/asio/base.hpp", "rank": 63, "score": 106639.63769525145 }, { "content": "class enabled {\n\npublic:\n\n enabled()\n\n : m_enabled(false)\n\n , m_s2c_no_context_takeover(false)\n\n , m_c2s_no_context_takeover(false)\n\n , m_s2c_max_window_bits(15)\n\n , m_c2s_max_window_bits(15)\n\n , m_s2c_max_window_bits_mode(mode::accept)\n\n , m_c2s_max_window_bits_mode(mode::accept)\n\n , m_initialized(false)\n\n , m_compress_buffer_size(16384)\n\n {\n\n m_dstate.zalloc = Z_NULL;\n\n m_dstate.zfree = Z_NULL;\n\n m_dstate.opaque = Z_NULL;\n\n\n\n m_istate.zalloc = Z_NULL;\n\n m_istate.zfree = Z_NULL;\n\n m_istate.opaque = Z_NULL;\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/extensions/permessage_deflate/enabled.hpp", "rank": 64, "score": 106630.60248010949 }, { "content": "class endpoint {\n\npublic:\n\n /// The type of this endpoint socket component\n\n typedef endpoint type;\n\n\n\n /// The type of the corresponding connection socket component\n\n typedef connection socket_con_type;\n\n /// The type of a shared pointer to the corresponding connection socket\n\n /// component.\n\n typedef socket_con_type::ptr socket_con_ptr;\n\n\n\n explicit endpoint() {}\n\n\n\n /// Checks whether the endpoint creates secure connections\n\n /**\n\n * @return Whether or not the endpoint creates secure connections\n\n */\n\n bool is_secure() const {\n\n return true;\n\n }\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/asio/security/tls.hpp", "rank": 65, "score": 106630.60248010949 }, { "content": "/// A fake lock guard implementation that does nothing\n\nclass fake_lock_guard {\n\npublic:\n\n explicit fake_lock_guard(fake_mutex) {}\n\n ~fake_lock_guard() {}\n\n};\n\n} // namespace none_impl\n\n\n\n/// Stub concurrency policy that implements the interface using no-ops.\n\n/**\n\n * This policy documents the concurrency policy interface using no-ops. It can\n\n * be used as a reference or base for building a new concurrency policy. It can\n\n * also be used as is to disable all locking for endpoints used in purely single\n\n * threaded programs.\n\n */\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/concurrency/none.hpp", "rank": 66, "score": 106630.60248010949 }, { "content": "class endpoint {\n\npublic:\n\n /// The type of this endpoint socket component\n\n typedef endpoint type;\n\n\n\n /// The type of the corresponding connection socket component\n\n typedef connection socket_con_type;\n\n /// The type of a shared pointer to the corresponding connection socket\n\n /// component.\n\n typedef socket_con_type::ptr socket_con_ptr;\n\n\n\n explicit endpoint() {}\n\n\n\n /// Checks whether the endpoint creates secure connections\n\n /**\n\n * @return Whether or not the endpoint creates secure connections\n\n */\n\n bool is_secure() const {\n\n return false;\n\n }\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/asio/security/none.hpp", "rank": 67, "score": 106630.60248010949 }, { "content": "class disabled {\n\n typedef std::pair<lib::error_code,std::string> err_str_pair;\n\n\n\npublic:\n\n /// Negotiate extension\n\n /**\n\n * The disabled extension always fails the negotiation with a disabled \n\n * error.\n\n *\n\n * @param offer Attribute from client's offer\n\n * @return Status code and value to return to remote endpoint\n\n */\n\n err_str_pair negotiate(http::attribute_list const &) {\n\n return make_pair(make_error_code(error::disabled),std::string());\n\n }\n\n\n\n /// Returns true if the extension is capable of providing\n\n /// permessage_deflate functionality\n\n bool is_implemented() const {\n\n return false;\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/extensions/permessage_deflate/disabled.hpp", "rank": 68, "score": 106630.60248010949 }, { "content": "class JSON_API ValueArrayAllocator {\n\npublic:\n\n virtual ~ValueArrayAllocator();\n\n virtual ValueInternalArray* newArray() = 0;\n\n virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) = 0;\n\n virtual void destructArray(ValueInternalArray* array) = 0;\n\n /** \\brief Reallocate array page index.\n\n * Reallocates an array of pointer on each page.\n\n * \\param indexes [input] pointer on the current index. May be \\c NULL.\n\n * [output] pointer on the new index of at least\n\n * \\a minNewIndexCount pages.\n\n * \\param indexCount [input] current number of pages in the index.\n\n * [output] number of page the reallocated index can handle.\n\n * \\b MUST be >= \\a minNewIndexCount.\n\n * \\param minNewIndexCount Minimum number of page the new index must be able\n\n * to\n\n * handle.\n\n */\n\n virtual void\n\n reallocateArrayPageIndex(Value**& indexes,\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 69, "score": 106449.24937760929 }, { "content": "class JSON_API ValueInternalLink {\n\npublic:\n\n enum {\n\n itemPerLink = 6\n\n }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.\n\n enum InternalFlags {\n\n flagAvailable = 0,\n\n flagUsed = 1\n\n };\n\n\n\n ValueInternalLink();\n\n\n\n ~ValueInternalLink();\n\n\n\n Value items_[itemPerLink];\n\n char* keys_[itemPerLink];\n\n ValueInternalLink* previous_;\n\n ValueInternalLink* next_;\n\n};\n\n\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 70, "score": 106449.24937760929 }, { "content": "class JSON_API StyledStreamWriter {\n\npublic:\n\n StyledStreamWriter(std::string indentation = \"\\t\");\n\n ~StyledStreamWriter() {}\n\n\n\npublic:\n\n /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n\n * \\param out Stream to write to. (Can be ostringstream, e.g.)\n\n * \\param root Value to serialize.\n\n * \\note There is no point in deriving from Writer, since write() should not\n\n * return a value.\n\n */\n\n void write(std::ostream& out, const Value& root);\n\n\n\nprivate:\n\n void writeValue(const Value& value);\n\n void writeArrayValue(const Value& value);\n\n bool isMultineArray(const Value& value);\n\n void pushValue(const std::string& value);\n\n void writeIndent();\n", "file_path": "jsoncpp-0.8.0/include/json/writer.h", "rank": 71, "score": 106449.24937760929 }, { "content": "class JSON_API ValueInternalArray {\n\n friend class Value;\n\n friend class ValueIteratorBase;\n\n\n\npublic:\n\n enum {\n\n itemsPerPage = 8\n\n }; // should be a power of 2 for fast divide and modulo.\n\n typedef Value::ArrayIndex ArrayIndex;\n\n typedef unsigned int PageIndex;\n\n\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n struct IteratorState // Must be a POD\n\n {\n\n IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}\n\n ValueInternalArray* array_;\n\n Value** currentPageIndex_;\n\n unsigned int currentItemIndex_;\n\n };\n\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 72, "score": 106449.24937760929 }, { "content": "class JSON_API ValueMapAllocator {\n\npublic:\n\n virtual ~ValueMapAllocator();\n\n virtual ValueInternalMap* newMap() = 0;\n\n virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) = 0;\n\n virtual void destructMap(ValueInternalMap* map) = 0;\n\n virtual ValueInternalLink* allocateMapBuckets(unsigned int size) = 0;\n\n virtual void releaseMapBuckets(ValueInternalLink* links) = 0;\n\n virtual ValueInternalLink* allocateMapLink() = 0;\n\n virtual void releaseMapLink(ValueInternalLink* link) = 0;\n\n};\n\n\n\n/** \\brief ValueInternalMap hash-map bucket chain link (for internal use only).\n\n * \\internal previous_ & next_ allows for bidirectional traversal.\n\n */\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 73, "score": 106449.24937760929 }, { "content": "class JSON_API ValueInternalMap {\n\n friend class ValueIteratorBase;\n\n friend class Value;\n\n\n\npublic:\n\n typedef unsigned int HashKey;\n\n typedef unsigned int BucketIndex;\n\n\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n struct IteratorState {\n\n IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}\n\n ValueInternalMap* map_;\n\n ValueInternalLink* link_;\n\n BucketIndex itemIndex_;\n\n BucketIndex bucketIndex_;\n\n };\n\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n\n\n ValueInternalMap();\n\n ValueInternalMap(const ValueInternalMap& other);\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 74, "score": 106449.24937760929 }, { "content": "class JSON_API ValueIteratorBase {\n\npublic:\n\n typedef std::bidirectional_iterator_tag iterator_category;\n\n typedef unsigned int size_t;\n\n typedef int difference_type;\n\n typedef ValueIteratorBase SelfType;\n\n\n\n ValueIteratorBase();\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);\n\n#else\n\n ValueIteratorBase(const ValueInternalArray::IteratorState& state);\n\n ValueIteratorBase(const ValueInternalMap::IteratorState& state);\n\n#endif\n\n\n\n bool operator==(const SelfType& other) const { return isEqual(other); }\n\n\n\n bool operator!=(const SelfType& other) const { return !isEqual(other); }\n\n\n\n difference_type operator-(const SelfType& other) const {\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 75, "score": 106449.24937760929 }, { "content": "/// An endpoint manager that maintains a shared pool of connection managers\n\n/// and returns an appropriate one for the requesting connection.\n\nclass endpoint_msg_manager {\n\n\n\n};\n\n\n\n} // namespace pool\n\n\n\n} // namespace message_buffer\n\n} // namespace websocketpp\n\n\n\n#endif // WEBSOCKETPP_MESSAGE_BUFFER_ALLOC_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/message_buffer/pool.hpp", "rank": 76, "score": 104669.958229619 }, { "content": "class custom_alloc_handler {\n\npublic:\n\n custom_alloc_handler(handler_allocator& a, Handler h)\n\n : allocator_(a),\n\n handler_(h)\n\n {}\n\n\n\n template <typename Arg1>\n\n void operator()(Arg1 arg1) {\n\n handler_(arg1);\n\n }\n\n\n\n template <typename Arg1, typename Arg2>\n\n void operator()(Arg1 arg1, Arg2 arg2) {\n\n handler_(arg1, arg2);\n\n }\n\n\n\n friend void* asio_handler_allocate(std::size_t size,\n\n custom_alloc_handler<Handler> * this_handler)\n\n {\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/transport/asio/base.hpp", "rank": 77, "score": 104664.82664675721 }, { "content": "class con_msg_manager\n\n : public lib::enable_shared_from_this<con_msg_manager<message> >\n\n{\n\npublic:\n\n typedef con_msg_manager<message> type;\n\n typedef lib::shared_ptr<con_msg_manager> ptr;\n\n typedef lib::weak_ptr<con_msg_manager> weak_ptr;\n\n\n\n typedef typename message::ptr message_ptr;\n\n\n\n /// Get an empty message buffer\n\n /**\n\n * @return A shared pointer to an empty new message\n\n */\n\n message_ptr get_message() {\n\n return message_ptr(lib::make_shared<message>(type::shared_from_this()));\n\n }\n\n\n\n /// Get a message buffer with specified size and opcode\n\n /**\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/message_buffer/alloc.hpp", "rank": 78, "score": 104664.82664675721 }, { "content": "/// A connection messages manager that maintains a pool of messages that is\n\n/// used to fulfill get_message requests.\n\nclass con_msg_manager {\n\n\n\n};\n\n\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/message_buffer/pool.hpp", "rank": 79, "score": 104664.82664675721 }, { "content": "class endpoint_msg_manager {\n\npublic:\n\n typedef typename con_msg_manager::ptr con_msg_man_ptr;\n\n\n\n /// Get a pointer to a connection message manager\n\n /**\n\n * @return A pointer to the requested connection message manager.\n\n */\n\n con_msg_man_ptr get_manager() const {\n\n return con_msg_man_ptr(lib::make_shared<con_msg_manager>());\n\n }\n\n};\n\n\n\n} // namespace alloc\n\n} // namespace message_buffer\n\n} // namespace websocketpp\n\n\n\n#endif // WEBSOCKETPP_MESSAGE_BUFFER_ALLOC_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/message_buffer/alloc.hpp", "rank": 80, "score": 104664.82664675721 }, { "content": "struct ci_less : std::binary_function<std::string, std::string, bool> {\n\n // case-independent (ci) compare_less binary function\n\n struct nocase_compare\n\n : public std::binary_function<unsigned char,unsigned char,bool>\n\n {\n\n bool operator() (unsigned char const & c1, unsigned char const & c2) const {\n\n return tolower (c1) < tolower (c2);\n\n }\n\n };\n\n bool operator() (std::string const & s1, std::string const & s2) const {\n\n return std::lexicographical_compare\n\n (s1.begin (), s1.end (), // source range\n\n s2.begin (), s2.end (), // dest range\n\n nocase_compare ()); // comparison\n\n }\n\n};\n\n\n\n/// Find substring (case insensitive)\n\n/**\n\n * @param [in] haystack The string to search in\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/utilities.hpp", "rank": 81, "score": 103803.18431372347 }, { "content": "class response : public parser {\n\npublic:\n\n typedef response type;\n\n typedef lib::shared_ptr<type> ptr;\n\n\n\n response()\n\n : m_read(0)\n\n , m_buf(lib::make_shared<std::string>())\n\n , m_status_code(status_code::uninitialized)\n\n , m_state(RESPONSE_LINE) {}\n\n\n\n /// Process bytes in the input buffer\n\n /**\n\n * Process up to len bytes from input buffer buf. Returns the number of\n\n * bytes processed. Bytes left unprocessed means bytes left over after the\n\n * final header delimiters.\n\n *\n\n * Consume is a streaming processor. It may be called multiple times on one\n\n * response and the full headers need not be available before processing can\n\n * begin. If the end of the response was reached during this call to consume\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/http/response.hpp", "rank": 82, "score": 98865.5364548178 }, { "content": "class request : public parser {\n\npublic:\n\n typedef request type;\n\n typedef lib::shared_ptr<type> ptr;\n\n\n\n request()\n\n : m_buf(lib::make_shared<std::string>())\n\n , m_ready(false) {}\n\n\n\n /// Process bytes in the input buffer\n\n /**\n\n * Process up to len bytes from input buffer buf. Returns the number of\n\n * bytes processed. Bytes left unprocessed means bytes left over after the\n\n * final header delimiters.\n\n *\n\n * Consume is a streaming processor. It may be called multiple times on one\n\n * request and the full headers need not be available before processing can\n\n * begin. If the end of the request was reached during this call to consume\n\n * the ready flag will be set. Further calls to consume once ready will be\n\n * ignored.\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/http/request.hpp", "rank": 83, "score": 98865.5364548178 }, { "content": "class JSON_API StyledWriter : public Writer {\n\npublic:\n\n StyledWriter();\n\n virtual ~StyledWriter() {}\n\n\n\npublic: // overridden from Writer\n\n /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n\n * \\param root Value to serialize.\n\n * \\return String containing the JSON document that represents the root value.\n\n */\n\n virtual std::string write(const Value& root);\n\n\n\nprivate:\n\n void writeValue(const Value& value);\n\n void writeArrayValue(const Value& value);\n\n bool isMultineArray(const Value& value);\n\n void pushValue(const std::string& value);\n\n void writeIndent();\n\n void writeWithIndent(const std::string& value);\n\n void indent();\n", "file_path": "jsoncpp-0.8.0/include/json/writer.h", "rank": 84, "score": 98362.84721286001 }, { "content": "class JSON_API FastWriter : public Writer {\n\npublic:\n\n FastWriter();\n\n virtual ~FastWriter() {}\n\n\n\n void enableYAMLCompatibility();\n\n\n\npublic: // overridden from Writer\n\n virtual std::string write(const Value& root);\n\n\n\nprivate:\n\n void writeValue(const Value& value);\n\n\n\n std::string document_;\n\n bool yamlCompatiblityEnabled_;\n\n};\n\n\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n\n *human friendly way.\n\n *\n", "file_path": "jsoncpp-0.8.0/include/json/writer.h", "rank": 85, "score": 98362.84721286001 }, { "content": "namespace Random {\n\n // Inclusive\n\n unsigned int GetU32(unsigned int start, unsigned int end);\n\n double GetReal();\n", "file_path": "screenbot/Random.h", "rank": 86, "score": 98310.2765229296 }, { "content": " class DefaultValueMapAllocator : public ValueMapAllocator\n\n {\n\n public: // overridden from ValueMapAllocator\n\n virtual ValueInternalMap *newMap()\n\n {\n\n return new ValueInternalMap();\n\n }\n\n\n\n virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n\n {\n\n return new ValueInternalMap( other );\n\n }\n\n\n\n virtual void destructMap( ValueInternalMap *map )\n\n {\n\n delete map;\n\n }\n\n\n\n virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n\n {\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 87, "score": 96899.76062146554 }, { "content": "class DefaultValueArrayAllocator : public ValueArrayAllocator\n\n{\n\npublic: // overridden from ValueArrayAllocator\n\nvirtual ~DefaultValueArrayAllocator()\n\n{\n\n}\n\n\n\nvirtual ValueInternalArray *newArray()\n\n{\n\n return new ValueInternalArray();\n\n}\n\n\n\nvirtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n\n{\n\n return new ValueInternalArray( other );\n\n}\n\n\n\nvirtual void destruct( ValueInternalArray *array )\n\n{\n\n delete array;\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 88, "score": 96899.76062146554 }, { "content": "class exception : public std::exception {\n\npublic:\n\n exception(std::string const & msg, lib::error_code ec = make_error_code(error::general))\n\n : m_msg(msg.empty() ? ec.message() : msg), m_code(ec)\n\n {}\n\n\n\n explicit exception(lib::error_code ec)\n\n : m_msg(ec.message()), m_code(ec)\n\n {}\n\n\n\n ~exception() throw() {}\n\n\n\n virtual char const * what() const throw() {\n\n return m_msg.c_str();\n\n }\n\n\n\n lib::error_code code() const throw() {\n\n return m_code;\n\n }\n\n\n\n const std::string m_msg;\n\n lib::error_code m_code;\n\n};\n\n\n\n} // namespace websocketpp\n\n\n\n#endif // WEBSOCKETPP_ERROR_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/error.hpp", "rank": 89, "score": 96289.69061172003 }, { "content": "class hybi07 : public hybi08<config> {\n\npublic:\n\n typedef typename config::request_type request_type;\n\n\n\n typedef typename config::con_msg_manager_type::ptr msg_manager_ptr;\n\n typedef typename config::rng_type rng_type;\n\n\n\n explicit hybi07(bool secure, bool p_is_server, msg_manager_ptr manager, rng_type& rng)\n\n : hybi08<config>(secure, p_is_server, manager, rng) {}\n\n\n\n /// Fill in a set of request headers for a client connection request\n\n /**\n\n * The Hybi 07 processor only implements incoming connections so this will\n\n * always return an error.\n\n *\n\n * @param [out] req Set of headers to fill in\n\n * @param [in] uri The uri being connected to\n\n * @param [in] subprotocols The list of subprotocols to request\n\n */\n\n lib::error_code client_handshake_request(request_type &, uri_ptr,\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/processors/hybi07.hpp", "rank": 90, "score": 94323.91477836776 }, { "content": "class hybi08 : public hybi13<config> {\n\npublic:\n\n typedef hybi08<config> type;\n\n typedef typename config::request_type request_type;\n\n\n\n typedef typename config::con_msg_manager_type::ptr msg_manager_ptr;\n\n typedef typename config::rng_type rng_type;\n\n\n\n explicit hybi08(bool secure, bool p_is_server, msg_manager_ptr manager, rng_type& rng)\n\n : hybi13<config>(secure, p_is_server, manager, rng) {}\n\n\n\n /// Fill in a set of request headers for a client connection request\n\n /**\n\n * The Hybi 08 processor only implements incoming connections so this will\n\n * always return an error.\n\n *\n\n * @param [out] req Set of headers to fill in\n\n * @param [in] uri The uri being connected to\n\n * @param [in] subprotocols The list of subprotocols to request\n\n */\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/processors/hybi08.hpp", "rank": 91, "score": 94323.91477836776 }, { "content": "class JSON_API ValueIterator : public ValueIteratorBase {\n\n friend class Value;\n\n\n\npublic:\n\n typedef Value value_type;\n\n typedef unsigned int size_t;\n\n typedef int difference_type;\n\n typedef Value& reference;\n\n typedef Value* pointer;\n\n typedef ValueIterator SelfType;\n\n\n\n ValueIterator();\n\n ValueIterator(const ValueConstIterator& other);\n\n ValueIterator(const ValueIterator& other);\n\n\n\nprivate:\n\n/*! \\internal Use by Value to create an iterator.\n\n */\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n explicit ValueIterator(const Value::ObjectValues::iterator& current);\n", "file_path": "jsoncpp-0.8.0/include/json/value.h", "rank": 92, "score": 94323.91477836776 }, { "content": "class category : public lib::error_category {\n\npublic:\n\n category() {}\n\n\n\n char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {\n\n return \"websocketpp\";\n\n }\n\n\n\n std::string message(int value) const {\n\n switch(value) {\n\n case error::general:\n\n return \"Generic error\";\n\n case error::send_queue_full:\n\n return \"send queue full\";\n\n case error::payload_violation:\n\n return \"payload violation\";\n\n case error::endpoint_not_secure:\n\n return \"endpoint not secure\";\n\n case error::endpoint_unavailable:\n\n return \"endpoint not available\";\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/error.hpp", "rank": 93, "score": 94323.91477836776 }, { "content": "class hybi13 : public processor<config> {\n\npublic:\n\n typedef processor<config> base;\n\n\n\n typedef typename config::request_type request_type;\n\n typedef typename config::response_type response_type;\n\n\n\n typedef typename config::message_type message_type;\n\n typedef typename message_type::ptr message_ptr;\n\n\n\n typedef typename config::con_msg_manager_type msg_manager_type;\n\n typedef typename msg_manager_type::ptr msg_manager_ptr;\n\n typedef typename config::rng_type rng_type;\n\n\n\n typedef typename config::permessage_deflate_type permessage_deflate_type;\n\n\n\n typedef std::pair<lib::error_code,std::string> err_str_pair;\n\n\n\n explicit hybi13(bool secure, bool p_is_server, msg_manager_ptr manager, rng_type& rng)\n\n : processor<config>(secure, p_is_server)\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/processors/hybi13.hpp", "rank": 94, "score": 94323.91477836776 }, { "content": " class exception : public std::exception {\n\n public:\n\n exception(const std::string& log_msg,\n\n status_code::value error_code,\n\n const std::string& error_msg = \"\",\n\n const std::string& body = \"\")\n\n : m_msg(log_msg)\n\n , m_error_msg(error_msg)\n\n , m_body(body)\n\n , m_error_code(error_code) {}\n\n\n\n ~exception() throw() {}\n\n\n\n virtual const char* what() const throw() {\n\n return m_msg.c_str();\n\n }\n\n\n\n std::string m_msg;\n\n std::string m_error_msg;\n\n std::string m_body;\n\n status_code::value m_error_code;\n\n };\n\n}\n\n}\n\n\n\n#endif // HTTP_CONSTANTS_HPP\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/http/constants.hpp", "rank": 95, "score": 94323.91477836776 }, { "content": "class hybi00 : public processor<config> {\n\npublic:\n\n typedef processor<config> base;\n\n\n\n typedef typename config::request_type request_type;\n\n typedef typename config::response_type response_type;\n\n\n\n typedef typename config::message_type message_type;\n\n typedef typename message_type::ptr message_ptr;\n\n\n\n typedef typename config::con_msg_manager_type::ptr msg_manager_ptr;\n\n\n\n explicit hybi00(bool secure, bool p_is_server, msg_manager_ptr manager)\n\n : processor<config>(secure, p_is_server)\n\n , msg_hdr(0x00)\n\n , msg_ftr(0xff)\n\n , m_state(HEADER)\n\n , m_msg_manager(manager) {}\n\n\n\n int get_version() const {\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/processors/hybi00.hpp", "rank": 96, "score": 94323.91477836776 }, { "content": " * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n *\n\n */\n\n\n\n#ifndef WEBSOCKETPP_RANDOM_RANDOM_DEVICE_HPP\n\n#define WEBSOCKETPP_RANDOM_RANDOM_DEVICE_HPP\n\n\n\n#include <websocketpp/common/random.hpp>\n\n\n\nnamespace websocketpp {\n\nnamespace random {\n\n/// RNG policy based on std::random_device or boost::random_device\n\nnamespace random_device {\n\n\n\n/// Thread safe non-deterministic random integer generator.\n\n/**\n\n * This template class provides thread safe non-deterministic random integer\n", "file_path": "plugins/Web/websocketpp/include/websocketpp/random/random_device.hpp", "rank": 97, "score": 93127.22318602854 } ]
C++
src/hdf5/DataTypeHDF5.cpp
balint42/nix
50f1de33b946b7b194c82fb0efd9b0cecba9ed54
#include <nix/hdf5/DataTypeHDF5.hpp> #include <stdexcept> #include <iostream> #include <cassert> namespace nix { namespace hdf5 { namespace h5x { DataType DataType::copy(hid_t source) { DataType hi_copy = H5Tcopy(source); hi_copy.check("Could not copy type"); return hi_copy; } DataType DataType::makeStrType(size_t size) { DataType str_type = H5Tcopy(H5T_C_S1); str_type.check("Could not create string type"); str_type.size(size); return str_type; } void DataType::size(size_t t) { HErr res = H5Tset_size(hid, t); res.check("DataType::size: Could not set size"); } size_t DataType::size() const { return H5Tget_size(hid); } bool DataType::isVariableString() const { HTri res = H5Tis_variable_str(hid); res.check("DataType::isVariableString(): H5Tis_variable_str failed"); return res.result(); } } h5x::DataType data_type_to_h5_filetype(DataType dtype) { switch (dtype) { case DataType::Bool: return h5x::DataType::copy(H5T_STD_B8LE); case DataType::Int8: return h5x::DataType::copy(H5T_STD_I8LE); case DataType::Int16: return h5x::DataType::copy(H5T_STD_I16LE); case DataType::Int32: return h5x::DataType::copy(H5T_STD_I32LE); case DataType::Int64: return h5x::DataType::copy(H5T_STD_I64LE); case DataType::UInt8: return h5x::DataType::copy(H5T_STD_U8LE); case DataType::UInt16: return h5x::DataType::copy(H5T_STD_U16LE); case DataType::UInt32: return h5x::DataType::copy(H5T_STD_U32LE); case DataType::UInt64: return h5x::DataType::copy(H5T_STD_U64LE); case DataType::Float: return h5x::DataType::copy(H5T_IEEE_F32LE); case DataType::Double: return h5x::DataType::copy(H5T_IEEE_F64LE); case DataType::String: return h5x::DataType::makeStrType(); case DataType::Opaque: return h5x::DataType::copy(H5T_NATIVE_OPAQUE); case DataType::Char: break; case DataType::Nothing: break; case DataType::Date: break; case DataType::DateTime: break; } throw std::invalid_argument("Unkown DataType"); } h5x::DataType data_type_to_h5_memtype(DataType dtype) { switch(dtype) { case DataType::Bool: return h5x::DataType::copy(H5T_NATIVE_B8); case DataType::Int8: return h5x::DataType::copy(H5T_NATIVE_INT8); case DataType::Int16: return h5x::DataType::copy(H5T_NATIVE_INT16); case DataType::Int32: return h5x::DataType::copy(H5T_NATIVE_INT32); case DataType::Int64: return h5x::DataType::copy(H5T_NATIVE_INT64); case DataType::UInt8: return h5x::DataType::copy(H5T_NATIVE_UINT8); case DataType::UInt16: return h5x::DataType::copy(H5T_NATIVE_UINT16); case DataType::UInt32: return h5x::DataType::copy(H5T_NATIVE_UINT32); case DataType::UInt64: return h5x::DataType::copy(H5T_NATIVE_UINT64); case DataType::Float: return h5x::DataType::copy(H5T_NATIVE_FLOAT); case DataType::Double: return h5x::DataType::copy(H5T_NATIVE_DOUBLE); case DataType::String: return h5x::DataType::makeStrType(); case DataType::Opaque: return h5x::DataType::copy(H5T_NATIVE_OPAQUE); case DataType::Char: break; case DataType::Nothing: break; case DataType::Date: break; case DataType::DateTime: break; } throw std::invalid_argument("DataType not handled!"); } #define NOT_IMPLEMENTED false DataType data_type_from_h5(H5T_class_t vclass, size_t vsize, H5T_sign_t vsign) { if (vclass == H5T_INTEGER) { switch (vsize) { case 1: return vsign == H5T_SGN_2 ? DataType::Int8 : DataType::UInt8; case 2: return vsign == H5T_SGN_2 ? DataType::Int16 : DataType::UInt16; case 4: return vsign == H5T_SGN_2 ? DataType::Int32 : DataType::UInt32; case 8: return vsign == H5T_SGN_2 ? DataType::Int64 : DataType::UInt64; } } else if (vclass == H5T_FLOAT) { return vsize == 8 ? DataType::Double : DataType::Float; } else if (vclass == H5T_STRING) { return DataType::String; } else if (vclass == H5T_BITFIELD) { switch (vsize) { case 1: return DataType::Bool; } } std::cerr << "FIXME: Not implemented " << vclass << " " << vsize << " " << vsign << " " << std::endl; assert(NOT_IMPLEMENTED); return DataType::Nothing; } } }
#include <nix/hdf5/DataTypeHDF5.hpp> #include <stdexcept> #include <iostream> #include <cassert> namespace nix { namespace hdf5 { namespace h5x { DataType DataType::copy(hid_t source) { DataType hi_copy = H5Tcopy(source); hi_copy.check("Could not copy type"); return hi_copy; } DataType DataType::makeStrType(size_t size) { DataType str_type = H5Tcopy(H5T_C_S1); str_type.check("Could not create string type"); str_type.size(size); return str_type; } void DataType::size(size_t t) { HErr res = H5Tset_size(hid, t); res.check("DataType::size: Could not set size"); } size_t DataType::size() const { return H5Tget_size(hid); } bool DataType::isVariableString() const { HTri res = H5Tis_variable_str(hid); res.check("DataType::isVariableString(): H5Tis_variable_str failed"); return res.result(); } } h5x::DataType data_type_to_h5_filetype(DataType dtype) { switch (dtype) { case DataType::Bool: return h5x::DataType::copy(H5T_STD_B8LE); case DataType::Int8: return h5x::DataType::copy(H5T_STD_I8LE); case DataType::Int16: return h5x::DataType::copy(H5T_STD_I16LE); case DataType::Int32: return h5x::DataType::copy(H5T_STD_I32LE); case DataType::Int64: return h5x::DataType::copy(H5T_STD_I64LE); case DataType::UInt8: return h5x::DataType::copy(H5T_STD_U8LE); case DataType::UInt16: return h5x::DataType::copy(H5T_STD_U16LE); case DataType::UInt32: return h5x::DataType::copy(H5T_STD_U32LE); case DataType::UInt64: return h5x::DataType::copy(H5T_STD_U64LE); case DataType::Float: return h5x::DataType::copy(H5T_IEEE_F32LE); case DataType::Double: return h5x::DataType::copy(H5T_IEEE_F64LE); case DataType::String: return h5x::DataType::makeStrType(); case DataType::Opaque: return h5x::DataType::copy(H5T_NATIVE_OPAQUE); case DataType::Char: break; case DataType::Nothing: break; case DataType::Date: break; case DataType::DateTime: break; } throw std::invalid_argument("Unkown DataType"); } h5x::DataType data_type_to_h5_memtype(DataType dtype) { switch(dtype) { case DataType::Bool: return h5x::DataType::copy(H5T_NATIVE_B8); case DataType::Int8: return h5x::DataType::copy(H5T_NATIVE_INT8); case DataType::Int16: return h5x::DataType::copy(H5T_NATIVE_INT16); case DataType::Int32: return h5x::DataType::copy(H5T_NATIVE_INT32); case DataType::Int64: return h5x::DataType::copy(H5T_NATIVE_INT64); case DataType::UInt8: return h5x::DataType::copy(H5T_NATIVE_UINT8); case DataType::UInt16: return h5x::DataType::copy(H5T_NATIVE_UINT16); case DataType::UInt32: return h5x::DataType::copy(H5T_NATIVE_UINT32); case DataType::UInt64: return h5x::DataType::copy(H5T_NATIVE_UINT64); case DataType::Float: return h5x::DataType::copy(H5T_NATIVE_FLOAT); case DataType::Double: return h5x::DataType::copy(H5T_NATIVE_DOUBLE); case DataType::String: return h5x::DataType::makeStrType(); case DataType::Opaque: return h5x::DataType::copy(H5T_NATIVE_OPAQUE); case DataType::Char: break; case DataType::Nothing: break; case DataType::Date: break; case DataType::DateTime: break; } throw std::invalid_argument("DataType not handled!"); } #define NOT_IMPLEMENTED false DataType data_type_from_h5(H5T_class_t vclass, size_t vsize, H5T_sign_t vsign) { if (vclass == H5T_INTEGER) { switch (vsize) { case 1: return vsign == H5T_SGN_2 ? DataType::Int8 : DataType::UInt8; case 2: return vsign == H5T_SGN_2 ? DataType::Int16 : DataType::UInt16; case 4: return vsign == H5T_SGN_2 ? DataType::Int32 : DataType::UInt32; case 8: return vsign == H5T_SGN_2 ? DataType::Int64 : DataType::UInt64; } } else if (vclass == H5T_FLOAT) { return vsize == 8 ? DataType::Double : DataType::Float; } else
std::cerr << "FIXME: Not implemented " << vclass << " " << vsize << " " << vsign << " " << std::endl; assert(NOT_IMPLEMENTED); return DataType::Nothing; } } }
if (vclass == H5T_STRING) { return DataType::String; } else if (vclass == H5T_BITFIELD) { switch (vsize) { case 1: return DataType::Bool; } }
if_condition
[ { "content": "struct to_data_type<bool> {\n\n static const bool is_valid = true;\n\n static const DataType value = DataType::Bool;\n\n};\n\n\n\n/**\n\n * @brief Determine if a type is a valid data type.\n\n */\n\ntemplate<>\n", "file_path": "include/nix/DataType.hpp", "rank": 0, "score": 187458.8884167712 }, { "content": "struct to_data_type<std::string> {\n\n static const bool is_valid = true;\n\n static const DataType value = DataType::String;\n\n};\n\n\n\n/**\n\n * @brief Determine the size of a data type.\n\n *\n\n * @param dtype The data type.\n\n *\n\n * @return The size of the type.\n\n */\n\nNIXAPI size_t data_type_to_size(DataType dtype);\n\n\n\n/**\n\n * @brief Convert a data type into string representation.\n\n *\n\n * @param dtype The data type.\n\n *\n\n * @return A human readable name for the given type.\n", "file_path": "include/nix/DataType.hpp", "rank": 1, "score": 179598.83164520582 }, { "content": "struct to_data_type<const char *> {\n\n static const bool is_valid = true;\n\n static const DataType value = DataType::String;\n\n};\n\n\n\nnamespace hdf5 {\n\n\n\nDataSet::DataSet(hid_t hid)\n\n : LocID(hid) {\n\n\n\n}\n\n\n\nDataSet::DataSet(const DataSet &other)\n\n : LocID(other) {\n\n\n\n}\n\n\n\nvoid DataSet::read(hid_t memType, void *data) const\n\n{\n\n HErr res = H5Dread(hid, memType, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);\n", "file_path": "src/hdf5/DataSetHDF5.cpp", "rank": 2, "score": 178194.76609172154 }, { "content": "class NIXAPI DataType : public hdf5::BaseHDF5 {\n\n\n\npublic:\n\n DataType() : BaseHDF5() { }\n\n DataType(hid_t hid) : BaseHDF5(hid, false) { }\n\n DataType(hid_t hid, bool is_copy) : BaseHDF5(hid, is_copy) { }\n\n DataType(const DataType &other) : BaseHDF5(other) { }\n\n\n\n\n\n //Basically the same as DataType(hid_t, true)\n\n // but more explicit, so it is easier in the code\n\n // to read\n\n static DataType copy(hid_t);\n\n static DataType makeStrType(size_t size = H5T_VARIABLE);\n\n\n\n\n\n void size(size_t);\n\n size_t size() const;\n\n\n\n bool isVariableString() const;\n", "file_path": "include/nix/hdf5/DataTypeHDF5.hpp", "rank": 3, "score": 176261.27417330773 }, { "content": " ndsize_t sourceCount() const;\n\n\n\n\n\n std::shared_ptr<base::ISource> createSource(const std::string &name, const std::string &type);\n\n\n\n\n\n bool deleteSource(const std::string &name_or_id);\n\n\n\n //--------------------------------------------------\n\n // Other methods and functions\n\n //--------------------------------------------------\n\n\n\n\n\n virtual ~SourceHDF5();\n\n};\n\n\n\n\n\n} // namestace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_SOURCE_HDF5_H\n", "file_path": "include/nix/hdf5/SourceHDF5.hpp", "rank": 4, "score": 165115.20494374807 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_SOURCE_HDF5_H\n\n#define NIX_SOURCE_HDF5_H\n\n\n\n#include <nix/base/ISource.hpp>\n\n#include <nix/hdf5/EntityWithMetadataHDF5.hpp>\n\n\n\n#include <vector>\n\n#include <string>\n\n#include <boost/optional.hpp>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n/**\n\n * An entity that implements ISource for the HDF5 back-end.\n\n */\n", "file_path": "include/nix/hdf5/SourceHDF5.hpp", "rank": 5, "score": 165111.73744237775 }, { "content": " /**\n\n * Default constructor that preserves the creation time.\n\n */\n\n SourceHDF5(const std::shared_ptr<base::IFile> &file, const Group &group, const std::string &id, const std::string &type,\n\n const std::string &name, time_t time);\n\n\n\n //--------------------------------------------------\n\n // Methods concerning child sources\n\n //--------------------------------------------------\n\n\n\n\n\n bool hasSource(const std::string &name_or_id) const;\n\n\n\n \n\n std::shared_ptr<base::ISource> getSource(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ISource> getSource(size_t index) const;\n\n\n\n\n", "file_path": "include/nix/hdf5/SourceHDF5.hpp", "rank": 6, "score": 165103.1501124621 }, { "content": "class Source;\n", "file_path": "include/nix/types.hpp", "rank": 7, "score": 161535.6549966072 }, { "content": "};\n\n\n\n}\n\n\n\n\n\nNIXAPI h5x::DataType data_type_to_h5_filetype(DataType dtype);\n\n\n\n\n\nNIXAPI h5x::DataType data_type_to_h5_memtype(DataType dtype);\n\n\n\nNIXAPI DataType data_type_from_h5(H5T_class_t vclass, size_t vsize, H5T_sign_t vsign);\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif //NIX_DATA_TYPE_HDF5_H\n", "file_path": "include/nix/hdf5/DataTypeHDF5.hpp", "rank": 8, "score": 159280.79478893062 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_DATA_TYPE_HDF5_H\n\n#define NIX_DATA_TYPE_HDF5_H\n\n\n\n#include <nix/DataType.hpp>\n\n#include <nix/hdf5/BaseHDF5.hpp>\n\n\n\n#include <nix/Platform.hpp>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\nnamespace h5x {\n\n\n", "file_path": "include/nix/hdf5/DataTypeHDF5.hpp", "rank": 9, "score": 159269.66938167394 }, { "content": " void vlenReclaim(h5x::DataType mem_type, void *data, DataSpace *dspace = nullptr) const;\n\n\n\n static h5x::DataType fileTypeForValue(DataType dtype);\n\n static h5x::DataType memTypeForValue(DataType dtype);\n\n\n\n DataType dataType(void) const;\n\n\n\n DataSpace getSpace() const;\n\n};\n\n\n\n\n\n\n\n/**\n\n * Read *all* the data from a DataSet into memory\n\n *\n\n * @param value Reference to a variable to store the data in\n\n * @param resize Resize variable to fit the size of the DataSet\n\n */\n\ntemplate<typename T> void DataSet::read(T &value, bool resize) const\n\n{\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 10, "score": 159231.27123502677 }, { "content": " *\n\n * NB: Size of the DataSet and the variable must be the same\n\n * @param value Reference to a variable to read the data from\n\n * @param fileSel Selection to indicate into which subspace of value to read data from\n\n * @param memSel Selection to indicate into which subspace of the DataSpace to write to\n\n */\n\ntemplate<typename T> void DataSet::write(const T &value, const Selection &fileSel, const Selection &memSel)\n\n{\n\n const Hydra<const T> hydra(value);\n\n DataType dtype = hydra.element_data_type();\n\n\n\n this->write(dtype, hydra.data(), fileSel, memSel);\n\n}\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_DATASET_H\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 11, "score": 159230.00361643767 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_DATASET_H\n\n#define NIX_DATASET_H\n\n\n\n#include <nix/hdf5/Selection.hpp>\n\n#include <nix/hdf5/DataSpace.hpp>\n\n#include <nix/hdf5/DataTypeHDF5.hpp>\n\n#include <nix/hdf5/LocID.hpp>\n\n#include <nix/Hydra.hpp>\n\n#include <nix/Value.hpp>\n\n\n\n#include <nix/Platform.hpp>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 12, "score": 159227.72505587788 }, { "content": "\n\n void read(std::vector<Value> &values) const;\n\n void write(const std::vector<Value> &values);\n\n\n\n template<typename T> void read(T &value, bool resize = false) const;\n\n template<typename T> void read(T &value, const Selection &fileSel, bool resize = false) const;\n\n template<typename T> void read(T &value, const Selection &fileSel, const Selection &memSel) const;\n\n\n\n template<typename T> void write(const T &value);\n\n template<typename T> void write(const T &value, const Selection &fileSel);\n\n template<typename T> void write(const T &value, const Selection &fileSel, const Selection &memSel);\n\n\n\n static NDSize guessChunking(NDSize dims, DataType dtype);\n\n\n\n static NDSize guessChunking(NDSize dims, size_t element_size);\n\n\n\n void setExtent(const NDSize &dims);\n\n Selection createSelection() const;\n\n NDSize size() const;\n\n\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 13, "score": 159224.47737824425 }, { "content": "\n\n DataType dtype = hydra.element_data_type();\n\n NDSize size = hydra.shape();\n\n write(dtype, size, hydra.data());\n\n}\n\n\n\n/**\n\n * Write all memory stored in the variable value into a *selected* subspace of the DataSet\n\n *\n\n * NB: Size of the DataSet and the variable must be the same\n\n * @param value Reference to a variable to read the data from\n\n * @param fileSel Selection to indicate into which subspace of value to read data from\n\n */\n\ntemplate<typename T> void DataSet::write(const T &value, const Selection &fileSel)\n\n{\n\n write(value, fileSel, Selection(value));\n\n}\n\n\n\n/**\n\n * Write a *selected part* of memory stored in the variable value into a *selected* subspace of the DataSet\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 14, "score": 159221.25264686157 }, { "content": " */\n\ntemplate<typename T> void DataSet::read(T &value, const Selection &fileSel, const Selection &memSel) const\n\n{\n\n Hydra<T> hydra(value);\n\n\n\n DataType dtype = hydra.element_data_type();\n\n this->read(dtype, hydra.data(), fileSel, memSel);\n\n}\n\n\n\n/* ************************************************************************* */\n\n\n\n/**\n\n * Write all memory stored in the variable value into all of the DataSet\n\n *\n\n * NB: Size of the DataSet and the variable must be the same\n\n * @param value Reference to a variable to read the data from\n\n */\n\ntemplate<typename T> void DataSet::write(const T &value)\n\n{\n\n const Hydra<const T> hydra(value);\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 15, "score": 159221.08490874353 }, { "content": " Hydra<T> hydra(value);\n\n\n\n if (resize) {\n\n NDSize dims = this->size();\n\n hydra.resize(dims);\n\n }\n\n\n\n DataType dtype = hydra.element_data_type();\n\n NDSize size = hydra.shape();\n\n read(dtype, size, hydra.data());\n\n}\n\n\n\n/**\n\n * Read *selected* data from a DataSet into memory\n\n *\n\n * NB: Since this function assumes that whole variable is being read into,\n\n * the number of selected elements in fileSel and the size of the variable value\n\n * must be the same\n\n *\n\n * @param value Reference to a variable to store the data in\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 16, "score": 159217.84637016436 }, { "content": " * @param fileSel Selection to indicate which subspace of the DataSet to read\n\n * @param resize Resize variable to fit the size of the Selection\n\n */\n\ntemplate<typename T> void DataSet::read(T &value, const Selection &fileSel, bool resize) const\n\n{\n\n if (resize) {\n\n Hydra<T> hydra(value);\n\n NDSize fsize = fileSel.size();\n\n hydra.resize(fsize);\n\n }\n\n\n\n read(value, fileSel, Selection(value));\n\n}\n\n\n\n/**\n\n * Read *selected* data from a DataSet into *selected part* of memory\n\n *\n\n * @param value Reference to a variable to store the data in\n\n * @param fileSel Selection to indicate which subspace of the DataSet to read\n\n * @param memSel Selection to indicate which subspace of the memory to read into\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 17, "score": 159215.11833149169 }, { "content": " void addSource(const std::string &id);\n\n\n\n\n\n bool removeSource(const std::string &id);\n\n\n\n\n\n std::shared_ptr<base::ISource> getSource(const std::string &id) const;\n\n\n\n\n\n std::shared_ptr<base::ISource> getSource(const size_t index) const;\n\n\n\n /**\n\n * Destructor.\n\n */\n\n virtual ~EntityWithSourcesHDF5();\n\n\n\n\n\n std::shared_ptr<base::IBlock> block() const;\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif /* NIX_ENTITY_WITH_SOURCES_HDF5_H */\n", "file_path": "include/nix/hdf5/EntityWithSourcesHDF5.hpp", "rank": 18, "score": 159192.5585401756 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_ENTITY_WITH_SOURCES_HDF5_H\n\n#define NIX_ENTITY_WITH_SOURCES_HDF5_H\n\n\n\n#include <nix/base/IBlock.hpp>\n\n#include <nix/base/IEntityWithSources.hpp>\n\n#include <nix/hdf5/SourceHDF5.hpp>\n\n#include <nix/hdf5/EntityWithMetadataHDF5.hpp>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n\n\n/**\n\n * Base class for entities that are associated with sources.\n\n */\n", "file_path": "include/nix/hdf5/EntityWithSourcesHDF5.hpp", "rank": 19, "score": 159183.73691900552 }, { "content": " /**\n\n * Standard constructor for new entity that preserves the creation time.\n\n */\n\n EntityWithSourcesHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group,\n\n const std::string &id, const std::string &type, const std::string &name, time_t time);\n\n\n\n ndsize_t sourceCount() const;\n\n\n\n\n\n bool hasSource(const std::string &id) const;\n\n\n\n /**\n\n * @brief Set all sources associations for this entity.\n\n *\n\n * All previously existing associations will be overwritten.\n\n *\n\n * @param sources A vector with all sources.\n\n */\n\n void sources(const std::vector<Source> &sources);\n\n\n", "file_path": "include/nix/hdf5/EntityWithSourcesHDF5.hpp", "rank": 20, "score": 159180.80388848792 }, { "content": "class SetDimension;\n", "file_path": "include/nix/types.hpp", "rank": 21, "score": 154833.4904697389 }, { "content": "class DataSet;\n", "file_path": "include/nix/types.hpp", "rank": 22, "score": 154833.4904697389 }, { "content": "class StringReader {\n\npublic:\n\n typedef const std::string value_type;\n\n typedef value_type *pointer;\n\n typedef const char *data_type;\n\n typedef data_type *data_ptr;\n\n\n\n\n\n StringReader(const NDSize &size, pointer stringdata)\n\n : nelms(size.nelms()), data(stringdata) {\n\n\t\tsize_t bs = nix::check::fits_in_size_t(nelms,\n\n \"Cannot allocate storage (exceeds memory)\");\n\n buffer = new data_type[bs];\n\n for (ndsize_t i = 0; i < bs; i++) {\n\n buffer[i] = data[i].c_str();\n\n }\n\n }\n\n\n\n data_ptr operator*() {\n\n return buffer;\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 23, "score": 153916.4498917899 }, { "content": "class StringWriter {\n\npublic:\n\n typedef std::string value_type;\n\n typedef value_type *pointer;\n\n typedef char *data_type;\n\n typedef data_type *data_ptr;\n\n\n\n\n\n StringWriter(const NDSize &size, pointer stringdata)\n\n : nelms(size.nelms()), data(stringdata) {\n\n\t\tsize_t bs = nix::check::fits_in_size_t(nelms,\n\n \"Cannot allocate storage (exceeds memory)\");\n\n buffer = new data_type[bs];\n\n }\n\n\n\n data_ptr operator*() {\n\n return buffer;\n\n }\n\n\n\n void finish() {\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 24, "score": 153916.4498917899 }, { "content": "struct SourceLocation {\n\n\n\n SourceLocation(const std::string &fp, int fl, const std::string &fs) :\n\n filepath(fp), fileline(fl), funcsig(fs) {}\n\n std::string filepath;\n\n int fileline;\n\n std::string funcsig;\n\n\n\n};\n\n\n\nNIXAPI void check_h5_arg_name_loc(const std::string &name, const SourceLocation &location);\n\n#define check_h5_arg_name(name__) nix::hdf5::check::check_h5_arg_name_loc(name__, {NIX_SRC_FILE, \\\n\n NIX_SRC_LINE, \\\n\n NIX_SRC_FUNC})\n\n\n\n} //nix::hdf5::check\n\n} // nix::hdf5\n\n} // nix::\n\n\n\n\n\n#endif", "file_path": "include/nix/hdf5/ExceptionHDF5.hpp", "rank": 25, "score": 153653.97099021784 }, { "content": "class SourceHDF5 : virtual public base::ISource, public EntityWithMetadataHDF5 {\n\n\n\nprivate:\n\n\n\n optGroup source_group;\n\n\n\npublic:\n\n\n\n\n\n /**\n\n * Standard constructor for existing Source\n\n */\n\n SourceHDF5(const std::shared_ptr<base::IFile> &file, const Group &group);\n\n\n\n /**\n\n * Default constructor.\n\n */\n\n SourceHDF5(const std::shared_ptr<base::IFile> &file, const Group &group, const std::string &id, const std::string &type,\n\n const std::string &name);\n\n\n", "file_path": "include/nix/hdf5/SourceHDF5.hpp", "rank": 26, "score": 151616.2053262613 }, { "content": "struct FileValue<bool> {\n\n\n\n unsigned char value;\n\n\n\n double uncertainty;\n\n char *reference;\n\n char *filename;\n\n char *encoder;\n\n char *checksum;\n\n\n\n //ctors\n\n FileValue() {}\n\n explicit FileValue(const bool &vref) :\n\n value(static_cast<unsigned char>(vref ? 1 : 0)) {\n\n }\n\n\n\n inline bool val() const { return value > 0; }\n\n};\n\n\n\n//\n\n\n", "file_path": "src/hdf5/DataSetHDF5.cpp", "rank": 27, "score": 150184.43199644933 }, { "content": "struct NIXAPI HErr {\n\n typedef herr_t value_type;\n\n\n\n HErr() : value(static_cast<value_type>(-1)) { }\n\n HErr(value_type result) : value(result) {}\n\n\n\n inline bool isError() {\n\n return value < 0;\n\n }\n\n\n\n explicit operator bool() {\n\n return !isError();\n\n }\n\n\n\n inline bool check(const std::string &msg) {\n\n if (isError()) {\n\n throw H5Error(value, msg);\n\n }\n\n\n\n return true;\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 28, "score": 145047.90665479575 }, { "content": "struct NIXAPI HTri {\n\n typedef htri_t value_type;\n\n\n\n HTri(value_type result) : value(result) {}\n\n\n\n inline bool result() {\n\n return value > 0;\n\n }\n\n\n\n inline bool isError() {\n\n return value < 0;\n\n }\n\n\n\n explicit operator bool() {\n\n return result();\n\n }\n\n\n\n inline bool check(const std::string &msg) {\n\n if (value < 0) {\n\n throw H5Exception(msg);\n\n }\n\n\n\n return result();\n\n }\n\n\n\n value_type value;\n\n};\n\n\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 29, "score": 145047.90665479575 }, { "content": "class NIXAPI DataSet : public LocID {\n\n\n\npublic:\n\n\n\n DataSet() : LocID() { };\n\n\n\n DataSet(hid_t hid);\n\n\n\n DataSet(hid_t hid, bool is_copy) : LocID(hid, is_copy) { }\n\n\n\n DataSet(const DataSet &other);\n\n\n\n void read(hid_t memType, void *data) const;\n\n void write(hid_t memType, const void *data);\n\n\n\n void read(DataType dtype, const NDSize &size, void *data) const;\n\n void write(DataType dtype, const NDSize &size, const void *data);\n\n\n\n void read(DataType dtype, void *data, const Selection &fileSel, const Selection &memSel) const;\n\n void write(DataType dtype, const void *data, const Selection &fileSel, const Selection &memSel);\n", "file_path": "include/nix/hdf5/DataSetHDF5.hpp", "rank": 30, "score": 143785.1000131018 }, { "content": "class EntityWithSourcesHDF5: public virtual base::IEntityWithSources, public EntityWithMetadataHDF5 {\n\n\n\nprivate:\n\n\n\n std::shared_ptr<base::IBlock> entity_block;\n\n optGroup sources_refs;\n\n\n\npublic:\n\n\n\n /**\n\n * Standard constructor for existing entity.\n\n */\n\n EntityWithSourcesHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group);\n\n \n\n /**\n\n * Standard constructor for new entity.\n\n */\n\n EntityWithSourcesHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group,\n\n const std::string &id, const std::string &type, const std::string &name);\n\n\n", "file_path": "include/nix/hdf5/EntityWithSourcesHDF5.hpp", "rank": 31, "score": 143045.6420079654 }, { "content": "class SetDimensionHDF5 : virtual public base::ISetDimension, public DimensionHDF5 {\n\n\n\npublic:\n\n\n\n SetDimensionHDF5(const Group &group, size_t index);\n\n\n\n\n\n DimensionType dimensionType() const;\n\n\n\n\n\n std::vector<std::string> labels() const;\n\n\n\n\n\n void labels(const std::vector<std::string> &labels);\n\n\n\n\n\n void labels(const none_t t);\n\n\n\n\n\n virtual ~SetDimensionHDF5();\n\n\n\n};\n\n\n\n\n", "file_path": "include/nix/hdf5/DimensionHDF5.hpp", "rank": 32, "score": 141501.51656165742 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_TYPES_H\n\n#define NIX_TYPES_H\n\n\n\nnamespace nix {\n\n\n\n// Can be used for forward declaration\n", "file_path": "include/nix/types.hpp", "rank": 33, "score": 125216.36184736247 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_SOURCE_H\n\n#define NIX_SOURCE_H\n\n\n\n#include <nix/util/filter.hpp>\n\n#include <nix/base/EntityWithMetadata.hpp>\n\n#include <nix/base/ISource.hpp>\n\n\n\n#include <nix/Platform.hpp>\n\n\n\n#include <ostream>\n\n#include <string>\n\n\n", "file_path": "include/nix/Source.hpp", "rank": 34, "score": 125128.72437020588 }, { "content": " * @return The created source object.\n\n */\n\n Source createSource(const std::string &name, const std::string &type) {\n\n return backend()->createSource(name, type);\n\n }\n\n\n\n /**\n\n * @brief Delete a root source and all its child sources from\n\n * the source.\n\n *\n\n * @param name_or_id The name or id of the source to remove.\n\n *\n\n * @return True if the source was deleted, false otherwise.\n\n */\n\n bool deleteSource(const std::string &name_or_id) {\n\n return backend()->deleteSource(name_or_id);\n\n }\n\n\n\n /**\n\n * @brief Delete a root source and all its child sources from\n", "file_path": "include/nix/Source.hpp", "rank": 35, "score": 125128.51332545585 }, { "content": "\n\n /**\n\n * @brief Copy constructor.\n\n *\n\n * Copying of all NIX front facing objects like Source is a rather cheap operation.\n\n * Semantically this is equivalent to the creation of another reference to the original\n\n * object.\n\n *\n\n * @param other The source to copy.\n\n */\n\n Source(const Source &other);\n\n\n\n /**\n\n * @brief Constructor that creates a new source from a shared pointer to\n\n * an implementation instance.\n\n *\n\n * This constructor should only be used in the back-end.\n\n */\n\n Source(const std::shared_ptr<base::ISource> &p_impl);\n\n\n", "file_path": "include/nix/Source.hpp", "rank": 36, "score": 125127.32493333795 }, { "content": " */\n\n Source getSource(const std::string &name_or_id) const {\n\n return backend()->getSource(name_or_id);\n\n }\n\n\n\n /**\n\n * @brief Retrieves a specific source by index.\n\n *\n\n * @param index The index of the source.\n\n *\n\n * @return The source at the specified index.\n\n */\n\n Source getSource(size_t index) const {\n\n return backend()->getSource(index);\n\n }\n\n\n\n /**\n\n * @brief Returns the number of sources that are direct descendants of this source.\n\n *\n\n * @return The number of direct child sources.\n", "file_path": "include/nix/Source.hpp", "rank": 37, "score": 125125.61086268221 }, { "content": " /**\n\n * @brief Output operator\n\n */\n\n NIXAPI friend std::ostream& operator<<(std::ostream &out, const Source &ent);\n\n\n\n};\n\n\n\n\n\n} // namespace nix\n\n\n\n#endif // NIX_SOURCE_H\n", "file_path": "include/nix/Source.hpp", "rank": 38, "score": 125123.63542121436 }, { "content": " bool hasSource(const std::string &name_or_id) const {\n\n return backend()->hasSource(name_or_id);\n\n }\n\n\n\n /**\n\n * @brief Checks if this source has a specific source as direct descendant.\n\n *\n\n * @param source The Source.\n\n *\n\n * @return True if a source is a direct descendant, false otherwise.\n\n */\n\n bool hasSource(const Source &source) const;\n\n\n\n /**\n\n * @brief Retrieves a specific child source that is a direct descendant.\n\n *\n\n * @param name_or_id The name or id of the source.\n\n *\n\n * @return The source with the given name/id. If it doesn't exist an exception\n\n * will be thrown.\n", "file_path": "include/nix/Source.hpp", "rank": 39, "score": 125122.72089542836 }, { "content": " * This method traverses the sub-tree of all child sources of the source. The traversal\n\n * is accomplished via breadth first and can be limited in depth. On each node or\n\n * source a filter is applied. If the filter returns true the respective source\n\n * will be added to the result list.\n\n * By default a filter is used that accepts all sources.\n\n *\n\n * @param filter A filter function.\n\n * @param max_depth The maximum depth of traversal.\n\n *\n\n * @return A vector containing the matching descendant sources.\n\n */\n\n std::vector<Source> findSources(const util::Filter<Source>::type &filter = util::AcceptAll<Source>(),\n\n size_t max_depth = std::numeric_limits<size_t>::max()) const;\n\n\n\n /**\n\n * @brief Create a new root source.\n\n *\n\n * @param name The name of the source to create.\n\n * @param type The type of the source.\n\n *\n", "file_path": "include/nix/Source.hpp", "rank": 40, "score": 125122.66841337683 }, { "content": "namespace nix {\n\n\n\n/**\n\n * @brief A class that describes the provenance of other entities of the NIX data model.\n\n *\n\n * The Source is conceptually a rather simple entity. I t is used to note the provenance of\n\n * the data and offers the opportunity to bind additional metadata.\n\n * One special feature of the Source is the possibility to contain other sources as children\n\n * thus building up a tree of sources.\n\n * This can, for example, be used to specify that a source electrode array contains\n\n * multiple electrodes as its child sources.\n\n */\n", "file_path": "include/nix/Source.hpp", "rank": 41, "score": 125122.43123934358 }, { "content": " * the source.\n\n *\n\n * @param source The Source to delete.\n\n *\n\n * @return True if the source was deleted, false otherwise.\n\n */\n\n bool deleteSource(const Source &source);\n\n\n\n //--------------------------------------------------\n\n // Other methods and functions\n\n //--------------------------------------------------\n\n\n\n /**\n\n * @brief Assignment operator for none.\n\n */\n\n Source &operator=(const none_t &t) {\n\n ImplContainer::operator=(t);\n\n return *this;\n\n }\n\n\n", "file_path": "include/nix/Source.hpp", "rank": 42, "score": 125118.81555403343 }, { "content": " /**\n\n * @brief Constructor with move semantics that creates a new source from a shared pointer to\n\n * an implementation instance.\n\n *\n\n * This constructor should only be used in the back-end.\n\n */\n\n Source(std::shared_ptr<base::ISource> &&ptr);\n\n\n\n //--------------------------------------------------\n\n // Methods concerning child sources\n\n //--------------------------------------------------\n\n\n\n /**\n\n * @brief Checks if this source has a specific source as direct descendant.\n\n *\n\n * @param name_or_id The name or id of the source.\n\n *\n\n * @return True if a source with the given name/id is a direct descendant, false\n\n * otherwise.\n\n */\n", "file_path": "include/nix/Source.hpp", "rank": 43, "score": 125118.01656528078 }, { "content": " */\n\n ndsize_t sourceCount() const {\n\n return backend()->sourceCount();\n\n }\n\n\n\n /**\n\n * @brief Get all direct child sources associated with this source.\n\n *\n\n * The parameter filter can be used to filter sources by various\n\n * criteria. By default a filter is used that accepts all sources.\n\n *\n\n * @param filter A filter function.\n\n *\n\n * @return A vector containing the matching child sources.\n\n */\n\n std::vector<Source> sources(const util::Filter<Source>::type &filter = util::AcceptAll<Source>()) const;\n\n\n\n /**\n\n * @brief Get all descendant sources of the source recursively.\n\n *\n", "file_path": "include/nix/Source.hpp", "rank": 44, "score": 125114.63634304704 }, { "content": "\n\n std::shared_ptr<base::IProperty> getProperty(size_t index) const;\n\n\n\n\n\n std::shared_ptr<base::IProperty> createProperty(const std::string &name, const DataType &dtype);\n\n\n\n\n\n std::shared_ptr<base::IProperty> createProperty(const std::string &name, const Value &value);\n\n\n\n\n\n std::shared_ptr<base::IProperty> createProperty(const std::string &name, const std::vector<Value> &values);\n\n\n\n\n\n bool deleteProperty(const std::string &name_or_id);\n\n\n\n //--------------------------------------------------\n\n // Ohter methods and operators\n\n //--------------------------------------------------\n\n\n\n virtual ~SectionHDF5();\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_SECTION_HDF5_H\n", "file_path": "include/nix/hdf5/SectionHDF5.hpp", "rank": 45, "score": 125068.5047856101 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_DIMENSIONS_HDF5_H\n\n#define NIX_DIMENSIONS_HDF5_H\n\n\n\n#include <nix/base/IDimensions.hpp>\n\n#include <nix/hdf5/Group.hpp>\n\n\n\n#include <string>\n\n#include <iostream>\n\n#include <ctime>\n\n#include <memory>\n\n\n\nnamespace nix {\n", "file_path": "include/nix/hdf5/DimensionHDF5.hpp", "rank": 46, "score": 125063.0459711879 }, { "content": "// Copyright © 2015 German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n//\n\n// Author: Christian Kellner <[email protected]>\n\n\n\n#ifndef NIX_EXCEPTION_H5_H\n\n#define NIX_EXCEPTION_H5_H\n\n\n\n#include <nix/Platform.hpp>\n\n\n\n#include <hdf5.h>\n\n\n\n#include <stdexcept>\n\n#include <string>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n", "file_path": "include/nix/hdf5/ExceptionHDF5.hpp", "rank": 47, "score": 125062.84972318001 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_SECTION_HDF5_H\n\n#define NIX_SECTION_HDF5_H\n\n\n\n#include <nix/hdf5/NamedEntityHDF5.hpp>\n\n#include <nix/base/ISection.hpp>\n\n#include <nix/Section.hpp>\n\n\n\n#include <string>\n\n#include <memory>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n", "file_path": "include/nix/hdf5/SectionHDF5.hpp", "rank": 48, "score": 125060.86674351369 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_FEATURE_HDF5_H\n\n#define NIX_FEATURE_HDF5_H\n\n\n\n#include <nix/base/IBlock.hpp>\n\n#include <nix/base/IFeature.hpp>\n\n#include <nix/hdf5/EntityHDF5.hpp>\n\n\n\n#include <string>\n\n#include <vector>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n", "file_path": "include/nix/hdf5/FeatureHDF5.hpp", "rank": 49, "score": 125060.86674351369 }, { "content": " * Standard constructor for new Feature with time\n\n */\n\n FeatureHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group,\n\n const std::string &id, DataArray data, LinkType link_type, time_t time);\n\n\n\n\n\n void linkType(LinkType type);\n\n\n\n\n\n LinkType linkType() const;\n\n\n\n\n\n void data(const std::string &name_or_id);\n\n\n\n\n\n std::shared_ptr<base::IDataArray> data() const;\n\n\n\n\n\n virtual ~FeatureHDF5();\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_FEATURE_HDF5_H\n", "file_path": "include/nix/hdf5/FeatureHDF5.hpp", "rank": 50, "score": 125060.7466060906 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_ENTITY_HDF5_H\n\n#define NIX_ENTITY_HDF5_H\n\n\n\n#include <nix/base/IFile.hpp>\n\n\n\n#include <nix/base/IEntity.hpp>\n\n#include <nix/hdf5/Group.hpp>\n\n\n\n#include <string>\n\n#include <memory>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n\n\n/**\n\n * HDF5 implementation of IEntity\n\n */\n", "file_path": "include/nix/hdf5/EntityHDF5.hpp", "rank": 51, "score": 125060.66722190386 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_FILE_HDF5_H\n\n#define NIX_FILE_HDF5_H\n\n\n\n#include <nix/base/IFile.hpp>\n\n\n\n#include <nix/hdf5/Group.hpp>\n\n\n\n#include <string>\n\n#include <memory>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n\n\n/**\n\n * Class that represents a NIX file.\n\n */\n", "file_path": "include/nix/hdf5/FileHDF5.hpp", "rank": 52, "score": 125060.57776307224 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_PROPERTY_HDF5_H\n\n#define NIX_PROPERTY_HDF5_H\n\n\n\n#include <nix/base/IFile.hpp>\n\n#include <nix/base/IEntity.hpp>\n\n#include <nix/base/IProperty.hpp>\n\n#include <nix/hdf5/NamedEntityHDF5.hpp>\n\n\n\n#include <string>\n\n#include <memory>\n\n#include <ctime>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n\n", "file_path": "include/nix/hdf5/PropertyHDF5.hpp", "rank": 53, "score": 125060.56459669935 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n#ifndef NIX_BLOCK_HDF5_H\n\n#define NIX_BLOCK_HDF5_H\n\n\n\n#include <nix/base/IBlock.hpp>\n\n#include <nix/hdf5/EntityWithMetadataHDF5.hpp>\n\n\n\n#include <vector>\n\n#include <string>\n\n#include <boost/optional.hpp>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n/**\n\n * Class that represents a NIX Block entity.\n\n */\n", "file_path": "include/nix/hdf5/BlockHDF5.hpp", "rank": 54, "score": 125060.37448538978 }, { "content": "\n\n time_t createdAt() const;\n\n\n\n\n\n void setUpdatedAt();\n\n\n\n\n\n void forceUpdatedAt();\n\n\n\n\n\n void setCreatedAt();\n\n\n\n\n\n void forceCreatedAt(time_t t);\n\n\n\n\n\n bool operator==(const EntityHDF5 &other) const;\n\n\n\n\n\n bool operator!=(const EntityHDF5 &other) const;\n", "file_path": "include/nix/hdf5/EntityHDF5.hpp", "rank": 55, "score": 125060.25145525213 }, { "content": "\n\n std::shared_ptr<base::IMultiTag> createMultiTag(const std::string &name, const std::string &type,\n\n const DataArray &positions);\n\n\n\n\n\n bool deleteMultiTag(const std::string &name_or_id);\n\n\n\n //--------------------------------------------------\n\n // Other methods and functions\n\n //--------------------------------------------------\n\n\n\n\n\n virtual ~BlockHDF5();\n\n\n\n\n\n std::shared_ptr<IBlock> block() const;\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_BLOCK_HDF5_H\n", "file_path": "include/nix/hdf5/BlockHDF5.hpp", "rank": 56, "score": 125060.0563306179 }, { "content": "// Copyright © 2015 German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n//\n\n// Author: Adrian Stoewer <[email protected]>\n\n// Christian Kellner <[email protected]>\n\n\n\n#ifndef NIX_WRAP_ID_H\n\n#define NIX_WRAP_ID_H\n\n\n\n#include <nix/Platform.hpp>\n\n#include <nix/Hydra.hpp>\n\n#include <nix/hdf5/ExceptionHDF5.hpp>\n\n\n\n#include <hdf5.h>\n\n\n\n#include <string>\n\n#include <boost/optional.hpp>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 57, "score": 125059.2896239165 }, { "content": "\n\n void setUpdatedAt();\n\n\n\n\n\n void forceUpdatedAt();\n\n\n\n\n\n void setCreatedAt();\n\n\n\n\n\n void forceCreatedAt(time_t t);\n\n\n\n\n\n void close() override;\n\n\n\n\n\n bool isOpen() const;\n\n\n\n\n\n bool operator==(const FileHDF5 &other) const;\n", "file_path": "include/nix/hdf5/FileHDF5.hpp", "rank": 58, "score": 125059.06748638338 }, { "content": "\n\n\n\n boost::optional<std::string> unit() const;\n\n\n\n\n\n void unit(const std::string &unit);\n\n\n\n\n\n void unit(const none_t t);\n\n\n\n\n\n std::vector<double> ticks() const;\n\n\n\n\n\n void ticks(const std::vector<double> &ticks);\n\n\n\n\n\n virtual ~RangeDimensionHDF5();\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_DIMENSIONS_HDF5_H\n", "file_path": "include/nix/hdf5/DimensionHDF5.hpp", "rank": 59, "score": 125058.24476183602 }, { "content": "\n\n bool operator!=(const PropertyHDF5 &other) const; //FIXME: not implemented\n\n\n\n\n\n virtual ~PropertyHDF5();\n\n\n\nprivate:\n\n\n\n DataSet dataset() const {\n\n return entity_dataset;\n\n }\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_PROPERTY_HDF5_H\n", "file_path": "include/nix/hdf5/PropertyHDF5.hpp", "rank": 60, "score": 125057.89313698755 }, { "content": "\n\n\n\n bool operator!=(const FileHDF5 &other) const;\n\n\n\n\n\n virtual ~FileHDF5();\n\n\n\nprivate:\n\n\n\n std::shared_ptr<base::IFile> file() const;\n\n\n\n // check for existence\n\n bool fileExists(const std::string &name) const;\n\n\n\n // check if the header of the file is valid\n\n bool checkHeader() const;\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_FILE_HDF5_H\n", "file_path": "include/nix/hdf5/FileHDF5.hpp", "rank": 61, "score": 125057.50724579665 }, { "content": "// Copyright (c) 2013, German Neuroinformatics Node (G-Node)\n\n//\n\n// All rights reserved.\n\n//\n\n// Redistribution and use in source and binary forms, with or without\n\n// modification, are permitted under the terms of the BSD License. See\n\n// LICENSE file in the root of the Project.\n\n\n\n\n\n#ifndef NIX_TAG_HDF5_H\n\n#define NIX_TAG_HDF5_H\n\n\n\n#include <nix/hdf5/BaseTagHDF5.hpp>\n\n#include <nix/base/ITag.hpp>\n\n\n\nnamespace nix {\n\nnamespace hdf5 {\n\n\n\n\n\n/**\n\n * Class that represents a NIX tag.\n\n */\n", "file_path": "include/nix/hdf5/TagHDF5.hpp", "rank": 62, "score": 125056.75031303533 }, { "content": "namespace hdf5 {\n\n\n\n\n\nDimensionType dimensionTypeFromStr(const std::string &str);\n\n\n\n\n\nstd::string dimensionTypeToStr(DimensionType dim);\n\n\n\n\n\nstd::shared_ptr<base::IDimension> openDimensionHDF5(const Group &group, size_t index);\n\n\n\n\n", "file_path": "include/nix/hdf5/DimensionHDF5.hpp", "rank": 63, "score": 125056.62579998044 }, { "content": "\n\n //--------------------------------------------------\n\n // Methods concerning data arrays\n\n //--------------------------------------------------\n\n\n\n bool hasDataArray(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::IDataArray> getDataArray(const std::string &name_or_id) const;\n\n\n\n \n\n std::shared_ptr<base::IDataArray> getDataArray(size_t index) const;\n\n\n\n\n\n ndsize_t dataArrayCount() const;\n\n\n\n\n\n std::shared_ptr<base::IDataArray> createDataArray(const std::string &name, const std::string &type,\n\n nix::DataType data_type, const NDSize &shape) override;\n\n\n", "file_path": "include/nix/hdf5/BlockHDF5.hpp", "rank": 64, "score": 125056.09196061843 }, { "content": " //--------------------------------------------------\n\n // Methods concerning sources\n\n //--------------------------------------------------\n\n\n\n bool hasSource(const std::string &name_or_id) const;\n\n\n\n \n\n std::shared_ptr<base::ISource> getSource(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ISource> getSource(size_t index) const;\n\n\n\n\n\n ndsize_t sourceCount() const;\n\n\n\n\n\n std::shared_ptr<base::ISource> createSource(const std::string &name, const std::string &type);\n\n\n\n\n\n bool deleteSource(const std::string &name_or_id);\n", "file_path": "include/nix/hdf5/BlockHDF5.hpp", "rank": 65, "score": 125056.02614151867 }, { "content": " BaseHDF5(BaseHDF5 &&other);\n\n\n\n BaseHDF5& operator=(const BaseHDF5 &other);\n\n\n\n BaseHDF5& operator=(BaseHDF5 &&other);\n\n\n\n bool operator==(const BaseHDF5 &other) const;\n\n\n\n bool operator!=(const BaseHDF5 &other) const;\n\n\n\n //NB: use the following functions with caution\n\n hid_t h5id() const; //no refcount increase\n\n\n\n int refCount() const;\n\n\n\n bool isValid() const;\n\n\n\n void check(const std::string &msg_if_fail) {\n\n if (!isValid()) {\n\n throw H5Exception(msg_if_fail);\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 66, "score": 125055.96125882985 }, { "content": " * Constructor for new Property with time\n\n */\n\n PropertyHDF5(const std::shared_ptr<base::IFile> &file, const DataSet &dataset, const std::string &id,\n\n const std::string &name, time_t time);\n\n\n\n\n\n std::string id() const;\n\n\n\n\n\n time_t updatedAt() const;\n\n\n\n\n\n time_t createdAt() const;\n\n\n\n\n\n void setUpdatedAt();\n\n\n\n\n\n void forceUpdatedAt();\n\n\n", "file_path": "include/nix/hdf5/PropertyHDF5.hpp", "rank": 67, "score": 125055.46922472118 }, { "content": "\n\n\n\n std::vector<double> extent() const;\n\n\n\n\n\n void extent(const std::vector<double> &extent);\n\n\n\n\n\n void extent(const none_t t);\n\n\n\n //--------------------------------------------------\n\n // Other methods and functions\n\n //--------------------------------------------------\n\n\n\n /**\n\n * Destructor.\n\n */\n\n virtual ~TagHDF5();\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_TAG_HDF5_H\n", "file_path": "include/nix/hdf5/TagHDF5.hpp", "rank": 68, "score": 125053.64581611063 }, { "content": "\n\n void setCreatedAt();\n\n\n\n\n\n void forceCreatedAt(time_t t);\n\n\n\n\n\n std::string name() const;\n\n\n\n\n\n boost::optional<std::string> definition() const;\n\n\n\n\n\n void definition(const std::string &definition);\n\n\n\n\n\n void definition(const none_t t);\n\n\n\n\n\n void mapping(const std::string &mapping);\n", "file_path": "include/nix/hdf5/PropertyHDF5.hpp", "rank": 69, "score": 125053.56488429956 }, { "content": " }\n\n\n\n value_type value;\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif /* NIX_WRAP_ID_H */\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 70, "score": 125053.3475950354 }, { "content": "\n\n\n\n/**\n\n * Converts a LinkType into a string.\n\n *\n\n * @param link_type The type to convert.\n\n */\n\nstd::string linkTypeToString(LinkType link_type);\n\n\n\n/**\n\n * Create a link type from a string. If no matching type\n\n * exists, an exception will be thrown.\n\n *\n\n * @return The link type that matches the string.\n\n */\n\nLinkType linkTypeFromString(const std::string &str);\n\n\n\n\n\n/**\n\n * Class that represents a NIX feature entity\n\n */\n", "file_path": "include/nix/hdf5/FeatureHDF5.hpp", "rank": 71, "score": 125052.09957687343 }, { "content": " //--------------------------------------------------\n\n\n\n\n\n ndsize_t blockCount() const;\n\n\n\n\n\n bool hasBlock(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::IBlock> getBlock(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::IBlock> getBlock(size_t index) const;\n\n\n\n\n\n std::shared_ptr<base::IBlock> createBlock(const std::string &name, const std::string &type);\n\n\n\n\n\n bool deleteBlock(const std::string &name_or_id);\n\n\n", "file_path": "include/nix/hdf5/FileHDF5.hpp", "rank": 72, "score": 125049.89143712039 }, { "content": " //--------------------------------------------------\n\n // Methods concerning sections\n\n //--------------------------------------------------\n\n\n\n bool hasSection(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ISection> getSection(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ISection> getSection(size_t index) const;\n\n\n\n\n\n ndsize_t sectionCount() const;\n\n\n\n\n\n std::shared_ptr<base::ISection> createSection(const std::string &name, const std::string &type);\n\n\n\n\n\n bool deleteSection(const std::string &name_or_id);\n", "file_path": "include/nix/hdf5/FileHDF5.hpp", "rank": 73, "score": 125049.64117396764 }, { "content": "\n\n bool deleteDataArray(const std::string &name_or_id);\n\n\n\n //--------------------------------------------------\n\n // Methods concerning tags.\n\n //--------------------------------------------------\n\n\n\n bool hasTag(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ITag> getTag(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ITag> getTag(size_t index) const;\n\n\n\n\n\n ndsize_t tagCount() const;\n\n\n\n\n\n std::shared_ptr<base::ITag> createTag(const std::string &name, const std::string &type,\n", "file_path": "include/nix/hdf5/BlockHDF5.hpp", "rank": 74, "score": 125049.55959526157 }, { "content": "\n\n\n\n Group group() const;\n\n\n\n\n\n virtual ~EntityHDF5();\n\n\n\nprotected:\n\n\n\n std::shared_ptr<base::IFile> file() const;\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_ENTITY_HDF5_H\n", "file_path": "include/nix/hdf5/EntityHDF5.hpp", "rank": 75, "score": 125049.12901800804 }, { "content": "\n\n\n\n boost::optional<std::string> mapping() const;\n\n\n\n\n\n void mapping(const none_t t);\n\n\n\n\n\n DataType dataType() const;\n\n\n\n\n\n void unit(const std::string &unit);\n\n\n\n\n\n boost::optional<std::string> unit() const;\n\n\n\n\n\n void unit(const none_t t);\n\n\n\n\n", "file_path": "include/nix/hdf5/PropertyHDF5.hpp", "rank": 76, "score": 125048.87964321938 }, { "content": " }\n\n }\n\n\n\n std::string name() const;\n\n\n\n virtual void close();\n\n\n\n virtual ~BaseHDF5();\n\n\n\nprotected:\n\n\n\n void inc() const;\n\n\n\n void dec() const;\n\n\n\n void invalidate();\n\n};\n\n\n\n\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 77, "score": 125047.63466511537 }, { "content": " * Constructor with parent that preserves the creation time.\n\n */\n\n SectionHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::ISection> &parent, const Group &group,\n\n const std::string &id, const std::string &type, const std::string &name, time_t time);\n\n\n\n\n\n //--------------------------------------------------\n\n // Attribute getter and setter\n\n //--------------------------------------------------\n\n\n\n void repository(const std::string &repository);\n\n\n\n\n\n boost::optional<std::string> repository() const;\n\n\n\n\n\n void repository(const none_t t);\n\n\n\n\n\n void link(const std::string &id);\n", "file_path": "include/nix/hdf5/SectionHDF5.hpp", "rank": 78, "score": 125046.78705512814 }, { "content": "\n\n\n\n std::shared_ptr<base::ISection> createSection(const std::string &name, const std::string &type);\n\n\n\n\n\n bool deleteSection(const std::string &name_or_id);\n\n\n\n //--------------------------------------------------\n\n // Methods for property access\n\n //--------------------------------------------------\n\n\n\n\n\n ndsize_t propertyCount() const;\n\n\n\n\n\n bool hasProperty(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::IProperty> getProperty(const std::string &name_or_id) const;\n\n\n", "file_path": "include/nix/hdf5/SectionHDF5.hpp", "rank": 79, "score": 125046.77033950333 }, { "content": " void deleteValues();\n\n\n\n\n\n ndsize_t valueCount() const;\n\n\n\n\n\n void values(const std::vector<Value> &values);\n\n\n\n\n\n std::vector<Value> values(void) const;\n\n\n\n\n\n void values(const boost::none_t t);\n\n\n\n\n\n int compare(const std::shared_ptr<IProperty> &other) const;\n\n\n\n\n\n bool operator==(const PropertyHDF5 &other) const; //FIXME: not implemented\n\n\n", "file_path": "include/nix/hdf5/PropertyHDF5.hpp", "rank": 80, "score": 125046.17854883707 }, { "content": " /**\n\n * Standard constructor for new Tag that preserves the creation time.\n\n */\n\n TagHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group, const std::string &id,\n\n const std::string &type, const std::string &name, const std::vector<double> &_position, const time_t time);\n\n\n\n\n\n std::vector<std::string> units() const;\n\n\n\n\n\n void units(const std::vector<std::string> &units);\n\n\n\n\n\n void units(const none_t t);\n\n\n\n\n\n std::vector<double> position() const;\n\n\n\n\n\n void position(const std::vector<double> &position);\n", "file_path": "include/nix/hdf5/TagHDF5.hpp", "rank": 81, "score": 125046.10561561596 }, { "content": " const std::vector<double> &position);\n\n\n\n\n\n bool deleteTag(const std::string &name_or_id);\n\n\n\n //--------------------------------------------------\n\n // Methods concerning multi tags.\n\n //--------------------------------------------------\n\n\n\n bool hasMultiTag(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::IMultiTag> getMultiTag(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::IMultiTag> getMultiTag(size_t index) const;\n\n\n\n\n\n ndsize_t multiTagCount() const;\n\n\n", "file_path": "include/nix/hdf5/BlockHDF5.hpp", "rank": 82, "score": 125045.62446975455 }, { "content": "\n\n\n\n std::shared_ptr<base::ISection> parent() const;\n\n\n\n\n\n //--------------------------------------------------\n\n // Methods for child section access\n\n //--------------------------------------------------\n\n\n\n\n\n ndsize_t sectionCount() const;\n\n\n\n\n\n bool hasSection(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ISection> getSection(const std::string &name_or_id) const;\n\n\n\n\n\n std::shared_ptr<base::ISection> getSection(size_t index) const;\n", "file_path": "include/nix/hdf5/SectionHDF5.hpp", "rank": 83, "score": 125044.7093910389 }, { "content": "\n\n /**\n\n * Standard constructor for new entity\n\n */\n\n SectionHDF5(const std::shared_ptr<base::IFile> &file, const Group &group, const std::string &id,\n\n const std::string &type, const std::string &name);\n\n\n\n /**\n\n * Standard constructor for new entity with parent.\n\n */\n\n SectionHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::ISection> &parent, const Group &group,\n\n const std::string &id, const std::string &type, const std::string &name);\n\n\n\n /**\n\n * Constructor that preserves the creation time.\n\n */\n\n SectionHDF5(const std::shared_ptr<base::IFile> &file, const Group &group, const std::string &id,\n\n const std::string &type, const std::string &name, time_t time);\n\n\n\n /**\n", "file_path": "include/nix/hdf5/SectionHDF5.hpp", "rank": 84, "score": 125043.14788103777 }, { "content": "\n\n\n\n std::shared_ptr<base::ISection> link() const;\n\n\n\n\n\n void link(const none_t t);\n\n\n\n\n\n void mapping(const std::string &mapping);\n\n\n\n\n\n boost::optional<std::string> mapping() const;\n\n\n\n\n\n void mapping(const none_t t);\n\n\n\n\n\n //--------------------------------------------------\n\n // Methods for parent access\n\n //--------------------------------------------------\n", "file_path": "include/nix/hdf5/SectionHDF5.hpp", "rank": 85, "score": 125043.14261493013 }, { "content": "\n\n\n\n boost::optional<std::string> unit() const;\n\n\n\n\n\n void unit(const std::string &unit);\n\n\n\n\n\n void unit(const none_t t);\n\n\n\n\n\n double samplingInterval() const;\n\n\n\n\n\n void samplingInterval(double sampling_interval);\n\n\n\n\n\n boost::optional<double> offset() const;\n\n\n\n\n", "file_path": "include/nix/hdf5/DimensionHDF5.hpp", "rank": 86, "score": 125043.09490909938 }, { "content": " void offset(double offset);\n\n\n\n\n\n void offset(const none_t t);\n\n\n\n\n\n virtual ~SampledDimensionHDF5();\n\n\n\n};\n\n\n\n\n", "file_path": "include/nix/hdf5/DimensionHDF5.hpp", "rank": 87, "score": 125042.82357415355 }, { "content": "\n\n //--------------------------------------------------\n\n // Methods for file attribute access.\n\n //--------------------------------------------------\n\n\n\n\n\n std::vector<int> version() const;\n\n\n\n\n\n std::string format() const;\n\n\n\n\n\n std::string location() const;\n\n\n\n\n\n time_t createdAt() const;\n\n\n\n\n\n time_t updatedAt() const;\n\n\n", "file_path": "include/nix/hdf5/FileHDF5.hpp", "rank": 88, "score": 125042.22896601257 }, { "content": " * @param file The file which contains this block.\n\n * @param group The group that represents the block inside the file.\n\n * @param id The id of this block.\n\n * @param type The type of this block.\n\n * @param name The name of this block.\n\n */\n\n BlockHDF5(const std::shared_ptr<base::IFile> &file, const Group &group, const std::string &id, const std::string &type, const std::string &name);\n\n\n\n /**\n\n * Standard constructor for a new Block.\n\n *\n\n * @param file The file which contains this block.\n\n * @param group The group that represents the block inside the file.\n\n * @param id The id of this block.\n\n * @param type The type of this block.\n\n * @param name The name of this block.\n\n * @param time The creation time of this block.\n\n */\n\n BlockHDF5(const std::shared_ptr<base::IFile> &file, const Group &group, const std::string &id, const std::string &type, const std::string &name, time_t time);\n\n\n", "file_path": "include/nix/hdf5/BlockHDF5.hpp", "rank": 89, "score": 125041.71800176198 }, { "content": " }\n\n\n\n ~StringReader() {\n\n delete[] buffer;\n\n }\n\n\n\nprivate:\n\n ndsize_t nelms;\n\n pointer data;\n\n data_ptr buffer;\n\n};\n\n\n\n\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 90, "score": 125037.03403334823 }, { "content": " for (ndsize_t i = 0; i < nelms; i++) {\n\n data[i] = buffer[i];\n\n }\n\n }\n\n\n\n ~StringWriter() {\n\n delete[] buffer;\n\n }\n\n\n\nprivate:\n\n ndsize_t nelms;\n\n pointer data;\n\n data_ptr buffer;\n\n};\n\n\n", "file_path": "include/nix/hdf5/BaseHDF5.hpp", "rank": 91, "score": 125036.86382026685 }, { "content": "class DataArrayHDF5 : virtual public base::IDataArray, public EntityWithSourcesHDF5 {\n\n\n\nprivate:\n\n\n\n static const NDSize MIN_CHUNK_SIZE;\n\n static const NDSize MAX_SIZE_1D;\n\n\n\n optGroup dimension_group;\n\n\n\npublic:\n\n\n\n /**\n\n * Standard constructor for existing DataArrays\n\n */\n\n DataArrayHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group);\n\n \n\n /**\n\n * Standard constructor for new DataArrays\n\n */\n\n DataArrayHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group,\n", "file_path": "include/nix/hdf5/DataArrayHDF5.hpp", "rank": 92, "score": 123346.27627840728 }, { "content": "class BaseTagHDF5 : public EntityWithSourcesHDF5, virtual public base::IBaseTag {\n\n\n\nprivate:\n\n\n\n optGroup feature_group;\n\n optGroup refs_group;\n\n\n\npublic:\n\n\n\n /**\n\n * Standard constructor for existing Tag\n\n */\n\n BaseTagHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group);\n\n\n\n /**\n\n * Standard constructor for new Tag\n\n */\n\n BaseTagHDF5(const std::shared_ptr<base::IFile> &file, const std::shared_ptr<base::IBlock> &block, const Group &group, const std::string &id,\n\n const std::string &type, const std::string &name);\n\n\n", "file_path": "include/nix/hdf5/BaseTagHDF5.hpp", "rank": 93, "score": 123346.27627840728 }, { "content": "struct to_data_type {\n\n static const bool is_valid = false;\n\n};\n\n\n\n/**\n\n * @brief Determine if a type is a valid data type.\n\n */\n\ntemplate<>\n", "file_path": "include/nix/DataType.hpp", "rank": 94, "score": 122221.09990483648 }, { "content": "class Source;\n\n\n\nnamespace base {\n\n\n\n/**\n\n * @brief Interface for entities that can be associated with sources.\n\n *\n\n * See {@link nix::base::EntityWithSources} for a more detailed description.\n\n */\n", "file_path": "include/nix/base/IEntityWithSources.hpp", "rank": 95, "score": 122116.83042023955 }, { "content": "class CompoundType {\n\npublic:\n\n\n\n explicit CompoundType(size_t size) : strType(H5I_INVALID_HID) {\n\n hid = H5Tcreate(H5T_COMPOUND, size);\n\n if (hid < 0) {\n\n throw H5Exception(\"Could not create compound type\");\n\n }\n\n }\n\n\n\n void insert(const std::string &name, size_t offset, hid_t memberType) {\n\n HErr result = H5Tinsert(hid, name.c_str(), offset, memberType);\n\n result.check(\"CompoundType::insert(): Could not insert member into compound type\");\n\n }\n\n\n\n void insertString(const std::string &name, size_t offset) {\n\n if (strType == H5I_INVALID_HID) {\n\n strType = H5Tcopy (H5T_C_S1);\n\n\n\n if (strType < 0) {\n", "file_path": "src/hdf5/DataSetHDF5.cpp", "rank": 96, "score": 121877.01821245764 }, { "content": " DataType dataType(void) const;\n\n\n\nprivate:\n\n\n\n // small helper for handling dimension groups\n\n Group createDimensionGroup(size_t index);\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_DATA_ARRAY_HDF5_H\n", "file_path": "include/nix/hdf5/DataArrayHDF5.hpp", "rank": 97, "score": 120751.30345307663 }, { "content": " virtual std::shared_ptr<base::IFeature> getFeature(const std::string &name_or_id) const;\n\n\n\n\n\n virtual std::shared_ptr<base::IFeature> getFeature(size_t index) const;\n\n\n\n\n\n virtual std::shared_ptr<base::IFeature> createFeature(const std::string &name_or_id, LinkType link_type);\n\n\n\n\n\n virtual bool deleteFeature(const std::string &name_or_id);\n\n\n\n\n\n //--------------------------------------------------\n\n // Other methods and functions\n\n //--------------------------------------------------\n\n\n\n /**\n\n * Destructor.\n\n */\n\n virtual ~BaseTagHDF5();\n\n\n\n};\n\n\n\n\n\n} // namespace hdf5\n\n} // namespace nix\n\n\n\n#endif // NIX_BASETAG_HDF5_H\n", "file_path": "include/nix/hdf5/BaseTagHDF5.hpp", "rank": 98, "score": 120746.24413374129 }, { "content": " //--------------------------------------------------\n\n\n\n virtual void createData(DataType dtype, const NDSize &size);\n\n\n\n\n\n bool hasData() const;\n\n\n\n\n\n void write(DataType dtype, const void *data, const NDSize &count, const NDSize &offset);\n\n\n\n\n\n void read(DataType dtype, void *buffer, const NDSize &count, const NDSize &offset) const;\n\n\n\n\n\n NDSize dataExtent(void) const;\n\n\n\n\n\n void dataExtent(const NDSize &extent);\n\n\n\n\n", "file_path": "include/nix/hdf5/DataArrayHDF5.hpp", "rank": 99, "score": 120743.14107745167 } ]
C++
src/base/circlebuffer.cpp
aksenofo/sparrow
c0300700a023f374ebb8faa69bcefe261e99d9d5
#include "circlebuffer.h" namespace sparrow { CircularBuffer::CircularBuffer(uint32_t size) : m_size(size) { m_buffer.reset(new uint8_t[m_size]); m_head = m_tail = m_buffer.get(); m_state = m_size == 0 ? Full : Empty; } uint32_t CircularBuffer::WriteEnd(const void* ptr, uint32_t size) noexcept { assert(m_tail <= m_head); const uint8_t* curPtr = reinterpret_cast<const uint8_t*>(ptr); uint32_t canWrite = std::min(size, uint32_t(Eob() - m_head)); memcpy(m_head, curPtr, canWrite); size -= canWrite; m_head += canWrite; assert(m_head <= Eob()); if (m_head == Eob()) m_head = m_buffer.get(); m_state = m_head == m_tail ? Full : Unknown; return size; } uint32_t CircularBuffer::WriteBegin(const void* ptr, uint32_t size) noexcept { assert(m_tail > m_head); const uint8_t* curPtr = reinterpret_cast<const uint8_t*>(ptr); uint32_t canWrite = std::min(size, uint32_t(m_tail - m_head)); memcpy(m_head, curPtr, canWrite); size -= canWrite; m_head += canWrite; assert(m_head <= m_tail); m_state = m_head == m_tail ? Full : Unknown; return size; } uint32_t CircularBuffer::Put(const void* ptr, uint32_t size) noexcept { const uint8_t* curPtr = reinterpret_cast<const uint8_t*>(ptr); if (m_state == Full || size == 0) return 0; uint32_t sizeRest = size; if (m_tail <= m_head) { sizeRest = WriteEnd(ptr, size); curPtr += size - sizeRest; if (m_state == Full || sizeRest == 0) return size - sizeRest; } sizeRest = WriteBegin(curPtr, sizeRest); return size - sizeRest; } uint8_t CircularBuffer::Get() { uint8_t v; if (ConsumeSize() > 0) { v = *Ptr(); Consume(1); } else throw std::runtime_error("Not enough data in buffer."); return v; } void CircularBuffer::Reset() noexcept { m_head = m_tail = m_buffer.get(); m_state = m_size == 0 ? Full : Empty; } uint32_t CircularBuffer::ConsumeSize() noexcept { if (m_state == Empty) return 0; if (m_tail < m_head) return m_head - m_tail; else return Eob() - m_tail; } uint32_t CircularBuffer::PopulateSize() noexcept { if (IsFull()) return 0; if (m_head >= m_tail) return Eob() - m_head; else return m_tail - m_head; } void CircularBuffer::Populate(uint32_t size) noexcept { if (size == 0) return; assert(m_state != Full); if (m_tail <= m_head) { assert(m_head + size <= Eob()); m_head += size; } else { assert(m_head + size <= m_tail); m_head += size; } if (m_head == Eob()) m_head = m_buffer.get(); if (m_tail == m_head) m_state = Full; else m_state = Unknown; } void CircularBuffer::Consume(uint32_t size) noexcept { if (size == 0) return; assert(m_state != Empty); assert(m_tail + size <= Eob()); m_tail += size; if (m_tail == Eob()) m_tail = m_buffer.get(); if (m_tail == m_head) m_state = Empty; else m_state = Unknown; } uint32_t CircularBuffer::FilledSize() const noexcept { if (m_state == Full) return m_size; if (m_tail <= m_head) return m_head - m_tail; else return (Eob() - m_tail) + m_head - m_buffer.get(); } uint32_t CircularBuffer::Get(void* ptr, uint32_t size) noexcept { uint32_t ts1 = std::min(ConsumeSize(), size); if (ts1 == 0) return 0; memcpy(ptr, Ptr(), ts1); Consume(ts1); uint32_t ts2 = std::min(ConsumeSize(), size - ts1); if (ts2 == 0) return ts1; memcpy(reinterpret_cast<uint8_t*>(ptr) + ts1, Ptr(), ts2); Consume(ts2); return ts1 + ts2; } uint32_t CircularBuffer::PutLatecomer(uint32_t lateSize, const void* ptr, uint32_t size) noexcept { const uint8_t* point = static_cast<const uint8_t*>(ptr); if (IsEmpty() || size == 0) { return 0; } else if (m_head > m_tail) { uint8_t* stop = m_head - lateSize; uint8_t* start = stop - size; if (stop < m_tail) return 0; start = std::max(start, m_tail); if (start < m_buffer.get() + m_size) { memcpy(start, point, stop - start); return stop - start; } return 0; } else { uint32_t consumed = 0; uint32_t s1 = m_buffer.get() + m_size - m_tail; if (s1 < lateSize) lateSize -= s1; else { uint8_t* start = m_tail + lateSize; uint8_t* stop = std::min(m_buffer.get() + m_size, start + size); memcpy(start, point, stop - start); point += stop - start; consumed += stop - start; size -= stop - start; lateSize = 0; } uint32_t s2 = m_buffer.get() - m_head; if (s1 < lateSize) return consumed; else { uint8_t* start = m_buffer.get() + lateSize; uint8_t* stop = std::min(start + size, m_head); memcpy(start, point, stop - start); consumed += stop - start; } return consumed; } } uint32_t CircularBuffer::Blocks() const noexcept { if (m_state == Empty) { return 0; } if (m_tail < m_head) return 1; else return 2; } }
#include "circlebuffer.h" namespace sparrow { CircularBuffer::CircularBuffer(uint32_t size) : m_size(size) { m_buffer.reset(new uint8_t[m_size]); m_head = m_tail = m_buffer.get(); m_state = m_size == 0 ? Full : Empty; } uint32_t CircularBuffer::WriteEnd(const void* ptr, uint32_t size) noexcept { assert(m_tail <= m_head); const uint8_t* curPtr = reinterpret_cast<const uint8_t*>(ptr); uint32_t canWrite = std::min(size, uint32_t(Eob() - m_head)); memcpy(m_head, curPtr, canWrite); size -= canWrite; m_head += canWrite; assert(m_head <= Eob()); if (m_head == Eob()) m_head = m_buffer.get(); m_state = m_head == m_tail ? Full : Unknown; return size; } uint32_t CircularBuffer::WriteBegin(const void* ptr, uint32_t size) noexcept { assert(m_tail > m_head); const uint8_t* curPtr = reinterpret_cast<const uint8_t*>(ptr); uint32_t canWrite = std::min(size, uint32_t(m_tail - m_head)); memcpy(m_head, curPtr, canWrite); size -= canWrite; m_head += canWrite; assert(m_head <= m_tail); m_state = m_head == m_tail ? Full : Unknown; return size; } uint32_t CircularBuffer::Put(const void* ptr, uint32_t size) noexcept { const uint8_t* curPtr = reinterpret_cast<const uint8_t*>(ptr); if (m_state == Full || size == 0) return 0; uint32_t sizeRest = size; if (m_tail <= m_head) { sizeRest = WriteEnd(ptr, size); curPtr += size - sizeRest; if (m_state == Full || sizeRest == 0) return size - sizeRest; } sizeRest = WriteBegin(curPtr, sizeRest); return size - sizeRest; } uint8_t CircularBuffer::Get() { uint8_t v; if (ConsumeSize() > 0) { v = *Ptr(); Consume(1); } else throw std::runtime_error("Not enough data in buffer."); return v; } void CircularBuffer::Reset() noexcept { m_head = m_tail = m_buffer.get(); m_state = m_size == 0 ? Full : Empty; } uint32_t CircularBuffer::ConsumeSize() noexcept { if (m_state == Empty) return 0; if (m_tail < m_head) return m_head - m_tail; else return Eob() - m_tail; } uint32_t CircularBuffer::PopulateSize() noexcept { if (IsFull()) return 0; if (m_head >= m_tail) return Eob() - m_head; else return m_tail - m_head; } void CircularBuffer::Populate(uint32_t size) noexcept { if (size == 0) return; assert(m_state != Full); if (m_tail <= m_head) { assert(m_head + size <= Eob()); m_head += size; } else { assert(m_head + size <= m_tail); m_head += size; } if (m_head == Eob()) m_head = m_buffer.get(); if (m_tail == m_head) m_state = Full; else m_state = Unknown; } void CircularBuffer::Consume(uint32_t size) noexcept { if (size == 0) return; assert(m_state != Empty); assert(m_tail + size <= Eob()); m_tail += size; if (m_tail == Eob()) m_tail = m_buffer.get(); if (m_tail == m_head) m_state = Empty; else m_state = Unknown; } uint32_t CircularBuffer::FilledSize() const noexcept { if (m_state == Full) return m_size; if (m_tail <= m_head) return m_head - m_tail; else return (Eob() - m_tail) + m_head - m_buffer.get(); } uint32_t CircularBuffer::Get(void* ptr, uint32_t size) noexcept { uint32_t ts1 = std::min(ConsumeSize(), size); if (ts1 == 0) return 0; memcpy(ptr, Ptr(), ts1); Consume(ts1); uint32_t ts2 = std::min(ConsumeSize(), size - ts1); if (ts2 == 0) return ts1; memcpy(reinterpret_cast<uint8_t*>(ptr) + ts1, Ptr(), ts2); Consume(ts2); return ts1 + ts2; } uint32_t CircularBuffer::PutLatecomer(uint32_t lateSize, const void* ptr, uint32_t size) noexcept { const uint8_t* point = static_cast<const uint8_t*>(ptr); if (IsEmpty() || size == 0) { return 0; } else if (m_head > m_tail) { uint8_t* stop = m_head - lateSize; uint8_t* start = stop - size; if (stop < m_tail) return 0; start = std::max(start, m_tail); if (start < m_buffer.get() + m_size) { memcpy(start, point, stop - start); return stop - start; } return 0; } else { uint32_t consumed = 0; uint32_t s1 = m_buffer.get() + m_size - m_tail; if (s1 < lateSize) lateSize -= s1; else { uint8_t*
} uint32_t s2 = m_buffer.get() - m_head; if (s1 < lateSize) return consumed; else { uint8_t* start = m_buffer.get() + lateSize; uint8_t* stop = std::min(start + size, m_head); memcpy(start, point, stop - start); consumed += stop - start; } return consumed; } } uint32_t CircularBuffer::Blocks() const noexcept { if (m_state == Empty) { return 0; } if (m_tail < m_head) return 1; else return 2; } }
start = m_tail + lateSize; uint8_t* stop = std::min(m_buffer.get() + m_size, start + size); memcpy(start, point, stop - start); point += stop - start; consumed += stop - start; size -= stop - start; lateSize = 0;
random
[ { "content": "class Consumer\n\n{\n\npublic:\n\n Consumer() = default;\n\n COPYBLE_DEFAULT(Consumer);\n\n MOVEBLE_DEFAULT(Consumer);\n\n\n\n template<typename Func>\n\n uint32_t operator()(CircularBuffer& circularBuffer, Func fn)\n\n {\n\n uint32_t totallyConsumed = 0;\n\n while (true) {\n\n uint32_t size = circularBuffer.ConsumeSize();\n\n if (size) {\n\n uint32_t consSize = fn(circularBuffer.Tail(), size);\n\n assert(consSize <= size);\n\n circularBuffer.Consume(consSize);\n\n totallyConsumed += consSize;\n\n if (consSize < size)\n\n break;\n", "file_path": "src/base/circlebuffer.h", "rank": 0, "score": 63234.21928107127 }, { "content": "namespace sparrow\n\n{\n\n\n\nstruct SslInitializer {\n\n\n\n SslInitializer()\n\n {\n\n SSL_library_init();\n\n OpenSSL_add_all_algorithms();\n\n SSL_load_error_strings();\n\n ERR_load_BIO_strings();\n\n // ERR_load_crypto_strings();\n\n }\n\n};\n\n\n", "file_path": "src/ssl/sslinitializer.h", "rank": 1, "score": 61930.937249847586 }, { "content": "class CircularBufferConst : public CircularBuffer\n\n{\n\npublic:\n\n CircularBufferConst()\n\n : CircularBuffer(Size)\n\n {\n\n }\n\n};\n\n\n\n\n\n/*! \\brief Consumer aux class.\n\n *\n\n * Consumer allows simplify process of reading data from circular buffer.\n\n */\n", "file_path": "src/base/circlebuffer.h", "rank": 2, "score": 59926.56333238851 }, { "content": "class CircularBuffer\n\n{\n\n enum State {\n\n Unknown, /**< buffer is neither Full nor empty */\n\n Full, /**< buffer is full */\n\n Empty /**< buffer is empty */\n\n };\n\n\n\npublic:\n\n //! Constructor\n\n /*!\n\n \\param size is the size of buffer.\n\n */\n\n CircularBuffer(uint32_t size);\n\n\n\n //! Makes class moveable(and noncopyable)\n\n MOVEBLE_DEFAULT(CircularBuffer);\n\n\n\n //! Put data to the buffer\n\n /*!\n", "file_path": "src/base/circlebuffer.h", "rank": 3, "score": 30096.892529268745 }, { "content": " SslInitializer()\n\n {\n\n SSL_library_init();\n\n OpenSSL_add_all_algorithms();\n\n SSL_load_error_strings();\n", "file_path": "src/ssl/sslinitializer.h", "rank": 4, "score": 28646.05608117099 }, { "content": "bool IsEqual(const std::string& a, const std::string& b)\n\n{\n\n return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == tolower(b); });\n", "file_path": "example/auxillary/aux.h", "rank": 5, "score": 27409.53567478951 }, { "content": " size_t prev = 0, pos = 0;\n", "file_path": "example/auxillary/aux.h", "rank": 6, "score": 27409.53567478951 }, { "content": "inline std::vector<std::string> StringToVector(const std::string& str, const std::string& delim = \" \")\n\n{\n", "file_path": "example/auxillary/aux.h", "rank": 7, "score": 26275.34799169477 }, { "content": " Author: Alexander Ksenofontov\n\n License: MIT\n\n All right reserved\n\n \n\n# Sparrow\n\nYou may use __openssl__ with __libev__ (minimalistic idea) \n\nSee example folder. \n\nProject is using some socket wrapper only to simplify unitests and examples. \n\nYou may use your own wrapers for your projects. \n\n\n\n# Download\n\n\n\n1. Use git to clone.\n\n\n\n2. Load submodules \n\n 'git submodule init' \n\n 'git submodule update' \n\n\n\n3. Build 3th libraries \n\n a. cd 3th/ \n\n b. run __./build_openssl.bash__ ( ATT! you need to enter root password to install 'libtext-template-perl') \n\n You may install it __outside__ script by running _sudo apt-get install libtext-template-perl_ and commenting appropriate string in script \n\n c. run __./build_googletest.bash__ to build google test \n\n d. run __./build_libev.bash__ to build libev \n\n\n\n5. Use cmake to build \n\n a. run __mkdir__ _any_location_you_want_ \n\n b. run __cd__ _any_location_you_want_ \n\n c. run __cmake__ _absolute_or_relative_path_to_source_location_ \n\n d. run __make__ \n\n \n\n__You will get two libraries__ \n\nlibsparrow-base.a - basic classes \n\nlibsparrow-ssl.a - ssl classes \n\n\n\n# Run example\n\n\n\nfor __server__ \n\n./server -c _absolute_or_relative_path_to_source_location_/.rsa/server.crt -k _absolute_or_relative_path_to_source_location_/.rsa/server.key \n\n( see file example/main_server.cpp for detail)\n\n\n\nfor __client__ \n\n./client\n\n\n\n# Map\n\n\n\nsrc/base - basic classes \n\nsrc/ssl - ssl wrappers \n\nutest/base - unitests for basic classes \n\nutest/ssl - unitests for ssl wrappers \n\n\n\nftest/auxillary - auxillary classes for funtional tests (tcp,.. etc) \n\nftest - funtional tests itself(client and server modules) \n\n\n\nexample/auxillary - auxillary classes for example (tcp,.. etc) \n\nftest - example itself(client and server modules) \n", "file_path": "README.md", "rank": 8, "score": 21771.974509483276 }, { "content": " \\param ptr point to the data buffer.\n\n \\param size is the size of data buffer.\n\n \\return size of consumed data \n\n \\sa uint32_t Put(const char* ptr) noexcept\n\n */\n\n uint32_t Put(const void* ptr, uint32_t size) noexcept;\n\n\n\n //! Put byte to the buffer\n\n /*!\n\n \\param ptr point to the data buffer.\n\n \\return size of consumed data \n\n */\n\n uint32_t Put(uint8_t byte) noexcept;\n\n\n\n //! Put string to the buffer\n\n /*!\n\n \\param ptr point to the data buffer.\n\n \\return size of consumed data \n\n \\sa uint32_t Put(const void* ptr, uint32_t size) noexcept\n\n */\n", "file_path": "src/base/circlebuffer.h", "rank": 12, "score": 33.346474687433115 }, { "content": " uint32_t Put(const char* ptr) noexcept { return Put(ptr, strlen(ptr)); }\n\n\n\n //! Set data to the circular buffer with shifting reference to the begining of buffer\n\n /*!\n\n \\param lateSize is shifting reference \n\n \\param ptr point to the data buffer.\n\n \\return size of consumed data \n\n */\n\n uint32_t PutLatecomer(uint32_t lateSize, const void* ptr, uint32_t size) noexcept;\n\n\n\n //! Set data to the circular buffer with shifting reference to the begining of buffer\n\n /*!\n\n \\param lateSize is shifting reference \n\n \\param ptr point to the string buffer.\n\n \\return size of consumed data \n\n */\n\n uint32_t PutLatecomer(uint32_t lateSize, const char* ptr) noexcept { return PutLatecomer(lateSize, ptr, strlen(ptr)); }\n\n\n\n //! Get single byte from buffer and free one byte\n\n /*!\n", "file_path": "src/base/circlebuffer.h", "rank": 13, "score": 32.34986360342718 }, { "content": " \\return true/false \n\n */\n\n bool IsFull() const noexcept { return m_state == Full; }\n\n\n\n //! Reset buffer\n\n /*!\n\n */\n\n void Reset() noexcept;\n\n\n\n //! Return how many bytes can be consumed from continuous data block\n\n /*!\n\n \\return size of contunuous data block \n\n */\n\n uint32_t ConsumeSize() noexcept;\n\n\n\n //! Consume some data from continuous block\n\n //! Att. if data block is less than consume size than assert.\n\n /*!\n\n \\param size of data block\n\n */\n", "file_path": "src/base/circlebuffer.h", "rank": 15, "score": 30.405931271183626 }, { "content": " //! Write to the end of buffer.\n\n //! \\param ptr - pointer to the buffer\n\n //! \\param size of buffer\n\n /*!\n\n \\return number of bytes which been really consumed \n\n */\n\n uint32_t WriteEnd(const void* ptr, uint32_t size) noexcept;\n\n //! Write to the begin of buffer.\n\n //! \\param ptr - pointer to the buffer\n\n //! \\param size of buffer\n\n /*!\n\n \\return number of bytes which been really consumed \n\n */\n\n uint32_t WriteBegin(const void* ptr, uint32_t size) noexcept;\n\n\n\n uint8_t* m_tail = nullptr; /*!< pointer to tail of buffer */\n\n uint8_t* m_head = nullptr; /*!< pointer to head of buffer */\n\n\n\n uint32_t m_size; /*!< totally reserver buffer size*/\n\n\n\n std::unique_ptr<uint8_t[]> m_buffer; /*!< data buffer */\n\n State m_state; /*!< buffer state(full, empty, ...)*/\n\n};\n\n\n\n/*! \\brief Circular buffer template.\n\n *\n\n * Circular buffer is used to hold temporary date.\n\n */\n\ntemplate<int Size>\n", "file_path": "src/base/circlebuffer.h", "rank": 18, "score": 27.38115784013643 }, { "content": " void Consume(uint32_t size) noexcept;\n\n\n\n //! Return how many bytes can be populated to continuous data block\n\n /*!\n\n \\return size of contunuous data block \n\n */\n\n uint32_t PopulateSize() noexcept;\n\n\n\n //! Populate some data from continuous block\n\n //! Att. if data block is less thab populate size than assert.\n\n /*!\n\n \\param size of data block\n\n */\n\n void Populate(uint32_t size) noexcept;\n\n\n\n //! Return const. pointer to the actulal buffer position\n\n /*!\n\n \\return size of contunuous data block \n\n */\n\n const uint8_t* Ptr() const noexcept { return Tail(); }\n", "file_path": "src/base/circlebuffer.h", "rank": 19, "score": 27.0040174440529 }, { "content": " \\return single byte \n\n */\n\n uint8_t Get();\n\n\n\n //! Get bytes from buffer\n\n /*!\n\n \\param ptr is pointer to the buffer\n\n \\param size of buffer \n\n \\return actual number of bytes \n\n */\n\n uint32_t Get(void* ptr, uint32_t size) noexcept;\n\n\n\n //! Return true if buffer is empty\n\n /*!\n\n \\return true/false \n\n */\n\n bool IsEmpty() const noexcept { return m_state == Empty; }\n\n\n\n //! Return true if buffer is full\n\n /*!\n", "file_path": "src/base/circlebuffer.h", "rank": 20, "score": 26.204630670941697 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test1001)\n\n{\n\n \n\n sparrow::CircularBuffer buf(10);\n\n buf.Put(\"0123456789\");\n\n\n\n sparrow::Consumer consumer;\n\n ASSERT_EQ(consumer(buf, [&](void* ptr, uint32_t size) { return 5; }), 5);\n\n ASSERT_EQ(buf.PopulateSize(), 5);\n\n\n", "file_path": "utest/base/circbuffer1001.cpp", "rank": 21, "score": 25.46631334207725 }, { "content": " ASSERT_EQ(consumer(buf, [&](void* ptr, uint32_t size) { return 1; }), 1);\n\n ASSERT_EQ(buf.PopulateSize(), 6);\n\n\n\n consumer(buf, [&](void* ptr, uint32_t size) { return 4; });\n\n ASSERT_EQ(buf.PopulateSize(), 10);\n\n}\n\n\n\nTEST(circular_buffer, test1001_1)\n\n{\n\n\n\n sparrow::CircularBuffer buf(10);\n\n buf.Put(\"0123456789\");\n\n\n\n sparrow::Consumer consumer;\n\n ASSERT_EQ(consumer(buf, [&](void* ptr, uint32_t size) { return 5; }), 5);\n\n ASSERT_EQ(buf.PopulateSize(), 5);\n\n\n\n ASSERT_EQ(consumer(buf, [&](void* ptr, uint32_t size) { return 1; }), 1);\n\n ASSERT_EQ(buf.PopulateSize(), 6);\n\n\n", "file_path": "utest/base/circbuffer1001.cpp", "rank": 23, "score": 24.955035788948386 }, { "content": "\n\n //! Return pointer to the actulal buffer position\n\n /*!\n\n \\return size of contunuous data block \n\n */\n\n uint8_t* Ptr() noexcept { return Tail(); }\n\n\n\n uint32_t AvailableSize() const noexcept { return m_size - FilledSize(); }\n\n\n\n uint32_t FilledSize() const noexcept;\n\n\n\n //! Return size of reserved bytes.\n\n /*!\n\n \\return Return size of reserved bytes \n\n */\n\n uint32_t Capacity() const noexcept { return m_size; }\n\n\n\n //! Return number of continuous blocks in buffer.\n\n //! May be 0 - buffer is empty,\n\n //! 1 - buffer has only one block (tail is less than head),\n", "file_path": "src/base/circlebuffer.h", "rank": 26, "score": 22.751898871790637 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test1000)\n\n{\n\n sparrow::CircularBuffer buf(3);\n\n ASSERT_EQ(buf.ConsumeSize(), 0);\n\n\n\n buf.Put(\"123\");\n\n ASSERT_EQ(*buf.Ptr(), '1');\n\n buf.Consume(1);\n\n ASSERT_EQ(*buf.Ptr(), '2');\n\n buf.Consume(1);\n", "file_path": "utest/base/circbuffer1000.cpp", "rank": 28, "score": 22.088309233992497 }, { "content": "\n\n size_t unencrypted = cb.FilledSize() - sizeInBegin;\n\n if (unencrypted)\n\n LOG(Debug) << format(\"Unencrypted: %1 bytes\", unencrypted);\n\n}\n\n\n\nbool SslHandler::Encrypt(CircularBuffer& cb)\n\n{\n\n SslBio wbio = m_ssl.Wbio();\n\n Consumer consumer;\n\n Populator populator;\n\n\n\n do {\n\n size_t nWritenTotal = static_cast<size_t>(m_encSendBuffer.AvailableSize());\n\n\n\n // Transmit data from input data buffer to encryptor(SSL)\n\n consumer(cb, [this, &nWritenTotal](const uint8_t* ptr, size_t size) {\n\n size = std::min(size, nWritenTotal);\n\n int nWrite = m_ssl.Write(ptr, size);\n\n if (!m_ssl.IsAcceptableReturn(nWrite, 0)) {\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 29, "score": 21.574572116854814 }, { "content": "\n\n return m_encSendBuffer.IsFull();\n\n}\n\n\n\nvoid SslHandler::SockSend(int sock, CircularBuffer& cb)\n\n{\n\n Consumer consumer;\n\n uint32_t s = consumer(cb, [&sock](const uint8_t* ptr, const size_t size) {\n\n int rc = write(sock, ptr, size);\n\n if (rc < 0 && errno != EAGAIN) {\n\n throw std::runtime_error(format(\"Cannot write to socket. %1\", ToECode(errno)));\n\n }\n\n return rc < 0 ? 0 : rc;\n\n ;\n\n });\n\n if (s)\n\n LOG(Debug) << format(\"send:%1 bytes.\", s);\n\n}\n\n\n\nbool SslHandler::SockRecv(int sock, CircularBuffer& cb)\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 30, "score": 20.731780313000055 }, { "content": " std::string m_str;\n\n};\n\n\n\nTEST(circular_buffer, test1002_1)\n\n{\n\n sparrow::CircularBuffer buf(10);\n\n sparrow::Consumer consumer;\n\n const char* tmpbuff = \"0123456789\";\n\n\n\n Collector collector(10);\n\n for (size_t simulSize : { 1, 3, 5, 9 }) {\n\n for (size_t t = 0; t < 100; t++) {\n\n collector.Reset();\n\n buf.Put(tmpbuff, simulSize);\n\n\n\n consumer(buf, [&](uint8_t* ptr, size_t size) {\n\n size = std::min(size, simulSize);\n\n return collector.Set(ptr, size);\n\n });\n\n ASSERT_TRUE(strncmp(tmpbuff, collector.Ptr(), simulSize) == 0);\n", "file_path": "utest/base/circbuffer1002.cpp", "rank": 31, "score": 20.718715312488822 }, { "content": " ASSERT_EQ(*buf.Ptr(), '3');\n\n buf.Consume(1);\n\n\n\n ASSERT_EQ(buf.ConsumeSize(), 0);\n\n buf.Put(\"456\");\n\n ASSERT_EQ(*buf.Ptr(), '4');\n\n buf.Consume(1);\n\n ASSERT_EQ(*buf.Ptr(), '5');\n\n buf.Consume(1);\n\n ASSERT_EQ(*buf.Ptr(), '6');\n\n buf.Consume(1);\n\n}\n\n\n\nTEST(circular_buffer, test1000_1)\n\n{\n\n sparrow::CircularBuffer buf(3);\n\n ASSERT_EQ(buf.PopulateSize(), 3);\n\n buf.Populate(1);\n\n ASSERT_EQ(buf.PopulateSize(), 2);\n\n buf.Populate(1);\n", "file_path": "utest/base/circbuffer1000.cpp", "rank": 32, "score": 20.21466641102496 }, { "content": " ASSERT_EQ(populator(buf, [&](void* ptr, uint32_t size) { return 4; }), 4);\n\n ASSERT_EQ(buf.PopulateSize(), 1);\n\n ASSERT_EQ(buf.Blocks(), 1);\n\n\n\n sparrow::Consumer consumer;\n\n ASSERT_EQ(consumer(buf, [&](void* ptr, uint32_t size) { return 1; }), 1);\n\n ASSERT_EQ(buf.Blocks(), 1);\n\n\n\n ASSERT_EQ(buf.PopulateSize(), 1);\n\n ASSERT_EQ(buf.AvailableSize(), 2);\n\n ASSERT_EQ(populator(buf, [&](void* ptr, uint32_t size) {\n\n return 1;\n\n }),\n\n 2);\n\n ASSERT_EQ(buf.PopulateSize(), 0);\n\n}\n\n\n", "file_path": "utest/base/circbuffer1002.cpp", "rank": 33, "score": 19.998091824093038 }, { "content": " consumer(buf, [&](void* ptr, uint32_t size) { return 2; });\n\n ASSERT_EQ(buf.PopulateSize(), 8);\n\n\n\n buf.Put(\"01234567\");\n\n ASSERT_EQ(consumer(buf, [&](void* ptr, uint32_t size) { return 2; }),\n\n 4);\n\n ASSERT_EQ(buf.PopulateSize(), 2);\n\n\n\n consumer(buf, [&](void* ptr, uint32_t size) { return 4; });\n\n ASSERT_EQ(buf.PopulateSize(), 2);\n\n\n\n consumer(buf, [&](void* ptr, uint32_t size) { return 2; });\n\n ASSERT_EQ(buf.PopulateSize(), 2);\n\n\n\n}\n", "file_path": "utest/base/circbuffer1001.cpp", "rank": 34, "score": 19.607794235153612 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test3)\n\n{\n\n sparrow::CircularBuffer buf(3);\n\n ASSERT_EQ(buf.Put(\"A\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 1);\n\n ASSERT_EQ(buf.Put(\"B\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 2);\n\n ASSERT_EQ(buf.Put(\"C\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 3);\n\n\n\n buf.Consume(1);\n\n ASSERT_EQ(buf.FilledSize(), 2);\n\n buf.Consume(1);\n\n ASSERT_EQ(buf.FilledSize(), 1);\n\n buf.Consume(1);\n\n ASSERT_EQ(buf.FilledSize(), 0);\n\n\n\n ASSERT_TRUE(buf.IsEmpty());\n\n}", "file_path": "utest/base/circbuffer3.cpp", "rank": 35, "score": 19.470843111845717 }, { "content": " Consumer consumer;\n\n nWrite = consumer(m_encRecvBuffer, [&rbio, this](const uint8_t* buf, size_t size) {\n\n int nWrite = rbio.Write(buf, size);\n\n if (!m_ssl.IsAcceptableReturn(nWrite, SSL_ERROR_WANT_WRITE)) {\n\n throw std::runtime_error(format(\"Cannot BIO_write. %1\", GetLastErrorText()));\n\n }\n\n return nWrite < 0 ? 0 : nWrite;\n\n });\n\n\n\n // Transmit from unencrypter (SSL) to output data buffer.\n\n Populator populator;\n\n nRead = populator(cb, [this](uint8_t* buf, size_t size) {\n\n int nRead = m_ssl.Read(buf, size);\n\n if (!m_ssl.IsAcceptableReturn(nRead, SSL_ERROR_WANT_READ)) {\n\n throw std::runtime_error(format(\"Cannot SSL_read. %1\", GetLastErrorText()));\n\n }\n\n return nRead < 0 ? 0 : nRead;\n\n });\n\n\n\n } while ((nRead || nWrite) && !cb.IsFull());\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 36, "score": 19.06455377690034 }, { "content": "}\n\n\n\n\n\nTEST(circular_buffer, test1000_2)\n\n{\n\n sparrow::CircularBuffer buf(10);\n\n buf.Put(\"0123456789\");\n\n ASSERT_EQ(buf.PopulateSize(), 0);\n\n buf.Consume(8);\n\n ASSERT_EQ(buf.PopulateSize(), 8);\n\n buf.Put(\"QWERTYUI\");\n\n ASSERT_EQ(buf.PopulateSize(), 0);\n\n buf.Consume(2);\n\n ASSERT_EQ(buf.PopulateSize(), 2);\n\n ASSERT_EQ(*buf.Ptr(), 'Q');\n\n\n\n buf.Consume(2);\n\n ASSERT_EQ(*buf.Ptr(), 'E');\n\n ASSERT_EQ(buf.PopulateSize(), 2);\n\n}\n", "file_path": "utest/base/circbuffer1000.cpp", "rank": 38, "score": 18.91353142253125 }, { "content": "\n\nTEST(circular_buffer, test1000_3)\n\n{\n\n sparrow::CircularBuffer buf(10);\n\n buf.Populate(5);\n\n ASSERT_EQ(buf.ConsumeSize(), 5);\n\n buf.Populate(4);\n\n ASSERT_EQ(buf.ConsumeSize(), 9);\n\n buf.Consume(1);\n\n\n\n ASSERT_EQ(buf.Put(\"01xxxxxxxxxxxxxx\"), 2);\n\n ASSERT_EQ(buf.ConsumeSize(), 9);\n\n buf.Consume(9);\n\n ASSERT_EQ(buf.ConsumeSize(), 1);\n\n}\n\n\n\nTEST(circular_buffer, test1000_4)\n\n{\n\n sparrow::CircularBuffer buf(10);\n\n char v = 10;\n", "file_path": "utest/base/circbuffer1000.cpp", "rank": 39, "score": 18.78730345759912 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test0)\n\n{\n\n sparrow::CircularBuffer buf(3);\n\n ASSERT_EQ(buf.Put(\"A\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 1);\n\n ASSERT_EQ(buf.ConsumeSize(), 1);\n\n ASSERT_EQ(*buf.Ptr(), 'A');\n\n\n\n ASSERT_EQ(buf.Put(\"B\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 2);\n", "file_path": "utest/base/circbuffer0.cpp", "rank": 40, "score": 18.743329116173026 }, { "content": " ASSERT_EQ(memcmp(buf.Ptr(), \"N\", 1), 0);\n\n buf.Consume(1);\n\n ASSERT_EQ(memcmp(buf.Ptr(), \"H\", 1), 0);\n\n buf.Consume(1);\n\n ASSERT_TRUE(buf.IsEmpty());\n\n\n\n ASSERT_EQ(buf.Put(\"12345\", 5), 5);\n\n uint32_t t = buf.ConsumeSize();\n\n buf.Consume(t);\n\n t = buf.ConsumeSize();\n\n buf.Consume(t);\n\n ASSERT_TRUE(buf.IsEmpty());\n\n}", "file_path": "utest/base/circbuffer10.cpp", "rank": 42, "score": 18.53727869826701 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include <circlebuffer.h>\n\n#include <gtest/gtest.h>\n\n\n\nTEST(circular_buffer, test2)\n\n{\n\n sparrow::CircularBuffer buf(3);\n\n ASSERT_EQ(buf.Put(\"A\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 1);\n\n ASSERT_EQ(buf.Put(\"B\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 2);\n\n\n\n ASSERT_EQ(memcmp(buf.Buffer(), \"AB\", 2), 0);\n\n uint32_t v = buf.ConsumeSize();\n\n buf.Consume(1);\n", "file_path": "utest/base/circbuffer2.cpp", "rank": 43, "score": 18.363070072271245 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test10)\n\n{\n\n sparrow::CircularBuffer buf(5);\n\n ASSERT_EQ(buf.Put(\"ABCD\", 4), 4);\n\n ASSERT_EQ(memcmp(buf.Ptr(), \"ABC\", 3), 0);\n\n buf.Consume(2);\n\n ASSERT_EQ(memcmp(buf.Ptr(), \"CD\", 2), 0);\n\n buf.Consume(2);\n\n ASSERT_EQ(buf.Put(\"NH\", 2), 2);\n\n\n", "file_path": "utest/base/circbuffer10.cpp", "rank": 44, "score": 18.017156293882454 }, { "content": "\n\n write = !m_encSendBuffer.IsEmpty() || consumedNumber > 0 || needRead || notFinished;\n\n read = true;\n\n return socketNotClosed;\n\n}\n\n\n\nvoid SslHandler::Unencrypt(CircularBuffer& cb)\n\n{\n\n int nRead = 0;\n\n int nWrite = 0;\n\n auto sizeInBegin = cb.FilledSize();\n\n\n\n SslBio rbio = m_ssl.Rbio();\n\n\n\n do {\n\n if (cb.IsFull()) {\n\n throw std::runtime_error(format(\"Buffer has no space. Capacity: %1\", cb.Capacity()));\n\n }\n\n\n\n // Transmit from encryted circular buffer to unencrypter (Read BIO).\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 45, "score": 17.74151119911299 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test1002)\n\n{\n\n\n\n sparrow::CircularBuffer buf(10);\n\n\n\n sparrow::Populator populator;\n\n ASSERT_EQ(populator(buf, [&](void* ptr, uint32_t size) { return 5; }), 5);\n\n ASSERT_EQ(buf.PopulateSize(), 5);\n\n ASSERT_EQ(buf.Blocks(), 1);\n\n\n", "file_path": "utest/base/circbuffer1002.cpp", "rank": 46, "score": 17.598711996500995 }, { "content": " ASSERT_EQ(buf.PopulateSize(), 1);\n\n buf.Populate(1);\n\n ASSERT_EQ(buf.PopulateSize(), 0);\n\n ASSERT_TRUE(buf.IsFull());\n\n buf.Consume(1);\n\n ASSERT_FALSE(buf.IsFull());\n\n ASSERT_EQ(buf.PopulateSize(), 1);\n\n buf.Consume(1);\n\n ASSERT_EQ(buf.PopulateSize(), 2);\n\n buf.Consume(1);\n\n ASSERT_TRUE(buf.IsEmpty());\n\n ASSERT_EQ(buf.PopulateSize(), 3);\n\n buf.Populate(2);\n\n ASSERT_FALSE(buf.IsFull());\n\n ASSERT_FALSE(buf.IsEmpty());\n\n ASSERT_EQ(buf.PopulateSize(), 1);\n\n buf.Populate(1);\n\n ASSERT_TRUE(buf.IsFull());\n\n ASSERT_FALSE(buf.IsEmpty());\n\n ASSERT_EQ(buf.PopulateSize(), 0);\n", "file_path": "utest/base/circbuffer1000.cpp", "rank": 47, "score": 17.41498172900995 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nstatic uint32_t size = 1000;\n\n\n\nvoid Erase1(sparrow::CircularBuffer& buf)\n\n{\n\n buf = sparrow::CircularBuffer(size);\n\n\n\n uint8_t buffer[size / 100];\n\n memset(buffer, 0, sizeof(buffer));\n\n\n\n for (uint32_t t = 0; t < size / sizeof(buffer); t++) {\n", "file_path": "utest/base/circbuffer101.cpp", "rank": 48, "score": 17.054596235812102 }, { "content": "}\n\n\n\nstatic void fill3(sparrow::CircularBuffer& buf)\n\n{\n\n buf = sparrow::CircularBuffer(buf.Capacity());\n\n buf.Put(\"A\", 1);\n\n buf.Put(\"B\", 1);\n\n buf.Put(\"C\", 1);\n\n buf.Put(\"D\", 1);\n\n buf.Consume(2);\n\n buf.Put(\"E\", 1);\n\n}\n\n\n\nTEST(circular_buffer, latecomer_simple_2)\n\n{\n\n sparrow::CircularBuffer buf(4);\n\n fill4(buf);\n\n uint8_t ptr[10];\n\n uint32_t rc;\n\n\n", "file_path": "utest/base/circbuffer100.cpp", "rank": 49, "score": 16.67707502170458 }, { "content": " ASSERT_EQ(buf.ConsumeSize(), 2);\n\n ASSERT_EQ(buf.Ptr()[1], 'B');\n\n\n\n ASSERT_EQ(buf.Blocks(), 1);\n\n\n\n ASSERT_EQ(buf.Put(\"C\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 3);\n\n ASSERT_EQ(buf.ConsumeSize(), 3);\n\n ASSERT_EQ(buf.Ptr()[2], 'C');\n\n\n\n ASSERT_EQ(buf.Blocks(), 2);\n\n\n\n ASSERT_TRUE(buf.IsFull());\n\n ASSERT_EQ(buf.ConsumeSize(), 3);\n\n buf.Consume(1);\n\n ASSERT_EQ(buf.ConsumeSize(), 2);\n\n ASSERT_EQ(buf.FilledSize(), 2);\n\n\n\n ASSERT_EQ(buf.Put(\"x\", 1), 1);\n\n ASSERT_EQ(buf.ConsumeSize(), 2);\n\n ASSERT_EQ(buf.FilledSize(), 3);\n\n}", "file_path": "utest/base/circbuffer0.cpp", "rank": 50, "score": 16.65795337391649 }, { "content": "}\n\n\n\nint SslBio::Read(void* buf, int len) const noexcept\n\n{\n\n return BIO_read(const_cast<BIO*>(BioPtr()), buf, len);\n\n}\n\n\n\nint SslBio::Gets(char* buf, int size) const noexcept\n\n{\n\n return BIO_gets(const_cast<BIO*>(BioPtr()), buf, size);\n\n}\n\n\n\nint SslBio::Write(const void* buf, int len) const noexcept\n\n{\n\n return BIO_write(const_cast<BIO*>(BioPtr()), buf, len);\n\n}\n\n\n\nint SslBio::Puts(const char* buf) const noexcept\n\n{\n\n return BIO_puts(const_cast<BIO*>(BioPtr()), buf);\n\n}\n\n\n\n} //namespace sparrow\n", "file_path": "src/ssl/sslbio.cpp", "rank": 51, "score": 16.619571053271233 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nstatic void fill4(sparrow::CircularBuffer& buf)\n\n{\n\n buf = sparrow::CircularBuffer(buf.Capacity());\n\n buf.Put(\"A\", 1);\n\n buf.Put(\"B\", 1);\n\n buf.Put(\"C\", 1);\n\n buf.Put(\"D\", 1);\n\n buf.Consume(2);\n\n buf.Put(\"E\", 1);\n\n buf.Put(\"F\", 1);\n", "file_path": "utest/base/circbuffer100.cpp", "rank": 52, "score": 16.527811362645252 }, { "content": " return SSL_read(m_ssl.get(), ptr, size);\n\n}\n\n\n\nint SslBase::Write(const uint8_t* ptr, size_t size) const noexcept\n\n{\n\n assert(m_ssl.get());\n\n return SSL_write(m_ssl.get(), ptr, size);\n\n}\n\n\n\nvoid SslBase::CheckPrivateKey() const\n\n{\n\n assert(m_ssl.get());\n\n CheckIf_1(SSL_check_private_key(m_ssl.get()));\n\n}\n\n\n\nSslBase::~SslBase() = default;\n\n\n\n} // namespace sparrow", "file_path": "src/ssl/sslbase.cpp", "rank": 53, "score": 16.424561122473882 }, { "content": " ASSERT_EQ(buf.FilledSize(), 1);\n\n ASSERT_FALSE(buf.IsEmpty());\n\n buf.Consume(1);\n\n ASSERT_EQ(buf.FilledSize(), 0);\n\n ASSERT_TRUE(buf.IsEmpty());\n\n\n\n ASSERT_EQ(buf.Put(\"x\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 1);\n\n ASSERT_FALSE(buf.IsEmpty());\n\n auto pl = buf.Buffer();\n\n buf.Consume(1);\n\n ASSERT_EQ(buf.FilledSize(), 0);\n\n ASSERT_TRUE(buf.IsEmpty());\n\n\n\n ASSERT_EQ(buf.Tail(), buf.Head());\n\n}", "file_path": "utest/base/circbuffer2.cpp", "rank": 54, "score": 15.86657525651368 }, { "content": " throw std::runtime_error(format(\"Cannot SSL_write. %1\", GetLastErrorText()));\n\n }\n\n nWrite = nWrite < 0 ? 0 : nWrite;\n\n nWritenTotal -= nWrite;\n\n return nWrite;\n\n });\n\n\n\n // if (!m_ssl.IsInitFinished()) // TODO\n\n // throw std::runtime_error(format(\"Needs to re-negotiate. Not implemented\"));\n\n\n\n // Transmit data from encryptor to output encrypted data buffer\n\n populator(m_encSendBuffer, [&wbio](uint8_t* ptr, size_t size) {\n\n int nRead = wbio.Read(ptr, size);\n\n if (nRead == -1 && !wbio.ShouldRetry()) {\n\n throw std::runtime_error(format(\"Cannot BIO_read. %1\", GetLastErrorText()));\n\n }\n\n return nRead < 0 ? 0 : nRead;\n\n });\n\n\n\n } while (!cb.IsEmpty() && !m_encSendBuffer.IsFull());\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 55, "score": 15.840956098058104 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#pragma once\n\n\n\n#include <circlebuffer.h>\n\n#include <sslaux.h>\n\n#include <sslbase.h>\n\n#include <utils.h>\n\n\n\nnamespace sparrow\n\n{\n\n\n\nconst int kEncBufferSize = 32;\n\n\n", "file_path": "src/ssl/sslhandler.h", "rank": 56, "score": 15.683697889057669 }, { "content": " } else\n\n break;\n\n }\n\n return totallyConsumed;\n\n }\n\n};\n\n\n\n\n\ninline uint32_t CircularBuffer::Put(uint8_t byte) noexcept {\n\n return Put(&byte, 1);\n\n}\n\n\n\n/*! \\brief Populator aux class.\n\n *\n\n * Populator allows simplify process of writing data to circular buffer.\n\n */\n", "file_path": "src/base/circlebuffer.h", "rank": 57, "score": 15.315501799765691 }, { "content": " });\n\n }\n\n SockSend(socket, m_encSendBuffer);\n\n\n\n bool socketNotClosed = true;\n\n if (read) {\n\n socketNotClosed = SockRecv(socket, m_encRecvBuffer);\n\n }\n\n\n\n uint32_t consumedNumber = consumer(m_encRecvBuffer, [&rbio](const uint8_t* ptr, size_t size) {\n\n int nWrite = rbio.Write(ptr, size);\n\n if (nWrite == -1 && !rbio.ShouldRetry()) {\n\n throw std::runtime_error(format(\"Cannot BIO_write. %1\", GetLastErrorText()));\n\n }\n\n return (nWrite < 0) ? 0 : nWrite;\n\n });\n\n\n\n if (m_ssl.IsInitFinished()) {\n\n LOG(Info) << format(\"SSL connection established for socket #%1\", socket);\n\n }\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 58, "score": 15.238994168423098 }, { "content": " uint32_t g = buf.Put(buffer, sizeof(buffer));\n\n ASSERT_EQ(g, sizeof(buffer));\n\n }\n\n}\n\n\n\nvoid Pop(sparrow::CircularBuffer& buf, uint32_t size)\n\n{\n\n while (size--) {\n\n buf.Get();\n\n }\n\n}\n\n\n\nvoid Erase2(sparrow::CircularBuffer& buf)\n\n{\n\n buf = sparrow::CircularBuffer(size);\n\n\n\n uint8_t buffer[size / 100];\n\n memset(buffer, 0, sizeof(buffer));\n\n\n\n for (uint32_t t = 0; t < size / sizeof(buffer); t++) {\n", "file_path": "utest/base/circbuffer101.cpp", "rank": 59, "score": 14.959081693332205 }, { "content": " bool IsInitFinished() const noexcept;\n\n SslBio Rbio();\n\n SslBio Wbio();\n\n bool PreparedAsServer() const noexcept { return m_preparedAsServer; }\n\n int Read(uint8_t* ptr, size_t size) const noexcept;\n\n int Write(const uint8_t* ptr, size_t size) const noexcept;\n\n void CheckPrivateKey() const;\n\n int DoHandshake();\n\n\n\n template<typename SslBaseT>\n\n SslBaseT Dup();\n\n\n\n std::unique_ptr<SslContext> ContextPtr();\n\n\n\n bool IsAcceptableReturn(const int n, const int code) const noexcept;\n\n bool IsCode(int n, int extraCode);\n\n\n\n bool operator==(const SslBase& o) const noexcept;\n\n bool operator!=(const SslBase& o) const noexcept;\n\n\n", "file_path": "src/ssl/sslbase.h", "rank": 60, "score": 14.779979888145512 }, { "content": "{\n\n const SslBio wbio = m_ssl.Wbio();\n\n SslBio rbio = m_ssl.Rbio();\n\n Populator populator;\n\n Consumer consumer;\n\n\n\n bool notFinished = m_ssl.IsInitFinished();\n\n int n = m_ssl.DoHandshake();\n\n if (!m_ssl.IsAcceptableReturn(n, SSL_ERROR_WANT_READ)) {\n\n throw std::runtime_error(format(\"Cannot SSL_do_handshake. %1\", m_ssl.GetLastErrorText()));\n\n }\n\n\n\n bool needRead = m_ssl.IsCode(n, SSL_ERROR_WANT_READ);\n\n if (needRead) {\n\n populator(m_encSendBuffer, [&wbio](uint8_t* ptr, size_t size) {\n\n int nRead = wbio.Read(ptr, size);\n\n if (nRead == -1 && !wbio.ShouldRetry()) {\n\n throw std::runtime_error(format(\"Cannot BIO_read. %1\", GetLastErrorText()));\n\n }\n\n return (nRead < 0) ? 0 : nRead;\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 61, "score": 14.640153847629687 }, { "content": "\n\n sparrow::CircularBuffer cbuf(bufSize / 11);\n\n\n\n size_t inside = 0;\n\n size_t step = bufSize / 11 / 7;\n\n uint8_t lastCounterValue = 0;\n\n uint32_t counterValue = 0;\n\n\n\n while (counterValue != bufSize) {\n\n size_t t = std::min(step, bufSize - inside);\n\n t = std::min(t, (size_t)cbuf.AvailableSize());\n\n if (t) {\n\n cbuf.Put(ptr + inside, t);\n\n inside += t;\n\n }\n\n\n\n size_t stepRead = step / 2 + 111; // Just same randomizing\n\n uint32_t av = std::min(cbuf.ConsumeSize(), (uint32_t)stepRead);\n\n if (av) {\n\n for (uint32_t t = 0; t < av; t++) {\n", "file_path": "utest/base/circbuffer20.cpp", "rank": 62, "score": 14.555845386821282 }, { "content": "\n\n //! Write() attempts to write len bytes from buf to BIO b.\n\n /*!\n\n \\param buf - is a pointer of buffer\n\n \\param len - is a size if buffer\n\n \\return This function returns the amount of data successfully written (if the return value is positive) \n\n or that no data was successfully written if the result is 0 or -1. \n\n If the return value is -2 then the operation is not implemented in the specific BIO type.\n\n */\n\n int Write(const void* buf, int len) const noexcept;\n\n\n\n //! Puts() attempts to write a null terminated string buf to BIO b.\n\n /*!\n\n \\param buf - is a pointer of buffer\n\n \\param len - is a size if buffer\n\n \\return This function returns the amount of data successfully written (if the return value is positive) \n\n or that no data was successfully written if the result is 0 or -1. \n\n If the return value is -2 then the operation is not implemented in the specific BIO type.\n\n */\n\n int Puts(const char* buf) const noexcept;\n", "file_path": "src/ssl/sslbio.h", "rank": 63, "score": 14.37590890336779 }, { "content": " \\param len - is a size if buffer\n\n \\return This function returns the amount of data successfully read (if the return value is positive) \n\n or that no data was successfully read if the result is 0 or -1. \n\n If the return value is -2 then the operation is not implemented in the specific BIO type.\n\n */\n\n int Read(void* buf, int len) const noexcept;\n\n\n\n //! Gets() performs the BIOs \"gets\" operation and places the data in buf. \n\n /*!\n\n Usually this operation will attempt to read a line of data from the BIO of maximum length len. \n\n There are exceptions to this however, for example Gets() on a digest BIO will \n\n calculate and return the digest and other BIOs may not support Gets() at all.\n\n\n\n \\param buf - is a pointer of buffer\n\n \\param len - is a size if buffer\n\n \\return This function returns the amount of data successfully read (if the return value is positive) \n\n or that no data was successfully read if the result is 0 or -1. \n\n If the return value is -2 then the operation is not implemented in the specific BIO type.\n\n */\n\n int Gets(char* buf, int size) const noexcept;\n", "file_path": "src/ssl/sslbio.h", "rank": 64, "score": 13.99150031239442 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nconst uint32_t size = 1000;\n\n\n\nTEST(circular_buffer, latecomer001)\n\n{\n\n sparrow::CircularBuffer buf(size + 1);\n\n\n\n uint8_t buffer[size];\n\n\n\n ASSERT_EQ(buf.Put(buffer, size), size);\n\n\n", "file_path": "utest/base/circbuffer102.cpp", "rank": 65, "score": 13.966269804498296 }, { "content": " m_sendBuffer.Put(\"Hello from client\\n\");\n\n\n\n bool rc = m_handler->Handle(m_sendBuffer, m_recvBuffer, watcher.fd, write, read);\n\n\n\n while(!m_recvBuffer.IsEmpty()) {\n\n char buffer [MAX_USER_SIZE];\n\n auto v = m_recvBuffer.Get(buffer, sizeof(buffer));\n\n if (v) {\n\n std::cout << std::string(buffer, v);\n\n }\n\n }\n\n\n\n if (rc)\n\n watcher.start(m_tcp->Socket(), (read ? ev::READ : 0) | (write ? ev::WRITE : 0));\n\n else\n\n watcher.stop();\n\n}\n", "file_path": "example/client.cpp", "rank": 66, "score": 13.538536073275875 }, { "content": " fill3(buf);\n\n rc = buf.PutLatecomer(3, (uint8_t*)\"XYZ\", 3);\n\n ASSERT_EQ(rc, 0);\n\n}\n\n\n\nTEST(circular_buffer, latecomer_sinple)\n\n{\n\n sparrow::CircularBuffer buf(4);\n\n ASSERT_TRUE(buf.Head() == buf.Tail() && buf.IsEmpty());\n\n\n\n ASSERT_EQ(buf.Put(\"A\", 1), 1);\n\n ASSERT_TRUE(buf.Head() > buf.Tail() && !buf.IsFull() && !buf.IsEmpty());\n\n ASSERT_EQ(buf.FilledSize(), 1);\n\n\n\n ASSERT_EQ(buf.Put(\"B\", 1), 1);\n\n ASSERT_TRUE(buf.Head() > buf.Tail() && !buf.IsFull() && !buf.IsEmpty());\n\n ASSERT_EQ(buf.FilledSize(), 2);\n\n\n\n ASSERT_EQ(buf.Put(\"C\", 1), 1);\n\n ASSERT_EQ(buf.FilledSize(), 3);\n", "file_path": "utest/base/circbuffer100.cpp", "rank": 67, "score": 13.524511350898454 }, { "content": " //! 2 - buffer has two blocks(from tail to end of buffer, from begin of buffer to head)\n\n /*!\n\n \\return number of block in buffer \n\n */\n\n uint32_t Blocks() const noexcept;\n\n\n\n // Internal and auxillary methods\n\n const uint8_t* Tail() const noexcept { return m_tail; }\n\n\n\n uint8_t* Tail() noexcept { return m_tail; }\n\n\n\n const uint8_t* Head() const noexcept { return m_head; }\n\n\n\n uint8_t* Head() noexcept { return m_head; }\n\n\n\n const uint8_t* Eob() const noexcept { return m_buffer.get() + m_size; }\n\n\n\n const uint8_t* Buffer() const noexcept { return m_buffer.get(); }\n\n\n\nprivate:\n", "file_path": "src/base/circlebuffer.h", "rank": 68, "score": 13.39968262225848 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test20)\n\n{\n\n const size_t bufSize = 100000;\n\n std::unique_ptr<uint8_t[]> buf(new uint8_t[bufSize]);\n\n uint8_t* ptr = buf.get();\n\n\n\n uint8_t counter = 0;\n\n std::for_each(ptr, ptr + bufSize, [&](uint8_t& v) {\n\n v = counter++;\n\n });\n", "file_path": "utest/base/circbuffer20.cpp", "rank": 69, "score": 13.33621191421704 }, { "content": "\n\n/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include <openssl/err.h>\n\n#include <sslaux.h>\n\n#include <format.h>\n\n#include <exception>\n\n\n\nnamespace sparrow\n\n{\n\n\n\nstd::string SslAux::GetLastErrorText(char delimiter)\n\n{\n\n char buf[kErrBufferSize];\n\n std::string ret;\n\n for (unsigned long code = ERR_get_error(); code; code = ERR_get_error()) {\n", "file_path": "src/ssl/sslaux.cpp", "rank": 70, "score": 12.903353801384359 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#pragma once\n\n\n\n#include <algorithm>\n\n#include <assert.h>\n\n#include <cstdint>\n\n#include <iostream>\n\n#include <memory.h>\n\n#include <memory>\n\n#include <utils.h>\n\n\n\nnamespace sparrow\n\n{\n\n\n\n/*! \\brief Circular buffer.\n\n *\n\n * Circular buffer is used to hold temporary date.\n\n */\n", "file_path": "src/base/circlebuffer.h", "rank": 71, "score": 12.890945237184914 }, { "content": " }\n\n }\n\n}\n\n\n\nTEST(circular_buffer, test1002_2)\n\n{\n\n sparrow::CircularBuffer buf(10);\n\n sparrow::Populator populator;\n\n const char* tmpbuff = \"0123456789\";\n\n char outBuff[10];\n\n\n\n for (size_t simulSize : { 1, 3, 5, 9 }) {\n\n Distributor distributor(tmpbuff, simulSize);\n\n for (size_t t = 0; t < 100; t++) {\n\n distributor.Reset();\n\n populator(buf, [&](uint8_t* ptr, size_t size) {\n\n size = std::min(size, simulSize);\n\n auto p = distributor.Get(size);\n\n strncpy((char*)ptr, (const char*)p.first, p.second);\n\n return p.second;\n\n });\n\n\n\n buf.Get(outBuff, simulSize);\n\n ASSERT_TRUE(strncmp(tmpbuff, outBuff, simulSize) == 0);\n\n }\n\n }\n\n}\n", "file_path": "utest/base/circbuffer1002.cpp", "rank": 72, "score": 12.75752764761422 }, { "content": "\n\nprivate:\n\n static void Deleter(SSL_CTX* p) noexcept;\n\n\n\n std::unique_ptr<SSL_CTX, std::function<void(SSL_CTX*)>> m_ctx;\n\n};\n\n\n\ninline void SslContext::Deleter(SSL_CTX* p) noexcept\n\n{\n\n if (p)\n\n SSL_CTX_free(p);\n\n}\n\n\n\ninline bool SslContext::operator==(const SslContext& ctx) const noexcept\n\n{\n\n assert(m_ctx.get() && ctx.m_ctx.get());\n\n return m_ctx.get() == ctx.m_ctx.get();\n\n}\n\n\n\ninline bool SslContext::operator!=(const SslContext& ctx) const noexcept\n\n{\n\n assert(m_ctx.get() && ctx.m_ctx.get());\n\n return m_ctx.get() != ctx.m_ctx.get();\n\n}\n\n\n\n} //namespace sparrow\n", "file_path": "src/ssl/sslcontext.h", "rank": 73, "score": 12.543765088190025 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n#include \"sslbio.h\"\n\n\n\n#include <functional>\n\n\n\nnamespace sparrow\n\n{\n\n\n\nSslBio::SslBio(const BIO_METHOD* type)\n\n{\n\n BIO* bio = BIO_new(type);\n\n m_bio = std::unique_ptr<BIO, std::function<void(BIO*)>>(bio, &SslBio::Deleter);\n\n CheckIfNullptr(m_bio.get());\n\n}\n\n\n\nSslBio::SslBio(BIO* bio)\n", "file_path": "src/ssl/sslbio.cpp", "rank": 74, "score": 12.31357907776409 }, { "content": " ASSERT_EQ(lastCounterValue, cbuf.Ptr()[t]);\n\n\n\n lastCounterValue++;\n\n counterValue++;\n\n }\n\n cbuf.Consume(av);\n\n }\n\n }\n\n ASSERT_TRUE(cbuf.IsEmpty());\n\n}", "file_path": "utest/base/circbuffer20.cpp", "rank": 75, "score": 12.22591268618572 }, { "content": "}\n\n\n\n#define MAX_USER_SIZE 1024\n\n\n\nvoid SslInstance::OnCallback(ev::io& watcher, int revents)\n\n{\n\n bool write = revents & EV_WRITE;\n\n bool read = revents & EV_READ;\n\n\n\n\n\n if (m_sendBuffer.IsEmpty())\n\n m_sendBuffer.Put(\"Hello from server\\n\");\n\n\n\n bool rc = m_handler->Handle(m_sendBuffer, m_recvBuffer, watcher.fd, write, read);\n\n\n\n while(!m_recvBuffer.IsEmpty()) {\n\n char buffer [MAX_USER_SIZE];\n\n auto v = m_recvBuffer.Get(buffer, sizeof(buffer));\n\n if (v) {\n\n std::cout << std::string(buffer, v);\n", "file_path": "example/server.cpp", "rank": 76, "score": 12.02583451357492 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"circlebuffer.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n\n\nTEST(circular_buffer, test00)\n\n{\n\n sparrow::CircularBuffer buf(3);\n\n ASSERT_EQ(buf.Head(), buf.Buffer());\n\n ASSERT_EQ(buf.Put(\"A\", 1), 1);\n\n ASSERT_EQ(buf.Head() - buf.Buffer(), 1);\n\n ASSERT_EQ(buf.Put(\"B\", 1), 1);\n\n ASSERT_EQ(buf.Head() - buf.Buffer(), 2);\n\n ASSERT_EQ(buf.Put(\"C\", 1), 1);\n\n ASSERT_EQ(buf.Head(), buf.Buffer());\n\n ASSERT_TRUE(buf.IsFull());\n\n buf.Get();\n\n ASSERT_EQ(buf.Tail() - buf.Buffer(), 1);\n\n buf.Get();\n\n ASSERT_EQ(buf.Tail() - buf.Buffer(), 2);\n\n buf.Get();\n\n ASSERT_EQ(buf.Tail(), buf.Buffer());\n\n ASSERT_TRUE(buf.IsEmpty());\n\n}", "file_path": "utest/base/circbuffer00.cpp", "rank": 77, "score": 11.629637259473746 }, { "content": " ERR_error_string_n(code, buf, sizeof(buf));\n\n ret += std::string(delimiter ? 1 : 0, delimiter) + buf;\n\n }\n\n return ret;\n\n}\n\n\n\nvoid SslAux::CheckIf_1(const int rc)\n\n{\n\n if (rc != 1)\n\n throw std::runtime_error(format(\"'%1'\", GetLastErrorText()));\n\n}\n\n\n\nvoid SslAux::CheckIfNullptr(const void* ptr)\n\n{\n\n if (!ptr)\n\n throw std::runtime_error(format(\"'%1'\", GetLastErrorText()));\n\n}\n\n\n\n} //namespace sparrow\n", "file_path": "src/ssl/sslaux.cpp", "rank": 78, "score": 11.127519676411378 }, { "content": "#define NOCOPIBLE(clazz) \\\n\n clazz(const clazz&) = delete; \\\n\n clazz& operator=(const clazz&) = delete;\n\n\n\n#define MOVEBLE_DEFAULT(clazz) \\\n\n clazz(clazz&&) noexcept = default; \\\n\n clazz& operator=(clazz&&) noexcept = default;\n\n\n\nnamespace sparrow\n\n{\n\n\n\nstd::string ToIso8601(const std::chrono::time_point<std::chrono::system_clock>& t);\n\n\n\n/*\n\n*\n\n*/\n", "file_path": "src/base/utils.h", "rank": 79, "score": 11.127230000730467 }, { "content": " m_io.set<SslClient, &SslClient::OnCallback>(this);\n\n m_io.start(m_tcp->Socket(), ev::WRITE | ev::READ);\n\n SslContext ctx(SSLv23_method());\n\n SslBase base(ctx);\n\n base.SetConnectState();\n\n base.SetBio(SslBio(), SslBio());\n\n m_handler = std::make_unique<SslHandler>(base);\n\n LOG(Always) << format(\"Client is started.\");\n\n}\n\n\n\nvoid SslClient::OnCallback(ev::io& watcher, int revents)\n\n{\n\n bool write = revents & EV_WRITE;\n\n bool read = revents & EV_READ;\n\n\n\n if (m_sendBuffer.IsEmpty()) {\n\n for (size_t t = 0; t < m_sendBuffer.Capacity(); t++)\n\n m_sendBuffer.Put(static_cast<uint8_t>(m_clientToServerByteCounter++));\n\n }\n\n\n", "file_path": "ftest/client.cpp", "rank": 80, "score": 11.070770678837878 }, { "content": "{\n\n Populator populator;\n\n bool isSocketNotClosed = true;\n\n auto s = populator(cb, [&sock, &isSocketNotClosed](uint8_t* ptr, const size_t size) {\n\n int rc = read(sock, ptr, size);\n\n if (rc < 0 && errno != EAGAIN) {\n\n throw std::runtime_error(format(\"Cannot read from socket. %1\", ToECode(errno)));\n\n }\n\n\n\n isSocketNotClosed = rc;\n\n return rc < 0 ? 0 : rc;\n\n });\n\n\n\n if (s)\n\n LOG(Debug) << format(\"recv:%1 bytes.\", s);\n\n\n\n return isSocketNotClosed;\n\n}\n\n\n\n} //namespace sparrow\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 81, "score": 11.023878659217242 }, { "content": "}\n\n\n\ninline bool SslBio::ShouldRetry() const noexcept\n\n{\n\n return BIO_should_retry(BioPtr());\n\n}\n\n\n\ninline bool SslBio::operator==(const SslBio& bio) const noexcept\n\n{\n\n return m_bio.get() == bio.m_bio.get();\n\n}\n\n\n\ninline bool SslBio::operator!=(const SslBio& bio) const noexcept\n\n{\n\n return m_bio.get() != bio.m_bio.get();\n\n}\n\n\n\n\n\n} //namespace sparrow\n", "file_path": "src/ssl/sslbio.h", "rank": 82, "score": 10.987763028025606 }, { "content": "}\n\n\n\nbool SslBase::IsAcceptableReturn(const int n, const int extraCode) const noexcept\n\n{\n\n assert(m_ssl.get());\n\n int code = SSL_get_error(m_ssl.get(), n);\n\n return n >= 0 || code == SSL_ERROR_NONE || code == extraCode;\n\n}\n\n\n\nbool SslBase::IsCode(int n, int extraCode)\n\n{\n\n assert(m_ssl.get());\n\n int code = SSL_get_error(m_ssl.get(), n);\n\n assert(IsAcceptableReturn(n, extraCode));\n\n return code == extraCode;\n\n}\n\n\n\nint SslBase::Read(uint8_t* ptr, size_t size) const noexcept\n\n{\n\n assert(m_ssl.get());\n", "file_path": "src/ssl/sslbase.cpp", "rank": 83, "score": 10.687767514500262 }, { "content": " uint32_t g = buf.Put(buffer, sizeof(buffer));\n\n ASSERT_EQ(g, sizeof(buffer));\n\n }\n\n\n\n Pop(buf, size / 100);\n\n Pop(buf, size / 100);\n\n ASSERT_EQ(buf.Put(buffer, sizeof(buffer)), sizeof(buffer));\n\n ASSERT_EQ(buf.Put(buffer, sizeof(buffer)), sizeof(buffer));\n\n}\n\n\n\nTEST(circular_buffer, latecomer01)\n\n{\n\n sparrow::CircularBuffer buf(size);\n\n Erase1(buf);\n\n\n\n uint8_t buffer[size / 100];\n\n uint8_t getBuffer[size / 100];\n\n\n\n for (size_t ref = 0; ref < size - size / 100; ref++) {\n\n\n", "file_path": "utest/base/circbuffer101.cpp", "rank": 84, "score": 10.507996670097878 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include <iomanip>\n\n#include <sstream>\n\n#include <utils.h>\n\n\n\nnamespace sparrow\n\n{\n\n\n\nstd::string ToIso8601(const std::chrono::time_point<std::chrono::system_clock>& t)\n\n{\n\n auto epoch_seconds = std::chrono::system_clock::to_time_t(t);\n\n std::stringstream sstream;\n\n sstream << std::put_time(gmtime(&epoch_seconds), \"%FT%T\");\n\n auto truncated = std::chrono::system_clock::from_time_t(epoch_seconds);\n\n auto delta_us = std::chrono::duration_cast<std::chrono::microseconds>(t - truncated).count();\n\n sstream << \".\" << std::fixed << std::setw(6) << std::setfill('0') << delta_us;\n\n return sstream.str();\n\n}\n\n\n\n} // namespace sparrow\n", "file_path": "src/base/utils.cpp", "rank": 85, "score": 10.261272182882106 }, { "content": " return SSL_is_init_finished(m_ssl.get());\n\n}\n\n\n\ninline bool SslBase::operator==(const SslBase& o) const noexcept\n\n{\n\n assert(m_ssl.get() && o.m_ssl.get());\n\n return m_ssl.get() == o.m_ssl.get();\n\n}\n\n\n\ninline bool SslBase::operator!=(const SslBase& o) const noexcept\n\n{\n\n assert(m_ssl.get() && o.m_ssl.get());\n\n return m_ssl.get() != o.m_ssl.get();\n\n}\n\n\n\ninline void SslBase::Deleter(SSL* p) noexcept\n\n{\n\n if (p)\n\n SSL_free(p);\n\n}\n\n\n\n} //namespace sparrow\n", "file_path": "src/ssl/sslbase.h", "rank": 86, "score": 10.261256535020848 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#pragma once\n\n\n\n#include <functional>\n\n#include <string>\n\n#include <system_error>\n\n#include <type_traits>\n\n#include <vector>\n\n\n\nnamespace sparrow\n\n{\n\n\n", "file_path": "src/base/format.h", "rank": 87, "score": 10.191566337060546 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#pragma once\n\n\n\n#include <assert.h>\n\n#include <memory>\n\n#include <openssl/ssl.h>\n\n#include <sslaux.h>\n\n#include <utils.h>\n\n\n\nnamespace sparrow\n\n{\n\n\n", "file_path": "src/ssl/sslcontext.h", "rank": 88, "score": 10.191566337060546 }, { "content": "{\n\n bool ret = true;\n\n\n\n bool bufferIsFull = Encrypt(sendBuf);\n\n\n\n SockSend(socket, m_encSendBuffer);\n\n bool needWrite = !m_encSendBuffer.IsEmpty();\n\n\n\n if (read) {\n\n ret = SockRecv(socket, m_encRecvBuffer);\n\n }\n\n\n\n Unencrypt(recvBuf);\n\n\n\n write = !sendBuf.IsEmpty() || needWrite || bufferIsFull;\n\n read = true;\n\n return ret;\n\n}\n\n\n\nbool SslHandler::DoHandshake(int socket, bool& write, bool& read)\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 89, "score": 10.134971558383292 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#pragma once\n\n\n\n#include \"sslcontext.h\"\n\n\n\n#include <circlebuffer.h>\n\n#include <openssl/ssl.h>\n\n#include <sslaux.h>\n\n#include <string>\n\n#include <utils.h>\n\n\n\nnamespace sparrow\n\n{\n", "file_path": "src/ssl/sslbase.h", "rank": 90, "score": 10.134862684688787 }, { "content": " bool rc = m_handler->Handle(m_sendBuffer, m_recvBuffer, watcher.fd, write, read);\n\n\n\n while(!m_recvBuffer.IsEmpty()) {\n\n auto v = m_recvBuffer.Get();\n\n if(v != static_cast<uint8_t>(m_serverToClientByteCounter)) {\n\n throw std::runtime_error(format(\"Server to client. Invalid value. Imcoming %1, expected: %2\", v, static_cast<uint8_t>(m_serverToClientByteCounter)));\n\n }\n\n m_serverToClientByteCounter ++;\n\n }\n\n\n\n if (rc)\n\n watcher.start(m_tcp->Socket(), (read ? ev::READ : 0) | (write ? ev::WRITE : 0));\n\n else\n\n watcher.stop();\n\n}\n", "file_path": "ftest/client.cpp", "rank": 91, "score": 10.128848098469312 }, { "content": "}\n\n\n\nvoid SslInstance::OnCallback(ev::io& watcher, int revents)\n\n{\n\n bool write = revents & EV_WRITE;\n\n bool read = revents & EV_READ;\n\n\n\n if (m_sendBuffer.IsEmpty()) {\n\n for (size_t t = 0; t < m_sendBuffer.Capacity(); t++)\n\n m_sendBuffer.Put(static_cast<uint8_t>(m_serverToClientByteCounter++));\n\n }\n\n\n\n bool rc = m_handler->Handle(m_sendBuffer, m_recvBuffer, watcher.fd, write, read);\n\n\n\n while(!m_recvBuffer.IsEmpty()) {\n\n auto v = m_recvBuffer.Get();\n\n if(v != static_cast<uint8_t>(m_clientToServerByteCounter)) {\n\n throw std::runtime_error(format(\"Client to Server: Invalid value. Imcoming %1, expected: %2\", v, static_cast<uint8_t>(m_clientToServerByteCounter)));\n\n }\n\n m_clientToServerByteCounter ++;\n", "file_path": "ftest/server.cpp", "rank": 92, "score": 10.012170794284845 }, { "content": "{\n\n m_tcp = std::make_unique<TcpSocket>(\"127.0.0.1\", portNumber);\n\n m_io.set<SslClient, &SslClient::OnCallback>(this);\n\n m_io.start(m_tcp->Socket(), ev::WRITE | ev::READ);\n\n SslContext ctx(SSLv23_method());\n\n SslBase base(ctx);\n\n base.SetConnectState();\n\n base.SetBio(SslBio(), SslBio());\n\n m_handler = std::make_unique<SslHandler>(base);\n\n LOG(Always) << format(\"Client is started.\");\n\n}\n\n\n\n#define MAX_USER_SIZE 1024\n\n\n\nvoid SslClient::OnCallback(ev::io& watcher, int revents)\n\n{\n\n bool write = revents & EV_WRITE;\n\n bool read = revents & EV_READ;\n\n\n\n if (m_sendBuffer.IsEmpty())\n", "file_path": "example/client.cpp", "rank": 93, "score": 9.956351710631251 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"server.h\"\n\n#include \"client.h\"\n\n\n\n#include \"log.h\"\n\n\n\n#include <format.h>\n\n#include <netinet/in.h>\n\n#include <sslbio.h>\n\n#include <sys/socket.h>\n\n#include <tcp.h>\n\n\n\nusing namespace sparrow;\n\n\n\nstd::string sertificate, privateKey;\n", "file_path": "ftest/server.cpp", "rank": 94, "score": 9.741055486291105 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include \"server.h\"\n\n#include \"client.h\"\n\n\n\n#include \"log.h\"\n\n\n\n#include <format.h>\n\n#include <netinet/in.h>\n\n#include <sslbio.h>\n\n#include <sys/socket.h>\n\n#include <tcp.h>\n\n\n\nusing namespace sparrow;\n\n\n\nstd::string sertificate, privateKey;\n", "file_path": "example/server.cpp", "rank": 95, "score": 9.741055486291105 }, { "content": " //! Compare two BIO objects\n\n /*!\n\n \\return true if this is not the same objects.\n\n */\n\n bool operator!=(const SslBio& bio) const noexcept;\n\n\n\nprivate:\n\n //! Internal BIO deleter\n\n /*!\n\n \\param p - pointer to BIO object.\n\n */\n\n static void Deleter(BIO* p) noexcept;\n\n\n\n std::unique_ptr<BIO, std::function<void(BIO*)>> m_bio; /*!< unique pointer to BIO object */\n\n};\n\n\n\ninline void SslBio::Deleter(BIO* p) noexcept\n\n{\n\n if (p)\n\n BIO_free(p);\n", "file_path": "src/ssl/sslbio.h", "rank": 96, "score": 9.726926467700217 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n\n\n#include <format.h>\n\n#include <log.h>\n\n#include <sslbio.h>\n\n#include <sslhandler.h>\n\n#include <unistd.h>\n\n\n\nnamespace sparrow\n\n{\n\n\n\nSslHandler::SslHandler(const SslBase& ssl)\n\n: m_ssl(ssl)\n\n{\n\n}\n\n\n", "file_path": "src/ssl/sslhandler.cpp", "rank": 97, "score": 9.68909593112263 }, { "content": "/*\n\n * Author: Alexander Ksenofontov\n\n * License: MIT\n\n * All right reserved\n\n */\n\n#include \"client.h\"\n\n\n\n#include \"server.h\"\n\n\n\n#include <format.h>\n\n#include <log.h>\n\n#include <singletone.h>\n\n#include <sslbase.h>\n\n#include <sslbio.h>\n\n\n\nint portNumber = 55555;\n\n\n\nusing namespace sparrow;\n\n\n\nSslClient::SslClient()\n", "file_path": "example/client.cpp", "rank": 98, "score": 9.679150237009825 }, { "content": "{\n\n CheckIf_1(SSL_CTX_check_private_key(CtxPtr()));\n\n}\n\n\n\nlong SslContext::SetOptions(long options)\n\n{\n\n return SSL_CTX_set_options(CtxPtr(), options);\n\n}\n\n\n\nlong SslContext::ClearOptions(long options)\n\n{\n\n return SSL_CTX_clear_options(CtxPtr(), options);\n\n}\n\n\n\nlong SslContext::GetOptions()\n\n{\n\n return SSL_CTX_get_options(CtxPtr());\n\n}\n\n\n\nvoid SslContext::CheckPrivateKey() const\n\n{\n\n assert(CtxPtr());\n\n CheckIf_1(SSL_CTX_check_private_key(const_cast<SSL_CTX*>(CtxPtr())));\n\n}\n\n\n\n\n\n} //namespace sparrow\n", "file_path": "src/ssl/sslcontext.cpp", "rank": 99, "score": 9.576392923520448 } ]
C++
caffe2/operators/load_save_op_util.cc
wenhaopeter/read_pytorch_code
491f989cd918cf08874dd4f671fb7f0142a0bc4f
#include "caffe2/operators/load_save_op_util.h" namespace caffe2 { namespace load_save_op_util { std::string buildBlobNameFromDbKey( const std::string& dbKey, const std::string& strip_prefix, const std::string& add_prefix) { std::string key = dbKey.substr(0, dbKey.find(kChunkIdSeparator)); if (!strip_prefix.empty()) { auto match_pos = key.find(strip_prefix); if (match_pos != std::string::npos) { key = key.substr(match_pos + strip_prefix.size()); } } key = add_prefix + key; return key; } void ProcessBlob( Blob* blob, const BlobProto& proto, std::unordered_map<std::string, BlobState>* blob_states_ptr, const std::string& key, int* loaded_blobs) { auto& blob_states = *blob_states_ptr; if (blob_states.count(key) == 0) { blob->Reset(); } DeserializeBlob(proto, blob); if (proto.has_content_num_chunks()) { if (!blob_states.count(key)) { blob_states[key] = BlobState(proto.content_num_chunks()); } CAFFE_ENFORCE( blob_states[key] .seen_chunks_ids.insert(proto.content_chunk_id()) .second, "Chunk with the same id has occurred twice for: ", key); CAFFE_ENFORCE( proto.content_chunk_id() >= 0 && proto.content_chunk_id() < blob_states[key].total_size, "Chunk id has to be not less than 0 and " "less than content_num_chunks for key: ", key); blob_states[key].current_size++; CAFFE_ENFORCE( !blob_states[key].is_tensor, "Proto with content_chunks can not store tensor: ", key); CAFFE_ENFORCE( blob_states[key].current_size <= blob_states[key].total_size, "Found an extra part for an already filled blob: ", key); if (blob_states[key].current_size == blob_states[key].total_size) { (*loaded_blobs)++; } return; } if (!proto.has_tensor()) { CAFFE_ENFORCE(blob_states.count(key) == 0, "Blob duplicated: ", key); blob_states[key] = BlobState(); (*loaded_blobs)++; return; } CAFFE_ENFORCE(proto.has_tensor()); if (blob_states.count(key)) { CAFFE_ENFORCE(blob_states[key].is_tensor, "Must be tensor ", key); CAFFE_ENFORCE( blob_states[key].current_size < blob_states[key].total_size, "Found an extra part for an already filled tensor: ", key); CAFFE_ENFORCE( proto.tensor().has_segment(), "Partial tensor must have a segment: ", key); blob_states[key].current_size += proto.tensor().segment().end() - proto.tensor().segment().begin(); CAFFE_ENFORCE( blob_states[key].current_size <= blob_states[key].total_size, "Tensor parts are bigger than target size for tensor: ", key); } else { const auto& dims = proto.tensor().dims(); int64_t total_size = 1; for (const auto& dim : dims) { total_size *= dim; } auto current_size = total_size; if (proto.tensor().has_segment()) { current_size = proto.tensor().segment().end() - proto.tensor().segment().begin(); } blob_states[key] = BlobState(total_size, current_size, true ); } if (blob_states[key].current_size == blob_states[key].total_size) { (*loaded_blobs)++; } } void validateBlobStates( const std::unordered_map<std::string, BlobState>& blob_states) { for (const auto& iter : blob_states) { const BlobState& blob_state = iter.second; CAFFE_ENFORCE( blob_state.current_size == blob_state.total_size, "Data size mismatch for blob ", iter.first, ". Expected: ", blob_state.total_size, " Read: ", blob_state.current_size); } } } }
#include "caffe2/operators/load_save_op_util.h" namespace caffe2 { namespace load_save_op_util { std::string buildBlobNameFromDbKey( const std::string& dbKey, const std::string& strip_prefix, const std::string& add_prefix) { std::string key = dbKey.substr(0, dbKey.find(kChunkIdSeparator)); if (!strip_prefix.empty()) { auto match_pos = key.find(strip_prefix); if (match_pos != std::string::npos) { key = key.substr(match_pos + strip_prefix.size()); } } key = add_prefix + key; return key; } void ProcessBlob( Blob* blob, const BlobProto& proto, std::unordered_map<std::string, BlobState>* blob_states_ptr, const std::string& key, int* loaded_blobs) { auto& blob_states = *blob_states_ptr; if (blob_states.count(key) == 0) { blob->Reset(); } DeserializeBlob(proto, blob); if (proto.has_content_num_chunks()) { if (!blob_states.count(key)) { blob_states[key] = BlobState(proto.content_num_chunks()); } CAFFE_ENFORCE( blob_states[key] .seen_chunks_ids.insert(proto.content_chunk_id()) .second, "Chunk with the same id has occurred twice for: ", key); CAFFE_ENFORCE( proto.content_chunk_id() >= 0 && proto.content_chunk_id() < blob_states[key].total_size, "Chunk id has to be not less than 0 and " "less than content_num_chunks for key: ", key); blob_states[key].current_size++; CAFFE_ENFORCE( !blob_states[key].is_tensor, "Proto with content_chunks can not store tensor: ", key); CAFFE_ENFORCE( blob_states[key].current_size <= blob_states[key].total_size, "Found an extra part for an already filled blob: ", key); if (blob_states[key].current_size == blob_states[key].total_size) { (*loaded_blobs)++; } return; } if (!proto.has_tensor()) { CAFFE_ENFORCE(blob_states.count(key) == 0, "Blob duplicated: ", key); blob_states[key] = BlobState(); (*loaded_blobs)++; return; } CAFFE_ENFORCE(proto.has_tensor()); if (blob_states.count(key)) { CAFFE_ENFORCE(blob_states[key].is_tensor, "Must be tensor ", key);
; CAFFE_ENFORCE( proto.tensor().has_segment(), "Partial tensor must have a segment: ", key); blob_states[key].current_size += proto.tensor().segment().end() - proto.tensor().segment().begin(); CAFFE_ENFORCE( blob_states[key].current_size <= blob_states[key].total_size, "Tensor parts are bigger than target size for tensor: ", key); } else { const auto& dims = proto.tensor().dims(); int64_t total_size = 1; for (const auto& dim : dims) { total_size *= dim; } auto current_size = total_size; if (proto.tensor().has_segment()) { current_size = proto.tensor().segment().end() - proto.tensor().segment().begin(); } blob_states[key] = BlobState(total_size, current_size, true ); } if (blob_states[key].current_size == blob_states[key].total_size) { (*loaded_blobs)++; } } void validateBlobStates( const std::unordered_map<std::string, BlobState>& blob_states) { for (const auto& iter : blob_states) { const BlobState& blob_state = iter.second; CAFFE_ENFORCE( blob_state.current_size == blob_state.total_size, "Data size mismatch for blob ", iter.first, ". Expected: ", blob_state.total_size, " Read: ", blob_state.current_size); } } } }
CAFFE_ENFORCE( blob_states[key].current_size < blob_states[key].total_size, "Found an extra part for an already filled tensor: ", key)
call_expression
[ { "content": "class Int8GivenIntTensorFillOp final : public Operator<CPUContext> {\n\n public:\n\n template <class... Args>\n\n explicit Int8GivenIntTensorFillOp(Args&&... args)\n\n : Operator<CPUContext>(std::forward<Args>(args)...),\n\n scale_(this->template GetSingleArgument<float>(\"Y_scale\", 1.0)),\n\n zero_point_(\n\n this->template GetSingleArgument<int32_t>(\"Y_zero_point\", 0)),\n\n shape_(this->template GetRepeatedArgument<int64_t>(\"shape\")) {\n\n ExtractValues();\n\n }\n\n\n\n bool RunOnDevice() override {\n\n auto* output = Outputs()[0]->template GetMutable<Int8TensorCPU>();\n\n output->t.Resize(shape_);\n\n output->scale = scale_;\n\n output->zero_point = zero_point_;\n\n return Fill(output);\n\n }\n\n\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.h", "rank": 0, "score": 244102.85762389385 }, { "content": "class IDEEPInt8GivenIntTensorFillOp final : public IDEEPOperator {\n\n public:\n\n USE_IDEEP_DEF_ALIASES();\n\n USE_IDEEP_OPERATOR_FUNCTIONS();\n\n\n\n IDEEPInt8GivenIntTensorFillOp(const OperatorDef& operator_def, Workspace* ws)\n\n : IDEEPOperator(operator_def, ws),\n\n zero_point_(\n\n this->template GetSingleArgument<int32_t>(\"Y_zero_point\", 0)),\n\n shape_(this->template GetRepeatedArgument<itensor::dim>(\"shape\")) {\n\n CAFFE_ENFORCE(zero_point_ == 0, \"Not support zero point\");\n\n if (HasArgument(\"Y_scales\")) {\n\n scales_ = this->template GetRepeatedArgument<float>(\"Y_scales\");\n\n } else {\n\n auto scale = (this->template GetSingleArgument<float>(\"Y_scale\", 1.0));\n\n scales_ = {scale};\n\n }\n\n\n\n auto source_values = this->template GetRepeatedArgument<int32_t>(\"values\");\n\n auto src_size = source_values.size();\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 1, "score": 236572.38355233165 }, { "content": "def full_0_4(size:List[int], fill_value:number, *, out:Tensor) -> Tensor:\n\n return torch.full(size, fill_value, out=out)\n\n)SCRIPT\";\n\n\n", "file_path": "torch/csrc/jit/frontend/builtin_functions.cpp", "rank": 2, "score": 235813.83097706438 }, { "content": " const c10::ScalarType& scalar_type() const {\n\n return scalar_type_;\n", "file_path": "torch/csrc/api/include/torch/detail/TensorDataContainer.h", "rank": 3, "score": 231242.37889120358 }, { "content": "class CAFFE2_API Return : public Terminator {\n\n public:\n\n Return() : Terminator(Instruction::Opcode::Return) {}\n\n};\n\n\n", "file_path": "caffe2/core/nomnigraph/include/nomnigraph/Representations/Compiler.h", "rank": 4, "score": 227946.5633812137 }, { "content": "class GivenTensorFill : public NeuralNetOperator {\n\n public:\n\n GivenTensorFill() : NeuralNetOperator(NNKind::GivenTensorFill) {}\n\n\n\n ~GivenTensorFill() {}\n\n\n\n NOMNIGRAPH_DEFINE_NN_RTTI(GivenTensorFill);\n\n\n\n private:\n\n};\n\n\n", "file_path": "caffe2/core/nomnigraph/include/nomnigraph/Generated/OpClasses.h", "rank": 5, "score": 223760.82525707767 }, { "content": "class CAFFE2_API Tensor : public NeuralNetData {\n\n public:\n", "file_path": "caffe2/core/nomnigraph/include/nomnigraph/Representations/NeuralNet.h", "rank": 6, "score": 216888.23184321338 }, { "content": " def _create_test_tensor_protos(self, idx):\n\n item = caffe2_pb2.TensorProtos()\n\n data = item.protos.add()\n\n data.data_type = core.DataType.STRING\n\n data.string_data.append(\"foo{}\".format(idx).encode('utf-8'))\n\n label = item.protos.add()\n\n label.data_type = core.DataType.INT32\n\n label.int32_data.append(1)\n\n\n", "file_path": "caffe2/python/ideep/blobs_queue_db_test.py", "rank": 7, "score": 214803.01086042565 }, { "content": "object as value. These TensorProtos objects should have the same size, and they\n\nwill be grouped into batches of the given size. The DB Reader is provided as\n\ninput to the operator and it returns as many output tensors as the size of the\n\nTensorProtos object. Each output will simply be a tensor containing a batch of\n\ndata with size specified by the 'batch_size' argument containing data from the\n\ncorresponding index in the TensorProtos objects in the DB.\n\n)DOC\")\n\n .Arg(\"batch_size\", \"(int, default 0) the number of samples in a batch. The \"\n\n \"default value of 0 means that the operator will attempt to insert the \"\n\n \"entire data in a single output blob.\")\n\n .Input(0, \"data\", \"A pre-initialized DB reader. Typically, this is obtained \"\n\n \"by calling CreateDB operator with a db_name and a db_type. The \"\n\n \"resulting output blob is a DB Reader tensor\")\n\n .Output(0, \"output\", \"The output tensor in which the batches of data are \"\n\n \"returned. The number of output tensors is equal to the size of \"\n\n \"(number of TensorProto's in) the TensorProtos objects stored in the \"\n\n \"DB as values. Each output tensor will be of size specified by the \"\n\n \"'batch_size' argument of the operator\");\n\n\n\nNO_GRADIENT(TensorProtosDBInput);\n\n} // namespace caffe2\n", "file_path": "caffe2/operators/tensor_protos_db_input.cc", "rank": 8, "score": 214523.77552186517 }, { "content": "class CAFFE2_API TensorDeserializer : public BlobDeserializerBase {\n\n public:\n\n void Deserialize(const BlobProto& proto, Blob* blob) override;\n\n\n\n /* There are cases when a Tensor is split into multiple protos and\n\n * we have to call Deserialize multiple times to get the complete deserialized\n\n * Tensor, each call will fill part of the Tensor given the segment begin and\n\n * end information in proto, therefore we have to pass in the Tensor pointer\n\n * rather than create a new Tensor every time.\n\n *\n\n * Precondition: Tensor must be initialized\n\n */\n\n void DeserializeToTensor(const TensorProto& proto, Tensor* tensor);\n\n\n\n /* Deserialize the proto and return a new Tensor\n\n * This is a utility function that combines EmptyTensorFromProto and\n\n * Deserialize(const TensorProto&, Tensor*);\n\n */\n\n Tensor Deserialize(const TensorProto& proto);\n\n};\n", "file_path": "caffe2/core/blob_serialization.h", "rank": 9, "score": 213892.0056747531 }, { "content": "class CAFFE2_API TensorSerializer : public BlobSerializerBase {\n\n public:\n\n TensorSerializer() {}\n\n ~TensorSerializer() override {}\n\n /**\n\n * Serializes a Blob. Note that this blob has to contain Tensor,\n\n * otherwise this function produces a fatal error.\n\n */\n\n void Serialize(\n\n const void* pointer,\n\n TypeMeta typeMeta,\n\n const string& name,\n\n SerializationAcceptor acceptor) override;\n\n void SerializeWithChunkSize(\n\n const void* pointer,\n\n TypeMeta typeMeta,\n\n const string& name,\n\n SerializationAcceptor acceptor,\n\n int chunk_size) override;\n\n\n", "file_path": "caffe2/core/blob_serialization.h", "rank": 10, "score": 213892.0056747531 }, { "content": "namespace caffe2 {\n\n\n\nusing DeviceType = at::DeviceType;\n\nconstexpr DeviceType CPU = DeviceType::CPU;\n\nconstexpr DeviceType CUDA = DeviceType::CUDA;\n\nconstexpr DeviceType OPENGL = DeviceType::OPENGL;\n\nconstexpr DeviceType OPENCL = DeviceType::OPENCL;\n\nconstexpr DeviceType MKLDNN = DeviceType::MKLDNN;\n\nconstexpr DeviceType IDEEP = DeviceType::IDEEP;\n\nconstexpr DeviceType HIP = DeviceType::HIP;\n\nconstexpr DeviceType COMPILE_TIME_MAX_DEVICE_TYPES =\n\n DeviceType::COMPILE_TIME_MAX_DEVICE_TYPES;\n\nconstexpr DeviceType ONLY_FOR_TEST = DeviceType::ONLY_FOR_TEST;\n\n\n\ninline CAFFE2_API DeviceType ProtoToType(const caffe2::DeviceTypeProto p) {\n\n switch (p) {\n\n case caffe2::PROTO_CPU:\n\n return DeviceType::CPU;\n\n case caffe2::PROTO_CUDA:\n\n return DeviceType::CUDA;\n\n case caffe2::PROTO_OPENGL:\n\n return DeviceType::OPENGL;\n\n case caffe2::PROTO_OPENCL:\n\n return DeviceType::OPENCL;\n\n case caffe2::PROTO_MKLDNN:\n\n return DeviceType::MKLDNN;\n\n case caffe2::PROTO_IDEEP:\n\n return DeviceType::IDEEP;\n\n case caffe2::PROTO_HIP:\n\n return DeviceType::HIP;\n\n case caffe2::PROTO_COMPILE_TIME_MAX_DEVICE_TYPES:\n\n return DeviceType::COMPILE_TIME_MAX_DEVICE_TYPES;\n\n case caffe2::PROTO_ONLY_FOR_TEST:\n\n return DeviceType::ONLY_FOR_TEST;\n\n default:\n\n AT_ERROR(\n\n \"Unknown device:\",\n\n static_cast<int32_t>(p),\n\n \". If you have recently updated the caffe2.proto file to add a new \"\n\n \"device type, did you forget to update the ProtoToType() and TypeToProto\"\n\n \"function to reflect such recent changes?\");\n\n }\n\n}\n\n\n\ninline CAFFE2_API DeviceType ProtoToType(int p) {\n\n return ProtoToType(static_cast<caffe2::DeviceTypeProto>(p));\n\n}\n\n\n\ninline CAFFE2_API DeviceTypeProto TypeToProto(const DeviceType& t) {\n\n switch (t) {\n\n case DeviceType::CPU:\n\n return caffe2::PROTO_CPU;\n\n case DeviceType::CUDA:\n\n return caffe2::PROTO_CUDA;\n\n case DeviceType::OPENGL:\n\n return caffe2::PROTO_OPENGL;\n\n case DeviceType::OPENCL:\n\n return caffe2::PROTO_OPENCL;\n\n case DeviceType::MKLDNN:\n\n return caffe2::PROTO_MKLDNN;\n\n case DeviceType::IDEEP:\n\n return caffe2::PROTO_IDEEP;\n\n case DeviceType::HIP:\n\n return caffe2::PROTO_HIP;\n\n case DeviceType::COMPILE_TIME_MAX_DEVICE_TYPES:\n\n return caffe2::PROTO_COMPILE_TIME_MAX_DEVICE_TYPES;\n\n case DeviceType::ONLY_FOR_TEST:\n\n return caffe2::PROTO_ONLY_FOR_TEST;\n\n default:\n\n AT_ERROR(\n\n \"Unknown device:\",\n\n static_cast<int32_t>(t),\n\n \". If you have recently updated the caffe2.proto file to add a new \"\n\n \"device type, did you forget to update the ProtoToType() and TypeToProto\"\n\n \"function to reflect such recent changes?\");\n\n }\n\n}\n\n\n\ninline CAFFE2_API caffe2::DeviceOption DeviceToOption(\n\n const at::Device& device) {\n\n caffe2::DeviceOption option;\n\n auto type = device.type();\n\n option.set_device_type(TypeToProto(type));\n\n\n\n switch (type) {\n\n case DeviceType::CPU:\n\n if (device.index() != -1) {\n\n option.set_numa_node_id(device.index());\n\n }\n\n break;\n\n case DeviceType::CUDA:\n\n case DeviceType::HIP:\n\n option.set_device_id(device.index());\n\n break;\n\n case DeviceType::OPENGL:\n\n case DeviceType::OPENCL:\n\n case DeviceType::MKLDNN:\n\n case DeviceType::IDEEP:\n\n case DeviceType::COMPILE_TIME_MAX_DEVICE_TYPES:\n\n case DeviceType::ONLY_FOR_TEST:\n\n break;\n\n default:\n\n AT_ERROR(\n\n \"Unknown device:\",\n\n static_cast<int32_t>(type),\n\n \". If you have recently updated the caffe2.proto file to add a new \"\n\n \"device type, did you forget to update the ProtoToType() and TypeToProto\"\n\n \"function to reflect such recent changes?\");\n\n }\n\n return option;\n\n}\n\n\n\ninline CAFFE2_API at::Device OptionToDevice(const caffe2::DeviceOption option) {\n\n auto type = option.device_type();\n\n int32_t id = -1;\n\n switch (type) {\n\n case caffe2::PROTO_CPU:\n\n if (option.has_numa_node_id()) {\n\n id = option.numa_node_id();\n\n }\n\n break;\n\n case caffe2::PROTO_CUDA:\n\n case caffe2::PROTO_HIP:\n\n id = option.device_id();\n\n break;\n\n }\n\n return at::Device(ProtoToType(type), id);\n\n}\n\n\n\ninline void ExtractDeviceOption(\n\n DeviceOption* device_option,\n\n const at::Device& device) {\n\n AT_ASSERT(device_option);\n\n device_option->CopyFrom(DeviceToOption(device));\n\n}\n\n\n", "file_path": "caffe2/proto/caffe2_pb.h", "rank": 11, "score": 210682.3690528943 }, { "content": " def _create_test_tensor_protos(self, idx):\n\n item = caffe2_pb2.TensorProtos()\n\n data = item.protos.add()\n\n data.data_type = core.DataType.STRING\n\n data.string_data.append(\"foo{}\".format(idx).encode('utf-8'))\n\n label = item.protos.add()\n\n label.data_type = core.DataType.INT32\n\n label.int32_data.append(1)\n\n\n", "file_path": "caffe2/python/operator_test/blobs_queue_db_test.py", "rank": 12, "score": 210518.36988471381 }, { "content": "class Tensor;\n\n};\n\n#endif\n\nnamespace caffe2 {\n\n\n\nusing at::UndefinedTensorImpl;\n\n\n\n/**\n\n * @brief Tensor class holds a shared pointer to the implementation TensorImpl,\n\n * redirects API calls to TensorImpl;\n\n * Copying of Tensor results in sharing the same underlying implementation\n\n * object\n\n *\n\n * NB: See TensorImpl for documentation on these methods.\n\n */\n", "file_path": "caffe2/core/tensor.h", "rank": 13, "score": 209643.15012603032 }, { "content": " CAFFE_ENFORCE(protos.protos_size() == OutputSize());\n\n for (int i = 0; i < protos.protos_size(); ++i) {\n\n if (protos.protos(i).has_device_detail()) {\n\n protos.mutable_protos(i)->clear_device_detail();\n\n }\n\n BlobSetTensor(\n\n &prefetched_blobs_[i], deserializer.Deserialize(protos.protos(i)));\n\n // deserializer.Deserialize(\n\n // protos.protos(i), BlobGetMutableTensor(&prefetched_blobs_[i],\n\n // CPU));\n\n }\n\n } else {\n\n for (int item_id = 0; item_id < batch_size_; ++item_id) {\n\n reader.Read(&key_, &value_);\n\n TensorProtos protos;\n\n CAFFE_ENFORCE(protos.ParseFromString(value_));\n\n CAFFE_ENFORCE(protos.protos_size() == OutputSize());\n\n // Note: shape_inferred_ is ignored, we'll always get dimensions from\n\n // proto\n\n for (int i = 0; i < protos.protos_size(); ++i) {\n", "file_path": "caffe2/operators/tensor_protos_db_input.h", "rank": 14, "score": 206941.67406046297 }, { "content": "#ifndef CAFFE2_OPERATORS_TENSOR_PROTOS_DB_INPUT_H_\n\n#define CAFFE2_OPERATORS_TENSOR_PROTOS_DB_INPUT_H_\n\n\n\n#include <iostream>\n\n#include <mutex>\n\n\n\n#include \"caffe2/core/db.h\"\n\n#include \"caffe2/operators/prefetch_op.h\"\n\n\n\nnamespace caffe2 {\n\n\n\ntemplate <class Context>\n", "file_path": "caffe2/operators/tensor_protos_db_input.h", "rank": 15, "score": 206938.85946355597 }, { "content": "}\n\n\n\ntemplate <class Context>\n\nbool TensorProtosDBInput<Context>::CopyPrefetched() {\n\n for (int i = 0; i < OutputSize(); ++i) {\n\n OperatorBase::template Output<Tensor>(i, Context::GetDeviceType())\n\n ->CopyFrom(\n\n prefetched_blobs_[i].template Get<TensorCPU>(), /* async */ true);\n\n }\n\n return true;\n\n}\n\n\n\n} // namespace caffe2\n\n\n\n#endif // CAFFE2_OPERATORS_TENSOR_PROTOS_DB_INPUT_H_\n", "file_path": "caffe2/operators/tensor_protos_db_input.h", "rank": 16, "score": 206938.8256376749 }, { "content": "\n\ntemplate <class Context>\n\nTensorProtosDBInput<Context>::TensorProtosDBInput(\n\n const OperatorDef& operator_def,\n\n Workspace* ws)\n\n : PrefetchOperator<Context>(operator_def, ws),\n\n prefetched_blobs_(operator_def.output_size()),\n\n batch_size_(\n\n this->template GetSingleArgument<int>(\"batch_size\", 0)) {}\n\n\n\ntemplate <class Context>\n\nbool TensorProtosDBInput<Context>::Prefetch() {\n\n const db::DBReader& reader = this->template Input<db::DBReader>(0);\n\n TensorDeserializer deserializer;\n\n if (batch_size_ == 0) {\n\n // We do not need to construct a batch. As a result, we will simply\n\n // deserialize everything into the target prefetched blob.\n\n reader.Read(&key_, &value_);\n\n TensorProtos protos;\n\n CAFFE_ENFORCE(protos.ParseFromString(value_));\n", "file_path": "caffe2/operators/tensor_protos_db_input.h", "rank": 17, "score": 206930.02125704187 }, { "content": "\n\n template <typename Type>\n\n bool FillWithType(Tensor* output) {\n\n CAFFE_ENFORCE_EQ(output->numel(), values_.numel());\n\n auto* data = output->template mutable_data<Type>();\n\n const Type* values_data = values_.template data<Type>();\n\n if (output->numel()) {\n\n context_.CopyItemsFromCPU(\n\n TypeMeta::Make<Type>(), output->numel(), values_data, data);\n\n }\n\n return true;\n\n }\n\n\n\n bool (GivenTensorFillOp::*body_)(Tensor* output);\n\n Tensor values_;\n\n};\n\n} // namespace caffe2\n", "file_path": "caffe2/operators/given_tensor_fill_op.h", "rank": 18, "score": 206928.09488932558 }, { "content": " }\n\n }\n\n }\n\n\n\n bool Fill(Tensor* output) override {\n\n return (this->*body_)(output);\n\n }\n\n\n\n private:\n\n template <typename Type>\n\n void ExtractValues() {\n\n auto source_values =\n\n this->template GetRepeatedArgument<Type>(\"values\");\n\n ReinitializeTensor(&values_, {static_cast<int64_t>(source_values.size())}, at::dtype<Type>().device(CPU));\n\n Type* values_data = values_.template mutable_data<Type>();\n\n for (int i = 0; i < source_values.size(); i++) {\n\n values_data[i] = static_cast<Type>(source_values[i]);\n\n }\n\n body_ = &GivenTensorFillOp::FillWithType<Type>;\n\n }\n", "file_path": "caffe2/operators/given_tensor_fill_op.h", "rank": 19, "score": 206927.60762775008 }, { "content": " vector<int64_t> dims(\n\n protos.protos(i).dims().begin(), protos.protos(i).dims().end());\n\n dims.insert(dims.begin(), batch_size_);\n\n if (protos.protos(i).has_device_detail()) {\n\n protos.mutable_protos(i)->clear_device_detail();\n\n }\n\n Tensor src = deserializer.Deserialize(protos.protos(i));\n\n Tensor* dst = BlobGetMutableTensor(\n\n &prefetched_blobs_[i], dims, at::dtype(src.dtype()).device(CPU));\n\n DCHECK_EQ(src.numel() * batch_size_, dst->numel());\n\n this->context_.CopyItemsSameDevice(\n\n src.dtype(),\n\n src.numel(),\n\n src.raw_data(),\n\n static_cast<char*>(dst->raw_mutable_data(src.dtype())) +\n\n src.nbytes() * item_id);\n\n }\n\n }\n\n }\n\n return true;\n", "file_path": "caffe2/operators/tensor_protos_db_input.h", "rank": 20, "score": 206926.6450794918 }, { "content": "#pragma once\n\n\n\n#include \"caffe2/core/context.h\"\n\n#include \"caffe2/core/logging.h\"\n\n#include \"caffe2/core/operator.h\"\n\n#include \"caffe2/operators/filler_op.h\"\n\n#include \"caffe2/utils/cast.h\"\n\n#include \"caffe2/utils/math.h\"\n\n\n\nnamespace caffe2 {\n\n\n\ntemplate <typename T, class Context>\n", "file_path": "caffe2/operators/given_tensor_fill_op.h", "rank": 21, "score": 206924.72837228994 }, { "content": " break;\n\n case TensorProto_DataType_BOOL:\n\n ExtractValues<bool>();\n\n break;\n\n case TensorProto_DataType_INT16:\n\n ExtractValues<int16_t>();\n\n break;\n\n case TensorProto_DataType_INT32:\n\n ExtractValues<int>();\n\n break;\n\n case TensorProto_DataType_INT64:\n\n ExtractValues<int64_t>();\n\n break;\n\n case TensorProto_DataType_STRING:\n\n ExtractValues<std::string>();\n\n break;\n\n case TensorProto_DataType_UNDEFINED:\n\n CAFFE_THROW(\"Cannot have undefined 'dtype' argument\");\n\n default:\n\n CAFFE_THROW(\"Unexpected 'dtype' argument value: \", dtype);\n", "file_path": "caffe2/operators/given_tensor_fill_op.h", "rank": 22, "score": 206921.18267770248 }, { "content": "namespace caffe2 {\n\n\n\ninline bool BlobIsInt8TensorCPUType(const Blob& blob) {\n\n return blob.meta().Match<int8::Int8TensorCPU>();\n\n}\n\n\n\ninline bool BlobIsTensorType(const Blob& blob, DeviceType device_type) {\n\n bool is_match = blob.meta().Match<Tensor>();\n\n if (!is_match) {\n\n return false;\n\n }\n\n const Tensor* tensor = &blob.Get<Tensor>();\n\n return tensor && *tensor && tensor->GetDeviceType() == device_type;\n\n}\n\n\n\ninline Tensor* BlobSetTensor(Blob* blob, Tensor&& tensor) {\n\n return blob->Reset<Tensor>(new Tensor(std::move(tensor)));\n\n}\n\n\n\ninline Tensor GetSizedTensorWithOptions(\n\n Tensor&& previous_tensor,\n\n at::IntArrayRef dims,\n\n at::TensorOptions options) {\n\n Tensor tensor = std::move(previous_tensor);\n\n if (!tensor.defined()) {\n\n return caffe2::empty(dims, options);\n\n }\n\n if (tensor.GetDevice() == options.device() ||\n\n (!tensor.GetDevice().has_index() &&\n\n tensor.GetDeviceType() == options.device().type())) {\n\n if (tensor.sizes() != dims) {\n\n // Resize when the dims doesn't match\n\n tensor.Resize(dims);\n\n }\n\n if (tensor.dtype() == options.dtype()) {\n\n tensor.raw_mutable_data();\n\n } else {\n\n // create a new Tensor when the data_type doesn't match\n\n return caffe2::empty(dims, options);\n\n }\n\n return tensor;\n\n }\n\n return caffe2::empty(dims, options);\n\n}\n\n\n\n// need to keep both functions that returns Tensor* and the one\n\n// returns Tensor for clangr codemod\n\ninline Tensor*\n\nBlobGetMutableTensor(Blob* blob, at::IntArrayRef dims, at::TensorOptions options) {\n\n if (blob->IsType<Tensor>()) {\n\n Tensor* tensor = blob->GetMutable<Tensor>();\n\n if (*tensor) {\n\n // We only compare device_type if the index is not set since there are Tensors\n\n // TODO: remove the extra check when all the Tensors are properly initialized\n\n if (tensor->GetDevice() == options.device() || (!tensor->GetDevice().has_index() && tensor->GetDeviceType() == options.device().type())) {\n\n if (tensor->sizes() != dims) {\n\n // Resize when the dims doesn't match\n\n tensor->Resize(dims);\n\n }\n\n if (tensor->dtype() == options.dtype()) {\n\n tensor->raw_mutable_data();\n\n } else {\n\n tensor->raw_mutable_data(options.dtype());\n\n }\n\n return tensor;\n\n }\n\n // create a new Tensor when device doesn't match\n\n }\n\n }\n\n\n\n VLOG(1) << \"Create new mutable object \" << TypeMeta::TypeName<Tensor>()\n\n << \" dims: \" << dims;\n\n // << \" options: \" << options; (operator<< for Options is in at:: now)\n\n return BlobSetTensor(blob, caffe2::empty(dims, options));\n\n}\n\n\n\ninline Tensor\n\nXBlobGetMutableTensor(Blob* blob, at::IntArrayRef dims, at::TensorOptions options) {\n\n return BlobGetMutableTensor(blob, dims, options)->UnsafeSharedInstance();\n\n}\n\n\n\ninline Tensor* BlobGetMutableTensor(Blob* blob, DeviceType device_type) {\n\n if (blob->IsType<Tensor>()) {\n\n Tensor* tensor = blob->GetMutable<Tensor>();\n\n if (*tensor && tensor->GetDeviceType() == device_type) {\n\n return tensor;\n\n }\n\n }\n\n\n\n // if we're here, then either Blob didn't hold a Tensor\n\n // or that Tensor had the wrong DeviceType.\n\n VLOG(1) << \"Create new mutable object \" << TypeMeta::TypeName<Tensor>()\n\n << \" DeviceType:\" << device_type;\n\n\n\n return BlobSetTensor(blob, Tensor(device_type));\n\n}\n\n\n\ninline const Tensor& BlobGetTensor(const Blob& blob, DeviceType device_type) {\n\n if (blob.IsType<Tensor>()) {\n\n const auto& tensor = blob.Get<Tensor>();\n\n if (tensor.GetDeviceType() == device_type) {\n\n return tensor;\n\n }\n\n }\n\n CAFFE_THROW(\"Blob didn't contain a Tensor or the device_type doesn't match\");\n\n}\n\n\n\ninline Tensor BlobGetTensorOrUndefined(const Blob& blob) {\n\n if (blob.IsType<Tensor>()) {\n\n return blob.Get<Tensor>().UnsafeSharedInstance();\n\n } else {\n\n return Tensor();\n\n }\n\n}\n\n\n", "file_path": "caffe2/core/blob.h", "rank": 23, "score": 205534.0801442496 }, { "content": "struct TensorStatGetter : BlobStatGetter {\n\n size_t sizeBytes(const Blob& blob) const override {\n\n const auto& tensor = blob.Get<Tensor>();\n\n auto nbytes = tensor.nbytes();\n\n if (nbytes > 0 && tensor.IsType<std::string>()) {\n\n const auto* data = tensor.data<std::string>();\n\n for (int i = 0; i < tensor.numel(); ++i) {\n\n nbytes += data[i].size();\n\n }\n\n }\n\n return nbytes;\n\n }\n\n};\n\nREGISTER_BLOB_STAT_GETTER(Tensor, TensorStatGetter);\n\n} // namespace\n\n\n\n} // namespace caffe2\n", "file_path": "caffe2/core/tensor.cc", "rank": 24, "score": 204578.41802484958 }, { "content": "class TensorProtosDBInput final : public PrefetchOperator<Context> {\n\n public:\n\n using OperatorBase::OutputSize;\n\n using PrefetchOperator<Context>::prefetch_thread_;\n\n explicit TensorProtosDBInput(const OperatorDef& operator_def, Workspace* ws);\n\n ~TensorProtosDBInput() {\n\n PrefetchOperator<Context>::Finalize();\n\n }\n\n\n\n bool Prefetch() override;\n\n bool CopyPrefetched() override;\n\n\n\n private:\n\n // Prefetch will always just happen on the CPU side.\n\n vector<Blob> prefetched_blobs_;\n\n int batch_size_;\n\n bool shape_inferred_ = false;\n\n string key_;\n\n string value_;\n\n};\n", "file_path": "caffe2/operators/tensor_protos_db_input.h", "rank": 25, "score": 204222.03717370218 }, { "content": "class GivenTensorFillOp final : public FillerOp<Context> {\n\n public:\n\n USE_OPERATOR_CONTEXT_FUNCTIONS;\n\n explicit GivenTensorFillOp(const OperatorDef& operator_def, Workspace* ws)\n\n : FillerOp<Context>(operator_def, ws) {\n\n const ArgumentHelper helper(operator_def);\n\n // GivenTensorFillOp can be provided with a \"dtype\" arg if float is\n\n // is specified as T. Otherwise, \"dtype\" is ignored.\n\n // In the ideal world, we would get rid of templating of T at all, but we\n\n // need to provide backwards compatibility.\n\n if (!std::is_same<T, float>::value || !helper.HasArgument(\"dtype\")) {\n\n ExtractValues<T>();\n\n } else {\n\n auto dtype = cast::GetCastDataType(helper, \"dtype\");\n\n switch (dtype) {\n\n case TensorProto_DataType_FLOAT:\n\n ExtractValues<float>();\n\n break;\n\n case TensorProto_DataType_DOUBLE:\n\n ExtractValues<double>();\n", "file_path": "caffe2/operators/given_tensor_fill_op.h", "rank": 26, "score": 204221.04857540267 }, { "content": "class Blob;\n\n\n\nconstexpr int kDefaultChunkSize = -1;\n\nconstexpr int kNoChunking = 0;\n\n\n\n/**\n\n * @brief BlobSerializerBase is an abstract class that serializes a blob to a\n\n * string.\n\n *\n\n * This class exists purely for the purpose of registering type-specific\n\n * serialization code. If you need to serialize a specific type, you should\n\n * write your own Serializer class, and then register it using\n\n * REGISTER_BLOB_SERIALIZER. For a detailed example, see TensorSerializer for\n\n * details.\n\n */\n", "file_path": "caffe2/core/blob_serializer_base.h", "rank": 27, "score": 203327.4034045278 }, { "content": "namespace caffe2 {\n", "file_path": "caffe2/utils/proto_convert.h", "rank": 28, "score": 202833.1581697598 }, { "content": "namespace caffe2 {\n\n\n\n// A wrapper function to shut down protobuf library (this is needed in ASAN\n\n// testing and valgrind cases to avoid protobuf appearing to \"leak\" memory).\n\nCAFFE2_API void ShutdownProtobufLibrary();\n\n\n", "file_path": "caffe2/utils/proto_wrap.h", "rank": 29, "score": 202833.1581697598 }, { "content": "namespace caffe2 {\n\n\n\nstruct BlobStatGetter {\n\n virtual size_t sizeBytes(const Blob& blob) const = 0;\n\n virtual ~BlobStatGetter() {}\n\n};\n\n\n\nstruct BlobStatRegistry {\n\n private:\n\n std::unordered_map<TypeIdentifier, std::unique_ptr<BlobStatGetter>> map_;\n\n void doRegister(TypeIdentifier id, std::unique_ptr<BlobStatGetter>&& v);\n\n\n\n public:\n\n template <typename T, typename Getter>\n\n struct Registrar {\n\n Registrar() {\n\n BlobStatRegistry::instance().doRegister(\n\n TypeMeta::Id<T>(), std::unique_ptr<Getter>(new Getter));\n\n }\n\n };\n\n\n\n const BlobStatGetter* get(TypeIdentifier id);\n\n static BlobStatRegistry& instance();\n\n};\n\n\n\n#define REGISTER_BLOB_STAT_GETTER(Type, BlobStatGetterClass) \\\n\n static BlobStatRegistry::Registrar<Type, BlobStatGetterClass> \\\n\n C10_ANONYMOUS_VARIABLE(BlobStatRegistry)\n\n\n\nnamespace BlobStat {\n\n\n\n/**\n\n * Return size in bytes of the blob, if available for a blob of given type.\n\n * If not available, return 0.\n\n */\n\nCAFFE2_API size_t sizeBytes(const Blob& blob);\n\n}\n", "file_path": "caffe2/core/blob_stats.h", "rank": 30, "score": 202802.64107471198 }, { "content": " /// Discriminator for LLVM-style RTTI (isa<>)\n\n enum class NNDataKind { Generic, Tensor };\n\n\n\n NeuralNetData(NNDataKind kind) : kind_(kind) {}\n\n\n\n NeuralNetData() : kind_(NNDataKind::Generic) {}\n\n\n\n NNDataKind getKind() const {\n\n return kind_;\n\n }\n\n\n\n virtual NeuralNetData* clone() = 0;\n\n\n\n const std::string getName() const;\n\n\n\n virtual ~NeuralNetData() = 0;\n\n\n\n private:\n\n NNDataKind kind_;\n\n};\n\n\n", "file_path": "caffe2/core/nomnigraph/include/nomnigraph/Representations/NeuralNet.h", "rank": 31, "score": 202741.91189487284 }, { "content": "namespace caffe2 {\n\nnamespace int8 {\n\n\n\nstruct Int8TensorCPU {\n\n float scale{1.0};\n\n int32_t zero_point{0};\n\n // Generally stores uint8_t data, but sometimes int32_t (e.g. bias\n\n // parameters).\n\n Tensor t{CPU};\n\n};\n\n} // namespace int8\n", "file_path": "caffe2/core/tensor_int8.h", "rank": 32, "score": 202619.6541712706 }, { "content": "namespace caffe2 {\n\n using at::ToVectorint64_t;\n\n using at::size_from_dim_;\n\n using at::size_to_dim_;\n\n using at::size_between_dim_;\n\n using at::canonical_axis_index_;\n\n using at::TensorImpl;\n", "file_path": "caffe2/core/tensor_impl.h", "rank": 33, "score": 202619.6541712706 }, { "content": " def test_uniform_int_fill_op_blob_input(self, shape, a, b, gc, dc):\n\n net = core.Net('test_net')\n\n\n\n with core.DeviceScope(core.DeviceOption(caffe2_pb2.CPU)):\n\n shape_blob = net.Const(shape, dtype=np.int64)\n\n a_blob = net.Const(a, dtype=np.int32)\n\n b_blob = net.Const(b, dtype=np.int32)\n\n uniform_fill = net.UniformIntFill([shape_blob, a_blob, b_blob],\n\n 1, input_as_shape=1)\n\n\n\n workspace.RunNetOnce(net)\n\n\n\n blob_out = workspace.FetchBlob(uniform_fill)\n\n if b < a:\n\n new_shape = shape[:]\n\n new_shape[0] = 0\n\n np.testing.assert_array_equal(new_shape, blob_out.shape)\n\n else:\n\n np.testing.assert_array_equal(shape, blob_out.shape)\n\n self.assertTrue((blob_out >= a).all())\n", "file_path": "caffe2/python/operator_test/filler_ops_test.py", "rank": 34, "score": 202608.48559832587 }, { "content": "class CAFFE2_API Tensor final {\n\n private:\n\n enum Unsafe { IDoWantAliasing };\n\n Tensor(const Tensor& other, Unsafe _) : impl_(other.getIntrusivePtr()) {}\n\n\n\n protected:\n\n using TensorImplPtr = c10::intrusive_ptr<TensorImpl, UndefinedTensorImpl>;\n\n TensorImplPtr impl_;\n\n\n\n void enforce_invariants();\n\n\n\n public:\n\n Tensor() : impl_() {}\n\n\n\n Tensor(const Tensor& t) : impl_(t.impl_) {}\n\n Tensor& operator=(const Tensor& t) {\n\n impl_ = t.impl_;\n\n return *this;\n\n }\n\n\n", "file_path": "caffe2/core/tensor.h", "rank": 35, "score": 201947.98347534443 }, { "content": "#include \"caffe2/operators/tensor_protos_db_input.h\"\n\n\n\nnamespace caffe2 {\n\nREGISTER_CPU_OPERATOR(TensorProtosDBInput, TensorProtosDBInput<CPUContext>);\n\n\n\nOPERATOR_SCHEMA(TensorProtosDBInput)\n\n .NumInputs(1)\n\n .NumOutputs(1, INT_MAX)\n\n .SetDoc(R\"DOC(\n\nTensorProtosDBInput is a simple input operator that basically reads things\n\nfrom a db where each key-value pair stores an index as key, and a TensorProtos\n", "file_path": "caffe2/operators/tensor_protos_db_input.cc", "rank": 36, "score": 201661.94610357977 }, { "content": " true /* required */)\n\n .Arg(\n\n \"shape\",\n\n \"The shape of the output tensor.\"\n\n \"Cannot set the shape argument and pass in an input at the same time.\")\n\n .Arg(\n\n \"extra_shape\",\n\n \"The additional dimensions appended at the end of the shape indicated\"\n\n \"by the input blob.\"\n\n \"Cannot set the extra_shape argument when there is no input blob.\")\n\n .Arg(\n\n \"input_as_shape\",\n\n \"1D tensor containing the desired output shape. First input must be in CPU context.\")\n\n .TensorInferenceFunction(\n\n FillerTensorInference<TensorProto_DataType_STRING>);\n\n\n\n} // namespace caffe2\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 37, "score": 201652.55573250438 }, { "content": " \"extra_shape\",\n\n \"The additional dimensions appended at the end of the shape indicated\"\n\n \"by the input blob.\"\n\n \"Cannot set the extra_shape argument when there is no input blob.\")\n\n .Arg(\n\n \"input_as_shape\",\n\n \"1D tensor containing the desired output shape. First input must be in CPU context.\")\n\n .TensorInferenceFunction(FillerTensorInference<TensorProto_DataType_INT16>);\n\n\n\nOPERATOR_SCHEMA(GivenTensorIntFill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .Arg(\n\n \"values\",\n\n \"The value for the elements of the output tensor.\",\n\n true /* required */)\n\n .Arg(\n\n \"shape\",\n\n \"The shape of the output tensor.\"\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 38, "score": 201651.1090022454 }, { "content": "#include \"caffe2/operators/given_tensor_fill_op.h\"\n\n\n\nnamespace caffe2 {\n\n\n\nREGISTER_CPU_OPERATOR(GivenTensorFill, GivenTensorFillOp<float, CPUContext>);\n\nREGISTER_CPU_OPERATOR(\n\n GivenTensorDoubleFill,\n\n GivenTensorFillOp<double, CPUContext>);\n\nREGISTER_CPU_OPERATOR(GivenTensorBoolFill, GivenTensorFillOp<bool, CPUContext>);\n\nREGISTER_CPU_OPERATOR(\n\n GivenTensorInt16Fill,\n\n GivenTensorFillOp<int16_t, CPUContext>);\n\nREGISTER_CPU_OPERATOR(GivenTensorIntFill, GivenTensorFillOp<int, CPUContext>);\n\nREGISTER_CPU_OPERATOR(\n\n GivenTensorInt64Fill,\n\n GivenTensorFillOp<int64_t, CPUContext>);\n\nREGISTER_CPU_OPERATOR(\n\n GivenTensorStringFill,\n\n GivenTensorFillOp<std::string, CPUContext>);\n\n\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 39, "score": 201647.9574746153 }, { "content": "NO_GRADIENT(GivenTensorFill);\n\nNO_GRADIENT(GivenTensorDoubleFill);\n\nNO_GRADIENT(GivenTensorBoolFill);\n\nNO_GRADIENT(GivenTensorInt16Fill);\n\nNO_GRADIENT(GivenTensorIntFill);\n\nNO_GRADIENT(GivenTensorInt64Fill);\n\nNO_GRADIENT(GivenTensorStringFill);\n\n\n\nOPERATOR_SCHEMA(GivenTensorFill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .SetDoc(R\"DOC(\n\nThis op fills an output tensor with the data specified by the *value* and *dtype* arguments. The output tensor shape is specified by the *shape* argument. Beware, when using this argument *value* should have a value for every element of the *output*, as missing values will not be initialized automatically. If *input_as_shape* is set to *true*, then the *input* should be a 1D tensor containing the desired output shape (the dimensions specified in *extra_shape* will also be appended). In this case, the *shape* argument should **not** be set.\n\n\n\n*Note: Do not set the shape argument and pass in an input at the same time.*\n\n\n\nGithub Links:\n\n- https://github.com/caffe2/caffe2/blob/master/caffe2/operators/given_tensor_fill_op.h\n\n- https://github.com/caffe2/caffe2/blob/master/caffe2/operators/given_tensor_fill_op.cc\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 40, "score": 201647.53752103946 }, { "content": " .Arg(\n\n \"dtype\",\n\n \"The data type for the elements of the output tensor. Strictly must be one of the types from DataType enum in TensorProto.\")\n\n .Arg(\n\n \"shape\",\n\n \"*(type: [int])* Desired shape of the *output* tensor.\")\n\n .Arg(\n\n \"extra_shape\",\n\n \"*(type: [int])* The additional dimensions appended at the end of the *shape* indicated by the input blob. Cannot set the *extra_shape* argument when there is no input blob.\")\n\n .Arg(\n\n \"input_as_shape\",\n\n \"*(type: bool; default: False)* set to *True* to use the *input* as shape. First, input must be in CPU context.\")\n\n .Input(\n\n 0,\n\n \"input\",\n\n \"(Optional) 1D tensor specifying the shape of the output. Must be used with *input_as_shape=True*\")\n\n .Output(\n\n 0,\n\n \"output\",\n\n \"Output tensor with desired dimension filled with specified data. If the shape argument is set, this is the shape specified, and if the *input* exists and *input_as_shape=True*, it is the shape specified by the *input* tensor.\")\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 41, "score": 201647.48164538978 }, { "content": " \"shape\",\n\n \"The shape of the output tensor.\"\n\n \"Cannot set the shape argument and pass in an input at the same time.\")\n\n .Arg(\n\n \"extra_shape\",\n\n \"The additional dimensions appended at the end of the shape indicated\"\n\n \"by the input blob.\"\n\n \"Cannot set the extra_shape argument when there is no input blob.\")\n\n .Arg(\n\n \"input_as_shape\",\n\n \"1D tensor containing the desired output shape. First input must be in CPU context.\")\n\n .TensorInferenceFunction(FillerTensorInference<TensorProto_DataType_INT64>);\n\n\n\nOPERATOR_SCHEMA(GivenTensorStringFill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .Arg(\n\n \"values\",\n\n \"The value for the elements of the output tensor.\",\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 42, "score": 201646.29521375074 }, { "content": " \"Cannot set the shape argument and pass in an input at the same time.\")\n\n .Arg(\n\n \"extra_shape\",\n\n \"The additional dimensions appended at the end of the shape indicated\"\n\n \"by the input blob.\"\n\n \"Cannot set the extra_shape argument when there is no input blob.\")\n\n .Arg(\n\n \"input_as_shape\",\n\n \"1D tensor containing the desired output shape. First input must be in CPU context.\")\n\n .TensorInferenceFunction(FillerTensorInference<TensorProto_DataType_INT32>);\n\n\n\nOPERATOR_SCHEMA(GivenTensorInt64Fill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .Arg(\n\n \"values\",\n\n \"The value for the elements of the output tensor.\",\n\n true /* required */)\n\n .Arg(\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 43, "score": 201646.21959316905 }, { "content": " \"by the input blob.\"\n\n \"Cannot set the extra_shape argument when there is no input blob.\")\n\n .Arg(\n\n \"input_as_shape\",\n\n \"1D tensor containing the desired output shape. First input must be in CPU context.\")\n\n .TensorInferenceFunction(FillerTensorInference<TensorProto_DataType_BOOL>);\n\n\n\nOPERATOR_SCHEMA(GivenTensorInt16Fill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .Arg(\n\n \"values\",\n\n \"The value for the elements of the output tensor.\",\n\n true /* required */)\n\n .Arg(\n\n \"shape\",\n\n \"The shape of the output tensor.\"\n\n \"Cannot set the shape argument and pass in an input at the same time.\")\n\n .Arg(\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 44, "score": 201645.17146681706 }, { "content": " \"input_as_shape\",\n\n \"1D tensor containing the desired output shape. First input must be in CPU context.\")\n\n .TensorInferenceFunction(\n\n FillerTensorInference<TensorProto_DataType_DOUBLE>);\n\n\n\nOPERATOR_SCHEMA(GivenTensorBoolFill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .Arg(\n\n \"values\",\n\n \"The value for the elements of the output tensor.\",\n\n true /* required */)\n\n .Arg(\n\n \"shape\",\n\n \"The shape of the output tensor.\"\n\n \"Cannot set the shape argument and pass in an input at the same time.\")\n\n .Arg(\n\n \"extra_shape\",\n\n \"The additional dimensions appended at the end of the shape indicated\"\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 45, "score": 201639.43681689564 }, { "content": " .TensorInferenceFunction(FillerTensorInference<>);\n\n\n\nOPERATOR_SCHEMA(GivenTensorDoubleFill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .Arg(\n\n \"values\",\n\n \"The value for the elements of the output tensor.\",\n\n true /* required */)\n\n .Arg(\n\n \"shape\",\n\n \"The shape of the output tensor.\"\n\n \"Cannot set the shape argument and pass in an input at the same time.\")\n\n .Arg(\n\n \"extra_shape\",\n\n \"The additional dimensions appended at the end of the shape indicated\"\n\n \"by the input blob.\"\n\n \"Cannot set the extra_shape argument when there is no input blob.\")\n\n .Arg(\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 46, "score": 201639.3075912731 }, { "content": "print(\"Out:\\n\", workspace.FetchBlob(\"out\"))\n\n\n\n```\n\n\n\n**Result**\n\n\n\n```\n\n\n\nOut:\n\n [1. 2. 3.]\n\n\n\n```\n\n\n\n</details>\n\n\n\n)DOC\")\n\n .Arg(\n\n \"values\",\n\n \"*(type depends on dtype, Required=True)* The value of the elements to go in the *output* tensor.\",\n\n true /* required */)\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 47, "score": 201626.2095246784 }, { "content": "\n\n<details>\n\n\n\n<summary> <b>Example</b> </summary>\n\n\n\n**Code**\n\n\n\n```\n\n\n\nworkspace.ResetWorkspace()\n\n\n\nop = core.CreateOperator(\n\n \"GivenTensorFill\",\n\n [],\n\n [\"out\"],\n\n values=[1., 2., 3.],\n\n shape=[3],\n\n)\n\n\n\nworkspace.RunOperatorOnce(op)\n", "file_path": "caffe2/operators/given_tensor_fill_op.cc", "rank": 48, "score": 201626.0993732907 }, { "content": "namespace caffe2 {\n\n\n\n/**\n\n * Packed weight matrix for DNNLOWP Int8FC operator\n\n */\n\nstruct Int8FCDNNLowPPackedWeightBlob {\n\n std::vector<dnnlowp::TensorQuantizationParams> qparams;\n\n std::shared_ptr<std::vector<std::int32_t>> column_offsets;\n\n\n\n // The original tensor before packing but only with meta information\n\n Tensor original_tensor{CPU};\n\n\n\n std::shared_ptr<std::vector<std::int32_t>> bias;\n\n\n\n // Only for 32-bit accumulation\n\n std::shared_ptr<fbgemm::PackBMatrix<std::int8_t>> W;\n\n\n\n // Only for 16-bit accumulation\n\n // Dense matrix holding common values\n\n std::shared_ptr<fbgemm::PackBMatrix<std::int8_t, std::int16_t>> W_acc16;\n\n // Sparse matrix holding outliers\n\n std::shared_ptr<fbgemm::CompressedSparseColumn> W_outlier;\n\n int nbits_in_non_outlier;\n\n};\n\n\n\n/**\n\n * Packed weight matrix for DNNLOWP Int8Conv operator\n\n */\n\nstruct Int8ConvDNNLowPPackedWeightBlob : public Int8FCDNNLowPPackedWeightBlob {\n\n // Only for 32-bit accumulation\n\n std::shared_ptr<fbgemm::PackedDepthWiseConvMatrix> W_depthwise;\n\n std::shared_ptr<fbgemm::PackWeightMatrixForGConv<std::int8_t>> W_gconv;\n\n std::shared_ptr<\n\n fbgemm::PackWeightMatrixForGConv<std::int8_t, std::int32_t, 3>>\n\n W_gconv3d;\n\n};\n\n\n", "file_path": "caffe2/quantization/server/fbgemm_pack_blob.h", "rank": 49, "score": 197653.99665615754 }, { "content": "#include \"caffe2/core/common_gpu.h\"\n\n#include \"caffe2/core/context_gpu.h\"\n\n#include \"caffe2/operators/tensor_protos_db_input.h\"\n\n\n\nnamespace caffe2 {\n\nREGISTER_CUDA_OPERATOR(TensorProtosDBInput, TensorProtosDBInput<CUDAContext>);\n\n} // namespace caffe2\n", "file_path": "caffe2/operators/tensor_protos_db_input_gpu.cc", "rank": 50, "score": 196630.77981012705 }, { "content": "#ifndef CAFFE2_OPERATORS_INT8_GIVEN_TENSOR_FILL_OP_H_\n\n#define CAFFE2_OPERATORS_INT8_GIVEN_TENSOR_FILL_OP_H_\n\n\n\n#include \"caffe2/core/context.h\"\n\n#include \"caffe2/core/logging.h\"\n\n#include \"caffe2/core/operator.h\"\n\n#include \"caffe2/core/tensor_int8.h\"\n\n#include \"caffe2/operators/filler_op.h\"\n\n#include \"caffe2/utils/cast.h\"\n\n#include \"caffe2/utils/math.h\"\n\n\n\nnamespace caffe2 {\n\nnamespace int8 {\n\n\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.h", "rank": 51, "score": 196628.3652456766 }, { "content": " }\n\n return true;\n\n }\n\n\n\n float scale_;\n\n int32_t zero_point_;\n\n vector<int64_t> shape_;\n\n Tensor values_;\n\n};\n\n\n\n} // namespace int8\n\n} // namespace caffe2\n\n\n\n#endif // CAFFE2_OPERATORS_INT8_GIVEN_TENSOR_FILL_OP_H_\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.h", "rank": 52, "score": 196619.08807621506 }, { "content": " private:\n\n void ExtractValues() {\n\n auto source_values = this->template GetRepeatedArgument<int32_t>(\"values\");\n\n ReinitializeTensor(\n\n &values_, {static_cast<int64_t>(source_values.size())}, at::dtype<int32_t>().device(CPU));\n\n auto* values_data = values_.template mutable_data<int32_t>();\n\n for (int i = 0; i < source_values.size(); i++) {\n\n values_data[i] = static_cast<int32_t>(source_values[i]);\n\n }\n\n }\n\n\n\n bool Fill(Int8TensorCPU* output) {\n\n DCHECK_EQ(output->t.numel(), values_.numel())\n\n << \"output size: \" << output->t.numel()\n\n << \" given size: \" << values_.numel();\n\n auto* data = output->t.template mutable_data<int32_t>();\n\n const auto* values_data = values_.template data<int32_t>();\n\n if (output->t.numel()) {\n\n context_.template CopySameDevice<int32_t>(\n\n output->t.numel(), values_data, data);\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.h", "rank": 53, "score": 196612.84812837056 }, { "content": " private:\n\n void ExtractValues() {\n\n auto source_values = this->template GetSingleArgument<string>(\"values\", \"\");\n\n ReinitializeTensor(\n\n &values_, {static_cast<int64_t>(source_values.size())}, at::dtype<uint8_t>().device(CPU));\n\n uint8_t* values_data = values_.template mutable_data<uint8_t>();\n\n for (int i = 0; i < source_values.size(); i++) {\n\n values_data[i] = static_cast<uint8_t>(source_values[i]);\n\n }\n\n }\n\n\n\n bool Fill(Int8TensorCPU* output) {\n\n DCHECK_EQ(output->t.numel(), values_.numel())\n\n << \"output size: \" << output->t.numel()\n\n << \" given size: \" << values_.numel();\n\n auto* data = output->t.template mutable_data<uint8_t>();\n\n const uint8_t* values_data = values_.template data<uint8_t>();\n\n if (output->t.numel()) {\n\n context_.template CopySameDevice<uint8_t>(\n\n output->t.numel(), values_data, data);\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.h", "rank": 54, "score": 196611.16199918493 }, { "content": "class ConstTensorView {\n\n public:\n\n ConstTensorView(const T* data, const std::vector<int>& dims)\n\n : data_(data), dims_(dims) {}\n\n\n\n int ndim() const {\n\n return dims_.size();\n\n }\n\n const std::vector<int>& dims() const {\n\n return dims_;\n\n }\n\n int dim(int i) const {\n\n DCHECK_LE(i, dims_.size());\n\n return dims_[i];\n\n }\n\n const T* data() const {\n\n return data_;\n\n }\n\n size_t size() const {\n\n return std::accumulate(\n", "file_path": "caffe2/operators/generate_proposals_op.h", "rank": 55, "score": 196597.35963965135 }, { "content": " }\n\n return true;\n\n }\n\n\n\n float scale_;\n\n int32_t zero_point_;\n\n vector<int64_t> shape_;\n\n Tensor values_;\n\n};\n\n\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.h", "rank": 56, "score": 196596.96722347898 }, { "content": "class Int8GivenTensorFillOp final : public Operator<CPUContext> {\n\n public:\n\n template <class... Args>\n\n explicit Int8GivenTensorFillOp(Args&&... args)\n\n : Operator<CPUContext>(std::forward<Args>(args)...),\n\n scale_(this->template GetSingleArgument<float>(\"Y_scale\", 1.0)),\n\n zero_point_(\n\n this->template GetSingleArgument<int32_t>(\"Y_zero_point\", 0)),\n\n shape_(this->template GetRepeatedArgument<int64_t>(\"shape\")) {\n\n ExtractValues();\n\n }\n\n\n\n bool RunOnDevice() override {\n\n auto* output = Outputs()[0]->template GetMutable<Int8TensorCPU>();\n\n ReinitializeTensor(&output->t, shape_, at::dtype<uint8_t>().device(CPU));\n\n output->scale = scale_;\n\n output->zero_point = zero_point_;\n\n return Fill(output);\n\n }\n\n\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.h", "rank": 57, "score": 194896.9931193494 }, { "content": "// TODO: Change dims related arguments to int64_t?\n\nclass Tensor;\n\n\n", "file_path": "caffe2/utils/math.h", "rank": 58, "score": 194733.84520629773 }, { "content": "from __future__ import absolute_import\n\nfrom __future__ import division\n\nfrom __future__ import print_function\n\nfrom __future__ import unicode_literals\n\n\n\nfrom caffe2.python import core\n\nfrom hypothesis import given\n\nimport hypothesis.strategies as st\n\nimport caffe2.python.hypothesis_test_util as hu\n\nimport numpy as np\n\n\n\nimport unittest\n\n\n\n\n\nclass TestGivenTensorFillOps(hu.HypothesisTestCase):\n\n @given(X=hu.tensor(min_dim=1, max_dim=4, dtype=np.int32),\n\n t=st.sampled_from([\n\n (core.DataType.BOOL, np.bool_, \"GivenTensorFill\"),\n\n (core.DataType.INT32, np.int32, \"GivenTensorFill\"),\n\n (core.DataType.FLOAT, np.float32, \"GivenTensorFill\"),\n\n (core.DataType.INT16, np.int16, \"GivenTensorInt16Fill\"),\n\n (core.DataType.INT32, np.int32, \"GivenTensorIntFill\"),\n\n (core.DataType.INT64, np.int64, \"GivenTensorInt64Fill\"),\n\n (core.DataType.BOOL, np.bool_, \"GivenTensorBoolFill\"),\n\n (core.DataType.DOUBLE, np.double, \"GivenTensorDoubleFill\"),\n\n (core.DataType.INT32, np.double, \"GivenTensorDoubleFill\"),\n\n ]),\n\n **hu.gcs)\n\n def test_given_tensor_fill(self, X, t, gc, dc):\n\n X = X.astype(t[1])\n\n print('X: ', str(X))\n\n op = core.CreateOperator(\n\n t[2], [], [\"Y\"],\n\n shape=X.shape,\n\n dtype=t[0],\n\n values=X.reshape((1, X.size)),\n\n )\n\n\n\n def constant_fill(*args, **kw):\n\n return [X]\n\n\n\n self.assertReferenceChecks(gc, op, [], constant_fill)\n\n self.assertDeviceChecks(dc, op, [], [0])\n\n\n\n\n\nif __name__ == \"__main__\":\n\n unittest.main()\n", "file_path": "caffe2/python/operator_test/given_tensor_fill_op_test.py", "rank": 59, "score": 193031.07341404934 }, { "content": " def test_given_tensor_fill(self, X, t, gc, dc):\n\n X = X.astype(t[1])\n\n print('X: ', str(X))\n\n op = core.CreateOperator(\n\n t[2], [], [\"Y\"],\n\n shape=X.shape,\n\n dtype=t[0],\n\n values=X.reshape((1, X.size)),\n\n )\n\n\n\n def constant_fill(*args, **kw):\n\n return [X]\n\n\n\n self.assertReferenceChecks(gc, op, [], constant_fill)\n", "file_path": "caffe2/python/operator_test/given_tensor_fill_op_test.py", "rank": 60, "score": 191981.67191248824 }, { "content": "#include \"int8_given_tensor_fill_op.h\"\n\n\n\nnamespace caffe2 {\n\n\n\nOPERATOR_SCHEMA(Int8GivenTensorFill)\n\n .NumInputs(0)\n\n .NumOutputs(1)\n\n .Arg(\"values\", \"Input array of type char(byte)\")\n\n .Arg(\"shape\", \"Input tensor shape\")\n\n .Arg(\"Y_scale\", \"Output tensor quantization scale\")\n\n .Arg(\"Y_zero_point\", \"Output tensor quantization offset\")\n\n .SetDoc(R\"DOC(\n\n Creates quantized tensor of type char(byte) with scale and zero point info.\n\n)DOC\")\n\n .Output(0, \"Tensor\", \"An Int8TensorCPU with scale and zero point info\")\n\n .TensorInferenceFunction(FillerTensorInference<>);\n\n\n\nOPERATOR_SCHEMA(Int8GivenIntTensorFill)\n\n .NumInputs(0)\n\n .NumOutputs(1)\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.cc", "rank": 61, "score": 191840.79364789542 }, { "content": " .Arg(\"values\", \"Input array of type int32\")\n\n .Arg(\"shape\", \"Input tensor shape\")\n\n .Arg(\"Y_scale\", \"Output tensor quantization scale\")\n\n .Arg(\"Y_zero_point\", \"Output tensor quantization offset\")\n\n .SetDoc(R\"DOC(\n\n Creates quantized tensor of type int32 with scale and zero point info.\n\n)DOC\")\n\n .Output(0, \"Tensor\", \"An Int8TensorCPU with scale and zero point info\")\n\n .TensorInferenceFunction(FillerTensorInference<>);\n\n\n\nREGISTER_CPU_OPERATOR(Int8GivenTensorFill, int8::Int8GivenTensorFillOp);\n\nREGISTER_CPU_OPERATOR(Int8GivenIntTensorFill, int8::Int8GivenIntTensorFillOp);\n\n\n\n} // namespace caffe2\n", "file_path": "caffe2/operators/quantized/int8_given_tensor_fill_op.cc", "rank": 62, "score": 191839.72121985347 }, { "content": " << \" given size: \" << source_values.size();\n\n\n\n auto str = source_values[0];\n\n ReinitializeTensor(&values_, {static_cast<int64_t>(str.size())}, at::dtype<uint8_t>().device(CPU));\n\n uint8_t* values_data = values_.template mutable_data<uint8_t>();\n\n for (int i = 0; i < str.size(); i++) {\n\n values_data[i] = static_cast<uint8_t>(str[i]);\n\n }\n\n}\n\n\n\nTensor values_;\n\n};\n\n} // namespace caffe2\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.h", "rank": 63, "score": 191837.48157090603 }, { "content": "#pragma once\n\n\n\n#include \"caffe2/core/context.h\"\n\n#include \"caffe2/core/logging.h\"\n\n#include \"caffe2/core/operator.h\"\n\n#include \"caffe2/operators/filler_op.h\"\n\n#include \"caffe2/utils/cast.h\"\n\n#include \"caffe2/utils/math.h\"\n\n\n\nnamespace caffe2 {\n\n\n\ntemplate <class Context>\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.h", "rank": 64, "score": 191834.88415674417 }, { "content": " }\n\n\n\n bool Fill(Tensor* output) override {\n\n DCHECK_EQ(output->numel(), values_.numel())\n\n << \"output size: \" << output->numel()\n\n << \" given size: \" << values_.numel();\n\n auto* data = output->template mutable_data<uint8_t>();\n\n const uint8_t* values_data = values_.template data<uint8_t>();\n\n if (output->numel()) {\n\n context_.template CopySameDevice<uint8_t>(\n\n output->numel(), values_data, data);\n\n }\n\n return true;\n\n }\n\n\n\n private:\n\n void Extract() {\n\n auto source_values = this->template GetRepeatedArgument<string>(\"values\");\n\n DCHECK_EQ(source_values.size(), 1)\n\n << \"expected size: 1 \"\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.h", "rank": 65, "score": 191829.34349410495 }, { "content": "class Tensor;\n\n\n\nnamespace math {\n\n\n\ntemplate <typename T, class Context>\n\nCAFFE2_API void\n\nReduceMin(const int N, const T* X, T* y, Tensor* scratch_ptr, Context* context);\n\n\n\ntemplate <typename T, class Context>\n\nCAFFE2_API void\n\nReduceMax(const int N, const T* X, T* y, Tensor* scratch_ptr, Context* context);\n\n\n\n// In all of the reduce functions, X_dims and Y_dims should have ndim elements.\n\n// Each dimension of Y_dims must match the corresponding dimension of X_dims or\n\n// must be equal to 1. The dimensions equal to 1 indicate the dimensions of X to\n\n// be reduced.\n\n\n\n// Y = alpha * ReduceMin(X)\n\ntemplate <typename T, class Context>\n\nCAFFE2_API void ReduceMin(\n", "file_path": "caffe2/utils/math/reduce.h", "rank": 66, "score": 190840.0951839801 }, { "content": "def ndim(a : Tensor) -> int:\n\n return a.dim()\n", "file_path": "torch/csrc/jit/frontend/builtin_functions.cpp", "rank": 67, "score": 190121.12009311505 }, { "content": "class Tensor;\n\n\n\n/**\n\n * @brief Blob is a general container that hosts a typed pointer.\n\n *\n\n * A Blob hosts a pointer as well as its type, and takes charge of deleting it\n\n * properly when the blob is deallocated or re-allocated with a new type. A blob\n\n * could contain anything, although the most common case is to contain a Tensor.\n\n */\n", "file_path": "aten/src/ATen/core/blob.h", "rank": 68, "score": 189671.5208816167 }, { "content": "class IDEEPInt8GivenTensorFillOp final : public IDEEPOperator {\n\n public:\n\n USE_IDEEP_DEF_ALIASES();\n\n USE_IDEEP_OPERATOR_FUNCTIONS();\n\n\n\n IDEEPInt8GivenTensorFillOp(const OperatorDef& operator_def, Workspace* ws)\n\n : IDEEPOperator(operator_def, ws),\n\n zero_point_(\n\n this->template GetSingleArgument<int32_t>(\"Y_zero_point\", 0)),\n\n shape_(this->template GetRepeatedArgument<itensor::dim>(\"shape\")) {\n\n CAFFE_ENFORCE(shape_.size() == 4 || shape_.size() == 2 || shape_.size() == 1);\n\n CAFFE_ENFORCE(zero_point_ == 0 || zero_point_ == 128,\n\n \"Not support zero point\");\n\n if (HasArgument(\"Y_scales\")) {\n\n scales_ = this->template GetRepeatedArgument<float>(\"Y_scales\");\n\n } else {\n\n auto scale = (this->template GetSingleArgument<float>(\"Y_scale\", 1.0));\n\n scales_ = {scale};\n\n }\n\n\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 69, "score": 189155.08415883873 }, { "content": "class TestGivenTensorFillOps(hu.HypothesisTestCase):\n\n @given(X=hu.tensor(min_dim=1, max_dim=4, dtype=np.int32),\n\n t=st.sampled_from([\n\n (core.DataType.BOOL, np.bool_, \"GivenTensorFill\"),\n\n (core.DataType.INT32, np.int32, \"GivenTensorFill\"),\n\n (core.DataType.FLOAT, np.float32, \"GivenTensorFill\"),\n\n (core.DataType.INT16, np.int16, \"GivenTensorInt16Fill\"),\n\n (core.DataType.INT32, np.int32, \"GivenTensorIntFill\"),\n\n (core.DataType.INT64, np.int64, \"GivenTensorInt64Fill\"),\n\n (core.DataType.BOOL, np.bool_, \"GivenTensorBoolFill\"),\n\n (core.DataType.DOUBLE, np.double, \"GivenTensorDoubleFill\"),\n\n (core.DataType.INT32, np.double, \"GivenTensorDoubleFill\"),\n\n ]),\n\n **hu.gcs)\n\n def test_given_tensor_fill(self, X, t, gc, dc):\n\n X = X.astype(t[1])\n\n print('X: ', str(X))\n\n op = core.CreateOperator(\n\n t[2], [], [\"Y\"],\n\n shape=X.shape,\n\n dtype=t[0],\n\n values=X.reshape((1, X.size)),\n\n )\n\n\n\n def constant_fill(*args, **kw):\n\n return [X]\n\n\n\n self.assertReferenceChecks(gc, op, [], constant_fill)\n", "file_path": "caffe2/python/operator_test/given_tensor_fill_op_test.py", "rank": 70, "score": 189155.08415883873 }, { "content": " \"The shape of the output tensor.\"\n\n \"Cannot set the shape argument and pass in an input at the same time.\")\n\n .Arg(\n\n \"extra_shape\",\n\n \"The additional dimensions appended at the end of the shape indicated\"\n\n \"by the input blob.\"\n\n \"Cannot set the extra_shape argument when there is no input blob.\")\n\n .Arg(\n\n \"input_as_shape\",\n\n \"1D tensor containing the desired output shape. First input must be in CPU context.\")\n\n .TensorInferenceFunction(\n\n FillerTensorInference<TensorProto_DataType_STRING>);\n\n\n\n} // namespace caffe2\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.cc", "rank": 71, "score": 187298.07625716523 }, { "content": "#include \"caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.h\"\n\n\n\nnamespace caffe2 {\n\nREGISTER_CPU_OPERATOR(\n\n GivenTensorByteStringToUInt8Fill,\n\n GivenTensorByteStringToUInt8FillOp<CPUContext>);\n\n\n\nNO_GRADIENT(GivenTensorByteStringToUInt8Fill);\n\n\n\nOPERATOR_SCHEMA(GivenTensorByteStringToUInt8Fill)\n\n .NumInputs(0, 1)\n\n .NumOutputs(1)\n\n .AllowInplace({{0, 0}})\n\n .SetDoc(R\"DOC(\n\nThis op fills a uint8 output tensor with the data specified by the *value* argument. The data must previously be serialized as a byte string. The output tensor shape is specified by the *shape* argument. Beware, when using this argument *value* should have a value for every element of the *output*, as missing values will not be initialized automatically. If *input_as_shape* is set to *true*, then the *input* should be a 1D tensor containing the desired output shape (the dimensions specified in *extra_shape* will also be appended). In this case, the *shape* argument should **not** be set.\n\n\n\nThis op allows us to write uint8 tensors to Protobuf as byte strings and read them back as uint8 tensors in order to avoid the Protobuf uint32_t varint encoding size penalty.\n\n\n\n<details>\n\n\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.cc", "rank": 72, "score": 187291.18917188628 }, { "content": " }\n\n return true;\n\n }\n\n\n\n private:\n\n iscale scales_;\n\n int32_t zero_point_;\n\n itensor::dims shape_;\n\n Tensor values_{CPU};\n\n\n\n OUTPUT_TAGS(OUTPUT);\n\n};\n\n\n\nREGISTER_IDEEP_OPERATOR(Int8GivenTensorFill, IDEEPInt8GivenTensorFillOp);\n\nREGISTER_IDEEP_OPERATOR(Int8GivenIntTensorFill, IDEEPInt8GivenIntTensorFillOp);\n\n\n\n} // namespace\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 73, "score": 187286.4984443066 }, { "content": "#include <caffe2/ideep/ideep_utils.h>\n\n\n\nusing namespace caffe2;\n\n\n\nnamespace {\n\n\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 74, "score": 187282.34410841818 }, { "content": "<summary> <b>Example</b> </summary>\n\n\n\n**Code**\n\n\n\n```\n\n\n\nworkspace.ResetWorkspace()\n\n\n\nval = np.array([1, 2, 3], dtype=np.uint8)\n\nop = core.CreateOperator(\n\n \"GivenTensorByteStringToUInt8Fill\",\n\n [],\n\n [\"out\"],\n\n values=[val.tobytes()],\n\n shape=val.shape,\n\n)\n\n\n\nworkspace.RunOperatorOnce(op)\n\nprint(\"Out:\\n\", workspace.FetchBlob(\"out\"))\n\n\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.cc", "rank": 75, "score": 187274.02343896238 }, { "content": " auto* data_s8 = static_cast<int8_t*>(temp_ten.get_data_handle());\n\n auto nelems = temp_ten.get_nelems();\n\n for (int i = 0; i < nelems; i++) {\n\n data_s8[i] = data_s8[i] - zero_point_;\n\n }\n\n }\n\n\n\n output->feed_from(temp_ten);\n\n }\n\n\n\n output->set_scale(ConvertScales(scales_));\n\n return true;\n\n }\n\n\n\n private:\n\n iscale scales_;\n\n int32_t zero_point_;\n\n iformat fmt_;\n\n itensor::dims shape_;\n\n Tensor values_{CPU};\n\n\n\n OUTPUT_TAGS(OUTPUT);\n\n};\n\n\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 76, "score": 187273.74749371532 }, { "content": " if (shape_.size() == 4) {\n\n fmt_ = iformat::nhwc;\n\n auto C = shape_[3];\n\n shape_[3] = shape_[2];\n\n shape_[2] = shape_[1];\n\n shape_[1] = C;\n\n } else if (shape_.size() == 2) {\n\n fmt_ = iformat::nc;\n\n } else {\n\n fmt_ = iformat::x;\n\n }\n\n\n\n auto source_values = this->template GetSingleArgument<string>(\"values\", \"\");\n\n auto src_size = source_values.size();\n\n values_.Resize(src_size);\n\n uint8_t* values_data = values_.template mutable_data<uint8_t>();\n\n for (int i = 0; i < src_size; i++) {\n\n values_data[i] = static_cast<uint8_t>(source_values[i]);\n\n }\n\n }\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 77, "score": 187269.7377754296 }, { "content": " values_.Resize(src_size);\n\n auto* values_data = values_.template mutable_data<int32_t>();\n\n for (int i = 0; i < src_size; i++) {\n\n values_data[i] = static_cast<int32_t>(source_values[i]);\n\n }\n\n }\n\n\n\n bool RunOnDevice() override {\n\n auto* output = Output(OUTPUT);\n\n output->init({shape_, idtype::s32});\n\n output->set_scale(ConvertScales(scales_));\n\n DCHECK_EQ(output->get_nelems(), values_.numel())\n\n << \"output size: \" << output->get_nelems()\n\n << \" given size: \" << values_.numel();\n\n\n\n if (output->get_nelems() > 0) {\n\n auto* data = static_cast<int32_t*>(output->get_data_handle());\n\n const int32_t* values_data = values_.template data<int32_t>();\n\n context_.template CopySameDevice<int32_t>(\n\n output->get_nelems(), values_data, data);\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 78, "score": 187268.18633982877 }, { "content": "\n\n bool RunOnDevice() override {\n\n auto* output = Output(OUTPUT);\n\n auto data_type = zero_point_ == 0 ? idtype::u8 : idtype::s8;\n\n\n\n output->init({shape_, data_type});\n\n DCHECK_EQ(output->get_nelems(), values_.numel())\n\n << \"output size: \" << output->get_nelems()\n\n << \" given size: \" << values_.numel();\n\n\n\n if (output->get_nelems() > 0) {\n\n itensor temp_ten;\n\n temp_ten.init({shape_, data_type, fmt_});\n\n auto* data_u8 = static_cast<uint8_t*>(temp_ten.get_data_handle());\n\n const auto* values_data = values_.template data<uint8_t>();\n\n context_.template CopySameDevice<uint8_t>(\n\n temp_ten.get_nelems(), values_data, data_u8);\n\n\n\n // Shift quantized data to s8 per zero point\n\n if (zero_point_ == 128) {\n", "file_path": "caffe2/ideep/operators/quantization/int8_given_tensor_fill_op.cc", "rank": 79, "score": 187265.20537514795 }, { "content": "```\n\n\n\n**Result**\n\n\n\n```\n\n\n\nOut:\n\n [1 2 3]\n\n\n\n```\n\n\n\n</details>\n\n\n\n)DOC\")\n\n .Arg(\n\n \"values\",\n\n \"The value for the elements of the output tensor.\",\n\n true /* required */)\n\n .Arg(\n\n \"shape\",\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.cc", "rank": 80, "score": 187264.9781460127 }, { "content": "class TensorFetcher : public BlobFetcherBase {\n\n public:\n\n pybind11::object Fetch(const Blob& blob) override {\n\n return FetchTensor(blob.Get<Tensor>(), true).obj;\n\n }\n\n\n\n // Checks whether the data with type `dtype` needs to be copied in the context\n\n // of `tensor`\n\n bool NeedsCopy(const Tensor* tensor, const TypeMeta& dtype) const {\n\n#ifdef USE_NUMPY\n\n return tensor->GetDeviceType() != CPU ||\n\n CaffeToNumpyType(dtype) == NPY_OBJECT;\n\n#else\n\n return tensor->GetDeviceType() != CPU;\n\n#endif // USE_NUMPY\n\n }\n\n\n\n FetchedBlob FetchTensor(const Tensor& tensor, bool force_copy) {\n\n#ifdef USE_NUMPY\n\n FetchedBlob result;\n", "file_path": "caffe2/python/pybind_state.h", "rank": 81, "score": 187228.67190569118 }, { "content": "class TensorFeeder : public BlobFeederBase {\n\n public:\n\n Tensor FeedTensor(const DeviceOption& option, PyArrayObject* original_array) {\n\n Tensor out;\n\n FeedTensor(option, original_array, &out, false);\n\n return out;\n\n }\n\n\n\n void FeedTensor(\n\n const DeviceOption& option,\n\n PyArrayObject* original_array,\n\n Tensor* out,\n\n bool in_place) {\n\n#ifdef USE_NUMPY\n\n PyArrayObject* array = PyArray_GETCONTIGUOUS(original_array);\n\n auto g = MakeGuard([&]() { Py_XDECREF(array); });\n\n\n\n const auto npy_type = PyArray_TYPE(array);\n\n const TypeMeta& dtype = NumpyTypeToCaffe(npy_type);\n\n CAFFE_ENFORCE(\n", "file_path": "caffe2/python/pybind_state.h", "rank": 82, "score": 187228.67190569118 }, { "content": "// Tensor is a \"generic\" object holding a pointer to the underlying TensorImpl object, which\n\n// has an embedded reference count. In this way, Tensor is similar to boost::intrusive_ptr.\n\n//\n\n// For example:\n\n//\n\n// void func(Tensor a) {\n\n// Tensor b = a;\n\n// ...\n\n// }\n\n//\n\n// In this example, when we say Tensor b = a, we are creating a new object that points to the\n\n// same underlying TensorImpl, and bumps its reference count. When b goes out of scope, the\n\n// destructor decrements the reference count by calling release() on the TensorImpl it points to.\n\n// The existing constructors, operator overloads, etc. take care to implement the correct semantics.\n\n//\n\n// Note that Tensor can also be NULL, i.e. it is not associated with any underlying TensorImpl, and\n\n// special care must be taken to handle this.\n\nclass CAFFE2_API Tensor {\n\n public:\n\n Tensor(){};\n\n // This constructor should not be used by end users and is an implementation\n\n // detail invoked by autogenerated code.\n\n explicit Tensor(\n\n c10::intrusive_ptr<TensorImpl, UndefinedTensorImpl> tensor_impl)\n\n : impl_(std::move(tensor_impl)) {\n\n if (impl_.get() == nullptr) {\n\n throw std::runtime_error(\"TensorImpl with nullptr is not supported\");\n\n }\n\n }\n\n Tensor(const Tensor&) = default;\n\n Tensor(Tensor&&) = default;\n\n\n\n\n\n public:\n\n // Creates a new wrapper from TensorImpl. Intentionally a free method because\n\n // it should be used with care. Checks necessary invariants\n\n static Tensor wrap_tensor_impl(\n", "file_path": "aten/src/ATen/templates/TensorBody.h", "rank": 83, "score": 186201.3246486241 }, { "content": " def id(self):\n\n \"\"\"\n\n Return the zero-indexed position of this scalar field in its schema.\n\n Used in order to index into the field_blob list returned by readers or\n\n accepted by writers.\n\n \"\"\"\n", "file_path": "caffe2/python/schema.py", "rank": 84, "score": 186192.88514594035 }, { "content": "def Const(net, value, dtype=None, name=None):\n\n \"\"\"\n\n Create a 'constant' by first creating an external input in the given\n\n net, and then feeding the corresponding blob with its provided value\n\n in the current workspace. The name is automatically generated in order\n\n to avoid clashes with existing blob names.\n\n \"\"\"\n\n assert isinstance(net, core.Net), 'net must be a core.Net instance.'\n\n value = np.array(value, dtype=dtype)\n\n blob = net.AddExternalInput(net.NextName(prefix=name))\n\n workspace.FeedBlob(str(blob), value)\n", "file_path": "caffe2/python/dataset.py", "rank": 85, "score": 186183.99594848306 }, { "content": " def Proto(self):\n", "file_path": "caffe2/python/core.py", "rank": 86, "score": 186176.76255038616 }, { "content": "struct ASTExpr {\n\n std::string name = \"\";\n\n std::vector<ASTExpr*> children;\n\n bool isCallFlag = false;\n\n bool starInputsFlag = false;\n\n\n\n ~ASTExpr() {\n\n for (ASTExpr* e : children)\n\n delete e;\n\n }\n\n bool isCall() const {\n\n return isCallFlag;\n", "file_path": "caffe2/opt/nql/ast.h", "rank": 87, "score": 186176.34068055556 }, { "content": " def Const(self, array, blob_out=None, dtype=None):\n\n if isinstance(array, bool):\n\n return self.ConstantFill(\n\n [],\n\n blob_out or 1,\n\n dtype=DataType.BOOL,\n\n value=array)\n\n\n\n if dtype is None:\n\n array = np.array(array)\n\n else:\n\n array = np.array(array, dtype=dtype)\n\n\n\n def do_set(operator):\n\n return operator(\n\n [],\n\n blob_out or 1,\n\n shape=array.shape,\n\n values=array.flatten().tolist())\n\n\n\n if array.dtype == np.int32:\n\n return do_set(self.GivenTensorIntFill)\n\n elif array.dtype == np.int64:\n\n return do_set(self.GivenTensorInt64Fill)\n\n elif array.dtype == np.str:\n\n return do_set(self.GivenTensorStringFill)\n\n elif array.dtype == np.bool:\n\n return do_set(self.GivenTensorBoolFill)\n\n else:\n", "file_path": "caffe2/python/core.py", "rank": 88, "score": 186176.34068055556 }, { "content": "inline Tensor Tensor::operator[](int64_t index) const {\n\n return select(0, index);\n", "file_path": "aten/src/ATen/TensorOperators.h", "rank": 89, "score": 185346.480160344 }, { "content": "class CAFFE2_API StoreHandlerWrapper : public ::gloo::rendezvous::Store {\n\n public:\n\n explicit StoreHandlerWrapper(StoreHandler& handler) : handler_(handler) {}\n\n\n\n virtual ~StoreHandlerWrapper() {}\n\n\n\n virtual void set(const std::string& key, const std::vector<char>& data)\n\n override;\n\n\n\n virtual std::vector<char> get(const std::string& key) override;\n\n\n\n virtual void wait(const std::vector<std::string>& keys) override {\n\n wait(keys, ::gloo::rendezvous::Store::kDefaultTimeout);\n\n }\n\n\n\n virtual void wait(\n\n const std::vector<std::string>& keys,\n\n const std::chrono::milliseconds& timeout) override;\n\n\n\n protected:\n\n StoreHandler& handler_;\n\n};\n\n\n\n} // namespace gloo\n\n} // namespace caffe2\n", "file_path": "caffe2/contrib/gloo/store_handler.h", "rank": 90, "score": 184003.97252336392 }, { "content": "class GivenTensorByteStringToUInt8FillOp final : public FillerOp<Context> {\n\n public:\n\n USE_OPERATOR_CONTEXT_FUNCTIONS;\n\n explicit GivenTensorByteStringToUInt8FillOp(const OperatorDef& operator_def, Workspace* ws)\n\n : FillerOp<Context>(operator_def, ws) {\n\n const ArgumentHelper helper(operator_def);\n\n if (!helper.HasArgument(\"dtype\")) {\n\n Extract();\n\n } else {\n\n auto dtype = cast::GetCastDataType(helper, \"dtype\");\n\n switch (dtype) {\n\n case TensorProto_DataType_STRING:\n\n Extract();\n\n break;\n\n case TensorProto_DataType_UNDEFINED:\n\n CAFFE_THROW(\"Cannot have undefined 'dtype' argument\");\n\n default:\n\n CAFFE_THROW(\"Unexpected 'dtype' argument value: \", dtype);\n\n }\n\n }\n", "file_path": "caffe2/operators/given_tensor_byte_string_to_uint8_fill_op.h", "rank": 91, "score": 183751.85909805002 }, { "content": "#include \"caffe2/predictor/predictor_utils.h\"\n\n\n\n#include \"caffe2/core/blob.h\"\n\n#include \"caffe2/core/logging.h\"\n\n#include \"caffe2/proto/caffe2_pb.h\"\n\n#include \"caffe2/proto/predictor_consts.pb.h\"\n\n#include \"caffe2/utils/proto_utils.h\"\n\n\n\nnamespace caffe2 {\n\nnamespace predictor_utils {\n\n\n\nCAFFE2_API const NetDef& getNet(\n\n const MetaNetDef& def,\n\n const std::string& name) {\n\n for (const auto& n : def.nets()) {\n\n if (n.key() == name) {\n\n return n.value();\n\n }\n\n }\n\n CAFFE_THROW(\"Net not found: \", name);\n", "file_path": "caffe2/predictor/predictor_utils.cc", "rank": 94, "score": 53.72112835227641 }, { "content": "#include \"caffe2/core/init.h\"\n\n#include \"caffe2/core/operator.h\"\n\n#include \"caffe2/core/tensor.h\"\n\n#include \"caffe2/utils/math.h\"\n\n#include \"caffe2/utils/proto_utils.h\"\n\n\n\n#include \"gtest/gtest.h\"\n\n#include <cmath>\n\n#include <random>\n\n\n\nnamespace caffe2 {\n\n\n\nvoid AddConstInput(const vector<int64_t>& shape,\n\n const float value,\n\n const string& name,\n\n Workspace* ws) {\n\n DeviceOption option;\n\n CPUContext context(option);\n\n Blob* blob = ws->CreateBlob(name);\n\n auto* tensor = BlobGetMutableTensor(blob, CPU);\n", "file_path": "caffe2/operators/conv_transpose_op_mobile_test.cc", "rank": 95, "score": 53.239304541967144 }, { "content": "#include \"caffe2/core/init.h\"\n\n#include \"caffe2/core/operator.h\"\n\n#include \"caffe2/core/tensor.h\"\n\n#include \"caffe2/utils/math.h\"\n\n#include \"caffe2/utils/proto_utils.h\"\n\n#include \"gtest/gtest.h\"\n\n\n\n#include <cmath>\n\n#include <random>\n\n\n\nnamespace caffe2 {\n\n\n\nnamespace {\n\n\n\nvoid AddNoiseInput(const vector<int64_t>& shape, const string& name, Workspace* ws) {\n\n DeviceOption option;\n\n CPUContext context(option);\n\n Blob* blob = ws->CreateBlob(name);\n\n auto* tensor = BlobGetMutableTensor(blob, CPU);\n\n tensor->Resize(shape);\n", "file_path": "caffe2/mobile/contrib/ios/resize_test.cc", "rank": 96, "score": 50.93963486592756 }, { "content": "#include \"caffe2/core/init.h\"\n\n#include \"caffe2/core/operator.h\"\n\n#include \"caffe2/core/tensor.h\"\n\n#include \"caffe2/utils/math.h\"\n\n#include \"caffe2/utils/proto_utils.h\"\n\n#include \"gtest/gtest.h\"\n\n\n\n#include <cmath>\n\n#include <random>\n\n\n\nnamespace caffe2 {\n\n\n\nnamespace {\n\n\n\nvoid AddNoiseInput(const vector<int64_t>& shape, const string& name, Workspace* ws) {\n\n DeviceOption option;\n\n CPUContext context(option);\n\n Blob* blob = ws->CreateBlob(name);\n\n auto* tensor = BlobGetMutableTensor(blob, CPU);\n\n tensor->Resize(shape);\n", "file_path": "caffe2/mobile/contrib/ios/pool_test.cc", "rank": 97, "score": 50.93963486592756 }, { "content": " int chunk_size) {\n\n CAFFE_ENFORCE(typeMeta.Match<Tensor>());\n\n const auto& tensor = *static_cast<const Tensor*>(pointer);\n\n if (chunk_size == kNoChunking) {\n\n chunk_size = tensor.numel() + 1; // to account for empty tensors\n\n } else if (chunk_size == kDefaultChunkSize) {\n\n chunk_size = FLAGS_caffe2_tensor_chunk_size;\n\n }\n\n\n\n auto processChunk = [&](int64_t chunkStart) {\n\n BlobProto blob_proto;\n\n blob_proto.set_name(name);\n\n blob_proto.set_type(kTensorBlobType);\n\n TensorProto& proto = *blob_proto.mutable_tensor();\n\n proto.set_name(name);\n\n this->Serialize(\n\n tensor, name, blob_proto.mutable_tensor(), chunkStart, chunk_size);\n\n acceptor(\n\n c10::str(name, kChunkIdSeparator, chunkStart / chunk_size),\n\n SerializeBlobProtoAsString_EnforceCheck(blob_proto));\n", "file_path": "caffe2/core/blob_serialization.cc", "rank": 98, "score": 50.119853568879435 }, { "content": "#ifndef CAFFE2_CORE_BLOB_SERIALIZATION_H_\n\n#define CAFFE2_CORE_BLOB_SERIALIZATION_H_\n\n\n\n#include <limits>\n\n#include <future>\n\n\n\n#include <google/protobuf/repeated_field.h>\n\n\n\n#include \"caffe2/core/blob.h\"\n\n#include \"caffe2/core/blob_serializer_base.h\"\n\n#include \"caffe2/core/tensor.h\"\n\n#include <c10/util/typeid.h>\n\n#include \"caffe2/core/types.h\"\n\n#include \"caffe2/utils/simple_queue.h\"\n\n\n\nC10_DECLARE_int(caffe2_tensor_chunk_size);\n\nC10_DECLARE_int(caffe2_max_tensor_serializer_threads);\n\nC10_DECLARE_bool(caffe2_serialize_fp16_as_bytes);\n\n\n\nnamespace caffe2 {\n", "file_path": "caffe2/core/blob_serialization.h", "rank": 99, "score": 49.94888560574006 } ]
C++
test/syscalls/linux/close_range.cc
neilalexander/gvisor
14807179c24110d46441efbf30cf375a22d04e57
#include <asm-generic/errno-base.h> #include <unistd.h> #include <vector> #include "gtest/gtest.h" #include "absl/base/macros.h" #include "test/util/file_descriptor.h" #include "test/util/posix_error.h" #include "test/util/temp_path.h" #include "test/util/test_util.h" namespace gvisor { namespace testing { namespace { #ifndef CLOSE_RANGE_UNSHARE #define CLOSE_RANGE_UNSHARE (1U << 1) #endif #ifndef CLOSE_RANGE_CLOEXEC #define CLOSE_RANGE_CLOEXEC (1U << 2) #endif #ifndef SYS_close_range #if defined(__x86_64__) || defined(__aarch64__) #define SYS_close_range 436 #else #error "Unknown architecture" #endif #endif int close_range(unsigned int first, unsigned int last, unsigned int flags) { return syscall(SYS_close_range, first, last, flags); } class CloseRangeTest : public ::testing::Test { public: void CreateFiles(int num_files) { file_names_.reserve(num_files); for (int i = 0; i < num_files; ++i) { file_names_.push_back(NewTempAbsPath()); int fd; ASSERT_THAT(fd = open(file_names_[i].c_str(), O_CREAT, 0644), SyscallSucceeds()); ASSERT_THAT(close(fd), SyscallSucceeds()); } } void OpenFilesRdwr() { fds_.clear(); fds_.reserve(file_names_.size()); for (std::string &file_name : file_names_) { int fd; ASSERT_THAT(fd = open(file_name.c_str(), O_RDWR), SyscallSucceeds()); fds_.push_back(fd); } } private: void TearDown() override { for (std::string &name : file_names_) { unlink(name.c_str()); } } protected: std::vector<std::string> file_names_; std::vector<unsigned int> fds_; }; TEST_F(CloseRangeTest, ContiguousRange) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } } TEST_F(CloseRangeTest, RangeWithHoles) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close(fds_[2]), SyscallSucceeds()); EXPECT_THAT(close(fds_[7]), SyscallSucceeds()); EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } } TEST_F(CloseRangeTest, RangeInMiddleOfOpenFiles) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } size_t slice_start = 4; size_t slice_end = 7; EXPECT_THAT(close_range(fds_[slice_start], fds_[slice_end], flags), SyscallSucceeds()); for (int fd : std::vector(fds_.begin() + slice_start, fds_.begin() + slice_end + 1)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } for (int fd : std::vector(fds_.begin(), fds_.begin() + slice_start)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } for (int fd : std::vector(fds_.begin() + slice_end + 1, fds_.end())) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } } TEST_F(CloseRangeTest, SingleFile) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 1; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); auto ret = ReadAllFd(fds_[0]); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); EXPECT_THAT(close_range(fds_[0], fds_[0], flags), SyscallSucceeds()); ret = ReadAllFd(fds_[0]); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } TEST_F(CloseRangeTest, CallCloseRangeTwice) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); } TEST_F(CloseRangeTest, CloexecFlagTest) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_CLOEXEC; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } } TEST_F(CloseRangeTest, UnshareFlagTest) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } } TEST_F(CloseRangeTest, UnshareFlagAndCloseRangeAtStart) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } size_t range_split = 5; EXPECT_THAT(close_range(fds_[0], fds_[range_split - 1], flags), SyscallSucceeds()); for (int fd : std::vector(fds_.begin(), fds_.begin() + range_split)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } for (int fd : std::vector(fds_.begin() + range_split, fds_.end())) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } } TEST_F(CloseRangeTest, UnshareFlagAndCloseRangeAtEnd) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } size_t range_split = 5; EXPECT_THAT( close_range(fds_[range_split], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : std::vector(fds_.begin(), fds_.begin() + range_split)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } for (int fd : std::vector(fds_.begin() + range_split, fds_.end())) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } } TEST_F(CloseRangeTest, CloexecAndUnshareFlagTest) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_CLOEXEC | CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } } TEST_F(CloseRangeTest, RangeFirstGreaterThanLast) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); EXPECT_THAT(close_range(fds_[num_files_in_range - 1], fds_[0], flags), SyscallFailsWithErrno(EINVAL)); } TEST_F(CloseRangeTest, InvalidFlags) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; CreateFiles(num_files_in_range); OpenFilesRdwr(); unsigned int flags = CLOSE_RANGE_CLOEXEC | CLOSE_RANGE_UNSHARE | 0xF; EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallFailsWithErrno(EINVAL)); flags = 0xF0; EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallFailsWithErrno(EINVAL)); flags = CLOSE_RANGE_CLOEXEC | 0xF00; EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallFailsWithErrno(EINVAL)); } } } }
#include <asm-generic/errno-base.h> #include <unistd.h> #include <vector> #include "gtest/gtest.h" #include "absl/base/macros.h" #include "test/util/file_descriptor.h" #include "test/util/posix_error.h" #include "test/util/temp_path.h" #include "test/util/test_util.h" namespace gvisor { namespace testing { namespace { #ifndef CLOSE_RANGE_UNSHARE #define CLOSE_RANGE_UNSHARE (1U << 1) #endif #ifndef CLOSE_RANGE_CLOEXEC #define CLOSE_RANGE_CLOEXEC (1U << 2) #endif #ifndef SYS_close_range #if defined(__x86_64__) || defined(__aarch64__) #define SYS_close_range 436 #else #error "Unknown architecture" #endif #endif int close_range(unsigned int first, unsigned int last, unsigned int flags) { return syscall(SYS_close_range, first, last, flags); } class CloseRangeTest : public ::testing::Test { public: void CreateFiles(int num_files) { file_names_.reserve(num_files); for (int i = 0; i < num_files; ++i) { file_names_.push_back(NewTempAbsPath()); int fd; ASSERT_THAT(fd = open(file_names_[i].c_str(), O_CREAT, 0644), SyscallSucceeds()); ASSERT_THAT(close(fd), SyscallSucceeds()); } } void OpenFilesRdwr() { fds_.clear(); fds_.reserve(file_names_.size()); for (std::string &file_name : file_names_) { int fd; ASSERT_THAT(fd = open(file_name.c_str(), O_RDWR), SyscallSucceeds()); fds_.push_back(fd); } } private: void TearDown() override { for (std::string &name : file_names_) { unlink(name.c_str()); } } protected: std::vector<std::string> file_names_; std::vector<unsigned int> fds_; }; TEST_F(CloseRangeTest, ContiguousRange) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } } TEST_F(CloseRangeTest, RangeWithHoles) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close(fds_[2]), SyscallSucceeds()); EXPECT_THAT(close(fds_[7]), SyscallSucceeds()); EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } } TEST_F(CloseRangeTest, RangeInMiddleOfOpenFiles) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } size_t slice_start = 4; size_t slice_end = 7; EXPECT_THAT(close_range(fds_[slice_start], fds_[slice_end], flags), SyscallSucceeds()); for (int fd : std::vector(fds_.begin() + slice_start, fds_.begin() + slice_end + 1)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } for (int fd : std::vector(fds_.begin(), fds_.begin() + slice_start)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } for (int fd : std::vector(fds_.begin() + slice_end + 1, fds_.end())) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } } TEST_F(CloseRangeTest, SingleFile) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 1; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); auto ret = ReadAllFd(fds_[0]); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); EXPECT_THAT(close_range(fds_[0], fds_[0], flags), SyscallSucceeds()); ret = ReadAllFd(fds_[0]); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } TEST_F(CloseRangeTest, CallCloseRangeTwice) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); } TEST_F(CloseRangeTest, CloexecFlagTest) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_CLOEXEC; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } } TEST_F(CloseRangeTest, UnshareFlagTest) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } } TEST_F(CloseRangeTest, UnshareFlagAndCloseRangeAtStart) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } size_t range_split = 5; EXPECT_THAT(close_range(fds_[0], fds_[range_split - 1], flags), SyscallSucceeds()); for (int fd : std::vector(fds_.begin(), fds_.begin() + range_split)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } for (int fd : std::vector(fds_.begin() + range_split, fds_.end())) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } } TEST_F(CloseRangeTest, UnshareFlagAndCloseRangeAtEnd) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } size_t range_split = 5; EXPECT_THAT( close_range(fds_[range_split], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : std::vector(fds_.begin(), fds_.begin() + range_split)) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } for (int fd : std::vector(fds_.begin() + range_split, fds_.end())) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, PosixErrorIs(EBADF)); } }
TEST_F(CloseRangeTest, RangeFirstGreaterThanLast) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = 0; CreateFiles(num_files_in_range); OpenFilesRdwr(); EXPECT_THAT(close_range(fds_[num_files_in_range - 1], fds_[0], flags), SyscallFailsWithErrno(EINVAL)); } TEST_F(CloseRangeTest, InvalidFlags) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; CreateFiles(num_files_in_range); OpenFilesRdwr(); unsigned int flags = CLOSE_RANGE_CLOEXEC | CLOSE_RANGE_UNSHARE | 0xF; EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallFailsWithErrno(EINVAL)); flags = 0xF0; EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallFailsWithErrno(EINVAL)); flags = CLOSE_RANGE_CLOEXEC | 0xF00; EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallFailsWithErrno(EINVAL)); } } } }
TEST_F(CloseRangeTest, CloexecAndUnshareFlagTest) { SKIP_IF(!IsRunningOnGvisor() && close_range(1, 0, 0) < 0 && errno == ENOSYS); int num_files_in_range = 10; unsigned int flags = CLOSE_RANGE_CLOEXEC | CLOSE_RANGE_UNSHARE; CreateFiles(num_files_in_range); OpenFilesRdwr(); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } EXPECT_THAT(close_range(fds_[0], fds_[num_files_in_range - 1], flags), SyscallSucceeds()); for (int fd : fds_) { auto ret = ReadAllFd(fd); EXPECT_THAT(ret, IsPosixErrorOkMatcher()); } }
function_block-full_function
[ { "content": "class SpecificErrnoMatcher : public ::testing::MatcherInterface<int> {\n\n public:\n\n explicit SpecificErrnoMatcher(int const expected) : expected_(expected) {}\n\n\n\n bool MatchAndExplain(\n\n int const actual_errno,\n\n ::testing::MatchResultListener* const listener) const override {\n\n return actual_errno == expected_;\n\n }\n\n\n\n void DescribeTo(::std::ostream* const os) const override {\n\n *os << PosixError(expected_);\n\n }\n\n\n\n void DescribeNegationTo(::std::ostream* const os) const override {\n\n *os << \"not \" << PosixError(expected_);\n\n }\n\n\n\n private:\n\n int const expected_;\n", "file_path": "test/util/test_util.h", "rank": 0, "score": 414891.8182090702 }, { "content": "class FuseFdTest : public FuseTest {\n\n public:\n\n // Sets the FUSE server to respond to a FUSE_OPEN with corresponding flags and\n\n // fh. Then does a real file system open on the absolute path to get an fd.\n\n PosixErrorOr<FileDescriptor> OpenPath(const std::string &path,\n\n uint32_t flags = O_RDONLY,\n\n uint64_t fh = 1);\n\n\n\n // Returns a cleanup object that closes the fd when it is destroyed. After\n\n // the close is done, tells the FUSE server to skip this FUSE_RELEASE.\n\n Cleanup CloseFD(FileDescriptor &fd);\n\n};\n\n\n\n} // namespace testing\n\n} // namespace gvisor\n\n\n\n#endif // GVISOR_TEST_FUSE_FUSE_FD_UTIL_H_\n", "file_path": "test/fuse/linux/fuse_fd_util.h", "rank": 1, "score": 356171.090263707 }, { "content": "class TimerfdTest : public ::testing::TestWithParam<int> {};\n\n\n\nTEST_P(TimerfdTest, IsInitiallyStopped) {\n\n auto const tfd = ASSERT_NO_ERRNO_AND_VALUE(TimerfdCreate(GetParam(), 0));\n\n struct itimerspec its = {};\n\n ASSERT_THAT(timerfd_gettime(tfd.get(), &its), SyscallSucceeds());\n\n EXPECT_EQ(0, its.it_value.tv_sec);\n\n EXPECT_EQ(0, its.it_value.tv_nsec);\n\n}\n\n\n\nTEST_P(TimerfdTest, SingleShot) {\n\n constexpr absl::Duration kDelay = absl::Seconds(1);\n\n\n\n auto const tfd = ASSERT_NO_ERRNO_AND_VALUE(TimerfdCreate(GetParam(), 0));\n\n struct itimerspec its = {};\n\n its.it_value = absl::ToTimespec(kDelay);\n\n ASSERT_THAT(timerfd_settime(tfd.get(), /* flags = */ 0, &its, nullptr),\n\n SyscallSucceeds());\n\n\n\n // The timer should fire exactly once since the interval is zero.\n", "file_path": "test/syscalls/linux/timerfd.cc", "rank": 2, "score": 350831.458788641 }, { "content": "class SignalfdTest : public ::testing::TestWithParam<int> {};\n\n\n\nTEST_P(SignalfdTest, Basic) {\n\n int signo = GetParam();\n\n // Create the signalfd.\n\n sigset_t mask;\n\n sigemptyset(&mask);\n\n sigaddset(&mask, signo);\n\n FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(NewSignalFD(&mask, 0));\n\n\n\n // Deliver the blocked signal.\n\n const auto scoped_sigmask =\n\n ASSERT_NO_ERRNO_AND_VALUE(ScopedSignalMask(SIG_BLOCK, signo));\n\n ASSERT_THAT(tgkill(getpid(), gettid(), signo), SyscallSucceeds());\n\n\n\n // We should now read the signal.\n\n struct signalfd_siginfo rbuf;\n\n ASSERT_THAT(read(fd.get(), &rbuf, sizeof(rbuf)),\n\n SyscallSucceedsWithValue(sizeof(rbuf)));\n\n EXPECT_EQ(rbuf.ssi_signo, signo);\n", "file_path": "test/syscalls/linux/signalfd.cc", "rank": 3, "score": 350831.458788641 }, { "content": "// Fixture for tests parameterized by protocol.\n\nclass RawSocketTest : public ::testing::TestWithParam<std::tuple<int, int>> {\n\n protected:\n\n // Creates a socket to be used in tests.\n\n void SetUp() override;\n\n\n\n // Closes the socket created by SetUp().\n\n void TearDown() override;\n\n\n\n // Sends buf via s_.\n\n void SendBuf(const char* buf, int buf_len);\n\n\n\n // Reads from s_ into recv_buf.\n\n void ReceiveBuf(char* recv_buf, size_t recv_buf_len);\n\n\n\n void ReceiveBufFrom(int sock, char* recv_buf, size_t recv_buf_len);\n\n\n\n int Protocol() { return std::get<0>(GetParam()); }\n\n\n\n int Family() { return std::get<1>(GetParam()); }\n\n\n", "file_path": "test/syscalls/linux/raw_socket.cc", "rank": 4, "score": 346843.64970160025 }, { "content": "class StatfsTest : public FuseFdTest {\n\n public:\n\n void SetUp() override { FuseFdTest::SetUp(); }\n\n\n\n protected:\n\n const mode_t dir_mode_ = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO;\n\n bool StatsfsAreEqual(struct statfs expected, struct statfs actual) {\n\n return memcmp(&expected, &actual, sizeof(struct statfs)) == 0;\n\n }\n\n\n\n const mode_t expected_mode = S_IFREG | S_IRUSR | S_IWUSR;\n\n const uint64_t fh = 23;\n\n};\n\n\n\nTEST_F(StatfsTest, StatfsNormal) {\n\n SetServerInodeLookup(mount_point_.path(), dir_mode_);\n\n\n\n struct fuse_out_header out_header = {\n\n .len = sizeof(struct fuse_out_header) + sizeof(struct fuse_statfs_out),\n\n };\n", "file_path": "test/fuse/linux/statfs_test.cc", "rank": 5, "score": 344673.169356704 }, { "content": "class StatTest : public FuseFdTest {\n\n public:\n\n void SetUp() override {\n\n FuseFdTest::SetUp();\n\n test_file_path_ = JoinPath(mount_point_.path(), test_file_);\n\n }\n\n\n\n protected:\n\n bool StatsAreEqual(struct stat expected, struct stat actual) {\n\n // Device number will be dynamically allocated by kernel, we cannot know in\n\n // advance.\n\n actual.st_dev = expected.st_dev;\n\n return memcmp(&expected, &actual, sizeof(struct stat)) == 0;\n\n }\n\n\n\n const std::string test_file_ = \"testfile\";\n\n const mode_t expected_mode = S_IFREG | S_IRUSR | S_IWUSR;\n\n const uint64_t fh = 23;\n\n\n\n std::string test_file_path_;\n", "file_path": "test/fuse/linux/stat_test.cc", "rank": 6, "score": 344673.169356704 }, { "content": "// Fixture for tests parameterized by the address family to use (AF_INET and\n\n// AF_INET6) when creating sockets.\n\nclass TcpSocketTest : public ::testing::TestWithParam<int> {\n\n protected:\n\n // Creates three sockets that will be used by test cases -- a listener, one\n\n // that connects, and the accepted one.\n\n void SetUp() override;\n\n\n\n // Closes the sockets created by SetUp().\n\n void TearDown() override;\n\n\n\n // Listening socket.\n\n int listener_ = -1;\n\n\n\n // Socket connected via connect().\n\n int first_fd = -1;\n\n\n\n // Socket connected via accept().\n\n int second_fd = -1;\n\n\n\n // Initial size of the send buffer.\n\n int sendbuf_size_ = -1;\n", "file_path": "test/syscalls/linux/tcp_socket.cc", "rank": 7, "score": 344648.3752289769 }, { "content": "// Fixture for tests parameterized by the address family to use (AF_INET and\n\n// AF_INET6) when creating sockets.\n\nclass UdpSocketTest : public ::testing::TestWithParam<int> {\n\n protected:\n\n // Creates two sockets that will be used by test cases.\n\n void SetUp() override;\n\n\n\n // Binds the socket bind_ to the loopback and updates bind_addr_.\n\n PosixError BindLoopback();\n\n\n\n // Binds the socket bind_ to Any and updates bind_addr_.\n\n PosixError BindAny();\n\n\n\n // Binds given socket to address addr and updates.\n\n PosixError BindSocket(int socket, struct sockaddr* addr);\n\n\n\n // Return initialized Any address to port 0.\n\n struct sockaddr_storage InetAnyAddr();\n\n\n\n // Return initialized Loopback address to port 0.\n\n struct sockaddr_storage InetLoopbackAddr();\n\n\n", "file_path": "test/syscalls/linux/udp_socket.cc", "rank": 8, "score": 344648.3752289769 }, { "content": "class PacketSocketTest : public ::testing::TestWithParam<int> {\n\n protected:\n\n void SetUp() override {\n\n if (!ASSERT_NO_ERRNO_AND_VALUE(HavePacketSocketCapability())) {\n\n ASSERT_THAT(socket(AF_PACKET, GetParam(), 0),\n\n SyscallFailsWithErrno(EPERM));\n\n GTEST_SKIP() << \"Missing packet socket capability\";\n\n }\n\n\n\n socket_ = ASSERT_NO_ERRNO_AND_VALUE(Socket(AF_PACKET, GetParam(), 0));\n\n }\n\n\n\n FileDescriptor socket_;\n\n};\n\n\n\nTEST_P(PacketSocketTest, GetSockName) {\n\n {\n\n // First check the local address of an unbound packet socket.\n\n sockaddr_ll addr;\n\n socklen_t addrlen = sizeof(addr);\n", "file_path": "test/syscalls/linux/packet_socket.cc", "rank": 9, "score": 344642.70680812816 }, { "content": "class SendFileTest : public ::testing::TestWithParam<int> {\n\n protected:\n\n PosixErrorOr<std::unique_ptr<SocketPair>> Sockets(int type) {\n\n // Bind a server socket.\n\n int family = GetParam();\n\n switch (family) {\n\n case AF_INET: {\n\n if (type == SOCK_STREAM) {\n\n return SocketPairKind{\n\n \"TCP\", AF_INET, type, 0,\n\n TCPAcceptBindSocketPairCreator(AF_INET, type, 0, false)}\n\n .Create();\n\n } else {\n\n return SocketPairKind{\n\n \"UDP\", AF_INET, type, 0,\n\n UDPBidirectionalBindSocketPairCreator(AF_INET, type, 0, false)}\n\n .Create();\n\n }\n\n }\n\n case AF_UNIX: {\n", "file_path": "test/syscalls/linux/sendfile_socket.cc", "rank": 10, "score": 344642.70680812816 }, { "content": "// Tests for \"raw\" (SOCK_RAW) packet(7) sockets.\n\nclass RawPacketTest : public ::testing::TestWithParam<int> {\n\n protected:\n\n // Creates a socket to be used in tests.\n\n void SetUp() override;\n\n\n\n // Closes the socket created by SetUp().\n\n void TearDown() override;\n\n\n\n // Gets the device index of the loopback device.\n\n int GetLoopbackIndex();\n\n\n\n // The socket used for both reading and writing.\n\n int s_;\n\n};\n\n\n\nvoid RawPacketTest::SetUp() {\n\n if (!ASSERT_NO_ERRNO_AND_VALUE(HavePacketSocketCapability())) {\n\n ASSERT_THAT(socket(AF_PACKET, SOCK_RAW, htons(GetParam())),\n\n SyscallFailsWithErrno(EPERM));\n\n GTEST_SKIP();\n", "file_path": "test/syscalls/linux/packet_socket_raw.cc", "rank": 11, "score": 341665.08225678065 }, { "content": "// Tests for \"cooked\" (SOCK_DGRAM) packet(7) sockets.\n\nclass CookedPacketTest : public ::testing::TestWithParam<int> {\n\n protected:\n\n // Creates a socket to be used in tests.\n\n void SetUp() override;\n\n\n\n // Closes the socket created by SetUp().\n\n void TearDown() override;\n\n\n\n // Gets the device index of the loopback device.\n\n int GetLoopbackIndex();\n\n\n\n // The socket used for both reading and writing.\n\n int socket_;\n\n};\n\n\n\nvoid CookedPacketTest::SetUp() {\n\n if (!ASSERT_NO_ERRNO_AND_VALUE(HavePacketSocketCapability())) {\n\n ASSERT_THAT(socket(AF_PACKET, SOCK_DGRAM, htons(GetParam())),\n\n SyscallFailsWithErrno(EPERM));\n\n GTEST_SKIP();\n", "file_path": "test/syscalls/linux/packet_socket_dgram.cc", "rank": 12, "score": 341665.08225678065 }, { "content": "class SetStatTest : public FuseFdTest {\n\n public:\n\n void SetUp() override {\n\n FuseFdTest::SetUp();\n\n test_dir_path_ = JoinPath(mount_point_.path(), test_dir_);\n\n test_file_path_ = JoinPath(mount_point_.path(), test_file_);\n\n }\n\n\n\n protected:\n\n const uint64_t fh = 23;\n\n const std::string test_dir_ = \"testdir\";\n\n const std::string test_file_ = \"testfile\";\n\n const mode_t test_dir_mode_ = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;\n\n const mode_t test_file_mode_ = S_IFREG | S_IRUSR | S_IWUSR | S_IXUSR;\n\n\n\n std::string test_dir_path_;\n\n std::string test_file_path_;\n\n};\n\n\n\nTEST_F(SetStatTest, ChmodDir) {\n", "file_path": "test/fuse/linux/setstat_test.cc", "rank": 13, "score": 341542.83087436965 }, { "content": "class AIOVectorizedParamTest : public AIOTest,\n\n public ::testing::WithParamInterface<int> {};\n\n\n\nTEST_P(AIOVectorizedParamTest, BadIOVecs) {\n\n // Setup a context that is 128 entries deep.\n\n ASSERT_THAT(SetupContext(128), SyscallSucceeds());\n\n\n\n struct iocb cb = CreateCallback();\n\n struct iocb* cbs[1] = {&cb};\n\n\n\n // Modify the callback to use the operation from the param.\n\n cb.aio_lio_opcode = GetParam();\n\n\n\n // Create an iovec with address in kernel range, and pass that as the buffer.\n\n iovec iov = {};\n\n iov.iov_base = reinterpret_cast<void*>(0xFFFFFFFF00000000);\n\n iov.iov_len = 1;\n\n cb.aio_buf = reinterpret_cast<uint64_t>(&iov);\n\n // aio_nbytes is the number of iovecs.\n\n cb.aio_nbytes = 1;\n", "file_path": "test/syscalls/linux/aio.cc", "rank": 14, "score": 341163.35868469154 }, { "content": "\t\tname string\n", "file_path": "pkg/fd/fd_test.go", "rank": 15, "score": 333116.87634588557 }, { "content": "class MonoPosixErrorIsMatcherImpl : public ::testing::MatcherInterface<T> {\n\n public:\n\n explicit MonoPosixErrorIsMatcherImpl(\n\n PosixErrorIsMatcherCommonImpl common_impl)\n\n : common_impl_(std::move(common_impl)) {}\n\n\n\n void DescribeTo(std::ostream* os) const override {\n\n common_impl_.DescribeTo(os);\n\n }\n\n\n\n void DescribeNegationTo(std::ostream* os) const override {\n\n common_impl_.DescribeNegationTo(os);\n\n }\n\n\n\n bool MatchAndExplain(\n\n T actual_value,\n\n ::testing::MatchResultListener* result_listener) const override {\n\n return common_impl_.MatchAndExplain(actual_value, result_listener);\n\n }\n\n\n\n private:\n\n PosixErrorIsMatcherCommonImpl common_impl_;\n\n};\n\n\n\ninline ::testing::Matcher<int> ToErrorCodeMatcher(\n\n const ::testing::Matcher<int>& m) {\n\n return m;\n\n}\n\n\n", "file_path": "test/util/posix_error.h", "rank": 16, "score": 330421.51577483263 }, { "content": "class MonoPosixErrorIsOkMatcherImpl : public ::testing::MatcherInterface<T> {\n\n public:\n\n void DescribeTo(std::ostream* os) const override { *os << \"is OK\"; }\n\n void DescribeNegationTo(std::ostream* os) const override {\n\n *os << \"is not OK\";\n\n }\n\n bool MatchAndExplain(T actual_value,\n\n ::testing::MatchResultListener*) const override {\n\n return actual_value.ok();\n\n }\n\n};\n\n\n", "file_path": "test/util/posix_error.h", "rank": 17, "score": 327410.6704999675 }, { "content": "// A FDSocketPair is a SocketPair that consists of only a pair of file\n\n// descriptors.\n\nclass FDSocketPair : public SocketPair {\n\n public:\n\n FDSocketPair(int first_fd, int second_fd)\n\n : first_(first_fd), second_(second_fd) {}\n\n FDSocketPair(std::unique_ptr<FileDescriptor> first_fd,\n\n std::unique_ptr<FileDescriptor> second_fd)\n\n : first_(first_fd->release()), second_(second_fd->release()) {}\n\n\n\n int first_fd() const override { return first_.get(); }\n\n int second_fd() const override { return second_.get(); }\n\n int release_first_fd() override { return first_.release(); }\n\n int release_second_fd() override { return second_.release(); }\n\n const struct sockaddr* first_addr() const override { return nullptr; }\n\n const struct sockaddr* second_addr() const override { return nullptr; }\n\n size_t first_addr_size() const override { return 0; }\n\n size_t second_addr_size() const override { return 0; }\n\n size_t first_addr_len() const override { return 0; }\n\n size_t second_addr_len() const override { return 0; }\n\n\n\n private:\n\n FileDescriptor first_;\n\n FileDescriptor second_;\n\n};\n\n\n\n// CalculateUnixSockAddrLen calculates the length returned by recvfrom(2) and\n\n// recvmsg(2) for Unix sockets.\n\nsize_t CalculateUnixSockAddrLen(const char* sun_path);\n\n\n", "file_path": "test/util/socket_util.h", "rank": 18, "score": 327333.58693074016 }, { "content": "\tname string\n", "file_path": "test/packetimpact/tests/udp_icmp_error_propagation_test.go", "rank": 19, "score": 326066.60846174986 }, { "content": "func TestCheckpointReturnsFirstCheckerError(t *testing.T) {\n\n\terrFirstChecker := errors.New(\"first Checker error\")\n\n\terrSecondChecker := errors.New(\"second Checker error\")\n\n\n\n\tvar s State\n\n\tcheckersCalled := [2]bool{}\n\n\ts.AppendChecker(&testChecker{onClone: func(ctx context.Context, mask CloneFieldSet, info CloneInfo) error {\n\n\t\tcheckersCalled[0] = true\n\n\t\treturn errFirstChecker\n\n\t}}, &CheckerReq{\n\n\t\tPoints: []Point{PointClone},\n\n\t})\n\n\ts.AppendChecker(&testChecker{onClone: func(ctx context.Context, mask CloneFieldSet, info CloneInfo) error {\n\n\t\tcheckersCalled[1] = true\n\n\t\treturn errSecondChecker\n\n\t}}, &CheckerReq{\n\n\t\tPoints: []Point{PointClone},\n\n\t})\n\n\n\n\tif !s.Enabled(PointClone) {\n\n\t\tt.Errorf(\"Enabled(PointClone): got false, wanted true\")\n\n\t}\n\n\tif err := s.Clone(context.Background(), CloneFieldSet{}, &CloneInfo{}); err != errFirstChecker {\n\n\t\tt.Errorf(\"Clone(): got %v, wanted %v\", err, errFirstChecker)\n\n\t}\n\n\tif !checkersCalled[0] {\n\n\t\tt.Errorf(\"Clone() did not call first Checker\")\n\n\t}\n\n\tif checkersCalled[1] {\n\n\t\tt.Errorf(\"Clone() called second Checker\")\n\n\t}\n", "file_path": "pkg/sentry/seccheck/seccheck_test.go", "rank": 20, "score": 325764.52242686367 }, { "content": "// Fixture for futex tests parameterized by whether to use private or shared\n\n// futexes.\n\nclass PrivateAndSharedFutexTest : public ::testing::TestWithParam<bool> {\n\n protected:\n\n bool IsPrivate() const { return GetParam(); }\n\n int PrivateFlag() const { return IsPrivate() ? FUTEX_PRIVATE_FLAG : 0; }\n\n};\n\n\n\n// FUTEX_WAIT with 0 timeout does not block.\n\nTEST_P(PrivateAndSharedFutexTest, Wait_ZeroTimeout) {\n\n struct timespec timeout = {};\n\n\n\n // Don't use the futex_wait helper because it adjusts timeout.\n\n int a = 1;\n\n EXPECT_THAT(syscall(SYS_futex, &a, FUTEX_WAIT | PrivateFlag(), a, &timeout),\n\n SyscallFailsWithErrno(ETIMEDOUT));\n\n}\n\n\n\nTEST_P(PrivateAndSharedFutexTest, Wait_Timeout) {\n\n std::atomic<int> a = ATOMIC_VAR_INIT(1);\n\n\n\n MonotonicTimer timer;\n", "file_path": "test/syscalls/linux/futex.cc", "rank": 21, "score": 325557.4693722246 }, { "content": "// A AddrFDSocketPair is a SocketPair that consists of a pair of file\n\n// descriptors in addition to a pair of socket addresses.\n\nclass AddrFDSocketPair : public SocketPair {\n\n public:\n\n AddrFDSocketPair(int first_fd, int second_fd,\n\n const struct sockaddr_un& first_address,\n\n const struct sockaddr_un& second_address)\n\n : first_(first_fd),\n\n second_(second_fd),\n\n first_addr_(to_storage(first_address)),\n\n second_addr_(to_storage(second_address)),\n\n first_len_(CalculateUnixSockAddrLen(first_address.sun_path)),\n\n second_len_(CalculateUnixSockAddrLen(second_address.sun_path)),\n\n first_size_(sizeof(first_address)),\n\n second_size_(sizeof(second_address)) {}\n\n\n\n AddrFDSocketPair(int first_fd, int second_fd,\n\n const struct sockaddr_in& first_address,\n\n const struct sockaddr_in& second_address)\n\n : first_(first_fd),\n\n second_(second_fd),\n\n first_addr_(to_storage(first_address)),\n", "file_path": "test/util/socket_util.h", "rank": 22, "score": 323545.79349378654 }, { "content": "\t\tname string\n", "file_path": "pkg/sentry/kernel/fd_table_test.go", "rank": 24, "score": 311423.81929271604 }, { "content": "class RawSocketICMPTest : public Test {\n\n protected:\n\n // Creates a socket to be used in tests.\n\n void SetUp() override;\n\n\n\n // Closes the socket created by SetUp().\n\n void TearDown() override;\n\n\n\n // Checks that both an ICMP echo request and reply are received. Calls should\n\n // be wrapped in ASSERT_NO_FATAL_FAILURE.\n\n void ExpectICMPSuccess(const struct icmphdr& icmp);\n\n\n\n // Sends icmp via s_.\n\n void SendEmptyICMP(const struct icmphdr& icmp);\n\n\n\n // Sends icmp via s_ to the given address.\n\n void SendEmptyICMPTo(int sock, const struct sockaddr_in& addr,\n\n const struct icmphdr& icmp);\n\n\n\n // Reads from s_ into recv_buf.\n", "file_path": "test/syscalls/linux/raw_socket_icmp.cc", "rank": 25, "score": 296746.43244720425 }, { "content": "// FuseTest base class is useful in FUSE integration test. Inherit this class\n\n// to automatically set up a fake FUSE server and use the member functions\n\n// to manipulate with it. Refer to test/fuse/README.md for detailed explanation.\n\nclass FuseTest : public ::testing::Test {\n\n public:\n\n // nodeid_ is the ID of a fake inode. We starts from 2 since 1 is occupied by\n\n // the mount point.\n\n FuseTest() : nodeid_(2) {}\n\n void SetUp() override;\n\n void TearDown() override;\n\n\n\n // Called by the testing thread to set up a fake response for an expected\n\n // opcode via socket. This can be used multiple times to define a sequence of\n\n // expected FUSE reactions.\n\n void SetServerResponse(uint32_t opcode, std::vector<struct iovec>& iovecs);\n\n\n\n // Called by the testing thread to install a fake path under the mount point.\n\n // e.g. a file under /mnt/dir/file and moint point is /mnt, then it will look\n\n // up \"dir/file\" in this case.\n\n //\n\n // It sets a fixed response to the FUSE_LOOKUP requests issued with this\n\n // path, pretending there is an inode and avoid ENOENT when testing. If mode\n\n // is not given, it creates a regular file with mode 0600.\n", "file_path": "test/fuse/linux/fuse_base.h", "rank": 26, "score": 296109.9830862802 }, { "content": "// TODO(gvisor.dev/issue/2370): This test is currently very rudimentary.\n\nclass WriteTest : public ::testing::Test {\n\n public:\n\n ssize_t WriteBytes(int fd, int bytes) {\n\n std::vector<char> buf(bytes);\n\n std::fill(buf.begin(), buf.end(), 'a');\n\n return WriteFd(fd, buf.data(), buf.size());\n\n }\n\n};\n\n\n\nTEST_F(WriteTest, WriteNoExceedsRLimit) {\n\n // Get the current rlimit and restore after test run.\n\n struct rlimit initial_lim;\n\n ASSERT_THAT(getrlimit(RLIMIT_FSIZE, &initial_lim), SyscallSucceeds());\n\n auto cleanup = Cleanup([&initial_lim] {\n\n EXPECT_THAT(setrlimit(RLIMIT_FSIZE, &initial_lim), SyscallSucceeds());\n\n });\n\n\n\n int fd;\n\n struct rlimit setlim;\n\n const int target_lim = 1024;\n", "file_path": "test/syscalls/linux/write.cc", "rank": 27, "score": 296109.73169365065 }, { "content": "// These tests are for both the sched_getaffinity(2) and sched_setaffinity(2)\n\n// syscalls.\n\nclass AffinityTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n EXPECT_THAT(\n\n // Needs use the raw syscall to get the actual size.\n\n cpuset_size_ = syscall(SYS_sched_getaffinity, /*pid=*/0,\n\n sizeof(cpu_set_t), &mask_),\n\n SyscallSucceeds());\n\n // Lots of tests rely on having more than 1 logical processor available.\n\n EXPECT_GT(CPU_COUNT(&mask_), 1);\n\n }\n\n\n\n static PosixError ClearLowestBit(cpu_set_t* mask, size_t cpus) {\n\n const size_t mask_size = CPU_ALLOC_SIZE(cpus);\n\n for (size_t n = 0; n < cpus; ++n) {\n\n if (CPU_ISSET_S(n, mask_size, mask)) {\n\n CPU_CLR_S(n, mask_size, mask);\n\n return NoError();\n\n }\n\n }\n", "file_path": "test/syscalls/linux/affinity.cc", "rank": 28, "score": 296103.43043283833 }, { "content": "class Pread64Test : public ::testing::Test {\n\n void SetUp() override {\n\n name_ = NewTempAbsPath();\n\n ASSERT_NO_ERRNO_AND_VALUE(Open(name_, O_CREAT, 0644));\n\n }\n\n\n\n void TearDown() override { unlink(name_.c_str()); }\n\n\n\n public:\n\n std::string name_;\n\n};\n\n\n\nTEST(Pread64TestNoTempFile, BadFileDescriptor) {\n\n char buf[1024];\n\n EXPECT_THAT(pread64(-1, buf, 1024, 0), SyscallFailsWithErrno(EBADF));\n\n}\n\n\n\nTEST_F(Pread64Test, ZeroBuffer) {\n\n const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(name_, O_RDWR));\n\n\n", "file_path": "test/syscalls/linux/pread64.cc", "rank": 29, "score": 296096.87319626205 }, { "content": "class AccessTest : public ::testing::Test {\n\n public:\n\n std::string CreateTempFile(int perm) {\n\n const std::string path = NewTempAbsPath();\n\n const int fd = open(path.c_str(), O_CREAT | O_RDONLY, perm);\n\n TEST_PCHECK(fd > 0);\n\n TEST_PCHECK(close(fd) == 0);\n\n return path;\n\n }\n\n\n\n protected:\n\n // SetUp creates various configurations of files.\n\n void SetUp() override {\n\n // Move to the temporary directory. This allows us to reason more easily\n\n // about absolute and relative paths.\n\n ASSERT_THAT(chdir(GetAbsoluteTestTmpdir().c_str()), SyscallSucceeds());\n\n\n\n // Create an empty file, standard permissions.\n\n relfile_ = NewTempRelPath();\n\n int fd;\n", "file_path": "test/syscalls/linux/access.cc", "rank": 30, "score": 296096.87319626205 }, { "content": "class ReadTest : public ::testing::Test {\n\n void SetUp() override {\n\n name_ = NewTempAbsPath();\n\n int fd;\n\n ASSERT_THAT(fd = open(name_.c_str(), O_CREAT, 0644), SyscallSucceeds());\n\n ASSERT_THAT(close(fd), SyscallSucceeds());\n\n }\n\n\n\n void TearDown() override { unlink(name_.c_str()); }\n\n\n\n public:\n\n std::string name_;\n\n};\n\n\n\nTEST_F(ReadTest, ZeroBuffer) {\n\n int fd;\n\n ASSERT_THAT(fd = open(name_.c_str(), O_RDWR), SyscallSucceeds());\n\n\n\n char msg[] = \"hello world\";\n\n EXPECT_THAT(PwriteFd(fd, msg, strlen(msg), 0),\n", "file_path": "test/syscalls/linux/read.cc", "rank": 31, "score": 296096.87319626205 }, { "content": "class MkdirTest : public ::testing::Test {\n\n protected:\n\n // SetUp creates various configurations of files.\n\n void SetUp() override { dirname_ = NewTempAbsPath(); }\n\n\n\n // TearDown unlinks created files.\n\n void TearDown() override {\n\n EXPECT_THAT(rmdir(dirname_.c_str()), SyscallSucceeds());\n\n }\n\n\n\n std::string dirname_;\n\n};\n\n\n\nTEST_F(MkdirTest, CanCreateWritableDir) {\n\n ASSERT_THAT(mkdir(dirname_.c_str(), 0777), SyscallSucceeds());\n\n std::string filename = JoinPath(dirname_, \"anything\");\n\n int fd;\n\n ASSERT_THAT(fd = open(filename.c_str(), O_RDWR | O_CREAT, 0666),\n\n SyscallSucceeds());\n\n EXPECT_THAT(close(fd), SyscallSucceeds());\n", "file_path": "test/syscalls/linux/mkdir.cc", "rank": 32, "score": 296096.87319626205 }, { "content": "class SysretTest : public ::testing::Test {\n\n protected:\n\n struct user_regs_struct regs_;\n\n struct iovec iov;\n\n pid_t child_;\n\n\n\n void SetUp() override {\n\n pid_t pid = fork();\n\n\n\n // Child.\n\n if (pid == 0) {\n\n TEST_PCHECK(ptrace(PTRACE_TRACEME, 0, 0, 0) == 0);\n\n MaybeSave();\n\n TEST_PCHECK(raise(SIGSTOP) == 0);\n\n MaybeSave();\n\n _exit(0);\n\n }\n\n\n\n // Parent.\n\n int status;\n", "file_path": "test/syscalls/linux/sysret.cc", "rank": 33, "score": 296096.87319626205 }, { "content": "class IoctlTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n ASSERT_THAT(fd_ = open(\"/dev/null\", O_RDONLY), SyscallSucceeds());\n\n }\n\n\n\n void TearDown() override {\n\n if (fd_ >= 0) {\n\n ASSERT_THAT(close(fd_), SyscallSucceeds());\n\n fd_ = -1;\n\n }\n\n }\n\n\n\n int fd() const { return fd_; }\n\n\n\n private:\n\n int fd_ = -1;\n\n};\n\n\n\nTEST_F(IoctlTest, BadFileDescriptor) {\n", "file_path": "test/syscalls/linux/ioctl.cc", "rank": 34, "score": 296096.87319626205 }, { "content": "class FileTest : public ::testing::Test {\n\n public:\n\n void SetUp() override {\n\n test_pipe_[0] = -1;\n\n test_pipe_[1] = -1;\n\n\n\n test_file_name_ = NewTempAbsPath();\n\n test_file_fd_ = ASSERT_NO_ERRNO_AND_VALUE(\n\n Open(test_file_name_, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR));\n\n\n\n ASSERT_THAT(pipe(test_pipe_), SyscallSucceeds());\n\n ASSERT_THAT(fcntl(test_pipe_[0], F_SETFL, O_NONBLOCK), SyscallSucceeds());\n\n }\n\n\n\n // CloseFile will allow the test to manually close the file descriptor.\n\n void CloseFile() { test_file_fd_.reset(); }\n\n\n\n // UnlinkFile will allow the test to manually unlink the file.\n\n void UnlinkFile() {\n\n if (!test_file_name_.empty()) {\n", "file_path": "test/syscalls/linux/file_base.h", "rank": 35, "score": 296096.87319626205 }, { "content": "class ForkTest : public ::testing::Test {\n\n protected:\n\n // SetUp creates a populated, open file.\n\n void SetUp() override {\n\n // Make a shared mapping.\n\n shared_ = reinterpret_cast<char*>(mmap(0, kPageSize, PROT_READ | PROT_WRITE,\n\n MAP_SHARED | MAP_ANONYMOUS, -1, 0));\n\n ASSERT_NE(reinterpret_cast<void*>(shared_), MAP_FAILED);\n\n\n\n // Make a private mapping.\n\n private_ =\n\n reinterpret_cast<char*>(mmap(0, kPageSize, PROT_READ | PROT_WRITE,\n\n MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));\n\n ASSERT_NE(reinterpret_cast<void*>(private_), MAP_FAILED);\n\n\n\n // Make a pipe.\n\n ASSERT_THAT(pipe(pipes_), SyscallSucceeds());\n\n }\n\n\n\n // TearDown frees associated resources.\n", "file_path": "test/syscalls/linux/fork.cc", "rank": 36, "score": 296096.87319626205 }, { "content": "class GetdentsTest : public ::testing::Test {\n\n public:\n\n using LinuxDirentType = T;\n\n using DirentBufferType = DirentBuffer<T>;\n\n\n\n protected:\n\n void SetUp() override {\n\n dir_ = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());\n\n fd_ = ASSERT_NO_ERRNO_AND_VALUE(Open(dir_.path(), O_RDONLY | O_DIRECTORY));\n\n }\n\n\n\n // Must be overridden with explicit specialization. See below.\n\n int SyscallNum();\n\n\n\n int Getdents(LinuxDirentType* dirp, unsigned int count) {\n\n return RetryEINTR(syscall)(SyscallNum(), fd_.get(), dirp, count);\n\n }\n\n\n\n // Fill directory with num files, named by number starting at 0.\n\n void FillDirectory(size_t num) {\n", "file_path": "test/syscalls/linux/getdents.cc", "rank": 37, "score": 296096.87319626205 }, { "content": "class TuntapTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n const bool have_net_admin_cap =\n\n ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_ADMIN));\n\n\n\n if (have_net_admin_cap && !IsRunningOnGvisor()) {\n\n // gVisor always creates enabled/up'd interfaces, while Linux does not (as\n\n // observed in b/110961832). Some of the tests require the Linux stack to\n\n // notify the socket of any link-address-resolution failures. Those\n\n // notifications do not seem to show up when the loopback interface in the\n\n // namespace is down.\n\n auto link = ASSERT_NO_ERRNO_AND_VALUE(GetLinkByName(\"lo\"));\n\n ASSERT_NO_ERRNO(LinkChangeFlags(link.index, IFF_UP, IFF_UP));\n\n }\n\n }\n\n};\n\n\n\nTEST_F(TuntapTest, CreateInterfaceNoCap) {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_ADMIN)));\n", "file_path": "test/syscalls/linux/tuntap.cc", "rank": 38, "score": 296096.87319626205 }, { "content": "class PtyTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n master_ = ASSERT_NO_ERRNO_AND_VALUE(Open(\"/dev/ptmx\", O_RDWR | O_NONBLOCK));\n\n replica_ = ASSERT_NO_ERRNO_AND_VALUE(OpenReplica(master_));\n\n }\n\n\n\n void DisableCanonical() {\n\n struct kernel_termios t = {};\n\n EXPECT_THAT(ioctl(replica_.get(), TCGETS, &t), SyscallSucceeds());\n\n t.c_lflag &= ~ICANON;\n\n EXPECT_THAT(ioctl(replica_.get(), TCSETS, &t), SyscallSucceeds());\n\n }\n\n\n\n void EnableCanonical() {\n\n struct kernel_termios t = {};\n\n EXPECT_THAT(ioctl(replica_.get(), TCGETS, &t), SyscallSucceeds());\n\n t.c_lflag |= ICANON;\n\n EXPECT_THAT(ioctl(replica_.get(), TCSETS, &t), SyscallSucceeds());\n\n }\n", "file_path": "test/syscalls/linux/pty.cc", "rank": 39, "score": 296096.87319626205 }, { "content": "class MunmapTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n m_ = mmap(nullptr, kPageSize, PROT_READ | PROT_WRITE,\n\n MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n\n ASSERT_NE(MAP_FAILED, m_);\n\n }\n\n\n\n void* m_ = nullptr;\n\n};\n\n\n\nTEST_F(MunmapTest, HappyCase) {\n\n EXPECT_THAT(munmap(m_, kPageSize), SyscallSucceeds());\n\n}\n\n\n\nTEST_F(MunmapTest, ZeroLength) {\n\n EXPECT_THAT(munmap(m_, 0), SyscallFailsWithErrno(EINVAL));\n\n}\n\n\n\nTEST_F(MunmapTest, LastPageRoundUp) {\n\n // Attempt to unmap up to and including the last page.\n\n EXPECT_THAT(munmap(m_, static_cast<size_t>(-kPageSize + 1)),\n\n SyscallFailsWithErrno(EINVAL));\n\n}\n\n\n\n} // namespace\n\n\n\n} // namespace testing\n\n} // namespace gvisor\n", "file_path": "test/syscalls/linux/munmap.cc", "rank": 40, "score": 296096.87319626205 }, { "content": "// TODO(gvisor.dev/issue/2370): This test is currently very rudimentary.\n\nclass Pwrite64 : public ::testing::Test {\n\n void SetUp() override {\n\n name_ = NewTempAbsPath();\n\n int fd;\n\n ASSERT_THAT(fd = open(name_.c_str(), O_CREAT, 0644), SyscallSucceeds());\n\n EXPECT_THAT(close(fd), SyscallSucceeds());\n\n }\n\n\n\n void TearDown() override { unlink(name_.c_str()); }\n\n\n\n public:\n\n std::string name_;\n\n};\n\n\n\nTEST_F(Pwrite64, AppendOnly) {\n\n int fd;\n\n ASSERT_THAT(fd = open(name_.c_str(), O_APPEND | O_RDWR), SyscallSucceeds());\n\n constexpr int64_t kBufSize = 1024;\n\n std::vector<char> buf(kBufSize);\n\n std::fill(buf.begin(), buf.end(), 'a');\n", "file_path": "test/syscalls/linux/pwrite64.cc", "rank": 41, "score": 295155.397079248 }, { "content": "class RawSocketICMPv6Test : public Test {\n\n public:\n\n void SetUp() override {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveRawIPSocketCapability()));\n\n\n\n fd_ = ASSERT_NO_ERRNO_AND_VALUE(\n\n Socket(AF_INET6, SOCK_RAW | SOCK_NONBLOCK, IPPROTO_ICMPV6));\n\n }\n\n\n\n void TearDown() override {\n\n if (!ASSERT_NO_ERRNO_AND_VALUE(HaveRawIPSocketCapability())) {\n\n return;\n\n }\n\n\n\n EXPECT_THAT(close(fd_.release()), SyscallSucceeds());\n\n }\n\n\n\n protected:\n\n const FileDescriptor& fd() { return fd_; }\n\n\n", "file_path": "test/syscalls/linux/raw_socket_icmp.cc", "rank": 42, "score": 294477.4122483898 }, { "content": "// Base test fixture for poll, select, ppoll, and pselect tests.\n\n//\n\n// This fixture makes use of SIGALRM. The handler is saved in SetUp() and\n\n// restored in TearDown().\n\nclass BasePollTest : public ::testing::Test {\n\n protected:\n\n BasePollTest();\n\n ~BasePollTest() override;\n\n\n\n // Sets a timer that will send a signal to the calling thread after\n\n // `duration`.\n\n void SetTimer(absl::Duration duration);\n\n\n\n // Returns true if the timer has fired.\n\n bool TimerFired() const;\n\n\n\n // Stops the pending timer (if any) and clear the \"fired\" state.\n\n void ClearTimer();\n\n\n\n private:\n\n // Thread that implements the timer. If the timer is stopped, timer_ is null.\n\n //\n\n // We have to use a thread for this purpose because tests using this fixture\n\n // expect to be interrupted by the timer signal, but itimers/alarm(2) send\n", "file_path": "test/syscalls/linux/base_poll_test.h", "rank": 43, "score": 293825.0692421919 }, { "content": "// Fixture for iptables tests.\n\nclass IPTablesTest : public ::testing::Test {\n\n protected:\n\n // Creates a socket to be used in tests.\n\n void SetUp() override;\n\n\n\n // Closes the socket created by SetUp().\n\n void TearDown() override;\n\n\n\n // The socket via which to manipulate iptables.\n\n int s_;\n\n};\n\n\n\nvoid IPTablesTest::SetUp() {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_RAW)));\n\n\n\n ASSERT_THAT(s_ = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), SyscallSucceeds());\n\n}\n\n\n\nvoid IPTablesTest::TearDown() {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_NET_RAW)));\n", "file_path": "test/syscalls/linux/iptables.cc", "rank": 44, "score": 293766.983173165 }, { "content": "class RtSignalTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n action_cleanup_ = ASSERT_NO_ERRNO_AND_VALUE(SetupSignalHandler(SIGUSR1));\n\n mask_cleanup_ =\n\n ASSERT_NO_ERRNO_AND_VALUE(ScopedSignalMask(SIG_UNBLOCK, SIGUSR1));\n\n }\n\n\n\n void TearDown() override { ClearSavedInfo(); }\n\n\n\n private:\n\n Cleanup action_cleanup_;\n\n Cleanup mask_cleanup_;\n\n};\n\n\n\nstatic int rt_sigqueueinfo(pid_t tgid, int sig, siginfo_t* uinfo) {\n\n int ret;\n\n do {\n\n // NOTE(b/25434735): rt_sigqueueinfo(2) could return EAGAIN for RT signals.\n\n ret = syscall(SYS_rt_sigqueueinfo, tgid, sig, uinfo);\n", "file_path": "test/syscalls/linux/rtsignal.cc", "rank": 45, "score": 293759.86811111856 }, { "content": "class JobControlTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n master_ = ASSERT_NO_ERRNO_AND_VALUE(Open(\"/dev/ptmx\", O_RDWR | O_NONBLOCK));\n\n replica_ = ASSERT_NO_ERRNO_AND_VALUE(OpenReplica(master_));\n\n\n\n // Make this a session leader, which also drops the controlling terminal.\n\n // In the gVisor test environment, this test will be run as the session\n\n // leader already (as the sentry init process).\n\n if (!IsRunningOnGvisor()) {\n\n // Ignore failure because setsid(2) fails if the process is already the\n\n // session leader.\n\n setsid();\n\n ioctl(replica_.get(), TIOCNOTTY);\n\n }\n\n }\n\n\n\n PosixError RunInChild(SubprocessCallback childFunc) {\n\n pid_t child = fork();\n\n if (!child) {\n", "file_path": "test/syscalls/linux/pty.cc", "rank": 46, "score": 293759.86811111856 }, { "content": "class SetgidDirTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n original_gid_ = getegid();\n\n\n\n // If we can't find two usable groups, we're in an unsupporting environment.\n\n // Skip the test.\n\n PosixErrorOr<std::pair<gid_t, gid_t>> groups = Groups();\n\n SKIP_IF(!groups.ok());\n\n groups_ = groups.ValueOrDie();\n\n\n\n // Ensure we can actually use both groups.\n\n auto cleanup1 = Setegid(groups_.first);\n\n SKIP_IF(!cleanup1.ok());\n\n auto cleanup2 = Setegid(groups_.second);\n\n SKIP_IF(!cleanup2.ok());\n\n\n\n auto cleanup = Setegid(groups_.first);\n\n temp_dir_ = ASSERT_NO_ERRNO_AND_VALUE(\n\n TempPath::CreateDirWith(GetAbsoluteTestTmpdir(), 0777 /* mode */));\n", "file_path": "test/syscalls/linux/setgid.cc", "rank": 47, "score": 293759.86811111856 }, { "content": "class MmapTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN)));\n\n // Mount a tmpfs file system, to be wrapped by a verity fs.\n\n tmpfs_dir_ = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());\n\n ASSERT_THAT(mount(\"\", tmpfs_dir_.path().c_str(), \"tmpfs\", 0, \"\"),\n\n SyscallSucceeds());\n\n\n\n // Create a new file in the tmpfs mount.\n\n file_ = ASSERT_NO_ERRNO_AND_VALUE(\n\n TempPath::CreateFileWith(tmpfs_dir_.path(), kContents, 0777));\n\n filename_ = Basename(file_.path());\n\n }\n\n\n\n TempPath tmpfs_dir_;\n\n TempPath file_;\n\n std::string filename_;\n\n};\n\n\n", "file_path": "test/syscalls/linux/verity_mmap.cc", "rank": 48, "score": 293759.86811111856 }, { "content": "class FcntlSignalTest : public ::testing::Test {\n\n public:\n\n void SetUp() override {\n\n int pipe_fds[2];\n\n ASSERT_THAT(pipe2(pipe_fds, O_NONBLOCK), SyscallSucceeds());\n\n pipe_read_fd_ = pipe_fds[0];\n\n pipe_write_fd_ = pipe_fds[1];\n\n }\n\n\n\n PosixErrorOr<Cleanup> RegisterSignalHandler(int signum) {\n\n struct sigaction handler;\n\n handler.sa_sigaction = setsig_signal_handler;\n\n setsig_signal_handle = [&](int signum, siginfo_t* siginfo,\n\n void* unused_ucontext) {\n\n SignalDelivery sig;\n\n sig.num = signum;\n\n sig.info = *siginfo;\n\n signals_received_.push_back(sig);\n\n num_signals_received_++;\n\n };\n", "file_path": "test/syscalls/linux/fcntl.cc", "rank": 49, "score": 293759.8681111186 }, { "content": "class MMapTest : public ::testing::Test {\n\n protected:\n\n // Unmap mapping, if one was made.\n\n void TearDown() override {\n\n if (addr_) {\n\n EXPECT_THAT(Unmap(), SyscallSucceeds());\n\n }\n\n }\n\n\n\n // Remembers mapping, so it can be automatically unmapped.\n\n uintptr_t Map(uintptr_t addr, size_t length, int prot, int flags, int fd,\n\n off_t offset) {\n\n void* ret =\n\n mmap(reinterpret_cast<void*>(addr), length, prot, flags, fd, offset);\n\n\n\n if (ret != MAP_FAILED) {\n\n addr_ = ret;\n\n length_ = length;\n\n }\n\n\n", "file_path": "test/syscalls/linux/mmap.cc", "rank": 50, "score": 293759.8681111186 }, { "content": "class FcntlLockTest : public ::testing::Test {\n\n public:\n\n void SetUp() override {\n\n // Let's make a socket pair.\n\n ASSERT_THAT(socketpair(AF_UNIX, SOCK_STREAM, 0, fds_), SyscallSucceeds());\n\n }\n\n\n\n void TearDown() override {\n\n EXPECT_THAT(close(fds_[0]), SyscallSucceeds());\n\n EXPECT_THAT(close(fds_[1]), SyscallSucceeds());\n\n }\n\n\n\n int64_t GetSubprocessFcntlTimeInUsec() {\n\n int64_t ret = 0;\n\n EXPECT_THAT(ReadFd(fds_[0], reinterpret_cast<void*>(&ret), sizeof(ret)),\n\n SyscallSucceedsWithValue(sizeof(ret)));\n\n return ret;\n\n }\n\n\n\n // The first fd will remain with the process creating the subprocess\n\n // and the second will go to the subprocess.\n\n int fds_[2] = {};\n\n};\n\n\n", "file_path": "test/syscalls/linux/fcntl.cc", "rank": 51, "score": 293759.8681111186 }, { "content": "class IoctlTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN)));\n\n // Mount a tmpfs file system, to be wrapped by a verity fs.\n\n tmpfs_dir_ = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());\n\n ASSERT_THAT(mount(\"\", tmpfs_dir_.path().c_str(), \"tmpfs\", 0, \"\"),\n\n SyscallSucceeds());\n\n\n\n // Create a new file in the tmpfs mount.\n\n file_ = ASSERT_NO_ERRNO_AND_VALUE(\n\n TempPath::CreateFileWith(tmpfs_dir_.path(), kContents, 0777));\n\n filename_ = Basename(file_.path());\n\n }\n\n\n\n TempPath tmpfs_dir_;\n\n TempPath file_;\n\n std::string filename_;\n\n};\n\n\n", "file_path": "test/syscalls/linux/verity_ioctl.cc", "rank": 52, "score": 293759.86811111856 }, { "content": "class SymlinkTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN)));\n\n // Mount a tmpfs file system, to be wrapped by a verity fs.\n\n tmpfs_dir_ = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());\n\n ASSERT_THAT(mount(\"\", tmpfs_dir_.path().c_str(), \"tmpfs\", 0, \"\"),\n\n SyscallSucceeds());\n\n\n\n // Create a new file in the tmpfs mount.\n\n file_ = ASSERT_NO_ERRNO_AND_VALUE(\n\n TempPath::CreateFileWith(tmpfs_dir_.path(), kContents, 0777));\n\n filename_ = Basename(file_.path());\n\n\n\n // Create a symlink to the file.\n\n ASSERT_THAT(symlink(file_.path().c_str(),\n\n JoinPath(tmpfs_dir_.path(), kSymlink).c_str()),\n\n SyscallSucceeds());\n\n }\n\n\n", "file_path": "test/syscalls/linux/verity_symlink.cc", "rank": 53, "score": 293759.8681111186 }, { "content": "// The test fixture saves and restores the signal mask and\n\n// sets up handlers for kTestSignal1 and kTestSignal2.\n\nclass SigProcMaskTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n // Save the current signal mask.\n\n EXPECT_THAT(raw_sigprocmask(SIG_SETMASK, nullptr, &mask_),\n\n SyscallSucceeds());\n\n\n\n // Setup signal handlers for kTestSignal1 and kTestSignal2.\n\n struct sigaction sa;\n\n sa.sa_sigaction = SigHandler;\n\n sigfillset(&sa.sa_mask);\n\n sa.sa_flags = SA_SIGINFO;\n\n EXPECT_THAT(sigaction(kTestSignal1, &sa, &sa_test_sig_1_),\n\n SyscallSucceeds());\n\n EXPECT_THAT(sigaction(kTestSignal2, &sa, &sa_test_sig_2_),\n\n SyscallSucceeds());\n\n\n\n // Clear the signal counters.\n\n memset(signal_count, 0, sizeof(signal_count));\n\n }\n", "file_path": "test/syscalls/linux/sigprocmask.cc", "rank": 54, "score": 291486.54858630063 }, { "content": "class ReadvSocketTest : public ::testing::Test {\n\n public:\n\n void SetUp() override {\n\n test_unix_stream_socket_[0] = -1;\n\n test_unix_stream_socket_[1] = -1;\n\n test_unix_dgram_socket_[0] = -1;\n\n test_unix_dgram_socket_[1] = -1;\n\n test_unix_seqpacket_socket_[0] = -1;\n\n test_unix_seqpacket_socket_[1] = -1;\n\n\n\n ASSERT_THAT(socketpair(AF_UNIX, SOCK_STREAM, 0, test_unix_stream_socket_),\n\n SyscallSucceeds());\n\n ASSERT_THAT(fcntl(test_unix_stream_socket_[0], F_SETFL, O_NONBLOCK),\n\n SyscallSucceeds());\n\n ASSERT_THAT(socketpair(AF_UNIX, SOCK_DGRAM, 0, test_unix_dgram_socket_),\n\n SyscallSucceeds());\n\n ASSERT_THAT(fcntl(test_unix_dgram_socket_[0], F_SETFL, O_NONBLOCK),\n\n SyscallSucceeds());\n\n ASSERT_THAT(\n\n socketpair(AF_UNIX, SOCK_SEQPACKET, 0, test_unix_seqpacket_socket_),\n", "file_path": "test/syscalls/linux/readv_socket.cc", "rank": 55, "score": 291478.5325028988 }, { "content": "class GetDentsTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN)));\n\n // Mount a tmpfs file system, to be wrapped by a verity fs.\n\n tmpfs_dir_ = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());\n\n ASSERT_THAT(mount(\"\", tmpfs_dir_.path().c_str(), \"tmpfs\", 0, \"\"),\n\n SyscallSucceeds());\n\n\n\n // Create a new file in the tmpfs mount.\n\n file_ = ASSERT_NO_ERRNO_AND_VALUE(\n\n TempPath::CreateFileWith(tmpfs_dir_.path(), kContents, 0777));\n\n filename_ = Basename(file_.path());\n\n }\n\n\n\n TempPath tmpfs_dir_;\n\n TempPath file_;\n\n std::string filename_;\n\n};\n\n\n", "file_path": "test/syscalls/linux/verity_getdents.cc", "rank": 56, "score": 291478.5325028988 }, { "content": "// Tests for IPPROTO_RAW raw sockets, which implies IP_HDRINCL.\n\nclass RawHDRINCL : public ::testing::Test {\n\n protected:\n\n // Creates a socket to be used in tests.\n\n void SetUp() override;\n\n\n\n // Closes the socket created by SetUp().\n\n void TearDown() override;\n\n\n\n // Returns a valid looback IP header with no payload.\n\n struct iphdr LoopbackHeader();\n\n\n\n // Fills in buf with an IP header, UDP header, and payload. Returns false if\n\n // buf_size isn't large enough to hold everything.\n\n bool FillPacket(char* buf, size_t buf_size, int port, const char* payload,\n\n uint16_t payload_size);\n\n\n\n // The socket used for both reading and writing.\n\n int socket_;\n\n\n\n // The loopback address.\n", "file_path": "test/syscalls/linux/raw_socket_hdrincl.cc", "rank": 57, "score": 287836.9680933769 }, { "content": "// PartialBadBufferTest checks the result of various IO syscalls when passed a\n\n// buffer that does not have the space specified in the syscall (most of it is\n\n// PROT_NONE). Linux is annoyingly inconsistent among different syscalls, so we\n\n// test all of them.\n\nclass PartialBadBufferTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n // Create and open a directory for getdents cases.\n\n directory_ = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());\n\n ASSERT_THAT(\n\n directory_fd_ = open(directory_.path().c_str(), O_RDONLY | O_DIRECTORY),\n\n SyscallSucceeds());\n\n\n\n // Create and open a normal file, placing it in the directory\n\n // so the getdents cases have some dirents.\n\n name_ = JoinPath(directory_.path(), \"a\");\n\n ASSERT_THAT(fd_ = open(name_.c_str(), O_RDWR | O_CREAT, 0644),\n\n SyscallSucceeds());\n\n\n\n // Write some initial data.\n\n size_t size = sizeof(kMessage) - 1;\n\n EXPECT_THAT(WriteFd(fd_, &kMessage, size), SyscallSucceedsWithValue(size));\n\n ASSERT_THAT(lseek(fd_, 0, SEEK_SET), SyscallSucceeds());\n\n\n", "file_path": "test/syscalls/linux/partial_bad_buffer.cc", "rank": 58, "score": 287080.74317771604 }, { "content": "class PrctlKeepCapsSetuidTest : public ::testing::Test {\n\n protected:\n\n void SetUp() override {\n\n // PR_GET_KEEPCAPS will only return 0 or 1 (on success).\n\n ASSERT_THAT(original_keepcaps_ = prctl(PR_GET_KEEPCAPS, 0, 0, 0, 0),\n\n SyscallSucceeds());\n\n ASSERT_TRUE(original_keepcaps_ == 0 || original_keepcaps_ == 1);\n\n }\n\n\n\n void TearDown() override {\n\n // Restore PR_SET_KEEPCAPS.\n\n ASSERT_THAT(prctl(PR_SET_KEEPCAPS, original_keepcaps_, 0, 0, 0),\n\n SyscallSucceeds());\n\n\n\n // Verify that it was restored.\n\n ASSERT_THAT(prctl(PR_GET_KEEPCAPS, 0, 0, 0, 0),\n\n SyscallSucceedsWithValue(original_keepcaps_));\n\n }\n\n\n\n // The original keep caps value exposed so tests can use it if they need.\n", "file_path": "test/syscalls/linux/prctl_setuid.cc", "rank": 59, "score": 287074.47695913014 }, { "content": "func TestNewFromFileError(t *testing.T) {\n\n\tf, err := NewFromFile(nil)\n\n\tif err == nil {\n\n\t\tt.Errorf(\"NewFromFile got %v with nil err want non-nil\", f)\n\n\t\tf.Close()\n\n\t}\n", "file_path": "pkg/fd/fd_test.go", "rank": 60, "score": 285045.63518488425 }, { "content": "func TestSyscallErrnoToErrors(t *testing.T) {\n\n\tfor _, tc := range []struct {\n\n\t\terrno syscall.Errno\n\n\t\terr error\n\n\t}{\n\n\t\t{errno: syscall.EACCES, err: linuxerr.EACCES},\n\n\t\t{errno: syscall.EAGAIN, err: linuxerr.EAGAIN},\n\n\t\t{errno: syscall.EBADF, err: linuxerr.EBADF},\n\n\t\t{errno: syscall.EBUSY, err: linuxerr.EBUSY},\n\n\t\t{errno: syscall.EDOM, err: linuxerr.EDOM},\n\n\t\t{errno: syscall.EEXIST, err: linuxerr.EEXIST},\n\n\t\t{errno: syscall.EFAULT, err: linuxerr.EFAULT},\n\n\t\t{errno: syscall.EFBIG, err: linuxerr.EFBIG},\n\n\t\t{errno: syscall.EINTR, err: linuxerr.EINTR},\n\n\t\t{errno: syscall.EINVAL, err: linuxerr.EINVAL},\n\n\t\t{errno: syscall.EIO, err: linuxerr.EIO},\n\n\t\t{errno: syscall.ENOTDIR, err: linuxerr.ENOTDIR},\n\n\t\t{errno: syscall.ENOTTY, err: linuxerr.ENOTTY},\n\n\t\t{errno: syscall.EPERM, err: linuxerr.EPERM},\n\n\t\t{errno: syscall.EPIPE, err: linuxerr.EPIPE},\n\n\t\t{errno: syscall.ESPIPE, err: linuxerr.ESPIPE},\n\n\t\t{errno: syscall.EWOULDBLOCK, err: linuxerr.EAGAIN},\n\n\t} {\n\n\t\tt.Run(tc.errno.Error(), func(t *testing.T) {\n\n\t\t\te := linuxerr.ErrorFromUnix(unix.Errno(tc.errno))\n\n\t\t\tif e != tc.err {\n\n\t\t\t\tt.Fatalf(\"Mismatch errors: want: %+v %T got: %+v %T\", tc.err, tc.err, e, e)\n\n\t\t\t}\n\n\t\t})\n\n\t}\n", "file_path": "pkg/errors/linuxerr/linuxerr_test.go", "rank": 61, "score": 282193.02512393886 }, { "content": "func TestFileDotFileError(t *testing.T) {\n\n\tf := &FD{ReadWriter{-2}}\n\n\n\n\tif of, err := f.File(); err == nil {\n\n\t\tt.Errorf(\"File %v got nil err want non-nil\", of)\n\n\t\tof.Close()\n\n\t}\n", "file_path": "pkg/fd/fd_test.go", "rank": 62, "score": 282077.11420889024 }, { "content": "class MkdirTest : public FuseTest {\n\n protected:\n\n const std::string test_dir_ = \"test_dir\";\n\n const mode_t perms_ = S_IRWXU | S_IRWXG | S_IRWXO;\n\n};\n\n\n\nTEST_F(MkdirTest, CreateDir) {\n\n const std::string test_dir_path_ =\n\n JoinPath(mount_point_.path().c_str(), test_dir_);\n\n const mode_t new_umask = 0077;\n\n\n\n struct fuse_out_header out_header = {\n\n .len = sizeof(struct fuse_out_header) + sizeof(struct fuse_entry_out),\n\n };\n\n struct fuse_entry_out out_payload = DefaultEntryOut(S_IFDIR | perms_, 5);\n\n auto iov_out = FuseGenerateIovecs(out_header, out_payload);\n\n SetServerResponse(FUSE_MKDIR, iov_out);\n\n TempUmask mask(new_umask);\n\n ASSERT_THAT(mkdir(test_dir_path_.c_str(), 0777), SyscallSucceeds());\n\n\n", "file_path": "test/fuse/linux/mkdir_test.cc", "rank": 63, "score": 279358.74825223273 }, { "content": "class ReleaseTest : public FuseTest {\n\n protected:\n\n const std::string test_file_ = \"test_file\";\n\n};\n\n\n\nTEST_F(ReleaseTest, RegularFile) {\n\n const std::string test_file_path =\n\n JoinPath(mount_point_.path().c_str(), test_file_);\n\n SetServerInodeLookup(test_file_, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO);\n\n\n\n struct fuse_out_header out_header = {\n\n .len = sizeof(struct fuse_out_header) + sizeof(struct fuse_open_out),\n\n };\n\n struct fuse_open_out out_payload = {\n\n .fh = 1,\n\n .open_flags = O_RDWR,\n\n };\n\n auto iov_out = FuseGenerateIovecs(out_header, out_payload);\n\n SetServerResponse(FUSE_OPEN, iov_out);\n\n FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(test_file_path, O_RDWR));\n", "file_path": "test/fuse/linux/release_test.cc", "rank": 64, "score": 279358.74825223273 }, { "content": "class ReadlinkTest : public FuseTest {\n\n protected:\n\n const std::string test_file_ = \"test_file_\";\n\n const mode_t perms_ = S_IRWXU | S_IRWXG | S_IRWXO;\n\n};\n\n\n\nTEST_F(ReadlinkTest, ReadSymLink) {\n\n const std::string symlink_path =\n\n JoinPath(mount_point_.path().c_str(), test_file_);\n\n SetServerInodeLookup(test_file_, S_IFLNK | perms_);\n\n\n\n struct fuse_out_header out_header = {\n\n .len = static_cast<uint32_t>(sizeof(struct fuse_out_header)) +\n\n static_cast<uint32_t>(test_file_.length()) + 1,\n\n };\n\n std::string link = test_file_;\n\n auto iov_out = FuseGenerateIovecs(out_header, link);\n\n SetServerResponse(FUSE_READLINK, iov_out);\n\n const std::string actual_link =\n\n ASSERT_NO_ERRNO_AND_VALUE(ReadLink(symlink_path));\n", "file_path": "test/fuse/linux/readlink_test.cc", "rank": 65, "score": 279358.74825223273 }, { "content": "class WriteTest : public FuseTest {\n\n void SetUp() override {\n\n FuseTest::SetUp();\n\n test_file_path_ = JoinPath(mount_point_.path().c_str(), test_file_);\n\n }\n\n\n\n // TearDown overrides the parent's function\n\n // to skip checking the unconsumed release request at the end.\n\n void TearDown() override { UnmountFuse(); }\n\n\n\n protected:\n\n const std::string test_file_ = \"test_file\";\n\n const mode_t test_file_mode_ = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;\n\n const uint64_t test_fh_ = 1;\n\n const uint32_t open_flag_ = O_RDWR;\n\n\n\n std::string test_file_path_;\n\n\n\n PosixErrorOr<FileDescriptor> OpenTestFile(const std::string &path,\n\n uint64_t size = 512) {\n", "file_path": "test/fuse/linux/write_test.cc", "rank": 66, "score": 279358.74825223273 }, { "content": "class CreateTest : public FuseTest {\n\n protected:\n\n const std::string test_file_name_ = \"test_file\";\n\n const mode_t mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;\n\n};\n\n\n\nTEST_F(CreateTest, CreateFile) {\n\n const std::string test_file_path =\n\n JoinPath(mount_point_.path().c_str(), test_file_name_);\n\n\n\n // Ensure the file doesn't exist.\n\n struct fuse_out_header out_header = {\n\n .len = sizeof(struct fuse_out_header),\n\n .error = -ENOENT,\n\n };\n\n auto iov_out = FuseGenerateIovecs(out_header);\n\n SetServerResponse(FUSE_LOOKUP, iov_out);\n\n\n\n // creat(2) is equal to open(2) with open_flags O_CREAT | O_WRONLY | O_TRUNC.\n\n const mode_t new_mask = S_IWGRP | S_IWOTH;\n", "file_path": "test/fuse/linux/create_test.cc", "rank": 67, "score": 279358.74825223273 }, { "content": "class ReaddirTest : public FuseTest {\n\n public:\n\n void fill_fuse_dirent(char *buf, const char *name, uint64_t ino) {\n\n size_t namelen = strlen(name);\n\n size_t entlen = FUSE_NAME_OFFSET + namelen;\n\n size_t entlen_padded = FUSE_DIRENT_ALIGN(entlen);\n\n struct fuse_dirent *dirent;\n\n\n\n dirent = reinterpret_cast<struct fuse_dirent *>(buf);\n\n dirent->ino = ino;\n\n dirent->namelen = namelen;\n\n memcpy(dirent->name, name, namelen);\n\n memset(dirent->name + namelen, 0, entlen_padded - entlen);\n\n }\n\n\n\n protected:\n\n const std::string test_dir_name_ = \"test_dir\";\n\n};\n\n\n\nTEST_F(ReaddirTest, SingleEntry) {\n", "file_path": "test/fuse/linux/readdir_test.cc", "rank": 68, "score": 279358.74825223273 }, { "content": "class SymlinkTest : public FuseTest {\n\n protected:\n\n const std::string target_file_ = \"target_file_\";\n\n const std::string symlink_ = \"symlink_\";\n\n const mode_t perms_ = S_IRWXU | S_IRWXG | S_IRWXO;\n\n};\n\n\n\nTEST_F(SymlinkTest, CreateSymLink) {\n\n const std::string symlink_path =\n\n JoinPath(mount_point_.path().c_str(), symlink_);\n\n\n\n struct fuse_out_header out_header = {\n\n .len = sizeof(struct fuse_out_header) + sizeof(struct fuse_entry_out),\n\n };\n\n struct fuse_entry_out out_payload = DefaultEntryOut(S_IFLNK | perms_, 5);\n\n auto iov_out = FuseGenerateIovecs(out_header, out_payload);\n\n SetServerResponse(FUSE_SYMLINK, iov_out);\n\n ASSERT_THAT(symlink(target_file_.c_str(), symlink_path.c_str()),\n\n SyscallSucceeds());\n\n\n", "file_path": "test/fuse/linux/symlink_test.cc", "rank": 69, "score": 279358.7482522327 }, { "content": "class OpenTest : public FuseTest {\n\n // OpenTest doesn't care the release request when close a fd,\n\n // so doesn't check leftover requests when tearing down.\n\n void TearDown() { UnmountFuse(); }\n\n\n\n protected:\n\n const std::string test_file_ = \"test_file\";\n\n const mode_t regular_file_ = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;\n\n\n\n struct fuse_open_out out_payload_ = {\n\n .fh = 1,\n\n .open_flags = O_RDWR,\n\n };\n\n};\n\n\n\nTEST_F(OpenTest, RegularFile) {\n\n const std::string test_file_path =\n\n JoinPath(mount_point_.path().c_str(), test_file_);\n\n SetServerInodeLookup(test_file_, regular_file_);\n\n\n", "file_path": "test/fuse/linux/open_test.cc", "rank": 70, "score": 279358.74825223273 }, { "content": "class ReadTest : public FuseTest {\n\n void SetUp() override {\n\n FuseTest::SetUp();\n\n test_file_path_ = JoinPath(mount_point_.path().c_str(), test_file_);\n\n }\n\n\n\n // TearDown overrides the parent's function\n\n // to skip checking the unconsumed release request at the end.\n\n void TearDown() override { UnmountFuse(); }\n\n\n\n protected:\n\n const std::string test_file_ = \"test_file\";\n\n const mode_t test_file_mode_ = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;\n\n const uint64_t test_fh_ = 1;\n\n const uint32_t open_flag_ = O_RDWR;\n\n\n\n std::string test_file_path_;\n\n\n\n PosixErrorOr<FileDescriptor> OpenTestFile(const std::string &path,\n\n uint64_t size = 512) {\n", "file_path": "test/fuse/linux/read_test.cc", "rank": 71, "score": 279358.74825223273 }, { "content": "class MknodTest : public FuseTest {\n\n protected:\n\n const std::string test_file_ = \"test_file\";\n\n const mode_t perms_ = S_IRWXU | S_IRWXG | S_IRWXO;\n\n};\n\n\n\nTEST_F(MknodTest, RegularFile) {\n\n const std::string test_file_path =\n\n JoinPath(mount_point_.path().c_str(), test_file_);\n\n const mode_t new_umask = 0077;\n\n\n\n struct fuse_out_header out_header = {\n\n .len = sizeof(struct fuse_out_header) + sizeof(struct fuse_entry_out),\n\n };\n\n struct fuse_entry_out out_payload = DefaultEntryOut(S_IFREG | perms_, 5);\n\n auto iov_out = FuseGenerateIovecs(out_header, out_payload);\n\n SetServerResponse(FUSE_MKNOD, iov_out);\n\n TempUmask mask(new_umask);\n\n ASSERT_THAT(mknod(test_file_path.c_str(), perms_, 0), SyscallSucceeds());\n\n\n", "file_path": "test/fuse/linux/mknod_test.cc", "rank": 72, "score": 279358.74825223273 }, { "content": "class UnlinkTest : public FuseTest {\n\n protected:\n\n const std::string test_file_ = \"test_file\";\n\n const std::string test_subdir_ = \"test_subdir\";\n\n};\n\n\n\nTEST_F(UnlinkTest, RegularFile) {\n\n const std::string test_file_path =\n\n JoinPath(mount_point_.path().c_str(), test_file_);\n\n SetServerInodeLookup(test_file_, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO);\n\n\n\n struct fuse_out_header out_header = {\n\n .len = sizeof(struct fuse_out_header),\n\n };\n\n auto iov_out = FuseGenerateIovecs(out_header);\n\n SetServerResponse(FUSE_UNLINK, iov_out);\n\n\n\n ASSERT_THAT(unlink(test_file_path.c_str()), SyscallSucceeds());\n\n struct fuse_in_header in_header;\n\n std::vector<char> unlinked_file(test_file_.length() + 1);\n", "file_path": "test/fuse/linux/unlink_test.cc", "rank": 73, "score": 279358.74825223273 }, { "content": "// This test is currently very rudimentary.\n\n//\n\n// There are plenty of extra cases to cover once the sentry supports them.\n\n//\n\n// Different types of opens:\n\n// * O_CREAT\n\n// * O_DIRECTORY\n\n// * O_NOFOLLOW\n\n// * O_PATH\n\n//\n\n// Special operations on open:\n\n// * O_EXCL\n\n//\n\n// Special files:\n\n// * Blocking behavior for a named pipe.\n\n//\n\n// Different errors:\n\n// * EACCES\n\n// * EEXIST\n\n// * ENAMETOOLONG\n\n// * ELOOP\n\n// * ENOTDIR\n\n// * EPERM\n\nclass OpenTest : public FileTest {\n\n void SetUp() override {\n\n FileTest::SetUp();\n\n\n\n ASSERT_THAT(\n\n write(test_file_fd_.get(), test_data_.c_str(), test_data_.length()),\n\n SyscallSucceedsWithValue(test_data_.length()));\n\n EXPECT_THAT(lseek(test_file_fd_.get(), 0, SEEK_SET), SyscallSucceeds());\n\n }\n\n\n\n public:\n\n const std::string test_data_ = \"hello world\\n\";\n\n};\n\n\n\nTEST_F(OpenTest, OTrunc) {\n\n auto dir = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());\n\n ASSERT_THAT(open(dir.path().c_str(), O_TRUNC, 0666),\n\n SyscallFailsWithErrno(EISDIR));\n\n}\n\n\n", "file_path": "test/syscalls/linux/open.cc", "rank": 74, "score": 278255.29046888114 }, { "content": "class XattrTest : public FileTest {};\n\n\n\nTEST_F(XattrTest, XattrNonexistentFile) {\n\n const char* path = \"/does/not/exist\";\n\n const char* name = \"user.test\";\n\n EXPECT_THAT(setxattr(path, name, nullptr, 0, /*flags=*/0),\n\n SyscallFailsWithErrno(ENOENT));\n\n EXPECT_THAT(getxattr(path, name, nullptr, 0), SyscallFailsWithErrno(ENOENT));\n\n EXPECT_THAT(listxattr(path, nullptr, 0), SyscallFailsWithErrno(ENOENT));\n\n EXPECT_THAT(removexattr(path, name), SyscallFailsWithErrno(ENOENT));\n\n}\n\n\n\nTEST_F(XattrTest, XattrNullName) {\n\n const char* path = test_file_name_.c_str();\n\n\n\n EXPECT_THAT(setxattr(path, nullptr, nullptr, 0, /*flags=*/0),\n\n SyscallFailsWithErrno(EFAULT));\n\n EXPECT_THAT(getxattr(path, nullptr, nullptr, 0),\n\n SyscallFailsWithErrno(EFAULT));\n\n EXPECT_THAT(removexattr(path, nullptr), SyscallFailsWithErrno(EFAULT));\n", "file_path": "test/syscalls/linux/xattr.cc", "rank": 75, "score": 278244.64544025983 }, { "content": "class StatTest : public FileTest {};\n\n\n\nTEST_F(StatTest, FstatatAbs) {\n\n struct stat st;\n\n\n\n // Check that the stat works.\n\n EXPECT_THAT(fstatat(AT_FDCWD, test_file_name_.c_str(), &st, 0),\n\n SyscallSucceeds());\n\n EXPECT_TRUE(S_ISREG(st.st_mode));\n\n}\n\n\n\nTEST_F(StatTest, FstatatEmptyPath) {\n\n struct stat st;\n\n const auto fd = ASSERT_NO_ERRNO_AND_VALUE(Open(test_file_name_, O_RDONLY));\n\n\n\n // Check that the stat works.\n\n EXPECT_THAT(fstatat(fd.get(), \"\", &st, AT_EMPTY_PATH), SyscallSucceeds());\n\n EXPECT_TRUE(S_ISREG(st.st_mode));\n\n}\n\n\n", "file_path": "test/syscalls/linux/stat.cc", "rank": 76, "score": 278244.64544025983 }, { "content": "class AIOTest : public FileTest {\n\n public:\n\n AIOTest() : ctx_(0) {}\n\n\n\n int SetupContext(unsigned int nr) {\n\n return syscall(__NR_io_setup, nr, &ctx_);\n\n }\n\n\n\n int Submit(long nr, struct iocb** iocbpp) {\n\n return SubmitCtx(ctx_, nr, iocbpp);\n\n }\n\n\n\n int GetEvents(long min, long max, struct io_event* events,\n\n struct timespec* timeout) {\n\n return RetryEINTR(syscall)(__NR_io_getevents, ctx_, min, max, events,\n\n timeout);\n\n }\n\n\n\n int DestroyContext() { return syscall(__NR_io_destroy, ctx_); }\n\n\n", "file_path": "test/syscalls/linux/aio.cc", "rank": 77, "score": 278244.64544025983 }, { "content": "class FlockTest : public FileTest {};\n\n\n\nTEST_F(FlockTest, InvalidOpCombinations) {\n\n // The operation cannot be both exclusive and shared.\n\n EXPECT_THAT(flock(test_file_fd_.get(), LOCK_EX | LOCK_SH | LOCK_NB),\n\n SyscallFailsWithErrno(EINVAL));\n\n\n\n // Locking and Unlocking doesn't make sense.\n\n EXPECT_THAT(flock(test_file_fd_.get(), LOCK_EX | LOCK_UN | LOCK_NB),\n\n SyscallFailsWithErrno(EINVAL));\n\n EXPECT_THAT(flock(test_file_fd_.get(), LOCK_SH | LOCK_UN | LOCK_NB),\n\n SyscallFailsWithErrno(EINVAL));\n\n}\n\n\n\nTEST_F(FlockTest, NoOperationSpecified) {\n\n // Not specifying an operation is invalid.\n\n ASSERT_THAT(flock(test_file_fd_.get(), LOCK_NB),\n\n SyscallFailsWithErrno(EINVAL));\n\n}\n\n\n", "file_path": "test/syscalls/linux/flock.cc", "rank": 78, "score": 278244.64544025983 }, { "content": "class AllocateTest : public FileTest {\n\n void SetUp() override { FileTest::SetUp(); }\n\n};\n\n\n\nTEST_F(AllocateTest, Fallocate) {\n\n // Check that it starts at size zero.\n\n struct stat buf;\n\n ASSERT_THAT(fstat(test_file_fd_.get(), &buf), SyscallSucceeds());\n\n EXPECT_EQ(buf.st_size, 0);\n\n\n\n // Grow to ten bytes.\n\n ASSERT_THAT(fallocate(test_file_fd_.get(), 0, 0, 10), SyscallSucceeds());\n\n ASSERT_THAT(fstat(test_file_fd_.get(), &buf), SyscallSucceeds());\n\n EXPECT_EQ(buf.st_size, 10);\n\n\n\n // Allocate to a smaller size should be noop.\n\n ASSERT_THAT(fallocate(test_file_fd_.get(), 0, 0, 5), SyscallSucceeds());\n\n ASSERT_THAT(fstat(test_file_fd_.get(), &buf), SyscallSucceeds());\n\n EXPECT_EQ(buf.st_size, 10);\n\n\n", "file_path": "test/syscalls/linux/fallocate.cc", "rank": 79, "score": 278244.64544025983 }, { "content": "class ReadvTest : public FileTest {\n\n void SetUp() override {\n\n FileTest::SetUp();\n\n\n\n ASSERT_THAT(write(test_file_fd_.get(), kReadvTestData, kReadvTestDataSize),\n\n SyscallSucceedsWithValue(kReadvTestDataSize));\n\n ASSERT_THAT(lseek(test_file_fd_.get(), 0, SEEK_SET),\n\n SyscallSucceedsWithValue(0));\n\n ASSERT_THAT(write(test_pipe_[1], kReadvTestData, kReadvTestDataSize),\n\n SyscallSucceedsWithValue(kReadvTestDataSize));\n\n }\n\n};\n\n\n\nTEST_F(ReadvTest, ReadOneBufferPerByte_File) {\n\n ReadOneBufferPerByte(test_file_fd_.get());\n\n}\n\n\n\nTEST_F(ReadvTest, ReadOneBufferPerByte_Pipe) {\n\n ReadOneBufferPerByte(test_pipe_[0]);\n\n}\n", "file_path": "test/syscalls/linux/readv.cc", "rank": 80, "score": 278244.64544025983 }, { "content": "class RmDirTest : public FuseTest {\n\n protected:\n\n const std::string test_dir_name_ = \"test_dir\";\n\n const std::string test_subdir_ = \"test_subdir\";\n\n const mode_t test_dir_mode_ = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO;\n\n};\n\n\n\nTEST_F(RmDirTest, NormalRmDir) {\n\n const std::string test_dir_path_ =\n\n JoinPath(mount_point_.path().c_str(), test_dir_name_);\n\n\n\n SetServerInodeLookup(test_dir_name_, test_dir_mode_);\n\n\n\n // RmDir code.\n\n struct fuse_out_header rmdir_header = {\n\n .len = sizeof(struct fuse_out_header),\n\n };\n\n\n\n auto iov_out = FuseGenerateIovecs(rmdir_header);\n\n SetServerResponse(FUSE_RMDIR, iov_out);\n", "file_path": "test/fuse/linux/rmdir_test.cc", "rank": 81, "score": 277077.4126440129 }, { "content": "class PselectTest : public BasePollTest {\n\n protected:\n\n void SetUp() override { BasePollTest::SetUp(); }\n\n void TearDown() override { BasePollTest::TearDown(); }\n\n};\n\n\n\n// See that when there are no FD sets, pselect behaves like sleep.\n\nTEST_F(PselectTest, NullFds) {\n\n struct timespec timeout = absl::ToTimespec(absl::Milliseconds(10));\n\n ASSERT_THAT(syscallPselect6(0, nullptr, nullptr, nullptr, &timeout, nullptr),\n\n SyscallSucceeds());\n\n EXPECT_EQ(timeout.tv_sec, 0);\n\n EXPECT_EQ(timeout.tv_nsec, 0);\n\n\n\n timeout = absl::ToTimespec(absl::Milliseconds(10));\n\n ASSERT_THAT(syscallPselect6(1, nullptr, nullptr, nullptr, &timeout, nullptr),\n\n SyscallSucceeds());\n\n EXPECT_EQ(timeout.tv_sec, 0);\n\n EXPECT_EQ(timeout.tv_nsec, 0);\n\n}\n", "file_path": "test/syscalls/linux/pselect.cc", "rank": 82, "score": 275808.1453148322 }, { "content": "class PpollTest : public BasePollTest {\n\n protected:\n\n void SetUp() override { BasePollTest::SetUp(); }\n\n void TearDown() override { BasePollTest::TearDown(); }\n\n};\n\n\n\nTEST_F(PpollTest, InvalidFds) {\n\n // fds is invalid because it's null, but we tell ppoll the length is non-zero.\n\n struct timespec timeout = {};\n\n sigset_t sigmask;\n\n TEST_PCHECK(sigemptyset(&sigmask) == 0);\n\n EXPECT_THAT(syscallPpoll(nullptr, 1, &timeout, &sigmask, kSigsetSize),\n\n SyscallFailsWithErrno(EFAULT));\n\n EXPECT_THAT(syscallPpoll(nullptr, -1, &timeout, &sigmask, kSigsetSize),\n\n SyscallFailsWithErrno(EINVAL));\n\n}\n\n\n\n// See that when fds is null, ppoll behaves like sleep.\n\nTEST_F(PpollTest, NullFds) {\n\n struct timespec timeout = absl::ToTimespec(absl::Milliseconds(10));\n", "file_path": "test/syscalls/linux/ppoll.cc", "rank": 83, "score": 275808.1453148322 }, { "content": "class PollTest : public BasePollTest {\n\n protected:\n\n void SetUp() override { BasePollTest::SetUp(); }\n\n void TearDown() override { BasePollTest::TearDown(); }\n\n};\n\n\n\nTEST_F(PollTest, InvalidFds) {\n\n // fds is invalid because it's null, but we tell ppoll the length is non-zero.\n\n EXPECT_THAT(poll(nullptr, 1, 1), SyscallFailsWithErrno(EFAULT));\n\n EXPECT_THAT(poll(nullptr, -1, 1), SyscallFailsWithErrno(EINVAL));\n\n}\n\n\n\nTEST_F(PollTest, NullFds) {\n\n EXPECT_THAT(poll(nullptr, 0, 10), SyscallSucceeds());\n\n}\n\n\n\nTEST_F(PollTest, ZeroTimeout) {\n\n EXPECT_THAT(poll(nullptr, 0, 0), SyscallSucceeds());\n\n}\n\n\n", "file_path": "test/syscalls/linux/poll.cc", "rank": 84, "score": 275808.1453148322 }, { "content": "class FixtureTruncateTest : public FileTest {\n\n void SetUp() override { FileTest::SetUp(); }\n\n};\n\n\n\nTEST_F(FixtureTruncateTest, Truncate) {\n\n // Get the current rlimit and restore after test run.\n\n struct rlimit initial_lim;\n\n ASSERT_THAT(getrlimit(RLIMIT_FSIZE, &initial_lim), SyscallSucceeds());\n\n auto cleanup = Cleanup([&initial_lim] {\n\n EXPECT_THAT(setrlimit(RLIMIT_FSIZE, &initial_lim), SyscallSucceeds());\n\n });\n\n\n\n // Check that it starts at size zero.\n\n struct stat buf;\n\n ASSERT_THAT(fstat(test_file_fd_.get(), &buf), SyscallSucceeds());\n\n EXPECT_EQ(buf.st_size, 0);\n\n\n\n // Stay at size zero.\n\n EXPECT_THAT(truncate(test_file_name_.c_str(), 0), SyscallSucceeds());\n\n ASSERT_THAT(fstat(test_file_fd_.get(), &buf), SyscallSucceeds());\n", "file_path": "test/syscalls/linux/truncate.cc", "rank": 85, "score": 275808.1453148322 }, { "content": "class SelectTest : public BasePollTest {\n\n protected:\n\n void SetUp() override { BasePollTest::SetUp(); }\n\n void TearDown() override { BasePollTest::TearDown(); }\n\n};\n\n\n\n// See that when there are no FD sets, select behaves like sleep.\n\nTEST_F(SelectTest, NullFds) {\n\n struct timeval timeout = absl::ToTimeval(absl::Milliseconds(10));\n\n ASSERT_THAT(select(0, nullptr, nullptr, nullptr, &timeout),\n\n SyscallSucceeds());\n\n EXPECT_EQ(timeout.tv_sec, 0);\n\n EXPECT_EQ(timeout.tv_usec, 0);\n\n\n\n timeout = absl::ToTimeval(absl::Milliseconds(10));\n\n ASSERT_THAT(select(1, nullptr, nullptr, nullptr, &timeout),\n\n SyscallSucceeds());\n\n EXPECT_EQ(timeout.tv_sec, 0);\n\n EXPECT_EQ(timeout.tv_usec, 0);\n\n}\n", "file_path": "test/syscalls/linux/select.cc", "rank": 86, "score": 275808.1453148322 }, { "content": "func TestOverrideError(t *testing.T) {\n\n\ttestFlags := flag.NewFlagSet(\"test\", flag.ContinueOnError)\n\n\tRegisterFlags(testFlags)\n\n\tc, err := NewFromFlags(testFlags)\n\n\tif err != nil {\n\n\t\tt.Fatal(err)\n\n\t}\n\n\tc.AllowFlagOverride = true\n\n\tfor _, tc := range []struct {\n\n\t\tname string\n\n\t\tvalue string\n\n\t\terror string\n\n\t}{\n\n\t\t{\n\n\t\t\tname: \"invalid\",\n\n\t\t\tvalue: \"valid\",\n\n\t\t\terror: `flag \"invalid\" not found`,\n\n\t\t},\n\n\t\t{\n\n\t\t\tname: \"debug\",\n\n\t\t\tvalue: \"invalid\",\n\n\t\t\terror: \"error setting flag debug\",\n\n\t\t},\n\n\t\t{\n\n\t\t\tname: \"file-access\",\n\n\t\t\tvalue: \"invalid\",\n\n\t\t\terror: \"invalid file access type\",\n\n\t\t},\n\n\t} {\n\n\t\tt.Run(tc.name, func(t *testing.T) {\n\n\t\t\tif err := c.Override(testFlags, tc.name, tc.value); err == nil || !strings.Contains(err.Error(), tc.error) {\n\n\t\t\t\tt.Errorf(\"Override(%q, %q) wrong error: %v\", tc.name, tc.value, err)\n\n\t\t\t}\n\n\t\t})\n\n\t}\n", "file_path": "runsc/config/config_test.go", "rank": 87, "score": 273307.5480258394 }, { "content": "class ReadTestSmallMaxRead : public ReadTest {\n\n void SetUp() override {\n\n MountFuse(mountOpts);\n\n SetUpFuseServer();\n\n test_file_path_ = JoinPath(mount_point_.path().c_str(), test_file_);\n\n }\n\n\n\n protected:\n\n constexpr static char mountOpts[] =\n\n \"rootmode=755,user_id=0,group_id=0,max_read=4096\";\n\n // 4096 is hard-coded as the max_read in mount options.\n\n const int size_fragment = 4096;\n\n};\n\n\n\nTEST_F(ReadTest, ReadWhole) {\n\n auto fd = ASSERT_NO_ERRNO_AND_VALUE(OpenTestFile(test_file_path_));\n\n\n\n // Prepare for the read.\n\n const int n_read = 5;\n\n std::vector<char> data(n_read);\n", "file_path": "test/fuse/linux/read_test.cc", "rank": 88, "score": 272673.35710024426 }, { "content": "class WriteTestSmallMaxWrite : public WriteTest {\n\n void SetUp() override {\n\n MountFuse();\n\n SetUpFuseServer(&fuse_init_payload);\n\n test_file_path_ = JoinPath(mount_point_.path().c_str(), test_file_);\n\n }\n\n\n\n protected:\n\n const static uint32_t max_write_ = 4096;\n\n constexpr static struct fuse_init_out fuse_init_payload = {\n\n .major = 7,\n\n .max_write = max_write_,\n\n };\n\n\n\n const uint32_t size_fragment = max_write_;\n\n};\n\n\n\nTEST_F(WriteTest, WriteNormal) {\n\n auto fd = ASSERT_NO_ERRNO_AND_VALUE(OpenTestFile(test_file_path_));\n\n\n", "file_path": "test/fuse/linux/write_test.cc", "rank": 89, "score": 272673.35710024426 }, { "content": "class MMapFileTest : public MMapTest {\n\n protected:\n\n FileDescriptor fd_;\n\n std::string filename_;\n\n\n\n // Open a file for read/write\n\n void SetUp() override {\n\n MMapTest::SetUp();\n\n\n\n filename_ = NewTempAbsPath();\n\n fd_ = ASSERT_NO_ERRNO_AND_VALUE(Open(filename_, O_CREAT | O_RDWR, 0644));\n\n\n\n // Extend file so it can be written once mapped. Deliberately make the file\n\n // only half a page in size, so we can test what happens when we access the\n\n // second half.\n\n // Use ftruncate(2) once the sentry supports it.\n\n char zero = 0;\n\n size_t count = 0;\n\n do {\n\n const DisableSave ds; // saving 2048 times is slow and useless.\n", "file_path": "test/syscalls/linux/mmap.cc", "rank": 90, "score": 271106.8774817261 }, { "content": "class AIOReadWriteParamTest : public AIOTest,\n\n public ::testing::WithParamInterface<int> {};\n\n\n\nTEST_P(AIOReadWriteParamTest, BadOffset) {\n\n // Setup a context that is 128 entries deep.\n\n ASSERT_THAT(SetupContext(128), SyscallSucceeds());\n\n\n\n struct iocb cb = CreateCallback();\n\n struct iocb* cbs[1] = {&cb};\n\n\n\n // Create a buffer that we can write to.\n\n char buf[] = \"hello world!\";\n\n cb.aio_buf = reinterpret_cast<uint64_t>(buf);\n\n\n\n // Set the operation on the callback and give a negative offset.\n\n const int opcode = GetParam();\n\n cb.aio_lio_opcode = opcode;\n\n\n\n iovec iov = {};\n\n if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) {\n", "file_path": "test/syscalls/linux/aio.cc", "rank": 91, "score": 271106.8774817261 }, { "content": "func wantErrno(c connectionMode, icmpErr icmpError) unix.Errno {\n\n\tif c && icmpErr == portUnreachable {\n\n\t\treturn unix.ECONNREFUSED\n\n\t}\n\n\treturn unix.Errno(0)\n", "file_path": "test/packetimpact/tests/udp_icmp_error_propagation_test.go", "rank": 92, "score": 270473.9606242497 }, { "content": "\tremoteFD int32\n", "file_path": "test/packetimpact/tests/udp_icmp_error_propagation_test.go", "rank": 93, "score": 270357.71772514953 }, { "content": "\tcleanFD int32\n", "file_path": "test/packetimpact/tests/udp_icmp_error_propagation_test.go", "rank": 94, "score": 270357.71772514953 }, { "content": "func (*fdSender) Name() string {\n\n\treturn \"fd_sender\"\n", "file_path": "test/cmd/test_app/fds.go", "rank": 95, "score": 269943.1636999093 }, { "content": "func (*fdReceiver) Name() string {\n\n\treturn \"fd_receiver\"\n", "file_path": "test/cmd/test_app/fds.go", "rank": 96, "score": 269943.1636999093 }, { "content": "// Fixture for tests parameterized by a function that waits for any child to\n\n// exit with the given options, checks that it exited with the given code, and\n\n// then returns its PID.\n\n//\n\n// N.B. These tests run in a multi-threaded environment. We assume that\n\n// background threads do not create child processes and are not themselves\n\n// created with clone(... | SIGCHLD). Either may cause these tests to\n\n// erroneously wait on child processes/threads.\n\nclass WaitAnyChildTest : public ::testing::TestWithParam<\n\n std::function<PosixErrorOr<pid_t>(int, int)>> {\n\n protected:\n\n PosixErrorOr<pid_t> WaitAny(int code) { return WaitAnyWithOptions(code, 0); }\n\n\n\n PosixErrorOr<pid_t> WaitAnyWithOptions(int code, int options) {\n\n return GetParam()(code, options);\n\n }\n\n};\n\n\n\n// Wait for any child to exit.\n\nTEST_P(WaitAnyChildTest, Fork) {\n\n pid_t child;\n\n ASSERT_THAT(child = ForkAndExit(0, 0), SyscallSucceeds());\n\n\n\n EXPECT_THAT(WaitAny(0), IsPosixErrorOkAndHolds(child));\n\n}\n\n\n\n// Call wait4 for any process after the child has already exited.\n\nTEST_P(WaitAnyChildTest, AfterExit) {\n", "file_path": "test/syscalls/linux/wait.cc", "rank": 97, "score": 269595.41096537525 } ]
C++
src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp
YggDrazil/-MaNGOsZero0.20
6bc64bf5c42cbd1e491c28a4d7a2bf91051323fb
#include "Config/Config.h" #include "../botpch.h" #include "playerbot.h" #include "PlayerbotAIConfig.h" #include "PlayerbotFactory.h" #include "AccountMgr.h" #include "ObjectMgr.h" #include "DatabaseEnv.h" #include "PlayerbotAI.h" #include "Player.h" #include "RandomPlayerbotFactory.h" #include "SystemConfig.h" map<uint8, vector<uint8> > RandomPlayerbotFactory::availableRaces; RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(accountId) { availableRaces[CLASS_WARRIOR].push_back(RACE_HUMAN); availableRaces[CLASS_WARRIOR].push_back(RACE_NIGHTELF); availableRaces[CLASS_WARRIOR].push_back(RACE_GNOME); availableRaces[CLASS_WARRIOR].push_back(RACE_DWARF); availableRaces[CLASS_WARRIOR].push_back(RACE_ORC); availableRaces[CLASS_WARRIOR].push_back(RACE_UNDEAD); availableRaces[CLASS_WARRIOR].push_back(RACE_TAUREN); availableRaces[CLASS_WARRIOR].push_back(RACE_TROLL); availableRaces[CLASS_PALADIN].push_back(RACE_HUMAN); availableRaces[CLASS_PALADIN].push_back(RACE_DWARF); availableRaces[CLASS_ROGUE].push_back(RACE_HUMAN); availableRaces[CLASS_ROGUE].push_back(RACE_DWARF); availableRaces[CLASS_ROGUE].push_back(RACE_NIGHTELF); availableRaces[CLASS_ROGUE].push_back(RACE_GNOME); availableRaces[CLASS_ROGUE].push_back(RACE_ORC); availableRaces[CLASS_ROGUE].push_back(RACE_TROLL); availableRaces[CLASS_PRIEST].push_back(RACE_HUMAN); availableRaces[CLASS_PRIEST].push_back(RACE_DWARF); availableRaces[CLASS_PRIEST].push_back(RACE_NIGHTELF); availableRaces[CLASS_PRIEST].push_back(RACE_TROLL); availableRaces[CLASS_PRIEST].push_back(RACE_UNDEAD); availableRaces[CLASS_MAGE].push_back(RACE_HUMAN); availableRaces[CLASS_MAGE].push_back(RACE_GNOME); availableRaces[CLASS_MAGE].push_back(RACE_UNDEAD); availableRaces[CLASS_MAGE].push_back(RACE_TROLL); availableRaces[CLASS_WARLOCK].push_back(RACE_HUMAN); availableRaces[CLASS_WARLOCK].push_back(RACE_GNOME); availableRaces[CLASS_WARLOCK].push_back(RACE_UNDEAD); availableRaces[CLASS_WARLOCK].push_back(RACE_ORC); availableRaces[CLASS_SHAMAN].push_back(RACE_ORC); availableRaces[CLASS_SHAMAN].push_back(RACE_TAUREN); availableRaces[CLASS_SHAMAN].push_back(RACE_TROLL); availableRaces[CLASS_HUNTER].push_back(RACE_DWARF); availableRaces[CLASS_HUNTER].push_back(RACE_NIGHTELF); availableRaces[CLASS_HUNTER].push_back(RACE_ORC); availableRaces[CLASS_HUNTER].push_back(RACE_TAUREN); availableRaces[CLASS_HUNTER].push_back(RACE_TROLL); availableRaces[CLASS_DRUID].push_back(RACE_NIGHTELF); availableRaces[CLASS_DRUID].push_back(RACE_TAUREN); } bool RandomPlayerbotFactory::CreateRandomBot(uint8 cls) { sLog.outDetail("Creating new random bot for class %d", cls); uint8 gender = rand() % 2 ? GENDER_MALE : GENDER_FEMALE; uint8 race = availableRaces[cls][urand(0, availableRaces[cls].size() - 1)]; string name = CreateRandomBotName(); if (name.empty()) return false; uint8 skin = urand(0, 7); uint8 face = urand(0, 7); uint8 hairStyle = urand(0, 7); uint8 hairColor = urand(0, 7); uint8 facialHair = urand(0, 7); uint8 outfitId = 0; WorldSession* session = new WorldSession(accountId, NULL, SEC_PLAYER, 0, LOCALE_enUS); if (!session) { sLog.outError("Couldn't create session for random bot account %d", accountId); delete session; return false; } Player *player = new Player(session); if (!player->Create(sObjectMgr.GeneratePlayerLowGuid(), name, race, cls, gender, skin, face, hairStyle, hairColor, facialHair, outfitId)) { player->DeleteFromDB(player->GetObjectGuid(), accountId, true, true); delete session; delete player; sLog.outError("Unable to create random bot for account %d - name: \"%s\"; race: %u; class: %u; gender: %u; skin: %u; face: %u; hairStyle: %u; hairColor: %u; facialHair: %u; outfitId: %u", accountId, name.c_str(), race, cls, gender, skin, face, hairStyle, hairColor, facialHair, outfitId); return false; } player->setCinematic(2); player->SetAtLoginFlag(AT_LOGIN_NONE); player->SaveToDB(); sLog.outDetail("Random bot created for account %d - name: \"%s\"; race: %u; class: %u; gender: %u; skin: %u; face: %u; hairStyle: %u; hairColor: %u; facialHair: %u; outfitId: %u", accountId, name.c_str(), race, cls, gender, skin, face, hairStyle, hairColor, facialHair, outfitId); return true; } string RandomPlayerbotFactory::CreateRandomBotName() { QueryResult *result = CharacterDatabase.Query("SELECT MAX(name_id) FROM ai_playerbot_names"); if (!result) return ""; Field *fields = result->Fetch(); uint32 maxId = fields[0].GetUInt32(); delete result; uint32 id = urand(0, maxId); result = CharacterDatabase.PQuery("SELECT n.name FROM ai_playerbot_names n " "LEFT OUTER JOIN characters e ON e.name = n.name " "WHERE e.guid IS NULL AND n.name_id >= '%u' LIMIT 1", id); if (!result) { sLog.outError("No more names left for random bots"); return ""; } Field *nfields = result->Fetch(); string name = nfields[0].GetCppString(); delete result; return name; }
#include "Config/Config.h" #include "../botpch.h" #include "playerbot.h" #include "PlayerbotAIConfig.h" #include "PlayerbotFactory.h" #include "AccountMgr.h" #include "ObjectMgr.h" #include "DatabaseEnv.h" #include "PlayerbotAI.h" #include "Player.h" #include "RandomPlayerbotFactory.h" #include "SystemConfig.h" map<uint8, vector<uint8> > RandomPlayerbotFactory::availableRaces; RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(accountId) { availableRaces[CLASS_WARRIOR].push_back(RACE_HUMAN); availableRaces[CLASS_WARRIOR].push_back(RACE_NIGHTELF); availableRaces[CLASS_WARRIOR].push_back(RACE_GNOME); availableRaces[CLASS_WARRIOR].push_back(RACE_DWARF); availableRaces[CLASS_WARRIOR].push_back(RACE_ORC); availableRaces[CLASS_WARRIOR].push_back(RACE_UNDEAD); availableRaces[CLASS_WARRIOR].push_back(RACE_TAUREN); availableRaces[CLASS_WARRIOR].push_back(RACE_TROLL); availableRaces[CLASS_PALADIN].push_back(RACE_HUMAN); availableRaces[CLASS_PALADIN].push_back(RACE_DWARF); availableRaces[CLASS_ROGUE].push_back(RACE_HUMAN); availableRaces[CLASS_ROGUE].push_back(RACE_DWARF); availableRaces[CLASS_ROGUE].push_back(RACE_NIGHTELF); availableRaces[CLASS_ROGUE].push_back(RACE_GNOME); availableRaces[CLASS_ROGUE].push_back(RACE_ORC); availableRaces[CLASS_ROGUE].push_back(RACE_TROLL); availableRaces[CLASS_PRIEST].push_back(RACE_HUMAN); availableRaces[CLASS_PRIEST].push_back(RACE_DWARF); availableRaces[CLASS_PRIEST].push_back(RACE_NIGHTELF); availableRaces[CLASS_PRIEST].push_back(RACE_TROLL); availableRaces[CLASS_PRIEST].push_back(RACE_UNDEAD); availableRaces[CLASS_MAGE].push_back(RACE_HUMAN); availableRaces[CLASS_MAGE].push_back(RACE_GNOME); availableRaces[CLASS_MAGE].push_back(RACE_UNDEAD); availableRaces[CLASS_MAGE].push_back(RACE_TROLL); availableRaces[CLASS_WARLOCK].push_back(RACE_HUMAN); availableRaces[CLASS_WARLOCK].push_back(RACE_GNOME); availableRaces[CLASS_WARLOCK].push_back(RACE_UNDEAD); availableRaces[CLASS_WARLOCK].push_back(RACE_ORC); availableRaces[CLASS_SHAMAN].push_back(RACE_ORC); availableRaces[CLASS_SHAMAN].push_back(RACE_TAUREN); availableRaces[CLASS_SHAMAN].push_back(RACE_TROLL); availableRaces[CLASS_HUNTER].push_back(RACE_DWARF); availableRaces[CLASS_HUNTER].push_back(RACE_NIGHTELF); availableRaces[CLASS_HUNTER].push_back(RACE_ORC); availableRaces[CLASS_HUNTER].push_back(RACE_TAUREN); availableRaces[CLASS_HUNTER].push_back(RACE_TROLL); availableRaces[CLASS_DRUID].push_back(RACE_NIGHTELF); availableRaces[CLASS_DRUID].push_back(RACE_TAUREN); } bool RandomPlayerbotFactory::CreateRandomBot(uint8 cls) { sLog.outDetail("Creating new random bot for class %d", cls); uint8 gender = rand() % 2 ? GENDER_MALE : GENDER_FEMALE; uint8 race = availableRaces[cls][urand(0, availableRaces[cls].size() - 1)]; string name = CreateRandomBotName(); if (name.empty()) return false; uint8 skin = urand(0, 7); uint8 face = urand(0, 7); uint8 hairStyle = urand(0, 7); uint8 hairColor = urand(0, 7); uint8 facialHair = urand(0, 7); uint8 outfitId = 0; WorldSession* session = new WorldSession(accountId, NULL, SEC_PLAYER, 0, LOCALE_enUS); if (!session) { sLog.outError("Couldn't create session for random bot account %d", accountId); delete session; return false; } Player *player = new Player(session);
player->setCinematic(2); player->SetAtLoginFlag(AT_LOGIN_NONE); player->SaveToDB(); sLog.outDetail("Random bot created for account %d - name: \"%s\"; race: %u; class: %u; gender: %u; skin: %u; face: %u; hairStyle: %u; hairColor: %u; facialHair: %u; outfitId: %u", accountId, name.c_str(), race, cls, gender, skin, face, hairStyle, hairColor, facialHair, outfitId); return true; } string RandomPlayerbotFactory::CreateRandomBotName() { QueryResult *result = CharacterDatabase.Query("SELECT MAX(name_id) FROM ai_playerbot_names"); if (!result) return ""; Field *fields = result->Fetch(); uint32 maxId = fields[0].GetUInt32(); delete result; uint32 id = urand(0, maxId); result = CharacterDatabase.PQuery("SELECT n.name FROM ai_playerbot_names n " "LEFT OUTER JOIN characters e ON e.name = n.name " "WHERE e.guid IS NULL AND n.name_id >= '%u' LIMIT 1", id); if (!result) { sLog.outError("No more names left for random bots"); return ""; } Field *nfields = result->Fetch(); string name = nfields[0].GetCppString(); delete result; return name; }
if (!player->Create(sObjectMgr.GeneratePlayerLowGuid(), name, race, cls, gender, skin, face, hairStyle, hairColor, facialHair, outfitId)) { player->DeleteFromDB(player->GetObjectGuid(), accountId, true, true); delete session; delete player; sLog.outError("Unable to create random bot for account %d - name: \"%s\"; race: %u; class: %u; gender: %u; skin: %u; face: %u; hairStyle: %u; hairColor: %u; facialHair: %u; outfitId: %u", accountId, name.c_str(), race, cls, gender, skin, face, hairStyle, hairColor, facialHair, outfitId); return false; }
if_condition
[ { "content": "class Player;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotMgr.h", "rank": 0, "score": 310367.1292837344 }, { "content": "class Player;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotFactory.h", "rank": 1, "score": 310367.1292837344 }, { "content": "class Player;\n", "file_path": "src/game/Server/WorldSession.h", "rank": 2, "score": 265251.5922415188 }, { "content": "class Player;\n", "file_path": "src/modules/Bots/playerbot/PlayerbotMgr.h", "rank": 3, "score": 259141.55112926627 }, { "content": "class Player;\n", "file_path": "src/modules/Bots/playerbot/PlayerbotAI.h", "rank": 4, "score": 259141.55112926627 }, { "content": "class Player;\n\n\n\nusing namespace ai;\n\n\n", "file_path": "src/modules/Bots/playerbot/AiFactory.h", "rank": 5, "score": 259141.55112926627 }, { "content": "class Player;\n\n\n\nnamespace ai\n\n{\n", "file_path": "src/modules/Bots/playerbot/FleeManager.h", "rank": 6, "score": 259141.55112926627 }, { "content": "class Player;\n", "file_path": "src/modules/Bots/playerbot/PlayerbotFactory.h", "rank": 7, "score": 259141.55112926627 }, { "content": "class Player;\n", "file_path": "src/modules/Bots/playerbot/PlayerbotAIConfig.h", "rank": 8, "score": 254466.7732316724 }, { "content": "class Player;\n", "file_path": "src/modules/Bots/playerbot/PlayerbotAIBase.h", "rank": 9, "score": 254466.7732316724 }, { "content": " class IsFacingValue : public BoolCalculatedValue, public Qualified\n\n\t{\n\n\tpublic:\n\n IsFacingValue(PlayerbotAI* ai) : BoolCalculatedValue(ai) {}\n\n\n\n virtual bool Calculate()\n\n {\n\n Unit* target = AI_VALUE(Unit*, qualifier);\n\n if (!target)\n\n return false;\n\n\n\n return bot->isInFront(target, sPlayerbotAIConfig.sightDistance, M_PI_F / 3.0f);\n\n }\n\n };\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/IsFacingValue.h", "rank": 10, "score": 226138.00330327608 }, { "content": " class Uint8CalculatedValue : public CalculatedValue<uint8>\n\n {\n\n public:\n\n Uint8CalculatedValue(PlayerbotAI* ai, string name = \"value\", int checkInterval = 1) :\n\n CalculatedValue<uint8>(ai, name, checkInterval) {}\n\n\n\n virtual string Format()\n\n {\n\n ostringstream out; out << (int)Calculate();\n\n return out.str();\n\n }\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/Value.h", "rank": 11, "score": 226019.64922187364 }, { "content": " class BoolCalculatedValue : public CalculatedValue<bool>\n\n {\n\n public:\n\n BoolCalculatedValue(PlayerbotAI* ai, string name = \"value\", int checkInterval = 1) :\n\n CalculatedValue<bool>(ai, name, checkInterval) {}\n\n\n\n virtual string Format()\n\n {\n\n return Calculate() ? \"true\" : \"false\";\n\n }\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/Value.h", "rank": 12, "score": 226011.38757103105 }, { "content": "class Player;\n\n\n", "file_path": "src/game/Object/Pet.h", "rank": 13, "score": 209613.9594904455 }, { "content": "class Player;\n", "file_path": "src/game/Object/Creature.h", "rank": 14, "score": 209613.9594904455 }, { "content": "class Player;\n\n\n", "file_path": "src/game/Object/Camera.h", "rank": 15, "score": 209613.9594904455 }, { "content": "class Player;\n", "file_path": "src/game/Object/Object.h", "rank": 16, "score": 209613.9594904455 }, { "content": "class Item;\n\n\n\nusing namespace std;\n\n\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotFactory.h", "rank": 17, "score": 208331.5048248173 }, { "content": "class Item;\n\n\n\nusing namespace std;\n\n\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotMgr.h", "rank": 18, "score": 208331.5048248173 }, { "content": "class Unit;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotFactory.h", "rank": 19, "score": 208331.5048248173 }, { "content": "class Object;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotMgr.h", "rank": 20, "score": 208331.5048248173 }, { "content": "class Unit;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotMgr.h", "rank": 21, "score": 208331.5048248173 }, { "content": "class Object;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotFactory.h", "rank": 22, "score": 208331.5048248173 }, { "content": "class Player;\n", "file_path": "src/game/Object/SpellMgr.h", "rank": 23, "score": 206107.75994684157 }, { "content": "class Player;\n", "file_path": "src/game/Object/ReputationMgr.h", "rank": 24, "score": 206107.75994684157 }, { "content": "class Player;\n\n\n", "file_path": "src/game/References/GroupReference.h", "rank": 25, "score": 206107.75994684157 }, { "content": "class Player;\n\n\n\n#define MAIL_BODY_ITEM_TEMPLATE 8383 ///< - plain letter, A Dusty Unsent Letter: 889\n\n/// The maximal amount of items a mail can contain.\n\n#define MAX_MAIL_ITEMS 1\n\n/**\n\n * The type of the mail.\n\n * A mail can have 5 Different Types.\n\n */\n", "file_path": "src/game/WorldHandlers/Mail.h", "rank": 26, "score": 206107.75994684157 }, { "content": "class Player;\n", "file_path": "src/game/WorldHandlers/Weather.h", "rank": 27, "score": 206107.75994684157 }, { "content": "class Player;\n", "file_path": "src/game/WorldHandlers/World.h", "rank": 28, "score": 206107.75994684157 }, { "content": "class Player;\n", "file_path": "src/game/Object/LootMgr.h", "rank": 29, "score": 206107.75994684157 }, { "content": "class Player;\n", "file_path": "src/game/Object/SocialMgr.h", "rank": 30, "score": 206107.75994684157 }, { "content": "class Player;\n", "file_path": "src/game/Object/CreatureAI.h", "rank": 31, "score": 206107.75994684157 }, { "content": "class Player;\n", "file_path": "src/game/WorldHandlers/Chat.h", "rank": 32, "score": 206107.75994684157 }, { "content": "class WorldPacket;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotFactory.h", "rank": 33, "score": 203894.22070742384 }, { "content": "class WorldPacket;\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotMgr.h", "rank": 34, "score": 203894.22070742384 }, { "content": " class Qualified\n\n {\n\n public:\n\n Qualified() {};\n\n\n\n public:\n\n void Qualify(string qualifier) { this->qualifier = qualifier; }\n\n\n\n protected:\n\n string qualifier;\n\n };\n\n\n\n template <class T> class NamedObjectFactory\n\n {\n\n protected:\n\n typedef T* (*ActionCreator) (PlayerbotAI* ai);\n\n map<string, ActionCreator> creators;\n\n\n\n public:\n\n T* create(string name, PlayerbotAI* ai)\n", "file_path": "src/modules/Bots/playerbot/strategy/NamedObjectContext.h", "rank": 35, "score": 203879.76236748477 }, { "content": " class RtiValue : public ManualSetValue<string>\n\n\t{\n\n\tpublic:\n\n RtiValue(PlayerbotAI* ai);\n\n };\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/RtiValue.h", "rank": 36, "score": 203296.4209078017 }, { "content": "class Player;\n", "file_path": "src/game/WorldHandlers/InstanceData.h", "rank": 37, "score": 202799.75166851713 }, { "content": "class Player;\n\n\n", "file_path": "src/game/WorldHandlers/QuestDef.h", "rank": 38, "score": 202799.75166851713 }, { "content": "class Player;\n", "file_path": "src/game/BattleGround/BattleGround.h", "rank": 39, "score": 202799.75166851713 }, { "content": "class Player;\n", "file_path": "src/game/WorldHandlers/ScriptMgr.h", "rank": 40, "score": 202799.75166851713 }, { "content": "class Player;\n", "file_path": "src/game/WorldHandlers/GridDefines.h", "rank": 41, "score": 202799.75166851713 }, { "content": "class Player;\n\n\n", "file_path": "src/game/MotionGenerators/MovementGenerator.h", "rank": 42, "score": 202799.75166851713 }, { "content": "class Player;\n", "file_path": "src/game/References/GroupRefManager.h", "rank": 43, "score": 202799.75166851713 }, { "content": "class Player;\n", "file_path": "src/game/Object/CreatureEventAI.h", "rank": 44, "score": 202799.75166851713 }, { "content": "class Player;\n", "file_path": "src/game/Object/AuctionHouseMgr.h", "rank": 45, "score": 202799.75166851713 }, { "content": "class MANGOS_DLL_SPEC RandomPlayerbotFactory\n\n{\n\n public:\n\n RandomPlayerbotFactory(uint32 accountId);\n\n\t\tvirtual ~RandomPlayerbotFactory() {}\n\n\n\n\tpublic:\n\n bool CreateRandomBot(uint8 cls);\n\n\n\n\tprivate:\n\n string CreateRandomBotName();\n\n\n\n private:\n\n uint32 accountId;\n\n static map<uint8, vector<uint8> > availableRaces;\n\n};\n\n\n\n#endif\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotFactory.h", "rank": 46, "score": 199406.1984741086 }, { "content": "class Player : public Unit\n\n{\n\n friend class WorldSession;\n\n friend void Item::AddToUpdateQueueOf(Player* player);\n\n friend void Item::RemoveFromUpdateQueueOf(Player* player);\n\n public:\n\n explicit Player(WorldSession* session);\n\n ~Player();\n\n\n\n time_t lastTimeLooted;\n\n\n\n void CleanupsBeforeDelete() override;\n\n\n\n static UpdateMask updateVisualBits;\n\n static void InitVisibleBits();\n\n\n\n void AddToWorld() override;\n\n void RemoveFromWorld() override;\n\n\n\n bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0, bool allowNoDelay = false);\n", "file_path": "src/game/Object/Player.h", "rank": 47, "score": 198911.710733575 }, { "content": "class Player;\n", "file_path": "src/game/OutdoorPvP/OutdoorPvP.h", "rank": 48, "score": 196714.6874708881 }, { "content": "class Player;\n", "file_path": "src/game/WorldHandlers/MapPersistentStateMgr.h", "rank": 49, "score": 196714.6874708881 }, { "content": "class Player;\n", "file_path": "src/game/OutdoorPvP/OutdoorPvPMgr.h", "rank": 50, "score": 193909.96479860437 }, { "content": " class FindPlayerPredicate\n\n {\n\n public:\n\n virtual bool Check(Unit*) = 0;\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/values/PartyMemberValue.h", "rank": 51, "score": 191476.10410094503 }, { "content": " class EnemyPlayerValue : public TargetValue\n\n\t{\n\n\tpublic:\n\n EnemyPlayerValue(PlayerbotAI* ai) : TargetValue(ai) {}\n\n\n\n public:\n\n Unit* Calculate();\n\n };\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/EnemyPlayerValue.h", "rank": 52, "score": 188523.99181740294 }, { "content": " class Multiplier : public AiNamedObject\n\n {\n\n public:\n\n Multiplier(PlayerbotAI* ai, string name) : AiNamedObject(ai, name) {}\n\n virtual ~Multiplier() {}\n\n\n\n public:\n\n virtual float GetValue(Action* action) { return 1.0f; }\n\n };\n\n\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/Multiplier.h", "rank": 53, "score": 186936.0976101706 }, { "content": " class Trigger : public AiNamedObject\n\n\t{\n\n\tpublic:\n\n Trigger(PlayerbotAI* ai, string name = \"trigger\", int checkInterval = 1) : AiNamedObject(ai, name) {\n\n\t\t\tthis->checkInterval = checkInterval;\n\n\t\t\tticksElapsed = 0;\n\n }\n\n virtual ~Trigger() {}\n\n\n\n\tpublic:\n\n virtual Event Check();\n\n virtual void ExternalEvent(string param, Player* owner = NULL) {}\n\n virtual void ExternalEvent(WorldPacket &packet, Player* owner = NULL) {}\n\n virtual bool IsActive() { return false; }\n\n virtual NextAction** getHandlers() { return NULL; }\n\n void Update() {}\n\n virtual void Reset() {}\n\n virtual Unit* GetTarget();\n\n virtual Value<Unit*>* GetTargetValue();\n\n virtual string GetTargetName() { return \"self target\"; }\n", "file_path": "src/modules/Bots/playerbot/strategy/Trigger.h", "rank": 54, "score": 186936.0976101706 }, { "content": " class Action : public AiNamedObject\n\n\t{\n\n\tpublic:\n\n Action(PlayerbotAI* ai, string name = \"action\") : verbose(false), AiNamedObject(ai, name) { }\n\n virtual ~Action(void) {}\n\n\n\n public:\n\n virtual bool Execute(Event event) { return true; }\n\n virtual bool isPossible() { return true; }\n\n virtual bool isUseful() { return true; }\n\n virtual NextAction** getPrerequisites() { return NULL; }\n\n virtual NextAction** getAlternatives() { return NULL; }\n\n virtual NextAction** getContinuers() { return NULL; }\n\n virtual ActionThreatType getThreatType() { return ACTION_THREAT_NONE; }\n\n void Update() {}\n\n void Reset() {}\n\n virtual Unit* GetTarget();\n\n virtual Value<Unit*>* GetTargetValue();\n\n virtual string GetTargetName() { return \"self target\"; }\n\n void MakeVerbose() { verbose = true; }\n\n\n\n protected:\n\n bool verbose;\n\n\t};\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/Action.h", "rank": 55, "score": 186936.0976101706 }, { "content": " class MoveRandomStrategy : public NonCombatStrategy\n\n {\n\n public:\n\n MoveRandomStrategy(PlayerbotAI* ai) : NonCombatStrategy(ai) {}\n\n virtual string getName() { return \"move random\"; }\n\n\n\n public:\n\n virtual void InitTriggers(std::list<TriggerNode*> &triggers);\n\n };\n\n\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/generic/MoveRandomStrategy.h", "rank": 56, "score": 186013.94362523 }, { "content": " class CreatePolicy = MaNGOS::OperatorNew<T>,\n", "file_path": "src/framework/Policies/Singleton.h", "rank": 57, "score": 184883.93453024732 }, { "content": "\tclass PartyMemberActionNameSupport {\n\n\tpublic:\n\n\t\tPartyMemberActionNameSupport(string spell)\n\n\t\t{\n\n\t\t\tname = string(spell) + \" on party\";\n\n\t\t}\n\n\n\n\t\tvirtual string getName() { return name; }\n\n\n\n\tprivate:\n\n\t\tstring name;\n\n\t};\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h", "rank": 58, "score": 184835.9703205775 }, { "content": " class RandomTrigger : public Trigger\n\n {\n\n public:\n\n RandomTrigger(PlayerbotAI* ai, int probability = 200) : Trigger(ai)\n\n {\n\n this->probability = probability;\n\n }\n\n public:\n\n virtual bool IsActive();\n\n virtual string getName() { return \"random\"; }\n\n\n\n protected:\n\n int probability;\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/triggers/GenericTriggers.h", "rank": 59, "score": 183155.0931837348 }, { "content": " class UntypedValue : public AiNamedObject\n\n {\n\n public:\n\n UntypedValue(PlayerbotAI* ai, string name) : AiNamedObject(ai, name) {}\n\n virtual void Update() {}\n\n virtual void Reset() {}\n\n virtual string Format() { return \"?\"; }\n\n };\n\n\n\n template<class T>\n", "file_path": "src/modules/Bots/playerbot/strategy/Value.h", "rank": 60, "score": 183141.70896203927 }, { "content": "class MANGOS_DLL_SPEC RandomPlayerbotMgr : public PlayerbotHolder\n\n{\n\n public:\n\n RandomPlayerbotMgr();\n\n virtual ~RandomPlayerbotMgr();\n\n\n\n virtual void UpdateAIInternal(uint32 elapsed);\n\n\n\n\tpublic:\n\n bool IsRandomBot(Player* bot);\n\n bool IsRandomBot(uint32 bot);\n\n void Randomize(Player* bot);\n\n void RandomizeFirst(Player* bot);\n\n void IncreaseLevel(Player* bot);\n\n void ScheduleTeleport(uint32 bot);\n\n void HandleCommand(uint32 type, const string& text, Player& fromPlayer);\n\n void OnPlayerLogout(Player* player);\n\n void OnPlayerLogin(Player* player);\n\n Player* GetRandomPlayer();\n\n void PrintStats();\n", "file_path": "src/modules/Bots/playerbot/RandomPlayerbotMgr.h", "rank": 61, "score": 182866.029369449 }, { "content": "class FindDeadPlayer : public FindPlayerPredicate\n\n{\n\npublic:\n\n FindDeadPlayer(PartyMemberValue* value) : value(value) {}\n\n\n\n virtual bool Check(Unit* unit)\n\n {\n\n Player* player = dynamic_cast<Player*>(unit);\n\n return player && player->GetDeathState() == CORPSE && !value->IsTargetOfSpellCast(player, predicate);\n\n }\n\n\n\nprivate:\n\n PartyMemberValue* value;\n\n IsTargetOfResurrectSpell predicate;\n\n};\n\n\n\nUnit* PartyMemberToResurrect::Calculate()\n\n{\n\n\tFindDeadPlayer finder(this);\n\n return FindPartyMember(finder);\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/PartyMemberToResurrect.cpp", "rank": 62, "score": 182575.65027046605 }, { "content": " class FollowMasterRandomStrategy : public NonCombatStrategy\n\n {\n\n public:\n\n FollowMasterRandomStrategy(PlayerbotAI* ai) : NonCombatStrategy(ai) {}\n\n virtual string getName() { return \"be near\"; }\n\n virtual void InitTriggers(std::list<TriggerNode*> &triggers);\n\n\n\n };\n\n}", "file_path": "src/modules/Bots/playerbot/strategy/generic/FollowMasterRandomStrategy.h", "rank": 63, "score": 180283.58163889364 }, { "content": "class FindEnemyPlayerStrategy : public FindTargetStrategy\n\n{\n\npublic:\n\n FindEnemyPlayerStrategy(PlayerbotAI* ai) : FindTargetStrategy(ai)\n\n {\n\n }\n\n\n\npublic:\n\n virtual void CheckAttacker(Unit* attacker, ThreatManager* threatManager)\n\n {\n\n if (!result)\n\n {\n\n Player* enemy = dynamic_cast<Player*>(attacker);\n\n if (enemy && ai->IsOpposing(enemy) && enemy->IsPvP())\n\n result = attacker;\n\n }\n\n }\n\n\n\n};\n\n\n\n\n\nUnit* EnemyPlayerValue::Calculate()\n\n{\n\n FindEnemyPlayerStrategy strategy(ai);\n\n return FindTarget(&strategy);\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/EnemyPlayerValue.cpp", "rank": 64, "score": 179774.82392969856 }, { "content": " class AttackEnemyPlayersStrategy : public NonCombatStrategy\n\n {\n\n public:\n\n AttackEnemyPlayersStrategy(PlayerbotAI* ai) : NonCombatStrategy(ai) {}\n\n virtual string getName() { return \"pvp\"; }\n\n\n\n public:\n\n virtual void InitTriggers(std::list<TriggerNode*> &triggers);\n\n };\n\n\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/generic/AttackEnemyPlayersStrategy.h", "rank": 65, "score": 179774.82392969856 }, { "content": " class IsNotFacingTargetTrigger : public Trigger\n\n {\n\n public:\n\n IsNotFacingTargetTrigger(PlayerbotAI* ai) : Trigger(ai) {}\n\n\n\n public:\n\n virtual bool IsActive();\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/triggers/GenericTriggers.h", "rank": 66, "score": 179572.4076434967 }, { "content": " class SeldomTrigger : public RandomTrigger\n\n {\n\n public:\n\n SeldomTrigger(PlayerbotAI* ai) : RandomTrigger(ai, 9000) {}\n\n virtual string getName() { return \"seldom\"; }\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/triggers/GenericTriggers.h", "rank": 67, "score": 179543.76473110326 }, { "content": " class OftenTrigger : public RandomTrigger\n\n {\n\n public:\n\n OftenTrigger(PlayerbotAI* ai) : RandomTrigger(ai, 50) {}\n\n virtual string getName() { return \"often\"; }\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/triggers/GenericTriggers.h", "rank": 68, "score": 179543.76473110326 }, { "content": " class AiNamedObject : public AiObject\n\n {\n\n public:\n\n AiNamedObject(PlayerbotAI* ai, string name) : AiObject(ai), name(name) {}\n\n\n\n public:\n\n virtual string getName() { return name; }\n\n\n\n protected:\n\n string name;\n\n };\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/AiObject.h", "rank": 69, "score": 179530.7039405771 }, { "content": " class EnemyPlayerIsAttacking : public Trigger\n\n {\n\n public:\n\n EnemyPlayerIsAttacking(PlayerbotAI* ai) : Trigger(ai, \"enemy player is attacking\") {}\n\n\n\n public:\n\n virtual bool IsActive();\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/triggers/GenericTriggers.h", "rank": 70, "score": 179129.17383038567 }, { "content": " class MoveRandomAction : public MovementAction\n\n {\n\n public:\n\n MoveRandomAction(PlayerbotAI* ai) : MovementAction(ai, \"move random\") {}\n\n virtual bool Execute(Event event);\n\n virtual bool isPossible()\n\n {\n\n return MovementAction::isPossible() &&\n\n AI_VALUE2(uint8, \"health\", \"self target\") > sPlayerbotAIConfig.mediumHealth &&\n\n (!AI_VALUE2(uint8, \"mana\", \"self target\") || AI_VALUE2(uint8, \"mana\", \"self target\") > sPlayerbotAIConfig.mediumMana);\n\n }\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/actions/MovementActions.h", "rank": 71, "score": 176102.85439392366 }, { "content": " class AhBot\n\n {\n\n public:\n\n AhBot() : nextAICheckTime(0), updating(false) {}\n\n virtual ~AhBot();\n\n\n\n public:\n\n ObjectGuid GetAHBplayerGUID();\n\n void Init();\n\n void Update();\n\n void ForceUpdate();\n\n void HandleCommand(string command);\n\n void Won(AuctionEntry* entry) { AddToHistory(entry); }\n\n void Expired(AuctionEntry* entry) {}\n\n\n\n double GetCategoryMultiplier(string category)\n\n {\n\n return categoryMultipliers[category];\n\n }\n\n\n", "file_path": "src/modules/Bots/ahbot/AhBot.h", "rank": 72, "score": 173814.2229406077 }, { "content": "class PlayerSocial;\n", "file_path": "src/game/Object/Player.h", "rank": 73, "score": 173590.47189854214 }, { "content": "class PlayerMenu;\n", "file_path": "src/game/Object/Player.h", "rank": 74, "score": 173590.47189854214 }, { "content": "class PlayerTaxi\n\n{\n\n public:\n\n PlayerTaxi();\n\n ~PlayerTaxi() {}\n\n // Nodes\n\n void InitTaxiNodes(uint32 race, uint32 level);\n\n void LoadTaxiMask(const char* data);\n\n\n\n bool IsTaximaskNodeKnown(uint32 nodeidx) const\n\n {\n\n uint8 field = uint8((nodeidx - 1) / 32);\n\n uint32 submask = 1 << ((nodeidx - 1) % 32);\n\n return (m_taximask[field] & submask) == submask;\n\n }\n\n bool SetTaximaskNode(uint32 nodeidx)\n\n {\n\n uint8 field = uint8((nodeidx - 1) / 32);\n\n uint32 submask = 1 << ((nodeidx - 1) % 32);\n\n if ((m_taximask[field] & submask) != submask)\n", "file_path": "src/game/Object/Player.h", "rank": 75, "score": 173590.47189854214 }, { "content": " class StrategyContext : public NamedObjectContext<Strategy>\n\n {\n\n public:\n\n StrategyContext()\n\n {\n\n creators[\"racials\"] = &StrategyContext::racials;\n\n creators[\"loot\"] = &StrategyContext::loot;\n\n creators[\"gather\"] = &StrategyContext::gather;\n\n creators[\"emote\"] = &StrategyContext::emote;\n\n creators[\"passive\"] = &StrategyContext::passive;\n\n creators[\"conserve mana\"] = &StrategyContext::conserve_mana;\n\n creators[\"food\"] = &StrategyContext::food;\n\n creators[\"chat\"] = &StrategyContext::chat;\n\n creators[\"default\"] = &StrategyContext::world_packet;\n\n creators[\"ready check\"] = &StrategyContext::ready_check;\n\n creators[\"dead\"] = &StrategyContext::dead;\n\n creators[\"flee\"] = &StrategyContext::flee;\n\n creators[\"duel\"] = &StrategyContext::duel;\n\n creators[\"kite\"] = &StrategyContext::kite;\n\n creators[\"potions\"] = &StrategyContext::potions;\n", "file_path": "src/modules/Bots/playerbot/strategy/StrategyContext.h", "rank": 76, "score": 172942.18751611136 }, { "content": " class SetFacingTargetAction : public MovementAction\n\n {\n\n public:\n\n SetFacingTargetAction(PlayerbotAI* ai) : MovementAction(ai, \"set facing\") {}\n\n virtual bool Execute(Event event);\n\n virtual bool isUseful();\n\n };\n\n\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/actions/MovementActions.h", "rank": 77, "score": 172847.8996387155 }, { "content": " class BagSpaceValue : public Uint8CalculatedValue\n\n {\n\n public:\n\n BagSpaceValue(PlayerbotAI* ai) : Uint8CalculatedValue(ai) {}\n\n\n\n virtual uint8 Calculate();\n\n };\n\n\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/StatsValues.h", "rank": 78, "score": 172845.40786208498 }, { "content": " class FollowMasterRandomAction : public MovementAction {\n\n public:\n\n FollowMasterRandomAction(PlayerbotAI* ai) : MovementAction(ai, \"be near\") {}\n\n virtual bool Execute(Event event);\n\n };\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/actions/FollowActions.h", "rank": 79, "score": 172820.57722452813 }, { "content": "/// Player session in the World\n\nclass WorldSession\n\n{\n\n friend class CharacterHandler;\n\n\n\n public:\n\n WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, time_t mute_time, LocaleConstant locale);\n\n ~WorldSession();\n\n\n\n bool PlayerLoading() const\n\n {\n\n return m_playerLoading;\n\n }\n\n bool PlayerLogout() const\n\n {\n\n return m_playerLogout;\n\n }\n\n bool PlayerLogoutWithSave() const\n\n {\n\n return m_playerLogout && m_playerSave;\n\n }\n", "file_path": "src/game/Server/WorldSession.h", "rank": 80, "score": 171263.15753137326 }, { "content": "class WorldSession;\n\n\n", "file_path": "src/game/Server/WorldSession.h", "rank": 81, "score": 171249.29668262386 }, { "content": "class PlayerDump\n\n{\n\n protected:\n\n PlayerDump() {}\n\n};\n\n\n", "file_path": "src/game/Tools/PlayerDump.h", "rank": 82, "score": 170651.44041709113 }, { "content": "class PlayerLogger\n\n{\n\npublic:\n\n PlayerLogger(ObjectGuid);\n\n ~PlayerLogger();\n\n\n\n static inline PlayerLogMask CalcLogMask(PlayerLogEntity entity) { return PlayerLogMask(1 << entity); }\n\n\n\n // active logs check\n\n bool IsLoggingActive(PlayerLogMask mask) const { return (mask & logActiveMask) != 0; }\n\n bool IsLoggingActive(PlayerLogEntity entity) const { return IsLoggingActive(CalcLogMask(entity)); }\n\n\n\n // check active loggers and init missing ones\n\n void Initialize(PlayerLogEntity, uint32 maxLength = 0);\n\n\n\n // remove entries of type PlayerLogEntity\n\n void Clean(PlayerLogMask);\n\n\n\n // save to DB entries\n\n bool SaveToDB(PlayerLogMask, bool removeSaved = true, bool insideTransaction = false);\n", "file_path": "src/game/Object/PlayerLogger.h", "rank": 83, "score": 170651.44041709113 }, { "content": " class HasAvailableLootValue : public BoolCalculatedValue\n\n\t{\n\n\tpublic:\n\n HasAvailableLootValue(PlayerbotAI* ai) : BoolCalculatedValue(ai) {}\n\n\n\n public:\n\n virtual bool Calculate()\n\n {\n\n return !AI_VALUE(bool, \"can loot\") &&\n\n AI_VALUE(LootObjectStack*, \"available loot\")->CanLoot(sPlayerbotAIConfig.lootDistance) &&\n\n !bot->IsMounted();\n\n }\n\n };\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/HasAvailableLootValue.h", "rank": 84, "score": 169708.0568253476 }, { "content": " class CanLootValue : public BoolCalculatedValue\n\n {\n\n public:\n\n CanLootValue(PlayerbotAI* ai) : BoolCalculatedValue(ai) {}\n\n\n\n virtual bool Calculate()\n\n {\n\n LootObject loot = AI_VALUE(LootObject, \"loot target\");\n\n return !loot.IsEmpty() && loot.GetWorldObject(bot) && AI_VALUE2(float, \"distance\", \"loot target\") <= INTERACTION_DISTANCE;\n\n }\n\n };\n\n}\n", "file_path": "src/modules/Bots/playerbot/strategy/values/AvailableLootValue.h", "rank": 85, "score": 169708.0568253476 }, { "content": " class ActionContext : public NamedObjectContext<Action>\n\n {\n\n public:\n\n ActionContext()\n\n {\n\n creators[\"attack\"] = &ActionContext::melee;\n\n creators[\"melee\"] = &ActionContext::melee;\n\n creators[\"reach spell\"] = &ActionContext::ReachSpell;\n\n creators[\"reach melee\"] = &ActionContext::ReachMelee;\n\n creators[\"flee\"] = &ActionContext::flee;\n\n creators[\"gift of the naaru\"] = &ActionContext::gift_of_the_naaru;\n\n creators[\"shoot\"] = &ActionContext::shoot;\n\n creators[\"lifeblood\"] = &ActionContext::lifeblood;\n\n creators[\"arcane torrent\"] = &ActionContext::arcane_torrent;\n\n creators[\"end pull\"] = &ActionContext::end_pull;\n\n creators[\"healthstone\"] = &ActionContext::healthstone;\n\n creators[\"healing potion\"] = &ActionContext::healing_potion;\n\n creators[\"mana potion\"] = &ActionContext::mana_potion;\n\n creators[\"food\"] = &ActionContext::food;\n\n creators[\"drink\"] = &ActionContext::drink;\n", "file_path": "src/modules/Bots/playerbot/strategy/actions/ActionContext.h", "rank": 86, "score": 169660.20430799815 }, { "content": " class AssistStrategyContext : public NamedObjectContext<Strategy>\n\n {\n\n public:\n\n AssistStrategyContext() : NamedObjectContext<Strategy>(false, true)\n\n {\n\n creators[\"dps assist\"] = &AssistStrategyContext::dps_assist;\n\n creators[\"dps aoe\"] = &AssistStrategyContext::dps_aoe;\n\n creators[\"tank assist\"] = &AssistStrategyContext::tank_assist;\n\n creators[\"tank aoe\"] = &AssistStrategyContext::tank_aoe;\n\n creators[\"attack weak\"] = &AssistStrategyContext::attack_weak;\n\n creators[\"grind\"] = &AssistStrategyContext::grind;\n\n creators[\"attack rti\"] = &AssistStrategyContext::attack_rti;\n\n }\n\n\n\n private:\n\n static Strategy* dps_assist(PlayerbotAI* ai) { return new DpsAssistStrategy(ai); }\n\n static Strategy* dps_aoe(PlayerbotAI* ai) { return new DpsAoeStrategy(ai); }\n\n static Strategy* tank_assist(PlayerbotAI* ai) { return new TankAssistStrategy(ai); }\n\n static Strategy* tank_aoe(PlayerbotAI* ai) { return new TankAoeStrategy(ai); }\n\n static Strategy* attack_weak(PlayerbotAI* ai) { return new AttackWeakStrategy(ai); }\n\n static Strategy* grind(PlayerbotAI* ai) { return new GrindingStrategy(ai); }\n\n static Strategy* attack_rti(PlayerbotAI* ai) { return new AttackRtiStrategy(ai); }\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/StrategyContext.h", "rank": 87, "score": 169660.20430799815 }, { "content": " class MovementStrategyContext : public NamedObjectContext<Strategy>\n\n {\n\n public:\n\n MovementStrategyContext() : NamedObjectContext<Strategy>(false, true)\n\n {\n\n creators[\"follow master\"] = &MovementStrategyContext::follow_master;\n\n creators[\"be near\"] = &MovementStrategyContext::follow_master_random;\n\n creators[\"follow line\"] = &MovementStrategyContext::follow_line;\n\n creators[\"stay\"] = &MovementStrategyContext::stay;\n\n creators[\"runaway\"] = &MovementStrategyContext::runaway;\n\n creators[\"flee from adds\"] = &MovementStrategyContext::flee_from_adds;\n\n creators[\"stay circle\"] = &MovementStrategyContext::stay_circle;\n\n creators[\"stay combat\"] = &MovementStrategyContext::stay_combat;\n\n creators[\"stay line\"] = &MovementStrategyContext::stay_line;\n\n creators[\"guard\"] = &MovementStrategyContext::guard;\n\n creators[\"move random\"] = &MovementStrategyContext::move_random;\n\n }\n\n\n\n private:\n\n static Strategy* move_random(PlayerbotAI* ai) { return new MoveRandomStrategy(ai); }\n", "file_path": "src/modules/Bots/playerbot/strategy/StrategyContext.h", "rank": 88, "score": 169660.20430799815 }, { "content": " class QuestStrategyContext : public NamedObjectContext<Strategy>\n\n {\n\n public:\n\n QuestStrategyContext() : NamedObjectContext<Strategy>(false, true)\n\n {\n\n creators[\"quest\"] = &QuestStrategyContext::quest;\n\n creators[\"accept all quests\"] = &QuestStrategyContext::accept_all_quests;\n\n }\n\n\n\n private:\n\n static Strategy* quest(PlayerbotAI* ai) { return new DefaultQuestStrategy(ai); }\n\n static Strategy* accept_all_quests(PlayerbotAI* ai) { return new AcceptAllQuestsStrategy(ai); }\n\n };\n\n};\n", "file_path": "src/modules/Bots/playerbot/strategy/StrategyContext.h", "rank": 89, "score": 169660.20430799815 }, { "content": " class TriggerContext : public NamedObjectContext<Trigger>\n\n {\n\n public:\n\n TriggerContext()\n\n {\n\n creators[\"timer\"] = &TriggerContext::Timer;\n\n creators[\"random\"] = &TriggerContext::Random;\n\n creators[\"seldom\"] = &TriggerContext::seldom;\n\n creators[\"often\"] = &TriggerContext::often;\n\n\n\n creators[\"target critical health\"] = &TriggerContext::TargetCriticalHealth;\n\n\n\n creators[\"critical health\"] = &TriggerContext::CriticalHealth;\n\n creators[\"low health\"] = &TriggerContext::LowHealth;\n\n creators[\"medium health\"] = &TriggerContext::MediumHealth;\n\n creators[\"almost full health\"] = &TriggerContext::AlmostFullHealth;\n\n\n\n creators[\"low mana\"] = &TriggerContext::LowMana;\n\n creators[\"medium mana\"] = &TriggerContext::MediumMana;\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/triggers/TriggerContext.h", "rank": 90, "score": 169660.20430799815 }, { "content": " class AttackEnemyPlayerAction : public AttackAction\n\n {\n\n public:\n\n AttackEnemyPlayerAction(PlayerbotAI* ai) : AttackAction(ai, \"attack enemy player\") {}\n\n virtual string GetTargetName() { return \"enemy player target\"; }\n\n };\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/actions/ChooseTargetActions.h", "rank": 91, "score": 169299.64378609805 }, { "content": "class AhBotConfig\n\n{\n\npublic:\n\n AhBotConfig();\n\n\n\npublic:\n\n bool Initialize();\n\n\n\n bool enabled;\n\n uint64 guid;\n\n uint32 updateInterval;\n\n uint32 historyDays, maxSellInterval;\n\n uint32 itemBuyMinInterval, itemBuyMaxInterval;\n\n uint32 itemSellMinInterval, itemSellMaxInterval;\n\n uint32 alwaysAvailableMoney;\n\n float priceMultiplier, priceQualityMultiplier;\n\n uint32 defaultMinPrice;\n\n uint32 maxItemLevel, maxRequiredLevel;\n\n float underPriceProbability;\n\n std::set<uint32> ignoreItemIds;\n", "file_path": "src/modules/Bots/ahbot/AhBotConfig.h", "rank": 92, "score": 169046.4797632601 }, { "content": "class AccountMgr\n\n{\n\n public:\n\n AccountMgr();\n\n ~AccountMgr();\n\n\n\n AccountOpResult CreateAccount(std::string username, std::string password);\n\n AccountOpResult DeleteAccount(uint32 accid);\n\n AccountOpResult ChangeUsername(uint32 accid, std::string new_uname, std::string new_passwd);\n\n AccountOpResult ChangePassword(uint32 accid, std::string new_passwd);\n\n bool CheckPassword(uint32 accid, std::string passwd);\n\n\n\n uint32 GetId(std::string username);\n\n AccountTypes GetSecurity(uint32 acc_id);\n\n bool GetName(uint32 acc_id, std::string& name);\n\n uint32 GetCharactersCount(uint32 acc_id);\n\n std::string CalculateShaPassHash(std::string& name, std::string& password);\n\n\n\n static bool normalizeString(std::string& utf8str);\n\n};\n\n\n\n#define sAccountMgr MaNGOS::Singleton<AccountMgr>::Instance()\n\n#endif\n", "file_path": "src/game/WorldHandlers/AccountMgr.h", "rank": 93, "score": 168480.94981660528 }, { "content": "class AuctionBotAgent\n\n{\n\n public:\n\n /**\n\n * @brief\n\n *\n\n */\n\n AuctionBotAgent() {}\n\n /**\n\n * @brief\n\n *\n\n */\n\n virtual ~AuctionBotAgent() {}\n\n public:\n\n /**\n\n * @brief Initializes this agent/bot and makes sure that there's anything to actually do for it.\n\n * If there's not it will return false and there's really no interest in keeping it for\n\n * the moment, otherwise returns true and has atleast one active house where it will do\n\n * business.\n\n *\n", "file_path": "src/game/AuctionHouseBot/AuctionHouseBot.h", "rank": 94, "score": 166806.95188303757 }, { "content": "class AuctionBotConfig\n\n{\n\n public:\n\n /**\n\n * @brief\n\n *\n\n */\n\n AuctionBotConfig();\n\n\n\n /**\n\n * @brief\n\n *\n\n * @param filename\n\n */\n\n void SetConfigFileName(char const* filename) { m_configFileName = filename; }\n\n /**\n\n * @brief\n\n *\n\n * @return bool\n\n */\n", "file_path": "src/game/AuctionHouseBot/AuctionHouseBot.h", "rank": 95, "score": 166806.95188303757 }, { "content": "class AuctionHouseBot\n\n{\n\n public:\n\n /**\n\n * @brief Initializes a new instance of the \\ref AuctionHouseBot class.\n\n *\n\n */\n\n AuctionHouseBot();\n\n /**\n\n * @brief Finalizes an instance of the \\ref AuctionHouseBot class.\n\n *\n\n */\n\n ~AuctionHouseBot();\n\n\n\n /**\n\n * @brief Updates the \\ref AuctionHouseBot by checking if either the \\ref AuctionBotSeller or\n\n * \\ref AuctionBotBuyer wants to sell/buy anything and in that case lets one of them do\n\n * that and the other one will have to wait until the next call to \\ref AuctionHouseBot::Update\n\n *\n\n */\n", "file_path": "src/game/AuctionHouseBot/AuctionHouseBot.h", "rank": 96, "score": 166806.95188303757 }, { "content": "\tclass CastDemonSkinAction : public CastBuffSpellAction {\n\n\tpublic:\n\n\t\tCastDemonSkinAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, \"demon skin\") {}\n\n\t};\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/warlock/WarlockActions.h", "rank": 97, "score": 166717.34879421548 }, { "content": "\tclass CastCreateHealthstoneAction : public CastBuffSpellAction\n\n\t{\n\n\tpublic:\n\n\t\tCastCreateHealthstoneAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, \"create healthstone\") {}\n\n\t};\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/warlock/WarlockActions.h", "rank": 98, "score": 166714.30613636994 }, { "content": "\tclass CastCreateFirestoneAction : public CastBuffSpellAction\n\n\t{\n\n\tpublic:\n\n\t\tCastCreateFirestoneAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, \"create firestone\") {}\n\n\t};\n\n\n", "file_path": "src/modules/Bots/playerbot/strategy/warlock/WarlockActions.h", "rank": 99, "score": 166714.30613636994 } ]
C++
examples/FloodPedestrian_2019/Flood_XML_inpGen/XML_inpGen/xmlGen.cpp
SahebSh/FLAMEGPU
c81323b68532a52756b96dbf55fd29416e642cc9
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <algorithm> double bed_data(double x_int, double y_int); #define SIZE 128 #define xmin 0 #define xmax 15 #define ymin 0 #define ymax 15 #define OFF 0 #define ON 1 int main() { FILE *fp = fopen("flood_init.xml", "w"); if (fp == NULL) { printf("Error opening file!\n"); exit(1); } int inDomain = 1; double dt_ped = 0.0f; double dt_flood = 0.0f; int auto_dt_on = OFF; int body_effect_on = OFF; int evacuation_on = OFF; int sandbagging_on = OFF; int pedestrians_population = 1000; float hero_percentage = 0.5; double FLOOD_START_TIME = 200; double DISCHARGE_PEAK_TIME = 400; double FLOOD_END_TIME = 600; double evacuation_start_time = 400; double sandbagging_start_time = 400; double sandbagging_end_time = 4200; double pickup_duration = 30; double drop_duration = 30; double DISCHARGE_INITIAL = 0.0f; double DISCHARGE_PEAK = 1.3f; double DISCHARGE_END = 0.0f; int INFLOW_BOUNDARY = 3; int BOUNDARY_EAST_STATUS = 2; int BOUNDARY_WEST_STATUS = 2; int BOUNDARY_NORTH_STATUS = 1; int BOUNDARY_SOUTH_STATUS = 2; double x1_boundary = 110; double x2_boundary = 190; double y1_boundary = 40; double y2_boundary = 120; double init_depth_boundary = 0.1; float sandbag_length = 0.50f; float sandbag_height = 0.10f; float sandbag_width = 0.25f; float dike_length = 120.0f; float dike_height = 0.5f; float dike_width = 3.0f; int evacuation_exit_number = 6; int pickup_point = 5; int drop_point = 7; double lx, ly; double dx, dy; int i, j; auto z0_int = new double[SIZE + 1][SIZE + 1](); auto x_int = new double[SIZE + 1](); auto y_int = new double[SIZE + 1](); auto z0 = new double[SIZE][SIZE](); auto x = new double[SIZE](); auto y = new double[SIZE](); double qx_initial = 0.0; double qy_initial = 0.0; lx = xmax - xmin; ly = ymax - ymin; dx = (double)lx / (double)SIZE; dy = (double)ly / (double)SIZE; FILE *fp2 = fopen("init_topo.txt", "w"); if (fp2 == NULL){ printf("Error opening file!\n"); exit(1); } fprintf(fp, "<states>\n"); fprintf(fp, "<itno>0</itno>\n"); fprintf(fp, " <environment>\n\n"); fprintf(fp, " <xmin>%d</xmin>\n", xmin); fprintf(fp, " <xmax>%d</xmax>\n", xmax); fprintf(fp, " <ymin>%d</ymin>\n", ymin); fprintf(fp, " <ymax>%d</ymax>\n\n", ymax); fprintf(fp, " <dt_ped>%f</dt_ped>\n", dt_ped); fprintf(fp, " <dt_flood>%f</dt_flood>\n\n", dt_flood); fprintf(fp, " <auto_dt_on>%d</auto_dt_on>\n", auto_dt_on); fprintf(fp, " <body_effect_on>%d</body_effect_on>\n", body_effect_on); fprintf(fp, " <evacuation_on>%d</evacuation_on>\n", evacuation_on); fprintf(fp, " <sandbagging_on>%d</sandbagging_on>\n\n", sandbagging_on); fprintf(fp, " <pedestrians_population>%d</pedestrians_population>\n", pedestrians_population); fprintf(fp, " <hero_percentage>%f</hero_percentage>\n\n", hero_percentage); fprintf(fp, " <FLOOD_START_TIME>%f</FLOOD_START_TIME>\n", FLOOD_START_TIME); fprintf(fp, " <DISCHARGE_PEAK_TIME>%f</DISCHARGE_PEAK_TIME>\n", DISCHARGE_PEAK_TIME); fprintf(fp, " <FLOOD_END_TIME>%f</FLOOD_END_TIME>\n", FLOOD_END_TIME); fprintf(fp, " <evacuation_start_time>%f</evacuation_start_time>\n", evacuation_start_time); fprintf(fp, " <sandbagging_start_time>%f</sandbagging_start_time>\n", sandbagging_start_time); fprintf(fp, " <sandbagging_end_time>%f</sandbagging_end_time>\n", sandbagging_end_time); fprintf(fp, " <pickup_duration>%f</pickup_duration>\n", pickup_duration); fprintf(fp, " <drop_duration>%f</drop_duration>\n\n", drop_duration); fprintf(fp, " <DISCHARGE_INITIAL>%f</DISCHARGE_INITIAL>\n", DISCHARGE_INITIAL); fprintf(fp, " <DISCHARGE_PEAK>%f</DISCHARGE_PEAK>\n", DISCHARGE_PEAK); fprintf(fp, " <DISCHARGE_END>%f</DISCHARGE_END>\n\n", DISCHARGE_END); fprintf(fp, " <INFLOW_BOUNDARY>%d</INFLOW_BOUNDARY>\n", INFLOW_BOUNDARY); fprintf(fp, " <BOUNDARY_EAST_STATUS>%d</BOUNDARY_EAST_STATUS>\n", BOUNDARY_EAST_STATUS); fprintf(fp, " <BOUNDARY_WEST_STATUS>%d</BOUNDARY_WEST_STATUS>\n", BOUNDARY_WEST_STATUS); fprintf(fp, " <BOUNDARY_NORTH_STATUS>%d</BOUNDARY_NORTH_STATUS>\n", BOUNDARY_NORTH_STATUS); fprintf(fp, " <BOUNDARY_SOUTH_STATUS>%d</BOUNDARY_SOUTH_STATUS>\n\n", BOUNDARY_SOUTH_STATUS); fprintf(fp, " <x1_boundary>%f</x1_boundary>\n", x1_boundary); fprintf(fp, " <x2_boundary>%f</x2_boundary>\n", x2_boundary); fprintf(fp, " <y1_boundary>%f</y1_boundary>\n", y1_boundary); fprintf(fp, " <y2_boundary>%f</y2_boundary>\n\n", y2_boundary); fprintf(fp, " <init_depth_boundary>%f</init_depth_boundary>\n\n", init_depth_boundary); fprintf(fp, " <sandbag_length>%f</sandbag_length>\n", sandbag_length); fprintf(fp, " <sandbag_height>%f</sandbag_height>\n", sandbag_height); fprintf(fp, " <sandbag_width>%f</sandbag_width>\n", sandbag_width); fprintf(fp, " <dike_length>%f</dike_length>\n", dike_length); fprintf(fp, " <dike_height>%f</dike_height>\n", dike_height); fprintf(fp, " <dike_width>%f</dike_width>\n\n", dike_width); fprintf(fp, " <evacuation_exit_number>%d</evacuation_exit_number>\n\n", evacuation_exit_number); fprintf(fp, " <pickup_point>%d</pickup_point>\n", pickup_point); fprintf(fp, " <drop_point>%d</drop_point>\n\n", drop_point); fprintf(fp, " </environment>\n\n"); for (i = 0; i < SIZE + 1; i++){ for (j = 0; j < SIZE + 1; j++){ x_int[i] = xmin + i * dx; y_int[j] = ymin + j * dy; z0_int[i][j] = bed_data((double)x_int[i], (double)y_int[j]); } } for (i = 0; i < SIZE; i++) for (j = 0; j< SIZE; j++) { { x[i] = 0.5 * (x_int[i] + x_int[i + 1]); y[j] = 0.5 * (y_int[j] + y_int[j + 1]); z0[i][j] = (z0_int[i][j] + z0_int[i + 1][j] + z0_int[i][j + 1] + z0_int[i + 1][j + 1]) / 4; fprintf(fp2, "%d\t\t %d\t\t %f \n", i, j, z0[i][j]); fprintf(fp, " <xagent>\n"); fprintf(fp, "\t<name>FloodCell</name>\n"); fprintf(fp, "\t<inDomain>%d</inDomain>\n", inDomain); fprintf(fp, "\t<x>%d</x>\n", i); fprintf(fp, "\t<y>%d</y>\n", j); fprintf(fp, "\t<z0>%f</z0>\n", z0[i][j]); fprintf(fp, " </xagent>\n"); } } fprintf(fp, "</states>"); fclose(fp); return 0; } double bed_data(double x_int, double y_int) { double zz; double flume_length = 1; double x1 = (xmax - flume_length) / 2 ; double x2 = (xmax + flume_length) / 2 ; if ((x_int <= x1) || (x_int >= x2)) zz = 10; else zz = 0; return zz; }
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <algorithm> double bed_data(double x_int, double y_int); #define SIZE 128 #define xmin 0 #define xmax 15 #define ymin 0 #define ymax 15 #define OFF 0 #define ON 1 int main() { FILE *fp = fopen("flood_init.xml", "w"); if (fp == NULL) { printf("Error opening file!\n"); exit(1); } int inDomain = 1; double dt_ped = 0.0f; double dt_flood = 0.0f; int auto_dt_on = OFF; int body_effect_on = OFF; int evacuation_on = OFF; int sandbagging_on = OFF; int pedestrians_population = 1000; float hero_percentage = 0.5; double FLOOD_START_TIME = 200; double DISCHARGE_PEAK_TIME = 400; double FLOOD_END_TIME = 600; double evacuation_start_time = 400; double sandbagging_start_time = 400; double sandbagging_end_time = 4200; double pickup_duration = 30; double drop_duration = 30; double DISCHARGE_INITIAL = 0.0f; double DISCHARGE_PEAK = 1.3f; double DISCHARGE_END = 0.0f; int INFLOW_BOUNDARY = 3; int BOUNDARY_EAST_STATUS = 2; int BOUNDARY_WEST_STATUS = 2; int BOUNDARY_NORTH_STATUS = 1; int BOUNDARY_SOUTH_STATUS = 2; double x1_boundary = 110; double x2_boundary = 190; double y1_boundary = 40; double y2_boundary = 120; double init_depth_boundary = 0.1; float sandbag_length = 0.50f; float sandbag_height = 0.10f; float sandbag_width = 0.25f; float dike_length = 120.0f; float dike_height = 0.5f; float dike_width = 3.0f; int evacuation_exit_number = 6; int pickup_point = 5; int drop_point = 7; double lx, ly; double dx, dy; int i, j; auto z0_int = new double[SIZE + 1][SIZE + 1](); auto x_int = new double[SIZE + 1](); auto y_int = new double[SIZE + 1](); auto z0 = new double[SIZE][SIZE](); auto x = new double[SIZE](); auto y = new double[SIZE](); double qx_initial = 0.0; double qy_initial = 0.0; lx = xmax - xmin; ly = ymax - ymin; dx = (double)lx / (double)SIZE; dy = (double)ly / (double)SIZE; FILE *fp2 = fopen("init_topo.txt", "w"); if (fp2 == NULL){ printf("Error opening file!\n"); exit(1); } fprintf(fp, "<states>\n"); fprintf(fp, "<itno>0</itno>\n"); fprintf(fp, " <environment>\n\n"); fprintf(fp, " <xmin>%d</xmin>\n", xmin); fprintf(fp, " <xmax>%d</xmax>\n", xmax); fprintf(fp, " <ymin>%d</ymin>\n", ymin); fprintf(fp, " <ymax>%d</ymax>\n\n", ymax); fprintf(fp, " <dt_ped>%f</dt_ped>\n", dt_ped); fprintf(fp, " <dt_flood>%f</dt_flood>\n\n", dt_flood); fprintf(fp, " <auto_dt_on>%d</auto_dt_on>\n", auto_dt_on); fprintf(fp, " <body_effect_on>%d</body_effect_on>\n", body_effect_on); fprintf(fp, " <evacuation_on>%d</evacuation_on>\n", evacuation_on); fprintf(fp, " <sandbagging_on>%d</sandbagging_on>\n\n", sandbagging_on); fprintf(fp, " <pedestrians_population>%d</pedestrians_population>\n", pedestrians_population); fprintf(fp, " <hero_percentage>%f</hero_percentage>\n\n", hero_percentage); fprintf(fp, " <FLOOD_START_TIME>%f</FLOOD_START_TIME>\n", FLOOD_START_TIME); fprintf(fp, " <DISCHARGE_PEAK_TIME>%f</DISCHARGE_PEAK_TIME>\n", DISCHARGE_PEAK_TIME); fprintf(fp, " <FLOOD_END_TIME>%f</FLOOD_END_TIME>\n", FLOOD_END_TIME); fprintf(fp, " <evacuation_start_time>%f</evacuation_start_time>\n", evacuation_start_time); fprintf(fp, " <sandbagging_start_time>%f</sandbagging_start_time>\n", sandbagging_start_time); fprintf(fp, " <sandbagging_end_time>%f</sandbagging_end_time>\n", sandbagging_end_time); fprintf(fp, " <pickup_duration>%f</pickup_duration>\n", pickup_duration); fprintf(fp, " <drop_duration>%f</drop_duration>\n\n", drop_duration); fprintf(fp, " <DISCHARGE_INITIAL>%f</DISCHARGE_INITIAL>\n", DISCHARGE_INITIAL); fprintf(fp, " <DISCHARGE_PEAK>%f</DISCHARGE_PEAK>\n", DISCHARGE_PEAK); fprintf(fp, " <DISCHARGE_END>%f</DISCHARGE_END>\n\n", DISCHARGE_END); fprintf(fp, " <INFLOW_BOUNDARY>%d</INFLOW_BOUNDARY>\n", INFLOW_BOUNDARY); fprintf(fp, " <BOUNDARY_EAST_STATUS>%d</BOUNDARY_EAST_STATUS>\n", BOUNDARY_EAST_STATUS); fprintf(fp, " <BOUNDARY_WEST_STATUS>%d</BOUNDARY_WEST_STATUS>\n", BOUNDARY_WEST_STATUS); fprintf(fp, " <BOUNDARY_NORTH_STATUS>%d</BOUNDARY_NORTH_STATUS>\n", BOUNDARY_NORTH_STATUS); fprintf(fp, " <BOUNDARY_SOUTH_STATUS>%d</BOUNDARY_SOUTH_STATUS>\n\n", BOUNDARY_SOUTH_STATUS); fprintf(fp, " <x1_boundary>%f</x1_boundary>\n", x1_boundary); fprintf(fp, " <x2_boundary>%f</x2_boundary>\n", x2_boundary); fprintf(fp, " <y1_boundary>%f</y1_boundary>\n", y1_boundary); fprintf(fp, " <y2_boundary>%f</y2_boundary>\n\n", y2_boundary); fprintf(fp, " <init_depth_boundary>%f</init_depth_boundary>\n\n", init_depth_boundary); fprintf(fp, " <sandbag_length>%f</sandbag_length>\n", sandbag_length); fprintf(fp, " <sandbag_height>%f</sandbag_height>\n", sandbag_height); fprintf(fp, " <sandbag_width>%f</sandbag_width>\n", sandbag_width); fprintf(fp, " <dike_length>%f</dike_length>\n", dike_length); fprintf(fp, " <dike_height>%f</dike_height>\n", dike_height); fprintf(fp, " <dike_width>%f</dike_width>\n\n", dike_width); fprintf(fp, " <evacuation_exit_number>%d</evacuation_exit_number>\n\n", evacuation_exit_number); fprintf(fp, " <pickup_point>%d</pickup_point>\n", pickup_point); fprintf(fp, " <drop_point>%d</drop_point>\n\n", drop_point); fprintf(fp, " </environment>\n\n"); for (i = 0; i < SIZE + 1; i++){ for (j = 0; j < SIZE + 1; j++){ x_int[i] = xmin + i * dx; y_int[j] = ymin + j * dy; z0_int[i][j] = bed_data((double)x_int[i], (double)y_int[j]); } } for (i = 0; i < SIZE; i++) for (j = 0; j< SIZE; j++) { { x[i] = 0.5 * (x_int[i] + x_int[i + 1]); y[j] = 0.5 * (y_int[j] + y_int[j + 1]); z0[i][j] = (z0_int[i][j] + z0_int[i + 1][j] + z0_int[i][j + 1] + z0_int[i + 1][j + 1]) / 4; fprintf(fp2, "%d\t\t %d\t\t %f \n", i, j, z0[i][j]); fprintf(fp, " <xagent>\n"); fprintf(fp, "\t<name>FloodCell</name>\n"); fprintf(fp, "\t<inDomain>%d</inDomain>\n", inDomain); fprintf(fp, "\t<x>%d</x>\n", i); fprintf(fp, "\t<y>%d</y>\n", j); fprintf(fp, "\t<z0>%f</z0>\n", z0[i][j]); fprintf(fp, " </xagent>\n"); } } fprintf(fp, "</states>"); fclose(fp); return 0; } double bed_data(double x_int, double y_int) { double zz; double flume_length =
1; double x1 = (xmax - flume_length) / 2 ; double x2 = (xmax + flume_length) / 2 ; if ((x_int <= x1) || (x_int >= x2)) zz = 10; else zz = 0; return zz; }
function_block-function_prefixed
[ { "content": "class Double {\n\npublic:\n\n Double() {}\n\n Double(double d) : d_(d) {}\n\n Double(uint64_t u) : u_(u) {}\n\n\n\n double Value() const { return d_; }\n\n uint64_t Uint64Value() const { return u_; }\n\n\n\n double NextPositiveDouble() const {\n\n RAPIDJSON_ASSERT(!Sign());\n\n return Double(u_ + 1).Value();\n\n }\n\n\n\n bool Sign() const { return (u_ & kSignMask) != 0; }\n\n uint64_t Significand() const { return u_ & kSignificandMask; }\n\n int Exponent() const { return static_cast<int>(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); }\n\n\n\n bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; }\n\n bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; }\n", "file_path": "include/rapidjson/internal/ieee754.h", "rank": 0, "score": 151553.72070216583 }, { "content": "struct TypeHelper<ValueType, double> {\n\n static bool Is(const ValueType& v) { return v.IsDouble(); }\n\n static double Get(const ValueType& v) { return v.GetDouble(); }\n\n static ValueType& Set(ValueType& v, double data) { return v.SetDouble(data); }\n\n static ValueType& Set(ValueType& v, double data, typename ValueType::AllocatorType&) { return v.SetDouble(data); }\n\n};\n\n\n\ntemplate<typename ValueType> \n", "file_path": "include/rapidjson/document.h", "rank": 1, "score": 138289.6997655095 }, { "content": " double ToDouble() const {\n\n union {\n\n double d;\n\n uint64_t u64;\n\n }u;\n\n const uint64_t be = (e == kDpDenormalExponent && (f & kDpHiddenBit) == 0) ? 0 : \n\n static_cast<uint64_t>(e + kDpExponentBias);\n\n u.u64 = (f & kDpSignificandMask) | (be << kDpSignificandSize);\n\n return u.d;\n", "file_path": "include/rapidjson/internal/diyfp.h", "rank": 2, "score": 134369.67678003048 }, { "content": "def main():\n\n # Process command line arguments\n\n parser = argparse.ArgumentParser(\n\n description=\"Create and rename a copy of a FLAME GPU example, as a starting point for new projects\"\n\n )\n\n parser.add_argument(\n\n \"name\",\n\n type=str,\n\n help=\"Name of the new project, which should not already exist\"\n\n )\n\n\n\n parser.add_argument(\n\n \"--base\",\n\n type=str,\n\n help=\"The name of the existing example project to be based on\",\n\n default=DEFAULT_BASE\n\n )\n\n\n\n parser.add_argument(\n\n \"-f\",\n\n \"--force\",\n\n action=\"store_true\",\n\n help=\"Force destination directory to be replaced.\",\n\n default=False\n\n )\n\n\n\n args = parser.parse_args()\n\n\n\n\n\n # Get the location of this script, and calcualte relavant paths\n\n script_path = os.path.realpath(__file__)\n\n script_dir = os.path.split(script_path)[0]\n\n examples_dir = os.path.abspath(os.path.join(script_dir, RELATIVE_EXAMPLES_DIR))\n\n\n\n # Output a summary of what is attempted to be done.\n\n print(\"Creating new example `{:}` based on `{:}` in `{:}` \".format(args.name, args.base, examples_dir))\n\n\n\n # Ensure the examples dir exists.\n\n if not examplesDirExists(examples_dir):\n\n print(\"Error: examples directory {:} does not exist\".format(examples_dir))\n\n return False\n\n\n\n # Construct some paths.\n\n base_dir = os.path.abspath(os.path.join(examples_dir, args.base))\n\n target_dir = os.path.abspath(os.path.join(examples_dir, args.name))\n\n\n\n # If the base does not exist, abort.\n\n if not baseExists(base_dir):\n\n print(\"Error: base model {:} does not exist\".format(base_dir))\n\n return False\n\n\n\n # Check if the target project already exists, abd we are not forcing replacement.\n\n if targetExists(target_dir) and not args.force:\n\n # If it exists, abort.\n\n print(\"Error: target example directory {:} already exists. Use `--force` to overwrite.\".format(target_dir))\n\n return False\n\n\n\n # Otherwise, unless we have any race conditions at this point, we can try to proceed.\n\n\n\n try:\n\n created = createExample(args.name, target_dir, args.base, base_dir)\n\n if created:\n\n print(\"Example `{:}` successfully created at `{:}`\".format(args.name, target_dir))\n\n return True\n\n else:\n\n print(\"Error: Could not create the example. Please try again.\")\n\n return False\n\n except Exception as e:\n\n print(\"Error: an exception occurred.\\n > {:}\".format(e))\n", "file_path": "tools/new_example.py", "rank": 3, "score": 131344.75376141956 }, { "content": "struct TypeHelper<ValueType, int> {\n\n static bool Is(const ValueType& v) { return v.IsInt(); }\n\n static int Get(const ValueType& v) { return v.GetInt(); }\n\n static ValueType& Set(ValueType& v, int data) { return v.SetInt(data); }\n\n static ValueType& Set(ValueType& v, int data, typename ValueType::AllocatorType&) { return v.SetInt(data); }\n\n};\n\n\n\ntemplate<typename ValueType> \n", "file_path": "include/rapidjson/document.h", "rank": 4, "score": 108437.97570060057 }, { "content": "struct TypeHelper<ValueType, float> {\n\n static bool Is(const ValueType& v) { return v.IsFloat(); }\n\n static float Get(const ValueType& v) { return v.GetFloat(); }\n\n static ValueType& Set(ValueType& v, float data) { return v.SetFloat(data); }\n\n static ValueType& Set(ValueType& v, float data, typename ValueType::AllocatorType&) { return v.SetFloat(data); }\n\n};\n\n\n\ntemplate<typename ValueType> \n", "file_path": "include/rapidjson/document.h", "rank": 5, "score": 108427.4767981032 }, { "content": "#else\n\n#\terror \"GLM error: multiple default precision requested for unsigned integer types\"\n\n#endif\n\n\n\n\t/// Unsigned integer type.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.3 Integers</a>\n\n\ttypedef unsigned int\t\t\t\tuint;\n\n\n\n\t/// @}\n\n\n\n////////////////////\n\n// check type sizes\n\n#ifndef GLM_STATIC_ASSERT_NULL\n\n\tGLM_STATIC_ASSERT(sizeof(glm::int8) == 1, \"int8 size isn't 1 byte on this platform\");\n\n\tGLM_STATIC_ASSERT(sizeof(glm::int16) == 2, \"int16 size isn't 2 bytes on this platform\");\n\n\tGLM_STATIC_ASSERT(sizeof(glm::int32) == 4, \"int32 size isn't 4 bytes on this platform\");\n\n\tGLM_STATIC_ASSERT(sizeof(glm::int64) == 8, \"int64 size isn't 8 bytes on this platform\");\n\n\n\n\tGLM_STATIC_ASSERT(sizeof(glm::uint8) == 1, \"uint8 size isn't 1 byte on this platform\");\n\n\tGLM_STATIC_ASSERT(sizeof(glm::uint16) == 2, \"uint16 size isn't 2 bytes on this platform\");\n\n\tGLM_STATIC_ASSERT(sizeof(glm::uint32) == 4, \"uint32 size isn't 4 bytes on this platform\");\n\n\tGLM_STATIC_ASSERT(sizeof(glm::uint64) == 8, \"uint64 size isn't 8 bytes on this platform\");\n\n#endif//GLM_STATIC_ASSERT_NULL\n\n\n\n}//namespace glm\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 6, "score": 95684.2843881831 }, { "content": "/// @ref core\n\n/// @file glm/detail/type_int.hpp\n\n\n\n#pragma once\n\n\n\n#include \"setup.hpp\"\n\n#if GLM_HAS_MAKE_SIGNED\n\n#\tinclude <type_traits>\n\n#endif\n\n\n\n#if GLM_HAS_EXTENDED_INTEGER_TYPE\n\n#\tinclude <cstdint>\n\n#endif\n\n\n\nnamespace glm{\n\nnamespace detail\n\n{\n\n#\tif GLM_HAS_EXTENDED_INTEGER_TYPE\n\n\t\ttypedef std::int8_t\t\t\t\t\tint8;\n\n\t\ttypedef std::int16_t\t\t\t\tint16;\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 7, "score": 95682.4950347449 }, { "content": "#endif//\n\n\n\n\ttypedef signed int\t\t\t\t\t\tlowp_int_t;\n\n\ttypedef signed int\t\t\t\t\t\tmediump_int_t;\n\n\ttypedef signed int\t\t\t\t\t\thighp_int_t;\n\n\n\n\ttypedef unsigned int\t\t\t\t\tlowp_uint_t;\n\n\ttypedef unsigned int\t\t\t\t\tmediump_uint_t;\n\n\ttypedef unsigned int\t\t\t\t\thighp_uint_t;\n\n\n\n#\tif GLM_HAS_MAKE_SIGNED\n\n\t\tusing std::make_signed;\n\n\t\tusing std::make_unsigned;\n\n\n\n#\telse//GLM_HAS_MAKE_SIGNED\n\n\t\ttemplate<typename genType>\n\n\t\tstruct make_signed\n\n\t\t{};\n\n\n\n\t\ttemplate<>\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 8, "score": 95679.5782356856 }, { "content": "#if(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))\n\n\ttypedef mediump_int\t\t\t\t\tint_t;\n\n#elif(defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))\n\n\ttypedef highp_int\t\t\t\t\tint_t;\n\n#elif(!defined(GLM_PRECISION_HIGHP_INT) && defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))\n\n\ttypedef mediump_int\t\t\t\t\tint_t;\n\n#elif(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && defined(GLM_PRECISION_LOWP_INT))\n\n\ttypedef lowp_int\t\t\t\t\tint_t;\n\n#else\n\n#\terror \"GLM error: multiple default precision requested for signed integer types\"\n\n#endif\n\n\n\n#if(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))\n\n\ttypedef mediump_uint\t\t\t\tuint_t;\n\n#elif(defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))\n\n\ttypedef highp_uint\t\t\t\t\tuint_t;\n\n#elif(!defined(GLM_PRECISION_HIGHP_UINT) && defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))\n\n\ttypedef mediump_uint\t\t\t\tuint_t;\n\n#elif(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && defined(GLM_PRECISION_LOWP_UINT))\n\n\ttypedef lowp_uint\t\t\t\t\tuint_t;\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 9, "score": 95679.35981652171 }, { "content": "\t\tstruct make_signed<char>\n\n\t\t{\n\n\t\t\ttypedef char type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<short>\n\n\t\t{\n\n\t\t\ttypedef short type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<int>\n\n\t\t{\n\n\t\t\ttypedef int type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<long>\n\n\t\t{\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 10, "score": 95678.64696384635 }, { "content": "\t\t\ttypedef long type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<unsigned char>\n\n\t\t{\n\n\t\t\ttypedef char type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<unsigned short>\n\n\t\t{\n\n\t\t\ttypedef short type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<unsigned int>\n\n\t\t{\n\n\t\t\ttypedef int type;\n\n\t\t};\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 11, "score": 95678.52318815763 }, { "content": "\t\t\ttypedef unsigned short type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<int>\n\n\t\t{\n\n\t\t\ttypedef unsigned int type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<long>\n\n\t\t{\n\n\t\t\ttypedef unsigned long type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<unsigned char>\n\n\t\t{\n\n\t\t\ttypedef unsigned char type;\n\n\t\t};\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 12, "score": 95678.44345145024 }, { "content": "\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<unsigned short>\n\n\t\t{\n\n\t\t\ttypedef unsigned short type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<unsigned int>\n\n\t\t{\n\n\t\t\ttypedef unsigned int type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<unsigned long>\n\n\t\t{\n\n\t\t\ttypedef unsigned long type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 13, "score": 95678.44345145024 }, { "content": "\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.3 Integers</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef detail::lowp_int_t\t\t\t\tlowp_int;\n\n\n\n\t/// Medium qualifier signed integer.\n\n\t/// There is no guarantee on the actual qualifier.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.3 Integers</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef detail::mediump_int_t\t\t\tmediump_int;\n\n\n\n\t/// High qualifier signed integer.\n\n\t/// There is no guarantee on the actual qualifier.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.3 Integers</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef detail::highp_int_t\t\t\t\thighp_int;\n\n\n\n\t/// Low qualifier unsigned integer.\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 14, "score": 95678.07464226862 }, { "content": "\n\n#\t\telif (GLM_COMPILER & GLM_COMPILER_CLANG)\n\n#\t\t\tpragma clang diagnostic ignored \"-Wc++11-long-long\"\n\n\t\t\ttypedef signed long\tlong\t\tsint64;\n\n\t\t\ttypedef unsigned long long\t\tuint64;\n\n\n\n#\t\telse//unknown compiler\n\n\t\t\ttypedef signed long\tlong\t\tsint64;\n\n\t\t\ttypedef unsigned long long\t\tuint64;\n\n#\t\tendif//GLM_COMPILER\n\n\n\n\t\ttypedef signed char\t\t\t\t\tint8;\n\n\t\ttypedef signed short\t\t\t\tint16;\n\n\t\ttypedef signed int\t\t\t\t\tint32;\n\n\t\ttypedef sint64\t\t\t\t\t\tint64;\n\n\n\n\t\ttypedef unsigned char\t\t\t\tuint8;\n\n\t\ttypedef unsigned short\t\t\t\tuint16;\n\n\t\ttypedef unsigned int\t\t\t\tuint32;\n\n\t\ttypedef uint64\t\t\t\t\t\tuint64;\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 15, "score": 95677.08539431021 }, { "content": "class FileWriteStream {\n\npublic:\n\n typedef char Ch; //!< Character type. Only support char.\n\n\n\n FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { \n\n RAPIDJSON_ASSERT(fp_ != 0);\n\n }\n\n\n\n void Put(char c) { \n\n if (current_ >= bufferEnd_)\n\n Flush();\n\n\n\n *current_++ = c;\n\n }\n\n\n\n void PutN(char c, size_t n) {\n\n size_t avail = static_cast<size_t>(bufferEnd_ - current_);\n\n while (n > avail) {\n\n std::memset(current_, c, avail);\n\n current_ += avail;\n", "file_path": "include/rapidjson/filewritestream.h", "rank": 16, "score": 95675.0842133741 }, { "content": "class FileReadStream;\n\n\n\n// filewritestream.h\n\n\n", "file_path": "include/rapidjson/fwd.h", "rank": 17, "score": 95675.0842133741 }, { "content": "class FileReadStream {\n\npublic:\n\n typedef char Ch; //!< Character type (byte).\n\n\n\n //! Constructor.\n\n /*!\n\n \\param fp File pointer opened for read.\n\n \\param buffer user-supplied buffer.\n\n \\param bufferSize size of buffer in bytes. Must >=4 bytes.\n\n */\n\n FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { \n\n RAPIDJSON_ASSERT(fp_ != 0);\n\n RAPIDJSON_ASSERT(bufferSize >= 4);\n\n Read();\n\n }\n\n\n\n Ch Peek() const { return *current_; }\n\n Ch Take() { Ch c = *current_; Read(); return c; }\n\n size_t Tell() const { return count_ + static_cast<size_t>(current_ - buffer_); }\n\n\n", "file_path": "include/rapidjson/filereadstream.h", "rank": 18, "score": 95675.0842133741 }, { "content": "class FileWriteStream;\n\n\n\n// memorybuffer.h\n\n\n\ntemplate <typename Allocator>\n", "file_path": "include/rapidjson/fwd.h", "rank": 19, "score": 95675.0842133741 }, { "content": "\t\ttypedef std::int32_t\t\t\t\tint32;\n\n\t\ttypedef std::int64_t\t\t\t\tint64;\n\n\n\n\t\ttypedef std::uint8_t\t\t\t\tuint8;\n\n\t\ttypedef std::uint16_t\t\t\t\tuint16;\n\n\t\ttypedef std::uint32_t\t\t\t\tuint32;\n\n\t\ttypedef std::uint64_t\t\t\t\tuint64;\n\n#\telse\n\n#\t\tif(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available\n\n\t\t\ttypedef int64_t\t\t\t\t\tsint64;\n\n\t\t\ttypedef uint64_t\t\t\t\tuint64;\n\n\n\n#\t\telif GLM_COMPILER & GLM_COMPILER_VC\n\n\t\t\ttypedef signed __int64\t\t\tsint64;\n\n\t\t\ttypedef unsigned __int64\t\tuint64;\n\n\n\n#\t\telif GLM_COMPILER & GLM_COMPILER_GCC\n\n#\t\t\tpragma GCC diagnostic ignored \"-Wlong-long\"\n\n\t\t\t__extension__ typedef signed long long\t\tsint64;\n\n\t\t\t__extension__ typedef unsigned long long\tuint64;\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 20, "score": 95672.60713258058 }, { "content": "\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<unsigned long>\n\n\t\t{\n\n\t\t\ttypedef long type;\n\n\t\t};\n\n\n\n\t\ttemplate<typename genType>\n\n\t\tstruct make_unsigned\n\n\t\t{};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<char>\n\n\t\t{\n\n\t\t\ttypedef unsigned char type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<short>\n\n\t\t{\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 21, "score": 95672.60713258058 }, { "content": "\t\t\ttypedef unsigned long long type;\n\n\t\t};\n\n#\tendif//GLM_HAS_MAKE_SIGNED\n\n}//namespace detail\n\n\n\n\ttypedef detail::int8\t\t\t\t\tint8;\n\n\ttypedef detail::int16\t\t\t\t\tint16;\n\n\ttypedef detail::int32\t\t\t\t\tint32;\n\n\ttypedef detail::int64\t\t\t\t\tint64;\n\n\n\n\ttypedef detail::uint8\t\t\t\t\tuint8;\n\n\ttypedef detail::uint16\t\t\t\t\tuint16;\n\n\ttypedef detail::uint32\t\t\t\t\tuint32;\n\n\ttypedef detail::uint64\t\t\t\t\tuint64;\n\n\n\n\t/// @addtogroup core_precision\n\n\t/// @{\n\n\n\n\t/// Low qualifier signed integer.\n\n\t/// There is no guarantee on the actual qualifier.\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 22, "score": 95672.60713258058 }, { "content": "\t/// There is no guarantee on the actual qualifier.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.3 Integers</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef detail::lowp_uint_t\t\t\t\tlowp_uint;\n\n\n\n\t/// Medium qualifier unsigned integer.\n\n\t/// There is no guarantee on the actual qualifier.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.3 Integers</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef detail::mediump_uint_t\t\t\tmediump_uint;\n\n\n\n\t/// High qualifier unsigned integer.\n\n\t/// There is no guarantee on the actual qualifier.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.3 Integers</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef detail::highp_uint_t\t\t\thighp_uint;\n\n\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 23, "score": 95672.60713258058 }, { "content": "\t\tstruct make_signed<long long>\n\n\t\t{\n\n\t\t\ttypedef long long type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_signed<unsigned long long>\n\n\t\t{\n\n\t\t\ttypedef long long type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<long long>\n\n\t\t{\n\n\t\t\ttypedef unsigned long long type;\n\n\t\t};\n\n\n\n\t\ttemplate<>\n\n\t\tstruct make_unsigned<unsigned long long>\n\n\t\t{\n", "file_path": "include/glm/detail/type_int.hpp", "rank": 24, "score": 95672.60713258058 }, { "content": "\t\ttypedef double\t\t\t\tfloat64;\n\n#\tendif//GLM_FORCE_SINGLE_ONLY\n\n\n\n////////////////////\n\n// check type sizes\n\n#ifndef GLM_STATIC_ASSERT_NULL\n\n\tGLM_STATIC_ASSERT(sizeof(glm::float32) == 4, \"float32 size isn't 4 bytes on this platform\");\n\n#\tifndef GLM_FORCE_SINGLE_ONLY\n\n\t\tGLM_STATIC_ASSERT(sizeof(glm::float64) == 8, \"float64 size isn't 8 bytes on this platform\");\n\n#\tendif//GLM_FORCE_SINGLE_ONLY\n\n#endif//GLM_STATIC_ASSERT_NULL\n\n\n\n\t/// @}\n\n\n\n}//namespace glm\n", "file_path": "include/glm/detail/type_float.hpp", "rank": 25, "score": 95672.21350062291 }, { "content": "/// @ref core\n\n/// @file glm/detail/type_float.hpp\n\n\n\n#pragma once\n\n\n\n#include \"setup.hpp\"\n\n\n\nnamespace glm{\n\nnamespace detail\n\n{\n\n\ttypedef float\t\t\t\tfloat32;\n\n\n\n#\tifndef GLM_FORCE_SINGLE_ONLY\n\n\t\ttypedef double\t\t\tfloat64;\n\n#\tendif//GLM_FORCE_SINGLE_ONLY\n\n}//namespace detail\n\n\n\n\ttypedef float\t\t\t\tlowp_float_t;\n\n\ttypedef float\t\t\t\tmediump_float_t;\n\n\ttypedef double\t\t\t\thighp_float_t;\n", "file_path": "include/glm/detail/type_float.hpp", "rank": 26, "score": 95672.10294172162 }, { "content": "\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.4 Floats</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef highp_float_t\t\thighp_float;\n\n\n\n#if(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))\n\n\ttypedef mediump_float\t\tfloat_t;\n\n#elif(defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))\n\n\ttypedef highp_float\t\t\tfloat_t;\n\n#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && defined(GLM_PRECISION_MEDIUMP_FLOAT) && !defined(GLM_PRECISION_LOWP_FLOAT))\n\n\ttypedef mediump_float\t\tfloat_t;\n\n#elif(!defined(GLM_PRECISION_HIGHP_FLOAT) && !defined(GLM_PRECISION_MEDIUMP_FLOAT) && defined(GLM_PRECISION_LOWP_FLOAT))\n\n\ttypedef lowp_float\t\t\tfloat_t;\n\n#else\n\n#\terror \"GLM error: multiple default precision requested for floating-point types\"\n\n#endif\n\n\n\n\ttypedef float\t\t\t\tfloat32;\n\n\n\n#\tifndef GLM_FORCE_SINGLE_ONLY\n", "file_path": "include/glm/detail/type_float.hpp", "rank": 27, "score": 95668.55550411573 }, { "content": "\n\n\t/// @addtogroup core_precision\n\n\t/// @{\n\n\n\n\t/// Low qualifier floating-point numbers.\n\n\t/// There is no guarantee on the actual qualifier.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.4 Floats</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef lowp_float_t\t\tlowp_float;\n\n\n\n\t/// Medium qualifier floating-point numbers.\n\n\t/// There is no guarantee on the actual qualifier.\n\n\t///\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.1.4 Floats</a>\n\n\t/// @see <a href=\"http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf\">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>\n\n\ttypedef mediump_float_t\t\tmediump_float;\n\n\n\n\t/// High qualifier floating-point numbers.\n\n\t/// There is no guarantee on the actual qualifier.\n", "file_path": "include/glm/detail/type_float.hpp", "rank": 28, "score": 95667.82960486667 }, { "content": "class ISchemaStateFactory {\n\npublic:\n\n virtual ~ISchemaStateFactory() {}\n\n virtual ISchemaValidator* CreateSchemaValidator(const SchemaType&) = 0;\n\n virtual void DestroySchemaValidator(ISchemaValidator* validator) = 0;\n\n virtual void* CreateHasher() = 0;\n\n virtual uint64_t GetHashCode(void* hasher) = 0;\n\n virtual void DestroryHasher(void* hasher) = 0;\n\n virtual void* MallocState(size_t size) = 0;\n\n virtual void FreeState(void* p) = 0;\n\n};\n\n\n\n///////////////////////////////////////////////////////////////////////////////\n\n// Hasher\n\n\n\n// For comparison of compound value\n\ntemplate<typename Encoding, typename Allocator>\n", "file_path": "include/rapidjson/schema.h", "rank": 29, "score": 95605.4500661558 }, { "content": "class AutoUTFOutputStream {\n\n RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n\npublic:\n\n typedef CharType Ch;\n\n\n\n //! Constructor.\n\n /*!\n\n \\param os output stream to be wrapped.\n\n \\param type UTF encoding type.\n\n \\param putBOM Whether to write BOM at the beginning of the stream.\n\n */\n\n AutoUTFOutputStream(OutputByteStream& os, UTFType type, bool putBOM) : os_(&os), type_(type) {\n\n RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE);\n\n\n\n // Runtime check whether the size of character type is sufficient. It only perform checks with assertion.\n\n if (type_ == kUTF16LE || type_ == kUTF16BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 2);\n\n if (type_ == kUTF32LE || type_ == kUTF32BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 4);\n\n\n\n static const PutFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Put) };\n\n putFunc_ = f[type_];\n", "file_path": "include/rapidjson/encodedstream.h", "rank": 30, "score": 92814.6030114661 }, { "content": "class AutoUTFInputStream {\n\n RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n\npublic:\n\n typedef CharType Ch;\n\n\n\n //! Constructor.\n\n /*!\n\n \\param is input stream to be wrapped.\n\n \\param type UTF encoding type if it is not detected from the stream.\n\n */\n\n AutoUTFInputStream(InputByteStream& is, UTFType type = kUTF8) : is_(&is), type_(type), hasBOM_(false) {\n\n RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE); \n\n DetectType();\n\n static const TakeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Take) };\n\n takeFunc_ = f[type_];\n\n current_ = takeFunc_(*is_);\n\n }\n\n\n\n UTFType GetType() const { return type_; }\n\n bool HasBOM() const { return hasBOM_; }\n", "file_path": "include/rapidjson/encodedstream.h", "rank": 31, "score": 92814.6030114661 }, { "content": "def rename_files(target_dir, target_name, base_name):\n\n try: \n\n for subdir, dirs, files in os.walk(target_dir):\n\n for file in files:\n\n # If the file starts with the bsae_name, replace it.\n\n if file.startswith(base_name):\n\n # @todo - only rename certain files.\n\n new_file = file.replace(base_name, target_name)\n\n shutil.move(os.path.join(subdir, file), os.path.join(subdir, new_file))\n\n except Exception as e:\n\n print(\"Exception renaming files:\\n > {:}\".format(fpathe))\n\n return False\n", "file_path": "tools/new_example.py", "rank": 32, "score": 91034.20646296667 }, { "content": "def update_files(target_dir, target_name, base_name):\n\n # For each file we wish to change\n\n for file_pattern in FILES_TO_CHANGE:\n\n # Find the filepath\n\n fname = file_pattern.replace(\"{:}\", target_name)\n\n fpath = os.path.join(target_dir, fname)\n\n # If the file exists.\n\n if os.path.isfile(fpath):\n\n # Open the path for read \n\n content = None\n\n try:\n\n with open(fpath, \"r\") as file:\n\n content = file.readlines()\n\n except Exception as e: \n\n print(\"Exception whilst reading {:}\\n > {:}\".format(fpath, e))\n\n return False\n\n\n\n try:\n\n with open(fpath, \"w\") as file:\n\n for line in content:\n\n newline = line.replace(base_name, target_name)\n\n file.write(newline)\n\n except Exception as e:\n\n print(\"Exception whilst writing {:}\\n > {:}\".format(fpath, e))\n\n return False\n", "file_path": "tools/new_example.py", "rank": 33, "score": 91034.20646296667 }, { "content": "\t\tclass basic_state_saver {\n\n\n\n\t\tpublic:\n\n\n\n\t\t\tGLM_FUNC_DECL explicit basic_state_saver(std::basic_ios<CTy,CTr>&);\n\n\t\t\tGLM_FUNC_DECL ~basic_state_saver();\n\n\n\n\t\tprivate:\n\n\n\n\t\t\ttypedef ::std::basic_ios<CTy,CTr> state_type;\n\n\t\t\ttypedef typename state_type::char_type char_type;\n\n\t\t\ttypedef ::std::ios_base::fmtflags flags_type;\n\n\t\t\ttypedef ::std::streamsize streamsize_type;\n\n\t\t\ttypedef ::std::locale const locale_type;\n\n\n\n\t\t\tstate_type& state_;\n\n\t\t\tflags_type flags_;\n\n\t\t\tstreamsize_type precision_;\n\n\t\t\tstreamsize_type width_;\n\n\t\t\tchar_type fill_;\n\n\t\t\tlocale_type locale_;\n\n\n\n\t\t\tGLM_FUNC_DECL basic_state_saver& operator=(basic_state_saver const&);\n\n\t\t};\n\n\n\n\t\ttypedef basic_state_saver<char> state_saver;\n\n\t\ttypedef basic_state_saver<wchar_t> wstate_saver;\n\n\n\n\t\ttemplate<typename CTy, typename CTr = std::char_traits<CTy> >\n", "file_path": "include/glm/gtx/io.hpp", "rank": 34, "score": 90027.17421140442 }, { "content": "inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) {\n\n std::memset(memoryBuffer.stack_.Push<char>(n), c, n * sizeof(c));\n", "file_path": "include/rapidjson/memorybuffer.h", "rank": 35, "score": 87553.9507933792 }, { "content": " int XOrigin, YOrigin, maxHeight, maxWidth;\n", "file_path": "include/GL/glxext.h", "rank": 36, "score": 87551.48038150638 }, { "content": " int destXOrigin, destYOrigin, destWidth, destHeight;\n", "file_path": "include/GL/glxext.h", "rank": 37, "score": 85138.11645062258 }, { "content": " int srcXOrigin, srcYOrigin, srcWidth, srcHeight;\n", "file_path": "include/GL/glxext.h", "rank": 38, "score": 85138.11645062258 }, { "content": "def main():\n\n # Argument parsing.\n\n parser = argparse.ArgumentParser(description=\"Create an archive of the required files for standalone execution of examples\")\n\n\n\n parser.add_argument(\n\n \"-o\",\n\n \"--output\",\n\n type=str,\n\n help=\"Output Directory for archive. Defaults to {:}\".format(DEFAULT_OUTPUT),\n\n default=DEFAULT_OUTPUT\n\n )\n\n\n\n args = parser.parse_args()\n\n\n", "file_path": "tools/create_release_archive.py", "rank": 39, "score": 83245.15391696773 }, { "content": " static const int kDiySignificandSize = 64;\n", "file_path": "include/rapidjson/internal/diyfp.h", "rank": 40, "score": 82854.23255179815 }, { "content": " static const int kDpSignificandSize = 52;\n", "file_path": "include/rapidjson/internal/diyfp.h", "rank": 41, "score": 82854.23255179815 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float;\n", "file_path": "include/GL/glew.h", "rank": 42, "score": 82830.5617305342 }, { "content": "GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float;\n", "file_path": "include/GL/glxew.h", "rank": 43, "score": 82830.5617305342 }, { "content": "GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer;\n", "file_path": "include/GL/glxew.h", "rank": 44, "score": 82830.5617305342 }, { "content": "WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer;\n", "file_path": "include/GL/wglew.h", "rank": 45, "score": 82830.5617305342 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float;\n", "file_path": "include/GL/glew.h", "rank": 46, "score": 82830.5617305342 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float;\n", "file_path": "include/GL/glew.h", "rank": 47, "score": 82830.5617305342 }, { "content": "WGLEW_EXPORT GLboolean __WGLEW_EXT_depth_float;\n", "file_path": "include/GL/wglew.h", "rank": 48, "score": 82830.5617305342 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer;\n", "file_path": "include/GL/glew.h", "rank": 49, "score": 82830.5617305342 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float;\n", "file_path": "include/GL/glew.h", "rank": 50, "score": 82830.5617305342 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels;\n", "file_path": "include/GL/glew.h", "rank": 51, "score": 82830.5617305342 }, { "content": "void toggleStateExit1();\n", "file_path": "examples/FloodPedestrian_2020/src/visualisation/GlobalsController.h", "rank": 52, "score": 81921.89303634454 }, { "content": "void toggleStateExit1();\n", "file_path": "examples/FloodPedestrian_2019/src/visualisation/GlobalsController.h", "rank": 53, "score": 81921.89303634454 }, { "content": "void toggleStateExit1();\n", "file_path": "examples/FloodPedestrian_2018/src/visualisation/GlobalsController.h", "rank": 54, "score": 81921.89303634454 }, { "content": "int getStateExit1();\n", "file_path": "examples/FloodPedestrian_2019/src/visualisation/GlobalsController.h", "rank": 55, "score": 81915.91459502537 }, { "content": "int getStateExit1();\n", "file_path": "examples/FloodPedestrian_2018/src/visualisation/GlobalsController.h", "rank": 56, "score": 81915.91459502537 }, { "content": "int getStateExit1();\n", "file_path": "examples/FloodPedestrian_2020/src/visualisation/GlobalsController.h", "rank": 57, "score": 81915.91459502537 }, { "content": "typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n", "file_path": "include/GL/glxew.h", "rank": 58, "score": 80898.86619608247 }, { "content": " int x, y;\n", "file_path": "include/GL/glxext.h", "rank": 59, "score": 80898.86619608247 }, { "content": "def main():\n\n # Process command line arguments\n\n parser = argparse.ArgumentParser(\n\n description=\"Update the visual studio version of one or all flame gpu projects\"\n\n )\n\n parser.add_argument(\n\n \"--name\",\n\n type=str,\n\n help=\"Name of a single example to update. If omitted, all examples will be modified.\"\n\n )\n\n\n\n parser.add_argument(\n\n \"version\",\n\n type=str,\n\n help=\"New cuda version. I.e. 8.0, 9.0 or 9.1\"\n\n )\n\n\n\n # parser.add_argument(\n\n # \"-f\",\n\n # \"--force\",\n\n # action=\"store_true\",\n\n # help=\"Force destination directory to be replaced.\",\n\n # default=False\n\n # )\n\n\n\n args = parser.parse_args()\n\n\n\n\n\n # Get the location of this script, and calcualte relavant paths\n\n script_path = os.path.realpath(__file__)\n\n script_dir = os.path.split(script_path)[0]\n\n examples_dir = os.path.abspath(os.path.join(script_dir, RELATIVE_EXAMPLES_DIR))\n\n \n\n # Ensure the version is legit.\n\n if not checkVersion(args.version):\n\n print(\"Error: Version must be of the format {:}\".format(VERSION_FORMAT))\n\n return False\n\n # Ensure the examples dir exists.\n\n if not examplesDirExists(examples_dir):\n\n print(\"Error: examples directory {:} does not exist\".format(examples_dir))\n\n return False\n\n\n\n # Output a summary of what is attempted to be done.\n\n if args.name is not None:\n\n print(\"Updating CUDA version for {:} visual studio project to {:}\".format(args.name, args.version))\n\n else:\n\n print(\"Updating CUDA version for all visual studio projects to {:}\".format(args.version))\n\n\n\n\n\n if args.name is not None:\n\n return updateCudaVersionInVsproj(args.name, args.version, examples_dir)\n\n else:\n\n # Get all the example projects\n\n projects = findAllVcxprojFiles(examples_dir)\n\n statuses = []\n\n for project in projects:\n\n returncode = updateCudaVersionInVsproj(project, args.version, examples_dir)\n\n statuses.append(returncode)\n\n num_successes = statuses.count(True)\n\n print(\"{:} of {:} projects updated successfully.\".format(num_successes, len(statuses)))\n", "file_path": "tools/update_cuda_version_visual_studio.py", "rank": 60, "score": 80866.3507829002 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex;\n", "file_path": "include/GL/glew.h", "rank": 61, "score": 80666.62833263924 }, { "content": "WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format_float;\n", "file_path": "include/GL/wglew.h", "rank": 62, "score": 80666.62833263924 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float;\n", "file_path": "include/GL/glew.h", "rank": 63, "score": 80666.62833263924 }, { "content": "GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;\n", "file_path": "include/GL/glxew.h", "rank": 64, "score": 80666.62833263924 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float;\n", "file_path": "include/GL/glew.h", "rank": 65, "score": 80666.62833263924 }, { "content": "GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float;\n", "file_path": "include/GL/glxew.h", "rank": 66, "score": 80666.62833263924 }, { "content": "WGLEW_EXPORT GLboolean __WGLEW_ATI_pixel_format_float;\n", "file_path": "include/GL/wglew.h", "rank": 67, "score": 80666.62833263924 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel;\n", "file_path": "include/GL/glew.h", "rank": 68, "score": 80666.62833263924 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float;\n", "file_path": "include/GL/glew.h", "rank": 69, "score": 80666.62833263924 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access;\n", "file_path": "include/GL/glew.h", "rank": 70, "score": 80619.39983807913 }, { "content": "void setStateExit1Text(char* text);\n", "file_path": "examples/FloodPedestrian_2019/src/visualisation/GlobalsController.h", "rank": 71, "score": 79931.41060752813 }, { "content": "void setStateExit1Text(char* text);\n", "file_path": "examples/FloodPedestrian_2020/src/visualisation/GlobalsController.h", "rank": 72, "score": 79931.41060752813 }, { "content": "void setStateExit1Text(char* text);\n", "file_path": "examples/FloodPedestrian_2018/src/visualisation/GlobalsController.h", "rank": 73, "score": 79931.41060752813 }, { "content": " uint64_t f;\n", "file_path": "include/rapidjson/internal/diyfp.h", "rank": 74, "score": 79644.76308477989 }, { "content": "WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float;\n", "file_path": "include/GL/wglew.h", "rank": 75, "score": 78612.8810766456 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size;\n", "file_path": "include/GL/glew.h", "rank": 76, "score": 76683.02074794007 }, { "content": "class StreamLocalCopy<Stream, 1> {\n\npublic:\n\n StreamLocalCopy(Stream& original) : s(original), original_(original) {}\n\n ~StreamLocalCopy() { original_ = s; }\n\n\n\n Stream s;\n\n\n\nprivate:\n\n StreamLocalCopy& operator=(const StreamLocalCopy&) /* = delete */;\n\n\n\n Stream& original_;\n\n};\n\n\n\n//! Keep reference.\n\ntemplate<typename Stream>\n", "file_path": "include/rapidjson/reader.h", "rank": 77, "score": 61528.923975924336 }, { "content": "class StreamLocalCopy<Stream, 0> {\n\npublic:\n\n StreamLocalCopy(Stream& original) : s(original) {}\n\n\n\n Stream& s;\n\n\n\nprivate:\n\n StreamLocalCopy& operator=(const StreamLocalCopy&) /* = delete */;\n\n};\n\n\n\n} // namespace internal\n\n\n\n///////////////////////////////////////////////////////////////////////////////\n\n// SkipWhitespace\n\n\n\n//! Skip the JSON white spaces in a stream.\n\n/*! \\param is A input stream for skipping white spaces.\n\n \\note This function has SSE2/SSE4.2 specialization.\n\n*/\n\ntemplate<typename InputStream>\n", "file_path": "include/rapidjson/reader.h", "rank": 78, "score": 61528.923975924336 }, { "content": "echo off\n\necho \"This will overwrite the existing functions.c file!\"\n\npause\n\nXSLTProcessor.exe XMLModelFile.xml functions.xslt functions.c\n\npause", "file_path": "tools/GenerateFunctionsFileTemplate.bat", "rank": 79, "score": 51160.79985545778 }, { "content": "GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_include;\n", "file_path": "include/GL/glew.h", "rank": 80, "score": 49789.48090316409 }, { "content": " }\n\n\n\n //! Get the value as float type.\n\n /*! \\note If the value is 64-bit integer type, it may lose precision. Use \\c IsLosslessFloat() to check whether the converison is lossless.\n\n */\n\n float GetFloat() const {\n\n return static_cast<float>(GetDouble());\n\n }\n\n\n\n GenericValue& SetInt(int i) { this->~GenericValue(); new (this) GenericValue(i); return *this; }\n\n GenericValue& SetUint(unsigned u) { this->~GenericValue(); new (this) GenericValue(u); return *this; }\n\n GenericValue& SetInt64(int64_t i64) { this->~GenericValue(); new (this) GenericValue(i64); return *this; }\n\n GenericValue& SetUint64(uint64_t u64) { this->~GenericValue(); new (this) GenericValue(u64); return *this; }\n\n GenericValue& SetDouble(double d) { this->~GenericValue(); new (this) GenericValue(d); return *this; }\n\n GenericValue& SetFloat(float f) { this->~GenericValue(); new (this) GenericValue(f); return *this; }\n\n\n\n //@}\n\n\n\n //!@name String\n\n //@{\n", "file_path": "include/rapidjson/document.h", "rank": 81, "score": 49105.17147901814 }, { "content": " if (!IsNumber()) return false;\n\n double a = GetDouble();\n\n if (a < static_cast<double>(-std::numeric_limits<float>::max())\n\n || a > static_cast<double>(std::numeric_limits<float>::max()))\n\n return false;\n\n double b = static_cast<double>(static_cast<float>(a));\n\n return a >= b && a <= b; // Prevent -Wfloat-equal\n\n }\n\n\n\n //@}\n\n\n\n //!@name Null\n\n //@{\n\n\n\n GenericValue& SetNull() { this->~GenericValue(); new (this) GenericValue(); return *this; }\n\n\n\n //@}\n\n\n\n //!@name Bool\n\n //@{\n", "file_path": "include/rapidjson/document.h", "rank": 82, "score": 49103.110350538336 }, { "content": " else if (maximum_.IsInt64())\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString()); // i >= 0 > maximum_\n\n else if (!CheckDoubleMaximum(context, static_cast<double>(i)))\n\n return false;\n\n }\n\n\n\n if (!multipleOf_.IsNull()) {\n\n if (multipleOf_.IsUint64()) {\n\n if (i % multipleOf_.GetUint64() != 0)\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());\n\n }\n\n else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))\n\n return false;\n\n }\n\n\n\n return true;\n\n }\n\n\n\n bool CheckDoubleMinimum(Context& context, double d) const {\n\n if (exclusiveMinimum_ ? d <= minimum_.GetDouble() : d < minimum_.GetDouble())\n", "file_path": "include/rapidjson/schema.h", "rank": 83, "score": 49101.88797085974 }, { "content": " return false;\n\n return CreateParallelValidator(context);\n\n }\n\n\n\n bool Uint64(Context& context, uint64_t u) const {\n\n if (!CheckUint(context, u))\n\n return false;\n\n return CreateParallelValidator(context);\n\n }\n\n\n\n bool Double(Context& context, double d) const {\n\n if (!(type_ & (1 << kNumberSchemaType)))\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n\n\n if (!minimum_.IsNull() && !CheckDoubleMinimum(context, d))\n\n return false;\n\n\n\n if (!maximum_.IsNull() && !CheckDoubleMaximum(context, d))\n\n return false;\n\n \n", "file_path": "include/rapidjson/schema.h", "rank": 84, "score": 49101.28877601322 }, { "content": " if (!multipleOf_.IsNull() && !CheckDoubleMultipleOf(context, d))\n\n return false;\n\n \n\n return CreateParallelValidator(context);\n\n }\n\n \n\n bool String(Context& context, const Ch* str, SizeType length, bool) const {\n\n if (!(type_ & (1 << kStringSchemaType)))\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n\n\n if (minLength_ != 0 || maxLength_ != SizeType(~0)) {\n\n SizeType count;\n\n if (internal::CountStringCodePoint<EncodingType>(str, length, &count)) {\n\n if (count < minLength_)\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinLengthString());\n\n if (count > maxLength_)\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxLengthString());\n\n }\n\n }\n\n\n", "file_path": "include/rapidjson/schema.h", "rank": 85, "score": 49100.49643171802 }, { "content": " /*!@name Implementation of Handler\n\n \\see Handler\n\n */\n\n //@{\n\n\n\n bool Null() { Prefix(kNullType); return EndValue(WriteNull()); }\n\n bool Bool(bool b) { Prefix(b ? kTrueType : kFalseType); return EndValue(WriteBool(b)); }\n\n bool Int(int i) { Prefix(kNumberType); return EndValue(WriteInt(i)); }\n\n bool Uint(unsigned u) { Prefix(kNumberType); return EndValue(WriteUint(u)); }\n\n bool Int64(int64_t i64) { Prefix(kNumberType); return EndValue(WriteInt64(i64)); }\n\n bool Uint64(uint64_t u64) { Prefix(kNumberType); return EndValue(WriteUint64(u64)); }\n\n\n\n //! Writes the given \\c double value to the stream\n\n /*!\n\n \\param d The value to be written.\n\n \\return Whether it is succeed.\n\n */\n\n bool Double(double d) { Prefix(kNumberType); return EndValue(WriteDouble(d)); }\n\n\n\n bool RawNumber(const Ch* str, SizeType length, bool copy = false) {\n", "file_path": "include/rapidjson/writer.h", "rank": 86, "score": 49100.47897824869 }, { "content": " //@{\n\n\n\n bool Null() { PrettyPrefix(kNullType); return Base::WriteNull(); }\n\n bool Bool(bool b) { PrettyPrefix(b ? kTrueType : kFalseType); return Base::WriteBool(b); }\n\n bool Int(int i) { PrettyPrefix(kNumberType); return Base::WriteInt(i); }\n\n bool Uint(unsigned u) { PrettyPrefix(kNumberType); return Base::WriteUint(u); }\n\n bool Int64(int64_t i64) { PrettyPrefix(kNumberType); return Base::WriteInt64(i64); }\n\n bool Uint64(uint64_t u64) { PrettyPrefix(kNumberType); return Base::WriteUint64(u64); }\n\n bool Double(double d) { PrettyPrefix(kNumberType); return Base::WriteDouble(d); }\n\n\n\n bool RawNumber(const Ch* str, SizeType length, bool copy = false) {\n\n (void)copy;\n\n PrettyPrefix(kNumberType);\n\n return Base::WriteString(str, length);\n\n }\n\n\n\n bool String(const Ch* str, SizeType length, bool copy = false) {\n\n (void)copy;\n\n PrettyPrefix(kStringType);\n\n return Base::WriteString(str, length);\n", "file_path": "include/rapidjson/prettywriter.h", "rank": 87, "score": 49100.45291041745 }, { "content": " the event publisher should terminate the process.\n\n\\code\n\nconcept Handler {\n\n typename Ch;\n\n\n\n bool Null();\n\n bool Bool(bool b);\n\n bool Int(int i);\n\n bool Uint(unsigned i);\n\n bool Int64(int64_t i);\n\n bool Uint64(uint64_t i);\n\n bool Double(double d);\n\n /// enabled via kParseNumbersAsStringsFlag, string is not null-terminated (use length)\n\n bool RawNumber(const Ch* str, SizeType length, bool copy);\n\n bool String(const Ch* str, SizeType length, bool copy);\n\n bool StartObject();\n\n bool Key(const Ch* str, SizeType length, bool copy);\n\n bool EndObject(SizeType memberCount);\n\n bool StartArray();\n\n bool EndArray(SizeType elementCount);\n", "file_path": "include/rapidjson/reader.h", "rank": 88, "score": 49100.34242841136 }, { "content": " N16, // 10~1F\n\n N, N, StringToken, N, N, N, N, N, N, N, N, N, CommaToken, N, N, N, // 20~2F\n\n N, N, N, N, N, N, N, N, N, N, ColonToken, N, N, N, N, N, // 30~3F\n\n N16, // 40~4F\n\n N, N, N, N, N, N, N, N, N, N, N, LeftBracketToken, N, RightBracketToken, N, N, // 50~5F\n\n N, N, N, N, N, N, FalseToken, N, N, N, N, N, N, N, NullToken, N, // 60~6F\n\n N, N, N, N, TrueToken, N, N, N, N, N, N, LeftCurlyBracketToken, N, RightCurlyBracketToken, N, N, // 70~7F\n\n N16, N16, N16, N16, N16, N16, N16, N16 // 80~FF\n\n };\n\n#undef N\n\n#undef N16\n\n//!@endcond\n\n\n\n if (sizeof(Ch) == 1 || static_cast<unsigned>(c) < 256)\n\n return static_cast<Token>(tokenMap[static_cast<unsigned char>(c)]);\n\n else\n\n return NumberToken;\n\n }\n\n\n\n RAPIDJSON_FORCEINLINE IterativeParsingState Predict(IterativeParsingState state, Token token) {\n", "file_path": "include/rapidjson/reader.h", "rank": 89, "score": 49100.302925749194 }, { "content": "\n\n bool WriteUint64(uint64_t u64) {\n\n char buffer[20];\n\n char* end = internal::u64toa(u64, buffer);\n\n PutReserve(*os_, static_cast<size_t>(end - buffer));\n\n for (char* p = buffer; p != end; ++p)\n\n PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));\n\n return true;\n\n }\n\n\n\n bool WriteDouble(double d) {\n\n if (internal::Double(d).IsNanOrInf()) {\n\n if (!(writeFlags & kWriteNanAndInfFlag))\n\n return false;\n\n if (internal::Double(d).IsNan()) {\n\n PutReserve(*os_, 3);\n\n PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N');\n\n return true;\n\n }\n\n if (internal::Double(d).Sign()) {\n", "file_path": "include/rapidjson/writer.h", "rank": 90, "score": 49100.2794465558 }, { "content": "\n\n bool CheckInt(Context& context, int64_t i) const {\n\n if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType))))\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n\n\n if (!minimum_.IsNull()) {\n\n if (minimum_.IsInt64()) {\n\n if (exclusiveMinimum_ ? i <= minimum_.GetInt64() : i < minimum_.GetInt64())\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());\n\n }\n\n else if (minimum_.IsUint64()) {\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString()); // i <= max(int64_t) < minimum.GetUint64()\n\n }\n\n else if (!CheckDoubleMinimum(context, static_cast<double>(i)))\n\n return false;\n\n }\n\n\n\n if (!maximum_.IsNull()) {\n\n if (maximum_.IsInt64()) {\n\n if (exclusiveMaximum_ ? i >= maximum_.GetInt64() : i > maximum_.GetInt64())\n", "file_path": "include/rapidjson/schema.h", "rank": 91, "score": 49099.712343373314 }, { "content": " RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());\n\n }\n\n else if (maximum_.IsUint64())\n\n /* do nothing */; // i <= max(int64_t) < maximum_.GetUint64()\n\n else if (!CheckDoubleMaximum(context, static_cast<double>(i)))\n\n return false;\n\n }\n\n\n\n if (!multipleOf_.IsNull()) {\n\n if (multipleOf_.IsUint64()) {\n\n if (static_cast<uint64_t>(i >= 0 ? i : -i) % multipleOf_.GetUint64() != 0)\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());\n\n }\n\n else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))\n\n return false;\n\n }\n\n\n\n return true;\n\n }\n\n\n", "file_path": "include/rapidjson/schema.h", "rank": 92, "score": 49099.63395989784 }, { "content": " }\n\n if (IsInt64()) {\n\n int64_t i = GetInt64();\n\n volatile double d = static_cast<double>(i);\n\n return (d >= static_cast<double>(std::numeric_limits<int64_t>::min()))\n\n && (d < static_cast<double>(std::numeric_limits<int64_t>::max()))\n\n && (i == static_cast<int64_t>(d));\n\n }\n\n return true; // double, int, uint are always lossless\n\n }\n\n\n\n // Checks whether a number is a float (possible lossy).\n\n bool IsFloat() const {\n\n if ((data_.f.flags & kDoubleFlag) == 0)\n\n return false;\n\n double d = GetDouble();\n\n return d >= -3.4028234e38 && d <= 3.4028234e38;\n\n }\n\n // Checks whether a number can be losslessly converted to a float.\n\n bool IsLosslessFloat() const {\n", "file_path": "include/rapidjson/document.h", "rank": 93, "score": 49099.317997681515 }, { "content": " GenericDocument& d_;\n\n };\n\n\n\n // callers of the following private Handler functions\n\n // template <typename,typename,typename> friend class GenericReader; // for parsing\n\n template <typename, typename> friend class GenericValue; // for deep copying\n\n\n\npublic:\n\n // Implementation of Handler\n\n bool Null() { new (stack_.template Push<ValueType>()) ValueType(); return true; }\n\n bool Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b); return true; }\n\n bool Int(int i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n\n bool Uint(unsigned i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n\n bool Int64(int64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n\n bool Uint64(uint64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n\n bool Double(double d) { new (stack_.template Push<ValueType>()) ValueType(d); return true; }\n\n\n\n bool RawNumber(const Ch* str, SizeType length, bool copy) { \n\n if (copy) \n\n new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());\n", "file_path": "include/rapidjson/document.h", "rank": 94, "score": 49098.99862272712 }, { "content": " RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());\n\n return true;\n\n }\n\n\n\n bool CheckDoubleMaximum(Context& context, double d) const {\n\n if (exclusiveMaximum_ ? d >= maximum_.GetDouble() : d > maximum_.GetDouble())\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());\n\n return true;\n\n }\n\n\n\n bool CheckDoubleMultipleOf(Context& context, double d) const {\n\n double a = std::abs(d), b = std::abs(multipleOf_.GetDouble());\n\n double q = std::floor(a / b);\n\n double r = a - q * b;\n\n if (r > 0.0)\n\n RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());\n\n return true;\n\n }\n\n\n\n struct Property {\n", "file_path": "include/rapidjson/schema.h", "rank": 95, "score": 49098.993565228244 }, { "content": " if (!AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size))\n\n return NULL;\n\n\n\n void *buffer = reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size;\n\n chunkHead_->size += size;\n\n return buffer;\n\n }\n\n\n\n //! Resizes a memory block (concept Allocator)\n\n void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {\n\n if (originalPtr == 0)\n\n return Malloc(newSize);\n\n\n\n if (newSize == 0)\n\n return NULL;\n\n\n\n originalSize = RAPIDJSON_ALIGN(originalSize);\n\n newSize = RAPIDJSON_ALIGN(newSize);\n\n\n\n // Do not shrink if new size is smaller than original\n", "file_path": "include/rapidjson/allocators.h", "rank": 96, "score": 49098.93328840451 }, { "content": " useDouble = true;\n\n break;\n\n }\n\n i64 = i64 * 10 + static_cast<unsigned>(s.TakePush() - '0');\n\n significandDigit++;\n\n }\n\n }\n\n\n\n // Force double for big integer\n\n if (useDouble) {\n\n while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n\n if (RAPIDJSON_UNLIKELY(d >= 1.7976931348623157e307)) // DBL_MAX / 10.0\n\n RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);\n\n d = d * 10 + (s.TakePush() - '0');\n\n }\n\n }\n\n\n\n // Parse frac = decimal-point 1*DIGIT\n\n int expFrac = 0;\n\n size_t decimalPosition;\n", "file_path": "include/rapidjson/reader.h", "rank": 97, "score": 49098.08059920675 }, { "content": " if (originalSize >= newSize)\n\n return originalPtr;\n\n\n\n // Simply expand it if it is the last allocation and there is sufficient space\n\n if (originalPtr == reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size - originalSize) {\n\n size_t increment = static_cast<size_t>(newSize - originalSize);\n\n if (chunkHead_->size + increment <= chunkHead_->capacity) {\n\n chunkHead_->size += increment;\n\n return originalPtr;\n\n }\n\n }\n\n\n\n // Realloc process: allocate and copy memory, do not free original buffer.\n\n if (void* newBuffer = Malloc(newSize)) {\n\n if (originalSize)\n\n std::memcpy(newBuffer, originalPtr, originalSize);\n\n return newBuffer;\n\n }\n\n else\n\n return NULL;\n", "file_path": "include/rapidjson/allocators.h", "rank": 98, "score": 49097.06166825529 }, { "content": "\n\n\tauto x = new double[SIZE]();\n\n\tauto y = new double[SIZE]();\n\n\n\n\n\n\t// initial flow rate\n\n\tdouble qx_initial = 0.0;\n\n\tdouble qy_initial = 0.0;\n\n\n\n\t// Mesh-grid propertise\n\n\tlx = xmax - xmin;\n\n\tly = ymax - ymin;\n\n\tdx = (double)lx / (double)SIZE;\n\n\tdy = (double)ly / (double)SIZE;\n\n\n\n\tFILE *fp2 = fopen(\"init_topo.txt\", \"w\");\n\n\tif (fp2 == NULL){\n\n\t\tprintf(\"Error opening file!\\n\");\n\n\t\texit(1);\n\n\t}\n", "file_path": "examples/FloodPedestrian_2018/Flood_XML_inpGen/XML_inpGen/xmlGen.cpp", "rank": 99, "score": 64.35373287703062 } ]
C++
LuaKitProject/src/Projects/jni/com_common_luakit_LuaHelper.cpp
williamwen1986/Luakit
2e113a3b429a8205cf8ac0dbc074480906b34384
#include <com_common_luakit_LuaHelper.h> #include "base/logging.h" #include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "common/business_main_delegate.h" #include "common/business_runtime.h" #include "base/android/base_jni_registrar.h" #include "base/android/jni_android.h" #include "JniEnvWrapper.h" #include "base/thread_task_runner_handle.h" #include "common/base_lambda_support.h" #include "tools/lua_helpers.h" #include "JniLuaConvertor.h" #ifdef __cplusplus extern "C" { #endif #include "lua.h" #include "lauxlib.h" JNIEXPORT void JNICALL Java_com_common_luakit_LuaHelper_startLuaKitNative (JNIEnv *env, jclass c, jobject context) { static bool hasStartLuakit = false; if (!hasStartLuakit) { base::android::InitApplicationContext(env, base::android::ScopedJavaLocalRef<jobject>(env, context)); LOG(ERROR) << "nativeNewObject support ... "; setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA")); BusinessMainDelegate* delegate(new BusinessMainDelegate()); BusinessRuntime* Business_runtime(BusinessRuntime::Create()); Business_runtime->Initialize(delegate); Business_runtime->Run(); } else { assert(0); } } void pushLuaModule(std::string moduleName) { lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) std::string lua = "TEM_OC_OBJECT = require('"+ moduleName +"')"; doString(L, lua.c_str()); lua_getglobal(L, "TEM_OC_OBJECT"); lua_pushnil(L); lua_setglobal(L, "TEM_OC_OBJECT"); END_STACK_MODIFY(L, 1) } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { int err = lua_pcall(L, 0, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName,jobject p1) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); int err = lua_pcall(L, 1, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName,jobject p1, jobject p2) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); int err = lua_pcall(L, 2, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName, jobject p1, jobject p2, jobject p3) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); object_fromjava(L, env ,p3); int err = lua_pcall(L, 3, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName, jobject p1,jobject p2,jobject p3,jobject p4) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); object_fromjava(L, env ,p3); object_fromjava(L, env ,p4); int err = lua_pcall(L, 4, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName,jobject p1,jobject p2,jobject p3,jobject p4,jobject p5) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); object_fromjava(L, env ,p3); object_fromjava(L, env ,p4); object_fromjava(L, env ,p5); int err = lua_pcall(L, 5, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } jint JNI_OnLoad(JavaVM* jvm, void* reserved) { JniEnvWrapper env(jvm); JNIEnv * envp = env; LOG(INFO) << "JNI_Onload start"; base::android::InitVM(jvm); if (!base::android::RegisterJni(env)) { LOG(ERROR)<<"base::android::RegisterJni(env) error"; return -1; } CommandLine::Init(0, nullptr); LOG(INFO) << "JNI_Onload end"; return JNI_VERSION_1_6; } #ifdef __cplusplus } #endif
#include <com_common_luakit_LuaHelper.h> #include "base/logging.h" #include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "common/business_main_delegate.h" #include "common/business_runtime.h" #include "base/android/base_jni_registrar.h" #include "base/android/jni_android.h" #include "JniEnvWrapper.h" #include "base/thread_task_runner_handle.h" #include "common/base_lambda_support.h" #include "tools/lua_helpers.h" #include "JniLuaConvertor.h" #ifdef __cplusplus extern "C" { #endif #include "lua.h" #include "lauxlib.h" JNIEXPORT void JNICALL Java_com_common_luakit_LuaHelper_startLuaKitNative (JNIEnv *env, jclass c, jobject context) { static bool hasStartLuakit = false; if (!hasStartLuakit) { base::android::InitApplicationContext(env, base::android::ScopedJavaLocalRef<jobject>(env, context)); LOG(ERROR) << "nativeNewObject support ... "; setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA")); BusinessMainDelegate* delegate(new BusinessMainDelegate()); BusinessRuntime* Business_runtime(BusinessRuntime::Create()); Business_runtime->Initialize(delegate); Business_runtime->Run(); } else { assert(0); } } void pushLuaModule(std::string moduleName) { lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) std::string lua = "TEM_OC_OBJECT = require('"+ moduleName +"')"; doString(L, lua.c_str()); lua_getglobal(L, "TEM_OC_OBJECT"); lua_pushnil(L); lua_setglobal(L, "TEM_OC_OBJECT"); END_STACK_MODIFY(L, 1) } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { int err = lua_pcall(L, 0, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName,jobject p1) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); int err = lua_pcall(L, 1, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName,jobject p1, jobject p2) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); int err = lua_pcall(L, 2, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName, jobject p1, jobject p2, jobject p3) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); object_fromjava(L, env ,p3); int err = lua_pcall(L, 3, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName, jobject p1,jobject p2,jobject p3,jobject p4) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); object_fromjava(L, env ,p3); object_fromjava(L, env ,p4); int err = lua_pcall(L, 4, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } JNIEXPORT jobject JNICALL Java_com_common_luakit_LuaHelper_callLuaFunction__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2Ljava_lang_Object_2 (JNIEnv *env, jclass, jstring moduleName, jstring methodName,jobject p1,jobject p2,jobject p3,jobject p4,jobject p5) { const char* module = env->GetStringUTFChars((jstring)moduleName, NULL); const char* method = env->GetStringUTFChars((jstring)methodName, NULL); lua_State * L = BusinessThread::GetCurrentThreadLuaState(); BEGIN_STACK_MODIFY(L) pushLuaModule(module); lua_pushstring(L, method); lua_rawget(L, -2); jobject ret = NULL; if (lua_isfunction(L, -1)) { object_fromjava(L, env ,p1); object_fromjava(L, env ,p2); object_fromjava(L, env ,p3); object_fromjava(L, env ,p4); object_fromjava(L, env ,p5); int err = lua_pcall(L, 5, 1, 0); if (err != 0) { luaError(L,"callLuaFunction call error"); } else { ret = object_copyToJava(L, env,-1); } } else { luaError(L,"callLuaFunction call error no such function"); } END_STACK_MODIFY(L, 0) env->ReleaseStringUTFChars((jstring)moduleName, module); env->ReleaseStringUTFChars((jstring)methodName, method); return ret; } jint JNI_OnLoad(JavaVM* jvm, void* reserved) { JniEnvWrapper env(jvm); JNIEnv * envp = env; LOG(INFO) << "J
#ifdef __cplusplus } #endif
NI_Onload start"; base::android::InitVM(jvm); if (!base::android::RegisterJni(env)) { LOG(ERROR)<<"base::android::RegisterJni(env) error"; return -1; } CommandLine::Init(0, nullptr); LOG(INFO) << "JNI_Onload end"; return JNI_VERSION_1_6; }
function_block-function_prefixed
[ { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,\n\n P6)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<6, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n typedef UnwrapTraits<P5> Bound5UnwrapTraits;\n\n typedef UnwrapTraits<P6> Bound6UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4, const P5& p5, const P6& p6)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 0, "score": 484585.3252438573 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,\n\n P7)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<7, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n typedef UnwrapTraits<P5> Bound5UnwrapTraits;\n\n typedef UnwrapTraits<P6> Bound6UnwrapTraits;\n\n typedef UnwrapTraits<P7> Bound7UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4, const P5& p5, const P6& p6, const P7& p7)\n\n : runnable_(runnable),\n\n p1_(p1),\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 1, "score": 472099.20887192246 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,\n\n P6)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<6, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n typedef UnwrapTraits<P5> Bound5UnwrapTraits;\n\n typedef UnwrapTraits<P6> Bound6UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4, const P5& p5, const P6& p6)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n", "file_path": "LuaKitProject/src/Projects/base/bind_internal.h", "rank": 2, "score": 440797.76784805424 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,\n\n P7)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<7, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n typedef UnwrapTraits<P5> Bound5UnwrapTraits;\n\n typedef UnwrapTraits<P6> Bound6UnwrapTraits;\n\n typedef UnwrapTraits<P7> Bound7UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4, const P5& p5, const P6& p6, const P7& p7)\n\n : runnable_(runnable),\n\n p1_(p1),\n", "file_path": "LuaKitProject/src/Projects/base/bind_internal.h", "rank": 3, "score": 428803.9548510371 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3, P4,\n\n P5)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<5, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n typedef UnwrapTraits<P5> Bound5UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4, const P5& p5)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n\n p3_(p3),\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 4, "score": 426589.1388925977 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3, P4,\n\n P5)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<5, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n typedef UnwrapTraits<P5> Bound5UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4, const P5& p5)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n\n p3_(p3),\n", "file_path": "LuaKitProject/src/Projects/base/bind_internal.h", "rank": 5, "score": 380495.4455715132 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3,\n\n P4)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<4, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n\n p3_(p3),\n\n p4_(p4) {\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 6, "score": 365472.78308186476 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<3, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n\n p3_(p3) {\n\n MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);\n\n }\n\n\n\n virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,\n\n P1>::Release(p1_); }\n\n\n\n RunnableType runnable_;\n\n P1 p1_;\n\n P2 p2_;\n\n P3 p3_;\n\n};\n\n\n\ntemplate <typename Runnable, typename RunType, typename P1, typename P2,\n\n typename P3, typename P4>\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 7, "score": 336638.5632800738 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3,\n\n P4)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<4, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n typedef UnwrapTraits<P4> Bound4UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,\n\n const P4& p4)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n\n p3_(p3),\n\n p4_(p4) {\n", "file_path": "LuaKitProject/src/Projects/base/bind_internal.h", "rank": 8, "score": 316946.6428193119 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<3, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n typedef UnwrapTraits<P3> Bound3UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2),\n\n p3_(p3) {\n\n MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);\n\n }\n\n\n\n virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,\n\n P1>::Release(p1_); }\n\n\n\n RunnableType runnable_;\n\n P1 p1_;\n\n P2 p2_;\n\n P3 p3_;\n\n};\n\n\n\ntemplate <typename Runnable, typename RunType, typename P1, typename P2,\n\n typename P3, typename P4>\n", "file_path": "LuaKitProject/src/Projects/base/bind_internal.h", "rank": 9, "score": 290536.01851527893 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<2, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2) {\n\n MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);\n\n }\n\n\n\n virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,\n\n P1>::Release(p1_); }\n\n\n\n RunnableType runnable_;\n\n P1 p1_;\n\n P2 p2_;\n\n};\n\n\n\ntemplate <typename Runnable, typename RunType, typename P1, typename P2,\n\n typename P3>\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 10, "score": 275805.51075533585 }, { "content": " unsigned long error;\n", "file_path": "LuaKitProject/src/Projects/openssl/openssl-1.1.1/include/openssl/err.h", "rank": 11, "score": 253918.25141200755 }, { "content": "struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<2, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n typedef UnwrapTraits<P2> Bound2UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1, const P2& p2)\n\n : runnable_(runnable),\n\n p1_(p1),\n\n p2_(p2) {\n\n MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);\n\n }\n\n\n\n virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,\n\n P1>::Release(p1_); }\n\n\n\n RunnableType runnable_;\n\n P1 p1_;\n\n P2 p2_;\n\n};\n\n\n\ntemplate <typename Runnable, typename RunType, typename P1, typename P2,\n\n typename P3>\n", "file_path": "LuaKitProject/src/Projects/base/bind_internal.h", "rank": 12, "score": 227423.49886276224 }, { "content": "class FooTest : public ::testing::TestWithParam<const char*> {\n\n // You can implement all the usual class fixture members here.\n\n};\n\n\n\n// Then, use the TEST_P macro to define as many parameterized tests\n\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n\n// or \"pattern\", whichever you prefer to think.\n\n\n\nTEST_P(FooTest, DoesBlah) {\n\n // Inside a test, access the test parameter with the GetParam() method\n\n // of the TestWithParam<T> class:\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n ...\n\n}\n\n\n\nTEST_P(FooTest, HasBlahBlah) {\n\n ...\n\n}\n\n\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n", "file_path": "LuaKitProject/src/Projects/testing/gtest/include/gtest/gtest-param-test.h", "rank": 13, "score": 217865.00474406793 }, { "content": "struct BindState<Runnable, RunType, void(P1)> : public BindStateBase {\n\n typedef Runnable RunnableType;\n\n typedef IsWeakMethod<HasIsMethodTag<Runnable>::value, P1> IsWeakCall;\n\n typedef Invoker<1, BindState, RunType> InvokerType;\n\n typedef typename InvokerType::UnboundRunType UnboundRunType;\n\n\n\n // Convenience typedefs for bound argument types.\n\n typedef UnwrapTraits<P1> Bound1UnwrapTraits;\n\n\n\n BindState(const Runnable& runnable, const P1& p1)\n\n : runnable_(runnable),\n\n p1_(p1) {\n\n MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);\n\n }\n\n\n\n virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,\n\n P1>::Release(p1_); }\n\n\n\n RunnableType runnable_;\n\n P1 p1_;\n\n};\n\n\n\ntemplate <typename Runnable, typename RunType, typename P1, typename P2>\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 14, "score": 211387.12270933058 }, { "content": "LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);\n", "file_path": "LuaKitProject/IOSFrameWork/include/lua.h", "rank": 15, "score": 203936.07181665706 }, { "content": "struct ForceVoidReturn;\n\n\n\ntemplate <typename R>\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 16, "score": 202166.79335179713 }, { "content": "LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/lua.h", "rank": 17, "score": 200674.82060406258 }, { "content": "LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);\n", "file_path": "LuaKitProject/IOSFrameWork/include/lua.h", "rank": 18, "score": 200059.4698277542 }, { "content": "LUA_API int (lua_isnumber) (lua_State *L, int idx);\n", "file_path": "LuaKitProject/IOSFrameWork/include/lua.h", "rank": 19, "score": 200041.81591270992 }, { "content": "LUAI_FUNC void luaC_callGCTM (lua_State *L);\n", "file_path": "LuaKitProject/IOSFrameWork/include/lgc.h", "rank": 20, "score": 199001.37066683162 }, { "content": "// Implements the ReturnNull() action.\n\nclass ReturnNullAction {\n\n public:\n\n // Allows ReturnNull() to be used in any pointer-returning function.\n\n template <typename Result, typename ArgumentTuple>\n\n static Result Perform(const ArgumentTuple&) {\n\n GTEST_COMPILE_ASSERT_(internal::is_pointer<Result>::value,\n\n ReturnNull_can_be_used_to_return_a_pointer_only);\n\n return NULL;\n\n }\n\n};\n\n\n", "file_path": "LuaKitProject/src/Projects/testing/gmock/include/gmock/gmock-actions.h", "rank": 21, "score": 198749.87394878166 }, { "content": "// Implements the Return() action.\n\nclass ReturnVoidAction {\n\n public:\n\n // Allows Return() to be used in any void-returning function.\n\n template <typename Result, typename ArgumentTuple>\n\n static void Perform(const ArgumentTuple&) {\n\n CompileAssertTypesEqual<void, Result>();\n\n }\n\n};\n\n\n\n// Implements the polymorphic ReturnRef(x) action, which can be used\n\n// in any function that returns a reference to the type of x,\n\n// regardless of the argument types.\n\ntemplate <typename T>\n", "file_path": "LuaKitProject/src/Projects/testing/gmock/include/gmock/gmock-actions.h", "rank": 22, "score": 198720.64463669903 }, { "content": "struct ForceVoidReturn<R()> {\n\n typedef void(RunType)();\n\n};\n\n\n\ntemplate <typename R, typename A1>\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 23, "score": 198713.37154396978 }, { "content": "LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/lua.h", "rank": 24, "score": 197651.71116994525 }, { "content": "LUA_API int (lua_isnumber) (lua_State *L, int idx);\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/lua.h", "rank": 25, "score": 197634.2067139701 }, { "content": "int lua_err(const char *result) {\n\n if(luaErrorFun != NULL){\n\n luaErrorFun(result);\n\n }\n\n LOG(ERROR)<<\"lua_err \\n\"<<result;\n\n return 0;\n\n}\n\n\n\nextern void luaError (lua_State *L, const char *error)\n\n{\n\n luaL_error(L, error);\n\n}\n\n\n\nextern void doString(lua_State* L,const char * s)\n\n{\n\n luaL_dostring(L, s);\n\n}\n\n\n\nextern void luaSetPackagePath(const char * path)\n\n{\n", "file_path": "LuaKitProject/src/Projects/lua-5.1.5/lua/tools/lua_helpers.cpp", "rank": 35, "score": 56.99798498081016 }, { "content": " jshort \t\tCallStaticShortMethod(const char* classsig, const char* name, const char* sig, ...);\n\n jint \t\tCallStaticIntMethod(const char* classsig, const char* name, const char* sig, ...);\n\n jlong \t\tCallStaticLongMethod(const char* classsig, const char* name, const char* sig, ...);\n\n jfloat \t\tCallStaticFloatMethod(const char* classsig, const char* name, const char* sig, ...);\n\n jdouble \tCallStaticDoubleMethod(const char* classsig, const char* name, const char* sig, ...);\n\n void \t\tCallStaticVoidMethod(const char* classsig, const char* name, const char* sig, ...);\n\n\n\n // new object\n\n jobject NewObject(const char* classSig, const char* constructorSig, ...);\n\n jobjectArray NewObjectArray(const char* classSig, int elementCount, jobject initialElement);\n\n\n\nprivate:\n\n void Init();\n\n\tJNIEnv* env_;\n\n\tbool attached_;\n\n\tstatic JavaVM* jvm_;\n\n};\n\n\n\n#endif /* JNIENVWRAPPER_H_ */\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.h", "rank": 36, "score": 56.03194785411029 }, { "content": "static jint InnerFunction(JNIEnv*, jclass) {\n\n return 0;\n\n}\n\n\n\n} // namespace android\n\n} // namespace base\n\n\n\nint main() {\n\n // On a regular application, you'd call AttachCurrentThread(). This sample is\n\n // not yet linking with all the libraries.\n\n JNIEnv* env = /* AttachCurrentThread() */ NULL;\n\n\n\n // This is how you call a java static method from C++.\n\n bool foo = base::android::Java_SampleForTests_staticJavaMethod(env);\n\n\n\n // This is how you call a java method from C++. Note that you must have\n\n // obtained the jobject somehow.\n\n jobject my_java_object = NULL;\n\n int bar = base::android::Java_SampleForTests_javaMethod(\n\n env, my_java_object, 1, 2);\n", "file_path": "LuaKitProject/src/Projects/base/android/jni_generator/sample_for_tests.cc", "rank": 37, "score": 55.33578648145573 }, { "content": "static jclass DoubleClass;\n\nstatic jclass HashmapClass;\n\nstatic jclass StringClass;\n\nstatic jclass ArraylistClass;\n\n\n\nstatic bool hasInitClass = false;\n\nstatic std::recursive_mutex globle_lock;\n\n\n\nstatic int\n\nlua_isinteger(lua_State *L, int index) {\n\n int32_t x = (int32_t)lua_tointeger(L,index);\n\n lua_Number n = lua_tonumber(L,index);\n\n return ((lua_Number)x==n);\n\n}\n\n\n\nstatic bool isJavaArray(JNIEnv *env , jobject o)\n\n{\n\n jclass clazz = env->GetObjectClass(o);\n\n jmethodID mid = env->GetMethodID(clazz, \"getClass\", \"()Ljava/lang/Class;\");\n\n jobject clsObj = env->CallObjectMethod(o, mid);\n", "file_path": "LuaKitProject/src/Projects/jni/JniLuaConvertor.cpp", "rank": 38, "score": 52.62395707783826 }, { "content": "#include \"lua_language.h\"\n\n#include \"LuakitLoader.h\"\n\n#include \"xxtea.h\"\n\n\n\nstatic bool _xxteaEnabled = false;\n\nstatic char* _xxteaKey = NULL;\n\nstatic int _xxteaKeyLen = 0;\n\nstatic char* _xxteaSign = NULL;\n\nstatic int _xxteaSignLen = 0;\n\n\n\ntypedef void (*LuaErrorFun)(const char *);\n\n\n\n#if defined(OS_IOS)\n\nstatic const int PATH_SERVICE_KEY = base::DIR_DOCUMENTS;\n\n#elif defined(OS_ANDROID)\n\nstatic const int PATH_SERVICE_KEY = base::DIR_ANDROID_APP_DATA;\n\n#endif\n\n\n\nstatic std::string packagePath = \"\";\n\n\n", "file_path": "LuaKitProject/src/Projects/lua-5.1.5/lua/tools/lua_helpers.cpp", "rank": 39, "score": 52.008663794836075 }, { "content": "\t\tobject_copyToJava(L, *env ,2)\n\n\t\t);\n\n\tenv->PopLocalFrame(NULL);\n\n return 0;\n\n}\n\n\n\nstatic const struct luaL_Reg metaFunctions[] = {\n\n {\"__gc\", __gc},\n\n {\"__call\", __call},\n\n {NULL, NULL}\n\n};\n\n\n\nstatic const struct luaL_Reg functions[] = {\n\n {NULL, NULL}\n\n};\n\n\n\nextern int luaopen_jni_callback(lua_State* L)\n\n{\n\n\tBEGIN_STACK_MODIFY(L);\n\n luaL_newmetatable(L, LUA_JNI_CALLBACK_METATABLE_NAME);\n", "file_path": "LuaKitProject/src/Projects/jni/JniCallbackHelper.cpp", "rank": 40, "score": 50.803003251207016 }, { "content": "// Static free functions declared and called directly from java.\n\nstatic jint Init(JNIEnv* env, jobject obj, jstring param) {\n\n return 0;\n\n}\n\n\n\nstatic jdouble GetDoubleFunction(JNIEnv*, jobject) {\n\n return 0;\n\n}\n\n\n\nstatic jfloat GetFloatFunction(JNIEnv*, jclass) {\n\n return 0;\n\n}\n\n\n\nstatic void SetNonPODDatatype(JNIEnv*, jobject, jobject) {\n\n}\n\n\n\nstatic jobject GetNonPODDatatype(JNIEnv*, jobject) {\n\n return NULL;\n\n}\n\n\n", "file_path": "LuaKitProject/src/Projects/base/android/jni_generator/sample_for_tests.cc", "rank": 41, "score": 50.111336561063474 }, { "content": "}\n\n\n\njboolean JniEnvWrapper::CallStaticBooleanMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jboolean, Boolean);\n\n}\n\n\n\njbyte JniEnvWrapper::CallStaticByteMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jbyte, Byte);\n\n}\n\n\n\njchar JniEnvWrapper::CallStaticCharMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jchar, Char);\n\n}\n\n\n\njshort JniEnvWrapper::CallStaticShortMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jshort, Short);\n\n}\n\n\n\njint JniEnvWrapper::CallStaticIntMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jint, Int);\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.cpp", "rank": 42, "score": 49.64403449590361 }, { "content": " &g_releaseTimer);\n\n env->CallStaticVoidMethod(g_TimerUtil_clazz,method_id,timer);\n\n jni_generator::CheckException(env);\n\n}\n\n\n\nstatic void timerCallJni(jlong ref, jint threadId) {\n\n BusinessThread::PostTask(threadId, FROM_HERE, base::BindLambda([=](){\n\n lua_State * state = BusinessThread::GetCurrentThreadLuaState();\n\n pushUserdataInWeakTable(state,(jobject)ref);\n\n if (!lua_isnil(state, -1)) {\n\n lua_getfield(state, -1, \"callback\");\n\n if (lua_isfunction(state, -1)) {\n\n int err = lua_pcall(state, 0, 0, 0);\n\n if (err != 0) {\n\n luaL_error(state,\"lua timer callback error\");\n\n }\n\n } else {\n\n lua_pop(state, 1);\n\n }\n\n }\n", "file_path": "LuaKitProject/src/Projects/extensions/timer/lua_timer_android.cpp", "rank": 43, "score": 49.543838116593435 }, { "content": " }\n\n }\n\n } else {\n\n lua_newtable(L);\n\n }\n\n } else {\n\n jclass clazz = env->GetObjectClass(o);\n\n jmethodID methodid = env->GetMethodID(clazz, \"onResult\", \"(Ljava/lang/Object;)V\");\n\n if (methodid != NULL)\n\n {\n\n push_jni_block(L,o);\n\n } else {\n\n luaL_error(L, \"pushOneObject error type is illigel\");\n\n }\n\n }\n\n}\n\n\n\nextern void object_fromjava(lua_State *L, JNIEnv *env, jobject o)\n\n{\n\n initClass(env);\n", "file_path": "LuaKitProject/src/Projects/jni/JniLuaConvertor.cpp", "rank": 45, "score": 49.08429282585523 }, { "content": "#ifdef __cplusplus\n\nextern \"C\" {\n\n#endif\n\n#include \"lauxlib.h\"\n\n#include \"lapi.h\"\n\n#ifdef __cplusplus\n\n}\n\n#endif\n\n#include \"lua_helpers.h\"\n\n#include \"JniCallbackHelper.h\"\n\n#include \"JavaRefCountedWrapper.h\"\n\n#include \"JniEnvWrapper.h\"\n\n#include \"JniLuaConvertor.h\"\n\n\n\n#define LUA_JNI_CALLBACK_METATABLE_NAME \"lua.jnicallback\"\n\n\n\nstatic int __gc(lua_State *L);\n\nstatic int __call(lua_State *L);\n\n\n\nstatic int __gc(lua_State *L)\n", "file_path": "LuaKitProject/src/Projects/jni/JniCallbackHelper.cpp", "rank": 46, "score": 48.35938151273295 }, { "content": " lua_pop(state, 1); \n\n }));\n\n}\n\n\n\n\n\nstatic void timerCall(JNIEnv* env, jclass jcaller, jlong ref, jint threadId) {\n\n timerCallJni(ref, threadId);\n\n}\n\n\n\nstatic const JNINativeMethod kMethodsTimerUtil[] = {\n\n { \"timerCall\",\n\n \"(JI)V\",\n\n reinterpret_cast<void*>(timerCall) }\n\n};\n\n\n\nextern bool RegisterTimerUtil(JNIEnv* env) {\n\n g_TimerUtil_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(\n\n base::android::GetClass(env, kTimerUtilClassPath).obj()));\n\n const int kMethodsTimerUtilSize = arraysize(kMethodsTimerUtil);\n\n\n", "file_path": "LuaKitProject/src/Projects/extensions/timer/lua_timer_android.cpp", "rank": 47, "score": 47.640011388324595 }, { "content": "extern \"C\" {\n\n#include \"lua.h\"\n\n#include \"lauxlib.h\"\n\n}\n\n#include \"tools/lua_helpers.h\"\n\n#include \"lua_notify.h\"\n\n#include \"common/notification_service.h\"\n\n#include \"common/base_lambda_support.h\"\n\n#include \"serialize.h\"\n\n\n\nstatic int postNotification(lua_State *L);\n\nstatic int createListener(lua_State *L);\n\nstatic int AddObserver(lua_State *L);\n\nstatic int RemoveObserver(lua_State *L);\n\nstatic int __index(lua_State *L);\n\nstatic int __newindex(lua_State *L);\n\nstatic int __gc(lua_State *L);\n\n\n\nstatic int postNotification(lua_State *L)\n\n{\n", "file_path": "LuaKitProject/src/Projects/extensions/Notify/lua_notify.cpp", "rank": 48, "score": 47.45362761421213 }, { "content": "extern \"C\" {\n\n#include \"lua.h\"\n\n#include \"lauxlib.h\"\n\n}\n\n#include \"lua_async_socket.h\"\n\n#include \"tools/lua_helpers.h\"\n\n#include \"network/async_socket.h\"\n\n#include \"network/net/io_buffer.h\"\n\n#include \"common/base_lambda_support.h\"\n\nstatic int create(lua_State *L);\n\nstatic int __index(lua_State *L);\n\nstatic int __newindex(lua_State *L);\n\nstatic int __gc(lua_State *L);\n\nstatic int connect(lua_State *L);\n\nstatic int read(lua_State *L);\n\nstatic int write(lua_State *L);\n\nstatic int disconnect(lua_State *L);\n\nstatic int isConnected(lua_State *L);\n\n\n\nstatic int create(lua_State *L)\n", "file_path": "LuaKitProject/src/Projects/extensions/AsyncSocket/lua_async_socket.cpp", "rank": 49, "score": 47.13587473757442 }, { "content": " return (*function)(p.a, p.b, p.c, p.d, c.a, c.b, c.c, c.d, c.e, c.f);\n\n}\n\n\n\n// 5 - 0\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple0& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple0& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e);\n\n}\n\n\n\n// 5 - 1\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 50, "score": 46.11164982593559 }, { "content": " {\"postToThreadSync\", postToThreadSync},\n\n {\"synchronized\", synchronized},\n\n {\"unpack\", unpack},\n\n {NULL, NULL}\n\n};\n\n\n\nstatic int unpack(lua_State *L){\n\n return seri_unpack(L);\n\n}\n\n\n\nstatic int synchronized(lua_State *L){\n\n std::lock_guard<std::recursive_mutex> guard(globle_lock);\n\n BEGIN_STACK_MODIFY(L)\n\n if(lua_isfunction(L, -1)) {\n\n int err = lua_pcall(L, 0, 0, 0);\n\n if (err != 0) {\n\n luaL_error(L,\"synchronized call error\");\n\n }\n\n } else {\n\n luaL_error(L, \"can only synchronized lua function\");\n", "file_path": "LuaKitProject/src/Projects/extensions/thread/lua_thread.cpp", "rank": 52, "score": 45.77394212917903 }, { "content": "template <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename C1>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple1<C1>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename C1>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple1<C1>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, c.a);\n\n}\n\n\n\n// 5 - 2\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename C1, typename C2>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 53, "score": 45.0597766489209 }, { "content": "extern \"C\" {\n\n#include \"lua.h\"\n\n#include \"lualib.h\"\n\n#include \"lauxlib.h\"\n\n}\n\n#include \"tools/lua_helpers.h\"\n\n#include \"serialize.h\"\n\n#include \"lua_thread.h\"\n\n#include \"common/base_lambda_support.h\"\n\n#include \"common/business_runtime.h\"\n\n#include \"base/synchronization/waitable_event.h\"\n\n#include \"base/threading/thread_restrictions.h\"\n\n#include <iostream>\n\n#include <time.h>\n\n\n\n\n\nstatic int unpack(lua_State *L);\n\nstatic int postToThread(lua_State *L);\n\nstatic int postToThreadSync(lua_State *L);\n\nstatic int createThread(lua_State *L);\n", "file_path": "LuaKitProject/src/Projects/extensions/thread/lua_thread.cpp", "rank": 54, "score": 44.92634865421135 }, { "content": "}\n\n\n\njlong JniEnvWrapper::CallStaticLongMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jlong, Long);\n\n}\n\n\n\njfloat JniEnvWrapper::CallStaticFloatMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jfloat, Float);\n\n}\n\n\n\njdouble JniEnvWrapper::CallStaticDoubleMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_STATIC_TYPE_METHOD_IMPL(jdouble, Double);\n\n}\n\n\n\nvoid JniEnvWrapper::CallStaticVoidMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tjmethodID methodid = JniClassMember::GetInstance()->GetStaticMethod(env_, obj, classsig, name, sig);\n\n\tDCHECK(methodid != 0);\n\n\tva_list args;\n\n\tva_start (args, sig);\n\n\tenv_->CallStaticVoidMethodV(env_->GetObjectClass(obj), methodid, args);\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.cpp", "rank": 55, "score": 44.82713508652614 }, { "content": " jfloat CallFloatMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jdouble CallDoubleMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n void CallVoidMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n\n\n // call static method\n\n jobject \tCallStaticObjectMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jboolean \tCallStaticBooleanMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jbyte \t\tCallStaticByteMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jchar \t\tCallStaticCharMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jshort \t\tCallStaticShortMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jint \t\tCallStaticIntMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jlong \t\tCallStaticLongMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jfloat \t\tCallStaticFloatMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n jdouble \tCallStaticDoubleMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n void \t\tCallStaticVoidMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...);\n\n\n\n\tjobject \tCallStaticObjectMethod(const char* classsig, const char* name, const char* sig, ...);\n\n jboolean \tCallStaticBooleanMethod(const char* classsig, const char* name, const char* sig, ...);\n\n jbyte \t\tCallStaticByteMethod(const char* classsig, const char* name, const char* sig, ...);\n\n jchar \t\tCallStaticCharMethod(const char* classsig, const char* name, const char* sig, ...);\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.h", "rank": 56, "score": 44.70118178894728 }, { "content": "}\n\n\n\n// Tests streaming NULL pointers to testing::Message.\n\nTEST(MessageTest, NullPointers) {\n\n Message msg;\n\n char* const p1 = NULL;\n\n unsigned char* const p2 = NULL;\n\n int* p3 = NULL;\n\n double* p4 = NULL;\n\n bool* p5 = NULL;\n\n Message* p6 = NULL;\n\n\n\n msg << p1 << p2 << p3 << p4 << p5 << p6;\n\n ASSERT_STREQ(\"(null)(null)(null)(null)(null)(null)\",\n\n msg.GetString().c_str());\n\n}\n\n\n\n// Tests streaming wide strings to testing::Message.\n\nTEST(MessageTest, WideStrings) {\n\n // Streams a NULL of type const wchar_t*.\n", "file_path": "LuaKitProject/src/Projects/testing/gtest/test/gtest_unittest.cc", "rank": 57, "score": 44.34519818004494 }, { "content": "}\n\n\n\n// 6 - 0\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename P6>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple0& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename P6>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple0& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, p.f);\n\n}\n\n\n\n// 6 - 1\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 58, "score": 44.331849365009475 }, { "content": "}\n\n\n\njbyte \t\tJniEnvWrapper::CallStaticByteMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_CLASS_STATIC_TYPE_METHOD_IMPL(jbyte, Byte);\n\n}\n\n\n\njchar \t\tJniEnvWrapper::CallStaticCharMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_CLASS_STATIC_TYPE_METHOD_IMPL(jchar, Char);\n\n}\n\n\n\njshort \t\tJniEnvWrapper::CallStaticShortMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_CLASS_STATIC_TYPE_METHOD_IMPL(jshort, Short);\n\n}\n\n\n\njint \t\tJniEnvWrapper::CallStaticIntMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_CLASS_STATIC_TYPE_METHOD_IMPL(jint, Int);\n\n}\n\n\n\njlong \t\tJniEnvWrapper::CallStaticLongMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_CLASS_STATIC_TYPE_METHOD_IMPL(jlong, Long);\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.cpp", "rank": 59, "score": 44.330537196282556 }, { "content": "\t\t\t\treturn o;\n\n\t\t\t}\n\n\t\t}\n\n\t\tvoid ConvertToNative(JNIEnv* env, jobject source, unsigned char& target) {\n\n\t\t\tif (env->IsSameObject(source, NULL)) {\n\n\t\t\t\ttarget = 0;\n\n\t\t\t} else {\n\n\t\t\t\tJniEnvWrapper envw(env);\n\n\t\t\t\ttarget = envw.CallByteMethod(source, classSig, byteValue.name, byteValue.sig);\n\n\t\t\t}\n\n\t\t}\n\n\t\tIMPLEMENT_DIRECT_CONVERT_TO_NATIVE(unsigned char)\n\n\t};\n\n\n\n\tnamespace Integer {\n\n\t\tjobject ConvertToJava(JNIEnv* env, int source) {\n\n\t\t\tstatic jobject ZERO = NULL;\n\n\t\t\tif (source == 0) {\n\n\t\t\t\tif (ZERO == NULL) {\n\n\t\t\t\t\tjclass clazz = env->FindClass(classSig);\n", "file_path": "LuaKitProject/src/Projects/jni/JNIModel.cpp", "rank": 60, "score": 44.261165092111625 }, { "content": " typename P3, typename P4, typename P5, typename P6, typename C1>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple1<C1>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename P6, typename C1>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple1<C1>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a);\n\n}\n\n\n\n// 6 - 2\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename P6, typename C1,\n\n typename C2>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 61, "score": 44.235644712731116 }, { "content": "extern \"C\" {\n\n#include \"lua.h\"\n\n#include \"lauxlib.h\"\n\n}\n\n#include \"tools/lua_helpers.h\"\n\n#include \"lua_http.h\"\n\n#include \"network/async_cgi_task_dispatcher.h\"\n\n#include \"common/base_lambda_support.h\"\n\n#include \"lua_http_task.h\"\n\n#include \"base/synchronization/waitable_event.h\"\n\n#include \"base/threading/thread_restrictions.h\"\n\n\n\nstatic scoped_refptr<network::HttpCgiTaskDispatcher> dispatcher = NULL;\n\nstatic int request(lua_State *L);\n\n\n\nstatic int __newindex(lua_State *L)\n\n{\n\n BEGIN_STACK_MODIFY(L);\n\n // Add value to the userdata's environment table.\n\n lua_getfenv(L, 1);\n", "file_path": "LuaKitProject/src/Projects/extensions/HTTP/lua_http.cpp", "rank": 62, "score": 44.203310823962155 }, { "content": "extern \"C\" {\n\n#include \"lua.h\"\n\n#include \"lauxlib.h\"\n\n}\n\n#include \"lua_notification_utility.h\"\n\n#include \"common/base_lambda_support.h\"\n\n#include \"tools/lua_helpers.h\"\n\n#include \"JniLuaConvertor.h\"\n\n#include \"JniEnvWrapper.h\"\n\n#include \"JavaRefCountedWrapper.h\"\n\n\n\nextern void notification_call_to_lua(LuaNotificationListener * l, int type, const content::NotificationSource& source, const content::NotificationDetails& details)\n\n{\n\n content::Details<void> content(details);\n\n void * d = content.ptr();\n\n jobject data = (jobject)d;\n\n\n\n BusinessThreadID from_thread_identifier;\n\n BusinessThread::GetCurrentThreadIdentifier(&from_thread_identifier);\n\n if (from_thread_identifier == l->threadId) {\n", "file_path": "LuaKitProject/src/Projects/extensions/Notify/lua_notification_utility_android.cpp", "rank": 63, "score": 43.67410658218346 }, { "content": "extern \"C\" {\n\n#include \"lua.h\"\n\n#include \"lauxlib.h\"\n\n}\n\n#include \"tools/lua_helpers.h\"\n\n#include \"lua_file.h\"\n\n#include \"base/file_util.h\"\n\n\n\nstatic int ComputeDirectorySize(lua_State *L);\n\nstatic int DeleteFile(lua_State *L);\n\nstatic int Move(lua_State *L);\n\nstatic int ReplaceFile(lua_State *L);\n\nstatic int CopyFile(lua_State *L);\n\nstatic int CopyDirectory(lua_State *L);\n\nstatic int PathExists(lua_State *L);\n\nstatic int DirectoryExists(lua_State *L);\n\nstatic int ContentsEqual(lua_State *L);\n\nstatic int TextContentsEqual(lua_State *L);\n\nstatic int ReadFile(lua_State *L);\n\nstatic int IsDirectoryEmpty(lua_State *L);\n", "file_path": "LuaKitProject/src/Projects/extensions/File/lua_file.cpp", "rank": 64, "score": 43.19697736831627 }, { "content": "}\n\n\n\nACTION_TEMPLATE(InvokeArgument,\n\n HAS_1_TEMPLATE_PARAMS(int, k),\n\n AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {\n\n return internal::CallableHelper<return_type>::Call(\n\n ::std::tr1::get<k>(args), p0, p1, p2, p3, p4);\n\n}\n\n\n\nACTION_TEMPLATE(InvokeArgument,\n\n HAS_1_TEMPLATE_PARAMS(int, k),\n\n AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {\n\n return internal::CallableHelper<return_type>::Call(\n\n ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);\n\n}\n\n\n\nACTION_TEMPLATE(InvokeArgument,\n\n HAS_1_TEMPLATE_PARAMS(int, k),\n\n AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {\n\n return internal::CallableHelper<return_type>::Call(\n", "file_path": "LuaKitProject/src/Projects/testing/gmock/include/gmock/gmock-generated-actions.h", "rank": 65, "score": 43.1566894830562 }, { "content": "\n\nextern jobject object_copyToJava(lua_State *L, JNIEnv *env, int stackIndex)\n\n{\n\n int type = lua_type(L,stackIndex);\n\n switch(type) {\n\n case LUA_TNIL:{\n\n return NULL;\n\n }\n\n break;\n\n case LUA_TBOOLEAN:{\n\n int ret = lua_toboolean(L, stackIndex);\n\n return JNIModel::Boolean::ConvertToJava(env,ret);\n\n }\n\n break;\n\n case LUA_TNUMBER:{\n\n if (lua_isinteger(L, stackIndex)) {\n\n lua_Integer ret = lua_tointeger(L,stackIndex);\n\n return JNIModel::Integer::ConvertToJava(env,ret);\n\n } else {\n\n lua_Number ret = lua_tonumber(L,stackIndex);\n", "file_path": "LuaKitProject/src/Projects/jni/JniLuaConvertor.cpp", "rank": 66, "score": 43.138807682198106 }, { "content": "\tCALL_TYPE_METHOD_IMPL(jint, Int);\n\n}\n\n\n\njlong JniEnvWrapper::CallLongMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_TYPE_METHOD_IMPL(jlong, Long);\n\n}\n\n\n\njfloat JniEnvWrapper::CallFloatMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_TYPE_METHOD_IMPL(jfloat, Float);\n\n}\n\n\n\njdouble JniEnvWrapper::CallDoubleMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_TYPE_METHOD_IMPL(jdouble, Double);\n\n}\n\n\n\nvoid JniEnvWrapper::CallVoidMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\t// LOG(INFO) << \"classsig = \" << classsig << \", name = \" << name << \", sig = \" << sig;\n\n\tjmethodID methodid = JniClassMember::GetInstance()->GetMethod(env_, obj, classsig, name, sig);\n\n\tif (methodid == 0) {\n\n LOG(ERROR) << \"methodid = 0. classsig = \" << classsig << \", name = \" << name << \", sig = \" << sig;\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.cpp", "rank": 67, "score": 43.048968211358606 }, { "content": "inline R DispatchToFunction(Function function,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple4<C1, C2, C3, C4>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d);\n\n}\n\n\n\n// 5 - 5\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename C1, typename C2,\n\n typename C3, typename C4, typename C5>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple5<C1, C2, C3, C4, C5>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d, c.e);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename C1, typename C2, typename C3,\n\n typename C4, typename C5>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 68, "score": 42.83843298055327 }, { "content": " \n\n END_STACK_MODIFY(L, 0)\n\n return 0;\n\n}\n\nstatic const struct luaL_Reg callBackMetaFunctions[] = {\n\n {\"__gc\", callbackGc},\n\n {\"__call\", callbackCall},\n\n {NULL, NULL}\n\n};\n\n\n\nstatic const struct luaL_Reg callBackFunctions[] = {\n\n {NULL, NULL}\n\n};\n\n\n\nstatic int callbackGc(lua_State *L) {\n\n thread::CallbackContext **instanceUserdata = (thread::CallbackContext **)luaL_checkudata(L, 1, LUA_CALLBACK_METATABLE_NAME);\n\n BusinessThreadID now_thread_identifier;\n\n BusinessThread::GetCurrentThreadIdentifier(&now_thread_identifier);\n\n thread::CallbackContext * localInstanceUserdata = *instanceUserdata;\n\n std::lock_guard<std::recursive_mutex> guard(localInstanceUserdata->lock);\n", "file_path": "LuaKitProject/src/Projects/extensions/thread/lua_thread.cpp", "rank": 69, "score": 42.77540938045041 }, { "content": " const Tuple2<C1, C2>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename C1, typename C2>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple2<C1, C2>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b);\n\n}\n\n\n\n// 5 - 3\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename C1, typename C2,\n\n typename C3>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple3<C1, C2, C3>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c);\n\n}\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 70, "score": 42.71845378665218 }, { "content": "\n\nvoid JniEnvWrapper::SetStaticIntField(jobject obj, const char* classsig, const char* name, jint value) {\n\n\tIMPL_SET_STATIC_TYPE_FIELD(Int, SIG_INT);\n\n}\n\n\n\nvoid JniEnvWrapper::SetStaticBoolField(jobject obj, const char* classsig, const char* name, jboolean value) {\n\n\tIMPL_SET_STATIC_TYPE_FIELD(Boolean, SIG_BOOL);\n\n}\n\n\n\nvoid JniEnvWrapper::SetStaticByteField(jobject obj, const char* classsig, const char* name, jbyte value) {\n\n\tIMPL_SET_STATIC_TYPE_FIELD(Byte, SIG_BYTE);\n\n}\n\n\n\nvoid JniEnvWrapper::SetStaticCharField(jobject obj, const char* classsig, const char* name, jchar value) {\n\n\tIMPL_SET_STATIC_TYPE_FIELD(Char, SIG_CHAR);\n\n}\n\n\n\nvoid JniEnvWrapper::SetStaticShortField(jobject obj, const char* classsig, const char* name, jshort value) {\n\n\tIMPL_SET_STATIC_TYPE_FIELD(Short, SIG_SHORT);\n\n}\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.cpp", "rank": 71, "score": 42.64269399788128 }, { "content": " object_fromjava(state, *env, dataPtr.get()->obj());\n\n int err = lua_pcall(state, 1, 0, 0);\n\n if (err != 0) {\n\n luaL_error(state,\"LuaNotificationListener::Observe call error %s\", lua_tostring(state, -1));\n\n }\n\n } else {\n\n int err = lua_pcall(state, 0, 0, 0);\n\n if (err != 0) {\n\n luaL_error(state,\"LuaNotificationListener::Observe call error %s\", lua_tostring(state, -1));\n\n }\n\n }\n\n } else {\n\n lua_pop(state, 1);\n\n }\n\n }\n\n lua_pop(state, 1);\n\n }));\n\n }\n\n}\n\n\n\n\n\n\n", "file_path": "LuaKitProject/src/Projects/extensions/Notify/lua_notification_utility_android.cpp", "rank": 72, "score": 42.463577083720466 }, { "content": " lua_newtable(L);\n\n JniEnvWrapper envw(env);\n\n env->PushLocalFrame(0);\n\n jint size = envw.CallIntMethod(o, JNIModel::ArrayList::classSig, JNIModel::ArrayList::size.name, JNIModel::ArrayList::size.sig);\n\n for (int i = 0; i < size; ++i)\n\n {\n\n lua_pushinteger(L,i+1);\n\n jobject val = envw.CallObjectMethod(o, JNIModel::ArrayList::classSig, JNIModel::ArrayList::get.name, JNIModel::ArrayList::get.sig,i);\n\n if (!env->IsSameObject(val, NULL)) {\n\n pushOneObject(L, env, val);\n\n lua_rawset(L, -3);\n\n } \n\n env->DeleteLocalRef(val);\n\n }\n\n env->PopLocalFrame(NULL);\n\n } else if (isJavaArray(env,o)){\n\n int length = env->GetArrayLength((jobjectArray)o);\n\n if (length > 0)\n\n {\n\n jobject val = (jobject)env->GetObjectArrayElement((jobjectArray)o, 0);\n", "file_path": "LuaKitProject/src/Projects/jni/JniLuaConvertor.cpp", "rank": 73, "score": 42.03983910979853 }, { "content": " ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);\n\n}\n\n\n\nACTION_TEMPLATE(InvokeArgument,\n\n HAS_1_TEMPLATE_PARAMS(int, k),\n\n AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {\n\n return internal::CallableHelper<return_type>::Call(\n\n ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);\n\n}\n\n\n\nACTION_TEMPLATE(InvokeArgument,\n\n HAS_1_TEMPLATE_PARAMS(int, k),\n\n AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {\n\n return internal::CallableHelper<return_type>::Call(\n\n ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);\n\n}\n\n\n\nACTION_TEMPLATE(InvokeArgument,\n\n HAS_1_TEMPLATE_PARAMS(int, k),\n\n AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {\n", "file_path": "LuaKitProject/src/Projects/testing/gmock/include/gmock/gmock-generated-actions.h", "rank": 74, "score": 42.00081461967367 }, { "content": "template <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename C1, typename C2, typename C3>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple3<C1, C2, C3>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c);\n\n}\n\n\n\n// 5 - 4\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename C1, typename C2,\n\n typename C3, typename C4>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple5<P1, P2, P3, P4, P5>& p,\n\n const Tuple4<C1, C2, C3, C4>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, c.a, c.b, c.c, c.d);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename C1, typename C2, typename C3,\n\n typename C4>\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 75, "score": 41.83913568573088 }, { "content": "\t\twb_table(L, b, index, depth+1,callbackContexts);\n\n\t\tbreak;\n\n\tdefault:\n\n\t\twb_free(b);\n\n\t\tluaL_error(L, \"Unsupport type %s to serialize\", lua_typename(L, type));\n\n\t}\n\n}\n\n\n\nstatic void\n\n_pack_from(lua_State *L, struct write_block *b, int count, std::list<thread::CallbackContext *> & callbackContext) {\n\n\tint from = lua_gettop(L) - count + 1;\n\n\tint i;\n\n\tfor (i=from;i<=lua_gettop(L);i++) {\n\n\t\t_pack_one(L, b , i, 0, callbackContext);\n\n\t}\n\n}\n\n\n\nextern struct block *\n\nseri_pack(lua_State *L ,std::list<thread::CallbackContext *> & callbackContext, int count) {\n\n if (count < 0) {\n", "file_path": "LuaKitProject/src/Projects/extensions/thread/serialize.cpp", "rank": 76, "score": 41.71812301129642 }, { "content": " if (lua_isfunction(L, -1)) {\n\n lua_pushlstring(L, (char *)(buffer->data()), rv);\n\n int err = lua_pcall(L, 1, 0, 0);\n\n if (err != 0) {\n\n luaL_error(L,\"async_socket readCallback error\");\n\n }\n\n } else {\n\n lua_pop(L, 1);\n\n }\n\n }\n\n lua_pop(L, 1);\n\n }\n\n }));\n\n END_STACK_MODIFY(L, 0)\n\n return 0;\n\n}\n\n\n\nstatic int write(lua_State *L)\n\n{\n\n BEGIN_STACK_MODIFY(L);\n", "file_path": "LuaKitProject/src/Projects/extensions/AsyncSocket/lua_async_socket.cpp", "rank": 77, "score": 41.71279261601784 }, { "content": "\t\treturn result;\n\n\t}\n\n\t\n\n\tvoid SetAtomicIntegerValue(JNIEnv *env, jobject integerRef, jint intValue)\n\n\t{\n\n \tif (integerRef == NULL)\n\n \treturn;\n\n \tjclass cls = env->GetObjectClass(integerRef);\n\n \tjmethodID mid = env->GetMethodID(cls, \"set\", \"(I)V\");\n\n \tif (mid == NULL){\n\n \tenv->DeleteLocalRef(cls);\n\n \treturn;\n\n \t}\n\n \tenv->CallVoidMethod(integerRef, mid, intValue);\n\n \tenv->DeleteLocalRef(cls);\n\n\t}\n\n\n\n\tvoid SetAtomicLongValue(JNIEnv *env, jobject integerRef, jlong longValue)\n\n\t{\n\n \tif (integerRef == NULL)\n", "file_path": "LuaKitProject/src/Projects/jni/JNIConversionImpl.cpp", "rank": 78, "score": 41.67660831709789 }, { "content": " const Tuple2<C1, C2>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename P6, typename C1, typename C2>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple2<C1, C2>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b);\n\n}\n\n\n\n// 6 - 3\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename P6, typename C1,\n\n typename C2, typename C3>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple3<C1, C2, C3>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c);\n\n}\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 79, "score": 41.6534713457062 }, { "content": "\n\n // Call ByteArrayOutputStream.toString()\n\n ScopedJavaLocalRef<jstring> exception_string(\n\n env, static_cast<jstring>(\n\n env->CallObjectMethod(bytearray_output_stream.obj(),\n\n bytearray_output_stream_tostring)));\n\n\n\n return ConvertJavaStringToUTF8(exception_string);\n\n}\n\n\n\n} // namespace\n\n\n\nnamespace base {\n\nnamespace android {\n\n\n\nJNIEnv* AttachCurrentThread() {\n\n DCHECK(g_jvm);\n\n JNIEnv* env = NULL;\n\n jint ret = g_jvm->AttachCurrentThread(&env, NULL);\n\n DCHECK_EQ(JNI_OK, ret);\n", "file_path": "LuaKitProject/src/Projects/base/android/jni_android.cc", "rank": 80, "score": 41.59625518215965 }, { "content": "extern \"C\" {\n\n#include \"lua.h\"\n\n#include \"lualib.h\"\n\n#include \"lauxlib.h\"\n\n}\n\n#include \"common/business_runtime.h\"\n\n#include \"common/base_lambda_support.h\"\n\n#include \"lua_timer.h\"\n\n#include \"lua_helpers.h\"\n\n#include \"base/timer/timer.h\"\n\n\n\nstatic int __newindex(lua_State *L)\n\n{\n\n BEGIN_STACK_MODIFY(L);\n\n // Add value to the userdata's environment table.\n\n lua_getfenv(L, 1);\n\n lua_insert(L, 2);\n\n lua_rawset(L, 2);\n\n END_STACK_MODIFY(L, 0);\n\n return 0;\n", "file_path": "LuaKitProject/src/Projects/extensions/timer/lua_timer.cpp", "rank": 81, "score": 41.47564167013605 }, { "content": "template <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename P6, typename C1, typename C2,\n\n typename C3>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple3<C1, C2, C3>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c);\n\n}\n\n\n\n// 6 - 4\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename P6, typename C1,\n\n typename C2, typename C3, typename C4>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple4<C1, C2, C3, C4>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c, c.d);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename P6, typename C1, typename C2,\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 82, "score": 41.25858666043044 }, { "content": "#include \"com_common_luakit_NotificationHelper.h\"\n\n#include \"common/notification_service.h\"\n\n#include \"common/notification_details.h\"\n\n#include \"common/notification_source.h\"\n\n#include \"lua_notify.h\"\n\n#include \"JniLuaConvertor.h\"\n\n#include \"base/logging.h\"\n\n#ifdef __cplusplus\n\nextern \"C\" {\n\n#endif\n\n#include \"lua.h\"\n\n#include \"lauxlib.h\"\n\n/*\n\n * Class: com_common_luakit_NotificationHelper\n\n * Method: postNotificationNative\n\n * Signature: (ILjava/lang/Object;)V\n\n */\n\nJNIEXPORT jlong JNICALL Java_com_common_luakit_NotificationHelper_postNotificationNative\n\n (JNIEnv * env, jclass c, jint type, jobject data)\n\n{\n\n Notification::sourceType s = Notification::ANDROID_SYS;\n\n content::NotificationService::current()->Notify(type,content::Source<Notification::sourceType>(&s),content::Details<void>((void *)data));\n\n}\n\n\n\n#ifdef __cplusplus\n\n}\n\n#endif", "file_path": "LuaKitProject/src/Projects/jni/com_common_luakit_NotificationHelper.cpp", "rank": 83, "score": 41.18773026629007 }, { "content": "{\n\n JavaRefCountedWrapper **instanceUserdata = (JavaRefCountedWrapper **)luaL_checkudata(L, 1, LUA_JNI_CALLBACK_METATABLE_NAME);\n\n delete *instanceUserdata;\n\n return 0;\n\n}\n\n\n\nstatic int __call(lua_State *L)\n\n{\n\n assert(lua_gettop(L) == 2);\n\n JavaRefCountedWrapper **instanceUserdata = (JavaRefCountedWrapper **)luaL_checkudata(L, 1, LUA_JNI_CALLBACK_METATABLE_NAME);\n\n JniEnvWrapper env;\n\n\tif (env->IsSameObject((*instanceUserdata)->obj(), NULL)) {\n\n\t\treturn 0;\n\n\t}\n\n\tjclass clazz = env->GetObjectClass((*instanceUserdata)->obj());\n\n jmethodID methodid = env->GetMethodID(clazz, \"onResult\", \"(Ljava/lang/Object;)V\");\n\n\tenv->PushLocalFrame(0);\n\n\tenv->CallVoidMethod(\n\n\t\t(*instanceUserdata)->obj(),\n\n\t\tmethodid,\n", "file_path": "LuaKitProject/src/Projects/jni/JniCallbackHelper.cpp", "rank": 84, "score": 41.07978295083992 }, { "content": "\tCALL_TYPE_METHOD_IMPL(jobject, Object);\n\n}\n\n\n\njboolean JniEnvWrapper::CallBooleanMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_TYPE_METHOD_IMPL(jboolean, Boolean);\n\n}\n\n\n\njbyte JniEnvWrapper::CallByteMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_TYPE_METHOD_IMPL(jbyte, Byte);\n\n}\n\n\n\njchar JniEnvWrapper::CallCharMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_TYPE_METHOD_IMPL(jchar, Char);\n\n}\n\n\n\njshort JniEnvWrapper::CallShortMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_TYPE_METHOD_IMPL(jshort, Short);\n\n}\n\n\n\njint JniEnvWrapper::CallIntMethod(jobject obj, const char* classsig, const char* name, const char* sig, ...){\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.cpp", "rank": 85, "score": 40.9755209076657 }, { "content": " lua_remove(L, -2);//盏顶是function\n\n if (lua_isfunction(L, -1)) {\n\n lua_pushcfunction(L, seri_unpack);\n\n lua_pushlightuserdata(L, params);\n\n int err = lua_pcall(L, 1, paramsNum, 0);\n\n \n\n if (err != 0) {\n\n luaL_error(L,\"seri_unpack call error\");\n\n } else {\n\n err = lua_pcall(L, paramsNum, 0, 0);\n\n if (err != 0) {\n\n luaL_error(L,\"call error %s\", lua_tostring(L, -1));\n\n }\n\n }\n\n } else {\n\n lua_pop(L, 1);\n\n }\n\n } else {\n\n //所有callbackContexts也暂时不能回收,等真正调用完才能回收,从weak表copy到strong表\n\n for(it=callbackContexts.begin();it!=callbackContexts.end();it++)\n", "file_path": "LuaKitProject/src/Projects/extensions/thread/lua_thread.cpp", "rank": 86, "score": 40.97399502081967 }, { "content": " HAS_1_TEMPLATE_PARAMS(typename, T),\n\n AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {\n\n return new T(p0, p1, p2, p3, p4);\n\n}\n\n\n\nACTION_TEMPLATE(ReturnNew,\n\n HAS_1_TEMPLATE_PARAMS(typename, T),\n\n AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {\n\n return new T(p0, p1, p2, p3, p4, p5);\n\n}\n\n\n\nACTION_TEMPLATE(ReturnNew,\n\n HAS_1_TEMPLATE_PARAMS(typename, T),\n\n AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {\n\n return new T(p0, p1, p2, p3, p4, p5, p6);\n\n}\n\n\n\nACTION_TEMPLATE(ReturnNew,\n\n HAS_1_TEMPLATE_PARAMS(typename, T),\n\n AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {\n", "file_path": "LuaKitProject/src/Projects/testing/gmock/include/gmock/gmock-generated-actions.h", "rank": 87, "score": 40.90070147522094 }, { "content": "}\n\n\n\njfloat \t\tJniEnvWrapper::CallStaticFloatMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_CLASS_STATIC_TYPE_METHOD_IMPL(jfloat, Float);\n\n}\n\n\n\njdouble \tJniEnvWrapper::CallStaticDoubleMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tCALL_CLASS_STATIC_TYPE_METHOD_IMPL(jdouble, Double);\n\n}\n\n\n\nvoid \t\tJniEnvWrapper::CallStaticVoidMethod(const char* classsig, const char* name, const char* sig, ...){\n\n\tjclass classid = JniClassMember::GetInstance()->GetClass(env_, classsig);\n\n\tDCHECK(classid != 0);\n\n\tjmethodID methodid = JniClassMember::GetInstance()->GetStaticMethod(env_, classid, classsig, name, sig);\n\n\tDCHECK(methodid != 0);\n\n\tva_list args;\n\n\tva_start (args, sig);\n\n\tenv_->CallStaticVoidMethodV(classid, methodid, args);\n\n\tva_end (args);\\\n\n}\n", "file_path": "LuaKitProject/src/Projects/jni/JniEnvWrapper.cpp", "rank": 88, "score": 40.86857519175198 }, { "content": " if (env->IsInstanceOf(val,ByteClass))\n\n {\n\n char * cPtr = new char [length];\n\n for (int i = 0; i < length; i++) {\n\n env->PushLocalFrame(0);\n\n jobject val = (jobject)env->GetObjectArrayElement((jobjectArray)o, i);\n\n cPtr[i] = JNIModel::Byte::ConvertToNative(env,val);\n\n env->PopLocalFrame(NULL);\n\n }\n\n lua_pushlstring(L, cPtr, length);\n\n delete []cPtr;\n\n } else {\n\n lua_newtable(L);\n\n for (int i = 0; i < length; i++) {\n\n env->PushLocalFrame(0);\n\n jobject val = (jobject)env->GetObjectArrayElement((jobjectArray)o, i);\n\n lua_pushinteger(L,i+1);\n\n pushOneObject(L,env,val);\n\n lua_rawset(L, -3);\n\n env->PopLocalFrame(NULL);\n", "file_path": "LuaKitProject/src/Projects/jni/JniLuaConvertor.cpp", "rank": 89, "score": 40.594276937521954 }, { "content": " return 1;\n\n}\n\n\n\nstatic const struct luaL_Reg metaFunctions[] = {\n\n {NULL, NULL}\n\n};\n\n\n\nstatic const struct luaL_Reg functions[] = {\n\n {\"getLanguageType\", getLanguageType},\n\n {NULL, NULL}\n\n};\n\n\n\nextern int luaopen_language(lua_State* L)\n\n{\n\n BEGIN_STACK_MODIFY(L);\n\n luaL_newmetatable(L, LUA_LANGUAGE_METATABLE_NAME);\n\n luaL_register(L, NULL, metaFunctions);\n\n luaL_register(L, LUA_LANGUAGE_METATABLE_NAME, functions);\n\n END_STACK_MODIFY(L, 0)\n\n return 0;\n\n}\n\n\n", "file_path": "LuaKitProject/src/Projects/extensions/language/lua_language.cpp", "rank": 90, "score": 40.58948921756013 }, { "content": " lua_State * state = BusinessThread::GetCurrentThreadLuaState();\n\n pushUserdataInWeakTable(state,l);\n\n if (!lua_isnil(state, -1)) {\n\n lua_pushinteger(state, type);\n\n lua_gettable(state, -2);\n\n if (lua_isfunction(state, -1)) {\n\n if (data) {\n\n JniEnvWrapper env;\n\n object_fromjava(state, *env, data);\n\n int err = lua_pcall(state, 1, 0, 0);\n\n if (err != 0) {\n\n luaL_error(state,\"LuaNotificationListener::Observe call error %s\", lua_tostring(state, -1));\n\n }\n\n } else {\n\n int err = lua_pcall(state, 0, 0, 0);\n\n if (err != 0) {\n\n luaL_error(state,\"LuaNotificationListener::Observe call error %s\", lua_tostring(state, -1));\n\n }\n\n }\n\n } else {\n", "file_path": "LuaKitProject/src/Projects/extensions/Notify/lua_notification_utility_android.cpp", "rank": 91, "score": 40.56028475718246 }, { "content": " void* pv2 = (void*)0xABC0; // NOLINT\n\n wchar_t* const p1 = reinterpret_cast<wchar_t*>(pv1);\n\n wchar_t* const p2 = reinterpret_cast<wchar_t*>(pv2);\n\n EXPECT_EQ(p0, p0);\n\n\n\n EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),\n\n \"Value of: p2\");\n\n EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),\n\n \"p2\");\n\n void* pv3 = (void*)0x1234; // NOLINT\n\n void* pv4 = (void*)0xABC0; // NOLINT\n\n const wchar_t* p3 = reinterpret_cast<const wchar_t*>(pv3);\n\n const wchar_t* p4 = reinterpret_cast<const wchar_t*>(pv4);\n\n EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p3, p4),\n\n \"p4\");\n\n}\n\n\n\n// Tests using other types of pointers in {EXPECT|ASSERT}_EQ.\n\nTEST(EqAssertionTest, OtherPointer) {\n\n ASSERT_EQ(static_cast<const int*>(NULL),\n\n static_cast<const int*>(NULL));\n\n EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(NULL),\n\n reinterpret_cast<const int*>(0x1234)),\n\n \"0x1234\");\n\n}\n\n\n", "file_path": "LuaKitProject/src/Projects/testing/gtest/test/gtest_unittest.cc", "rank": 92, "score": 40.42486762657591 }, { "content": " const P3& p3, const P4& p4, const P5& p5) {\n\n MutantRunner<R, Tuple0>* t =\n\n new MutantFunction<R, R (*)(X1, X2, X3, X4, X5),\n\n Tuple5<P1, P2, P3, P4, P5>, Tuple0>\n\n (function, MakeTuple(p1, p2, p3, p4, p5));\n\n return MutantFunctor<R, Tuple0>(t);\n\n}\n\n\n\n#ifdef GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING\n\ntemplate <typename R, typename T, typename U, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename X1, typename X2,\n\n typename X3, typename X4, typename X5>\n\ninline MutantFunctor<R, Tuple0>\n\nCreateFunctor(T** obj, R (U::*method)(X1, X2, X3, X4, X5), const P1& p1,\n\n const P2& p2, const P3& p3, const P4& p4, const P5& p5) {\n\n MutantRunner<R, Tuple0>* t =\n\n new MutantLateObjectBind<R, T, R (U::*)(X1, X2, X3, X4, X5),\n\n Tuple5<P1, P2, P3, P4, P5>, Tuple0>\n\n (obj, method, MakeTuple(p1, p2, p3, p4, p5));\n\n return MutantFunctor<R, Tuple0>(t);\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 93, "score": 40.35309760981466 }, { "content": "inline R DispatchToFunction(Function function,\n\n const Tuple3<P1, P2, P3>& p,\n\n const Tuple6<C1, C2, C3, C4, C5, C6>& c) {\n\n return (*function)(p.a, p.b, p.c, c.a, c.b, c.c, c.d, c.e, c.f);\n\n}\n\n\n\n// 4 - 0\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple4<P1, P2, P3, P4>& p,\n\n const Tuple0& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple4<P1, P2, P3, P4>& p,\n\n const Tuple0& c) {\n\n return (*function)(p.a, p.b, p.c, p.d);\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 94, "score": 40.3240252812114 }, { "content": " const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple5<C1, C2, C3, C4, C5>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c, c.d, c.e);\n\n}\n\n\n\n// 6 - 6\n\ntemplate <typename R, typename T, typename Method, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename P6, typename C1,\n\n typename C2, typename C3, typename C4, typename C5, typename C6>\n\ninline R DispatchToMethod(T* obj, Method method,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple6<C1, C2, C3, C4, C5, C6>& c) {\n\n return (obj->*method)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c, c.d, c.e, c.f);\n\n}\n\ntemplate <typename R, typename Function, typename P1, typename P2, typename P3,\n\n typename P4, typename P5, typename P6, typename C1, typename C2,\n\n typename C3, typename C4, typename C5, typename C6>\n\ninline R DispatchToFunction(Function function,\n\n const Tuple6<P1, P2, P3, P4, P5, P6>& p,\n\n const Tuple6<C1, C2, C3, C4, C5, C6>& c) {\n\n return (*function)(p.a, p.b, p.c, p.d, p.e, p.f, c.a, c.b, c.c, c.d, c.e, c.f);\n\n}\n\n\n\n// Interface that is exposed to the consumer, that does the actual calling\n\n// of the method.\n\ntemplate <typename R, typename Params>\n", "file_path": "LuaKitProject/src/Projects/testing/gmock_mutant.h", "rank": 95, "score": 40.29412303740349 }, { "content": " return JNIModel::Double::ConvertToJava(env,ret);\n\n }\n\n }\n\n break;\n\n case LUA_TSTRING:{\n\n size_t size;\n\n const char * ret = lua_tolstring(L, stackIndex, &size);\n\n std::string s = std::string(ret, size);\n\n return JNIModel::String::ConvertToJava(env, s);\n\n }\n\n break;\n\n case LUA_TTABLE:{\n\n jobject o = getTableObject(L, env ,stackIndex);\n\n return o;\n\n }\n\n break;\n\n default:\n\n luaL_error(L, \"Unsupport type %s to getOneObject\", lua_typename(L, type));\n\n }\n\n return NULL;\n\n}", "file_path": "LuaKitProject/src/Projects/jni/JniLuaConvertor.cpp", "rank": 96, "score": 40.19568015577663 }, { "content": "\n\nextern int luaopen_callback(lua_State* L)\n\n{\n\n BEGIN_STACK_MODIFY(L);\n\n luaL_newmetatable(L, LUA_CALLBACK_METATABLE_NAME);\n\n luaL_register(L, NULL, callBackMetaFunctions);\n\n luaL_register(L, LUA_CALLBACK_METATABLE_NAME, callBackFunctions);\n\n END_STACK_MODIFY(L, 0)\n\n return 0;\n\n}\n", "file_path": "LuaKitProject/src/Projects/extensions/thread/lua_thread.cpp", "rank": 97, "score": 40.137744120025246 }, { "content": " p4_(p4),\n\n p5_(p5) {\n\n MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);\n\n }\n\n\n\n virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,\n\n P1>::Release(p1_); }\n\n\n\n RunnableType runnable_;\n\n P1 p1_;\n\n P2 p2_;\n\n P3 p3_;\n\n P4 p4_;\n\n P5 p5_;\n\n};\n\n\n\ntemplate <typename Runnable, typename RunType, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename P6>\n", "file_path": "LuaKitProject/LuakitPod/LuakitPod/include/bind_internal.h", "rank": 98, "score": 40.11983198788763 }, { "content": " p4_(p4),\n\n p5_(p5) {\n\n MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);\n\n }\n\n\n\n virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,\n\n P1>::Release(p1_); }\n\n\n\n RunnableType runnable_;\n\n P1 p1_;\n\n P2 p2_;\n\n P3 p3_;\n\n P4 p4_;\n\n P5 p5_;\n\n};\n\n\n\ntemplate <typename Runnable, typename RunType, typename P1, typename P2,\n\n typename P3, typename P4, typename P5, typename P6>\n", "file_path": "LuaKitProject/src/Projects/base/bind_internal.h", "rank": 99, "score": 40.11983198788763 } ]
C++
xls/noc/config_ng/flattened_multi_dimensional_array_test.cc
felixzhuologist/xls
b6a4ec7190049002be1c0829d52b1d7767c88204
#include "xls/noc/config_ng/flattened_multi_dimensional_array.h" #include "gtest/gtest.h" namespace xls::noc { namespace { TEST(FlattenedMultiDimensionalArrayTest, GetElementCount) { FlattenedMultiDimensionalArray<int64_t> array({3, 4}); EXPECT_EQ(array.GetElementCount(), 12); FlattenedMultiDimensionalArray<int64_t> zero_array({}); EXPECT_EQ(zero_array.GetElementCount(), 1); } TEST(FlattenedMultiDimensionalArrayTest, iterators) { FlattenedMultiDimensionalArray<int64_t> array({3, 4}); int64_t count = 0; for (int64_t element : array) { element++; count++; } EXPECT_EQ(array.GetElementCount(), count); FlattenedMultiDimensionalArray<int64_t> zero_array({}); count = 0; for (int64_t element : zero_array) { element++; count++; } EXPECT_EQ(zero_array.GetElementCount(), count); } TEST(FlattenedMultiDimensionalArrayTest, GetDimensions) { FlattenedMultiDimensionalArray<int64_t> array({3, 4}); const DimensionBounds& dimensions = array.GetDimensions(); EXPECT_EQ(dimensions.GetDimensionCount(), 2); EXPECT_EQ(dimensions.GetDimensionBound(0), 3); EXPECT_EQ(dimensions.GetDimensionBound(1), 4); FlattenedMultiDimensionalArray<int64_t> zero_array({}); const DimensionBounds& zero_dimensions = zero_array.GetDimensions(); EXPECT_EQ(zero_dimensions.GetDimensionCount(), 0); } TEST(FlattenedMultiDimensionalArrayTest, SetValueCoordinate) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); for (int64_t dimension_1 = 0; dimension_1 < 2; dimension_1++) { for (int64_t dimension_0 = 0; dimension_0 < 2; dimension_0++) { array.SetValue({dimension_0, dimension_1}, 42); } } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue({}, 42); } TEST(FlattenedMultiDimensionalArrayTest, SetValueIndex) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); for (int64_t count = 0; count < 4; count++) { array.SetValue(count, 42); } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue(0, 42); } TEST(FlattenedMultiDimensionalArrayTest, GetValueCoordinate) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); int value = 0; for (int64_t dimension_1 = 0; dimension_1 < 2; dimension_1++) { for (int64_t dimension_0 = 0; dimension_0 < 2; dimension_0++) { array.SetValue({dimension_0, dimension_1}, value++); } } value = 0; for (int64_t dimension_1 = 0; dimension_1 < 2; dimension_1++) { for (int64_t dimension_0 = 0; dimension_0 < 2; dimension_0++) { int64_t result = array.GetValue({dimension_0, dimension_1}); EXPECT_EQ(result, value++); } } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue({}, 42); int64_t result = zero_array.GetValue({}); EXPECT_EQ(result, 42); } TEST(FlattenedMultiDimensionalArrayTest, GetValueIndex) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); int value = 0; for (int64_t count = 0; count < 4; count++) { array.SetValue(count, value++); } value = 0; for (int64_t count = 0; count < 4; count++) { int64_t result = array.GetValue(count); EXPECT_EQ(result, value++); } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue(0, 42); int64_t result = zero_array.GetValue(0); EXPECT_EQ(result, 42); } TEST(FlattenedMultiDimensionalArrayTest, GetCoordinateOfIndex) { FlattenedMultiDimensionalArray<int64_t> array({2, 3}); int64_t index = 0; for (int64_t i = 0; i < 3; i++) { for (int64_t j = 0; j < 2; j++) { Coordinate coordinate = array.GetCoordinateOfIndex(index).value(); EXPECT_EQ(coordinate.GetDimensionCount(), 2); EXPECT_EQ(coordinate.GetCoordinate(0), j); EXPECT_EQ(coordinate.GetCoordinate(1), i); index++; } } EXPECT_EQ(array.GetCoordinateOfIndex(index), absl::nullopt); FlattenedMultiDimensionalArray<int64_t> zero_array({}); Coordinate coordinate = zero_array.GetCoordinateOfIndex(0).value(); EXPECT_EQ(coordinate.GetDimensionCount(), 0); EXPECT_EQ(zero_array.GetCoordinateOfIndex(1), absl::nullopt); } TEST(FlattenedMultiDimensionalArrayIteratorTest, IsAtBoundsCheck) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); EXPECT_FALSE(iterator.IsAtBounds()); int64_t count = 0; while (!iterator.IsAtBounds()) { ++iterator; count++; } EXPECT_EQ(count, 6); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_FALSE(zero_iterator.IsAtBounds()); count = 0; while (!zero_iterator.IsAtBounds()) { ++zero_iterator; count++; } EXPECT_EQ(count, 1); } TEST(FlattenedMultiDimensionalArrayIteratorTest, DistanceFromEnd) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); for (int64_t i = 0; i < 3; i++) { for (int64_t j = 0; j < 2; j++) { EXPECT_EQ(iterator.DistanceFromEnd(0), 2 - j); EXPECT_EQ(iterator.DistanceFromEnd(1), 3 - i); ++iterator; } } EXPECT_EQ(iterator.DistanceFromEnd(0), 0); EXPECT_EQ(iterator.DistanceFromEnd(1), 0); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_EQ(zero_iterator.DistanceFromEnd(absl::nullopt), 1); ++zero_iterator; EXPECT_EQ(zero_iterator.DistanceFromEnd(absl::nullopt), 0); } TEST(FlattenedMultiDimensionalArrayIteratorTest, GetDimensions) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); EXPECT_EQ(iterator.GetDimensions(), array.GetDimensions()); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_EQ(zero_iterator.GetDimensions(), zero_array.GetDimensions()); } TEST(FlattenedMultiDimensionalArrayIteratorTest, GetCoordinate) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); for (int64_t i = 0; i < 3; i++) { for (int64_t j = 0; j < 2; j++) { EXPECT_EQ(iterator.GetCoordinate(), Coordinate({j, i})); ++iterator; } } EXPECT_EQ(iterator.GetCoordinate(), absl::nullopt); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_EQ(zero_iterator.GetCoordinate(), Coordinate({})); ++zero_iterator; EXPECT_EQ(zero_iterator.GetCoordinate(), absl::nullopt); } TEST(FlattenedMultiDimensionalArrayIteratorTest, EqualAndNotEqualOperator) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator0 = array.GetDimensionalSpaceIterator({0, 1}); array_t::DimensionalSpaceIterator iterator1 = array.GetDimensionalSpaceIterator({0, 1}); for (; !iterator0.IsAtBounds(); ++iterator0, ++iterator1) { EXPECT_TRUE(iterator0 == iterator1); EXPECT_FALSE(iterator0 != iterator1); } EXPECT_TRUE(iterator0 == iterator1); EXPECT_FALSE(iterator0 != iterator1); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator0 = zero_array.GetDimensionalSpaceIterator({}); array_t::DimensionalSpaceIterator zero_iterator1 = zero_array.GetDimensionalSpaceIterator({}); for (; !iterator0.IsAtBounds(); ++zero_iterator0, ++zero_iterator1) { EXPECT_TRUE(zero_iterator0 == zero_iterator1); EXPECT_FALSE(zero_iterator0 != zero_iterator1); } EXPECT_TRUE(zero_iterator0 == zero_iterator1); EXPECT_FALSE(zero_iterator0 != zero_iterator1); } TEST(FlattenedMultiDimensionalArrayIteratorTest, PostfixAddition) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); array_t::DimensionalSpaceIterator iterator_copy(iterator); array_t::DimensionalSpaceIterator iterator_postfix = iterator++; EXPECT_EQ(iterator_copy, iterator_postfix); EXPECT_NE(iterator, iterator_postfix); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); array_t::DimensionalSpaceIterator zero_iterator_copy(zero_iterator); array_t::DimensionalSpaceIterator zero_iterator_postfix = zero_iterator++; EXPECT_EQ(zero_iterator_copy, zero_iterator_postfix); EXPECT_NE(zero_iterator, zero_iterator_postfix); } TEST(FlattenedMultiDimensionalArrayIteratorTest, ElementAccess) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); int64_t count = 0; while (!iterator.IsAtBounds()) { *iterator++ = count++; } for (int64_t index = 0; index < 6; index++) { EXPECT_EQ(array.GetValue(index), index); } array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); *zero_iterator++ = 42; EXPECT_EQ(zero_array.GetValue(0), 42); } } }
#include "xls/noc/config_ng/flattened_multi_dimensional_array.h" #include "gtest/gtest.h" namespace xls::noc { namespace { TEST(FlattenedMultiDimensionalArrayTest, GetElementCount) { FlattenedMultiDimensionalArray<int64_t> array({3, 4}); EXPECT_EQ(array.GetElementCount(), 12); FlattenedMultiDimensionalArray<int64_t> zero_array({}); EXPECT_EQ(zero_array.GetElementCount(), 1); } TEST(FlattenedMultiDimensionalArrayTest, iterators) { FlattenedMultiDimensionalArray<int64_t> array({3, 4}); int64_t count = 0; for (int64_t element : array) { element++; count++; } EXPECT_EQ(array.GetElementCount(), count); FlattenedMultiDimensionalArray<int64_t> zero_array({}); count = 0; for (int64_t element : zero_array) { element++; count++; } EXPECT_EQ(zero_array.GetElementCount(), count); } TEST(FlattenedMultiDimensionalArrayTest, GetDimensions) { FlattenedMultiDimensionalArray<int64_t> array({3, 4}); const DimensionBounds& dimensions = array.GetDimensions(); EXPECT_EQ(dimensions.GetDimensionCount(), 2); EXPECT_EQ(dimensions.GetDimensionBound(0), 3); EXPECT_EQ(dimensions.GetDimensionBound(1), 4); FlattenedMultiDimensionalArray<int64_t> zero_array({}); const DimensionBounds& zero_dimensions = zero_array.GetDimensions(); EXPECT_EQ(zero_dimensions.GetDimensionCount(), 0); } TEST(FlattenedMultiDimensionalArrayTest, SetValueCoordinate) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); for (int64_t dimension_1 = 0; dimension_1 < 2; dimension_1++) { for (int64_t dimension_0 = 0; dimension_0 < 2; dimension_0++) { array.SetValue({dimension_0, dimension_1}, 42); } } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue({}, 42); } TEST(FlattenedMultiDimensionalArrayTest, SetValueIndex) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); for (int64_t count = 0; count < 4; count++) { array.SetValue(count, 42); } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue(0, 42); } TEST(FlattenedMultiDimensionalArrayTest, GetValueCoordinate) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); int value = 0; for (int64_t dimension_1 = 0; dimension_1 < 2; dimension_1++) { for (int64_t dimension_0 = 0; dimension_0 < 2; dimension_0++) { array.SetValue({dimension_0, dimension_1}, value++); } } value = 0; for (int64_t dimension_1 = 0; dimension_1 < 2; dimension_1++) { for (int64_t dimension_0 = 0; dimension_0 < 2; dimension_0++) { int64_t result = array.GetValue({dimension_0, dimension_1}); EXPECT_EQ(result, value++); } } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue({}, 42); int64_t result = zero_array.GetValue({}); EXPECT_EQ(result, 42); } TEST(FlattenedMultiDimensionalArrayTest, GetValueIndex) { FlattenedMultiDimensionalArray<int64_t> array({2, 2}); int value = 0; for (int64_t count = 0; count < 4; count++) { array.SetValue(count, value++); } value = 0; for (int64_t count = 0; count < 4; count++) { int64_t result = array.GetValue(count); EXPECT_EQ(result, value++); } FlattenedMultiDimensionalArray<int64_t> zero_array({}); zero_array.SetValue(0, 42); int64_t result = zero_array.GetValue(0); EXPECT_EQ(result, 42); } TEST(FlattenedMultiDimensionalArrayTest, GetCoordinateOfIndex) { FlattenedMultiDimensionalArray<int64_t> array({2, 3}); int64_t index = 0; for (int64_t i = 0; i < 3; i++) { for (int64_t j = 0; j < 2; j++) { Coordinate coordinate = array.GetCoordinateOfIndex(index).value(); EXPECT_EQ(coordinate.GetDimensionCount(), 2); EXPECT_EQ(coordinate.GetCoordinate(0), j); EXPECT_EQ(coordinate.GetCoordinate(1), i); index++; } } EXPECT_EQ(array.GetCoordinateOfIndex(index), absl::nullopt); FlattenedMultiDimensionalArray<int64_t> zero_array({}); Coordinate coordinate = zero_array.GetCoordinateOfIndex(0).value(); EXPECT_EQ(coordinate.GetDimensionCount(), 0); EXPECT_EQ(zero_array.GetCoordinateOfIndex(1), absl::nullopt); } TEST(FlattenedMultiDimensionalArrayIteratorTest, IsAtBoundsCheck) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); EXPECT_FALSE(iterator.IsAtBounds()); int64_t count = 0; while (!iterator.IsAtBounds()) { ++iterator; count++; } EXPECT_EQ(count, 6); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_FALSE(zero_iterator.IsAtBounds()); count = 0; while (!zero_iterator.IsAtBounds()) { ++zero_iterator; count++; } EXPECT_EQ(count, 1); } TEST(FlattenedMultiDimensionalArrayIteratorTest, DistanceFromEnd) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); for (int64_t i = 0; i < 3; i++) { for (int64_t j = 0; j < 2; j++) { EXPECT_EQ(iterator.DistanceFromEnd(0), 2 - j); EXPECT_EQ(iterator.DistanceFromEnd(1), 3 - i); ++iterator; } } EXPECT_EQ(iterator.DistanceFromEnd(0), 0); EXPECT_EQ(iterator.DistanceFromEnd(1), 0); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_EQ(zero_iterator.DistanceFromEnd(absl::nullopt), 1); ++zero_iterator; EXPECT_EQ(zero_iterator.DistanceFromEnd(absl::nullopt), 0); } TEST(FlattenedMultiDimensionalArrayIteratorTest, GetDimensions) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); EXPECT_EQ(iterator.GetDimensions(), array.GetDimensions()); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_EQ(zero_iterator.GetDimensions(), zero_array.GetDimensions()); } TEST(FlattenedMultiDimensionalArrayIteratorTest, GetCoordinate) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); for (int64_t i = 0; i < 3; i++) { for (int64_t j = 0; j < 2; j++) { EXPECT_EQ(iterator.GetCoordinate(), Coordinate({j, i})); ++iterator; } } EXPECT_EQ(iterator.GetCoordinate(), absl::nullopt); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); EXPECT_EQ(zero_iterator.GetCoordinate(), Coordinate({})); ++zero_iterator; EXPECT_EQ(zero_iterator.GetCoordinate(), absl::nullopt); } TEST(FlattenedMultiDimensionalArrayIteratorTest, EqualAndNotEqualOperator) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator0 = array.GetDimensionalSpaceIterator({0, 1}); array_t::DimensionalSpaceIterator iterator1 = array.GetDimensionalSpaceIterator({0, 1}); for (; !iterator0.IsAtBounds(); ++iterator0, ++iterator1) { EXPECT_TRUE(iterator0 == iterator1); EXPECT_FALSE(iterator0 != iterator1); } EXPECT_TRUE(iterator0 == iterator1); EXPECT_FALSE(iterator0 != iterator1); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator0 = zero_array.GetDimensionalSpaceIterator({}); array_t::DimensionalSpaceIterator zero_iterator1 = zero_array.GetDimensionalSpaceIterator({}); for (; !iterator0.IsAtBounds(); ++zero_iterator0, ++zero_iterator1) { EXPECT_TRUE(zero_iterator0 == zero_iterator1); EXPECT_FALSE(zero_iterator0 != zero_iterator1); } EXPECT_TRUE(zero_iterator0 == zero_iterator1); EXPECT_FALSE(zero_iterator0 != zero_iterator1); } TEST(FlattenedMultiDimensionalArrayIteratorTest, PostfixAddition) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); array_t::DimensionalSpaceIterator iterator_copy(iterator); array_t::DimensionalSpaceIterator iterator_postfix = iterator++; EXPECT_EQ(iterator_copy, iterator_postfix); EXPECT_NE(iterator, iterator_postfix); array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterat
PECT_EQ(zero_array.GetValue(0), 42); } } }
or = zero_array.GetDimensionalSpaceIterator({}); array_t::DimensionalSpaceIterator zero_iterator_copy(zero_iterator); array_t::DimensionalSpaceIterator zero_iterator_postfix = zero_iterator++; EXPECT_EQ(zero_iterator_copy, zero_iterator_postfix); EXPECT_NE(zero_iterator, zero_iterator_postfix); } TEST(FlattenedMultiDimensionalArrayIteratorTest, ElementAccess) { using array_t = FlattenedMultiDimensionalArray<int64_t>; array_t array({2, 3}); array_t::DimensionalSpaceIterator iterator = array.GetDimensionalSpaceIterator({0, 1}); int64_t count = 0; while (!iterator.IsAtBounds()) { *iterator++ = count++; } for (int64_t index = 0; index < 6; index++) { EXPECT_EQ(array.GetValue(index), index); } array_t zero_array({}); array_t::DimensionalSpaceIterator zero_iterator = zero_array.GetDimensionalSpaceIterator({}); *zero_iterator++ = 42; EX
random
[ { "content": "fn array_and_array(p: bits[2][5][4][42], q: bits[32], v: bits[2][5][4]) -> bits[2][5][4][42] {\n\n ret array_update.1: bits[2][5][4][42] = array_update(p, v, indices=[q], id=1)\n\n}\n\n)\";\n\n ParseFunctionAndCheckDump(input);\n\n}\n\n\n\nTEST(IrParserTest, DifferentWidthMultiplies) {\n\n std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 0, "score": 147931.0350448892 }, { "content": "fn to_apply(element: bits[42]) -> bits[1] {\n\n literal.2: bits[42] = literal(value=10, id=2)\n\n ret ult.3: bits[1] = ult(element, literal.2, id=3)\n\n}\n\n\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 1, "score": 135594.86270535778 }, { "content": "fn array_and_array(p: bits[2][5][4][42], q: bits[32], r: bits[2]) -> bits[2][5] {\n\n ret array_index.1: bits[2][5] = array_index(p, indices=[q, r], id=1)\n\n}\n\n)\";\n\n ParseFunctionAndCheckDump(input);\n\n}\n\n\n\nTEST(IrParserTest, ParseNestedBitsArrayUpdate) {\n\n std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 2, "score": 129659.78601981106 }, { "content": " // Iterator over the indices. Implements the bare minimum sufficient to write\n\n // for-range loops.\n\n class StrongIntRangeIterator {\n\n public:\n\n explicit StrongIntRangeIterator(IntType initial) : current_(initial) {}\n\n bool operator!=(const StrongIntRangeIterator &other) const {\n\n return current_ != other.current_;\n\n }\n\n IntType operator*() const { return current_; }\n\n const StrongIntRangeIterator &operator++() {\n\n ++current_;\n\n return *this;\n\n }\n\n\n\n private:\n\n IntType current_;\n\n };\n\n\n\n // Loops from IntType(0) up to (but not including) end.\n\n explicit StrongIntRange(IntType end) : begin_(IntType(0)), end_(end) {}\n\n // Loops from begin up to (but not including) end.\n\n StrongIntRange(IntType begin, IntType end) : begin_(begin), end_(end) {}\n", "file_path": "xls/common/strong_int.h", "rank": 3, "score": 119268.87461139684 }, { "content": "fn main(a: bits[4][4], i: bits[2], value: bits[4]) -> bits[4][4] {\n\n ret x: bits[4][4] = array_update(a, value, indices=[i])\n\n}\n\n)\";\n\n XLS_ASSERT_OK_AND_ASSIGN(FunctionData fd, GetFunctionData(kIrText, \"main\"));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto fancy_jit, IrJit::Create(fd.source));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto basic_jit, IrJit::Create(fd.boolified));\n\n\n\n XLS_ASSERT_OK_AND_ASSIGN(Value a, Value::UBitsArray({4, 7, 2, 1}, 4));\n\n\n\n std::vector<Value> inputs(3);\n\n inputs[0] = a;\n\n for (int i = 0; i < 4; ++i) {\n\n inputs[1] = Value(UBits(i, 2));\n\n for (int value = 0; value < 16; ++value) {\n\n inputs[2] = Value(UBits(value, 4));\n\n\n\n XLS_ASSERT_OK_AND_ASSIGN(Value fancy_value, fancy_jit->Run(inputs));\n\n XLS_ASSERT_OK_AND_ASSIGN(Value basic_value, basic_jit->Run(inputs));\n\n ASSERT_EQ(fancy_value, basic_value);\n", "file_path": "xls/tools/booleanifier_test.cc", "rank": 4, "score": 112852.54887876313 }, { "content": "class ArrayView {\n\n public:\n\n explicit ArrayView(absl::Span<const uint8_t> buffer) : buffer_(buffer) {\n\n XLS_CHECK(buffer_.data() == nullptr);\n\n XLS_CHECK(buffer_.size() == GetTypeSize())\n\n << \"Span isn't sized to this array's type!\";\n\n }\n\n\n\n // Gets the storage size of this array.\n\n static constexpr uint64_t GetTypeSize() {\n\n return ElementT::GetTypeSize() * kNumElements;\n\n }\n\n\n\n // Gets the N'th element in the array.\n\n static ElementT Get(const uint8_t* buffer, int index) {\n\n return ElementT(buffer + (ElementT::GetTypeSize() * index));\n\n }\n\n\n\n private:\n\n absl::Span<const uint8_t> buffer_;\n", "file_path": "xls/ir/value_view.h", "rank": 5, "score": 111166.63515369128 }, { "content": "fn array_and_array(x: (bits[32], bits[1]), y: (bits[32], bits[1])) -> (bits[32], bits[1])[3] {\n\n ret array.1: (bits[32], bits[1])[3] = array(x, y, x, id=1)\n\n}\n\n)\";\n\n ParseFunctionAndCheckDump(input);\n\n}\n\n\n\nTEST(IrParserTest, ParseNestedBitsArrayIndex) {\n\n std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 6, "score": 111026.1990899359 }, { "content": "struct hash<::xls::StrongInt<Tag, Value, Validator>>\n\n : ::xls::StrongInt<Tag, Value, Validator>::Hasher {};\n\n\n\n} // namespace std\n\n\n\n#endif // XLS_COMMON_STRONG_INT_H_\n", "file_path": "xls/common/strong_int.h", "rank": 7, "score": 110978.382175179 }, { "content": "fn main(index: bits[2], other_index: bits[2], else: bits[32]) -> bits[32] {\n\n _111: bits[32] = literal(value=111)\n\n _222: bits[32] = literal(value=222)\n\n _333: bits[32] = literal(value=333)\n\n _444: bits[32] = literal(value=444)\n\n\n\n literal_0: bits[2] = literal(value=0)\n\n literal_1: bits[2] = literal(value=1)\n\n literal_2: bits[2] = literal(value=2)\n\n literal_3: bits[2] = literal(value=3)\n\n eq_0: bits[1] = eq(other_index, literal_0)\n\n eq_1: bits[1] = eq(index, literal_1)\n\n eq_2: bits[1] = eq(index, literal_2)\n\n eq_3: bits[1] = eq(index, literal_3)\n\n\n\n sel_3: bits[32] = sel(eq_1, cases=[else, _222])\n\n sel_2: bits[32] = sel(eq_3, cases=[sel_3, _444])\n\n sel_1: bits[32] = sel(eq_2, cases=[sel_2, _333])\n\n ret sel_0: bits[32] = sel(eq_0, cases=[sel_1, _111])\n\n})\";\n\n\n\n auto p = CreatePackage();\n\n XLS_ASSERT_OK_AND_ASSIGN(Function * f, ParseFunction(program, p.get()));\n\n ASSERT_THAT(Run(f), IsOkAndHolds(false));\n\n}\n\n\n\nTEST_F(TableSwitchPassTest, HoleInIndexSpace) {\n\n std::string program = R\"(\n", "file_path": "xls/passes/table_switch_pass_test.cc", "rank": 8, "score": 110406.07117250482 }, { "content": "class PackedArrayView {\n\n public:\n\n static constexpr int64_t kBitCount = ElementT::kBitCount * kNumElements;\n\n\n\n // *Somewhat* magical converter, which will grab the guts of an array with an\n\n // appropriate width integral type and turn it into this packed array view\n\n // type. This allows us to pass std::arrays to APIs which take fixed size\n\n // arrays of that bit count with more type safety than casting to a `void*`.\n\n //\n\n // For example:\n\n // absl::Status PopulateArray(std::array<int32_t, 64>* a) {\n\n // return populate_array_jit->Run(\n\n // PackedArrayView<PackedBitsView<32>, 64>(a));\n\n // }\n\n template <typename ArrayElementT,\n\n typename =\n\n std::enable_if_t<std::is_integral<ArrayElementT>::value &&\n\n std::numeric_limits<ArrayElementT>::digits +\n\n std::is_signed<ArrayElementT>::value ==\n\n ElementT::kBitCount>>\n", "file_path": "xls/ir/value_view.h", "rank": 9, "score": 107617.49939113094 }, { "content": "class MutableArrayView {\n\n public:\n\n explicit MutableArrayView(absl::Span<uint8_t> buffer) : buffer_(buffer) {\n\n int64_t type_size = ArrayView<ElementT, kNumElements>::GetTypeSize();\n\n XLS_DCHECK(buffer_.size() == type_size)\n\n << \"Span isn't sized to this array's type!\";\n\n }\n\n\n\n // Gets the N'th element in the array.\n\n ElementT Get(int index) {\n\n return ElementT(buffer_ + (ElementT::GetTypeSize() * index));\n\n }\n\n\n\n private:\n\n absl::Span<uint8_t> buffer_;\n\n};\n\n\n\ntemplate <uint64_t kNumBits>\n", "file_path": "xls/ir/value_view.h", "rank": 10, "score": 107617.49939113094 }, { "content": "// Represents a Verilog indexing operation; e.g.\n\n//\n\n// subject[index]\n\nclass Index : public IndexableExpression {\n\n public:\n\n Index(IndexableExpression* subject, Expression* index, VerilogFile* file)\n\n : IndexableExpression(file), subject_(subject), index_(index) {}\n\n\n\n std::string Emit() const override;\n\n\n\n private:\n\n IndexableExpression* subject_;\n\n Expression* index_;\n\n};\n\n\n", "file_path": "xls/codegen/vast.h", "rank": 11, "score": 105846.18259075744 }, { "content": "// A constant array expression is an array expression where all of the\n\n// expressions contained within it are constant.\n\nclass ConstantArray : public Array {\n\n public:\n\n // Adds checking for constant-expression-ness of the members beyond\n\n // Array::Array.\n\n ConstantArray(Module* owner, Span span, std::vector<Expr*> members,\n\n bool has_ellipsis);\n\n\n\n absl::Status Accept(AstNodeVisitor* v) override {\n\n return v->HandleConstantArray(this);\n\n }\n\n};\n\n\n\n// Several different AST nodes define types that can be referred to by a\n\n// TypeRef.\n\nusing TypeDefinition = absl::variant<TypeDef*, StructDef*, EnumDef*, ColonRef*>;\n\n\n\nabsl::StatusOr<TypeDefinition> ToTypeDefinition(AstNode* node);\n\n\n", "file_path": "xls/dslx/ast.h", "rank": 12, "score": 105834.86988085319 }, { "content": "fn main(index: bits[2]) -> bits[32] {\n\n _111: bits[32] = literal(value=111)\n\n _222: bits[32] = literal(value=222)\n\n _333: bits[32] = literal(value=333)\n\n _444: bits[32] = literal(value=444)\n\n _555: bits[32] = literal(value=555)\n\n\n\n literal_0: bits[2] = literal(value=0)\n\n literal_1: bits[2] = literal(value=1)\n\n literal_2: bits[2] = literal(value=2)\n\n literal_3: bits[2] = literal(value=3)\n\n eq_0: bits[1] = eq(index, literal_0)\n\n eq_0_but_swapped: bits[1] = eq(literal_0, index)\n\n eq_1: bits[1] = eq(index, literal_1)\n\n eq_3: bits[1] = eq(index, literal_3)\n\n\n\n // There is no comparison of index to 2.\n\n sel_3: bits[32] = sel(eq_1, cases=[_333, _222])\n\n sel_2: bits[32] = sel(eq_3, cases=[sel_3, _444])\n\n // _555 cannot be result of function.\n", "file_path": "xls/passes/table_switch_pass_test.cc", "rank": 13, "score": 105363.44570976958 }, { "content": "fn ____SequentialModuleSimple__main_counted_for_0_body(index: bits[32], acc: bits[32]) -> bits[32] {\n\n ret add.5: bits[32] = add(acc, index, pos=0,2,8)\n\n}\n\n\n", "file_path": "xls/codegen/sequential_generator_test.cc", "rank": 14, "score": 105142.26036717926 }, { "content": "fn ____LoopBodyPipelineTest__main_counted_for_0_body(index: bits[32], acc: bits[32]) -> bits[32] {\n\n add.5: bits[32] = add(acc, index, pos=0,2,8)\n\n literal.6: bits[32] = literal(value=3, pos=0,2,22)\n\n add.7: bits[32] = add(add.5, literal.6, pos=0,2,16)\n\n literal.8: bits[32] = literal(value=4, pos=0,2,30)\n\n ret add.9: bits[32] = add(add.7, literal.8, pos=0,2,24)\n\n}\n\n\n", "file_path": "xls/codegen/sequential_generator_test.cc", "rank": 15, "score": 103212.48386982891 }, { "content": "// An array assignment pattern such as: \"'{foo, bar, baz}\"\n\nclass ArrayAssignmentPattern : public IndexableExpression {\n\n public:\n\n ArrayAssignmentPattern(absl::Span<Expression* const> args, VerilogFile* file)\n\n : IndexableExpression(file), args_(args.begin(), args.end()) {}\n\n\n\n std::string Emit() const override;\n\n\n\n private:\n\n std::vector<Expression*> args_;\n\n};\n\n\n", "file_path": "xls/codegen/vast.h", "rank": 16, "score": 101215.81646135017 }, { "content": "class Result {\n\n public:\n\n Result(int64_t leading_zero_count, int64_t set_bit_count,\n\n int64_t trailing_zero_count)\n\n : leading_zero_count_(leading_zero_count),\n\n set_bit_count_(set_bit_count),\n\n trailing_zero_count_(trailing_zero_count) {}\n\n\n\n bool operator==(const Result& other) const {\n\n return leading_zero_count_ == other.leading_zero_count_ &&\n\n set_bit_count_ == other.set_bit_count_ &&\n\n trailing_zero_count_ == other.trailing_zero_count_;\n\n }\n\n\n\n private:\n\n friend std::ostream& operator<<(std::ostream&, const Result&);\n\n\n\n int64_t leading_zero_count_;\n\n int64_t set_bit_count_;\n\n int64_t trailing_zero_count_;\n\n};\n\n\n\nstd::ostream& operator<<(std::ostream& os, const Result& result) {\n\n os << absl::StreamFormat(\"{%d, %d, %d}\", result.leading_zero_count_,\n\n result.set_bit_count_, result.trailing_zero_count_);\n\n return os;\n\n}\n\n\n", "file_path": "xls/ir/node_util_test.cc", "rank": 17, "score": 100477.1444090183 }, { "content": "type MyArrayType2 = u31[CONST_1];\n", "file_path": "xls/dslx/cpp_transpiler_test.cc", "rank": 18, "score": 98295.5703212239 }, { "content": "type MyArrayType4 = s8[CONST_1];\n\n\n", "file_path": "xls/dslx/cpp_transpiler_test.cc", "rank": 19, "score": 98295.5703212239 }, { "content": "// ArrayIndex matcher. Supported forms:\n\n//\n\n// EXPECT_THAT(foo, m::ArrayIndex());\n\n// EXPECT_THAT(foo, m::ArrayIndex(m::Param(),\n\n// /*indices=*/{m::Xor(), m::And});\n\nclass ArrayIndexMatcher : public NodeMatcher {\n\n public:\n\n ArrayIndexMatcher(::testing::Matcher<const Node*> array,\n\n std::vector<::testing::Matcher<const Node*>> indices)\n\n : NodeMatcher(Op::kArrayIndex, [&]() {\n\n std::vector<::testing::Matcher<const Node*>> operands;\n\n operands.push_back(array);\n\n operands.insert(operands.end(), indices.begin(), indices.end());\n\n return operands;\n\n }()) {}\n\n};\n\n\n\ninline ::testing::Matcher<const ::xls::Node*> ArrayIndex(\n\n ::testing::Matcher<const Node*> array,\n\n std::vector<::testing::Matcher<const Node*>> indices) {\n\n return ::testing::MakeMatcher(\n\n new ::xls::op_matchers::ArrayIndexMatcher(array, indices));\n\n}\n\n\n\ninline ::testing::Matcher<const ::xls::Node*> ArrayIndex() {\n\n return ::testing::MakeMatcher(\n\n new ::xls::op_matchers::NodeMatcher(Op::kArrayIndex, {}));\n\n}\n\n\n", "file_path": "xls/ir/ir_matcher.h", "rank": 20, "score": 98276.06857548108 }, { "content": "// Creates a status based on an original_status, but enriched with additional\n\n// information. The builder implicitly converts to Status and StatusOr<T>\n\n// allowing for it to be returned directly.\n\n//\n\n// StatusBuilder builder(original);\n\n// builder << \"info about error\";\n\n// return builder;\n\n//\n\n// It provides method chaining to simplify typical usage:\n\n//\n\n// return StatusBuilder(original)\n\n// .Log(absl::LogSeverity::kWarning) << \"oh no!\";\n\n//\n\n// In more detail:\n\n// - When the original status is OK, all methods become no-ops and nothing will\n\n// be logged.\n\n// - Messages streamed into the status builder are collected into a single\n\n// additional message string.\n\n// - The original Status's message and the additional message are joined\n\n// together when the result status is built.\n\n// - By default, the messages will be joined including a convenience separator\n\n// between the original message and the additional one. This behavior can be\n\n// changed with the `SetAppend()` and `SetPrepend()` methods of the builder.\n\n// - By default, the result status is not logged. The `Log` and\n\n// `EmitStackTrace` methods will cause the builder to log the result status\n\n// when it is built.\n\n// - All side effects (like logging or constructing a stack trace) happen when\n\n// the builder is converted to a status.\n\nclass ABSL_MUST_USE_RESULT StatusBuilder {\n\n public:\n\n // Creates a `StatusBuilder` based on an original status. If logging is\n\n // enabled, it will use `location` as the location from which the log message\n\n // occurs. A typical user will not specify `location`, allowing it to default\n\n // to the current location.\n\n explicit StatusBuilder(const absl::Status& original_status,\n\n xabsl::SourceLocation location\n\n XABSL_LOC_CURRENT_DEFAULT_ARG);\n\n explicit StatusBuilder(absl::Status&& original_status,\n\n xabsl::SourceLocation location\n\n XABSL_LOC_CURRENT_DEFAULT_ARG);\n\n\n\n // Creates a `StatusBuilder` from a status code. If logging is enabled, it\n\n // will use `location` as the location from which the log message occurs. A\n\n // typical user will not specify `location`, allowing it to default to the\n\n // current location.\n\n explicit StatusBuilder(absl::StatusCode code,\n\n xabsl::SourceLocation location\n\n XABSL_LOC_CURRENT_DEFAULT_ARG);\n", "file_path": "xls/common/status/status_builder.h", "rank": 21, "score": 95594.53614970426 }, { "content": "type MyArrayType3 = MySignedType[CONST_1];\n", "file_path": "xls/dslx/cpp_transpiler_test.cc", "rank": 22, "score": 95512.74103333837 }, { "content": " // A Dimensional Space Iterator traverses a dimensional space defined by a\n\n // dimension bounds.\n\n class DimensionalSpaceIterator {\n\n public:\n\n // Returns true if the instance is at the dimensional bounds (end).\n\n bool IsAtBounds() const {\n\n if (coordinate_.HasZeroDimensions()) {\n\n return traversed_zero_dimension_;\n\n }\n\n bool at_end = true;\n\n // TODO (vmirian) 04-05-21 should be sufficient to check a single\n\n // dimension.\n\n for (int64_t count = 0; count < coordinate_.GetDimensionCount();\n\n count++) {\n\n at_end = at_end && coordinate_.GetCoordinate(count) ==\n\n dimensions_.GetDimensionBound(count);\n\n }\n\n return at_end;\n\n }\n\n\n\n // Returns the distance from the end for a dimension_index.\n\n // dimension_index: the index of the dimension. For a non-zero dimensional\n", "file_path": "xls/noc/config_ng/flattened_multi_dimensional_array.h", "rank": 23, "score": 95509.7243646008 }, { "content": "// Represents an index expression; e.g. `a[i]`\n\n//\n\n// * `lhs()` is the subject being indexed\n\n// * `rhs()` is the index specifier, can be either an:\n\n// * expression (e.g. `i` in the `a[i]` example above)\n\n// * slice (from compile-time-constant index to compile-time-constant index)\n\n// * width slice (from start index a compile-time-constant number of bits)\n\nclass Index : public Expr {\n\n public:\n\n Index(Module* owner, Span span, Expr* lhs, IndexRhs rhs)\n\n : Expr(owner, std::move(span)), lhs_(lhs), rhs_(rhs) {}\n\n\n\n absl::Status Accept(AstNodeVisitor* v) override {\n\n return v->HandleIndex(this);\n\n }\n\n void AcceptExpr(ExprVisitor* v) override { v->HandleIndex(this); }\n\n\n\n absl::string_view GetNodeTypeName() const override { return \"Index\"; }\n\n std::string ToString() const override;\n\n\n\n std::vector<AstNode*> GetChildren(bool want_types) const override {\n\n return {lhs_, ToAstNode(rhs_)};\n\n }\n\n\n\n Expr* lhs() const { return lhs_; }\n\n IndexRhs rhs() const { return rhs_; }\n\n\n\n private:\n\n // Expression that yields the value being indexed into; e.g. `a` in `a[10]`.\n\n Expr* lhs_;\n\n // Index expression; e.g. `10` in `a[10]`.\n\n IndexRhs rhs_;\n\n};\n\n\n", "file_path": "xls/dslx/ast.h", "rank": 24, "score": 92992.36465967476 }, { "content": "// Represents an array expression; e.g. `[a, b, c]`.\n\nclass Array : public Expr {\n\n public:\n\n Array(Module* owner, Span span, std::vector<Expr*> members,\n\n bool has_ellipsis);\n\n\n\n absl::Status Accept(AstNodeVisitor* v) override {\n\n return v->HandleArray(this);\n\n }\n\n void AcceptExpr(ExprVisitor* v) override { v->HandleArray(this); }\n\n\n\n absl::string_view GetNodeTypeName() const override { return \"Array\"; }\n\n std::string ToString() const override;\n\n std::vector<AstNode*> GetChildren(bool want_types) const override;\n\n\n\n const std::vector<Expr*>& members() const { return members_; }\n\n TypeAnnotation* type_annotation() const { return type_annotation_; }\n\n\n\n // TODO(leary): 2021-05-18 See TODO comment on Number::set_type_annotation for\n\n // the reason this exists (prefix types for literal values), but it should be\n\n // removed in favor of a decorator construct instead of using mutability.\n", "file_path": "xls/dslx/ast.h", "rank": 25, "score": 92990.52467960442 }, { "content": " def test_array_index(self):\n\n program = textwrap.dedent(\"\"\"\\\n\n #![test]\n\n fn indexing_test() {\n\n let x: u32[3] = u32[3]:[1, 2, 3];\n\n let y: u32 = u32:1;\n\n assert_eq(u32:2, x[y])\n\n }\n\n \"\"\")\n", "file_path": "xls/dslx/interpreter/interpreter_test.py", "rank": 26, "score": 92849.84786435073 }, { "content": "fn main(a: bits[4][4], i: bits[2], j: bits[2]) -> bits[4][2] {\n\n a_i: bits[4] = array_index(a, indices=[i])\n\n a_j: bits[4] = array_index(a, indices=[j])\n\n ret x: bits[4][2] = array(a_i, a_j)\n\n}\n\n)\";\n\n XLS_ASSERT_OK_AND_ASSIGN(FunctionData fd, GetFunctionData(kIrText, \"main\"));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto fancy_jit, IrJit::Create(fd.source));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto basic_jit, IrJit::Create(fd.boolified));\n\n\n\n XLS_ASSERT_OK_AND_ASSIGN(Value a, Value::UBitsArray({4, 7, 2, 1}, 4));\n\n\n\n std::vector<Value> inputs(3);\n\n inputs[0] = a;\n\n for (int i = 0; i < 4; ++i) {\n\n inputs[1] = Value(UBits(i, 2));\n\n for (int j = 0; j < 4; ++j) {\n\n inputs[2] = Value(UBits(j, 2));\n\n\n\n XLS_ASSERT_OK_AND_ASSIGN(Value fancy_value, fancy_jit->Run(inputs));\n", "file_path": "xls/tools/booleanifier_test.cc", "rank": 27, "score": 92144.03937722399 }, { "content": "fn main(index: bits[2], else: bits[32]) -> bits[32] {\n\n _111: bits[32] = literal(value=111)\n\n _222: bits[32] = literal(value=222)\n\n _333: bits[32] = literal(value=333)\n\n _444: bits[32] = literal(value=444)\n\n\n\n literal_0: bits[2] = literal(value=0)\n\n literal_1: bits[2] = literal(value=1)\n\n literal_2: bits[2] = literal(value=2)\n\n literal_3: bits[2] = literal(value=3)\n\n eq_0: bits[1] = eq(index, literal_0)\n\n eq_1: bits[1] = eq(index, literal_1)\n\n eq_2: bits[1] = eq(index, literal_2)\n\n eq_3: bits[1] = eq(index, literal_3)\n\n\n\n // The comparisons can appear in any order. Final else does not have to be a\n\n // literal because it is dead (never selected by chain).\n\n sel_3: bits[32] = sel(eq_1, cases=[else, _222])\n\n sel_2: bits[32] = sel(eq_3, cases=[sel_3, _444])\n\n sel_1: bits[32] = sel(eq_2, cases=[sel_2, _333])\n", "file_path": "xls/passes/table_switch_pass_test.cc", "rank": 28, "score": 92100.8453014192 }, { "content": "fn ____SequentialModuleInvariants__main_counted_for_0_body(index: bits[32], acc: bits[32], invara: bits[32], invarb: bits[32]) -> bits[32] {\n\n add.9: bits[32] = add(acc, index, pos=0,2,8)\n\n add.10: bits[32] = add(add.9, invara, pos=0,2,16)\n\n ret add.11: bits[32] = add(add.10, invarb, pos=0,2,25)\n\n}\n\n\n", "file_path": "xls/codegen/sequential_generator_test.cc", "rank": 29, "score": 91575.33400141518 }, { "content": "fn foo(array: bits[32][3], idx: bits[32], newval: bits[64]) -> bits[32][3] {\n\n ret array_update.4: bits[32][3] = array_update(array, newval, indices=[idx], id=4)\n\n}\n\n)\";\n\n Package p(\"my_package\");\n\n EXPECT_THAT(Parser::ParseFunction(input, &p).status(),\n\n StatusIs(absl::StatusCode::kInvalidArgument,\n\n HasSubstr(\"Expected update value to have type bits[32]; \"\n\n \"has type bits[64]\")));\n\n}\n\n\n\nTEST(IrParserTest, ParseArrayConcat0) {\n\n const std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 30, "score": 91202.37835785741 }, { "content": "fn foo(array: bits[32][3], idx: bits[32], newval: bits[32]) -> bits[32][3] {\n\n ret array_update.4: bits[32][3] = array_update(array, newval, indices=[idx], id=4)\n\n}\n\n)\";\n\n ParseFunctionAndCheckDump(input);\n\n}\n\n\n\nTEST(IrParserTest, ParseArrayUpdateNonArary) {\n\n const std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 31, "score": 91202.37835785741 }, { "content": "fn main(index: bits[32], bad_selector: bits[3]) -> bits[32] {\n\n literal.0: bits[32] = literal(value=0)\n\n literal.1: bits[32] = literal(value=1)\n\n literal.2: bits[32] = literal(value=2)\n\n literal.4: bits[32] = literal(value=4)\n\n literal.5: bits[32] = literal(value=5)\n\n literal.50: bits[32] = literal(value=0)\n\n literal.51: bits[32] = literal(value=111)\n\n literal.52: bits[32] = literal(value=222)\n\n literal.53: bits[32] = literal(value=333)\n\n literal.55: bits[32] = literal(value=555)\n\n literal.56: bits[32] = literal(value=666)\n\n eq.11: bits[1] = eq(index, literal.1)\n\n eq.12: bits[1] = eq(index, literal.2)\n\n eq.14: bits[1] = eq(index, literal.4)\n\n eq.15: bits[1] = eq(index, literal.5)\n\n sel.20: bits[32] = sel(bad_selector, cases=[literal.50, literal.51, literal.56], default=literal.55)\n\n sel.21: bits[32] = sel(eq.11, cases=[sel.20, literal.52])\n\n sel.22: bits[32] = sel(eq.12, cases=[sel.21, literal.53])\n\n sel.24: bits[32] = sel(eq.14, cases=[sel.22, literal.55])\n", "file_path": "xls/passes/table_switch_pass_test.cc", "rank": 32, "score": 90947.71588280544 }, { "content": "fn main(a: (bits[2], bits[3], bits[4]), b: (bits[2], bits[3], bits[4])) -> (bits[4], bits[3], bits[2]) {\n\n a_0: bits[2] = tuple_index(a, index=0)\n\n a_1: bits[3] = tuple_index(a, index=1)\n\n a_2: bits[4] = tuple_index(a, index=2)\n\n b_0: bits[2] = tuple_index(b, index=0)\n\n b_1: bits[3] = tuple_index(b, index=1)\n\n b_2: bits[4] = tuple_index(b, index=2)\n\n c_0: bits[2] = add(a_0, b_0)\n\n c_1: bits[3] = add(a_1, b_1)\n\n c_2: bits[4] = add(a_2, b_2)\n\n c: (bits[2], bits[3], bits[4]) = tuple(c_0, c_1, c_2)\n\n x_0: bits[4] = tuple_index(c, index=2)\n\n x_1: bits[3] = tuple_index(c, index=1)\n\n x_2: bits[2] = tuple_index(c, index=0)\n\n ret x: (bits[4], bits[3], bits[2]) = tuple(x_0, x_1, x_2)\n\n}\n\n)\";\n\n XLS_ASSERT_OK_AND_ASSIGN(FunctionData fd, GetFunctionData(kIrText, \"main\"));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto fancy_jit, IrJit::Create(fd.source));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto basic_jit, IrJit::Create(fd.boolified));\n", "file_path": "xls/tools/booleanifier_test.cc", "rank": 33, "score": 90602.90166359302 }, { "content": "class ShiftRightWithSign<Width, true, IndexW> {\n\n public:\n\n inline static __xls_bits<Width> Operate(__xls_bits<Width> a,\n\n __xls_bits<IndexW> b) {\n\n __xls_bits<Width> ret;\n\n asm(\"fn (fid)(a: bits[i], o: bits[c]) -> bits[i] { ret op_(aid): bits[i] = \"\n\n \"shra(a, o, pos=(loc)) }\"\n\n : \"=r\"(ret)\n\n : \"i\"(Width), \"c\"(IndexW), \"a\"(a), \"o\"(b));\n\n return ret;\n\n }\n\n};\n\n\n\ntemplate <int Width, bool Signed>\n", "file_path": "xls/contrib/xlscc/synth_only/xls_int.h", "rank": 34, "score": 90344.04443201609 }, { "content": "class ShiftRightWithSign<Width, false, IndexW> {\n\n public:\n\n inline static __xls_bits<Width> Operate(__xls_bits<Width> a,\n\n __xls_bits<IndexW> b) {\n\n __xls_bits<Width> ret;\n\n asm(\"fn (fid)(a: bits[i], o: bits[c]) -> bits[i] { ret op_(aid): bits[i] = \"\n\n \"shrl(a, o, pos=(loc)) }\"\n\n : \"=r\"(ret)\n\n : \"i\"(Width), \"c\"(IndexW), \"a\"(a), \"o\"(b));\n\n return ret;\n\n }\n\n};\n\n\n\ntemplate <int Width, int IndexW>\n", "file_path": "xls/contrib/xlscc/synth_only/xls_int.h", "rank": 35, "score": 90344.04443201609 }, { "content": "def _random_array_value(element_width: int, num_elements: int) -> str:\n\n \"\"\"Returns a random array value as a string with hexadecimal elements.\"\"\"\n\n elements = [_random_bits_value(element_width) for _ in range(num_elements)]\n", "file_path": "xls/delay_model/op_module_generator.py", "rank": 36, "score": 90336.26402558167 }, { "content": "fn ____ModuleSignatureTestInvariants__main_counted_for_0_body(index: bits[32], acc: bits[32], invar_a: bits[32], invar_b: bits[32]) -> bits[32] {\n\n add.10: bits[32] = add(acc, index, pos=0,5,8)\n\n add.11: bits[32] = add(add.10, invar_a, pos=0,5,16)\n\n ret add.12: bits[32] = add(add.11, invar_b, pos=0,5,26)\n\n}\n\n\n", "file_path": "xls/codegen/sequential_generator_test.cc", "rank": 37, "score": 89967.80628559778 }, { "content": " def test_const_array_of_enum_refs(self):\n\n program = \"\"\"\n\n enum MyEnum: u2 {\n\n FOO = 2,\n\n BAR = 3,\n\n }\n\n const A = MyEnum[2]:[MyEnum::FOO, MyEnum::BAR];\n\n #![test]\n\n fn t_test() {\n\n let _ = assert_eq(MyEnum::FOO, A[u32:0]);\n\n let _ = assert_eq(MyEnum::BAR, A[u32:1]);\n\n ()\n\n }\n\n \"\"\"\n", "file_path": "xls/dslx/interpreter/interpreter_test.py", "rank": 38, "score": 88035.65348703513 }, { "content": " def test_struct_with_const_sized_array(self):\n\n program = \"\"\"\n\n const THING_COUNT = u32:2;\n\n type Foo = (\n\n u32[THING_COUNT]\n\n );\n\n fn get_thing(x: Foo, i: u32) -> u32 {\n\n let things: u32[THING_COUNT] = x[0];\n\n things[i]\n\n }\n\n #![test]\n\n fn foo_test() {\n\n let foo: Foo = (u32[THING_COUNT]:[42, 64],);\n\n let _ = assert_eq(u32:42, get_thing(foo, u32:0));\n\n let _ = assert_eq(u32:64, get_thing(foo, u32:1));\n\n ()\n\n }\n\n \"\"\"\n", "file_path": "xls/dslx/interpreter/interpreter_test.py", "rank": 39, "score": 88035.65348703513 }, { "content": " def test_array_index(self):\n\n self.assertEqual(\n\n \"\"\"package array_index_characterization\n\n\n\nfn main(op0: bits[17][42][10], op1: bits[32], op2: bits[3]) -> bits[17] {\n\n ret result: bits[17] = array_index(op0, indices=[op1, op2])\n\n}\"\"\",\n\n opgen.generate_ir_package(\n\n 'array_index',\n\n output_type='bits[17]',\n", "file_path": "xls/delay_model/op_module_generator_test.py", "rank": 40, "score": 88004.09686030154 }, { "content": "fn foo() -> bits[32][2][3][1] {\n\n ret literal.1: bits[32][2][3][1] = literal(value=[[[0, 1], [2, 3], [4, 5]]], id=1)\n\n}\n\n)\";\n\n ParseFunctionAndCheckDump(input);\n\n}\n\n\n\nTEST(IrParserTest, ParseArrayLiteralWithInsufficientBits) {\n\n Package p(\"my_package\");\n\n const std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 41, "score": 86311.14404952765 }, { "content": " def test_cast_array_to_wrong_bit_count(self):\n\n program = textwrap.dedent(\"\"\"\\\n\n #![test]\n\n fn cast_array_to_wrong_bit_count_test() {\n\n let x = u2[2]:[2, 3];\n\n assert_eq(u3:0, x as u3)\n\n }\n\n \"\"\")\n\n stderr = self._parse_and_test(program, want_error=True)\n\n self.assertIn(\n\n 'uN[2][2] vs uN[3]: Cannot cast from expression type uN[2][2] to uN[3].',\n", "file_path": "xls/dslx/interpreter/interpreter_test.py", "rank": 42, "score": 85790.45998879266 }, { "content": " def test_index_struct_value(self):\n\n stderr = self._run('xls/dslx/tests/errors/index_struct_value.x')\n\n self.assertIn('index_struct_value.x:23:4-23:7', stderr)\n", "file_path": "xls/dslx/tests/errors/error_modules_test.py", "rank": 43, "score": 85758.85972419249 }, { "content": "def _array_elements_sweep():\n\n \"\"\"Yields a standard range of array elements along a single dimension.\"\"\"\n\n\n\n # array_elements <= 8 noisy\n\n # larger array_elements extremely slow to synthesize (especially w/ nesting)\n\n for dim_size in range(12, 37, 12):\n", "file_path": "xls/contrib/integrator/area_model/area_characterization_client_main.py", "rank": 44, "score": 83685.12139071642 }, { "content": "def _get_array_num_elements(array_dims: List[int],\n\n index_depth: Optional[int] = None):\n\n \"\"\"Returns the number of elements in a (nested) array.\n\n\n\n Returns the number of elements in a (nested) array with dimensions\n\n 'array_dims'. If the array is indexed 'index_depth' times. If 'index_depth'\n\n is not specified, the maximum number of possible indices is assumed.\n\n\n\n Args:\n\n array_dims: Array dimensions.\n\n index_depth: Depth of index.\n\n\n\n Returns:\n\n The number of elements in a (nested) array with dimensions 'array_dims'.\n\n\n\n \"\"\"\n\n if index_depth is None:\n\n index_depth = len(array_dims) - 1\n\n\n\n elem_count = 1\n\n for idx in range(len(array_dims) - index_depth, len(array_dims)):\n\n elem_count = elem_count * array_dims[idx]\n", "file_path": "xls/contrib/integrator/area_model/area_characterization_client_main.py", "rank": 45, "score": 81670.5333464957 }, { "content": " def test_non_const_array_type_dimension(self):\n\n stderr = self._run('xls/dslx/tests/errors/non_const_array_type_dimension.x')\n\n # TODO(leary): 2021-06-21 This error should become something like \"can only\n\n # refer to constant or parametric values in dimensions\".\n\n self.assertIn('non_const_array_type_dimension.x:16:10-16:18', stderr)\n", "file_path": "xls/dslx/tests/errors/error_modules_test.py", "rank": 46, "score": 81644.24282642262 }, { "content": "fn foo(array: bits[32], idx: bits[32], newval: bits[32]) -> bits[32][3] {\n\n ret array_update.4: bits[32][3] = array_update(array, newval, indices=[idx], id=4)\n\n}\n\n)\";\n\n Package p(\"my_package\");\n\n EXPECT_THAT(\n\n Parser::ParseFunction(input, &p).status(),\n\n StatusIs(\n\n absl::StatusCode::kInvalidArgument,\n\n HasSubstr(\n\n \"Too many indices (1) to index into array of type bits[32]\")));\n\n}\n\n\n\nTEST(IrParserTest, ParseArrayUpdateIncompatibleTypes) {\n\n const std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 47, "score": 81616.53444878111 }, { "content": "fn array_and_array(x: bits[32], y: bits[32], z: bits[32]) -> bits[32][3] {\n\n ret array.1: bits[32][3] = array(x, y, z, id=1)\n\n}\n\n)\";\n\n ParseFunctionAndCheckDump(input);\n\n}\n\n\n\nTEST(IrParserTest, ParseReverse) {\n\n std::string input = R\"(\n", "file_path": "xls/ir/ir_parser_test.cc", "rank": 48, "score": 80925.7525474467 }, { "content": " def _set_addressable_element_count_expression(elm_expr):\n\n _set_divide_expression(elm_expr)\n\n _set_operand_bit_count_expression_factor(elm_expr.lhs_expression, 0)\n", "file_path": "xls/contrib/integrator/area_model/area_characterization_client_main.py", "rank": 49, "score": 79773.91854922114 }, { "content": "def _set_addressable_element_count_factor(\n\n expr: delay_model_pb2.DelayExpression):\n", "file_path": "xls/contrib/integrator/area_model/area_characterization_client_main.py", "rank": 50, "score": 79773.91854922114 }, { "content": "def _run_array_index_op_and_add(\n\n op: str, kop: str, model: delay_model_pb2.DelayModel,\n\n stub: synthesis_service_pb2_grpc.SynthesisServiceStub) -> None:\n\n \"\"\"Runs characterization for the ArrayIndex op.\"\"\"\n\n add_op_model = _new_regression_op_model(model, kop)\n\n\n\n # Area is a function of #elements*weight + elements*bitwidth*weight.\n\n #\n\n # This seems to hold across a range of element counts, bitwidth, and number\n\n # of dimensions i.e.\n\n #\n\n # The weight isn't an artifact of where we sampled data - It is actually\n\n # ~constant rather than being something like the ratio of #elements to\n\n # #bitwidths or similar.\n\n\n\n def _set_addressable_element_count_expression(elm_expr):\n\n _set_divide_expression(elm_expr)\n\n _set_operand_bit_count_expression_factor(elm_expr.lhs_expression, 0)\n\n _set_result_bit_count_expression_factor(elm_expr.rhs_expression)\n\n\n\n elm_expr = _new_expression(add_op_model)\n\n _set_addressable_element_count_expression(elm_expr)\n\n mul_expr = _new_expression(add_op_model)\n\n _set_multiply_expression(mul_expr)\n\n _set_addressable_element_count_expression(mul_expr.lhs_expression)\n\n _set_result_bit_count_expression_factor(mul_expr.rhs_expression)\n\n\n\n for num_dims in range(1, 3):\n\n for array_dimension_sizes in _yield_array_dimension_sizes(num_dims):\n\n\n\n # If single-dimension array, increase number of elements.\n\n if num_dims == 1:\n\n assert len(array_dimension_sizes) == 1\n\n array_dimension_sizes[0] = array_dimension_sizes[0] * 2\n\n\n\n for element_bit_count in _bitwidth_sweep(3):\n\n array_and_element_dimensions = [element_bit_count\n\n ] + array_dimension_sizes\n\n\n\n # Format dimension args\n\n operand_dimensions = [array_and_element_dimensions]\n\n for dim in reversed(array_dimension_sizes):\n\n operand_dimensions.append([bits.min_bit_count_unsigned(dim - 1)])\n\n\n\n # Record data point\n\n result = _build_data_point(op, kop, [element_bit_count],\n\n operand_dimensions, stub)\n\n result.operation.bit_count = element_bit_count\n\n operand = result.operation.operands.add()\n\n operand.bit_count = functools.reduce(operator.mul,\n\n array_and_element_dimensions, 1)\n\n model.data_points.append(result)\n\n\n\n logging.info('%s: %s --> %s', str(kop),\n\n ','.join(str(item) for item in operand_dimensions),\n\n str(result.delay))\n\n\n\n # Validate model\n", "file_path": "xls/contrib/integrator/area_model/area_characterization_client_main.py", "rank": 51, "score": 79700.01539441646 }, { "content": " function automatic signed [5:0][2:0][32:0] func (input reg foo, input reg signed [6 + 6 - 1:0][110:0] bar, input reg signed [32:0] baz);\n\n begin\n\n func = 0;\n\n end\n\n endfunction\n\n reg a;\n\n wire signed [6 + 6 - 1:0][110:0] b;\n\n wire signed [32:0] c;\n\n wire signed [5:0][2:0][32:0] qux;\n\n assign qux = func(a, b, c);\n\nendmodule)\");\n\n}\n\n\n\nINSTANTIATE_TEST_SUITE_P(VastTestInstantiation, VastTest,\n\n testing::Values(false, true),\n\n [](const testing::TestParamInfo<bool>& info) {\n\n return info.param ? \"SystemVerilog\" : \"Verilog\";\n\n });\n\n\n\n} // namespace\n\n} // namespace verilog\n\n} // namespace xls\n", "file_path": "xls/codegen/vast_test.cc", "rank": 52, "score": 79248.0251413143 }, { "content": "fn f(x: bits[3], y: bits[2], z: bits[1]) -> bits[6] {\n\n ret concat.4: bits[6] = concat(x, y, z)\n\n}\n\n)\",\n\n p.get()));\n\n EXPECT_EQ(f->return_value()->op(), Op::kConcat);\n\n Concat* concat = FindNode(\"concat.4\", f)->As<Concat>();\n\n // z operand\n\n EXPECT_EQ(0, concat->GetOperandSliceData(2).start);\n\n EXPECT_EQ(1, concat->GetOperandSliceData(2).width);\n\n // y operand\n\n EXPECT_EQ(1, concat->GetOperandSliceData(1).start);\n\n EXPECT_EQ(2, concat->GetOperandSliceData(1).width);\n\n // x operand\n\n EXPECT_EQ(3, concat->GetOperandSliceData(0).start);\n\n EXPECT_EQ(3, concat->GetOperandSliceData(0).width);\n\n}\n\n\n\nTEST_F(NodeTest, NodeNames) {\n\n auto p = CreatePackage();\n", "file_path": "xls/ir/node_test.cc", "rank": 53, "score": 79077.58451095088 }, { "content": "fn f(index: bits[32]) -> bits[32] {\n\n literal.1: bits[32] = literal(value=0)\n\n ret literal.2: bits[32] = literal(value=1)\n\n literal.3: bits[32] = literal(value=99)\n\n array.6: bits[32][2] = array(literal.1, literal.1)\n\n array_update.8: bits[32][2] = array_update(array.6, literal.2, indices=[index])\n\n element_0: bits[32] = array_index(array_update.8, indices=[literal.1])\n\n array_index.10: bits[32] = array_index(array_update.8, indices=[literal.2])\n\n}\n\n)\";\n\n\n\n XLS_ASSERT_OK_AND_ASSIGN(auto p, ParsePackage(program));\n\n XLS_ASSERT_OK_AND_ASSIGN(Function * f, p->GetFunction(\"f\"));\n\n\n\n std::vector<std::string> in_str = {\"literal.1\", \"literal.2\", \"literal.1\",\n\n \"literal.2\"};\n\n std::vector<std::string> out_str = {\"element_0\", \"element_0\",\n\n \"array_index.10\", \"array_index.10\"};\n\n\n\n // If we don't know the update index, we don't know if the final\n", "file_path": "xls/solvers/z3_ir_translator_test.cc", "rank": 54, "score": 77976.74791057876 }, { "content": "def _set_result_bit_count_expression_factor(\n\n expr: delay_model_pb2.DelayExpression, add_constant=0):\n\n if add_constant != 0:\n\n _set_add_expression(expr)\n\n _set_result_bit_count_expression_factor(expr.rhs_expression)\n\n _set_constant_expression(expr.lhs_expression, add_constant)\n\n else:\n", "file_path": "xls/contrib/integrator/area_model/area_characterization_client_main.py", "rank": 55, "score": 77926.0434326184 }, { "content": "fn main(a: bits[4][4][4], i: bits[2][2]) -> bits[4] {\n\n literal.1: bits[1] = literal(value=0)\n\n literal.2: bits[1] = literal(value=1)\n\n array_index.3: bits[2] = array_index(i, indices=[literal.1])\n\n array_index.4: bits[2] = array_index(i, indices=[literal.2])\n\n ret x: bits[4] = array_index(a, indices=[array_index.3, array_index.4])\n\n}\n\n)\";\n\n XLS_ASSERT_OK_AND_ASSIGN(FunctionData fd, GetFunctionData(kIrText, \"main\"));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto fancy_jit, IrJit::Create(fd.source));\n\n XLS_ASSERT_OK_AND_ASSIGN(auto basic_jit, IrJit::Create(fd.boolified));\n\n\n\n XLS_ASSERT_OK_AND_ASSIGN(Value a, Value::UBits2DArray({{0x0, 0x1, 0x2, 0x3},\n\n {0x4, 0x5, 0x6, 0x7},\n\n {0x8, 0x9, 0xa, 0xb},\n\n {0xc, 0xd, 0xe, 0xf}},\n\n 4));\n\n\n\n std::vector<Value> inputs(2);\n\n inputs[0] = a;\n", "file_path": "xls/tools/booleanifier_test.cc", "rank": 56, "score": 77124.07958063063 }, { "content": "fn main(index: bits[128]) -> bits[128] {\n\n literal.0: bits[128] = literal(value=0x0)\n\n literal.1: bits[128] = literal(value=0x1)\n\n literal.2: bits[128] = literal(value=0x2)\n\n literal.3: bits[128] = literal(value=0x3)\n\n literal.4: bits[128] = literal(value=0x4)\n\n literal.5: bits[128] = literal(value=0x5)\n\n literal.50: bits[128] = literal(value=0x$0)\n\n literal.51: bits[128] = literal(value=0x$1)\n\n literal.52: bits[128] = literal(value=0x$2)\n\n literal.53: bits[128] = literal(value=0x$3)\n\n literal.54: bits[128] = literal(value=0x$4)\n\n literal.55: bits[128] = literal(value=0x$5)\n\n eq.10: bits[1] = eq(index, literal.0)\n\n eq.11: bits[1] = eq(index, literal.1)\n\n eq.12: bits[1] = eq(index, literal.2)\n\n eq.13: bits[1] = eq(index, literal.3)\n\n eq.14: bits[1] = eq(index, literal.4)\n\n eq.15: bits[1] = eq(index, literal.5)\n\n sel.20: bits[128] = sel(eq.10, cases=[literal.50, literal.51])\n", "file_path": "xls/passes/table_switch_pass_test.cc", "rank": 57, "score": 76585.25015302192 }, { "content": "fn main(index: bits[32]) -> bits[32] {\n\n literal.0: bits[32] = literal(value=0)\n\n literal.1: bits[32] = literal(value=1)\n\n literal.2: bits[32] = literal(value=2)\n\n literal.3: bits[32] = literal(value=3)\n\n literal.4: bits[32] = literal(value=4)\n\n literal.5: bits[32] = literal(value=5)\n\n literal.6: bits[32] = literal(value=6)\n\n eq.10: bits[1] = eq(index, literal.0)\n\n eq.11: bits[1] = eq(index, literal.1)\n\n eq.12: bits[1] = eq(index, literal.2)\n\n eq.13: bits[1] = eq(index, literal.3)\n\n eq.14: bits[1] = eq(index, literal.4)\n\n eq.15: bits[1] = eq(index, literal.5)\n\n sel.20: bits[32] = sel(eq.10, cases=[literal.0, literal.1])\n\n sel.21: bits[32] = sel(eq.11, cases=[sel.20, literal.2])\n\n sel.22: bits[32] = sel(eq.12, cases=[sel.21, literal.3])\n\n sel.23: bits[32] = sel(eq.13, cases=[sel.22, literal.4])\n\n sel.24: bits[32] = sel(eq.14, cases=[sel.23, literal.5])\n\n ret sel.25: bits[32] = sel(eq.15, cases=[sel.24, literal.6])\n", "file_path": "xls/passes/table_switch_pass_test.cc", "rank": 58, "score": 76585.25015302192 }, { "content": "struct WrappedFunctionParameterTraits<absl::Span<const T>,\n\n std::enable_if_t<HasPyHolderType<T>>> {\n\n using WrappedType = absl::Span<const PyHolderType<T>>;\n\n\n\n static std::vector<T> Unwrap(const WrappedType& t) {\n\n std::vector<T> values;\n\n values.reserve(t.size());\n\n for (auto& value : t) {\n\n values.push_back(value.deref());\n\n }\n\n return values;\n\n }\n\n};\n\n\n\n// WrappedFunctionParameterTraits for absl::optionals of types that have wrapper\n\n// types.\n\ntemplate <typename T>\n", "file_path": "xls/ir/python/wrapper_types.h", "rank": 59, "score": 76470.17495122695 }, { "content": "fn body(index: bits[32][2], accumulator: bits[32], invariant_1: bits[48], invariant_2: bits[64]) -> bits[32] {\n\n ret add.5: bits[32] = add(accumulator, accumulator, id=5)\n\n}\n\n\n", "file_path": "xls/ir/verifier_test.cc", "rank": 60, "score": 75617.57170106415 }, { "content": "// Class for matching XLS Types. Example usage:\n\n//\n\n// EXPECT_THAT(foo, m::Type(\"bits[32]\"));\n\n// EXPECT_THAT(foo, m::Type(package->GetBitsType(32)));\n\nclass TypeMatcher : public ::testing::MatcherInterface<const Node*> {\n\n public:\n\n explicit TypeMatcher(absl::string_view type_str) : type_str_(type_str) {}\n\n\n\n bool MatchAndExplain(const Node* node,\n\n ::testing::MatchResultListener* listener) const override;\n\n void DescribeTo(std::ostream* os) const override;\n\n\n\n private:\n\n std::string type_str_;\n\n};\n\n\n\ninline ::testing::Matcher<const ::xls::Node*> Type(const Type* type) {\n\n return ::testing::MakeMatcher(\n\n new ::xls::op_matchers::TypeMatcher(type->ToString()));\n\n}\n\n\n\ninline ::testing::Matcher<const ::xls::Node*> Type(const char* type_str) {\n\n return ::testing::MakeMatcher(new ::xls::op_matchers::TypeMatcher(type_str));\n\n}\n\n\n", "file_path": "xls/ir/ir_matcher.h", "rank": 61, "score": 75339.2107869841 }, { "content": "// Class for matching node names. Example usage:\n\n//\n\n// EXPECT_THAT(baz, m::Or(m::Name(\"foo\"), m::Name(\"bar\"))\n\n//\n\n// TODO(meheff): Through template wizardry it'd probably be possible to elide\n\n// the m::Name. For example: EXPECT_THAT(baz, m::Or(\"foo\", \"bar\")).\n\nclass NameMatcher : public ::testing::MatcherInterface<const Node*> {\n\n public:\n\n explicit NameMatcher(absl::string_view name) : name_(name) {}\n\n\n\n bool MatchAndExplain(const Node* node,\n\n ::testing::MatchResultListener* listener) const override;\n\n void DescribeTo(std::ostream* os) const override;\n\n\n\n private:\n\n std::string name_;\n\n};\n\n\n\ninline ::testing::Matcher<const ::xls::Node*> Name(absl::string_view name_str) {\n\n return ::testing::MakeMatcher(new ::xls::op_matchers::NameMatcher(name_str));\n\n}\n\n\n\n// Node* matchers for ops which have no metadata beyond Op, type, and operands.\n\n#define NODE_MATCHER(op) \\\n\n template <typename... M> \\\n\n ::testing::Matcher<const ::xls::Node*> op(M... operands) { \\\n", "file_path": "xls/ir/ir_matcher.h", "rank": 62, "score": 75339.2107869841 }, { "content": "// Base class for matchers. Has two constructions. The first checks the op and\n\n// then recursively checks the operands. The second simply matches the name.\n\nclass NodeMatcher : public ::testing::MatcherInterface<const Node*> {\n\n public:\n\n NodeMatcher(const NodeMatcher&) = default;\n\n NodeMatcher(Op op, absl::Span<const ::testing::Matcher<const Node*>> operands)\n\n : op_(op), operands_(operands.begin(), operands.end()) {}\n\n\n\n bool MatchAndExplain(const Node* node,\n\n ::testing::MatchResultListener* listener) const override;\n\n void DescribeTo(::std::ostream* os) const override;\n\n\n\n protected:\n\n // Helper for DescribeTo which emits a description of the match with optional\n\n // extra fields. The resulting string has the form:\n\n //\n\n // op(operand_0, operand_1, ..., operand_n, field_0, field_1, ..., field_n)\n\n //\n\n // This enables emission of match descriptions with attribute values. For\n\n // example:\n\n //\n\n // tuple_index(param(), index=1)\n\n void DescribeToHelper(::std::ostream* os,\n\n absl::Span<const std::string> additional_fields) const;\n\n\n\n Op op_;\n\n std::vector<::testing::Matcher<const Node*>> operands_;\n\n};\n\n\n", "file_path": "xls/ir/ir_matcher.h", "rank": 63, "score": 75339.2107869841 }, { "content": "// Register matcher. Supported forms:\n\n//\n\n// EXPECT_THAT(foo, m::Register());\n\n// EXPECT_THAT(foo, m::Register(\"foo\"));\n\n// EXPECT_THAT(foo, m::Register(m::Add()));\n\n// EXPECT_THAT(foo, m::Register(\"foo\", m::Add()));\n\n//\n\nclass RegisterMatcher : public ::testing::MatcherInterface<const Node*> {\n\n public:\n\n explicit RegisterMatcher(absl::optional<std::string> register_name)\n\n : d_matcher_(register_name) {}\n\n RegisterMatcher(::testing::Matcher<const Node*> input,\n\n absl::optional<std::string> register_name)\n\n : q_matcher_(RegisterWriteMatcher(input, register_name)),\n\n d_matcher_(register_name) {}\n\n\n\n bool MatchAndExplain(const Node* node,\n\n ::testing::MatchResultListener* listener) const override;\n\n void DescribeTo(::std::ostream* os) const override;\n\n\n\n private:\n\n // Optional matcher for the send side of the register (the Q input port).\n\n absl::optional<RegisterWriteMatcher> q_matcher_;\n\n\n\n // Matcher for the receive side of the register (the D output port). This\n\n // matches a tuple index of a receive operation.\n\n RegisterReadMatcher d_matcher_;\n", "file_path": "xls/ir/ir_matcher.h", "rank": 64, "score": 75339.2107869841 }, { "content": "fn f(x: bits[4][1], y: bits[4][1]) -> bits[4] {\n\n array_concat.3: bits[4][4] = array_concat(x, x, y, y)\n\n\n\n literal.4: bits[32] = literal(value=0)\n\n literal.5: bits[32] = literal(value=1)\n\n literal.6: bits[32] = literal(value=2)\n\n literal.7: bits[32] = literal(value=3)\n\n\n\n array_index.8: bits[4] = array_index(array_concat.3, indices=[literal.4])\n\n element_0: bits[4] = array_index(array_concat.3, indices=[literal.5])\n\n array_index.10: bits[4] = array_index(array_concat.3, indices=[literal.6])\n\n array_index.11: bits[4] = array_index(array_concat.3, indices=[literal.7])\n\n\n\n xor.12: bits[4] = xor(array_index.8, array_index.11)\n\n xor.13: bits[4] = xor(xor.12, element_0)\n\n ret result: bits[4] = xor(xor.13, array_index.10)\n\n}\n\n)\";\n\n\n\n auto p = CreatePackage();\n\n XLS_ASSERT_OK_AND_ASSIGN(Function * f, ParseFunction(program, p.get()));\n\n XLS_ASSERT_OK_AND_ASSIGN(\n\n bool proven, TryProve(f, f->return_value(), Predicate::EqualToZero(),\n\n absl::InfiniteDuration()));\n\n EXPECT_TRUE(proven);\n\n}\n\n\n\n// Array Concat #0b - Test bits after concat are traced back to input (part b)\n\nTEST_F(Z3IrTranslatorTest, ConcatNotZero) {\n\n const std::string program = R\"(\n", "file_path": "xls/solvers/z3_ir_translator_test.cc", "rank": 65, "score": 74158.43991681132 }, { "content": "fn f(x: bits[4][1], y: bits[4][1]) -> bits[1] {\n\n array_concat.3: bits[4][4] = array_concat(x, x, y, y)\n\n\n\n literal.4: bits[32] = literal(value=0)\n\n literal.5: bits[32] = literal(value=1)\n\n literal.6: bits[32] = literal(value=2)\n\n literal.7: bits[32] = literal(value=3)\n\n\n\n array_index.8: bits[4] = array_index(array_concat.3, indices=[literal.4])\n\n element_0: bits[4] = array_index(array_concat.3, indices=[literal.5])\n\n array_index.10: bits[4] = array_index(array_concat.3, indices=[literal.6])\n\n array_index.11: bits[4] = array_index(array_concat.3, indices=[literal.7])\n\n\n\n xor.12: bits[4] = xor(array_index.8, array_index.11)\n\n xor.13: bits[4] = xor(xor.12, element_0)\n\n\n\n array_index.14: bits[4] = array_index(x, indices=[literal.4])\n\n array_index.15: bits[4] = array_index(y, indices=[literal.4])\n\n\n\n ret result: bits[1] = eq(xor.13, array_index.15)\n", "file_path": "xls/solvers/z3_ir_translator_test.cc", "rank": 66, "score": 74138.15263214606 }, { "content": "// Represents a value in the XLS system; e.g. values can be \"bits\", tuples of\n\n// values, or arrays or values. Arrays are represented similarly to tuples, but\n\n// are monomorphic and potentially multi-dimensional.\n\n//\n\n// TODO(leary): 2019-04-04 Arrays are not currently multi-dimensional, we had\n\n// some discussion around this, maybe they should be?\n\nclass Value {\n\n public:\n\n static Value Tuple(absl::Span<const Value> elements) {\n\n return Value(ValueKind::kTuple, elements);\n\n }\n\n static Value TupleOwned(std::vector<Value>&& elements) {\n\n return Value(ValueKind::kTuple, elements);\n\n }\n\n\n\n // All members of \"elements\" must be of the same type, or an error status will\n\n // be returned.\n\n static absl::StatusOr<Value> Array(absl::Span<const Value> elements);\n\n\n\n // Shortcut to create an array of bits from an initializer list of literals\n\n // ex. UBitsArray({1, 2}, 32) will create a Value of type bits[32][2]\n\n static absl::StatusOr<Value> UBitsArray(absl::Span<const uint64_t> elements,\n\n int64_t bit_count);\n\n static absl::StatusOr<Value> UBits2DArray(\n\n absl::Span<const absl::Span<const uint64_t>> elements, int64_t bit_count);\n\n static absl::StatusOr<Value> SBitsArray(absl::Span<const int64_t> elements,\n", "file_path": "xls/ir/value.h", "rank": 67, "score": 72872.10797132459 }, { "content": "fn f(x: bits[1], y: bits[2], z: bits[3]) -> bits[1] {\n\n concat.1: bits[6] = concat(x, y, z)\n\n literal.2: bits[6] = literal(value=0)\n\n ret eq.3: bits[1] = eq(concat.1, literal.2)\n\n}\n\n )\",\n\n p.get()));\n\n EXPECT_THAT(Run(f), IsOkAndHolds(true));\n\n EXPECT_THAT(\n\n f->return_value(),\n\n m::And(m::And(m::Eq(m::Param(\"x\"), m::BitSlice(m::Literal(0), 5, 1)),\n\n m::Eq(m::Param(\"y\"), m::BitSlice(m::Literal(0), 3, 2))),\n\n m::Eq(m::Param(\"z\"), m::BitSlice(m::Literal(0), 0, 3))));\n\n}\n\n\n\nTEST_F(ConcatSimplificationPassTest, NeOfConcatDistributes) {\n\n auto p = CreatePackage();\n\n XLS_ASSERT_OK_AND_ASSIGN(Function * f, ParseFunction(R\"(\n", "file_path": "xls/passes/concat_simplification_pass_test.cc", "rank": 68, "score": 71173.09287147393 }, { "content": "class AssignOrReturnLoop : public ReturnLoop<absl::StatusOr<int>> {\n\n public:\n\n explicit AssignOrReturnLoop(ReturnType return_value)\n\n : ReturnLoop(std::move(return_value)) {}\n\n\n\n private:\n\n ReturnType LoopAgain(size_t* ops) override {\n\n --*ops;\n\n XLS_ASSIGN_OR_RETURN(int result, Loop(ops));\n\n return result;\n\n }\n\n\n\n ReturnType result_;\n\n};\n\n\n", "file_path": "xls/common/status/status_macros_test.cc", "rank": 69, "score": 70650.58565588246 }, { "content": "// A coordinate representation in a dimensional space. It is composed of a\n\n// coordinate value for each dimension. The dimension count and each coordinate\n\n// value is greater than or equal to zero.\n\nclass Coordinate {\n\n public:\n\n Coordinate(std::initializer_list<int64_t> coordinates);\n\n Coordinate(int64_t dimension_count, int64_t value);\n\n absl::Span<const int64_t> GetCoordinates() const;\n\n int64_t GetCoordinate(int64_t dimension_index) const;\n\n void SetCoordinate(int64_t dimension_index, int64_t value);\n\n int64_t GetDimensionCount() const;\n\n\n\n // Returns true if the dimension count of the instance is equal to zero.\n\n // Otherwise, returns false.\n\n bool HasZeroDimensions() const;\n\n\n\n // Returns true if the dimension count between the instance and the\n\n // coordinate is equal. Otherwise, returns false.\n\n bool IsDimensionCountEqual(const Coordinate& coordinate) const;\n\n\n\n // Returns true if the dimension count between the instance and the\n\n // limit is equal. Otherwise, returns false.\n\n bool IsDimensionCountEqual(const DimensionBounds& dimensional_space) const;\n", "file_path": "xls/noc/config_ng/coordinate.h", "rank": 70, "score": 69971.38448467846 }, { "content": "// A type that orders the reachable nodes in a function into a usable traversal\n\n// order. Currently just does a stable topological ordering.\n\n//\n\n// Note that this container value must outlive any iterators derived from it\n\n// (via begin()/end()).\n\nclass NodeIterator {\n\n public:\n\n static NodeIterator Create(FunctionBase* f) {\n\n NodeIterator it(f);\n\n it.Initialize();\n\n return it;\n\n }\n\n\n\n static NodeIterator CreateReverse(FunctionBase* f) {\n\n NodeIterator it(f);\n\n it.Initialize();\n\n std::reverse(it.ordered_->begin(), it.ordered_->end());\n\n return it;\n\n }\n\n\n\n std::vector<Node*>::iterator begin() { return ordered_->begin(); }\n\n std::vector<Node*>::iterator end() { return ordered_->end(); }\n\n\n\n private:\n\n explicit NodeIterator(FunctionBase* f) : f_(f) {}\n", "file_path": "xls/ir/node_iterator.h", "rank": 71, "score": 69955.52887921741 }, { "content": "class iterator_range {\n\n public:\n\n using iterator = IteratorT;\n\n using const_iterator = IteratorT;\n\n using value_type = typename std::iterator_traits<IteratorT>::value_type;\n\n\n\n iterator_range() : begin_iterator_(), end_iterator_() {}\n\n iterator_range(IteratorT begin_iterator, IteratorT end_iterator)\n\n : begin_iterator_(std::move(begin_iterator)),\n\n end_iterator_(std::move(end_iterator)) {}\n\n\n\n IteratorT begin() const { return begin_iterator_; }\n\n IteratorT end() const { return end_iterator_; }\n\n\n\n private:\n\n IteratorT begin_iterator_, end_iterator_;\n\n};\n\n\n\n// Convenience function for iterating over sub-ranges.\n\n//\n", "file_path": "xls/common/iterator_range.h", "rank": 72, "score": 69944.03986208305 }, { "content": "class UnwrappingIterator\n\n : public std::iterator<std::input_iterator_tag,\n\n decltype(std::declval<NestedIter>()->get())> {\n\n private:\n\n NestedIter iter_;\n\n\n\n public:\n\n explicit UnwrappingIterator(NestedIter iter) : iter_(std::move(iter)) {}\n\n\n\n auto operator*() -> decltype(iter_->get()) { return iter_->get(); }\n\n auto operator-> () -> decltype(iter_->get()) { return iter_->get(); }\n\n UnwrappingIterator& operator++() {\n\n ++iter_;\n\n return *this;\n\n }\n\n UnwrappingIterator operator++(int) {\n\n UnwrappingIterator temp(iter_);\n\n operator++();\n\n return temp;\n\n }\n", "file_path": "xls/ir/unwrapping_iterator.h", "rank": 73, "score": 69944.03986208305 }, { "content": "// A DSLX interpreter value (variant), with InterpValueTag as a discriminator.\n\nclass InterpValue {\n\n public:\n\n struct UserFnData {\n\n Module* module;\n\n Function* function;\n\n };\n\n using FnData = absl::variant<Builtin, UserFnData>;\n\n\n\n // Factories\n\n\n\n // TODO(leary): 2020-10-18 Port to be consistent with xls/ir/bits.h\n\n static InterpValue MakeUBits(int64_t bit_count, int64_t value);\n\n static InterpValue MakeSBits(int64_t bit_count, int64_t value);\n\n\n\n static InterpValue MakeUnit() { return MakeTuple({}); }\n\n static InterpValue MakeU32(uint32_t value) {\n\n return MakeUBits(/*bit_count=*/32, value);\n\n }\n\n static InterpValue MakeEnum(Bits bits, EnumDef* type) {\n\n return InterpValue(InterpValueTag::kEnum, std::move(bits), type);\n", "file_path": "xls/dslx/interp_value.h", "rank": 74, "score": 69845.06757600502 }, { "content": "enum class ValueKind {\n\n kInvalid,\n\n\n\n kBits,\n\n\n\n kTuple,\n\n\n\n // Arrays must be homogeneous in their elements, and may choose to use a\n\n // more efficient storage mechanism as a result. For now we always used the\n\n // boxed Value type, though.\n\n kArray,\n\n\n\n kToken\n\n};\n\n\n\nstd::string ValueKindToString(ValueKind kind);\n\n\n\ninline std::ostream& operator<<(std::ostream& os, ValueKind kind) {\n\n os << ValueKindToString(kind);\n\n return os;\n\n}\n\n\n", "file_path": "xls/ir/value.h", "rank": 75, "score": 69837.74188711045 }, { "content": "class StrongInt {\n\n public:\n\n typedef NativeType ValueType;\n\n\n\n struct ABSL_DEPRECATED(\"Use absl::Hash instead\") Hasher {\n\n size_t operator()(const StrongInt &x) const {\n\n return static_cast<size_t>(x.value());\n\n }\n\n };\n\n\n\n static constexpr absl::string_view TypeName() { return TagType::TypeName(); }\n\n\n\n // Default value initialization.\n\n constexpr StrongInt()\n\n : value_((ValidatorType::template ValidateInit<ValueType>(NativeType()),\n\n NativeType())) {}\n\n\n\n // Explicit initialization from another StrongInt type that has an\n\n // implementation of:\n\n //\n", "file_path": "xls/common/strong_int.h", "rank": 76, "score": 69821.63513621483 }, { "content": "// Class which wraps OpenSSL's bignum library to provide support for arbitrary\n\n// width integer arithmetic operations.\n\nclass BigInt {\n\n public:\n\n // Make (un)signed BigInt from the given bits object. MakeSigned assumes a\n\n // twos-complement representation.\n\n static BigInt MakeSigned(const Bits& bits);\n\n static BigInt MakeUnsigned(const Bits& bits);\n\n\n\n BigInt();\n\n BigInt(const BigInt& other);\n\n BigInt(BigInt&& other);\n\n ~BigInt();\n\n BigInt& operator=(const BigInt& other);\n\n BigInt& operator=(BigInt&& other);\n\n\n\n bool operator==(const BigInt& other) const;\n\n bool operator!=(const BigInt& other) const { return !(*this == other); }\n\n\n\n // Returns the BigInt value as a (un)signed Bits object. The Bits object\n\n // returned from ToSignedBits is in twos-complement representation. If a width\n\n // is unspecified, then the Bits object has the minimum number of bits\n", "file_path": "xls/ir/big_int.h", "rank": 77, "score": 69821.63513621483 }, { "content": "class AssignOrReturnAnnotateLoop : public ReturnLoop<absl::StatusOr<int>> {\n\n public:\n\n explicit AssignOrReturnAnnotateLoop(ReturnType return_value)\n\n : ReturnLoop(std::move(return_value)) {}\n\n\n\n private:\n\n ReturnType LoopAgain(size_t* ops) override {\n\n --*ops;\n\n XLS_ASSIGN_OR_RETURN(int result, Loop(ops),\n\n _ << \"The quick brown fox jumped over the lazy dog.\");\n\n return result;\n\n }\n\n\n\n ReturnType result_;\n\n};\n\n\n\n} // namespace\n", "file_path": "xls/common/status/status_macros_test.cc", "rank": 78, "score": 69639.37643100834 }, { "content": "fn main(in: bits[16][3][2]) -> bits[16][3][2] {\n\n ret param.1: bits[16][3][2] = param(name=in)\n\n}\n\n)\";\n\n\n\n Value input = Array2D({{101, 102, 103}, {201, 202, 203}}, 16);\n\n RunAndExpectEq({{\"in\", input}}, input, text);\n\n}\n\n\n\nTEST_F(IrTypeTests, ArrayOfTuplesConstant) {\n\n // Index from an constant array of tuple and return an array of tuple\n\n // constructed from the elements.\n\n std::string text = R\"(\n\npackage ArrayOfTuplesConstant\n\n\n", "file_path": "xls/tests/ir_types_test.cc", "rank": 79, "score": 69221.29325445388 }, { "content": "struct IsStrongInt<StrongInt<Ts...>> : public std::true_type {};\n\n\n\n} // namespace xls\n\n\n\n// Defines the StrongInt using value_type and typedefs it to type_name, with no\n\n// validation of under/overflow situations.\n\n// The struct int_type_name ## _tag_ trickery is needed to ensure that a new\n\n// type is created per type_name.\n\n#define DEFINE_STRONG_INT_TYPE(type_name, value_type) \\\n\n struct type_name##_strong_int_tag_ { \\\n\n static constexpr absl::string_view TypeName() { return #type_name; } \\\n\n }; \\\n\n typedef ::xls::StrongInt<type_name##_strong_int_tag_, value_type, \\\n\n ::xls::NullStrongIntValidator> \\\n\n type_name;\n\n\n\nnamespace std {\n\n\n\n// Allow StrongInt to be used as a key to hashable containers.\n\ntemplate <typename Tag, typename Value, typename Validator>\n", "file_path": "xls/common/strong_int.h", "rank": 80, "score": 69050.01692654131 }, { "content": "// Associates each port used by a set of network components with an\n\n// ordered numeric index. Separate output and input indices are\n\n// provided and each are sequential in the range [0 ... Input/OutputCount()).\n\nclass PortIndexMap {\n\n public:\n\n // Number of input ports associated with a network component.\n\n absl::StatusOr<int64_t> InputPortCount(NetworkComponentId nc_id) const;\n\n\n\n // Number of output ports associated with a network component.\n\n // If port is not found then -1 is returned.\n\n absl::StatusOr<int64_t> OutputPortCount(NetworkComponentId nc_id) const;\n\n\n\n // Retrieve an input/output port based off of their index.\n\n // Note - must be called after FinalizePortOrder();\n\n absl::StatusOr<PortId> GetPortByIndex(NetworkComponentId nc_id,\n\n PortDirection dir,\n\n int64_t port_index) const;\n\n\n\n // Returns corresponding index of a port.\n\n absl::StatusOr<int64_t> GetPortIndex(PortId port_id, PortDirection dir) const;\n\n\n\n // Add to the index an ordering of ports.\n\n // All ports should be from the same network component, with the stated\n", "file_path": "xls/noc/simulation/indexer.h", "rank": 81, "score": 68506.76682304192 }, { "content": "class StrongIntRange {\n\n public:\n", "file_path": "xls/common/strong_int.h", "rank": 82, "score": 68404.29098004456 }, { "content": "class XlsInt : public XlsIntBase<Width, Signed> {\n\n public:\n\n // XLS[cc] will initialize to 0\n\n inline XlsInt() {}\n\n\n\n template <int ToW, bool ToSign>\n\n inline XlsInt(const XlsInt<ToW, ToSign> &o)\n\n : XlsIntBase<Width, Signed>(\n\n ConvertBits<ToW, Width, ToSign>::Convert(o.storage)) {}\n\n\n\n inline XlsInt(const BitElemRef &value)\n\n : XlsIntBase<Width, Signed>(ConvertBits<1, Width, false>::Convert(\n\n BuiltinIntToBits<bool, 1>::Convert(value))) {}\n\n\n\n inline XlsInt(bool value)\n\n : XlsIntBase<Width, Signed>(ConvertBits<1, Width, false>::Convert(\n\n BuiltinIntToBits<bool, 1>::Convert(value))) {}\n\n\n\n inline XlsInt(char value)\n\n : XlsIntBase<Width, Signed>(ConvertBits<8, Width, true>::Convert(\n", "file_path": "xls/contrib/xlscc/synth_only/xls_int.h", "rank": 83, "score": 68119.45421407092 }, { "content": "// Associates each virtual channel used in a design with an ordered numeric\n\n// index. The index goes from 0 ... VirtualChannelCount()-1.\n\n//\n\n// This is to enable optimization in which the order of the virtual channels\n\n// in a config is not the same as the index for that virtual channel. For,\n\n// example, the config could have ordered VC0/VC1 for port A and VC1/VC0 for\n\n// port B. This object enables reordering those virtual channels within the\n\n// simulator.\n\nclass VirtualChannelIndexMap {\n\n public:\n\n // Number of virtual channels associated with a port.\n\n // If port is not found then -1 is returned.\n\n absl::StatusOr<int64_t> VirtualChannelCount(PortId port_id) const;\n\n\n\n // Returns corresponding index of virtual channel.\n\n absl::StatusOr<int64_t> GetVirtualChannelIndex(PortId port_id,\n\n VirtualChannelParam vc) const;\n\n\n\n // Returns corresponding index of virtual channel name.\n\n absl::StatusOr<int64_t> GetVirtualChannelIndexByName(\n\n PortId port_id, absl::string_view vc_name) const;\n\n\n\n // Retrieve virtual channel based off of their index.\n\n // Note - must be called after FinalizeVirtualChannelOrder();\n\n absl::StatusOr<VirtualChannelParam> GetVirtualChannelByIndex(\n\n PortId port_id, int64_t vc_index) const;\n\n\n\n // Add to the index an ordering of virtual channels.\n", "file_path": "xls/noc/simulation/indexer.h", "rank": 84, "score": 67143.86255778323 }, { "content": "// Used to construct a PortIndexMap object.\n\nclass PortIndexMapBuilder {\n\n public:\n\n // Associate a given input/output port and vc with an index.\n\n // Note - index must be in the range [0, Input/OutputPortCount).\n\n absl::Status SetPortIndex(PortId port_id, PortDirection dir, int64_t index);\n\n\n\n // Returns corresponding index of a port.\n\n absl::StatusOr<int64_t> GetPortIndex(PortId port_id, PortDirection dir) const;\n\n\n\n // Returns a PortIndexMap which enables directly accessing ports based\n\n // off their index.\n\n absl::StatusOr<PortIndexMap> BuildPortIndex();\n\n\n\n private:\n\n struct PortOrder {\n\n std::vector<std::pair<PortId, int64_t>> input_port_index;\n\n std::vector<std::pair<PortId, int64_t>> output_port_index;\n\n };\n\n\n\n absl::flat_hash_map<NetworkComponentId, PortOrder> nc_to_ports_;\n\n};\n\n\n", "file_path": "xls/noc/simulation/indexer.h", "rank": 85, "score": 67139.45786516371 }, { "content": " element_type->AsArrayOrDie()->size()));\n\n element_type = element_type->AsArrayOrDie()->element_type();\n\n }\n\n return StoreResult(index, element);\n\n}\n\n\n\nabsl::Status FunctionBuilderVisitor::HandleArraySlice(ArraySlice* slice) {\n\n llvm::Value* array = node_map_.at(slice->array());\n\n llvm::Value* start = node_map_.at(slice->start());\n\n int64_t width = slice->width();\n\n\n\n // This overestimates the number of bits needed but in all practical\n\n // situations it should be fine. The only exception to that is if some code\n\n // uses a 64 bit index but doesn't actually make full use of that range, then\n\n // this will possibly push us over a performance cliff.\n\n int64_t index_bits = start->getType()->getIntegerBitWidth() +\n\n Bits::MinBitCountSigned(width) + 1;\n\n llvm::Type* index_type = builder_->getIntNTy(index_bits);\n\n llvm::Type* result_type =\n\n type_converter_->ConvertToLlvmType(slice->GetType());\n", "file_path": "xls/jit/function_builder_visitor.cc", "rank": 89, "score": 43.67332245434066 }, { "content": "### Function prefix_scan_eq\n\n\n\nThe implementation displays a few interesting language features.\n\n\n\nThe function prototype is straigt-forward. Input is an array of 8 values of type\n\n`u32`. Output is an array of size 8 holding 3-bit values (the maximum resulting\n\ncount can only be 7, which fits in 3 bits).\n\n\n\n```\n\nfn prefix_scan_eq(x: u32[8]) -> bits[8,3] {\n\n```\n\n\n\nThe first let expression produces a tuple of 3 values. It only cares about the\n\nlast value `result`, so it stubs out the other two elements via the 'ignore'\n\nplaceholder `_`.\n\n\n\n```\n\n let (_, _, result) =\n\n```\n\n\n\nWhy a 3-Tuple? Because he following loop has tuple of three values as the\n\naccumulator. The return type of the loop is the type of the accumulator, so\n\nabove let needs to be of the same type.\n\n\n\n#### Enumerated Loop\n\n\n\nUsing tuples as the accumulator is a convenient way to model multiple\n\nloop-carried values:\n\n\n\n```\n\n for ((i, elem), (prior, count, result)): ((u32, u32), (u32, u3, bits[8,3]))\n\n in enumerate(x) {\n\n```\n\n\n\nThe iterable of this loop is `enumerate(x)`. On each iteration, this construct\n\ndelivers a tuple consisting of current index and current element. This is\n\nrepresented as the tuple `(i, elem)` in the `for` construct.\n\n\n\nThe loop next specifies the accumulator, which is a 3-tuple consisting of the\n\nvalues named `prior`, `count`, and `result`.\n\n\n\nThe types of the iterable and accumulator are specified next. The iterable is a\n\ntuple consisting of two `u32` values. The accumulator is more interesting, it is\n\na tuple consiting of a `u32` value (`prior`), a `u3` value (`count`), and a\n\n2-dimension array type `bits[8, 3]`, which is an array holding 8 elements of\n\nbit-width 3. This is the type of `result` in the accumulator.\n\n\n\nLooping back to the prior `let` statement, it ignores the `prior` and `count`\n\nmembers of the tuple and will only return the `result` part.\n\n\n", "file_path": "docs_src/dslx_intro_example3.md", "rank": 90, "score": 43.19888098198861 }, { "content": " int64_t result_elements = array_type->getArrayNumElements();\n\n for (Node* operand : concat->operands()) {\n\n llvm::Value* array = node_map_.at(operand);\n\n llvm::Type* array_type = array->getType();\n\n\n\n int64_t element_count = array_type->getArrayNumElements();\n\n for (int64_t j = 0; j < element_count; ++j) {\n\n llvm::Value* element =\n\n builder_->CreateExtractValue(array, {static_cast<uint32_t>(j)});\n\n\n\n if (result_index >= result_elements) {\n\n return absl::InternalError(absl::StrFormat(\n\n \"array-concat %s result and source have mismatched number of \"\n\n \"elements - expected %d\",\n\n concat->ToString(), result_elements));\n\n }\n\n\n\n result = builder_->CreateInsertValue(\n\n result, element, {static_cast<uint32_t>(result_index)});\n\n ++result_index;\n", "file_path": "xls/jit/function_builder_visitor.cc", "rank": 91, "score": 42.67603152719975 }, { "content": "#include \"xls/ir/number_parser.h\"\n\n#include \"xls/ir/value.h\"\n\n\n\nnamespace xls {\n\nnamespace {\n\n\n\nusing status_testing::IsOkAndHolds;\n\nusing status_testing::StatusIs;\n\nusing ::testing::ElementsAre;\n\nusing ::testing::HasSubstr;\n\n\n\n// Create a Bits of the given bit count with the prime number index bits set to\n\n// one.\n\nBits PrimeBits(int64_t bit_count) {\n\n auto is_prime = [](int64_t n) {\n\n if (n < 2) {\n\n return false;\n\n }\n\n for (int64_t i = 2; i * i < n; ++i) {\n\n if (n % i == 0) {\n", "file_path": "xls/ir/bits_test.cc", "rank": 93, "score": 40.918629191314686 }, { "content": " std::vector<BValue> indices = {\n\n builder_.Literal(UBits(i, CeilOfLog2(array_type->size())))};\n\n BValue array_index = builder_.ArrayIndex(bv_node, indices);\n\n Vector element = UnpackParam(array_type->element_type(), array_index);\n\n result.insert(result.end(), element.begin(), element.end());\n\n }\n\n return result;\n\n }\n\n case TypeKind::kTuple: {\n\n Vector result;\n\n TupleType* tuple_type = type->AsTupleOrDie();\n\n for (int i = 0; i < tuple_type->size(); i++) {\n\n BValue tuple_index = builder_.TupleIndex(bv_node, i);\n\n Vector element = UnpackParam(tuple_type->element_type(i), tuple_index);\n\n result.insert(result.end(), element.begin(), element.end());\n\n }\n\n return result;\n\n }\n\n default:\n\n XLS_LOG(FATAL) << \"Unsupported/unimplemened param kind: \" << type->kind();\n", "file_path": "xls/tools/booleanifier.cc", "rank": 94, "score": 39.980738082339556 }, { "content": "\n\nBooleanifier::Vector Booleanifier::HandleArrayUpdate(\n\n const ArrayType* array_type, const Vector& array,\n\n const Vector& update_index, const Vector& update_value) {\n\n Vector result;\n\n const int64_t index_width = update_index.size();\n\n for (int i = 0; i < array_type->size(); i++) {\n\n const Value loop_index(UBits(i, index_width));\n\n\n\n const Element equals_index =\n\n evaluator_->Equals(FlattenValue(loop_index), update_index);\n\n const Vector old_value =\n\n HandleLiteralArrayIndex(array_type, array, loop_index, 0);\n\n const Vector new_value =\n\n evaluator_->Select(Vector({equals_index}), {old_value, update_value});\n\n result.insert(result.end(), new_value.begin(), new_value.end());\n\n }\n\n return result;\n\n}\n\n\n", "file_path": "xls/tools/booleanifier.cc", "rank": 96, "score": 38.98747472403147 }, { "content": " }\n\n if (dimensions_.HasZeroDimensions()) {\n\n return 0;\n\n }\n\n int64_t index = 0;\n\n for (int64_t count = 0; count < dimensions_offset_.size(); count++) {\n\n index += coordinate.GetCoordinate(count) * dimensions_offset_[count];\n\n }\n\n return index;\n\n }\n\n\n\n // For the use cases predicted for this class, the number of dimensions will\n\n // most likely not exceed eight. Enabling an efficient implementation for an\n\n // eight dimension instance.\n\n absl::InlinedVector<int64_t, 8> dimensions_offset_;\n\n DimensionBounds dimensions_;\n\n std::vector<T> elements_;\n\n};\n\n\n\n} // namespace xls::noc\n\n\n\n#endif // XLS_NOC_CONFIG_FLATTENED_MULTI_DIMENSIONAL_ARRAY_H_\n", "file_path": "xls/noc/config_ng/flattened_multi_dimensional_array.h", "rank": 97, "score": 38.88181290997213 }, { "content": " llvm::Type* result_element_type = type_converter_->ConvertToLlvmType(\n\n slice->GetType()->AsArrayOrDie()->element_type());\n\n llvm::AllocaInst* alloca_uncasted = builder_->CreateAlloca(result_type);\n\n llvm::Value* alloca = builder_->CreateBitCast(\n\n alloca_uncasted,\n\n llvm::PointerType::get(result_element_type, /*AddressSpace=*/0),\n\n \"alloca\");\n\n llvm::Value* start_big = builder_->CreateZExt(start, index_type, \"start_big\");\n\n\n\n for (int64_t i = 0; i < width; i++) {\n\n llvm::Value* index = builder_->CreateAdd(\n\n start_big, llvm::ConstantInt::get(index_type, i), \"index\");\n\n XLS_ASSIGN_OR_RETURN(\n\n llvm::Value * value,\n\n IndexIntoArray(array, index,\n\n slice->array()->GetType()->AsArrayOrDie()->size()));\n\n std::vector<llvm::Value*> gep_indices = {\n\n llvm::ConstantInt::get(llvm::Type::getInt64Ty(ctx_), i)};\n\n llvm::Value* gep =\n\n builder_->CreateGEP(result_element_type, alloca, gep_indices);\n", "file_path": "xls/jit/function_builder_visitor.cc", "rank": 98, "score": 38.851236603780116 }, { "content": "#### **`array_update`**\n\n\n\nReturns a modified copy of an array.\n\n\n\n**Syntax**\n\n\n\n```\n\nresult = array_update(array, value, indices=[idx_{0}, ... , idx_{N-1}])\n\n```\n\n\n\n**Types**\n\n\n\nValue | Type\n\n--------- | --------------------------------\n\n`array` | Array of at least `N` dimensions\n\n`value` | `T`\n\n`idx_{i}` | Arbitrary bits type\n\n`result` | Same type as `array`\n\n\n\nReturns a copy of the input array with the element at the given indices replaced\n\nwith the given value. If any index is out of bounds, the result is identical to\n\nthe input `array`. The indexing semantics is identical to `array_index` with the\n\nexception of out-of-bounds behavior.\n\n\n\n### Tuple operations\n\n\n\n\n\n#### **`tuple`**\n\n\n\nConstructs a tuple of its operands.\n\n\n\n```\n\nresult = tuple(operand_{0}, ..., operand_{N-1})\n\n```\n\n\n\n**Types**\n\n\n\nValue | Type\n\n------------- | ------------------------\n\n`operand_{i}` | `T_{i}`\n\n`result` | `(T_{0}, ... , T_{N-1})`\n\n\n\nTuple can take and arbitrary number of operands including zero (which produces\n\nan empty tuple).\n\n\n\n#### **`tuple_index`**\n\n\n\nReturns a single element from a tuple-typed operand.\n\n\n\n**Syntax**\n\n\n\n```\n\nresult = tuple_index(operand, index=<index>)\n\n```\n\n\n\n**Types**\n\n\n\nValue | Type\n\n--------- | ------------------------\n\n`operand` | `(T_{0}, ... , T_{N-1})`\n\n`result` | `T_{<index>}`\n\n\n\n**Keyword arguments**\n\n\n\nKeyword | Type | Required | Default | Description\n\n------- | --------- | -------- | ------- | ---------------------------------\n\n`index` | `int64_t` | yes | | Index of tuple element to produce\n\n\n\n### Bit-vector operations\n\n\n", "file_path": "docs_src/ir_semantics.md", "rank": 99, "score": 38.44290383301349 } ]
C++
src/god_field.cpp
connorzl/geometry-central
99114ffaf3efb58c912f94402dd0426cbb17d3f1
#include "geometrycentral/god_field.h" GodField::GodField(HalfedgeMesh *m, Geometry<Euclidean>* g) : mesh(m), geom(g) { edgeVector = HalfedgeData<std::complex<double>>(mesh); r = HalfedgeData<std::complex<double>>(mesh); field = FaceData<std::complex<double>>(mesh); faceAreas = FaceData<double>(mesh); } void GodField::computeCrossField(EdgeData<double> &lengths, HalfedgeData<double> &angles) { std::cout << "Computing Smoothest Cross Field" << std::endl; edgeLengths = lengths; heAngles = angles; faceAreas = Operators::computeAreas(mesh, edgeLengths); setup(); Eigen::SparseMatrix<std::complex<double>> M = assembleM(); Eigen::SparseMatrix<std::complex<double>> A = assembleA(); A = A + 1e-8 * M; Eigen::MatrixXcd u = Eigen::MatrixXcd::Random(mesh->nFaces(),1); Eigen::MatrixXcd x; PositiveDefiniteSolver<std::complex<double>> s(A); for (int i = 0; i < nPowerIterations; i++) { Eigen::MatrixXcd rhs = M * u; x = s.solve(rhs); std::complex<double> norm2 = (x.transpose() * M * x)(0,0); u = x / sqrt(norm2); } FaceData<size_t> faceIndices = mesh->getFaceIndices(); for (FacePtr f : mesh->faces()) { std::complex<double> c = u(faceIndices[f],0); std::complex<double> val; if (std::abs(c) == 0) { val = 0; } else { val = c / std::abs(c); } field[f] = val; } std::cout << "Done!" << std::endl; } void GodField::setup() { for (FacePtr f : mesh->faces()) { HalfedgePtr he = f.halfedge(); double l_jl = edgeLengths[he.edge()]; double l_ij = edgeLengths[he.prev().edge()]; double theta_ijl = heAngles[he.next()]; Vector2 j = Vector2{0,0}; Vector2 l = Vector2{l_jl,0}; Vector2 i = Vector2{cos(theta_ijl) * l_ij, sin(theta_ijl) * l_ij}; Vector2 jl = l - j; Vector2 li = i - l; Vector2 ij = j - i; edgeVector[he] = std::complex<double>(jl.x,jl.y); edgeVector[he.next()] = std::complex<double>(li.x,li.y); edgeVector[he.prev()] = std::complex<double>(ij.x,ij.y); } for (VertexPtr v : mesh->vertices()) { for (HalfedgePtr he : v.outgoingHalfedges()) { if (he.edge().isBoundary()) { continue; } std::complex<double> theta_ij = edgeVector[he]; std::complex<double> theta_ji = edgeVector[he.twin()]; r[he] = std::pow((-theta_ij / theta_ji), 4); r[he] = r[he] / std::abs(r[he]); } } } Eigen::SparseMatrix<std::complex<double>> GodField::assembleM() { size_t n = mesh->nFaces(); Eigen::SparseMatrix<std::complex<double>> M(n,n); std::vector<Eigen::Triplet<std::complex<double>>> triplets; FaceData<size_t> faceIndices = mesh->getFaceIndices(); for (FacePtr f : mesh->faces()) { size_t i = faceIndices[f]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i, i, faceAreas[f])); } M.setFromTriplets(triplets.begin(),triplets.end()); return M; } Eigen::SparseMatrix<std::complex<double>> GodField::assembleA() { size_t n = mesh->nFaces(); Eigen::SparseMatrix<std::complex<double>> A(n,n); std::vector<Eigen::Triplet<std::complex<double>>> triplets; FaceData<size_t> faceIndices = mesh->getFaceIndices(); for (FacePtr f : mesh->faces()) { size_t i = faceIndices[f]; HalfedgePtr he_ij = f.halfedge(); std::complex<double> r_ij, r_jk, r_ki; r_ij = r[he_ij]; r_jk = r[he_ij.next()]; r_ki = r[he_ij.prev()]; double sumWeight = 0; double weight; HalfedgePtr he = f.halfedge(); if (!he_ij.edge().isBoundary()) { weight = 1; sumWeight += weight; size_t i_ij = faceIndices[he_ij.twin().face()]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i,i_ij,-weight * r_ij)); } if (!he_ij.next().edge().isBoundary()) { weight = 1; sumWeight += weight; size_t i_jk = faceIndices[he_ij.next().twin().face()]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i,i_jk,-weight * r_jk)); } if (!he_ij.prev().edge().isBoundary()) { weight = 1; sumWeight += weight; size_t i_ki = faceIndices[he_ij.prev().twin().face()]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i,i_ki,-weight * r_ki)); } triplets.push_back(Eigen::Triplet<std::complex<double>>(i, i, sumWeight)); } A.setFromTriplets(triplets.begin(),triplets.end()); return A; } size_t GodField::computeSingularities(VertexData<int> &singularities) { std::cout << "Computing Singularities..."; int total = 0; size_t numSingularities = 0; for (VertexPtr v : mesh->vertices()) { double angleSum = 0; if (v.isBoundary()) { singularities[v] = 0; continue; } for (HalfedgePtr he : v.outgoingHalfedges()) { std::complex<double> u_i = field[he.face()]; std::complex<double> u_j = field[he.twin().face()]; std::complex<double> r_ji = r[he]; angleSum += std::arg(u_i / (r_ji * u_j)); } double phi = (angleSum + 4*geom->angleDefect(v)) / (2.0 * M_PI); singularities[v] = std::round(phi); if (singularities[v] != 0) { numSingularities++; } total += singularities[v]; } std::cout << "Done! Singularities Index Sum: " << total << std::endl; return numSingularities; }
#include "geometrycentral/god_field.h" GodField::GodField(HalfedgeMesh *m, Geometry<Euclidean>* g) : mesh(m), geom(g) { edgeVector = HalfedgeData<std::complex<double>>(mesh); r = HalfedgeData<std::complex<double>>(mesh); field = FaceData<std::complex<double>>(mesh); faceAreas = FaceData<double>(mesh); }
void GodField::setup() { for (FacePtr f : mesh->faces()) { HalfedgePtr he = f.halfedge(); double l_jl = edgeLengths[he.edge()]; double l_ij = edgeLengths[he.prev().edge()]; double theta_ijl = heAngles[he.next()]; Vector2 j = Vector2{0,0}; Vector2 l = Vector2{l_jl,0}; Vector2 i = Vector2{cos(theta_ijl) * l_ij, sin(theta_ijl) * l_ij}; Vector2 jl = l - j; Vector2 li = i - l; Vector2 ij = j - i; edgeVector[he] = std::complex<double>(jl.x,jl.y); edgeVector[he.next()] = std::complex<double>(li.x,li.y); edgeVector[he.prev()] = std::complex<double>(ij.x,ij.y); } for (VertexPtr v : mesh->vertices()) { for (HalfedgePtr he : v.outgoingHalfedges()) { if (he.edge().isBoundary()) { continue; } std::complex<double> theta_ij = edgeVector[he]; std::complex<double> theta_ji = edgeVector[he.twin()]; r[he] = std::pow((-theta_ij / theta_ji), 4); r[he] = r[he] / std::abs(r[he]); } } } Eigen::SparseMatrix<std::complex<double>> GodField::assembleM() { size_t n = mesh->nFaces(); Eigen::SparseMatrix<std::complex<double>> M(n,n); std::vector<Eigen::Triplet<std::complex<double>>> triplets; FaceData<size_t> faceIndices = mesh->getFaceIndices(); for (FacePtr f : mesh->faces()) { size_t i = faceIndices[f]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i, i, faceAreas[f])); } M.setFromTriplets(triplets.begin(),triplets.end()); return M; } Eigen::SparseMatrix<std::complex<double>> GodField::assembleA() { size_t n = mesh->nFaces(); Eigen::SparseMatrix<std::complex<double>> A(n,n); std::vector<Eigen::Triplet<std::complex<double>>> triplets; FaceData<size_t> faceIndices = mesh->getFaceIndices(); for (FacePtr f : mesh->faces()) { size_t i = faceIndices[f]; HalfedgePtr he_ij = f.halfedge(); std::complex<double> r_ij, r_jk, r_ki; r_ij = r[he_ij]; r_jk = r[he_ij.next()]; r_ki = r[he_ij.prev()]; double sumWeight = 0; double weight; HalfedgePtr he = f.halfedge(); if (!he_ij.edge().isBoundary()) { weight = 1; sumWeight += weight; size_t i_ij = faceIndices[he_ij.twin().face()]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i,i_ij,-weight * r_ij)); } if (!he_ij.next().edge().isBoundary()) { weight = 1; sumWeight += weight; size_t i_jk = faceIndices[he_ij.next().twin().face()]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i,i_jk,-weight * r_jk)); } if (!he_ij.prev().edge().isBoundary()) { weight = 1; sumWeight += weight; size_t i_ki = faceIndices[he_ij.prev().twin().face()]; triplets.push_back(Eigen::Triplet<std::complex<double>>(i,i_ki,-weight * r_ki)); } triplets.push_back(Eigen::Triplet<std::complex<double>>(i, i, sumWeight)); } A.setFromTriplets(triplets.begin(),triplets.end()); return A; } size_t GodField::computeSingularities(VertexData<int> &singularities) { std::cout << "Computing Singularities..."; int total = 0; size_t numSingularities = 0; for (VertexPtr v : mesh->vertices()) { double angleSum = 0; if (v.isBoundary()) { singularities[v] = 0; continue; } for (HalfedgePtr he : v.outgoingHalfedges()) { std::complex<double> u_i = field[he.face()]; std::complex<double> u_j = field[he.twin().face()]; std::complex<double> r_ji = r[he]; angleSum += std::arg(u_i / (r_ji * u_j)); } double phi = (angleSum + 4*geom->angleDefect(v)) / (2.0 * M_PI); singularities[v] = std::round(phi); if (singularities[v] != 0) { numSingularities++; } total += singularities[v]; } std::cout << "Done! Singularities Index Sum: " << total << std::endl; return numSingularities; }
void GodField::computeCrossField(EdgeData<double> &lengths, HalfedgeData<double> &angles) { std::cout << "Computing Smoothest Cross Field" << std::endl; edgeLengths = lengths; heAngles = angles; faceAreas = Operators::computeAreas(mesh, edgeLengths); setup(); Eigen::SparseMatrix<std::complex<double>> M = assembleM(); Eigen::SparseMatrix<std::complex<double>> A = assembleA(); A = A + 1e-8 * M; Eigen::MatrixXcd u = Eigen::MatrixXcd::Random(mesh->nFaces(),1); Eigen::MatrixXcd x; PositiveDefiniteSolver<std::complex<double>> s(A); for (int i = 0; i < nPowerIterations; i++) { Eigen::MatrixXcd rhs = M * u; x = s.solve(rhs); std::complex<double> norm2 = (x.transpose() * M * x)(0,0); u = x / sqrt(norm2); } FaceData<size_t> faceIndices = mesh->getFaceIndices(); for (FacePtr f : mesh->faces()) { std::complex<double> c = u(faceIndices[f],0); std::complex<double> val; if (std::abs(c) == 0) { val = 0; } else { val = c / std::abs(c); } field[f] = val; } std::cout << "Done!" << std::endl; }
function_block-full_function
[ { "content": "class GodField {\n\n public:\n\n GodField() {};\n\n GodField(HalfedgeMesh *m, Geometry<Euclidean> *geom);\n\n\n\n void computeCrossField(EdgeData<double> &lengths, HalfedgeData<double> &angles);\n\n size_t computeSingularities(VertexData<int> &singularities);\n\n\n\n FaceData<std::complex<double>> field;\n\n\n\n private:\n\n HalfedgeMesh* mesh;\n\n Geometry<Euclidean> *geom;\n\n\n\n int nPowerIterations = 20;\n\n\n\n void setup();\n\n \n\n Eigen::SparseMatrix<std::complex<double>> assembleM();\n\n Eigen::SparseMatrix<std::complex<double>> assembleA();\n\n\n\n HalfedgeData<std::complex<double>> r;\n\n HalfedgeData<std::complex<double>> edgeVector;\n\n\n\n EdgeData<double> edgeLengths;\n\n HalfedgeData<double> heAngles;\n\n FaceData<double> faceAreas;\n\n};", "file_path": "include/geometrycentral/god_field.h", "rank": 0, "score": 127443.01234932964 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n#include \"geometrycentral/operators.h\"\n\n#include \"geometrycentral/linear_solvers.h\"\n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/god_field.h", "rank": 1, "score": 120845.47530601801 }, { "content": "namespace geometrycentral {\n\n\n\n// === Completely compute direction fields\n\n// If the mesh has boundary, imposes dirichlet boundary conditions to\n\n// conform to the boundary.\n\n// Otherwise, computes the unit-norm solution\n\n// t \\in [0,1] controls the strength of alignment with principal directions\n\n\n\nVertexData<Complex> computeSmoothestVertexDirectionField(Geometry<Euclidean>* geometry, int nSym = 1,\n\n bool alignCurvature = false);\n\n\n\nFaceData<Complex> computeSmoothestFaceDirectionField(Geometry<Euclidean>* geometry, int nSym = 1,\n\n bool alignCurvature = false);\n\n\n\n// Find singularities in direction fields\n\nFaceData<int> computeFaceIndex(Geometry<Euclidean>* geometry, VertexData<Complex> directionField, int nSym = 1);\n\nVertexData<int> computeVertexIndex(Geometry<Euclidean>* geometry, FaceData<Complex> directionField, int nSym = 1);\n\n\n", "file_path": "include/geometrycentral/direction_fields.h", "rank": 2, "score": 103770.4285684568 }, { "content": "struct get_dim<Matrix<S,R,C,O,MR,MC> > { enum { Dim = R }; };\n\n\n\ntemplate<typename Transformation, int N>\n", "file_path": "deps/eigen/bench/geometry.cpp", "rank": 3, "score": 85408.99040955439 }, { "content": "#pragma once\n\n\n\n#include <cmath>\n\n#include <complex>\n\n#include <complex>\n\n#include <exception>\n\n#include <limits>\n\n#include <random>\n\n#include <string>\n\n#include <typeinfo>\n\n\n\n#include \"geometrycentral/vector2.h\"\n\n#include \"geometrycentral/vector3.h\"\n\n\n\nnamespace geometrycentral {\n\n\n\nconst double PI = 3.1415926535897932384;\n\n\n\n// Lightweight class for holding 3-tuples of unsigned ints\n\nunion uint3 {\n", "file_path": "include/geometrycentral/utilities.h", "rank": 4, "score": 62364.02286437124 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n#include \"geometrycentral/spectral_conformal.h\"\n\n#include <fstream> \n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/arap.h", "rank": 5, "score": 62363.59751295986 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n#include \"geometrycentral/operators.h\"\n\n#include \"geometrycentral/linear_solvers.h\"\n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/uniformization.h", "rank": 6, "score": 62363.5707432548 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n#include <fstream> \n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/tutte.h", "rank": 7, "score": 62363.41914710773 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n#include \"geometrycentral/polygon_soup_mesh.h\"\n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/stripes.h", "rank": 8, "score": 62363.31783482637 }, { "content": "#pragma once\n\n\n\n// The MeshIO class provides a variety of methods for mesh input/output.\n\n\n\n#include \"geometrycentral/geometry.h\"\n\n#include <fstream>\n\n#include <string>\n\n\n\nnamespace geometrycentral {\n\n\n", "file_path": "include/geometrycentral/meshio.h", "rank": 9, "score": 62363.25175407431 }, { "content": "//\n\n// Note that the Geometry class also includes convenience methods for\n\n// computing standard quantities like total surface area, etc.\n\n//\n\n\n\n// TODO: Right now many parts of Geometry implicitly assume that all real faces\n\n// are triangular.\n\n// If you want to store non-triangular faces, be careful.\n\n\n\n#include <iostream>\n\n\n\n#include \"geometrycentral/geometry_cache.h\"\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/unit_vector3.h\"\n\n#include \"geometrycentral/vector2.h\"\n\n#include \"geometrycentral/vector3.h\"\n\n\n\nnamespace geometrycentral {\n\n\n\n// Possible geometry types\n\ntypedef Vector2 Planar; // TODO change to Complex\n\ntypedef Vector3 Euclidean;\n\ntypedef UnitVector3 Spherical;\n\n// TODO Hyperbolic\n\n\n\n\n\n// TODO In the future, could be extended to other types of mesh data structures\n\n// (e.g., via an additional template argument)\n\ntemplate <class T>\n", "file_path": "include/geometrycentral/geometry.h", "rank": 10, "score": 62363.05807292477 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/distortion.h", "rank": 11, "score": 62362.99266593985 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/operators.h", "rank": 12, "score": 62362.99266593985 }, { "content": "// Vector3 b = q.im();\n\n//\n\n// or by index:\n\n//\n\n// Quaternion q;\n\n// double a = q[0];\n\n// double bi = q[1];\n\n// double bj = q[2];\n\n// double bk = q[3];\n\n//\n\n\n\n#include \"geometrycentral/vector3.h\"\n\n#include <ostream>\n\n\n\nnamespace geometrycentral {\n\n\n", "file_path": "include/geometrycentral/quaternion.h", "rank": 13, "score": 62362.685355222035 }, { "content": "\n\n void getAngularCoordinates(HalfedgeData<double>& angularCoordinates);\n\n\n\n void normalize();\n\n std::vector<T> getVertexPositionList();\n\n\n\n // members\n\n HalfedgeMesh& mesh;\n\n GeometryCache<T> cache;\n\n\n\nprotected:\n\n VertexData<T>& p; // convenience reference to \"this\"\n\n};\n\n\n\n} // namespace geometrycentral\n\n\n\n#include \"geometrycentral/geometry.ipp\"\n", "file_path": "include/geometrycentral/geometry.h", "rank": 14, "score": 62360.502748185245 }, { "content": "#pragma once\n\n\n\n// Curve =======================================================================\n\n\n\n// Curve is an abstract base class defining the interface for\n\n// parameterized curves interpolating data of any type T that\n\n// overloads standard vector space operations (+,-,*) and has\n\n// a method T T::zero() returning a zero value (additive identity).\n\n// (Such types include, for instance, Vector2 and Vector3.)\n\n//\n\n// Curves may be evaluated either via named methods or the\n\n// parenthesis operator. For example,\n\n//\n\n// Curve<double> curve;\n\n// double a = curve.value( 1.23 );\n\n// double b = curve( 1.23 );\n\n// // Both a and b now hold the value at time t=1.23\n\n//\n\n// Likewise, derivatives can be expressed via\n\n//\n", "file_path": "include/geometrycentral/curve.h", "rank": 15, "score": 62359.84806644038 }, { "content": "// double u = curve.derivative( 1.23, 2 );\n\n// double v = curve( 1.23, 2 );\n\n// // Both u and v now hold the first derivative at time t=1.23\n\n//\n\n// Curve evaluation returns valid results for values in the range\n\n// [0,L], where L is the length returned by Curve::length(). Any\n\n// behavior outside this range is undefined, and may vary depending\n\n// on the curve type. For instance,\n\n//\n\n// double L = curve.length();\n\n// curve.value( 2.*L ); // behavior undefined!\n\n//\n\n// Beyond this basic interface nothing is assumed about the\n\n// representation of the curve, though subclasses may expose\n\n// additional information. See below for more detail.\n\n//\n\n\n\n#include <vector>\n\n\n\nnamespace geometrycentral {\n\n\n\ntemplate <typename T>\n", "file_path": "include/geometrycentral/curve.h", "rank": 16, "score": 62359.73225562354 }, { "content": "\n\n Quaternion unit(void) const;\n\n // returns unit quaternion\n\n\n\n void normalize(void);\n\n // divides by Euclidean length\n\n\n\n protected:\n\n double s;\n\n // scalar (double) part\n\n\n\n Vector3 v;\n\n // vector (imaginary) part\n\n};\n\n\n\nQuaternion conjugate(const Quaternion& q);\n\n// conjugation---this method simply invokes Quaternion::bar(),\n\n// and is needed only for providing a uniform interface to templated\n\n// classes that need to handle both Quaternions and atomic types like\n\n// double (specifically, the SparseMatrix and DenseMatrix classes)\n\n\n\nQuaternion operator*(double c, const Quaternion& q);\n\n// left scalar multiplication\n\n\n\nstd::ostream& operator<<(std::ostream& os, const Quaternion& q);\n\n// prints components\n\n\n\n} // namespace geometrycentral", "file_path": "include/geometrycentral/quaternion.h", "rank": 17, "score": 62355.67940094006 }, { "content": " Vector3 normal(FacePtr f);\n\n Vector3 areaVector(FacePtr f);\n\n T barycenter(FacePtr f);\n\n T circumcenter(FacePtr f);\n\n\n\n // Halfedge attributes\n\n T vector(HalfedgePtr h);\n\n double angle(HalfedgePtr h); // **triangles only**\n\n double angle(CornerPtr c); // **triangles only**\n\n double angularCoordinate(HalfedgePtr h); // **triangles only** Measured CCW\n\n // against the tail vertex's\n\n // arbitrary halfedge\n\n double cotan(HalfedgePtr h); // **triangles only**\n\n\n\n // Global attributes\n\n double totalArea(void); // Total surface area (assuming all triangles)\n\n T center(void); // Center of mass (assuming constant density)\n\n void boundingBox(T& bboxMin,\n\n T& bboxMax); // Corners of axis-aligned bounding box\n\n T extent(void); // Width, height, and depth of the axis-aligned bounding box\n", "file_path": "include/geometrycentral/geometry.h", "rank": 18, "score": 62355.67940094006 }, { "content": "#pragma once\n\n\n\n// Quaternion represents an element of the quaternions, along with all the usual\n\n// vectors space operations (addition, multiplication by scalars, etc.). The\n\n// Hamilton product is expressed using the * operator:\n\n//\n\n// Quaternion p, q, r;\n\n// r = q * p;\n\n//\n\n// and conjugation is expressed using the method Quaternion::bar():\n\n//\n\n// Quaternion q;\n\n// double normQSquared = -q.bar()*q;\n\n//\n\n// Individual components can be accessed in several ways: the real and imaginary\n\n// parts can be accessed using the methods Quaternion::re() and\n\n// Quaternion::im():\n\n//\n\n// Quaternion q;\n\n// double a = q.re();\n", "file_path": "include/geometrycentral/quaternion.h", "rank": 19, "score": 62355.67940094006 }, { "content": " struct {\n\n unsigned int first;\n\n unsigned int second;\n\n unsigned int third;\n\n };\n\n unsigned int v[3];\n\n};\n\n\n\n// Complex numbers are useful\n\nusing Complex = ::std::complex<double>;\n\nconst Complex IM_I(0.0, 1.0);\n\ninline double dot(Complex x, Complex y) {\n\n return x.real() * y.real() + x.imag() * y.imag();\n\n}\n\n\n\ninline Complex inv(Complex c) { return ::std::conj(c) / ::std::norm(c); }\n\ninline Complex unit(Complex c) { return c / ::std::abs(c); }\n\n\n\n// Various functions\n\ntemplate <typename T>\n", "file_path": "include/geometrycentral/utilities.h", "rank": 20, "score": 62355.67940094006 }, { "content": " // right scalar multiplication\n\n\n\n Quaternion operator/(double c) const;\n\n // scalar division\n\n\n\n void operator+=(const Quaternion& q);\n\n // addition / assignment\n\n\n\n void operator+=(double c);\n\n // addition / assignment of pure real\n\n\n\n void operator-=(const Quaternion& q);\n\n // subtraction / assignment\n\n\n\n void operator-=(double c);\n\n // subtraction / assignment of pure real\n\n\n\n void operator*=(double c);\n\n // scalar multiplication / assignment\n\n\n", "file_path": "include/geometrycentral/quaternion.h", "rank": 21, "score": 62355.67940094006 }, { "content": " double lengthScale(void); // A length scale for the geometry\n\n\n\n // Methods for caching current attributes\n\n void getVertexPositions(VertexData<T>& vertexPosition);\n\n void getVertexNormals(VertexData<Vector3>& vertexNormal);\n\n void getVertexAngleDefects(VertexData<double>& vertexAngleDefect);\n\n void getPrincipalDirections(VertexData<Complex>& principalDirections);\n\n void getPrincipalDirections(VertexData<Complex>& principalDirections, HalfedgeData<double>& angularCoordinates);\n\n\n\n void getEdgeLengths(EdgeData<double>& edgeLength);\n\n void getEdgeCotanWeights(EdgeData<double>& edgeCotanWeight);\n\n\n\n void getFaceAreas(FaceData<double>& faceArea);\n\n void getFaceNormals(FaceData<Vector3>& faceNormal);\n\n void getFaceBarycenters(FaceData<T>& faceBarycenter);\n\n\n\n void getHalfedgeVectors(HalfedgeData<T>& halfedgeVector);\n\n void getHalfedgeAngles(HalfedgeData<double>& halfedgeAngle);\n\n void getCornerAngles(CornerData<double>& cornerAngle);\n\n void getHalfedgeCotans(HalfedgeData<double>& halfedgeCotan);\n", "file_path": "include/geometrycentral/geometry.h", "rank": 22, "score": 62355.67940094006 }, { "content": " // component (real part is zero)\n\n\n\n const Quaternion& operator=(double s);\n\n // assigns a purely real quaternion with real value s\n\n\n\n const Quaternion& operator=(const Vector3& v);\n\n // assigns a purely real quaternion with imaginary value v\n\n\n\n double& operator[](int index);\n\n // returns reference to the specified component (0-based indexing: r, i, j, k)\n\n\n\n const double& operator[](int index) const;\n\n // returns const reference to the specified component (0-based indexing: r, i,\n\n // j, k)\n\n\n\n void toMatrix(double Q[4][4]) const;\n\n // builds 4x4 matrix Q representing (left) quaternion multiplication\n\n\n\n double& re(void);\n\n // returns reference to double part\n", "file_path": "include/geometrycentral/quaternion.h", "rank": 23, "score": 62355.67940094006 }, { "content": " void operator/=(double c);\n\n // scalar division / assignment\n\n\n\n Quaternion operator*(const Quaternion& q) const;\n\n // Hamilton product\n\n\n\n void operator*=(const Quaternion& q);\n\n // Hamilton product / assignment\n\n\n\n Quaternion bar(void) const;\n\n // conjugation\n\n\n\n Quaternion inv(void) const;\n\n // inverse\n\n\n\n double norm(void) const;\n\n // returns Euclidean length\n\n\n\n double norm2(void) const;\n\n // returns Euclidean length squared\n", "file_path": "include/geometrycentral/quaternion.h", "rank": 24, "score": 62355.67940094006 }, { "content": " double y = clamp(val.y, low.y, high.y);\n\n double z = clamp(val.z, low.z, high.z);\n\n return Vector3{x, y, z};\n\n}\n\n\n\ntemplate <typename T>\n\ninline bool approxEqualsAbsolute(T a, T b, double eps) {\n\n double absA = ::std::abs(a);\n\n double absB = ::std::abs(b);\n\n double absDiff = ::std::abs(a - b);\n\n\n\n if (a == b) {\n\n return true;\n\n } else {\n\n return absDiff < eps;\n\n }\n\n}\n\n\n\ninline double regularizeAngle(double theta) {\n\n return theta - 2 * PI * ::std::floor(theta / (2 * PI));\n", "file_path": "include/geometrycentral/utilities.h", "rank": 25, "score": 62355.67940094006 }, { "content": " VertexData<std::complex<double>> field;\n\n FaceData<int> singularities;\n\n EdgeData<int> branchCover;\n\n EdgeData<double> omega;\n\n \n\n // helpers\n\n void setup();\n\n Eigen::SparseMatrix<std::complex<double>> assembleM();\n\n Eigen::SparseMatrix<std::complex<double>> assembleA();\n\n Eigen::MatrixXcd principalEigenvector(Eigen::SparseMatrix<std::complex<double>> A, Eigen::SparseMatrix<std::complex<double>> B);\n\n Eigen::SparseMatrix<double> EnergyMatrix();\n\n Eigen::SparseMatrix<double> MassMatrix();\n\n Eigen::MatrixXcd principalEigenvector(Eigen::SparseMatrix<double> A, Eigen::SparseMatrix<double> B);\n\n\n\n // visualization\n\n //Eigen::SparseMatrix<std::complex<double>> buildLaplacian();\n\n};", "file_path": "include/geometrycentral/stripes.h", "rank": 26, "score": 62355.67940094006 }, { "content": "}\n\n\n\ntemplate <typename T>\n\nstd::string typeNameString(T& x) {\n\n return std::string(typeid(x).name());\n\n}\n\n\n\ntemplate <typename T>\n\nstd::string typeNameString(T* x) {\n\n return std::string(typeid(x).name());\n\n}\n\n\n\ntemplate <typename T>\n\nvoid safeDelete(T*& x) {\n\n if (x != nullptr) {\n\n delete x;\n\n x = nullptr;\n\n }\n\n}\n\n\n", "file_path": "include/geometrycentral/utilities.h", "rank": 27, "score": 62355.67940094006 }, { "content": "inline std::string to_string(std::vector<T> const& v) {\n\n std::stringstream ss;\n\n ss << \"[\";\n\n for (size_t i = 0; i < v.size(); i++) {\n\n if (i > 0) {\n\n ss << \",\";\n\n }\n\n ss << v[i];\n\n }\n\n ss << \"]\";\n\n\n\n return ss.str();\n\n}\n\n\n\n// === Custom error types\n", "file_path": "include/geometrycentral/utilities.h", "rank": 28, "score": 62355.67940094006 }, { "content": "T clamp(T val, T low, T high);\n\nVector3 clamp(Vector3 val, Vector3 low, Vector3 high);\n\ntemplate <typename T>\n\nbool approxEqualsAbsolute(T a, T b, double eps = 1e-6);\n\ndouble regularizeAngle(double theta); // Map theta in to [0,2pi)\n\n\n\ntemplate <typename T>\n\nT sqr(T x) {\n\n return x * x;\n\n}\n\n\n\n// === Inline implementations\n\ntemplate <typename T>\n\ninline T clamp(T val, T low, T high) {\n\n if (val > high) return high;\n\n if (val < low) return low;\n\n return val;\n\n}\n\ninline Vector3 clamp(Vector3 val, Vector3 low, Vector3 high) {\n\n double x = clamp(val.x, low.x, high.x);\n", "file_path": "include/geometrycentral/utilities.h", "rank": 29, "score": 62355.67940094006 }, { "content": "template <typename T>\n\nvoid safeDeleteArray(T*& x) {\n\n if (x != nullptr) {\n\n delete[] x;\n\n x = nullptr;\n\n }\n\n}\n\n\n\n// Random number generation -----------------------------------------\n\nextern std::random_device util_random_device;\n\nextern std::mt19937 util_mersenne_twister;\n\n\n\ninline double unitRand() {\n\n std::uniform_real_distribution<double> dist(0., 1.);\n\n return dist(util_mersenne_twister);\n\n}\n\n\n\ninline double randomReal(double minVal, double maxVal) {\n\n std::uniform_real_distribution<double> dist(minVal, maxVal);\n\n return dist(util_mersenne_twister);\n", "file_path": "include/geometrycentral/utilities.h", "rank": 30, "score": 62355.67940094006 }, { "content": "// Finally, caching only the attributes that are needed (rather than\n\n// all possible attributes) reduces memory usage.\n\n//\n\n// Example usage:\n\n//\n\n// // compute the total surface area directly\n\n// double sum = 0.;\n\n// for(FacePtr f : mesh->faces)\n\n// {\n\n// sum += geometry->area(f);\n\n// }\n\n//\n\n// // compute the total surface area using cached values\n\n// FaceData<double> area;\n\n// geometry->getFaceAreas(area); // fill the cache\n\n// double sum = 0.;\n\n// for(FacePtr f : mesh->faces())\n\n// {\n\n// sum += area[f];\n\n// }\n", "file_path": "include/geometrycentral/geometry.h", "rank": 31, "score": 62355.67940094006 }, { "content": "#pragma once\n\n\n\n// The Geometry class specifies the geometry of a given mesh, i.e.,\n\n// the location of its vertices in space, where \"in space\" could mean\n\n// a variety of things (in 3D, in the plane, on the sphere). It is\n\n// also used to answer queries about that geometry, e.g., what is the\n\n// area of a given triangle or the length of a given edge.\n\n//\n\n// There are two principal ways to evaluate a given geometric quantity:\n\n//\n\n// 1. via methods that evaluate attributes directly, or\n\n// 2. by caching attributes in a Data vector (Geometry::get*())\n\n//\n\n// The former is useful in scenarios where the geometry is constantly\n\n// changing (e.g., when smoothing or editing a surface), hence cached\n\n// values quickly become stale and there is little gained by storing\n\n// them. The latter is useful in scenarios where the geometry remains\n\n// fixed throughout the entire algorithm (e.g., flattening or\n\n// remeshing), hence there is no reason to repeatedly recompute values.\n\n// Caching may also simplify syntax and reduce function call overhead.\n", "file_path": "include/geometrycentral/geometry.h", "rank": 32, "score": 62355.67940094006 }, { "content": "}\n\n\n\n// Generate a random int in the INCLUSIVE range [lower,upper]\n\ninline int randomInt(int lower, int upper) {\n\n std::uniform_int_distribution<int> dist(lower, upper);\n\n return dist(util_mersenne_twister);\n\n}\n\n// Generate a random size_t in the range [0, N)\n\ninline size_t randomIndex(size_t size) {\n\n std::uniform_int_distribution<size_t> dist(0, size-1);\n\n return dist(util_mersenne_twister);\n\n}\n\n\n\ninline double randomNormal(double mean=0.0, double stddev=1.0) {\n\n std::normal_distribution<double> dist{mean, stddev};\n\n return dist(util_mersenne_twister);\n\n}\n\n\n\n// === Printing things to strings ===\n\ntemplate <typename T>\n", "file_path": "include/geometrycentral/utilities.h", "rank": 33, "score": 62355.67940094006 }, { "content": "\n\n const double& re(void) const;\n\n // returns const reference to double part\n\n\n\n Vector3& im(void);\n\n // returns reference to imaginary part\n\n\n\n const Vector3& im(void) const;\n\n // returns const reference to imaginary part\n\n\n\n Quaternion operator+(const Quaternion& q) const;\n\n // addition\n\n\n\n Quaternion operator-(const Quaternion& q) const;\n\n // subtraction\n\n\n\n Quaternion operator-(void) const;\n\n // negation\n\n\n\n Quaternion operator*(double c) const;\n", "file_path": "include/geometrycentral/quaternion.h", "rank": 34, "score": 62355.67940094006 }, { "content": " Vector3 boundaryNormal(VertexPtr v); // length-weighted normal vector to the\n\n // two neighboring edges\n\n Vector3 projectToTangentSpace(VertexPtr v, const Vector3& inVec);\n\n Complex tangentVectorToComplexAngle(VertexPtr v, const Vector3& inVec);\n\n Vector3 complexAngleToTangentVector(VertexPtr v, Complex inAngle);\n\n Complex principalDirection(VertexPtr v); // the 2-symmetric complex vector aligned with k1\n\n\n\n HalfedgeData<Vector2> paramCoords;\n\n VertexData<Vector2> uvCoords;\n\n \n\n // Edge attributes\n\n // --- Primal ---\n\n T midpoint(EdgePtr e);\n\n double length(EdgePtr e);\n\n double cotanWeight(EdgePtr e); // **triangles only**\n\n double dihedralAngle(EdgePtr e);\n\n\n\n // Face attributes\n\n // --- Primal ---\n\n double area(FacePtr f);\n", "file_path": "include/geometrycentral/geometry.h", "rank": 35, "score": 62355.67940094006 }, { "content": "#include <geometrycentral/direction_fields.h>\n\n\n\n#include \"geometrycentral/linear_solvers.h\"\n\n\n\n#include <Eigen/Core>\n\n#include <Eigen/Dense>\n\n#include <Eigen/Sparse>\n\n#include <Eigen/SparseLU>\n\n#include <Eigen/SparseQR>\n\n\n\nusing std::cout;\n\nusing std::endl;\n\n\n\nnamespace geometrycentral {\n\n\n\n// Anonymous namespace for helper functions\n\nnamespace {\n\n\n\nVertexData<Complex> computeSmoothestVertexDirectionField_noBoundary(Geometry<Euclidean>* geometry, int nSym,\n\n bool alignCurvature) {\n", "file_path": "src/direction_fields.cpp", "rank": 36, "score": 60546.62031425115 }, { "content": " }\n\n\n\n if (hasBoundary) {\n\n std::cout << \"Mesh has boundary, computing dirichlet boundary condition solution\" << std::endl;\n\n return computeSmoothestVertexDirectionField_boundary(geometry, nSym, alignCurvature);\n\n } else {\n\n std::cout << \"Mesh has no boundary, computing unit-norm solution\" << std::endl;\n\n return computeSmoothestVertexDirectionField_noBoundary(geometry, nSym, alignCurvature);\n\n }\n\n}\n\n\n\n// Helpers for computing face-based direction fields\n\nnamespace {\n\n\n\nFaceData<Complex> computeSmoothestFaceDirectionField_noBoundary(Geometry<Euclidean>* geometry, int nSym,\n\n bool alignCurvature) {\n\n\n\n HalfedgeMesh* mesh = geometry->getMesh();\n\n unsigned int N = mesh->nFaces();\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 38, "score": 60539.165006375166 }, { "content": " if (hasBoundary) {\n\n std::cout << \"Mesh has boundary, computing dirichlet boundary condition solution\" << std::endl;\n\n return computeSmoothestFaceDirectionField_boundary(geometry, nSym, alignCurvature);\n\n } else {\n\n std::cout << \"Mesh has no boundary, computing unit-norm solution\" << std::endl;\n\n return computeSmoothestFaceDirectionField_noBoundary(geometry, nSym, alignCurvature);\n\n }\n\n}\n\n\n\n\n\nFaceData<int> computeFaceIndex(Geometry<Euclidean>* geometry, VertexData<Complex> directionField, int nSym) {\n\n HalfedgeMesh* mesh = geometry->getMesh();\n\n\n\n GeometryCache<Euclidean>& gc = geometry->cache;\n\n gc.requireFaceTransportCoefs();\n\n\n\n // Store the result here\n\n FaceData<int> indices(mesh);\n\n\n\n // TODO haven't tested that this correctly reports the index when it is larger\n", "file_path": "src/direction_fields.cpp", "rank": 39, "score": 60538.92000698659 }, { "content": " // than +-1\n\n\n\n for (VertexPtr v : mesh->vertices()) {\n\n\n\n // Trace the direction field around the face and see how many times it\n\n // spins!\n\n double totalRot = 0;\n\n\n\n for (HalfedgePtr he : v.incomingHalfedges()) {\n\n // Compute the rotation along the halfedge implied by the field\n\n Complex x0 = directionField[he.face()];\n\n Complex x1 = directionField[he.twin().face()];\n\n Complex transport = std::pow(gc.faceTransportCoefs[he], nSym);\n\n\n\n // Find the difference in angle\n\n double theta0 = std::arg(transport * x0);\n\n double theta1 = std::arg(x1);\n\n double deltaTheta = std::arg(x1 / (transport * x0));\n\n\n\n totalRot += deltaTheta;\n", "file_path": "src/direction_fields.cpp", "rank": 40, "score": 60538.37426062342 }, { "content": " // than +-1\n\n\n\n for (FacePtr f : mesh->faces()) {\n\n // Trace the direction field around the face and see how many times it\n\n // spins!\n\n double totalRot = 0;\n\n\n\n for (HalfedgePtr he : f.adjacentHalfedges()) {\n\n // Compute the rotation along the halfedge implied by the field\n\n Complex x0 = directionField[he.vertex()];\n\n Complex x1 = directionField[he.twin().vertex()];\n\n Complex transport = std::pow(gc.vertexTransportCoefs[he], nSym);\n\n\n\n // Find the difference in angle\n\n double theta0 = std::arg(transport * x0);\n\n double theta1 = std::arg(x1);\n\n double deltaTheta = regularizeAngle(theta1 - theta0 + PI) - PI; // regularize to [-PI,PI]\n\n\n\n totalRot += deltaTheta; // accumulate\n\n }\n", "file_path": "src/direction_fields.cpp", "rank": 41, "score": 60538.25594488339 }, { "content": " }\n\n }\n\n\n\n return toReturn;\n\n}\n\n}; // namespace\n\n\n\nVertexData<Complex> computeSmoothestVertexDirectionField(Geometry<Euclidean>* geometry, int nSym, bool alignCurvature) {\n\n std::cout << \"Computing globally optimal direction field\" << std::endl;\n\n\n\n if (alignCurvature && !(nSym == 2 || nSym == 4)) {\n\n throw std::logic_error(\"ERROR: It only makes sense to align with curvature when nSym = 2 or \"\n\n \"4\");\n\n }\n\n\n\n // Dispatch to either the boundary of no boundary variant depending on the\n\n // mesh type\n\n bool hasBoundary = false;\n\n for (VertexPtr v : geometry->getMesh()->vertices()) {\n\n hasBoundary |= v.isBoundary();\n", "file_path": "src/direction_fields.cpp", "rank": 44, "score": 60537.24206593249 }, { "content": "}\n\n\n\n} // namespace\n\n\n\nFaceData<Complex> computeSmoothestFaceDirectionField(Geometry<Euclidean>* geometry, int nSym, bool alignCurvature) {\n\n\n\n std::cout << \"Computing globally optimal direction field in faces\" << std::endl;\n\n\n\n if (alignCurvature && !(nSym == 2 || nSym == 4)) {\n\n throw std::logic_error(\"ERROR: It only makes sense to align with curvature when nSym = 2 or \"\n\n \"4\");\n\n }\n\n\n\n // Dispatch to either the boundary of no boundary variant depending on the mesh type\n\n bool hasBoundary = false;\n\n for (VertexPtr v : geometry->getMesh()->vertices()) {\n\n hasBoundary |= v.isBoundary();\n\n }\n\n\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 45, "score": 60537.24206593249 }, { "content": " solution = smallestEigenvectorPositiveDefinite(energyMatrix, massMatrix);\n\n }\n\n\n\n\n\n // Copy the result to a FaceData object\n\n FaceData<Complex> field(mesh);\n\n for (FacePtr f : mesh->faces()) {\n\n field[f] = solution[gc.faceIndices[f]] / std::abs(solution[gc.faceIndices[f]]);\n\n }\n\n\n\n return field;\n\n}\n\n\n\nFaceData<Complex> computeSmoothestFaceDirectionField_boundary(Geometry<Euclidean>* geometry, int nSym,\n\n bool alignCurvature) {\n\n\n\n HalfedgeMesh* mesh = geometry->getMesh();\n\n\n\n GeometryCache<Euclidean>& gc = geometry->cache;\n\n gc.requireFaceTransportCoefs();\n", "file_path": "src/direction_fields.cpp", "rank": 46, "score": 60536.90998813782 }, { "content": "\n\n // Compute the net rotation and corresponding index\n\n int index = static_cast<int>(std::round(totalRot / (2 * PI))); // should be very close to a multiple of 2PI\n\n indices[f] = index;\n\n }\n\n\n\n return indices;\n\n}\n\n\n\n\n\nVertexData<int> computeVertexIndex(Geometry<Euclidean>* geometry, FaceData<Complex> directionField, int nSym) {\n\n\n\n HalfedgeMesh* mesh = geometry->getMesh();\n\n GeometryCache<Euclidean>& gc = geometry->cache;\n\n gc.requireFaceTransportCoefs();\n\n\n\n // Store the result here\n\n VertexData<int> indices(mesh);\n\n\n\n // TODO haven't tested that this correctly reports the index when it is larger\n", "file_path": "src/direction_fields.cpp", "rank": 47, "score": 60536.90998813782 }, { "content": " gc.requirePrincipalDirections();\n\n\n\n Eigen::VectorXcd dirVec(N);\n\n if (nSym == 2) {\n\n for (VertexPtr v : mesh->vertices()) {\n\n dirVec[gc.vertexIndices[v]] = gc.principalDirections[v];\n\n }\n\n } else if (nSym == 4) {\n\n for (VertexPtr v : mesh->vertices()) {\n\n dirVec[gc.vertexIndices[v]] = std::pow(gc.principalDirections[v], 2);\n\n }\n\n }\n\n\n\n // Normalize the alignment field\n\n double scale = std::sqrt(std::abs((dirVec.adjoint() * massMatrix * dirVec)[0]));\n\n dirVec /= scale;\n\n\n\n double lambdaT = 0.0; // this is something of a magical constant, see\n\n // \"Globally Optimal Direction Fields\", eqn 16\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 49, "score": 60536.88466657975 }, { "content": " Eigen::VectorXcd dirVec(nInterior);\n\n for (VertexPtr v : mesh->vertices()) {\n\n if (v.isBoundary()) {\n\n continue;\n\n }\n\n\n\n Complex directionVal = gc.principalDirections[v];\n\n if (nSym == 4) {\n\n directionVal = std::pow(directionVal, 2);\n\n }\n\n\n\n // Normalize the curvature vectors. By doing so, we lose the property of adjusting the strength of the alignment\n\n // based on the strength of the curvature, but resolve any scaling issues between the magnitude of the normals and\n\n // the magnitude of the desired field. Be careful when interpreting this as opposed to the usual direction field\n\n // optimization.\n\n dirVec[gc.interiorVertexIndices[v]] = directionVal / std::abs(directionVal);\n\n }\n\n\n\n double t = 0.01; // this is something of a magical constant, see \"Globally\n\n // Optimal Direction Fields\", eqn 9\n", "file_path": "src/direction_fields.cpp", "rank": 50, "score": 60536.76286723085 }, { "content": " sum /= weightSum;\n\n\n\n dirVec[gc.faceIndices[f]] = sum;\n\n }\n\n\n\n // Normalize the alignment field\n\n double scale = std::sqrt(std::abs((dirVec.adjoint() * massMatrix * dirVec)[0]));\n\n dirVec /= scale;\n\n\n\n double lambdaT = 0.0; // this is something of a magical constant, see \"Globally Optimal Direction Fields\", eqn 16\n\n\n\n // Eigen::VectorXcd RHS = massMatrix * dirVec;\n\n Eigen::VectorXcd RHS = dirVec;\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> LHS = energyMatrix - lambdaT * massMatrix;\n\n solution = solveSquare(LHS, RHS);\n\n\n\n }\n\n // Otherwise find the smallest eigenvector\n\n else {\n\n std::cout << \"Solving smoothest field eigenvalue problem...\" << std::endl;\n", "file_path": "src/direction_fields.cpp", "rank": 52, "score": 60536.479527010204 }, { "content": "\n\n // Normalize the curvature vectors. By doing so, we lose the property of adjusting the strength of the alignment\n\n // based on the strength of the curvature, but resolve any scaling issues between the magnitude of the normals\n\n // and the magnitude of the desired field. Be careful when interpreting this as opposed to the usual direction\n\n // field optimization.\n\n dirVec[interiorFaceInd[f]] = unit(sum);\n\n }\n\n }\n\n\n\n\n\n double t = 0.1; // this is something of a magical constant, see \"Globally\n\n // Optimal Direction Fields\", eqn 9\n\n // NOTE: This value is different from the one used for vertex fields; seems to work better?\n\n\n\n std::cout << \"Solving smoothest field dirichlet problem with curvature term...\" << std::endl;\n\n Eigen::VectorXcd RHS = massMatrix * (t * dirVec + b);\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> LHS = energyMatrix;\n\n solution = solveSquare(LHS, RHS);\n\n\n\n }\n", "file_path": "src/direction_fields.cpp", "rank": 53, "score": 60536.4397161518 }, { "content": "VertexData<Complex> computeSmoothestVertexDirectionField_boundary(Geometry<Euclidean>* geometry, int nSym,\n\n bool alignCurvature) {\n\n HalfedgeMesh* mesh = geometry->getMesh();\n\n size_t nInterior = mesh->nInteriorVertices();\n\n\n\n GeometryCache<Euclidean>& gc = geometry->cache;\n\n gc.requireVertexTransportCoefs();\n\n gc.requireEdgeCotanWeights();\n\n gc.requireVertexBases();\n\n gc.requireInteriorVertexIndices();\n\n gc.requireVertexDualAreas();\n\n\n\n // Compute the boundary values\n\n VertexData<std::complex<double>> boundaryValues(mesh);\n\n for (VertexPtr v : mesh->vertices()) {\n\n if (v.isBoundary()) {\n\n Vector3 b = geometry->boundaryNormal(v);\n\n Complex bC(dot(gc.vertexBases[v][0], b), dot(gc.vertexBases[v][1], b)); // TODO can do better\n\n bC = unit(bC);\n\n boundaryValues[v] = std::pow(bC, nSym);\n", "file_path": "src/direction_fields.cpp", "rank": 54, "score": 60536.27139604417 }, { "content": "\n\n // Mass matrix\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> massMatrix(N, N);\n\n massMatrix.reserve(1);\n\n\n\n // === Build matrices\n\n\n\n // Build the mass matrix\n\n for (VertexPtr v : mesh->vertices()) {\n\n size_t i = gc.vertexIndices[v];\n\n massMatrix.insert(i, i) = gc.vertexDualAreas[v];\n\n }\n\n\n\n // Build the energy matrix\n\n for (VertexPtr v : mesh->vertices()) {\n\n size_t i = gc.vertexIndices[v];\n\n\n\n std::complex<double> weightISum = 0;\n\n for (HalfedgePtr he : v.incomingHalfedges()) {\n\n size_t j = gc.vertexIndices[he.vertex()];\n", "file_path": "src/direction_fields.cpp", "rank": 55, "score": 60533.036247952215 }, { "content": " GeometryCache<Euclidean>& gc = geometry->cache;\n\n gc.requireFaceTransportCoefs();\n\n gc.requireFaceNormals();\n\n gc.requireFaceAreas();\n\n gc.requireDihedralAngles();\n\n gc.requireFaceIndices();\n\n\n\n // === Allocate matrices\n\n // Energy matrix\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> energyMatrix(N, N);\n\n energyMatrix.reserve(Eigen::VectorXi::Constant(N, 4));\n\n\n\n // Mass matrix\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> massMatrix(N, N);\n\n massMatrix.reserve(Eigen::VectorXi::Constant(N, 1));\n\n\n\n\n\n // === Build matrices\n\n\n\n // Build the mass matrix\n", "file_path": "src/direction_fields.cpp", "rank": 56, "score": 60533.036247952215 }, { "content": " gc.requireFaceNormals();\n\n gc.requireFaceAreas();\n\n gc.requireDihedralAngles();\n\n\n\n\n\n // Index interior faces\n\n size_t nInteriorFace = 0;\n\n FaceData<size_t> interiorFaceInd(mesh, -77);\n\n FaceData<char> isInterior(mesh);\n\n for (FacePtr f : mesh->faces()) {\n\n bool isBoundary = false;\n\n for (EdgePtr e : f.adjacentEdges()) {\n\n isBoundary |= e.isBoundary();\n\n }\n\n isInterior[f] = !isBoundary;\n\n if (!isBoundary) {\n\n interiorFaceInd[f] = nInteriorFace++;\n\n }\n\n }\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 59, "score": 60533.036247952215 }, { "content": " // Compute boundary values\n\n FaceData<Complex> boundaryValues(mesh);\n\n for (FacePtr f : mesh->faces()) {\n\n if (isInterior[f]) {\n\n boundaryValues[f] = 0;\n\n } else {\n\n Vector3 bVec = Vector3::zero();\n\n for (HalfedgePtr he : f.adjacentHalfedges()) {\n\n if (he.edge().isBoundary()) {\n\n bVec += geometry->vector(he).rotate_around(gc.faceNormals[f], -PI / 2.0);\n\n }\n\n }\n\n Complex bC(dot(gc.faceBases[f][0], bVec), dot(gc.faceBases[f][1], bVec));\n\n bC = unit(bC);\n\n boundaryValues[f] = std::pow(bC, nSym);\n\n }\n\n }\n\n\n\n\n\n // === Allocate matrices\n", "file_path": "src/direction_fields.cpp", "rank": 60, "score": 60533.036247952215 }, { "content": " } else {\n\n boundaryValues[v] = 0;\n\n }\n\n }\n\n\n\n VertexData<size_t> vertInd = mesh->getInteriorVertexIndices();\n\n\n\n // Energy matrix\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> energyMatrix(nInterior, nInterior);\n\n\n\n Eigen::VectorXi nEntries(nInterior);\n\n for (VertexPtr v : mesh->vertices()) {\n\n if (v.isBoundary()) {\n\n continue;\n\n }\n\n nEntries[gc.interiorVertexIndices[v]] = v.degree() + 1;\n\n }\n\n energyMatrix.reserve(nEntries);\n\n\n\n // Mass matrix\n", "file_path": "src/direction_fields.cpp", "rank": 61, "score": 60533.036247952215 }, { "content": "\n\n energyMatrix.insert(i, i) = weightISum;\n\n }\n\n\n\n // Shift to avoid singularities\n\n Eigen::SparseMatrix<Complex> eye(nInterior, nInterior);\n\n eye.setIdentity();\n\n energyMatrix += 1e-4 * eye;\n\n\n\n // Compute the actual solution\n\n std::cout << \"Solving linear problem...\" << std::endl;\n\n\n\n // Store the solution here\n\n Eigen::VectorXcd solution;\n\n\n\n // If requested, align to principal curvatures\n\n if (alignCurvature) {\n\n\n\n gc.requirePrincipalDirections();\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 62, "score": 60533.036247952215 }, { "content": " // Energy matrix\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> energyMatrix(nInteriorFace, nInteriorFace);\n\n energyMatrix.reserve(Eigen::VectorXi::Constant(nInteriorFace, 4));\n\n\n\n // Mass matrix\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> massMatrix(nInteriorFace, nInteriorFace);\n\n massMatrix.reserve(Eigen::VectorXi::Constant(nInteriorFace, 1));\n\n\n\n // RHS\n\n Eigen::VectorXcd b(nInteriorFace);\n\n\n\n // === Build matrices\n\n\n\n // Build the mass matrix\n\n for (FacePtr f : mesh->faces()) {\n\n if (isInterior[f]) {\n\n size_t i = interiorFaceInd[f];\n\n massMatrix.insert(i, i) = gc.faceAreas[f];\n\n }\n\n }\n", "file_path": "src/direction_fields.cpp", "rank": 63, "score": 60533.036247952215 }, { "content": "\n\n // Build the energy matrix\n\n for (FacePtr f : mesh->faces()) {\n\n if (isInterior[f]) {\n\n size_t i = interiorFaceInd[f];\n\n\n\n std::complex<double> weightISum = 0;\n\n for (HalfedgePtr he : f.adjacentHalfedges()) {\n\n\n\n FacePtr neighFace = he.twin().face();\n\n double weight = 1; // FIXME TODO figure out weights\n\n Complex rBar = std::pow(gc.faceTransportCoefs[he.twin()], nSym);\n\n\n\n if (isInterior[neighFace]) {\n\n size_t j = interiorFaceInd[neighFace];\n\n energyMatrix.insert(i, j) = -weight * rBar;\n\n } else {\n\n std::complex<double> bVal = boundaryValues[neighFace];\n\n b(i) += weight * rBar * bVal;\n\n }\n", "file_path": "src/direction_fields.cpp", "rank": 64, "score": 60533.036247952215 }, { "content": " Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> massMatrix(nInterior, nInterior);\n\n massMatrix.reserve(1);\n\n\n\n // RHS\n\n Eigen::VectorXcd b(nInterior);\n\n\n\n // === Build matrices\n\n\n\n // Build the mass matrix and zero b\n\n for (VertexPtr v : mesh->vertices()) {\n\n if (v.isBoundary()) {\n\n continue;\n\n }\n\n size_t i = gc.interiorVertexIndices[v];\n\n b(i) = 0.0;\n\n massMatrix.insert(i, i) = gc.vertexDualAreas[v];\n\n }\n\n\n\n // Build the energy matrix\n\n for (VertexPtr v : mesh->vertices()) {\n", "file_path": "src/direction_fields.cpp", "rank": 65, "score": 60533.036247952215 }, { "content": " if (v.isBoundary()) {\n\n continue;\n\n }\n\n size_t i = gc.interiorVertexIndices[v];\n\n\n\n std::complex<double> weightISum = 0;\n\n for (HalfedgePtr he : v.incomingHalfedges()) {\n\n std::complex<double> rBar = std::pow(gc.vertexTransportCoefs[he], nSym);\n\n double w = gc.edgeCotanWeights[he.edge()];\n\n\n\n // Interior-boundary term\n\n if (he.vertex().isBoundary()) {\n\n std::complex<double> bVal = boundaryValues[he.vertex()];\n\n b(i) += w * rBar * bVal;\n\n } else { // Interior-interior term\n\n size_t j = gc.interiorVertexIndices[he.vertex()];\n\n energyMatrix.insert(i, j) = -w * rBar;\n\n }\n\n weightISum += w;\n\n }\n", "file_path": "src/direction_fields.cpp", "rank": 66, "score": 60533.036247952215 }, { "content": "\n\n Eigen::VectorXcd dirVec(N);\n\n for (FacePtr f : mesh->faces()) {\n\n\n\n // Compute something like the principal directions\n\n double weightSum = 0;\n\n Complex sum = 0;\n\n\n\n for (HalfedgePtr he : f.adjacentHalfedges()) {\n\n\n\n double dihedralAngle = std::abs(gc.dihedralAngles[he.edge()]);\n\n double weight = norm(geometry->vector(he));\n\n weightSum += weight;\n\n double angleCoord = angleInPlane(geometry->vector(f.halfedge()), geometry->vector(he), gc.faceNormals[f]);\n\n Complex coord = std::exp(angleCoord * IM_I *\n\n (double)nSym); // nsym should be 2 or 4, checked in the funciton which calls this\n\n\n\n sum += coord * weight * dihedralAngle;\n\n }\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 67, "score": 60533.036247952215 }, { "content": " HalfedgeMesh* mesh = geometry->getMesh();\n\n size_t N = mesh->nVertices();\n\n\n\n GeometryCache<Euclidean>& gc = geometry->cache;\n\n gc.requireVertexTransportCoefs();\n\n gc.requireEdgeCotanWeights();\n\n gc.requireVertexIndices();\n\n gc.requireVertexDualAreas();\n\n\n\n // Energy matrix\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> energyMatrix(\n\n N, N); // have to use ColMajor because LU solver below demands it\n\n\n\n // Supposedly reserving space in the matrix makes construction real zippy\n\n // below\n\n Eigen::VectorXi nEntries(N);\n\n for (VertexPtr v : mesh->vertices()) {\n\n nEntries[gc.vertexIndices[v]] = v.degree() + 1;\n\n }\n\n energyMatrix.reserve(nEntries);\n", "file_path": "src/direction_fields.cpp", "rank": 68, "score": 60533.036247952215 }, { "content": " for (FacePtr f : mesh->faces()) {\n\n size_t i = gc.faceIndices[f];\n\n massMatrix.insert(i, i) = gc.faceAreas[f];\n\n }\n\n\n\n // Build the energy matrix\n\n for (FacePtr f : mesh->faces()) {\n\n size_t i = gc.faceIndices[f];\n\n\n\n std::complex<double> weightISum = 0;\n\n for (HalfedgePtr he : f.adjacentHalfedges()) {\n\n\n\n if (!he.twin().isReal()) {\n\n continue;\n\n }\n\n\n\n FacePtr neighFace = he.twin().face();\n\n unsigned int j = gc.faceIndices[neighFace];\n\n\n\n // LC connection between the faces\n", "file_path": "src/direction_fields.cpp", "rank": 69, "score": 60533.036247952215 }, { "content": " // Otherwise find the general closest solution\n\n else {\n\n std::cout << \"Solving smoothest field dirichlet problem...\" << std::endl;\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> LHS = energyMatrix;\n\n Eigen::VectorXcd RHS = massMatrix * b;\n\n solution = solveSquare(LHS, RHS);\n\n }\n\n\n\n\n\n // Copy the result to a FaceData object\n\n FaceData<Complex> field(mesh);\n\n for (FacePtr f : mesh->faces()) {\n\n if (isInterior[f]) {\n\n field[f] = unit(solution[interiorFaceInd[f]]);\n\n } else {\n\n field[f] = unit(boundaryValues[f]);\n\n }\n\n }\n\n\n\n return field;\n", "file_path": "src/direction_fields.cpp", "rank": 70, "score": 60533.036247952215 }, { "content": " std::complex<double> rBar = std::pow(gc.vertexTransportCoefs[he], nSym);\n\n double weight = gc.edgeCotanWeights[he.edge()];\n\n energyMatrix.insert(i, j) = -weight * rBar;\n\n weightISum += weight;\n\n }\n\n\n\n energyMatrix.insert(i, i) = weightISum;\n\n }\n\n\n\n // Shift to avoid singularity\n\n Eigen::SparseMatrix<Complex> eye(N, N);\n\n eye.setIdentity();\n\n energyMatrix += 1e-4 * eye;\n\n\n\n // Store the solution here\n\n Eigen::VectorXcd solution;\n\n\n\n // If requested, align to principal curvatures\n\n if (alignCurvature) {\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 71, "score": 60533.036247952215 }, { "content": " Complex rBar = std::pow(gc.faceTransportCoefs[he.twin()], nSym);\n\n\n\n double weight = 1; // FIXME TODO figure out weights\n\n energyMatrix.insert(i, j) = -weight * rBar;\n\n weightISum += weight;\n\n }\n\n\n\n energyMatrix.insert(i, i) = weightISum;\n\n }\n\n\n\n // Shift to avoid singularity\n\n Eigen::SparseMatrix<Complex> eye(N, N);\n\n eye.setIdentity();\n\n energyMatrix += 1e-4 * eye;\n\n\n\n // Store the solution here\n\n Eigen::VectorXcd solution;\n\n\n\n // If requested, align to principal curvatures\n\n if (alignCurvature) {\n", "file_path": "src/direction_fields.cpp", "rank": 72, "score": 60533.036247952215 }, { "content": "\n\n weightISum += weight;\n\n }\n\n\n\n energyMatrix.insert(i, i) = weightISum;\n\n }\n\n }\n\n\n\n // Shift to avoid singularity\n\n Eigen::SparseMatrix<Complex> eye(nInteriorFace, nInteriorFace);\n\n eye.setIdentity();\n\n energyMatrix += 1e-4 * eye;\n\n\n\n // Store the solution here\n\n Eigen::VectorXcd solution;\n\n\n\n // If requested, align to principal curvatures\n\n if (alignCurvature) {\n\n\n\n Eigen::VectorXcd dirVec(nInteriorFace);\n", "file_path": "src/direction_fields.cpp", "rank": 73, "score": 60533.036247952215 }, { "content": "\n\n Eigen::VectorXcd RHS = massMatrix * (t * dirVec + b);\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> LHS = energyMatrix;\n\n solution = solveSquare(LHS, RHS);\n\n }\n\n // Otherwise find the general closest solution\n\n else {\n\n std::cout << \"Solving smoothest field dirichlet problem...\" << std::endl;\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> LHS = energyMatrix;\n\n Eigen::VectorXcd RHS = massMatrix * b;\n\n solution = solveSquare(LHS, RHS);\n\n }\n\n\n\n // Copy the result to a VertexData vector for both the boudary and interior\n\n VertexData<Complex> toReturn(mesh);\n\n for (VertexPtr v : mesh->vertices()) {\n\n if (v.isBoundary()) {\n\n toReturn[v] = boundaryValues[v];\n\n } else {\n\n toReturn[v] = unit(solution[gc.interiorVertexIndices[v]]);\n", "file_path": "src/direction_fields.cpp", "rank": 75, "score": 60533.036247952215 }, { "content": " // Eigen::VectorXcd RHS = massMatrix * dirVec;\n\n Eigen::VectorXcd RHS = dirVec;\n\n Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> LHS = energyMatrix - lambdaT * massMatrix;\n\n solution = solveSquare(LHS, RHS);\n\n }\n\n // Otherwise find the smallest eigenvector\n\n else {\n\n std::cout << \"Solving smoothest field eigenvalue problem...\" << std::endl;\n\n solution = smallestEigenvectorPositiveDefinite(energyMatrix, massMatrix);\n\n }\n\n\n\n // Copy the result to a VertexData vector\n\n VertexData<Complex> toReturn(mesh);\n\n for (VertexPtr v : mesh->vertices()) {\n\n toReturn[v] = solution[gc.vertexIndices[v]] / std::abs(solution[gc.vertexIndices[v]]);\n\n }\n\n\n\n return toReturn;\n\n}\n\n\n", "file_path": "src/direction_fields.cpp", "rank": 76, "score": 60533.036247952215 }, { "content": " }\n\n\n\n double angleDefect = geometry->angleDefect(v);\n\n totalRot += angleDefect * nSym;\n\n\n\n // Compute the net rotation and corresponding index\n\n int index = static_cast<int>(std::round(totalRot / (2 * PI))); // should be very close to a multiple of 2PI\n\n indices[v] = index;\n\n }\n\n\n\n return indices;\n\n}\n\n\n\n} // namespace geometrycentral\n", "file_path": "src/direction_fields.cpp", "rank": 77, "score": 60533.036247952215 }, { "content": " for (FacePtr f : mesh->faces()) {\n\n if (isInterior[f]) {\n\n\n\n // Compute something like the principal directions\n\n double weightSum = 0;\n\n Complex sum = 0;\n\n\n\n for (HalfedgePtr he : f.adjacentHalfedges()) {\n\n\n\n double dihedralAngle = std::abs(gc.dihedralAngles[he.edge()]);\n\n double weight = norm(geometry->vector(he));\n\n weightSum += weight;\n\n double angleCoord = angleInPlane(geometry->vector(f.halfedge()), geometry->vector(he), gc.faceNormals[f]);\n\n Complex coord = std::exp(angleCoord * IM_I *\n\n (double)nSym); // nsym should be 2 or 4, checked in the funciton which calls this\n\n\n\n sum += coord * weight * dihedralAngle;\n\n }\n\n\n\n sum /= weightSum;\n", "file_path": "src/direction_fields.cpp", "rank": 79, "score": 60533.036247952215 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/unit_vector3.h\"\n\n#include \"geometrycentral/vector2.h\"\n\n#include \"geometrycentral/vector3.h\"\n\n\n\n#include <functional>\n\n#include <vector>\n\n\n\n#include <Eigen/SparseCore>\n\n\n\nnamespace geometrycentral {\n\n\n\n// Helper class which manages a dependency graph of quantities\n", "file_path": "include/geometrycentral/geometry_cache.h", "rank": 80, "score": 60312.69133602186 }, { "content": "#pragma once\n\n\n\n#include <algorithm>\n\n#include <cmath>\n\n\n\n#include <geometrycentral/utilities.h>\n\n#include \"geometrycentral/vector3.h\"\n\n\n\nnamespace geometrycentral {\n\n\n", "file_path": "include/geometrycentral/unit_vector3.h", "rank": 81, "score": 60312.574747785446 }, { "content": "#pragma once\n\n\n\n\n\n#include \"geometrycentral/geometry.h\"\n\n\n\n#include <fstream>\n\n#include <iostream>\n\n#include <string>\n\n\n\n#include \"happly.h\"\n\n\n\n// === Reader and writing classes supporting direct interop between the GeometryCentral mesh types and the .ply file\n\n// === format.\n\n\n\nnamespace geometrycentral {\n\n\n", "file_path": "include/geometrycentral/ply_wrapper.h", "rank": 82, "score": 60312.46787205906 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/linear_algebra_utilities.h\"\n\n\n\n#include \"Eigen/Sparse\"\n\n\n\n#include <iostream>\n\n\n\n// Suitesparse includes, as needed\n\n#ifdef HAVE_SUITESPARSE\n\n#include \"geometrycentral/suitesparse_utilities.h\"\n\n#include <SuiteSparseQR.hpp>\n\n#include <cholmod.h>\n\n#endif\n\n\n\n\n\n// This disables various safety chceks in linear algebra code and solvers\n\n #define GC_NLINALG_DEBUG\n\n\n\n// Note: actual solvers implemented with explicit template instantiation in solvers.cpp\n", "file_path": "include/geometrycentral/linear_solvers.h", "rank": 83, "score": 60312.409219413516 }, { "content": "\n\n#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include <map>\n\n#include <queue>\n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/BHalfedgemesh.h", "rank": 84, "score": 60312.32183255546 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n#include <fstream> \n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/spectral_conformal.h", "rank": 85, "score": 60312.28746191873 }, { "content": "#pragma once\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n#include \"geometrycentral/geometry.h\"\n\n#include \"geometrycentral/polygon_soup_mesh.h\"\n\n\n\nusing namespace geometrycentral;\n\n\n", "file_path": "include/geometrycentral/quad_cover.h", "rank": 86, "score": 60312.18614963737 }, { "content": "#pragma once\n\n\n\n#include <vector>\n\n\n\n#include \"geometrycentral/vector3.h\"\n\n#include <geometrycentral/utilities.h>\n\n// NOTE: More includes at bottom of file\n\n\n\nnamespace geometrycentral {\n\n\n\n// A HalfedgeMesh encodes the connectivity---but not the geometry---of a\n\n// manifold surface, possibly with boundary.\n\n\n\n// Forward declare classes for primary mesh objects\n", "file_path": "include/geometrycentral/halfedge_mesh.h", "rank": 87, "score": 60312.15610942905 }, { "content": "#pragma once\n\n\n\n#include \"Eigen/Sparse\"\n\n\n\n// Suitesparse includes, as needed\n\n#ifdef HAVE_SUITESPARSE\n\n#include <cholmod.h>\n\n#else\n\n#error \"USING SUITESPARSE FEATURES, BUT DON'T HAVE SUITESPARSE\"\n\n#endif\n\n\n\nnamespace geometrycentral {\n\n\n\n\n", "file_path": "include/geometrycentral/suitesparse_utilities.h", "rank": 88, "score": 60312.055121667545 }, { "content": "#pragma once\n\n\n\n#include <cstddef>\n\n#include <vector>\n\n\n\nnamespace geometrycentral {\n\n\n", "file_path": "include/geometrycentral/disjoint_sets.h", "rank": 89, "score": 60312.049002516964 }, { "content": "#pragma once\n\n\n\n#include <iterator>\n\n\n\n#include \"geometrycentral/halfedge_mesh.h\"\n\n\n\nnamespace geometrycentral {\n\n\n\n// TODO add const interators across the board\n\n\n\n// NOTE: These iterators are not STL compliant (so you can use them with\n\n// <algorithm> and friends.\n\n// This is mainly becuase the STL notion of iterators seems to strongly imply\n\n// each \"container\"\n\n// has exactly one set of data to be iterated over. Obviously we break this\n\n// here, we don't even\n\n// have containers.\n\n\n\n// The ugly inlining throughout these iterators was chosen after some\n\n// halfhearted performance\n", "file_path": "include/geometrycentral/halfedge_iterators.h", "rank": 90, "score": 60310.51486661015 }, { "content": " EdgeData<size_t> edgeIndices;\n\n\n\n inline void requireHalfedgeIndices() { halfedgeIndicesQ.require(); }\n\n HalfedgeData<size_t> halfedgeIndices;\n\n\n\n\n\n // == Operators\n\n // Note: These don't quite follow the usual naming scheme, for the sake of grouping common operators\n\n // TODO factorizations?\n\n\n\n // All of the basic DEC operators\n\n inline void requireBasicDECOperators() { basicDECOperatorsQ.require(); }\n\n Eigen::SparseMatrix<double> d0, d1, hodge0, hodge1, hodge2;\n\n\n\n // Includes inverses\n\n inline void requireModifiedDECOperators() { modifiedDECOperatorsQ.require(); }\n\n Eigen::SparseMatrix<double> hodge0Inv, hodge1Inv, hodge2Inv;\n\n\n\n // Cotan-laplace operator\n\n // Remember, this DOES NOT include the mass matrix (hodge0)\n\n inline void requireZeroFormWeakLaplacian() { zeroFormWeakLaplacianQ.require(); }\n\n Eigen::SparseMatrix<double> zeroFormWeakLaplacian;\n\n};\n\n\n\n}; // namespace geometrycentral\n", "file_path": "include/geometrycentral/geometry_cache.h", "rank": 91, "score": 60309.07858074544 }, { "content": " // Note: the ordering in which the quantities are listed is used to implicitly encode the DAG amongst the\n\n // dependencies... a quantity may only depend on those which appear above it!\n\n\n\n // (note, more public members below)\n\nprivate:\n\n // The mesh for which this cache applies\n\n HalfedgeMesh* mesh;\n\n Geometry<G>* geometry;\n\n\n\n std::vector<DependentQuantity*> allQuantities;\n\n\n\n // === Internal interface for all quantities\n\n\n\n // == Basic geometric quantities\n\n\n\n DependentQuantity faceAreaNormalsQ;\n\n void computeFaceAreaNormals();\n\n\n\n DependentQuantity faceAreasQ;\n\n void computeFaceAreas();\n", "file_path": "include/geometrycentral/geometry_cache.h", "rank": 92, "score": 60308.76996786793 }, { "content": " FaceData<int> singularities;\n\n HalfedgeData<int> branchCover;\n\n\n\n // helpers\n\n void setup();\n\n Eigen::SparseMatrix<std::complex<double>> assembleM();\n\n Eigen::SparseMatrix<std::complex<double>> assembleA();\n\n void computeSmoothestField(Eigen::SparseMatrix<std::complex<double>> M, Eigen::SparseMatrix<std::complex<double>> A);\n\n\n\n // visualization\n\n Eigen::SparseMatrix<std::complex<double>> buildLaplacian();\n\n void emitTriangles(VertexData<double> offset);\n\n};", "file_path": "include/geometrycentral/quad_cover.h", "rank": 93, "score": 60308.63669077146 }, { "content": " do {\n\n BFaces.push_back(BHe_curr.face());\n\n BHe_curr = BHe_curr.next().next().twin();\n\n } while (BHe_curr != BHe_orig);\n\n\n\n return BFaces;\n\n}\n\n\n\ninline bool BVertex::operator==(const BVertex& other) const {\n\n if (BC->singularities[v] == 0 && BC->singularities[other.v] == 0) {\n\n return ((v == other.v) && (sheet == other.sheet));\n\n } else if (BC->singularities[v] != 0 && BC->singularities[other.v] != 0) {\n\n if (sheet != other.sheet) throw std::logic_error(\"sheets of singular vertices do not match\");\n\n return (v == other.v);\n\n } else {\n\n return false;\n\n }\n\n}\n\n\n\ninline bool BVertex::operator!=(const BVertex& other) const {\n", "file_path": "include/geometrycentral/BHalfedgemesh.h", "rank": 94, "score": 60304.54771575106 }, { "content": "inline bool BEdge::operator==(const BEdge& other) const {\n\n return (e == other.e && sheet == other.sheet);\n\n}\n\n\n\ninline bool BEdge::operator!=(const BEdge& other) const {\n\n return !(*this == other);\n\n}\n\n\n\n// BVertex functions\n\ninline BHalfedge BVertex::halfedge() {\n\n if (BC->singularities[v] != 0) return BHalfedge{ v.halfedge(), BC->singularSheet, BC };\n\n return BHalfedge{ v.halfedge(), sheet, BC };\n\n}\n\n\n\ninline std::vector<BFace> BVertex::adjacentBFaces() {\n\n std::vector<BFace> BFaces;\n\n\n\n // TODO: might need to fix this for meshes with boundary\n\n BHalfedge BHe_orig = halfedge();\n\n BHalfedge BHe_curr = BHe_orig;\n", "file_path": "include/geometrycentral/BHalfedgemesh.h", "rank": 95, "score": 60304.54771575106 }, { "content": "inline bool BFace::operator==(const BFace& other) const {\n\n return (f == other.f && sheet == other.sheet);\n\n}\n\n\n\ninline bool BFace::operator!=(const BFace& other) const {\n\n return !(*this == other);\n\n}\n\n\n\ninline bool BFace::operator<(const BFace& other) const {\n\n if (f == other.f) {\n\n return sheet < other.sheet;\n\n }\n\n return (f < other.f);\n\n}\n\n\n\n// BEdge functions\n\ninline BHalfedge BEdge::halfedge() {\n\n return BHalfedge{ e.halfedge(), sheet, BC };\n\n}\n\n\n", "file_path": "include/geometrycentral/BHalfedgemesh.h", "rank": 96, "score": 60304.54771575106 }, { "content": "class ARAP {\n\n public:\n\n ARAP(HalfedgeMesh* m, Geometry<Euclidean>* g);\n\n void computeARAP();\n\n\n\n private:\n\n HalfedgeMesh* mesh;\n\n Geometry<Euclidean>* geom;\n\n VertexData<size_t> vertexIndices;\n\n HalfedgeData<Vector2> isoTriangleParam;\n\n VertexData<Vector2> uvCoords;\n\n\n\n // helpers\n\n void computeIsoTriangleParam();\n\n Eigen::SparseMatrix<std::complex<double>> createLaplaceMatrix();\n\n FaceData<Eigen::Matrix2d> computeLRotations(VertexData<Vector2> const &u);\n\n Eigen::MatrixXcd computebVector(FaceData<Eigen::Matrix2d> const &L);\n\n void writeToFile(std::ofstream &outfile);\n\n void normalize();\n\n};", "file_path": "include/geometrycentral/arap.h", "rank": 97, "score": 60304.54771575106 }, { "content": " return !(*this == other);\n\n}\n\n\n\n// BHalfedge functions\n\ninline BHalfedge BHalfedge::next() {\n\n return BHalfedge{ he.next(), sheet, BC };\n\n}\n\n\n\ninline BHalfedge BHalfedge::twin() {\n\n if (!he.isReal() && BC->eta[he] != 0) {\n\n throw std::logic_error(\"Boundary halfedge eta is non-zero\");\n\n }\n\n return BHalfedge{ he.twin(), (sheet + BC->eta[he]) % 4, BC };\n\n}\n\n\n\ninline BVertex BHalfedge::vertex() { \n\n /*\n\n if (!he.isReal() && BC->eta[he] != 0) {\n\n throw std::logic_error(\"Boundary halfedge eta is non-zero\");\n\n }\n", "file_path": "include/geometrycentral/BHalfedgemesh.h", "rank": 98, "score": 60304.54771575106 }, { "content": "class Curve {\n\n public:\n\n // Evaluate the curve at time t\n\n virtual T value(double t) const = 0;\n\n T operator()(double t) const;\n\n\n\n // Evaluate the kth derivative of the curve at time t\n\n // (NOTE: may return NaN if curve is not k times differentiable)\n\n virtual T derivative(double t, unsigned int k) const = 0;\n\n T operator()(double t, unsigned int k) const;\n\n\n\n // The curve is defined between [0,length]\n\n virtual double length() const = 0;\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "include/geometrycentral/curve.h", "rank": 99, "score": 60304.54771575106 } ]
C++
Src/Graphics/Camera.cpp
QuaternionMark/COMP371-FinalProject
ac750a5bb4896f4800d8fbc08fac9ef9a002ed44
#include <cmath> #include <stdexcept> #include "Camera.h" #include "../Math/MathUtil.h" Camera::Camera(int w, int h, float fov, float nearZ, float farZ, bool orthographic) { position = Vector3f(0.f, 0.f, 0.f); lookAt = Vector3f(0.f, 0.f, 1.f); upDir = Vector3f(0.f, 1.f, 0.f); viewMatrix = Matrix4x4f::constructViewMat(position, lookAt, upDir); xAngle = 0.f; yAngle = 0.f; yAngleLimit = 1.5f; tilt = 0.f; this->nearPlaneZ = nearZ; this->farPlaneZ = farZ; this->fov = fov; this->width = w; this->height = h; this->orthographicProj = orthographic; this->thirdPerson = false; this->thirdPersonRadius = 20.f; rotation = Matrix4x4f::identity; needsViewUpdate = true; needsProjUpdate = true; } Camera::Camera(int w, int h) : Camera(w, h, MathUtil::degToRad(70.f)) { } void Camera::addShader(Shader* shd) { shaders.push_back(shd); needsViewUpdate = true; needsProjUpdate = true; } Matrix4x4f Camera::getViewMatrix() const { return viewMatrix; } Matrix4x4f Camera::getProjectionMatrix() const { return projectionMatrix; } void Camera::update() { GLuint err = GL_NO_ERROR; err = glGetError(); if (err != GL_NO_ERROR) { throw std::runtime_error("Uncaught exception - Camera::update()."); } if (needsViewUpdate) { if (!thirdPerson) { rotation = Matrix4x4f::rotate(Vector3f(-yAngle, xAngle, tilt)); viewMatrix = Matrix4x4f::constructViewMat(position, rotation.transform(lookAt), rotation.transform(upDir)); } else { float cosXAngle = std::cos(xAngle); float cosYAngle = std::cos(yAngle); float sinXAngle = std::sin(xAngle); float sinYAngle = std::sin(yAngle); Vector3f thirdPersonPosition = position.subtract(Vector3f(thirdPersonRadius * cosYAngle * cosXAngle, thirdPersonRadius * sinYAngle, -thirdPersonRadius * cosYAngle * sinXAngle)); viewMatrix = Matrix4x4f::constructViewMat(thirdPersonPosition, position.subtract(thirdPersonPosition).normalize(), upDir); } for (int i = 0; i < (int)shaders.size(); i++) { shaders[i]->getMat4Uniform("viewMatrix")->setValue(viewMatrix); } needsViewUpdate = false; } if (needsProjUpdate) { if (!orthographicProj) { projectionMatrix = Matrix4x4f::constructPerspectiveMat(fov, getAspectRatio(), nearPlaneZ, farPlaneZ); } else { projectionMatrix = Matrix4x4f::constructOrthographicMat((float)width, (float)height, nearPlaneZ, farPlaneZ); } for (int i = 0; i < (int)shaders.size(); i++) { shaders[i]->getMat4Uniform("projectionMatrix")->setValue(projectionMatrix); } needsProjUpdate = false; } } Vector3f Camera::getPosition() const { return position; } void Camera::setPosition(const Vector3f& pos) { needsViewUpdate = true; position = pos; } void Camera::setTilt(float rad) { needsViewUpdate = !MathUtil::eqFloats(rad, tilt); tilt = rad; } void Camera::addAngle(float x, float y) { if (MathUtil::eqFloats(x, 0.f) && MathUtil::eqFloats(y, 0.f)) { return; } xAngle += x; yAngle -= y; if (yAngle < -yAngleLimit) { yAngle = -yAngleLimit; } else if (yAngle > yAngleLimit) { yAngle = yAngleLimit; } float PI_MUL_2 = MathUtil::PI * 2.f; if (xAngle > PI_MUL_2) { xAngle -= PI_MUL_2; } else if (xAngle < -PI_MUL_2) { xAngle += PI_MUL_2; } needsViewUpdate = true; } void Camera::resetAngle() { xAngle = 0.f; yAngle = 0.f; needsViewUpdate = true; } void Camera::setThirdPersonPerspective(bool bruh) { needsViewUpdate = bruh != thirdPerson; thirdPerson = bruh; } bool Camera::isThirdPerson() const { return thirdPerson; } void Camera::addFov(float deg) { fov += MathUtil::degToRad(deg); fov = MathUtil::clampFloat(fov, 0.1f, 2.9f); needsProjUpdate = true; } void Camera::setXYClippings(int w, int h) { if (width == w && height == h) { return; } this->width = w; this->height = h; needsProjUpdate = true; } void Camera::setZClippings(float nearZ, float farZ) { if (MathUtil::eqFloats(nearPlaneZ, nearZ) && MathUtil::eqFloats(farPlaneZ, farZ)) { return; } nearPlaneZ = nearZ; farPlaneZ = farZ; needsProjUpdate = true; } float Camera::getAspectRatio() const { return (float)width / height; } void Camera::setOrthographicProj(bool bruh) { needsProjUpdate = bruh != orthographicProj; orthographicProj = bruh; }
#include <cmath> #include <stdexcept> #include "Camera.h" #include "../Math/MathUtil.h" Camera::Camera(int w, int h, float fov, float nearZ, float farZ, bool orthographic) { position = Vector3f(0.f, 0.f, 0.f); lookAt = Vector3f(0.f, 0.f, 1.f); upDir = Vector3f(0.f, 1.f, 0.f); viewMatrix = Matrix4x4f::constructViewMat(position, lookAt, upDir); xAngle = 0.f; yAngle = 0.f; yAngleLimit = 1.5f; tilt = 0.f; this->nearPlaneZ = nearZ; this->farPlaneZ = farZ; this->fov = fov; this->width = w; this->height = h; this->orthographicProj = orthographic; this->thirdPerson = false; this->thirdPersonRadius = 20.f; rotation = Matrix4x4f::identity; needsViewUpdate = true; needsProjUpdate = true; } Camera::Camera(int w, int h) : Camera(w, h, MathUtil::degToRad(70.f)) { } void Camera::addShader(Shader* shd) { shaders.push_back(shd); needsViewUpdate = true; needsProjUpdate = true; } Matrix4x4f Camera::getViewMatrix() const { return viewMatrix; } Matrix4x4f Camera::getProjectionMatrix() const { return projectionMatrix; } void Camera::update() { GLuint err = GL_NO_ERROR; err = glGetError(); if (err != GL_NO_ERROR) { throw std::runtime_error("Uncaught exception - Camera::update()."); } if (needsViewUpdate) { if (!thirdPerson) { rotation = Matrix4x4f::rotate(Vector3f(-yAngle, xAngle, tilt)); viewMatrix = Matrix4x4f::constructViewMat(position, rotation.transform(lookAt), rotation.transform(upDir)); } else { float cosXAngle = std::cos(xAngle); float cosYAngle = std::cos(yAngle); float sinXAngle = std::sin(xAngle); float sinYAngle = std::sin(yAngle); Vector3f thirdPersonPosition =
; viewMatrix = Matrix4x4f::constructViewMat(thirdPersonPosition, position.subtract(thirdPersonPosition).normalize(), upDir); } for (int i = 0; i < (int)shaders.size(); i++) { shaders[i]->getMat4Uniform("viewMatrix")->setValue(viewMatrix); } needsViewUpdate = false; } if (needsProjUpdate) { if (!orthographicProj) { projectionMatrix = Matrix4x4f::constructPerspectiveMat(fov, getAspectRatio(), nearPlaneZ, farPlaneZ); } else { projectionMatrix = Matrix4x4f::constructOrthographicMat((float)width, (float)height, nearPlaneZ, farPlaneZ); } for (int i = 0; i < (int)shaders.size(); i++) { shaders[i]->getMat4Uniform("projectionMatrix")->setValue(projectionMatrix); } needsProjUpdate = false; } } Vector3f Camera::getPosition() const { return position; } void Camera::setPosition(const Vector3f& pos) { needsViewUpdate = true; position = pos; } void Camera::setTilt(float rad) { needsViewUpdate = !MathUtil::eqFloats(rad, tilt); tilt = rad; } void Camera::addAngle(float x, float y) { if (MathUtil::eqFloats(x, 0.f) && MathUtil::eqFloats(y, 0.f)) { return; } xAngle += x; yAngle -= y; if (yAngle < -yAngleLimit) { yAngle = -yAngleLimit; } else if (yAngle > yAngleLimit) { yAngle = yAngleLimit; } float PI_MUL_2 = MathUtil::PI * 2.f; if (xAngle > PI_MUL_2) { xAngle -= PI_MUL_2; } else if (xAngle < -PI_MUL_2) { xAngle += PI_MUL_2; } needsViewUpdate = true; } void Camera::resetAngle() { xAngle = 0.f; yAngle = 0.f; needsViewUpdate = true; } void Camera::setThirdPersonPerspective(bool bruh) { needsViewUpdate = bruh != thirdPerson; thirdPerson = bruh; } bool Camera::isThirdPerson() const { return thirdPerson; } void Camera::addFov(float deg) { fov += MathUtil::degToRad(deg); fov = MathUtil::clampFloat(fov, 0.1f, 2.9f); needsProjUpdate = true; } void Camera::setXYClippings(int w, int h) { if (width == w && height == h) { return; } this->width = w; this->height = h; needsProjUpdate = true; } void Camera::setZClippings(float nearZ, float farZ) { if (MathUtil::eqFloats(nearPlaneZ, nearZ) && MathUtil::eqFloats(farPlaneZ, farZ)) { return; } nearPlaneZ = nearZ; farPlaneZ = farZ; needsProjUpdate = true; } float Camera::getAspectRatio() const { return (float)width / height; } void Camera::setOrthographicProj(bool bruh) { needsProjUpdate = bruh != orthographicProj; orthographicProj = bruh; }
position.subtract(Vector3f(thirdPersonRadius * cosYAngle * cosXAngle, thirdPersonRadius * sinYAngle, -thirdPersonRadius * cosYAngle * sinXAngle))
call_expression
[ { "content": "struct NameCompare: std::binary_function <const char *, const char *, bool>\n\n{\n\n bool\n\n operator () (const char *x, const char *y) const\n\n {\n\n\treturn strcmp (x, y) < 0;\n\n }\n\n};\n\n\n\n\n\ntypedef Attribute* (*Constructor)();\n\ntypedef std::map <const char *, Constructor, NameCompare> TypeMap;\n\n\n\n\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmImf/ImfAttribute.cpp", "rank": 0, "score": 172905.35184195382 }, { "content": "PFNGLVIEWPORTPOSITIONWSCALENVPROC __glewViewportPositionWScaleNV = NULL;\n", "file_path": "Libraries/glew-2.1.0/src/glew.c", "rank": 1, "score": 129239.37530202165 }, { "content": " int err;\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/gzlib.c", "rank": 2, "score": 115035.89834212716 }, { "content": "const char * ZEXPORT zError(err)\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/zutil.c", "rank": 3, "score": 115035.89834212716 }, { "content": " int err; /* error code */\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/gzguts.h", "rank": 4, "score": 115035.89834212716 }, { "content": "local int gz_decomp(state)\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/gzread.c", "rank": 5, "score": 115035.40246082231 }, { "content": "local int build_bl_tree(s)\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/trees.c", "rank": 6, "score": 115034.79933936216 }, { "content": "local int gz_init(state)\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/gzwrite.c", "rank": 7, "score": 115034.73788585953 }, { "content": "local void fixedtables(state)\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/infback.c", "rank": 8, "score": 115031.72925338359 }, { "content": "local void fixedtables(state)\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/inflate.c", "rank": 9, "score": 115031.72925338359 }, { "content": "local void fill_window OF((deflate_state *s));\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/deflate.c", "rank": 10, "score": 115031.54080120887 }, { "content": "local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/inflate.c", "rank": 11, "score": 115028.34371094767 }, { "content": "local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/deflate.c", "rank": 12, "score": 115028.34371094767 }, { "content": "local void send_bits OF((deflate_state *s, int value, int length));\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/trees.c", "rank": 13, "score": 115024.54747815485 }, { "content": "local void make_crc_table OF((void));\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/crc32.c", "rank": 14, "score": 115024.54747815485 }, { "content": "local void gz_reset(state)\n", "file_path": "Libraries/FreeImage-3170/Source/ZLib/gzlib.c", "rank": 15, "score": 115024.54747815485 }, { "content": "\tjpeg_error_mgr\terr;\t\t/* libjpeg error manager */\n", "file_path": "Libraries/FreeImage-3170/Source/LibTIFF4/tif_jpeg.c", "rank": 16, "score": 114261.59154571212 }, { "content": "", "file_path": "Libraries/FreeImage-3170/Source/LibJXR/jxrgluelib/JXRMeta.h", "rank": 17, "score": 113505.20160027158 }, { "content": "Vec4<int>::length () const;\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/Imath/ImathVec.h", "rank": 18, "score": 113504.6292903313 }, { "content": " score_t H, R, score; // header bits, rate, score.\n", "file_path": "Libraries/FreeImage-3170/Source/LibWebP/src/enc/vp8enci.h", "rank": 19, "score": 112764.07406201486 }, { "content": "IMF_EXPORT\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmImf/ImfMisc.h", "rank": 20, "score": 112758.73396287477 }, { "content": "IMF_EXPORT\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmImf/ImfMisc.h", "rank": 21, "score": 112754.93773008193 }, { "content": "IMF_EXPORT bool isMultiPartOpenExrFile (IStream &is);\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmImf/ImfTestFile.h", "rank": 22, "score": 112044.88676763719 }, { "content": "class Matrix4x4f {\n\npublic:\n\n float elements[4][4];\n\n\n\n Matrix4x4f();\n\n Matrix4x4f(float aa,float ab,float ac,float ad,\n\n float ba,float bb,float bc,float bd,\n\n float ca,float cb,float cc,float cd,\n\n float da,float db,float dc,float dd);\n\n\n\n Matrix4x4f transpose() const;\n\n\n\n Matrix4x4f product(const Matrix4x4f& other) const;\n\n Vector4f transform(const Vector4f& other) const;\n\n Vector3f transform(const Vector3f& other) const;\n\n\n\n static Matrix4x4f translate(const Vector3f& position);\n\n static Matrix4x4f scale(const Vector3f& scale);\n\n static Matrix4x4f scale(const Vector3f& scale, const Vector3f& origin);\n\n static Matrix4x4f rotate(const Vector3f& rotation);\n", "file_path": "Src/Math/Matrix.h", "rank": 23, "score": 110875.58988310402 }, { "content": "class Vector3f {\n\npublic:\n\n float x; float y; float z;\n\n\n\n Vector3f();\n\n Vector3f(float s);\n\n Vector3f(float ix,float iy,float iz);\n\n\n\n float lengthSquared() const;\n\n float length() const;\n\n\n\n float distanceSquared(const Vector3f& b) const;\n\n float distance(const Vector3f& b) const;\n\n\n\n Vector3f add(const Vector3f& b) const;\n\n Vector3f subtract(const Vector3f& b) const;\n\n\n\n Vector3f multiply(float s) const;\n\n Vector3f normalize() const;\n\n \n\n Vector3f negate() const;\n\n Vector3f reflect(const Vector3f& n) const;\n\n float dotProduct(const Vector3f& b) const;\n\n Vector3f crossProduct(const Vector3f& b) const;\n\n\n\n static const Vector3f zero;\n\n static const Vector3f one;\n\n};\n\n\n", "file_path": "Src/Math/Vector.h", "rank": 24, "score": 110875.17114649565 }, { "content": "class Vector2f; class Vector3f;\n\n\n", "file_path": "Src/Math/Vector.h", "rank": 25, "score": 96437.77952582345 }, { "content": "static void opj_j2k_write_float_to_float (const void * p_src_data, void * p_dest_data, OPJ_UINT32 p_nb_elem);\n", "file_path": "Libraries/FreeImage-3170/Source/LibOpenJPEG/j2k.c", "rank": 26, "score": 78165.7844741262 }, { "content": "IEX_EXPORT void throwErrnoExc();\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/Iex/IexThrowErrnoExc.h", "rank": 27, "score": 77651.69625716025 }, { "content": "", "file_path": "Libraries/FreeImage-3170/Source/LibJXR/jxrgluelib/JXRGluePFC.c", "rank": 28, "score": 77622.37645025317 }, { "content": "", "file_path": "Libraries/FreeImage-3170/Source/LibJXR/jxrgluelib/JXRGluePFC.c", "rank": 29, "score": 77622.37645025317 }, { "content": "OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER\n\n\n\ntypedef std::vector<float>\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmImf/ImfFloatVectorAttribute.h", "rank": 30, "score": 77622.37645025317 }, { "content": "const char *FloatVectorAttribute::staticTypeName ();\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmImf/ImfFloatVectorAttribute.h", "rank": 31, "score": 77086.47180104422 }, { "content": "unsigned int\n\nhalfToFloat (unsigned short y)\n\n{\n\n\n\n int s = (y >> 15) & 0x00000001;\n\n int e = (y >> 10) & 0x0000001f;\n\n int m = y & 0x000003ff;\n\n\n\n if (e == 0)\n\n {\n\n\tif (m == 0)\n\n\t{\n\n\t //\n\n\t // Plus or minus zero\n\n\t //\n\n\n\n\t return s << 31;\n\n\t}\n\n\telse\n\n\t{\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/Half/toFloat.cpp", "rank": 32, "score": 70296.87575558462 }, { "content": "//\n\n//\tA program to generate the lookup table for half-to-float\n\n//\tconversion needed by class half.\n\n//\tThe program loops over all 65536 possible half numbers,\n\n//\tconverts each of them to a float, and prints the result.\n\n//\n\n//---------------------------------------------------------------------------\n\n\n\n\n\n#include <iostream>\n\n#include <iomanip>\n\n\n\nusing namespace std;\n\n\n\n//---------------------------------------------------\n\n// Interpret an unsigned short bit pattern as a half,\n\n// and convert that half to the corresponding float's\n\n// bit pattern.\n\n//---------------------------------------------------\n\n\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/Half/toFloat.cpp", "rank": 33, "score": 70296.52362845841 }, { "content": "\t \"// This is an automatically generated file.\\n\"\n\n\t \"// Do not edit.\\n\"\n\n\t \"//\\n\\n\";\n\n\n\n cout << \"{\\n \";\n\n\n\n const int iMax = (1 << 16);\n\n\n\n for (int i = 0; i < iMax; i++)\n\n {\n\n\tcout << \"{0x\" << setfill ('0') << setw (8) << halfToFloat (i) << \"}, \";\n\n\n\n\tif (i % 4 == 3)\n\n\t{\n\n\t cout << \"\\n\";\n\n\n\n\t if (i < iMax - 1)\n\n\t\tcout << \" \";\n\n\t}\n\n }\n\n\n\n cout << \"};\\n\";\n\n return 0;\n\n}\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/Half/toFloat.cpp", "rank": 34, "score": 70295.70966516741 }, { "content": "\n\n Vector3f position;\n\n Vector3f lookAt;\n\n Vector3f upDir;\n\n\n\n Matrix4x4f viewMatrix;\n\n Matrix4x4f projectionMatrix;\n\n Matrix4x4f rotation;\n\n\n\n std::vector<Shader*> shaders;\n\n\n\npublic:\n\n Camera(int w, int h, float fov, float nearZ = 0.01f, float farZ = 30.f, bool orthographic = false);\n\n Camera(int w, int h);\n\n\n\n void addShader(Shader* shd);\n\n\n\n Matrix4x4f getViewMatrix() const;\n\n Matrix4x4f getProjectionMatrix() const;\n\n\n", "file_path": "Src/Graphics/Camera.h", "rank": 36, "score": 64.47632117073445 }, { "content": " void update();\n\n\n\n Vector3f getPosition() const;\n\n void setPosition(const Vector3f& pos);\n\n void setTilt(float rad);\n\n void addAngle(float xAngle, float yAngle);\n\n void resetAngle();\n\n void setThirdPersonPerspective(bool bruh);\n\n bool isThirdPerson() const;\n\n \n\n void addFov(float deg);\n\n void setXYClippings(int w, int h);\n\n void setZClippings(float nearZ, float farZ);\n\n float getAspectRatio() const;\n\n void setOrthographicProj(bool bruh);\n\n};\n\n\n\n#endif // CAMERA_H_INCLUDED\n", "file_path": "Src/Graphics/Camera.h", "rank": 37, "score": 62.236418332017536 }, { "content": " Cube(Shader* shd);\n\n\n\n\tvoid setPosition(const Vector3f& vect);\n\n void setPosition(float x, float y, float z);\n\n void addPositionXZ(const Vector2f& vect);\n\n\tvoid setScale(const Vector3f& vect);\n\n\tvoid setScale(float x, float y, float z);\n\n void addRotationX(float bruh);\n\n void addRotationY(float bruh);\n\n void addRotationZ(float bruh);\n\n\n\n void setShader(Shader* shd);\n\n \n\n void constructWorldMat();\n\n void constructWorldMat( const Matrix4x4f& originWorldMatrix);\n\n Matrix4x4f getWorldMatrix() const;\n\n\n\n void update(const Matrix4x4f& originWorldMatrix);\n\n void render() const;\n\n};\n\n\n\n#endif // CUBE_H_INCLUDED\n", "file_path": "Src/Primitives/Cube.h", "rank": 38, "score": 55.727375090770636 }, { "content": " static Matrix4x4f rotate(const Vector3f& rotation, const Vector3f& origin);\n\n static Matrix4x4f constructWorldMat(const Vector3f& position,const Vector3f& scale,const Vector3f& rotation);\n\n static Matrix4x4f constructViewMat(const Vector3f& position,const Vector3f& target,const Vector3f& upVector);\n\n static Matrix4x4f constructPerspectiveMat(float horizontalfov, float aspectRatio, float nearZ, float farZ);\n\n static Matrix4x4f constructOrthographicMat(float width, float height, float nearZ, float farZ);\n\n\n\n static const Matrix4x4f identity;\n\n};\n\n\n\n#endif // MATRIX_H_INCLUDED\n", "file_path": "Src/Math/Matrix.h", "rank": 39, "score": 50.70316334193676 }, { "content": " }\n\n\n\n tireRotation = MathUtil::clampFloat(tireRotation, -1.f, 1.f);\n\n for (int i = 0; i < 4; i++) {\n\n wheels[i]->setTireRotation(tireRotation);\n\n }\n\n}\n\n\n\nbool Car::deltaPositionCausesCollision(int& collidedCar, RectCollider::CollisionDir& dir) {\n\n Vector3f newPosition = position.add(Vector3f(deltaPositionXZ.x, 0.f, deltaPositionXZ.y));\n\n Vector3f newRotation = rotation.add(Vector3f(0.f, deltaRotationY, 0.f));\n\n collider->update(Matrix4x4f::constructWorldMat(newPosition, Vector3f::one, newRotation));\n\n\n\n bool didCollide = false;\n\n for (int i = 0; i < (int)allCars.size(); i++) {\n\n if (allCars[i] == this) { continue; }\n\n\n\n if (collider->collides(allCars[i]->collider, dir)) {\n\n collidedCar = i;\n\n didCollide = true;\n", "file_path": "Src/Objects/Car.cpp", "rank": 40, "score": 48.01231094712674 }, { "content": " \n\n void updateAcceleration(WalkInput input, float speed);\n\n void updateVelocity(Car::WalkInput input, float timestep);\n\n void updatePosition(WalkInput input);\n\n void updateTireRotation(WalkInput input, float speed);\n\n bool deltaPositionCausesCollision(int& collidedCar, RectCollider::CollisionDir& dir);\n\n \n\npublic:\n\n Car(Shader* shd, Shader* colliderShd, Shader* spriteShd);\n\n ~Car();\n\n \n\n void addPositionXZ(const Vector2f& vect);\n\n Vector3f getPosition() const;\n\n void addScale(float sca);\n\n void addRotationX(float bruh);\n\n void addRotationY(float bruh);\n\n float getRotationY() const;\n\n void addRotationZ(float bruh);\n\n\n\n\tvoid toggleHeadlightsTaillights();\n", "file_path": "Src/Objects/Car.h", "rank": 41, "score": 47.51220044900529 }, { "content": " void addRotationX(float bruh);\n\n void addRotationZ(float bruh);\n\n void setTireRotation(float bruh);\n\n\n\n void setShader(Shader* shd);\n\n \n\n void update(const Matrix4x4f& originWorldMatrix);\n\n void render();\n\n};\n\n\n\n#endif // WHEEL_H_INCLUDED\n", "file_path": "Src/Primitives/Wheel.h", "rank": 43, "score": 45.64683354489338 }, { "content": "\n\n void setScale(float scale);\n\n void setPosition(const Vector3f& pos);\n\n void addRotation(float rad);\n\n \n\n void setOpacity(float value);\n\n\n\n void update();\n\n void render() const;\n\n};\n\n\n\n#endif // SPRITE_H_INCLUDED\n", "file_path": "Src/Graphics/Sprite.h", "rank": 44, "score": 45.32385780481448 }, { "content": "#include <stdexcept>\n\n\n\n#include \"Quad.h\"\n\n#include \"../Graphics/Mesh.h\"\n\n\n\nQuad::Quad(Shader* shd) {\n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Quad(Shader* shd).\");\n\n }\n\n \n\n mesh = new Mesh(shd);\n\n std::vector<float> verts;\n\n for (int i = 0; i < 16; i++) {\n\n verts.push_back(quadVertices[i]);\n\n }\n\n std::vector<int> prims = {\n\n 2, 0, 1,\n\n 2, 1, 3\n\n };\n\n \n\n mesh->setGeometry(verts, prims);\n\n}\n\n\n\nvoid Quad::render() {\n\n mesh->render();\n\n}\n", "file_path": "Src/Primitives/Quad.cpp", "rank": 45, "score": 44.968542978696135 }, { "content": " break;\n\n }\n\n }\n\n\n\n if (didCollide) {\n\n // Restore original collider.\n\n collider->update(Matrix4x4f::constructWorldMat(position, Vector3f::one, rotation));\n\n }\n\n\n\n return didCollide;\n\n}\n\n\n\nMatrix4x4f Car::getRotationMatrix() const {\n\n return rotationMatrix;\n\n}\n\n\n\nvoid Car::setShader(Shader* shd) {\n\n for (int i = 0; i < (int)parts.size(); i++) {\n\n parts[i]->setShader(shd);\n\n }\n", "file_path": "Src/Objects/Car.cpp", "rank": 47, "score": 43.94725467690405 }, { "content": "#include <cmath>\n\n#include <vector>\n\n#include <stdexcept>\n\n\n\n#include \"Sprite.h\"\n\n#include \"Mesh.h\"\n\n\n\nSprite::Sprite(Shader* shd) {\n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Sprite(Shader* shd).\");\n\n }\n\n\n\n mesh = new Mesh(shd);\n\n std::vector<float> verts = {\n\n -0.5f, 0.5f,\n\n 0.5f, -0.5f,\n\n -0.5f, -0.5f,\n\n 0.5f, 0.5f\n\n };\n", "file_path": "Src/Graphics/Sprite.cpp", "rank": 48, "score": 43.542936557279816 }, { "content": "#include <stdexcept>\n\n\n\n#include \"Axis.h\"\n\n#include \"../Graphics/Mesh.h\"\n\n\n\nAxis::Axis(Shader* shd) {\n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Axes(Shader* shd).\");\n\n }\n\n \n\n mesh = new Mesh(shd);\n\n std::vector<float> verts;\n\n for (int i = 0; i < 12; i++) {\n\n verts.push_back(vertices[i]);\n\n }\n\n std::vector<int> prims = {\n\n 0, 1\n\n };\n\n \n", "file_path": "Src/Primitives/Axis.cpp", "rank": 49, "score": 42.763797170183615 }, { "content": "#include <stdexcept>\n\n\n\n#include \"Cube.h\"\n\n#include \"../Graphics/Mesh.h\"\n\n\n\nCube::Cube(Shader* shd) {\n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Cube(Shader* shd).\");\n\n }\n\n \n\n mesh = new Mesh(shd);\n\n setShader(shd);\n\n std::vector<float> verts;\n\n for (int i = 0; i < 288; i++) {\n\n verts.push_back(vertices[i]);\n\n }\n\n std::vector<int> prims = {\n\n 2, 1, 0,\n\n 5, 4, 3,\n", "file_path": "Src/Primitives/Cube.cpp", "rank": 50, "score": 42.575827978431654 }, { "content": "#include <stdexcept>\n\n\n\n#include \"Grid.h\"\n\n#include \"../Graphics/Mesh.h\"\n\n\n\nGrid::Grid(Shader* shd) {\n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Grid(Shader* shd).\");\n\n }\n\n \n\n mesh = new Mesh(shd);\n\n setShader(shd);\n\n std::vector<float> verts;\n\n for (int i = 0; i < 32; i++) {\n\n verts.push_back(vertices[i]);\n\n }\n\n std::vector<int> prims = {\n\n 0, 2, 3,\n\n 3, 1, 0\n", "file_path": "Src/Primitives/Grid.cpp", "rank": 51, "score": 42.575827978431654 }, { "content": "#include \"Smoke.h\"\n\n#include \"../Graphics/Sprite.h\"\n\n\n\nSmoke::Smoke(Shader* shd, const Vector3f& position) {\n\n sprite = new Sprite(shd);\n\n sprite->setPosition(position);\n\n \n\n age = 0.f;\n\n markedForRemoval = false;\n\n}\n\n\n\nSmoke::~Smoke() {\n\n delete sprite;\n\n}\n\n\n\nbool Smoke::isMarkedForRemoval() const {\n\n return markedForRemoval;\n\n}\n\n\n\nvoid Smoke::update(float timestep) {\n", "file_path": "Src/Objects/Smoke.cpp", "rank": 52, "score": 42.19683031461659 }, { "content": " this->scale = scale;\n\n}\n\n\n\nvoid Sprite::setPosition(const Vector3f& pos) {\n\n position = pos;\n\n}\n\n\n\nvoid Sprite::addRotation(float rad) {\n\n rotation += rad;\n\n}\n\n\n\nvoid Sprite::setOpacity(float value) {\n\n color.w = value;\n\n}\n\n\n\nvoid Sprite::update() {\n\n modelMatrix = Matrix4x4f::translate(position);\n\n float sinRoll = sin(rotation);\n\n float cosRoll = cos(rotation);\n\n rotationMatrix = Matrix4x4f(cosRoll,-sinRoll,0.f,0.f,\n", "file_path": "Src/Graphics/Sprite.cpp", "rank": 53, "score": 41.86775086902772 }, { "content": " \n\n Matrix4x4f getRotationMatrix() const;\n\n \n\n void setShader(Shader* shd);\n\n \n\n void update(WalkInput input, float timestep);\n\n void render();\n\n};\n\n\n\nconst Car::WalkInput operator&(const Car::WalkInput& a, const Car::WalkInput& b);\n\nconst Car::WalkInput operator|(const Car::WalkInput& a, const Car::WalkInput& b);\n\n\n\n#endif // CAR_H_INCLUDED\n", "file_path": "Src/Objects/Car.h", "rank": 56, "score": 38.28985552060628 }, { "content": " rotation.x += bruh;\n\n}\n\n\n\nvoid Cube::addRotationY(float bruh) {\n\n rotation.y += bruh;\n\n}\n\n\n\nvoid Cube::addRotationZ(float bruh) {\n\n rotation.z += bruh;\n\n}\n\n\n\nvoid Cube::setShader(Shader* shd) {\n\n mesh->setShader(shd);\n\n worldMatUniform = shd->getMat4Uniform(\"modelMatrix\");\n\n colorUniform = shd->getVec4fUniform(\"fsColor\");\n\n}\n\n\n\nvoid Cube::constructWorldMat() {\n\n worldMatrix = Matrix4x4f::constructWorldMat(position, scale, rotation);\n\n}\n", "file_path": "Src/Primitives/Cube.cpp", "rank": 57, "score": 38.141350710609174 }, { "content": " } else {\n\n std::cerr << \"Something went wrong.\\n\";\n\n }\n\n \n\n color = Vector4f(1.f, 0.f, 0.f, 1.f);\n\n scale = Vector3f(0.025f, 0.025f, 0.025f);\n\n rotation.y = MathUtil::PI / 2.f;\n\n tireRotation = 0.f;\n\n}\n\n\n\nvoid Wheel::setPosition(float x, float y, float z) {\n\n position = Vector3f(x, y, z);\n\n}\n\n\n\nvoid Wheel::addPositionXZ(const Vector2f& vect) {\n\n position.x += vect.x;\n\n position.z += vect.y;\n\n}\n\n\n\nvoid Wheel::addRotationX(float bruh) {\n", "file_path": "Src/Primitives/Wheel.cpp", "rank": 59, "score": 37.73188315209489 }, { "content": "}\n\n\n\nvoid Cube::setPosition(float x, float y, float z) {\n\n\tposition = Vector3f(x, y, z);\n\n}\n\n\n\nvoid Cube::addPositionXZ(const Vector2f& vect) {\n\n position.x += vect.x;\n\n position.z += vect.y;\n\n}\n\n\n\nvoid Cube::setScale(const Vector3f& vect) {\n\n\tscale = vect;\n\n}\n\n\n\nvoid Cube::setScale(float x, float y, float z) {\n\n scale = Vector3f(x, y, z);\n\n}\n\n\n\nvoid Cube::addRotationX(float bruh) {\n", "file_path": "Src/Primitives/Cube.cpp", "rank": 60, "score": 37.333836886979086 }, { "content": "#include <GL/glew.h>\n\n#include <stdexcept>\n\n#include <stdexcept>\n\n\n\n#include \"Triangle.h\"\n\n#include \"../Graphics/Mesh.h\"\n\n\n\nTriangle::Triangle(Shader* shd) {\n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Triangle(Shader* shd).\");\n\n }\n\n \n\n mesh = new Mesh(shd);\n\n std::vector<float> verts;\n\n verts.push_back(vertices[0]);\n\n verts.push_back(vertices[1]);\n\n verts.push_back(vertices[2]);\n\n verts.push_back(vertices[3]);\n\n verts.push_back(vertices[4]);\n", "file_path": "Src/Primitives/Triangle.cpp", "rank": 61, "score": 36.006877823464066 }, { "content": "#include \"Wheel.h\"\n\n#include \"../Graphics/Mesh.h\"\n\n#include \"../Utils/OBJ_Loader.h\"\n\n#include \"../Math/MathUtil.h\"\n\n\n\nWheel::Wheel(Shader* shd) {\n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Wheel(Shader* shd).\");\n\n }\n\n \n\n mesh = new Mesh(shd);\n\n setShader(shd);\n\n \n\n // Initialize Loader\n\n objl::Loader loader;\n\n bool loaded = loader.LoadFile(\"Textures/wheel.obj\");\n\n\n\n if (loaded) {\n\n for (int i = 0; i < (int)loader.LoadedMeshes.size(); i++) {\n", "file_path": "Src/Primitives/Wheel.cpp", "rank": 62, "score": 35.982079078798975 }, { "content": " rotation.x += bruh;\n\n}\n\n\n\nvoid Wheel::addRotationZ(float bruh) {\n\n rotation.z += bruh;\n\n}\n\n\n\nvoid Wheel::setTireRotation(float bruh) {\n\n tireRotation = bruh;\n\n}\n\n\n\nvoid Wheel::setShader(Shader* shd) {\n\n mesh->setShader(shd);\n\n worldMatrixUniform = shd->getMat4Uniform(\"modelMatrix\");\n\n colorUniform = shd->getVec4fUniform(\"fsColor\");\n\n}\n\n\n\nvoid Wheel::update(const Matrix4x4f& originWorldMatrix) {\n\n Matrix4x4f scaleMat = Matrix4x4f::scale(scale);\n\n \n", "file_path": "Src/Primitives/Wheel.cpp", "rank": 63, "score": 35.94918947388893 }, { "content": " magnitude = -deltaPositionXZ.length();\n\n }\n\n\n\n if (!MathUtil::eqFloats(magnitude, 0.f)) {\n\n for (int i = 0; i < 4; i++) {\n\n wheels[i]->addRotationZ(magnitude);\n\n }\n\n }\n\n\n\n rotationMatrix = Matrix4x4f::rotate(rotation, position);\n\n Matrix4x4f scaleMatrix = Matrix4x4f::scale(scale, position);\n\n\n\n Matrix4x4f worldMatrix = scaleMatrix.product(rotationMatrix);\n\n\n\n for (int i = 0; i < (int)parts.size(); i++) {\n\n parts[i]->update(worldMatrix);\n\n }\n\n for (int i = 0; i < 4; i++) {\n\n wheels[i]->update(worldMatrix);\n\n }\n", "file_path": "Src/Objects/Car.cpp", "rank": 64, "score": 35.45701825852426 }, { "content": " };\n\n \n\n mesh->setGeometry(verts, prims);\n\n\n\n color = Vector4f(1.f, 1.f, 1.f, 1.f);\n\n scale = Vector3f::one;\n\n}\n\n\n\nvoid Grid::setShader(Shader* shd) {\n\n mesh->setShader(shd);\n\n worldMat = shd->getMat4Uniform(\"modelMatrix\");\n\n colorUniform = shd->getVec4fUniform(\"fsColor\");\n\n}\n\n\n\nvoid Grid::render() {\n\n GLuint err = GL_NO_ERROR;\n\n err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - Grid::render().\");\n\n }\n\n Matrix4x4f mat = Matrix4x4f::constructWorldMat(Vector3f::zero, scale, Vector3f::zero);\n\n worldMat->setValue(mat);\n\n colorUniform->setValue(color);\n\n \n\n mesh->render();\n\n}\n", "file_path": "Src/Primitives/Grid.cpp", "rank": 65, "score": 35.32825204914927 }, { "content": "#include <stdexcept>\n\n\n\n#include \"RectCollider.h\"\n\n#include \"../Graphics/Mesh.h\"\n\n\n\nstatic void pushNormalsToVector(std::vector<float>& vect) {\n\n vect.push_back(0.f);\n\n vect.push_back(1.f);\n\n vect.push_back(0.f);\n\n}\n\n\n\nRectCollider::RectCollider(const Vector2f& tl, const Vector2f& tr, const Vector2f& bl, const Vector2f& br, Shader* shd) {\n\n topLeft = tl;\n\n topRight = tr;\n\n bottomLeft = bl;\n\n bottomRight = br;\n\n \n\n GLuint err = glGetError();\n\n if (err != GL_NO_ERROR) {\n\n throw std::runtime_error(\"Uncaught exception - RectCollider(Shader* shd).\");\n", "file_path": "Src/Objects/RectCollider.cpp", "rank": 66, "score": 35.31905123115861 }, { "content": " wheels[2]->setPosition(-2.5f, 0.f, 2.25f);\n\n wheels[3] = new Wheel(shd);\n\n wheels[3]->setPosition(-2.5f, 0.f, -2.25f);\n\n\n\n for (int i = 0; i < 4; i++) {\n\n wheels[i]->color = Vector4f(0.2f, 0.2f, 0.2f, 1.f);\n\n }\n\n\n\n metalTexture = new Texture(\"Textures/metal.jpg\");\n\n tireTexture = new Texture(\"Textures/tire.png\");\n\n tireRotation = 0.f;\n\n deltaRotationY = 0.f;\n\n scale = Vector3f::one;\n\n\n\n\tenableHeadlightsAndTailights = true;\n\n \n\n spriteShader = spriteShd;\n\n}\n\n\n\nCar::~Car() {\n", "file_path": "Src/Objects/Car.cpp", "rank": 67, "score": 34.414060458541584 }, { "content": " }\n\n}\n\n\n\nvoid Car::addPositionXZ(const Vector2f& vect) {\n\n position.x += vect.x;\n\n position.z += vect.y;\n\n for (int i = 0; i < (int)parts.size(); i++) {\n\n parts[i]->addPositionXZ(vect);\n\n }\n\n for (int i = 0; i < 4; i++) {\n\n wheels[i]->addPositionXZ(vect);\n\n }\n\n}\n\n\n\nVector3f Car::getPosition() const {\n\n return position;\n\n}\n\n\n\nvoid Car::addScale(float sca) {\n\n scale = scale.add(Vector3f(sca, sca, sca));\n", "file_path": "Src/Objects/Car.cpp", "rank": 68, "score": 34.02312680953683 }, { "content": "}\n\n\n\nvoid Mesh::setGeometry(std::vector<float>& vertices, std::vector<int>& primitives, GLenum mod) {\n\n vertexData = vertices;\n\n primData = primitives;\n\n mode = mod;\n\n \n\n needsUpload = true;\n\n}\n\n\n\nvoid Mesh::setShader(Shader* shd) {\n\n shader = shd;\n\n}\n\n\n\nvoid Mesh::uploadData() {\n\n GLuint err = GL_NO_ERROR;\n\n\n\n glBufferData(GL_ARRAY_BUFFER, vertexData.size() * sizeof(float), vertexData.data(), GL_STATIC_DRAW);\n\n err = glGetError();\n\n if (err != GL_NO_ERROR) {\n", "file_path": "Src/Graphics/Mesh.cpp", "rank": 69, "score": 33.964558865244655 }, { "content": " mesh->setGeometry(verts, prims, GL_LINES);\n\n\n\n worldMat = shd->getMat4Uniform(\"modelMatrix\");\n\n colorUniform = shd->getVec4fUniform(\"fsColor\");\n\n rotation = Vector3f::zero;\n\n color = Vector4f::one;\n\n}\n\n\n\nvoid Axis::render() {\n\n// Matrix4x4f mat = Matrix4x4f::rotate(rotation);\n\n Matrix4x4f mat = Matrix4x4f::constructWorldMat(Vector3f::zero, Vector3f(2.f, 2.f, 2.f), rotation);\n\n worldMat->setValue(mat);\n\n colorUniform->setValue(color);\n\n \n\n mesh->render();\n\n}\n", "file_path": "Src/Primitives/Axis.cpp", "rank": 70, "score": 32.85268156622509 }, { "content": "\t\t/// <param name=\"right\">Specifies the right position of the cropped rectangle.</param>\n\n\t\t/// <param name=\"bottom\">Specifies the bottom position of the cropped rectangle.</param>\n\n\t\t/// <returns>Returns true on success, false on failure.</returns>\n\n\t\t/// <exception cref=\"ArgumentNullException\">\n\n\t\t/// <paramref name=\"source\"/> or <paramref name=\"destination\"/> is null.\n\n\t\t/// </exception>\n\n\t\t/// <exception cref=\"FileNotFoundException\">\n\n\t\t/// <paramref name=\"source\"/> does not exist.\n\n\t\t/// </exception>\n\n\t\tpublic static bool JPEGCrop(string source, string destination, int left, int top, int right, int bottom)\n\n\t\t{\n\n\t\t\tif (source == null)\n\n\t\t\t{\n\n\t\t\t\tthrow new ArgumentNullException(\"source\");\n\n\t\t\t}\n\n\t\t\tif (!File.Exists(source))\n\n\t\t\t{\n\n\t\t\t\tthrow new FileNotFoundException(\"source\");\n\n\t\t\t}\n\n\t\t\tif (destination == null)\n", "file_path": "Libraries/FreeImage-3170/Wrapper/FreeImage.NET/cs/UnitTest/FreeImage.cs", "rank": 71, "score": 32.58780542862083 }, { "content": "\t\t/// <param name=\"left\">Specifies the left position of the cropped rectangle.</param>\n\n\t\t/// <param name=\"top\">Specifies the top position of the cropped rectangle.</param>\n\n\t\t/// <param name=\"right\">Specifies the right position of the cropped rectangle.</param>\n\n\t\t/// <param name=\"bottom\">Specifies the bottom position of the cropped rectangle.</param>\n\n\t\t/// <returns>Returns true on success, false on failure.</returns>\n\n\t\t/// <exception cref=\"ArgumentNullException\">\n\n\t\t/// <paramref name=\"source\"/> or <paramref name=\"destination\"/> is null.\n\n\t\t/// </exception>\n\n\t\t/// <exception cref=\"FileNotFoundException\">\n\n\t\t/// <paramref name=\"source\"/> does not exist.\n\n\t\t/// </exception>\n\n\t\tpublic static bool JPEGCrop(string source, string destination, int left, int top, int right, int bottom)\n\n\t\t{\n\n\t\t\tif (source == null)\n\n\t\t\t{\n\n\t\t\t\tthrow new ArgumentNullException(\"source\");\n\n\t\t\t}\n\n\t\t\tif (!File.Exists(source))\n\n\t\t\t{\n\n\t\t\t\tthrow new FileNotFoundException(\"source\");\n", "file_path": "Libraries/FreeImage-3170/Wrapper/FreeImage.NET/cs/Library/Classes/FreeImageBitmap.cs", "rank": 72, "score": 32.306290722813934 }, { "content": "#include \"Graphics/Texture.h\"\n\n#include \"Math/MathUtil.h\"\n\n\n\nint width = 1024;\n\nint height = 768;\n\n\n\n// Mouse position last frame.\n\nfloat prevMouseX = 0.f;\n\nfloat prevMouseY = 0.f;\n\n// Difference between the mouse position in this frame and the previous frame.\n\nfloat mouseXDiff = 0.f;\n\nfloat mouseYDiff = 0.f;\n\n\n\n// Whether to perform a depth pass for shadow mapping.\n\nbool enableShadows = false;\n\n\n\n// Whether to use texture colors or vertex colors.\n\nbool enableTextures = false;\n\n\n\n// Whether to render the depth map to a texture for debugging.\n", "file_path": "Src/Main.cpp", "rank": 73, "score": 31.47254913123698 }, { "content": "#define GLEW_STATIC 1\n\n#include <GL/glew.h>\n\n#include <GLFW/glfw3.h>\n\n\n\n#include \"Player.h\"\n\n#include \"../Utils/InputUtil.h\"\n\n#include \"../Graphics/Shader.h\"\n\n#include \"../Graphics/Camera.h\"\n\n#include \"../Objects/Car.h\"\n\n\n\nPlayer::Player(Shader* shd, Shader* colliderShd, Shader* spriteShd, int camWidth, int camHeight) {\n\n car = new Car(shd, colliderShd, spriteShd);\n\n car->addPositionXZ(Vector2f(0.f, -15.f));\n\n camera = new Camera(camWidth, camHeight);\n\n camera->addAngle(MathUtil::PI, 0.f);\n\n\n\n\tcameraFollowingCar = true;\n\n camera->setThirdPersonPerspective(true);\n\n}\n\n\n", "file_path": "Src/Controllers/Player.cpp", "rank": 74, "score": 31.30628680078832 }, { "content": "#include <cmath>\n\n\n\n#include \"MathUtil.h\"\n\n\n\nfloat MathUtil::degToRad(float degree) {\n\n return degree * PI / 180.0f;\n\n}\n\n\n\nbool MathUtil::eqFloats(float p1, float p2) {\n\n return fabs(p1 - p2) < MARGIN_ERROR;\n\n}\n\n\n\nint MathUtil::clamp(int val, int min, int max) {\n\n if (val <= min) { return min; }\n\n if (val >= max) { return max; }\n\n return val;\n\n}\n\n\n\nfloat MathUtil::clampFloat(float val, float min, float max) {\n\n if (val <= min) { return min; }\n", "file_path": "Src/Math/MathUtil.cpp", "rank": 75, "score": 31.23063612237275 }, { "content": " \n\n void acquire ()\n\n {\n\n _mutex.lock();\n\n _locked = true;\n\n }\n\n \n\n void release ()\n\n {\n\n _mutex.unlock();\n\n _locked = false;\n\n }\n\n \n\n bool locked ()\n\n {\n\n return _locked;\n\n }\n\n\n\n private:\n\n\n\n const Mutex &\t_mutex;\n\n bool\t\t_locked;\n\n};\n\n\n\n\n\nILMTHREAD_INTERNAL_NAMESPACE_HEADER_EXIT\n\n\n\n#endif // INCLUDED_ILM_THREAD_MUTEX_H\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmThread/IlmThreadMutex.h", "rank": 76, "score": 31.107974832176126 }, { "content": " \n\n Matrix4x4f rollMat = Matrix4x4f(cosRoll,sinRoll,0.f,0.f,\n\n -sinRoll,cosRoll,0.f,0.f,\n\n 0.f,0.f,1.f,0.f,\n\n 0.f,0.f,0.f,1.f);\n\n \n\n return rollMat.product(pitchMat.product(yawMat));\n\n}\n\n\n\nMatrix4x4f Matrix4x4f::rotate(const Vector3f& rotation, const Vector3f& origin) {\n\n return Matrix4x4f::translate(Vector3f(-origin.x, -origin.y, -origin.z)).product(Matrix4x4f::rotate(rotation).product(Matrix4x4f::translate(origin)));\n\n}\n\n\n\nMatrix4x4f Matrix4x4f::constructWorldMat(const Vector3f& position,const Vector3f& scale,const Vector3f& rotation) {\n\n Matrix4x4f translationMat = translate(position);\n\n Matrix4x4f scaleMat = Matrix4x4f::scale(scale);\n\n Matrix4x4f rotationMat = rotate(rotation);\n\n\n\n return scaleMat.product(rotationMat.product(translationMat));\n\n}\n", "file_path": "Src/Math/Matrix.cpp", "rank": 77, "score": 30.878373946863 }, { "content": " return Matrix4x4f::translate(Vector3f(-origin.x, -origin.y, -origin.z)).product(Matrix4x4f::scale(scale).product(Matrix4x4f::translate(origin)));\n\n}\n\n\n\nMatrix4x4f Matrix4x4f::rotate(const Vector3f& rotation) {\n\n float sinPitch = sin(rotation.x);\n\n float sinYaw = sin(rotation.y);\n\n float sinRoll = sin(rotation.z);\n\n float cosPitch = cos(rotation.x);\n\n float cosYaw = cos(rotation.y);\n\n float cosRoll = cos(rotation.z);\n\n \n\n Matrix4x4f pitchMat = Matrix4x4f(1.f,0.f,0.f,0.f,\n\n 0.f,cosPitch,sinPitch,0.f,\n\n 0.f,-sinPitch,cosPitch,0.f,\n\n 0.f,0.f,0.f,1.f);\n\n \n\n Matrix4x4f yawMat = Matrix4x4f(cosYaw,0.f,-sinYaw,0.f,\n\n 0.f,1.f,0.f,0.f,\n\n sinYaw,0.f,cosYaw,0.f,\n\n 0.f,0.f,0.f,1.f);\n", "file_path": "Src/Math/Matrix.cpp", "rank": 78, "score": 30.54266115546882 }, { "content": " // Wheel center is 0,0,0. Push it up to 0,0.5,0 since that's where they should be rotated about.\n\n Vector3f localOrigin = Vector3f(0.f, 0.5f, 0.f);\n\n Matrix4x4f rotationMat = Matrix4x4f::rotate(Vector3f(rotation.x, rotation.y, rotation.z), localOrigin);\n\n // Do tire rotations after. Otherwise the rotations are out of order and the \"moving\" animation of the wheels is on the wrong axis.\n\n Matrix4x4f tireRotateMat = Matrix4x4f::rotate(Vector3f(0.f, tireRotation, 0.f), localOrigin);\n\n rotationMat = rotationMat.product(tireRotateMat);\n\n \n\n worldMatrix = scaleMat.product(rotationMat.product(Matrix4x4f::translate(position).product(originWorldMatrix)));\n\n}\n\n\n\nvoid Wheel::render() {\n\n worldMatrixUniform->setValue(worldMatrix);\n\n colorUniform->setValue(color);\n\n glCullFace(GL_FRONT);\n\n mesh->render();\n\n glCullFace(GL_BACK);\n\n}\n", "file_path": "Src/Primitives/Wheel.cpp", "rank": 79, "score": 30.526362078879245 }, { "content": "}\n\n\n\nvoid Car::addRotationX(float bruh) {\n\n rotation.x += bruh;\n\n for (int i = 0; i < (int)parts.size(); i++) {\n\n parts[i]->addRotationX(bruh);\n\n }\n\n for (int i = 0; i < 4; i++) {\n\n wheels[i]->addRotationX(bruh);\n\n }\n\n}\n\n\n\nvoid Car::addRotationY(float bruh) {\n\n rotation.y += bruh;\n\n}\n\n\n\nfloat Car::getRotationY() const {\n\n return rotation.y;\n\n}\n\n\n", "file_path": "Src/Objects/Car.cpp", "rank": 80, "score": 30.411700251078578 }, { "content": " Vector3f scale;\n\n Vector3f rotation;\n\n float deltaRotationY;\n\n float tireRotation;\n\n\n\n\tbool enableHeadlightsAndTailights;\n\n \n\n Matrix4x4f rotationMatrix;\n\n \n\n Texture* metalTexture;\n\n Texture* tireTexture;\n\n \n\n Shader* spriteShader;\n\n std::vector<Smoke*> smokeParticles;\n\n \n\n std::vector<Cube*> parts;\n\n Wheel* wheels[4];\n\n RectCollider* collider;\n\n \n\n Vector2f getDirectionVector(RectCollider::CollisionDir dir);\n", "file_path": "Src/Objects/Car.h", "rank": 81, "score": 30.23578661027234 }, { "content": "#include <assert.h>\n\n\n\nIEX_INTERNAL_NAMESPACE_SOURCE_ENTER\n\n\n\n\n\nnamespace \n\n{\n\n\tvolatile FpExceptionHandler fpeHandler = 0;\n\n\tvoid fpExc_(int x)\n\n\t{\n\n\t if (fpeHandler != 0)\n\n\t {\n\n\t\tfpeHandler(x, \"\");\n\n\t }\n\n\t else\n\n\t {\n\n\t\tassert(0 != \"Floating point exception\");\n\n\t }\n\n\t}\n\n}\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IexMath/IexMathFpu.cpp", "rank": 82, "score": 30.230367036785395 }, { "content": "", "file_path": "Libraries/FreeImage-3170/Wrapper/FreeImagePlus/FreeImagePlus.h", "rank": 84, "score": 29.617520081286564 }, { "content": "\n\n#include \"IlmBaseConfig.h\"\n\n\n\n//#if !defined(_WIN32) && !defined(_WIN64) && !defined(HAVE_PTHREAD)\n\n#include \"IlmThreadSemaphore.h\"\n\n\n\nILMTHREAD_INTERNAL_NAMESPACE_SOURCE_ENTER\n\n\n\n\n\nSemaphore::Semaphore (unsigned int value) {}\n\nSemaphore::~Semaphore () {}\n\nvoid Semaphore::wait () {}\n\nbool Semaphore::tryWait () {return true;}\n\nvoid Semaphore::post () {}\n\nint Semaphore::value () const {return 0;}\n\n\n\n\n\nILMTHREAD_INTERNAL_NAMESPACE_SOURCE_EXIT\n\n\n\n//#endif\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IlmThread/IlmThreadSemaphore.cpp", "rank": 85, "score": 29.5959272378189 }, { "content": "\n\nvoid Cube::constructWorldMat(const Matrix4x4f& originWorldMatrix) {\n\n Matrix4x4f scaleMat = Matrix4x4f::scale(scale);\n\n Matrix4x4f rotateMat = Matrix4x4f::rotate(rotation, Vector3f(0.f, 0.5f, 0.f));\n\n \n\n worldMatrix = scaleMat.product(Matrix4x4f::translate(position).product(rotateMat.product(originWorldMatrix)));\n\n}\n\n\n\nMatrix4x4f Cube::getWorldMatrix() const {\n\n return worldMatrix;\n\n}\n\n\n\nvoid Cube::update(const Matrix4x4f& originWorldMatrix) {\n\n constructWorldMat(originWorldMatrix);\n\n}\n\n\n\nvoid Cube::render() const {\n\n worldMatUniform->setValue(worldMatrix);\n\n colorUniform->setValue(color);\n\n// glCullFace(GL_FRONT);\n\n mesh->render();\n\n// glCullFace(GL_BACK);\n\n \n\n}\n", "file_path": "Src/Primitives/Cube.cpp", "rank": 86, "score": 29.427808950991917 }, { "content": "#include <cmath>\n\n\n\n#include \"AI.h\"\n\n\n\nAI::AI(Shader* shd, Shader* colliderShd, Shader* spriteShd) {\n\n car = new Car(shd, colliderShd, spriteShd);\n\n \n\n stepsUntilNewTask = 0;\n\n currTaskDirection = Car::WalkInput::None;\n\n \n\n brainFreeze = true;\n\n}\n\n\n\nAI::~AI() {\n\n delete car;\n\n}\n\n\n\nvoid AI::setCarShader(Shader* shd) {\n\n car->setShader(shd);\n\n}\n", "file_path": "Src/Controllers/AI.cpp", "rank": 87, "score": 29.42600192512498 }, { "content": "", "file_path": "Libraries/FreeImage-3170/Wrapper/FreeImagePlus/FreeImagePlus.h", "rank": 88, "score": 29.07584268922587 }, { "content": "", "file_path": "Libraries/FreeImage-3170/Source/FreeImage/tmoFattal02.cpp", "rank": 89, "score": 28.854373341838404 }, { "content": "\n\n#include \"FreeImage.h\"\n\n#include \"Utilities.h\"\n\n\n\n// ----------------------------------------------------------\n\n// internal conversions X to 4 bits\n\n// ----------------------------------------------------------\n\n\n\nvoid DLL_CALLCONV\n\nFreeImage_ConvertLine1To4(BYTE *target, BYTE *source, int width_in_pixels) {\n\n\tBOOL hinibble = TRUE;\n\n\tfor (int cols = 0; cols < width_in_pixels; cols++){\n\n\t\tif (hinibble == TRUE){\n\n\t\t\ttarget[cols >> 1] = ((source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0 ? 15 : 0) << 4;\n\n\t\t} \n\n\t\telse {\n\n\t\t\ttarget[cols >> 1] |= ((source[cols >> 3] & (0x80 >> (cols & 0x07))) != 0 ? 15 : 0);\n\n\t\t}\n\n\n\n\t\thinibble = !hinibble;\n", "file_path": "Libraries/FreeImage-3170/Source/FreeImage/Conversion4.cpp", "rank": 90, "score": 28.448981845558436 }, { "content": " std::vector<int> prims = {\n\n 0, 1, 2,\n\n 0, 3, 1\n\n };\n\n mesh->setGeometry(verts, prims);\n\n\n\n modelMatrixUniform = shd->getMat4Uniform(\"modelMatrix\");\n\n scaleUniform = shd->getVec2fUniform(\"scale\");\n\n rotationMatrixUniform = shd->getMat4Uniform(\"rotationMatrix\");\n\n colorUniform = shd->getVec4fUniform(\"spriteColor\");\n\n\n\n scale = Vector2f::one;\n\n\trotation = 0.f;\n\n}\n\n\n\nSprite::~Sprite() {\n\n delete mesh;\n\n}\n\n\n\nvoid Sprite::setScale(float scale) {\n", "file_path": "Src/Graphics/Sprite.cpp", "rank": 91, "score": 28.413751909406635 }, { "content": " deltaRotationY = tireRotation * 0.05f;\n\n } else if ((input & WalkInput::Backward) != WalkInput::None) {\n\n deltaRotationY = tireRotation * -0.05f;\n\n }\n\n\n\n acceleration = targetDir.normalize().multiply(speed);\n\n Vector3f particlePosition = position;\n\n smokeParticles.push_back(new Smoke(spriteShader, particlePosition));\n\n}\n\n\n\nvoid Car::updateVelocity(Car::WalkInput input, float timestep) {\n\n velocity = velocity.add(acceleration);\n\n\n\n if (input == WalkInput::None) {\n\n float timestepFriction = FRICTION * timestep;\n\n\n\n if (!MathUtil::eqFloats(velocity.x, 0.f) || !MathUtil::eqFloats(velocity.y, 0.f)) {\n\n float velocityMagnitude = velocity.length();\n\n float reducedLength = MathUtil::maxFloat(velocityMagnitude - timestepFriction, 0.f);\n\n velocity = velocity.multiply(reducedLength / velocityMagnitude);\n", "file_path": "Src/Objects/Car.cpp", "rank": 92, "score": 28.382653697739702 }, { "content": "", "file_path": "Libraries/FreeImage-3170/Wrapper/FreeImagePlus/FreeImagePlus.h", "rank": 94, "score": 28.153009283434848 }, { "content": " const bool forcePositiveDeterminant);\n\ntemplate IMATH_EXPORT void jacobiSVD (const IMATH_INTERNAL_NAMESPACE::Matrix44<double>& A,\n\n IMATH_INTERNAL_NAMESPACE::Matrix44<double>& U,\n\n IMATH_INTERNAL_NAMESPACE::Vec4<double>& S,\n\n IMATH_INTERNAL_NAMESPACE::Matrix44<double>& V,\n\n const double tol,\n\n const bool forcePositiveDeterminant);\n\n\n\nnamespace\n\n{\n\n\n\ntemplate <int j, int k, typename TM>\n\ninline \n\nvoid\n\njacobiRotateRight (TM& A,\n\n const typename TM::BaseType s,\n\n const typename TM::BaseType tau)\n\n{\n\n typedef typename TM::BaseType T;\n\n\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/Imath/ImathMatrixAlgo.cpp", "rank": 95, "score": 27.986659022039113 }, { "content": "void Car::addRotationZ(float bruh) {\n\n rotation.z += bruh;\n\n for (int i = 0; i < (int)parts.size(); i++) {\n\n parts[i]->addRotationZ(bruh);\n\n }\n\n for (int i = 0; i < 4; i++) {\n\n wheels[i]->addRotationZ(bruh);\n\n }\n\n}\n\n\n\nvoid Car::toggleHeadlightsTaillights() {\n\n\tenableHeadlightsAndTailights = !enableHeadlightsAndTailights;\n\n}\n\n\n\nVector2f Car::getDirectionVector(RectCollider::CollisionDir dir) {\n\n float sinAngle = std::sin(rotation.y);\n\n float cosAngle = std::cos(rotation.y);\n\n\n\n Vector2f retval;\n\n switch (dir) {\n", "file_path": "Src/Objects/Car.cpp", "rank": 96, "score": 27.955487829106332 }, { "content": "\t\t\tmemoryStream.Position = (newPosition <= memoryStream.Length) ? newPosition : memoryStream.Length;\n\n\t\t\treturn 0;\n\n\t\t}\n\n\n\n\t\t// No write-support\n\n\t\tpublic override void SetLength(long value)\n\n\t\t{\n\n\t\t\tthrow new Exception(\"The method or operation is not implemented.\");\n\n\t\t}\n\n\n\n\t\t// No write-support\n\n\t\tpublic override void Write(byte[] buffer, int offset, int count)\n\n\t\t{\n\n\t\t\tthrow new Exception(\"The method or operation is not implemented.\");\n\n\t\t}\n\n\n\n\t\tpublic void Reset()\n\n\t\t{\n\n\t\t\tcheckDisposed();\n\n\t\t\tPosition = 0;\n", "file_path": "Libraries/FreeImage-3170/Wrapper/FreeImage.NET/cs/UnitTest/FreeImage.cs", "rank": 97, "score": 27.94703839879059 }, { "content": "\n\nvoid\n\nsetFpExceptions( int )\n\n{\n\n}\n\n\n\n\n\nvoid\n\nsetFpExceptionHandler (FpExceptionHandler handler)\n\n{\n\n // improve floating point exception handling nanoscopically above \"nothing at all\"\n\n fpeHandler = handler;\n\n signal(SIGFPE, fpExc_);\n\n}\n\n\n\nint\n\nfpExceptions()\n\n{\n\n return 0;\n\n}\n", "file_path": "Libraries/FreeImage-3170/Source/OpenEXR/IexMath/IexMathFpu.cpp", "rank": 98, "score": 27.891571354768736 }, { "content": " // Returns whether enough time is left on the accumulator for another tick.\n\n bool tickReady();\n\n // Subtracts one tick from the accumlator.\n\n void subtractTick();\n\n // Returns the elapsed seconds since the last call to this function.\n\n double getElapsedSeconds();\n\n // Returns the total elapsed time since the object's creation.\n\n double getTotalElapsedTime();\n\n};\n\n\n\n#endif // TIMING_H_INCLUDED\n", "file_path": "Src/Utils/Timing.h", "rank": 99, "score": 27.582673404583915 } ]
C++
StageProc2F64Neon.hpp
unevens/hiir
4589fedb4d08b899514cb605ccd7418bf262ab18
#if ! defined (hiir_StageProc2F64Neon_CODEHEADER_INCLUDED) #define hiir_StageProc2F64Neon_CODEHEADER_INCLUDED #include "hiir/StageDataNeonV2F64.h" namespace hiir { template <> inline void StageProc2F64Neon <1>::process_sample_pos (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - 1; const float64x2_t tmp_0 = vmlaq_f64 ( vld1q_f64 (stage_arr [cnt - 2]._mem ), spl_0 - vld1q_f64 (stage_arr [cnt ]._mem ), vld1q_f64 (stage_arr [cnt ]._coef) ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); vst1q_f64 (stage_arr [cnt ]._mem, tmp_0); spl_0 = tmp_0; } template <> inline void StageProc2F64Neon <0>::process_sample_pos (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2; vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); } template <int REMAINING> void StageProc2F64Neon <REMAINING>::process_sample_pos (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - REMAINING; const float64x2_t tmp_0 = vmlaq_f64 ( vld1q_f64 (stage_arr [cnt - 2]._mem ), spl_0 - vld1q_f64 (stage_arr [cnt ]._mem ), vld1q_f64 (stage_arr [cnt ]._coef) ); const float64x2_t tmp_1 = vmlaq_f64 ( vld1q_f64 (stage_arr [cnt - 1]._mem ), spl_1 - vld1q_f64 (stage_arr [cnt + 1]._mem ), vld1q_f64 (stage_arr [cnt + 1]._coef) ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); spl_0 = tmp_0; spl_1 = tmp_1; StageProc2F64Neon <REMAINING - 2>::process_sample_pos ( nbr_coefs, spl_0, spl_1, stage_arr ); } template <> inline void StageProc2F64Neon <1>::process_sample_neg (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - 1; float64x2_t tmp_0 = spl_0; tmp_0 += vld1q_f64 (stage_arr [cnt ]._mem ); tmp_0 *= vld1q_f64 (stage_arr [cnt ]._coef); tmp_0 -= vld1q_f64 (stage_arr [cnt - 2]._mem ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); vst1q_f64 (stage_arr [cnt ]._mem, tmp_0); spl_0 = tmp_0; } template <> inline void StageProc2F64Neon <0>::process_sample_neg (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2; vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); } template <int REMAINING> void StageProc2F64Neon <REMAINING>::process_sample_neg (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - REMAINING; float64x2_t tmp_0 = spl_0; tmp_0 += vld1q_f64 (stage_arr [cnt ]._mem ); tmp_0 *= vld1q_f64 (stage_arr [cnt ]._coef); tmp_0 -= vld1q_f64 (stage_arr [cnt - 2]._mem ); float64x2_t tmp_1 = spl_1; tmp_1 += vld1q_f64 (stage_arr [cnt + 1]._mem ); tmp_1 *= vld1q_f64 (stage_arr [cnt + 1]._coef); tmp_1 -= vld1q_f64 (stage_arr [cnt - 1]._mem ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); spl_0 = tmp_0; spl_1 = tmp_1; StageProc2F64Neon <REMAINING - 2>::process_sample_neg ( nbr_coefs, spl_0, spl_1, stage_arr ); } } #endif
#if ! defined (hiir_StageProc2F64Neon_CODEHEADER_INCLUDED) #define hiir_StageProc2F64Neon_CODEHEADER_INCLUDED #include "hiir/StageDataNeonV2F64.h" namespace hiir { template <> inline void StageProc2F64Neon <1>::process_sample_pos (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, St
aq_f64 ( vld1q_f64 (stage_arr [cnt - 2]._mem ), spl_0 - vld1q_f64 (stage_arr [cnt ]._mem ), vld1q_f64 (stage_arr [cnt ]._coef) ); const float64x2_t tmp_1 = vmlaq_f64 ( vld1q_f64 (stage_arr [cnt - 1]._mem ), spl_1 - vld1q_f64 (stage_arr [cnt + 1]._mem ), vld1q_f64 (stage_arr [cnt + 1]._coef) ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); spl_0 = tmp_0; spl_1 = tmp_1; StageProc2F64Neon <REMAINING - 2>::process_sample_pos ( nbr_coefs, spl_0, spl_1, stage_arr ); } template <> inline void StageProc2F64Neon <1>::process_sample_neg (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - 1; float64x2_t tmp_0 = spl_0; tmp_0 += vld1q_f64 (stage_arr [cnt ]._mem ); tmp_0 *= vld1q_f64 (stage_arr [cnt ]._coef); tmp_0 -= vld1q_f64 (stage_arr [cnt - 2]._mem ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); vst1q_f64 (stage_arr [cnt ]._mem, tmp_0); spl_0 = tmp_0; } template <> inline void StageProc2F64Neon <0>::process_sample_neg (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2; vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); } template <int REMAINING> void StageProc2F64Neon <REMAINING>::process_sample_neg (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - REMAINING; float64x2_t tmp_0 = spl_0; tmp_0 += vld1q_f64 (stage_arr [cnt ]._mem ); tmp_0 *= vld1q_f64 (stage_arr [cnt ]._coef); tmp_0 -= vld1q_f64 (stage_arr [cnt - 2]._mem ); float64x2_t tmp_1 = spl_1; tmp_1 += vld1q_f64 (stage_arr [cnt + 1]._mem ); tmp_1 *= vld1q_f64 (stage_arr [cnt + 1]._coef); tmp_1 -= vld1q_f64 (stage_arr [cnt - 1]._mem ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); spl_0 = tmp_0; spl_1 = tmp_1; StageProc2F64Neon <REMAINING - 2>::process_sample_neg ( nbr_coefs, spl_0, spl_1, stage_arr ); } } #endif
ageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - 1; const float64x2_t tmp_0 = vmlaq_f64 ( vld1q_f64 (stage_arr [cnt - 2]._mem ), spl_0 - vld1q_f64 (stage_arr [cnt ]._mem ), vld1q_f64 (stage_arr [cnt ]._coef) ); vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); vst1q_f64 (stage_arr [cnt ]._mem, tmp_0); spl_0 = tmp_0; } template <> inline void StageProc2F64Neon <0>::process_sample_pos (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2; vst1q_f64 (stage_arr [cnt - 2]._mem, spl_0); vst1q_f64 (stage_arr [cnt - 1]._mem, spl_1); } template <int REMAINING> void StageProc2F64Neon <REMAINING>::process_sample_pos (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr) { const int cnt = nbr_coefs + 2 - REMAINING; const float64x2_t tmp_0 = vml
random
[ { "content": "class StageProc2F64Neon\n\n{\n\n\tstatic_assert (REMAINING >= 0, \"REMAINING must be >= 0.\");\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\npublic:\n\n\n\n\tstatic hiir_FORCEINLINE void\n\n\t process_sample_pos (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr);\n\n\tstatic hiir_FORCEINLINE void\n\n\t process_sample_neg (const int nbr_coefs, float64x2_t &spl_0, float64x2_t &spl_1, StageDataNeonV2F64 *stage_arr);\n\n\n\n\n\n\n\n/*\\\\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\nprotected:\n\n\n\n\n", "file_path": "StageProc2F64Neon.h", "rank": 0, "score": 29585.13991235672 }, { "content": "# HIIR\n\n\n\nThis used to be a fork of the [HIIR library by Laurent De Soras](http://ldesoras.free.fr/prod.html), *\"an oversampling and Hilbert transform library in C++\"*, with some new files that add support for double precision floating point numbers and AVX instructions, making the library able to work with:\n\n\n\n- 8 interleaved channels of single precision floating point data (using AVX instructions).\n\n- 4 interleaved channels of double precision floating point data (using AVX instructions).\n\n- 2 interleaved channels of double precision floating point data (using SSE2 instructions).\n\n\n\nThe original HIIR library is already able to work with:\n\n\n\n- 4 interleaved channels of single precision floating point data (using SSE or Neon instructions), see `Upsampler2x4xSse.hpp` and `Upsampler2x4xNeon.hpp`.\n\n\n\nAs of March 2020 this functionality has been merged in the official release of HIIR, version 1.30, which also supports \n\n\n\n- 16 interleaved channels of single precision floating point data (using AVX512 instructions).\n\n- 8 interleaved channels of double precision floating point data (using AVX512 instructions).\n\n\n\nThis repository has been updated to version 1.30, but is header-only, and does not contain the `test` folder.\n\n\n\nAs of April 2021 I added support for double precision floating point data using Neon on ARM AArch64, making the library able to work with:\n\n\n\n- 2 interleaved channels of double precision floating point data (using Neon instructions).\n\n\n\nFor usage instructions see the original library readme: `readme.txt`.\n\n\n", "file_path": "README.md", "rank": 1, "score": 25348.735893446243 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageDataNeonV4.h\"\n\n#include \"hiir/fnc_neon.h\"\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <>\n\ninline void\tStageProc4Neon <1>::process_sample_pos (const int nbr_coefs, float32x4_t &spl_0, float32x4_t &spl_1, StageDataNeonV4 *stage_arr)\n\n{\n", "file_path": "StageProc4Neon.hpp", "rank": 2, "score": 25.443315922849226 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageDataNeonV2.h\"\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <int CUR>\n\nvoid\tStageProcNeonV2 <CUR>::process_sample_pos (float32x2_t &x, StageDataNeonV2 *stage_ptr)\n", "file_path": "StageProcNeonV2.hpp", "rank": 4, "score": 22.540452424008034 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageDataNeonV4.h\"\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <int CUR>\n\nvoid\tStageProcNeonV4 <CUR>::process_sample_pos (StageDataNeonV4 *stage_ptr, float32x4_t &y, float32x4_t &mem)\n", "file_path": "StageProcNeonV4.hpp", "rank": 5, "score": 22.212025727578858 }, { "content": "#include \"hiir/def.h\"\n\n#include \"hiir/StageDataSse.h\"\n\n\n\n#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPiSse.h", "rank": 6, "score": 21.988393765347876 }, { "content": "#include \"hiir/StageDataSse.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2xSseOld.h", "rank": 7, "score": 21.84829006028331 }, { "content": "#include \"hiir/StageDataSse.h\"\n\n\n\n#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2xSseOld.h", "rank": 8, "score": 21.79881671606401 }, { "content": "\n\n#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x8Avx.h", "rank": 9, "score": 21.770030981194243 }, { "content": "\n\n#include <immintrin.h> \n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x4F64Avx.h", "rank": 10, "score": 21.770030981194243 }, { "content": "#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x16Avx512.h", "rank": 11, "score": 21.770030981194243 }, { "content": "#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x4Sse.h", "rank": 12, "score": 21.770030981194243 }, { "content": "#include <immintrin.h> \n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x8F64Avx512.h", "rank": 13, "score": 21.770030981194243 }, { "content": "#include <immintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x16Avx512.h", "rank": 14, "score": 21.770030981194243 }, { "content": "\n\n#include <emmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x2F64Sse2.h", "rank": 15, "score": 21.770030981194243 }, { "content": "\n\n#include <immintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x8Avx.h", "rank": 16, "score": 21.770030981194243 }, { "content": "\n\n#include <immintrin.h> \n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x4F64Avx.h", "rank": 17, "score": 21.770030981194243 }, { "content": "#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x4Sse.h", "rank": 18, "score": 21.770030981194243 }, { "content": "#include <immintrin.h> \n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x8F64Avx512.h", "rank": 19, "score": 21.770030981194243 }, { "content": "\n\n#include <emmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x2F64Sse2.h", "rank": 20, "score": 21.770030981194243 }, { "content": "#include \"hiir/def.h\"\n\n#include \"hiir/StageDataNeonV4.h\"\n\n\n\n#include <arm_neon.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPiNeon.h", "rank": 21, "score": 21.64229625390616 }, { "content": "#include \"hiir/StageDataNeonV4.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2xNeonOld.h", "rank": 22, "score": 21.639747587006106 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataF64Sse2.h\"\n\n\n\n#include <emmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2xF64Sse2.h", "rank": 23, "score": 21.61989645707728 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataF64Sse2.h\"\n\n\n\n#include <emmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2xF64Sse2.h", "rank": 24, "score": 21.61989645707728 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataF64Sse2.h\"\n\n\n\n#include <emmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPiF64Sse2.h", "rank": 25, "score": 21.61989645707728 }, { "content": "#include <arm_neon.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x4Neon.h", "rank": 26, "score": 21.534529607376566 }, { "content": "#include <arm_neon.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x4Neon.h", "rank": 27, "score": 21.534529607376566 }, { "content": "\n\n#include <arm_neon.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x2F64Neon.h", "rank": 28, "score": 21.534529607376566 }, { "content": "\n\n#include <arm_neon.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x2F64Neon.h", "rank": 29, "score": 21.534529607376566 }, { "content": "\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2xNeonOld.h", "rank": 30, "score": 21.52003423578902 }, { "content": "*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_Downsampler2xSse_HEADER_INCLUDED)\n\n#define hiir_Downsampler2xSse_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataSse.h\"\n\n\n\n#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2xSse.h", "rank": 31, "score": 20.3753192096851 }, { "content": "*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_Upsampler2xSse_HEADER_INCLUDED)\n\n#define hiir_Upsampler2xSse_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataSse.h\"\n\n\n\n#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2xSse.h", "rank": 32, "score": 20.3753192096851 }, { "content": "#if ! defined (hiir_StageProc3dnow_HEADER_INCLUDED)\n\n#define hiir_StageProc3dnow_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int CUR>\n", "file_path": "StageProc3dnow.h", "rank": 33, "score": 20.061198051593042 }, { "content": "\n\n\n\n#if ! defined (hiir_Upsampler2x3dnow_HEADER_INCLUDED)\n\n#define hiir_Upsampler2x3dnow_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageData3dnow.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2x3dnow.h", "rank": 34, "score": 20.035653180413256 }, { "content": "\n\n\n\n#if ! defined (hiir_Downsampler2x3dnow_HEADER_INCLUDED)\n\n#define hiir_Downsampler2x3dnow_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageData3dnow.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2x3dnow.h", "rank": 35, "score": 20.035653180413256 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_PhaseHalfPi4Sse_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi4Sse_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataSse.h\"\n\n\n\n#include <xmmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi4Sse.h", "rank": 36, "score": 19.90135028610223 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_PhaseHalfPi8Avx_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi8Avx_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataAvx.h\"\n\n\n\n#include <immintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi8Avx.h", "rank": 37, "score": 19.901350286102225 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_PhaseHalfPi16Avx512_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi16Avx512_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataAvx512.h\"\n\n\n\n#include <immintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi16Avx512.h", "rank": 38, "score": 19.90135028610223 }, { "content": "*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_Downsampler2xNeon_HEADER_INCLUDED)\n\n#define hiir_Downsampler2xNeon_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma warning (4 : 4250)\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataNeonV2.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Downsampler2xNeon.h", "rank": 39, "score": 19.79945865761544 }, { "content": "*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_Upsampler2xNeon_HEADER_INCLUDED)\n\n#define hiir_Upsampler2xNeon_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma warning (4 : 4250)\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageDataNeonV2.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "Upsampler2xNeon.h", "rank": 40, "score": 19.725623583670725 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_PhaseHalfPi4Neon_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi4Neon_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataNeonV4.h\"\n\n\n\n#include <arm_neon.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi4Neon.h", "rank": 41, "score": 19.675064735427593 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#if ! defined (hiir_StageProc_HEADER_INCLUDED)\n\n#define hiir_StageProc_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int REMAINING, typename DT>\n", "file_path": "StageProcFpu.h", "rank": 42, "score": 19.666428394720278 }, { "content": "\n\n\n\n\n\n#if ! defined (hiir_PhaseHalfPi3dnow_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi3dnow_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageData3dnow.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi3dnow.h", "rank": 43, "score": 19.570330998839864 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_PhaseHalfPi4F64Avx_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi4F64Avx_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataF64Avx.h\"\n\n\n\n#include <immintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi4F64Avx.h", "rank": 44, "score": 19.564439984102993 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_PhaseHalfPi2F64Sse2_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi2F64Sse2_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataF64Sse2.h\"\n\n\n\n#include <emmintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi2F64Sse2.h", "rank": 45, "score": 19.564439984102993 }, { "content": "\n\n*Tab=3***********************************************************************/\n\n\n\n\n\n\n\n#pragma once\n\n#if ! defined (hiir_PhaseHalfPi8F64Avx512_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPi8F64Avx512_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n#include \"hiir/StageDataF64Avx512.h\"\n\n\n\n#include <immintrin.h>\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC>\n", "file_path": "PhaseHalfPi8F64Avx512.h", "rank": 46, "score": 19.564439984102993 }, { "content": "\n\n\n\n#if ! defined (hiir_Downsampler2xFpuTpl_HEADER_INCLUDED)\n\n#define hiir_Downsampler2xFpuTpl_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC, typename DT>\n", "file_path": "Downsampler2xFpuTpl.h", "rank": 47, "score": 19.481197687341254 }, { "content": "\n\n\n\n#if ! defined (hiir_Upsampler2xFpuTpl_HEADER_INCLUDED)\n\n#define hiir_Upsampler2xFpuTpl_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC, typename DT>\n", "file_path": "Upsampler2xFpuTpl.h", "rank": 48, "score": 19.481197687341254 }, { "content": "\n\n\n\n\n\n#if ! defined (hiir_PhaseHalfPiFpuTpl_HEADER_INCLUDED)\n\n#define hiir_PhaseHalfPiFpuTpl_HEADER_INCLUDED\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma once\n\n\t#pragma warning (4 : 4250) // \"Inherits via dominance.\"\n\n#endif\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n\n\n#include <array>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\ntemplate <int NC, typename DT>\n", "file_path": "PhaseHalfPiFpuTpl.h", "rank": 49, "score": 19.0138513721208 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <int CUR>\n\nvoid StageProcSseV2 <CUR>::process_sample_pos (__m128 &x, StageDataSse *stage_arr)\n\n{\n\n StageProcSseV2 <CUR>::process_sample_pos_rec (x, stage_arr);\n\n\t_mm_store_ps (stage_arr [CUR]._mem, x);\n", "file_path": "StageProcSseV2.hpp", "rank": 50, "score": 18.34142919306666 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <int CUR>\n\nvoid StageProcF64Sse2 <CUR>::process_sample_pos (__m128d &x, StageDataF64Sse2 *stage_arr)\n\n{\n\n StageProcF64Sse2 <CUR>::process_sample_pos_rec (x, stage_arr);\n\n\t_mm_store_pd (stage_arr [CUR]._mem, x);\n", "file_path": "StageProcF64Sse2.hpp", "rank": 51, "score": 18.18338353266393 }, { "content": "#define hiir_fnc_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_fnc_CODEHEADER_INCLUDED)\n\n#define hiir_fnc_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include <cassert>\n\n#include <cmath>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\nint\tround_int (double x)\n", "file_path": "fnc.hpp", "rank": 52, "score": 18.076428658442364 }, { "content": "#define hiir_StageProc3dnow_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_StageProc3dnow_CODEHEADER_INCLUDED)\n\n#define hiir_StageProc3dnow_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageData3dnow.h\"\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma inline_depth (255)\n\n#endif\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n", "file_path": "StageProc3dnow.hpp", "rank": 53, "score": 16.659528462073823 }, { "content": "#define hiir_StageProc_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_StageProc_CODEHEADER_INCLUDED)\n\n#define hiir_StageProc_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma inline_depth (255)\n\n#endif\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n", "file_path": "StageProcFpu.hpp", "rank": 54, "score": 16.634317467524454 }, { "content": "#define hiir_StageProc4Sse_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_StageProc4Sse_CODEHEADER_INCLUDED)\n\n#define hiir_StageProc4Sse_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageDataSse.h\"\n\n\n\n\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma inline_depth (255)\n\n#endif\n\n\n\n\n\n\n\nnamespace hiir\n", "file_path": "StageProc4Sse.hpp", "rank": 55, "score": 16.2828042848648 }, { "content": "#define hiir_StageProc16Avx512_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_StageProc16Avx512_CODEHEADER_INCLUDED)\n\n#define hiir_StageProc16Avx512_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageDataAvx512.h\"\n\n\n\n\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma inline_depth (255)\n\n#endif\n\n\n\n\n\n\n\nnamespace hiir\n", "file_path": "StageProc16Avx512.hpp", "rank": 56, "score": 16.282804284864795 }, { "content": "#define hiir_StageProcSseV4_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_StageProcSseV4_CODEHEADER_INCLUDED)\n\n#define hiir_StageProcSseV4_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageDataSse.h\"\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma inline_depth (255)\n\n#endif\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n", "file_path": "StageProcSseV4.hpp", "rank": 57, "score": 16.013997006912845 }, { "content": "#define hiir_StageProc8F64Avx512_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_StageProc8F64Avx512_CODEHEADER_INCLUDED)\n\n#define hiir_StageProc8F64Avx512_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageDataF64Avx512.h\"\n\n\n\n\n\n\n\n#if defined (_MSC_VER)\n\n\t#pragma inline_depth (255)\n\n#endif\n\n\n\n\n\n\n\nnamespace hiir\n", "file_path": "StageProc8F64Avx512.hpp", "rank": 58, "score": 15.926845757289868 }, { "content": "\n\nvoid storea (float *ptr, float32x2_t x)\n\n{\n\n vst1_f32 (ptr, x);\n\n}\n\n\n\n\n\n\n\nvoid storeu (float *ptr, float32x2_t x)\n\n{\n\n vst1_u8 (reinterpret_cast <uint8_t *> (ptr), vreinterpret_u8_f32 (x));\n\n}\n\n\n\n\n\n\n\n} // namespace hiir\n\n\n\n\n\n\n\n#endif // hiir_fnc_neon_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n", "file_path": "fnc_neon.hpp", "rank": 59, "score": 15.263877312524837 }, { "content": "\t\tint j = -1;\n\n\t\tdouble acc = 0;\n\n\t\tdouble q_i2;\n\n\t\tdo\n\n\t\t{\n\n\t\t\tq_i2 = hiir::ipowp(q, i * i);\n\n\t\t\tq_i2 *= cos(i * 2 * c * hiir::PI / order) * j;\n\n\t\t\tacc += q_i2;\n\n\n\n\t\t\tj = -j;\n\n\t\t\t++i;\n\n\t\t} while (fabs(q_i2) > 1e-100);\n\n\n\n\t\treturn acc;\n\n\t}\n\n\n\n\n\n\n\n}\t// namespace hiir\n\n\n\n\n\n\n\n#endif // hiir_PolyphaseIir2Designer_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n", "file_path": "PolyphaseIir2Designer.h", "rank": 60, "score": 15.25629465564544 }, { "content": "namespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <>\n\nhiir_FORCEINLINE void\tStageProc8Avx <1>::process_sample_pos (const int nbr_coefs, __m256 &spl_0, __m256 &spl_1, StageDataAvx *stage_arr)\n\n{\n\n\tconst int cnt = nbr_coefs + 2 - 1;\n\n\n\n\tconst __m256 tmp_0 = _mm256_add_ps (\n\n\t\t_mm256_mul_ps (\n\n\t\t\t_mm256_sub_ps (spl_0, _mm256_load_ps (stage_arr [cnt ]._mem)),\n\n\t\t\t_mm256_load_ps (stage_arr [cnt ]._coef)\n\n\t\t),\n\n\t\t_mm256_load_ps (stage_arr [cnt - 2]._mem)\n", "file_path": "StageProc8Avx.hpp", "rank": 61, "score": 15.06805868298717 }, { "content": "namespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <>\n\nhiir_FORCEINLINE void\tStageProc4F64Avx <1>::process_sample_pos (const int nbr_coefs, __m256d &spl_0, __m256d &spl_1, StageDataF64Avx *stage_arr)\n\n{\n\n\tconst int cnt = nbr_coefs + 2 - 1;\n\n\n\n\tconst __m256d tmp_0 = _mm256_add_pd (\n\n\t\t_mm256_mul_pd (\n\n\t\t\t_mm256_sub_pd (spl_0, _mm256_load_pd (stage_arr [cnt ]._mem)),\n\n\t\t\t_mm256_load_pd (stage_arr [cnt ]._coef)\n\n\t\t),\n\n\t\t_mm256_load_pd (stage_arr [cnt - 2]._mem)\n", "file_path": "StageProc4F64Avx.hpp", "rank": 62, "score": 14.879965314589112 }, { "content": "namespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n\ntemplate <>\n\nhiir_FORCEINLINE void\tStageProc2F64Sse2 <1>::process_sample_pos (const int nbr_coefs, __m128d &spl_0, __m128d &spl_1, StageDataF64Sse2 *stage_arr)\n\n{\n\n\tconst int cnt = nbr_coefs + 2 - 1;\n\n\n\n\tconst __m128d tmp_0 = _mm_add_pd (\n\n\t\t_mm_mul_pd (\n\n\t\t\t_mm_sub_pd (spl_0, _mm_load_pd (stage_arr [cnt ]._mem)),\n\n\t\t\t_mm_load_pd (stage_arr [cnt ]._coef)\n\n\t\t),\n\n\t\t_mm_load_pd (stage_arr [cnt - 2]._mem)\n", "file_path": "StageProc2F64Sse2.hpp", "rank": 63, "score": 14.879965314589112 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n\n\n#include <xmmintrin.h>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n", "file_path": "StageProcSseV2.h", "rank": 64, "score": 14.216050795489066 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/def.h\"\n\n\n\n#include <emmintrin.h>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n", "file_path": "StageProcF64Sse2.h", "rank": 65, "score": 14.216050795489066 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageProc4Neon.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x4Neon.hpp", "rank": 66, "score": 14.03407809862188 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageProc4Neon.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPi4Neon.hpp", "rank": 67, "score": 14.03407809862188 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageProc4Neon.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x4Neon.hpp", "rank": 68, "score": 14.03407809862188 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageProcNeonV4.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPiNeon.hpp", "rank": 69, "score": 13.946388553051277 }, { "content": "template <>\n\ninline void\tStageProc4Neon <1>::process_sample_neg (const int nbr_coefs, float32x4_t &spl_0, float32x4_t &spl_1, StageDataNeonV4 *stage_arr)\n\n{\n\n\tconst int cnt = nbr_coefs + 2 - 1;\n\n\n\n\tfloat32x4_t tmp_0 = spl_0;\n\n\ttmp_0 += load4a (stage_arr [cnt ]._mem );\n\n\ttmp_0 *= load4a (stage_arr [cnt ]._coef);\n\n\ttmp_0 -= load4a (stage_arr [cnt - 2]._mem );\n\n\n\n\tstorea (stage_arr [cnt - 2]._mem, spl_0);\n\n\tstorea (stage_arr [cnt - 1]._mem, spl_1);\n\n\tstorea (stage_arr [cnt ]._mem, tmp_0);\n\n\n\n\tspl_0 = tmp_0;\n\n}\n\n\n\ntemplate <>\n\ninline void\tStageProc4Neon <0>::process_sample_neg (const int nbr_coefs, float32x4_t &spl_0, float32x4_t &spl_1, StageDataNeonV4 *stage_arr)\n\n{\n", "file_path": "StageProc4Neon.hpp", "rank": 70, "score": 13.935509350998231 }, { "content": "\n\n\n\n} // namespace hiir\n\n\n\n\n\n\n\n#include \"hiir/Upsampler2x3dnow.hpp\"\n\n\n\n\n\n\n\n#endif // hiir_Upsampler2x3dnow_HEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n", "file_path": "Upsampler2x3dnow.h", "rank": 71, "score": 13.869872982663773 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageProcNeonV2.h\"\n\n\n\n#include <arm_neon.h>\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2xNeon.hpp", "rank": 72, "score": 13.837167309489233 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/fnc_neon.h\"\n\n#include \"hiir/StageProcNeonV4.h\"\n\n\n\n#include <arm_neon.h>\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2xNeonOld.hpp", "rank": 73, "score": 13.837167309489232 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc4Sse.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x4Sse.hpp", "rank": 74, "score": 13.780738019386785 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc16Avx512.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPi16Avx512.hpp", "rank": 75, "score": 13.780738019386785 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc16Avx512.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x16Avx512.hpp", "rank": 76, "score": 13.780738019386785 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc8Avx.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x8Avx.hpp", "rank": 77, "score": 13.780738019386785 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc8Avx.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPi8Avx.hpp", "rank": 78, "score": 13.780738019386787 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc4Sse.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x4Sse.hpp", "rank": 79, "score": 13.780738019386785 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc16Avx512.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x16Avx512.hpp", "rank": 80, "score": 13.780738019386787 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc8Avx.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x8Avx.hpp", "rank": 81, "score": 13.780738019386785 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc4Sse.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPi4Sse.hpp", "rank": 82, "score": 13.780738019386787 }, { "content": "#define hiir_Downsampler2x3dnow_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_Downsampler2x3dnow_CODEHEADER_INCLUDED)\n\n#define hiir_Downsampler2x3dnow_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc3dnow.h\"\n\n\n\n#include <mm3dnow.h>\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n", "file_path": "Downsampler2x3dnow.hpp", "rank": 83, "score": 13.757084952263575 }, { "content": "#define hiir_Upsampler2x3dnow_CURRENT_CODEHEADER\n\n\n\n#if ! defined (hiir_Upsampler2x3dnow_CODEHEADER_INCLUDED)\n\n#define\thiir_Upsampler2x3dnow_CODEHEADER_INCLUDED\n\n\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc3dnow.h\"\n\n\n\n#include <mm3dnow.h>\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x3dnow.hpp", "rank": 84, "score": 13.69417621895462 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProcSseV2.h\"\n\n\n\n#include <xmmintrin.h>\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2xSse.hpp", "rank": 85, "score": 13.681688787128 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc8F64Avx512.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x8F64Avx512.hpp", "rank": 86, "score": 13.67656335989874 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc4F64Avx.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPi4F64Avx.hpp", "rank": 87, "score": 13.67656335989874 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc2F64Sse2.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPi2F64Sse2.hpp", "rank": 88, "score": 13.67656335989874 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProcSseV2.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2xSse.hpp", "rank": 89, "score": 13.67656335989874 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc2F64Sse2.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x2F64Sse2.hpp", "rank": 90, "score": 13.67656335989874 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc8F64Avx512.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x8F64Avx512.hpp", "rank": 91, "score": 13.67656335989874 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProcF64Sse2.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2xF64Sse2.hpp", "rank": 92, "score": 13.67656335989874 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc4F64Avx.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x4F64Avx.hpp", "rank": 93, "score": 13.67656335989874 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc2F64Neon.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2x2F64Neon.hpp", "rank": 94, "score": 13.67656335989874 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProcF64Sse2.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Upsampler2xF64Sse2.hpp", "rank": 95, "score": 13.67656335989874 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc2F64Sse2.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x2F64Sse2.hpp", "rank": 96, "score": 13.67656335989874 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc2F64Neon.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x2F64Neon.hpp", "rank": 97, "score": 13.67656335989874 }, { "content": "\n\n\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc4F64Avx.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "Downsampler2x4F64Avx.hpp", "rank": 98, "score": 13.67656335989874 }, { "content": "\n\n\n\n/*\\\\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n#include \"hiir/StageProc8F64Avx512.h\"\n\n\n\n#include <cassert>\n\n\n\n\n\n\n\nnamespace hiir\n\n{\n\n\n\n\n\n\n\n/*\\\\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/\n\n\n\n\n\n\n", "file_path": "PhaseHalfPi8F64Avx512.hpp", "rank": 99, "score": 13.67656335989874 } ]
C++
dependencies/mountutils/src/linux/functions.cpp
runcitadel/imager
5519eec99a8003b4acb71cbfea507f384d4fb910
#include "../mountutils.hpp" #include <cerrno> #include <mntent.h> #include <sys/mount.h> #include <sys/stat.h> auto unmount_disk(const char *device_path) -> MOUNTUTILS_RESULT { const char *mount_path = nullptr; std::vector<std::string> mount_dirs = {}; struct stat stats; if (stat(device_path, &stats) != 0) { MountUtilsLog("Stat failed"); return MOUNTUTILS_ERROR_GENERAL; } else if (S_ISDIR(stats.st_mode)) { MountUtilsLog("Device is a directory"); return MOUNTUTILS_ERROR_INVALID_DRIVE; } struct mntent *mnt_p; struct mntent data; char mnt_buf[4096 + 1024]; FILE *proc_mounts; MountUtilsLog("Reading /proc/mounts"); proc_mounts = setmntent("/proc/mounts", "r"); if (proc_mounts == nullptr) { MountUtilsLog("Couldn't read /proc/mounts"); return MOUNTUTILS_ERROR_GENERAL; } while ((mnt_p = getmntent_r(proc_mounts, &data, mnt_buf, sizeof(mnt_buf))) != nullptr) { mount_path = mnt_p->mnt_fsname; if (strncmp(mount_path, device_path, strlen(device_path)) == 0) { MountUtilsLog("Mount point " + std::string(mount_path) + " belongs to drive " + std::string(device_path)); mount_dirs.emplace_back(mnt_p->mnt_dir); } } MountUtilsLog("Closing /proc/mounts"); endmntent(proc_mounts); size_t unmounts = 0; MOUNTUTILS_RESULT result_code = MOUNTUTILS_SUCCESS; for (const std::string& mount_dir : mount_dirs) { MountUtilsLog("Unmounting " + mount_dir + "..."); mount_path = mount_dir.c_str(); if (umount2(mount_path, MNT_EXPIRE) != 0) { MountUtilsLog("Unmount MNT_EXPIRE " + mount_dir + ": EAGAIN"); if (umount2(mount_path, MNT_EXPIRE) != 0) { MountUtilsLog("Unmount MNT_EXPIRE " + mount_dir + " failed: " + std::string(strerror(errno))); } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } if (umount2(mount_path, MNT_DETACH) != 0) { MountUtilsLog("Unmount MNT_DETACH " + mount_dir + " failed: " + std::string(strerror(errno))); } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } if (umount2(mount_path, MNT_FORCE) != 0) { MountUtilsLog("Unmount MNT_FORCE " + mount_dir + " failed: " + std::string(strerror(errno))); } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } } return unmounts == mount_dirs.size() ? MOUNTUTILS_SUCCESS : MOUNTUTILS_ERROR_GENERAL; } auto eject_disk(const char *device) -> MOUNTUTILS_RESULT { return unmount_disk(device); }
#include "../mountutils.hpp" #include <cerrno> #include <mntent.h> #include <sys/mount.h> #include <sys/stat.h> auto unmount_disk(const char *device_path) -> MOUNTUTILS_RESULT { const char *mount_path = nullptr; std::vector<std::string> mount_dirs = {}; struct stat stats; if (stat(device_path, &stats) != 0) { MountUtilsLog("Stat fa
ts == nullptr) { MountUtilsLog("Couldn't read /proc/mounts"); return MOUNTUTILS_ERROR_GENERAL; } while ((mnt_p = getmntent_r(proc_mounts, &data, mnt_buf, sizeof(mnt_buf))) != nullptr) { mount_path = mnt_p->mnt_fsname; if (strncmp(mount_path, device_path, strlen(device_path)) == 0) { MountUtilsLog("Mount point " + std::string(mount_path) + " belongs to drive " + std::string(device_path)); mount_dirs.emplace_back(mnt_p->mnt_dir); } } MountUtilsLog("Closing /proc/mounts"); endmntent(proc_mounts); size_t unmounts = 0; MOUNTUTILS_RESULT result_code = MOUNTUTILS_SUCCESS; for (const std::string& mount_dir : mount_dirs) { MountUtilsLog("Unmounting " + mount_dir + "..."); mount_path = mount_dir.c_str(); if (umount2(mount_path, MNT_EXPIRE) != 0) { MountUtilsLog("Unmount MNT_EXPIRE " + mount_dir + ": EAGAIN"); if (umount2(mount_path, MNT_EXPIRE) != 0) { MountUtilsLog("Unmount MNT_EXPIRE " + mount_dir + " failed: " + std::string(strerror(errno))); } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } if (umount2(mount_path, MNT_DETACH) != 0) { MountUtilsLog("Unmount MNT_DETACH " + mount_dir + " failed: " + std::string(strerror(errno))); } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } if (umount2(mount_path, MNT_FORCE) != 0) { MountUtilsLog("Unmount MNT_FORCE " + mount_dir + " failed: " + std::string(strerror(errno))); } else { MountUtilsLog("Unmount " + mount_dir + ": success"); unmounts++; continue; } } return unmounts == mount_dirs.size() ? MOUNTUTILS_SUCCESS : MOUNTUTILS_ERROR_GENERAL; } auto eject_disk(const char *device) -> MOUNTUTILS_RESULT { return unmount_disk(device); }
iled"); return MOUNTUTILS_ERROR_GENERAL; } else if (S_ISDIR(stats.st_mode)) { MountUtilsLog("Device is a directory"); return MOUNTUTILS_ERROR_INVALID_DRIVE; } struct mntent *mnt_p; struct mntent data; char mnt_buf[4096 + 1024]; FILE *proc_mounts; MountUtilsLog("Reading /proc/mounts"); proc_mounts = setmntent("/proc/mounts", "r"); if (proc_moun
random
[ { "content": "#define HAVE_STRUCT_STAT_ST_BLKSIZE 1\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/config_freebsd.h", "rank": 0, "score": 121046.8140738607 }, { "content": "#define\tHAVE_STRUCT_STAT_ST_FLAGS 1\n", "file_path": "dependencies/libarchive-3.4.2/tar/config_freebsd.h", "rank": 1, "score": 121046.8140738607 }, { "content": "#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/config_freebsd.h", "rank": 2, "score": 121046.8140738607 }, { "content": "#define HAVE_STRUCT_STAT_ST_FLAGS 1\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/config_freebsd.h", "rank": 3, "score": 121046.8140738607 }, { "content": "#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/config_freebsd.h", "rank": 4, "score": 117643.31642022893 }, { "content": "#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/config_freebsd.h", "rank": 5, "score": 117643.31642022893 }, { "content": "#define\tHAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1\n", "file_path": "dependencies/libarchive-3.4.2/tar/config_freebsd.h", "rank": 6, "score": 117643.31642022893 }, { "content": "#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/config_freebsd.h", "rank": 7, "score": 117643.31642022893 }, { "content": "local void fixedtables(state)\n", "file_path": "dependencies/zlib-1.2.11/inflate.c", "rank": 8, "score": 111275.40245012866 }, { "content": "local void fixedtables(state)\n", "file_path": "dependencies/zlib-1.2.11/infback.c", "rank": 9, "score": 111275.40245012866 }, { "content": "local struct tab *done; /* states already evaluated array */\n", "file_path": "dependencies/zlib-1.2.11/examples/enough.c", "rank": 10, "score": 110273.66130905855 }, { "content": "local struct access *addpoint(struct access *index, int bits,\n", "file_path": "dependencies/zlib-1.2.11/examples/zran.c", "rank": 11, "score": 110273.66130905855 }, { "content": "\tvoid *stat;\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/archive_entry_private.h", "rank": 12, "score": 108370.76978814787 }, { "content": "\tint\t\t\t stat;\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/archive_write_set_format_7zip.c", "rank": 13, "score": 106555.62787877565 }, { "content": "struct format_params\n\n{\n\n\tint sectors_per_cluster = 0; // can be zero for default or 1,2,4,8,16,32 or 64\n\n\tbool make_protected_autorun = false;\n\n\tbool all_yes = false;\n\n\tchar volume_label[sizeof(FAT_BOOTSECTOR32::sVolLab) + 1] = {};\n\n};\n\n\n\n[[noreturn]]\n\nvoid die(_In_z_ PCSTR error)\n\n{\n\n\tDWORD dw = GetLastError();\n\n\n\n\tif (dw != NO_ERROR)\n\n\t{\n\n\t\tPSTR lpMsgBuf;\n\n\t\tFormatMessageA(\n\n\t\t\tFORMAT_MESSAGE_ALLOCATE_BUFFER |\n\n\t\t\tFORMAT_MESSAGE_FROM_SYSTEM |\n\n\t\t\tFORMAT_MESSAGE_IGNORE_INSERTS,\n", "file_path": "dependencies/fat32format/fat32format.cpp", "rank": 14, "score": 99722.21270890682 }, { "content": "struct FAT_FSINFO\n\n{\n\n\tDWORD dLeadSig; // 0x41615252\n\n\tBYTE sReserved1[480]; // zeros\n\n\tDWORD dStrucSig; // 0x61417272\n\n\tDWORD dFree_Count; // 0xFFFFFFFF\n\n\tDWORD dNxt_Free; // 0xFFFFFFFF\n\n\tBYTE sReserved2[12]; // zeros\n\n\tDWORD dTrailSig; // 0xAA550000\n\n};\n\n\n", "file_path": "dependencies/fat32format/fat32format.cpp", "rank": 15, "score": 99722.21270890682 }, { "content": "#pragma pack(push, 1)\n\nstruct FAT_BOOTSECTOR32\n\n{\n\n\t// Common fields.\n\n\tBYTE sJmpBoot[3];\n\n\tCHAR sOEMName[8];\n\n\tWORD wBytsPerSec;\n\n\tBYTE bSecPerClus;\n\n\tWORD wRsvdSecCnt;\n\n\tBYTE bNumFATs;\n\n\tWORD wRootEntCnt;\n\n\tWORD wTotSec16; // if zero, use dTotSec32 instead\n\n\tBYTE bMedia;\n\n\tWORD wFATSz16;\n\n\tWORD wSecPerTrk;\n\n\tWORD wNumHeads;\n\n\tDWORD dHiddSec;\n\n\tDWORD dTotSec32;\n\n\t// Fat 32/16 only\n\n\tDWORD dFATSz32;\n\n\tWORD wExtFlags;\n", "file_path": "dependencies/fat32format/fat32format.cpp", "rank": 16, "score": 99722.21270890682 }, { "content": "struct FAT_DIRECTORY\n\n{\n\n\tUINT8 DIR_Name[8 + 3];\n\n\tUINT8 DIR_Attr;\n\n\tUINT8 DIR_NTRes;\n\n\tUINT8 DIR_CrtTimeTenth;\n\n\tUINT16 DIR_CrtTime;\n\n\tUINT16 DIR_CrtDate;\n\n\tUINT16 DIR_LstAccDate;\n\n\tUINT16 DIR_FstClusHI;\n\n\tUINT16 DIR_WrtTime;\n\n\tUINT16 DIR_WrtDate;\n\n\tUINT16 DIR_FstClusLO;\n\n\tUINT32 DIR_FileSize;\n\n};\n\nstatic_assert(sizeof(FAT_DIRECTORY) == 32);\n\n\n\n#pragma pack(pop)\n\n\n\n/*\n", "file_path": "dependencies/fat32format/fat32format.cpp", "rank": 17, "score": 99722.21270890682 }, { "content": "struct DeviceDescriptor {\n\n std::string enumerator;\n\n std::string busType;\n\n std::string busVersion;\n\n bool busVersionNull;\n\n std::string device;\n\n std::string devicePath;\n\n bool devicePathNull;\n\n std::string raw;\n\n std::string description;\n\n std::string error;\n\n uint64_t size;\n\n uint32_t blockSize = 512;\n\n uint32_t logicalBlockSize = 512;\n\n std::vector<std::string> mountpoints;\n\n std::vector<std::string> mountpointLabels;\n\n bool isReadOnly; // Device is read-only\n\n bool isSystem; // Device is a system drive\n\n bool isVirtual; // Device is a virtual storage device\n\n bool isRemovable; // Device is removable from the running system\n", "file_path": "dependencies/drivelist/src/drivelist.hpp", "rank": 18, "score": 98688.73616785933 }, { "content": "struct MountPoint {\n\n std::string path;\n\n};\n\n\n", "file_path": "dependencies/drivelist/src/drivelist.hpp", "rank": 19, "score": 98688.73616785933 }, { "content": "struct RunLoopContext {\n\n MOUNTUTILS_RESULT code = MOUNTUTILS_SUCCESS;\n\n};\n\n\n\nMOUNTUTILS_RESULT translate_dissenter(DADissenterRef dissenter) {\n\n if (dissenter) {\n\n DAReturn status = DADissenterGetStatus(dissenter);\n\n if (status == kDAReturnBadArgument ||\n\n status == kDAReturnNotFound) {\n\n return MOUNTUTILS_ERROR_INVALID_DRIVE;\n\n } else if (status == kDAReturnNotPermitted ||\n\n status == kDAReturnNotPrivileged) {\n\n return MOUNTUTILS_ERROR_ACCESS_DENIED;\n\n } else {\n\n MountUtilsLog(\"Unknown dissenter status\");\n\n return MOUNTUTILS_ERROR_GENERAL;\n\n }\n\n } else {\n\n return MOUNTUTILS_SUCCESS;\n\n }\n", "file_path": "dependencies/mountutils/src/darwin/functions.cpp", "rank": 20, "score": 96715.54962141992 }, { "content": "static lzma_ret\n\nauto_decode(void *coder_ptr, const lzma_allocator *allocator,\n\n\t\tconst uint8_t *restrict in, size_t *restrict in_pos,\n\n\t\tsize_t in_size, uint8_t *restrict out,\n\n\t\tsize_t *restrict out_pos, size_t out_size, lzma_action action)\n\n{\n\n\tlzma_auto_coder *coder = coder_ptr;\n\n\n\n\tswitch (coder->sequence) {\n\n\tcase SEQ_INIT:\n\n\t\tif (*in_pos >= in_size)\n\n\t\t\treturn LZMA_OK;\n\n\n\n\t\t// Update the sequence now, because we want to continue from\n\n\t\t// SEQ_CODE even if we return some LZMA_*_CHECK.\n\n\t\tcoder->sequence = SEQ_CODE;\n\n\n\n\t\t// Detect the file format. For now this is simple, since if\n\n\t\t// it doesn't start with 0xFD (the first magic byte of the\n\n\t\t// new format), it has to be LZMA_Alone, or something that\n\n\t\t// we don't support at all.\n\n\t\tif (in[*in_pos] == 0xFD) {\n\n\t\t\treturn_if_error(lzma_stream_decoder_init(\n\n\t\t\t\t\t&coder->next, allocator,\n\n\t\t\t\t\tcoder->memlimit, coder->flags));\n\n\t\t} else {\n\n\t\t\treturn_if_error(lzma_alone_decoder_init(&coder->next,\n\n\t\t\t\t\tallocator, coder->memlimit, true));\n\n\n\n\t\t\t// If the application wants to know about missing\n\n\t\t\t// integrity check or about the check in general, we\n\n\t\t\t// need to handle it here, because LZMA_Alone decoder\n\n\t\t\t// doesn't accept any flags.\n\n\t\t\tif (coder->flags & LZMA_TELL_NO_CHECK)\n\n\t\t\t\treturn LZMA_NO_CHECK;\n\n\n\n\t\t\tif (coder->flags & LZMA_TELL_ANY_CHECK)\n\n\t\t\t\treturn LZMA_GET_CHECK;\n\n\t\t}\n\n\n\n\t// Fall through\n\n\n\n\tcase SEQ_CODE: {\n\n\t\tconst lzma_ret ret = coder->next.code(\n\n\t\t\t\tcoder->next.coder, allocator,\n\n\t\t\t\tin, in_pos, in_size,\n\n\t\t\t\tout, out_pos, out_size, action);\n\n\t\tif (ret != LZMA_STREAM_END\n\n\t\t\t\t|| (coder->flags & LZMA_CONCATENATED) == 0)\n\n\t\t\treturn ret;\n\n\n\n\t\tcoder->sequence = SEQ_FINISH;\n\n\t}\n\n\n\n\t// Fall through\n\n\n\n\tcase SEQ_FINISH:\n\n\t\t// When LZMA_DECODE_CONCATENATED was used and we were decoding\n\n\t\t// LZMA_Alone file, we need to check check that there is no\n\n\t\t// trailing garbage and wait for LZMA_FINISH.\n\n\t\tif (*in_pos < in_size)\n\n\t\t\treturn LZMA_DATA_ERROR;\n\n\n\n\t\treturn action == LZMA_FINISH ? LZMA_STREAM_END : LZMA_OK;\n\n\n\n\tdefault:\n\n\t\tassert(0);\n\n\t\treturn LZMA_PROG_ERROR;\n\n\t}\n", "file_path": "dependencies/cmliblzma/liblzma/common/auto_decoder.c", "rank": 21, "score": 75184.88414996624 }, { "content": "extern LZMA_API(lzma_ret)\n\nlzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)\n\n{\n\n\tlzma_next_strm_init(auto_decoder_init, strm, memlimit, flags);\n\n\n\n\tstrm->internal->supported_actions[LZMA_RUN] = true;\n\n\tstrm->internal->supported_actions[LZMA_FINISH] = true;\n\n\n\n\treturn LZMA_OK;\n", "file_path": "dependencies/cmliblzma/liblzma/common/auto_decoder.c", "rank": 22, "score": 74515.43391698983 }, { "content": "static lzma_ret\n\nauto_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,\n\n\t\tuint64_t memlimit, uint32_t flags)\n\n{\n\n\tlzma_next_coder_init(&auto_decoder_init, next, allocator);\n\n\n\n\tif (flags & ~LZMA_SUPPORTED_FLAGS)\n\n\t\treturn LZMA_OPTIONS_ERROR;\n\n\n\n\tlzma_auto_coder *coder = next->coder;\n\n\tif (coder == NULL) {\n\n\t\tcoder = lzma_alloc(sizeof(lzma_auto_coder), allocator);\n\n\t\tif (coder == NULL)\n\n\t\t\treturn LZMA_MEM_ERROR;\n\n\n\n\t\tnext->coder = coder;\n\n\t\tnext->code = &auto_decode;\n\n\t\tnext->end = &auto_decoder_end;\n\n\t\tnext->get_check = &auto_decoder_get_check;\n\n\t\tnext->memconfig = &auto_decoder_memconfig;\n\n\t\tcoder->next = LZMA_NEXT_CODER_INIT;\n\n\t}\n\n\n\n\tcoder->memlimit = my_max(1, memlimit);\n\n\tcoder->flags = flags;\n\n\tcoder->sequence = SEQ_INIT;\n\n\n\n\treturn LZMA_OK;\n", "file_path": "dependencies/cmliblzma/liblzma/common/auto_decoder.c", "rank": 23, "score": 74515.43391698983 }, { "content": "static void\n\nauto_decoder_end(void *coder_ptr, const lzma_allocator *allocator)\n\n{\n\n\tlzma_auto_coder *coder = coder_ptr;\n\n\tlzma_next_end(&coder->next, allocator);\n\n\tlzma_free(coder, allocator);\n\n\treturn;\n", "file_path": "dependencies/cmliblzma/liblzma/common/auto_decoder.c", "rank": 24, "score": 74515.43391698983 }, { "content": "static lzma_ret\n\nauto_decoder_memconfig(void *coder_ptr, uint64_t *memusage,\n\n\t\tuint64_t *old_memlimit, uint64_t new_memlimit)\n\n{\n\n\tlzma_auto_coder *coder = coder_ptr;\n\n\n\n\tlzma_ret ret;\n\n\n\n\tif (coder->next.memconfig != NULL) {\n\n\t\tret = coder->next.memconfig(coder->next.coder,\n\n\t\t\t\tmemusage, old_memlimit, new_memlimit);\n\n\t\tassert(*old_memlimit == coder->memlimit);\n\n\t} else {\n\n\t\t// No coder is configured yet. Use the base value as\n\n\t\t// the current memory usage.\n\n\t\t*memusage = LZMA_MEMUSAGE_BASE;\n\n\t\t*old_memlimit = coder->memlimit;\n\n\n\n\t\tret = LZMA_OK;\n\n\t\tif (new_memlimit != 0 && new_memlimit < *memusage)\n\n\t\t\tret = LZMA_MEMLIMIT_ERROR;\n\n\t}\n\n\n\n\tif (ret == LZMA_OK && new_memlimit != 0)\n\n\t\tcoder->memlimit = new_memlimit;\n\n\n\n\treturn ret;\n", "file_path": "dependencies/cmliblzma/liblzma/common/auto_decoder.c", "rank": 25, "score": 74515.43391698983 }, { "content": "const struct stat *\n\narchive_entry_stat(struct archive_entry *entry)\n\n{\n\n\tstruct stat *st;\n\n\tif (entry->stat == NULL) {\n\n\t\tentry->stat = calloc(1, sizeof(*st));\n\n\t\tif (entry->stat == NULL)\n\n\t\t\treturn (NULL);\n\n\t\tentry->stat_valid = 0;\n\n\t}\n\n\n\n\t/*\n\n\t * If none of the underlying fields have been changed, we\n\n\t * don't need to regenerate. In theory, we could use a bitmap\n\n\t * here to flag only those items that have changed, but the\n\n\t * extra complexity probably isn't worth it. It will be very\n\n\t * rare for anyone to change just one field then request a new\n\n\t * stat structure.\n\n\t */\n\n\tif (entry->stat_valid)\n\n\t\treturn (entry->stat);\n\n\n\n\tst = entry->stat;\n\n\t/*\n\n\t * Use the public interfaces to extract items, so that\n\n\t * the appropriate conversions get invoked.\n\n\t */\n\n\tst->st_atime = archive_entry_atime(entry);\n\n#if HAVE_STRUCT_STAT_ST_BIRTHTIME\n\n\tst->st_birthtime = archive_entry_birthtime(entry);\n\n#endif\n\n\tst->st_ctime = archive_entry_ctime(entry);\n\n\tst->st_mtime = archive_entry_mtime(entry);\n\n\tst->st_dev = archive_entry_dev(entry);\n\n\tst->st_gid = (gid_t)archive_entry_gid(entry);\n\n\tst->st_uid = (uid_t)archive_entry_uid(entry);\n\n\tst->st_ino = (ino_t)archive_entry_ino64(entry);\n\n\tst->st_nlink = archive_entry_nlink(entry);\n\n\tst->st_rdev = archive_entry_rdev(entry);\n\n\tst->st_size = (off_t)archive_entry_size(entry);\n\n\tst->st_mode = archive_entry_mode(entry);\n\n\n\n\t/*\n\n\t * On systems that support high-res timestamps, copy that\n\n\t * information into struct stat.\n\n\t */\n\n#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC\n\n\tst->st_atimespec.tv_nsec = archive_entry_atime_nsec(entry);\n\n\tst->st_ctimespec.tv_nsec = archive_entry_ctime_nsec(entry);\n\n\tst->st_mtimespec.tv_nsec = archive_entry_mtime_nsec(entry);\n\n#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC\n\n\tst->st_atim.tv_nsec = archive_entry_atime_nsec(entry);\n\n\tst->st_ctim.tv_nsec = archive_entry_ctime_nsec(entry);\n\n\tst->st_mtim.tv_nsec = archive_entry_mtime_nsec(entry);\n\n#elif HAVE_STRUCT_STAT_ST_MTIME_N\n\n\tst->st_atime_n = archive_entry_atime_nsec(entry);\n\n\tst->st_ctime_n = archive_entry_ctime_nsec(entry);\n\n\tst->st_mtime_n = archive_entry_mtime_nsec(entry);\n\n#elif HAVE_STRUCT_STAT_ST_UMTIME\n\n\tst->st_uatime = archive_entry_atime_nsec(entry) / 1000;\n\n\tst->st_uctime = archive_entry_ctime_nsec(entry) / 1000;\n\n\tst->st_umtime = archive_entry_mtime_nsec(entry) / 1000;\n\n#elif HAVE_STRUCT_STAT_ST_MTIME_USEC\n\n\tst->st_atime_usec = archive_entry_atime_nsec(entry) / 1000;\n\n\tst->st_ctime_usec = archive_entry_ctime_nsec(entry) / 1000;\n\n\tst->st_mtime_usec = archive_entry_mtime_nsec(entry) / 1000;\n\n#endif\n\n#if HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC\n\n\tst->st_birthtimespec.tv_nsec = archive_entry_birthtime_nsec(entry);\n\n#endif\n\n\n\n\t/*\n\n\t * TODO: On Linux, store 32 or 64 here depending on whether\n\n\t * the cached stat structure is a stat32 or a stat64. This\n\n\t * will allow us to support both variants interchangeably.\n\n\t */\n\n\tentry->stat_valid = 1;\n\n\n\n\treturn (st);\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/archive_entry_stat.c", "rank": 26, "score": 74507.33803927602 }, { "content": "static lzma_check\n\nauto_decoder_get_check(const void *coder_ptr)\n\n{\n\n\tconst lzma_auto_coder *coder = coder_ptr;\n\n\n\n\t// It is LZMA_Alone if get_check is NULL.\n\n\treturn coder->next.get_check == NULL ? LZMA_CHECK_NONE\n\n\t\t\t: coder->next.get_check(coder->next.coder);\n", "file_path": "dependencies/cmliblzma/liblzma/common/auto_decoder.c", "rank": 27, "score": 73857.80011132977 }, { "content": "void\n\narchive_entry_copy_stat(struct archive_entry *entry, const struct stat *st)\n\n{\n\n#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC\n\n\tarchive_entry_set_atime(entry, st->st_atime, st->st_atimespec.tv_nsec);\n\n\tarchive_entry_set_ctime(entry, st->st_ctime, st->st_ctimespec.tv_nsec);\n\n\tarchive_entry_set_mtime(entry, st->st_mtime, st->st_mtimespec.tv_nsec);\n\n#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC\n\n\tarchive_entry_set_atime(entry, st->st_atime, st->st_atim.tv_nsec);\n\n\tarchive_entry_set_ctime(entry, st->st_ctime, st->st_ctim.tv_nsec);\n\n\tarchive_entry_set_mtime(entry, st->st_mtime, st->st_mtim.tv_nsec);\n\n#elif HAVE_STRUCT_STAT_ST_MTIME_NSEC\n\n\tarchive_entry_set_atime(entry, st->st_atime, st->st_atime_nsec);\n\n\tarchive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_nsec);\n\n\tarchive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_nsec);\n\n#elif HAVE_STRUCT_STAT_ST_MTIME_N\n\n\tarchive_entry_set_atime(entry, st->st_atime, st->st_atime_n);\n\n\tarchive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_n);\n\n\tarchive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_n);\n\n#elif HAVE_STRUCT_STAT_ST_UMTIME\n\n\tarchive_entry_set_atime(entry, st->st_atime, st->st_uatime * 1000);\n\n\tarchive_entry_set_ctime(entry, st->st_ctime, st->st_uctime * 1000);\n\n\tarchive_entry_set_mtime(entry, st->st_mtime, st->st_umtime * 1000);\n\n#elif HAVE_STRUCT_STAT_ST_MTIME_USEC\n\n\tarchive_entry_set_atime(entry, st->st_atime, st->st_atime_usec * 1000);\n\n\tarchive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_usec * 1000);\n\n\tarchive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_usec * 1000);\n\n#else\n\n\tarchive_entry_set_atime(entry, st->st_atime, 0);\n\n\tarchive_entry_set_ctime(entry, st->st_ctime, 0);\n\n\tarchive_entry_set_mtime(entry, st->st_mtime, 0);\n\n#endif\n\n#if HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC\n\n\tarchive_entry_set_birthtime(entry, st->st_birthtime, st->st_birthtimespec.tv_nsec);\n\n#elif HAVE_STRUCT_STAT_ST_BIRTHTIME\n\n\tarchive_entry_set_birthtime(entry, st->st_birthtime, 0);\n\n#else\n\n\tarchive_entry_unset_birthtime(entry);\n\n#endif\n\n\tarchive_entry_set_dev(entry, st->st_dev);\n\n\tarchive_entry_set_gid(entry, st->st_gid);\n\n\tarchive_entry_set_uid(entry, st->st_uid);\n\n\tarchive_entry_set_ino(entry, st->st_ino);\n\n\tarchive_entry_set_nlink(entry, st->st_nlink);\n\n\tarchive_entry_set_rdev(entry, st->st_rdev);\n\n\tarchive_entry_set_size(entry, st->st_size);\n\n\tarchive_entry_set_mode(entry, st->st_mode);\n", "file_path": "dependencies/libarchive-3.4.2/libarchive/archive_entry_copy_stat.c", "rank": 28, "score": 73203.71838535553 }, { "content": " const static_tree_desc *stat_desc; /* the corresponding static tree */\n", "file_path": "dependencies/zlib-1.2.11/deflate.h", "rank": 29, "score": 64238.389929010555 }, { "content": " struct curl_httppost *more; /* if one field name has more than one\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 30, "score": 64212.894379601166 }, { "content": "static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,\n\n const char **param_charp)\n\n{\n\n switch(info) {\n\n case CURLINFO_EFFECTIVE_URL:\n\n *param_charp = data->change.url?data->change.url:(char *)\"\";\n\n break;\n\n case CURLINFO_CONTENT_TYPE:\n\n *param_charp = data->info.contenttype;\n\n break;\n\n case CURLINFO_PRIVATE:\n\n *param_charp = (char *) data->set.private_data;\n\n break;\n\n case CURLINFO_FTP_ENTRY_PATH:\n\n /* Return the entrypath string from the most recent connection.\n\n This pointer was copied from the connectdata structure by FTP.\n\n The actual string may be free()ed by subsequent libcurl calls so\n\n it must be copied to a safer area before the next libcurl call.\n\n Callers must never free it themselves. */\n\n *param_charp = data->state.most_recent_ftp_entrypath;\n\n break;\n\n case CURLINFO_REDIRECT_URL:\n\n /* Return the URL this request would have been redirected to if that\n\n option had been enabled! */\n\n *param_charp = data->info.wouldredirect;\n\n break;\n\n case CURLINFO_PRIMARY_IP:\n\n /* Return the ip address of the most recent (primary) connection */\n\n *param_charp = data->info.conn_primary_ip;\n\n break;\n\n case CURLINFO_LOCAL_IP:\n\n /* Return the source/local ip address of the most recent (primary)\n\n connection */\n\n *param_charp = data->info.conn_local_ip;\n\n break;\n\n case CURLINFO_RTSP_SESSION_ID:\n\n *param_charp = data->set.str[STRING_RTSP_SESSION_ID];\n\n break;\n\n case CURLINFO_SCHEME:\n\n *param_charp = data->info.conn_scheme;\n\n break;\n\n\n\n default:\n\n return CURLE_UNKNOWN_OPTION;\n\n }\n\n\n\n return CURLE_OK;\n", "file_path": "dependencies/cmcurl/lib/getinfo.c", "rank": 31, "score": 63273.881119668935 }, { "content": "static int get_char(char c, int base);\n", "file_path": "dependencies/cmcurl/lib/strtoofft.c", "rank": 32, "score": 63273.881119668935 }, { "content": "#define hasStat 16 /* The st entry is set. */\n", "file_path": "dependencies/libarchive-3.4.2/contrib/shar/tree.c", "rank": 33, "score": 63267.00660284609 }, { "content": " const char *version; /* LIBCURL_VERSION */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 34, "score": 63247.9334101315 }, { "content": " curl_off_t size;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 35, "score": 63241.89658538441 }, { "content": " void *internals;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 36, "score": 63241.89658538441 }, { "content": " unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 37, "score": 63241.89658538441 }, { "content": " const char *name;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 38, "score": 63241.89658538441 }, { "content": " size_t b_size;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 39, "score": 63241.89658538441 }, { "content": "int strcasecmp(const char *, const char *);\n", "file_path": "dependencies/cmcurl/include/curl/stdcheaders.h", "rank": 40, "score": 63241.89658538441 }, { "content": " char *time;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 41, "score": 63241.89658538441 }, { "content": " char *perm;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 42, "score": 63241.89658538441 }, { "content": " char *data;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 43, "score": 63241.89658538441 }, { "content": " int protocol;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 44, "score": 63241.89658538441 }, { "content": " curl_socket_t fd;\n", "file_path": "dependencies/cmcurl/include/curl/multi.h", "rank": 45, "score": 63241.89658538441 }, { "content": " char *filename;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 46, "score": 63241.89658538441 }, { "content": " struct curl_slist *next;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 47, "score": 63241.89658538441 }, { "content": " char *showfilename; /* The file name to show. If not set, the\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 48, "score": 63241.89658538441 }, { "content": "size_t fwrite(const void *, size_t, size_t, FILE *);\n", "file_path": "dependencies/cmcurl/include/curl/stdcheaders.h", "rank": 49, "score": 63241.89658538441 }, { "content": " const char *ares;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 50, "score": 63241.89658538441 }, { "content": " union {\n\n void *whatever; /* message-specific data */\n\n CURLcode result; /* return code for transfer */\n", "file_path": "dependencies/cmcurl/include/curl/multi.h", "rank": 51, "score": 63241.89658538441 }, { "content": " bit include_header:1; /* include received protocol headers in data output */\n", "file_path": "dependencies/cmcurl/lib/urldata.h", "rank": 52, "score": 63241.89658538441 }, { "content": " CURLMSG msg; /* what this message means */\n", "file_path": "dependencies/cmcurl/include/curl/multi.h", "rank": 53, "score": 63241.89658538441 }, { "content": " char *group;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 54, "score": 63241.89658538441 }, { "content": " CURLversion age; /* age of the returned struct */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 55, "score": 63241.89658538441 }, { "content": " enum curl_khtype keytype;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 56, "score": 63241.89658538441 }, { "content": " short events;\n", "file_path": "dependencies/cmcurl/include/curl/multi.h", "rank": 57, "score": 63241.89658538441 }, { "content": " const char *value;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 58, "score": 63241.89658538441 }, { "content": " long namelength; /* length of name length */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 59, "score": 63241.89658538441 }, { "content": " const char *libidn;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 60, "score": 63241.89658538441 }, { "content": " curl_sslbackend id;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 61, "score": 63241.89658538441 }, { "content": " short revents; /* not supported yet */\n", "file_path": "dependencies/cmcurl/include/curl/multi.h", "rank": 62, "score": 63241.89658538441 }, { "content": " struct {\n\n /* If some of these fields is not NULL, it is a pointer to b_data. */\n\n char *time;\n\n char *perm;\n\n char *user;\n\n char *group;\n\n char *target; /* pointer to the target filename of a symlink */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 63, "score": 63241.89658538441 }, { "content": " struct sockaddr addr;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 64, "score": 63241.89658538441 }, { "content": " struct curl_slist **certinfo; /* for each index in this array, there's a\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 65, "score": 63241.89658538441 }, { "content": " char *user;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 66, "score": 63241.89658538441 }, { "content": " char *buffer; /* pointer to allocated buffer contents */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 67, "score": 63241.89658538441 }, { "content": " char *b_data;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 68, "score": 63241.89658538441 }, { "content": " const char * const *protocols;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 69, "score": 63241.89658538441 }, { "content": " curl_off_t contentlen; /* alternative length of contents\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 70, "score": 63241.89658538441 }, { "content": " unsigned int flags;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 71, "score": 63241.89658538441 }, { "content": " void *userp; /* custom pointer used for\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 72, "score": 63241.89658538441 }, { "content": " int uid;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 73, "score": 63241.89658538441 }, { "content": " char *contents; /* pointer to allocated data contents */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 74, "score": 63241.89658538441 }, { "content": " int gid;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 75, "score": 63241.89658538441 }, { "content": " const char *key; /* points to a zero-terminated string encoded with base64\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 76, "score": 63241.89658538441 }, { "content": " int features; /* bitmask, see defines below */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 77, "score": 63241.89658538441 }, { "content": " const char *host; /* OS/host/cpu/machine when configured */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 78, "score": 63241.89658538441 }, { "content": " int socktype;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 79, "score": 63241.89658538441 }, { "content": " curl_sslbackend backend;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 80, "score": 63241.89658538441 }, { "content": " size_t b_used;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 81, "score": 63241.89658538441 }, { "content": " curlfiletype filetype;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 82, "score": 63241.89658538441 }, { "content": " CURLformoption option;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 83, "score": 63241.89658538441 }, { "content": " int family;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 84, "score": 63241.89658538441 }, { "content": " long contentslength; /* length of contents field, see also\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 85, "score": 63241.89658538441 }, { "content": " char *target; /* pointer to the target filename of a symlink */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 86, "score": 63241.89658538441 }, { "content": " struct curl_slist *contentheader; /* list of extra headers for this form */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 87, "score": 63241.89658538441 }, { "content": "int strncasecmp(const char *, const char *, size_t);\n", "file_path": "dependencies/cmcurl/include/curl/stdcheaders.h", "rank": 88, "score": 63241.89658538441 }, { "content": "size_t fread(void *, size_t, size_t, FILE *);\n", "file_path": "dependencies/cmcurl/include/curl/stdcheaders.h", "rank": 89, "score": 63241.89658538441 }, { "content": " long bufferlength; /* length of buffer field */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 90, "score": 63241.89658538441 }, { "content": " char *contenttype; /* Content-Type */\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 91, "score": 63241.89658538441 }, { "content": " long int hardlinks;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 92, "score": 63241.89658538441 }, { "content": " size_t len;\n", "file_path": "dependencies/cmcurl/include/curl/curl.h", "rank": 93, "score": 63241.89658538441 }, { "content": "#include \"zstream.h\"\n\n#include <math.h>\n\n#include <stdlib.h>\n\n#include <iomanip.h>\n\n\n\nvoid main() {\n\n char h[256] = \"Hello\";\n\n char* g = \"Goodbye\";\n\n ozstream out(\"temp.gz\");\n\n out < \"This works well\" < h < g;\n\n out.close();\n\n\n\n izstream in(\"temp.gz\"); // read it back\n\n char *x = read_string(in), *y = new char[256], z[256];\n\n in > y > z;\n\n in.close();\n\n cout << x << endl << y << endl << z << endl;\n\n\n\n out.open(\"temp.gz\"); // try ascii output; zcat temp.gz to see the results\n\n out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl;\n\n out << z << endl << y << endl << x << endl;\n\n out << 1.1234567890123456789 << endl;\n\n\n\n delete[] x; delete[] y;\n\n}\n", "file_path": "dependencies/zlib-1.2.11/contrib/iostream2/zstream_test.cpp", "rank": 95, "score": 11.051321850636636 }, { "content": " {\n\n qDebug() << \"Error opening cache file for writing. Disabling caching.\";\n\n }\n\n}\n\n\n\nvoid DownloadThread::_hashData(const char *buf, size_t len)\n\n{\n\n _writehash.addData(buf, len);\n\n}\n\n\n\nauto DownloadThread::_writeFile(const char *buf, size_t len) -> size_t\n\n{\n\n if (_cancelled)\n\n {\n\n return len;\n\n }\n\n\n\n if (_firstBlock == nullptr)\n\n {\n\n _writehash.addData(buf, len);\n", "file_path": "downloadthread.cpp", "rank": 96, "score": 10.013370292984385 }, { "content": "/*\n\n * SPDX-License-Identifier: Apache-2.0\n\n * Copyright (C) 2020 Raspberry Pi (Trading) Limited\n\n */\n\n\n\n#include \"downloadthread.h\"\n\n#include \"config.h\"\n\n#include \"dependencies/drivelist/src/drivelist.hpp\"\n\n#include \"dependencies/mountutils/src/mountutils.hpp\"\n\n#include <QDebug>\n\n#include <QProcess>\n\n#include <QSettings>\n\n#include <QtConcurrent/QtConcurrent>\n\n#include <fcntl.h>\n\n#include <fstream>\n\n#include <iostream>\n\n#include <regex>\n\n#include <sstream>\n\n#include <sys/stat.h>\n\n#include <sys/types.h>\n", "file_path": "downloadthread.cpp", "rank": 97, "score": 9.762304254313303 }, { "content": "#include <QScreen>\n\n#include <QSettings>\n\n#ifndef QT_NO_WIDGETS\n\n#include <QtWidgets/QApplication>\n\n#endif\n\n#ifdef Q_OS_DARWIN\n\n#include <CoreFoundation/CoreFoundation.h>\n\n#endif\n\n\n\nstatic QTextStream cerr(stderr);\n\n\n\n#ifdef Q_OS_WIN\n\nstatic void consoleMsgHandler(QtMsgType, const QMessageLogContext &, const QString &str) {\n\n cerr << str << Qt::endl;\n\n}\n\n#endif\n\n\n\nauto main(int argc, char *argv[]) -> int\n\n{\n\n for (int i = 1; i < argc; i++)\n", "file_path": "main.cpp", "rank": 98, "score": 9.692385656992334 }, { "content": "#define uid_t short\n\n\n", "file_path": "dependencies/libarchive-3.4.2/contrib/android/config/windows_host.h", "rank": 99, "score": 9.617208254429864 } ]
C++
src/imageio/NumpyImageLoader.cpp
gao-duan/tev
4916200e2315f4fe3c22dfa1546faa085ea68a62
#include <tev/imageio/NumpyImageLoader.h> #include <tev/ThreadPool.h> #include <regex> using namespace Eigen; using namespace filesystem; using namespace std; TEV_NAMESPACE_BEGIN bool NumpyImageLoader::canLoadFile(std::istream& iStream) const { std::string header; std::getline(iStream, header); bool result = !!iStream && header.length() >= 10 && header.substr(1, 5) == "NUMPY" && (unsigned char)header[0] == (unsigned char)0x93; iStream.clear(); iStream.seekg(0); return result; } ImageData NumpyImageLoader::load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const { ImageData result; ThreadPool threadPool; Vector2i img_size; std::string header; std::getline(iStream, header); if (header.length() < 10 || header.substr(1, 5) != "NUMPY" || (unsigned char)header[0] != (unsigned char)0x93) { throw invalid_argument{ tfm::format("Invalid numpy image") }; } auto pos = header.find("descr"); if (pos == std::string::npos) { throw invalid_argument{ tfm::format("Numpy image cannot find `descr` in the header.") }; } pos += 9; bool littleEndian = (header[pos] == '<' || header[pos] == '|' ? true : false); if (!littleEndian) { throw invalid_argument{ tfm::format("Numpy image only supports little endian.") }; } char type = header[pos + 1]; int size = atoi(header.substr(pos + 2, 1).c_str()); if (type != 'f' && type != 'u' && size > 4) { throw invalid_argument{ tfm::format("Numpy image load error, type is neither `f` or `u`") }; } pos = header.find("fortran_order"); if (pos == std::string::npos) throw invalid_argument{ tfm::format("Numpy image load error, no order information") }; pos += 16; bool fortranOrder = header.substr(pos, 4) == "True" ? true : false; if (fortranOrder) throw invalid_argument{ tfm::format("Numpy image load error, only C order is supported now") }; auto offset = header.find("(") + 1; auto shapeString = header.substr(offset, header.find(")") - offset); std::regex regex("[0-9][0-9]*"); std::smatch match; std::vector<int> shape; while (std::regex_search(shapeString, match, regex)) { shape.push_back(std::stoi(match[0].str())); shapeString = match.suffix().str(); } int w = 0, h = 0, ch = 1; if (shape.size() < 2 || shape.size() > 4) { throw invalid_argument{ tfm::format("Numpy image load error, only supports numpy with shape length 2/3/4") }; } if (shape.size() == 2) { h = shape[0]; w = shape[1]; ch = 1; } else if (shape.size() == 3) { h = shape[0]; w = shape[1]; ch = shape[2]; } else if (shape.size() == 4) { h = shape[1]; w = shape[2]; ch = shape[3]; } if (ch > 4) throw invalid_argument{ tfm::format("Numpy image load error, only at most 4 channels is supported") }; img_size = Vector2i(w, h); std::vector<char> data; data.resize(w * h * ch * size); if (!iStream.read(data.data(), w * h * ch * size)) throw invalid_argument{ tfm::format("Numpy image load error, cannot read the data region") }; std::vector<float> float_data; float_data.resize(w * h * ch); if (type == 'f' && size == 4) { const float * new_data = reinterpret_cast<const float*>(data.data()); for (size_t i = 0; i < float_data.size(); ++i) { float_data[i] = new_data[i]; } } else if (type == 'f' && size == 2) { const ::half* new_data = reinterpret_cast<const ::half*>(data.data()); for (size_t i = 0; i < float_data.size(); ++i) { float_data[i] = float(new_data[i]); } } else if (type == 'u' && size == 1) { for (size_t i = 0; i < float_data.size(); ++i) { float_data[i] = float((unsigned char)(data[i])) / 255.0f; } } vector<Channel> channels = makeNChannels(ch, img_size); threadPool.parallelFor<DenseIndex>(0, img_size.y(), [&](DenseIndex y) { for (int x = 0; x < img_size.x(); ++x) { int baseIdx = (y * img_size.x() + x) * ch; for (int c = 0; c < ch; ++c) { float val = float_data[baseIdx + c]; channels[c].at({ x, y }) = val; } } }); vector<pair<size_t, size_t>> matches; for (size_t i = 0; i < channels.size(); ++i) { size_t matchId; if (matchesFuzzy(channels[i].name(), channelSelector, &matchId)) { matches.emplace_back(matchId, i); } } if (!channelSelector.empty()) { sort(begin(matches), end(matches)); } for (const auto& match : matches) { result.channels.emplace_back(move(channels[match.second])); } result.layers.emplace_back(""); return result; } TEV_NAMESPACE_END
#include <tev/imageio/NumpyImageLoader.h> #include <tev/ThreadPool.h> #include <regex> using namespace Eigen; using namespace filesystem; using namespace std; TEV_NAMESPACE_BEGIN bool NumpyImageLoader::canLoadFile(std::istream& iStream) const { std::string header; std::getline(iStream, header); bool result = !!iStream && header.length() >= 10 && header.substr(1, 5) == "NUMPY" && (unsigned char)header[0] == (unsigned char)0x93; iStream.clear(); iStream.seekg(0); return result; } ImageData NumpyImageLoader::load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const { ImageData result; ThreadPool threadPool; Vector2i img_size; std::string header; std::getline(iStream, header); if (header.length() < 10 || header.substr(1, 5) != "NUMPY" || (unsigned char)header[0] != (unsigned char)0x93) { throw invalid_argument{ tfm::format("Invalid numpy image") }; } auto pos = header.find("descr"); if (pos == std::string::npos) { throw invalid_argument{ tfm::format("Numpy image cannot find `descr` in the header.") }; } pos += 9; bool littleEndian = (header[pos] == '<' || header[pos] == '|' ? true : false); if (!littleEndian) { throw invalid_argument{ tfm::format("Numpy image only supports little endian.") }; } char type = header[pos + 1]; int size = atoi(header.substr(pos + 2, 1).c_str()); if (type != 'f' && type != 'u' && size > 4) { throw invalid_argument{ tfm::format("Numpy image load error, type is neither `f` or `u`") }; } pos = header.find("fortran_order"); if (pos == std::string::npos) throw invalid_argument{ tfm::format("Numpy image load error, no order information") }; pos += 16; bool fortranOrder = header.substr(pos, 4) == "True" ? true : false; if (fortranOrder) throw invalid_argument{ tfm::format("Numpy image load error, only C order is supported now") }; auto offset = header.find("(") + 1; auto shapeString = header.substr(offset, header.find(")") - offset); std::regex regex("[0-9][0-9]*"); std::smatch match; std::vector<int> shape; while (std::regex_search(shapeString, match, regex)) { shape.push_back(std::stoi(match[0].str())); shapeString = match.suffix().str(); } int w = 0, h = 0, ch = 1; if (shape.size() < 2 || shape.size() > 4) { throw invalid_argument{ tfm::format("Numpy image load error, only supports numpy with shape length 2/3/4") }; } if (shape.size() == 2) { h = shape[0]; w = shape[1]; ch = 1; } else if (shape.size() == 3) { h = shape[0]; w = shape[1]; ch = shape[2]; } else if (shape.size() == 4) { h = shape[1]; w = shape[2]; ch = shape[3]; } if (ch > 4) throw invalid_argument{ tfm::format("Numpy image load error, only at most 4 channels is supported") }; img_size = Vector2i(w, h); std::vector<char> data; data.resize(w * h * ch * size); if (!iStream.read(data.data(), w * h * ch * size)) throw invalid_argument{ tfm::format("Numpy image load error, cannot read the data region") }; std::vector<float> float_data; float_data.resize(w * h * ch); if (type == 'f' && size == 4) { const float * new_data = reinterpret_cast<const float*>(data.data()); for (size_t i = 0; i < float_data.size(); ++i) { float_data[i] = new_data[i]; } } else if (type == 'f' && size == 2) { const ::half* new_data = reinterpret_cast<const ::half*>(data.data()); for (size_t i = 0; i < float_data.size(); ++i) { float_data[i] = float(new_data[i]); } } else if (type == 'u' && size == 1) { for (size_t i = 0; i < float_data.size(); ++i) { float_data[i] = float((unsigned char)(data[i])) / 255.0f; } } vector<Channel> channels = makeNChannels(ch, img_size); threadPool.parallelFor<DenseIndex>(0, img_size.y(), [&](DenseIndex y) { for (int x = 0; x < img_size.x(); ++x) { int baseIdx = (y * img_size.x() + x) * ch; for (int c = 0; c < ch; ++c) { float val = float_data[baseIdx + c]; channels[c].at({ x, y }) = val; } } }); vector<pair<size_t, size_t>> matches; for (size_t i = 0; i < channels.size(); ++i) { size_t matchId; if (matchesFuzzy(channels[i].name(), channelSelector, &matchId)) { matches.emplace_back(matchId, i); } }
TEV_NAMESPACE_END
if (!channelSelector.empty()) { sort(begin(matches), end(matches)); } for (const auto& match : matches) { result.channels.emplace_back(move(channels[match.second])); } result.layers.emplace_back(""); return result; }
function_block-function_prefix_line
[ { "content": "class NumpyImageSaver : public TypedImageSaver<float> {\n\npublic:\n\n void save(std::ostream& oStream, const filesystem::path& path, const std::vector<float>& data, const Eigen::Vector2i& imageSize, int nChannels) const override;\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return false;\n\n }\n\n\n\n virtual bool canSaveFile(const std::string& extension) const override {\n\n std::string lowerExtension = toLower(extension);\n\n return lowerExtension == \"npy\";\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/NumpyImageSaver.h", "rank": 0, "score": 154254.72165622446 }, { "content": "struct ImageData {\n\n std::vector<Channel> channels;\n\n std::vector<std::string> layers;\n\n};\n\n\n", "file_path": "include/tev/Image.h", "rank": 1, "score": 129323.181492359 }, { "content": "class ExrImageSaver : public TypedImageSaver<float> {\n\npublic:\n\n void save(std::ostream& oStream, const filesystem::path& path, const std::vector<float>& data, const Eigen::Vector2i& imageSize, int nChannels) const override;\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return true;\n\n }\n\n\n\n virtual bool canSaveFile(const std::string& extension) const override {\n\n std::string lowerExtension = toLower(extension);\n\n return lowerExtension == \"exr\";\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/ExrImageSaver.h", "rank": 2, "score": 120707.09915677222 }, { "content": "class StbiLdrImageSaver : public TypedImageSaver<char> {\n\npublic:\n\n void save(std::ostream& oStream, const filesystem::path& path, const std::vector<char>& data, const Eigen::Vector2i& imageSize, int nChannels) const override;\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return false;\n\n }\n\n\n\n virtual bool canSaveFile(const std::string& extension) const override {\n\n std::string lowerExtension = toLower(extension);\n\n return lowerExtension == \"jpg\"\n\n || lowerExtension == \"jpeg\"\n\n || lowerExtension == \"png\"\n\n || lowerExtension == \"bmp\"\n\n || lowerExtension == \"tga\"\n\n ;\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/StbiLdrImageSaver.h", "rank": 3, "score": 115004.81234093793 }, { "content": "class StbiHdrImageSaver : public TypedImageSaver<float> {\n\npublic:\n\n void save(std::ostream& oStream, const filesystem::path& path, const std::vector<float>& data, const Eigen::Vector2i& imageSize, int nChannels) const override;\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return false;\n\n }\n\n\n\n virtual bool canSaveFile(const std::string& extension) const override {\n\n std::string lowerExtension = toLower(extension);\n\n return lowerExtension == \"hdr\";\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/StbiHdrImageSaver.h", "rank": 4, "score": 114891.93807224401 }, { "content": "class Channel {\n\npublic:\n\n using RowMatrixXf = Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;\n\n\n\n Channel(const std::string& name, Eigen::Vector2i size);\n\n\n\n const std::string& name() const {\n\n return mName;\n\n }\n\n\n\n const RowMatrixXf& data() const {\n\n return mData;\n\n }\n\n\n\n float eval(Eigen::DenseIndex index) const {\n\n if (index >= mData.size()) {\n\n return 0;\n\n }\n\n return mData(index);\n\n }\n", "file_path": "include/tev/Channel.h", "rank": 5, "score": 104079.35334823086 }, { "content": "class NumpyImageLoader : public ImageLoader {\n\npublic:\n\n bool canLoadFile(std::istream& iStream) const override;\n\n ImageData load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const override;\n\n\n\n std::string name() const override {\n\n return \"Numpy\";\n\n }\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return false;\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/NumpyImageLoader.h", "rank": 6, "score": 95645.18474140696 }, { "content": "struct ChannelGroup {\n\n std::string name;\n\n std::vector<std::string> channels;\n\n};\n\n\n", "file_path": "include/tev/Image.h", "rank": 7, "score": 95234.64422572815 }, { "content": "class TypedImageSaver;\n\n\n", "file_path": "include/tev/imageio/ImageSaver.h", "rank": 8, "score": 92042.83748871829 }, { "content": "// This file was developed by Duan Gao <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Image.h>\n\n#include <tev/imageio/ImageLoader.h>\n\n\n\n#include <istream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/NumpyImageLoader.h", "rank": 9, "score": 90560.43702576915 }, { "content": "// This file was developed by Duan Gao <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/imageio/ImageSaver.h>\n\n\n\n#include <ostream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/NumpyImageSaver.h", "rank": 10, "score": 90556.29599834827 }, { "content": "class TypedImageSaver : public ImageSaver {\n\npublic:\n\n virtual void save(std::ostream& oStream, const filesystem::path& path, const std::vector<T>& data, const Eigen::Vector2i& imageSize, int nChannels) const = 0;\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/ImageSaver.h", "rank": 11, "score": 87672.08417678419 }, { "content": "enum SocketError : int {\n\n#ifdef _WIN32\n\n Again = EAGAIN,\n\n ConnRefused = WSAECONNREFUSED,\n\n WouldBlock = WSAEWOULDBLOCK,\n\n#else\n\n Again = EAGAIN,\n\n ConnRefused = ECONNREFUSED,\n\n WouldBlock = EWOULDBLOCK,\n\n#endif\n\n};\n\n\n\nIpcPacket::IpcPacket(const char* data, size_t length) {\n\n if (length <= 0) {\n\n throw runtime_error{\"Cannot construct an IPC packet from no data.\"};\n\n }\n\n mPayload.assign(data, data+length);\n\n}\n\n\n\nvoid IpcPacket::setOpenImage(const string& imagePath, bool grabFocus) {\n", "file_path": "src/Ipc.cpp", "rank": 12, "score": 85749.16618791738 }, { "content": "enum ETonemap : int {\n\n SRGB = 0,\n\n Gamma,\n\n FalseColor,\n\n PositiveNegative,\n\n\n\n // This enum value should never be used directly.\n\n // It facilitates looping over all members of this enum.\n\n NumTonemaps,\n\n};\n\n\n\nETonemap toTonemap(std::string name);\n\n\n", "file_path": "include/tev/Common.h", "rank": 13, "score": 84384.92297786233 }, { "content": "enum EMetric : int {\n\n Error = 0,\n\n AbsoluteError,\n\n SquaredError,\n\n RelativeAbsoluteError,\n\n RelativeSquaredError,\n\n\n\n // This enum value should never be used directly.\n\n // It facilitates looping over all members of this enum.\n\n NumMetrics,\n\n};\n\n\n\nEMetric toMetric(std::string name);\n\n\n", "file_path": "include/tev/Common.h", "rank": 14, "score": 84384.92297786233 }, { "content": "class Path(str):\n\n def __enter__(self):\n\n return self\n\n\n\n def __exit__(self, type, value, traceback):\n", "file_path": "scripts/create-dmg/support/dmg-license.py", "rank": 15, "score": 78392.5810465638 }, { "content": "class Image {\n\npublic:\n\n Image(const filesystem::path& path, std::istream& iStream, const std::string& channelSelector);\n\n\n\n const filesystem::path& path() const {\n\n return mPath;\n\n }\n\n\n\n const std::string& channelSelector() const {\n\n return mChannelSelector;\n\n }\n\n\n\n const std::string& name() const {\n\n return mName;\n\n }\n\n\n\n std::string shortName() const;\n\n\n\n bool hasChannel(const std::string& channelName) const {\n\n return channel(channelName) != nullptr;\n", "file_path": "include/tev/Image.h", "rank": 16, "score": 73801.95762038013 }, { "content": " }\n\n\n\n float at(Eigen::Vector2i index) const {\n\n return at(index.x() + index.y() * mData.cols());\n\n }\n\n\n\n Eigen::DenseIndex count() const {\n\n return mData.size();\n\n }\n\n\n\n Eigen::Vector2i size() const {\n\n return {mData.cols(), mData.rows()};\n\n }\n\n\n\n void divideByAsync(const Channel& other, ThreadPool& pool);\n\n void multiplyWithAsync(const Channel& other, ThreadPool& pool);\n\n\n\n void setZero() { mData.setZero(); }\n\n\n\n void updateTile(int x, int y, int width, int height, const std::vector<float>& newData);\n", "file_path": "include/tev/Channel.h", "rank": 17, "score": 73164.43189921064 }, { "content": "\n\n float eval(Eigen::Vector2i index) const {\n\n if (index.x() < 0 || index.x() >= mData.cols() ||\n\n index.y() < 0 || index.y() >= mData.rows()) {\n\n return 0;\n\n }\n\n\n\n return mData(index.x() + index.y() * mData.cols());\n\n }\n\n\n\n float& at(Eigen::DenseIndex index) {\n\n return mData(index);\n\n }\n\n\n\n float at(Eigen::DenseIndex index) const {\n\n return mData(index);\n\n }\n\n\n\n float& at(Eigen::Vector2i index) {\n\n return at(index.x() + index.y() * mData.cols());\n", "file_path": "include/tev/Channel.h", "rank": 18, "score": 73154.05312643888 }, { "content": "\n\n static std::pair<std::string, std::string> split(const std::string& fullChannel);\n\n\n\n static std::string tail(const std::string& fullChannel);\n\n static std::string head(const std::string& fullChannel);\n\n\n\n static bool isTopmost(const std::string& fullChannel);\n\n\n\n static nanogui::Color color(std::string fullChannel);\n\n\n\nprivate:\n\n std::string mName;\n\n RowMatrixXf mData;\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/Channel.h", "rank": 19, "score": 73152.86259716198 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/GlTexture.h>\n\n#include <tev/ThreadPool.h>\n\n\n\n#include <vector>\n\n#include <string>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/Channel.h", "rank": 20, "score": 73143.89604829405 }, { "content": "struct ImageAddition {\n\n bool shallSelect;\n\n std::shared_ptr<Image> image;\n\n};\n\n\n", "file_path": "include/tev/Image.h", "rank": 21, "score": 70739.34738432268 }, { "content": "struct ImageTexture {\n\n GlTexture glTexture;\n\n std::vector<std::string> channels;\n\n};\n\n\n", "file_path": "include/tev/Image.h", "rank": 22, "score": 70739.34738432268 }, { "content": "class ImageLoader;\n\n\n", "file_path": "include/tev/Image.h", "rank": 23, "score": 70739.34738432268 }, { "content": "\n\n void ensureValid();\n\n\n\n filesystem::path mPath;\n\n std::string mChannelSelector;\n\n\n\n std::string mName;\n\n\n\n std::map<std::string, ImageTexture> mTextures;\n\n\n\n ImageData mData;\n\n \n\n std::vector<ChannelGroup> mChannelGroups;\n\n\n\n int mId;\n\n};\n\n\n\nstd::shared_ptr<Image> tryLoadImage(filesystem::path path, std::istream& iStream, std::string channelSelector);\n\nstd::shared_ptr<Image> tryLoadImage(filesystem::path path, std::string channelSelector);\n\n\n", "file_path": "include/tev/Image.h", "rank": 24, "score": 68797.31290778347 }, { "content": " }\n\n\n\n const Channel* channel(const std::string& channelName) const {\n\n auto it = std::find_if(std::begin(mData.channels), std::end(mData.channels), [&channelName](const Channel& c) { return c.name() == channelName; });\n\n if (it != std::end(mData.channels)) {\n\n return &(*it);\n\n } else {\n\n return nullptr;\n\n }\n\n }\n\n\n\n GlTexture* texture(const std::string& channelGroupName);\n\n GlTexture* texture(const std::vector<std::string>& channelNames);\n\n\n\n std::vector<std::string> channelsInGroup(const std::string& groupName) const;\n\n std::vector<std::string> getSortedChannels(const std::string& layerName) const;\n\n\n\n Eigen::Vector2i size() const {\n\n return mData.channels.front().size();\n\n }\n", "file_path": "include/tev/Image.h", "rank": 25, "score": 68791.29814721608 }, { "content": "\n\n Eigen::DenseIndex count() const {\n\n return mData.channels.front().count();\n\n }\n\n\n\n const std::vector<ChannelGroup>& channelGroups() const {\n\n return mChannelGroups;\n\n }\n\n\n\n int id() const {\n\n return mId;\n\n }\n\n\n\n void bumpId() {\n\n mId = sId++;\n\n }\n\n\n\n void updateChannel(const std::string& channelName, int x, int y, int width, int height, const std::vector<float>& data);\n\n\n\n std::string toString() const;\n", "file_path": "include/tev/Image.h", "rank": 26, "score": 68790.59823020444 }, { "content": "\n\nprivate:\n\n static std::atomic<int> sId;\n\n\n\n Channel* mutableChannel(const std::string& channelName) {\n\n auto it = std::find_if(std::begin(mData.channels), std::end(mData.channels), [&channelName](const Channel& c) { return c.name() == channelName; });\n\n if (it != std::end(mData.channels)) {\n\n return &(*it);\n\n } else {\n\n return nullptr;\n\n }\n\n }\n\n\n\n std::vector<std::string> channelsInLayer(std::string layerName) const;\n\n std::vector<ChannelGroup> getGroupedChannels(const std::string& layerName) const;\n\n\n\n void alphaOperation(const std::function<void(Channel&, const Channel&)>& func);\n\n\n\n void multiplyAlpha();\n\n void unmultiplyAlpha();\n", "file_path": "include/tev/Image.h", "rank": 27, "score": 68786.04190522403 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Channel.h>\n\n#include <tev/GlTexture.h>\n\n#include <tev/SharedQueue.h>\n\n#include <tev/ThreadPool.h>\n\n\n\n#include <atomic>\n\n#include <istream>\n\n#include <map>\n\n#include <memory>\n\n#include <string>\n\n#include <vector>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/Image.h", "rank": 28, "score": 68780.98196567038 }, { "content": "class BackgroundImagesLoader {\n\npublic:\n\n void enqueue(const filesystem::path& path, const std::string& channelSelector, bool shallSelect);\n\n ImageAddition tryPop() { return mLoadedImages.tryPop(); }\n\n\n\nprivate:\n\n // A single worker is enough, since parallelization will happen _within_ each image load.\n\n ThreadPool mWorkers{1};\n\n SharedQueue<ImageAddition> mLoadedImages;\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/Image.h", "rank": 29, "score": 67931.03299327745 }, { "content": "class StdIStream: public Imf::IStream\n\n{\n\npublic:\n\n StdIStream(istream& stream, const char fileName[])\n\n : Imf::IStream{fileName}, mStream{stream} { }\n\n\n\n bool read(char c[/*n*/], int n) override {\n\n if (!mStream)\n\n throw IEX_NAMESPACE::InputExc(\"Unexpected end of file.\");\n\n\n\n clearError();\n\n mStream.read(c, n);\n\n return checkError(mStream, n);\n\n }\n\n\n\n Imf::Int64 tellg() override {\n\n return streamoff(mStream.tellg());\n\n }\n\n\n\n void seekg(Imf::Int64 pos) override {\n", "file_path": "src/imageio/ExrImageLoader.cpp", "rank": 30, "score": 65973.4542563513 }, { "content": "class ImageSaver {\n\npublic:\n\n virtual ~ImageSaver() {}\n\n\n\n virtual bool hasPremultipliedAlpha() const = 0;\n\n\n\n virtual bool canSaveFile(const std::string& extension) const = 0;\n\n bool canSaveFile(const filesystem::path& path) const {\n\n return canSaveFile(toLower(path.extension()));\n\n }\n\n\n\n static const std::vector<std::unique_ptr<ImageSaver>>& getSavers();\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "include/tev/imageio/ImageSaver.h", "rank": 31, "score": 65345.53195906549 }, { "content": "class ImageLoader {\n\npublic:\n\n virtual ~ImageLoader() {}\n\n\n\n virtual bool canLoadFile(std::istream& iStream) const = 0;\n\n virtual ImageData load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const = 0;\n\n\n\n virtual std::string name() const = 0;\n\n\n\n virtual bool hasPremultipliedAlpha() const = 0;\n\n\n\n static const std::vector<std::unique_ptr<ImageLoader>>& getLoaders();\n\n\n\nprotected:\n\n static std::vector<Channel> makeNChannels(int numChannels, Eigen::Vector2i size);\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/ImageLoader.h", "rank": 32, "score": 65345.53195906549 }, { "content": " int width, int height,\n\n const std::vector<float>& imageData\n\n );\n\n\n\n void selectImage(const std::shared_ptr<Image>& image, bool stopPlayback = true);\n\n\n\n void selectGroup(std::string name);\n\n\n\n void selectReference(const std::shared_ptr<Image>& image);\n\n\n\n float exposure() {\n\n return mExposureSlider->value();\n\n }\n\n\n\n void setExposure(float value);\n\n\n\n float offset() {\n\n return mOffsetSlider->value();\n\n }\n\n\n", "file_path": "include/tev/ImageViewer.h", "rank": 33, "score": 65091.147305666775 }, { "content": " }\n\n\n\n Eigen::Vector2i getImageCoords(const Image& image, Eigen::Vector2i mousePos);\n\n\n\n void getValuesAtNanoPos(Eigen::Vector2i nanoPos, std::vector<float>& result, const std::vector<std::string>& channels);\n\n std::vector<float> getValuesAtNanoPos(Eigen::Vector2i nanoPos, const std::vector<std::string>& channels) {\n\n std::vector<float> result;\n\n getValuesAtNanoPos(nanoPos, result, channels);\n\n return result;\n\n }\n\n\n\n ETonemap tonemap() const {\n\n return mTonemap;\n\n }\n\n\n\n void setTonemap(ETonemap tonemap) {\n\n mTonemap = tonemap;\n\n }\n\n\n\n static Eigen::Vector3f applyTonemap(const Eigen::Vector3f& value, float gamma, ETonemap tonemap);\n", "file_path": "include/tev/ImageCanvas.h", "rank": 34, "score": 65090.91902550351 }, { "content": " EMetric metric\n\n );\n\n\n\n static std::shared_ptr<CanvasStatistics> computeCanvasStatistics(\n\n std::shared_ptr<Image> image,\n\n std::shared_ptr<Image> reference,\n\n const std::string& requestedChannelGroup,\n\n EMetric metric\n\n );\n\n\n\n Eigen::Vector2f pixelOffset(const Eigen::Vector2i& size) const;\n\n\n\n // Assembles the transform from canonical space to\n\n // the [-1, 1] square for the current image.\n\n Eigen::Transform<float, 2, 2> transform(const Image* image);\n\n Eigen::Transform<float, 2, 2> textureToNanogui(const Image* image);\n\n\n\n float mPixelRatio = 1;\n\n float mExposure = 0;\n\n float mOffset = 0;\n", "file_path": "include/tev/ImageCanvas.h", "rank": 35, "score": 65090.54393889575 }, { "content": "\n\n void setBackgroundColor(const nanogui::Color& color) {\n\n mShader.setBackgroundColor(color);\n\n }\n\n\n\n void fitImageToScreen(const Image& image);\n\n void resetTransform();\n\n\n\n std::vector<float> getHdrImageData(bool divideAlpha) const;\n\n std::vector<char> getLdrImageData(bool divideAlpha) const;\n\n\n\n void saveImage(const filesystem::path& filename) const;\n\n\n\n std::shared_ptr<Lazy<std::shared_ptr<CanvasStatistics>>> canvasStatistics();\n\n\n\nprivate:\n\n static std::vector<Channel> channelsFromImages(\n\n std::shared_ptr<Image> image,\n\n std::shared_ptr<Image> reference,\n\n const std::string& requestedChannelGroup,\n", "file_path": "include/tev/ImageCanvas.h", "rank": 36, "score": 65088.18737389492 }, { "content": " }\n\n\n\n void setHighlightRange(size_t begin, size_t end);\n\n\n\nprivate:\n\n std::string mCaption;\n\n bool mCanBeReference;\n\n\n\n bool mIsReference = false;\n\n std::function<void(bool)> mReferenceCallback;\n\n\n\n bool mIsSelected = false;\n\n std::function<void()> mSelectedCallback;\n\n\n\n size_t mId = 0;\n\n size_t mCutoff = 0;\n\n Eigen::Vector2i mSizeForWhichCutoffWasComputed = Eigen::Vector2i::Constant(0);\n\n\n\n size_t mHighlightBegin = 0;\n\n size_t mHighlightEnd = 0;\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/ImageButton.h", "rank": 37, "score": 65086.24978944547 }, { "content": " float mGamma = 2.2f;\n\n\n\n std::shared_ptr<Image> mImage;\n\n std::shared_ptr<Image> mReference;\n\n\n\n std::string mRequestedChannelGroup = \"\";\n\n\n\n Eigen::Transform<float, 2, 2> mTransform = Eigen::Affine2f::Identity();\n\n\n\n UberShader mShader;\n\n\n\n ETonemap mTonemap = SRGB;\n\n EMetric mMetric = Error;\n\n\n\n std::map<std::string, std::shared_ptr<Lazy<std::shared_ptr<CanvasStatistics>>>> mMeanValues;\n\n ThreadPool mMeanValueThreadPool;\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/ImageCanvas.h", "rank": 38, "score": 65085.47312993221 }, { "content": " int imageId(const std::shared_ptr<Image>& image) const;\n\n int imageId(const std::string& imageName) const;\n\n\n\n std::string nextGroup(const std::string& groupName, EDirection direction);\n\n std::string nthVisibleGroup(size_t n);\n\n\n\n std::shared_ptr<Image> nextImage(const std::shared_ptr<Image>& image, EDirection direction);\n\n std::shared_ptr<Image> nthVisibleImage(size_t n);\n\n std::shared_ptr<Image> imageByName(const std::string& imageName);\n\n\n\n bool canDragSidebarFrom(const Eigen::Vector2i& p) {\n\n return mSidebar->visible() && p.x() - mSidebar->fixedWidth() < 10 && p.x() - mSidebar->fixedWidth() > -5;\n\n }\n\n\n\n int visibleSidebarWidth() {\n\n return mSidebar->visible() ? mSidebar->fixedWidth() : 0;\n\n }\n\n\n\n int visibleFooterHeight() {\n\n return mFooter->visible() ? mFooter->fixedHeight() : 0;\n", "file_path": "include/tev/ImageViewer.h", "rank": 39, "score": 65084.45525805625 }, { "content": " void setOffset(float offset) {\n\n mOffset = offset;\n\n }\n\n\n\n void setGamma(float gamma) {\n\n mGamma = gamma;\n\n }\n\n\n\n float applyExposureAndOffset(float value) const;\n\n\n\n void setImage(std::shared_ptr<Image> image) {\n\n mImage = image;\n\n }\n\n\n\n void setReference(std::shared_ptr<Image> reference) {\n\n mReference = reference;\n\n }\n\n\n\n void setRequestedChannelGroup(const std::string& groupName) {\n\n mRequestedChannelGroup = groupName;\n", "file_path": "include/tev/ImageCanvas.h", "rank": 40, "score": 65084.27334010102 }, { "content": " insertImage(image, mImages.size(), shallSelect);\n\n }\n\n\n\n void removeImage(std::shared_ptr<Image> image);\n\n void removeImage(const std::string& imageName) {\n\n removeImage(imageByName(imageName));\n\n }\n\n void removeAllImages();\n\n\n\n void reloadImage(std::shared_ptr<Image> image, bool shallSelect = false);\n\n void reloadImage(const std::string& imageName, bool shallSelect = false) {\n\n reloadImage(imageByName(imageName), shallSelect);\n\n }\n\n void reloadAllImages();\n\n\n\n void updateImage(\n\n const std::string& imageName,\n\n bool shallSelect,\n\n const std::string& channel,\n\n int x, int y,\n", "file_path": "include/tev/ImageViewer.h", "rank": 41, "score": 65083.137835908405 }, { "content": "\n\n void setMetric(EMetric metric);\n\n\n\n void resizeToFitImage(const std::shared_ptr<Image>& image);\n\n void resizeToFitAllImages();\n\n bool setFilter(const std::string& filter);\n\n\n\n bool useRegex();\n\n void setUseRegex(bool value);\n\n\n\n void maximize();\n\n bool isMaximized();\n\n void toggleMaximized();\n\n\n\n bool isUiVisible() {\n\n return mSidebar->visible();\n\n }\n\n void setUiVisible(bool shouldBeVisible);\n\n\n\n void toggleHelpWindow();\n", "file_path": "include/tev/ImageViewer.h", "rank": 42, "score": 65082.566442755946 }, { "content": " HelpWindow* mHelpWindow = nullptr;\n\n\n\n bool mIsDraggingSidebar = false;\n\n bool mIsDraggingImage = false;\n\n bool mIsDraggingImageButton = false;\n\n size_t mDraggedImageButtonId;\n\n\n\n Eigen::Vector2f mDraggingStartPosition;\n\n\n\n size_t mClipboardIndex = 0;\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/ImageViewer.h", "rank": 43, "score": 65081.64707892674 }, { "content": " // Buttons which require a current image to be meaningful.\n\n std::vector<nanogui::Button*> mCurrentImageButtons;\n\n\n\n // Buttons which require at least one image to be meaningful\n\n std::vector<nanogui::Button*> mAnyImageButtons;\n\n\n\n nanogui::Button* mPlayButton;\n\n nanogui::IntBox<int>* mFpsTextBox;\n\n std::thread mPlaybackThread;\n\n bool mShallRunPlaybackThread = true;\n\n\n\n nanogui::Widget* mImageButtonContainer;\n\n nanogui::Widget* mScrollContent;\n\n nanogui::VScrollPanel* mImageScrollContainer;\n\n\n\n ImageCanvas* mImageCanvas;\n\n\n\n nanogui::Widget* mGroupButtonContainer;\n\n std::string mCurrentGroup;\n\n\n", "file_path": "include/tev/ImageViewer.h", "rank": 44, "score": 65079.0901382072 }, { "content": "\n\n void openImageDialog();\n\n void saveImageDialog();\n\n\n\n void requestLayoutUpdate() {\n\n mRequiresLayoutUpdate = true;\n\n }\n\n\n\n template <typename T>\n\n void scheduleToUiThread(const T& fun) {\n\n mTaskQueue.push(fun);\n\n }\n\n\n\nprivate:\n\n void updateFilter();\n\n void updateLayout();\n\n void updateTitle();\n\n std::string groupName(size_t index);\n\n\n\n int groupId(const std::string& groupName) const;\n", "file_path": "include/tev/ImageViewer.h", "rank": 45, "score": 65077.73950074623 }, { "content": " }\n\n\n\n SharedQueue<std::function<void(void)>> mTaskQueue;\n\n\n\n bool mRequiresFilterUpdate = true;\n\n bool mRequiresLayoutUpdate = true;\n\n\n\n nanogui::Widget* mVerticalScreenSplit;\n\n\n\n nanogui::Widget* mSidebar;\n\n nanogui::Button* mHelpButton;\n\n nanogui::Widget* mSidebarLayout;\n\n\n\n nanogui::Widget* mFooter;\n\n\n\n nanogui::Label* mExposureLabel;\n\n nanogui::Slider* mExposureSlider;\n\n\n\n nanogui::Label* mOffsetLabel;\n\n nanogui::Slider* mOffsetSlider;\n", "file_path": "include/tev/ImageViewer.h", "rank": 46, "score": 65076.57567268792 }, { "content": " void setOffset(float value);\n\n\n\n float gamma() {\n\n return mGammaSlider->value();\n\n }\n\n\n\n void setGamma(float value);\n\n\n\n void normalizeExposureAndOffset();\n\n void resetImage();\n\n\n\n ETonemap tonemap() {\n\n return mImageCanvas->tonemap();\n\n }\n\n\n\n void setTonemap(ETonemap tonemap);\n\n\n\n EMetric metric() {\n\n return mImageCanvas->metric();\n\n }\n", "file_path": "include/tev/ImageViewer.h", "rank": 47, "score": 65075.69812765556 }, { "content": "\n\n nanogui::Label* mGammaLabel;\n\n nanogui::Slider* mGammaSlider;\n\n\n\n nanogui::Widget* mTonemapButtonContainer;\n\n nanogui::Widget* mMetricButtonContainer;\n\n\n\n std::shared_ptr<BackgroundImagesLoader> mImagesLoader;\n\n\n\n std::shared_ptr<Image> mCurrentImage;\n\n std::shared_ptr<Image> mCurrentReference;\n\n\n\n std::vector<std::shared_ptr<Image>> mImages;\n\n\n\n MultiGraph* mHistogram;\n\n std::set<std::shared_ptr<Image>> mToBump;\n\n\n\n nanogui::TextBox* mFilter;\n\n nanogui::Button* mRegexButton;\n\n\n", "file_path": "include/tev/ImageViewer.h", "rank": 48, "score": 65075.28457591474 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/HelpWindow.h>\n\n#include <tev/Image.h>\n\n#include <tev/ImageButton.h>\n\n#include <tev/ImageCanvas.h>\n\n#include <tev/Lazy.h>\n\n#include <tev/MultiGraph.h>\n\n#include <tev/SharedQueue.h>\n\n\n\n#include <nanogui/glutil.h>\n\n#include <nanogui/opengl.h>\n\n#include <nanogui/screen.h>\n\n#include <nanogui/slider.h>\n\n#include <nanogui/textbox.h>\n\n\n\n#include <memory>\n\n#include <set>\n\n#include <vector>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/ImageViewer.h", "rank": 49, "score": 65074.781386696384 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/UberShader.h>\n\n#include <tev/Image.h>\n\n#include <tev/Lazy.h>\n\n\n\n#include <nanogui/glcanvas.h>\n\n\n\n#include <memory>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/ImageCanvas.h", "rank": 50, "score": 65074.38453362451 }, { "content": " }\n\n\n\n bool isReference() const {\n\n return mIsReference;\n\n }\n\n\n\n void setSelectedCallback(const std::function<void()> &callback) {\n\n mSelectedCallback = callback;\n\n }\n\n\n\n void setIsSelected(bool isSelected) {\n\n mIsSelected = isSelected;\n\n }\n\n\n\n bool isSelected() const {\n\n return mIsSelected;\n\n }\n\n\n\n void setId(size_t id) {\n\n mId = id;\n", "file_path": "include/tev/ImageButton.h", "rank": 51, "score": 65074.09675876889 }, { "content": " Eigen::Vector3f applyTonemap(const Eigen::Vector3f& value) const {\n\n return applyTonemap(value, mGamma, mTonemap);\n\n }\n\n\n\n EMetric metric() const {\n\n return mMetric;\n\n }\n\n\n\n void setMetric(EMetric metric) {\n\n mMetric = metric;\n\n }\n\n\n\n static float applyMetric(float value, float reference, EMetric metric);\n\n float applyMetric(float value, float reference) const {\n\n return applyMetric(value, reference, mMetric);\n\n }\n\n\n\n const nanogui::Color& backgroundColor() {\n\n return mShader.backgroundColor();\n\n }\n", "file_path": "include/tev/ImageCanvas.h", "rank": 52, "score": 65072.053461146905 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Common.h>\n\n\n\n#include <nanogui/widget.h>\n\n\n\n#include <string>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/ImageButton.h", "rank": 53, "score": 65071.683644103425 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Channel.h>\n\n#include <tev/Image.h>\n\n\n\n#include <istream>\n\n#include <string>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/ImageLoader.h", "rank": 54, "score": 61755.33832107775 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Common.h>\n\n\n\n#include <Eigen/Core>\n\n\n\n#include <ostream>\n\n#include <string>\n\n#include <vector>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n\ntemplate <typename T>\n", "file_path": "include/tev/imageio/ImageSaver.h", "rank": 55, "score": 61749.30577106072 }, { "content": "class ImageViewer : public nanogui::Screen {\n\npublic:\n\n ImageViewer(const std::shared_ptr<BackgroundImagesLoader>& imagesLoader, bool processPendingDrops);\n\n virtual ~ImageViewer();\n\n\n\n bool mouseButtonEvent(const Eigen::Vector2i &p, int button, bool down, int modifiers) override;\n\n bool mouseMotionEvent(const Eigen::Vector2i& p, const Eigen::Vector2i& rel, int button, int modifiers) override;\n\n\n\n bool dropEvent(const std::vector<std::string>& filenames) override;\n\n\n\n bool keyboardEvent(int key, int scancode, int action, int modifiers) override;\n\n\n\n void focusWindow();\n\n\n\n void drawContents() override;\n\n\n\n void insertImage(std::shared_ptr<Image> image, size_t index, bool shallSelect = false);\n\n void moveImageInList(size_t oldIndex, size_t newIndex);\n\n\n\n void addImage(std::shared_ptr<Image> image, bool shallSelect = false) {\n", "file_path": "include/tev/ImageViewer.h", "rank": 56, "score": 60741.663579859574 }, { "content": "class ImageButton : public nanogui::Widget {\n\npublic:\n\n ImageButton(nanogui::Widget* parent, const std::string& caption, bool canBeReference);\n\n\n\n Eigen::Vector2i preferredSize(NVGcontext *ctx) const override;\n\n\n\n bool mouseButtonEvent(const Eigen::Vector2i &p, int button, bool down, int modifiers) override;\n\n\n\n void draw(NVGcontext *ctx) override;\n\n\n\n const std::string& caption() const {\n\n return mCaption;\n\n }\n\n\n\n void setReferenceCallback(const std::function<void(bool)> &callback) {\n\n mReferenceCallback = callback;\n\n }\n\n\n\n void setIsReference(bool isReference) {\n\n mIsReference = isReference;\n", "file_path": "include/tev/ImageButton.h", "rank": 57, "score": 60741.663579859574 }, { "content": "class StbiImageLoader : public ImageLoader {\n\npublic:\n\n bool canLoadFile(std::istream& iStream) const override;\n\n ImageData load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const override;\n\n\n\n std::string name() const override {\n\n return \"STBI\";\n\n }\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return false;\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/StbiImageLoader.h", "rank": 58, "score": 60284.20727237269 }, { "content": "class ExrImageLoader : public ImageLoader {\n\npublic:\n\n bool canLoadFile(std::istream& iStream) const override;\n\n ImageData load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const override;\n\n\n\n std::string name() const override {\n\n return \"OpenEXR\";\n\n }\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return true;\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/ExrImageLoader.h", "rank": 59, "score": 60284.20727237269 }, { "content": "class EmptyImageLoader : public ImageLoader {\n\npublic:\n\n bool canLoadFile(std::istream& iStream) const override;\n\n ImageData load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const override;\n\n\n\n std::string name() const override {\n\n return \"IPC\";\n\n }\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return true;\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/EmptyImageLoader.h", "rank": 60, "score": 60284.20727237269 }, { "content": "class ClipboardImageLoader : public ImageLoader {\n\npublic:\n\n bool canLoadFile(std::istream& iStream) const override;\n\n ImageData load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const override;\n\n\n\n std::string name() const override {\n\n return \"clipboard\";\n\n }\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return false;\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/ClipboardImageLoader.h", "rank": 61, "score": 60284.20727237269 }, { "content": "class PfmImageLoader : public ImageLoader {\n\npublic:\n\n bool canLoadFile(std::istream& iStream) const override;\n\n ImageData load(std::istream& iStream, const filesystem::path& path, const std::string& channelSelector) const override;\n\n\n\n std::string name() const override {\n\n return \"PFM\";\n\n }\n\n\n\n bool hasPremultipliedAlpha() const override {\n\n return false;\n\n }\n\n};\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "include/tev/imageio/PfmImageLoader.h", "rank": 62, "score": 60284.20727237269 }, { "content": " append_chars(descr, BigEndianTest());\n\n append_chars(descr, 'f');\n\n append_chars(descr, std::to_string(sizeof(float)));\n\n append_chars(descr, \"', 'fortran_order': False, 'shape': (\");\n\n append_chars(descr, std::to_string(imageSize.x()));\n\n append_chars(descr, ',');\n\n append_chars(descr, std::to_string(imageSize.y()));\n\n append_chars(descr, ',');\n\n append_chars(descr, std::to_string(nChannels));\n\n append_chars(descr, \"),}\");\n\n\n\n //pad with spaces so that preamble+dict is modulo 16 bytes. preamble is 10 bytes. dict needs to end with \\n\n\n int remainder = 16 - (10 + descr.size()) % 16;\n\n append_chars(descr, std::string(' ', remainder));\n\n descr.back() = '\\n';\n\n \n\n // header\n\n append_chars(header, (char)0x93);\n\n append_chars(header, \"NUMPY\");\n\n append_chars(header, (char)0x01); //major version of numpy format\n", "file_path": "src/imageio/NumpyImageSaver.cpp", "rank": 69, "score": 59985.32850982369 }, { "content": "void append_chars(std::vector<char>& buffer, const std::string& str) {\n\n buffer.insert(buffer.end(), str.begin(), str.end());\n\n}\n\n\n\nvoid append_chars(std::vector<char>& buffer, const std::vector<char>& str) {\n\n buffer.insert(buffer.end(), str.begin(), str.end());\n\n}\n\n\n\nvoid append_chars(std::vector<char>& buffer, char c) {\n\n buffer.push_back(c);\n\n}\n\n\n\n\n\nvoid NumpyImageSaver::save(std::ostream& oStream, const filesystem::path& path, const std::vector<float>& data, const Eigen::Vector2i& imageSize, int nChannels) const\n\n{\n\n std::vector<char> header;\n\n\n\n // descr of header\n\n std::vector<char> descr;\n\n append_chars(descr, \"{'descr': '\");\n", "file_path": "src/imageio/NumpyImageSaver.cpp", "rank": 70, "score": 59984.17636804345 }, { "content": " append_chars(header, (char)0x00); //minor version of numpy format\n\n uint16_t header_size = (uint16_t)descr.size();\n\n append_chars(header, (header_size >> 8) & 0xff );\n\n append_chars(header, header_size & 0xff);\n\n append_chars(header, descr);\n\n\n\n // data\n\n const char* byte_data = reinterpret_cast<const char*>(data.data());\n\n assert(data.size() == imageSize.x() * imageSize.y() * nChannels);\n\n\n\n oStream.write(header.data(), header.size());\n\n oStream.write(byte_data, data.size() * sizeof(float));\n\n\n\n}\n\n\n\nTEV_NAMESPACE_END\n", "file_path": "src/imageio/NumpyImageSaver.cpp", "rank": 71, "score": 59980.48851716164 }, { "content": "// This file was developed by Duan Gao <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#include <tev/imageio/NumpyImageSaver.h>\n\n\n\nusing namespace Eigen;\n\nusing namespace filesystem;\n\nusing namespace std;\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n\nchar BigEndianTest() {\n\n int x = 1;\n\n return (((char*)& x)[0]) ? '<' : '>';\n\n}\n\n\n\nvoid append_chars(std::vector<char>& buffer, const char* str) {\n\n buffer.insert(buffer.end(), str, str + strlen(str));\n\n}\n\n\n", "file_path": "src/imageio/NumpyImageSaver.cpp", "rank": 73, "score": 59976.135939711676 }, { "content": " class IStream {\n\n public:\n\n IStream(const std::vector<char>& data) : mData{data} {\n\n uint32_t size;\n\n *this >> size;\n\n if ((size_t)size != data.size()) {\n\n throw std::runtime_error{\"Trying to read IPC packet with incorrect size.\"};\n\n }\n\n }\n\n\n\n IStream& operator>>(bool& var) {\n\n if (mData.size() < mIdx + 1) {\n\n throw std::runtime_error{\"Trying to read beyond the bounds of the IPC packet payload.\"};\n\n }\n\n\n\n var = mData[mIdx] == 1;\n\n ++mIdx;\n\n return *this;\n\n }\n\n\n", "file_path": "include/tev/Ipc.h", "rank": 76, "score": 58810.314854710174 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Image.h>\n\n#include <tev/imageio/ImageLoader.h>\n\n\n\n#include <istream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/PfmImageLoader.h", "rank": 77, "score": 58750.88463944468 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Image.h>\n\n#include <tev/imageio/ImageLoader.h>\n\n\n\n#include <istream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/ExrImageLoader.h", "rank": 78, "score": 58750.88463944468 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Image.h>\n\n#include <tev/imageio/ImageLoader.h>\n\n\n\n#include <istream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/StbiImageLoader.h", "rank": 79, "score": 58750.88463944468 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Image.h>\n\n#include <tev/imageio/ImageLoader.h>\n\n\n\n#include <istream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/ClipboardImageLoader.h", "rank": 80, "score": 58750.88463944468 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/Image.h>\n\n#include <tev/imageio/ImageLoader.h>\n\n\n\n#include <istream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/EmptyImageLoader.h", "rank": 81, "score": 58750.88463944468 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/imageio/ImageSaver.h>\n\n\n\n#include <ostream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/ExrImageSaver.h", "rank": 82, "score": 58746.682353230004 }, { "content": "struct CanvasStatistics {\n\n float mean;\n\n float maximum;\n\n float minimum;\n\n Eigen::MatrixXf histogram;\n\n int histogramZero;\n\n};\n\n\n", "file_path": "include/tev/ImageCanvas.h", "rank": 83, "score": 58736.47016480504 }, { "content": "class ImageCanvas : public nanogui::GLCanvas {\n\npublic:\n\n ImageCanvas(nanogui::Widget* parent, float pixelRatio);\n\n\n\n bool scrollEvent(const Eigen::Vector2i& p, const Eigen::Vector2f& rel) override;\n\n\n\n void drawGL() override;\n\n\n\n void draw(NVGcontext *ctx) override;\n\n\n\n void translate(const Eigen::Vector2f& amount);\n\n void scale(float amount, const Eigen::Vector2f& origin);\n\n float extractScale() const {\n\n return std::sqrt(mTransform.linear().determinant());\n\n }\n\n\n\n void setExposure(float exposure) {\n\n mExposure = exposure;\n\n }\n\n\n", "file_path": "include/tev/ImageCanvas.h", "rank": 84, "score": 58682.1200447976 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/imageio/ImageSaver.h>\n\n\n\n#include <ostream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/StbiHdrImageSaver.h", "rank": 85, "score": 56023.05913092679 }, { "content": "// This file was developed by Thomas Müller <[email protected]>.\n\n// It is published under the BSD 3-Clause License within the LICENSE file.\n\n\n\n#pragma once\n\n\n\n#include <tev/imageio/ImageSaver.h>\n\n\n\n#include <ostream>\n\n\n\nTEV_NAMESPACE_BEGIN\n\n\n", "file_path": "include/tev/imageio/StbiLdrImageSaver.h", "rank": 86, "score": 56023.05913092679 }, { "content": "struct IpcPacketReloadImage {\n\n std::string imageName;\n\n bool grabFocus;\n\n};\n\n\n", "file_path": "include/tev/Ipc.h", "rank": 87, "score": 56012.84694250183 }, { "content": "struct IpcPacketOpenImage {\n\n std::string imagePath;\n\n bool grabFocus;\n\n};\n\n\n", "file_path": "include/tev/Ipc.h", "rank": 88, "score": 56012.84694250183 }, { "content": "struct IpcPacketCloseImage {\n\n std::string imageName;\n\n};\n\n\n", "file_path": "include/tev/Ipc.h", "rank": 89, "score": 56012.84694250183 }, { "content": "struct IpcPacketUpdateImage {\n\n std::string imageName;\n\n bool grabFocus;\n\n std::string channel;\n\n int32_t x, y, width, height;\n\n std::vector<float> imageData;\n\n};\n\n\n", "file_path": "include/tev/Ipc.h", "rank": 90, "score": 56012.84694250183 }, { "content": "struct IpcPacketCreateImage {\n\n std::string imageName;\n\n bool grabFocus;\n\n int32_t width, height;\n\n int32_t nChannels;\n\n std::vector<std::string> channelNames;\n\n};\n\n\n", "file_path": "include/tev/Ipc.h", "rank": 91, "score": 56012.84694250183 }, { "content": "class ThreadPool {\n\npublic:\n\n ThreadPool();\n\n ThreadPool(size_t maxNumThreads, bool force = false);\n\n virtual ~ThreadPool();\n\n\n\n template<class F>\n\n std::future<typename std::result_of<F(void)>::type> enqueueTask(F&& f, bool highPriority = false) {\n\n typedef typename std::result_of<F(void)>::type return_type;\n\n\n\n ++mNumTasksInSystem;\n\n\n\n auto task = std::make_shared<std::packaged_task<return_type()>>(std::forward<F>(f));\n\n\n\n auto res = task->get_future();\n\n\n\n {\n\n std::lock_guard<std::mutex> lock{mTaskQueueMutex};\n\n\n\n if (highPriority) {\n", "file_path": "include/tev/ThreadPool.h", "rank": 92, "score": 55585.89262188796 }, { "content": " // Inline helper class for dealing with the raw channels loaded from an exr file.\n\n class RawChannel {\n\n public:\n\n RawChannel(string name, Imf::Channel imfChannel)\n\n : mName(name), mImfChannel(imfChannel) {\n\n }\n\n\n\n void resize(size_t size) {\n\n mData.resize(size * bytesPerPixel());\n\n }\n\n\n\n void registerWith(Imf::FrameBuffer& frameBuffer, const Imath::Box2i& dw) {\n\n int width = dw.max.x - dw.min.x + 1;\n\n frameBuffer.insert(mName.c_str(), Imf::Slice(\n\n mImfChannel.type,\n\n mData.data() - (dw.min.x + dw.min.y * width) * bytesPerPixel(),\n\n bytesPerPixel(), bytesPerPixel() * width,\n\n mImfChannel.xSampling, mImfChannel.ySampling, 0\n\n ));\n\n }\n\n\n", "file_path": "src/imageio/ExrImageLoader.cpp", "rank": 93, "score": 54693.56671268374 }, { "content": "TEV_NAMESPACE_BEGIN\n\n\n\nnamespace colormap {\n\n const std::vector<float>& turbo();\n\n const std::vector<float>& viridis();\n", "file_path": "include/tev/FalseColor.h", "rank": 94, "score": 54599.512615676555 }, { "content": "#!/usr/bin/env python3\n\n\n\n\"\"\"\n\nParses .vscode/.cmaketools.json to obtain a list of include paths.\n\nThese can then be subsequently pasted into .vscode/c_cpp_properties.json\n\nto make intellisense work. This is script exists purely for convenience\n\nand only needs to be used when the include paths change (e.g. when a new\n\ndependency is added).\n\n\"\"\"\n\n\n\nimport json\n\nimport os\n\nimport sys\n\n\n\ndef iterate_over(dict_or_list, result):\n\n \"\"\"\n\n Iterates recursively over nested lists and dictionaries\n\n keeping track of all \"path\" values with the key \"includePath\"\n\n within nested dictionaries.\n\n \"\"\"\n\n if isinstance(dict_or_list, list):\n\n for child in dict_or_list:\n\n iterate_over(child, result)\n\n elif isinstance(dict_or_list, dict):\n\n for key, value in dict_or_list.items():\n\n if key == \"includePath\":\n\n for child in value:\n\n result.add(child[\"path\"])\n\n else:\n\n iterate_over(value, result)\n\n\n\ndef main(arguments):\n\n \"\"\"Main function of this program.\"\"\"\n\n\n\n workspace = os.path.realpath(os.path.join(__file__, os.pardir, os.pardir))\n\n print(\"Workspace root: '{}'\".format(workspace))\n\n\n\n with open(os.path.join(workspace, \".vscode\", \".cmaketools.json\")) as f:\n\n data = json.loads(f.read())\n\n\n\n result = set()\n\n\n\n iterate_over(data, result)\n\n\n\n result = [x.replace(workspace, \"${workspaceRoot}\") for x in result]\n\n\n\n print(json.dumps(result, indent=0))\n\n\n\n\n\nif __name__ == \"__main__\":\n\n sys.exit(main(sys.argv[1:]))\n", "file_path": "scripts/parse-include-paths.py", "rank": 95, "score": 54584.30928997 }, { "content": "def iterate_over(dict_or_list, result):\n\n \"\"\"\n\n Iterates recursively over nested lists and dictionaries\n\n keeping track of all \"path\" values with the key \"includePath\"\n\n within nested dictionaries.\n\n \"\"\"\n\n if isinstance(dict_or_list, list):\n\n for child in dict_or_list:\n\n iterate_over(child, result)\n\n elif isinstance(dict_or_list, dict):\n\n for key, value in dict_or_list.items():\n\n if key == \"includePath\":\n\n for child in value:\n\n result.add(child[\"path\"])\n\n else:\n", "file_path": "scripts/parse-include-paths.py", "rank": 96, "score": 52359.88506665927 }, { "content": "def main(arguments):\n\n \"\"\"Main function of this program.\"\"\"\n\n\n\n workspace = os.path.realpath(os.path.join(__file__, os.pardir, os.pardir))\n\n print(\"Workspace root: '{}'\".format(workspace))\n\n\n\n with open(os.path.join(workspace, \".vscode\", \".cmaketools.json\")) as f:\n\n data = json.loads(f.read())\n\n\n\n result = set()\n\n\n\n iterate_over(data, result)\n\n\n\n result = [x.replace(workspace, \"${workspaceRoot}\") for x in result]\n\n\n", "file_path": "scripts/parse-include-paths.py", "rank": 97, "score": 52351.68881771735 }, { "content": "class StdOStream: public Imf::OStream\n\n{\n\npublic:\n\n StdOStream(ostream& stream, const char fileName[])\n\n : Imf::OStream{fileName}, mStream{stream} { }\n\n\n\n void write(const char c[/*n*/], int n) {\n\n clearError();\n\n mStream.write (c, n);\n\n checkError(mStream);\n\n }\n\n\n\n Imf::Int64 tellp() {\n\n return std::streamoff(mStream.tellp());\n\n }\n\n\n\n void seekp(Imf::Int64 pos) {\n\n mStream.seekp(pos);\n\n checkError(mStream);\n\n }\n", "file_path": "src/imageio/ExrImageSaver.cpp", "rank": 98, "score": 44830.846665974044 }, { "content": "#! /usr/bin/env python\n\n\"\"\"\n\nThis script adds a license file to a DMG. Requires Xcode and a plain ascii text\n\nlicense file.\n\nObviously only runs on a Mac.\n\n\n\nCopyright (C) 2011-2013 Jared Hobbs\n\n\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\n\nof this software and associated documentation files (the \"Software\"), to deal\n\nin the Software without restriction, including without limitation the rights\n\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\ncopies of the Software, and to permit persons to whom the Software is\n\nfurnished to do so, subject to the following conditions:\n\n\n\nThe above copyright notice and this permission notice shall be included in\n\nall copies or substantial portions of the Software.\n\n\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\nTHE SOFTWARE.\n\n\"\"\"\n\nimport os\n\nimport sys\n\nimport tempfile\n\nimport optparse\n\n\n\n\n\nclass Path(str):\n\n def __enter__(self):\n\n return self\n\n\n\n def __exit__(self, type, value, traceback):\n\n os.unlink(self)\n\n\n\n\n\ndef mktemp(dir=None, suffix=''):\n\n (fd, filename) = tempfile.mkstemp(dir=dir, suffix=suffix)\n\n os.close(fd)\n\n return Path(filename)\n\n\n\n\n\ndef main(options, args):\n\n dmgFile, license = args\n\n with mktemp('.') as tmpFile:\n\n with open(tmpFile, 'w') as f:\n\n f.write(\"\"\"data 'TMPL' (128, \"LPic\") {\n\n $\"1344 6566 6175 6C74 204C 616E 6775 6167\"\n\n $\"6520 4944 4457 5244 0543 6F75 6E74 4F43\"\n\n $\"4E54 042A 2A2A 2A4C 5354 430B 7379 7320\"\n\n $\"6C61 6E67 2049 4444 5752 441E 6C6F 6361\"\n\n $\"6C20 7265 7320 4944 2028 6F66 6673 6574\"\n\n $\"2066 726F 6D20 3530 3030 4457 5244 1032\"\n\n $\"2D62 7974 6520 6C61 6E67 7561 6765 3F44\"\n\n $\"5752 4404 2A2A 2A2A 4C53 5445\"\n\n};\n\n\n\ndata 'LPic' (5000) {\n\n $\"0000 0002 0000 0000 0000 0000 0004 0000\"\n\n};\n\n\n\ndata 'STR#' (5000, \"English buttons\") {\n\n $\"0006 0D45 6E67 6C69 7368 2074 6573 7431\"\n\n $\"0541 6772 6565 0844 6973 6167 7265 6505\"\n\n $\"5072 696E 7407 5361 7665 2E2E 2E7A 4966\"\n\n $\"2079 6F75 2061 6772 6565 2077 6974 6820\"\n\n $\"7468 6520 7465 726D 7320 6F66 2074 6869\"\n\n $\"7320 6C69 6365 6E73 652C 2063 6C69 636B\"\n\n $\"2022 4167 7265 6522 2074 6F20 6163 6365\"\n\n $\"7373 2074 6865 2073 6F66 7477 6172 652E\"\n\n $\"2020 4966 2079 6F75 2064 6F20 6E6F 7420\"\n\n $\"6167 7265 652C 2070 7265 7373 2022 4469\"\n\n $\"7361 6772 6565 2E22\"\n\n};\n\n\n\ndata 'STR#' (5002, \"English\") {\n\n $\"0006 0745 6E67 6C69 7368 0541 6772 6565\"\n\n $\"0844 6973 6167 7265 6505 5072 696E 7407\"\n\n $\"5361 7665 2E2E 2E7B 4966 2079 6F75 2061\"\n\n $\"6772 6565 2077 6974 6820 7468 6520 7465\"\n\n $\"726D 7320 6F66 2074 6869 7320 6C69 6365\"\n\n $\"6E73 652C 2070 7265 7373 2022 4167 7265\"\n\n $\"6522 2074 6F20 696E 7374 616C 6C20 7468\"\n\n $\"6520 736F 6674 7761 7265 2E20 2049 6620\"\n\n $\"796F 7520 646F 206E 6F74 2061 6772 6565\"\n\n $\"2C20 7072 6573 7320 2244 6973 6167 7265\"\n\n $\"6522 2E\"\n\n};\\n\\n\"\"\")\n\n with open(license, 'r') as l:\n\n kind = 'RTF ' if license.lower().endswith('.rtf') else 'TEXT'\n\n f.write('data \\'%s\\' (5000, \"English\") {\\n' % kind)\n\n def escape(s):\n\n return s.strip().replace('\\\\', '\\\\\\\\').replace('\"', '\\\\\"')\n\n\n\n for line in l:\n\n if len(line) < 1000:\n\n f.write(' \"' + escape(line) + '\\\\n\"\\n')\n\n else:\n\n for liner in line.split('.'):\n\n f.write(' \"' + escape(liner) + '. \\\\n\"\\n')\n\n f.write('};\\n\\n')\n\n f.write(\"\"\"data 'styl' (5000, \"English\") {\n\n $\"0003 0000 0000 000C 0009 0014 0000 0000\"\n\n $\"0000 0000 0000 0000 0027 000C 0009 0014\"\n\n $\"0100 0000 0000 0000 0000 0000 002A 000C\"\n\n $\"0009 0014 0000 0000 0000 0000 0000\"\n\n};\\n\"\"\")\n\n os.system('hdiutil unflatten -quiet \"%s\"' % dmgFile)\n\n ret = os.system('%s -a %s -o \"%s\"' %\n\n (options.rez, tmpFile, dmgFile))\n\n os.system('hdiutil flatten -quiet \"%s\"' % dmgFile)\n\n if options.compression is not None:\n\n os.system('cp %s %s.temp.dmg' % (dmgFile, dmgFile))\n\n os.remove(dmgFile)\n\n if options.compression == \"bz2\":\n\n os.system('hdiutil convert %s.temp.dmg -format UDBZ -o %s' %\n\n (dmgFile, dmgFile))\n\n elif options.compression == \"gz\":\n\n os.system('hdiutil convert %s.temp.dmg -format ' % dmgFile +\n\n 'UDZO -imagekey zlib-devel=9 -o %s' % dmgFile)\n\n os.remove('%s.temp.dmg' % dmgFile)\n\n if ret == 0:\n\n print \"Successfully added license to '%s'\" % dmgFile\n\n else:\n\n print \"Failed to add license to '%s'\" % dmgFile\n\n\n\nif __name__ == '__main__':\n\n parser = optparse.OptionParser()\n\n parser.set_usage(\"\"\"%prog <dmgFile> <licenseFile> [OPTIONS]\n\n This program adds a software license agreement to a DMG file.\n\n It requires Xcode and either a plain ascii text <licenseFile>\n\n or a <licenseFile.rtf> with the RTF contents.\n\n\n\n See --help for more details.\"\"\")\n\n parser.add_option(\n\n '--rez',\n\n '-r',\n\n action='store',\n\n default='/Applications/Xcode.app/Contents/Developer/Tools/Rez',\n\n help='The path to the Rez tool. Defaults to %default'\n\n )\n\n parser.add_option(\n\n '--compression',\n\n '-c',\n\n action='store',\n\n choices=['bz2', 'gz'],\n\n default=None,\n\n help='Optionally compress dmg using specified compression type. '\n\n 'Choices are bz2 and gz.'\n\n )\n\n options, args = parser.parse_args()\n\n cond = len(args) != 2\n\n if not os.path.exists(options.rez):\n\n print 'Failed to find Rez at \"%s\"!\\n' % options.rez\n\n cond = True\n\n if cond:\n\n parser.print_usage()\n\n sys.exit(1)\n\n main(options, args)\n", "file_path": "scripts/create-dmg/support/dmg-license.py", "rank": 99, "score": 37567.87811205298 } ]
C++
externals/mpir-3.0.0/tests/cxx/t-binary.cc
JaminChan/eos_win
c03e57151cfe152d0d3120abb13226f4df74f37e
#include <iostream> #include "mpir.h" #include "mpirxx.h" #include "gmp-impl.h" #include "tests.h" using namespace std; void check_mpz (void) { { mpz_class a(1), b(2); mpz_class c(a + b); ASSERT_ALWAYS(c == 3); } { mpz_class a(3), b(4); mpz_class c; c = a * b; ASSERT_ALWAYS(c == 12); } { mpz_class a(5), b(3); mpz_class c; c = a % b; ASSERT_ALWAYS(c == 2); } { mpz_class a(1); signed int b = 3; mpz_class c(a - b); ASSERT_ALWAYS(c == -2); } { mpz_class a(-8); unsigned int b = 2; mpz_class c; c = a / b; ASSERT_ALWAYS(c == -4); } { mpz_class a(2); double b = 3.0; mpz_class c(a + b); ASSERT_ALWAYS(c == 5); } { mpz_class a(4); mpz_class b; b = a + 0; ASSERT_ALWAYS(b == 4); } { mpz_class a(3); signed int b = 9; mpz_class c(b / a); ASSERT_ALWAYS(c == 3); } { mpz_class a(3), b(4); mpz_class c(a * (-b)); ASSERT_ALWAYS(c == -12); } { mpz_class a(3), b(2), c(1); mpz_class d; d = (a % b) + c; ASSERT_ALWAYS(d == 2); } { mpz_class a(-5); unsigned int b = 2; mpz_class c((-a) << b); ASSERT_ALWAYS(c == 20); } { mpz_class a(5), b(-4); signed int c = 3; mpz_class d; d = (a * b) >> c; ASSERT_ALWAYS(d == -3); } { mpz_class a(2), b(4); double c = 6; mpz_class d(c / (a - b)); ASSERT_ALWAYS(d == -3); } { mpz_class a(3), b(2); double c = 1; mpz_class d; d = c + (a + b); ASSERT_ALWAYS(d == 6); } { mpz_class a(3), b(5), c(7); mpz_class d; d = (a - b) * (-c); ASSERT_ALWAYS(d == 14); } } void check_mpq (void) { { mpq_class a(1, 2), b(3, 4); mpq_class c(a + b); ASSERT_ALWAYS(c == 1.25); } { mpq_class a(1, 2); signed int b = 3; mpq_class c(a - b); ASSERT_ALWAYS(c == -2.5); } { mpq_class a(1, 2); mpq_class b; b = a + 0; ASSERT_ALWAYS(b == 0.5); } { mpq_class a(2, 3); signed int b = 4; mpq_class c; c = b / a; ASSERT_ALWAYS(c == 6); } { mpq_class a(1, 2); mpz_class b(1); mpq_class c(a + b); ASSERT_ALWAYS(c == 1.5); } { mpq_class a(2, 3); mpz_class b(1); double c = 2.0; mpq_class d; d = a * (b + c); ASSERT_ALWAYS(d == 2); } { mpq_class a(2, 3); mpz_class b(4); mpq_class c(b / a); ASSERT_ALWAYS(c == 6); } { mpq_class a(2, 3); mpz_class b(1), c(4); mpq_class d; d = (b - c) * a; ASSERT_ALWAYS(d == -2); } { mpq_class a(1, 3), b(3, 4); mpq_class c; c = a * (-b); ASSERT_ALWAYS(c == -0.25); } { mpq_class a(1, 3), b(2, 3), c(1, 4); mpq_class d((a / b) + c); ASSERT_ALWAYS(d == 0.75); } { mpq_class a(3, 8); unsigned int b = 4; mpq_class c((-a) << b); ASSERT_ALWAYS(c == -6); } { mpq_class a(1, 2), b(1, 4); double c = 6.0; mpq_class d; d = c / (a + b); ASSERT_ALWAYS(d == 8); } { mpq_class a(1, 2), b(1, 4); mpz_class c(1); mpq_class d((a + b) - c); ASSERT_ALWAYS(d == -0.25); } { mpq_class a(1, 3), b(3, 2); mpz_class c(2), d(4); mpq_class e; e = (a * b) / (c - d); ASSERT_ALWAYS(e == -0.25); } { mpq_class a(1, 3), b(3, 4); mpz_class c(-3); mpq_class d(c * (a * b)); ASSERT_ALWAYS(d == -0.75); } { mpq_class a(1, 3), b(3, 5); mpz_class c(6); signed int d = 4; mpq_class e; e = (c % d) / (a * b); ASSERT_ALWAYS(e == 10); } { mpq_class a(1, 3), b(3, 4), c(2, 5); mpq_class d; d = (a * b) / (-c); ASSERT_ALWAYS(d == -0.625); } } void check_mpf (void) { { mpf_class a(1), b(2); mpf_class c(a + b); ASSERT_ALWAYS(c == 3); } { mpf_class a(1.5), b(6); mpf_class c; c = a / b; ASSERT_ALWAYS(c == 0.25); } { mpf_class a(1); signed int b = -2; mpf_class c(a - b); ASSERT_ALWAYS(c == 3); } { mpf_class a(2); mpf_class b; b = a + 0; ASSERT_ALWAYS(b == 2); } { mpf_class a(2); unsigned int b = 3; mpf_class c; c = b / a; ASSERT_ALWAYS(c == 1.5); } { mpf_class a(2); mpz_class b(3); mpf_class c(a - b); ASSERT_ALWAYS(c == -1); } { mpf_class a(3); mpz_class b(2), c(1); mpf_class d; d = a * (b + c); ASSERT_ALWAYS(d == 9); } { mpf_class a(6); mpq_class b(3, 4); mpf_class c(a * b); ASSERT_ALWAYS(c == 4.5); } { mpf_class a(2), b(-3); mpf_class c; c = a * (-b); ASSERT_ALWAYS(c == 6); } { mpf_class a(3), b(4), c(5); mpf_class d; d = (a / b) - c; ASSERT_ALWAYS(d == -4.25); } { mpf_class a(3); unsigned int b = 2; mpf_class c((-a) >> b); ASSERT_ALWAYS(c == -0.75); } { mpf_class a(2), b(3); double c = 5.0; mpf_class d; d = c / (a + b); ASSERT_ALWAYS(d == 1); } { mpf_class a(2), b(3); mpz_class c(4); mpf_class d; d = (a + b) * c; ASSERT_ALWAYS(d == 20); } { mpf_class a(2), b(3); mpq_class c(1, 2), d(1, 4); mpf_class e; e = (a * b) / (c + d); ASSERT_ALWAYS(e == 8); } { mpf_class a(1), b(2); mpq_class c(3); mpf_class d(c / (a + b)); ASSERT_ALWAYS(d == 1); } { mpf_class a(1); mpz_class b(2); mpq_class c(3, 4); mpf_class d; d = (-c) + (a + b); ASSERT_ALWAYS(d == 2.25); } { mpf_class a(1), b(2), c(3); mpf_class d; d = (a + b) * (-c); ASSERT_ALWAYS(d == -9); } } int main (void) { tests_start(); check_mpz(); check_mpq(); check_mpf(); tests_end(); return 0; }
#include <iostream> #include "mpir.h" #include "mpirxx.h" #include "gmp-impl.h" #include "tests.h" using namespace std; void check_mpz (void) { { mpz_class a(1), b(2); mpz_class c(a + b); ASSERT_ALWAYS(c == 3); } { mpz_class a(3), b(4); mpz_class c; c = a * b; ASSERT_ALWAYS(c == 12); } { mpz_class a(5), b(3); mpz_class c; c = a % b; ASSERT_ALWAYS(c == 2); } { mpz_class a(1); signed int b = 3; mpz_class c(a - b); ASSERT_ALWAYS(c == -2); } { mpz_class a(-8); unsigned int b = 2; mpz_class c; c = a / b; ASSERT_ALWAYS(c == -4); } { mpz_class a(2); double b = 3.0; mpz_class c(a + b); ASSERT_ALWAYS(c == 5); } { mpz_class a(4); mpz_class b; b = a + 0; ASSERT_ALWAYS(b == 4); } { mpz_class a(3); signed int b = 9; mpz_class c(b / a); ASSERT_ALWAYS(c == 3); } { mpz_class a(3), b(4); mpz_class c(a * (-b)); ASSERT_ALWAYS(c == -12); } { mpz_class a(3), b(2), c(1); mpz_class d; d = (a % b) + c; ASSERT_ALWAYS(d == 2); } { mpz_class a(-5); unsigned int b = 2; mpz_class c((-a) << b); ASSERT_ALWAYS(c == 20); } { mpz_class a(5), b(-4); signed int c = 3; mpz_class d; d = (a * b) >> c; ASSERT_ALWAYS(d == -3); } { mpz_class a(2), b(4); double c = 6; mpz_class d(c / (a - b)); ASSERT_ALWAYS(d == -3); } { mpz_class a(3), b(2); double c = 1; mpz_class d; d = c + (a + b); ASSERT_ALWAYS(d == 6); } { mpz_class a(3), b(5), c(7); mpz_class d; d = (a - b) * (-c); ASSERT_ALWAYS(d == 14); } } void check_mpq (void) { { mpq_class a(1, 2), b(3, 4); mpq_class c(a + b); ASSERT_ALWAYS(c == 1.25); } { mpq_class a(1, 2); signed int b = 3; mpq_class c(a - b); ASSERT_ALWAYS(c == -2.5); } { mpq_class a(1, 2); mpq_class b; b = a + 0; ASSERT_ALWA
2), b(1, 4); mpz_class c(1); mpq_class d((a + b) - c); ASSERT_ALWAYS(d == -0.25); } { mpq_class a(1, 3), b(3, 2); mpz_class c(2), d(4); mpq_class e; e = (a * b) / (c - d); ASSERT_ALWAYS(e == -0.25); } { mpq_class a(1, 3), b(3, 4); mpz_class c(-3); mpq_class d(c * (a * b)); ASSERT_ALWAYS(d == -0.75); } { mpq_class a(1, 3), b(3, 5); mpz_class c(6); signed int d = 4; mpq_class e; e = (c % d) / (a * b); ASSERT_ALWAYS(e == 10); } { mpq_class a(1, 3), b(3, 4), c(2, 5); mpq_class d; d = (a * b) / (-c); ASSERT_ALWAYS(d == -0.625); } } void check_mpf (void) { { mpf_class a(1), b(2); mpf_class c(a + b); ASSERT_ALWAYS(c == 3); } { mpf_class a(1.5), b(6); mpf_class c; c = a / b; ASSERT_ALWAYS(c == 0.25); } { mpf_class a(1); signed int b = -2; mpf_class c(a - b); ASSERT_ALWAYS(c == 3); } { mpf_class a(2); mpf_class b; b = a + 0; ASSERT_ALWAYS(b == 2); } { mpf_class a(2); unsigned int b = 3; mpf_class c; c = b / a; ASSERT_ALWAYS(c == 1.5); } { mpf_class a(2); mpz_class b(3); mpf_class c(a - b); ASSERT_ALWAYS(c == -1); } { mpf_class a(3); mpz_class b(2), c(1); mpf_class d; d = a * (b + c); ASSERT_ALWAYS(d == 9); } { mpf_class a(6); mpq_class b(3, 4); mpf_class c(a * b); ASSERT_ALWAYS(c == 4.5); } { mpf_class a(2), b(-3); mpf_class c; c = a * (-b); ASSERT_ALWAYS(c == 6); } { mpf_class a(3), b(4), c(5); mpf_class d; d = (a / b) - c; ASSERT_ALWAYS(d == -4.25); } { mpf_class a(3); unsigned int b = 2; mpf_class c((-a) >> b); ASSERT_ALWAYS(c == -0.75); } { mpf_class a(2), b(3); double c = 5.0; mpf_class d; d = c / (a + b); ASSERT_ALWAYS(d == 1); } { mpf_class a(2), b(3); mpz_class c(4); mpf_class d; d = (a + b) * c; ASSERT_ALWAYS(d == 20); } { mpf_class a(2), b(3); mpq_class c(1, 2), d(1, 4); mpf_class e; e = (a * b) / (c + d); ASSERT_ALWAYS(e == 8); } { mpf_class a(1), b(2); mpq_class c(3); mpf_class d(c / (a + b)); ASSERT_ALWAYS(d == 1); } { mpf_class a(1); mpz_class b(2); mpq_class c(3, 4); mpf_class d; d = (-c) + (a + b); ASSERT_ALWAYS(d == 2.25); } { mpf_class a(1), b(2), c(3); mpf_class d; d = (a + b) * (-c); ASSERT_ALWAYS(d == -9); } } int main (void) { tests_start(); check_mpz(); check_mpq(); check_mpf(); tests_end(); return 0; }
YS(b == 0.5); } { mpq_class a(2, 3); signed int b = 4; mpq_class c; c = b / a; ASSERT_ALWAYS(c == 6); } { mpq_class a(1, 2); mpz_class b(1); mpq_class c(a + b); ASSERT_ALWAYS(c == 1.5); } { mpq_class a(2, 3); mpz_class b(1); double c = 2.0; mpq_class d; d = a * (b + c); ASSERT_ALWAYS(d == 2); } { mpq_class a(2, 3); mpz_class b(4); mpq_class c(b / a); ASSERT_ALWAYS(c == 6); } { mpq_class a(2, 3); mpz_class b(1), c(4); mpq_class d; d = (b - c) * a; ASSERT_ALWAYS(d == -2); } { mpq_class a(1, 3), b(3, 4); mpq_class c; c = a * (-b); ASSERT_ALWAYS(c == -0.25); } { mpq_class a(1, 3), b(2, 3), c(1, 4); mpq_class d((a / b) + c); ASSERT_ALWAYS(d == 0.75); } { mpq_class a(3, 8); unsigned int b = 4; mpq_class c((-a) << b); ASSERT_ALWAYS(c == -6); } { mpq_class a(1, 2), b(1, 4); double c = 6.0; mpq_class d; d = c / (a + b); ASSERT_ALWAYS(d == 8); } { mpq_class a(1,
random
[]
C++
Classes/Scene/BattleMode/BattleScene.cpp
jimmyy512/LegendStory
d2b271023d02eab4f1b540a297d56eae5716bf1f
#include "scene/BattleMode/BattleScene.h" #include <sstream> #include "cocos-ext.h" #include "spine\spine-cocos2dx.h" #include "spine\spine.h" #include "Tools\AudioManagement.h" #include "UI\BattleMode\BattleHUDlayer.h" #include "Map\BattleMode\BattleMap.h" #include "Monster\BattleMode\BattleSoldierFactory.h" #include "Monster\BattleMode\SoldierAI.h" #include "Scene\DeveloperMenuScene.h" #include "ExtensionsAlgorithm.h" #include "DebugLayer.h" USING_NS_CC; USING_NS_CC_EXT; using namespace spine; using namespace cocos2d::experimental; NS_BATTLEMODE_BEGAN BattleScene* BattleScene::static_BattleScene = nullptr; cocos2d::Scene * BattleScene::createScene(int our, int enemy) { auto scene = Scene::createWithPhysics(); auto layer = BattleScene::create(our,enemy); scene->addChild(layer); return scene; } BattleScene* BattleScene::getBattleScene() { if (static_BattleScene == nullptr) return nullptr; else return static_BattleScene; } BattleScene::BattleScene() { this->_continuousClickCount=0; } BattleScene::~BattleScene() { NotificationCenter::getInstance()->removeAllObservers(this); AudioManagement::getInstance()->clearAudioManagement(); SoldierAI::getInstance()->clearData(); static_BattleScene = nullptr; } BattleScene* BattleScene::create(int our, int enemy) { BattleScene* _ptr = new (std::nothrow)BattleScene; if (_ptr && _ptr->init(our,enemy)) { _ptr->autorelease(); } else { CC_SAFE_DELETE(_ptr); } return _ptr; } bool BattleScene::init(int our, int enemy) { if (!Layer::init()) { return false; } static_BattleScene = this; visible = Director::getInstance()->getVisibleSize(); origin = Director::getInstance()->getVisibleOrigin(); NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(BattleScene::pauseBattleMapListenerCallBack), "PauseBattleMapListenerCallBack", NULL); NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(BattleScene::resumeBattleMapListenerCallBack), "ResumeBattleMapListenerCallBack", NULL); AudioManagement::getInstance()->play("music/battleMusic3.mp3", AudioManagement::AudioType::Music, true); auto battleMap = BattleMap::create("map/BattleMode/battleMap.png"); battleMap->setScale(0.8f); battleMap->setAnchorPoint(cocos2d::Vec2(0, 0)); battleMap->setPosition(cocos2d::Vec2(0, 0)); this->addChild(battleMap, 0, BattleMapTag); auto hudlayer = BattleMode::BattleHUDlayer::create(); this->addChild(hudlayer,1); this->m_ScaleOfScene = 1.0f; this->schedule([this](float dt) { SoldierAI::getInstance()->updateSoldierAI(); }, 0.7f, "SoldierAIUpdate"); this->schedule([this](float dt) { SoldierAI::getInstance()->updateBattleSoldier(); }, 0.2f, "BattleSoldierUpdate"); this->schedule([this](float dt) { SoldierAI::getInstance()->updateSoldierPosition(); }, 0.04f, "SoldierPositionupdate"); auto multiTouchListener = EventListenerTouchAllAtOnce::create(); multiTouchListener->onTouchesBegan = [&](std::vector<Touch*> touch, Event* event) { if (SoldierAI::getInstance()->getOurSoldierSelectedTotal() >= 1) { this->_continuousClickCount++; this->_currentClickTime = ExtensionsAlgorithm::getCurrentTime(); if (this->_currentClickTime -this->_prevClickTime < 10) { this->_continuousClickCount = 0; } if (this->_continuousClickCount >= 2 && this->_currentClickTime - this->_prevClickTime < 300 && touch.size()==1) { Vec2 battleMapAnchorPoint = BattleMap::getBattleMap()->getAnchorPoint(); Size battleMapSize = BattleMap::getBattleMap()->getBoundingBox().size; battleMapSize.width = battleMapSize.width*battleMapAnchorPoint.x; battleMapSize.height = battleMapSize.height*battleMapAnchorPoint.y; Vec2 touchOnBattleMap = touch[0]->getLocation() + (-BattleMap::getBattleMap()->getPosition()); touchOnBattleMap.x = touchOnBattleMap.x + battleMapSize.width; touchOnBattleMap.y = touchOnBattleMap.y + battleMapSize.height; SoldierAI::getInstance()->_structAICommand.AssignMoveCommand = true; AudioManagement::getInstance()->play("sound/assignPos.mp3", AudioManagement::AudioType::Sound, false); Sprite* targetFlag = (Sprite*)BattleMap::getBattleMap()->getChildByTag(BattleMap::TARGET_FLAG); targetFlag->setVisible(true); targetFlag->setPosition(touchOnBattleMap*(1 / BattleMap::getBattleMap()->getScale())); SoldierAI::getInstance()->updateSelectedLegionFlagTargetPosition(targetFlag->getPosition()); this->_continuousClickCount = 0; } this->_prevClickTime = this->_currentClickTime; } }; multiTouchListener->onTouchesMoved = [this](std::vector<Touch*> touches, Event* event) { BattleMap* battleMap = (BattleMap*)getChildByTag(BattleMapTag); if (touches.size() >= 2) { auto point1 = touches[0]->getLocation(); auto point2 = touches[1]->getLocation(); auto currDistance = point1.distance(point2); auto prevDistance = touches[0]->getPreviousLocation().distance(touches[1]->getPreviousLocation()); cocos2d::Vec2 touchWithOrginDef1 = point1 - mapCurrentPosition; cocos2d::Vec2 touchWithOrginDef2 = point2 - mapCurrentPosition; float touchWithOrginMidX = (touchWithOrginDef1.x + touchWithOrginDef2.x) / 2; float touchWithOrginMidY = (touchWithOrginDef1.y + touchWithOrginDef2.y) / 2; auto newAnchorX = touchWithOrginMidX / battleMap->getBoundingBox().size.width; auto newAnchorY = touchWithOrginMidY / battleMap->getBoundingBox().size.height; battleMap->setAnchorPoint(cocos2d::Vec2(newAnchorX, newAnchorY)); cocos2d::Vec2 mapNewPosition; mapNewPosition.x = (point2.x + point1.x) / 2; mapNewPosition.y = (point2.y + point1.y) / 2; if (currDistance > prevDistance) { m_ScaleOfScene += 0.01f; if (m_ScaleOfScene > 1.8f) m_ScaleOfScene = 1.8f; battleMap->setScale(m_ScaleOfScene); } else if (currDistance < prevDistance) { m_ScaleOfScene -= 0.01f; if (m_ScaleOfScene < 0.8f) m_ScaleOfScene = 0.8f; battleMap->setScale(m_ScaleOfScene); } Size battleMapOirginSize = battleMap->getBoundingBox().size; if (mapCurrentPosition.x > 0) { mapNewPosition.x -= mapCurrentPosition.x; } if (mapCurrentPosition.x < (-battleMapOirginSize.width) + visible.width) { mapNewPosition.x += (-battleMapOirginSize.width) + visible.width - mapCurrentPosition.x; } if (mapCurrentPosition.y > 0) { mapNewPosition.y -= mapCurrentPosition.y; } if (mapCurrentPosition.y < (-battleMapOirginSize.height) + visible.height) { mapNewPosition.y += (-battleMapOirginSize.height) + visible.height - mapCurrentPosition.y; } if (mapNewPosition != battleMap->getPosition()) { this->_continuousClickCount = 0; } battleMap->setPosition(mapNewPosition); mapCurrentPosition = cocos2d::Vec2(mapNewPosition.x, mapNewPosition.y)- cocos2d::Vec2(battleMapOirginSize.width * newAnchorX, battleMapOirginSize.height * newAnchorY); } else { Size battleMapOirginSize = battleMap->getBoundingBox().size; auto touch = touches[0]; auto currentPointToPreviousPointDistance = touch->getDelta(); auto pos = battleMap->getPosition() + currentPointToPreviousPointDistance; auto MaxMapPosX = battleMapOirginSize.width * battleMap->getAnchorPoint().x+origin.x; auto MaxMapPosY = battleMapOirginSize.height * battleMap->getAnchorPoint().y+origin.y; auto MinMapPosX = -battleMapOirginSize.width + visible.width + battleMapOirginSize.width * battleMap->getAnchorPoint().x+origin.x; auto MinMapPosY = -battleMapOirginSize.height + visible.height + battleMapOirginSize.height * battleMap->getAnchorPoint().y+origin.y; pos.x = MIN(pos.x, MaxMapPosX); pos.x = MAX(pos.x, MinMapPosX); pos.y = MIN(pos.y, MaxMapPosY); pos.y = MAX(pos.y, MinMapPosY); if (pos != battleMap->getPosition()) { this->_continuousClickCount = 0; } battleMap->setPosition(pos.x,pos.y); if (pos.x >= MaxMapPosX || pos.x <= MinMapPosX) { currentPointToPreviousPointDistance.x = 0; } if (pos.y >= MaxMapPosY || pos.y <= MinMapPosY) { currentPointToPreviousPointDistance.y = 0; } mapCurrentPosition += currentPointToPreviousPointDistance; } }; multiTouchListener->onTouchesEnded = [this](std::vector<Touch*> touches, Event* event) { }; Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(multiTouchListener, this); SoldierAI::getInstance()->generateOneLegion(1, 48, SoldierType::Musket, SoldierCamp::OurSoldier, battleMap, cocos2d::Vec2(250, 400)); SoldierAI::getInstance()->generateOneLegion(2, 48, SoldierType::ShieldSoldier, SoldierCamp::EnemySoldier, battleMap, cocos2d::Vec2(1500, 400)); SoldierAI::getInstance()->generateOneLegion(1, 48, SoldierType::Musket, SoldierCamp::OurSoldier, battleMap, cocos2d::Vec2(250, 200)); SoldierAI::getInstance()->generateOneLegion(2, 48, SoldierType::ShieldSoldier, SoldierCamp::EnemySoldier, battleMap, cocos2d::Vec2(1500, 200)); return true; } void BattleScene::pauseBattleMapListenerCallBack(Ref* ref) { auto battleMap = getChildByTag(BattleMapTag); Director::getInstance()->getEventDispatcher()->pauseEventListenersForTarget(battleMap, true); } void BattleScene::resumeBattleMapListenerCallBack(Ref* ref) { auto battleMap = getChildByTag(BattleMapTag); Director::getInstance()->getEventDispatcher()->resumeEventListenersForTarget(battleMap, true); } NS_BATTLEMODE_END
#include "scene/BattleMode/BattleScene.h" #include <sstream> #include "cocos-ext.h" #include "spine\spine-cocos2dx.h" #include "spine\spine.h" #include "Tools\AudioManagement.h" #include "UI\BattleMode\BattleHUDlayer.h" #include "Map\BattleMode\BattleMap.h" #include "Monster\BattleMode\BattleSoldierFactory.h" #include "Monster\BattleMode\SoldierAI.h" #include "Scene\DeveloperMenuScene.h" #include "ExtensionsAlgorithm.h" #include "DebugLayer.h" USING_NS_CC; USING_NS_CC_EXT; using namespace spine; using namespace cocos2d::experimental; NS_BATTLEMODE_BEGAN BattleScene* BattleScene::static_BattleScene = nullptr; cocos2d::Scene * BattleScene::createScene(int our, int enemy) { auto scene = Scene::createWithPhysics(); auto layer = BattleScene::create(our,enemy); scene->addChild(layer); return scene; } BattleScene* BattleScene::getBattleScene() { if (static_BattleScene == nullptr) return nullptr; else return static_BattleScene; } BattleScene::BattleScene() { this->_continuousClickCount=0; } BattleScene::~BattleScene() { NotificationCenter::getInstance()->removeAllObservers(this); AudioManagement::getInstance()->clearAudioManagement(); SoldierAI::getInstance()->clearData(); static_BattleScene = nullptr; } BattleScene* BattleScene::create(int our, int enemy) { BattleScene* _ptr = new (std::nothrow)BattleScene; if (_ptr && _ptr->init(our,enemy)) { _ptr->autorelease(); } else { CC_SAFE_DELETE(_ptr); } return _ptr; } bool BattleScene::init(int our, int enemy) { if (!Layer::init()) { return false; } static
irginSize.width * battleMap->getAnchorPoint().x+origin.x; auto MaxMapPosY = battleMapOirginSize.height * battleMap->getAnchorPoint().y+origin.y; auto MinMapPosX = -battleMapOirginSize.width + visible.width + battleMapOirginSize.width * battleMap->getAnchorPoint().x+origin.x; auto MinMapPosY = -battleMapOirginSize.height + visible.height + battleMapOirginSize.height * battleMap->getAnchorPoint().y+origin.y; pos.x = MIN(pos.x, MaxMapPosX); pos.x = MAX(pos.x, MinMapPosX); pos.y = MIN(pos.y, MaxMapPosY); pos.y = MAX(pos.y, MinMapPosY); if (pos != battleMap->getPosition()) { this->_continuousClickCount = 0; } battleMap->setPosition(pos.x,pos.y); if (pos.x >= MaxMapPosX || pos.x <= MinMapPosX) { currentPointToPreviousPointDistance.x = 0; } if (pos.y >= MaxMapPosY || pos.y <= MinMapPosY) { currentPointToPreviousPointDistance.y = 0; } mapCurrentPosition += currentPointToPreviousPointDistance; } }; multiTouchListener->onTouchesEnded = [this](std::vector<Touch*> touches, Event* event) { }; Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(multiTouchListener, this); SoldierAI::getInstance()->generateOneLegion(1, 48, SoldierType::Musket, SoldierCamp::OurSoldier, battleMap, cocos2d::Vec2(250, 400)); SoldierAI::getInstance()->generateOneLegion(2, 48, SoldierType::ShieldSoldier, SoldierCamp::EnemySoldier, battleMap, cocos2d::Vec2(1500, 400)); SoldierAI::getInstance()->generateOneLegion(1, 48, SoldierType::Musket, SoldierCamp::OurSoldier, battleMap, cocos2d::Vec2(250, 200)); SoldierAI::getInstance()->generateOneLegion(2, 48, SoldierType::ShieldSoldier, SoldierCamp::EnemySoldier, battleMap, cocos2d::Vec2(1500, 200)); return true; } void BattleScene::pauseBattleMapListenerCallBack(Ref* ref) { auto battleMap = getChildByTag(BattleMapTag); Director::getInstance()->getEventDispatcher()->pauseEventListenersForTarget(battleMap, true); } void BattleScene::resumeBattleMapListenerCallBack(Ref* ref) { auto battleMap = getChildByTag(BattleMapTag); Director::getInstance()->getEventDispatcher()->resumeEventListenersForTarget(battleMap, true); } NS_BATTLEMODE_END
_BattleScene = this; visible = Director::getInstance()->getVisibleSize(); origin = Director::getInstance()->getVisibleOrigin(); NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(BattleScene::pauseBattleMapListenerCallBack), "PauseBattleMapListenerCallBack", NULL); NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(BattleScene::resumeBattleMapListenerCallBack), "ResumeBattleMapListenerCallBack", NULL); AudioManagement::getInstance()->play("music/battleMusic3.mp3", AudioManagement::AudioType::Music, true); auto battleMap = BattleMap::create("map/BattleMode/battleMap.png"); battleMap->setScale(0.8f); battleMap->setAnchorPoint(cocos2d::Vec2(0, 0)); battleMap->setPosition(cocos2d::Vec2(0, 0)); this->addChild(battleMap, 0, BattleMapTag); auto hudlayer = BattleMode::BattleHUDlayer::create(); this->addChild(hudlayer,1); this->m_ScaleOfScene = 1.0f; this->schedule([this](float dt) { SoldierAI::getInstance()->updateSoldierAI(); }, 0.7f, "SoldierAIUpdate"); this->schedule([this](float dt) { SoldierAI::getInstance()->updateBattleSoldier(); }, 0.2f, "BattleSoldierUpdate"); this->schedule([this](float dt) { SoldierAI::getInstance()->updateSoldierPosition(); }, 0.04f, "SoldierPositionupdate"); auto multiTouchListener = EventListenerTouchAllAtOnce::create(); multiTouchListener->onTouchesBegan = [&](std::vector<Touch*> touch, Event* event) { if (SoldierAI::getInstance()->getOurSoldierSelectedTotal() >= 1) { this->_continuousClickCount++; this->_currentClickTime = ExtensionsAlgorithm::getCurrentTime(); if (this->_currentClickTime -this->_prevClickTime < 10) { this->_continuousClickCount = 0; } if (this->_continuousClickCount >= 2 && this->_currentClickTime - this->_prevClickTime < 300 && touch.size()==1) { Vec2 battleMapAnchorPoint = BattleMap::getBattleMap()->getAnchorPoint(); Size battleMapSize = BattleMap::getBattleMap()->getBoundingBox().size; battleMapSize.width = battleMapSize.width*battleMapAnchorPoint.x; battleMapSize.height = battleMapSize.height*battleMapAnchorPoint.y; Vec2 touchOnBattleMap = touch[0]->getLocation() + (-BattleMap::getBattleMap()->getPosition()); touchOnBattleMap.x = touchOnBattleMap.x + battleMapSize.width; touchOnBattleMap.y = touchOnBattleMap.y + battleMapSize.height; SoldierAI::getInstance()->_structAICommand.AssignMoveCommand = true; AudioManagement::getInstance()->play("sound/assignPos.mp3", AudioManagement::AudioType::Sound, false); Sprite* targetFlag = (Sprite*)BattleMap::getBattleMap()->getChildByTag(BattleMap::TARGET_FLAG); targetFlag->setVisible(true); targetFlag->setPosition(touchOnBattleMap*(1 / BattleMap::getBattleMap()->getScale())); SoldierAI::getInstance()->updateSelectedLegionFlagTargetPosition(targetFlag->getPosition()); this->_continuousClickCount = 0; } this->_prevClickTime = this->_currentClickTime; } }; multiTouchListener->onTouchesMoved = [this](std::vector<Touch*> touches, Event* event) { BattleMap* battleMap = (BattleMap*)getChildByTag(BattleMapTag); if (touches.size() >= 2) { auto point1 = touches[0]->getLocation(); auto point2 = touches[1]->getLocation(); auto currDistance = point1.distance(point2); auto prevDistance = touches[0]->getPreviousLocation().distance(touches[1]->getPreviousLocation()); cocos2d::Vec2 touchWithOrginDef1 = point1 - mapCurrentPosition; cocos2d::Vec2 touchWithOrginDef2 = point2 - mapCurrentPosition; float touchWithOrginMidX = (touchWithOrginDef1.x + touchWithOrginDef2.x) / 2; float touchWithOrginMidY = (touchWithOrginDef1.y + touchWithOrginDef2.y) / 2; auto newAnchorX = touchWithOrginMidX / battleMap->getBoundingBox().size.width; auto newAnchorY = touchWithOrginMidY / battleMap->getBoundingBox().size.height; battleMap->setAnchorPoint(cocos2d::Vec2(newAnchorX, newAnchorY)); cocos2d::Vec2 mapNewPosition; mapNewPosition.x = (point2.x + point1.x) / 2; mapNewPosition.y = (point2.y + point1.y) / 2; if (currDistance > prevDistance) { m_ScaleOfScene += 0.01f; if (m_ScaleOfScene > 1.8f) m_ScaleOfScene = 1.8f; battleMap->setScale(m_ScaleOfScene); } else if (currDistance < prevDistance) { m_ScaleOfScene -= 0.01f; if (m_ScaleOfScene < 0.8f) m_ScaleOfScene = 0.8f; battleMap->setScale(m_ScaleOfScene); } Size battleMapOirginSize = battleMap->getBoundingBox().size; if (mapCurrentPosition.x > 0) { mapNewPosition.x -= mapCurrentPosition.x; } if (mapCurrentPosition.x < (-battleMapOirginSize.width) + visible.width) { mapNewPosition.x += (-battleMapOirginSize.width) + visible.width - mapCurrentPosition.x; } if (mapCurrentPosition.y > 0) { mapNewPosition.y -= mapCurrentPosition.y; } if (mapCurrentPosition.y < (-battleMapOirginSize.height) + visible.height) { mapNewPosition.y += (-battleMapOirginSize.height) + visible.height - mapCurrentPosition.y; } if (mapNewPosition != battleMap->getPosition()) { this->_continuousClickCount = 0; } battleMap->setPosition(mapNewPosition); mapCurrentPosition = cocos2d::Vec2(mapNewPosition.x, mapNewPosition.y)- cocos2d::Vec2(battleMapOirginSize.width * newAnchorX, battleMapOirginSize.height * newAnchorY); } else { Size battleMapOirginSize = battleMap->getBoundingBox().size; auto touch = touches[0]; auto currentPointToPreviousPointDistance = touch->getDelta(); auto pos = battleMap->getPosition() + currentPointToPreviousPointDistance; auto MaxMapPosX = battleMapO
random
[ { "content": "#include \"cocos2d.h\"\n\n#include \"DefinitionBattleMode.h\"\n\n#include \"cocostudio\\CocoStudio.h\"\n\n#include \"ui/CocosGUI.h\"\n\nclass LoginScene : public cocos2d::Layer\n\n{\n\npublic:\n\n static cocos2d::Scene* createScene();\n\n virtual bool init();\n\n CREATE_FUNC(LoginScene);\n\nprivate:\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n\tcocos2d::Label* resaultLabel;\n\n\tcocos2d::ui::TextField* userName;\n\n\tcocos2d::ui::TextField* userPass;\n\n\tcocos2d::ui::Button* loginButton;\n\n\tstd::string recvbuf;\n\n\tvoid curlConnect();\n\n};\n\n#endif // __GameScene_SCENE_H__\n", "file_path": "Classes/Scene/LoginScene.h", "rank": 0, "score": 133626.77002633078 }, { "content": "#include \"cocos2d.h\"\n\n#include \"cocos-ext.h\"\n\n#include \"cocostudio\\CocoStudio.h\"\n\nclass FailScene : public cocos2d::Layer\n\n{\n\npublic:\n\n static cocos2d::Scene* createScene();\n\n virtual bool init();\n\n CREATE_FUNC(FailScene);\n\nprivate:\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n\tcocos2d::Node* _sceneNode;\n\n\tvirtual void onExit();\n\n\tbool _isReplaceScene;\n\n};\n\n\n\n#endif\n", "file_path": "Classes/Scene/FailScene.h", "rank": 1, "score": 133626.6655965187 }, { "content": "", "file_path": "Classes/Scene/ItemScene.h", "rank": 2, "score": 133619.9726219377 }, { "content": "", "file_path": "Classes/Scene/StoreScene.h", "rank": 3, "score": 133619.9726219377 }, { "content": "class MissionScene : public cocos2d::Layer\n\n{\n\npublic:\n\n static cocos2d::Scene* createScene(cocos2d::RenderTexture* capture);\n\n virtual bool init();\n\n CREATE_FUNC(MissionScene);\n\nprivate:\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n\tcocos2d::Node* _sceneCSB;\n\n\tcocos2d::Label* _missionTitle;\n\n\tcocos2d::Label* _missionContent;\n\n\tcocos2d::Label* _missionTip;\n\n\tShakeButton* _returnBtn;\n\n\tvirtual void onEnterTransitionDidFinish();\n\n};\n\n\n\n#endif\n", "file_path": "Classes/Scene/MissionScene.h", "rank": 4, "score": 133619.9726219377 }, { "content": "", "file_path": "Classes/Scene/CreateCharacterScene.h", "rank": 5, "score": 132036.7890755768 }, { "content": "class SplashScene :public cocos2d::Layer\n\n{\n\npublic:\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\nprotected:\n\n\tvoid addLoadingSpriteWitchSpark();\n\n\tvoid addWordJumpEffect(char* jumpWordString);\n\n\tvirtual bool init();\n\npublic:\n\n\tvirtual void nextScene(float dt)=0;\n\n\tvirtual void loadTextureCallBack(cocos2d::Texture2D* texture) = 0;\n\n};\n\n\n", "file_path": "Classes/Scene/SplashSceneFactory.h", "rank": 6, "score": 131583.49003469278 }, { "content": "#include \"cocos2d.h\"\n\n#include \"cocostudio\\CocoStudio.h\"\n\n#include \"cocos-ext.h\"\n\nclass MainScene : public cocos2d::Layer\n\n{\n\npublic:\n\n static cocos2d::Scene* createScene();\n\n virtual bool init();\n\n CREATE_FUNC(MainScene);\n\nprivate:\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n\tcocos2d::Node* _sceneNode;\n\n\tbool _isReplaceScene;\n\n};\n\n\n\n#endif\n", "file_path": "Classes/MainScene.h", "rank": 7, "score": 130011.46388049657 }, { "content": "#include \"cocos2d.h\"\n\n#include \"ui\\CocosGUI.h\"\n\n#include \"UI\\MyButton.h\"\n\nclass DeveloperMenuScene : public cocos2d::Layer\n\n{\n\npublic:\n\n static cocos2d::Scene* createScene();\n\n virtual bool init();\n\n CREATE_FUNC(DeveloperMenuScene);\n\nprivate:\n\n\tvoid ScrollModeMenuItemCallBack(Ref* sender);\n\n\tvoid BattleModeMenuItemCallBack(Ref* sender);\n\n\tvoid TestMapMenuItemCallBack(Ref* sender);\n\n\tvoid CreateCharacterSceneItemCallBack(Ref* sender);\n\n\tvoid LuoYangSceneCallBack(Ref* sender);\n\n\tvoid BackMountSceneCallBack(Ref* sender);\n\n\tvoid ChiuanJenSceneCallBack(Ref* sender);\n\n\tvoid CaveSceneCallBack(Ref* sender);\n\n\tvoid checkBoxCallback(cocos2d::Ref * ref, cocos2d::ui::CheckBox::EventType type);\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n\tcocos2d::Menu* _menu;\n\n\tcocos2d::Node* _page2Node;\n\n\tcocos2d::Label* _MissionName;\n\n\tcocos2d::Label* _setLevelLabel;\n\n\tbool _pageTurn;\n\n\tShakeButton* _pageBtn;\n\n};\n\n\n\n#endif // __DeveloperMenuScene_SCENE_H__\n", "file_path": "Classes/Scene/DeveloperMenuScene.h", "rank": 8, "score": 129641.65602642136 }, { "content": "", "file_path": "Classes/Scene/BattleMode/BattleScene.h", "rank": 9, "score": 129634.96305184036 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 10, "score": 127768.28258910682 }, { "content": "", "file_path": "Classes/Scene/SettingMenu.h", "rank": 11, "score": 115231.00775797182 }, { "content": "class HelloWorld : public cocos2d::Layer\n\n{\n\npublic:\n\n static cocos2d::Scene* createScene();\n\n\n\n virtual bool init();\n\n \n\n // a selector callback\n\n void menuCloseCallback(cocos2d::Ref* pSender);\n\n \n\n // implement the \"static create()\" method manually\n\n CREATE_FUNC(HelloWorld);\n\n};\n\n\n\n#endif // __HELLOWORLD_SCENE_H__\n", "file_path": "Classes/HelloWorldScene.h", "rank": 12, "score": 115231.00775797182 }, { "content": "class DebugLayer : public cocos2d::Layer\n\n{\n\npublic:\n\n virtual bool init();\n\n\tstatic DebugLayer* getInstance();\n\n\tcocos2d::Label* label;\n\n\tcocos2d::Label* label2;\n\n\tcocos2d::Label* label3;\n\nprivate:\n\n\t//DebugLayer();\n\n\tstatic DebugLayer* static_debugLayer;\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n};\n\n\n\n#endif\n", "file_path": "Classes/DebugLayer.h", "rank": 13, "score": 92143.40724780511 }, { "content": " friend bool operator==(ParseErrorCode code, const ParseResult & err) { return code == err.code_; }\n", "file_path": "Classes/rapidjson/error/error.h", "rank": 14, "score": 85655.36580855155 }, { "content": "struct TypeHelper<ValueType, int> {\n\n static bool Is(const ValueType& v) { return v.IsInt(); }\n\n static int Get(const ValueType& v) { return v.GetInt(); }\n\n static ValueType& Set(ValueType& v, int data) { return v.SetInt(data); }\n\n static ValueType& Set(ValueType& v, int data, typename ValueType::AllocatorType&) { return v.SetInt(data); }\n\n};\n\n\n\ntemplate<typename ValueType> \n", "file_path": "Classes/rapidjson/document.h", "rank": 15, "score": 76558.71028742836 }, { "content": "struct TypeHelper<ValueType, bool> {\n\n static bool Is(const ValueType& v) { return v.IsBool(); }\n\n static bool Get(const ValueType& v) { return v.GetBool(); }\n\n static ValueType& Set(ValueType& v, bool data) { return v.SetBool(data); }\n\n static ValueType& Set(ValueType& v, bool data, typename ValueType::AllocatorType&) { return v.SetBool(data); }\n\n};\n\n\n\ntemplate<typename ValueType> \n", "file_path": "Classes/rapidjson/document.h", "rank": 16, "score": 76544.17219975877 }, { "content": "", "file_path": "Classes/UI/ScrollMode/Dialog.h", "rank": 17, "score": 72616.9867159493 }, { "content": "", "file_path": "Classes/UI/DamageMG.h", "rank": 18, "score": 72616.9867159493 }, { "content": "#include \"cocos2d.h\"\n\n#include \"UI\\CocosGUI.h\"\n\n#include \"ui\\UIVideoPlayer.h\"\n\nclass GameStartMovie : public cocos2d::Layer\n\n{\n\npublic:\n\n\t~GameStartMovie();\n\n static cocos2d::Scene* createScene();\n\n virtual bool init();\n\n CREATE_FUNC(GameStartMovie);\n\n\tstatic bool isAlive();\n\nprivate:\n\n\tvoid videoPlayOverCallback();\n\n#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) && !defined(CC_PLATFORM_OS_TVOS)\n\n\tvoid videoEventCallback(Ref* sender, cocos2d::experimental::ui::VideoPlayer::EventType eventType);\n\n#endif\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n\tcocos2d::Label* _label;\n\n\tint _touchCount;\n\n\tstatic GameStartMovie* static_instance;\n\n};\n\n\n\n#endif\n", "file_path": "Classes/GameStartMovie.h", "rank": 19, "score": 71413.59282069124 }, { "content": "", "file_path": "Classes/UI/ScrollMode/HUDlayer.h", "rank": 20, "score": 70262.7894184963 }, { "content": "class JoyStick : public cocos2d::Layer\n\n{\n\n\tenum\n\n\t{\n\n\t\tJOYSTICKBACKGROUND,\n\n\t\tJOYSTICKBALL\n\n\t};\n\npublic:\n\n static cocos2d::Scene* createScene();\n\n virtual bool init();\n\n CREATE_FUNC(JoyStick);\n\nprivate:\n\n\tvoid showJoyStick();\n\n\tvoid hideJoyStick();\n\nprivate:\n\n\tcocos2d::Size visible;\n\n\tcocos2d::Vec2 origin;\n\n};\n\nNS_BATTLEMODE_END\n\n#endif // __GameScene_SCENE_H__\n", "file_path": "Classes/UI/BattleMode/JoyStick.h", "rank": 21, "score": 70262.7894184963 }, { "content": "", "file_path": "Classes/UI/BattleMode/BattleHUDlayer.h", "rank": 22, "score": 68151.64041767473 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 23, "score": 62441.603278198905 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 24, "score": 62441.603278198905 }, { "content": "#ifndef __SplashSceneFactory_SCENE_H__\n\n#define __SplashSceneFactory_SCENE_H__\n\n#include \"cocos2d.h\"\n\n#include \"cocos-ext.h\"\n\nclass SplashSceneFactory \n\n{\n\npublic:\n", "file_path": "Classes/Scene/SplashSceneFactory.h", "rank": 25, "score": 61865.1609216922 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 26, "score": 61790.133347532435 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 27, "score": 61790.133347532435 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 28, "score": 61790.133347532435 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 29, "score": 61152.11697203381 }, { "content": "\tenum class preLoadScene\n\n\t{\n\n\t\tpreLoadForestField,\n\n\t\tpreLoadLuoYangCity,\n\n\t\tpreLoadChiuanJenMount,\n\n\t\tpreLoadChiuanJen,\n\n\t\tpreLoadBattleTrainingField,\n\n\t\tpreLoadCave,\n\n\t\tpreLoadTestMap\n\n\t};\n\n\tstatic cocos2d::Scene* createScene(preLoadScene preLoadsceneName);\n\n};\n", "file_path": "Classes/Scene/SplashSceneFactory.h", "rank": 30, "score": 61002.98590598838 }, { "content": "", "file_path": "Classes/Scene/ItemScene.h", "rank": 31, "score": 60720.0348670936 }, { "content": "", "file_path": "Classes/Scene/StoreScene.h", "rank": 32, "score": 60720.0348670936 }, { "content": "#ifndef __LoginScene_SCENE_H__\n\n#define __LoginScene_SCENE_H__\n\n\n\n#include \"cocos2d.h\"\n\n#include \"DefinitionBattleMode.h\"\n\n#include \"cocostudio\\CocoStudio.h\"\n\n#include \"ui/CocosGUI.h\"\n", "file_path": "Classes/Scene/LoginScene.h", "rank": 33, "score": 60720.02899824761 }, { "content": "#ifndef __FailScene_SCENE_H__\n\n#define __FailScene_SCENE_H__\n\n\n\n#include \"cocos2d.h\"\n\n#include \"cocos-ext.h\"\n\n#include \"cocostudio\\CocoStudio.h\"\n", "file_path": "Classes/Scene/FailScene.h", "rank": 34, "score": 60719.970022583366 }, { "content": "#ifndef __Mission_SCENE_H__\n\n#define __Mission_SCENE_H__\n\n#include \"cocos2d.h\"\n\n#include \"cocostudio\\CocoStudio.h\"\n\n#include \"ui\\CocosGUI.h\"\n", "file_path": "Classes/Scene/MissionScene.h", "rank": 35, "score": 60719.280522817215 }, { "content": "", "file_path": "Classes/Scene/StoreScene.h", "rank": 36, "score": 60712.94576207708 }, { "content": "", "file_path": "Classes/Scene/StoreScene.h", "rank": 37, "score": 60706.89528937237 }, { "content": "", "file_path": "Classes/Scene/ItemScene.h", "rank": 38, "score": 60706.89528937237 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 39, "score": 60176.53285318118 }, { "content": "", "file_path": "Classes/Scene/ScrollMode/ScrollSceneFactory.h", "rank": 40, "score": 60176.53285318118 }, { "content": "#include \"FailScene.h\"\n\n#include \"tools\\JsonParser.h\"\n\n#include \"UI\\MyButton.h\"\n\n#include \"tools\\AudioManagement.h\"\n\n#include \"SplashSceneFactory.h\"\n\nUSING_NS_CC;\n\nusing namespace experimental;\n\nusing namespace MyTools;\n\nScene* FailScene::createScene()\n\n{\n\n auto scene = Scene::create();\n\n auto layer = FailScene::create();\n\n scene->addChild(layer);\n\n return scene;\n\n}\n\nbool FailScene::init()\n\n{\n\n if ( !Layer::init() )\n\n {\n\n return false;\n", "file_path": "Classes/Scene/FailScene.cpp", "rank": 41, "score": 59525.33661948185 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 42, "score": 59519.379101243394 }, { "content": "#include \"MissionScene.h\"\n\n#include \"tools\\JsonParser.h\"\n\n#include \"UI\\MyButton.h\"\n\n#include \"UI\\ScrollMode\\HUDlayer.h\"\n\n#include \"tools\\AudioManagement.h\"\n\nUSING_NS_CC;\n\nusing namespace MyTools;\n\nScene* MissionScene::createScene(cocos2d::RenderTexture* capture)\n\n{\n\n\tSize visible = Director::getInstance()->getVisibleSize();\n\n\tVec2 origin = Director::getInstance()->getVisibleOrigin();\n\n\tauto scene = Scene::create();\n\n\tauto layer = MissionScene::create();\n\n\tscene->addChild(layer, 1);\n\n\t\n\n\tif (capture!=nullptr)\n\n\t{\n\n\t\tauto pause_background = Sprite::createWithTexture(capture->getSprite()->getTexture());\n\n\t\tpause_background->setFlipY(true);\n\n\t\tpause_background->setColor(Color3B::GRAY);\n", "file_path": "Classes/Scene/MissionScene.cpp", "rank": 43, "score": 59518.553811128215 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 44, "score": 59515.26447083762 }, { "content": "//#include \"LoginScene.h\"\n\n//#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)\n\n//\t#include \"curl/include/win32/curl/curl.h\"//window下頭文件位子\n\n//\t#pragma comment(lib,\"libcurl_imp.lib\")//動態連結庫的位子\n\n//#else if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)\n\n//\t#include \"curl\\include\\android\\curl\\curl.h\"\n\n//#endif\n\n//USING_NS_CC;\n\n//Scene* LoginScene::createScene()\n\n//{\n\n// // 'scene' is an autorelease object\n\n// auto scene = Scene::create();\n\n// \n\n// // 'layer' is an autorelease object\n\n// auto layer = LoginScene::create();\n\n//\n\n// // add layer as a child to scene\n\n// scene->addChild(layer);\n\n//\n\n// // return the scene\n", "file_path": "Classes/Scene/LoginScene.cpp", "rank": 45, "score": 59513.74073455824 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 46, "score": 59510.54081681646 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 47, "score": 59508.74830842348 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 48, "score": 59508.34580209311 }, { "content": "\t\t_missionTip->setString(_missionTip->getString() + std::string(newStr));\n\n\t}\n\n\t\n\n return true;\n\n}\n\nvoid MissionScene::onEnterTransitionDidFinish()\n\n{\n\n\tLayer::onEnterTransitionDidFinish();\n\n\tif (ScrollMode::HUDlayer::getHUDlayer() != nullptr)\n\n\t{\n\n\t\tScrollMode::HUDlayer::getHUDlayer()->_isReplaceingScene = false;\n\n\t}\n\n}", "file_path": "Classes/Scene/MissionScene.cpp", "rank": 49, "score": 59504.63952334794 }, { "content": "\t\tpause_background->setPosition(Vec2(visible.width / 2 + origin.x, visible.height / 2 + origin.y));\n\n\t\tlayer->addChild(pause_background, 0);\n\n\t}\n\n\treturn scene;\n\n}\n\nbool MissionScene::init()\n\n{\n\n if ( !Layer::init() )\n\n {\n\n return false;\n\n }\n\n visible = Director::getInstance()->getVisibleSize();\n\n origin = Director::getInstance()->getVisibleOrigin();\n\n\tScrollMode::HUDlayer::getHUDlayer()->setMissionTip(false);\n\n\tthis->_sceneCSB= CSLoader::createNode(\"MissionScene/MissionScene.csb\");\n\n\tthis->addChild(_sceneCSB, 1);\n\n\t\n\n\t_returnBtn=ShakeButton::create(JsonParser::getJsonString(\"MissionScene\",\"Return\",JsonParser::JsonType::UserInterFace),\n\n\t\tJsonParser::fontType(), JsonParser::fontSize(14), Color4B::BLACK, \"ui/Button2.png\", \n\n\t[](ShakeButton* btn)\n", "file_path": "Classes/Scene/MissionScene.cpp", "rank": 50, "score": 59504.26954504278 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 51, "score": 59503.382272768664 }, { "content": "\tReturnButton->setPosition(_sceneNode->getChildByName(\"ReturnBtnPos\")->getPosition());\n\n\tthis->addChild(ReturnButton);\n\n\n\n\tJsonParser::setSave(\"Infor\", \"HP\", \"1000\");\n\n\tJsonParser::setSave(\"Infor\", \"MP\", \"1000\");\n\n return true;\n\n}\n\n\n\nvoid FailScene::onExit()\n\n{\n\n\tLayer::onExit();\n\n\tAudioManagement::getInstance()->clearAudioManagement();\n\n}\n", "file_path": "Classes/Scene/FailScene.cpp", "rank": 52, "score": 59502.340476076526 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 53, "score": 59502.2664007235 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 54, "score": 59502.008346242685 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 55, "score": 59501.69222860171 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 56, "score": 59501.27770553418 }, { "content": " }\n\n visible = Director::getInstance()->getVisibleSize();\n\n origin = Director::getInstance()->getVisibleOrigin();\n\n\t_isReplaceScene = false;\n\n\tAudioManagement::getInstance()->play(\"music/FailScene.mp3\", AudioManagement::AudioType::Music, false);\n\n\t_sceneNode = CSLoader::createNode(\"FailScene/FailScene.csb\");\n\n\t_sceneNode->setVisible(true);\n\n\tthis->addChild(_sceneNode);\n\n\n\n\tauto ReturnButton = ShakeButton::create(JsonParser::getJsonString(\"FailScene\",\"Return\",JsonParser::JsonType::UserInterFace), \n\n\t\tJsonParser::fontType(), JsonParser::fontSize(12), Color4B::BLACK, \"ui/Button.png\",\n\n\t\t[this](ShakeButton* btn)\n\n\t{\n\n\t\tif (_isReplaceScene)\n\n\t\t\treturn;\n\n\t\t_isReplaceScene = true;\n\n\t\tAudioManagement::getInstance()->play(\"sound/ui_select2.mp3\", AudioManagement::AudioType::Sound, false);\n\n\t\tDirector::getInstance()->replaceScene(TransitionFade::create(1.f, SplashSceneFactory::createScene(SplashSceneFactory::preLoadScene::preLoadChiuanJen)));\n\n\t});\n\n\tReturnButton->setScale(1.3);\n", "file_path": "Classes/Scene/FailScene.cpp", "rank": 57, "score": 59500.55128954882 }, { "content": "#ifndef __DeveloperMenuScene_SCENE_H__\n\n#define __DeveloperMenuScene_SCENE_H__\n\n\n\n#include \"cocos2d.h\"\n\n#include \"ui\\CocosGUI.h\"\n\n#include \"UI\\MyButton.h\"\n", "file_path": "Classes/Scene/DeveloperMenuScene.h", "rank": 58, "score": 59500.34045918852 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 59, "score": 59500.257786591144 }, { "content": "#ifndef __SplashSceneFactory_SCENE_H__\n\n#define __SplashSceneFactory_SCENE_H__\n\n#include \"cocos2d.h\"\n\n#include \"cocos-ext.h\"\n", "file_path": "Classes/Scene/SplashSceneFactory.h", "rank": 60, "score": 59500.06642501832 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 61, "score": 59499.83803455336 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 62, "score": 59499.372545146995 }, { "content": "", "file_path": "Classes/Scene/CreateCharacterScene.h", "rank": 63, "score": 59499.354239852335 }, { "content": "// return scene;\n\n//}\n\n//size_t processData(char *ptr, std::size_t size, std::size_t nmemb, std::string *stream)\n\n//{\n\n//\t//char* ptr就是返回的服务器数据,服务器echo 1,这里就返回\"1\" \n\n//\tCCLOG(\"Writting data\");\n\n//\tif (stream == NULL)\n\n//\t{\n\n//\t\treturn 0;\n\n//\t}\n\n//\tsize_t sizes = size * nmemb;\n\n//\t//string* ss = (string *)stream; \n\n//\tstream->append(ptr, sizes);\n\n//\treturn sizes;\n\n//}\n\n//// on \"init\" you need to initialize your instance\n\n//bool LoginScene::init()\n\n//{\n\n// if ( !Layer::init() )\n\n// {\n", "file_path": "Classes/Scene/LoginScene.cpp", "rank": 64, "score": 59499.198434295766 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 65, "score": 59499.16445235923 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 66, "score": 59498.84292457056 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 67, "score": 59498.79171160236 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 68, "score": 59498.57250802066 }, { "content": "\t_missionContent->setColor(Color3B::BLACK);\n\n\tthis->_sceneCSB->addChild(_missionContent);\n\n\n\n\tstd::string tipContent = JsonParser::getJsonString(\"MissionScene\", \"Tip\", JsonParser::JsonType::UserInterFace);\n\n\ttipContent += MissionMG::getInstance()->getCurrentMissionTip();\n\n\t_missionTip= Label::createWithTTF(tipContent, JsonParser::fontType(), JsonParser::fontSize(15));\n\n\t_missionTip->setPosition(_sceneCSB->getChildByName(\"MissionTipPos\")->getPosition());\n\n\t_missionTip->enableOutline(Color4B::GRAY, 1);\n\n\t_missionTip->setAnchorPoint(Vec2(0.5, 0));\n\n\t//_missionTip->setColor(Color3B(255,128,0));\n\n\t/*_missionTip->setColor(Color3B(255, 140, 0));*/\n\n\t/*_missionTip->setColor(Color3B(11, 155, 169));*/\n\n\t_missionTip->setColor(Color3B::WHITE);\n\n\tthis->_sceneCSB->addChild(_missionTip);\n\n\tint targetAmount = MissionMG::getInstance()->getCurrentMissionTargetAmount();\n\n\tif (targetAmount != -1)\n\n\t{\n\n\t\tint currentAmount = atoi(JsonParser::getJsonString(\"Infor\", \"MissionTargetMount\", JsonParser::JsonType::Save).c_str());\n\n\t\tchar newStr[30];\n\n\t\tsprintf(newStr,\" %d / %d\", currentAmount, targetAmount);\n", "file_path": "Classes/Scene/MissionScene.cpp", "rank": 69, "score": 59498.50549623184 }, { "content": "// return false;\n\n// }\n\n// visible = Director::getInstance()->getVisibleSize();\n\n// origin = Director::getInstance()->getVisibleOrigin();\n\n//\n\n//\tauto csbNode = CSLoader::createNode(\"scene/loginScene.csb\");\n\n//\tthis->addChild(csbNode);\n\n//\n\n//\tresaultLabel = Label::create();\n\n//\tresaultLabel->setPosition(visible.width / 2, visible.height / 18 * 3);\n\n//\tresaultLabel->setTextColor(Color4B::BLACK);\n\n//\tresaultLabel->setSystemFontSize(24);\n\n//\tcsbNode->addChild(resaultLabel);\n\n//\t\n\n//\tuserName = static_cast<cocos2d::ui::TextField*>(csbNode->getChildByName(\"inputField_UserName\"));\n\n//\tuserPass = static_cast<cocos2d::ui::TextField*>(csbNode->getChildByName(\"inputField_Password\"));\n\n//\tloginButton = static_cast<cocos2d::ui::Button*>(csbNode->getChildByName(\"loginButton\"));\n\n//\n\n//\tloginButton->addTouchEventListener([this](cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type)\n\n//\t{\n", "file_path": "Classes/Scene/LoginScene.cpp", "rank": 70, "score": 59497.8769532738 }, { "content": "", "file_path": "Classes/Scene/CreateCharacterScene.h", "rank": 71, "score": 59497.64900871376 }, { "content": "\t{\n\n\t\tAudioManagement::getInstance()->play(\"sound/scrollClose.mp3\", AudioManagement::AudioType::Sound, false);\n\n\t\tDirector::getInstance()->popScene([](Scene* scene)\n\n\t\t{\n\n\t\t\treturn TransitionPageTurn::create(0.4f, scene, false);\n\n\t\t});\n\n\t});\n\n\t_returnBtn->setPosition(_sceneCSB->getChildByName(\"ReturnBtnPos\")->getPosition());\n\n\tthis->_sceneCSB->addChild(_returnBtn);\n\n\n\n\t_missionTitle = Label::createWithTTF(MissionMG::getInstance()->getCurrentMissionTitle(), JsonParser::fontType(), JsonParser::fontSize(24));\n\n\t_missionTitle->setPosition(_sceneCSB->getChildByName(\"MissionTtitlePos\")->getPosition());\n\n\t_missionTitle->enableOutline(Color4B::BLACK, 1);\n\n\t_missionTitle->setColor(Color3B::WHITE);\n\n\tthis->_sceneCSB->addChild(_missionTitle);\n\n\n\n\t_missionContent= Label::createWithTTF(MissionMG::getInstance()->getCurrentMissionContent(), JsonParser::fontType(), JsonParser::fontSize(16));\n\n\t_missionContent->setPosition(_sceneCSB->getChildByName(\"MissionContentPos\")->getPosition());\n\n\t_missionContent->setAnchorPoint(Vec2(0, 1));\n\n\t_missionContent->setMaxLineWidth(200.f);\n", "file_path": "Classes/Scene/MissionScene.cpp", "rank": 72, "score": 59497.51263651622 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 73, "score": 59497.460792233265 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 74, "score": 59497.0146270978 }, { "content": "", "file_path": "Classes/Scene/CreateCharacterScene.h", "rank": 75, "score": 59496.88160827848 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 76, "score": 59496.68215416251 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 77, "score": 59496.33695456629 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 78, "score": 59496.07786442157 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 79, "score": 59495.99765800992 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 80, "score": 59495.956340823715 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 81, "score": 59495.920686100246 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 82, "score": 59495.67544410326 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 83, "score": 59495.64669641089 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 84, "score": 59495.6089009352 }, { "content": "//\t\t//curl_easy_setopt(curl, CURLOPT_WRITEDATA, &recvbuf);\n\n//\t\t////curl_easy_setopt(curl, CURLOPT_POSTFIELDS);\n\n//\t\t//res = curl_easy_perform(curl);\n\n//\t\t//if (CURLE_OK == res) //CURLE_OK == 0 \n\n//\t\t//{\t\n\n//\t\t//\tif (recvbuf.compare(\"0\")==0)\n\n//\t\t//\t{ //返回值\"1 \" 即是帳密正確 這邊網站上是\"1\" 不過我自己測試是用\"1 \"才成功\n\n//\t\t//\t\tresaultLabel->setString(\"Login Success!\");\n\n//\t\t//\t\t//Director::getInstance()->replaceScene(SplashScene::createScene());//我自己寫的遊戲場景\n\n//\t\t//\t}\n\n//\t\t//\telse //登入失敗 \n\n//\t\t//\t{\n\n//\t\t//\t\tresaultLabel->setString(\"Login Failed!\");\n\n//\t\t//\t}\n\n//\t\t//}\n\n//\t\tchar url[1000];\n\n//\t\tsprintf(url, \"http://localhost:3000/login?Account=%s&Password=%s\", strUser.c_str(), strPass.c_str());\n\n//\t\tint res;\n\n//\t\tres = curl_easy_setopt(curl, CURLOPT_URL, url);\n\n//\t\tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, processData);\n", "file_path": "Classes/Scene/LoginScene.cpp", "rank": 85, "score": 59495.53081979873 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 86, "score": 59495.29670886186 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 87, "score": 59495.15306869834 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 88, "score": 59495.08521817252 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 89, "score": 59494.816315024065 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 90, "score": 59494.81708317302 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 91, "score": 59494.62987175196 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 92, "score": 59494.39454435779 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 93, "score": 59493.99163185297 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 94, "score": 59493.95297026403 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 95, "score": 59493.83395948155 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 96, "score": 59493.70364482217 }, { "content": "", "file_path": "Classes/Scene/StoreScene.cpp", "rank": 97, "score": 59493.59900308034 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 98, "score": 59493.59630392968 }, { "content": "", "file_path": "Classes/Scene/ItemScene.cpp", "rank": 99, "score": 59493.56439593222 } ]
C++
3rdParty/iresearch/utils/index-convert.cpp
sita1999/arangodb
6a4f462fa209010cd064f99e63d85ce1d432c500
#if defined(_MSC_VER) #pragma warning(disable: 4101) #pragma warning(disable: 4267) #endif #include <cmdline.h> #if defined(_MSC_VER) #pragma warning(default: 4267) #pragma warning(default: 4101) #endif #include "shared.hpp" #include "index-convert.hpp" #include "common.hpp" #include "formats/formats.hpp" #include "index/directory_reader.hpp" #include "index/index_writer.hpp" NS_LOCAL const std::string HELP = "help"; const std::string DIR_TYPE = "dir-type"; const std::string IN_DIR = "in"; const std::string OUT_DIR = "out"; const std::string OUT_FORMAT = "out-format"; const std::string FORMATS_DIR = "format-dir"; NS_END int convert( const std::string& in, const std::string& out, const std::string& dir_type, const std::string& format) { auto in_dir = create_directory(dir_type, in); if (!in_dir) { std::cerr << "Unable to create input directory directory of type '" << dir_type << "'" << std::endl; return 1; } auto out_dir = create_directory(dir_type, out); if (!out_dir) { std::cerr << "Unable to create input directory directory of type '" << dir_type << "'" << std::endl; return 1; } auto codec = irs::formats::get(format); if (!codec) { std::cerr << "Unable to load the specified format '" << dir_type << "'" << std::endl; return 1; } auto reader = irs::directory_reader::open(*in_dir); auto writer = irs::index_writer::make(*out_dir, codec, irs::OM_CREATE | irs::OM_APPEND); writer->import(*reader); writer->commit(); return 0; } int convert(const cmdline::parser& args) { if (!args.exist(IN_DIR) || !args.exist(OUT_DIR) || !args.exist(OUT_FORMAT)) { return 1; } const auto& in_path = args.get<std::string>(IN_DIR); if (in_path.empty()) { return 1; } const auto& out_path = args.get<std::string>(OUT_DIR); if (out_path.empty()) { return 1; } const auto& out_format = args.get<std::string>(OUT_FORMAT); const auto dir_type = args.exist(DIR_TYPE) ? args.get<std::string>(DIR_TYPE) : std::string("fs"); irs::formats::init(); if (args.exist(FORMATS_DIR)) { auto& formats_dir = args.get<std::string>(FORMATS_DIR); if (!formats_dir.empty()) { irs::formats::load_all(formats_dir); } } return convert(in_path, out_path, dir_type, out_format); } int convert(int argc, char* argv[]) { cmdline::parser cmdconv; cmdconv.add(HELP, '?', "Produce help message"); cmdconv.add<std::string>(IN_DIR, 0, "Path to input index directory", true); cmdconv.add<std::string>(OUT_DIR, 0, "Path to output index directory", true); cmdconv.add<std::string>(FORMATS_DIR, 0, "Plugin directory", false); cmdconv.add<std::string>(OUT_FORMAT, 0, "Output format", true); cmdconv.add<std::string>(DIR_TYPE, 0, "Directory type (fs|mmap)", false, std::string("fs")); cmdconv.parse(argc, argv); if (cmdconv.exist(HELP)) { std::cout << cmdconv.usage() << std::endl; return 0; } return convert(cmdconv); }
#if defined(_MSC_VER) #pragma warning(disable: 4101) #pragma warning(disable: 4267) #endif #include <cmdline.h> #if defined(_MSC_VER) #pragma warning(default: 4267) #pragma warning(default: 4101) #endif #include "shared.hpp" #include "index-convert.hpp" #include "common.hpp" #include "formats/formats.hpp" #include "index/directory_reader.hpp" #include "index/index_writer.hpp" NS_LOCAL const std::string HELP = "help"; const std::string DIR_TYPE = "dir-type"; const std::string IN_DIR = "in"; const std::string OUT_DIR = "out"; const std::string OUT_FORMAT = "out-format"; const std::string FORMATS_DIR = "format-dir";
int convert(const cmdline::parser& args) { if (!args.exist(IN_DIR) || !args.exist(OUT_DIR) || !args.exist(OUT_FORMAT)) { return 1; } const auto& in_path = args.get<std::string>(IN_DIR); if (in_path.empty()) { return 1; } const auto& out_path = args.get<std::string>(OUT_DIR); if (out_path.empty()) { return 1; } const auto& out_format = args.get<std::string>(OUT_FORMAT); const auto dir_type = args.exist(DIR_TYPE) ? args.get<std::string>(DIR_TYPE) : std::string("fs"); irs::formats::init(); if (args.exist(FORMATS_DIR)) { auto& formats_dir = args.get<std::string>(FORMATS_DIR); if (!formats_dir.empty()) { irs::formats::load_all(formats_dir); } } return convert(in_path, out_path, dir_type, out_format); } int convert(int argc, char* argv[]) { cmdline::parser cmdconv; cmdconv.add(HELP, '?', "Produce help message"); cmdconv.add<std::string>(IN_DIR, 0, "Path to input index directory", true); cmdconv.add<std::string>(OUT_DIR, 0, "Path to output index directory", true); cmdconv.add<std::string>(FORMATS_DIR, 0, "Plugin directory", false); cmdconv.add<std::string>(OUT_FORMAT, 0, "Output format", true); cmdconv.add<std::string>(DIR_TYPE, 0, "Directory type (fs|mmap)", false, std::string("fs")); cmdconv.parse(argc, argv); if (cmdconv.exist(HELP)) { std::cout << cmdconv.usage() << std::endl; return 0; } return convert(cmdconv); }
NS_END int convert( const std::string& in, const std::string& out, const std::string& dir_type, const std::string& format) { auto in_dir = create_directory(dir_type, in); if (!in_dir) { std::cerr << "Unable to create input directory directory of type '" << dir_type << "'" << std::endl; return 1; } auto out_dir = create_directory(dir_type, out); if (!out_dir) { std::cerr << "Unable to create input directory directory of type '" << dir_type << "'" << std::endl; return 1; } auto codec = irs::formats::get(format); if (!codec) { std::cerr << "Unable to load the specified format '" << dir_type << "'" << std::endl; return 1; } auto reader = irs::directory_reader::open(*in_dir); auto writer = irs::index_writer::make(*out_dir, codec, irs::OM_CREATE | irs::OM_APPEND); writer->import(*reader); writer->commit(); return 0; }
function_block-full_function
[]
C++
asw/xy_to_angle.cpp
aswdevz/asw
ba483a71742fefbe6aa886e0e6acf56f22f375fe
#include "stdafx.h" #include "asw.h" #include "xy_to_angle.h" #ifdef USE_ORIGINAL_DEADZONE_FUNCTION bool in_deadzone(short x, short y, int deadzone) { int x_percent = (int)(abs(x) / 327.67); int y_percent = (int)(abs(y) / 327.67); if ( sqrt(pow(x_percent, 2) + pow(y_percent, 2) ) <= deadzone) { return TRUE; } return FALSE; } #else bool in_deadzone(short x, short y, int deadzone) { double x_percent = abs(x) / 327.67; double y_percent = abs(y) / 327.67; if ( sqrt(pow(x_percent, 2) + pow(y_percent, 2) ) <= deadzone) { return TRUE; } return FALSE; } #endif double calculate_angle_from_x_y(short x, short y) { if (x == 0) { if (y >= 0) return 0.0; else return 180.0; } if (y == 0) { if (x >= 0) return 90.0; else return -90.0; } if (x > 0) { if (y > 0) { return (atan((double)x / (double)y) * 180.0 / M_PI); } if (y < 0) { return ((atan(-(double)y / (double)x) * 180.0 / M_PI) + 90.0); } } if (x < 0) { if (y > 0) { return ((-atan(-(double)x / (double)y)) * 180.0 / M_PI); } if (y < 0) { return ((-atan(-(double)y / -(double)x) * 180.0 / M_PI) - 90.0); } } return 0.0; } long angle_to_vjoy(double angle, int virtual_wheel_max_angle) { double max_angle = ((double)virtual_wheel_max_angle) / 2; double min_angle = -((double)virtual_wheel_max_angle) / 2; if (angle > max_angle) angle = max_angle; if (angle < min_angle) angle = min_angle; long finalvalue = (long)round(((angle + max_angle)*(32767.0 / ((double)virtual_wheel_max_angle)) + 1)); return finalvalue; } int check_if_rotated_past_180(double current, double last, int* rotations) { if (((current >= -180.0) && (current < 0.0)) && (current < (last - 180.0))) { *rotations = *rotations + 1; return 1; } if (((current <= 180.0) && (current > 0.0)) && (current > (last + 180.0))) { *rotations = *rotations - 1; return -1; } return 0; } int clip_angle_and_rotations(int virtual_wheel_max_angle, double* angle_in, int* rotations) { double right_lock = ((double)virtual_wheel_max_angle) / 2; double left_lock = -(((double)virtual_wheel_max_angle) / 2); int max_rotations = (int)((right_lock + 180.0) / 360.0); int min_rotations = (int)((left_lock - 180.0) / 360.0); double max_angle = right_lock - (360.0 * max_rotations); double min_angle = left_lock + (360.0 * (-min_rotations)); double angle = ((*angle_in) + (*rotations)*360.0); if (angle > ((double)virtual_wheel_max_angle) / 2) { angle = ((double)virtual_wheel_max_angle) / 2; *angle_in = max_angle; *rotations = max_rotations; } if (angle < (-((double)virtual_wheel_max_angle) / 2)) { angle = -(((double)virtual_wheel_max_angle) / 2); *angle_in = min_angle; *rotations = min_rotations; } return 0; } double calculate_real_angle(double current, int virtual_wheel_max_angle, int* rotations, int* steering_lock) { *steering_lock = 0; double angle = (current + (*rotations)*360.0); if (angle > ((double)virtual_wheel_max_angle) / 2) { angle = ((double)virtual_wheel_max_angle) / 2; *steering_lock = 1; } if (angle < (-((double)virtual_wheel_max_angle) / 2)) { angle = -(((double)virtual_wheel_max_angle) / 2); *steering_lock = -1; } return angle; } LONG invert_vjoy_axis_value(LONG value, int invert_axis) { if (invert_axis == 1) return 32769 - value; else return value; }
#include "stdafx.h" #include "asw.h" #include "xy_to_angle.h" #ifdef USE_ORIGINAL_DEADZONE_FUNCTION bool in_deadzone(short x, short y, int deadzone) { int x_percent = (int)(abs(x) / 327.67); int y_percent = (int)(abs(y) / 327.67); if ( sqrt(pow(x_percent, 2) + pow(y_percent, 2) ) <= deadzone) { return TRUE; } return FALSE; } #else bool in_deadzone(short x, short y, int deadzone) { double x_percent = abs(x) / 327.67; double y_percent = abs(y) / 327.67; if ( sqrt(pow(x_percent, 2) + pow(y_percent, 2) ) <= deadzone) { return TRUE; } return FALSE; } #endif double calculate_angle_from_x_y(short x, short y) { if (x == 0) { if (y >= 0) return 0.0; else return 180.0; } if (y == 0) { if (x >
uble)virtual_wheel_max_angle)) + 1)); return finalvalue; } int check_if_rotated_past_180(double current, double last, int* rotations) { if (((current >= -180.0) && (current < 0.0)) && (current < (last - 180.0))) { *rotations = *rotations + 1; return 1; } if (((current <= 180.0) && (current > 0.0)) && (current > (last + 180.0))) { *rotations = *rotations - 1; return -1; } return 0; } int clip_angle_and_rotations(int virtual_wheel_max_angle, double* angle_in, int* rotations) { double right_lock = ((double)virtual_wheel_max_angle) / 2; double left_lock = -(((double)virtual_wheel_max_angle) / 2); int max_rotations = (int)((right_lock + 180.0) / 360.0); int min_rotations = (int)((left_lock - 180.0) / 360.0); double max_angle = right_lock - (360.0 * max_rotations); double min_angle = left_lock + (360.0 * (-min_rotations)); double angle = ((*angle_in) + (*rotations)*360.0); if (angle > ((double)virtual_wheel_max_angle) / 2) { angle = ((double)virtual_wheel_max_angle) / 2; *angle_in = max_angle; *rotations = max_rotations; } if (angle < (-((double)virtual_wheel_max_angle) / 2)) { angle = -(((double)virtual_wheel_max_angle) / 2); *angle_in = min_angle; *rotations = min_rotations; } return 0; } double calculate_real_angle(double current, int virtual_wheel_max_angle, int* rotations, int* steering_lock) { *steering_lock = 0; double angle = (current + (*rotations)*360.0); if (angle > ((double)virtual_wheel_max_angle) / 2) { angle = ((double)virtual_wheel_max_angle) / 2; *steering_lock = 1; } if (angle < (-((double)virtual_wheel_max_angle) / 2)) { angle = -(((double)virtual_wheel_max_angle) / 2); *steering_lock = -1; } return angle; } LONG invert_vjoy_axis_value(LONG value, int invert_axis) { if (invert_axis == 1) return 32769 - value; else return value; }
= 0) return 90.0; else return -90.0; } if (x > 0) { if (y > 0) { return (atan((double)x / (double)y) * 180.0 / M_PI); } if (y < 0) { return ((atan(-(double)y / (double)x) * 180.0 / M_PI) + 90.0); } } if (x < 0) { if (y > 0) { return ((-atan(-(double)x / (double)y)) * 180.0 / M_PI); } if (y < 0) { return ((-atan(-(double)y / -(double)x) * 180.0 / M_PI) - 90.0); } } return 0.0; } long angle_to_vjoy(double angle, int virtual_wheel_max_angle) { double max_angle = ((double)virtual_wheel_max_angle) / 2; double min_angle = -((double)virtual_wheel_max_angle) / 2; if (angle > max_angle) angle = max_angle; if (angle < min_angle) angle = min_angle; long finalvalue = (long)round(((angle + max_angle)*(32767.0 / ((do
random
[ { "content": "\tint* thumbstick_deadzone;\n", "file_path": "asw/asw.h", "rank": 0, "score": 26571.359982119866 }, { "content": "bool in_deadzone(short x, short y, int deadzone);\n", "file_path": "asw/xy_to_angle.h", "rank": 1, "score": 26571.359982119866 }, { "content": " WORD wButtons;\n", "file_path": "asw/inc/XInput.h", "rank": 2, "score": 24849.25804638837 }, { "content": " WORD Flags;\n", "file_path": "asw/inc/XInput.h", "rank": 3, "score": 24849.25804638837 }, { "content": " BYTE Type;\n", "file_path": "asw/inc/XInput.h", "rank": 4, "score": 24849.25804638837 }, { "content": " WCHAR Unicode;\n", "file_path": "asw/inc/XInput.h", "rank": 5, "score": 24849.25804638837 }, { "content": " XINPUT_GAMEPAD Gamepad;\n", "file_path": "asw/inc/XInput.h", "rank": 6, "score": 24849.25804638837 }, { "content": "\tLONG\twAxisX;\n", "file_path": "asw/inc/public.h", "rank": 7, "score": 24849.25804638837 }, { "content": " XINPUT_VIBRATION Vibration;\n", "file_path": "asw/inc/XInput.h", "rank": 8, "score": 24849.25804638837 }, { "content": "", "file_path": "asw/inc/vjoyinterface.h", "rank": 9, "score": 24849.25804638837 }, { "content": " WORD VirtualKey;\n", "file_path": "asw/inc/XInput.h", "rank": 10, "score": 23790.393574439106 }, { "content": " BYTE BatteryLevel;\n", "file_path": "asw/inc/XInput.h", "rank": 11, "score": 23790.393574439106 }, { "content": " BYTE SubType;\n", "file_path": "asw/inc/XInput.h", "rank": 12, "score": 23790.393574439106 }, { "content": " BYTE bRightTrigger;\n", "file_path": "asw/inc/XInput.h", "rank": 13, "score": 23790.393574439106 }, { "content": "", "file_path": "asw/inc/vjoyinterface.h", "rank": 14, "score": 23790.393574439106 }, { "content": " BYTE bLeftTrigger;\n", "file_path": "asw/inc/XInput.h", "rank": 15, "score": 23790.393574439106 }, { "content": " SHORT sThumbRY;\n", "file_path": "asw/inc/XInput.h", "rank": 16, "score": 23790.393574439106 }, { "content": " SHORT sThumbLX;\n", "file_path": "asw/inc/XInput.h", "rank": 17, "score": 23790.393574439106 }, { "content": " BYTE UserIndex;\n", "file_path": "asw/inc/XInput.h", "rank": 18, "score": 23790.393574439106 }, { "content": " BYTE HidCode;\n", "file_path": "asw/inc/XInput.h", "rank": 19, "score": 23790.393574439106 }, { "content": "\tLONG\twAxisXRot;\n", "file_path": "asw/inc/public.h", "rank": 20, "score": 23790.393574439106 }, { "content": " SHORT sThumbRX;\n", "file_path": "asw/inc/XInput.h", "rank": 21, "score": 23790.393574439106 }, { "content": " SHORT sThumbLY;\n", "file_path": "asw/inc/XInput.h", "rank": 22, "score": 23790.393574439106 }, { "content": " BYTE BatteryType;\n", "file_path": "asw/inc/XInput.h", "rank": 23, "score": 23790.393574439106 }, { "content": " DWORD dwPacketNumber;\n", "file_path": "asw/inc/XInput.h", "rank": 24, "score": 22818.08064393502 }, { "content": " WORD wLeftMotorSpeed;\n", "file_path": "asw/inc/XInput.h", "rank": 25, "score": 22818.08064393502 }, { "content": " WORD wRightMotorSpeed;\n", "file_path": "asw/inc/XInput.h", "rank": 26, "score": 22818.08064393502 }, { "content": "// cmdline.cpp : This file contains functions that parse the command line arguments\n\n//\n\n\n\n#include \"stdafx.h\" // for precompiled headers, must be present in every source file\n\n\n\n#include \"asw.h\" // I'm including this in every source file\n\n#include \"cmdline.h\"\n\n\n\nbool parse_cmdline(s_aliaslist aliaslist, int argc, char* argv[])\n\n{\n\n\tint int_scan_val = 0;\n\n\n\n\t#ifdef EXTRA_LINES\n\n\tprintf(\"argument count: %d\\n\", argc);\n\n\t#endif\n\n\tfor (int i = 0; i < argc; i++)\n\n\t{\n\n\t\t#ifdef EXTRA_LINES\n\n\t\tprintf(\"argument %d : %s\\n\", i, argv[i]);\n\n\t\t#endif\n", "file_path": "asw/cmdline.cpp", "rank": 29, "score": 6.722226184904718 }, { "content": "\n\n\t\tif ((argcmp(argv[i], \"deadzone\") == 0) || (argcmp(argv[i], \"d\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-deadzone detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t// valid deadzone setting is 0-100\n\n\t\t\t\t\tif ((int_scan_val >= 0) && (int_scan_val <= 100))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\t*(aliaslist.thumbstick_deadzone) = int_scan_val;\n\n\t\t\t\t\t\ti++;\n\n\t\t\t\t\t}\n\n\t\t\t\t\telse\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tprintf(\"-deadzone value out of range, min=0, max=100\\n\");\n\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n", "file_path": "asw/cmdline.cpp", "rank": 30, "score": 6.285085725901994 }, { "content": "// asw.cpp : Defines the entry point for the console application.\n\n//\n\n\n\n#include \"stdafx.h\" // for precompiled headers, must be present in every source file\n\n\n\n#include \"asw.h\" // I'm including this in every source file\n\n#include \"xy_to_angle.h\"\n\n#include \"cmdline.h\"\n\n\n\n// TODO:\n\n// fix deadzone function //fixed-check - ok but 100 still registered movement at the edge\n\n// add keyboard input (maybe later\n\n// add functionality to disable virtual wheel and triggers (not needed, can be done by removing the axis from vjoy)\n\n// tweak text output\n\n\n\nint main(int argc, char* argv[])\n\n{\n\n\t// variables needed for vjoy\n\n\tUINT iInterface = 1; // vjoy virtual joystick number\n\n\t\n", "file_path": "asw/asw.cpp", "rank": 31, "score": 5.452115674357712 }, { "content": "\t\t\tif (*(aliaslist.help_detected))\n\n\t\t\t\tprintf(\"\\n\");\n\n\t\t\t*(aliaslist.help_detected) = true;\n\n\t\t\tprintf(\"asw version %s\\n\", VERSION_STRING);\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\t// add extra comparisons here\n\n\n\n\t\tprintf(\"unrecognized argument: %s\\n\", argv[i]);\n\n\t\treturn false;\n\n\t}\n\n\n\n\treturn true;\n\n}\n\n\n\nint argcmp(char* arg, char* cmp)\n\n{\n\n\tint returnval = 1;\n\n\t\n", "file_path": "asw/cmdline.cpp", "rank": 32, "score": 4.927595755488566 }, { "content": "\tint tick_delay = 8; // sets the delay in miliseconds between each tick (main loop)\n\n\tbool use_right_stick = false; // if this is true, the right thumbstick will be used (if false, the left stick will be used)\n\n\tbool help_detected = false; // if this is true, the program will print the supported command line argument list and then quit\n\n\n\n\t// variables that define which vjoy device axis to use and for axis inversion\n\n\tUINT wheel_axis = HID_USAGE_X;\n\n\tUINT left_trigger_axis = HID_USAGE_SL0;\n\n\tUINT right_trigger_axis = HID_USAGE_SL1;\n\n\tLONG invert_wheel_axis = 0; // allowed values: 0 = not inverted, -1 = inverted\n\n\tLONG invert_left_trigger = 0; // allowed values: 0 = not inverted, -1 = inverted\n\n\tLONG invert_right_trigger = 0; // allowed values: 0 = not inverted, -1 = inverted\n\n\n\n\t// this structure holds pointers to the above, this structure is often passed into functions\n\n\ts_aliaslist aliaslist = {\n\n\t\t&iInterface,\n\n\t\t&controller_number,\n\n\t\t&thumbstick_deadzone,\n\n\t\t&virtual_wheel_max_angle,\n\n\t\t&bind_mode,\n\n\t\t&any_key_to_quit,\n", "file_path": "asw/asw.cpp", "rank": 33, "score": 4.898996373316921 }, { "content": "\n\n\t// variables needed for bind mode functionality\n\n\tint bind_mode = 0; // if bind_mode is set to 1, this program will generate and send positional changes to the vjoy virtual wheel axis\n\n\t // 2 is the same but for left trigger\n\n\t // 3 is the same but for right right trigger\n\n\t // this is useful for binding the virtual controller in games\n\n\tint bind_mode_increment = 128; // this defines how much will the generated position change between every tick\n\n\tint bind_mode_position = 0; // this stores the generated control position for the bind functionality\n\n\tint bind_mode_movement_direction = 1; // this determines if the generated control position is increasing (1) or decreasing (-1) each tick\n\n\tbool bind_mode_non_reversible = false; // if this is true bind mode will move the control in on direction only\n\n\t // if false, bind mode will reverse the direction when the end of travel is reached\n\n\tint bind_mode_reset_wait = 125; // this sets how many ticks of the main loop should bindmode wait when the end of travel is reached\n\n\t // after the wait, bindmode starts moving the control again\n\n\t // actual delay in ms = bind_mode_reset_wait * tick_delay\n\n\tint bind_mode_ticks_to_wait = 0;\n\n\t\n\n\t// other variables needed for my code\n\n\tint wheel_reset_buttons_flag = 0x8020; // defines the buttons that have to be pressed for the wheel to be reset\n\n\tbool disable_wheel_reset = false; // this disables wheel reset functionality\n\n\tbool any_key_to_quit = false; // if this is set to true, pressing any key will quit the app, else only esc will quit the app\n", "file_path": "asw/asw.cpp", "rank": 34, "score": 4.614737797658773 }, { "content": "\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tprintf(\"-deadzone value not present or in incorrect format\\n\");\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-deadzone value not present\\n\");\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ( (argcmp(argv[i], \"rotation\") == 0) || (argcmp(argv[i], \"r\") == 0) )\n\n\t\t{\n\n\t\t\t//printf(\"-rotation detected\\n\");\n\n\t\t\tif ( (i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n", "file_path": "asw/cmdline.cpp", "rank": 35, "score": 4.421156964463747 }, { "content": "\tprintf(\"use right stick: %s\\n\", use_right_stick ? \"true\" : \"false\");\n\n\tprintf(\"wheel axis: 0x%X\", wheel_axis);\n\n\tprintf(\" left trigger axis: 0x%X\", left_trigger_axis);\n\n\tprintf(\" right trigger axis: 0x%X\\n\", right_trigger_axis);\n\n\tprintf(\"axis inverted: wheel: %s\", invert_wheel_axis ? \"yes\" : \"no\");\n\n\tprintf(\" left trigger: %s\", invert_left_trigger ? \"yes\" : \"no\");\n\n\tprintf(\" right trigger: %s\\n\", invert_right_trigger ? \"yes\" : \"no\");\n\n\n\n\tprintf(\"-bmmd: %d \", bind_mode_movement_direction);\n\n\tprintf(\"-bmnr: %s \", bind_mode_non_reversible ? \"true\" : \"false\");\n\n\tprintf(\"-bmrw: %d\", bind_mode_reset_wait);\n\n\tprintf(\"\\n\");\n\n\tprintf(\"-wheelresetbuttonsflag: 0x%X \", wheel_reset_buttons_flag);\n\n\tprintf(\"-disablewheelreset: %s\", disable_wheel_reset ? \"true\" : \"false\");\n\n\tprintf(\"\\n\");\n\n\tprintf(\"=== starting asw ===\\n\");\n\n\n\n\n\n\t/******************************************************************************/\n\n\t/* Start of vjoy setup code */\n", "file_path": "asw/asw.cpp", "rank": 36, "score": 4.085034951924412 }, { "content": "\t\t{\n\n\t\t\t//printf(\"-bindmode detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t// bindmode should be 0-3\n\n\t\t\t\t\tif ((int_scan_val >= 0) && (int_scan_val <= 3))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\t*(aliaslist.bind_mode) = int_scan_val;\n\n\t\t\t\t\t\ti++;\n\n\t\t\t\t\t}\n\n\t\t\t\t\telse\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tprintf(\"-bindmode value out of range, min=0, max=3\\n\");\n\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n", "file_path": "asw/cmdline.cpp", "rank": 38, "score": 3.104659140610055 }, { "content": "\t\t{\n\n\t\t\t//printf(\"-bindmodeincrement detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t// bindmodeincrement should be 1-8192\n\n\t\t\t\t\tif ((int_scan_val >= 1) && (int_scan_val <= 8192))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\t*(aliaslist.bind_mode_increment) = int_scan_val;\n\n\t\t\t\t\t\ti++;\n\n\t\t\t\t\t}\n\n\t\t\t\t\telse\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tprintf(\"-bindmodeincrement value out of range, min=1, max=8192\\n\");\n\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n", "file_path": "asw/cmdline.cpp", "rank": 39, "score": 3.0815917386433345 }, { "content": "// stdafx.cpp : source file that includes just the standard includes\n\n// asw.pch will be the pre-compiled header\n\n// stdafx.obj will contain the pre-compiled type information\n\n\n\n#include \"stdafx.h\"\n\n\n\n// TODO: reference any additional headers you need in STDAFX.H\n\n// and not in this file\n", "file_path": "asw/stdafx.cpp", "rank": 40, "score": 3.0007584884623104 }, { "content": "", "file_path": "asw/inc/vjoyinterface.h", "rank": 41, "score": 2.861792267808232 }, { "content": "\t\tif ((argcmp(argv[i], \"disablewheelreset\") == 0) || (argcmp(argv[i], \"dwr\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-disablewheelreset detected\\n\");\n\n\t\t\t*(aliaslist.disable_wheel_reset) = 1;\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ((argcmp(argv[i], \"tickdelay\") == 0) || (argcmp(argv[i], \"t\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-tickdelay detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t// tickdelay should be 1-1000\n\n\t\t\t\t\tif ((int_scan_val >= 1) && (int_scan_val <= 1000))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\t*(aliaslist.tick_delay) = int_scan_val;\n\n\t\t\t\t\t\ti++;\n\n\t\t\t\t\t}\n", "file_path": "asw/cmdline.cpp", "rank": 42, "score": 2.8487643989122233 }, { "content": "\t\t\t\t\tif ((int_scan_val == 1) || (int_scan_val == -1))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\t*(aliaslist.bind_mode_movement_direction) = int_scan_val;\n\n\t\t\t\t\t\ti++;\n\n\t\t\t\t\t}\n\n\t\t\t\t\telse\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tprintf(\"-bindmodemovementdirection value out of range, allowed values: 1 and -1\\n\");\n\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tprintf(\"-bindmodemovementdirection value not present or in incorrect format\\n\");\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-bindmodemovementdirection value not present\\n\");\n", "file_path": "asw/cmdline.cpp", "rank": 43, "score": 2.770755637481564 }, { "content": "\t}\n\n\n\n\tfor (int i = 1; i < argc; i++)\n\n\t{\n\n\t\t#ifdef EXTRA_LINES\n\n\t\tprintf(\">>cmdline parse loop<<\\n\");\n\n\t\t#endif\n\n\n\n\t\t//std::cout << \"addr \" << &argv[i] << std::endl;\n\n\n\n\t\tif ((argcmp(argv[i], \"interface\") == 0) || (argcmp(argv[i], \"i\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-interface detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t// valid vjoy interface numbers are 1-16\n\n\t\t\t\t\t*(aliaslist.iInterface) = int_scan_val;\n\n\t\t\t\t\ti++;\n", "file_path": "asw/cmdline.cpp", "rank": 44, "score": 2.722259611247158 }, { "content": "\t/******************************************************************************/\n\n\t\n\n\tprintf(\"\\n\");\n\n\tif (!parse_cmdline(aliaslist, argc, argv))\n\n\t{\n\n\t\tprintf(\"incorrect command line arguments, asw is not started\\n\");\n\n\t\tprintf(\"use the following command to display help: asw -h\\n\");\n\n\t\treturn 0;\n\n\t}\n\n\tif (help_detected)\n\n\t\treturn 0;\n\n\tprintf(\"=== asw settings ===\\n\");\n\n\tprintf(\"using vJoy virtual interface: %d (recomended value: 1 to 16)\\n\", iInterface);\n\n\tprintf(\"using xinput controller number: %d (recomended value: 1 to 4)\\n\", controller_number + 1);\n\n\tprintf(\"using thumbstick deadzone: %d (must be 0 to 100)\\n\", thumbstick_deadzone);\n\n\tprintf(\"rotation: %d\\n\", virtual_wheel_max_angle);\n\n\tprintf(\"use any key to quit: %s\\n\", any_key_to_quit ? \"true\" : \"false\");\n\n\tprintf(\"bindmode: %d\\n\", bind_mode);\n\n\tprintf(\"bindmodeincrement: %d\\n\", bind_mode_increment);\n\n\tprintf(\"tick delay: %d\\n\", tick_delay);\n", "file_path": "asw/asw.cpp", "rank": 45, "score": 2.694322136311725 }, { "content": "\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%x\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t*(aliaslist.wheel_reset_buttons_flag) = int_scan_val;\n\n\t\t\t\t\ti++;\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tprintf(\"-wheelresetbuttonsflag value not present or in incorrect format\\n\");\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-wheelresetbuttonsflag value not present\\n\");\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n", "file_path": "asw/cmdline.cpp", "rank": 46, "score": 2.5307179647511746 }, { "content": "\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-wheelaxis value not present\\n\");\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ((argcmp(argv[i], \"lefttriggeraxis\") == 0) || (argcmp(argv[i], \"lta\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-lefttriggeraxis detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%x\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t*(aliaslist.left_trigger_axis) = int_scan_val;\n\n\t\t\t\t\ti++;\n", "file_path": "asw/cmdline.cpp", "rank": 47, "score": 2.4413395114930028 }, { "content": "\t// variables needed for xinput\n\n\tDWORD controller_number = 0; // xinput controller number [0-3]\n\n\tXINPUT_STATE controller_state; // this structure holds data indicating the state of all controls present on the controller\n\n\tZeroMemory(&controller_state, (sizeof(controller_state)));\n\n\tint thumbstick_deadzone = 15; // note: I was using 10 here before\n\n\n\n\t// variables needed for windows console input\n\n\tHANDLE console_input = GetStdHandle(STD_INPUT_HANDLE); // get a handle for the console input buffer\n\n\tINPUT_RECORD console_input_record; // create an INPUT_RECORD structure, this structure will hold one console event\n\n\tZeroMemory(&console_input_record, (sizeof(console_input_record)));\n\n\tDWORD console_events_count = 0; // GetNumberOfConsoleInputEvents() stores the event count left in the console input buffer into this variable\n\n\tDWORD console_events_read = 0; // ReadConsoleInput() stores the number of console input events read into this variable, should always be 1 in my code\n\n\n\n\t// variables that hold information about the stick position and the position of the virtual wheel axis\n\n\tdouble raw_angle = 0.0; // angle calculated from thumbstick X and Y axis position, should be from -180.0 to 180.0\n\n\tint rotations = 0; // the number of times the stick rotated past the 180° position, positive = right, negative = left\n\n\tint steering_lock = 0; // 0 = no lock, -1 = locked at full left, 1 = locked at full right, this variable is not actually used in this version of the code\n\n\tdouble real_angle = 0.0; // virtual wheel angle caluclated by combining \"raw_angle\" and \"rotations\"\n\n\tdouble last_raw_angle = 0.0; // holds the angle from the previous tick\n\n\tint virtual_wheel_max_angle = 900; // sets a limit on how much can the virtual wheel be rotated to\n", "file_path": "asw/asw.cpp", "rank": 48, "score": 2.440609756716783 }, { "content": "\t\t\t\tif (sscanf_s(argv[i + 1], \"%x\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t*(aliaslist.right_trigger_axis) = int_scan_val;\n\n\t\t\t\t\ti++;\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tprintf(\"-righttriggeraxis value not present or in incorrect format\\n\");\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-righttriggeraxis value not present\\n\");\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ((argcmp(argv[i], \"invertwheel\") == 0) || (argcmp(argv[i], \"iw\") == 0))\n", "file_path": "asw/cmdline.cpp", "rank": 49, "score": 2.3851805476316015 }, { "content": "\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t// valid xinput controller number is 0-3\n\n\t\t\t\t\t// 0 corresponds to controller number 1 etc.\n\n\t\t\t\t\t*(aliaslist.controller_number) = int_scan_val-1;\n\n\t\t\t\t\ti++;\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tprintf(\"-controller value not present or in incorrect format\\n\");\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-controller value not present\\n\");\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n", "file_path": "asw/cmdline.cpp", "rank": 50, "score": 2.358058931467216 }, { "content": "\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n\n\t\t\n\n\t\tif ((argcmp(argv[i], \"bindmodenonreversible\") == 0) || (argcmp(argv[i], \"bmnr\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-bindmodenonreversible detected\\n\");\n\n\t\t\t*(aliaslist.bind_mode_non_reversible) = 1;\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ((argcmp(argv[i], \"bindmoderesetwait\") == 0) || (argcmp(argv[i], \"bmrw\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-bindmoderesetwait detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t*(aliaslist.bind_mode_reset_wait) = int_scan_val;\n", "file_path": "asw/cmdline.cpp", "rank": 53, "score": 2.1614391093119227 }, { "content": "\t\tif ((argcmp(argv[i], \"rightstick\") == 0) || (argcmp(argv[i], \"rs\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-rightstick detected\\n\");\n\n\t\t\t*(aliaslist.use_right_stick) = 1;\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ((argcmp(argv[i], \"wheelaxis\") == 0) || (argcmp(argv[i], \"wa\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-wheelaxis detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%x\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t*(aliaslist.wheel_axis) = int_scan_val;\n\n\t\t\t\t\ti++;\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tprintf(\"-wheelaxis value not present or in incorrect format\\n\");\n", "file_path": "asw/cmdline.cpp", "rank": 54, "score": 2.1391433358346466 }, { "content": "\t\t\n\n\t\t\t// virtual wheel code\n\n\t\t\tif (!use_right_stick)\n\n\t\t\t{\n\n\t\t\t\tif (in_deadzone(controller_state.Gamepad.sThumbLX, controller_state.Gamepad.sThumbLY, thumbstick_deadzone))\n\n\t\t\t\t\traw_angle = last_raw_angle;\n\n\t\t\t\telse\n\n\t\t\t\t\traw_angle = calculate_angle_from_x_y(controller_state.Gamepad.sThumbLX, controller_state.Gamepad.sThumbLY);\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tif (in_deadzone(controller_state.Gamepad.sThumbRX, controller_state.Gamepad.sThumbRY, thumbstick_deadzone))\n\n\t\t\t\t\traw_angle = last_raw_angle;\n\n\t\t\t\telse\n\n\t\t\t\t\traw_angle = calculate_angle_from_x_y(controller_state.Gamepad.sThumbRX, controller_state.Gamepad.sThumbRY);\n\n\t\t\t}\n\n\n\n\t\t\tcheck_if_rotated_past_180(raw_angle, last_raw_angle, &rotations);\n\n\t\t\tclip_angle_and_rotations(virtual_wheel_max_angle, &raw_angle, &rotations);\n\n\t\t\treal_angle = calculate_real_angle(raw_angle, virtual_wheel_max_angle, &rotations, &steering_lock);\n", "file_path": "asw/asw.cpp", "rank": 55, "score": 2.119516408632354 }, { "content": "\t/******************************************************************************/\n\n\t/* Start of main loop */\n\n\t/******************************************************************************/\n\n\t\n\n\twhile (1)\n\n\t{\n\n\t\t// this for loop makes the app react to console input events, used mainly for keyboard\n\n\t\tGetNumberOfConsoleInputEvents(console_input, &console_events_count);\n\n\t\tfor (unsigned int i = 0; i < console_events_count; i++)\n\n\t\t{\n\n\t\t\t//printf(\"number of console events left: %u\\n\", console_events_count);\n\n\t\t\tReadConsoleInput(console_input, &console_input_record, 1, &console_events_read);\n\n\t\t\t//printf(\"events read: %u\\n\", console_events_read);\n\n\t\t\t//printf(\"event type: %X\\n\", console_input_record.EventType);\n\n\t\t\tswitch (console_input_record.EventType)\n\n\t\t\t{\n\n\t\t\tcase FOCUS_EVENT:\n\n\t\t\t\t#ifdef EXTRA_LINES\n\n\t\t\t\tprintf(\"FOCUS_EVENT\\n\");\n\n\t\t\t\t#endif\n", "file_path": "asw/asw.cpp", "rank": 56, "score": 2.0091094933230784 }, { "content": "\t\tif ((argcmp(argv[i], \"help\") == 0) || (argcmp(argv[i], \"h\") == 0) || (argcmp(argv[i], \"?\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-help detected\\n\");\n\n\t\t\tif (*(aliaslist.help_detected))\n\n\t\t\t\tprintf(\"\\n\");\n\n\t\t\t*(aliaslist.help_detected) = true;\n\n\t\t\tprintf(\"Usage: asw [-i vjoyid] [-c controller] [-d size] [-r range] [-b]\\n\");\n\n\t\t\tprintf(\" [-a] [-bmi increment] [-bmmd code] [-bmnr] [-bmrw delay]\\n\");\n\n\t\t\tprintf(\" [-wrbf buttons] [-dwr] [-t delay] [-rs] [-wa axis]\\n\");\n\n\t\t\tprintf(\" [-lta axis] [-rta axis] [-iw] [-ilt] [-irt] [-h] [-v]\\n\");\n\n\t\t\tprintf(\"\\n\");\n\n\t\t\tprintf(\"Options:\\n\");\n\n\t\t\tprintf(\" -i vjoyid vJoy interface to use [1-16]\\n\");\n\n\t\t\tprintf(\" -c controller controller to use [1-4]\\n\");\n\n\t\t\tprintf(\" -d size deadzone for the thumbstick input in percent\\n\");\n\n\t\t\tprintf(\" -r range number of degrees the virtual wheel can be rotated to\\n\");\n\n\t\t\tprintf(\" -b run program in bindmode\\n\");\n\n\t\t\tprintf(\" -a make any key press quit the program\\n\");\n\n\t\t\tprintf(\" -bmi increment adjust the speed of bindmode\\n\");\n\n\t\t\tprintf(\" -bmmd value changes the movement direction in bindmode\\n\");\n", "file_path": "asw/cmdline.cpp", "rank": 59, "score": 1.7279497438163829 }, { "content": "\t\t\t\t\tprintf(\"-bindmodeincrement value not present or in incorrect format\\n\");\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-bindmodeincrement value not present\\n\");\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ((argcmp(argv[i], \"bindmodemovementdirection\") == 0) || (argcmp(argv[i], \"bmmd\") == 0))\n\n\t\t{\n\n\t\t\t//printf(\"-bindmodemovementdirection detected\\n\");\n\n\t\t\tif ((i + 1) < argc)\n\n\t\t\t{\n\n\t\t\t\tif (sscanf_s(argv[i + 1], \"%d\", &int_scan_val) == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\t// bindmodemovementdirection should be 1 or -1\n", "file_path": "asw/cmdline.cpp", "rank": 60, "score": 1.7104528622279753 }, { "content": "\t\t\t\t{\n\n\t\t\t\t\t// I should probably clip this to 0-32767 just to be sure\n\n\t\t\t\t\t*(aliaslist.virtual_wheel_max_angle) = int_scan_val;\n\n\t\t\t\t\ti++;\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tprintf(\"-rotation value not present or in incorrect format\\n\");\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n\n\t\t\t\tprintf(\"-rotation value not present\\n\");\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcontinue;\n\n\t\t}\n\n\n\n\t\tif ((argcmp(argv[i], \"bindmode\") == 0) || (argcmp(argv[i], \"b\") == 0))\n", "file_path": "asw/cmdline.cpp", "rank": 61, "score": 1.6826949908094613 }, { "content": "\t\t\n\n\t\tif (bind_mode == 0)\n\n\t\t{\n\n\t\t\tXInputGetState(controller_number, &controller_state);\n\n\n\n\t\t\t// reset the wheel to center if the preconfigured controller button (or their combination) is currently pressed down\n\n\t\t\t//printf(\"0x%x %d\\n\", controller_state.Gamepad.wButtons, controller_state.Gamepad.wButtons & wheel_reset_buttons_flag);\n\n\t\t\tif (!disable_wheel_reset)\n\n\t\t\t{\n\n\t\t\t\tif ((controller_state.Gamepad.wButtons & wheel_reset_buttons_flag) == wheel_reset_buttons_flag)\n\n\t\t\t\t{\n\n\t\t\t\t\traw_angle = 0.0; // angle calculated from thumbstick X and Y axis position, should be from -180.0 to 180.0\n\n\t\t\t\t\trotations = 0; // the number of times the stick rotated past the 180° position, positive = right, negative = left\n\n\t\t\t\t\tsteering_lock = 0; // 0 = no lock, -1 = locked at full left, 1 = locked at full right, this variable is not actually used in this version of the code\n\n\t\t\t\t\treal_angle = 0.0; // virtual wheel angle caluclated by combining \"raw_angle\" and \"rotations\"\n\n\t\t\t\t\tlast_raw_angle = 0.0; // holds the angle from the previous tick\n\n\t\t\t\t\tSetAxis(invert_vjoy_axis_value(angle_to_vjoy(real_angle, virtual_wheel_max_angle), invert_wheel_axis), iInterface, wheel_axis);\n\n\t\t\t\t\tcontinue;\n\n\t\t\t\t}\n\n\t\t\t}\n", "file_path": "asw/asw.cpp", "rank": 63, "score": 1.2563520893583662 }, { "content": "\n\n\t// Reset this device to default values\n\n\tResetVJD(iInterface);\n\n\t\n\n\n\n\t/******************************************************************************/\n\n\t/* Start of xinput setup code */\n\n\t/******************************************************************************/\n\n\n\n\t// this is just a check to see if the controller is connected\n\n\t// the program will continue even if the controller is not connected\n\n\tif (XInputGetState(controller_number, &controller_state) == ERROR_DEVICE_NOT_CONNECTED)\n\n\t\tprintf(\"controller %u is not connected, the program will continue but controller input may not be read correctly\\n\", controller_number+1);\n\n\telse\n\n\t\tprintf(\"controller %u is connected\\n\", controller_number+1);\n\n\n\n\tprintf(\"asw version %s successfully started, \", VERSION_STRING);\n\n\tif (!any_key_to_quit)\n\n\t\tprintf(\"press esc to quit\\n\");\n\n\telse\n", "file_path": "asw/asw.cpp", "rank": 64, "score": 1.1558586655814698 }, { "content": "\t/******************************************************************************/\n\n\t\n\n\t// this code is taken from the \"How to write a vJoy Feeder (C/C++)\" document of version \"Updated: 19-Oct-2015 (v2.1.6)\"\n\n\t// this is available here: http://vjoystick.sourceforge.net/site/includes/SDK_ReadMe.pdf\n\n\n\n\t// Get the driver attributes (Vendor ID, Product ID, Version Number)\n\n\tif (!vJoyEnabled())\n\n\t{\n\n\t\tprintf(\"Failed Getting vJoy attributes.\\n\");\n\n\t\treturn -2;\n\n\t}\n\n\telse\n\n\t{\n\n\t\t#ifdef EXTRA_LINES\n\n\t\tprintf(\"Vendor: %S\\nProduct: %S\\nVersion Number: %S\\n\", \n\n\t\t\t(wchar_t*)GetvJoyManufacturerString(),\n\n\t\t\t(wchar_t*)GetvJoyProductString(),\n\n\t\t\t(wchar_t*)GetvJoySerialNumberString());\n\n\t\t#else\n\n\t\tprintf(\"using vJoy version: %S\\n\", (wchar_t*)GetvJoySerialNumberString());\n", "file_path": "asw/asw.cpp", "rank": 65, "score": 1.0341477473501008 }, { "content": "\tint cmp1size = strlen(cmp) + 1 + 1;\n\n\tchar* cmp1 = new char[cmp1size]();\n\n\tstrcpy_s(cmp1, cmp1size, \"-\");\n\n\tstrcat_s(cmp1, cmp1size, cmp);\n\n\treturnval = strcmp(arg, cmp1);\n\n\tdelete[] cmp1;\n\n\tif (returnval == 0)\n\n\t\treturn returnval;\n\n\n\n\tcmp1size = strlen(cmp) + 1 + 1;\n\n\tcmp1 = new char[cmp1size]();\n\n\tstrcpy_s(cmp1, cmp1size, \"/\");\n\n\tstrcat_s(cmp1, cmp1size, cmp);\n\n\treturnval = strcmp(arg, cmp1);\n\n\tdelete[] cmp1;\n\n\tif (returnval == 0)\n\n\t\treturn returnval;\n\n\n\n\tcmp1size = strlen(cmp) + 1 + 2;\n\n\tcmp1 = new char[cmp1size]();\n\n\tstrcpy_s(cmp1, cmp1size, \"--\");\n\n\tstrcat_s(cmp1, cmp1size, cmp);\n\n\treturnval = strcmp(arg, cmp1);\n\n\tdelete[] cmp1;\n\n\tif (returnval == 0)\n\n\t\treturn returnval;\n\n\n\n\treturn returnval;\n\n}", "file_path": "asw/cmdline.cpp", "rank": 66, "score": 1.0304906249476335 } ]
C++
thread_lib/main.cpp
fu4ck/linux_env_dev
8076ca56a2ec907dec0c952e6ed27b6e644c5ae1
#include <iostream> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/epoll.h> #include <fcntl.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <assert.h> #include <sys/stat.h> #include <string> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <stdarg.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include "threadpool.h" #include "http_conn.h" #define MAX_FD 65535 #define MAX_EVENT_NUMBER 10000 extern int addfd(int epollfd, int fd, bool one_shot); extern int removefd(int epollfd, int fd); void addsig(int sig, void(handler)(int), bool restart=true) { struct sigaction sa; memset(&sa, '\0', sizeof(sa)); sa.sa_handler = handler; if(restart){ sa.sa_flags |= SA_RESTART; } sigfillset(&sa.sa_mask); assert(sigaction(sig, &sa, NULL)!=-1); } void show_error(int connfd, const char* info){ printf("%s", info); send(connfd, info, strlen(info), 0); close(connfd); } int main(int argc, char* argv[]) { if (argc<=2){ return 1; } const char* ip = argv[1]; int port = atoi(argv[2]); addsig(SIGPIPE, SIG_IGN); threadpool<http_conn>* pool = NULL; try{ pool = new threadpool<http_conn>; }catch (...){ return 1; } http_conn* users = new http_conn[MAX_FD]; assert(users); int user_count = 0; int listenfd = socket(PF_INET, SOCK_STREAM, 0); assert(listenfd >= 0); struct linger tmp = {1,0}; setsockopt(listenfd, SOL_SOCKET, SO_LINGER, &tmp, sizeof(tmp)); int ret =0 ; struct sockaddr_in address; bzero(&address,sizeof(address)); address.sin_family=AF_INET; inet_pton(AF_INET, ip, &address.sin_addr); address.sin_port = htons(port); ret = bind(listenfd, (struct sockaddr*)&address, sizeof(address)); assert(ret>=0); ret = listen(listenfd, 5); assert(ret>=0); epoll_event events[MAX_EVENT_NUMBER]; int epollfd = epoll_create(5); assert(epollfd!=-1); addfd(epollfd, listenfd, false); http_conn::m_epollfd = epollfd; while(true){ int number = epoll_wait(epollfd, events, MAX_EVENT_NUMBER, -1); if((number<0)&&(errno!=EINTR)){ break; } for(int i=0;i<number;i++){ int sockfd = events[i].data.fd; if(sockfd==listenfd){ struct sockaddr_in client_address; socklen_t client_addrlength = sizeof(client_address); int connfd = accept(listenfd, (struct sockaddr*)&client_address, &client_addrlength); if (connfd <0){ continue; } if(http_conn::m_user_count>=MAX_FD){ continue; } users[connfd].init(connfd, client_address); }else if(events[i].events&(EPOLLRDHUP|EPOLLHUP|EPOLLERR)){ users[sockfd].close_conn(); }else if(events[i].events&EPOLLIN){ if(users[sockfd].read()){ pool->append(users+sockfd); }else{ users[sockfd].close_conn(); } }else if(events[i].events&EPOLLOUT){ if(!users[sockfd].write()){ users[sockfd].close_conn(); } }else{ } } } close(epollfd); close(listenfd); delete []users; delete pool; return 0; }
#include <iostream> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/epoll.h> #include <fcntl.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <assert.h> #include <sys/stat.h> #include <string> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <stdarg.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include "threadpool.h" #include "http_conn.h" #define MAX_FD 65535 #define MAX_EVENT_NUMBER 10000 extern int addfd(int epollfd, int fd, bool one_shot); extern int removefd(int epollfd, int fd); void addsig(int sig, void(handler)(int), bool restart=true) { struct sigaction sa; memset(&sa, '\0', sizeof(sa)); sa.sa_handler = handler; if(restart){ sa.sa_flags |= SA_RESTART; } sigfillset(&sa.sa_mask); assert(sigaction(sig, &sa, NULL)!=-1); } void show_error(int connfd, const char* info){ printf("%s", info); send(connfd, info, strlen(info), 0); close(connfd); } int main(int argc, char* argv[]) { if (argc<=2){ return 1; } const char* ip = argv[1]; int port = atoi(argv[2]); addsig(SIGPIPE, SIG_IGN); threadpool<http_conn>* pool = NULL; try{ pool = new threadpool<http_conn>; }catch (...){ return 1; } http_conn* users = new http_conn[MAX_FD]; assert(users); int user_count = 0; int listenfd = socket(PF_INET, SOCK_STREAM, 0); assert(listenfd >= 0); struct linger tmp = {1,0}; setsockopt(listenfd, SOL_SOCKET, SO_LINGER, &tmp, sizeof(tmp)); int ret =0 ; struct sockaddr_in address; bzero(&address,sizeof(address)); address.sin_family=AF_INET; inet_pton(AF_INET, ip, &address.sin_addr); address.sin_port = htons(port); ret = bind(listenfd, (struct sockaddr*)&address, sizeof(address)); assert(ret>=0); ret = listen(listenfd, 5); assert(ret>=0); epoll_event events[MAX_EVENT_NUMBER]; int epollfd = epoll_create(5); assert(epollfd!=-1); addfd(epollfd, listenfd, false); http_conn::m_epollfd = epollfd; while(true){ int number = epoll_wait(epollfd, events, MAX_EVENT_NUMBER, -1); if((number<0)&&(errno!=EINTR)){ break; } for(int i=0;i<number;i++){ int sockfd = events[i].data.fd; if(sockfd==listenfd){ struct sockaddr_in client_address; socklen_t client_addrlength = sizeof(client_address); int connfd = accept(listenfd, (struct sockaddr*)&client_address, &client_addrlength); if (connfd <0){ continue; } if(http_conn::m_user_count>=MAX_FD){ continue; } users[connfd].init(connfd, client_address); }else if(events[i].events&(EPOLLRDHUP|EPOLLHUP|EPOLLERR)){ users[sockfd].close_conn(); }else if(events[i].events&EPOLLIN){ if(users[sockfd].read()){ pool->append(users+sockfd); }else{ users[sockfd].close_conn(); } }
else if(events[i].events&EPOLLOUT){ if(!users[sockfd].write()){ users[sockfd].close_conn(); } }else{ } } } close(epollfd); close(listenfd); delete []users; delete pool; return 0; }
function_block-function_prefix_line
[ { "content": "char const* info_compiler = \"INFO\" \":\" \"compiler[\" COMPILER_ID \"]\";\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 0, "score": 15856.93664216525 }, { "content": "char const* info_platform = \"INFO\" \":\" \"platform[\" PLATFORM_ID \"]\";\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 1, "score": 15856.93664216525 }, { "content": "char const* info_compiler = \"INFO\" \":\" \"compiler[\" COMPILER_ID \"]\";\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 2, "score": 15856.93664216525 }, { "content": "char const* info_platform = \"INFO\" \":\" \"platform[\" PLATFORM_ID \"]\";\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 3, "score": 15856.93664216525 }, { "content": "char const* info_simulate = \"INFO\" \":\" \"simulate[\" SIMULATE_ID \"]\";\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 4, "score": 15854.720776870261 }, { "content": "char const* info_arch = \"INFO\" \":\" \"arch[\" ARCHITECTURE_ID \"]\";\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 5, "score": 15854.720776870261 }, { "content": "char const* info_simulate = \"INFO\" \":\" \"simulate[\" SIMULATE_ID \"]\";\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 6, "score": 15854.720776870261 }, { "content": "char const info_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',\n\n COMPILER_VERSION_MAJOR,\n\n# ifdef COMPILER_VERSION_MINOR\n\n '.', COMPILER_VERSION_MINOR,\n\n# ifdef COMPILER_VERSION_PATCH\n\n '.', COMPILER_VERSION_PATCH,\n\n# ifdef COMPILER_VERSION_TWEAK\n\n '.', COMPILER_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 7, "score": 15854.720776870261 }, { "content": "char const* info_arch = \"INFO\" \":\" \"arch[\" ARCHITECTURE_ID \"]\";\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 8, "score": 15854.720776870261 }, { "content": "char const info_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',\n\n COMPILER_VERSION_MAJOR,\n\n# ifdef COMPILER_VERSION_MINOR\n\n '.', COMPILER_VERSION_MINOR,\n\n# ifdef COMPILER_VERSION_PATCH\n\n '.', COMPILER_VERSION_PATCH,\n\n# ifdef COMPILER_VERSION_TWEAK\n\n '.', COMPILER_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 9, "score": 15854.720776870261 }, { "content": "char const info_version_internal[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',\n\n 'i','n','t','e','r','n','a','l','[',\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 10, "score": 15473.465900112154 }, { "content": "char const info_simulate_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',\n\n SIMULATE_VERSION_MAJOR,\n\n# ifdef SIMULATE_VERSION_MINOR\n\n '.', SIMULATE_VERSION_MINOR,\n\n# ifdef SIMULATE_VERSION_PATCH\n\n '.', SIMULATE_VERSION_PATCH,\n\n# ifdef SIMULATE_VERSION_TWEAK\n\n '.', SIMULATE_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 11, "score": 15473.465900112154 }, { "content": "char const info_simulate_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',\n\n SIMULATE_VERSION_MAJOR,\n\n# ifdef SIMULATE_VERSION_MINOR\n\n '.', SIMULATE_VERSION_MINOR,\n\n# ifdef SIMULATE_VERSION_PATCH\n\n '.', SIMULATE_VERSION_PATCH,\n\n# ifdef SIMULATE_VERSION_TWEAK\n\n '.', SIMULATE_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 12, "score": 15473.465900112154 }, { "content": "char const info_version_internal[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',\n\n 'i','n','t','e','r','n','a','l','[',\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 13, "score": 15473.465900112154 }, { "content": "const char* info_language_dialect_default =\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 14, "score": 15110.116357058996 }, { "content": "const char* info_language_dialect_default =\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdC/CMakeCCompilerId.c", "rank": 15, "score": 15110.116357058996 }, { "content": "class http_conn {\n\npublic:\n\n static const int FILENAME_LEN=200;\n\n static const int READ_BUFFER_SIZE=2048;\n\n static const int WRITE_BUFFER_SIZE=1024;\n\n enum METHOD {GET=0, POST, HEAD, PUT, DELETE,\n\n TRACE, OPTIONS, CONNECT, PATCH};\n\n enum CHECK_STATE{ CHECK_STATE_REQUESTLINE=0,\n\n CHECK_STATE_HEADER,\n\n CHECK_STATE_COTENT};\n\n enum HTTP_CODE{\n\n NO_REQUEST,\n\n GET_REQUEST,\n\n BAD_REQUEST,\n\n NO_RESOURCE,\n\n FORBIDDEN_REQUEST,\n\n FILE_REQUEST,\n\n INTERNAL_ERROR,\n\n CLOSED_CONNECTION,\n\n };\n", "file_path": "thread_lib/http_conn.h", "rank": 16, "score": 12303.889019044638 }, { "content": "\n\n while(!m_stop){\n\n number = epoll_wait(m_epollfd, events, MAX_EVENT_NUMBER, -1);\n\n if ((number<0)&&(errno!=EINTR)){\n\n printf(\"epoll failure\\n\");\n\n break;\n\n }\n\n for(int i=0;i<number;i++){\n\n int sockfd = events[i].data.fd;\n\n if((sockfd==pipefd)&&(events[i].events&EPOLLIN)){\n\n int client = 0;\n\n ret = recv(sockfd, (char *)&client, sizeof(client), 0);\n\n if(((ret<0)&&(errno!=EAGAIN))||ret==0){\n\n continue;\n\n }\n\n else{\n\n struct sockaddr_in client_address;\n\n socklen_t client_addrlength = sizeof(client_address);\n\n int connfd = accept(m_listenfd, (struct sockaddr*)&client_address, &client_addrlength);\n\n if (connfd<0){\n", "file_path": "process_lib/processpool.h", "rank": 19, "score": 28.607356722079604 }, { "content": " continue;\n\n }\n\n addfd(m_epollfd, connfd);\n\n users[connfd].init(m_epollfd, connfd, client_address);\n\n }\n\n }\n\n else if( sockfd==sig_pipefd[0]&&(events[i].events&EPOLLIN)){\n\n int sig;\n\n char signals[1024];\n\n ret = recv(sig_pipefd[0], signals, sizeof(signals), 0);\n\n if (ret <= 0){\n\n continue;\n\n }\n\n else{\n\n for(int i =0;i<ret;i++){\n\n switch(signals[i]){\n\n case SIGCHLD:\n\n {\n\n pid_t pid;\n\n int stat;\n", "file_path": "process_lib/processpool.h", "rank": 20, "score": 26.83199949797082 }, { "content": " int msg = sig;\n\n send(sig_pipefd[1], (char*)&msg, 1, 0);\n\n errno = save_errno;\n\n}\n\n\n\nstatic void addsig(int sig, void(handler)(int), bool restart=true){\n\n struct sigaction sa;\n\n memset(&sa, '\\0', sizeof(sa));\n\n sa.sa_handler = handler;\n\n if(restart){\n\n sa.sa_flags |= SA_RESTART;\n\n }\n\n sigfillset(&sa.sa_mask);\n\n assert(sigaction(sig, &sa, NULL)!=-1);\n\n}\n\n\n\ntemplate<typename T>\n\nprocesspool<T>::processpool(int listenfd, int process_number)\n\n:m_listenfd(listenfd), m_process_number(process_number), m_idx(-1), m_stop(false){\n\n assert((process_number>0)&&(process_number<=MAX_PROCESS_NUMBER));\n", "file_path": "process_lib/processpool.h", "rank": 23, "score": 25.024564919495415 }, { "content": "int main(int argc, char *argv[]) {\n\n\n\n if (argc<2){\n\n return 1;\n\n }\n\n const char* ip = argv[1];\n\n int port=atoi(argv[2]);\n\n int listenfd = socket(PF_INET, SOCK_STREAM, 0);\n\n assert(listenfd>0);\n\n\n\n int ret = 0;\n\n struct sockaddr_in address;\n\n bzero(&address, sizeof(address));\n\n address.sin_family = AF_INET;\n\n inet_pton(AF_INET, ip, &address.sin_addr);\n\n address.sin_port = htons(port);\n\n\n\n ret = bind(listenfd, (struct sockaddr*)&address, sizeof(address));\n\n assert(ret!=-1);\n\n\n", "file_path": "process_lib/main.cpp", "rank": 24, "score": 24.269094549078588 }, { "content": " int sub_process_counter = 0;\n\n int new_conn = 1;\n\n int number = 0;\n\n int ret = -1;\n\n while(!m_stop){\n\n number = epoll_wait(m_epollfd, events, MAX_EVENT_NUMBER, -1);\n\n if ((number <0)&&(errno!=EINTR)){\n\n printf(\"epoll failure\\n\");\n\n break;\n\n }\n\n for(int i=0;i<number;i++){\n\n int sockfd = events[i].data.fd;\n\n if(sockfd==m_listenfd){\n\n int i = sub_process_counter;\n\n do{\n\n if(m_sub_process[i].m_pid!=-1){\n\n break;\n\n }\n\n i = (i+1)%m_process_number;\n\n }while(i!=sub_process_counter);\n", "file_path": "process_lib/processpool.h", "rank": 25, "score": 24.136194898050334 }, { "content": " if (m_sub_process[i].m_pid==-1){\n\n m_stop=true;\n\n break;\n\n }\n\n sub_process_counter = (i+1)%m_process_number;\n\n send(m_sub_process[i].m_pipefd[0],(char *)&new_conn, sizeof(new_conn),0);\n\n printf(\"send request to child %d\\n\",i );\n\n }\n\n else if((sockfd==sig_pipefd[0])&&(events[i].events&EPOLLIN)){\n\n int sig;\n\n char signals[1024];\n\n ret = recv(sig_pipefd[0], signals, sizeof(signals),0);\n\n if (ret <= 0){\n\n continue;\n\n }else{\n\n for(int i=0;i<ret;i++){\n\n switch (signals[i]) {\n\n case SIGCHLD: {\n\n pid_t pid;\n\n int stat;\n", "file_path": "process_lib/processpool.h", "rank": 27, "score": 22.2880905542158 }, { "content": " close(fd);\n\n}\n\n\n\nvoid modfd(int epollfd, int fd, int ev){\n\n epoll_event event;\n\n event.data.fd = fd;\n\n event.events = ev | EPOLLET|EPOLLONESHOT | EPOLLRDHUP;\n\n epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, &event);\n\n}\n\n\n\nint http_conn::m_user_count = 0;\n\nint http_conn::m_epollfd = -1;\n\n\n\nvoid http_conn::close_conn(bool real_close){\n\n if(real_close&&(m_sockfd!=-1)){\n\n removefd(m_epollfd, m_sockfd);\n\n m_sockfd=-1;\n\n m_user_count--;\n\n }\n\n};\n", "file_path": "thread_lib/http_conn.cpp", "rank": 28, "score": 21.478551677167747 }, { "content": " }\n\n else{\n\n continue;\n\n }\n\n }\n\n }\n\n\n\n delete [] users;\n\n users = NULL;\n\n close(pipefd);\n\n close(m_epollfd);\n\n}\n\n\n\ntemplate<typename T>\n\nvoid processpool<T>::run_parent() {\n\n setup_sig_pipe();\n\n\n\n addfd(m_epollfd, m_listenfd);\n\n\n\n epoll_event events[MAX_EVENT_NUMBER];\n", "file_path": "process_lib/processpool.h", "rank": 29, "score": 21.455186599163294 }, { "content": " int new_option = old_option | O_NONBLOCK;\n\n fcntl(fd, F_SETFL, new_option);\n\n return old_option;\n\n}\n\n\n\nstatic void addfd(int epollfd, int fd){\n\n epoll_event event;\n\n event.data.fd = fd;\n\n event.events = EPOLLIN | EPOLLET;\n\n epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &event);\n\n setnonblocking(fd);\n\n}\n\n\n\nstatic void removefd(int epollfd, int fd){\n\n epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, 0 );\n\n close(fd);\n\n}\n\n\n\nstatic void sig_handler(int sig){\n\n int save_errno = errno;\n", "file_path": "process_lib/processpool.h", "rank": 30, "score": 20.979644055495484 }, { "content": " if(m_idx!=-1){\n\n run_child();\n\n return;\n\n }\n\n run_parent();\n\n}\n\n\n\ntemplate<typename T>\n\nvoid processpool<T>::run_child() {\n\n setup_sig_pipe();\n\n\n\n int pipefd = m_sub_process[m_idx].m_pipefd[1];\n\n addfd(m_epollfd, pipefd);\n\n\n\n epoll_event events[MAX_EVENT_NUMBER];\n\n T* users = new T[USER_PER_PROCESS];\n\n assert(users);\n\n\n\n int number = 0 ;\n\n int ret = -1;\n", "file_path": "process_lib/processpool.h", "rank": 31, "score": 19.546734912562815 }, { "content": " int old_option= fcntl(fd, F_GETFL);\n\n int new_option = old_option|O_NONBLOCK;\n\n fcntl(fd, F_SETFL, new_option);\n\n return old_option;\n\n}\n\n\n\nvoid addfd(int epollfd, int fd, bool one_slot){\n\n epoll_event event;\n\n event.data.fd = fd;\n\n event.events = EPOLLIN|EPOLLET|EPOLLRDHUP;\n\n if(one_slot){\n\n event.events |=EPOLLONESHOT;\n\n }\n\n epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &event);\n\n setnonblocking(fd);\n\n}\n\n\n\n\n\nvoid removefd(int epollfd, int fd){\n\n epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, 0);\n", "file_path": "thread_lib/http_conn.cpp", "rank": 32, "score": 18.394972790917983 }, { "content": " if(errno!=EAGAIN){\n\n removefd(m_epollfd, m_sockfd);\n\n }\n\n break;\n\n }\n\n else if(ret == 0){\n\n removefd(m_epollfd, m_sockfd);\n\n break;\n\n }else\n\n {\n\n m_read_idx +=ret;\n\n printf(\"user content is %s\\n\", m_buf);\n\n for(;idx<m_read_idx;++idx){\n\n if((idx>=1)&&(m_buf[idx-1]=='\\r')&&(m_buf[idx]=='\\n')){\n\n break;\n\n }\n\n }\n\n if (idx==m_read_idx){\n\n continue;\n\n }\n", "file_path": "process_lib/main.cpp", "rank": 33, "score": 17.499523030356627 }, { "content": " LINE_STATUS parse_line();\n\n\n\n void unmap();\n\n bool add_response(const char* format, ...);\n\n bool add_content(const char* content);\n\n bool add_status_line(int status, const char* title);\n\n bool add_headers(int content_length);\n\n bool add_content_length(int content_length);\n\n bool add_linger();\n\n bool add_blank_line();\n\npublic:\n\n static int m_epollfd;\n\n static int m_user_count;\n\nprivate:\n\n int m_sockfd;\n\n sockaddr_in m_address;\n\n\n\n char m_read_buf[READ_BUFFER_SIZE];\n\n int m_read_idx;\n\n int m_checked_idx;\n", "file_path": "thread_lib/http_conn.h", "rank": 34, "score": 17.457942650606597 }, { "content": "private:\n\n static const int MAX_PROCESS_NUMBER=16;\n\n static const int USER_PER_PROCESS=65535;\n\n static const int MAX_EVENT_NUMBER=10000;\n\n int m_process_number;\n\n int m_idx;\n\n int m_epollfd;\n\n int m_listenfd;\n\n int m_stop;\n\n process* m_sub_process;\n\n static processpool<T>* m_instance;\n\n};\n\n\n\ntemplate<typename T>\n\nprocesspool<T>* processpool<T>::m_instance = NULL;\n\n\n\nstatic int sig_pipefd[2];\n\nstatic int setnonblocking(int fd)\n\n{\n\n int old_option = fcntl(fd, F_GETFL);\n", "file_path": "process_lib/processpool.h", "rank": 35, "score": 17.23868681507967 }, { "content": "\n\ntemplate<typename T>\n\nvoid processpool<T>::setup_sig_pipe() {\n\n m_epollfd = epoll_create(5);\n\n assert(m_epollfd!=-1);\n\n\n\n int ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sig_pipefd);\n\n assert(ret!=-1);\n\n\n\n setnonblocking(sig_pipefd[1]);\n\n addfd(m_epollfd, sig_pipefd[0]);\n\n\n\n addsig(SIGCHLD, sig_handler);\n\n addsig(SIGTERM, sig_handler);\n\n addsig(SIGINT, sig_handler);\n\n addsig(SIGPIPE, SIG_IGN);\n\n}\n\n\n\ntemplate<typename T>\n\nvoid processpool<T>::run() {\n", "file_path": "process_lib/processpool.h", "rank": 36, "score": 15.164091200287356 }, { "content": " m_buf[idx-1]='\\0';\n\n char* file_name = m_buf;\n\n if(access(file_name, F_OK)==-1){\n\n removefd(m_epollfd, m_sockfd);\n\n break;\n\n }\n\n ret = fork();\n\n if(ret==-1){\n\n removefd(m_epollfd, m_sockfd);\n\n break;\n\n }\n\n else if(ret >0){\n\n removefd(m_epollfd, m_sockfd);\n\n break;\n\n }\n\n else{\n\n close(STDOUT_FILENO);\n\n dup(m_sockfd);\n\n execl(m_buf, m_buf, 0);\n\n exit(0);\n", "file_path": "process_lib/main.cpp", "rank": 37, "score": 14.763089247636994 }, { "content": "\n\nvoid http_conn::init(int sockfd, const sockaddr_in &addr) {\n\n m_sockfd = sockfd;\n\n m_address = addr;\n\n int reuse=1;\n\n setsockopt(m_sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse) );\n\n addfd(m_epollfd, sockfd, true);\n\n m_user_count++;\n\n init();\n\n}\n\n\n\nvoid http_conn::init() {\n\n m_check_state = CHECK_STATE_REQUESTLINE;\n\n m_linger = false;\n\n m_method = GET;\n\n m_url = 0;\n\n m_version = 0;\n\n m_content_length = 0;\n\n m_host = 0;\n\n m_start_line = 0;\n", "file_path": "thread_lib/http_conn.cpp", "rank": 38, "score": 14.311507781409622 }, { "content": " while((pid= waitpid(-1,&stat, WNOHANG))>0){\n\n continue;\n\n }\n\n break;\n\n }\n\n case SIGTERM:\n\n case SIGINT:\n\n {\n\n m_stop=true;\n\n break;\n\n }\n\n default:{\n\n break;\n\n }\n\n }\n\n }\n\n }\n\n }\n\n else if (events[i].events&EPOLLIN){\n\n users[sockfd].process();\n", "file_path": "process_lib/processpool.h", "rank": 39, "score": 13.805911580618272 }, { "content": " }\n\n }\n\n\n\n }\n\n }\n\n\n\n\n\nprivate:\n\n static const int BUFFER_SIZE=1024;\n\n static int m_epollfd;\n\n int m_sockfd;\n\n sockaddr_in m_address;\n\n char m_buf[BUFFER_SIZE];\n\n int m_read_idx;\n\n};\n\n\n\nint cgi_conn::m_epollfd=-1;\n\n\n\n\n\n\n", "file_path": "process_lib/main.cpp", "rank": 40, "score": 13.749753478212185 }, { "content": " printf(\"kill all the child\\n\");\n\n for(int i=0;i<m_process_number;i++){\n\n int pid = m_sub_process[i].m_pid;\n\n if (pid!=-1){\n\n kill(pid, SIGTERM);\n\n }\n\n }\n\n break;\n\n }\n\n default:\n\n break;\n\n }\n\n\n\n }\n\n }\n\n }\n\n else{\n\n continue;\n\n }\n\n }\n", "file_path": "process_lib/processpool.h", "rank": 41, "score": 13.65567242986493 }, { "content": "//\n\n// Created by root on 8/30/21.\n\n//\n\n\n\n#include <stdio.h>\n\n#include<stdlib.h>\n\n#include<iostream>\n\n#include<string.h>\n\n#include \"http_conn.h\"\n\nconst char* ok_200_title=\"OK\";\n\nconst char* error_400_title=\"Bad Request\";\n\nconst char* error_400_form=\"Your request has bad syntax\";\n\nconst char* error_403_title = \"Forbidden\";\n\nconst char* error_403_form=\"not have permission\";\n\nconst char* error_404_title=\"Not Found\";\n\nconst char* error_404_form=\"Not Found\";\n\nconst char* error_500_title=\"Internal Error\";\n\nconst char* error_500_form=\"Internal Error\";\n\n\n\nint setnonblocking(int fd){\n", "file_path": "thread_lib/http_conn.cpp", "rank": 42, "score": 13.370794931243193 }, { "content": " return true;\n\n}\n\n\n\nvoid http_conn::process() {\n\n HTTP_CODE read_ret = process_read();\n\n if(read_ret==NO_REQUEST){\n\n modfd(m_epollfd, m_sockfd, EPOLLIN);\n\n return;\n\n }\n\n bool write_ret = process_write(read_ret);\n\n if (!write_ret){\n\n close_conn();\n\n }\n\n modfd(m_epollfd, m_sockfd, EPOLLOUT);\n\n}\n\n\n\n\n\n\n\n\n\n\n", "file_path": "thread_lib/http_conn.cpp", "rank": 43, "score": 13.052470959282367 }, { "content": " m_sub_process = new process[process_number];\n\n assert(m_sub_process);\n\n\n\n for(int i=0;i<process_number;i++){\n\n int ret = socketpair(PF_UNIX, SOCK_STREAM, 0, m_sub_process[i].m_pipefd);\n\n assert(ret == 0);\n\n\n\n m_sub_process[i].m_pid = fork();\n\n assert(m_sub_process[i].m_pid >=0 );\n\n\n\n if(m_sub_process[i].m_pid>0){\n\n close(m_sub_process[i].m_pipefd[1]);\n\n continue;\n\n }else{\n\n close(m_sub_process[i].m_pipefd[0]);\n\n m_idx=i;\n\n break;\n\n }\n\n }\n\n}\n", "file_path": "process_lib/processpool.h", "rank": 45, "score": 12.173277485998003 }, { "content": "\n\nconst char* info_language_dialect_default = \"INFO\" \":\" \"dialect_default[\"\n\n#if CXX_STD > 202002L\n\n \"23\"\n\n#elif CXX_STD > 201703L\n\n \"20\"\n\n#elif CXX_STD >= 201703L\n\n \"17\"\n\n#elif CXX_STD >= 201402L\n\n \"14\"\n\n#elif CXX_STD >= 201103L\n\n \"11\"\n\n#else\n\n \"98\"\n\n#endif\n\n\"]\";\n\n\n\n/*--------------------------------------------------------------------------*/\n\n\n\nint main(int argc, char* argv[])\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 46, "score": 12.010291128707768 }, { "content": "\n\nconst char* info_language_dialect_default = \"INFO\" \":\" \"dialect_default[\"\n\n#if CXX_STD > 202002L\n\n \"23\"\n\n#elif CXX_STD > 201703L\n\n \"20\"\n\n#elif CXX_STD >= 201703L\n\n \"17\"\n\n#elif CXX_STD >= 201402L\n\n \"14\"\n\n#elif CXX_STD >= 201103L\n\n \"11\"\n\n#else\n\n \"98\"\n\n#endif\n\n\"]\";\n\n\n\n/*--------------------------------------------------------------------------*/\n\n\n\nint main(int argc, char* argv[])\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 47, "score": 12.010291128707768 }, { "content": " enum LINE_STATUS {LINE_OK=0,LINE_BAD,LINE_OPEN};\n\npublic:\n\n http_conn(){};\n\n ~http_conn(){};\n\npublic:\n\n void init(int sockfd, const sockaddr_in& addr);\n\n void close_conn(bool real_close=true);\n\n void process();\n\n bool read();\n\n bool write();\n\nprivate:\n\n void init();\n\n HTTP_CODE process_read();\n\n bool process_write(HTTP_CODE ret);\n\n\n\n HTTP_CODE parse_request_line(char * text);\n\n HTTP_CODE parse_headers(char *text);\n\n HTTP_CODE parse_content(char *text);\n\n HTTP_CODE do_request();\n\n char* get_line() {return m_read_buf+m_start_line;}\n", "file_path": "thread_lib/http_conn.h", "rank": 48, "score": 11.904465067601226 }, { "content": "\n\n int m_start_line;\n\n\n\n char m_write_buf[WRITE_BUFFER_SIZE];\n\n int m_write_idx;\n\n\n\n CHECK_STATE m_check_state;\n\n METHOD m_method;\n\n\n\n char m_real_file[FILENAME_LEN];\n\n char* m_url;\n\n char* m_version;\n\n char* m_host;\n\n int m_content_length;\n\n\n\n bool m_linger;\n\n\n\n char* m_file_address;\n\n struct stat m_file_stat;\n\n struct iovec m_iv[2];\n\n int m_iv_count;\n\n};\n\n\n\n\n\n#endif", "file_path": "thread_lib/http_conn.h", "rank": 49, "score": 11.630695792453253 }, { "content": "{\n\n int require = 0;\n\n require += info_compiler[argc];\n\n require += info_platform[argc];\n\n#ifdef COMPILER_VERSION_MAJOR\n\n require += info_version[argc];\n\n#endif\n\n#ifdef COMPILER_VERSION_INTERNAL\n\n require += info_version_internal[argc];\n\n#endif\n\n#ifdef SIMULATE_ID\n\n require += info_simulate[argc];\n\n#endif\n\n#ifdef SIMULATE_VERSION_MAJOR\n\n require += info_simulate_version[argc];\n\n#endif\n\n#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)\n\n require += info_cray[argc];\n\n#endif\n\n require += info_language_dialect_default[argc];\n\n (void)argv;\n\n return require;\n\n}\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 50, "score": 11.500882902827716 }, { "content": "{\n\n int require = 0;\n\n require += info_compiler[argc];\n\n require += info_platform[argc];\n\n#ifdef COMPILER_VERSION_MAJOR\n\n require += info_version[argc];\n\n#endif\n\n#ifdef COMPILER_VERSION_INTERNAL\n\n require += info_version_internal[argc];\n\n#endif\n\n#ifdef SIMULATE_ID\n\n require += info_simulate[argc];\n\n#endif\n\n#ifdef SIMULATE_VERSION_MAJOR\n\n require += info_simulate_version[argc];\n\n#endif\n\n#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)\n\n require += info_cray[argc];\n\n#endif\n\n require += info_language_dialect_default[argc];\n\n (void)argv;\n\n return require;\n\n}\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 51, "score": 11.500882902827716 }, { "content": "template<typename T>\n\nthreadpool<T>::threadpool(int thread_number, int max_requests)\n\n :m_thread_number(thread_number), m_max_requests(max_requests), m_stop(false), m_threads(NULL){\n\n if((thread_number<=0)||(max_requests<=0)){\n\n throw std::exception();\n\n }\n\n\n\n m_threads = new pthread_t[m_thread_number];\n\n if(!m_threads){\n\n throw std::exception();\n\n }\n\n for(int i=0;i<thread_number;i++){\n\n printf(\"init %d thread\\n\",i);\n\n if(pthread_create(m_threads+i,NULL, worker, this)!=0){\n\n delete []m_threads;\n\n throw std::exception();\n\n }\n\n if(pthread_detach(m_threads[i])){\n\n delete [] m_threads;\n\n throw std::exception();\n", "file_path": "thread_lib/threadpool.h", "rank": 52, "score": 10.901632069021867 }, { "content": " return false;\n\n }\n\n bytes_to_send -=temp;\n\n bytes_have_send+=temp;\n\n if (bytes_to_send<=bytes_have_send){\n\n unmap();\n\n if(m_linger){\n\n init();\n\n modfd(m_epollfd, m_sockfd, EPOLLIN);\n\n return true;\n\n }else{\n\n modfd(m_epollfd, m_sockfd, EPOLLIN);\n\n return false;\n\n }\n\n }\n\n }\n\n}\n\n\n\nbool http_conn::add_response(const char *format, ...) {\n\n if(m_write_idx>=WRITE_BUFFER_SIZE){\n", "file_path": "thread_lib/http_conn.cpp", "rank": 53, "score": 10.830737587085236 }, { "content": " ret = listen(listenfd, 5);\n\n assert(ret!=-1);\n\n processpool<cgi_conn>*pool = processpool<cgi_conn>::create(listenfd);\n\n\n\n if(pool){\n\n pool->run();\n\n delete pool;\n\n }\n\n close(listenfd);\n\n\n\n return 0;\n\n}\n", "file_path": "process_lib/main.cpp", "rank": 54, "score": 10.648665031183823 }, { "content": " }\n\n}\n\n\n\nbool http_conn::write() {\n\n int temp = 0;\n\n int bytes_have_send = 0;\n\n int bytes_to_send = m_write_idx;\n\n if(bytes_to_send==0){\n\n modfd(m_epollfd, m_sockfd, EPOLLIN);\n\n init();\n\n return true;\n\n }\n\n while(1){\n\n temp = writev(m_sockfd, m_iv, m_iv_count);\n\n if(temp<=-1){\n\n if(errno==EAGAIN){\n\n modfd(m_epollfd, m_sockfd, EPOLLOUT);\n\n return true;\n\n }\n\n unmap();\n", "file_path": "thread_lib/http_conn.cpp", "rank": 55, "score": 10.564360607178436 }, { "content": " strncpy(m_real_file+len, m_url, FILENAME_LEN-len-1);\n\n if(stat(m_real_file, &m_file_stat)<0){\n\n return NO_RESOURCE;\n\n }\n\n if(!(m_file_stat.st_mode&S_IROTH)){\n\n return FORBIDDEN_REQUEST;\n\n }\n\n if (S_ISDIR(m_file_stat.st_mode)){\n\n return BAD_REQUEST;\n\n }\n\n int fd = open(m_real_file, O_RDONLY);\n\n m_file_address = (char *) mmap(0, m_file_stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);\n\n close(fd);\n\n return FILE_REQUEST;\n\n}\n\n\n\nvoid http_conn::unmap() {\n\n if(m_file_address){\n\n munmap(m_file_address, m_file_stat.st_size);\n\n m_file_address = 0;\n", "file_path": "thread_lib/http_conn.cpp", "rank": 56, "score": 9.056867038376295 }, { "content": " add_linger();\n\n add_blank_line();\n\n}\n\n\n\nbool http_conn::add_content_length(int content_length) {\n\n return add_response(\"Content-Length: %d\\r\\n\", content_length);\n\n}\n\n\n\nbool http_conn::add_linger() {\n\n return add_response(\"Connection: %s\\r\\n\", (m_linger==true)?\"keep-alive\":\"close\");\n\n}\n\n\n\nbool http_conn::add_blank_line() {\n\n return add_response(\"%s\", \"\\r\\n\");\n\n}\n\n\n\nbool http_conn::add_content(const char *content) {\n\n return add_response(\"%s\", content);\n\n}\n\n\n", "file_path": "thread_lib/http_conn.cpp", "rank": 57, "score": 8.937879819133297 }, { "content": " while ((pid = waitpid(-1, &stat, WNOHANG)) > 0) {\n\n for (int i = 0; i < m_process_number; i++) {\n\n if (m_sub_process[i].m_pid == pid) {\n\n printf(\"child %d join\\n\", i);\n\n close(m_sub_process[i].m_pipefd[0]);\n\n m_sub_process[i].m_pid = -1;\n\n }\n\n }\n\n }\n\n m_stop = true;\n\n for (int i = 0; i < m_process_number; i++) {\n\n if (m_sub_process[i].m_pid != -1) {\n\n m_stop = false;\n\n }\n\n }\n\n break;\n\n }\n\n case SIGTERM:\n\n case SIGINT:\n\n {\n", "file_path": "process_lib/processpool.h", "rank": 58, "score": 8.934625909785717 }, { "content": " '.', COMPILER_VERSION_PATCH,\n\n# ifdef COMPILER_VERSION_TWEAK\n\n '.', COMPILER_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n\n ']','\\0'};\n\n#endif\n\n\n\n/* Construct a string literal encoding the internal version number. */\n\n#ifdef COMPILER_VERSION_INTERNAL\n\nchar const info_version_internal[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',\n\n 'i','n','t','e','r','n','a','l','[',\n\n COMPILER_VERSION_INTERNAL,']','\\0'};\n\n#endif\n\n\n\n/* Construct a string literal encoding the version number components. */\n\n#ifdef SIMULATE_VERSION_MAJOR\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 60, "score": 8.366159004684267 }, { "content": " '.', COMPILER_VERSION_PATCH,\n\n# ifdef COMPILER_VERSION_TWEAK\n\n '.', COMPILER_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n\n ']','\\0'};\n\n#endif\n\n\n\n/* Construct a string literal encoding the internal version number. */\n\n#ifdef COMPILER_VERSION_INTERNAL\n\nchar const info_version_internal[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',\n\n 'i','n','t','e','r','n','a','l','[',\n\n COMPILER_VERSION_INTERNAL,']','\\0'};\n\n#endif\n\n\n\n/* Construct a string literal encoding the version number components. */\n\n#ifdef SIMULATE_VERSION_MAJOR\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 61, "score": 8.366159004684267 }, { "content": " ret = parse_content(text);\n\n if (ret==GET_REQUEST){\n\n return do_request();\n\n }\n\n line_status = LINE_OPEN;\n\n break;\n\n }\n\n default:\n\n {\n\n return INTERNAL_ERROR;\n\n }\n\n }\n\n }\n\n return NO_REQUEST;\n\n}\n\n\n\nhttp_conn::HTTP_CODE http_conn::do_request() {\n\n char * doc_root;\n\n strcpy(m_real_file, doc_root);\n\n int len = strlen(doc_root);\n", "file_path": "thread_lib/http_conn.cpp", "rank": 62, "score": 8.285168408486566 }, { "content": " return true;\n\n}\n\n\n\ntemplate<typename T>\n\nvoid* threadpool<T>::worker(void *arg) {\n\n threadpool* pool = (threadpool*)arg;\n\n pool->run();\n\n return pool;\n\n}\n\n\n\ntemplate<typename T>\n\nvoid threadpool<T>::run() {\n\n while(!m_stop){\n\n m_queuestat.wait();\n\n m_queuelocker.lock();\n\n if(m_workqueue.empty()){\n\n m_queuelocker.unlock();\n\n continue;\n\n }\n\n T* request = m_workqueue.front();\n", "file_path": "thread_lib/threadpool.h", "rank": 63, "score": 8.060613754072188 }, { "content": " {\n\n ret = parse_request_line(text);\n\n if (ret == BAD_REQUEST){\n\n return BAD_REQUEST;\n\n }\n\n break;\n\n }\n\n case CHECK_STATE_HEADER:\n\n {\n\n ret = parse_headers(text);\n\n if (ret==BAD_REQUEST){\n\n return BAD_REQUEST;\n\n }\n\n else if (ret==GET_REQUEST){\n\n return do_request();\n\n }\n\n break;\n\n }\n\n case CHECK_STATE_COTENT:\n\n {\n", "file_path": "thread_lib/http_conn.cpp", "rank": 64, "score": 6.474434955827911 }, { "content": "char const* info_compiler = \"INFO\" \":\" \"compiler[\" COMPILER_ID \"]\";\n\n#ifdef SIMULATE_ID\n\nchar const* info_simulate = \"INFO\" \":\" \"simulate[\" SIMULATE_ID \"]\";\n\n#endif\n\n\n\n#ifdef __QNXNTO__\n\nchar const* qnxnto = \"INFO\" \":\" \"qnxnto[]\";\n\n#endif\n\n\n\n#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)\n\nchar const *info_cray = \"INFO\" \":\" \"compiler_wrapper[CrayPrgEnv]\";\n\n#endif\n\n\n\n#define STRINGIFY_HELPER(X) #X\n\n#define STRINGIFY(X) STRINGIFY_HELPER(X)\n\n\n\n/* Identify known platforms by name. */\n\n#if defined(__linux) || defined(__linux__) || defined(linux)\n\n# define PLATFORM_ID \"Linux\"\n\n\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 65, "score": 6.410489072964972 }, { "content": "char const* info_compiler = \"INFO\" \":\" \"compiler[\" COMPILER_ID \"]\";\n\n#ifdef SIMULATE_ID\n\nchar const* info_simulate = \"INFO\" \":\" \"simulate[\" SIMULATE_ID \"]\";\n\n#endif\n\n\n\n#ifdef __QNXNTO__\n\nchar const* qnxnto = \"INFO\" \":\" \"qnxnto[]\";\n\n#endif\n\n\n\n#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)\n\nchar const *info_cray = \"INFO\" \":\" \"compiler_wrapper[CrayPrgEnv]\";\n\n#endif\n\n\n\n#define STRINGIFY_HELPER(X) #X\n\n#define STRINGIFY(X) STRINGIFY_HELPER(X)\n\n\n\n/* Identify known platforms by name. */\n\n#if defined(__linux) || defined(__linux__) || defined(linux)\n\n# define PLATFORM_ID \"Linux\"\n\n\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 66, "score": 6.410489072964972 }, { "content": "/* Convert integer to hex digit literals. */\n\n#define HEX(n) \\\n\n ('0' + ((n)>>28 & 0xF)), \\\n\n ('0' + ((n)>>24 & 0xF)), \\\n\n ('0' + ((n)>>20 & 0xF)), \\\n\n ('0' + ((n)>>16 & 0xF)), \\\n\n ('0' + ((n)>>12 & 0xF)), \\\n\n ('0' + ((n)>>8 & 0xF)), \\\n\n ('0' + ((n)>>4 & 0xF)), \\\n\n ('0' + ((n) & 0xF))\n\n\n\n/* Construct a string literal encoding the version number components. */\n\n#ifdef COMPILER_VERSION_MAJOR\n\nchar const info_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',\n\n COMPILER_VERSION_MAJOR,\n\n# ifdef COMPILER_VERSION_MINOR\n\n '.', COMPILER_VERSION_MINOR,\n\n# ifdef COMPILER_VERSION_PATCH\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 67, "score": 6.405042219481173 }, { "content": "/* Convert integer to hex digit literals. */\n\n#define HEX(n) \\\n\n ('0' + ((n)>>28 & 0xF)), \\\n\n ('0' + ((n)>>24 & 0xF)), \\\n\n ('0' + ((n)>>20 & 0xF)), \\\n\n ('0' + ((n)>>16 & 0xF)), \\\n\n ('0' + ((n)>>12 & 0xF)), \\\n\n ('0' + ((n)>>8 & 0xF)), \\\n\n ('0' + ((n)>>4 & 0xF)), \\\n\n ('0' + ((n) & 0xF))\n\n\n\n/* Construct a string literal encoding the version number components. */\n\n#ifdef COMPILER_VERSION_MAJOR\n\nchar const info_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',\n\n COMPILER_VERSION_MAJOR,\n\n# ifdef COMPILER_VERSION_MINOR\n\n '.', COMPILER_VERSION_MINOR,\n\n# ifdef COMPILER_VERSION_PATCH\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 68, "score": 6.405042219481173 }, { "content": "#include <sys/types.h>\n\n#include <sys/socket.h>\n\n#include <netinet/in.h>\n\n#include <arpa/inet.h>\n\n#include <assert.h>\n\n#include <stdio.h>\n\n#include <unistd.h>\n\n#include <errno.h>\n\n#include <string.h>\n\n#include <fcntl.h>\n\n#include <stdlib.h>\n\n#include <sys/epoll.h>\n\n#include <signal.h>\n\n#include <sys/wait.h>\n\n#include <sys/stat.h>\n\n#include \"processpool.h\"\n\n\n", "file_path": "process_lib/main.cpp", "rank": 69, "score": 6.271042220852618 }, { "content": "bool http_conn::process_write(HTTP_CODE ret) {\n\n switch (ret) {\n\n case INTERNAL_ERROR:\n\n {\n\n add_status_line(500, error_500_title);\n\n add_headers(strlen(error_500_form));\n\n if(!add_content(error_500_form)){\n\n return false;\n\n }\n\n break;\n\n }\n\n case BAD_REQUEST:{\n\n add_status_line(400, error_400_title);\n\n add_headers(strlen(error_400_form));\n\n if(!add_content(error_400_form)){\n\n return false;\n\n }\n\n break;\n\n }\n\n case NO_RESOURCE:{\n", "file_path": "thread_lib/http_conn.cpp", "rank": 70, "score": 6.219794707921206 }, { "content": " int bytes_read = 0;\n\n while(true){\n\n bytes_read = recv(m_sockfd, m_read_buf+m_read_idx, READ_BUFFER_SIZE-m_read_idx,0);\n\n if (bytes_read==-1){\n\n if(errno==EAGAIN||errno==EWOULDBLOCK){\n\n break;\n\n }\n\n return false;\n\n }\n\n else if(bytes_read==0){\n\n return false;\n\n }\n\n m_read_idx+=bytes_read;\n\n }\n\n return true;\n\n}\n\n\n\nhttp_conn::HTTP_CODE http_conn::parse_request_line(char *text) {\n\n m_url = strpbrk(text, \"\\t\");\n\n if(!m_url){\n", "file_path": "thread_lib/http_conn.cpp", "rank": 71, "score": 6.205555144218117 }, { "content": "//\n\n// Created by root on 8/30/21.\n\n//\n\n\n\n#ifndef PROCESS_LIB_PROCESSPOOL_H\n\n#define PROCESS_LIB_PROCESSPOOL_H\n\n\n\n#include <sys/types.h>\n\n#include <sys/socket.h>\n\n#include <netinet/in.h>\n\n#include <arpa/inet.h>\n\n#include <assert.h>\n\n#include <stdio.h>\n\n#include <unistd.h>\n\n#include <errno.h>\n\n#include <string.h>\n\n#include <fcntl.h>\n\n#include <stdlib.h>\n\n#include <sys/epoll.h>\n\n#include <signal.h>\n\n#include <sys/wait.h>\n\n#include <sys/stat.h>\n\n\n", "file_path": "process_lib/processpool.h", "rank": 72, "score": 5.925514488000907 }, { "content": "//\n\n// Created by root on 8/30/21.\n\n//\n\n\n\n#ifndef HTTP_CONN_H\n\n#define HTTP_CONN_H\n\n\n\n#include <unistd.h>\n\n#include <signal.h>\n\n#include <sys/types.h>\n\n#include <sys/epoll.h>\n\n#include <fcntl.h>\n\n#include <sys/socket.h>\n\n#include <netinet/in.h>\n\n#include <arpa/inet.h>\n\n#include <assert.h>\n\n#include <sys/stat.h>\n\n#include <string>\n\n#include <pthread.h>\n\n#include <stdio.h>\n\n#include <stdlib.h>\n\n#include <sys/mman.h>\n\n#include <stdarg.h>\n\n#include <errno.h>\n\n#include \"locker.h\"\n\n\n\n\n\n\n", "file_path": "thread_lib/http_conn.h", "rank": 73, "score": 5.907201793291909 }, { "content": " m_iv[0].iov_len = m_write_idx;\n\n m_iv[1].iov_base = m_file_address;\n\n m_iv[1].iov_len = m_file_stat.st_size;\n\n m_iv_count = 2;\n\n return true;\n\n }else{\n\n const char* ok_string=\"<html><body></body></html>\";\n\n add_headers(strlen(ok_string));\n\n if(!add_content(ok_string)){\n\n return false;\n\n }\n\n }\n\n }\n\n default:{\n\n return false;\n\n }\n\n }\n\n m_iv[0].iov_base = m_write_buf;\n\n m_iv[0].iov_len = m_write_idx;\n\n m_iv_count = 1;\n", "file_path": "thread_lib/http_conn.cpp", "rank": 74, "score": 5.815473382241451 }, { "content": " return false;\n\n }\n\n va_list arg_list;\n\n va_start(arg_list, format);\n\n int len = vsnprintf(m_write_buf+m_write_idx,WRITE_BUFFER_SIZE-1-m_write_idx,\n\n format, arg_list);\n\n if (len>=(WRITE_BUFFER_SIZE-1-m_write_idx)){\n\n return false;\n\n }\n\n m_write_idx +=len;\n\n va_end(arg_list);\n\n return true;\n\n}\n\n\n\nbool http_conn::add_status_line(int status, const char *title) {\n\n return add_response(\"%s %d %s\\r\\n\", \"HTTP/1.1\", status, title);\n\n}\n\n\n\nbool http_conn::add_headers(int content_length) {\n\n add_content_length(content_length);\n", "file_path": "thread_lib/http_conn.cpp", "rank": 75, "score": 5.660269025415271 }, { "content": " return NO_REQUEST;\n\n}\n\n\n\nhttp_conn::HTTP_CODE http_conn::parse_content(char *text) {\n\n if(m_read_idx>=(m_user_count+m_checked_idx)){\n\n text[m_content_length]='\\0';\n\n return GET_REQUEST;\n\n }\n\n return NO_REQUEST;\n\n}\n\nhttp_conn::HTTP_CODE http_conn::process_read() {\n\n LINE_STATUS line_status = LINE_OK;\n\n HTTP_CODE ret = NO_REQUEST;\n\n char *text = 0;\n\n while(((m_check_state==CHECK_STATE_COTENT)&&(line_status == LINE_OK))||(line_status=parse_line())==LINE_OK){\n\n text = get_line();\n\n m_start_line = m_checked_idx;\n\n printf(\"get 1 http line %s\\n\", text);\n\n switch (m_check_state) {\n\n case CHECK_STATE_REQUESTLINE:\n", "file_path": "thread_lib/http_conn.cpp", "rank": 76, "score": 5.351086534146164 }, { "content": "char const* info_platform = \"INFO\" \":\" \"platform[\" PLATFORM_ID \"]\";\n\nchar const* info_arch = \"INFO\" \":\" \"arch[\" ARCHITECTURE_ID \"]\";\n\n\n\n\n\n\n\n#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L\n\n# if defined(__INTEL_CXX11_MODE__)\n\n# if defined(__cpp_aggregate_nsdmi)\n\n# define CXX_STD 201402L\n\n# else\n\n# define CXX_STD 201103L\n\n# endif\n\n# else\n\n# define CXX_STD 199711L\n\n# endif\n\n#elif defined(_MSC_VER) && defined(_MSVC_LANG)\n\n# define CXX_STD _MSVC_LANG\n\n#else\n\n# define CXX_STD __cplusplus\n\n#endif\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 77, "score": 5.1051975943629655 }, { "content": "char const* info_platform = \"INFO\" \":\" \"platform[\" PLATFORM_ID \"]\";\n\nchar const* info_arch = \"INFO\" \":\" \"arch[\" ARCHITECTURE_ID \"]\";\n\n\n\n\n\n\n\n#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L\n\n# if defined(__INTEL_CXX11_MODE__)\n\n# if defined(__cpp_aggregate_nsdmi)\n\n# define CXX_STD 201402L\n\n# else\n\n# define CXX_STD 201103L\n\n# endif\n\n# else\n\n# define CXX_STD 199711L\n\n# endif\n\n#elif defined(_MSC_VER) && defined(_MSVC_LANG)\n\n# define CXX_STD _MSVC_LANG\n\n#else\n\n# define CXX_STD __cplusplus\n\n#endif\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 78, "score": 5.1051975943629655 }, { "content": " pthread_mutex_unlock(&m_mutex);\n\n return ret == 0;\n\n }\n\n bool signal(){\n\n return pthread_cond_signal(&m_cond)==0;\n\n }\n\nprivate:\n\n pthread_mutex_t m_mutex;\n\n pthread_cond_t m_cond;\n\n};\n\n\n\n#endif\n", "file_path": "thread_lib/locker.h", "rank": 79, "score": 5.027439150427534 }, { "content": "char const info_simulate_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',\n\n SIMULATE_VERSION_MAJOR,\n\n# ifdef SIMULATE_VERSION_MINOR\n\n '.', SIMULATE_VERSION_MINOR,\n\n# ifdef SIMULATE_VERSION_PATCH\n\n '.', SIMULATE_VERSION_PATCH,\n\n# ifdef SIMULATE_VERSION_TWEAK\n\n '.', SIMULATE_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n\n ']','\\0'};\n\n#endif\n\n\n\n/* Construct the string literal in pieces to prevent the source from\n\n getting matched. Store it in a pointer rather than an array\n\n because some compilers will just produce instructions to fill the\n\n array rather than assigning a pointer to a static array. */\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 80, "score": 4.32377112098032 }, { "content": "char const info_simulate_version[] = {\n\n 'I', 'N', 'F', 'O', ':',\n\n 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',\n\n SIMULATE_VERSION_MAJOR,\n\n# ifdef SIMULATE_VERSION_MINOR\n\n '.', SIMULATE_VERSION_MINOR,\n\n# ifdef SIMULATE_VERSION_PATCH\n\n '.', SIMULATE_VERSION_PATCH,\n\n# ifdef SIMULATE_VERSION_TWEAK\n\n '.', SIMULATE_VERSION_TWEAK,\n\n# endif\n\n# endif\n\n# endif\n\n ']','\\0'};\n\n#endif\n\n\n\n/* Construct the string literal in pieces to prevent the source from\n\n getting matched. Store it in a pointer rather than an array\n\n because some compilers will just produce instructions to fill the\n\n array rather than assigning a pointer to a static array. */\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 81, "score": 4.32377112098032 }, { "content": "#include <exception>\n\n#include <pthread.h>\n\n#include <semaphore.h>\n\nclass sem\n\n{\n\npublic:\n\n sem(){\n\n if(sem_init(&m_sem, 0,0)!=0)\n\n {\n\n throw std::exception();\n\n }\n\n }\n\n ~sem(){\n\n sem_destroy(&m_sem);\n\n }\n\n bool wait()\n\n {\n\n return sem_wait(&m_sem)==0;\n\n }\n\n bool post()\n\n {\n\n return sem_post(&m_sem)==0;\n\n }\n\n\n\nprivate:\n\n sem_t m_sem;\n\n};\n\n\n", "file_path": "thread_lib/locker.h", "rank": 82, "score": 4.190584293503583 }, { "content": "//\n\n// Created by root on 8/30/21.\n\n//\n\n\n\n#ifndef THREADPOOL_H\n\n#define THREADPOOL_H\n\n\n\n\n\n#include <list>\n\n#include <cstdio>\n\n#include <exception>\n\n#include <pthread.h>\n\n#include \"locker.h\"\n\n\n\ntemplate<typename T>\n", "file_path": "thread_lib/threadpool.h", "rank": 83, "score": 4.047317291391187 }, { "content": "//\n\n// Created by root on 8/30/21.\n\n//\n\n#ifndef LOCKER_H\n\n#define LOCKER_H\n\n\n\n\n\n#include <exception>\n\n#include <pthread.h>\n\n#include <semaphore.h>\n", "file_path": "thread_lib/locker.h", "rank": 84, "score": 3.8651383363200864 }, { "content": " else if(strncasecmp(text, \"Connection:\", 11)==0){\n\n text+=11;\n\n text+=strspn(text, \"\\t\");\n\n if(strcasecmp(text, \"keep-alive\")==0){\n\n m_linger = true;\n\n }\n\n }\n\n else if (strncasecmp(text,\"Content-Length:\", 15)==0){\n\n text += 15;\n\n text += strspn(text,\"\\t\");\n\n m_content_length = atol(text);\n\n }\n\n else if (strncasecmp(text, \"Host:\", 5)==0){\n\n text+=5;\n\n text+= strspn(text,\"\\t\");\n\n m_host = text;\n\n }\n\n else{\n\n printf(\"oop! unknow header %s\\n\", text);\n\n }\n", "file_path": "thread_lib/http_conn.cpp", "rank": 85, "score": 3.5864480434907473 }, { "content": " }\n\n close(m_epollfd);\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "file_path": "process_lib/processpool.h", "rank": 86, "score": 3.507964002229432 }, { "content": " m_workqueue.pop_front();\n\n m_queuelocker.unlock();\n\n if(!request){\n\n continue;\n\n }\n\n request->process();\n\n }\n\n}\n\n\n\n\n\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "file_path": "thread_lib/threadpool.h", "rank": 87, "score": 3.0028172668435404 }, { "content": "# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)\n\n# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)\n\n# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)\n\n\n\n#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)\n\n# define COMPILER_ID \"Fujitsu\"\n\n\n\n#elif defined(__ghs__)\n\n# define COMPILER_ID \"GHS\"\n\n/* __GHS_VERSION_NUMBER = VVVVRP */\n\n# ifdef __GHS_VERSION_NUMBER\n\n# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)\n\n# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)\n\n# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)\n\n# endif\n\n\n\n#elif defined(__SCO_VERSION__)\n\n# define COMPILER_ID \"SCO\"\n\n\n\n#elif defined(__ARMCC_VERSION) && !defined(__clang__)\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 88, "score": 2.7860099617527614 }, { "content": "# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)\n\n# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)\n\n# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)\n\n\n\n#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)\n\n# define COMPILER_ID \"Fujitsu\"\n\n\n\n#elif defined(__ghs__)\n\n# define COMPILER_ID \"GHS\"\n\n/* __GHS_VERSION_NUMBER = VVVVRP */\n\n# ifdef __GHS_VERSION_NUMBER\n\n# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)\n\n# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)\n\n# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)\n\n# endif\n\n\n\n#elif defined(__SCO_VERSION__)\n\n# define COMPILER_ID \"SCO\"\n\n\n\n#elif defined(__ARMCC_VERSION) && !defined(__clang__)\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 89, "score": 2.7860099617527614 }, { "content": "# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))\n\n# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)\n\n# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)\n\n# endif\n\n\n\n\n\n/* These compilers are either not known or too old to define an\n\n identification macro. Try to identify the platform and guess that\n\n it is the native compiler. */\n\n#elif defined(__hpux) || defined(__hpua)\n\n# define COMPILER_ID \"HP\"\n\n\n\n#else /* unknown compiler */\n\n# define COMPILER_ID \"\"\n\n#endif\n\n\n\n/* Construct the string literal in pieces to prevent the source from\n\n getting matched. Store it in a pointer rather than an array\n\n because some compilers will just produce instructions to fill the\n\n array rather than assigning a pointer to a static array. */\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 90, "score": 2.474843830894569 }, { "content": "# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))\n\n# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)\n\n# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)\n\n# endif\n\n\n\n\n\n/* These compilers are either not known or too old to define an\n\n identification macro. Try to identify the platform and guess that\n\n it is the native compiler. */\n\n#elif defined(__hpux) || defined(__hpua)\n\n# define COMPILER_ID \"HP\"\n\n\n\n#else /* unknown compiler */\n\n# define COMPILER_ID \"\"\n\n#endif\n\n\n\n/* Construct the string literal in pieces to prevent the source from\n\n getting matched. Store it in a pointer rather than an array\n\n because some compilers will just produce instructions to fill the\n\n array rather than assigning a pointer to a static array. */\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 91, "score": 2.474843830894569 }, { "content": " add_status_line(404, error_404_title);\n\n add_headers(strlen(error_404_form));\n\n if(!add_content(error_404_form)){\n\n return false;\n\n }\n\n break;\n\n }\n\n case FORBIDDEN_REQUEST:{\n\n add_status_line(403, error_403_title);\n\n add_headers(strlen(error_403_form));\n\n if(!add_content(error_403_form)){\n\n return false;\n\n }\n\n break;\n\n }\n\n case FILE_REQUEST:{\n\n add_status_line(200, ok_200_title);\n\n if (m_file_stat.st_size!=0){\n\n add_headers(m_file_stat.st_size);\n\n m_iv[0].iov_base = m_write_buf;\n", "file_path": "thread_lib/http_conn.cpp", "rank": 92, "score": 2.1910706993356204 }, { "content": " }\n\n return LINE_BAD;\n\n }\n\n else if(temp=='\\n')\n\n {\n\n if((m_checked_idx>1)&&(m_read_buf[m_checked_idx-1]=='\\r')){\n\n m_read_buf[m_checked_idx-1]='\\0';\n\n m_read_buf[m_checked_idx++]='\\0';\n\n return LINE_OK;\n\n }\n\n return LINE_BAD;\n\n }\n\n }\n\n return LINE_OPEN;\n\n}\n\n\n\nbool http_conn::read() {\n\n if(m_read_idx>=READ_BUFFER_SIZE){\n\n return false;\n\n }\n", "file_path": "thread_lib/http_conn.cpp", "rank": 93, "score": 1.929022424183299 }, { "content": " return BAD_REQUEST;\n\n }\n\n *m_url++='\\0';\n\n char* method = text;\n\n if(strcasecmp(method, \"GET\")==0){\n\n m_method = GET;\n\n }else{\n\n return BAD_REQUEST;\n\n }\n\n\n\n m_url += strspn(m_url, \"\\t\");\n\n m_version = strpbrk(m_url, \"\\t\");\n\n if(!m_version){\n\n return BAD_REQUEST;\n\n }\n\n *m_version++='\\0';\n\n m_version += strspn(m_version, \"\\t\");\n\n if(strcasecmp(m_version, \"HTTP/1.1\")!=0){\n\n return BAD_REQUEST;\n\n }\n", "file_path": "thread_lib/http_conn.cpp", "rank": 94, "score": 1.9228664297525944 }, { "content": " }\n\n }\n\n}\n\n\n\ntemplate<typename T>\n\nthreadpool<T>::~threadpool(){\n\n delete []m_threads;\n\n m_stop=true;\n\n}\n\n\n\ntemplate<typename T>\n\nbool threadpool<T> ::append(T *requests) {\n\n m_queuelocker.lock();\n\n if(m_workqueue.size()>m_max_requests){\n\n m_queuelocker.unlock();\n\n return false;\n\n }\n\n m_workqueue.push_back(requests);\n\n m_queuelocker.unlock();\n\n m_queuestat.post();\n", "file_path": "thread_lib/threadpool.h", "rank": 95, "score": 1.847589139832667 }, { "content": " if(strncasecmp(m_url, \"http://\", 7) == 0){\n\n m_url +=7;\n\n m_url= strchr(m_url, '/');\n\n }\n\n if(!m_url||m_url[0]!='/'){\n\n return BAD_REQUEST;\n\n }\n\n m_check_state = CHECK_STATE_HEADER;\n\n return NO_REQUEST;\n\n}\n\n\n\n\n\nhttp_conn::HTTP_CODE http_conn::parse_headers(char *text) {\n\n if(text[0]=='\\0'){\n\n if(m_content_length!=0){\n\n m_check_state = CHECK_STATE_COTENT;\n\n return NO_REQUEST;\n\n }\n\n return GET_REQUEST;\n\n }\n", "file_path": "thread_lib/http_conn.cpp", "rank": 96, "score": 1.7386463475733605 }, { "content": "# define PLATFORM_ID \"Windows3x\"\n\n\n\n# elif defined(__VXWORKS__)\n\n# define PLATFORM_ID \"VxWorks\"\n\n\n\n# else /* unknown platform */\n\n# define PLATFORM_ID\n\n# endif\n\n\n\n#elif defined(__INTEGRITY)\n\n# if defined(INT_178B)\n\n# define PLATFORM_ID \"Integrity178\"\n\n\n\n# else /* regular Integrity */\n\n# define PLATFORM_ID \"Integrity\"\n\n# endif\n\n\n\n#else /* unknown platform */\n\n# define PLATFORM_ID\n\n\n", "file_path": "thread_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 97, "score": 1.7250942729818766 }, { "content": "# define PLATFORM_ID \"Windows3x\"\n\n\n\n# elif defined(__VXWORKS__)\n\n# define PLATFORM_ID \"VxWorks\"\n\n\n\n# else /* unknown platform */\n\n# define PLATFORM_ID\n\n# endif\n\n\n\n#elif defined(__INTEGRITY)\n\n# if defined(INT_178B)\n\n# define PLATFORM_ID \"Integrity178\"\n\n\n\n# else /* regular Integrity */\n\n# define PLATFORM_ID \"Integrity\"\n\n# endif\n\n\n\n#else /* unknown platform */\n\n# define PLATFORM_ID\n\n\n", "file_path": "process_lib/cmake-build-debug/CMakeFiles/3.20.2/CompilerIdCXX/CMakeCXXCompilerId.cpp", "rank": 98, "score": 1.7250942729818766 }, { "content": " m_checked_idx = 0;\n\n m_read_idx = 0;\n\n m_write_idx = 0;\n\n memset(m_read_buf, '\\0', READ_BUFFER_SIZE);\n\n memset(m_write_buf, '\\0', WRITE_BUFFER_SIZE);\n\n memset(m_real_file, '\\0', FILENAME_LEN);\n\n}\n\n\n\nhttp_conn::LINE_STATUS http_conn::parse_line() {\n\n char temp;\n\n for(;m_checked_idx<m_read_idx;++m_checked_idx){\n\n temp = m_read_buf[m_checked_idx];\n\n if(temp=='\\r'){\n\n if((m_checked_idx+1)==m_read_idx){\n\n return LINE_OPEN;\n\n }\n\n else if(m_read_buf[m_checked_idx+1]=='\\n'){\n\n m_read_buf[m_checked_idx++]='\\0';\n\n m_read_buf[m_checked_idx++]='\\0';\n\n return LINE_OK;\n", "file_path": "thread_lib/http_conn.cpp", "rank": 99, "score": 1.2695173966467808 } ]
C++
cpp_analysis/bin/check_sizes.cpp
shahrukhqasim/HGCalML
2808564b31c89d9b7eb882734f6aebc6f35e94f3
#include "TString.h" #include "TFile.h" #include "TTree.h" #include <vector> #include <iostream> #include "TH1D.h" #include "TCanvas.h" void mergeOF(TH1D* h){ double lastb = h->GetBinContent(h->GetNbinsX()); h->SetBinContent(h->GetNbinsX(), lastb+h->GetBinContent(h->GetNbinsX()+1)); } int main(int argc, char* argv[]){ if(argc<2) return -1; TString infile = argv[1]; TFile f(infile, "READ"); TTree * tree = (TTree*) f.Get("Delphes"); if(!tree || tree->IsZombie()){ std::cerr << "tree has a problem" << std::endl; return -1; } std::vector<std::vector<float> > * rh_feat =0, * rh_truth = 0, *lc_feat = 0, * lc_truth=0; tree->SetBranchAddress("rechit_features",&rh_feat); tree->SetBranchAddress("rechit_simcluster_fractions",&rh_truth); tree->SetBranchAddress("layercluster_features",&lc_feat); tree->SetBranchAddress("layercluster_simcluster_fractions",&lc_truth); if(tree->GetEntries()<1){ std::cerr << "tree has 0 entries" <<std::endl; return -2; } tree->GetEntry(0); if(rh_feat->size()<1 || lc_feat->size()<1){ std::cerr << "first entry has zero rechits or layer cluster" <<std::endl; return -3; } std::cout << "rechit_features: " << rh_feat->at(0).size() << std::endl; std::cout << "layercluster_features: " << lc_feat->at(0).size() << std::endl; std::cout << "\ncomputing average/max rechits" << std::endl; TH1D nrechits("nrechits","nrechits",20,1000,10000); TH1D nlayerclusters("nlayerclusters","nlayerclusters",20,100,2000); TH1D rechit_energy("rechit_energy","rechit_energy",20,0,0.05); TH1D rechit_truthenergy("rechit_truthenergy","rechit_truthenergy",20,0,0.05); int max_nrechits=0, max_nlayerclusters=0, max_simclusters=0; float avg_nrechits=0, avg_nlayerclusters=0; const int nentries = tree->GetEntries(); for(int event=0;event<nentries;event++){ tree->GetEntry(event); const int nrh = rh_feat->size(); const int nlc = lc_feat->size(); int nsc = 0; if(rh_truth->size()>0) nsc=rh_truth->at(0).size(); if(max_nrechits<nrh) max_nrechits=nrh; if(max_nlayerclusters<nlc) max_nlayerclusters=nlc; if(max_simclusters<nsc) max_simclusters=nsc; avg_nrechits+=nrh; avg_nlayerclusters+=nlc; nrechits.Fill(nrh); nlayerclusters.Fill(nlc); for(size_t i=0;i<rh_feat->size();i++){ rechit_energy.Fill(rh_feat->at(i).at(0)); float truthsum = 0; for(size_t j=0;j<rh_truth->at(i).size();j++){ truthsum+=rh_truth->at(i).at(j); } if(truthsum>0) rechit_truthenergy.Fill(truthsum*rh_feat->at(i).at(0)); if(truthsum>0 && fabs(truthsum-1.)>0.0001) std::cout << "weird truthsum" << truthsum << std::endl; } } avg_nrechits/=(float)nentries; avg_nlayerclusters/=(float)nentries; std::cout << "max nrechits: " << max_nrechits << std::endl; std::cout << "max nlayerclusters: " << max_nlayerclusters << std::endl; std::cout << "max nsimclusters: " << max_simclusters << std::endl; std::cout << "average nrechits: " << avg_nrechits << std::endl; std::cout << "average nlayerclusters: " << avg_nlayerclusters << std::endl; mergeOF(&nrechits); mergeOF(&nlayerclusters); TCanvas cv; nrechits.Draw(); cv.Print("nrechits.pdf"); nlayerclusters.Draw(); cv.Print("nlayerclusters.pdf"); rechit_energy.Draw(); cv.Print("rechit_energy.pdf"); rechit_truthenergy.SetLineColor(kRed); rechit_truthenergy.Draw("same"); cv.Print("rechit_truthenergy.pdf"); return 0; }
#include "TString.h" #include "TFile.h" #include "TTree.h" #include <vector> #include <iostream> #include "TH1D.h" #include "TCanvas.h" void mergeOF(TH1D* h){ double lastb = h->GetBinContent(h->GetNbinsX()); h->SetBinContent(h->GetNbinsX(), lastb+h->GetBinContent(h->GetNbinsX()+1)); }
int main(int argc, char* argv[]){ if(argc<2) return -1; TString infile = argv[1]; TFile f(infile, "READ"); TTree * tree = (TTree*) f.Get("Delphes"); if(!tree || tree->IsZombie()){ std::cerr << "tree has a problem" << std::endl; return -1; } std::vector<std::vector<float> > * rh_feat =0, * rh_truth = 0, *lc_feat = 0, * lc_truth=0; tree->SetBranchAddress("rechit_features",&rh_feat); tree->SetBranchAddress("rechit_simcluster_fractions",&rh_truth); tree->SetBranchAddress("layercluster_features",&lc_feat); tree->SetBranchAddress("layercluster_simcluster_fractions",&lc_truth); if(tree->GetEntries()<1){ std::cerr << "tree has 0 entries" <<std::endl; return -2; } tree->GetEntry(0); if(rh_feat->size()<1 || lc_feat->size()<1){ std::cerr << "first entry has zero rechits or layer cluster" <<std::endl; return -3; } std::cout << "rechit_features: " << rh_feat->at(0).size() << std::endl; std::cout << "layercluster_features: " << lc_feat->at(0).size() << std::endl; std::cout << "\ncomputing average/max rechits" << std::endl; TH1D nrechits("nrechits","nrechits",20,1000,10000); TH1D nlayerclusters("nlayerclusters","nlayerclusters",20,100,2000); TH1D rechit_energy("rechit_energy","rechit_energy",20,0,0.05); TH1D rechit_truthenergy("rechit_truthenergy","rechit_truthenergy",20,0,0.05); int max_nrechits=0, max_nlayerclusters=0, max_simclusters=0; float avg_nrechits=0, avg_nlayerclusters=0; const int nentries = tree->GetEntries(); for(int event=0;event<nentries;event++){ tree->GetEntry(event); const int nrh = rh_feat->size(); const int nlc = lc_feat->size(); int nsc = 0; if(rh_truth->size()>0) nsc=rh_truth->at(0).size(); if(max_nrechits<nrh) max_nrechits=nrh; if(max_nlayerclusters<nlc) max_nlayerclusters=nlc; if(max_simclusters<nsc) max_simclusters=nsc; avg_nrechits+=nrh; avg_nlayerclusters+=nlc; nrechits.Fill(nrh); nlayerclusters.Fill(nlc); for(size_t i=0;i<rh_feat->size();i++){ rechit_energy.Fill(rh_feat->at(i).at(0)); float truthsum = 0; for(size_t j=0;j<rh_truth->at(i).size();j++){ truthsum+=rh_truth->at(i).at(j); } if(truthsum>0) rechit_truthenergy.Fill(truthsum*rh_feat->at(i).at(0)); if(truthsum>0 && fabs(truthsum-1.)>0.0001) std::cout << "weird truthsum" << truthsum << std::endl; } } avg_nrechits/=(float)nentries; avg_nlayerclusters/=(float)nentries; std::cout << "max nrechits: " << max_nrechits << std::endl; std::cout << "max nlayerclusters: " << max_nlayerclusters << std::endl; std::cout << "max nsimclusters: " << max_simclusters << std::endl; std::cout << "average nrechits: " << avg_nrechits << std::endl; std::cout << "average nlayerclusters: " << avg_nlayerclusters << std::endl; mergeOF(&nrechits); mergeOF(&nlayerclusters); TCanvas cv; nrechits.Draw(); cv.Print("nrechits.pdf"); nlayerclusters.Draw(); cv.Print("nlayerclusters.pdf"); rechit_energy.Draw(); cv.Print("rechit_energy.pdf"); rechit_truthenergy.SetLineColor(kRed); rechit_truthenergy.Draw("same"); cv.Print("rechit_truthenergy.pdf"); return 0; }
function_block-full_function
[ { "content": "//#define GOOGLE_CUDA 1\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#define HANDLE_ERROR( err ) ( tensorflow::functor::HandleError( err, __FILE__, __LINE__ ) )\n\n\n\n#include \"slicing_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n#include <iostream>\n\n#include <vector>\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\nstatic void HandleError( cudaError_t err, const char *file, int line )\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 0, "score": 13.5101207956714 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"slicing_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n#include <vector>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nusing namespace std;\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n", "file_path": "modules/compiled/slicing_knn_kernel.cc", "rank": 1, "score": 11.146362204108879 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"compare_knn_outputs_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream>\n\n#include <set>\n\n#include <algorithm>\n\n#include <iterator>\n\n\n\n// #include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n", "file_path": "modules/compiled/compare_knn_outputs_kernel.cc", "rank": 2, "score": 9.75966537171698 }, { "content": "/*\n\n * cuda_helpers.h\n\n *\n\n * Created on: 12 May 2020\n\n * Author: jkiesele\n\n */\n\n\n\n#ifndef HGCALML_MODULES_COMPILED_CUDA_HELPERS_H_\n\n#define HGCALML_MODULES_COMPILED_CUDA_HELPERS_H_\n\n\n\n\n\n\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n\n\ntemplate <class T>\n\n//from dlib!\n\n// http://dlib.net/dlib/dnn/cuda_utils.h.html\n\n// boost licence, check for other sources at some point or install lib.\n\n// right now, for testing here\n", "file_path": "modules/compiled/cuda_helpers.h", "rank": 3, "score": 8.613930082848468 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"neighbour_covariance_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\n__global__\n\nstatic void calcmeans( // <<< vout,nfeat,(ncoords)\n\n const float *d_coords,\n", "file_path": "modules/compiled/neighbour_covariance_kernel.cu.cc", "rank": 4, "score": 8.377126796698981 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"local_group_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\n///__global__\n\n///void local_cluster_kernel(/*TBI*/) {\n\n/////parallelise over neighbours and row splits\n", "file_path": "modules/compiled/local_group_kernel.cu.cc", "rank": 5, "score": 8.344138245750514 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"local_cluster_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\n///__global__\n\n///void local_cluster_kernel(/*TBI*/) {\n\n/////parallelise over neighbours and row splits\n", "file_path": "modules/compiled/local_cluster_kernel.cu.cc", "rank": 6, "score": 8.344138245750514 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"local_distance_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n", "file_path": "modules/compiled/local_distance_kernel.cc", "rank": 7, "score": 8.19754699881959 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"select_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n", "file_path": "modules/compiled/select_knn_kernel.cc", "rank": 8, "score": 8.19754699881959 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"build_condensates_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n", "file_path": "modules/compiled/build_condensates_kernel.cc", "rank": 9, "score": 8.19754699881959 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"select_threshold_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n", "file_path": "modules/compiled/select_threshold_kernel.cc", "rank": 10, "score": 8.19754699881959 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"latent_space_grid_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n", "file_path": "modules/compiled/latent_space_grid_kernel.cc", "rank": 11, "score": 8.164374273670091 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"select_mod_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n", "file_path": "modules/compiled/select_mod_knn_kernel.cc", "rank": 12, "score": 8.164374273670091 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"local_cluster_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/local_cluster_kernel.cc", "rank": 13, "score": 8.035282909314995 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"oc_helper_m_indices_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n//helpers here\n\n\n\n\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/oc_helper_m_indices_kernel.cc", "rank": 14, "score": 8.035282909314995 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"local_group_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/local_group_kernel.cc", "rank": 15, "score": 8.035282909314995 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"select_knn_grad_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/select_knn_grad_kernel.cc", "rank": 16, "score": 8.003875393268903 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"select_mod_knn_grad_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/select_mod_knn_grad_kernel.cc", "rank": 17, "score": 7.972800840942616 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"pseudo_row_split_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n//helpers here\n\n\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/misc_for_later/pseudo_row_split_kernel.cc", "rank": 18, "score": 7.972800840942616 }, { "content": "#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"accumulate_knn_grad_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\nnamespace functor {\n\n\n\n\n\ninline static float distanceWeight(const float& distsq){\n", "file_path": "modules/compiled/accumulate_knn_grad_kernel.cc", "rank": 19, "score": 7.942052979714555 }, { "content": "def lovasz_hinge_x(logits, labels, per_image=True, ignore=None):\n\n \"\"\"\n\n Binary Lovasz hinge loss\n\n logits: [B, H, W] Variable, logits at each pixel (between -\\infty and +\\infty)\n\n labels: [B, H, W] Tensor, binary ground truth masks (0 or 1)\n\n per_image: compute the loss per image instead of per batch\n\n ignore: void class id\n\n \"\"\"\n\n\n\n\n\n logits = tf.transpose(logits, (1,0))\n\n labels = tf.transpose(labels, (1,0))\n\n\n\n\n\n # print(\"TF\", tf.reduce_sum(logits))\n\n\n\n\n\n if per_image:\n\n loss = mean(lovasz_hinge_flat_x(*flatten_binary_scores_x(tf.expand_dims(log, axis=0), tf.expand_dims(lab, axis=0), ignore))\n\n for log, lab in zip(logits, labels))\n\n else:\n\n 0/0\n\n # loss = lovasz_hinge_flat(\n\n # *flatten_binary_scores(logits, labels, ignore))\n", "file_path": "modules/segmentation_sota.py", "rank": 20, "score": 7.732868570057158 }, { "content": "typedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\nvoid printSet(std::set<int>& inList, string prefixLine=\"\"){\n\n std::cout << prefixLine << std::endl;\n\n for (auto const& i: inList){\n\n std::cout << i << \" \";\n\n }\n\n std::cout << std::endl;\n\n}\n\n\n\nvoid printVector(std::vector<int>& inList, string prefixLine=\"\"){\n\n std::cout << prefixLine << std::endl;\n\n for (auto const& i: inList){\n\n std::cout << i << \" \";\n\n }\n\n std::cout << std::endl;\n\n}\n", "file_path": "modules/compiled/compare_knn_outputs_kernel.cc", "rank": 21, "score": 7.692357225965834 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"accumulate_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n#include <iostream> //remove later DEBUG FIXME\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n\n\nstatic inline float distanceWeight(const float& distsq){\n\n return exp(-1.*ACCUMULATE_KNN_EXPONENT* distsq);\n\n}\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/accumulate_knn_kernel.cc", "rank": 22, "score": 7.679067064024057 }, { "content": " }\n\n}\n\n\n\ntemplate <typename T>\n\nvoid print_array(\n\n std::vector<T> in_arr,\n\n const size_t start,\n\n const size_t end,\n\n bool convert_to_int = false\n\n){\n\n for(size_t i = start ; i < end ; i += 1){\n\n float tmp_val = in_arr[i];\n\n if (convert_to_int == true)\n\n printf(\"i: %d;\\t%d\\n\", i, (int)tmp_val);\n\n else\n\n printf(\"i: %d;\\t%f\\n\", i, tmp_val);\n\n }\n\n}\n\n\n\ntemplate <typename T>\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 23, "score": 6.6551507920890955 }, { "content": "void print_gpu_array(\n\n const T *in_arr,\n\n const size_t arr_size,\n\n const size_t start,\n\n const size_t end,\n\n bool convert_to_int = false\n\n){\n\n std::vector<T> tmp_arr(arr_size);\n\n HANDLE_ERROR(cudaMemcpy(&tmp_arr.at(0),in_arr,arr_size*sizeof(T),cudaMemcpyDeviceToHost));\n\n\n\n for(size_t i = start ; i < end ; i += 1){\n\n float tmp_val = tmp_arr.at(i);\n\n if (convert_to_int == true)\n\n printf(\"i: %d;\\t%d\\n\", i, (int)tmp_val);\n\n else\n\n printf(\"i: %d;\\t%f\\n\", i, tmp_val);\n\n }\n\n}\n\n\n\ntemplate <typename T>\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 24, "score": 5.628528134088523 }, { "content": "void print_gpu_matrix(\n\n const T *in_arr,\n\n const size_t start,\n\n const size_t end,\n\n const size_t stride,\n\n bool convert_to_int = false\n\n){\n\n int arr_size = end-start;\n\n std::vector<T> tmp_arr(arr_size);\n\n HANDLE_ERROR(cudaMemcpy(&tmp_arr.at(0),in_arr,arr_size*sizeof(T),cudaMemcpyDeviceToHost));\n\n\n\n for(size_t i = start ; i < end ; i += 1){\n\n float tmp_val = tmp_arr[i];\n\n if (i % stride == 0){\n\n printf(\"\\n\");\n\n printf(\"%d: \", (int)(i/stride));\n\n }\n\n if (convert_to_int == true)\n\n printf(\"\\t%d\", (int)tmp_val);\n\n else\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 25, "score": 5.550687381168392 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"latent_space_grid_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n", "file_path": "modules/compiled/latent_space_grid_kernel.cu.cc", "rank": 26, "score": 5.526070073267526 }, { "content": "//template<class T>\n\n//class _lock{\n\n//\n\n//public:\n\n// __device__ _lock( void )\n\n// {\n\n// mutex = new T;\n\n// (*mutex) = 0;\n\n// }\n\n// __device__ ~_lock( void )\n\n// {\n\n// delete mutex;\n\n// }\n\n//\n\n// __device__ void lock( void )\n\n// {\n\n// while( atomicCAS( mutex, 0, 1 ) != 0 );\n\n// }\n\n// __device__ void unlock( void )\n\n// {\n", "file_path": "modules/compiled/cuda_helpers.h", "rank": 27, "score": 5.46142295841086 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"select_knn_grad_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\nnamespace gpu{\n\n\n\n/*\n", "file_path": "modules/compiled/select_knn_grad_kernel.cu.cc", "rank": 28, "score": 5.423702043018163 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"select_mod_knn_grad_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\nnamespace gpu{\n\n\n\n\n", "file_path": "modules/compiled/select_mod_knn_grad_kernel.cu.cc", "rank": 29, "score": 5.413214449835165 }, { "content": "float calculateDistance(size_t i_v, size_t j_v, const float * d_coord, size_t n_coords){\n\n float distsq=0;\n\n if(i_v == j_v)\n\n return 0;\n\n for(size_t i=0;i<n_coords;i++){\n\n float dist = d_coord[I2D(i_v,i,n_coords)] - d_coord[I2D(j_v,i,n_coords)];\n\n distsq += dist*dist;\n\n }\n\n return distsq;\n\n}\n\n\n\n//purely debug function\n\nvoid coutVector(size_t i_v, int* d_indices, int n_neigh, const float * d_coord, int n_coords){\n\n\n\n for(size_t n=0;n<n_neigh;n++){\n\n size_t gidx = d_indices[I2D(i_v,n,n_neigh)];\n\n float distsq = calculateDistance(i_v,gidx,d_coord,n_coords);\n\n std::cout << \"(\"<< n << \": \" << gidx << \": \" << distsq << \") \";\n\n }\n\n std::cout << std::endl;\n", "file_path": "modules/compiled/select_knn_kernel.cc", "rank": 30, "score": 5.401291106873005 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"local_distance_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\n\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n", "file_path": "modules/compiled/local_distance_kernel.cu.cc", "rank": 31, "score": 5.392360471327198 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"build_condensates_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\n\n", "file_path": "modules/compiled/build_condensates_kernel.cu.cc", "rank": 32, "score": 5.392360471327198 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"compare_knn_outputs_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\nnamespace gpu{\n\n\n\n// Define the CUDA kernel.\n", "file_path": "modules/compiled/compare_knn_outputs_kernel.cu.cc", "rank": 33, "score": 5.392360471327198 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"oc_helper_m_indices_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\n\n", "file_path": "modules/compiled/oc_helper_m_indices_kernel.cu.cc", "rank": 34, "score": 5.381993619956289 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"accumulate_knn_grad_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n", "file_path": "modules/compiled/accumulate_knn_grad_kernel.cu.cc", "rank": 35, "score": 5.381993619956289 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"select_threshold_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\n\n\n\n\n//just call once per rs, just to leave data on gpu\n", "file_path": "modules/compiled/select_threshold_kernel.cu.cc", "rank": 36, "score": 5.371666552790997 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"select_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\nnamespace gpu{\n\n__device__\n\nfloat calculateDistance(size_t i_v, size_t j_v, const float * d_coord, size_t n_coords){\n", "file_path": "modules/compiled/select_knn_kernel.cu.cc", "rank": 37, "score": 5.330751580754014 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"pseudo_row_split_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/misc_for_later/pseudo_row_split_kernel.cu.cc", "rank": 38, "score": 5.330751580754014 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"select_mod_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\nnamespace gpu{\n\n__device__\n\nstatic float calculateDistance(size_t i_v, size_t j_v, const float * d_coord,\n", "file_path": "modules/compiled/select_mod_knn_kernel.cu.cc", "rank": 39, "score": 5.330751580754014 }, { "content": "//#define GOOGLE_CUDA 1\n\n\n\n\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n\n\n#include \"accumulate_knn_kernel.h\"\n\n#include \"helpers.h\"\n\n#include \"tensorflow/core/util/gpu_kernel_helper.h\"\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <cuda_runtime_api.h>\n\n#include \"cuda_helpers.h\"\n\n\n\nnamespace tensorflow {\n\nnamespace functor {\n\n\n\n__device__\n\nstatic inline float distanceWeight(float distsq){\n\n return exp(-1.*ACCUMULATE_KNN_EXPONENT* distsq); //uses cuda built in exp\n", "file_path": "modules/compiled/accumulate_knn_kernel.cu.cc", "rank": 40, "score": 5.28047609141128 }, { "content": "\n\n#if GOOGLE_CUDA\n\n#define EIGEN_USE_GPU\n\n#endif // GOOGLE_CUDA\n\n\n\n\n\n#include \"tensorflow/core/framework/op_kernel.h\"\n\n#include \"neighbour_covariance_kernel.h\"\n\n#include \"helpers.h\"\n\n#include <string> //size_t, just for helper function\n\n#include <cmath>\n\n\n\n\n\nnamespace tensorflow {\n\ntypedef Eigen::ThreadPoolDevice CPUDevice;\n\ntypedef Eigen::GpuDevice GPUDevice;\n\n\n\nnamespace functor {\n\n\n\n\n", "file_path": "modules/compiled/neighbour_covariance_kernel.cc", "rank": 41, "score": 5.127557276577961 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"LocalDistance\")\n\n .Input(\"coordinates: float32\")\n\n .Input(\"neighbour_idxs: int32\")\n\n .Output(\"distances: float32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/local_distance_module.cc", "rank": 42, "score": 4.500956953315948 }, { "content": " def createFeatureDict(self,infeat,addxycomb=True):\n\n '''\n\n infeat is the full list of features, including truth\n\n '''\n\n \n\n #small compatibility layer with old usage.\n\n feat = infeat\n\n if type(infeat) == list:\n\n feat=infeat[0]\n\n \n\n d = {\n\n 'recHitEnergy': feat[:,0:1] , #recHitEnergy,\n\n 'recHitEta' : feat[:,1:2] , #recHitEta ,\n\n 'recHitID' : feat[:,2:3] , #recHitID, #indicator if it is track or not\n\n 'recHitTheta' : feat[:,3:4] , #recHitTheta ,\n\n 'recHitR' : feat[:,4:5] , #recHitR ,\n\n 'recHitX' : feat[:,5:6] , #recHitX ,\n\n 'recHitY' : feat[:,6:7] , #recHitY ,\n\n 'recHitZ' : feat[:,7:8] , #recHitZ ,\n\n 'recHitTime' : feat[:,8:9] , #recHitTime \n\n 'recHitHitR' : feat[:,9:10] , #recHitTime \n\n }\n\n if addxycomb:\n\n d['recHitXY'] = feat[:,5:7] \n\n \n", "file_path": "modules/datastructures/TrainData_NanoML.py", "rank": 43, "score": 4.413366144794809 }, { "content": " def createFeatureDict(self,infeat,addxycomb=True):\n\n '''\n\n infeat is the full list of features, including truth\n\n '''\n\n \n\n #small compatibility layer with old usage.\n\n feat = infeat\n\n if type(infeat) == list:\n\n feat=infeat[0]\n\n \n\n d = {\n\n 'recHitEnergy': feat[:,0:1] , #recHitEnergy,\n\n 'recHitEta' : feat[:,1:2] , #recHitEta ,\n\n 'recHitID' : feat[:,2:3] , #recHitID, #indicator if it is track or not\n\n 'recHitTheta' : feat[:,3:4] , #recHitTheta ,\n\n 'recHitR' : feat[:,4:5] , #recHitR ,\n\n 'recHitX' : feat[:,5:6] , #recHitX ,\n\n 'recHitY' : feat[:,6:7] , #recHitY ,\n\n 'recHitZ' : feat[:,7:8] , #recHitZ ,\n\n 'recHitTime' : feat[:,8:9] , #recHitTime \n\n }\n\n if addxycomb:\n\n d['recHitXY'] = feat[:,5:7] \n\n \n", "file_path": "modules/datastructures/TrainData_TrackML.py", "rank": 44, "score": 4.413366144794809 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"NeighbourCovariance\")\n\n .Input(\"coordinates: float32\")\n\n .Input(\"features: float32\")\n\n .Input(\"n_idxs: int32\")\n\n .Output(\"covariance: float32\")\n\n .Output(\"means: float32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/neighbour_covariance_module.cc", "rank": 45, "score": 4.377782162734767 }, { "content": "'''\n\nLayers with the sole purpose of debugging.\n\nThese should not be included in 'real' models\n\n'''\n\n\n\n\n\nimport tensorflow as tf\n\nimport plotly.express as px\n\nimport pandas as pd\n\nimport numpy as np\n\nfrom plotting_callbacks import shuffle_truth_colors\n\n \n\nclass PlotCoordinates(tf.keras.layers.Layer):\n\n \n\n def __init__(self, plot_every: int=100,\n\n outdir :str='.', **kwargs):\n\n '''\n\n Takes as input\n\n - coordinate \n\n - features (first will be used for size)\n\n - truth indices \n\n - row splits\n\n \n\n Returns coordinates (unchanged)\n\n '''\n\n \n\n if 'dynamic' in kwargs:\n\n super(PlotCoordinates, self).__init__(**kwargs)\n\n else:\n\n super(PlotCoordinates, self).__init__(dynamic=False,**kwargs)\n\n \n\n \n\n self.plot_every = plot_every\n\n self.outdir = outdir\n\n self.counter=-1\n\n import os\n\n if plot_every > 0:\n\n os.system('mkdir -p '+self.outdir)\n\n \n\n def get_config(self):\n\n config = {'plot_every': self.plot_every,\n\n 'outdir': self.outdir\n\n }\n\n base_config = super(PlotCoordinates, self).get_config()\n\n return dict(list(base_config.items()) + list(config.items()))\n\n \n\n def compute_output_shape(self, input_shapes):\n\n return input_shapes[0]\n\n \n\n def call(self, inputs):\n\n \n\n coords, features, tidx, rs = inputs\n\n if self.plot_every <=0:\n\n return coords\n\n if not hasattr(coords, 'numpy'): #only in eager\n\n return coords\n\n \n\n #plot initial state\n\n if self.counter>=0 and self.counter < self.plot_every:\n\n self.counter+=1\n\n return inputs[0]\n\n print('making debug plot')\n\n self.counter=0\n\n #just select first\n\n coords = coords[0:rs[1]]\n\n tidx = tidx[0:rs[1]]\n\n features = features[0:rs[1]]\n\n \n\n data={\n\n 'X': coords[:,0:1].numpy(),\n\n 'Y': coords[:,1:2].numpy(),\n\n 'Z': coords[:,2:3].numpy(),\n\n 'tIdx': tidx[:,0:1].numpy(),\n\n 'features': features[:,0:1].numpy()\n\n }\n\n \n\n df = pd.DataFrame (np.concatenate([data[k] for k in data],axis=1), columns = [k for k in data])\n\n df['orig_tIdx']=df['tIdx']\n\n rdst = np.random.RandomState(1234567890)#all the same\n\n shuffle_truth_colors(df,'tIdx',rdst)\n\n \n\n hover_data=['orig_tIdx']\n\n fig = px.scatter_3d(df, x=\"X\", y=\"Y\", z=\"Z\", \n\n color=\"tIdx\",\n\n size='features',\n\n hover_data=hover_data,\n\n template='plotly_dark',\n\n color_continuous_scale=px.colors.sequential.Rainbow)\n\n fig.update_traces(marker=dict(line=dict(width=0)))\n\n fig.write_html(self.outdir+'/'+self.name+\".html\")\n\n \n\n df = df[df['orig_tIdx']>=0]\n\n \n\n fig = px.scatter_3d(df, x=\"X\", y=\"Y\", z=\"Z\", \n\n color=\"tIdx\",\n\n size='features',\n\n hover_data=hover_data,\n\n template='plotly_dark',\n\n color_continuous_scale=px.colors.sequential.Rainbow)\n\n fig.update_traces(marker=dict(line=dict(width=0)))\n\n fig.write_html(self.outdir+'/'+self.name+\"_no_noise.html\")\n\n \n\n \n\n return inputs[0]\n\n \n\n\n", "file_path": "modules/debugLayers.py", "rank": 46, "score": 4.365193962392018 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"SelectKnnGrad\")\n\n .Input(\"grad_distances: float32\")\n\n .Input(\"indices: int32\")\n\n .Input(\"distances: float32\")\n\n .Input(\"coordinates: float32\")\n\n .Output(\"grad_coords: float32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/select_knn_grad_module.cc", "rank": 47, "score": 4.307061023419377 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"SelectThreshold\")\n\n .Attr(\"threshold: float\")\n\n .Input(\"th_value: float32\")\n\n .Input(\"rowsplits: int32\")\n\n .Output(\"scatter_idxs: int32\")\n\n .Output(\"new_rowsplits: int32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/select_threshold_module.cc", "rank": 48, "score": 4.307061023419377 }, { "content": " }\n\n}\n\n\n\ntemplate <typename T>\n\n__global__\n\nvoid set_defaults(\n\n T *in_arr,\n\n const size_t arr_size,\n\n const T def_val\n\n){\n\n int index = blockIdx.x * blockDim.x + threadIdx.x;\n\n int stride = blockDim.x * gridDim.x;\n\n for(size_t i = index ; i < arr_size ; i += stride){\n\n in_arr[i] = def_val;\n\n }\n\n}\n\n\n\n__global__\n\nvoid print_neighbours(\n\n const size_t i_v,\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 49, "score": 4.1846007152243425 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n/*\n\n *\n\n * Just creates indices\n\n * Each vertex gets assigned a condensation point index\n\n * or to noise (-1)\n\n *\n\n * \"soft\" is like softNMS\n\n *\n\n *\n\n */\n\n\n\n\n\nREGISTER_OP(\"BuildCondensates\")\n\n .Attr(\"radius: float\")\n\n .Attr(\"min_beta: float\")\n\n .Attr(\"soft: bool\")\n", "file_path": "modules/compiled/build_condensates_module.cc", "rank": 50, "score": 4.172259016292203 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"AccumulateKnn\")\n\n .Attr(\"n_moments: int\")\n\n .Attr(\"mean_and_max: bool\")\n\n .Input(\"distances: float32\") //change to distances!!\n\n .Input(\"features: float32\")\n\n .Input(\"indices: int32\")\n\n .Output(\"out_features: float32\")\n\n .Output(\"out_max_idxs: int32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/accumulate_knn_module.cc", "rank": 51, "score": 4.150608123228954 }, { "content": " return exp(-1.*ACCUMULATE_KNN_EXPONENT* distsq);\n\n}\n\n\n\nstatic void set_feature_grad_zero(\n\n float * d_out_grad_features,\n\n size_t n_vert,\n\n size_t n_feat\n\n){\n\n\n\n for (size_t i_v = 0; i_v < n_vert; i_v++){\n\n for (size_t i_f = 0; i_f < n_feat; i_f++)\n\n d_out_grad_features[I2D(i_v, i_f, n_feat)] = 0;\n\n }\n\n}\n\n\n\nstatic void calc_feature_gradients(\n\n const float * d_grad_from_out_features,\n\n const int * d_max_feat_indices,\n\n const int * d_neigh_indices,\n\n const float * d_distances,\n", "file_path": "modules/compiled/accumulate_knn_grad_kernel.cc", "rank": 52, "score": 4.09818937634879 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"SelectModKnnGrad\")\n\n .Input(\"grad_distances: float32\")\n\n .Input(\"indices: int32\")\n\n .Input(\"distances: float32\")\n\n .Input(\"coordinates: float32\")\n\n .Input(\"coord_mod: float32\")\n\n .Output(\"grad_coords: float32\")\n\n .Output(\"grad_coord_mod: float32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/select_mod_knn_grad_module.cc", "rank": 53, "score": 4.086982999622811 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"LocalCluster\")\n\n .Input(\"neighbour_idxs: int32\") //change to distances!!\n\n .Input(\"hierarchy_idxs: int32\")\n\n .Input(\"global_idxs: int32\")\n\n .Input(\"row_splits: int32\")\n\n .Output(\"out_row_splits: int32\")\n\n .Output(\"selection_idxs: int32\")\n\n .Output(\"backscatter_idxs: int32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/local_cluster_module.cc", "rank": 54, "score": 4.0456389729043645 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"SelectKnn\")\n\n .Attr(\"n_neighbours: int\")\n\n .Attr(\"tf_compatible: bool\")\n\n .Attr(\"max_radius: float\")\n\n .Attr(\"mask_mode: int\")\n\n .Input(\"coords: float32\")\n\n .Input(\"row_splits: int32\")\n\n .Input(\"mask: int32\")\n\n .Output(\"indices: int32\")\n\n .Output(\"distances: float32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/select_knn_module.cc", "rank": 55, "score": 4.025279058882822 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"SlicingKnn\")\n\n .Attr(\"features_to_bin_on: list(int) >= 2\")\n\n .Attr(\"n_neighbours: int\")\n\n .Input(\"coords: float32\")\n\n .Input(\"row_splits: int32\")\n\n .Input(\"n_bins: int32\")\n\n .Input(\"coord_min: float32\")\n\n .Input(\"coord_max: float32\")\n\n .Output(\"indices: int32\")\n\n .Output(\"distances: float32\");\n", "file_path": "modules/compiled/slicing_knn_module.cc", "rank": 56, "score": 4.005123043637688 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"AccumulateKnnGrad\")\n\n .Input(\"grad_from_out_features: float32\")\n\n .Input(\"distances: float32\")\n\n .Input(\"features: float32\")\n\n .Input(\"neigh_indices: int32\")\n\n .Input(\"max_feat_indices: int32\")\n\n .Output(\"out_grad_distances: float32\")\n\n .Output(\"out_grad_features: float32\");\n\n //.Output(\"grad_indices: int32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/accumulate_knn_grad_module.cc", "rank": 57, "score": 4.005123043637688 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"CompareKnnOutputs\")\n\n // .Attr(\"scale_factor: int\")\n\n .Input(\"in_tensor1: int32\")\n\n .Input(\"in_tensor2: int32\")\n\n .Output(\"out_tensor: int32\")\n\n .SetShapeFn([](::tensorflow::shape_inference::InferenceContext* c) {\n\n c->set_output(0, c->input(0)); // requires that output with idx 0\n\n return Status::OK(); // should have the same shape as\n\n }) // input with idx 0.\n\n; \n", "file_path": "modules/compiled/compare_knn_outputs_module.cc", "rank": 58, "score": 3.9851678794471974 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"SelectModKnn\")\n\n .Attr(\"n_neighbours: int\")\n\n .Attr(\"tf_compatible: bool\")\n\n .Attr(\"max_radius: float\")\n\n .Attr(\"mask_mode: int\")\n\n .Input(\"coords: float32\")\n\n .Input(\"coord_mod: float32\")\n\n .Input(\"row_splits: int32\")\n\n .Input(\"mask: int32\")\n\n .Output(\"indices: int32\")\n\n .Output(\"distances: float32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/select_mod_knn_module.cc", "rank": 59, "score": 3.926477913667958 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n/*\n\n *\n\n * Just creates indices\n\n * Each vertex gets assigned a condensation point index\n\n * or to noise (-1)\n\n *\n\n * \"soft\" is like softNMS\n\n *\n\n *\n\n */\n\n\n\n\n\nREGISTER_OP(\"PseudoRowSplit\")\n\n .Input(\"in_asso_idx: int32\")\n\n .Input(\"unique_assos: int32\")\n\n .Input(\"n_per_rs: int32\")\n\n .Input(\"row_splits: int32\")\n\n .Output(\"asso_idx: int32\")\n\n .Output(\"pseudo_rs: int32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/misc_for_later/pseudo_row_split_module.cc", "rank": 60, "score": 3.8694915251236277 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n/*\n\n * Takes as helper input\n\n * y, idx, count = tf.unique_with_counts(x)\n\n *\n\n * y is the unique tensor\n\n * idx going to be ignored\n\n * count -> tf.max(count) -> nmax_per_unique\n\n *\n\n */\n\n\n\nREGISTER_OP(\"MIndices\")\n\n .Attr(\"calc_m_not: bool\")\n\n .Input(\"asso_idxs: int32\")\n\n .Input(\"unique_idxs: int32\")\n\n .Input(\"nmax_per_unique: int32\")\n\n .Output(\"sel_idxs: int32\")\n\n .Output(\"m_not: float32\");\n\n\n\n\n", "file_path": "modules/compiled/oc_helper_m_indices_module.cc", "rank": 61, "score": 3.814135601035837 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n\n\nREGISTER_OP(\"LatentSpaceGrid\")\n\n .Attr(\"size: float\")\n\n .Attr(\"min_cells: int\") //same for all dimensions\n\n .Input(\"coords: float32\")\n\n .Input(\"min_coord: float32\") //per dimension\n\n .Input(\"max_coord: float32\")\n\n .Input(\"row_splits: int32\")\n\n .Output(\"select_idxs: int32\")\n\n .Output(\"pseudo_rowsplits: int32\")\n\n .Output(\"n_cells_per_rs_coord: int32\")\n\n .Output(\"vert_to_cell: int32\");\n\n\n\n\n\n\n", "file_path": "modules/compiled/latent_space_grid_module.cc", "rank": 62, "score": 3.778103236132542 }, { "content": "\n\ntemplate <typename T>\n\n__device__\n\nvoid print_device_array(\n\n const T *d_arr,\n\n const size_t start,\n\n const size_t end\n\n){\n\n for(size_t i = start ; i < end ; i += 1){\n\n printf(\"%d\\t%f\\n\", i, d_arr[i]);\n\n }\n\n}\n\n\n\n// calculate min and max of X and Y coordinates among all vertices\n\n// make bins with widths: (x_max-x_min)/n_bins and (y_max-y_min)/n_bins\n\n__global__\n\nvoid constructPhaseSpaceBins(const float *d_coords, const size_t n_coords, const size_t start_vert,\n\n const size_t end_vert, const int* d_n_bins,\n\n const float* d_coords_min, const float* d_coords_max,\n\n const int* d_features_to_bin_on, int *d_n_vtx_per_bin,\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 63, "score": 3.7321180664823324 }, { "content": " def __init__(self,**kwargs):\n\n '''\n\n Simply accumulates all neighbour index information (including self if in the neighbour indices)\n\n Output will be divded by K, but not explicitly averaged if the number of neighbours is <K for\n\n particular vertices\n\n \n\n Inputs: data, idxs\n\n '''\n", "file_path": "modules/GravNetLayersRagged.py", "rank": 64, "score": 3.716193934144958 }, { "content": " if(n >= n_neigh)\n\n return;\n\n\n\n if(n){\n\n if(tf_compat)\n\n d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n else\n\n d_indices[I2D(i_v,n,n_neigh)] = -1;\n\n }\n\n else{\n\n d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n }\n\n d_dist[I2D(i_v,n,n_neigh)] = 0;\n\n\n\n\n\n}\n\n\n\n\n\n__global__\n\nvoid select_knn_kernel(\n", "file_path": "modules/compiled/select_knn_kernel.cu.cc", "rank": 65, "score": 3.654345080771417 }, { "content": "#include \"tensorflow/core/framework/op.h\"\n\n#include \"tensorflow/core/framework/shape_inference.h\"\n\n\n\nusing namespace tensorflow;\n\n\n\n/*\n\n\n\nREGISTER_OP(\"LocalGroup\")\n\n .Input(\"neighbour_idxs: int32\") // V x K\n\n .Input(\"hierarchy_idxs: int32\") // V x 1 per group\n\n .Input(\"hierarchy_score: float\") // V x 1 score per group\n\n .Attr(\"score_threshold: float\")\n\n .Input(\"global_idxs: int32\") // V x 1\n\n .Input(\"row_splits: int32\") // RS\n\n .Output(\"out_row_splits: int32\") //RS'\n\n .Output(\"selection_neighbour_idxs: int32\") //V' x K'\n\n .Output(\"backscatter_idxs: int32\") //V\n\n .Output(\"n_in_group: int32\"); //V x 1\n\n\n\n*/\n", "file_path": "modules/compiled/local_group_module.cc", "rank": 66, "score": 3.575438935902277 }, { "content": " bin_neighbours[index+counter] = -1;\n\n }\n\n else{\n\n bin_neighbours[index+counter] = tmp_index;\n\n }\n\n counter+=1;\n\n }\n\n }\n\n }\n\n }\n\n}\n\n\n\ntemplate <typename T>\n\nvoid print_2d_matrix(\n\n const T *in_arr,\n\n const size_t stride,\n\n const size_t start,\n\n const size_t end,\n\n bool convert_to_int = false\n\n){\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 67, "score": 3.524547209665722 }, { "content": "}\n\n\n\n__global__\n\nvoid acc_knn_kernel(\n\n const float *d_distances,\n\n const float *d_feat,\n\n const int *d_idxs,\n\n\n\n float *d_out_feat,\n\n int *d_out_maxidxs,\n\n\n\n int n_vert,\n\n int n_neigh,\n\n int n_feat,\n\n\n\n int n_out_feat,\n\n\n\n int n_moments,\n\n bool mean_and_max) {\n\n\n", "file_path": "modules/compiled/accumulate_knn_kernel.cu.cc", "rank": 68, "score": 3.524547209665722 }, { "content": " def __init__(self, tree):\n\n '''\n\n Always use _readArray, not direct uproot to avoid compatibility issues\n\n \n\n define the following in a derived class:\n\n - _readTree(self,tree)\n\n - needs to include call to _readSplits(self,tree,splitlabel)\n\n - _assignTruth(self,tree)\n\n \n\n '''\n\n\n\n self.splitIdx=None\n\n self.features=None\n\n self.truth={}\n\n self.featurenames=[]\n\n \n\n self._readTree(tree)\n", "file_path": "modules/datastructures/TrainData_NanoML.py", "rank": 69, "score": 3.519944568368162 }, { "content": " for(size_t n=1;n<n_neigh;n++){ //0 is self\n\n float distsq = d_dist[I2D(i_v,n,n_neigh)];\n\n if(distsq > maxdist){\n\n maxdist = distsq;\n\n maxidx = n;\n\n }\n\n }\n\n return maxidx;\n\n}\n\n\n\nvoid set_defaults(\n\n int *d_indices,\n\n float *d_dist,\n\n const int n_vert,\n\n const int n_neigh\n\n){\n\n for(size_t i_v =0 ; i_v < n_vert ; i_v++){\n\n for(size_t n = 0; n < n_neigh; n++){\n\n\n\n if(n){\n", "file_path": "modules/compiled/slicing_knn_kernel.cc", "rank": 70, "score": 3.4935257682481153 }, { "content": " printf(\"ERROR: get_max_beta mem alloc not successful.\");\n\n if(cudaMalloc((void**)&new_ref_idx,n_sub*sizeof(int)) != cudaSuccess)\n\n printf(\"ERROR: get_max_beta mem alloc not successful.\");\n\n if(cudaMalloc((void**)&new_mask,n_sub*sizeof(int)) != cudaSuccess)\n\n printf(\"ERROR: get_max_beta mem alloc not successful.\");\n\n\n\n cudaDeviceSynchronize();\n\n\n\n grid_and_block gb(n_sub,256);\n\n //do\n\n //printf(\"launch kernel\\n\");\n\n get_max_sub<<<gb.grid(),gb.block()>>>(\n\n tmp_values,\n\n tmp_ref_idx,\n\n tmp_mask,\n\n new_values,\n\n new_ref_idx,\n\n new_mask,\n\n sub_n_total,\n\n n_sub,\n", "file_path": "modules/compiled/build_condensates_kernel.cu.cc", "rank": 71, "score": 3.471023627629237 }, { "content": " }\n\n else{\n\n d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n }\n\n d_dist[I2D(i_v,n,n_neigh)] = 0;\n\n\n\n\n\n}\n\n\n\n\n\n__global__\n\nstatic void select_knn_kernel(\n\n const float *d_coord,\n\n const float *d_coord_mod,\n\n const int* d_row_splits,\n\n const int* d_mask,\n\n int *d_indices,\n\n float *d_dist,\n\n\n\n const int n_vert,\n", "file_path": "modules/compiled/select_mod_knn_kernel.cu.cc", "rank": 72, "score": 3.463045635364845 }, { "content": "__global__\n\nstatic void calc(\n\n const int *d_truthidx,\n\n const int *d_unique_idx,\n\n\n\n int * out_idx,\n\n float * m_not,\n\n\n\n const int n_vert,\n\n const int n_unique,\n\n const int n_max_per_unique,\n\n bool calc_m_not){\n\n\n\n const int k = blockIdx.x * blockDim.x + threadIdx.x;\n\n if(k>=n_unique)\n\n return;\n\n\n\n\n\n //\n\n\n", "file_path": "modules/compiled/oc_helper_m_indices_kernel.cu.cc", "rank": 73, "score": 3.463045635364845 }, { "content": " d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n }\n\n else{\n\n d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n }\n\n d_dist[I2D(i_v,n,n_neigh)] = 0;\n\n\n\n }\n\n }\n\n}\n\n\n\nvoid select_knn_kernel(\n\n const float *d_coord,\n\n const int* d_row_splits,\n\n int *d_indices,\n\n float *d_dist,\n\n\n\n const int n_vert,\n\n const int n_neigh,\n\n const int n_coords,\n", "file_path": "modules/compiled/slicing_knn_kernel.cc", "rank": 74, "score": 3.4330927652198593 }, { "content": " void calcGB(size_t n,size_t b, T& grid, T& block){\n\n grid = n/b;\n\n block=b;\n\n if(n%b)\n\n grid+=1;\n\n if(!grid)\n\n grid=1;\n\n }\n\n _grid_and_block():gx_(0),gy_(0),gz_(0),bx_(0),by_(0),bz_(0){}\n\n T gx_,gy_,gz_; //replace by T\n\n T bx_,by_,bz_;\n\n};\n\n\n\ntemplate<class T>\n", "file_path": "modules/compiled/cuda_helpers.h", "rank": 75, "score": 3.403653593794474 }, { "content": " }//i_f\n\n }//i_v\n\n}\n\n\n\nstatic void calccov( // <<< vout,nfeat,(ncoords)\n\n const float *d_coords,\n\n const float *d_feats,\n\n const int* d_n_dixs,\n\n\n\n float * d_covariance, //just for same interface Vout x F x C\n\n float * d_means,\n\n\n\n const int n_vert,\n\n const int n_coords,\n\n const int n_feat,\n\n const int n_neigh,\n\n const int n_vert_out){\n\n\n\n int n_covs = n_coords*(n_coords+1)/2;\n\n\n", "file_path": "modules/compiled/neighbour_covariance_kernel.cc", "rank": 76, "score": 3.3462643780654195 }, { "content": "\n\nint getNumberOfUnmatchedNeigbours(const int* list1, const int* list2, int vertex_index, int n_neighbour){\n\n int i = vertex_index;\n\n int low_index = i*n_neighbour;\n\n int high_index = (i+1)*n_neighbour;\n\n std::set<int> s1(list1 + low_index,list1 + high_index);\n\n std::set<int> s2(list2 + low_index,list2 + high_index);\n\n std::vector<int> v_intersection;\n\n\n\n std::set_intersection(s1.begin(), s1.end(),\n\n s2.begin(), s2.end(),\n\n std::back_inserter(v_intersection));\n\n\n\n // std::cout << \"low_index: \" << low_index << \"; high_index: \" << high_index << std::endl;\n\n // printSet(s1,\"s1\");\n\n // printSet(s2,\"s2\");\n\n // printVector(v_intersection,\"v_intersection:\");\n\n\n\n return (n_neighbour-v_intersection.size());\n\n}\n\n\n\n// CPU specialization\n\ntemplate<typename dummy>\n", "file_path": "modules/compiled/compare_knn_outputs_kernel.cc", "rank": 77, "score": 3.343952185710264 }, { "content": "\n\n }\n\n }\n\n}\n\n\n\nvoid select_knn_kernel(\n\n const float *d_coord,\n\n const int* d_row_splits,\n\n const int* d_mask,\n\n int *d_indices,\n\n float *d_dist,\n\n\n\n const int n_vert,\n\n const int n_neigh,\n\n const int n_coords,\n\n\n\n const int j_rs,\n\n const bool tf_compat,\n\n const float max_radius,\n\n selknn::mask_mode_en mask_mode,\n", "file_path": "modules/compiled/select_knn_kernel.cc", "rank": 78, "score": 3.3182894354027814 }, { "content": " }\n\n\n\n\n\n cudaFree(tmp_values);\n\n cudaFree(tmp_ref_idx);\n\n cudaFree(tmp_mask);\n\n\n\n\n\n cudaDeviceSynchronize();\n\n return ref_beta;\n\n}\n\n\n\n__global__\n\nstatic void check_and_collect(\n\n\n\n const int ref_vertex,\n\n const float ref_beta,\n\n const float *d_ccoords,\n\n const float *d_betas,\n\n const float *d_dist,\n", "file_path": "modules/compiled/build_condensates_kernel.cu.cc", "rank": 79, "score": 3.3182894354027814 }, { "content": " for(size_t i = start ; i < end ; i += 1){\n\n float tmp_val = in_arr[i];\n\n if (i % stride == 0){\n\n printf(\"\\n\");\n\n printf(\"i: %d: \", (int)(i/stride));\n\n }\n\n if (convert_to_int == true)\n\n printf(\"\\t%d\", (int)tmp_val);\n\n else\n\n printf(\"\\t%f\", tmp_val);\n\n }\n\n printf(\"\\n\");\n\n}\n\n\n\nvoid set_defaults(\n\n int *neigh_idx,\n\n float *neigh_dist,\n\n const int V,\n\n const int K\n\n){\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 80, "score": 3.3182894354027814 }, { "content": "def oc_loss_interface(\n\n pred_beta, pred_ccoords, pred_energy, pred_pos, pred_time, pred_id,\n\n t_idx, t_energy, t_pos, t_time, t_pid,\n\n rowsplits,\n\n config,\n\n energy_weight_function=None #takes true energy and returns weight per hit\n\n ):\n\n '''\n\n This is going to be the new format.\n\n Do not pass features here. if any predictions are relative to features put that \n\n directly in the model.\n\n \n\n The classification loss is still not included here (because it isn't either in the data).\n\n \n\n inputs: all V x X (where X is at least 1)\n\n not self-explanatory ones:\n\n - energy_weight_function: takes per hit true energy and transforms it to a weight\n\n \n\n '''\n\n energyweights = tf.zeros_like(t_energy)+1.\n\n if energy_weight_function is not None:\n", "file_path": "modules/betaLosses.py", "rank": 81, "score": 3.3156639389249483 }, { "content": "//helpers here\n\n\n\nstatic void set_defaults(\n\n int *asso_idx,\n\n int * is_cpoint,\n\n const float * d_betas,\n\n float * temp_betas,\n\n const int start_vertex,\n\n const int end_vertex,\n\n const int n_vert){\n\n\n\n for(size_t i_v=start_vertex;i_v<end_vertex;i_v++){\n\n asso_idx[i_v] = -start_vertex-1;\n\n\n\n temp_betas[i_v] = d_betas[i_v];\n\n\n\n is_cpoint[i_v] = 0;//not needed on GPU?\n\n }\n\n}\n\n\n", "file_path": "modules/compiled/build_condensates_kernel.cc", "rank": 82, "score": 3.290778358721532 }, { "content": "void set_defaults(\n\n int *d_indices,\n\n float *d_dist,\n\n const bool tf_compat,\n\n const int n_vert,\n\n const int n_neigh\n\n){\n\n for(size_t i_v =0 ; i_v < n_vert ; i_v++){\n\n for(size_t n = 0; n < n_neigh; n++){\n\n\n\n if(n){\n\n if(tf_compat)\n\n d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n else\n\n d_indices[I2D(i_v,n,n_neigh)] = -1;\n\n }\n\n else{\n\n d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n }\n\n d_dist[I2D(i_v,n,n_neigh)] = 0;\n", "file_path": "modules/compiled/select_knn_kernel.cc", "rank": 83, "score": 3.290778358721532 }, { "content": " if(distsq > maxdist){\n\n maxdist = distsq;\n\n maxidx = n;\n\n }\n\n }\n\n return maxidx;\n\n}\n\n\n\n__global__\n\nvoid set_defaults(\n\n int *d_indices,\n\n float *d_dist,\n\n const bool tf_compat,\n\n const int n_vert,\n\n const int n_neigh\n\n){\n\n const size_t i_v = blockIdx.x * blockDim.x + threadIdx.x;\n\n if(i_v >= n_vert)\n\n return;\n\n const size_t n = blockIdx.y * blockDim.y + threadIdx.y;\n", "file_path": "modules/compiled/select_knn_kernel.cu.cc", "rank": 84, "score": 3.290778358721532 }, { "content": "}\n\n\n\n\n\n__global__\n\nstatic void make_resort_idxs(\n\n const int * pseudo_rs,\n\n const int * asso_vert_to_global_cell,\n\n\n\n int * n_vert_per_global_cell_filled,\n\n int * resort_idxs,\n\n\n\n const int n_cell,\n\n const int n_vert\n\n ){\n\n\n\n size_t ice= blockIdx.x * blockDim.x + threadIdx.x;\n\n if(ice >= n_cell)\n\n return;\n\n\n\n\n", "file_path": "modules/compiled/latent_space_grid_kernel.cu.cc", "rank": 85, "score": 3.290778358721532 }, { "content": " for(size_t i = 0 ; i < V*K ; i += 1){\n\n neigh_idx[i] = -1;\n\n neigh_dist[i] = 0;\n\n }\n\n}\n\n\n\n\n\ntemplate <typename T>\n\nvoid print_array(\n\n const T *in_arr,\n\n const size_t start,\n\n const size_t end,\n\n bool convert_to_int = false\n\n){\n\n for(size_t i = start ; i < end ; i += 1){\n\n float tmp_val = in_arr[i];\n\n if (convert_to_int == true)\n\n printf(\"i: %d;\\t%d\\n\", i, (int)tmp_val);\n\n else\n\n printf(\"i: %d;\\t%f\\n\", i, tmp_val);\n", "file_path": "modules/compiled/slicing_knn_kernel.cu.cc", "rank": 86, "score": 3.237102406538936 }, { "content": " for(size_t n=1;n<n_neigh;n++){ //0 is self\n\n float distsq = d_dist[I2D(i_v,n,n_neigh)];\n\n if(distsq > maxdist){\n\n maxdist = distsq;\n\n maxidx = n;\n\n }\n\n }\n\n return maxidx;\n\n}\n\n\n\n__global__\n\nstatic void set_defaults(\n\n int *d_indices,\n\n float *d_dist,\n\n const bool tf_compat,\n\n const int n_vert,\n\n const int n_neigh\n\n){\n\n const size_t i_v = blockIdx.x * blockDim.x + threadIdx.x;\n\n if(i_v >= n_vert)\n", "file_path": "modules/compiled/select_knn_grad_kernel.cu.cc", "rank": 87, "score": 3.237102406538936 }, { "content": "){\n\n size_t i_v = blockIdx.x * blockDim.x + threadIdx.x;\n\n if(i_v >= n_vert)\n\n return;\n\n\n\n size_t n= blockIdx.y * blockDim.y + threadIdx.y;\n\n if(n >= n_neigh)\n\n return;\n\n\n\n d_dist[I2D(i_v,n,n_neigh)] = 0;\n\n}\n\n\n\n__global__\n\nstatic void calc_distances(const int *d_neigh_idxs,\n\n const float *d_coords,\n\n\n\n float * d_distances,\n\n const int n_coords,\n\n const int n_in_vert,\n\n const int n_out_vert,\n", "file_path": "modules/compiled/local_distance_kernel.cu.cc", "rank": 88, "score": 3.237102406538936 }, { "content": " float xb = d_ccoords[I2D(v_b,i,n_ccoords)];\n\n distsq += (xa-xb)*(xa-xb);\n\n }\n\n return distsq;\n\n}\n\n\n\nstatic void check_and_collect(\n\n\n\n const int ref_vertex,\n\n const float ref_beta,\n\n const float *d_ccoords,\n\n const float *d_betas,\n\n const float *d_dist,\n\n\n\n int *asso_idx,\n\n float * temp_betas,\n\n\n\n const int n_vert,\n\n const int n_ccoords,\n\n\n", "file_path": "modules/compiled/build_condensates_kernel.cc", "rank": 89, "score": 3.237102406538936 }, { "content": " float entry = sum/(sumw+1e-4);\n\n if(!sumw)\n\n entry=0;\n\n d_means[I3D(i_v,i_f,i_c,n_feat,n_coords)]=entry;\n\n }\n\n\n\n}\n\n\n\n__global__\n\nstatic void calccov( // <<< vout,nfeat,(ncoords)\n\n const float *d_coords,\n\n const float *d_feats,\n\n const int* d_n_dixs,\n\n\n\n float * d_covariance, //just for same interface Vout x F x C\n\n float * d_means,\n\n\n\n const int n_vert,\n\n const int n_coords,\n\n const int n_feat,\n", "file_path": "modules/compiled/neighbour_covariance_kernel.cu.cc", "rank": 90, "score": 3.210915750752327 }, { "content": "// atomicExch( mutex, 0 );\n\n// }\n\n//private:\n\n// T *mutex;\n\n//};\n\n//\n\n//\n\n\n\n\n\n\n\ntypedef _grid_stride_range<size_t> grid_stride_range;\n\ntypedef _grid_stride_range_y<size_t> grid_stride_range_y;\n\ntypedef _grid_and_block<size_t> grid_and_block;\n\ntypedef _lock<int> lock;\n\ntypedef _lock_mutex<int> lock_mutex;\n\n\n\n#endif /* HGCALML_MODULES_COMPILED_CUDA_HELPERS_H_ */\n", "file_path": "modules/compiled/cuda_helpers.h", "rank": 91, "score": 3.194726956131779 }, { "content": "\n\n\n\n__device__\n\nstatic float distancesq(const int v_a,\n\n const int v_b,\n\n const float *d_ccoords,\n\n const int n_ccoords){\n\n float distsq=0;\n\n for(size_t i=0;i<n_ccoords;i++){\n\n float xa = d_ccoords[I2D(v_a,i,n_ccoords)];\n\n float xb = d_ccoords[I2D(v_b,i,n_ccoords)];\n\n distsq += (xa-xb)*(xa-xb);\n\n }\n\n return distsq;\n\n}\n\n\n\n__global__\n\nstatic void get_max_sub(\n\n\n\n const float* values,\n", "file_path": "modules/compiled/build_condensates_kernel.cu.cc", "rank": 92, "score": 3.18514937090707 }, { "content": " max_contrib = ginu_max * weight_im;\n\n firstself=false;\n\n }\n\n }\n\n else{\n\n max_contrib = ginu_max * weight_im;\n\n }\n\n }\n\n\n\n //ATOMIC because of m_v which can occur in different threads. this is slow.. but needs to be atomic at least here...\n\n d_out_grad_features[I2D(m_v, nu_f, n_feat)] += mean_contrib + max_contrib;\n\n\n\n // }\n\n }\n\n }\n\n }\n\n}\n\n\n\nstatic void calc_distance_gradients(\n\n const float * d_grad_from_out_features,\n", "file_path": "modules/compiled/accumulate_knn_grad_kernel.cc", "rank": 93, "score": 3.159793229882643 }, { "content": "__global__\n\nstatic void set_defaults(\n\n int *asso_idx,\n\n int * is_cpoint,\n\n const float * d_betas,\n\n float * temp_betas,\n\n const int start_vertex,\n\n const int end_vertex,\n\n const int n_vert){\n\n\n\n size_t i_v = blockIdx.x * blockDim.x + threadIdx.x + start_vertex;\n\n if(i_v>=end_vertex)\n\n return;\n\n\n\n asso_idx[i_v] = -start_vertex -1;\n\n\n\n temp_betas[i_v] = d_betas[i_v];\n\n\n\n is_cpoint[i_v] = 0;//not needed on GPU?\n\n}\n", "file_path": "modules/compiled/build_condensates_kernel.cu.cc", "rank": 94, "score": 3.1348376076458417 }, { "content": "static int searchLargestDistance(int i_v, float* d_dist, int n_neigh, float& maxdist){\n\n\n\n maxdist=0;\n\n int maxidx=0;\n\n if(n_neigh < 2)\n\n return maxidx;\n\n for(size_t n=1;n<n_neigh;n++){ //0 is self\n\n float distsq = d_dist[I2D(i_v,n,n_neigh)];\n\n if(distsq > maxdist){\n\n maxdist = distsq;\n\n maxidx = n;\n\n }\n\n }\n\n return maxidx;\n\n}\n\n\n\nstatic void set_defaults(\n\n int *d_indices,\n\n float *d_dist,\n\n const bool tf_compat,\n", "file_path": "modules/compiled/select_mod_knn_kernel.cc", "rank": 95, "score": 3.1348376076458417 }, { "content": "}\n\n\n\n__global__\n\nstatic void select_mod_knn_grad_mod_kernel(\n\n const float *d_grad_dist, // V x N\n\n const int *d_neigh_indices,\n\n const float *d_dist,\n\n const float *d_coord,\n\n const float *d_coord_mod,\n\n\n\n float * d_grad_coord_mod,\n\n\n\n const int n_vert,\n\n const int n_neigh,\n\n const int n_coords){\n\n\n\n\n\n size_t i_v = blockIdx.x * blockDim.x + threadIdx.x;\n\n if(i_v >= n_vert)\n\n return;\n", "file_path": "modules/compiled/select_mod_knn_grad_kernel.cu.cc", "rank": 96, "score": 3.1348376076458417 }, { "content": "__global__\n\nstatic void set_defaults(\n\n int *d_indices,\n\n float *d_dist,\n\n const bool tf_compat,\n\n const int n_vert,\n\n const int n_neigh\n\n){\n\n const size_t i_v = blockIdx.x * blockDim.x + threadIdx.x;\n\n if(i_v >= n_vert)\n\n return;\n\n const size_t n = blockIdx.y * blockDim.y + threadIdx.y;\n\n if(n >= n_neigh)\n\n return;\n\n\n\n if(n){\n\n if(tf_compat)\n\n d_indices[I2D(i_v,n,n_neigh)] = i_v;\n\n else\n\n d_indices[I2D(i_v,n,n_neigh)] = -1;\n", "file_path": "modules/compiled/select_mod_knn_kernel.cu.cc", "rank": 97, "score": 3.1348376076458417 }, { "content": "namespace gpu{\n\n\n\n\n\n__device__\n\nstatic float calculateDistance(size_t i_v, size_t j_v, const float * d_coord, size_t n_coords){\n\n float distsq=0;\n\n if(i_v == j_v)\n\n return 0;\n\n for(size_t i=0;i<n_coords;i++){\n\n float dist = d_coord[I2D(i_v,i,n_coords)] - d_coord[I2D(j_v,i,n_coords)];\n\n distsq += dist*dist;\n\n }\n\n return distsq;\n\n}\n\n\n\n__global__\n\nstatic void set_defaults(\n\n float *d_dist,\n\n const int n_vert,\n\n const int n_neigh\n", "file_path": "modules/compiled/local_distance_kernel.cu.cc", "rank": 98, "score": 3.1348376076458417 }, { "content": "\n\n\n\n //for too low n, d_indices might need to be initialised with some number the\n\n // rest of the code understands.. maybe -1?\n\n\n\n //just loop over n_rs, in a realistic setting these shouldn't be more than a handful entries\n\n\n\n grid_and_block gb(n_vert,256,n_neigh,4);\n\n\n\n gpu::set_defaults<<<gb.grid(),gb.block()>>>(\n\n d_indices,\n\n d_dist,\n\n tf_compat,\n\n n_vert,\n\n n_neigh);\n\n\n\n cudaDeviceSynchronize();\n\n\n\n\n\n std::vector<int> cpu_rowsplits(n_rs);\n", "file_path": "modules/compiled/select_mod_knn_kernel.cu.cc", "rank": 99, "score": 3.130765177880299 } ]
C++
src/platform/threadmgr/ThreadManager.cpp
shorton3/dashingplatforms
f461c967827b92c8bcf872c365afa64e56871aba
#include <iostream> #include <sstream> #include <ace/Thread.h> #include "ThreadManager.h" #include "platform/logger/Logger.h" #include "platform/common/Defines.h" #define THREAD_FUNC_RETRY 5 #define THREAD_MONITOR_PERIOD 2 #define MONITOR_GROUP_ID 17239115 ThreadManager::ThreadsWaitingForRestartMap ThreadManager::restartMap_; ACE_Thread_Mutex ThreadManager::restartMapMutex_; bool ThreadManager::isInitialized_ = false; ACE_thread_t ThreadManager::createThread(ACE_THR_FUNC function, void *functionArgs, const char* threadName, bool shouldRestart, long threadFlags, long priority, int threadGroup, size_t stackSize) { ACE_thread_t threadId = 0; if (!isInitialized_) { isInitialized_ = true; ThreadManager::createThread((ACE_THR_FUNC)ThreadManager::startThreadMonitor, 0, "ThreadManagerMonitor", true, THR_NEW_LWP | THR_JOINABLE | THR_SCHED_DEFAULT, ACE_DEFAULT_THREAD_PRIORITY, MONITOR_GROUP_ID); } ostringstream ostr; ostr << "Received request to create thread (" << threadName << ")" << ends; STRACELOG(DEVELOPERLOG, THREADLOG, ostr.str().c_str()); ThreadParameters* threadParameters = new ThreadParameters(threadName, shouldRestart, function, functionArgs, threadFlags, priority, threadGroup, stackSize); if (ACE_Thread_Manager::instance()->spawn( (ACE_THR_FUNC)ThreadManager::runThread, (void*)threadParameters, threadFlags, &threadId, 0 , priority, threadGroup, 0 , stackSize) == ERROR) { ostringstream ostr; ostr << "Unable to spawn thread (" << threadName << ")" << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); return 0; } else { ostringstream ostr; ostr << "Successfully spawned thread (" << threadName << ") returning Thread Id (" << threadId << ")" << ends; STRACELOG(DEBUGLOG, THREADLOG, ostr.str().c_str()); } return threadId; } ACE_thread_t* ThreadManager::createThreadPool(size_t Nthreads, ACE_THR_FUNC function, void *functionArgs, const char* threadName, bool shouldRestart, long threadFlags, long priority, int threadGroup, size_t stackSize) { ACE_thread_t* threadIds = new ACE_thread_t[Nthreads]; size_t stackSizes[Nthreads]; memset(stackSizes, stackSize, Nthreads); if (!isInitialized_) { isInitialized_ = true; ThreadManager::createThread((ACE_THR_FUNC)ThreadManager::startThreadMonitor, 0, "ThreadManagerMonitor", true, THR_NEW_LWP | THR_JOINABLE | THR_SCHED_DEFAULT, ACE_DEFAULT_THREAD_PRIORITY, MONITOR_GROUP_ID); } ostringstream ostr; ostr << "Received request to create thread pool (" << threadName << ") with (" << Nthreads << ") threads" << ends; STRACELOG(DEVELOPERLOG, THREADLOG, ostr.str().c_str()); ThreadParameters* threadParameters = new ThreadParameters(threadName, shouldRestart, function, functionArgs, threadFlags, priority, threadGroup, stackSize); if (ACE_Thread_Manager::instance()->spawn_n( threadIds, Nthreads, (ACE_THR_FUNC)ThreadManager::runThread, (void*)threadParameters, threadFlags, priority, threadGroup, 0 , stackSizes, 0 ) == ERROR) { ostringstream ostr; ostr << "Unable to spawn thread pool (" << threadName << ")" << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); return 0; } else { ostringstream ostr; ostr << "Successfully spawned thread pool (" << threadName << ")" << ends; STRACELOG(DEBUGLOG, THREADLOG, ostr.str().c_str()); } return threadIds; } void ThreadManager::startThreadMonitor() { while (1) { ThreadManager::restartMapMutex_.acquire(); if (!ThreadManager::restartMap_.empty()) { ThreadsWaitingForRestartMap::iterator restartMapIterator; ThreadsWaitingForRestartMap::iterator endIterator; restartMapIterator = ThreadManager::restartMap_.begin(); endIterator = ThreadManager::restartMap_.end(); while (restartMapIterator != endIterator) { ThreadParameters* threadParms = (ThreadParameters*)restartMapIterator->second; ACE_thread_t newThreadId = ThreadManager::createThread(threadParms->function_, threadParms->functionArgs_, threadParms->threadName_.c_str(), threadParms->shouldRestart_, threadParms->threadFlags_, threadParms->priority_, threadParms->threadGroup_, threadParms->stackSize_); ostringstream ostr; ostr << "Thread (" << threadParms->threadName_ << ") restarted with new Thread Id (" << newThreadId << ")" << ends; STRACELOG(DEBUGLOG, THREADLOG, ostr.str().c_str()); ThreadManager::restartMap_.erase(restartMapIterator->first); restartMapIterator++; } } ThreadManager::restartMapMutex_.release(); sleep(THREAD_MONITOR_PERIOD); } } ThreadManager::~ThreadManager() { if ((threadParameters_) && (!threadParameters_->shouldRestart_)) { delete threadParameters_; } } void ThreadManager::apply(void) { if (threadParameters_->shouldRestart_) { ostringstream ostr; ostr << "Thread exit handler caught thread death for thread (" << threadParameters_->threadName_ << ") with Id (" << threadId_ << "). Attempting restart." << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); typedef pair<unsigned long, ThreadParameters*> ThreadRestartPair; ThreadRestartPair threadRestartPair(threadId_, threadParameters_); ThreadManager::restartMapMutex_.acquire(); pair<map<unsigned long, ThreadParameters*>::iterator, bool> pairIterator = ThreadManager::restartMap_.insert(threadRestartPair); if (!pairIterator.second) { ostringstream ostr; ostr << "Error queuing thread (" << threadParameters_->threadName_ << ") with Id (" << threadId_ << ") for restart. Thread will not be restarted." << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); } ThreadManager::restartMapMutex_.release(); } else { ostringstream ostr; ostr << "Thread exit handler caught thread death for (" << threadParameters_->threadName_ << ") with Id (" << threadId_ << ")" << ends; STRACELOG(WARNINGLOG, THREADLOG, ostr.str().c_str()); } } ThreadManager::ThreadManager(ThreadParameters& threadParameters) : threadParameters_(&threadParameters) { threadId_ = ACE_Thread::self(); } ThreadManager* ThreadManager::getInstance(ThreadParameters& threadParameters) { return new ThreadManager(threadParameters); } ACE_THR_FUNC_RETURN ThreadManager::runThread(ThreadParameters& threadParameters) { ACE_Thread_Manager::instance()->at_exit(ThreadManager::getInstance(threadParameters)); ostringstream ostr1; ostr1 << "Attached thread exit handler to thread (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ")" << ends; STRACELOG(DEVELOPERLOG, THREADLOG, ostr1.str().c_str()); try { (*threadParameters.function_) (threadParameters.functionArgs_); } catch (exception exc) { ostringstream ostr; ostr << "Caught Application Level Exception - " << exc.what() << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); } if (threadParameters.shouldRestart_) { int counter = 0; while (counter < THREAD_FUNC_RETRY) { ostringstream ostr2; ostr2 << "Thread function (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ") returned. Calling it again (count=" << counter << ")." << ends; STRACELOG(ERRORLOG, THREADLOG, ostr2.str().c_str()); try { (*threadParameters.function_) (threadParameters.functionArgs_); } catch (exception exc) { ostringstream ostr; ostr << "Caught Application Level Exception - " << exc.what() << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); } counter++; } ostringstream ostr2; ostr2 << "Thread function (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ") returned " << counter << " times. Giving up to let the thread get restarted" << ends; STRACELOG(ERRORLOG, THREADLOG, ostr2.str().c_str()); } else { ostringstream ostr2; ostr2 << "Thread function (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ") returned." << ends; STRACELOG(WARNINGLOG, THREADLOG, ostr2.str().c_str()); } return 0; }
#include <iostream> #include <sstream> #include <ace/Thread.h> #include "ThreadManager.h" #include "platform/logger/Logger.h" #include "platform/common/Defines.h" #define THREAD_FUNC_RETRY 5 #define THREAD_MONITOR_PERIOD 2 #define MONITOR_GROUP_ID 17239115 ThreadManager::ThreadsWaitingForRestartMap ThreadManager::restartMap_; ACE_Thread_Mutex ThreadManager::restartMapMutex_; bool ThreadManager::isInitialized_ = false; ACE_thread_t ThreadManager::createThread(ACE_THR_FUNC function, void *functionArgs, const char* threadName, bool shouldRestart, long threadFlags, long priority, int threadGroup, size_t stackSize) { ACE_thread_t threadId = 0; if (!isInitialized_) { isInitialized_ = true; ThreadManager::createThread((ACE_THR_FUNC)ThreadManager::startThreadMonitor, 0, "ThreadManagerMonitor", true, THR_NEW_LWP | THR_JOINABLE | THR_SCHED_DEFAULT, ACE_DEFAULT_THREAD_PRIORITY, MONITOR_GROUP_ID); } ostringstream ostr; ostr << "Received request to create thread (" << threadName << ")" << ends; STRACELOG(DEVELOPERLOG, THREADLOG, ostr.str().c_str()); ThreadParameters* threadParameters = new ThreadParameters(threadName, shouldRestart, function, functionArgs, threadFlags, priority, threadGroup, stackSize); if (ACE_Thread_Manager::instance()->spawn( (ACE_THR_FUNC)ThreadManager::runThread, (void*)threadParameters, threadFlags, &threadId, 0 , priority, threadGroup, 0 , stackSize) == ERROR) { ostringstream ostr; ostr << "Unable to spawn thread (" << threadName << ")" << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); return 0; } else { ostringstream ostr; ostr << "Successfully spawned thread (" << threadName << ") returning Thread Id (" << threadId << ")" << ends; STRACELOG(DEBUGLOG, THREADLOG, ostr.str().c_str()); } return threadId; } ACE_thread_t* ThreadManager::createThreadPool(size_t Nthreads, ACE_THR_FUNC function, void *functionArgs, const char* threadName, bool shouldRestart, long threadFlags, long priority, int threadGroup, size_t stackSize) { ACE_thread_t* threadIds = new ACE_thread_t[Nthreads]; size_t stackSizes[Nthreads]; memset(stackSizes, stackSize, Nthreads); if (!isInitialized_) { isInitialized_ = true; ThreadManager::createThread((ACE_THR_FUNC)ThreadManager::startThreadMonitor, 0, "ThreadManagerMonitor", true, THR_NEW_LWP | THR_JOINABLE | THR_SCHED_DEFAULT, ACE_DEFAULT_THREAD_PRIORITY, MONITOR_GROUP_ID); } ostringstream ostr; ostr << "Received request to create thread pool (" << threadName << ") with (" << Nthreads << ") threads" << ends; STRACELOG(DEVELOPERLOG, THREADLOG, ostr.str().c_str()); ThreadParameters* threadParameters = new ThreadParameters(threadName, shouldRestart, function, functionArgs, threadFlags, priority, threadGroup, stackSize); if (ACE_Thread_Manager::instance()->spawn_n( threadIds, Nthreads, (ACE_THR_FUNC)ThreadManager::runThread, (void*)threadParameters, threadFlags, priority, threadGroup, 0 , stackSizes, 0 ) == ERROR) { ostringstream ostr; ostr << "Unable to spawn thread pool (" << threadName << ")" << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); return 0; } else { ostringstream ostr; ostr << "Successfully spawned thread pool (" << threadName << ")" << ends; STRACELOG(DEBUGLOG, THREADLOG, ostr.str().c_str()); } return threadIds; } void ThreadManager::startThreadMonitor() { while (1) { ThreadManager::restartMapMutex_.acquire(); if (!ThreadManager::restartMap_.empty()) { ThreadsWaitingForRestartMap::iterator restartMapIterator; ThreadsWaitingForRestartMap::iterator endIterator; restartMapIterator = ThreadManager::restartMap_.begin(); endIterator = ThreadManager::restartMap_.end(); while (restartMapIterator != endIterator) { ThreadParameters* threadParms = (ThreadParameters*)restartMapIterator->second; ACE_thread_t newThreadId =
; ostringstream ostr; ostr << "Thread (" << threadParms->threadName_ << ") restarted with new Thread Id (" << newThreadId << ")" << ends; STRACELOG(DEBUGLOG, THREADLOG, ostr.str().c_str()); ThreadManager::restartMap_.erase(restartMapIterator->first); restartMapIterator++; } } ThreadManager::restartMapMutex_.release(); sleep(THREAD_MONITOR_PERIOD); } } ThreadManager::~ThreadManager() { if ((threadParameters_) && (!threadParameters_->shouldRestart_)) { delete threadParameters_; } } void ThreadManager::apply(void) { if (threadParameters_->shouldRestart_) { ostringstream ostr; ostr << "Thread exit handler caught thread death for thread (" << threadParameters_->threadName_ << ") with Id (" << threadId_ << "). Attempting restart." << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); typedef pair<unsigned long, ThreadParameters*> ThreadRestartPair; ThreadRestartPair threadRestartPair(threadId_, threadParameters_); ThreadManager::restartMapMutex_.acquire(); pair<map<unsigned long, ThreadParameters*>::iterator, bool> pairIterator = ThreadManager::restartMap_.insert(threadRestartPair); if (!pairIterator.second) { ostringstream ostr; ostr << "Error queuing thread (" << threadParameters_->threadName_ << ") with Id (" << threadId_ << ") for restart. Thread will not be restarted." << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); } ThreadManager::restartMapMutex_.release(); } else { ostringstream ostr; ostr << "Thread exit handler caught thread death for (" << threadParameters_->threadName_ << ") with Id (" << threadId_ << ")" << ends; STRACELOG(WARNINGLOG, THREADLOG, ostr.str().c_str()); } } ThreadManager::ThreadManager(ThreadParameters& threadParameters) : threadParameters_(&threadParameters) { threadId_ = ACE_Thread::self(); } ThreadManager* ThreadManager::getInstance(ThreadParameters& threadParameters) { return new ThreadManager(threadParameters); } ACE_THR_FUNC_RETURN ThreadManager::runThread(ThreadParameters& threadParameters) { ACE_Thread_Manager::instance()->at_exit(ThreadManager::getInstance(threadParameters)); ostringstream ostr1; ostr1 << "Attached thread exit handler to thread (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ")" << ends; STRACELOG(DEVELOPERLOG, THREADLOG, ostr1.str().c_str()); try { (*threadParameters.function_) (threadParameters.functionArgs_); } catch (exception exc) { ostringstream ostr; ostr << "Caught Application Level Exception - " << exc.what() << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); } if (threadParameters.shouldRestart_) { int counter = 0; while (counter < THREAD_FUNC_RETRY) { ostringstream ostr2; ostr2 << "Thread function (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ") returned. Calling it again (count=" << counter << ")." << ends; STRACELOG(ERRORLOG, THREADLOG, ostr2.str().c_str()); try { (*threadParameters.function_) (threadParameters.functionArgs_); } catch (exception exc) { ostringstream ostr; ostr << "Caught Application Level Exception - " << exc.what() << ends; STRACELOG(ERRORLOG, THREADLOG, ostr.str().c_str()); } counter++; } ostringstream ostr2; ostr2 << "Thread function (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ") returned " << counter << " times. Giving up to let the thread get restarted" << ends; STRACELOG(ERRORLOG, THREADLOG, ostr2.str().c_str()); } else { ostringstream ostr2; ostr2 << "Thread function (" << threadParameters.threadName_ << ") with Id (" << ACE_Thread::self() << ") returned." << ends; STRACELOG(WARNINGLOG, THREADLOG, ostr2.str().c_str()); } return 0; }
ThreadManager::createThread(threadParms->function_, threadParms->functionArgs_, threadParms->threadName_.c_str(), threadParms->shouldRestart_, threadParms->threadFlags_, threadParms->priority_, threadParms->threadGroup_, threadParms->stackSize_)
call_expression
[ { "content": "function with a return - the return value is simply ignored.\n\n(See ethel example below)\n\n\n\nAll the correct virtual function behavior is preserved. (see ricky\n\nexample below).\n\n\n\nIf you somehow try to create something in violation\n\nof the type system you will get a compile-time or template-instantiation-\n\ntime error.\n\n\n\nThe CBFunctor base class and translator\n\nclasses are artifacts of this implementation. You should not write\n\ncode that relies upon their existence. Nor should you rely on the return\n\nvalue of makeFunctor being anything in particular.\n\n\n\nAll that is guaranteed is that the Functor classes have a default ctor,\n\na ctor that can accept 0 as an initializer,\n\nan operator() with the requested argument types and return type, an\n\noperator that will allow it to be evaluated in a conditional (with\n\n'true' meaning the functor is set, 'false' meaning it is not), and that\n", "file_path": "src/platform/msgmgr/Callback.h", "rank": 0, "score": 153933.06316201796 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/SeverityHelper.java", "rank": 1, "score": 87192.06798701984 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/DescriptionHelper.java", "rank": 2, "score": 87192.06798701984 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/session/Session_IHelper.java", "rank": 3, "score": 87192.06798701984 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/ResolutionHelper.java", "rank": 4, "score": 87192.06798701984 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/AcknowledgementHelper.java", "rank": 5, "score": 87192.06798701984 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/AlarmInformationHelper.java", "rank": 6, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/AlarmNotificationHelper.java", "rank": 7, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/IsFilterEnabledHelper.java", "rank": 8, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/TimeStampHelper.java", "rank": 9, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/alarmInterfaceHelper.java", "rank": 10, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/AlarmCodeHelper.java", "rank": 11, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/NEIDTypeHelper.java", "rank": 12, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/ManagedObjectHelper.java", "rank": 13, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/AlarmCategoryHelper.java", "rank": 14, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/IsAutoClearingHelper.java", "rank": 15, "score": 85354.85167103476 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/platformConfig/platformConfig_IHelper.java", "rank": 16, "score": 84493.28226783103 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/AlarmNotificationSequenceHelper.java", "rank": 17, "score": 83666.65437576824 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/HighWaterMarkHelper.java", "rank": 18, "score": 83666.65437576824 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/ManagedObjectInstanceHelper.java", "rank": 19, "score": 83666.65437576824 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/LowWaterMarkHelper.java", "rank": 20, "score": 83666.65437576824 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/alarms/AlarmInformationSequenceHelper.java", "rank": 21, "score": 83666.65437576824 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/platformConfig/platformConfigLogLevelsHelper.java", "rank": 22, "score": 81376.38256150638 }, { "content": " public static String id ()\n\n {\n\n return _id;\n", "file_path": "src/ems/idls/platformConfig/platformConfigLogLevelHelper.java", "rank": 23, "score": 81376.38256150638 }, { "content": "class ThreadManager : public ACE_At_Thread_Exit\n\n{\n\n public:\n\n\n\n /** Virtual Destructor */\n\n virtual ~ThreadManager();\n\n\n\n /**\n\n * Inheritied from ACE_At_Thread_Exit. Gets called upon thread death/exit.\n\n */\n\n void apply(void);\n\n\n\n /**\n\n * Main Thread creation API\n\n * @param function Static C++ method or C-style function to start the new thread with\n\n * @param functionArgs Array of arguments to pass to the function as parameters\n\n * @param threadName String identifier that should be unique to each thread\n\n * @param shouldRestart 'true' if the thread should be restarted upon exit;otherwise, it\n\n * will be allowed to terminate\n\n * @param threadFlags define the characteristics of the thread\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 24, "score": 64606.07033877408 }, { "content": "class SyncObjectPool : public ObjectPool\n\n{\n\n public:\n\n\n\n /**\n\n * Constructor initializes the pool to a configurable size and sets\n\n * the individual object's initializer to be stored in the Pool.\n\n * @param objectPoolID Object PoolID that identifies this object pool in the OPM\n\n * @param initialCapacity Starting size of the pool in objects\n\n * @param thresholdPercentage Percentage of current capacity to trigger\n\n * automatic growth.\n\n * @param capacityIncrement Number of objects to add to the current size when\n\n * increasing capacity\n\n * @param objectType const char* describing the class object stored in this pool\n\n * @param objectInitParam - Long parameter or pointer to initialization\n\n * data needed by the object or 0(NULL) if not needed (passed to \n\n * OPMBase::initialize).\n\n * @param bootStrapMethod pointer to a function or method (OPMBase::initialize)\n\n * that will create the object and return a pointer to it\n\n * @param growthMode Either NO_GROWTH, GROWTH_ALLOWED, or GROW_AND_SHRINK\n", "file_path": "src/platform/opm/SyncObjectPool.h", "rank": 25, "score": 63876.833429964485 }, { "content": "type compatible I mean a function with the same number of arguments, of\n\ntypes reachable from the functor's argument types by implicit conversion.\n\nThe return type of the function must be implicitly convertible to the\n\nreturn type of the functor. A functor with no return can be built from a\n", "file_path": "src/platform/msgmgr/Callback.h", "rank": 26, "score": 62521.40708791723 }, { "content": "class ThreadTest\n\n{\n\n public:\n\n\n\n /** Constructor */\n\n ThreadTest();\n\n\n\n /** Virtual Destructor */\n\n virtual ~ThreadTest();\n\n\n\n /** Initialization */\n\n void initialize();\n\n\n\n /** Perform Tests */\n\n static void performTests(void);\n\n\n\n /** Perform Restart Tests */\n\n static void performRestartTests(void);\n\n\n\n protected:\n", "file_path": "src/unittest/threadtest/ThreadTest.h", "rank": 27, "score": 62151.53477094359 }, { "content": "class ObjectPool\n\n{\n\n public:\n\n\n\n /**\n\n * Constructor initializes the pool to a configurable size and sets\n\n * the individual object's initializer to be stored in the Pool.\n\n * @param objectPoolID Object PoolID that identifies this object pool in the OPM\n\n * @param initialCapacity Starting size of the pool in objects\n\n * @param thresholdPercentage Percentage of current capacity to trigger\n\n * automatic growth.\n\n * @param capacityIncrement Number of objects to add to the current size when\n\n * increasing capacity\n\n * @param objectType const char* describing the class object stored in this pool\n\n * @param objectInitParam - Integer parameter or pointer to initialization\n\n * data needed by the object or 0(NULL) if not needed (passed to \n\n * OPMBase::initialize).\n\n * @param bootStrapMethod pointer to a function or method (OPMBase::initialize)\n\n * that will create the object and return a pointer to it\n\n * @param growthMode Either NO_GROWTH, GROWTH_ALLOWED, or GROW_AND_SHRINK\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 28, "score": 62121.64826732122 }, { "content": "-- Create a schema called 'platform'. This schema will contain all platform related\n\n-- database tables. Application tables should created in a separate schema. The\n\n-- reason for this is that DATA SEPARATION requirements may indicate that OA&M\n\n-- management data and customer bearing data be kept separate and that database\n\n-- access should happen on physically separate networks (Layer1 data separation)\n\ncreate schema platform;\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 29, "score": 61261.17837693868 }, { "content": "--******************************************************************************\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 30, "score": 59416.05295353774 }, { "content": "-- NEID is the top level primary index. Each Network Element is represented by an\n\n-- NEID. NEID consists of 9 characters: AAABBBCCC, where AAA is the customer Id,\n\n-- BBB is the cluster identifier, and CCC is the instance within the cluster.\n\n-- PEERIPAddress is the IP Address of the redundant mate for this network element.\n\n-- DbUserid and DbPassword will need to be stored in encrypted form (later).\n\ncreate table platform.NetworkElements (\n\n NEID character(9) not null,\n\n IPAddress varchar(15) not null,\n\n PeerIPAddress varchar(15),\n\n DataSourceName varchar(30) not null,\n\n DbUserid varchar(30) not null,\n\n DbPassword varchar(30) not null,\n\nprimary key (NEID));\n\n\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 31, "score": 59414.9850836991 }, { "content": "-- Outstanding Alarms table. Each network element maintains a local outstanding\n\n-- alarms list/table, and the EMS maintains a system wide outstanding alarms list.\n\n-- This table is for the EMS consolidated alarms, and provides a historical record\n\n-- of Alarms, when they got cleared, and the acknowledgement text. We need a \n\n-- strategy for how this table gets cleaned up.\n\n--\n\n-- OriginatedByNEID - will be different from ApplicableToNEID if this alarm was\n\n-- raised on behalf of another node (ie. another node sees ApplicableTo node go down)\n\n-- ApplicableToNEID - the node the Alarm applies to (also indicates which node's\n\n-- LocalAlarmsOutstanding table the alarms exists in)\n\n-- (In a NON-proxy(on behalf) condition, OriginatedByNEID == ApplicableToNEID)\n\n-- IsCleared indicates that the alarm has been cleared and is no longer outstanding;\n\n-- however, we do not want to delete the alarm for historical purposes of displaying\n\n-- the acknowledgement text as well as date/time.\n\n-- Since we are keeping Cleared Alarms for historical purposes (use of IsCleared), then\n\n-- TimeStamp needs to be part of the key to prevent a violation when an Alarm is\n\n-- raised that was previously cleared (and is still in the table).\n\ncreate table platform.AlarmsOutstanding (\n\n OriginatedByNEID character(9) not null,\n\n ApplicableToNEID character(9) not null,\n\n AlarmCode int2 not null,\n\n ManagedObject int2 not null,\n\n ManagedObjectInstance int4 not null,\n\n Pid int4 not null,\n\n TimeStamp timestamp with time zone not null,\n\n Acknowledgement varchar(500),\n\n IsCleared boolean not null, \n\nprimary key (OriginatedByNEID, ApplicableToNEID, AlarmCode, ManagedObject, ManagedObjectInstance, Pid, TimeStamp),\n\nforeign key (OriginatedByNEID) references platform.NetworkElements(NEID),\n\nforeign key (ApplicableToNEID) references platform.NetworkElements(NEID),\n\nforeign key (AlarmCode) references platform.AlarmsInventory(AlarmCode));\n\n\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 32, "score": 59410.48255126683 }, { "content": "-- Configured tracelog levels for each network element\n\ncreate table platform.LogLevels (\n\n NEID character(9) not null,\n\n SubSystem int2 not null,\n\n LogLevel int2 not null,\n\nprimary key (NEID, SubSystem),\n\nforeign key (NEID) references platform.NetworkElements(NEID));\n\n\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 33, "score": 59410.48255126683 }, { "content": "-- Configured Alarms Inventory for the entire platform.\n\n-- Severity represents the 'default' severity used by the system. We are required\n\n-- to maintain this for redundancy/failover analysis purposes.\n\n-- UserSeverity is the perceived severity of the user, which the user can re-assign.\n\n-- (This is what should be reported to the OSS/NOC as well as EMS client, and \n\n-- it should be initially datafilled the same as 'Severity')\n\ncreate table platform.AlarmsInventory (\n\n AlarmCode int2 not null,\n\n Category int2 not null,\n\n HighWaterMark int4,\n\n LowWaterMark int4,\n\n Severity int2 not null,\n\n UserSeverity int2 not null,\n\n AutoClearing boolean not null,\n\n FilterEnabled boolean not null,\n\n Description varchar(500) not null,\n\n Resolution varchar(500) not null,\n\nprimary key (AlarmCode));\n\n\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 34, "score": 59410.48255126683 }, { "content": "-- Configured Event Reports Inventory for the entire platform.\n\ncreate table platform.EventReportsInventory (\n\n EventCode int2 not null,\n\n FilterEnabled boolean not null,\n\n Description varchar(500) not null,\n\nprimary key (EventCode));\n\n\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 35, "score": 58529.06545159875 }, { "content": "-- Outstanding Alarms table. Each network element maintains a local outstanding\n\n-- alarms list/table, and the EMS maintains a system wide outstanding alarms list.\n\n-- This table is for the local node's outstanding alarms.\n\ncreate table platform.LocalAlarmsOutstanding (\n\n NEID character(9) not null,\n\n AlarmCode int2 not null,\n\n ManagedObject int2 not null,\n\n ManagedObjectInstance int4 not null,\n\n Pid int4 not null,\n\n TimeStamp timestamp with time zone not null,\n\n Acknowledgement varchar(500),\n\nprimary key (NEID, AlarmCode, ManagedObject, ManagedObjectInstance, Pid),\n\nforeign key (NEID) references platform.NetworkElements(NEID),\n\nforeign key (AlarmCode) references platform.AlarmsInventory(AlarmCode));\n\n\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 36, "score": 58529.06545159875 }, { "content": "-- Additional information for each Network Element\n\ncreate table platform.NetworkElementInfo (\n\n NEID character(9) not null,\n\n NEName varchar(15),\n\n Location varchar(30),\n\n City varchar(15),\n\n ZipCode varchar(15),\n\n RackNumber int2 not null,\n\n ShelfNumber int2 not null,\n\n SlotNumber int2 not null,\n\nforeign key (NEID) references platform.NetworkElements(NEID));\n\n\n\n\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 37, "score": 58529.06545159875 }, { "content": "-- Create the schema\n\ncreate table template(\n\n field1 int4,\n\n field2 int4,\n\nprimary key (field1));\n\n\n\ngrant all on template to userid;\n\n\n\n-- Populate default values\n\ninsert into template (field1, field2) values ('someValue1', 'someValue2');\n", "file_path": "make/Template.sql", "rank": 38, "score": 52867.53794200221 }, { "content": " * @param priority is the relative priority of the new thread (from 1 to 127). Specifying priority\n\n * other than the default is Discouraged, and should only be used RARELY!\n\n * @param threadGroup can be provided if thread pooling or grouping is desired.\n\n * @param stackSize specifies the size of the stack allocated for this thread\n\n * @returns Pointer array of unique thread Ids upon success; otherwise 0 upon failure.\n\n * This array of ACE_Thread_t thread ids is allocated on the heap, so ownership is \n\n * deferred to the application owner. In Linux, these values are\n\n * unsigned longs (see /usr/include/bits/pthread_types.h), so cannot use ERROR\n\n */\n\n static ACE_thread_t* createThreadPool(size_t Nthreads, ACE_THR_FUNC function, void *functionArgs,\n\n const char* threadName, bool shouldRestart, long threadFlags = THR_NEW_LWP | THR_JOINABLE | THR_SCHED_DEFAULT, \n\n long priority = ACE_DEFAULT_THREAD_PRIORITY, int threadGroup = -1, size_t stackSize = 0);\n\n\n\n protected:\n\n\n\n private:\n\n\n\n // Structure for passing arguments to the new thread\n\n struct ThreadParameters\n\n {\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 39, "score": 52863.20694391162 }, { "content": " * @param priority is the relative priority of the new thread (from 1 to 127). Specifying priority\n\n * other than the default is Discouraged, and should only be used RARELY!\n\n * @param threadGroup can be provided if thread pooling or grouping is desired.\n\n * @param stackSize specifies the size of the stack allocated for this thread\n\n * @returns the unique thread Id upon success; otherwise 0 upon failure. In Linux, this is\n\n * an unsigned long (see /usr/include/bits/pthread_types.h), so cannot use ERROR\n\n */\n\n static ACE_thread_t createThread(ACE_THR_FUNC function, void *functionArgs, const char* threadName, \n\n bool shouldRestart, long threadFlags = THR_NEW_LWP | THR_JOINABLE | THR_SCHED_DEFAULT,\n\n long priority = ACE_DEFAULT_THREAD_PRIORITY, int threadGroup = -1, size_t stackSize = 0);\n\n\n\n /**\n\n * Thread Pool creation API\n\n * @param Nthreads Number of threads to create in the pool\n\n * @param function Static C++ method or C-style function to start the new thread with\n\n * @param functionArgs Array of arguments to pass to the function as parameters\n\n * @param threadName String identifier that should be unique to each thread\n\n * @param shouldRestart 'true' if the thread should be restarted upon exit;otherwise, it\n\n * will be allowed to terminate\n\n * @param threadFlags define the characteristics of the thread\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 40, "score": 52862.02111703715 }, { "content": "--******************************************************************************\n", "file_path": "src/sql/PlatformTablesCreate.sql", "rank": 41, "score": 52861.606926058674 }, { "content": " /** ThreadParameters Constructor */\n\n ThreadParameters(const char* threadName, bool shouldRestart, ACE_THR_FUNC function, void* functionArgs,\n\n long threadFlags, long priority, int threadGroup, size_t stackSize)\n\n : threadName_(threadName),\n\n shouldRestart_(shouldRestart),\n\n function_(*function),\n\n functionArgs_(functionArgs), \n\n threadFlags_(threadFlags),\n\n priority_(priority),\n\n threadGroup_(threadGroup),\n\n stackSize_(stackSize){}\n\n /**\n\n * Unique name given to each thread.\n\n */\n\n string threadName_;\n\n /**\n\n * Boolean indicator as to whether this thread should be restarted in the event that it fails\n\n */\n\n bool shouldRestart_;\n\n /**\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 42, "score": 52837.14047842725 }, { "content": " * THR_SCHED_RR : Schedule the new thread using a round robin scheme, if available\n\n * THR_SCHED_DEFAULT : Use whatever default scheduling scheme is available on the OS\n\n * THR_INHERIT_SCHED : Thread will inherit scheduling scheme from its parent thread\n\n */\n\n long threadFlags_;\n\n /**\n\n * Priority of the child thread (Minimum is 1; Maximum in Linux is 127)\n\n */\n\n long priority_;\n\n /**\n\n * Arbitrary thread group Id assigned by the application developer\n\n */\n\n int threadGroup_;\n\n /**\n\n * Stack size to be assigned to the new thread\n\n */\n\n size_t stackSize_;\n\n };//end ThreadParameters\n\n\n\n /** Map is used to maintain a list of threads that have/are dying and must be restarted. Here,\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 43, "score": 52832.43630350472 }, { "content": " * <p>\n\n * In the event of a thread death/restart, we cannot just re-call createThread from\n\n * the space of the ACE_At_Exit handler, as the ACE_Thread_Manager is locked (we\n\n * are inside the lock), and we will need to lock it to call 'spawn', and that would\n\n * result in a DEADLOCK. Therefore, our strategy is to post the thread\n\n * details (threadparameters) to a static map, and have an independent thread\n\n * periodically every second or so check to see if the map contains any threads\n\n * that need restarting. Any other strategies for notification and restart of the\n\n * thread are very complex!\n\n * <p>\n\n * ALSO NOTE:!! Upon restart, the thread Id originally made available to the\n\n * application for this thread will be invalid. We can (IN THE FUTURE) allow\n\n * the application developer to pass in a call back function (with unsigned\n\n * long parameter) that can be called and passed the new Thread Id.\n\n * <p>\n\n * $Author: Stephen Horton$\n\n * $Revision: 1$\n\n */\n\n\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 44, "score": 52831.83710835026 }, { "content": " * ACE thread function type. (void*)\n\n */\n\n ACE_THR_FUNC function_;\n\n /**\n\n * Developer-provided function args\n\n */\n\n void* functionArgs_;\n\n /**\n\n * Thread flags (from ace/OS_NS_Threads.h):\n\n * THR_CANCEL_DISABLE : Do not allow thread to cancelled\n\n * THR_CANCEL_ENABLE : Allow thread to be cancelled\n\n * THR_CANCEL_DEFERRED : Allow for deferred cancellation only\n\n * THR_CANCEL_ASYNCHRONOUS : Allow for asynchronous cancellation only\n\n * THR_DETACHED : Create a detached thread\n\n * THR_BOUND : Create a thread that is bound to a kernel-schedulable entity\n\n * THR_NEW_LWP : Create a kernel-level thread\n\n * THR_DAEMON : Create a daemon thread\n\n * THR_JOINABLE : Allow the new thread to be joined with\n\n * THR_SUSPENDED : Create the thread but keep the new thread in suspended state\n\n * THR_SCHED_FIFO : Schedule the new thread using the FIFO policy, if available\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 45, "score": 52826.1153742563 }, { "content": " */\n\n static ThreadManager* getInstance(ThreadParameters& threadParameters);\n\n\n\n /**\n\n * Static method that the thread 'actually' gets invoked with.\n\n * Thread parameters contains: string& threadName, bool shouldRestart, ACE_THR_FUNC function,\n\n * void *functionArgs\n\n */\n\n static ACE_THR_FUNC_RETURN runThread(ThreadParameters& threadParameters);\n\n\n\n /**\n\n * Static method lazily invoked to start the thread monitoring mechanism that checks\n\n * the restart map.\n\n */\n\n static void startThreadMonitor();\n\n\n\n /**\n\n * Static instance of the restart map. Upon receiving an OS Signal, the signal handler will\n\n * read all of the ThreadParameter structs from the map and restart them.\n\n */\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 46, "score": 52825.80220447263 }, { "content": "//\n\n// Inside each block, we declare class members in this order:\n\n// 1) nested classes (if applicable)\n\n// 2) static methods\n\n// 3) static data\n\n// 4) instance methods (constructors/destructors first)\n\n// 5) instance data\n\n//\n\n\n\n/**\n\n * ThreadManager wraps the ACE Thread mechanism in order to provide Thread\n\n * monitoring, Thread naming, and death detection and restart capabilities. \n\n * <p>\n\n * The main developer interface is the createThread() method, which returns\n\n * an OS-assigned unique thread Id. This thread id can be stored by the application\n\n * and used with the ACE_Thread_Manager class for suspending, resuming, waiting on,\n\n * or managing groups of threads (see ace/Thread_Manager.h).\n\n * <p>\n\n * In the case of createThreadPool(), a pointer to an array of ACE_Thread_t\n\n * Thread Ids is returned--one for each of the N threads.\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 47, "score": 52823.78214693659 }, { "content": " the key is the OS assigned unique thread Id */\n\n typedef map<unsigned long, ThreadParameters*, less<unsigned long> > ThreadsWaitingForRestartMap;\n\n\n\n /** Constructor */\n\n ThreadManager(ThreadParameters& threadParameters);\n\n\n\n /**\n\n * Copy Constructor declared private so that default automatic\n\n * methods aren't used.\n\n */\n\n ThreadManager(const ThreadManager& rhs);\n\n\n\n /**\n\n * Assignment operator declared private so that default automatic\n\n * methods aren't used.\n\n */\n\n ThreadManager& operator= (const ThreadManager& rhs);\n\n\n\n /**\n\n * Static method to generate a new, dynamic instance of the ACE_At_Thread_Exit\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 48, "score": 52822.71852097194 }, { "content": " static ThreadsWaitingForRestartMap restartMap_;\n\n\n\n /** Non-recursive Thread Mutex for controlling access to the map */\n\n static ACE_Thread_Mutex restartMapMutex_;\n\n\n\n /** Flag that indicates if the lazy initialization of the thread monitor has occurred yet */\n\n static bool isInitialized_;\n\n\n\n /** Thread Parameters structure member variable */\n\n ThreadParameters* threadParameters_;\n\n\n\n /**\n\n * OS assigned unique thread Id for the child thread\n\n */\n\n ACE_thread_t threadId_;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 49, "score": 52819.16912129345 }, { "content": "//-----------------------------------------------------------------------------\n\n\n\n#include <map>\n\n#include <string>\n\n\n\n#include <ace/Thread_Manager.h>\n\n#include <ace/Thread_Mutex.h>\n\n\n\nusing namespace std;\n\n\n\n//-----------------------------------------------------------------------------\n\n// Component includes, includes elements of our system.\n\n//-----------------------------------------------------------------------------\n\n\n\n//-----------------------------------------------------------------------------\n\n// Forward Declarations.\n\n//-----------------------------------------------------------------------------\n\n\n\n// For C++ class declarations, we have one (and only one) of these access \n\n// blocks per class in this order: public, protected, and then private.\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 50, "score": 52815.18561558506 }, { "content": "/******************************************************************************\n\n* \n\n* File name: ThreadManager.h \n\n* Subsystem: Platform Services \n\n* Description: Wraps the ACE Thread mechanism in order to provide Thread\n\n* monitoring, Thread naming, and death detection and restart\n\n* capabilities.\n\n* \n\n* Name Date Release \n\n* -------------------- ---------- ---------------------------------------------\n\n* Stephen Horton 01/01/2014 Initial release \n\n* \n\n*\n\n******************************************************************************/\n\n\n\n#ifndef _PLAT_PLATFORM_THREAD_H_\n\n#define _PLAT_PLATFORM_THREAD_H_\n\n\n\n//-----------------------------------------------------------------------------\n\n// System include files, includes 3rd party libraries.\n", "file_path": "src/platform/threadmgr/ThreadManager.h", "rank": 51, "score": 52814.65387067638 }, { "content": "/******************************************************************************\n\n* \n\n* File name: ThreadTest.h \n\n* Subsystem: Platform Services \n\n* Description: Unit Test for Thread Monitoring, Recovery and Restart\n\n* \n\n* Name Date Release \n\n* -------------------- ---------- ---------------------------------------------\n\n* Stephen Horton 01/01/2014 Initial release \n\n* \n\n*\n\n******************************************************************************/\n\n\n\n#ifndef _PLAT_THREAD_TEST_H_\n\n#define _PLAT_THREAD_TEST_H_\n\n\n\n//-----------------------------------------------------------------------------\n\n// System include files, includes 3rd party libraries.\n\n//-----------------------------------------------------------------------------\n\n\n", "file_path": "src/unittest/threadtest/ThreadTest.h", "rank": 52, "score": 52814.566553806195 }, { "content": "//-----------------------------------------------------------------------------\n\n// Component includes, includes elements of our system.\n\n//-----------------------------------------------------------------------------\n\n\n\n//-----------------------------------------------------------------------------\n\n// Forward Declarations.\n\n//-----------------------------------------------------------------------------\n\n\n\n// For C++ class declarations, we have one (and only one) of these access \n\n// blocks per class in this order: public, protected, and then private.\n\n//\n\n// Inside each block, we declare class members in this order:\n\n// 1) nested classes (if applicable)\n\n// 2) static methods\n\n// 3) static data\n\n// 4) instance methods (constructors/destructors first)\n\n// 5) instance data\n\n//\n\n\n\n/**\n\n * ThreadTest is the Unit Test for the Thread Monitoring, Recovery, and Restart\n\n * <p>\n\n * $Author: Stephen Horton$\n\n * $Revision: 1$\n\n */\n\n\n", "file_path": "src/unittest/threadtest/ThreadTest.h", "rank": 53, "score": 52813.33876210356 }, { "content": " * data structure (could be wrong pool, is already released, or was\n\n * not created via OPM)\n\n */\n\n virtual bool release(OPMBase* object, const char* callingFileName, int callingLineNumb);\n\n \n\n /** Return the current capacity of this pool */\n\n int getCurrentCapacity();\n\n\n\n /** Return the current number of Used Objects in this pool */\n\n int getCurrentUsedObjects();\n\n\n\n /** Return the object type String being held in this pool */\n\n const char* getObjectType();\n\n\n\n /** Return the capacity increment size for this pool */\n\n int getCapacityIncrement();\n\n\n\n /** Return the threshold percentage for this pool */\n\n double getThresholdPercentage();\n\n\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 54, "score": 52809.282172421415 }, { "content": "\n\n private:\n\n\n\n /**\n\n * Copy Constructor declared private so that default automatic\n\n * methods aren't used.\n\n */\n\n ThreadTest(const ThreadTest& rhs);\n\n\n\n /**\n\n * Assignment operator declared private so that default automatic\n\n * methods aren't used.\n\n */\n\n ThreadTest& operator= (const ThreadTest& rhs);\n\n\n\n};\n\n\n\n#endif\n", "file_path": "src/unittest/threadtest/ThreadTest.h", "rank": 55, "score": 52808.98282457939 }, { "content": " */\n\n ObjectPool(int objectPoolID,\n\n int initialCapacity, \n\n double thresholdPercentage,\n\n int capacityIncrement, \n\n const char* objectType, \n\n long objectInitParam,\n\n OPM_INIT_PTR bootStrapMethod, \n\n OPMGrowthModeType growthMode);\n\n\n\n /** Virtual Destructor */\n\n virtual ~ObjectPool();\n\n\n\n\n\n /**\n\n * Reserve an object for use, thus making it unavailable for other tasks. This\n\n * method automatically monitors the number of in-use objects and will grow\n\n * the pool when the number exceeds the threshold. If the object pool is specified\n\n * to be non-resizable, then an error will be displayed and NULL returned if\n\n * no available objects exist.\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 56, "score": 52804.95352977738 }, { "content": " */\n\n double thresholdPercentage_;\n\n\n\n /** Current size of the Object Pool */\n\n int currentCapacity_;\n\n\n\n /**\n\n * Total count of objects created by this Object Pool including initial\n\n * capacity and all objects created during periods of growth.\n\n */\n\n long creationCount_;\n\n\n\n /** Current number of objects in the Free List */\n\n int currentFreeObjects_;\n\n\n\n /** Current number of objects in the Used List */\n\n int currentUsedObjects_;\n\n\n\n /** Total of all objects used from this pool during runtime */\n\n long totalUsedObjects_;\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 57, "score": 52804.51190959929 }, { "content": " /** Return the initializer for the objects in this pool (if there is one) */\n\n long getObjectInitParam();\n\n \n\n /**\n\n * Method to test if this pool is empty\n\n * @return <tt>true</tt> if the Free List is empty<br>\n\n * <tt>false</tt> if the Free List is NOT empty\n\n */\n\n virtual bool isEmpty();\n\n\n\n /**\n\n * Method to check if a specified object is in the Free Linked List or the\n\n * Used Linked List. This method traverses both lists looking for pointer\n\n * equality.\n\n * @return <tt>true</tt> if the Object is in the list<br>\n\n * <tt>false</tt> if the Object is NOT in the list\n\n */\n\n virtual bool containsObject(OPMBase* object);\n\n\n\n /**\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 58, "score": 52800.88758044983 }, { "content": " * the reserve Method results in the number of reserved (in-use) objects increasing\n\n * past the threshold percentage of current total objects (if Growth allowed).\n\n */\n\n void autoIncreaseLists();\n\n\n\n /**\n\n * Method to automatically shrink the Free Linked List by deallocating objects\n\n * This method is called when the release Method results in the number of \n\n * reserved (in-use) objects decreasing below the previous threshold percentage\n\n * of previous total objects\n\n */\n\n void autoDecreaseLists();\n\n\n\n /** Initial Threshold between the initial capacity and its corresponding threshold value */\n\n int initialThreshold_;\n\n\n\n /** Object PoolID that identifies this object pool in the OPM */\n\n int objectPoolID_;\n\n\n\n /** \n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 59, "score": 52798.45972866737 }, { "content": " * Method to set or reset the capacity increment of this Object Pool\n\n * @param capacityIncrement The new capacity increment value\n\n */\n\n virtual void setCapacityIncrement(int capacityIncrement);\n\n\n\n /* Method prints the Object Usage Summary for this Object Pool if DEBUG logs are enabled */\n\n virtual void printUsageSummary();\n\n\n\n protected:\n\n\n\n /** Pool Increment Size which is the number of objects to add when growing */\n\n int capacityIncrement_;\n\n\n\n private:\n\n \n\n\n\n /** The number times that the Free Linked List has been enlarged to handle more objects */\n\n int numberEnlargements_;\n\n\n\n /** Object initializer for all objects in the pool (optional) */\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 60, "score": 52798.35702831573 }, { "content": " long objectInitParam_;\n\n\n\n /**\n\n * Int array for storing the capacity values for each enlargement. By default,\n\n * space for 30 increases (autoIncreaseFreeList) are preallocated\n\n */\n\n vector<int>* historicalCapacityArray_;\n\n\n\n /**\n\n * Previous threshold value for the last capacity increment -- used to check\n\n * when removing an object if autoDecreaseFreeList needs to be called\n\n */\n\n int previousThresholdCount_;\n\n\n\n /** Initial size of the pool in objects when the pool is created */\n\n int initialCapacity_;\n\n\n\n /**\n\n * Percentage of the current capacity at which an automatic capacity increase\n\n * is triggered \n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 61, "score": 52796.77785699286 }, { "content": " * @param blockWaitingForAccess If true, this method will block until an object\n\n * becomes available if they are all in use. Otherwise, if false, this method\n\n * will return NULL if all objects are in use. Note that this parameter is used\n\n * ONLY with SyncObjectPool. It has no meaning here, other than for inheritance.\n\n */\n\n virtual OPMBase* reserve(bool blockWaitingForAccess = true);\n\n\n\n\n\n /**\n\n * Release an object back into the pool after using it. This makes the\n\n * object available again for use in other tasks. This method automatically\n\n * monitors the number of in-use objects and will shrink the pool when the\n\n * number drops below the previous increment's threshold value.\n\n * @param object Object to release back into the pool.\n\n * @param callingFileName - Specifies the source file from which the object \n\n * is being released (this will be printed as a DEBUG log using a MACRO)\n\n * @param callingLineNumb - Specifies the source line from which the object \n\n * is being released (this will be printed as a DEBUG log using a MACRO)\n\n * @return <tt>true</tt> if the specified Object was successfully released<br>\n\n * <tt>false</tt> if the Object Reference was not found in the USED\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 62, "score": 52794.555162062745 }, { "content": "/******************************************************************************\n\n*\n\n* File name: ObjectPool.h\n\n* Subsystem: Platform Services\n\n* Description: Implements the Object Pool Class (not thread safe) that is the\n\n* container for the pooled objects.\n\n*\n\n* Name Date Release\n\n* -------------------- ---------- ---------------------------------------------\n\n* Stephen Horton 01/01/2014 Initial release\n\n*\n\n*\n\n******************************************************************************/\n\n\n\n#ifndef _PLAT_OBJECT_POOL_H_\n\n#define _PLAT_OBJECT_POOL_H_\n\n\n\n//-----------------------------------------------------------------------------\n\n// System include files, includes 3rd party libraries.\n\n//-----------------------------------------------------------------------------\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 63, "score": 52793.88497455112 }, { "content": "\n\n /** Peak number of used objects (at any one time) during runtime */\n\n int peakUsedObjects_;\n\n\n\n /** Indicates the type of the object stored in this pool */\n\n char* objectType_;\n\n\n\n /**\n\n * Linked list of OPMBase objects that are available for use - able to be reserved\n\n */\n\n OPMLinkedList* freeList_;\n\n\n\n /**\n\n * Linked list of OPMBase objects that are in use and will be eventually released\n\n */\n\n OPMLinkedList* usedList_;\n\n\n\n /**\n\n * Method to automatically grow the Free Linked List by instantiating more\n\n * objects based on the capacityIncrement_ value. This method is called when\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 64, "score": 52789.21952660232 }, { "content": "// Forward Declarations.\n\n//-----------------------------------------------------------------------------\n\n\n\n// For C++ class declarations, we have one (and only one) of these access \n\n// blocks per class in this order: public, protected, and then private.\n\n//\n\n// Inside each block, we declare class members in this order:\n\n// 1) nested classes (if applicable)\n\n// 2) static methods\n\n// 3) static data\n\n// 4) instance methods (constructors/destructors first)\n\n// 5) instance data\n\n\n\n/**\n\n * ObjectPool stores objects of a particular type in the OPM and keeps track\n\n * of which objects are free and which are in use.\n\n * <p>\n\n * Object pool contains methods for reserving and releasing pooled objects\n\n * and for manipulating the capacity increments of the data structures (pool\n\n * supports both growing and shrinking based on increment size), computing\n\n * the count of free objects, setting the threshold and increment values,\n\n * and performing cleanup.\n\n * <p>\n\n * This class is currently NOT THREAD SAFE.\n\n *\n\n * $Author: Stephen Horton$\n\n * $Revision: 1$\n\n */\n\n\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 65, "score": 52786.72623283969 }, { "content": " * Pointer to a function or method (OPMBase::initialize)\n\n * that will create the object and return a pointer to it to\n\n */\n\n OPM_INIT_PTR bootStrapMethod_;\n\n\n\n /** \n\n * Flag to determine if object pool is resizable or not and in what way (grow / shrink /\n\n * none / both).\n\n */\n\n OPMGrowthModeType growthMode_;\n\n};\n\n\n\n#endif\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 66, "score": 52786.49801620201 }, { "content": "\n\n#include <vector>\n\n\n\n//-----------------------------------------------------------------------------\n\n// Component includes, includes elements of our system.\n\n//-----------------------------------------------------------------------------\n\n\n\n#include \"OPM.h\"\n\n#include \"OPMBase.h\"\n\n#include \"OPMLinkedList.h\"\n\n\n\n#define OPM_DEFAULT_INITIAL_CAPACITY 10\n\n\n\n#define OPM_DEFAULT_CAPACITY_INCREMENT 10\n\n\n\n#define OPM_DEFAULT_THRESHOLD_PERCENTAGE .8\n\n\n\n#define OPM_MAX_RESIZES 100\n\n\n\n//-----------------------------------------------------------------------------\n", "file_path": "src/platform/opm/ObjectPool.h", "rank": 67, "score": 52783.73038912674 }, { "content": "// Method Type: INSTANCE\n\n// Description: Initialization\n\n// Design:\n\n//-----------------------------------------------------------------------------\n\nvoid ThreadTest::initialize()\n\n{\n\n // Here we assign a thread Group Id, so we can use ACE_Thread_Manager to wait on that group id\n\n ACE_thread_t threadId = ThreadManager::createThread((ACE_THR_FUNC)ThreadTest::performTests, 0, \"THREADTEST\", false,\n\n THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED/*Thread Characteristics*/, ACE_DEFAULT_THREAD_PRIORITY /*priority*/,\n\n 1 /*Arbitrary Thread Group Id*/);\n\n\n\n TRACELOG(DEBUGLOG, THREADLOG, \"Spawned ThreadTest thread with id %ul\", threadId,0,0,0,0,0);\n\n\n\n // Now wait on the first thread to complete\n\n if (ACE_Thread_Manager::instance()->wait_grp(1) == ERROR)\n\n {\n\n TRACELOG(ERRORLOG, THREADLOG, \"Waiting on thread group to complete failed\",0,0,0,0,0,0);\n\n }//end if\n\n\n\n TRACELOG(DEBUGLOG, THREADLOG, \"Preparing to Spawn Restart Thread test\",0,0,0,0,0,0);\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 75, "score": 51466.198457783124 }, { "content": "\n\n threadId = ThreadManager::createThread((ACE_THR_FUNC)ThreadTest::performRestartTests, 0, \"RESTARTTHREAD\", true);\n\n \n\n}//end initialize\n\n\n\n\n\n//-----------------------------------------------------------------------------\n\n// Method Type: STATIC\n\n// Description: Perform unit tests \n\n// Design:\n\n//-----------------------------------------------------------------------------\n\nvoid ThreadTest::performTests(void)\n\n{\n\n TRACELOG(DEBUGLOG, THREADLOG, \"Beginning test for spawning non-restarting thread\",0,0,0,0,0,0);\n\n\n\n int i;\n\n for (i = 0; i < 5; i++)\n\n {\n\n TRACELOG(DEBUGLOG, THREADLOG, \"Performing Thread Test, iteration %d\", i,0,0,0,0,0);\n\n sleep(2);\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 76, "score": 51463.74092107959 }, { "content": " }//end for\n\n}//end performTests\n\n\n\n\n\n//-----------------------------------------------------------------------------\n\n// Method Type: STATIC\n\n// Description: Perform unit tests for restarting threads\n\n// Design:\n\n//-----------------------------------------------------------------------------\n\nvoid ThreadTest::performRestartTests(void)\n\n{\n\n TRACELOG(DEBUGLOG, THREADLOG, \"Beginning test for spawning restarting thread\",0,0,0,0,0,0);\n\n\n\n int i;\n\n for (i = 0; i < 5; i++)\n\n {\n\n TRACELOG(DEBUGLOG, THREADLOG, \"Performing Thread Restarting Test, iteration %d\", i,0,0,0,0,0);\n\n sleep(2);\n\n }//end for\n\n}//end performRestartTests\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 82, "score": 51451.308759083 }, { "content": "{\n\n // do some dummy stuff on bufPtr to prevent compiler warning - this code will be\n\n // removed by the optimizer when it runs\n\n int tmpInt __attribute__ ((unused)) = argc;\n\n char** tmpChar __attribute__ ((unused)) = argv;\n\n\n\n // Turn of OS limits\n\n struct rlimit resourceLimit;\n\n resourceLimit.rlim_cur = RLIM_INFINITY;\n\n resourceLimit.rlim_max = RLIM_INFINITY;\n\n setrlimit(RLIMIT_CORE, &resourceLimit);\n\n\n\n // Initialize the Logger; Set the logger output to be local stdout/stderr\n\n Logger::getInstance()->initialize(true);\n\n\n\n // Turn on All relevant Subsystem logging levels\n\n Logger::setSubsystemLogLevel(THREADLOG, DEVELOPERLOG);\n\n\n\n ThreadTest* threadTest = new ThreadTest();\n\n if (!threadTest)\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 84, "score": 51450.906378274405 }, { "content": "#include <string>\n\n#include <sstream>\n\n#include <sys/resource.h>\n\n\n\n#include <ace/OS_NS_unistd.h>\n\n#include <ace/Thread_Manager.h>\n\n\n\nusing namespace std;\n\n\n\n//-----------------------------------------------------------------------------\n\n// Component includes, includes elements of our system.\n\n//-----------------------------------------------------------------------------\n\n\n\n#include \"ThreadTest.h\"\n\n\n\n#include \"platform/logger/Logger.h\"\n\n\n\n#include \"platform/common/Defines.h\"\n\n\n\n#include \"platform/threadmgr/ThreadManager.h\"\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 85, "score": 51446.86778135872 }, { "content": " {\n\n TRACELOG(ERRORLOG, THREADLOG, \"Could not create Thread Test instance\",0,0,0,0,0,0);\n\n return ERROR;\n\n }//end if\n\n\n\n threadTest->initialize();\n\n\n\n TRACELOG(DEBUGLOG, THREADLOG, \"Thread Test initialize returned\",0,0,0,0,0,0);\n\n\n\n // Use Thread_Manager to wait on all child threads, no matter what they are \n\n // associated with\n\n ACE_Thread_Manager::instance()->wait(); \n\n\n\n}//end main\n\n\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 86, "score": 51446.67510587669 }, { "content": "/******************************************************************************\n\n*\n\n* File name: ThreadTest.cpp\n\n* Subsystem: Platform Services\n\n* Description: Unit Tests for Thread Monitoring, Recovery, and Restart\n\n*\n\n* Name Date Release\n\n* -------------------- ---------- ---------------------------------------------\n\n* Stephen Horton 01/01/2014 Initial release\n\n*\n\n*\n\n******************************************************************************/\n\n\n\n\n\n//-----------------------------------------------------------------------------\n\n// System include files, includes 3rd party libraries.\n\n//-----------------------------------------------------------------------------\n\n\n\n#include <cstdlib>\n\n#include <iostream>\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 88, "score": 51441.459360512396 }, { "content": "\n\n//-----------------------------------------------------------------------------\n\n// Static Declarations.\n\n//-----------------------------------------------------------------------------\n\n\n\n/* From the C++ FAQ, create a module-level identification string using a compile\n\n define - BUILD_LABEL must have NO spaces passed in from the make command\n\n line */\n\n#define StrConvert(x) #x\n\n#define XstrConvert(x) StrConvert(x)\n\nstatic volatile char main_sccs_id[] __attribute__ ((unused)) = \"@(#)Thread Test\"\n\n \"\\n Build Label: \" XstrConvert(BUILD_LABEL)\n\n \"\\n Compile Time: \" __DATE__ \" \" __TIME__;\n\n\n\n//-----------------------------------------------------------------------------\n\n// PUBLIC methods.\n\n//-----------------------------------------------------------------------------\n\n\n\n\n\n//-----------------------------------------------------------------------------\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 89, "score": 51441.31761844576 }, { "content": "\n\n\n\n//-----------------------------------------------------------------------------\n\n// PROTECTED methods.\n\n//-----------------------------------------------------------------------------\n\n\n\n//-----------------------------------------------------------------------------\n\n// PRIVATE methods.\n\n//-----------------------------------------------------------------------------\n\n\n\n//-----------------------------------------------------------------------------\n\n// Nested Class Definitions:\n\n//-----------------------------------------------------------------------------\n\n\n\n//-----------------------------------------------------------------------------\n\n// Function Type: main function for test binary\n\n// Description:\n\n// Design:\n\n//-----------------------------------------------------------------------------\n\nint main(int argc, char* argv[])\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 90, "score": 51440.483825488365 }, { "content": " if (Logger::getSubsystemLogLevel(OPMLOG) == DEVELOPERLOG)\n\n {\n\n ostringstream ostr;\n\n ostr << \"OPM Object successfully reserved from Pool \" << objectType_\n\n << \" in Process (\" << getpid() << \")\" << ends;\n\n STRACELOG(DEBUGLOG, OPMLOG, ostr.str().c_str());\n\n }//end if\n\n return object;\n\n}//end reserve\n\n\n\n\n\n//-----------------------------------------------------------------------------\n\n// Method Type: INSTANCE\n\n// Description: Release an object back into the pool after using it. This makes\n\n// the object available again for use in other threads.\n\n// Design: This method automatically monitors the number of in-use objects\n\n// and will shrink the pool when the number drops below the\n\n// previous increment's threshold value.\n\n//-----------------------------------------------------------------------------\n\nbool ObjectPool::release(OPMBase* object, const char* callingFileName, int callingLineNumb)\n", "file_path": "src/platform/opm/ObjectPool.cpp", "rank": 96, "score": 51435.181308347215 }, { "content": "// Method Type: Constructor\n\n// Description: \n\n// Design: \n\n//-----------------------------------------------------------------------------\n\nThreadTest::ThreadTest()\n\n{\n\n}//end constructor\n\n\n\n\n\n//-----------------------------------------------------------------------------\n\n// Method Type: Virtual Destructor\n\n// Description: \n\n// Design: \n\n//-----------------------------------------------------------------------------\n\nThreadTest::~ThreadTest()\n\n{\n\n}//end virtual destructor\n\n\n\n\n\n//-----------------------------------------------------------------------------\n", "file_path": "src/unittest/threadtest/ThreadTest.cpp", "rank": 99, "score": 51430.95615531239 } ]
C++
fboss/agent/state/tests/NeighborTests.cpp
dgrnbrg-meta/fboss
cde5aa021fbb28e08cc912a7c227e93ed3faefee
#include <fboss/agent/state/ArpResponseEntry.h> #include "fboss/agent/test/TestUtils.h" #include "fboss/agent/state/ArpEntry.h" #include "fboss/agent/state/NdpEntry.h" #include "fboss/agent/state/NeighborEntry.h" #include "fboss/agent/state/NeighborResponseTable.h" #include "fboss/agent/state/Vlan.h" #include <gtest/gtest.h> namespace { auto constexpr kState = "state"; } using namespace facebook::fboss; using folly::IPAddressV4; using folly::IPAddressV6; using folly::MacAddress; template <typename NeighborEntryT> void serializeTest(const NeighborEntryT& entry) { auto serialized = entry.toFollyDynamic(); auto entryBack = NeighborEntryT::fromFollyDynamic(serialized); EXPECT_EQ(entry, *entryBack); } TEST(ArpEntry, serialize) { auto entry = std::make_unique<ArpEntry>( IPAddressV4("192.168.0.1"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(1)), InterfaceID(10)); validateThriftyMigration(*entry); serializeTest(*entry); } TEST(NdpEntry, serialize) { auto entry = std::make_unique<NdpEntry>( IPAddressV6("2401:db00:21:70cb:face:0:96:0"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(10)), InterfaceID(10)); validateThriftyMigration(*entry); serializeTest(*entry); } TEST(ArpTable, serialize) { ArpTable table; table.addEntry( IPAddressV4("192.168.0.1"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(10)), InterfaceID(10), NeighborState::REACHABLE); table.addEntry( IPAddressV4("192.168.0.2"), MacAddress("01:01:01:01:01:02"), PortDescriptor(PortID(11)), InterfaceID(11), NeighborState::PENDING); validateThriftyMigration(table); serializeTest(table); } TEST(NdpTable, serialize) { NdpTable table; table.addEntry( IPAddressV6("2401:db00:21:70cb:face:0:96:0"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(10)), InterfaceID(10), NeighborState::REACHABLE); table.addEntry( IPAddressV6("2401:db00:21:70cb:face:0:96:1"), MacAddress("01:01:01:01:01:02"), PortDescriptor(PortID(11)), InterfaceID(11), NeighborState::PENDING); validateThriftyMigration(table); serializeTest(table); } TEST(NeighborResponseEntry, serialize) { auto entry = std::make_unique<ArpResponseEntry>( IPAddressV4("192.168.0.1"), MacAddress("01:01:01:01:01:01"), InterfaceID(0)); auto serialized = entry->toFollyDynamic(); auto entryBack = ArpResponseEntry::fromFollyDynamic(serialized); EXPECT_TRUE(*entry == *entryBack); } TEST(NeighborResponseTableTest, modify) { auto ip1 = IPAddressV4("192.168.0.1"), ip2 = IPAddressV4("192.168.0.2"); auto mac1 = MacAddress("01:01:01:01:01:01"), mac2 = MacAddress("01:01:01:01:01:02"); auto state = std::make_shared<SwitchState>(); auto vlan = std::make_shared<Vlan>(VlanID(2001), "vlan1"); auto arpResponseTable = std::make_shared<ArpResponseTable>(); arpResponseTable->setEntry(ip1, mac1, InterfaceID(0)); vlan->setArpResponseTable(arpResponseTable); state->getVlans()->addVlan(vlan); EXPECT_EQ(vlan.get(), vlan->modify(&state)); arpResponseTable = std::make_shared<ArpResponseTable>(); arpResponseTable->setEntry(ip2, mac2, InterfaceID(1)); vlan->setArpResponseTable(arpResponseTable); EXPECT_EQ(vlan.get(), vlan->modify(&state)); vlan->publish(); auto modifiedVlan = vlan->modify(&state); arpResponseTable = std::make_shared<ArpResponseTable>(); arpResponseTable->setEntry(ip1, mac1, InterfaceID(0)); EXPECT_DEATH(vlan->setArpResponseTable(arpResponseTable), "!isPublished"); modifiedVlan->setArpResponseTable(arpResponseTable); EXPECT_NE(vlan.get(), modifiedVlan); EXPECT_FALSE(vlan->getArpResponseTable()->getEntry(ip1) != nullptr); EXPECT_TRUE(vlan->getArpResponseTable()->getEntry(ip2) != nullptr); EXPECT_TRUE(modifiedVlan->getArpResponseTable()->getEntry(ip1) != nullptr); EXPECT_FALSE(modifiedVlan->getArpResponseTable()->getEntry(ip2) != nullptr); }
#include <fboss/agent/state/ArpResponseEntry.h> #include "fboss/agent/test/TestUtils.h" #include "fboss/agent/state/ArpEntry.h" #include "fboss/agent/state/NdpEntry.h" #include "fboss/agent/state/NeighborEntry.h" #include "fboss/agent/state/NeighborResponseTable.h" #include "fboss/agent/state/Vlan.h" #include <gtest/gtest.h> namespace { auto constexpr kState = "state"; } using namespace facebook::fboss; using folly::IPAddressV4; using folly::IPAddressV6; using folly::MacAddress; template <typename NeighborEntryT> void serializeTest(const NeighborEntryT& entry) { auto serialized = entry.toFollyDynamic(); auto entryBack = NeighborEntryT::fromFollyDynamic(serialized); EXPECT_EQ(entry, *entryBack); } TEST(ArpEntry, serialize) { auto entry = std::make_unique<ArpEntry>( IPAddressV4("192.168.0.1"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(1)), InterfaceID(10)); validateThriftyMigration(*entry); serializeTest(*entry); } TEST(NdpEntry, serialize) { auto entry = std::make_unique<NdpEntry>( IPAddressV6("2401:db00:21:70cb:face:0:96:0"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(10)), InterfaceID(10)); validateThriftyMigration(*entry); serializeTest(*entry); }
TEST(NdpTable, serialize) { NdpTable table; table.addEntry( IPAddressV6("2401:db00:21:70cb:face:0:96:0"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(10)), InterfaceID(10), NeighborState::REACHABLE); table.addEntry( IPAddressV6("2401:db00:21:70cb:face:0:96:1"), MacAddress("01:01:01:01:01:02"), PortDescriptor(PortID(11)), InterfaceID(11), NeighborState::PENDING); validateThriftyMigration(table); serializeTest(table); } TEST(NeighborResponseEntry, serialize) { auto entry = std::make_unique<ArpResponseEntry>( IPAddressV4("192.168.0.1"), MacAddress("01:01:01:01:01:01"), InterfaceID(0)); auto serialized = entry->toFollyDynamic(); auto entryBack = ArpResponseEntry::fromFollyDynamic(serialized); EXPECT_TRUE(*entry == *entryBack); } TEST(NeighborResponseTableTest, modify) { auto ip1 = IPAddressV4("192.168.0.1"), ip2 = IPAddressV4("192.168.0.2"); auto mac1 = MacAddress("01:01:01:01:01:01"), mac2 = MacAddress("01:01:01:01:01:02"); auto state = std::make_shared<SwitchState>(); auto vlan = std::make_shared<Vlan>(VlanID(2001), "vlan1"); auto arpResponseTable = std::make_shared<ArpResponseTable>(); arpResponseTable->setEntry(ip1, mac1, InterfaceID(0)); vlan->setArpResponseTable(arpResponseTable); state->getVlans()->addVlan(vlan); EXPECT_EQ(vlan.get(), vlan->modify(&state)); arpResponseTable = std::make_shared<ArpResponseTable>(); arpResponseTable->setEntry(ip2, mac2, InterfaceID(1)); vlan->setArpResponseTable(arpResponseTable); EXPECT_EQ(vlan.get(), vlan->modify(&state)); vlan->publish(); auto modifiedVlan = vlan->modify(&state); arpResponseTable = std::make_shared<ArpResponseTable>(); arpResponseTable->setEntry(ip1, mac1, InterfaceID(0)); EXPECT_DEATH(vlan->setArpResponseTable(arpResponseTable), "!isPublished"); modifiedVlan->setArpResponseTable(arpResponseTable); EXPECT_NE(vlan.get(), modifiedVlan); EXPECT_FALSE(vlan->getArpResponseTable()->getEntry(ip1) != nullptr); EXPECT_TRUE(vlan->getArpResponseTable()->getEntry(ip2) != nullptr); EXPECT_TRUE(modifiedVlan->getArpResponseTable()->getEntry(ip1) != nullptr); EXPECT_FALSE(modifiedVlan->getArpResponseTable()->getEntry(ip2) != nullptr); }
TEST(ArpTable, serialize) { ArpTable table; table.addEntry( IPAddressV4("192.168.0.1"), MacAddress("01:01:01:01:01:01"), PortDescriptor(PortID(10)), InterfaceID(10), NeighborState::REACHABLE); table.addEntry( IPAddressV4("192.168.0.2"), MacAddress("01:01:01:01:01:02"), PortDescriptor(PortID(11)), InterfaceID(11), NeighborState::PENDING); validateThriftyMigration(table); serializeTest(table); }
function_block-full_function
[ { "content": "class MacEntry\n\n : public ThriftyBaseT<state::MacEntryFields, MacEntry, MacEntryFields> {\n\n public:\n\n MacEntry(\n\n folly::MacAddress mac,\n\n PortDescriptor portDescr,\n\n std::optional<cfg::AclLookupClass> classID = std::nullopt,\n\n MacEntryType type = MacEntryType::DYNAMIC_ENTRY)\n\n : ThriftyBaseT(mac, portDescr, classID, type) {}\n\n\n\n static std::shared_ptr<MacEntry> fromFollyDynamicLegacy(\n\n const folly::dynamic& json) {\n\n const auto& fields = MacEntryFields::fromFollyDynamicLegacy(json);\n\n return std::make_shared<MacEntry>(fields);\n\n }\n\n\n\n folly::dynamic toFollyDynamicLegacy() const {\n\n return getFields()->toFollyDynamicLegacy();\n\n }\n\n\n", "file_path": "fboss/agent/state/MacEntry.h", "rank": 0, "score": 157707.96097440645 }, { "content": "class AclEntry\n\n : public ThriftyBaseT<state::AclEntryFields, AclEntry, AclEntryFields> {\n\n public:\n\n explicit AclEntry(int priority, const std::string& name);\n\n\n\n int getPriority() const {\n\n return getFields()->priority;\n\n }\n\n\n\n const std::string& getID() const {\n\n return getFields()->name;\n\n }\n\n\n\n const std::optional<MatchAction> getAclAction() const {\n\n return getFields()->aclAction;\n\n }\n\n\n\n void setAclAction(const MatchAction& action) {\n\n writableFields()->aclAction = action;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 1, "score": 157707.96097440645 }, { "content": "enum class MacEntryType : uint8_t { DYNAMIC_ENTRY, STATIC_ENTRY };\n\n\n", "file_path": "fboss/agent/state/MacEntry.h", "rank": 2, "score": 152672.07777829331 }, { "content": "class ArpResponseEntry\n\n : public NeighborResponseEntry<folly::IPAddressV4, ArpResponseEntry> {\n\n public:\n\n using NeighborResponseEntry::NeighborResponseEntry;\n\n};\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/ArpResponseEntry.h", "rank": 3, "score": 151288.78550241666 }, { "content": "class NdpResponseEntry\n\n : public NeighborResponseEntry<folly::IPAddressV6, NdpResponseEntry> {\n\n public:\n\n using NeighborResponseEntry::NeighborResponseEntry;\n\n};\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/NdpResponseEntry.h", "rank": 4, "score": 151288.78550241666 }, { "content": "class NdpEntry : public NeighborEntry<folly::IPAddressV6, NdpEntry> {\n\n public:\n\n using NeighborEntry::NeighborEntry;\n\n};\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/NdpEntry.h", "rank": 5, "score": 148467.57613837515 }, { "content": "class ArpEntry : public NeighborEntry<folly::IPAddressV4, ArpEntry> {\n\n public:\n\n using NeighborEntry::NeighborEntry;\n\n};\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/ArpEntry.h", "rank": 6, "score": 148467.57613837515 }, { "content": " NeighborState pending)\n\n : NeighborEntryFields(\n\n ip,\n\n MacAddress::BROADCAST,\n\n PortDescriptor(PortID(0)),\n\n interfaceID,\n\n pending) {\n\n // This constructor should only be used for PENDING entries\n\n CHECK(pending == NeighborState::PENDING);\n\n }\n\n\n\n template <typename Fn>\n\n void forEachChild(Fn /*fn*/) {}\n\n\n\n state::NeighborEntryFields toThrift() const {\n\n state::NeighborEntryFields entryTh;\n\n entryTh.ipaddress_ref() = ip.str();\n\n entryTh.mac_ref() = mac.toString();\n\n entryTh.portId_ref() = port.toThrift();\n\n entryTh.interfaceId_ref() = static_cast<uint32_t>(interfaceID);\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 7, "score": 148367.39989212574 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include <folly/IPAddressV6.h>\n\n#include \"fboss/agent/state/NeighborEntry.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\n/*\n\n * NdpEntry represents an entry in our IPv6 neighbor table.\n\n *\n\n * Note that we define NdpEntry as its own class here rather than using a\n\n * typedef purely to make it easier for other classes to forward declare\n\n * NdpEntry.\n\n */\n", "file_path": "fboss/agent/state/NdpEntry.h", "rank": 8, "score": 148365.28497329488 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include <folly/IPAddressV4.h>\n\n#include \"fboss/agent/state/NeighborEntry.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\n/*\n\n * ArpEntry represents an entry in our IPv4 neighbor table.\n\n *\n\n * Note that we define ArpEntry as its own class here rather than using a\n\n * typedef purely to make it easier for other classes to forward declare\n\n * ArpEntry.\n\n */\n", "file_path": "fboss/agent/state/ArpEntry.h", "rank": 9, "score": 148365.28497329488 }, { "content": " state::NeighborEntryFields,\n\n SUBCLASS,\n\n NeighborEntryFields<IPADDR>>\n\n Parent;\n\n // Inherit the constructors required for clone()\n\n using Parent::Parent;\n\n friend class CloneAllocator;\n\n};\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 10, "score": 148364.53895173973 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include <folly/MacAddress.h>\n\n#include \"fboss/agent/gen-cpp2/switch_config_types.h\"\n\n#include \"fboss/agent/gen-cpp2/switch_state_types.h\"\n\n#include \"fboss/agent/state/NodeBase.h\"\n\n#include \"fboss/agent/state/PortDescriptor.h\"\n\n#include \"fboss/agent/state/Thrifty.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\nusing folly::MacAddress;\n\n\n\n// TODO: remove this in favor of state::NeighborState in switch_state.thrift\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 11, "score": 148362.14894726285 }, { "content": " entryTh.state_ref() = static_cast<state::NeighborState>(state);\n\n if (classID.has_value()) {\n\n entryTh.classID_ref() = classID.value();\n\n }\n\n return entryTh;\n\n }\n\n\n\n static NeighborEntryFields fromThrift(\n\n state::NeighborEntryFields const& entryTh) {\n\n IPADDR ip(entryTh.get_ipaddress());\n\n folly::MacAddress mac(entryTh.get_mac());\n\n auto port = PortDescriptor::fromThrift(entryTh.get_portId());\n\n InterfaceID intf(entryTh.get_interfaceId());\n\n auto state = NeighborState(static_cast<int>(entryTh.get_state()));\n\n\n\n if (entryTh.classID_ref().has_value() && !ip.isLinkLocal()) {\n\n return NeighborEntryFields(\n\n ip, mac, port, intf, state, *entryTh.classID_ref());\n\n } else {\n\n return NeighborEntryFields(ip, mac, port, intf, state);\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 12, "score": 148361.08136840252 }, { "content": " writableFields()->portDescr_ = portDescr;\n\n }\n\n\n\n MacEntryType getType() const {\n\n return getFields()->type_;\n\n }\n\n\n\n void setType(MacEntryType type) {\n\n writableFields()->type_ = type;\n\n }\n\n\n\n std::string str() const;\n\n\n\n private:\n\n // Inherit the constructors required for clone()\n\n using ThriftyBaseT::ThriftyBaseT;\n\n friend class CloneAllocator;\n\n};\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/MacEntry.h", "rank": 13, "score": 148360.27908586577 }, { "content": " }\n\n }\n\n\n\n /*\n\n * Serialize to folly::dynamic\n\n */\n\n folly::dynamic toFollyDynamicLegacy() const;\n\n\n\n /*\n\n * Deserialize from folly::dynamic\n\n */\n\n static NeighborEntryFields fromFollyDynamicLegacy(\n\n const folly::dynamic& entryJson);\n\n\n\n AddressType ip;\n\n folly::MacAddress mac;\n\n PortDescriptor port;\n\n InterfaceID interfaceID;\n\n NeighborState state;\n\n std::optional<cfg::AclLookupClass> classID{std::nullopt};\n\n};\n\n\n\ntemplate <typename IPADDR, typename SUBCLASS>\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 14, "score": 148360.26726553033 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include \"fboss/agent/FbossError.h\"\n\n#include \"fboss/agent/gen-cpp2/switch_config_types.h\"\n\n#include \"fboss/agent/gen-cpp2/switch_state_types.h\"\n\n#include \"fboss/agent/state/NodeBase.h\"\n\n#include \"fboss/agent/state/PortDescriptor.h\"\n\n#include \"fboss/agent/state/Thrifty.h\"\n\n#include \"fboss/agent/types.h\"\n\n\n\n#include <folly/MacAddress.h>\n\n#include <optional>\n\n#include <string>\n\n#include <tuple>\n\n#include <utility>\n\n\n\nnamespace facebook::fboss {\n\n\n", "file_path": "fboss/agent/state/MacEntry.h", "rank": 15, "score": 148357.88445449376 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include \"fboss/agent/FbossError.h\"\n\n#include \"fboss/agent/gen-cpp2/switch_config_types.h\"\n\n#include \"fboss/agent/state/MatchAction.h\"\n\n#include \"fboss/agent/state/NodeBase.h\"\n\n#include \"fboss/agent/state/Thrifty.h\"\n\n#include \"fboss/agent/types.h\"\n\n\n\n#include <folly/IPAddress.h>\n\n#include <folly/MacAddress.h>\n\n#include <optional>\n\n#include <string>\n\n#include <utility>\n\n\n\nnamespace facebook::fboss {\n\n\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 16, "score": 148357.41365887754 }, { "content": " getL4SrcPort() || getL4DstPort() || getLookupClassL2() ||\n\n getLookupClassNeighbor() || getLookupClassRoute() ||\n\n getPacketLookupResult() || getEtherType() || getVlanID();\n\n }\n\n\n\n std::set<cfg::AclTableQualifier> getRequiredAclTableQualifiers() const;\n\n\n\n AclEntry* modify(std::shared_ptr<SwitchState>* state);\n\n\n\n private:\n\n // Inherit the constructors required for clone()\n\n using ThriftyBaseT::ThriftyBaseT;\n\n friend class CloneAllocator;\n\n};\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 17, "score": 148356.01784282082 }, { "content": " void setPending() {\n\n this->writableFields()->state = NeighborState::PENDING;\n\n }\n\n\n\n bool isReachable() const {\n\n return this->getFields()->state == NeighborState::REACHABLE;\n\n }\n\n\n\n std::optional<cfg::AclLookupClass> getClassID() const {\n\n return this->getFields()->classID;\n\n }\n\n\n\n void setClassID(std::optional<cfg::AclLookupClass> classID = std::nullopt) {\n\n this->writableFields()->classID = classID;\n\n }\n\n\n\n std::string str() const;\n\n\n\n private:\n\n typedef ThriftyBaseT<\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 18, "score": 148351.8509428352 }, { "content": " }\n\n bool zeroPort() const {\n\n return !nonZeroPort();\n\n }\n\n\n\n InterfaceID getIntfID() const {\n\n return this->getFields()->interfaceID;\n\n }\n\n void setIntfID(InterfaceID id) {\n\n this->writableFields()->interfaceID = id;\n\n }\n\n\n\n NeighborState setState(NeighborState state) {\n\n return this->writableFields()->state = state;\n\n }\n\n\n\n bool isPending() const {\n\n return this->getFields()->state == NeighborState::PENDING;\n\n }\n\n\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 19, "score": 148351.69484958946 }, { "content": " folly::MacAddress getMac() const {\n\n return this->getFields()->mac;\n\n }\n\n void setMAC(folly::MacAddress mac) {\n\n this->writableFields()->mac = mac;\n\n }\n\n\n\n void setPort(PortDescriptor port) {\n\n this->writableFields()->port = port;\n\n }\n\n PortDescriptor getPort() const {\n\n return this->getFields()->port;\n\n }\n\n\n\n NeighborState getState() const {\n\n return this->getFields()->state;\n\n }\n\n\n\n bool nonZeroPort() const {\n\n return getPort() != PortID(0);\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 20, "score": 148351.33983231866 }, { "content": " bool operator==(const MacEntry& macEntry) const {\n\n return getFields()->mac_ == macEntry.getMac() &&\n\n getFields()->portDescr_ == macEntry.getPort() &&\n\n getFields()->classID_ == macEntry.getClassID() &&\n\n getFields()->type_ == macEntry.getType();\n\n }\n\n\n\n bool operator!=(const MacEntry& other) const {\n\n return !(*this == other);\n\n }\n\n\n\n folly::MacAddress getMac() const {\n\n return getFields()->mac_;\n\n }\n\n\n\n void setMac(folly::MacAddress mac) {\n\n this->writableFields()->mac_ = mac;\n\n }\n\n\n\n PortDescriptor getPort() const {\n", "file_path": "fboss/agent/state/MacEntry.h", "rank": 21, "score": 148350.3706055049 }, { "content": " return std::make_shared<SUBCLASS>(fields);\n\n }\n\n\n\n folly::dynamic toFollyDynamicLegacy() const {\n\n return this->getFields()->toFollyDynamicLegacy();\n\n }\n\n\n\n bool operator==(const NeighborEntry& other) const {\n\n return getIP() == other.getIP() && getMac() == other.getMac() &&\n\n getPort() == other.getPort() && getIntfID() == other.getIntfID() &&\n\n getState() == other.getState() && getClassID() == other.getClassID();\n\n }\n\n bool operator!=(const NeighborEntry& other) const {\n\n return !operator==(other);\n\n }\n\n\n\n AddressType getIP() const {\n\n return this->getFields()->ip;\n\n }\n\n\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 22, "score": 148349.7348476856 }, { "content": " }\n\n\n\n AclTtl& operator=(const AclTtl& ttl) {\n\n value_ = ttl.value_;\n\n mask_ = ttl.mask_;\n\n return *this;\n\n }\n\n\n\n state::AclTtl toThrift() const;\n\n static AclTtl fromThrift(state::AclTtl const& entry);\n\n\n\n folly::dynamic toFollyDynamic() const;\n\n static AclTtl fromFollyDynamic(const folly::dynamic& ttlJson);\n\n\n\n private:\n\n uint16_t value_;\n\n uint16_t mask_;\n\n};\n\n\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 23, "score": 148349.2182612503 }, { "content": " std::optional<uint32_t> vlanID{std::nullopt};\n\n std::optional<cfg::EtherType> etherType{std::nullopt};\n\n cfg::AclActionType actionType{cfg::AclActionType::PERMIT};\n\n std::optional<MatchAction> aclAction{std::nullopt};\n\n};\n\n\n\n/*\n\n * AclEntry stores state about one of the access control entries on\n\n * the switch.\n\n */\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 24, "score": 148348.93339346204 }, { "content": "\n\n void setIpFrag(const cfg::IpFragMatch& frag) {\n\n writableFields()->ipFrag = frag;\n\n }\n\n\n\n std::optional<uint8_t> getIcmpCode() const {\n\n return getFields()->icmpCode;\n\n }\n\n\n\n void setIcmpCode(const uint8_t code) {\n\n writableFields()->icmpCode = code;\n\n }\n\n\n\n std::optional<uint8_t> getIcmpType() const {\n\n return getFields()->icmpType;\n\n }\n\n\n\n void setIcmpType(const uint8_t type) {\n\n writableFields()->icmpType = type;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 25, "score": 148344.19462941072 }, { "content": " return getFields()->portDescr_;\n\n }\n\n\n\n void setPort(PortDescriptor portDescr) {\n\n this->writableFields()->portDescr_ = portDescr;\n\n }\n\n\n\n std::optional<cfg::AclLookupClass> getClassID() const {\n\n return getFields()->classID_;\n\n }\n\n\n\n void setClassID(std::optional<cfg::AclLookupClass> classID = std::nullopt) {\n\n this->writableFields()->classID_ = classID;\n\n }\n\n\n\n folly::MacAddress getID() const {\n\n return getMac();\n\n }\n\n\n\n void setPortDescriptor(PortDescriptor portDescr) {\n", "file_path": "fboss/agent/state/MacEntry.h", "rank": 26, "score": 148343.95330203735 }, { "content": "\n\n void setDstIp(const folly::CIDRNetwork& ip) {\n\n writableFields()->dstIp = ip;\n\n }\n\n\n\n std::optional<uint8_t> getProto() const {\n\n return getFields()->proto;\n\n }\n\n\n\n void setProto(const uint8_t proto) {\n\n writableFields()->proto = proto;\n\n }\n\n\n\n std::optional<uint8_t> getTcpFlagsBitMap() const {\n\n return getFields()->tcpFlagsBitMap;\n\n }\n\n\n\n void setTcpFlagsBitMap(const uint8_t flagsBitMap) {\n\n writableFields()->tcpFlagsBitMap = flagsBitMap;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 27, "score": 148343.88700808078 }, { "content": "\n\n void setTtl(const AclTtl& ttl) {\n\n writableFields()->ttl = ttl;\n\n }\n\n\n\n std::optional<cfg::EtherType> getEtherType() const {\n\n return getFields()->etherType;\n\n }\n\n\n\n void setEtherType(cfg::EtherType etherType) {\n\n writableFields()->etherType = etherType;\n\n }\n\n\n\n std::optional<folly::MacAddress> getDstMac() const {\n\n return getFields()->dstMac;\n\n }\n\n\n\n void setDstMac(const folly::MacAddress& dstMac) {\n\n writableFields()->dstMac = dstMac;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 28, "score": 148343.85428501366 }, { "content": "\n\n std::optional<uint8_t> getDscp() const {\n\n return getFields()->dscp;\n\n }\n\n\n\n void setDscp(uint8_t dscp) {\n\n writableFields()->dscp = dscp;\n\n }\n\n\n\n std::optional<cfg::IpType> getIpType() const {\n\n return getFields()->ipType;\n\n }\n\n\n\n void setIpType(const cfg::IpType& ipType) {\n\n writableFields()->ipType = ipType;\n\n }\n\n\n\n std::optional<AclTtl> getTtl() const {\n\n return getFields()->ttl;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 29, "score": 148343.16493365698 }, { "content": "\n\n std::optional<uint16_t> getSrcPort() const {\n\n return getFields()->srcPort;\n\n }\n\n\n\n void setSrcPort(const uint16_t port) {\n\n writableFields()->srcPort = port;\n\n }\n\n\n\n std::optional<uint16_t> getDstPort() const {\n\n return getFields()->dstPort;\n\n }\n\n\n\n void setDstPort(const uint16_t port) {\n\n writableFields()->dstPort = port;\n\n }\n\n\n\n std::optional<cfg::IpFragMatch> getIpFrag() const {\n\n return getFields()->ipFrag;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 30, "score": 148343.08495047968 }, { "content": "\n\n cfg::AclActionType getActionType() const {\n\n return getFields()->actionType;\n\n }\n\n\n\n void setActionType(const cfg::AclActionType& actionType) {\n\n writableFields()->actionType = actionType;\n\n }\n\n\n\n folly::CIDRNetwork getSrcIp() const {\n\n return getFields()->srcIp;\n\n }\n\n\n\n void setSrcIp(const folly::CIDRNetwork& ip) {\n\n writableFields()->srcIp = ip;\n\n }\n\n\n\n folly::CIDRNetwork getDstIp() const {\n\n return getFields()->dstIp;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 31, "score": 148342.89281697935 }, { "content": "\n\n std::optional<uint16_t> getL4SrcPort() const {\n\n return getFields()->l4SrcPort;\n\n }\n\n\n\n void setL4SrcPort(const uint16_t port) {\n\n writableFields()->l4SrcPort = port;\n\n }\n\n\n\n std::optional<uint16_t> getL4DstPort() const {\n\n return getFields()->l4DstPort;\n\n }\n\n\n\n void setL4DstPort(const uint16_t port) {\n\n writableFields()->l4DstPort = port;\n\n }\n\n\n\n std::optional<cfg::AclLookupClass> getLookupClassL2() const {\n\n return getFields()->lookupClassL2;\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 32, "score": 148342.71113182858 }, { "content": " void setLookupClassL2(const cfg::AclLookupClass& lookupClassL2) {\n\n writableFields()->lookupClassL2 = lookupClassL2;\n\n }\n\n\n\n std::optional<cfg::AclLookupClass> getLookupClassNeighbor() const {\n\n return getFields()->lookupClassNeighbor;\n\n }\n\n void setLookupClassNeighbor(const cfg::AclLookupClass& lookupClassNeighbor) {\n\n writableFields()->lookupClassNeighbor = lookupClassNeighbor;\n\n }\n\n\n\n std::optional<cfg::AclLookupClass> getLookupClassRoute() const {\n\n return getFields()->lookupClassRoute;\n\n }\n\n void setLookupClassRoute(const cfg::AclLookupClass& lookupClassRoute) {\n\n writableFields()->lookupClassRoute = lookupClassRoute;\n\n }\n\n\n\n std::optional<cfg::PacketLookupResultType> getPacketLookupResult() const {\n\n return getFields()->packetLookupResult;\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 33, "score": 148342.69359011413 }, { "content": " }\n\n\n\n void setPacketLookupResult(\n\n const cfg::PacketLookupResultType packetLookupResult) {\n\n writableFields()->packetLookupResult = packetLookupResult;\n\n }\n\n\n\n std::optional<uint32_t> getVlanID() const {\n\n return getFields()->vlanID;\n\n }\n\n\n\n void setVlanID(uint32_t vlanID) {\n\n writableFields()->vlanID = vlanID;\n\n }\n\n\n\n bool hasMatcher() const {\n\n // at least one qualifier must be specified\n\n return getSrcIp().first || getDstIp().first || getProto() ||\n\n getTcpFlagsBitMap() || getSrcPort() || getDstPort() || getIpFrag() ||\n\n getIcmpType() || getDscp() || getIpType() || getTtl() || getDstMac() ||\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 34, "score": 148341.9884894074 }, { "content": "\n\n bool operator==(const AclEntryFields& acl) const {\n\n return priority == acl.priority && name == acl.name &&\n\n actionType == acl.actionType && aclAction == acl.aclAction &&\n\n srcIp == acl.srcIp && dstIp == acl.dstIp && proto == acl.proto &&\n\n tcpFlagsBitMap == acl.tcpFlagsBitMap && srcPort == acl.srcPort &&\n\n dstPort == acl.dstPort && ipFrag == acl.ipFrag &&\n\n icmpType == acl.icmpType && icmpCode == acl.icmpCode &&\n\n dscp == acl.dscp && dstMac == acl.dstMac && ipType == acl.ipType &&\n\n ttl == acl.ttl && l4SrcPort == acl.l4SrcPort &&\n\n l4DstPort == acl.l4DstPort && lookupClassL2 == acl.lookupClassL2 &&\n\n lookupClassNeighbor == acl.lookupClassNeighbor &&\n\n lookupClassRoute == acl.lookupClassRoute &&\n\n packetLookupResult == acl.packetLookupResult &&\n\n etherType == acl.etherType && vlanID == acl.vlanID;\n\n }\n\n\n\n static void checkFollyDynamic(const folly::dynamic& json);\n\n int priority{0};\n\n std::string name{nullptr};\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 35, "score": 148341.69227467684 }, { "content": " value_ = value;\n\n }\n\n\n\n uint16_t getMask() const {\n\n return mask_;\n\n }\n\n\n\n void setMask(uint16_t mask) {\n\n if (mask > 255) {\n\n throw FbossError(\"ttl mask is invalid (must be [0,255])\");\n\n }\n\n mask_ = mask;\n\n }\n\n\n\n bool operator<(const AclTtl& ttl) const {\n\n return std::tie(value_, mask_) < std::tie(ttl.value_, ttl.mask_);\n\n }\n\n\n\n bool operator==(const AclTtl& ttl) const {\n\n return std::tie(value_, mask_) == std::tie(ttl.value_, ttl.mask_);\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 36, "score": 148341.3104613151 }, { "content": " folly::CIDRNetwork srcIp{std::make_pair(folly::IPAddress(), 0)};\n\n folly::CIDRNetwork dstIp{std::make_pair(folly::IPAddress(), 0)};\n\n std::optional<uint8_t> proto{std::nullopt};\n\n std::optional<uint8_t> tcpFlagsBitMap{std::nullopt};\n\n std::optional<uint16_t> srcPort{std::nullopt};\n\n std::optional<uint16_t> dstPort{std::nullopt};\n\n std::optional<cfg::IpFragMatch> ipFrag{std::nullopt};\n\n std::optional<uint8_t> icmpType{std::nullopt};\n\n std::optional<uint8_t> icmpCode{std::nullopt};\n\n std::optional<uint8_t> dscp{std::nullopt};\n\n std::optional<cfg::IpType> ipType{std::nullopt};\n\n std::optional<AclTtl> ttl{std::nullopt};\n\n std::optional<folly::MacAddress> dstMac{std::nullopt};\n\n std::optional<uint16_t> l4SrcPort{std::nullopt};\n\n std::optional<uint16_t> l4DstPort{std::nullopt};\n\n std::optional<cfg::AclLookupClass> lookupClassL2{std::nullopt};\n\n std::optional<cfg::AclLookupClass> lookupClass{std::nullopt};\n\n std::optional<cfg::AclLookupClass> lookupClassNeighbor{std::nullopt};\n\n std::optional<cfg::AclLookupClass> lookupClassRoute{std::nullopt};\n\n std::optional<cfg::PacketLookupResultType> packetLookupResult{std::nullopt};\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 37, "score": 148336.2108422457 }, { "content": "enum class NeighborEntryState : uint8_t {\n\n UNINITIALIZED,\n\n INCOMPLETE,\n\n DELAY,\n\n PROBE,\n\n STALE,\n\n REACHABLE,\n\n EXPIRED,\n\n};\n\n\n\ntemplate <typename NTable>\n", "file_path": "fboss/agent/NeighborCacheEntry.h", "rank": 38, "score": 148280.7374760374 }, { "content": "struct MacEntryFields : public ThriftyFields {\n\n MacEntryFields(\n\n folly::MacAddress mac,\n\n PortDescriptor portDescr,\n\n std::optional<cfg::AclLookupClass> classID = std::nullopt,\n\n MacEntryType type = MacEntryType::DYNAMIC_ENTRY)\n\n : mac_(mac), portDescr_(portDescr), classID_(classID), type_(type) {}\n\n\n\n template <typename Fn>\n\n void forEachChild(Fn) {}\n\n\n\n state::MacEntryFields toThrift() const;\n\n static MacEntryFields fromThrift(state::MacEntryFields const& ma);\n\n\n\n folly::dynamic toFollyDynamicLegacy() const;\n\n static MacEntryFields fromFollyDynamicLegacy(const folly::dynamic& json);\n\n\n\n folly::MacAddress mac_;\n\n PortDescriptor portDescr_;\n\n std::optional<cfg::AclLookupClass> classID_{std::nullopt};\n\n MacEntryType type_{MacEntryType::DYNAMIC_ENTRY};\n\n};\n\n\n", "file_path": "fboss/agent/state/MacEntry.h", "rank": 39, "score": 145395.556930134 }, { "content": "class RouteNextHopEntry {\n\n public:\n\n using Action = RouteForwardAction;\n\n using NextHopSet = boost::container::flat_set<NextHop>;\n\n\n\n RouteNextHopEntry(\n\n Action action,\n\n AdminDistance distance,\n\n std::optional<RouteCounterID> counterID = std::nullopt)\n\n : adminDistance_(distance), action_(action), counterID_(counterID) {\n\n CHECK_NE(action_, Action::NEXTHOPS);\n\n }\n\n\n\n RouteNextHopEntry(\n\n NextHopSet nhopSet,\n\n AdminDistance distance,\n\n std::optional<RouteCounterID> counterID = std::nullopt);\n\n\n\n RouteNextHopEntry(\n\n NextHop nhop,\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 40, "score": 145395.556930134 }, { "content": "struct NeighborEntryFields : public ThriftyFields {\n\n typedef IPADDR AddressType;\n\n\n\n NeighborEntryFields(\n\n AddressType ip,\n\n folly::MacAddress mac,\n\n PortDescriptor port,\n\n InterfaceID interfaceID,\n\n NeighborState state = NeighborState::REACHABLE,\n\n std::optional<cfg::AclLookupClass> classID = std::nullopt)\n\n : ip(ip),\n\n mac(mac),\n\n port(port),\n\n interfaceID(interfaceID),\n\n state(state),\n\n classID(classID) {}\n\n\n\n NeighborEntryFields(\n\n AddressType ip,\n\n InterfaceID interfaceID,\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 41, "score": 145395.556930134 }, { "content": "class NeighborEntry : public ThriftyBaseT<\n\n state::NeighborEntryFields,\n\n SUBCLASS,\n\n NeighborEntryFields<IPADDR>> {\n\n public:\n\n typedef IPADDR AddressType;\n\n\n\n NeighborEntry(\n\n AddressType ip,\n\n folly::MacAddress mac,\n\n PortDescriptor port,\n\n InterfaceID interfaceID,\n\n NeighborState state = NeighborState::REACHABLE);\n\n\n\n NeighborEntry(AddressType ip, InterfaceID intfID, NeighborState ignored);\n\n\n\n static std::shared_ptr<SUBCLASS> fromFollyDynamicLegacy(\n\n const folly::dynamic& json) {\n\n const auto& fields =\n\n NeighborEntryFields<IPADDR>::fromFollyDynamicLegacy(json);\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 42, "score": 145395.556930134 }, { "content": "struct AclEntryFields : public ThriftyFields {\n\n static const uint8_t kProtoIcmp = 1;\n\n static const uint8_t kProtoIcmpv6 = 58;\n\n static const uint8_t kMaxIcmpType = 0xFF;\n\n static const uint8_t kMaxIcmpCode = 0xFF;\n\n static const uint16_t kMaxL4Port = 65535;\n\n\n\n explicit AclEntryFields(int priority, const std::string& name)\n\n : priority(priority), name(name) {}\n\n\n\n template <typename Fn>\n\n void forEachChild(Fn) {}\n\n\n\n state::AclEntryFields toThrift() const;\n\n static AclEntryFields fromThrift(state::AclEntryFields const& ma);\n\n static folly::dynamic migrateToThrifty(folly::dynamic const& dyn);\n\n static void migrateFromThrifty(folly::dynamic& dyn);\n\n\n\n folly::dynamic toFollyDynamicLegacy() const;\n\n static AclEntryFields fromFollyDynamicLegacy(const folly::dynamic& json);\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 43, "score": 145395.556930134 }, { "content": "// TODO: remove this in favor of state::NeighborState in switch_state.thrift\n\nenum class NeighborState { UNVERIFIED, PENDING, REACHABLE };\n\n\n\ntemplate <typename IPADDR>\n", "file_path": "fboss/agent/state/NeighborEntry.h", "rank": 44, "score": 145384.48773240836 }, { "content": " return this->getFields()->mac;\n\n }\n\n\n\n void setMac(folly::MacAddress mac) {\n\n this->writableFields()->mac = mac;\n\n }\n\n\n\n InterfaceID getInterfaceID() const {\n\n return this->getFields()->interfaceID;\n\n }\n\n\n\n void setInterfaceID(InterfaceID interface) {\n\n this->writableFields()->interfaceID = interface;\n\n }\n\n\n\n private:\n\n using Parent = ThriftyBaseT<\n\n state::NeighborResponseEntryFields,\n\n SUBCLASS,\n\n NeighborResponseEntryFields<IPADDR>>;\n\n using Parent::Parent;\n\n friend class CloneAllocator;\n\n};\n\n\n\n} // namespace facebook::fboss\n\n#include \"fboss/agent/state/NeighborResponseEntry-defs.h\"\n", "file_path": "fboss/agent/state/NeighborResponseEntry.h", "rank": 45, "score": 144274.92313599205 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#include \"fboss/agent/state/MacEntry.h\"\n\n#include \"fboss/agent/state/NodeBase-defs.h\"\n\n#include \"fboss/agent/state/StateUtils.h\"\n\n\n\n#include <sstream>\n\n\n\nnamespace {\n\nconstexpr auto kMac = \"mac\";\n\nconstexpr auto kMacEntryPort = \"portId\";\n\nconstexpr auto kClassID = \"classID\";\n\nconstexpr auto kType = \"type\";\n", "file_path": "fboss/agent/state/MacEntry.cpp", "rank": 46, "score": 144273.84415279434 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#include \"fboss/agent/state/NdpEntry.h\"\n\n\n\n#include \"fboss/agent/state/NeighborEntry-defs.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\ntemplate class NeighborEntry<folly::IPAddressV6, NdpEntry>;\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/NdpEntry.cpp", "rank": 47, "score": 144272.493415049 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#include \"fboss/agent/state/ArpEntry.h\"\n\n\n\n#include \"fboss/agent/state/NeighborEntry-defs.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\ntemplate class NeighborEntry<folly::IPAddressV4, ArpEntry>;\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/ArpEntry.cpp", "rank": 48, "score": 144272.493415049 }, { "content": " auto* ptr = newEntry.get();\n\n acls->updateNode(std::move(newEntry));\n\n return ptr;\n\n}\n\n\n\nAclEntry::AclEntry(int priority, const std::string& name)\n\n : ThriftyBaseT(priority, name) {}\n\n\n\ntemplate class ThriftyBaseT<state::AclEntryFields, AclEntry, AclEntryFields>;\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 49, "score": 144269.982509637 }, { "content": "} // namespace\n\n\n\nnamespace facebook::fboss {\n\n\n\nstate::MacEntryFields MacEntryFields::toThrift() const {\n\n auto entryTh = state::MacEntryFields();\n\n\n\n entryTh.mac() = mac_.toString();\n\n entryTh.portId() = portDescr_.toThrift();\n\n if (classID_.has_value()) {\n\n entryTh.classID() = *classID_;\n\n }\n\n entryTh.type() = static_cast<state::MacEntryType>(type_);\n\n\n\n return entryTh;\n\n}\n\n\n\nMacEntryFields MacEntryFields::fromThrift(\n\n state::MacEntryFields const& entryTh) {\n\n folly::MacAddress mac(entryTh.get_mac());\n", "file_path": "fboss/agent/state/MacEntry.cpp", "rank": 50, "score": 144267.8159128667 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include <folly/MacAddress.h>\n\n#include \"fboss/agent/gen-cpp2/switch_state_types.h\"\n\n#include \"fboss/agent/state/NodeBase.h\"\n\n#include \"fboss/agent/state/Thrifty.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\ntemplate <typename IPADDR>\n", "file_path": "fboss/agent/state/NeighborResponseEntry.h", "rank": 51, "score": 144264.27029411987 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include <folly/IPAddressV6.h>\n\n#include \"fboss/agent/state/NeighborResponseEntry.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n", "file_path": "fboss/agent/state/NdpResponseEntry.h", "rank": 52, "score": 144261.80352730144 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include <folly/IPAddressV4.h>\n\n#include \"fboss/agent/state/NeighborResponseEntry.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n", "file_path": "fboss/agent/state/ArpResponseEntry.h", "rank": 53, "score": 144261.80352730144 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#include \"fboss/agent/state/AclEntry.h\"\n\n#include <folly/Conv.h>\n\n#include <folly/MacAddress.h>\n\n#include <thrift/lib/cpp/util/EnumUtils.h>\n\n#include \"fboss/agent/gen-cpp2/switch_config_types.h\"\n\n#include \"fboss/agent/state/AclMap.h\"\n\n#include \"fboss/agent/state/NodeBase-defs.h\"\n\n#include \"fboss/agent/state/StateUtils.h\"\n\n#include \"fboss/agent/state/SwitchState.h\"\n\n#include \"folly/IPAddress.h\"\n\n\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 54, "score": 144261.05744648917 }, { "content": " const folly::dynamic& entry);\n\n\n\n template <typename Fn>\n\n void forEachChild(Fn /*fn*/) {}\n\n\n\n bool operator==(const NeighborResponseEntryFields& other) const {\n\n return mac == other.mac && interfaceID == other.interfaceID;\n\n }\n\n\n\n AddressType ipAddress;\n\n folly::MacAddress mac;\n\n InterfaceID interfaceID{0};\n\n};\n\n\n\ntemplate <typename IPADDR, typename SUBCLASS>\n", "file_path": "fboss/agent/state/NeighborResponseEntry.h", "rank": 55, "score": 144259.73428291938 }, { "content": " if (getLookupClassRoute()) {\n\n qualifiers.insert(cfg::AclTableQualifier::LOOKUP_CLASS_ROUTE);\n\n }\n\n if (getPacketLookupResult()) {\n\n // TODO: add qualifier in AclTableQualifier enum\n\n }\n\n if (getEtherType()) {\n\n qualifiers.insert(cfg::AclTableQualifier::ETHER_TYPE);\n\n }\n\n return qualifiers;\n\n}\n\n\n\nAclEntry* AclEntry::modify(std::shared_ptr<SwitchState>* state) {\n\n if (!isPublished()) {\n\n CHECK(!(*state)->isPublished());\n\n return this;\n\n }\n\n\n\n AclMap* acls = (*state)->getAcls()->modify(state);\n\n auto newEntry = clone();\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 56, "score": 144259.54844377647 }, { "content": "constexpr auto kDstMac = \"dstMac\";\n\nconstexpr auto kIpType = \"IpType\";\n\nconstexpr auto kTtl = \"ttl\";\n\nconstexpr auto kTtlValue = \"value\";\n\nconstexpr auto kTtlMask = \"mask\";\n\nconstexpr auto kLookupClassL2 = \"lookupClassL2\";\n\nconstexpr auto kLookupClass = \"lookupClass\";\n\nconstexpr auto kLookupClassNeighbor = \"lookupClassNeighbor\";\n\nconstexpr auto kLookupClassRoute = \"lookupClassRoute\";\n\nconstexpr auto kPacketLookupResult = \"packetLookupResult\";\n\nconstexpr auto kVlanID = \"vlanID\";\n\nconstexpr auto kAclAction = \"aclAction\";\n\n} // namespace\n\n\n\nnamespace facebook::fboss {\n\n\n\nstate::AclTtl AclTtl::toThrift() const {\n\n auto aclTtl = state::AclTtl();\n\n aclTtl.value_ref() = value_;\n\n aclTtl.mask_ref() = mask_;\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 57, "score": 144258.96073755767 }, { "content": " ? folly::to<std::string>(static_cast<int>(getClassID().value()))\n\n : \"None\";\n\n\n\n os << \"MacEntry:: MAC: \" << getMac().toString() << \" \" << getPort().str()\n\n << \" classID: \" << classIDStr << \" \"\n\n << \" type: \"\n\n << (getType() == MacEntryType::STATIC_ENTRY ? \"static\" : \"dynamic\");\n\n\n\n return os.str();\n\n}\n\n\n\ntemplate class NodeBaseT<MacEntry, MacEntryFields>;\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/MacEntry.cpp", "rank": 58, "score": 144258.1264724816 }, { "content": " }\n\n return AclTtl(ttlJson[kTtlValue].asInt(), ttlJson[kTtlMask].asInt());\n\n}\n\n\n\nstate::AclEntryFields AclEntryFields::toThrift() const {\n\n auto entry = state::AclEntryFields();\n\n entry.priority_ref() = priority;\n\n entry.name_ref() = name;\n\n\n\n if (srcIp.first) {\n\n entry.srcIp_ref() = IPAddress::networkToString(srcIp);\n\n }\n\n if (dstIp.first) {\n\n entry.dstIp_ref() = IPAddress::networkToString(dstIp);\n\n }\n\n\n\n entry.proto_ref().from_optional(proto);\n\n entry.tcpFlagsBitMap_ref().from_optional(tcpFlagsBitMap);\n\n entry.srcPort_ref().from_optional(srcPort);\n\n entry.dstPort_ref().from_optional(dstPort);\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 59, "score": 144257.72878698332 }, { "content": " entry.lookupClassNeighbor_ref().from_optional(lookupClassNeighbor);\n\n entry.lookupClassRoute_ref().from_optional(lookupClassRoute);\n\n entry.packetLookupResult_ref().from_optional(packetLookupResult);\n\n entry.vlanID_ref().from_optional(vlanID);\n\n entry.etherType_ref().from_optional(etherType);\n\n entry.actionType_ref() = actionType;\n\n\n\n if (aclAction.has_value()) {\n\n entry.aclAction_ref() = aclAction->toThrift();\n\n }\n\n\n\n return entry;\n\n}\n\n\n\nAclEntryFields AclEntryFields::fromThrift(state::AclEntryFields const& entry) {\n\n auto aclEntryFields = AclEntryFields(entry.get_priority(), entry.get_name());\n\n\n\n if (auto srcIp = entry.srcIp_ref()) {\n\n aclEntryFields.srcIp = IPAddress::createNetwork(*srcIp);\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 60, "score": 144257.58344043087 }, { "content": "using apache::thrift::TEnumTraits;\n\nusing folly::IPAddress;\n\n\n\nnamespace {\n\nconstexpr auto kPriority = \"priority\";\n\nconstexpr auto kName = \"name\";\n\nconstexpr auto kActionType = \"actionType\";\n\nconstexpr auto kSrcIp = \"srcIp\";\n\nconstexpr auto kDstIp = \"dstIp\";\n\nconstexpr auto kL4SrcPort = \"l4SrcPort\";\n\nconstexpr auto kL4DstPort = \"l4DstPort\";\n\nconstexpr auto kProto = \"proto\";\n\nconstexpr auto kTcpFlagsBitMap = \"tcpFlagsBitMap\";\n\nconstexpr auto kSrcPort = \"srcPort\";\n\nconstexpr auto kDstPort = \"dstPort\";\n\nconstexpr auto kIpFrag = \"ipFrag\";\n\nconstexpr auto kIcmpCode = \"icmpCode\";\n\nconstexpr auto kIcmpType = \"icmpType\";\n\nconstexpr auto kDscp = \"dscp\";\n\nconstexpr auto kPortName = \"portName\";\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 61, "score": 144257.0962669463 }, { "content": " aclEntry.vlanID = aclEntryJson[kVlanID].asInt();\n\n }\n\n TEnumTraits<cfg::AclActionType>::findValue(\n\n aclEntryJson[kActionType].asString().c_str(), &aclEntry.actionType);\n\n if (aclEntryJson.find(kAclAction) != aclEntryJson.items().end()) {\n\n aclEntry.aclAction =\n\n MatchAction::fromFollyDynamic(aclEntryJson[kAclAction]);\n\n }\n\n\n\n return aclEntry;\n\n}\n\n\n\nvoid AclEntryFields::checkFollyDynamic(const folly::dynamic& aclEntryJson) {\n\n // check src ip and dst ip are of the same type\n\n if (aclEntryJson.find(kSrcIp) != aclEntryJson.items().end() &&\n\n aclEntryJson.find(kDstIp) != aclEntryJson.items().end()) {\n\n auto src = IPAddress::createNetwork(aclEntryJson[kSrcIp].asString());\n\n auto dst = IPAddress::createNetwork(aclEntryJson[kDstIp].asString());\n\n if (src.first.isV4() != dst.first.isV4()) {\n\n throw FbossError(\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 62, "score": 144256.3444313155 }, { "content": " auto portDescr = PortDescriptor::fromThrift(entryTh.get_portId());\n\n auto classID = entryTh.classID().to_optional();\n\n auto type = static_cast<MacEntryType>(entryTh.get_type());\n\n\n\n return MacEntryFields(mac, portDescr, classID, type);\n\n}\n\n\n\nfolly::dynamic MacEntryFields::toFollyDynamicLegacy() const {\n\n folly::dynamic macEntry = folly::dynamic::object;\n\n macEntry[kMac] = mac_.toString();\n\n macEntry[kMacEntryPort] = portDescr_.toFollyDynamic();\n\n if (classID_.has_value()) {\n\n macEntry[kClassID] = static_cast<int>(classID_.value());\n\n }\n\n macEntry[kType] = static_cast<int>(type_);\n\n\n\n return macEntry;\n\n}\n\n\n\nMacEntryFields MacEntryFields::fromFollyDynamicLegacy(\n", "file_path": "fboss/agent/state/MacEntry.cpp", "rank": 63, "score": 144255.37186511024 }, { "content": "\n\n if (aclEntryJson.find(kL4DstPort) != aclEntryJson.items().end() &&\n\n (aclEntryJson[kL4DstPort].asInt() < 0 ||\n\n aclEntryJson[kL4DstPort].asInt() > kMaxL4Port)) {\n\n throw FbossError(\n\n \"L4 destination port must be between 0 and \",\n\n std::to_string(kMaxL4Port));\n\n }\n\n}\n\n\n\nstd::set<cfg::AclTableQualifier> AclEntry::getRequiredAclTableQualifiers()\n\n const {\n\n std::set<cfg::AclTableQualifier> qualifiers{};\n\n auto setIpQualifier = [&qualifiers](\n\n auto cidr, auto v4Qualifier, auto v6Qualifier) {\n\n if (cidr == folly::CIDRNetwork(folly::IPAddress(), 0)) {\n\n return;\n\n }\n\n if (cidr.first.isV4()) {\n\n qualifiers.insert(v4Qualifier);\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 64, "score": 144254.36579518983 }, { "content": " const folly::dynamic& jsonStr) {\n\n folly::MacAddress mac(jsonStr[kMac].stringPiece());\n\n auto portDescr = PortDescriptor::fromFollyDynamic(jsonStr[kMacEntryPort]);\n\n\n\n MacEntryType type{MacEntryType::DYNAMIC_ENTRY};\n\n if (jsonStr.find(kType) != jsonStr.items().end()) {\n\n type = static_cast<MacEntryType>(jsonStr[kType].asInt());\n\n }\n\n if (jsonStr.find(kClassID) != jsonStr.items().end()) {\n\n auto classID = cfg::AclLookupClass(jsonStr[kClassID].asInt());\n\n return MacEntryFields(mac, portDescr, classID, type);\n\n } else {\n\n return MacEntryFields(mac, portDescr, std::nullopt, type);\n\n }\n\n}\n\n\n\nstd::string MacEntry::str() const {\n\n std::ostringstream os;\n\n\n\n auto classIDStr = getClassID().has_value()\n", "file_path": "fboss/agent/state/MacEntry.cpp", "rank": 65, "score": 144254.06090686086 }, { "content": "\n\n if (auto ttl = entry.ttl_ref()) {\n\n aclEntryFields.ttl = AclTtl::fromThrift(*ttl);\n\n }\n\n\n\n aclEntryFields.icmpType = entry.icmpType_ref().to_optional();\n\n aclEntryFields.icmpCode = entry.icmpCode_ref().to_optional();\n\n aclEntryFields.dscp = entry.dscp_ref().to_optional();\n\n aclEntryFields.ipType = entry.ipType_ref().to_optional();\n\n\n\n if (auto dstMac = entry.dstMac_ref()) {\n\n aclEntryFields.dstMac = folly::MacAddress(*dstMac);\n\n }\n\n\n\n aclEntryFields.l4SrcPort = entry.l4SrcPort_ref().to_optional();\n\n aclEntryFields.l4DstPort = entry.l4DstPort_ref().to_optional();\n\n aclEntryFields.lookupClassL2 = entry.lookupClassL2_ref().to_optional();\n\n aclEntryFields.lookupClass = entry.lookupClass_ref().to_optional();\n\n aclEntryFields.lookupClassNeighbor =\n\n entry.lookupClassNeighbor_ref().to_optional();\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 66, "score": 144253.48339511428 }, { "content": " aclEntry[kLookupClassNeighbor] = lookupClassNameNeighbor;\n\n }\n\n if (lookupClassRoute) {\n\n auto lookupClassNameRoute =\n\n apache::thrift::util::enumName(*lookupClassRoute);\n\n if (lookupClassNameRoute == nullptr) {\n\n throw FbossError(\"invalid lookupClassRoute\");\n\n }\n\n aclEntry[kLookupClassRoute] = lookupClassNameRoute;\n\n }\n\n if (packetLookupResult) {\n\n aclEntry[kPacketLookupResult] =\n\n static_cast<uint32_t>(packetLookupResult.value());\n\n }\n\n if (vlanID) {\n\n aclEntry[kVlanID] = static_cast<uint32_t>(vlanID.value());\n\n }\n\n auto actionTypeName = apache::thrift::util::enumName(actionType);\n\n if (actionTypeName == nullptr) {\n\n throw FbossError(\"invalid actionType\");\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 67, "score": 144251.69205091812 }, { "content": " if (auto dstIp = entry.dstIp_ref()) {\n\n aclEntryFields.dstIp = IPAddress::createNetwork(*dstIp);\n\n }\n\n\n\n if (aclEntryFields.srcIp.first && aclEntryFields.dstIp.first &&\n\n aclEntryFields.srcIp.first.isV4() != aclEntryFields.dstIp.first.isV4()) {\n\n throw FbossError(\n\n \"Unmatched ACL IP versions \",\n\n aclEntryFields.srcIp.first,\n\n \" vs \",\n\n aclEntryFields.dstIp.first);\n\n }\n\n\n\n aclEntryFields.proto = entry.proto_ref().to_optional();\n\n aclEntryFields.tcpFlagsBitMap = entry.tcpFlagsBitMap_ref().to_optional();\n\n aclEntryFields.srcPort = entry.srcPort_ref().to_optional();\n\n aclEntryFields.dstPort = entry.dstPort_ref().to_optional();\n\n aclEntryFields.ipFrag = entry.ipFrag_ref().to_optional();\n\n aclEntryFields.proto = entry.proto_ref().to_optional();\n\n aclEntryFields.proto = entry.proto_ref().to_optional();\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 68, "score": 144251.5830277345 }, { "content": " aclEntryFields.lookupClassRoute = entry.lookupClassRoute_ref().to_optional();\n\n aclEntryFields.packetLookupResult =\n\n entry.packetLookupResult_ref().to_optional();\n\n aclEntryFields.vlanID = entry.vlanID_ref().to_optional();\n\n aclEntryFields.etherType = entry.etherType_ref().to_optional();\n\n aclEntryFields.actionType = entry.get_actionType();\n\n if (auto aclAction = entry.aclAction_ref()) {\n\n aclEntryFields.aclAction = MatchAction::fromThrift(*aclAction);\n\n }\n\n\n\n return aclEntryFields;\n\n}\n\n\n\n// TODO: remove all migration along with old ser/des after next disruptive push\n\nfolly::dynamic AclEntryFields::migrateToThrifty(const folly::dynamic& dyn) {\n\n folly::dynamic newDyn = dyn;\n\n\n\n // rename IpType -> ipType just for thrift name convention\n\n ThriftyUtils::renameField(newDyn, kIpType, \"ipType\");\n\n\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 69, "score": 144251.3411445228 }, { "content": " if (lookupClassL2) {\n\n auto lookupClassNameL2 = apache::thrift::util::enumName(*lookupClassL2);\n\n if (lookupClassNameL2 == nullptr) {\n\n throw FbossError(\"invalid lookupClassL2\");\n\n }\n\n aclEntry[kLookupClassL2] = lookupClassNameL2;\n\n }\n\n if (lookupClass) {\n\n auto lookupClassName = apache::thrift::util::enumName(*lookupClass);\n\n if (lookupClassName == nullptr) {\n\n throw FbossError(\"invalid lookupClass\");\n\n }\n\n aclEntry[kLookupClass] = lookupClassName;\n\n }\n\n if (lookupClassNeighbor) {\n\n auto lookupClassNameNeighbor =\n\n apache::thrift::util::enumName(*lookupClassNeighbor);\n\n if (lookupClassNameNeighbor == nullptr) {\n\n throw FbossError(\"invalid lookupClassNeighbor\");\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 70, "score": 144250.96548928184 }, { "content": " if (proto) {\n\n aclEntry[kProto] = static_cast<uint8_t>(proto.value());\n\n }\n\n if (tcpFlagsBitMap) {\n\n aclEntry[kTcpFlagsBitMap] = static_cast<uint8_t>(tcpFlagsBitMap.value());\n\n }\n\n if (srcPort) {\n\n aclEntry[kSrcPort] = static_cast<uint16_t>(srcPort.value());\n\n }\n\n if (dstPort) {\n\n aclEntry[kDstPort] = static_cast<uint16_t>(dstPort.value());\n\n }\n\n if (ipFrag) {\n\n auto ipFragName = apache::thrift::util::enumName(*ipFrag);\n\n if (ipFragName == nullptr) {\n\n throw FbossError(\"invalid ipFrag\");\n\n }\n\n aclEntry[kIpFrag] = ipFragName;\n\n }\n\n if (icmpCode) {\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 71, "score": 144250.77135361277 }, { "content": " ThriftyUtils::changeEnumToString<cfg::AclLookupClass>(\n\n dyn, kLookupClassNeighbor);\n\n ThriftyUtils::changeEnumToString<cfg::AclLookupClass>(dyn, kLookupClassRoute);\n\n ThriftyUtils::changeEnumToString<cfg::AclActionType>(dyn, kActionType);\n\n if (auto it = dyn.find(kAclAction); it != dyn.items().end()) {\n\n MatchAction::migrateFromThrifty(it->second);\n\n }\n\n}\n\n\n\nfolly::dynamic AclEntryFields::toFollyDynamicLegacy() const {\n\n folly::dynamic aclEntry = folly::dynamic::object;\n\n if (srcIp.first) {\n\n aclEntry[kSrcIp] = IPAddress::networkToString(srcIp);\n\n }\n\n if (dstIp.first) {\n\n aclEntry[kDstIp] = IPAddress::networkToString(dstIp);\n\n }\n\n if (dstMac) {\n\n aclEntry[kDstMac] = dstMac->toString();\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 72, "score": 144249.92903769022 }, { "content": " }\n\n aclEntry[kActionType] = actionTypeName;\n\n if (aclAction) {\n\n aclEntry[kAclAction] = aclAction.value().toFollyDynamic();\n\n }\n\n aclEntry[kPriority] = priority;\n\n aclEntry[kName] = name;\n\n return aclEntry;\n\n}\n\n\n\nAclEntryFields AclEntryFields::fromFollyDynamicLegacy(\n\n const folly::dynamic& aclEntryJson) {\n\n AclEntryFields aclEntry(\n\n aclEntryJson[kPriority].asInt(), aclEntryJson[kName].asString());\n\n if (aclEntryJson.find(kSrcIp) != aclEntryJson.items().end()) {\n\n aclEntry.srcIp = IPAddress::createNetwork(aclEntryJson[kSrcIp].asString());\n\n }\n\n if (aclEntryJson.find(kDstIp) != aclEntryJson.items().end()) {\n\n aclEntry.dstIp = IPAddress::createNetwork(aclEntryJson[kDstIp].asString());\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 73, "score": 144248.68883834334 }, { "content": " if (aclEntry.srcIp.first && aclEntry.dstIp.first &&\n\n aclEntry.srcIp.first.isV4() != aclEntry.dstIp.first.isV4()) {\n\n throw FbossError(\n\n \"Unmatched ACL IP versions \",\n\n aclEntryJson[kSrcIp].asString(),\n\n \" vs \",\n\n aclEntryJson[kDstIp].asString());\n\n }\n\n if (aclEntryJson.find(kDstMac) != aclEntryJson.items().end()) {\n\n aclEntry.dstMac = folly::MacAddress(aclEntryJson[kDstMac].asString());\n\n }\n\n if (aclEntryJson.find(kProto) != aclEntryJson.items().end()) {\n\n aclEntry.proto = aclEntryJson[kProto].asInt();\n\n }\n\n if (aclEntryJson.find(kTcpFlagsBitMap) != aclEntryJson.items().end()) {\n\n aclEntry.tcpFlagsBitMap = aclEntryJson[kTcpFlagsBitMap].asInt();\n\n }\n\n if (aclEntryJson.find(kSrcPort) != aclEntryJson.items().end()) {\n\n aclEntry.srcPort = aclEntryJson[kSrcPort].asInt();\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 74, "score": 144248.60823450278 }, { "content": " if (aclEntryJson.find(kDstPort) != aclEntryJson.items().end()) {\n\n aclEntry.dstPort = aclEntryJson[kDstPort].asInt();\n\n }\n\n if (aclEntryJson.find(kL4SrcPort) != aclEntryJson.items().end()) {\n\n aclEntry.l4SrcPort = aclEntryJson[kL4SrcPort].asInt();\n\n }\n\n if (aclEntryJson.find(kL4DstPort) != aclEntryJson.items().end()) {\n\n aclEntry.l4DstPort = aclEntryJson[kL4DstPort].asInt();\n\n }\n\n if (aclEntryJson.find(kIpFrag) != aclEntryJson.items().end()) {\n\n cfg::IpFragMatch ipFrag;\n\n TEnumTraits<cfg::IpFragMatch>::findValue(\n\n aclEntryJson[kIpFrag].asString().c_str(), &ipFrag);\n\n aclEntry.ipFrag = ipFrag;\n\n }\n\n if (aclEntryJson.find(kIcmpType) != aclEntryJson.items().end()) {\n\n aclEntry.icmpType = aclEntryJson[kIcmpType].asInt();\n\n }\n\n if (aclEntryJson.find(kIcmpCode) != aclEntryJson.items().end()) {\n\n aclEntry.icmpCode = aclEntryJson[kIcmpCode].asInt();\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 75, "score": 144248.56388474378 }, { "content": " }\n\n if (aclEntryJson.find(kDscp) != aclEntryJson.items().end()) {\n\n aclEntry.dscp = aclEntryJson[kDscp].asInt();\n\n }\n\n if (aclEntryJson.find(kIpType) != aclEntryJson.items().end()) {\n\n aclEntry.ipType = static_cast<cfg::IpType>(aclEntryJson[kIpType].asInt());\n\n }\n\n if (aclEntryJson.find(kTtl) != aclEntryJson.items().end()) {\n\n aclEntry.ttl = AclTtl::fromFollyDynamic(aclEntryJson[kTtl]);\n\n }\n\n if (aclEntryJson.find(kLookupClassL2) != aclEntryJson.items().end()) {\n\n cfg::AclLookupClass lookupClassL2;\n\n TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClassL2].asString().c_str(), &lookupClassL2);\n\n aclEntry.lookupClassL2 = lookupClassL2;\n\n }\n\n if (aclEntryJson.find(kLookupClass) != aclEntryJson.items().end()) {\n\n cfg::AclLookupClass lookupClass;\n\n TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClass].asString().c_str(), &lookupClass);\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 76, "score": 144248.29742663988 }, { "content": " entry.ipFrag_ref().from_optional(ipFrag);\n\n entry.proto_ref().from_optional(proto);\n\n entry.proto_ref().from_optional(proto);\n\n\n\n if (ttl.has_value()) {\n\n entry.ttl_ref() = ttl->toThrift();\n\n }\n\n\n\n entry.icmpType_ref().from_optional(icmpType);\n\n entry.icmpCode_ref().from_optional(icmpCode);\n\n entry.dscp_ref().from_optional(dscp);\n\n entry.ipType_ref().from_optional(ipType);\n\n\n\n if (dstMac.has_value()) {\n\n entry.dstMac_ref() = dstMac->toString();\n\n }\n\n entry.l4SrcPort_ref().from_optional(l4SrcPort);\n\n entry.l4DstPort_ref().from_optional(l4DstPort);\n\n entry.lookupClassL2_ref().from_optional(lookupClassL2);\n\n entry.lookupClass_ref().from_optional(lookupClass);\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 77, "score": 144248.27522577086 }, { "content": " aclEntry.lookupClass = lookupClass;\n\n }\n\n if (aclEntryJson.find(kLookupClassNeighbor) != aclEntryJson.items().end()) {\n\n cfg::AclLookupClass lookupClassNeighbor;\n\n TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClassNeighbor].asString().c_str(),\n\n &lookupClassNeighbor);\n\n aclEntry.lookupClassNeighbor = lookupClassNeighbor;\n\n }\n\n if (aclEntryJson.find(kLookupClassRoute) != aclEntryJson.items().end()) {\n\n cfg::AclLookupClass lookupClassRoute;\n\n TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClassRoute].asString().c_str(), &lookupClassRoute);\n\n aclEntry.lookupClassRoute = lookupClassRoute;\n\n }\n\n if (aclEntryJson.find(kPacketLookupResult) != aclEntryJson.items().end()) {\n\n aclEntry.packetLookupResult = static_cast<cfg::PacketLookupResultType>(\n\n aclEntryJson[kPacketLookupResult].asInt());\n\n }\n\n if (aclEntryJson.find(kVlanID) != aclEntryJson.items().end()) {\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 78, "score": 144247.98425342573 }, { "content": " (aclEntryJson[kIcmpCode].asInt() < 0 ||\n\n aclEntryJson[kIcmpCode].asInt() > kMaxIcmpCode)) {\n\n throw FbossError(\n\n \"icmp code value must be between 0 and \", std::to_string(kMaxIcmpCode));\n\n }\n\n // check the \"proto\" is either \"icmp\" or \"icmpv6\" when icmptype is set\n\n if (aclEntryJson.find(kIcmpType) != aclEntryJson.items().end() &&\n\n (aclEntryJson.find(kProto) == aclEntryJson.items().end() ||\n\n !(aclEntryJson[kProto] == kProtoIcmp ||\n\n aclEntryJson[kProto] == kProtoIcmpv6))) {\n\n throw FbossError(\n\n \"proto must be either icmp or icmpv6 \", \"if icmp type is set\");\n\n }\n\n\n\n if (aclEntryJson.find(kL4SrcPort) != aclEntryJson.items().end() &&\n\n (aclEntryJson[kL4SrcPort].asInt() < 0 ||\n\n aclEntryJson[kL4SrcPort].asInt() > kMaxL4Port)) {\n\n throw FbossError(\n\n \"L4 source port must be between 0 and \", std::to_string(kMaxL4Port));\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 79, "score": 144247.92350203282 }, { "content": " cfg::AclActionType aclActionType;\n\n if (!TEnumTraits<cfg::AclActionType>::findValue(\n\n aclEntryJson[kActionType].asString().c_str(), &aclActionType)) {\n\n throw FbossError(\n\n \"Unsupported ACL action \", aclEntryJson[kActionType].asString());\n\n }\n\n // check icmp type exists when icmp code exist\n\n if (aclEntryJson.find(kIcmpCode) != aclEntryJson.items().end() &&\n\n aclEntryJson.find(kIcmpType) == aclEntryJson.items().end()) {\n\n throw FbossError(\"icmp type must be set when icmp code is set\");\n\n }\n\n // the value of icmp type must be 0~255\n\n if (aclEntryJson.find(kIcmpType) != aclEntryJson.items().end() &&\n\n (aclEntryJson[kIcmpType].asInt() < 0 ||\n\n aclEntryJson[kIcmpType].asInt() > kMaxIcmpType)) {\n\n throw FbossError(\n\n \"icmp type value must be between 0 and \", std::to_string(kMaxIcmpType));\n\n }\n\n // the value of icmp code must be 0~255\n\n if (aclEntryJson.find(kIcmpCode) != aclEntryJson.items().end() &&\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 80, "score": 144247.78430296842 }, { "content": " \"Unmatched ACL IP versions \",\n\n aclEntryJson[kSrcIp].asString(),\n\n \" vs \",\n\n aclEntryJson[kDstIp].asString(),\n\n \"; source and destination IPs must be of the same type\");\n\n }\n\n }\n\n // check lookupClass is valid\n\n if (aclEntryJson.find(kLookupClass) != aclEntryJson.items().end()) {\n\n cfg::AclLookupClass lookupClass;\n\n if (!TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClass].asString().c_str(), &lookupClass)) {\n\n throw FbossError(\n\n \"Unsupported ACL Lookup Class option \",\n\n aclEntryJson[kLookupClass].asString());\n\n }\n\n }\n\n // check lookupClassL2 is valid\n\n if (aclEntryJson.find(kLookupClassL2) != aclEntryJson.items().end()) {\n\n cfg::AclLookupClass lookupClassL2;\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 81, "score": 144247.45620688985 }, { "content": " aclEntry[kIcmpCode] = static_cast<uint8_t>(icmpCode.value());\n\n }\n\n if (icmpType) {\n\n aclEntry[kIcmpType] = static_cast<uint8_t>(icmpType.value());\n\n }\n\n if (dscp) {\n\n aclEntry[kDscp] = static_cast<uint8_t>(dscp.value());\n\n }\n\n if (ipType) {\n\n aclEntry[kIpType] = static_cast<uint16_t>(ipType.value());\n\n }\n\n if (ttl) {\n\n aclEntry[kTtl] = ttl.value().toFollyDynamic();\n\n }\n\n if (l4SrcPort) {\n\n aclEntry[kL4SrcPort] = static_cast<uint16_t>(l4SrcPort.value());\n\n }\n\n if (l4DstPort) {\n\n aclEntry[kL4DstPort] = static_cast<uint16_t>(l4DstPort.value());\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 82, "score": 144247.4599257639 }, { "content": " if (!TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClassL2].asString().c_str(), &lookupClassL2)) {\n\n throw FbossError(\n\n \"Unsupported ACL Lookup ClassL2 option \",\n\n aclEntryJson[kLookupClassL2].asString());\n\n }\n\n }\n\n // check lookupClassNeighbor is valid\n\n if (aclEntryJson.find(kLookupClassNeighbor) != aclEntryJson.items().end()) {\n\n cfg::AclLookupClass lookupClassNeighbor;\n\n if (!TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClassNeighbor].asString().c_str(),\n\n &lookupClassNeighbor)) {\n\n throw FbossError(\n\n \"Unsupported ACL LookupClassNeighbor option \",\n\n aclEntryJson[kLookupClassNeighbor].asString());\n\n }\n\n }\n\n // check lookupClassRoute is valid\n\n if (aclEntryJson.find(kLookupClassRoute) != aclEntryJson.items().end()) {\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 83, "score": 144247.2185113939 }, { "content": " cfg::AclLookupClass lookupClassRoute;\n\n if (!TEnumTraits<cfg::AclLookupClass>::findValue(\n\n aclEntryJson[kLookupClassRoute].asString().c_str(),\n\n &lookupClassRoute)) {\n\n throw FbossError(\n\n \"Unsupported ACL LookupClassRoute option \",\n\n aclEntryJson[kLookupClassRoute].asString());\n\n }\n\n }\n\n // check ipFrag is valid\n\n if (aclEntryJson.find(kIpFrag) != aclEntryJson.items().end()) {\n\n cfg::IpFragMatch ipFrag;\n\n if (!TEnumTraits<cfg::IpFragMatch>::findValue(\n\n aclEntryJson[kIpFrag].asString().c_str(), &ipFrag)) {\n\n throw FbossError(\n\n \"Unsupported ACL IP fragmentation option \",\n\n aclEntryJson[kIpFrag].asString());\n\n }\n\n }\n\n // check action is valid\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 84, "score": 144246.8360221107 }, { "content": " ThriftyUtils::changeEnumToInt<cfg::IpFragMatch>(newDyn, kIpFrag);\n\n ThriftyUtils::changeEnumToInt<cfg::AclLookupClass>(newDyn, kLookupClassL2);\n\n ThriftyUtils::changeEnumToInt<cfg::AclLookupClass>(newDyn, kLookupClass);\n\n ThriftyUtils::changeEnumToInt<cfg::AclLookupClass>(\n\n newDyn, kLookupClassNeighbor);\n\n ThriftyUtils::changeEnumToInt<cfg::AclLookupClass>(newDyn, kLookupClassRoute);\n\n ThriftyUtils::changeEnumToInt<cfg::AclActionType>(newDyn, kActionType);\n\n if (auto it = newDyn.find(kAclAction); it != newDyn.items().end()) {\n\n it->second = MatchAction::migrateToThrifty(it->second);\n\n }\n\n\n\n return newDyn;\n\n}\n\n\n\nvoid AclEntryFields::migrateFromThrifty(folly::dynamic& dyn) {\n\n ThriftyUtils::renameField(dyn, \"ipType\", kIpType);\n\n\n\n ThriftyUtils::changeEnumToString<cfg::IpFragMatch>(dyn, kIpFrag);\n\n ThriftyUtils::changeEnumToString<cfg::AclLookupClass>(dyn, kLookupClassL2);\n\n ThriftyUtils::changeEnumToString<cfg::AclLookupClass>(dyn, kLookupClass);\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 85, "score": 144246.45941549548 }, { "content": " qualifiers.insert(cfg::AclTableQualifier::SRC_PORT);\n\n }\n\n if (getDstPort()) {\n\n qualifiers.insert(cfg::AclTableQualifier::OUT_PORT);\n\n }\n\n if (getIpFrag()) {\n\n qualifiers.insert(cfg::AclTableQualifier::IP_FRAG);\n\n }\n\n if (getIcmpType() && getProto()) {\n\n auto proto = getProto().value();\n\n if (proto == 1) {\n\n qualifiers.insert(cfg::AclTableQualifier::ICMPV4_TYPE);\n\n } else {\n\n qualifiers.insert(cfg::AclTableQualifier::ICMPV6_TYPE);\n\n }\n\n }\n\n if (getDscp()) {\n\n qualifiers.insert(cfg::AclTableQualifier::DSCP);\n\n }\n\n if (getIpType()) {\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 86, "score": 144242.72932349867 }, { "content": " return aclTtl;\n\n}\n\n\n\nAclTtl AclTtl::fromThrift(state::AclTtl const& ttl) {\n\n return AclTtl(ttl.get_value(), ttl.get_mask());\n\n}\n\n\n\nfolly::dynamic AclTtl::toFollyDynamic() const {\n\n folly::dynamic ttl = folly::dynamic::object;\n\n ttl[kTtlValue] = static_cast<uint16_t>(value_);\n\n ttl[kTtlMask] = static_cast<uint16_t>(mask_);\n\n return ttl;\n\n}\n\n\n\nAclTtl AclTtl::fromFollyDynamic(const folly::dynamic& ttlJson) {\n\n if (ttlJson.find(kTtlValue) == ttlJson.items().end()) {\n\n throw FbossError(\"ttl should have a value set\");\n\n }\n\n if (ttlJson.find(kTtlMask) == ttlJson.items().end()) {\n\n throw FbossError(\"ttl should have a mask set\");\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 87, "score": 144242.35479364157 }, { "content": " } else {\n\n qualifiers.insert(v6Qualifier);\n\n }\n\n };\n\n setIpQualifier(\n\n getSrcIp(),\n\n cfg::AclTableQualifier::SRC_IPV4,\n\n cfg::AclTableQualifier::SRC_IPV6);\n\n setIpQualifier(\n\n getDstIp(),\n\n cfg::AclTableQualifier::DST_IPV4,\n\n cfg::AclTableQualifier::DST_IPV6);\n\n\n\n if (getProto()) {\n\n qualifiers.insert(cfg::AclTableQualifier::IP_PROTOCOL);\n\n }\n\n if (getTcpFlagsBitMap()) {\n\n qualifiers.insert(cfg::AclTableQualifier::TCP_FLAGS);\n\n }\n\n if (getSrcPort()) {\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 88, "score": 144238.32133670672 }, { "content": " qualifiers.insert(cfg::AclTableQualifier::IP_TYPE);\n\n }\n\n if (getTtl()) {\n\n qualifiers.insert(cfg::AclTableQualifier::TTL);\n\n }\n\n if (getDstMac()) {\n\n qualifiers.insert(cfg::AclTableQualifier::DST_MAC);\n\n }\n\n if (getL4SrcPort()) {\n\n qualifiers.insert(cfg::AclTableQualifier::L4_SRC_PORT);\n\n }\n\n if (getL4DstPort()) {\n\n qualifiers.insert(cfg::AclTableQualifier::L4_DST_PORT);\n\n }\n\n if (getLookupClassL2()) {\n\n qualifiers.insert(cfg::AclTableQualifier::LOOKUP_CLASS_L2);\n\n }\n\n if (getLookupClassNeighbor()) {\n\n qualifiers.insert(cfg::AclTableQualifier::LOOKUP_CLASS_NEIGHBOR);\n\n }\n", "file_path": "fboss/agent/state/AclEntry.cpp", "rank": 89, "score": 144238.32133670672 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#include \"fboss/agent/state/ArpResponseEntry.h\"\n\n\n\n#include \"fboss/agent/state/NeighborResponseEntry-defs.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\ntemplate class NeighborResponseEntry<folly::IPAddressV4, ArpResponseEntry>;\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/ArpResponseEntry.cpp", "rank": 90, "score": 140394.18901514338 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#include \"fboss/agent/state/NdpResponseEntry.h\"\n\n\n\n#include \"fboss/agent/state/NeighborResponseEntry-defs.h\"\n\n\n\nnamespace facebook::fboss {\n\n\n\ntemplate class NeighborResponseEntry<folly::IPAddressV6, NdpResponseEntry>;\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/NdpResponseEntry.cpp", "rank": 91, "score": 140394.18901514338 }, { "content": "void toAppend(const RouteNextHopEntry& entry, std::string* result);\n\nstd::ostream& operator<<(std::ostream& os, const RouteNextHopEntry& entry);\n\n\n\nvoid toAppend(const RouteNextHopEntry::NextHopSet& nhops, std::string* result);\n\nstd::ostream& operator<<(\n\n std::ostream& os,\n\n const RouteNextHopEntry::NextHopSet& nhops);\n\nNextHopWeight totalWeight(const RouteNextHopEntry::NextHopSet& nhops);\n\n\n\nusing RouteNextHopSet = RouteNextHopEntry::NextHopSet;\n\n\n\nnamespace util {\n\n\n\n/**\n\n * Convert thrift representation of nexthops to RouteNextHops.\n\n */\n\nRouteNextHopSet toRouteNextHopSet(std::vector<NextHopThrift> const& nhts);\n\n\n\n/**\n\n * Convert RouteNextHops to thrift representaion of nexthops\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 92, "score": 140382.17451245635 }, { "content": "/*\n\n * Copyright (c) 2004-present, Facebook, Inc.\n\n * All rights reserved.\n\n *\n\n * This source code is licensed under the BSD-style license found in the\n\n * LICENSE file in the root directory of this source tree. An additional grant\n\n * of patent rights can be found in the PATENTS file in the same directory.\n\n *\n\n */\n\n#pragma once\n\n\n\n#include <boost/container/flat_set.hpp>\n\n\n\n#include <folly/dynamic.h>\n\n\n\n#include \"fboss/agent/gen-cpp2/switch_config_types.h\"\n\n#include \"fboss/agent/state/RouteNextHop.h\"\n\n#include \"fboss/agent/state/RouteTypes.h\"\n\n\n\nDECLARE_uint32(ecmp_width);\n\nDECLARE_bool(optimized_ucmp);\n\n\n\nnamespace facebook::fboss {\n\n\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 93, "score": 140380.1462003501 }, { "content": " */\n\nstd::vector<NextHopThrift> fromRouteNextHopSet(RouteNextHopSet const& nhs);\n\n\n\nUnicastRoute toUnicastRoute(\n\n const folly::CIDRNetwork& nw,\n\n const RouteNextHopEntry& nhopEntry);\n\n} // namespace util\n\n\n\n} // namespace facebook::fboss\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 94, "score": 140376.5117288081 }, { "content": " static void normalizeNextHopWeightsToMaxPaths(\n\n std::vector<uint64_t>& nhWeights,\n\n uint64_t normalizedPathCount);\n\n\n\n private:\n\n void normalize(\n\n std::vector<NextHopWeight>& scaledWeights,\n\n NextHopWeight totalWeight) const;\n\n AdminDistance adminDistance_;\n\n Action action_{Action::DROP};\n\n std::optional<RouteCounterID> counterID_;\n\n NextHopSet nhopSet_;\n\n};\n\n\n\n/**\n\n * Comparision operators\n\n */\n\nbool operator==(const RouteNextHopEntry& a, const RouteNextHopEntry& b);\n\nbool operator<(const RouteNextHopEntry& a, const RouteNextHopEntry& b);\n\n\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 95, "score": 140375.094531438 }, { "content": "\n\n // Methods to manipulate this object\n\n bool isDrop() const {\n\n return action_ == Action::DROP;\n\n }\n\n bool isToCPU() const {\n\n return action_ == Action::TO_CPU;\n\n }\n\n bool isSame(const RouteNextHopEntry& entry) const {\n\n return entry.getAdminDistance() == getAdminDistance();\n\n }\n\n\n\n // Reset the NextHopSet\n\n void reset() {\n\n nhopSet_.clear();\n\n action_ = Action::DROP;\n\n counterID_ = std::nullopt;\n\n }\n\n\n\n bool isValid(bool forMplsRoute = false) const;\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 96, "score": 140374.24312955336 }, { "content": " const std::optional<RouteCounterID> getCounterID() const {\n\n return counterID_;\n\n }\n\n\n\n NextHopSet normalizedNextHops() const;\n\n\n\n // Get the sum of the weights of all the nexthops in the entry\n\n NextHopWeight getTotalWeight() const;\n\n\n\n std::string str() const;\n\n\n\n /*\n\n * Serialize to folly::dynamic\n\n */\n\n folly::dynamic toFollyDynamic() const;\n\n\n\n /*\n\n * Deserialize from folly::dynamic\n\n */\n\n static RouteNextHopEntry fromFollyDynamic(const folly::dynamic& entryJson);\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 97, "score": 140373.9333560538 }, { "content": "\n\n static RouteNextHopEntry from(\n\n const facebook::fboss::UnicastRoute& route,\n\n AdminDistance defaultAdminDistance,\n\n std::optional<RouteCounterID> counterID);\n\n static RouteNextHopEntry from(\n\n const facebook::fboss::MplsRoute& route,\n\n AdminDistance defaultAdminDistance,\n\n std::optional<RouteCounterID> counterID);\n\n static facebook::fboss::RouteNextHopEntry createDrop(\n\n AdminDistance adminDistance = AdminDistance::STATIC_ROUTE);\n\n static facebook::fboss::RouteNextHopEntry createToCpu(\n\n AdminDistance adminDistance = AdminDistance::STATIC_ROUTE);\n\n static facebook::fboss::RouteNextHopEntry fromStaticRoute(\n\n const cfg::StaticRouteWithNextHops& route);\n\n static facebook::fboss::RouteNextHopEntry fromStaticIp2MplsRoute(\n\n const cfg::StaticIp2MplsRoute& route);\n\n static facebook::fboss::RouteNextHopEntry fromStaticMplsRoute(\n\n const cfg::StaticMplsRouteWithNextHops& route);\n\n static bool isUcmp(const NextHopSet& nhopSet);\n", "file_path": "fboss/agent/state/RouteNextHopEntry.h", "rank": 98, "score": 140368.93454964296 }, { "content": "class AclTtl {\n\n public:\n\n AclTtl(const AclTtl& ttl) {\n\n setValue(ttl.value_);\n\n setMask(ttl.mask_);\n\n }\n\n\n\n AclTtl(const uint16_t value, const uint16_t mask) {\n\n setValue(value);\n\n setMask(mask);\n\n }\n\n\n\n uint16_t getValue() const {\n\n return value_;\n\n }\n\n\n\n void setValue(uint16_t value) {\n\n if (value > 255) {\n\n throw FbossError(\"ttl value is invalid (must be [0,255])\");\n\n }\n", "file_path": "fboss/agent/state/AclEntry.h", "rank": 99, "score": 140360.75915112163 } ]
C++
src/hermite.cpp
azurite/AST-245-N-Body
cc3e3acd61f62415c1e5f40c8aba5b93703837fa
#include <iostream> #include <fstream> #include <chrono> #include <hermite.hpp> Hermite::Hermite() { t = .0; dt = 0.01; eps = 0.01; N = 0; filename = ""; lean = false; blockSize = 1; } void Hermite::enableLean() { if(!lean) lean = true; } void Hermite::disableLean() { if(lean) lean = false; } void Hermite::setBlockSize(int size) { if(size >= 1) { blockSize = size; } } void Hermite::setSoftening(double newEps) { eps = newEps; } void Hermite::integrate(double dt, int numSteps) { std::cout << "starting integration of: " << filename << std::endl; std::cout << "-------------------------------------------" << std::endl; std::cout << "N: " << N << std::endl; std::cout << "dt: " << dt << std::endl; std::cout << "softening: " << eps << std::endl; std::cout << "time interval: [0, " << (numSteps * dt) << "]" << std::endl; totalData = MatrixXd::Zero(3, (numSteps / blockSize + 1) * N); energy = VectorXd::Zero(numSteps); this->dt = dt; t = 0; auto start = std::chrono::high_resolution_clock::now(); for(int step = 0; step < numSteps; step++) { if(step % blockSize == 0) { totalData.block(0, (step / blockSize)*N, 3, N) = particles.block(1, 0, 3, N); } this->computeEnergy(step); this->step(); t += dt; } energy = (((energy(0) * VectorXd::Ones(numSteps)) - energy) / energy(0)).cwiseAbs(); auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> time = end - start; std::cout << "simulation time: " << time.count() << "s" << std::endl; std::cout << "-------------------------------------------" << std::endl; std::cout << std::endl; if(!lean) { std::ofstream file_pos(filename + ".output_pos.txt"); for(int i = 0; i < totalData.rows(); i++) { for(int j = 0; j < totalData.cols(); j++) { file_pos << totalData(i, j) << " "; } file_pos << std::endl; } } std::ofstream file_energy(filename + ".output_energy.txt"); for(int i = 0; i <= energy.size() - blockSize; i += blockSize) { file_energy << energy(i) << " "; } file_energy << std::endl; std::ofstream file_meta(filename + ".output_meta.txt"); file_meta << N << " " << dt << " " << (numSteps * dt) << " " << eps << std::endl; } void Hermite::computeEnergy(int step) { double etot = .0; double mi, mj, dx, dy, dz, vx, vy, vz; for(int i = 0; i < N; i++) { double subtract = .0; mi = particles(0, i); vx = particles(4, i); vy = particles(5, i); vz = particles(6, i); for(int j = 0; j < i; j++) { mj = particles(0, j); dx = particles(1, j) - particles(1, i); dy = particles(2, j) - particles(2, i); dz = particles(3, j) - particles(3, i); subtract += (mj / std::sqrt(dx*dx + dy*dy + dz*dz + eps*eps)); } etot += (mi * (0.5 * (vx*vx + vy*vy + vz*vz) - subtract)); } energy(step) = etot; } MatrixXd Hermite::computeForces(const MatrixXd mass, const MatrixXd pos, const MatrixXd vel) { double mi, mj, dx, dy, dz, dvx, dvy, dvz, sqrtInvDist, sqrtInvDist3, sqrtInvDist5, vdotr, ax, ay, az, jx, jy, jz; MatrixXd acc_and_jerk = MatrixXd::Zero(6, N); for(int i = 0; i < N; i++) { for(int j = i + 1; j < N; j++) { mj = mass(0, j); dx = pos(0, i) - pos(0, j); dy = pos(1, i) - pos(1, j); dz = pos(2, i) - pos(2, j); dvx = vel(0, i) - vel(0, j); dvy = vel(1, i) - vel(1, j); dvz = vel(2, i) - vel(2, j); sqrtInvDist = 1.0 / std::sqrt(dx * dx + dy * dy + dz * dz + eps * eps); sqrtInvDist3 = sqrtInvDist * sqrtInvDist * sqrtInvDist; sqrtInvDist5 = sqrtInvDist3 * sqrtInvDist * sqrtInvDist; vdotr = dvx * dx + dvy * dy + dvz * dz; ax = -mj * dx * sqrtInvDist3; ay = -mj * dy * sqrtInvDist3; az = -mj * dz * sqrtInvDist3; acc_and_jerk(0, i) += ax; acc_and_jerk(1, i) += ay; acc_and_jerk(2, i) += az; acc_and_jerk(0, j) -= ax; acc_and_jerk(1, j) -= ay; acc_and_jerk(2, j) -= az; jx = -mj * ((dvx * sqrtInvDist3) - (3 * vdotr * dx) * sqrtInvDist5); jy = -mj * ((dvy * sqrtInvDist3) - (3 * vdotr * dy) * sqrtInvDist5); jz = -mj * ((dvz * sqrtInvDist3) - (3 * vdotr * dz) * sqrtInvDist5); acc_and_jerk(3, i) += jx; acc_and_jerk(4, i) += jy; acc_and_jerk(5, i) += jz; acc_and_jerk(3, j) -= jx; acc_and_jerk(4, j) -= jy; acc_and_jerk(5, j) -= jz; } } return acc_and_jerk; } void Hermite::step() { MatrixXd masses = particles.topRows(1); x0 = particles.block(1, 0, 3, N); v0 = particles.block(4, 0, 3, N); MatrixXd acc_and_jerk0 = computeForces(masses, x0, v0); a0 = acc_and_jerk0.topRows(3); jerk0 = acc_and_jerk0.bottomRows(3); xp = (x0 + (v0 * dt) + (a0 * (0.5 * dt * dt)) + (jerk0 * (0.1667 * dt * dt * dt))); vp = (v0 + (a0 * dt) + (jerk0 * (0.5 * dt * dt))); MatrixXd acc_and_jerk1 = computeForces(masses, xp, vp); a1 = acc_and_jerk1.topRows(3); jerk1 = acc_and_jerk1.bottomRows(3); v1 = v0 + ((a0 + a1) * 0.5 * dt) + ((jerk0 - jerk1) * 0.0833 * dt * dt); x1 = x0 + ((v0 + v1) * 0.5 * dt) + ((a0 - a1) * 0.0833 * dt * dt); particles.block(1, 0, 3, N) = x1; particles.block(4, 0, 3, N) = v1; } bool Hermite::readData(const std::string &filename) { std::ifstream infile(filename); int numParticles, numGasParticles, numStarParticles; if(infile.is_open()) { infile >> numParticles >> numGasParticles >> numStarParticles; particles = Eigen::MatrixXd::Zero(HERMITE_DATA_ROWS, numParticles); N = numParticles; this->filename = filename; for(int i = 0; i < numParticles; i++) { infile >> particles(0, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(1, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(2, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(3, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(4, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(5, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(6, i); } infile >> eps; return true; } std::cout << "Hermite::readData(\"" << filename << "\") " << "could not read file" << std::endl; return false; } const Matrix<double, 3, Dynamic> &Hermite::data() { return totalData; }
#include <iostream> #include <fstream> #include <chrono> #include <hermite.hpp> Hermite::Hermite() { t = .0; dt = 0.01; eps = 0.01; N = 0; filename = ""; lean = false; blockSize = 1; } void Hermite::enableLean() { if(!lean) lean = true; } void Hermite::disableLean() { if(lean) lean = false; } void Hermite::setBlockSize(int size) { if(size >= 1) { blockSize = size; } } void Hermite::setSoftening(double newEps) { eps = newEps; } void Hermite::integrate(double dt, int numSteps) { std::cout << "starting integration of: " << filename << std::endl; std::cout << "-------------------------------------------" << std::endl; std::cout << "N: " << N << std::endl; std::cout << "dt: " << dt << std::endl; std::cout << "softening: " << eps << std::endl; std::cout << "time interval: [0, " << (numSteps * dt) << "]" << std::endl; totalData = MatrixXd::Zero(3, (numSteps / blockSize + 1) * N); energy = VectorXd::Zero(numSteps); this->dt = dt; t = 0; auto start = std::chrono::high_resolution_clock::now(); for(int step = 0; step < numSteps; step++) { if(step % blockSize == 0) { totalData.block(0, (step / blockSize)*N, 3, N) = particles.block(1, 0, 3, N); } this->computeEnergy(step); this->step(); t += dt; } energy = (((energy(0) * VectorXd::Ones(numSteps)) - energy) / energy(0)).cwiseAbs(); auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> time = end - start; std::cout << "simulation time: " << time.count() << "s" << std::endl; std::cout << "-------------------------------------------" << std::endl; std::cout << std::endl;
std::ofstream file_energy(filename + ".output_energy.txt"); for(int i = 0; i <= energy.size() - blockSize; i += blockSize) { file_energy << energy(i) << " "; } file_energy << std::endl; std::ofstream file_meta(filename + ".output_meta.txt"); file_meta << N << " " << dt << " " << (numSteps * dt) << " " << eps << std::endl; } void Hermite::computeEnergy(int step) { double etot = .0; double mi, mj, dx, dy, dz, vx, vy, vz; for(int i = 0; i < N; i++) { double subtract = .0; mi = particles(0, i); vx = particles(4, i); vy = particles(5, i); vz = particles(6, i); for(int j = 0; j < i; j++) { mj = particles(0, j); dx = particles(1, j) - particles(1, i); dy = particles(2, j) - particles(2, i); dz = particles(3, j) - particles(3, i); subtract += (mj / std::sqrt(dx*dx + dy*dy + dz*dz + eps*eps)); } etot += (mi * (0.5 * (vx*vx + vy*vy + vz*vz) - subtract)); } energy(step) = etot; } MatrixXd Hermite::computeForces(const MatrixXd mass, const MatrixXd pos, const MatrixXd vel) { double mi, mj, dx, dy, dz, dvx, dvy, dvz, sqrtInvDist, sqrtInvDist3, sqrtInvDist5, vdotr, ax, ay, az, jx, jy, jz; MatrixXd acc_and_jerk = MatrixXd::Zero(6, N); for(int i = 0; i < N; i++) { for(int j = i + 1; j < N; j++) { mj = mass(0, j); dx = pos(0, i) - pos(0, j); dy = pos(1, i) - pos(1, j); dz = pos(2, i) - pos(2, j); dvx = vel(0, i) - vel(0, j); dvy = vel(1, i) - vel(1, j); dvz = vel(2, i) - vel(2, j); sqrtInvDist = 1.0 / std::sqrt(dx * dx + dy * dy + dz * dz + eps * eps); sqrtInvDist3 = sqrtInvDist * sqrtInvDist * sqrtInvDist; sqrtInvDist5 = sqrtInvDist3 * sqrtInvDist * sqrtInvDist; vdotr = dvx * dx + dvy * dy + dvz * dz; ax = -mj * dx * sqrtInvDist3; ay = -mj * dy * sqrtInvDist3; az = -mj * dz * sqrtInvDist3; acc_and_jerk(0, i) += ax; acc_and_jerk(1, i) += ay; acc_and_jerk(2, i) += az; acc_and_jerk(0, j) -= ax; acc_and_jerk(1, j) -= ay; acc_and_jerk(2, j) -= az; jx = -mj * ((dvx * sqrtInvDist3) - (3 * vdotr * dx) * sqrtInvDist5); jy = -mj * ((dvy * sqrtInvDist3) - (3 * vdotr * dy) * sqrtInvDist5); jz = -mj * ((dvz * sqrtInvDist3) - (3 * vdotr * dz) * sqrtInvDist5); acc_and_jerk(3, i) += jx; acc_and_jerk(4, i) += jy; acc_and_jerk(5, i) += jz; acc_and_jerk(3, j) -= jx; acc_and_jerk(4, j) -= jy; acc_and_jerk(5, j) -= jz; } } return acc_and_jerk; } void Hermite::step() { MatrixXd masses = particles.topRows(1); x0 = particles.block(1, 0, 3, N); v0 = particles.block(4, 0, 3, N); MatrixXd acc_and_jerk0 = computeForces(masses, x0, v0); a0 = acc_and_jerk0.topRows(3); jerk0 = acc_and_jerk0.bottomRows(3); xp = (x0 + (v0 * dt) + (a0 * (0.5 * dt * dt)) + (jerk0 * (0.1667 * dt * dt * dt))); vp = (v0 + (a0 * dt) + (jerk0 * (0.5 * dt * dt))); MatrixXd acc_and_jerk1 = computeForces(masses, xp, vp); a1 = acc_and_jerk1.topRows(3); jerk1 = acc_and_jerk1.bottomRows(3); v1 = v0 + ((a0 + a1) * 0.5 * dt) + ((jerk0 - jerk1) * 0.0833 * dt * dt); x1 = x0 + ((v0 + v1) * 0.5 * dt) + ((a0 - a1) * 0.0833 * dt * dt); particles.block(1, 0, 3, N) = x1; particles.block(4, 0, 3, N) = v1; } bool Hermite::readData(const std::string &filename) { std::ifstream infile(filename); int numParticles, numGasParticles, numStarParticles; if(infile.is_open()) { infile >> numParticles >> numGasParticles >> numStarParticles; particles = Eigen::MatrixXd::Zero(HERMITE_DATA_ROWS, numParticles); N = numParticles; this->filename = filename; for(int i = 0; i < numParticles; i++) { infile >> particles(0, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(1, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(2, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(3, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(4, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(5, i); } for(int i = 0; i < numParticles; i++) { infile >> particles(6, i); } infile >> eps; return true; } std::cout << "Hermite::readData(\"" << filename << "\") " << "could not read file" << std::endl; return false; } const Matrix<double, 3, Dynamic> &Hermite::data() { return totalData; }
if(!lean) { std::ofstream file_pos(filename + ".output_pos.txt"); for(int i = 0; i < totalData.rows(); i++) { for(int j = 0; j < totalData.cols(); j++) { file_pos << totalData(i, j) << " "; } file_pos << std::endl; } }
if_condition
[ { "content": " VectorXd energy;\n\n std::string filename;\n\n bool lean; // if set to true solver will not write position files because they can get quite large\n\n int blockSize;\n\n Matrix<double, 3, Dynamic> totalData; // positions of all particles over all time steps\n\n\n\n void computeEnergy(int step);\n\n void step();\n\n MatrixXd computeForces(const MatrixXd mass, const MatrixXd pos, const MatrixXd vel);\n\npublic:\n\n Hermite();\n\n void enableLean();\n\n void disableLean();\n\n void setBlockSize(int size);\n\n void setSoftening(double newEps);\n\n void integrate(double dt, int numSteps);\n\n bool readData(const std::string &filename);\n\n const Matrix<double, 3, Dynamic> &data();\n\n};\n\n\n\n#endif // HERMITE_H\n", "file_path": "include/hermite.hpp", "rank": 0, "score": 22652.22725448479 }, { "content": "#include <fstream>\n\n#include <vector>\n\n#include <particle.hpp>\n\n\n\n#ifndef DATA_H\n\n#define DATA_H\n\n\n", "file_path": "include/data.hpp", "rank": 1, "score": 22637.58025642516 }, { "content": "#include <iostream>\n\n#include <Eigen/Dense>\n\n\n\nusing Eigen::Vector3f;\n\n\n\n#ifndef PARTICLE_H\n\n#define PARTICLE_H\n\n\n", "file_path": "include/particle.hpp", "rank": 2, "score": 22637.178532391878 }, { "content": " Vector3f r();\n\n void set_r(Vector3f r);\n\n\n\n float Vx();\n\n void set_Vx(float Vx);\n\n float Vy();\n\n void set_Vy(float Vy);\n\n float Vz();\n\n void set_Vz(float Vz);\n\n Vector3f v();\n\n void set_v(Vector3f v);\n\n\n\n float soft();\n\n void set_soft(float s);\n\n float pot();\n\n void set_pot(float p);\n\n\n\n float radius2();\n\n float radius();\n\n\n\n std::string toString() const;\n\n void print() const;\n\n\n\n friend std::ostream &operator<<(std::ostream &os, const Particle &p);\n\n};\n\n\n\n#endif // PARTICLE_H\n", "file_path": "include/particle.hpp", "rank": 3, "score": 22634.641367984124 }, { "content": "#include <Eigen/Dense>\n\n\n\nusing Eigen::Matrix;\n\nusing Eigen::MatrixXd;\n\nusing Eigen::VectorXd;\n\nusing Eigen::Vector3d;\n\nusing Eigen::Dynamic;\n\n\n\n#ifndef HERMITE_H\n\n#define HERMITE_H\n\n\n\n#define HERMITE_DATA_ROWS 7\n\n\n", "file_path": "include/hermite.hpp", "rank": 4, "score": 22633.443189866986 }, { "content": "#include <unsupported/Eigen/CXX11/Tensor>\n\n#include <Eigen/Dense>\n\n\n\nusing Eigen::Matrix;\n\nusing Eigen::Dynamic;\n\nusing Eigen::Tensor;\n\nusing Eigen::VectorXcf;\n\nusing Eigen::Vector3i;\n\nusing Eigen::Vector3f;\n\n\n\n#ifndef GRAVITYSOLVERS_H\n\n#define GRAVITYSOLVERS_H\n\n\n\n/*\n\n MatrixData[:,j] = [m, x, y, z, vx, vy, vz, fx, fy, fz]\n\n*/\n\n#define MATRIX_DATA_ROWS 10\n\ntypedef Matrix<float, MATRIX_DATA_ROWS, Dynamic> MatrixData;\n\n\n\n#define FIELD_TENSOR_DIMENSIONS 3\n\ntypedef Tensor<std::complex<float>, FIELD_TENSOR_DIMENSIONS> FieldTensorCF;\n\ntypedef Tensor<float, FIELD_TENSOR_DIMENSIONS> FieldTensorF;\n\n\n\nnamespace Gravitysolver {\n", "file_path": "include/gravitysolvers.hpp", "rank": 5, "score": 22633.333565969966 }, { "content": "import os\n\nimport numpy as np\n\nfrom numpy import loadtxt\n\nimport matplotlib.pyplot as plt\n\nfrom mpl_toolkits.mplot3d import Axes3D\n\n\n\nfrom matplotlib import rcParams\n\nrcParams.update({'figure.autolayout': True})\n\n\n\nbasedir_data = \"data/\"\n\nbasedir_plot = \"\"\n\nmetaname = basedir_data + \"meta.txt\"\n\n\n\nplotSize = (12,8)\n\n\n\nfiles = [\n\n \"data_n2_circular.dat.output\",\n\n \"data_n2_elliptic.dat.output\",\n\n \"data_n32.dat.output\",\n\n \"data_n64.dat.output\",\n\n \"data_n128.dat.output\",\n\n \"data_n256.dat.output\"\n\n ]\n\n\n\n# plot the positions of the integrations\n\nfor file in files:\n\n fullname = basedir_data + file + \"_pos.txt\"\n\n metaname = basedir_data + file + \"_meta.txt\"\n\n\n\n if os.path.exists(fullname):\n\n N, dt, T, eps = loadtxt(metaname)\n\n data = loadtxt(fullname)\n\n textstr = \"\\n\".join((\n\n r'N = %d' % N,\n\n r'Softening = %g' % (eps),\n\n r'Time Step = %g' % (dt),\n\n r'Time Interval = [0, %g]' % (T)\n\n ))\n\n\n\n fig = plt.figure(figsize=plotSize)\n\n fig.text(0.05, 0.85, textstr, fontsize=12)\n\n ax = fig.add_subplot(111, projection='3d')\n\n ax.scatter(\n\n xs=data[0],\n\n ys=data[1],\n\n zs=data[2],\n\n s=0.02,\n\n label=\"Planet Trajectory\"\n\n )\n\n ax.legend()\n\n fig.savefig(basedir_plot + file + \"_pos.png\")\n\n\n\n\n\n# Plot the energies of the integrations\n\nfor file in files:\n\n fullname = basedir_data + file + \"_energy.txt\"\n\n metaname = basedir_data + file + \"_meta.txt\"\n\n\n\n if os.path.exists(fullname):\n\n N, dt, T, eps = loadtxt(metaname)\n\n energy = loadtxt(fullname)\n\n time = np.arange(0, T, T / len(energy))\n\n fig, ax = plt.subplots(figsize=plotSize)\n\n\n\n labelstr = \" \".join((\n\n r'${\\Delta}$t = %g' % dt,\n\n r'${\\epsilon}$ = %g' % eps,\n\n r'N = %d' % N\n\n ))\n\n\n\n ax.plot(time, energy, \"b\", label=labelstr)\n\n ax.set(\n\n xlabel='time',\n\n ylabel='|[E(0) - E(t)]/E(0)|',\n\n title='Relative Energy Error',\n\n )\n\n ax.grid()\n\n ax.legend()\n\n fig.savefig(basedir_plot + file + \"_energy.png\")\n", "file_path": "plot.py", "rank": 6, "score": 21971.10439274909 }, { "content": "#ifndef SECOND_TASK_H\n\n#define SECOND_TASK_H\n\n\n\nvoid second_task();\n\n\n\n#endif // SECOND_TASK_H\n", "file_path": "include/second_task.hpp", "rank": 7, "score": 20953.904101908203 }, { "content": "#ifndef FIRST_TASK_H\n\n#define FIRST_TASK_H\n\n\n\nvoid first_task();\n\nfloat compute_relaxation();\n\n\n\n#endif // FIRST_TASK_H\n", "file_path": "include/first_task.hpp", "rank": 8, "score": 20953.794287787376 }, { "content": "class Particle\n\n{\n\n float mass; // Mass\n\n Vector3f pos; // Position Vector (x, y, z)\n\n Vector3f velocity; // Velocity Vector (vx, vy, vz)\n\n float softening;\n\n float potential;\n\n\n\npublic:\n\n Particle();\n\n Particle(float m, float x, float y, float z, float Vx, float Vy, float Vz, float softening, float potential);\n\n\n\n float m();\n\n void set_m(float m);\n\n float x();\n\n void set_x(float x);\n\n float y();\n\n void set_y(float y);\n\n float z();\n\n void set_z(float z);\n", "file_path": "include/particle.hpp", "rank": 9, "score": 20951.529904743904 }, { "content": "class Data\n\n{\n\npublic:\n\n static std::vector<Particle> *readFromFile(const std::string &filename);\n\n};\n\n\n\n#endif // DATA_H\n", "file_path": "include/data.hpp", "rank": 10, "score": 20951.529904743904 }, { "content": "class Hermite\n\n{\n\nprivate:\n\n int N; // number of particles\n\n double t; // current simulation time\n\n double dt; // integration timestep\n\n double eps; // softening\n\n\n\n Matrix<double, HERMITE_DATA_ROWS, Dynamic> particles;\n\n Matrix<double, 3, Dynamic> x0; // current positions\n\n Matrix<double, 3, Dynamic> v0; // current velocities\n\n Matrix<double, 3, Dynamic> xp; // predicted next positions\n\n Matrix<double, 3, Dynamic> vp; // predicted next velocities\n\n Matrix<double, 3, Dynamic> x1; // corrected next positions\n\n Matrix<double, 3, Dynamic> v1; // corrected next velocities\n\n Matrix<double, 3, Dynamic> a0; // predicted accelerations\n\n Matrix<double, 3, Dynamic> a1; // corrected accelerations\n\n Matrix<double, 3, Dynamic> jerk0; // predicted jerks\n\n Matrix<double, 3, Dynamic> jerk1; // corrected jerks\n\n\n", "file_path": "include/hermite.hpp", "rank": 11, "score": 20951.529904743904 }, { "content": " class DataIO\n\n {\n\n protected:\n\n float epsilon;\n\n MatrixData particles;\n\n public:\n\n DataIO();\n\n bool readDataOld(const std::string &filename);\n\n bool readData(const std::string &filename);\n\n bool writeData(const std::string &filename);\n\n };\n\n\n", "file_path": "include/gravitysolvers.hpp", "rank": 12, "score": 19503.79220169871 }, { "content": " class Direct : public DataIO\n\n {\n\n public:\n\n Direct();\n\n float softening();\n\n void setSoftening(float eps);\n\n void solve();\n\n const MatrixData &data();\n\n };\n\n\n", "file_path": "include/gravitysolvers.hpp", "rank": 13, "score": 17135.66463559887 }, { "content": " class PM : public DataIO\n\n {\n\n private:\n\n int Ng; // number of cells per dimension\n\n float h; // cell size\n\n float worldLen; // the size of the smallest enclosing cube of the galaxy\n\n FieldTensorCF density;\n\n FieldTensorCF greenFunction;\n\n FieldTensorCF potential;\n\n FieldTensorF ax;\n\n FieldTensorF ay;\n\n FieldTensorF az;\n\n Vector3i worldToGrid(float x, float y, float z);\n\n Vector3f gridToWorld(int i, int j, int k);\n\n void fft3d(FieldTensorCF &t);\n\n void ifft3d(FieldTensorCF &t);\n\n void conv3d(FieldTensorCF &out, FieldTensorCF &in, FieldTensorCF &kernel);\n\n public:\n\n PM(int numGridCells);\n\n void solve();\n\n const MatrixData &data();\n\n };\n\n}\n\n\n\n#endif // GRAVITYSOLVERS_H\n", "file_path": "include/gravitysolvers.hpp", "rank": 14, "score": 17135.66463559887 }, { "content": "#### void Hermite::integrate( \\<double\\>, \\<int\\>)\n\n\n\nCalling `integrate(dt, numSteps)` evolves the system with timestep `dt` for `numSteps` steps and (depending on the lean mode) writes the result of the simulation to a file.\n\n\n\n#### const Matrix<double, 3, Dynamic> &Hermite::data()\n\n\n\nReturns the state of the system over the entire simulation time. Each column contains the [x, y, z] position of the particles. The columns 0 to n-1 contain the state of n particles at the first time step, columns n to 2n-1 contain the state of n particles at the next (or a multiple of next depending on the block size) time step and so on.\n\n\n\n### Example Usage\n\n\n\n```cpp\n\n#include <gravitysolvers.hpp>\n\n#include <hermite.hpp>\n\n\n\nint main()\n\n{\n\n Gravitysolver::Direct *direct = new Gravitysolver::Direct();\n\n\n\n direct->readData(\"data.txt\");\n\n direct->setSoftening(0.001);\n\n direct->solve();\n\n direct->writeData(\"forces.txt\");\n\n\n\n Hermite *hermite = new Hermite();\n\n\n\n hermite->readData(\"data.txt\");\n\n hermite->setSoftening(0.001);\n\n hermite->setBlockSize(20);\n\n hermite->enableLean();\n\n hermite->integrate(0.01, 1000);\n\n\n\n return 0;\n\n}\n\n```\n", "file_path": "README.md", "rank": 15, "score": 11852.031012257965 }, { "content": "### Gravitysolver::PM\n\n\n\n* **Note this solver has not been tested for correctness and should therefore not be used!** Right now it uses the unsupported Eigen Tensor for the mesh which is not nearly as efficient as the Eigen matrices.\n\n\n\nComputes the n-body forces from a set of initial conditions by constructing a particle mesh whose size in one dimension is specified in the constructor. It computes the forces by solving the poisson equation with a fast fourier transform. It scales as `O(n³log(n))` where n is the number of mesh cells along one dimension. The interface is identical to the direct solver class except that the methods to get and set the softening are missing.\n\n\n\n### Hermite\n\n\n\nReads a set of initial conditions, evolves the system for a specified amount of time and writes the state of the system and the relative energy error over the entire time (for each timestep) to ouput files. One file for the particle positions and one file for the energy error.\n\n\n\n#### bool Hermite::readData( \\<filename\\> )\n\n\n\nReads a set of initial conditions from a file with the same format as specified in `Gravitysolver::Direct::readDataOld`. The very last value of the file can hold the softening if you whish to do so.\n\n\n\n#### void Hermite::setSoftening( \\<double\\> )\n\n\n\nSets the softening for the evolution to the function's input value\n\n\n\n#### void Hermite::enableLean()\n\n\n\nOnly writes the energy error to a file. Can be useful if the file for the positions becomes extremely large and one want's to avoid writing it.\n\n\n\n#### void Hermite::disableLean()\n\n\n\nInverse of `enableLean()`. If calling the simulation function now the particles positions are written to a file again.\n\n\n\n#### void Hermite::setBlockSize( \\<int\\> )\n\n\n\nOnly keeps track of every k-th iteration in the simulation where k is the function's input. This allows to save a lot of memory when usign very small step sizes.\n\n\n", "file_path": "README.md", "rank": 16, "score": 11846.79495382117 }, { "content": "#### bool Gravitysolver::Direct::readData( \\<filename\\> )\n\n\n\nReads a header in the format `N eps` where N is the number of particles and eps is the softening. It then reads the data particle by particle so `mass, x, y, z, vx, vy, vz` of particle i then `mass, x, y, z, vx, vy, vz` of particle i+1 and so on. The function returns `true` when successful and `false` otherwise. In the case of an unsuccessful read the console should give some output.\n\n\n\n#### bool Gravitysolver::Direct::writeData( \\<filename\\> )\n\n\n\nWrites the particles to a file in the same format as being used by the `readData()` function above. The function returns `true` when successfully writing the file and `false` otherwise. In the case of an unsuccessful write the console should give some output.\n\n\n\n#### float Gravitysolver::Direct::softening()\n\n\n\nReturns the currently used softening for the solver.\n\n\n\n#### void Gravitysolver::Direct::setSoftening( \\<float\\> )\n\n\n\nSets the softening value used by the solver to the function's input.\n\n\n\n#### Gravitysolver::Direct::solve()\n\n\n\nComputes the n-body forces acting on each particle with the direct summation algorithm.\n\n\n\n#### const MatrixData &Gravitysolver::Direct::data()\n\n\n\nReturns the current state (mass, position, velocity, force) of all particles in the form of a 10xN Eigen Matrix `Matrix<float, 10, Dynamic>` where the i-th column holds the state of the i-th particle in the form of `[mass, x, y, z, vx, vz, vz, fx, fy, fz]`. Note that until either `readDataOld()` or `readData()` have been called the output of the function remains uninitialized.\n\n\n", "file_path": "README.md", "rank": 17, "score": 11842.289234349339 }, { "content": "# AST-245 N-Body\n\n\n\nThis Repository contains the code for the N-Body project from the [UZH](https://www.uzh.ch/en.html) course on [Computational Astrophysics](http://www.vvz.ethz.ch/Vorlesungsverzeichnis/lerneinheit.view?semkez=2019W&ansicht=LEHRVERANSTALTUNGEN&lerneinheitId=132986&lang=en).\n\n\n\n## Dependencies\n\n\n\nYou'll need [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) for the code to compile. If needed change the `EIGEN` variable in the makefile to the path of your eigen source files. You'll need [MathGL 2.0](http://mathgl.sourceforge.net/) or higher to plot the data of the first task and [Python 3](https://www.python.org/download/releases/3.0/) or higher to plot the data of the second task.\n\n\n\n## Usage\n\n\n\nSimply compile the code with `make` and run it with `./main.out`. The plots for the first task are generated directly. The second task produces output files with data. To plot that data use `python3 plot.py`. The code will perform the necessary tasks for the project but the solvers are fully encapsulated and can be used on their own.\n\n\n\n## Documentation\n\n\n\n### Gravitysolver::Direct\n\n\n\nComputes the n-body forces from a set of initial conditions with the direct summation algorithm in `O(n²)` where n is the number of particles. The initial conditions can be read in two ways\n\n\n\n#### bool Gravitysolver::Direct::readDataOld( \\<filename\\> )\n\n\n\nReads a set of initial conditions in the format according to the data provided by the project. The data file is made of a header and sequential arrays, as follows: Number of particles(N), Number of gas particles(NG), Number of star particles (NS).\n\n\n\n```\n\nN NG NS\n\nMasses[i]\n\nx[i]\n\ny[i]\n\nz[i]\n\nVx[i]\n\nVy[i]\n\nVz[i]\n\n```\n\n\n\nNote that the data first runns through all N masses then through all N x coordinates, all N y coordinates, all N z coordinates etc. The function returns `true` when successful and `false` otherwise. In the case of an unsuccessful read the console should give some output.\n\n\n", "file_path": "README.md", "rank": 18, "score": 11837.361957760237 }, { "content": " for(float eps = softening / 8; eps <= softening * 8; eps *= 2, i++) {\n\n solver->setSoftening(eps);\n\n\n\n auto start = std::chrono::high_resolution_clock::now();\n\n\n\n solver->solve();\n\n\n\n auto end = std::chrono::high_resolution_clock::now();\n\n std::chrono::duration<double> time = end - start;\n\n\n\n solver->writeData(\"data/direct-nbody-\" + std::to_string(i) + \".txt\");\n\n\n\n std::cout << \"Done [\" << i << \"/\" << total << \"] time: \" << time.count() << \"s\" << std::endl;\n\n }\n\n\n\n delete solver;\n\n}\n\n\n\nint main(int argc, char **argv)\n\n{\n\n precompute_nbody_forces();\n\n first_task();\n\n second_task();\n\n return 0;\n\n}\n", "file_path": "src/main.cpp", "rank": 24, "score": 16.471096979951835 }, { "content": "#include <iostream>\n\n#include <chrono>\n\n#include <first_task.hpp>\n\n#include <second_task.hpp>\n\n\n\n#include <gravitysolvers.hpp>\n\n#include <hermite.hpp>\n\n\n\nvoid precompute_nbody_forces()\n\n{\n\n float softening = 4.34998; // mean interparticle separation\n\n\n\n Gravitysolver::Direct *solver = new Gravitysolver::Direct();\n\n solver->readDataOld(\"data/data.ascii\");\n\n\n\n int total = 7;\n\n int i = 1;\n\n\n\n std::cout << \"Starting N-Body-Forces Precomputation\" << std::endl;\n\n\n", "file_path": "src/main.cpp", "rank": 25, "score": 14.717228149404535 }, { "content": "\n\nvoid step2()\n\n{\n\n r0 = 0.005;\n\n int numSteps = 100;\n\n\n\n std::vector<float> softenings;\n\n std::vector<float> dAnalytic;\n\n std::vector<float> rInput;\n\n\n\n // creates evenly spaced intervals on a log scale on the interval [r0, radius]\n\n // drLinToLog(i) gives the start of the ith interval on [r0, radius]\n\n auto drLinToLog = [&](int i) {\n\n return r0 * std::pow(radius / r0, (float)i / (float)numSteps);\n\n };\n\n\n\n // transforms the numerical data into a dimension desirable for plotting\n\n // here we want to plot the magnitude of the force and add a small nonzero\n\n // number to the force to avoid problems with 0 on log scales since log(0) is undefined\n\n auto plotFit = [](float x) {\n", "file_path": "src/first_task.cpp", "rank": 26, "score": 11.755520384154567 }, { "content": " 0.00025,\n\n 0.0005,\n\n 0.001,\n\n 0.002\n\n };\n\n\n\n Hermite *solver = new Hermite();\n\n solver->setBlockSize(10);\n\n\n\n for(int i = 0; i < files.size(); i++) {\n\n\n\n if(i == 2)\n\n solver->setBlockSize(250);\n\n\n\n solver->readData(files[i]);\n\n solver->integrate(dt[i], T / dt[i]);\n\n }\n\n\n\n delete solver;\n\n}\n", "file_path": "src/second_task.cpp", "rank": 27, "score": 9.991165143223434 }, { "content": "{\n\n r0 = 0.005;\n\n int numSteps = 50;\n\n\n\n std::vector<float> hDensity;\n\n std::vector<float> nDensity;\n\n std::vector<float> rInput;\n\n std::vector<float> errors;\n\n\n\n // creates evenly spaced intervals on a log scale on the interval [r0, radius]\n\n // drLinToLog(i) gives the start of the ith interval on [r0, radius]\n\n auto drLinToLog = [&](int i) {\n\n return r0 * std::pow(radius / r0, (float)i / (float)numSteps);\n\n };\n\n\n\n // transforms the numerical data into a dimension desirable for plotting\n\n // here we want to avoid problems with 0 on log scales since log(0) is undefined\n\n auto plotFit = [](float x) {\n\n return x + std::numeric_limits<float>::epsilon();\n\n };\n", "file_path": "src/first_task.cpp", "rank": 28, "score": 9.405842237407063 }, { "content": "#include <iostream>\n\n#include <data.hpp>\n\n#include <particle.hpp>\n\n\n\n/*\n\n* The data file is made of a header and sequential arrays(each array as a single column data entry), as follows: Header\n\n* Number of particles(N), Number of gas particles(N*=0 there is actually no gas particle), Number of star particles\n\n* Arrays(running in i=1,...,N)\n\n* Masses[i]\n\n* x[i]\n\n* y[i]\n\n* z[i]\n\n* Vx[i]\n\n* Vy[i]\n\n* Vz[i]\n\n* softening[i]\n\n* potential[i]\n\n*/\n\n\n\nstd::vector<Particle> *Data::readFromFile(const std::string &filename)\n", "file_path": "src/data.cpp", "rank": 30, "score": 8.469610847430587 }, { "content": "// ************************************************************************* //\n\n// ***************************** DIRECT SOLVER ***************************** //\n\n// ************************************************************************* //\n\n\n\nGravitysolver::Direct::Direct()\n\n{\n\n\n\n}\n\n\n\nfloat Gravitysolver::Direct::softening()\n\n{\n\n return epsilon;\n\n}\n\n\n\nvoid Gravitysolver::Direct::setSoftening(float eps)\n\n{\n\n epsilon = eps;\n\n}\n\n\n\nvoid Gravitysolver::Direct::solve()\n", "file_path": "src/gravitysolvers.cpp", "rank": 31, "score": 8.454637317473416 }, { "content": "#include <iostream>\n\n#include <fstream>\n\n#include <Eigen/Dense>\n\n#include <unsupported/Eigen/FFT>\n\n#include <gravitysolvers.hpp>\n\n\n\n// ************************************************************************* //\n\n// ******************************** DATA IO ******************************** //\n\n// ************************************************************************* //\n\n\n\nGravitysolver::DataIO::DataIO()\n\n{\n\n epsilon = 0.0;\n\n}\n\n\n\nbool Gravitysolver::DataIO::readDataOld(const std::string &filename)\n\n{\n\n std::ifstream infile(filename);\n\n int numParticles, numGasParticles, numStarParticles;\n\n\n", "file_path": "src/gravitysolvers.cpp", "rank": 32, "score": 8.160539085276143 }, { "content": "#include <iostream>\n\n#include <vector>\n\n#include <second_task.hpp>\n\n#include <hermite.hpp>\n\n\n\nvoid second_task()\n\n{\n\n const std::vector<std::string> files = {\n\n \"data/data_n2_circular.dat\",\n\n \"data/data_n2_elliptic.dat\",\n\n \"data/data_n32.dat\",\n\n \"data/data_n64.dat\",\n\n \"data/data_n128.dat\",\n\n \"data/data_n256.dat\"\n\n };\n\n\n\n const double T = 100;\n\n const std::vector<double> dt = {\n\n 0.001,\n\n 0.001,\n", "file_path": "src/second_task.cpp", "rank": 33, "score": 7.6861028642086975 }, { "content": " std::cout << \" r0: \" << r0 << std::endl;\n\n std::cout << \" rhm: \" << rhm << std::endl;\n\n std::cout << \" scaleLength: \" << scaleLength << std::endl;\n\n std::cout << \" softening: \" << epsilon << std::endl;\n\n std::cout << \" t_relax: \" << t_relax << std::endl;\n\n std::cout << \"------------------\" << std::endl;\n\n}\n\n\n\nfloat compute_relaxation()\n\n{\n\n // Assumption: G = 1\n\n float N = particles.size();\n\n float vc = std::sqrt(totalMass * 0.5 / rhm);\n\n float t_cross = rhm / vc;\n\n float t_relax = N / (8 * std::log(N)) * t_cross;\n\n\n\n return t_relax;\n\n}\n\n\n\nvoid step1()\n", "file_path": "src/first_task.cpp", "rank": 36, "score": 6.736468400190958 }, { "content": "#include <iostream>\n\n#include <Eigen/Dense>\n\n#include <particle.hpp>\n\n\n\nusing Eigen::Vector3f;\n\n\n\nParticle::Particle()\n\n{\n\n mass = 0.0;\n\n pos << 0.0, 0.0, 0.0;\n\n velocity << 0.0, 0.0, 0.0;\n\n softening = 0.0;\n\n potential = 0.0;\n\n}\n\n\n\nParticle::Particle(float m, float x, float y, float z, float Vx, float Vy, float Vz, float s, float p)\n\n{\n\n mass = m;\n\n pos << x, y, z;\n\n velocity << Vx, Vy, Vz;\n", "file_path": "src/particle.cpp", "rank": 37, "score": 6.566722695792292 }, { "content": " particles(7, j) = fx;\n\n particles(8, j) = fy;\n\n particles(9, j) = fz;\n\n }\n\n\n\n return true;\n\n }\n\n\n\n std::cout << \"Gravitysolver::DataIO::readData(\\\"\" << filename << \"\\\") \" << \"could not read file\" << std::endl;\n\n return false;\n\n}\n\n\n\nbool Gravitysolver::DataIO::writeData(const std::string &filename)\n\n{\n\n std::ofstream outfile(filename);\n\n int N = particles.cols();\n\n\n\n if(outfile.is_open()) {\n\n outfile << N << \" \" << epsilon << \"\\n\";\n\n\n", "file_path": "src/gravitysolvers.cpp", "rank": 41, "score": 5.727566377469466 }, { "content": "#include <iostream>\n\n#include <memory>\n\n#include <algorithm>\n\n#include <iomanip>\n\n#include <math.h>\n\n#include <cmath>\n\n#include <mgl2/mgl.h>\n\n#include <Eigen/Dense>\n\n\n\n#include <data.hpp>\n\n#include <particle.hpp>\n\n#include <gravitysolvers.hpp>\n\n#include <first_task.hpp>\n\n\n\nstd::unique_ptr<std::vector<Particle>> p(Data::readFromFile(\"data.ascii\"));\n\nstd::vector<Particle> particles = *p;\n\n\n\nfloat pMass = 0.0;\n\nfloat totalMass = 0.0;\n\nfloat radius = 0.0;\n", "file_path": "src/first_task.cpp", "rank": 42, "score": 5.299704528516994 }, { "content": " softening = s;\n\n potential = p;\n\n}\n\n\n\nfloat Particle::m()\n\n{\n\n return mass;\n\n}\n\n\n\nvoid Particle::set_m(float m)\n\n{\n\n mass = m;\n\n}\n\n\n\nfloat Particle::x()\n\n{\n\n return pos(0);\n\n}\n\n\n\nvoid Particle::set_x(float x)\n", "file_path": "src/particle.cpp", "rank": 43, "score": 5.222552142015263 }, { "content": "{\n\n velocity(2) = Vz;\n\n}\n\n\n\nVector3f Particle::v()\n\n{\n\n return velocity;\n\n}\n\n\n\nvoid Particle::set_v(Vector3f v)\n\n{\n\n velocity = v;\n\n}\n\n\n\nfloat Particle::soft()\n\n{\n\n return softening;\n\n}\n\n\n\nvoid Particle::set_soft(float s)\n", "file_path": "src/particle.cpp", "rank": 44, "score": 5.097016739302061 }, { "content": " }\n\n}\n\n\n\nvoid Gravitysolver::PM::conv3d(FieldTensorCF &out, FieldTensorCF &in, FieldTensorCF &kernel)\n\n{\n\n int x = in.dimension(0);\n\n int y = in.dimension(1);\n\n int z = in.dimension(2);\n\n\n\n fft3d(in);\n\n fft3d(kernel);\n\n\n\n for(int i = 0; i < x; i++) {\n\n for(int j = 0; j < y; j++) {\n\n for(int k = 0; k < z; k++) {\n\n out(i,j,k) = in(i,j,k) * kernel(i,j,k);\n\n }\n\n }\n\n }\n\n\n", "file_path": "src/gravitysolvers.cpp", "rank": 45, "score": 5.065281501298293 }, { "content": " for(int j = 0; j < N; j++) {\n\n outfile << particles(0, j) << \"\\n\"; // m\n\n outfile << particles(1, j) << \"\\n\"; // x\n\n outfile << particles(2, j) << \"\\n\"; // y\n\n outfile << particles(3, j) << \"\\n\"; // z\n\n outfile << particles(4, j) << \"\\n\"; // vx\n\n outfile << particles(5, j) << \"\\n\"; // vy\n\n outfile << particles(6, j) << \"\\n\"; // vz\n\n outfile << particles(7, j) << \"\\n\"; // fx\n\n outfile << particles(8, j) << \"\\n\"; // fy\n\n outfile << particles(9, j) << \"\\n\"; // fz\n\n }\n\n\n\n return true;\n\n }\n\n\n\n std::cout << \"Gravitysolver::DataIO::writeData(\\\"\" << filename << \"\\\") \" << \"could not write file\" << std::endl;\n\n return false;\n\n}\n\n\n", "file_path": "src/gravitysolvers.cpp", "rank": 46, "score": 5.0139461506909955 }, { "content": " return std::abs(x) + std::numeric_limits<float>::epsilon();\n\n };\n\n\n\n // calculate the analytical force in the hernquist model\n\n for(int i = 0; i <= numSteps; i++) {\n\n float r = drLinToLog(i);\n\n dAnalytic.push_back(plotFit(force_hernquist(r)));\n\n rInput.push_back(r);\n\n }\n\n\n\n std::unique_ptr<Gravitysolver::Direct> solver(new Gravitysolver::Direct());\n\n std::vector<mglData> plotData;\n\n\n\n for(int i = 1; i <= 7; i++) {\n\n solver->readData(\"data/direct-nbody-\" + std::to_string(i) + \".txt\");\n\n softenings.push_back(solver->softening());\n\n\n\n std::vector<float> dNumeric;\n\n\n\n // project the force vector of each particle towards the center of the system\n", "file_path": "src/first_task.cpp", "rank": 47, "score": 5.011609438435576 }, { "content": " }\n\n\n\n for(int i = 0; i < x; i++) { // and for each of the x*y spikes pointing upwards in z-dir do a 1D fft\n\n for(int j = 0; j < y; j++) {\n\n\n\n VectorXcf tv(z);\n\n for(int k = 0; k < z; k++)\n\n tv(k) = t(i, j, k);\n\n\n\n VectorXcf fv = fft.fwd(tv);\n\n for(int k = 0; k < z; k++)\n\n t(i, j, k) = fv(k);\n\n }\n\n }\n\n}\n\n\n\nvoid Gravitysolver::PM::ifft3d(FieldTensorCF &t)\n\n{\n\n const int x = t.dimension(0);\n\n const int y = t.dimension(1);\n", "file_path": "src/gravitysolvers.cpp", "rank": 48, "score": 4.8836586100925405 }, { "content": "bool Gravitysolver::DataIO::readData(const std::string &filename)\n\n{\n\n std::ifstream infile(filename);\n\n int N;\n\n\n\n if(infile.is_open()) {\n\n infile >> N >> epsilon;\n\n particles = Eigen::MatrixXf::Zero(MATRIX_DATA_ROWS, N);\n\n\n\n float m, x, y, z, vx, vy, vz, fx, fy, fz;\n\n\n\n for(int j = 0; j < N; j++) {\n\n infile >> m >> x >> y >> z >> vx >> vy >> vz >> fx >> fy >> fz;\n\n particles(0, j) = m;\n\n particles(1, j) = x;\n\n particles(2, j) = y;\n\n particles(3, j) = z;\n\n particles(4, j) = vx;\n\n particles(5, j) = vy;\n\n particles(6, j) = vz;\n", "file_path": "src/gravitysolvers.cpp", "rank": 49, "score": 4.789214045521124 }, { "content": "\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> particles(4, i); // vx\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> particles(5, i); // vy\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> particles(6, i); // vz\n\n }\n\n\n\n return true;\n\n }\n\n\n\n std::cout << \"Gravitysolver::DataIO::readDataOld(\\\"\" << filename << \"\\\") \" << \"could not read file\" << std::endl;\n\n return false;\n\n}\n\n\n", "file_path": "src/gravitysolvers.cpp", "rank": 50, "score": 4.602187371597432 }, { "content": " for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n vx.push_back(curr);\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n vy.push_back(curr);\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n vz.push_back(curr);\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n softening.push_back(curr);\n\n }\n\n\n", "file_path": "src/data.cpp", "rank": 51, "score": 4.561974315024982 }, { "content": "{\n\n softening = s;\n\n}\n\n\n\nfloat Particle::pot()\n\n{\n\n return potential;\n\n}\n\n\n\nvoid Particle::set_pot(float p)\n\n{\n\n potential = p;\n\n}\n\n\n\nfloat Particle::radius2()\n\n{\n\n return pos.squaredNorm();\n\n}\n\n\n\nfloat Particle::radius()\n", "file_path": "src/particle.cpp", "rank": 52, "score": 4.39471181137099 }, { "content": "*/\n\nVector3f Gravitysolver::PM::gridToWorld(int i, int j, int k)\n\n{\n\n Vector3f worldCoor;\n\n\n\n worldCoor(0) = (i * worldLen / Ng) - (worldLen / 2) + (h / 2);\n\n worldCoor(1) = (j * worldLen / Ng) - (worldLen / 2) + (h / 2);\n\n worldCoor(2) = (k * worldLen / Ng) - (worldLen / 2) + (h / 2);\n\n\n\n return worldCoor;\n\n}\n\n\n\nvoid Gravitysolver::PM::fft3d(FieldTensorCF &t)\n\n{\n\n const int x = t.dimension(0);\n\n const int y = t.dimension(1);\n\n const int z = t.dimension(2);\n\n\n\n Eigen::FFT<float> fft;\n\n\n", "file_path": "src/gravitysolvers.cpp", "rank": 53, "score": 4.325756535943571 }, { "content": " ifft3d(out);\n\n}\n\n\n\nvoid Gravitysolver::PM::solve()\n\n{\n\n const int N = particles.cols();\n\n Vector3f maxPos = particles.block(1, 0, 3, N).rowwise().maxCoeff();\n\n Vector3f minPosAbs = particles.block(1, 0, 3, N).rowwise().minCoeff().cwiseAbs();\n\n\n\n worldLen = std::max(maxPos.maxCoeff(), minPosAbs.maxCoeff()) * 2;\n\n\n\n // adds one layer of cells in each dimension so particles at the edge will\n\n // contribute with their entire mass to the density field\n\n worldLen += (worldLen / Ng);\n\n h = worldLen / Ng;\n\n\n\n std::cout << \"PM solver global parameters\" << std::endl;\n\n std::cout << \"---------------------------\" << std::endl;\n\n std::cout << \"worldLen: \" << worldLen << std::endl;\n\n std::cout << \"Ng: \" << Ng << std::endl;\n", "file_path": "src/gravitysolvers.cpp", "rank": 54, "score": 4.31167746393754 }, { "content": "\n\n for(int i = 0; i <= numSteps; i++) {\n\n float r = drLinToLog(i);\n\n float r1 = drLinToLog(i + 1);\n\n float MShell = Mass(r1, true) - Mass(r, true);\n\n float VShell = 4.0/3.0*M_PI*(r1*r1*r1 - r*r*r);\n\n\n\n float nRho = MShell / VShell;\n\n float numParticlesInShell = MShell / pMass;\n\n\n\n // p = n*m/v, err = sqrt(n) =>\n\n // p_err = sqrt(n)/n*p = sqrt(n)*n*m/(n*v) = sqrt(n)*m/v\n\n // p = density, n = #particles, m = pMass\n\n float rhoError = std::sqrt(numParticlesInShell) * pMass / VShell;\n\n\n\n hDensity.push_back(plotFit(density_hernquist((r + r1) / 2)));\n\n nDensity.push_back(plotFit(nRho));\n\n errors.push_back(rhoError);\n\n rInput.push_back(r);\n\n }\n", "file_path": "src/first_task.cpp", "rank": 55, "score": 4.105161848040385 }, { "content": "\n\n mglData cData;\n\n cData.Set(dNumeric.data(), dNumeric.size());\n\n plotData.push_back(cData);\n\n }\n\n\n\n mglData aData;\n\n aData.Set(dAnalytic.data(), dAnalytic.size());\n\n\n\n mglData rData;\n\n rData.Set(rInput.data(), rInput.size());\n\n\n\n mglGraph gr(0, 1200, 800);\n\n\n\n float outMin;\n\n float outMax;\n\n\n\n for(int i = 0; i < plotData.size(); i++) {\n\n outMin = std::max(std::min(plotData[i].Minimal(), aData.Minimal()), 50.0);\n\n outMax = std::max(plotData[i].Maximal(), aData.Maximal());\n", "file_path": "src/first_task.cpp", "rank": 56, "score": 4.0639760912232745 }, { "content": " for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n potential.push_back(curr);\n\n }\n\n\n\n std::vector<Particle> *particles = new std::vector<Particle>();\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n Particle p(mass[i], x[i], y[i], z[i], vx[i], vy[i], vz[i], softening[i], potential[i]);\n\n particles->push_back(p);\n\n }\n\n\n\n return particles;\n\n }\n\n else {\n\n std::cout << \"Could not open file\" << std::endl;\n\n return NULL;\n\n }\n\n}\n", "file_path": "src/data.cpp", "rank": 57, "score": 3.985046845458453 }, { "content": " float r = drLinToLog(i);\n\n float r1 = drLinToLog(i + 1);\n\n float dr = r1 - r;\n\n\n\n float f = 0.0;\n\n int numParticles = 0;\n\n\n\n // calculate the average gravitational force in a shell\n\n for(int i = 0; i < particles.size(); i++) {\n\n Particle p = particles[i];\n\n\n\n if(r <= p.radius() && p.radius() < r1) {\n\n f += f_center(i);\n\n numParticles++;\n\n }\n\n }\n\n\n\n f = (numParticles == 0 ? .0 : f / numParticles);\n\n dNumeric.push_back(plotFit(f));\n\n }\n", "file_path": "src/first_task.cpp", "rank": 58, "score": 3.879745298306529 }, { "content": " }\n\n\n\n gr.SetRange('x', rData);\n\n gr.SetRange('y', outMin, outMax);\n\n\n\n gr.SetFontSize(2);\n\n gr.SetCoor(mglLogLog);\n\n gr.Axis();\n\n\n\n gr.Label('x', \"Radius [l]\", 0);\n\n gr.Label('y', \"Force [m]^2[l]^{-2}\", 0);\n\n\n\n gr.Plot(rData, aData, \"b\");\n\n gr.AddLegend(\"Analytic\", \"b\");\n\n\n\n // colors for plotting\n\n const char *opt[7] = {\"r +\", \"c +\", \"m +\", \"h +\", \"l +\", \"n +\", \"q +\"};\n\n\n\n for(int i = 0; i < plotData.size(); i++) {\n\n std::stringstream ss;\n", "file_path": "src/first_task.cpp", "rank": 59, "score": 3.804728492346892 }, { "content": " ss << \"\\\\epsilon = \" << std::setprecision(4) << softenings[i] << \" [l]\";\n\n\n\n gr.Plot(rData, plotData[i], opt[i]);\n\n gr.AddLegend(ss.str().c_str(), opt[i]);\n\n }\n\n\n\n gr.Legend();\n\n gr.WritePNG(\"forces.png\");\n\n}\n\n\n\nvoid first_task()\n\n{\n\n calculate_constants();\n\n step1();\n\n step2();\n\n}\n", "file_path": "src/first_task.cpp", "rank": 60, "score": 3.734352990910134 }, { "content": " const MatrixData &solverData = solver->data();\n\n Eigen::VectorXf f_center(solverData.cols());\n\n\n\n float fx, fy, fz, x, y, z, norm;\n\n\n\n for(int i = 0; i < solverData.cols(); i++) {\n\n x = solverData(1, i);\n\n y = solverData(2, i);\n\n z = solverData(3, i);\n\n fx = solverData(7, i);\n\n fy = solverData(8, i);\n\n fz = solverData(9, i);\n\n\n\n norm = std::sqrt(x*x + y*y + z*z);\n\n\n\n // project the force vector onto the normalized sphere normal\n\n f_center(i) = (x*fx + y*fy + z*fz) / norm;\n\n }\n\n\n\n for(int i = 0; i <= numSteps; i++) {\n", "file_path": "src/first_task.cpp", "rank": 61, "score": 3.4333825867461014 }, { "content": " const int z = t.dimension(2);\n\n\n\n const float invXYZ = 1.0 / (x*y*z);\n\n\n\n for(int i = 0; i < x; i++) {\n\n for(int j = 0; j < y; j++) {\n\n for(int k = 0; k < z; k++) {\n\n t(i,j,k) = std::conj(t(i,j,k));\n\n }\n\n }\n\n }\n\n\n\n fft3d(t);\n\n\n\n for(int i = 0; i < x; i++) {\n\n for(int j = 0; j < y; j++) {\n\n for(int k = 0; k < z; k++) {\n\n t(i,j,k) = std::conj(t(i,j,k)) * invXYZ;\n\n }\n\n }\n", "file_path": "src/gravitysolvers.cpp", "rank": 62, "score": 3.269403443673103 }, { "content": " for(int k = 0; k < z; k++) { // for each 2d sheet make a 2d fft\n\n for(int j = 0; j < y; j++) { // fft in x-dir\n\n VectorXcf tv(x);\n\n for(int i = 0; i < x; i++)\n\n tv(i) = t(i, j, k);\n\n\n\n VectorXcf fv = fft.fwd(tv);\n\n for(int i = 0; i < x; i++)\n\n t(i, j, k) = fv(i);\n\n }\n\n\n\n for(int i = 0; i < x; i++) { // fft in y-dir\n\n VectorXcf tv(y);\n\n for(int j = 0; j < y; j++)\n\n tv(j) = t(i, j, k);\n\n\n\n VectorXcf fv = fft.fwd(tv);\n\n for(int j = 0; j < y; j++)\n\n t(i, j, k) = fv(j);\n\n }\n", "file_path": "src/gravitysolvers.cpp", "rank": 63, "score": 3.086427342373993 }, { "content": "{\n\n pos(0) = x;\n\n}\n\n\n\nfloat Particle::y()\n\n{\n\n return pos(1);\n\n}\n\n\n\nvoid Particle::set_y(float y)\n\n{\n\n pos(1) = y;\n\n}\n\n\n\nfloat Particle::z()\n\n{\n\n return pos(2);\n\n}\n\n\n\nvoid Particle::set_z(float z)\n", "file_path": "src/particle.cpp", "rank": 65, "score": 2.917649581873259 }, { "content": "{\n\n pos(2) = z;\n\n}\n\n\n\nVector3f Particle::r()\n\n{\n\n return pos;\n\n}\n\n\n\nvoid Particle::set_r(Vector3f r)\n\n{\n\n pos = r;\n\n}\n\n\n\nfloat Particle::Vx()\n\n{\n\n return velocity(0);\n\n}\n\n\n\nvoid Particle::set_Vx(float Vx)\n", "file_path": "src/particle.cpp", "rank": 66, "score": 2.83322371732387 }, { "content": " for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n mass.push_back(curr);\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n x.push_back(curr);\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n y.push_back(curr);\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> curr;\n\n z.push_back(curr);\n\n }\n\n\n", "file_path": "src/data.cpp", "rank": 67, "score": 2.800327852583775 }, { "content": "\n\n mglData hData;\n\n hData.Set(hDensity.data(), hDensity.size());\n\n\n\n mglData nData;\n\n nData.Set(nDensity.data(), nDensity.size());\n\n\n\n mglData rData;\n\n rData.Set(rInput.data(), rInput.size());\n\n\n\n mglData eData;\n\n eData.Set(errors.data(), errors.size());\n\n\n\n mglGraph gr(0, 1200, 800);\n\n\n\n float outMin = std::min(hData.Minimal(), nData.Minimal());\n\n float outMax = std::max(hData.Maximal(), nData.Maximal());\n\n\n\n gr.SetRange('x', rData);\n\n gr.SetRange('y', outMin, outMax);\n", "file_path": "src/first_task.cpp", "rank": 68, "score": 2.7954361504482272 }, { "content": "{\n\n velocity(0) = Vx;\n\n}\n\n\n\nfloat Particle::Vy()\n\n{\n\n return velocity(1);\n\n}\n\n\n\nvoid Particle::set_Vy(float Vy)\n\n{\n\n velocity(1) = Vy;\n\n}\n\n\n\nfloat Particle::Vz()\n\n{\n\n return velocity(2);\n\n}\n\n\n\nvoid Particle::set_Vz(float Vz)\n", "file_path": "src/particle.cpp", "rank": 69, "score": 2.7028720407416342 }, { "content": " if(infile.is_open()) {\n\n infile >> numParticles >> numGasParticles >> numStarParticles;\n\n\n\n particles = Eigen::MatrixXf::Zero(MATRIX_DATA_ROWS, numParticles);\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> particles(0, i); // m\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> particles(1, i); // x\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> particles(2, i); // y\n\n }\n\n\n\n for(int i = 0; i < numParticles; i++) {\n\n infile >> particles(3, i); // z\n\n }\n", "file_path": "src/gravitysolvers.cpp", "rank": 70, "score": 2.6879255951637457 }, { "content": " greenFunction(2*Ng-i-1, 2*Ng-j-1, 2*Ng-k-1) = res;\n\n }\n\n }\n\n }\n\n\n\n // solve the poisson equation to get the potential\n\n conv3d(potential, density, greenFunction);\n\n\n\n // calculate acceleration field from potential\n\n for(int i = 1; i < Ng - 1; i++) {\n\n for(int j = 1; j < Ng - 1; j++) {\n\n for(int k = 1; k < Ng - 1; k++) {\n\n ax(i, j, k) = -(potential(i+1,j,k).real() - potential(i-1,j,k).real()) / (2*h);\n\n ay(i, j, k) = -(potential(i,j+1,k).real() - potential(i,j-1,k).real()) / (2*h);\n\n az(i, j, k) = -(potential(i,j,k+1).real() - potential(i,j,k-1).real()) / (2*h);\n\n }\n\n }\n\n }\n\n\n\n // interpolate acceleration field back from mesh to particles\n", "file_path": "src/gravitysolvers.cpp", "rank": 71, "score": 2.3846431027711175 }, { "content": "{\n\n std::vector<float> mass;\n\n std::vector<float> x;\n\n std::vector<float> y;\n\n std::vector<float> z;\n\n std::vector<float> vx;\n\n std::vector<float> vy;\n\n std::vector<float> vz;\n\n std::vector<float> softening;\n\n std::vector<float> potential;\n\n\n\n // This is just the file format, note that we only need the first of the three numbers\n\n int numParticles, numGasParticles, numStarParticles;\n\n float curr;\n\n\n\n std::ifstream infile(\"data/\" + filename);\n\n infile >> numParticles >> numGasParticles >> numStarParticles;\n\n\n\n if(infile.is_open()) {\n\n // calculate the total mass of the system on the fly\n", "file_path": "src/data.cpp", "rank": 72, "score": 2.360484455969841 }, { "content": " density(ti(0), ti(1), ti(2)) += (m / (h*h*h));\n\n }\n\n\n\n // green's function construction\n\n for(int i = 0; i < Ng; i++) {\n\n for(int j = 0; j < Ng; j++) {\n\n for(int k = 0; k < Ng; k++) {\n\n Vector3f worldPos = gridToWorld(i, j, k);\n\n\n\n // Assumption: G = 1\n\n float res = -1.0 / worldPos.norm();\n\n\n\n // make the function symmetric accross all axes\n\n greenFunction(i, j, k) = res;\n\n greenFunction(i, j, 2*Ng-k-1) = res;\n\n greenFunction(i, 2*Ng-j-1, k) = res;\n\n greenFunction(i, 2*Ng-j-1, 2*Ng-k-1) = res;\n\n greenFunction(2*Ng-i-1, j, k) = res;\n\n greenFunction(2*Ng-i-1, j, 2*Ng-k-1) = res;\n\n greenFunction(2*Ng-i-1, 2*Ng-j-1, k) = res;\n", "file_path": "src/gravitysolvers.cpp", "rank": 73, "score": 2.2261001321312595 }, { "content": "{\n\n for(int i = 0; i < particles.cols(); i++) {\n\n particles(7, i) = .0;\n\n particles(8, i) = .0;\n\n particles(9, i) = .0;\n\n }\n\n\n\n float mi, mj, dx, dy, dz, sqrtInvDist, sqrtInvDist3, fx, fy, fz;\n\n\n\n for(int i = 0; i < particles.cols(); i++) {\n\n for(int j = i + 1; j < particles.cols(); j++) {\n\n mi = particles(0, i);\n\n mj = particles(0, j);\n\n dx = particles(1, i) - particles(1, j);\n\n dy = particles(2, i) - particles(2, j);\n\n dz = particles(3, i) - particles(3, j);\n\n\n\n sqrtInvDist = 1.0 / std::sqrt(dx * dx + dy * dy + dz * dz + epsilon * epsilon);\n\n sqrtInvDist3 = sqrtInvDist * sqrtInvDist * sqrtInvDist;\n\n\n", "file_path": "src/gravitysolvers.cpp", "rank": 74, "score": 2.1544798475654483 }, { "content": "\n\n // exact mean inter-particle separation\n\n /*\n\n epsilon = .0;\n\n\n\n for(Particle &p : particles) {\n\n for(Particle &q : particles) {\n\n epsilon += (p.r() - q.r()).norm();\n\n }\n\n }\n\n\n\n long n = particles.size();\n\n epsilon /= (n*(n-1));\n\n */\n\n\n\n std::cout << \"First Task \" << std::endl;\n\n std::cout << \"------------------\" << std::endl;\n\n std::cout << \" pMass: \" << pMass << std::endl;\n\n std::cout << \" totalMass: \" << totalMass << std::endl;\n\n std::cout << \" radius: \" << radius << std::endl;\n", "file_path": "src/first_task.cpp", "rank": 76, "score": 1.7483784487068554 }, { "content": "float scaleLength = 0.0;\n\nfloat epsilon = 0.0; // softening\n\nfloat t_relax = 0.0;\n\nfloat r0 = std::numeric_limits<float>::max(); // center of system to avoid problems with dividing by 0\n\nfloat rhm = 0.0; // half mass radius\n\n\n\nfloat Mass(float r, bool strictlyLess = false)\n\n{\n\n float M = 0.0;\n\n\n\n for(Particle &p : particles) {\n\n float r2 = p.radius2();\n\n\n\n if((!strictlyLess && r2 <= r*r) || (strictlyLess && r2 < r*r)) {\n\n M += p.m();\n\n }\n\n }\n\n\n\n return M;\n\n}\n", "file_path": "src/first_task.cpp", "rank": 77, "score": 1.5955881423781895 }, { "content": "\n\nfloat density_hernquist(float r)\n\n{\n\n return (totalMass / (2 * M_PI)) * (scaleLength / r) * (1 / std::pow(r + scaleLength, 3));\n\n}\n\n\n\n// Computes force F where F = m*a\n\nfloat force_hernquist(float r)\n\n{\n\n // Assumption: G = 1\n\n return -totalMass * pMass / ((r + scaleLength) * (r + scaleLength));\n\n}\n\n\n\nvoid calculate_constants()\n\n{\n\n pMass = particles[0].m(); // all particles have the same mass\n\n\n\n for(Particle &p : particles) {\n\n totalMass += p.m();\n\n radius = std::max(p.radius2(), radius);\n", "file_path": "src/first_task.cpp", "rank": 78, "score": 1.548262647189576 }, { "content": "\n\n gr.SetFontSize(2);\n\n gr.SetCoor(mglLogLog);\n\n gr.Axis();\n\n\n\n gr.Label('x', \"Radius [l]\", 0);\n\n gr.Label('y', \"Density [m]/[l]^3\", 0);\n\n\n\n gr.Plot(rData, hData, \"b\");\n\n gr.AddLegend(\"Hernquist\", \"b\");\n\n\n\n gr.Plot(rData, nData, \"r .\");\n\n gr.AddLegend(\"Numeric\", \"r .\");\n\n\n\n gr.Error(rData, nData, eData, \"qo\");\n\n gr.AddLegend(\"Poissonian Error\", \"qo\");\n\n\n\n gr.Legend();\n\n gr.WritePNG(\"density_profiles.png\");\n\n}\n", "file_path": "src/first_task.cpp", "rank": 79, "score": 1.5252405822269548 }, { "content": "{\n\n return pos.norm();\n\n}\n\n\n\nstd::string Particle::toString() const\n\n{\n\n return \"{ mass=\" +\n\n std::to_string(mass) + \", x=\" +\n\n std::to_string(pos(0)) + \", y=\" +\n\n std::to_string(pos(1)) + \", z=\" +\n\n std::to_string(pos(2)) + \", Vx=\" +\n\n std::to_string(velocity(0)) + \", Vy=\" +\n\n std::to_string(velocity(1)) + \", Vz=\" +\n\n std::to_string(velocity(2)) + \" }\";\n\n}\n\n\n\nvoid Particle::print() const\n\n{\n\n std::cout << toString() << std::endl;\n\n}\n\n\n\nstd::ostream &operator<<(std::ostream &os, const Particle &p)\n\n{\n\n os << p.toString() << std::endl;\n\n return os;\n\n}\n", "file_path": "src/particle.cpp", "rank": 80, "score": 1.516293708179576 }, { "content": "// ************************************************************************* //\n\n// ******************************* PM SOLVER ******************************* //\n\n// ************************************************************************* //\n\n\n\nGravitysolver::PM::PM(int numGridCells)\n\n{\n\n // The Tensor in Eigen experiences a strange case of std::bad_alloc()\n\n // if it has more than 776 = 2*388 complex valued elements per dimension\n\n if(numGridCells > 0 && numGridCells <= 388) {\n\n Ng = numGridCells;\n\n }\n\n else {\n\n std::cout << \"Gravitysolver::PM::PM(\" << numGridCells << \") numGridCells must be > 0\" << std::endl;\n\n Ng = 1;\n\n }\n\n\n\n h = .0;\n\n}\n\n\n\n/**\n", "file_path": "src/gravitysolvers.cpp", "rank": 81, "score": 1.426916397909022 }, { "content": " for(int col = 0; col < particles.cols(); col++) {\n\n float m = particles(0, col);\n\n float px = particles(1, col);\n\n float py = particles(2, col);\n\n float pz = particles(3, col);\n\n\n\n // (NGP)\n\n Vector3i ti = worldToGrid(px, py, pz);\n\n\n\n // F = m*a\n\n particles(7, col) = m * ax(ti(0), ti(1), ti(2));\n\n particles(8, col) = m * ay(ti(0), ti(1), ti(2));\n\n particles(9, col) = m * az(ti(0), ti(1), ti(2));\n\n }\n\n}\n\n\n\nconst MatrixData &Gravitysolver::PM::data()\n\n{\n\n return particles;\n\n}\n", "file_path": "src/gravitysolvers.cpp", "rank": 82, "score": 1.3148480434033503 }, { "content": " std::cout << \"h: \" << h << std::endl;\n\n std::cout << \"---------------------------\" << std::endl;\n\n\n\n density.resize(2*Ng, 2*Ng, 2*Ng);\n\n greenFunction.resize(2*Ng, 2*Ng, 2*Ng);\n\n potential.resize(2*Ng, 2*Ng, 2*Ng);\n\n\n\n ax.resize(Ng, Ng, Ng);\n\n ay.resize(Ng, Ng, Ng);\n\n az.resize(Ng, Ng, Ng);\n\n\n\n // density field construction\n\n for(int col = 0; col < particles.cols(); col++) {\n\n float m = particles(0, col);\n\n float px = particles(1, col);\n\n float py = particles(2, col);\n\n float pz = particles(3, col);\n\n\n\n // (NGP)\n\n Vector3i ti = worldToGrid(px, py, pz);\n", "file_path": "src/gravitysolvers.cpp", "rank": 83, "score": 1.146076457993809 } ]
C++
sandbox/rootfs.cc
Codu-LLC/sandbox
f78cb0fb8705904ffcda370f3395ca134d5fd87e
#include "debug.h" #include "rootfs.h" #include "sandbox.h" #include "util.h" #include <fcntl.h> #include <iostream> #include <sys/types.h> #include <sys/mount.h> #include <sys/stat.h> #include <unistd.h> int setup_rootfs(Sandbox *ptr) { if (mount(ptr->get_src_root_fs_dir().c_str(), ptr->get_target_root_fs_dir().c_str(), "", MS_BIND | MS_REC, NULL) == -1) { return -1; } if (mkdir((ptr->get_target_root_fs_dir() + "/sandbox").c_str(), 0777) == -1 && errno != EEXIST) { print_string(ptr->is_debug(), "Making a directory for sandbox failed"); return -1; } if (mount(ptr->get_sandbox_dir().c_str(), (ptr->get_target_root_fs_dir() + "/sandbox").c_str(), "", MS_BIND, NULL) == -1) { print_string(ptr->is_debug(), "Mounting the sandbox directory failed."); return -1; } if (chdir(ptr->get_target_root_fs_dir().c_str()) == -1) { print_string(ptr->is_debug(), "Changing directory to the target rootfs failed."); return -1; } if (mkdir("sandbox/put_old", 0777) == -1 && errno != EEXIST) { print_string(ptr->is_debug(), "Making a directory for put_old failed."); return -1; } if (pivot_root(".", "sandbox/put_old") == -1) { print_string(ptr->is_debug(), "Pivot root failed."); return -1; } if (mount("sandbox/put_old/dev", "dev", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /dev failed."); return -1; } if (mount("", "dev", "", MS_SLAVE | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /dev failed."); return -1; } if (mount("sandbox/put_old/proc", "proc", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /proc failed."); return -1; } if (mount("", "proc", "", MS_SLAVE | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /proc failed."); return -1; } if (mount("sandbox/put_old/sys", "sys", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /sys failed."); return -1; } if (mount("", "sys", "", MS_SLAVE | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /sys failed."); return -1; } if (mount("sandbox/put_old/tmp", "tmp", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /tmp failed."); return -1; } if (umount2("sandbox/put_old", MNT_DETACH) == -1) { print_string(ptr->is_debug(), "Detaching old rootfs failed."); return -1; } if (remove("sandbox/put_old") == -1) { print_string(ptr->is_debug(), "Removing old rootfs failed."); return -1; } if (chdir("sandbox") == -1) { print_string(ptr->is_debug(), "Changing current directory to sandbox failed."); return -1; } int f = open("stat.txt", O_CREAT, 0777); if (f == -1) { print_string(ptr->is_debug(), "Creating stat file failed."); return -1; } close(f); return 0; }
#include "debug.h" #include "rootfs.h" #include "sandbox.h" #include "util.h" #include <fcntl.h> #include <iostream> #include <sys/types.h> #include <sys/mount.h> #include <sys/stat.h> #include <unistd.h> int setup_rootfs(Sandbox *ptr) { if (mount(ptr->get_src_root_fs_dir().c_str(), ptr->get_target_root_fs_dir().c_str(), "", MS_BIND | MS_REC, NULL) == -1) { return -1; } if (mkdir((ptr->get_target_root_fs_dir() + "/sandbox").c_str(), 0777) == -1 && errno != E
1; } if (umount2("sandbox/put_old", MNT_DETACH) == -1) { print_string(ptr->is_debug(), "Detaching old rootfs failed."); return -1; } if (remove("sandbox/put_old") == -1) { print_string(ptr->is_debug(), "Removing old rootfs failed."); return -1; } if (chdir("sandbox") == -1) { print_string(ptr->is_debug(), "Changing current directory to sandbox failed."); return -1; } int f = open("stat.txt", O_CREAT, 0777); if (f == -1) { print_string(ptr->is_debug(), "Creating stat file failed."); return -1; } close(f); return 0; }
EXIST) { print_string(ptr->is_debug(), "Making a directory for sandbox failed"); return -1; } if (mount(ptr->get_sandbox_dir().c_str(), (ptr->get_target_root_fs_dir() + "/sandbox").c_str(), "", MS_BIND, NULL) == -1) { print_string(ptr->is_debug(), "Mounting the sandbox directory failed."); return -1; } if (chdir(ptr->get_target_root_fs_dir().c_str()) == -1) { print_string(ptr->is_debug(), "Changing directory to the target rootfs failed."); return -1; } if (mkdir("sandbox/put_old", 0777) == -1 && errno != EEXIST) { print_string(ptr->is_debug(), "Making a directory for put_old failed."); return -1; } if (pivot_root(".", "sandbox/put_old") == -1) { print_string(ptr->is_debug(), "Pivot root failed."); return -1; } if (mount("sandbox/put_old/dev", "dev", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /dev failed."); return -1; } if (mount("", "dev", "", MS_SLAVE | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /dev failed."); return -1; } if (mount("sandbox/put_old/proc", "proc", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /proc failed."); return -1; } if (mount("", "proc", "", MS_SLAVE | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /proc failed."); return -1; } if (mount("sandbox/put_old/sys", "sys", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /sys failed."); return -1; } if (mount("", "sys", "", MS_SLAVE | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /sys failed."); return -1; } if (mount("sandbox/put_old/tmp", "tmp", "", MS_BIND | MS_REC, NULL) == -1) { print_string(ptr->is_debug(), "Mounting /tmp failed."); return -
random
[ { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/13/2021.\n\n//\n\n\n\n#include \"cgroup.h\"\n\n#include \"debug.h\"\n\n#include \"execution.h\"\n\n#include \"file.h\"\n\n#include \"limit.h\"\n\n#include <memory>\n\n#include <sched.h>\n\n#include <signal.h>\n\n#include <string>\n\n#include <sys/types.h>\n\n#include <sys/wait.h>\n\n#include <unistd.h>\n\n#include <iostream>\n\n#include <errno.h>\n\n\n\n#define MB_TO_BYTES(x) ((x) << 20)\n", "file_path": "sandbox/execution.cc", "rank": 1, "score": 7.351686040105021 }, { "content": "#ifndef _GNU_SOURCE\n\n#define _GNU_SOURCE\n\n#endif\n\n\n\n// The stack size is 256MB.\n\n#define STACK_SIZE 268435456\n\n#define PAGE_SIZE 4096\n\n\n\n#include \"debug.h\"\n\n#include \"execution.h\"\n\n#include \"file.h\"\n\n#include \"rootfs.h\"\n\n#include \"sandbox.h\"\n\n#include \"sandbox_builder.h\"\n\n#include \"util.h\"\n\n#include <errno.h>\n\n#include <iostream>\n\n#include <string>\n\n#include <string.h>\n\n#include <sys/wait.h>\n", "file_path": "sandbox/sandbox.cc", "rank": 2, "score": 7.089745831622842 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/21/2021.\n\n//\n\n\n\n#include \"file.h\"\n\n#include <cstdio>\n\n#include <string>\n\n#include <unistd.h>\n\n#include <iostream>\n\n\n\nbool File::write_file(const std::string &file_path, const std::string &str) {\n\n FILE *fd = fopen64(file_path.c_str(), \"w\");\n\n if (fd == NULL) {\n\n return false;\n\n }\n\n if (fputs(str.c_str(), fd) == -1) {\n\n fclose(fd);\n\n return false;\n\n }\n\n fclose(fd);\n", "file_path": "sandbox/file.cc", "rank": 3, "score": 6.5529097236097975 }, { "content": "\n\nstatic void run_child(Sandbox *ptr, int *fd) {\n\n // Close read file descriptor.\n\n if (close(fd[0]) == -1) {\n\n exit(EXIT_FAILURE);\n\n }\n\n if (unshare(CLONE_NEWUSER) == -1) {\n\n exit(EXIT_FAILURE);\n\n }\n\n print_string(ptr->is_debug(), \"After unshare\");\n\n debug_process(ptr->is_debug());\n\n std::vector<char *> argv;\n\n for (size_t i = 0; i < ptr->get_command().size(); i++) {\n\n argv.push_back(const_cast<char *>(ptr->get_command()[i].c_str()));\n\n }\n\n argv.push_back(NULL);\n\n char *env_variable[] = {NULL};\n\n set_sandbox_limit(ptr);\n\n if (execve(ptr->get_command().front().c_str(), &argv[0], env_variable) != 0) {\n\n std::cerr << \"execve error\" << std::endl;\n", "file_path": "sandbox/execution.cc", "rank": 4, "score": 6.180387237616434 }, { "content": " // Store output.\n\n // Set return code.\n\n ptr->set_return_code(status);\n\n // TODO(conankun): Add a signal catch to diversify verdict.\n\n debug_sandbox_stat(ptr);\n\n // Set time elapsed and memory usage.\n\n // TODO(conankun): Add safety check for std::stoll.\n\n ptr->set_time_elapsed(std::stoll(cgroup->get_property(\"cpuacct\", \"usage\")));\n\n ptr->set_memory_used(std::stoll(cgroup->get_property(\"memory\", \"max_usage_in_bytes\")));\n\n cgroup->delete_cgroup();\n\n return status;\n\n}\n\n\n\nint run_user_code(Sandbox *ptr) {\n\n int fd[2];\n\n // TODO(conankun): create the random cgroup name.\n\n auto cgroup = setup_cgroup(ptr, \"test_sandbox/subgroup\", true);\n\n if (cgroup == nullptr) {\n\n return -1;\n\n }\n", "file_path": "sandbox/execution.cc", "rank": 5, "score": 5.841525639762205 }, { "content": " std::cerr << \"Real UID: \" << getuid() << std::endl;\n\n std::cerr << \"Effective UID: \" << geteuid() << std::endl;\n\n }\n\n}\n\nvoid debug_sandbox_stat(Sandbox *ptr) {\n\n if (ptr->is_debug()) {\n\n std::cerr << \"========================= Statistics =========================\" << std::endl;\n\n std::cerr << \"Return code: \" << ptr->get_return_code() << std::endl;\n\n std::cerr << \"Signal: \" << WTERMSIG(ptr->get_return_code()) << std::endl;\n\n std::cerr << \"Time Elapsed: \" << ptr->get_time_elapsed() << \" ms\" << std::endl;\n\n std::cerr << \"Memory Used: \" << ptr->get_memory_used() << \" MB\" << std::endl;\n\n }\n\n}\n", "file_path": "sandbox/debug.cc", "rank": 6, "score": 5.5568750502252975 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/13/2021.\n\n//\n\n\n\n#include \"cgroup.h\"\n\n#include \"limit.h\"\n\n#include \"sandbox.h\"\n\n#include <cmath>\n\n#include <memory>\n\n#include <signal.h>\n\n#include <sys/resource.h>\n\n#include <string>\n\n#include <unistd.h>\n\n\n\n#define MB_TO_BYTES(x) ((x) << 20)\n\n#define MILLISECONDS_TO_SECONDS(x) ((x)/1000.)\n\n\n\nstd::unique_ptr <Cgroup> setup_cgroup(Sandbox *ptr, const std::string &cgroup_name, bool create) {\n\n auto cgroup = std::make_unique<Cgroup>(cgroup_name);\n\n cgroup->add_controller(\"cpu\");\n", "file_path": "sandbox/limit.cc", "rank": 8, "score": 5.4195128297472515 }, { "content": " std::string ret;\n\n ret.append(\"{\");\n\n ret.append(\"\\\"time_elapsed\\\": \" + std::to_string(sandbox.get_time_elapsed()) + \",\");\n\n ret.append(\"\\\"memory_used\\\": \" + std::to_string(sandbox.get_memory_used()) + \",\");\n\n ret.append(\"\\\"return_code\\\": \" + std::to_string(sandbox.get_return_code()));\n\n ret.append(\"}\");\n\n return ret;\n\n}\n\n\n\nstatic int launch_sandbox(void *args) {\n\n Sandbox *ptr = (Sandbox *) args;\n\n debug_process(ptr->is_debug());\n\n\n\n if (setup_rootfs(ptr) == -1) {\n\n std::cerr << \"setup rootfs failed\" << std::endl;\n\n return -1;\n\n }\n\n\n\n // TODO(conankun): Add seccomp.\n\n // Run the code provided by the user.\n", "file_path": "sandbox/sandbox.cc", "rank": 11, "score": 5.126376405888326 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/7/2021.\n\n//\n\n#include \"absl/flags/flag.h\"\n\n#include \"absl/flags/parse.h\"\n\n#include \"file.h\"\n\n#include \"sandbox.h\"\n\n#include \"sandbox_builder.h\"\n\n#include <cassert>\n\n#include <iostream>\n\n#include <string>\n\n#include <vector>\n\n\n\n#define NIL_INTEGER -1\n\n\n\n#define NIL_STRING std::string()\n\n\n\n#define NIL_STRING_ARRAY std::vector<std::string>()\n\n\n\nABSL_FLAG(bool, is_debug,\n", "file_path": "sandbox/main.cc", "rank": 12, "score": 5.0019016868374875 }, { "content": " perror(\"error: \");\n\n }\n\n // Close write file descriptor.\n\n if (close(fd[1]) == -1) {\n\n exit(EXIT_FAILURE);\n\n }\n\n}\n\n\n\n\n\nstatic int run_parent(Sandbox *ptr, std::unique_ptr<Cgroup> cgroup, pid_t pid, int *fd) {\n\n int status = 0;\n\n std::string output;\n\n\n\n while (true) {\n\n if (waitpid(pid, &status, WNOHANG) != 0) {\n\n break;\n\n }\n\n }\n\n waitpid(pid, &status, 0);\n\n // TODO(conankun): In case the process has not terminated, send SIGKILL.\n", "file_path": "sandbox/execution.cc", "rank": 14, "score": 4.812063307704487 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/13/2021.\n\n//\n\n\n\n#include \"debug.h\"\n\n#include \"sandbox.h\"\n\n#include <iostream>\n\n#include <string>\n\n#include <unistd.h>\n\n\n\nvoid print_string(bool debug, std::string str) {\n\n if (debug) {\n\n std::cerr << str << std::endl;\n\n }\n\n}\n\n\n\nvoid debug_process(bool debug) {\n\n if (debug) {\n\n std::cerr << \"PID: \" << getpid() << std::endl;\n\n std::cerr << \"PPID: \" << getppid() << std::endl;\n", "file_path": "sandbox/debug.cc", "rank": 15, "score": 4.805256272621623 }, { "content": " // Make 2MB of output.\n\n FILE *f = fopen(\"test_sandbox_file.txt\", \"w\");\n\n for (int i = 0; i < (MB >> 1); i++) {\n\n if (fprintf(f, \"test\\n\") < 0) {\n\n if (f != NULL) {\n\n fclose(f);\n\n }\n\n }\n\n }\n\n if (f != NULL) {\n\n fclose(f);\n\n }\n\n break;\n\n }\n\n default:\n\n validate_signal(pid, SIGXFSZ);\n\n break;\n\n }\n\n}\n\n\n", "file_path": "sandbox/test/sandbox_test.cc", "rank": 16, "score": 4.765643481373203 }, { "content": "\n\nlong long Sandbox::get_memory_used() const {\n\n return memory_used_in_mb;\n\n}\n\n\n\nvoid Sandbox::set_return_code(int return_code) {\n\n this->return_code = return_code;\n\n}\n\nint Sandbox::get_return_code() const {\n\n return return_code;\n\n}\n\n\n\n/**\n\n * The function that gets JSON-formatted string for statistics such as time elapsed, memory used, etc.\n\n * Args:\n\n * sandbox: The reference to the sandbox object.\n\n * Returns:\n\n * A string in JSON that contains statistics for the execution of user submitted code.\n\n */\n\nstatic std::string get_json_statistics(const Sandbox &sandbox) {\n", "file_path": "sandbox/sandbox.cc", "rank": 17, "score": 4.712213080906126 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/7/2021.\n\n//\n\n\n\n#ifndef _GNU_SOURCE\n\n#define _GNU_SOURCE\n\n#endif\n\n\n\n#include \"util.h\"\n\n\n\n#include <unistd.h>\n\n#include <string>\n\n#include <sys/syscall.h>\n\n\n\nint pivot_root(const std::string &new_root, const std::string &put_old) {\n\n return syscall(SYS_pivot_root, new_root.c_str(), put_old.c_str());\n\n}\n", "file_path": "sandbox/util.cc", "rank": 18, "score": 4.582490864299928 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/21/2021.\n\n//\n\n\n\n#include \"sandbox/file.h\"\n\n#include \"gtest/gtest.h\"\n\n#include <cstdio>\n\n#include <string>\n\n\n\nstatic int remove_file(std::string file_path) {\n\n if (std::remove(file_path.c_str()) != 0) {\n\n perror(\"Error while deleting the file\");\n\n }\n\n return 0;\n\n}\n\n\n\nTEST(FileTest, WritingToExistingFileSucceed) {\n\n // Create the new file named WritingToExistingFileSucceed.txt\n\n FILE *f = fopen(\"WritingToExistingFileSucceed.txt\", \"w\");\n\n fclose(f);\n", "file_path": "sandbox/test/file_test.cc", "rank": 20, "score": 4.190086240236592 }, { "content": " if (run_user_code(ptr) == -1) {\n\n return -1;\n\n }\n\n auto stat = get_json_statistics(*ptr);\n\n if (!File::write_file(\"/sandbox/stat.txt\", stat)) {\n\n\treturn -1;\n\n }\n\n return 0;\n\n}\n\n\n\nSandboxBuilder Sandbox::builder() {\n\n return SandboxBuilder{};\n\n}\n\n\n\nvoid Sandbox::run() {\n\n pid_t child_pid = clone(\n\n launch_sandbox,\n\n child_stack + STACK_SIZE,\n\n CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWNET | CLONE_NEWUTS | SIGCHLD,\n\n (void *) this\n\n );\n\n waitpid(child_pid, NULL, 0);\n\n}\n", "file_path": "sandbox/sandbox.cc", "rank": 21, "score": 3.823122319505848 }, { "content": " if (setrlimit(resource, &rl) == -1) {\n\n exit(EXIT_FAILURE);\n\n }\n\n}\n\n\n\nvoid set_sandbox_limit(Sandbox *ptr) {\n\n // Set Maximum file size to FILE_SIZE_LIMIT_IN_MB.\n\n set_resource_limit(RLIMIT_FSIZE, MB_TO_BYTES(ptr->get_file_size_limit_in_mb()));\n\n // TODO(conankun): Change return type to int and return -1 in this case.\n\n // Limit creating core dump files.\n\n set_resource_limit(RLIMIT_CORE, 0);\n\n // Limit sending and receiving message through message queue.\n\n set_resource_limit(RLIMIT_MSGQUEUE, 0);\n\n // Set the limit on the number of open file descriptors.\n\n set_resource_limit(RLIMIT_NOFILE, 100);\n\n // Limit creating another thread or process.\n\n set_resource_limit(RLIMIT_NPROC, 256);\n\n // Limit in Wall time. If process is sleeping, they are not consuming cpu time and thus can block grading system\n\n // from processing future requests. Therefore, there should be an enforcement on wall time\n\n alarm(static_cast<int>(ceil(MILLISECONDS_TO_SECONDS(ptr->get_time_limit_in_ms()))) << 1);\n\n set_resource_limit(\n\n RLIMIT_CPU,\n\n static_cast<int>(ceil(MILLISECONDS_TO_SECONDS(ptr->get_time_limit_in_ms() << 1))));\n\n // Prevent the process from making system calls other than read, write, sigreturn, and exit.\n\n // prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT);\n\n}\n", "file_path": "sandbox/limit.cc", "rank": 22, "score": 3.7393981386405244 }, { "content": " return true;\n\n}\n\n\n\nstd::string File::read_file(const std::string &file_path) {\n\n std::string ret;\n\n FILE *fd = fopen64(file_path.c_str(), \"r\");\n\n if (fd == NULL) {\n\n return std::string();\n\n }\n\n constexpr int BUFFER_SIZE = 512;\n\n char buffer[BUFFER_SIZE];\n\n while (true) {\n\n int count = fread(buffer, sizeof(char), BUFFER_SIZE, fd);\n\n if (count == -1) {\n\n fclose(fd);\n\n return std::string();\n\n } else if (count == 0) {\n\n break;\n\n } else {\n\n ret.append(buffer, count);\n", "file_path": "sandbox/file.cc", "rank": 23, "score": 3.724626279617227 }, { "content": " cgroup->add_controller(\"cpuacct\");\n\n cgroup->add_controller(\"memory\");\n\n if (create && !cgroup->setup_cgroup()) {\n\n return nullptr;\n\n }\n\n if (!cgroup->set_property(\"memory\", \"limit_in_bytes\",\n\n std::to_string(MB_TO_BYTES((int)(ptr->get_memory_limit_in_mb() * 1.1))))) {\n\n return nullptr;\n\n }\n\n if (!cgroup->set_property(\"cpu\", \"shares\", \"512\")) {\n\n return nullptr;\n\n }\n\n if (!cgroup->set_property(\"cpuacct\", \"usage\", \"0\")) {\n\n return nullptr;\n\n }\n\n return cgroup;\n\n}\n\n\n\nstatic void set_resource_limit(int resource, rlim_t limit) {\n\n struct rlimit rl = {limit, limit};\n", "file_path": "sandbox/limit.cc", "rank": 24, "score": 3.5746485174188316 }, { "content": " std::string& get_target_root_fs_dir();\n\n std::string& get_sandbox_dir();\n\n std::vector<std::string>& get_command();\n\n long long get_time_limit_in_ms() const;\n\n long long get_memory_limit_in_mb() const;\n\n long long get_file_size_limit_in_mb() const;\n\n // Store the running time of the user submitted code in terms of CPU time (in ms).\n\n void set_time_elapsed(long long nanoseconds);\n\n // Store the memory usage of the user submitted code in MB.\n\n void set_memory_used(long long bytes);\n\n long long get_time_elapsed() const;\n\n long long get_memory_used() const;\n\n void set_return_code(int return_code);\n\n int get_return_code() const;\n\n void run();\n\n};\n\n\n\n#endif //SANDBOX_SANDBOX_H\n", "file_path": "sandbox/sandbox.h", "rank": 25, "score": 3.522898177286798 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/10/2021.\n\n//\n\n\n\n#include \"sandbox/limit.h\"\n\n#include \"sandbox/sandbox.h\"\n\n#include \"sandbox/sandbox_builder.h\"\n\n#include \"gtest/gtest.h\"\n\n#include <csignal>\n\n#include <cstdlib>\n\n#include <memory>\n\n#include <string>\n\n#include <sys/types.h>\n\n#include <unistd.h>\n\n\n\n#define FAIL_TEST EXPECT_TRUE(false)\n\n#define PASS_TEST EXPECT_TRUE(true)\n\n\n\n#define MB (1 << 20)\n\n\n", "file_path": "sandbox/test/sandbox_test.cc", "rank": 26, "score": 3.3471379569433353 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/15/2021.\n\n//\n\n\n\n#include \"cgroup.h\"\n\n#include \"file.h\"\n\n#include \"sandbox.h\"\n\n#include <fstream>\n\n#include <string>\n\n#include <sys/types.h>\n\n#include <sys/wait.h>\n\n#include <unistd.h>\n\n\n\n#define MB_TO_BYTES(x) ((x) << 20)\n\n\n\nstatic std::string get_filename(\n\n const std::string &cgroup_name,\n\n const std::string &controller,\n\n const std::string &property) {\n\n return \"/sys/fs/cgroup/\" + controller + \"/\" + cgroup_name + \"/\" + controller + \".\" + property;\n", "file_path": "sandbox/cgroup.cc", "rank": 27, "score": 3.226861637849188 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/8/2021.\n\n//\n\n\n\n#ifndef SANDBOX_SANDBOX_BUILDER_H\n\n#define SANDBOX_SANDBOX_BUILDER_H\n\n\n\n#include \"sandbox.h\"\n\n#include <string>\n\n#include <vector>\n\n\n", "file_path": "sandbox/sandbox_builder.h", "rank": 28, "score": 3.0201609473586135 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/15/2021.\n\n//\n\n\n\n#ifndef SANDBOX_CGROUP_H\n\n#define SANDBOX_CGROUP_H\n\n#include \"sandbox.h\"\n\n#include <string>\n\n#include <sys/types.h>\n\n\n\n// TODO(conankun): Make cgroup builder.\n", "file_path": "sandbox/cgroup.h", "rank": 29, "score": 2.968127417971712 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/7/2021.\n\n//\n\n\n\n#ifndef SANDBOX_SANDBOX_H\n\n#define SANDBOX_SANDBOX_H\n\n\n\n#include <string>\n\n#include <vector>\n\n\n", "file_path": "sandbox/sandbox.h", "rank": 30, "score": 2.8397874711606512 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/10/2021.\n\n//\n\n\n\n#include \"sandbox/sandbox.h\"\n\n#include \"sandbox/sandbox_builder.h\"\n\n#include \"gtest/gtest.h\"\n\n#include <string>\n\n#include <vector> \n\nTEST(SandboxBuilderTest, ProducesCorrectSandboxConfiguration) {\n\n auto sandbox = Sandbox::builder()\n\n .set_debug(true)\n\n .set_time_limit(1000)\n\n .set_memory_limit(32)\n\n .set_sandbox_dir(\"/sandbox\")\n\n .set_src_root_fs_dir(\"/src/rootfs\")\n\n .set_target_root_fs_dir(\"/target/rootfs\")\n\n .set_command({\"./sandbox/test\"})\n\n .build();\n\n EXPECT_EQ(sandbox.get_time_limit_in_ms(), 1000);\n", "file_path": "sandbox/test/sandbox_builder_test.cc", "rank": 31, "score": 2.763338986790374 }, { "content": " if (pipe(fd) == -1) {\n\n return -1;\n\n }\n\n auto pid = fork();\n\n switch (pid) {\n\n case -1:\n\n return -1;\n\n case 0: /* Child */\n\n cgroup->attach_process(getpid());\n\n run_child(ptr, fd);\n\n exit(EXIT_SUCCESS);\n\n default: /* Parent */\n\n return run_parent(ptr, std::move(cgroup), pid, fd);\n\n break;\n\n }\n\n return 0;\n\n}\n", "file_path": "sandbox/execution.cc", "rank": 32, "score": 2.557910619977223 }, { "content": "int File::read_pipe(int fd, std::string &content, long long limit_in_bytes) {\n\n constexpr int BUFFER_SIZE = 512;\n\n char buffer[BUFFER_SIZE];\n\n for(;;) {\n\n auto num_read = read(fd, buffer, BUFFER_SIZE);\n\n if (num_read == -1) {\n\n return -1;\n\n } else if (num_read == 0) {\n\n break;\n\n } else {\n\n content.append(buffer, num_read);\n\n if (content.size() > limit_in_bytes) {\n\n break;\n\n }\n\n }\n\n }\n\n return (content.size() > limit_in_bytes) ? 1 : 0;\n\n}\n", "file_path": "sandbox/file.cc", "rank": 33, "score": 2.510151171486843 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/8/2021.\n\n//\n\n\n\n#include \"sandbox_builder.h\"\n\n\n\n#include <string>\n\n#include <vector>\n\n\n\nSandboxBuilder& SandboxBuilder::set_debug(bool debug) {\n\n this->sandbox.set_debug(debug);\n\n return *this;\n\n}\n\nSandboxBuilder& SandboxBuilder::set_src_root_fs_dir(std::string &&dir) {\n\n this->sandbox.set_src_root_fs_dir(dir);\n\n return *this;\n\n}\n\nSandboxBuilder& SandboxBuilder::set_target_root_fs_dir(std::string &&dir) {\n\n this->sandbox.set_target_root_fs_dir(dir);\n\n return *this;\n", "file_path": "sandbox/sandbox_builder.cc", "rank": 34, "score": 2.436425049406473 }, { "content": "}\n\n\n\nstatic int run_command(const std::string &command) {\n\n auto pid = fork();\n\n switch (pid) {\n\n case -1:\n\n return -1;\n\n break;\n\n case 0: /* Child */\n\n {\n\n // TODO(conankun): Replace with execve\n\n if (system(command.c_str()) != 0) {\n\n exit(EXIT_FAILURE);\n\n }\n\n exit(EXIT_SUCCESS);\n\n }\n\n default: /* Parent */\n\n int status;\n\n waitpid(pid, &status, 0);\n\n return status;\n", "file_path": "sandbox/cgroup.cc", "rank": 35, "score": 2.3577706322043763 }, { "content": "//\n\n// Created by Eugene Junghyun Kim on 1/21/2021.\n\n//\n\n\n\n#ifndef SANDBOX_FILE_H\n\n#define SANDBOX_FILE_H\n\n\n\n#include <string>\n\n\n", "file_path": "sandbox/file.h", "rank": 36, "score": 2.3427942698503452 }, { "content": "\n\nvoid Sandbox::set_command(std::vector<std::string> &command) {\n\n this->command = std::move(command);\n\n}\n\n\n\nvoid Sandbox::set_time_limit(int time_limit_in_ms) {\n\n this->time_limit_in_ms = time_limit_in_ms;\n\n}\n\n\n\nvoid Sandbox::set_memory_limit(int memory_limit_in_mb) {\n\n this->memory_limit_in_mb = memory_limit_in_mb;\n\n}\n\n\n\nvoid Sandbox::set_file_size_limit_in_mb(int file_size_in_mb) {\n\n this->file_size_limit_in_mb = file_size_in_mb;\n\n}\n\n\n\nbool Sandbox::is_debug() const {\n\n return debug;\n\n}\n", "file_path": "sandbox/sandbox.cc", "rank": 37, "score": 2.3127097766137035 }, { "content": "#include <unistd.h>\n\n#include <vector>\n\n\n\nstatic char child_stack[STACK_SIZE];\n\n\n\nvoid Sandbox::set_debug(bool debug) {\n\n this->debug = debug;\n\n}\n\n\n\nvoid Sandbox::set_src_root_fs_dir(std::string &dir) {\n\n this->src_root_fs_dir = dir;\n\n}\n\n\n\nvoid Sandbox::set_target_root_fs_dir(std::string &dir) {\n\n this->target_root_fs_dir = dir;\n\n}\n\n\n\nvoid Sandbox::set_sandbox_dir(std::string &dir) {\n\n this->sandbox_dir = dir;\n\n}\n", "file_path": "sandbox/sandbox.cc", "rank": 38, "score": 2.096710976267196 }, { "content": " // Set the directory where the file and compiled binary exists.\n\n void set_sandbox_dir(std::string &dir);\n\n\n\n // Set the command to execute inside the sandbox.\n\n void set_command(std::vector<std::string> &command);\n\n\n\n // Set the timeout after which the sandbox terminates the process forcefully.\n\n void set_time_limit(int time_limit_in_ms);\n\n\n\n // Set the memory limit so that the sandbox terminates the process if the process\n\n // uses more memory than memory_limit_in_mb.\n\n void set_memory_limit(int memory_limit_in_mb);\n\n\n\n // Set the maximum file size generated by the user output (e.g stdout).\n\n void set_file_size_limit_in_mb(int file_size_in_mb);\n\n\n\npublic:\n\n static SandboxBuilder builder();\n\n bool is_debug() const;\n\n std::string& get_src_root_fs_dir();\n", "file_path": "sandbox/sandbox.h", "rank": 39, "score": 2.0643679517151847 }, { "content": "}\n\nSandboxBuilder& SandboxBuilder::set_sandbox_dir(std::string &&dir) {\n\n this->sandbox.set_sandbox_dir(dir);\n\n return *this;\n\n}\n\nSandboxBuilder& SandboxBuilder::set_command(std::vector<std::string> &&command) {\n\n this->sandbox.set_command(command);\n\n return *this;\n\n}\n\nSandboxBuilder& SandboxBuilder::set_time_limit(int time_limit_in_ms) {\n\n this->sandbox.set_time_limit(time_limit_in_ms);\n\n return *this;\n\n}\n\nSandboxBuilder& SandboxBuilder::set_memory_limit(int memory_limit_in_mb) {\n\n this->sandbox.set_memory_limit(memory_limit_in_mb);\n\n return *this;\n\n}\n\nSandboxBuilder& SandboxBuilder::set_file_size_limit_in_mb(int file_size_in_mb) {\n\n this->sandbox.set_file_size_limit_in_mb(file_size_in_mb);\n\n return *this;\n\n}\n\n\n\nSandbox& SandboxBuilder::build() {\n\n return this->sandbox;\n\n}\n", "file_path": "sandbox/sandbox_builder.cc", "rank": 40, "score": 2.0474557594975966 }, { "content": "auto sandbox = Sandbox::builder()\n\n .set_debug(true)\n\n .set_time_limit(1000) /* 1 second */\n\n .set_memory_limit(16) /* 16MB */\n\n .set_file_size_limit_in_mb(1) /* 1MB */\n\n .set_sandbox_dir(\"/sandbox\")\n\n .set_src_root_fs_dir(\"/src/rootfs\")\n\n .set_target_root_fs_dir(\"/target/rootfs\")\n\n .set_command({\"./sandbox/test\"})\n\n .build();\n\n\n\nstatic void validate_signal(pid_t pid, int expected_signal) {\n\n int status;\n\n if (waitpid(pid, &status, 0) == -1) {\n\n // wait pid failed.\n\n FAIL_TEST;\n\n }\n\n EXPECT_TRUE(WIFSIGNALED(status));\n\n EXPECT_EQ(WTERMSIG(status), expected_signal);\n\n}\n", "file_path": "sandbox/test/sandbox_test.cc", "rank": 41, "score": 1.8685832342932513 }, { "content": " exit(EXIT_SUCCESS);\n\n }\n\n default: /* Parent */\n\n waitpid(pid, NULL, 0);\n\n EXPECT_TRUE(std::stoll(cgroup->get_property(\"memory\", \"max_usage_in_bytes\")) >= MB);\n\n break;\n\n }\n\n}\n\n\n\n\n\nTEST(SandboxTest, CheckMaximumFileSize) {\n\n auto pid = fork();\n\n switch(pid) {\n\n case -1:\n\n // Fork failed.\n\n FAIL_TEST;\n\n break;\n\n case 0:\n\n {\n\n set_sandbox_limit(&sandbox);\n", "file_path": "sandbox/test/sandbox_test.cc", "rank": 42, "score": 1.7476534509881754 }, { "content": " if (absl::GetFlag(FLAGS_file_size_limit) == NIL_INTEGER) {\n\n missing_flags.emplace_back(\"file_size_limit\");\n\n }\n\n if (absl::GetFlag(FLAGS_sandbox_dir) == NIL_STRING) {\n\n missing_flags.emplace_back(\"sandbox_dir\");\n\n }\n\n if (absl::GetFlag(FLAGS_src_root_fs_dir) == NIL_STRING) {\n\n missing_flags.emplace_back(\"src_root_fs_dir\");\n\n }\n\n if (absl::GetFlag(FLAGS_target_root_fs_dir) == NIL_STRING) {\n\n missing_flags.emplace_back(\"target_root_fs_dir\");\n\n }\n\n if (absl::GetFlag(FLAGS_command) == NIL_STRING_ARRAY) {\n\n missing_flags.emplace_back(\"command\");\n\n }\n\n return missing_flags.empty();\n\n}\n\n\n\nint main(int argc, char *argv[]) {\n\n absl::ParseCommandLine(argc, argv);\n", "file_path": "sandbox/main.cc", "rank": 43, "score": 1.6717239743885193 }, { "content": "TEST(SandboxTest, CheckMaximumSubProcesses) {\n\n auto pid = fork();\n\n switch(pid) {\n\n case -1:\n\n // Fork failed.\n\n FAIL_TEST;\n\n break;\n\n case 0: /* Child */\n\n {\n\n set_sandbox_limit(&sandbox);\n\n // This fork should fail if the number of calls goes beyond the limit.\n\n for (int i = 0; i < 100000; i++) {\n\n\t\t if (fork() == -1) {\n\n raise(SIGINT);\n\n exit(EXIT_FAILURE);\n\n }\n\n\t\t}\n\n break;\n\n }\n\n default:\n\n validate_signal(pid, SIGINT);\n\n break;\n\n }\n\n}\n", "file_path": "sandbox/test/sandbox_test.cc", "rank": 44, "score": 1.6409445446680206 }, { "content": " }\n\n }\n\n fclose(fd);\n\n return ret;\n\n}\n\n\n\n// The method for reading from the pipe.\n\n// Since pipe is stored in memory, its size cannot be limited by setrlimit(RLIMIT_FSIZE, ...).\n\n// Therefore, the limit on its total size is enforced here.\n\n// Returns\n\n/**\n\n * The method for reading from the pipe.\n\n * Since pipe is stored in memory, its size cannot be limited by setrlimit(RLIMIT_FSIZE, ...).\n\n * Therefore, the limit on its total size is enforced here.\n\n * @param fd the integer for file descriptor\n\n * @param content the reference of the string to append bytes from the pipe\n\n * @param limit_in_bytes the limit on total size of input from the pipe.\n\n * @return -1 if system error occurs. 0 if terminates without any issue. 1 if total size of the content is greater than\n\n * the limit.\n\n */\n", "file_path": "sandbox/file.cc", "rank": 45, "score": 1.4216900906945282 }, { "content": "// Run with bazel build -c opt //sandbox:app && unshare -m -r ./codu\n\n//\n\n\n\n/**\n\n * The function that checks whether all required flags are specified.\n\n * Args:\n\n * missing_flags: The string vector that will contain information on missing flags.\n\n * This will contain names of missing flags.\n\n * Should be empty when passed in.\n\n * Returns:\n\n * A boolean value indicating whether all required flags are specified. \n\n */\n\nbool has_required_flags(std::vector<std::string> &missing_flags) {\n\n assert(missing_flags.empty());\n\n if (absl::GetFlag(FLAGS_time_limit) == NIL_INTEGER) {\n\n missing_flags.emplace_back(\"time_limit\");\n\n }\n\n if (absl::GetFlag(FLAGS_memory_limit) == NIL_INTEGER) {\n\n missing_flags.emplace_back(\"memory_limit\");\n\n }\n", "file_path": "sandbox/main.cc", "rank": 46, "score": 1.3096137640183216 }, { "content": "\n\n// Since we cannot create cgroup from non-root user, we must run the following commands from root to set up test\n\n// environment for this test.\n\n// sudo cgcreate -a ${USER}:${GROUP} -g cpu,memory:/test_sandbox\n\n// sudo chown ${USER}:${GROUP} /sys/fs/cgroup/memory/test_sandbox/tasks\n\n// sudo chown ${USER}:${GROUP} /sys/fs/cgroup/cpu/test_sandbox/tasks\n\n// where ${USER} and ${GROUP} is user and group for the current shell session.\n\nTEST(SandboxTest, CheckMemoryLimit) {\n\n auto cgroup = setup_cgroup(&sandbox, \"test_sandbox\", false);\n\n auto pid = fork();\n\n switch(pid) {\n\n case -1:\n\n // Fork failed.\n\n FAIL_TEST;\n\n break;\n\n case 0: /* Child */\n\n {\n\n cgroup->attach_process(getpid());\n\n std::string test = \"\";\n\n for(int i = 0; i < 10000000; i++) test += \"test\";\n", "file_path": "sandbox/test/sandbox_test.cc", "rank": 47, "score": 1.1293143937993815 } ]
C++
src/cpp/toHTML/toHTML.cpp
tmadden/asm-dom
5cc18c41ba0da8319280355260d96d58bf67d782
#include "toHTML.hpp" #include "../utils/utils.hpp" #include "../VNode/VNode.hpp" #include "../Config/Config.hpp" #include <emscripten/val.h> #include <unordered_map> #include <string> namespace asmdom { std::unordered_map<std::string, bool> containerElements { {"a", true}, {"defs", true}, {"glyph", true}, {"g", true}, {"marker", true}, {"mask", true}, {"missing-glyph", true}, {"pattern", true}, {"svg", true}, {"switch", true}, {"symbol", true}, {"text", true}, {"desc", true}, {"metadata", true}, {"title", true} }; std::unordered_map<std::string, bool> voidElements { {"area", true}, {"base", true}, {"br", true}, {"col", true}, {"embed", true}, {"hr", true}, {"img", true}, {"input", true}, {"keygen", true}, {"link", true}, {"meta", true}, {"param", true}, {"source", true}, {"track", true}, {"wbr", true} }; #ifndef ASMDOM_JS_SIDE std::unordered_map<std::string, bool> omitProps { {"attributes", true}, {"childElementCount", true}, {"children", true}, {"classList", true}, {"clientHeight", true}, {"clientLeft", true}, {"clientTop", true}, {"clientWidth", true}, {"currentStyle", true}, {"firstElementChild", true}, {"innerHTML", true}, {"lastElementChild", true}, {"nextElementSibling", true}, {"ongotpointercapture", true}, {"onlostpointercapture", true}, {"onwheel", true}, {"outerHTML", true}, {"previousElementSibling", true}, {"runtimeStyle", true}, {"scrollHeight", true}, {"scrollLeft", true}, {"scrollLeftMax", true}, {"scrollTop", true}, {"scrollTopMax", true}, {"scrollWidth", true}, {"tabStop", true}, {"tagName", true} }; #endif std::string encode(const std::string& data) { std::string encoded; size_t size = data.size(); encoded.reserve(size); for(size_t pos = 0; pos != size; ++pos) { switch(data[pos]) { case '&': encoded.append("&amp;"); break; case '\"': encoded.append("&quot;"); break; case '\'': encoded.append("&apos;"); break; case '<': encoded.append("&lt;"); break; case '>': encoded.append("&gt;"); break; case '`': encoded.append("&#96;"); break; default: encoded.append(&data[pos], 1); break; } } return encoded; }; void appendAttributes(const VNode* const vnode, std::string& html) { for (auto& it : vnode->data.attrs) { html.append(" " + it.first + "=\"" + encode(it.second) + "\""); } #ifdef ASMDOM_JS_SIDE html.append( wstring_to_utf8(emscripten::val::module_property("appendProps")(reinterpret_cast<std::uintptr_t>(vnode)).as<std::wstring>()) ); #else emscripten::val String = emscripten::val::global("String"); for (auto& it : vnode->data.props) { if (!omitProps[it.first]) { std::string key = it.first; std::transform(key.begin(), key.end(), key.begin(), ::tolower); html.append(" " + key + "=\"" + encode(String(it.second).as<std::string>()) + "\""); } } #endif }; void toHTML(const VNode* const vnode, std::string& html) { if (!vnode) return; if (vnode->hash & isText && !vnode->sel.empty()) { html.append(encode(vnode->sel)); } else if (vnode->hash & isComment) { html.append("<!--" + vnode->sel + "-->"); } else if (vnode->hash & isFragment) { for(Children::size_type i = 0; i != vnode->children.size(); ++i) { toHTML(vnode->children[i], html); } } else { bool isSvg = (vnode->hash & hasNS) && vnode->ns == "http://www.w3.org/2000/svg"; bool isSvgContainerElement = isSvg && containerElements[vnode->sel]; html.append("<" + vnode->sel); appendAttributes(vnode, html); if (isSvg && !isSvgContainerElement) { html.append(" /"); } html.append(">"); if ( isSvgContainerElement || (!isSvg && !voidElements[vnode->sel]) ) { #ifdef ASMDOM_JS_SIDE html.append( wstring_to_utf8(emscripten::val::module_property("insertInnerHTML")(reinterpret_cast<std::uintptr_t>(vnode)).as<std::wstring>()) ); #else if (vnode->data.props.count("innerHTML") != 0) { html.append(vnode->data.props.at("innerHTML").as<std::string>()); } else #endif for(Children::size_type i = 0; i != vnode->children.size(); ++i) { toHTML(vnode->children[i], html); } html.append("</" + vnode->sel + ">"); } } }; std::string toHTML(VNode* const vnode) { std::string html; vnode->normalize(); toHTML(vnode, html); #ifndef ASMDOM_JS_SIDE if (vnode && CLEAR_MEMORY) { deleteVNode(vnode); } #endif return html; }; }
#include "toHTML.hpp" #include "../utils/utils.hpp" #include "../VNode/VNode.hpp" #include "../Config/Config.hpp" #include <emscripten/val.h> #include <unordered_map> #include <string> namespace asmdom { std::unordered_map<std::string, bool> containerElements { {"a", true}, {"defs", true}, {"glyph", true}, {"g", true}, {"marker", true}, {"mask", true}, {"missing-glyph", true}, {"pattern", true}, {"svg", true}, {"switch", true}, {"symbol", true}, {"text", true}, {"desc", true}, {"metadata", true}, {"title", true} }; std::unordered_map<std::string, bool> voidElements { {"area", true}, {"base", true}, {"br", true}, {"col", true}, {"embed", true}, {"hr", true}, {"img", true}, {"input", true}, {"keygen", true}, {"link", true}, {"meta", true}, {"param", true}, {"source", true}, {"track", true}, {"wbr", true} }; #ifndef ASMDOM_JS_SIDE std::unordered_map<std::string, bool> omitProps { {"attributes", true}, {"childElementCount", true}, {"children", true}, {"classList", true}, {"clientHeight", true}, {"clientLeft", true}, {"clientTop", true}, {"clientWidth", true}, {"currentStyle", true}, {"firstElementChild", true}, {"innerHTML", true}, {"lastElementChild", true}, {"nextElementSibling", true}, {"ongotpointercapture", true}, {"onlostpointercapture", true}, {"onwheel", true}, {"outerHTML", true}, {"previousElementSibling", true}, {"runtimeStyle", true}, {"scrollHeight", true}, {"scrollLeft", true}, {"scrollLeftMax", true}, {"scrollTop", true}, {"scrollTopMax", true}, {"scrollWidth", true}, {"tabStop", true}, {"tagName", true} }; #endif std::string encode(const std::string& data) { std::string encoded; size_t size = data.size(); encoded.reserve(size); for(size_t pos = 0; pos != size; ++pos) { switch(data[pos]) { case '&': encoded.append("&amp;"); break; case '\"': encoded.append("&quot;"); break; case '\'': encoded.append("&apos;"); break; case '<': encoded.append("&lt;"); break; case '>': encoded.append("&gt;"); break; case '`': encoded.append("&#96;"); break; default: encoded.append(&data[pos], 1); break; } } return encoded; }; void appendAttributes(const VNode* const vnode, std::string& html) { for (auto& it : vnode->data.attrs) { html.append(" " + it.first + "=\"" + encode(it.second) + "\""); } #ifdef ASMDOM_JS_SIDE html.append( wstring_to_utf8(emscripten::val::module_property("appendProps")(reinterpret_cast<std::uintptr_t>(vnode)).as<std::wstring>()) ); #else emscripten::val String = emscripten::val::global("String"); for (auto& it : vnode->data.props) { if (!omitProps[it.first]) { std::string key = it.first; std::transform(key.begin(), key.end(), key.begin(), ::tolower); html.append(" " + key + "=\"" + encode(String(it.second).as<std::string>()) + "\""); } } #endif }; void toHTML(const VNode* const vnode, std::string& html) { if (!vnode) return; if (vnode->hash & isText && !vnode->sel.empty()) { html.append(encode(vnode->sel)); } else if (vnode->hash & isComment) { html.append("<!--" + vnode->sel + "-->"); } else if (vnode->hash & isFragment) { for(Children::size_type i = 0; i != vnode->children.size(); ++i) { toHTML(vnode->children[i], html); } } else { bool isSvg = (vnode->hash & hasNS) && vnode->ns == "http://www.w3.org/2000/svg"; bool isSvgContainerElement = isSvg && containerElements[vnode->sel]; html.append("<" + vnode->sel); appendAttributes(vnode, html); if (isSvg && !isSvgContainerElement) { html.append(" /"); } html.append(">"); if ( isSvgContainerElement || (!isSvg && !voidElements[vnode->sel]) ) { #ifdef ASMDOM_JS_SIDE
; #else if (vnode->data.props.count("innerHTML") != 0) { html.append(vnode->data.props.at("innerHTML").as<std::string>()); } else #endif for(Children::size_type i = 0; i != vnode->children.size(); ++i) { toHTML(vnode->children[i], html); } html.append("</" + vnode->sel + ">"); } } }; std::string toHTML(VNode* const vnode) { std::string html; vnode->normalize(); toHTML(vnode, html); #ifndef ASMDOM_JS_SIDE if (vnode && CLEAR_MEMORY) { deleteVNode(vnode); } #endif return html; }; }
html.append( wstring_to_utf8(emscripten::val::module_property("insertInnerHTML")(reinterpret_cast<std::uintptr_t>(vnode)).as<std::wstring>()) )
call_expression
[ { "content": "const getData = (Module, obj) => {\n\n let hasRaws = obj.raw !== undefined;\n\n let hasEvents = false;\n\n\n\n let ref;\n\n const attrs = new Module.MapStringString();\n\n const raw = obj.raw !== undefined ? obj.raw : {};\n\n const events = {};\n\n\n\n if (typeof obj.className === 'string') attrs.set('class', obj.className);\n\n const keys = Object.keys(obj);\n\n let i = keys.length;\n\n while (i--) {\n\n const key = keys[i];\n\n const value = obj[key];\n\n if (key === 'value' || key === 'checked') {\n\n raw[key] = value;\n\n hasRaws = true;\n\n } else if (typeof value === 'function') {\n\n if (key === 'ref') {\n\n ref = value;\n\n } else {\n\n events[key.replace(/^on/, '')] = value;\n\n hasEvents = true;\n\n }\n\n } else if (value !== false && key !== 'raw' && key !== 'className') {\n\n // eslint-disable-next-line\n\n attrs.set(key, '' + value);\n\n }\n\n }\n\n\n\n return {\n\n ref,\n\n raw: hasRaws ? raw : undefined,\n\n events: hasEvents ? events : undefined,\n\n attrs,\n\n };\n", "file_path": "src/js/h.js", "rank": 0, "score": 81626.45386908337 }, { "content": "---\n\nid: string-encoding\n\ntitle: String Encoding\n\n---\n\n\n\nasm-dom renders attributes in UTF-8 (they are std::string) and props in UTF-16 (they are [emscripten::val](https://kripken.github.io/emscripten-site/docs/api_reference/val.h.html)).\n\nIf you want to take a string from javascript, from an input for example, you have to know that this string is encoded in UTF-16 and you can save it in a `std::wstring` variable, so, you have to pay attention to the encoding. In the [TODOMVC example](https://github.com/mbasso/asm-dom/tree/master/examples/todomvc%20-%20cpp) you can see how we have dealed with that. We have created [2 helpers](https://github.com/mbasso/asm-dom/blob/cpp-api/examples/todomvc%20-%20cpp/src/helpers.cpp) that are used when we take values from events (event.target.value) and put values into props. Here is an example:\n\n\n\n```c++\n\nstd::wstring utf8_to_wstring(const std::string& str) {\n\n std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;\n\n return converter.from_bytes(str);\n\n};\n\n\n\nstd::string wstring_to_utf8(const std::wstring& str) {\n\n std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;\n\n return converter.to_bytes(str);\n\n};\n\n\n\nconst int KEY_ENTER = 13;\n\n\n\nint main() {\n\n // some code here...\n\n\n\n std::string val = getInputValue();\n\n\n\n VNode* vnode = h(\"input\",\n\n Data(\n\n Attrs {\n\n // UTF-8 encoding, no stuff needed\n\n {\"type\", \"text\"}\n\n // UTF-8 encoding, u8 needed for accented characters\n\n {\"class\", u8\"ehilà\"}\n\n },\n\n Props {\n\n // setting a prop: UTF-8 to UTF-16\n\n {\"value\", emscripten::val(utf8_to_wstring(val))}\n\n {\"anotherProp\", emscripten::val(L\"This is UTF-16\")}\n\n },\n\n Callbacks {\n\n {\"onkeydown\", [handler](emscripten::val e) -> bool {\n\n // get value from event: UTF-16 to UTF-8\n\n std::string value = wstring_to_utf8(e[\"target\"][\"value\"].as<std::wstring>());\n\n if (e[\"keyCode\"].as<int>() == KEY_ENTER && !value.empty()) {\n\n // do stuff...\n\n }\n\n return true;\n\n }}\n\n }\n\n )\n\n );\n\n\n\n // some code here...\n\n};\n\n```\n", "file_path": "docs/string-encoding.md", "rank": 1, "score": 72111.39079417093 }, { "content": "\t\t{\"missing-glyph\", true},\n\n\t\t{\"pattern\", true},\n\n\t\t{\"svg\", true},\n\n\t\t{\"switch\", true},\n\n\t\t{\"symbol\", true},\n\n\t\t{\"text\", true},\n\n\n\n \t// http://www.w3.org/TR/SVG/intro.html#TermDescriptiveElement\n\n\t\t{\"desc\", true},\n\n\t\t{\"metadata\", true},\n\n\t\t{\"title\", true}\n\n\t};\n\n\n\n\t// http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements\n\n\tstd::unordered_map<std::string, bool> voidElements {\n\n\t\t{\"area\", true},\n\n\t\t{\"base\", true},\n\n\t\t{\"br\", true},\n\n\t\t{\"col\", true},\n\n\t\t{\"embed\", true},\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 2, "score": 52867.3419890097 }, { "content": "\t\t{\"hr\", true},\n\n\t\t{\"img\", true},\n\n\t\t{\"input\", true},\n\n\t\t{\"keygen\", true},\n\n\t\t{\"link\", true},\n\n\t\t{\"meta\", true},\n\n\t\t{\"param\", true},\n\n\t\t{\"source\", true},\n\n\t\t{\"track\", true},\n\n\t\t{\"wbr\", true}\n\n\t};\n\n\n\n\t#ifndef ASMDOM_JS_SIDE\n\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/element\n\n\t\tstd::unordered_map<std::string, bool> omitProps {\n\n\t\t\t{\"attributes\", true},\n\n\t\t\t{\"childElementCount\", true},\n\n\t\t\t{\"children\", true},\n\n\t\t\t{\"classList\", true},\n\n\t\t\t{\"clientHeight\", true},\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 3, "score": 52857.92350290239 }, { "content": "\t\treturn encoded;\n\n\t};\n\n\n\n\tvoid appendAttributes(const VNode* const vnode, std::string& html) {\n\n\t\tfor (auto& it : vnode->data.attrs) {\n\n\t\t\thtml.append(\" \" + it.first + \"=\\\"\" + encode(it.second) + \"\\\"\");\n\n\t\t}\n\n\n\n\t\t#ifdef ASMDOM_JS_SIDE\n\n\t\t\thtml.append(\n\n\t\t\t\twstring_to_utf8(emscripten::val::module_property(\"appendProps\")(reinterpret_cast<std::uintptr_t>(vnode)).as<std::wstring>())\n\n\t\t\t);\n\n\t\t#else\n\n\t\t\temscripten::val String = emscripten::val::global(\"String\");\n\n\t\t\tfor (auto& it : vnode->data.props) {\n\n\t\t\t\tif (!omitProps[it.first]) {\n\n\t\t\t\t\tstd::string key = it.first;\n\n\t\t\t\t\tstd::transform(key.begin(), key.end(), key.begin(), ::tolower);\n\n\t\t\t\t\thtml.append(\" \" + key + \"=\\\"\" + encode(String(it.second).as<std::string>()) + \"\\\"\");\n\n\t\t\t\t}\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 4, "score": 52855.765013688135 }, { "content": "\t\t\t{\"tabStop\", true},\n\n\t\t\t{\"tagName\", true}\n\n\t\t};\n\n\t#endif\n\n\n\n\tstd::string encode(const std::string& data) {\n\n\t\tstd::string encoded;\n\n\t\tsize_t size = data.size();\n\n\t\tencoded.reserve(size);\n\n\t\tfor(size_t pos = 0; pos != size; ++pos) {\n\n\t\t\t\tswitch(data[pos]) {\n\n\t\t\t\t\t\tcase '&': encoded.append(\"&amp;\"); break;\n\n\t\t\t\t\t\tcase '\\\"': encoded.append(\"&quot;\"); break;\n\n\t\t\t\t\t\tcase '\\'': encoded.append(\"&apos;\"); break;\n\n\t\t\t\t\t\tcase '<': encoded.append(\"&lt;\"); break;\n\n\t\t\t\t\t\tcase '>': encoded.append(\"&gt;\"); break;\n\n\t\t\t\t\t\tcase '`': encoded.append(\"&#96;\");\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault: encoded.append(&data[pos], 1); break;\n\n\t\t\t\t}\n\n\t\t}\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 5, "score": 52852.42616359458 }, { "content": "#include \"toHTML.hpp\"\n\n#include \"../utils/utils.hpp\"\n\n#include \"../VNode/VNode.hpp\"\n\n#include \"../Config/Config.hpp\"\n\n#include <emscripten/val.h>\n\n#include <unordered_map>\n\n#include <string>\n\n\n\nnamespace asmdom {\n\n\n\n\t// All SVG children elements, not in this list, should self-close\n\n\n\n\tstd::unordered_map<std::string, bool> containerElements {\n\n\t\t// http://www.w3.org/TR/SVG/intro.html#TermContainerElement\n\n\t\t{\"a\", true},\n\n\t\t{\"defs\", true},\n\n\t\t{\"glyph\", true},\n\n\t\t{\"g\", true},\n\n\t\t{\"marker\", true},\n\n\t\t{\"mask\", true},\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 6, "score": 52851.30932368202 }, { "content": "\t\t\t}\n\n\t\t#endif\n\n\t};\n\n\n\n\tvoid toHTML(const VNode* const vnode, std::string& html) {\n\n\t\tif (!vnode) return;\n\n\n\n\t\tif (vnode->hash & isText && !vnode->sel.empty()) {\n\n\t\t\thtml.append(encode(vnode->sel));\n\n\t\t} else if (vnode->hash & isComment) {\n\n\t\t\thtml.append(\"<!--\" + vnode->sel + \"-->\");\n\n\t\t} else if (vnode->hash & isFragment) {\n\n\t\t\tfor(Children::size_type i = 0; i != vnode->children.size(); ++i) {\n\n\t\t\t\ttoHTML(vnode->children[i], html);\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tbool isSvg = (vnode->hash & hasNS) && vnode->ns == \"http://www.w3.org/2000/svg\";\n\n\t\t\tbool isSvgContainerElement = isSvg && containerElements[vnode->sel];\n\n\n\n\t\t\thtml.append(\"<\" + vnode->sel);\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 7, "score": 52848.56283869958 }, { "content": "\t\t\tappendAttributes(vnode, html);\n\n\t\t\tif (isSvg && !isSvgContainerElement) {\n\n\t\t\t\thtml.append(\" /\");\n\n\t\t\t}\n\n\t\t\thtml.append(\">\");\n\n\n\n\t\t\tif (\n\n\t\t\t\tisSvgContainerElement ||\n\n\t\t\t\t(!isSvg && !voidElements[vnode->sel])\n\n\t\t\t) {\n\n\t\t\t\t#ifdef ASMDOM_JS_SIDE\n\n\t\t\t\t\thtml.append(\n\n\t\t\t\t\t\twstring_to_utf8(emscripten::val::module_property(\"insertInnerHTML\")(reinterpret_cast<std::uintptr_t>(vnode)).as<std::wstring>())\n\n\t\t\t\t\t);\n\n\t\t\t\t#else\n\n\t\t\t\t\tif (vnode->data.props.count(\"innerHTML\") != 0) {\n\n\t\t\t\t\t\thtml.append(vnode->data.props.at(\"innerHTML\").as<std::string>());\n\n\t\t\t\t\t} else\n\n\t\t\t\t#endif\n\n\t\t\t\t\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 8, "score": 52847.63139139258 }, { "content": "\t\t\t\tfor(Children::size_type i = 0; i != vnode->children.size(); ++i) {\n\n\t\t\t\t\ttoHTML(vnode->children[i], html);\n\n\t\t\t\t}\n\n\t\t\t\thtml.append(\"</\" + vnode->sel + \">\");\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\n\n\tstd::string toHTML(VNode* const vnode) {\n\n\t\tstd::string html;\n\n\t\tvnode->normalize();\n\n\t\ttoHTML(vnode, html);\n\n\n\n\t\t#ifndef ASMDOM_JS_SIDE\n\n\t\t\tif (vnode && CLEAR_MEMORY) {\n\n deleteVNode(vnode);\n\n\t\t\t}\n\n\t\t#endif\n\n\n\n return html;\n\n\t};\n\n\n\n}\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 9, "score": 52839.63215996247 }, { "content": "#ifndef asmdom_tohtml_hpp\n\n#define asmdom_tohtml_hpp\n\n\n\n#include \"../VNode/VNode.hpp\"\n\n#include <string>\n\n\n\nnamespace asmdom {\n\n\n\n\tstd::string toHTML(VNode* const vnode);\n\n\n\n}\n\n\n\n#endif", "file_path": "cpp/toHTML/toHTML.hpp", "rank": 10, "score": 52837.684658954444 }, { "content": "\t\t\t{\"clientLeft\", true},\n\n\t\t\t{\"clientTop\", true},\n\n\t\t\t{\"clientWidth\", true},\n\n\t\t\t{\"currentStyle\", true},\n\n\t\t\t{\"firstElementChild\", true},\n\n\t\t\t{\"innerHTML\", true},\n\n\t\t\t{\"lastElementChild\", true},\n\n\t\t\t{\"nextElementSibling\", true},\n\n\t\t\t{\"ongotpointercapture\", true},\n\n\t\t\t{\"onlostpointercapture\", true},\n\n\t\t\t{\"onwheel\", true},\n\n\t\t\t{\"outerHTML\", true},\n\n\t\t\t{\"previousElementSibling\", true},\n\n\t\t\t{\"runtimeStyle\", true},\n\n\t\t\t{\"scrollHeight\", true},\n\n\t\t\t{\"scrollLeft\", true},\n\n\t\t\t{\"scrollLeftMax\", true},\n\n\t\t\t{\"scrollTop\", true},\n\n\t\t\t{\"scrollTopMax\", true},\n\n\t\t\t{\"scrollWidth\", true},\n", "file_path": "cpp/toHTML/toHTML.cpp", "rank": 11, "score": 52830.610658832906 }, { "content": "\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"value\")),\n\n\t\temscripten::val::null()\n\n\t);\n\n\n\n\tdeleteVNode(vnode);\n\n};\n\n\n\nvoid shouldSetTruthyValuesToEmptyString() {\n\n\tVNode* vnode = h(\"input\", Data(\n\n\t\tAttrs {\n\n\t\t\t{\"href\", \"null\"},\n\n\t\t\t{\"minlength\", \"0\"},\n\n\t\t\t{\"readonly\", \"true\"}\n\n\t\t}\n\n\t));\n\n\tpatch(getRoot(), vnode);\n\n\t\n\n\temscripten::val elm = getBodyFirstChild();\n", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 12, "score": 52544.9138825985 }, { "content": "#include \"../../../src/cpp/asm-dom.hpp\"\n\n#include \"../utils.hpp\"\n\n#include <emscripten/bind.h>\n\n#include <emscripten/val.h>\n\n\n\nusing namespace asmdom;\n\n\n\nvoid shouldHaveTheirProvidedValues() {\n\n\tVNode* vnode = h(\"div\", Data(\n\n\t\tAttrs {\n\n\t\t\t{\"href\", \"/foo\"},\n\n\t\t\t{\"minlength\", \"1\"},\n\n\t\t\t{\"value\", \"foo\"}\n\n\t\t}\n\n\t));\n\n\tpatch(getRoot(), vnode);\n\n\t\n\n\temscripten::val elm = getBodyFirstChild();\n\n\n\n\tassertEquals(\n", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 13, "score": 52544.021385569984 }, { "content": "\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"href\")),\n\n\t\temscripten::val(\"null\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"minlength\")),\n\n\t\temscripten::val(\"0\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"readonly\")),\n\n\t\temscripten::val(\"\")\n\n\t);\n\n\n\n\tdeleteVNode(vnode);\n\n};\n\n\n\nvoid shouldBeSetCorrectlyWhenNamespaced() {\n\n\tVNode* vnode = h(\"div\", Data(\n\n\t\tAttrs {\n", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 14, "score": 52539.63477859067 }, { "content": "\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"href\")),\n\n\t\temscripten::val(\"/foo\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"minlength\")),\n\n\t\temscripten::val(\"1\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"value\")),\n\n\t\temscripten::val(\"foo\")\n\n\t);\n\n\n\n\tdeleteVNode(vnode);\n\n};\n\n\n\nvoid attributesCanBeMemoized() {\n\n\tData data = Data(\n\n\t\tAttrs {\n\n\t\t\t{\"href\", \"/foo\"},\n\n\t\t\t{\"minlength\", \"1\"},\n", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 15, "score": 52539.61024590066 }, { "content": "\n\nvoid shouldBeOmittedWhenFalsyValuesAreProvided() {\n\n\tVNode* vnode = h(\"div\", Data(\n\n\t\tAttrs {\n\n\t\t\t{\"href\", \"null\"},\n\n\t\t\t{\"minlength\", \"0\"},\n\n\t\t\t{\"value\", \"false\"}\n\n\t\t}\n\n\t));\n\n\tpatch(getRoot(), vnode);\n\n\t\n\n\temscripten::val elm = getBodyFirstChild();\n\n\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"href\")),\n\n\t\temscripten::val(\"null\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"minlength\")),\n\n\t\temscripten::val(\"0\")\n", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 16, "score": 52536.528689167106 }, { "content": "\t\t\t{\"value\", \"foo\"}\n\n\t\t}\n\n\t);\n\n\tVNode* vnode = h(\"div\", data);\n\n\tVNode* vnode2 = h(\"div\", data);\n\n\tpatch(getRoot(), vnode);\n\n\t\n\n\temscripten::val elm = getBodyFirstChild();\n\n\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"href\")),\n\n\t\temscripten::val(\"/foo\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"minlength\")),\n\n\t\temscripten::val(\"1\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"value\")),\n\n\t\temscripten::val(\"foo\")\n", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 17, "score": 52535.958473055565 }, { "content": "\t\t\t{\"xlink:href\", \"#foo\"}\n\n\t\t}\n\n\t));\n\n\tpatch(getRoot(), vnode);\n\n\t\n\n\temscripten::val elm = getBodyFirstChild();\n\n\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttributeNS\",\n\n\t\t\temscripten::val(\"http://www.w3.org/1999/xlink\"),\n\n\t\t\temscripten::val(\"href\")\n\n\t\t),\n\n\t\temscripten::val(\"#foo\")\n\n\t);\n\n\n\n\tdeleteVNode(vnode);\n\n};\n\n\n\nEMSCRIPTEN_BINDINGS(attributes_tests) {\n\n emscripten::function(\"shouldHaveTheirProvidedValues\", &shouldHaveTheirProvidedValues);\n\n emscripten::function(\"attributesCanBeMemoized\", &attributesCanBeMemoized);\n\n emscripten::function(\"shouldBeOmittedWhenFalsyValuesAreProvided\", &shouldBeOmittedWhenFalsyValuesAreProvided);\n\n\temscripten::function(\"shouldSetTruthyValuesToEmptyString\", &shouldSetTruthyValuesToEmptyString);\n\n\temscripten::function(\"shouldBeSetCorrectlyWhenNamespaced\", &shouldBeSetCorrectlyWhenNamespaced);\n\n};", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 18, "score": 52534.84193026889 }, { "content": "\t);\n\n\tpatch(vnode, vnode2);\n\n\t\n\n\telm = getBodyFirstChild();\n\n\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"href\")),\n\n\t\temscripten::val(\"/foo\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"minlength\")),\n\n\t\temscripten::val(\"1\")\n\n\t);\n\n\tassertEquals(\n\n\t\telm.call<emscripten::val>(\"getAttribute\", emscripten::val(\"value\")),\n\n\t\temscripten::val(\"foo\")\n\n\t);\n\n\n\n\tdeleteVNode(vnode2);\n\n};\n", "file_path": "test/cpp/attributes/attributes.cpp", "rank": 19, "score": 52528.89316849613 }, { "content": "};\n\n\n\nvoid shouldHandleVoidElements() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tChildren {\n\n\t\t\th(\"area\"),\n\n\t\t\th(\"base\"),\n\n\t\t\th(\"br\"),\n\n\t\t\th(\"col\"),\n\n\t\t\th(\"embed\"),\n\n\t\t\th(\"hr\"),\n\n\t\t\th(\"img\"),\n\n\t\t\th(\"input\"),\n\n\t\t\th(\"keygen\"),\n\n\t\t\th(\"link\"),\n\n\t\t\th(\"meta\"),\n\n\t\t\th(\"param\"),\n\n\t\t\th(\"source\"),\n\n\t\t\th(\"track\"),\n\n\t\t\th(\"wbr\")\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 20, "score": 52232.52570778281 }, { "content": "\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div><area><base><br><col><embed><hr><img><input><keygen><link><meta><param><source><track><wbr></div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldEscapeText() {\n\n\tVNode* vnode = h(\"<>\\\"'&`text\", true);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"&lt;&gt;&quot;&apos;&amp;&#96;text\")\n\n\t);\n\n};\n\n\n\nvoid shouldEscapeTextContent() {\n\n\tVNode* vnode = h(\"p\", std::string(\"<>\\\"'&`text\"));\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 21, "score": 52232.072663203675 }, { "content": "\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<svg><a></a><defs></defs><glyph></glyph><g></g><marker></marker><mask></mask><missing-glyph></missing-glyph><pattern></pattern><svg></svg><switch></switch><symbol></symbol><text></text><desc></desc><metadata></metadata><title></title></svg>\")\n\n\t);\n\n};\n\n\n\nvoid shouldHandleSvgNonContainerElements() {\n\n\tVNode* vnode = h(\"svg\",\n\n\t\tChildren {\n\n\t\t\th(\"rect\")\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<svg><rect /></svg>\")\n\n\t);\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 22, "score": 52228.288271881785 }, { "content": "};\n\n\n\nvoid shouldHandleSvgContainerElements() {\n\n\tVNode* vnode = h(\"svg\",\n\n\t\tChildren {\n\n\t\t\th(\"a\"),\n\n\t\t\th(\"defs\"),\n\n\t\t\th(\"glyph\"),\n\n\t\t\th(\"g\"),\n\n\t\t\th(\"marker\"),\n\n\t\t\th(\"mask\"),\n\n\t\t\th(\"missing-glyph\"),\n\n\t\t\th(\"pattern\"),\n\n\t\t\th(\"svg\"),\n\n\t\t\th(\"switch\"),\n\n\t\t\th(\"symbol\"),\n\n\t\t\th(\"text\"),\n\n\t\t\th(\"desc\"),\n\n\t\t\th(\"metadata\"),\n\n\t\t\th(\"title\")\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 24, "score": 52220.43806392484 }, { "content": "\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<p>&lt;&gt;&quot;&apos;&amp;&#96;text</p>\")\n\n\t);\n\n};\n\n\n\nvoid shouldEscapeAttributes() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tAttrs {\n\n\t\t\t{\"data-foo\", \"<>\\\"'&`text\"}\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div data-foo=\\\"&lt;&gt;&quot;&apos;&amp;&#96;text\\\"></div>\")\n\n\t);\n\n};\n\n\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 31, "score": 52199.28564269123 }, { "content": "\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<span></span><b></b>\")\n\n\t);\n\n};\n\n\n\nvoid shouldParseText() {\n\n\tVNode* vnode = h(\"a text 字à\", true);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"a text 字à\")\n\n\t);\n\n};\n\n\n\nvoid shouldHandleChildren() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tChildren {\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 32, "score": 52198.204450183366 }, { "content": "void shouldParseAttributes() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tAttrs {\n\n\t\t\t{\"data-foo\", \"bar 字à\"}\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div data-foo=\\\"bar 字à\\\"></div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldOmitFalsyAttributes() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tAttrs {\n\n\t\t\t{\"readonly\", \"false\"},\n\n\t\t\t{\"style\", \"width: 250px; height: 250px;\"}\n\n\t\t}\n\n\t);\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 33, "score": 52194.80003141373 }, { "content": "\t\t\t{\"scrollWidth\", emscripten::val(\"foo\")},\n\n\t\t\t{\"tabStop\", emscripten::val(\"foo\")},\n\n\t\t\t{\"tagName\", emscripten::val(\"foo\")}\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div>foo</div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldOmitCallbacks() {\n\n\tVNode* vnode = h(\"div\",\n\n Data(\n\n Callbacks {\n\n {\"onclick\", [](emscripten::val e) -> bool {\n\n return true;\n\n }}\n\n }\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 35, "score": 52193.179206397144 }, { "content": "#include \"../../../src/cpp/asm-dom.hpp\"\n\n#include \"../../../src/cpp/asm-dom-server.hpp\"\n\n#include \"../utils.hpp\"\n\n#include <emscripten/bind.h>\n\n\n\nusing namespace asmdom;\n\n\n\nvoid shouldHandleNullVNode() {\n\n\tVNode* vnode = NULL;\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"\")\n\n\t);\n\n};\n\n\n\nvoid shouldParseElements() {\n\n\tVNode* vnode = h(\"div\");\n\n\n\n\tassert(\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 36, "score": 52192.922358345306 }, { "content": "#ifndef asmdom_tohtml_hpp\n\n#define asmdom_tohtml_hpp\n\n\n\n#include \"../VNode/VNode.hpp\"\n\n#include <string>\n\n\n\nnamespace asmdom {\n\n\n\n\tstd::string toHTML(VNode* const vnode);\n\n\n\n}\n\n\n\n#endif", "file_path": "src/cpp/toHTML/toHTML.hpp", "rank": 37, "score": 52192.5949148078 }, { "content": "void shouldEscapeProps() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tProps {\n\n\t\t\t{\"data-foo\", emscripten::val(\"<>\\\"'&`text\")}\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div data-foo=\\\"&lt;&gt;&quot;&apos;&amp;&#96;text\\\"></div>\")\n\n\t);\n\n};\n\n\n\nEMSCRIPTEN_BINDINGS(tohtml_tests) {\n\n\temscripten::function(\"shouldHandleNullVNode\", &shouldHandleNullVNode);\n\n\temscripten::function(\"shouldParseElements\", &shouldParseElements);\n\n\temscripten::function(\"shouldParseComments\", &shouldParseComments);\n\n\temscripten::function(\"shouldParseFragments\", &shouldParseFragments);\n\n\temscripten::function(\"shouldParseText\", &shouldParseText);\n\n\temscripten::function(\"shouldHandleChildren\", &shouldHandleChildren);\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 38, "score": 52192.15196233628 }, { "content": "\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div style=\\\"width: 250px; height: 250px;\\\"></div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldSetTruthyAttributesToEmptyString() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tAttrs {\n\n\t\t\t{\"readonly\", \"true\"}\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div readonly=\\\"\\\"></div>\")\n\n\t);\n\n};\n\n\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 39, "score": 52191.19733733801 }, { "content": "void shouldParseProps() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tProps {\n\n\t\t\t{\"readonly\", emscripten::val(true)}\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div readonly=\\\"true\\\"></div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldOmitProps() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tProps {\n\n\t\t\t{\"attributes\", emscripten::val(\"foo\")},\n\n\t\t\t{\"childElementCount\", emscripten::val(\"foo\")},\n\n\t\t\t{\"children\", emscripten::val(\"foo\")},\n\n\t\t\t{\"classList\", emscripten::val(\"foo\")},\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 40, "score": 52191.1370747391 }, { "content": "\t\t\th(\"span\"),\n\n\t\t\th(\"b\")\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div><span></span><b></b></div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldHandleTextContent() {\n\n\tVNode* vnode = h(\"p\", std::string(\"a text 字à\"));\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<p>a text 字à</p>\")\n\n\t);\n\n};\n\n\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 41, "score": 52190.571032629945 }, { "content": "\t\t)\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div></div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldHandleInnerHTML() {\n\n\tVNode* vnode = h(\"div\",\n\n\t\tProps {\n\n\t\t\t{\"innerHTML\", emscripten::val(std::string(u8\"<p>a text 字à</p>\"))}\n\n\t\t}\n\n\t);\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(u8\"<div><p>a text 字à</p></div>\")\n\n\t);\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 42, "score": 52189.92016060729 }, { "content": "\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<div></div>\")\n\n\t);\n\n};\n\n\n\nvoid shouldParseComments() {\n\n\tVNode* vnode = h(\"!\", std::string(\"comment\"));\n\n\n\n\tassert(\n\n\t\ttoHTML(vnode) ==\n\n\t\tstd::string(\"<!--comment-->\")\n\n\t);\n\n};\n\n\n\nvoid shouldParseFragments() {\n\n\tVNode* vnode = h(\"\",\n\n\t\tChildren {\n\n\t\t\th(\"span\"),\n\n\t\t\th(\"b\")\n\n\t\t}\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 43, "score": 52189.77758628181 }, { "content": "\temscripten::function(\"shouldHandleTextContent\", &shouldHandleTextContent);\n\n\temscripten::function(\"shouldParseAttributes\", &shouldParseAttributes);\n\n\temscripten::function(\"shouldOmitFalsyAttributes\", &shouldOmitFalsyAttributes);\n\n\temscripten::function(\"shouldSetTruthyAttributesToEmptyString\", &shouldSetTruthyAttributesToEmptyString);\n\n\temscripten::function(\"shouldParseProps\", &shouldParseProps);\n\n\temscripten::function(\"shouldOmitProps\", &shouldOmitProps);\n\n\temscripten::function(\"shouldOmitCallbacks\", &shouldOmitCallbacks);\n\n\temscripten::function(\"shouldHandleInnerHTML\", &shouldHandleInnerHTML);\n\n\temscripten::function(\"shouldHandleSvgContainerElements\", &shouldHandleSvgContainerElements);\n\n\temscripten::function(\"shouldHandleSvgNonContainerElements\", &shouldHandleSvgNonContainerElements);\n\n\temscripten::function(\"shouldHandleVoidElements\", &shouldHandleVoidElements);\n\n\temscripten::function(\"shouldEscapeText\", &shouldEscapeText);\n\n\temscripten::function(\"shouldEscapeTextContent\", &shouldEscapeTextContent);\n\n\temscripten::function(\"shouldEscapeAttributes\", &shouldEscapeAttributes);\n\n\temscripten::function(\"shouldEscapeProps\", &shouldEscapeProps);\n\n};\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 44, "score": 52189.290074400546 }, { "content": "\t\t\t{\"clientHeight\", emscripten::val(\"foo\")},\n\n\t\t\t{\"clientLeft\", emscripten::val(\"foo\")},\n\n\t\t\t{\"clientTop\", emscripten::val(\"foo\")},\n\n\t\t\t{\"clientWidth\", emscripten::val(\"foo\")},\n\n\t\t\t{\"currentStyle\", emscripten::val(\"foo\")},\n\n\t\t\t{\"firstElementChild\", emscripten::val(\"foo\")},\n\n\t\t\t{\"innerHTML\", emscripten::val(\"foo\")},\n\n\t\t\t{\"lastElementChild\", emscripten::val(\"foo\")},\n\n\t\t\t{\"nextElementSibling\", emscripten::val(\"foo\")},\n\n\t\t\t{\"ongotpointercapture\", emscripten::val(\"foo\")},\n\n\t\t\t{\"onlostpointercapture\", emscripten::val(\"foo\")},\n\n\t\t\t{\"onwheel\", emscripten::val(\"foo\")},\n\n\t\t\t{\"outerHTML\", emscripten::val(\"foo\")},\n\n\t\t\t{\"previousElementSibling\", emscripten::val(\"foo\")},\n\n\t\t\t{\"runtimeStyle\", emscripten::val(\"foo\")},\n\n\t\t\t{\"scrollHeight\", emscripten::val(\"foo\")},\n\n\t\t\t{\"scrollLeft\", emscripten::val(\"foo\")},\n\n\t\t\t{\"scrollLeftMax\", emscripten::val(\"foo\")},\n\n\t\t\t{\"scrollTop\", emscripten::val(\"foo\")},\n\n\t\t\t{\"scrollTopMax\", emscripten::val(\"foo\")},\n", "file_path": "test/cpp/toHTML/toHTML.cpp", "rank": 46, "score": 52177.46273823709 }, { "content": "export const toHTML = (Module, vnode) => {\n\n if (typeof vnode !== 'number') return '';\n\n\n\n const html = Module._toHTML(vnode);\n\n\n\n if (Module.clearMemory === true) {\n\n setTimeout(Module.deleteVNode.bind(null, vnode));\n\n }\n\n\n\n return html;\n", "file_path": "src/js/toHTML.js", "rank": 47, "score": 49739.11856496464 }, { "content": "export const insertInnerHTML = (Module, vnodePtr) => {\n\n const data = Module.vnodesData[vnodePtr];\n\n return (\n\n data !== undefined &&\n\n data.raw !== undefined &&\n\n data.raw.innerHTML !== undefined\n\n ) ? String(data.raw.innerHTML)\n\n : '';\n", "file_path": "src/js/toHTML.js", "rank": 48, "score": 48607.02808185189 }, { "content": "import init from '../';\n\nimport setup from '../../setup';\n\n\n\ndescribe('attributes (cpp)', function testAttributes() {\n\n this.timeout(30000);\n\n\n\n let app;\n\n\n\n before((done) => {\n\n setup();\n\n app = init(done);\n\n });\n\n\n\n beforeEach(() => {\n\n while (document.body.firstChild) {\n\n document.body.removeChild(document.body.firstChild);\n\n }\n\n\n\n const root = document.createElement('div');\n\n root.setAttribute('id', 'root');\n\n document.body.appendChild(root);\n\n });\n\n\n\n it('should have their provided values', () => {\n\n app.shouldHaveTheirProvidedValues();\n\n });\n\n\n\n it('can be memoized', () => {\n\n app.attributesCanBeMemoized();\n\n });\n\n\n\n it('should be omitted when falsy values are provided', () => {\n\n app.shouldBeOmittedWhenFalsyValuesAreProvided();\n\n });\n\n\n\n it('should set truthy values to empty string', () => {\n\n app.shouldSetTruthyValuesToEmptyString();\n\n });\n\n\n\n it('should be set correctly when namespaced', () => {\n\n app.shouldBeSetCorrectlyWhenNamespaced();\n\n });\n\n});\n", "file_path": "test/cpp/attributes/attributes.spec.js", "rank": 49, "score": 45325.219954729924 }, { "content": "import init from '../';\n\nimport setup from '../../setup';\n\n\n\ndescribe('toHTML (cpp)', function test() {\n\n this.timeout(30000);\n\n\n\n let app;\n\n\n\n before((done) => {\n\n setup();\n\n app = init(done);\n\n });\n\n\n\n it('should handle NULL VNode', () => {\n\n app.shouldHandleNullVNode();\n\n });\n\n\n\n it('should parse elements', () => {\n\n app.shouldParseElements();\n\n });\n\n\n\n it('should parse comments', () => {\n\n app.shouldParseComments();\n\n });\n\n\n\n it('should parse fragments', () => {\n\n app.shouldParseFragments();\n\n });\n\n\n\n it('should parse text', () => {\n\n app.shouldParseText();\n\n });\n\n\n\n it('should handle children', () => {\n\n app.shouldHandleChildren();\n\n });\n\n\n\n it('should handle text content', () => {\n\n app.shouldHandleTextContent();\n\n });\n\n\n\n it('should parse attributes', () => {\n\n app.shouldParseAttributes();\n\n });\n\n\n\n it('should omit falsy attributes', () => {\n\n app.shouldOmitFalsyAttributes();\n\n });\n\n\n\n it('should set truthy attributes to empty string', () => {\n\n app.shouldSetTruthyAttributesToEmptyString();\n\n });\n\n\n\n it('should parse props', () => {\n\n app.shouldParseProps();\n\n });\n\n\n\n it('should omit props', () => {\n\n app.shouldOmitProps();\n\n });\n\n\n\n it('should omit callbacks', () => {\n\n app.shouldOmitCallbacks();\n\n });\n\n\n\n it('should handle innerHTML', () => {\n\n app.shouldHandleInnerHTML();\n\n });\n\n\n\n it('should handle svg container elements', () => {\n\n app.shouldHandleSvgContainerElements();\n\n });\n\n\n\n it('should handle svg non container elements', () => {\n\n app.shouldHandleSvgNonContainerElements();\n\n });\n\n\n\n it('should handle void elements', () => {\n\n app.shouldHandleVoidElements();\n\n });\n\n\n\n it('should escape text', () => {\n\n app.shouldEscapeText();\n\n });\n\n\n\n it('should escape text content', () => {\n\n app.shouldEscapeTextContent();\n\n });\n\n\n\n it('should escape attributes', () => {\n\n app.shouldEscapeAttributes();\n\n });\n\n\n\n it('should escape props', () => {\n\n app.shouldEscapeProps();\n\n });\n\n\n\n // js only:\n\n // should support props in utf8\n\n});\n", "file_path": "test/cpp/toHTML/toHTML.spec.js", "rank": 50, "score": 45020.59807777685 }, { "content": "const getChildren = (Module, arr) => {\n\n const result = new Module.VNodePtrVector();\n\n for (let i = 0; i < arr.length; i++) {\n\n if (typeof arr[i] === 'string') {\n\n result.push_back(Module._h_ti(arr[i], true));\n\n } else if (arr[i] !== false && arr[i] !== null && arr[i] !== undefined) {\n\n result.push_back(arr[i]);\n\n }\n\n }\n\n return result;\n", "file_path": "src/js/h.js", "rank": 51, "score": 40803.03699707102 }, { "content": "const escapes = {\n\n '<': '&lt;',\n\n '>': '&gt;',\n\n '&': '&amp;',\n\n '\"': '&quot;',\n\n '\\'': '&apos;',\n\n '`': '&#96;',\n", "file_path": "src/js/toHTML.js", "rank": 52, "score": 40382.54093184007 }, { "content": "const escape = string => String(string).replace(/[&<>\"'`]/g, char => escapes[char]);\n", "file_path": "src/js/toHTML.js", "rank": 53, "score": 40382.54093184007 }, { "content": "const omitProps = {\n\n attributes: true,\n\n childElementCount: true,\n\n children: true,\n\n classList: true,\n\n clientHeight: true,\n\n clientLeft: true,\n\n clientTop: true,\n\n clientWidth: true,\n\n currentStyle: true,\n\n firstElementChild: true,\n\n innerHTML: true,\n\n lastElementChild: true,\n\n nextElementSibling: true,\n\n ongotpointercapture: true,\n\n onlostpointercapture: true,\n\n onwheel: true,\n\n outerHTML: true,\n\n previousElementSibling: true,\n\n runtimeStyle: true,\n\n scrollHeight: true,\n\n scrollLeft: true,\n\n scrollLeftMax: true,\n\n scrollTop: true,\n\n scrollTopMax: true,\n\n scrollWidth: true,\n\n tabStop: true,\n\n tagName: true,\n", "file_path": "src/js/toHTML.js", "rank": 54, "score": 39633.10294296365 }, { "content": "export const appendProps = (Module, vnodePtr) => {\n\n let raws = Module.vnodesData[vnodePtr];\n\n if (raws === undefined) return '';\n\n\n\n raws = raws.raw;\n\n if (raws === undefined) return '';\n\n\n\n let props = '';\n\n // eslint-disable-next-line\n\n for (const key in raws) {\n\n const type = typeof raws[key];\n\n if (omitProps[key] === undefined && type !== 'function' && type !== 'undefined') {\n\n props += ` ${key}=\"${escape(raws[key])}\"`;\n\n }\n\n }\n\n\n\n return props;\n", "file_path": "src/js/toHTML.js", "rank": 55, "score": 39633.10294296365 }, { "content": "const KEY_ENTER = 13;\n", "file_path": "examples/todomvc - js/src/todos.js", "rank": 56, "score": 38612.613541259205 }, { "content": "const KEY_ENTER = 13;\n", "file_path": "examples/todomvc - js/src/task.js", "rank": 57, "score": 38612.613541259205 }, { "content": "---\n\nid: svg\n\ntitle: SVG\n\n---\n\n\n\nSVG just works when using the `h` function for creating virtual nodes. SVG elements are automatically created with the appropriate namespaces.\n\n\n\n```c++\n\nVNode* vnode = h(\"div\", Children {\n\n h(\"svg\",\n\n Data(\n\n Attrs {\n\n {\"width\", \"100\"},\n\n {\"height\", \"100\"}\n\n }\n\n ),\n\n Children {\n\n h(\"circle\",\n\n Data(\n\n Attrs {\n\n {\n\n {\"cx\", \"50\"},\n\n {\"cy\", \"50\"},\n\n {\"r\", \"40\"},\n\n {\"stroke\", \"green\"},\n\n {\"stroke-width\", \"4\"},\n\n {\"fill\", \"yellow\"}\n\n }\n\n }\n\n )\n\n )\n\n }\n\n )\n\n});\n\n```\n", "file_path": "docs/svg.md", "rank": 58, "score": 36679.47950952398 }, { "content": "---\n\nid: toHTML\n\ntitle: toHTML\n\n---\n\n\n\nRenders a vnode to HTML string. This is particularly useful if you want to generate HTML on the server.\n\n\n\n```c++\n\nVNode* vnode = h(\"div\",\n\n Data(\n\n Attrs {\n\n {\"id\", \"root\"}\n\n {\"style\", \"color: #000\"}\n\n }\n\n ),\n\n Children {\n\n h(\"h1\", string(\"Headline\")),\n\n h(\"p\", string(\"A paragraph\")),\n\n }\n\n);\n\n\n\nstd::string html = toHTML(vnode);\n\n// html = <div id=\"root\" style=\"color: #000\"><h1>Headline</h1><p>A paragraph</p></div>;\n\n```\n", "file_path": "docs/toHTML.md", "rank": 59, "score": 36292.00818567175 }, { "content": "---\n\nid: children\n\ntitle: Children\n\n---\n\n\n\nIf a tag is empty, you can close it with `/>`, like XML:\n\n\n\n```js\n\n<div />\n\n```\n\n\n\notherwise, it can contains children:\n\n\n\n```js\n\n<div>\n\n <h1>Hello World!</h1>\n\n <img src=\"hello.png\" />\n\n This is a text\n\n</div>\n\n```\n\n\n\n## Expressions as children\n\n\n\nYou can also embed expressions in children, these expressions can produce `std::string`, `asmdom::VNode` or `asmdom::Children`.\n\n\n\n### Strings\n\n\n\n`std::string` can be embed using double curly brackets:\n\n\n\n```js\n\n// std::string name = \"foo\";\n\n\n\n<div>\n\n <h1>Hello {{ name }}!</h1>\n\n</div>\n\n```\n\n\n\n### VNode\n\n\n\n`asmdom::VNode` can be embed using single curly brackets:\n\n\n\n```js\n\n/*\n\nasmdom::VNode getImg(std::string src) {\n\n return <img src={src} />;\n\n};\n\n*/\n\n\n\n<div>\n\n <h1>Hello World!</h1>\n\n { getImg(\"hello.png\") }\n\n</div>\n\n```\n\n\n\n### Children\n\n\n\n`asmdom::Children` can be embed using `{...expression}`:\n\n\n\n```js\n\n/*\n\nasmdom::Children getVNodes(std::string src) {\n\n return asmdom::Children {\n\n <img src={src} />,\n\n <div>Rendering {{ src }}</div>\n\n };\n\n};\n\n*/\n\n\n\n<div>\n\n <h1>Hello World!</h1>\n\n {...getVNodes(\"hello.png\")}\n\n</div>\n\n```\n\n\n\n## NULL children\n\n\n\nIf you want to conditionally render something, `CPX` accepts `NULL` values:\n\n\n\n```js\n\n// std::string name = \"foo\";\n\n<div>\n\n <h1>Hello World!</h1>\n\n { name === \"foo\" ? <h2>Hi Foo!</h2> : NULL }\n\n</div>\n", "file_path": "docs/cpx-children.md", "rank": 60, "score": 36057.25759660319 }, { "content": "---\n\nid: boolean-attributes\n\ntitle: Boolean Attributes\n\n---\n\n\n\nIf you want to set a boolean attribute, like `readonly`, you can just pass true or false as string, asm-dom will handle it for you:\n\n\n\n```c++\n\nVNode* vnode = h(\"input\",\n\n Data(\n\n Attrs {\n\n {\"type\", \"text\"}\n\n {\"readonly\", \"true\"}\n\n // or {\"readonly\", \"false\"}\n\n },\n\n )\n\n);\n\n```\n", "file_path": "docs/boolean-attributes.md", "rank": 61, "score": 35933.00767150558 }, { "content": " static get observedAttributes() {\n\n return ['name'];\n", "file_path": "examples/webcomponents - cpp/src/components/HelloComponent.js", "rank": 62, "score": 35903.399540809776 }, { "content": " static get observedAttributes() {\n\n return ['name'];\n", "file_path": "examples/webcomponents - js/src/components/HelloComponent.js", "rank": 63, "score": 35903.399540809776 }, { "content": "// https://developer.mozilla.org/en-US/docs/Web/API/element\n\nconst omitProps = {\n\n attributes: true,\n\n childElementCount: true,\n\n children: true,\n\n classList: true,\n\n clientHeight: true,\n\n clientLeft: true,\n\n clientTop: true,\n\n clientWidth: true,\n\n currentStyle: true,\n\n firstElementChild: true,\n\n innerHTML: true,\n\n lastElementChild: true,\n\n nextElementSibling: true,\n\n ongotpointercapture: true,\n\n onlostpointercapture: true,\n\n onwheel: true,\n\n outerHTML: true,\n\n previousElementSibling: true,\n\n runtimeStyle: true,\n\n scrollHeight: true,\n\n scrollLeft: true,\n\n scrollLeftMax: true,\n\n scrollTop: true,\n\n scrollTopMax: true,\n\n scrollWidth: true,\n\n tabStop: true,\n\n tagName: true,\n\n};\n\n\n\nconst escapes = {\n\n '<': '&lt;',\n\n '>': '&gt;',\n\n '&': '&amp;',\n\n '\"': '&quot;',\n\n '\\'': '&apos;',\n\n '`': '&#96;',\n\n};\n\n\n\nconst escape = string => String(string).replace(/[&<>\"'`]/g, char => escapes[char]);\n\n\n\nexport const appendProps = (Module, vnodePtr) => {\n\n let raws = Module.vnodesData[vnodePtr];\n\n if (raws === undefined) return '';\n\n\n\n raws = raws.raw;\n\n if (raws === undefined) return '';\n\n\n\n let props = '';\n\n // eslint-disable-next-line\n\n for (const key in raws) {\n\n const type = typeof raws[key];\n\n if (omitProps[key] === undefined && type !== 'function' && type !== 'undefined') {\n\n props += ` ${key}=\"${escape(raws[key])}\"`;\n\n }\n\n }\n\n\n\n return props;\n\n};\n\n\n\nexport const insertInnerHTML = (Module, vnodePtr) => {\n\n const data = Module.vnodesData[vnodePtr];\n\n return (\n\n data !== undefined &&\n\n data.raw !== undefined &&\n\n data.raw.innerHTML !== undefined\n\n ) ? String(data.raw.innerHTML)\n\n : '';\n\n};\n\n\n\nexport const toHTML = (Module, vnode) => {\n\n if (typeof vnode !== 'number') return '';\n\n\n\n const html = Module._toHTML(vnode);\n\n\n\n if (Module.clearMemory === true) {\n\n setTimeout(Module.deleteVNode.bind(null, vnode));\n\n }\n\n\n\n return html;\n\n};\n", "file_path": "src/js/toHTML.js", "rank": 64, "score": 35662.09986332247 }, { "content": "## Props\n\n\n\nProps corresponds to [`asmdom::Props`](https://github.com/mbasso/asm-dom/blob/master/docs/cpp.md#h), they are [`emscripten::val`](https://kripken.github.io/emscripten-site/docs/api_reference/val.h.html) and are set using the dot notation `node.prop = val`. You can specify that an attribute is a prop surrounding it with square brackets:\n\n\n\n```\n\n<div\n\n attribute=\"this is a attribute\"\n\n [prop]=\"this is a prop\"\n\n/>\n\n```\n\n\n\nUsing gccx you don't have to care about the type, values are automatically passed to `emscripten::val` constructor, so, you can do something like this:\n\n\n\n```\n\n// you can provide any type:\n\n// int foo = 7;\n\n\n\n// or emscripten::val\n\n// emscripten::val bar = emscripten::val::undefined();\n\n\n\n<div\n\n [foo]={foo}\n\n [bar]={bar}\n\n/>\n\n```\n\n\n\n## Callbacks\n\n\n\nCallbacks corresponds to [`asmdom::Callbacks`](https://github.com/mbasso/asm-dom/blob/master/docs/cpp.md#h) and they are `std::function<bool(emscripten::val)>`. You can specify that an attribute is a callback surrounding it with parens:\n\n\n\n```\n\n<button (onclick)={handler} />\n\n```\n\n\n\nYou can provide to callbacks a `std::function<bool(emscripten::val)>`, a pointer to a function or a lambda:\n\n\n\n```\n\n/*\n\nbool onChange(emscripten::val event) {\n\n\t// do stuff...\n\n\treturn true;\n\n};\n\n*/\n\n\n\n<input\n\n (onchange)={onChange}\n\n (onkeydown)={[&](emscripten::val e) -> bool {\n\n // do stuff...\n\n return false;\n\n }}\n\n/>\n\n```\n\n\n\n## Default to true\n\n\n\nIf you pass no value for an attribute or a prop, it defaults to true:\n\n\n\n```\n\n<input [booleanVal] readonly>\n\n// is equal to\n\n<input [booleanVal]={true} readonly=\"true\">\n\n\n\n// falsy values can be used as follows:\n\n<input [booleanVal]={false} readonly=\"false\">\n\n```\n\n\n\n## Spread attributes\n\n\n\nIf you already have an `asmdom::Data` object, and you want to pass it in `CPX`, you can use `...` as a `spread` operator to pass the whole object:\n\n\n\n```js\n\n/*\n\nasmdom::Data data(\n\n Attrs {\n\n {\"class\", \"css-class\"},\n\n {\"style\", \"font-weight: bold\"}\n\n }\n\n)\n", "file_path": "docs/cpx-tag-attributes.md", "rank": 65, "score": 35339.10104991036 }, { "content": "---\n\nid: tag-attributes\n\ntitle: Tag Attributes\n\n---\n\n\n\nAttributes (attributes, props, and callbacks) can be set as string literals with double quotes just like in XML:\n\n\n\n```js\n\n<img src=\"hello.png\" />\n\n```\n\n\n\nor you can assign an expression inside curly brackets:\n\n\n\n```js\n\n// std::string filename = \"hello\";\n\n// std::string extension = \"png\";\n\n\n\n<img src={filename + \".\" + extension} />\n\n```\n\n\n\nDifferently from JSX, you can set any attribute just like in html, you don't have to use for example `className` or camel case identifiers:\n\n\n\n```js\n\n// in JSX:\n\n<div className=\"css-class\" tabIndex=\"0\" />\n\n\n\n// in CPX:\n\n<div class=\"css-class\" tabindex=\"0\" />\n\n```\n\n\n\n## Attributes\n\n\n\nAttributes corresponds to [`asmdom::Attrs`](https://github.com/mbasso/asm-dom/blob/master/docs/cpp.md#h), they are `std::string` and are set using `domNode.setAttribute(attr, val)`. Here is the syntax:\n\n\n\n```\n\n<image\n\n attribute=\"this is an attribute\"\n\n class=\"css-class\"\n\n data-id=\"foo\" // dataset attribute\n\n xlink:href=\"link\" // namespaced attribute\n\n/>\n\n```\n\n\n\nHowever there are some special identifiers that are automatically interpreted as props like `value` or `checked`. This is particularly convenient to avoid a code like `<input [value]={variable} />` every time.\n\nIn addition, `ref` and every attribute that starts with `on` is automatically interpreted as callbacks and rendered lowercase, for example:\n\n\n\n```\n\n<button onClick={callback} />\n\n<button ref={callback} />\n\n\n\n// is equal to\n\n\n\n<button (onclick)={callback}>\n\n<button (ref)={callback}>\n\n```\n\n\n\nIf you want to declare an attribute that stars with `on`, `ref`, `value` or `checked`, so, you want to ignore these rules, you can surround it with curly brackets:\n\n\n\n```\n\n<button onClick={callback} /> // this is an \"onclick\" callback\n\n<button {onClick}=\"callback\" /> // this is an \"onClick\" attribute\n\n```\n\n\n", "file_path": "docs/cpx-tag-attributes.md", "rank": 66, "score": 35334.1362166948 }, { "content": "*/\n\n\n\n<div attribute=\"foo\" {...data} />\n\n// is equal to\n\n<div attribute=\"foo\" class=\"css-class\" style=\"font-weight: bold\" />\n\n\n\n// you can overwrite values in spread putting them after it\n\n<div attribute=\"foo\" {...data} class=\"another-css-class\"/>\n\n// <div attribute=\"foo\" style=\"font-weight: bold\" class=\"another-css-class\" />\n", "file_path": "docs/cpx-tag-attributes.md", "rank": 67, "score": 35326.12515149392 }, { "content": " attributeChangedCallback() {\n\n this.update();\n\n this.shadowRoot.dispatchEvent(new Event('change', { bubbles: true, composed: true }));\n", "file_path": "examples/webcomponents - js/src/components/HelloComponent.js", "rank": 68, "score": 35313.695550245204 }, { "content": "import expect from 'expect';\n\nimport init from '../../src/js/';\n\nimport setup from '../setup';\n\n\n\ndescribe('attributes (js)', function testAttributes() {\n\n this.timeout(30000);\n\n\n\n let root;\n\n let vdom;\n\n let h;\n\n let patch;\n\n\n\n before((done) => {\n\n setup();\n\n init({\n\n useAsmJS: true,\n\n }).then((asmDom) => {\n\n vdom = asmDom;\n\n h = vdom.h;\n\n patch = vdom.patch;\n\n done();\n\n });\n\n });\n\n\n\n beforeEach(() => {\n\n vdom.reset();\n\n\n\n while (document.body.firstChild) {\n\n document.body.removeChild(document.body.firstChild);\n\n }\n\n\n\n root = document.createElement('div');\n\n root.setAttribute('id', 'root');\n\n document.body.appendChild(root);\n\n });\n\n\n\n it('should have their provided values', () => {\n\n const vnode = h('div', { href: '/foo', minlength: 1, foo: 'foo' });\n\n patch(root, vnode);\n\n const elm = document.body.firstChild;\n\n expect(elm.getAttribute('href')).toEqual('/foo');\n\n expect(elm.getAttribute('minlength')).toEqual('1');\n\n expect(elm.getAttribute('foo')).toEqual('foo');\n\n vdom.deleteVNode(vnode);\n\n });\n\n\n\n it('can be memoized', () => {\n\n const attrs = { href: '/foo', minlength: 1, foo: 'foo' };\n\n const vnode = h('div', attrs);\n\n const vnode2 = h('div', attrs);\n\n patch(root, vnode);\n\n let elm = document.body.firstChild;\n\n expect(elm.getAttribute('href')).toEqual('/foo');\n\n expect(elm.getAttribute('minlength')).toEqual('1');\n\n expect(elm.getAttribute('foo')).toEqual('foo');\n\n patch(vnode, vnode2);\n\n elm = document.body.firstChild;\n\n expect(elm.getAttribute('href')).toEqual('/foo');\n\n expect(elm.getAttribute('minlength')).toEqual('1');\n\n expect(elm.getAttribute('foo')).toEqual('foo');\n\n vdom.deleteVNode(vnode2);\n\n });\n\n\n\n it('should be omitted when falsy values are provided', () => {\n\n const vnode = h('div', { href: null, minlength: 0, foo: false });\n\n patch(root, vnode);\n\n const elm = document.body.firstChild;\n\n expect(elm.getAttribute('href')).toEqual('null');\n\n expect(elm.getAttribute('minlength')).toEqual('0');\n\n expect(elm.getAttribute('foo')).toEqual(null);\n\n vdom.deleteVNode(vnode);\n\n });\n\n\n\n it('should set truthy values to empty string', () => {\n\n const vnode = h('input', { href: null, minlength: 0, readonly: true });\n\n patch(root, vnode);\n\n const elm = document.body.firstChild;\n\n expect(elm.getAttribute('href')).toEqual('null');\n\n expect(elm.getAttribute('minlength')).toEqual('0');\n\n expect(elm.getAttribute('readonly')).toEqual('');\n\n vdom.deleteVNode(vnode);\n\n });\n\n\n\n it('should be set correctly when namespaced', () => {\n\n const vnode = h('div', { 'xlink:href': '#foo' });\n\n patch(root, vnode);\n\n const elm = document.body.firstChild;\n\n expect(elm.getAttributeNS('http://www.w3.org/1999/xlink', 'href')).toEqual('#foo');\n\n vdom.deleteVNode(vnode);\n\n });\n\n});\n", "file_path": "test/js/attributes.spec.js", "rank": 69, "score": 35313.695550245204 }, { "content": " attributeChangedCallback() {\n\n this.render();\n\n this.shadowRoot.dispatchEvent(new Event('change', { bubbles: true, composed: true }));\n", "file_path": "examples/webcomponents - cpp/src/components/HelloComponent.js", "rank": 70, "score": 35313.695550245204 }, { "content": "import expect from 'expect';\n\nimport init from '../../src/js/';\n\nimport setup from '../setup';\n\n\n\ndescribe('toHTML (js)', function testToHTML() {\n\n this.timeout(30000);\n\n\n\n let vdom;\n\n let h;\n\n let toHTML;\n\n\n\n before((done) => {\n\n setup();\n\n init({\n\n useAsmJS: true,\n\n }).then((asmDom) => {\n\n vdom = asmDom;\n\n h = vdom.h;\n\n toHTML = vdom.toHTML;\n\n done();\n\n });\n\n });\n\n\n\n it('should handle NULL VNode', () => {\n\n const vnode = undefined;\n\n\n\n expect(toHTML(vnode)).toEqual('');\n\n });\n\n\n\n it('should parse elements', () => {\n\n const vnode = h('div');\n\n\n\n expect(toHTML(vnode)).toEqual('<div></div>');\n\n });\n\n\n\n it('should parse comments', () => {\n\n const vnode = h('!', 'comment');\n\n\n\n expect(toHTML(vnode)).toEqual('<!--comment-->');\n\n });\n\n\n\n it('should parse fragments', () => {\n\n const vnode = h('', [\n\n h('span'),\n\n h('b'),\n\n ]);\n\n\n\n expect(toHTML(vnode)).toEqual('<span></span><b></b>');\n\n });\n\n\n\n it('should parse text', () => {\n\n const vnode = h('a text', true);\n\n\n\n expect(toHTML(vnode)).toEqual('a text');\n\n });\n\n\n\n it('should handle children', () => {\n\n const vnode = h('div', [\n\n h('span'),\n\n h('b'),\n\n ]);\n\n\n\n expect(toHTML(vnode)).toEqual('<div><span></span><b></b></div>');\n\n });\n\n\n\n it('should handle text content', () => {\n\n const vnode = h('p', 'a text');\n\n\n\n expect(toHTML(vnode)).toEqual('<p>a text</p>');\n\n });\n\n\n\n it('should parse attributes', () => {\n\n const vnode = h('div', {\n\n 'data-foo': 'bar',\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div data-foo=\"bar\"></div>');\n\n });\n\n\n\n it('should omit falsy attributes', () => {\n\n const vnode = h('div', {\n\n readonly: false,\n\n style: 'width: 250px; height: 250px;',\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div style=\"width: 250px; height: 250px;\"></div>');\n\n });\n\n\n\n it('should set truthy attributes to empty string', () => {\n\n const vnode = h('div', {\n\n readonly: true,\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div readonly=\"\"></div>');\n\n });\n\n\n\n it('should parse props', () => {\n\n const vnode = h('div', {\n\n raw: {\n\n readonly: true,\n\n },\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div readonly=\"true\"></div>');\n\n });\n\n\n\n it('should omit props', () => {\n\n const vnode = h('div', {\n\n raw: {\n\n attributes: 'foo',\n\n childElementCount: 'foo',\n\n children: 'foo',\n\n classList: 'foo',\n\n clientHeight: 'foo',\n\n clientLeft: 'foo',\n\n clientTop: 'foo',\n\n clientWidth: 'foo',\n\n currentStyle: 'foo',\n\n firstElementChild: 'foo',\n\n innerHTML: 'foo',\n\n lastElementChild: 'foo',\n\n nextElementSibling: 'foo',\n\n ongotpointercapture: 'foo',\n\n onlostpointercapture: 'foo',\n\n onwheel: 'foo',\n\n outerHTML: 'foo',\n\n previousElementSibling: 'foo',\n\n runtimeStyle: 'foo',\n\n scrollHeight: 'foo',\n\n scrollLeft: 'foo',\n\n scrollLeftMax: 'foo',\n\n scrollTop: 'foo',\n\n scrollTopMax: 'foo',\n\n scrollWidth: 'foo',\n\n tabStop: 'foo',\n\n tagName: 'foo',\n\n },\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div>foo</div>');\n\n });\n\n\n\n it('should omit callbacks', () => {\n\n const vnode = h('div', {\n\n raw: {\n\n onclick: () => {},\n\n },\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div></div>');\n\n });\n\n\n\n it('should handle innerHTML', () => {\n\n const vnode = h('div', {\n\n raw: {\n\n innerHTML: '<p>a text 字à</p>',\n\n },\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div><p>a text 字à</p></div>');\n\n });\n\n\n\n it('should handle svg container elements', () => {\n\n const vnode = h('svg', [\n\n h('a'),\n\n h('defs'),\n\n h('glyph'),\n\n h('g'),\n\n h('marker'),\n\n h('mask'),\n\n h('missing-glyph'),\n\n h('pattern'),\n\n h('svg'),\n\n h('switch'),\n\n h('symbol'),\n\n h('text'),\n\n h('desc'),\n\n h('metadata'),\n\n h('title'),\n\n ]);\n\n\n\n expect(toHTML(vnode)).toEqual('<svg><a></a><defs></defs><glyph></glyph><g></g><marker></marker><mask></mask><missing-glyph></missing-glyph><pattern></pattern><svg></svg><switch></switch><symbol></symbol><text></text><desc></desc><metadata></metadata><title></title></svg>');\n\n });\n\n\n\n it('should handle svg non container elements', () => {\n\n const vnode = h('svg', [\n\n h('rect'),\n\n ]);\n\n\n\n expect(toHTML(vnode)).toEqual('<svg><rect /></svg>');\n\n });\n\n\n\n it('should handle void elements', () => {\n\n const vnode = h('div', [\n\n h('area'),\n\n h('base'),\n\n h('br'),\n\n h('col'),\n\n h('embed'),\n\n h('hr'),\n\n h('img'),\n\n h('input'),\n\n h('keygen'),\n\n h('link'),\n\n h('meta'),\n\n h('param'),\n\n h('source'),\n\n h('track'),\n\n h('wbr'),\n\n ]);\n\n\n\n expect(toHTML(vnode)).toEqual('<div><area><base><br><col><embed><hr><img><input><keygen><link><meta><param><source><track><wbr></div>');\n\n });\n\n\n\n it('should escape text', () => {\n\n const vnode = h('<>\"\\'&`text', true);\n\n\n\n expect(toHTML(vnode)).toEqual('&lt;&gt;&quot;&apos;&amp;&#96;text');\n\n });\n\n\n\n it('should escape text content', () => {\n\n const vnode = h('p', '<>\"\\'&`text');\n\n\n\n expect(toHTML(vnode)).toEqual('<p>&lt;&gt;&quot;&apos;&amp;&#96;text</p>');\n\n });\n\n\n\n it('should escape attributes', () => {\n\n const vnode = h('div', {\n\n 'data-foo': '<>\"\\'&`text',\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div data-foo=\"&lt;&gt;&quot;&apos;&amp;&#96;text\"></div>');\n\n });\n\n\n\n it('should escape props', () => {\n\n const vnode = h('div', {\n\n raw: {\n\n 'data-foo': '<>\"\\'&`text',\n\n },\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div data-foo=\"&lt;&gt;&quot;&apos;&amp;&#96;text\"></div>');\n\n });\n\n\n\n it('should support attrs and props in utf8', () => {\n\n const vnode = h('div', {\n\n 'data-bar': '漢字àèò',\n\n raw: {\n\n 'data-foo': 'àèò漢字',\n\n },\n\n });\n\n\n\n expect(toHTML(vnode)).toEqual('<div data-bar=\"漢字àèò\" data-foo=\"àèò漢字\"></div>');\n\n });\n\n});\n", "file_path": "test/js/toHTML.spec.js", "rank": 71, "score": 35076.359157142004 }, { "content": "webpackJsonp([1],{341:function(module,exports,__webpack_require__){(function(process){function ga(){return function(b){function Qa(e){eval.call(null,e)}function x(e,i){e||F(\"Assertion failed: \"+i)}function Ab(e){var i;switch(i=\"i32\",\"*\"===i.charAt(i.length-1)&&(i=\"i32\"),i){case\"i1\":case\"i8\":return B[e>>0];case\"i16\":return O[e>>1];case\"i32\":case\"i64\":return p[e>>2];case\"float\":return X[e>>2];case\"double\":return Y[e>>3];default:F(\"invalid type for setValue: \"+i)}return null}function G(e,i,f,n){var t,a;\"number\"==typeof e?(t=!0,a=e):(t=!1,a=e.length);var l,o=\"string\"==typeof i?i:null;if(l=4==f?n:[\"function\"==typeof L?L:h.F,h.D,h.F,h.M][void 0===f?2:f](Math.max(a,o?1:i.length)),t){for(n=l,x(0==(3&l)),e=l+(-4&a);n<e;n+=4)p[n>>2]=0;for(e=l+a;n<e;)B[n++>>0]=0;return l}if(\"i8\"===o)return e.subarray||e.slice?r.set(e,l):r.set(new Uint8Array(e),l),l;n=0;for(var u,s;n<a;){var b=e[n];if(\"function\"==typeof b&&(b=h.la(b)),0===(f=o||i[n]))n++;else{\"i64\"==f&&(f=\"i32\"),t=l+n;var c=f,c=c||\"i8\";switch(\"*\"===c.charAt(c.length-1)&&(c=\"i32\"),c){case\"i1\":case\"i8\":B[t>>0]=b;break;case\"i16\":O[t>>1]=b;break;case\"i32\":p[t>>2]=b;break;case\"i64\":tempI64=[b>>>0,(tempDouble=b,1<=+Bb(tempDouble)?0<tempDouble?(0|Cb(+Db(tempDouble/4294967296),4294967295))>>>0:~~+Eb((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],p[t>>2]=tempI64[0],p[t+4>>2]=tempI64[1];break;case\"float\":X[t>>2]=b;break;case\"double\":Y[t>>3]=b;break;default:F(\"invalid type for setValue: \"+c)}s!==f&&(u=h.B(f),s=f),n+=u}}return l}function wa(e){var i;if(0===i||!e)return\"\";for(var f,n=0,t=0;(f=r[e+t>>0],n|=f,0!=f||i)&&(t++,!i||t!=i););if(i||(i=t),f=\"\",128>n){for(;0<i;)n=String.fromCharCode.apply(String,r.subarray(e,e+Math.min(i,1024))),f=f?f+n:n,e+=1024,i-=1024;return f}return b.UTF8ToString(e)}function Ra(e,i){for(var r=i;e[r];)++r;if(16<r-i&&e.subarray&&Sa)return Sa.decode(e.subarray(i,r));for(var f,n,t,a,l,o,r=\"\";;){if(!(f=e[i++]))return r;128&f?(n=63&e[i++],192==(224&f)?r+=String.fromCharCode((31&f)<<6|n):(t=63&e[i++],224==(240&f)?f=(15&f)<<12|n<<6|t:(a=63&e[i++],240==(248&f)?f=(7&f)<<18|n<<12|t<<6|a:(l=63&e[i++],248==(252&f)?f=(3&f)<<24|n<<18|t<<12|a<<6|l:(o=63&e[i++],f=(1&f)<<30|n<<24|t<<18|a<<12|l<<6|o))),65536>f?r+=String.fromCharCode(f):(f-=65536,r+=String.fromCharCode(55296|f>>10,56320|1023&f)))):r+=String.fromCharCode(f)}}function Ta(e,i,r,f){if(0<f){f=r+f-1;for(var n=0;n<e.length;++n){var t=e.charCodeAt(n);if(55296<=t&&57343>=t&&(t=65536+((1023&t)<<10)|1023&e.charCodeAt(++n)),127>=t){if(r>=f)break;i[r++]=t}else{if(2047>=t){if(r+1>=f)break;i[r++]=192|t>>6}else{if(65535>=t){if(r+2>=f)break;i[r++]=224|t>>12}else{if(2097151>=t){if(r+3>=f)break;i[r++]=240|t>>18}else{if(67108863>=t){if(r+4>=f)break;i[r++]=248|t>>24}else{if(r+5>=f)break;i[r++]=252|t>>30,i[r++]=128|t>>24&63}i[r++]=128|t>>18&63}i[r++]=128|t>>12&63}i[r++]=128|t>>6&63}i[r++]=128|63&t}}i[r]=0}}function Ua(e){for(var i=0,r=0;r<e.length;++r){var f=e.charCodeAt(r);55296<=f&&57343>=f&&(f=65536+((1023&f)<<10)|1023&e.charCodeAt(++r)),127>=f?++i:i=2047>=f?i+2:65535>=f?i+3:2097151>=f?i+4:67108863>=f?i+5:i+6}return i}function Fb(e){return e.replace(/__Z[\\w\\d_]+/g,function(e){var i;e:{var f=b.___cxa_demangle||b.__cxa_demangle;if(f)try{var n=e.substr(1),t=Ua(n)+1,a=L(t);Ta(n,r,a,t);var l=L(4),o=f(a,0,0,l);if(0===Ab(l)&&o){i=wa(o);break e}}catch(e){}finally{a&&y(a),l&&y(l),o&&y(o)}else h.h(\"warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling\");i=e}return e===i?e:e+\" [\"+i+\"]\"})}function Gb(){var e;e:{if(e=Error(),!e.stack){try{throw Error(0)}catch(i){e=i}if(!e.stack){e=\"(no stack trace available)\";break e}}e=e.stack.toString()}return b.extraStackTrace&&(e+=\"\\n\"+b.extraStackTrace()),Fb(e)}function xa(){F(\"Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value \"+S+\", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 \")}function T(e){for(;0<e.length;){var i=e.shift();if(\"function\"==typeof i)i();else{var r=i.t;\"number\"==typeof r?void 0===i.q?b.dynCall_v(r):b.dynCall_vi(r,i.q):r(void 0===i.q?null:i.q)}}}function Hb(e){Va.unshift(e)}function ya(e){var i=Array(Ua(e)+1);return Ta(e,i,0,i.length),i}function Wa(){for(var e=Array(256),i=0;256>i;++i)e[i]=String.fromCharCode(i);Xa=e}function z(e){for(var i=\"\";r[e];)i+=Xa[r[e++]];return i}function ha(e){if(void 0===e)return\"_unknown\";e=e.replace(/[^a-zA-Z0-9_]/g,\"$\");var i=e.charCodeAt(0);return 48<=i&&57>=i?\"_\"+e:e}function za(e,i){return e=ha(e),new Function(\"body\",\"return function \"+e+'() {\\n \"use strict\"; return body.apply(this, arguments);\\n};\\n')(i)}function ia(e,i){var r=za(i,function(e){this.name=i,this.message=e,void 0!==(e=Error(e).stack)&&(this.stack=this.toString()+\"\\n\"+e.replace(/^Error(:[^\\n]*)?\\n/,\"\"))});return r.prototype=Object.create(e.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return void 0===this.message?this.name:this.name+\": \"+this.message},r}function u(e){throw new Ya(e)}function Aa(e){throw new Za(e)}function $a(e,i,r){function f(i){i=r(i),i.length!==e.length&&Aa(\"Mismatched type converter count\");for(var f=0;f<e.length;++f)H(e[f],i[f])}e.forEach(function(e){ja[e]=i});var n=Array(i.length),t=[],a=0;i.forEach(function(e,i){P.hasOwnProperty(e)?n[i]=P[e]:(t.push(e),U.hasOwnProperty(e)||(U[e]=[]),U[e].push(function(){n[i]=P[e],++a===t.length&&f(n)}))}),0===t.length&&f(n)}function H(e,i,r){if(r=r||{},!(\"argPackAdvance\"in i))throw new TypeError(\"registerType registeredInstance requires argPackAdvance\");var f=i.name;if(e||u('type \"'+f+'\" must have a positive integer typeid pointer'),P.hasOwnProperty(e)){if(r.R)return;u(\"Cannot register type '\"+f+\"' twice\")}P[e]=i,delete ja[e],U.hasOwnProperty(e)&&(i=U[e],delete U[e],i.forEach(function(e){e()}))}function ab(e){var i=ka.length;return ka.push(e),i}function Ba(e){e=Ib(e);var i=z(e);return y(e),i}function la(e,i){var r=P[e];return void 0===r&&u(i+\" has unknown type \"+Ba(e)),r}function bb(e,i){for(var r=Array(e),f=0;f<e;++f)r[f]=la(p[(i>>2)+f],\"parameter \"+f);return r}function Ca(e,i){if(!(e instanceof Function))throw new TypeError(\"new_ called with constructor type \"+typeof e+\" which is not a function\");var r=za(e.name||\"unknownFunctionName\",function(){});r.prototype=e.prototype;var r=new r,f=e.apply(r,i);return f instanceof Object?f:r}function V(){return!!V.a}function Z(){var e=t.l;if(!e)return 0|(h.g(0),0);var i=t.b[e],r=i.type;if(!r)return 0|(h.g(0),e);var f=Array.prototype.slice.call(arguments);b.___cxa_is_pointer_type(r),Z.buffer||(Z.buffer=L(4)),p[Z.buffer>>2]=e;for(var e=Z.buffer,n=0;n<f.length;n++)if(f[n]&&b.___cxa_can_catch(f[n],r,e))return e=p[e>>2],i.v=e,0|(h.g(f[n]),e);return e=p[e>>2],0|(h.g(r),e)}function aa(e){var i=Jb[e];return void 0===i?z(e):i}function cb(){for(var e=0,i=5;i<v.length;++i)void 0!==v[i]&&++e;return e}function db(){for(var e=5;e<v.length;++e)if(void 0!==v[e])return v[e];return null}function eb(){b.count_emval_handles=cb,b.get_first_emval=db}function K(e){switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var i=Da.length?Da.pop():v.length;return v[i]={d:1,value:e},i}}function D(e){return e||u(\"Cannot use deleted val. handle = \"+e),v[e].value}function fb(e){var i=[];return p[e>>2]=K(i),i}function ba(e,i){ba.a||(ba.a={}),e in ba.a||(b.dynCall_v(i),ba.a[e]=1)}function Ea(e){4<e&&0==--v[e].d&&(v[e]=void 0,Da.push(e))}function ma(e){if(null===e)return\"null\";var i=typeof e;return\"object\"===i||\"array\"===i||\"function\"===i?e.toString():\"\"+e}function na(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(\"Unknown type size: \"+e)}}function gb(e,i,f){switch(i){case 0:return f?function(e){return B[e]}:function(e){return r[e]};case 1:return f?function(e){return O[e>>1]}:function(e){return oa[e>>1]};case 2:return f?function(e){return p[e>>2]}:function(e){return I[e>>2]};default:throw new TypeError(\"Unknown integer type: \"+e)}}function pa(e){return this.fromWireType(I[e>>2])}function hb(e,i){switch(i){case 2:return function(e){return this.fromWireType(X[e>>2])};case 3:return function(e){return this.fromWireType(Y[e>>3])};default:throw new TypeError(\"Unknown float type: \"+e)}}function qa(e){var i,r;qa.i?(r=p[ib>>2],i=p[r>>2]):(qa.i=!0,J.USER=J.LOGNAME=\"web_user\",J.PATH=\"/\",J.PWD=\"/\",J.HOME=\"/home/web_user\",J.LANG=\"C\",J._=b.thisProgram,i=G(1024,\"i8\",2),r=G(256,\"i8*\",2),p[r>>2]=i,p[ib>>2]=r);var f,n=[],t=0;for(f in e)if(\"string\"==typeof e[f]){var a=f+\"=\"+e[f];n.push(a),t+=a.length}if(1024<t)throw Error(\"Environment size exceeded TOTAL_ENV_SIZE!\");for(e=0;e<n.length;e++){t=a=n[e],f=i;for(var l=0;l<t.length;++l)B[f++>>0]=t.charCodeAt(l);B[f>>0]=0,p[r+4*e>>2]=i,i+=a.length+1}p[r+4*n.length>>2]=0}function ca(e){return 0===e?0:(e=wa(e),J.hasOwnProperty(e)?(ca.a&&y(ca.a),ca.a=G(ya(J[e]),\"i8\",0),ca.a):0)}function Fa(e){for(;e.length;){var i=e.pop();e.pop()(i)}}function jb(e,i,r,f,n){var t=i.length;2>t&&u(\"argTypes array size mismatch! Must at least get return value and 'this' types!\");var a=null!==i[1]&&null!==r,l=\"\",o=\"\";for(r=0;r<t-2;++r)l+=(0!==r?\", \":\"\")+\"arg\"+r,o+=(0!==r?\", \":\"\")+\"arg\"+r+\"Wired\";e=\"return function \"+ha(e)+\"(\"+l+\") {\\nif (arguments.length !== \"+(t-2)+\") {\\nthrowBindingError('function \"+e+\" called with ' + arguments.length + ' arguments, expected \"+(t-2)+\" args!');\\n}\\n\";var s=!1;for(r=1;r<i.length;++r)if(null!==i[r]&&void 0===i[r].e){s=!0;break}s&&(e+=\"var destructors = [];\\n\");var b=s?\"destructors\":\"null\",l=\"throwBindingError invoker fn runDestructors retType classParam\".split(\" \");for(f=[u,f,n,Fa,i[0],i[1]],a&&(e+=\"var thisWired = classParam.toWireType(\"+b+\", this);\\n\"),r=0;r<t-2;++r)e+=\"var arg\"+r+\"Wired = argType\"+r+\".toWireType(\"+b+\", arg\"+r+\"); // \"+i[r+2].name+\"\\n\",l.push(\"argType\"+r),f.push(i[r+2]);if(a&&(o=\"thisWired\"+(0<o.length?\", \":\"\")+o),t=\"void\"!==i[0].name,e+=(t?\"var rv = \":\"\")+\"invoker(fn\"+(0<o.length?\", \":\"\")+o+\");\\n\",s)e+=\"runDestructors(destructors);\\n\";else for(r=a?1:2;r<i.length;++r)a=1===r?\"thisWired\":\"arg\"+(r-2)+\"Wired\",null!==i[r].e&&(e+=a+\"_dtor(\"+a+\"); // \"+i[r].name+\"\\n\",l.push(a+\"_dtor\"),f.push(i[r].e));return t&&(e+=\"var ret = retType.fromWireType(rv);\\nreturn ret;\\n\"),l.push(e+\"}\\n\"),Ca(Function,l).apply(null,f)}function kb(e,i,r){if(void 0===e[i].c){var f=e[i];e[i]=function(){return e[i].c.hasOwnProperty(arguments.length)||u(\"Function '\"+r+\"' called with an invalid number of arguments (\"+arguments.length+\") - expects one of (\"+e[i].c+\")!\"),e[i].c[arguments.length].apply(this,arguments)},e[i].c=[],e[i].c[f.I]=f}}function lb(e,i,r){b.hasOwnProperty(e)?((void 0===r||void 0!==b[e].c&&void 0!==b[e].c[r])&&u(\"Cannot register public name '\"+e+\"' twice\"),kb(b,e,e),b.hasOwnProperty(r)&&u(\"Cannot register multiple overloads of a function with the same number of arguments (\"+r+\")!\"),b[e].c[r]=i):(b[e]=i,void 0!==r&&(b[e].va=r))}function mb(e,i){for(var r=[],f=0;f<e;f++)r.push(p[(i>>2)+f]);return r}function nb(e,i,r){b.hasOwnProperty(e)||Aa(\"Replacing nonexistant public symbol\"),void 0!==b[e].c&&void 0!==r?b[e].c[r]=i:(b[e]=i,b[e].I=r)}function ob(e,i){e=z(e);var r;if(void 0!==b[\"FUNCTION_TABLE_\"+e])r=b[\"FUNCTION_TABLE_\"+e][i];else if(\"undefined\"!=typeof FUNCTION_TABLE)r=FUNCTION_TABLE[i];else{r=b.asm[\"dynCall_\"+e],void 0===r&&void 0===(r=b.asm[\"dynCall_\"+e.replace(/f/g,\"d\")])&&u(\"No dynCall invoker for signature: \"+e);for(var f=[],n=1;n<e.length;++n)f.push(\"a\"+n);n=\"return function dynCall_\"+e+\"_\"+i+\"(\"+f.join(\", \")+\") {\\n\",n+=\" return dynCall(rawFunction\"+(f.length?\", \":\"\")+f.join(\", \")+\");\\n\",r=new Function(\"dynCall\",\"rawFunction\",n+\"};\\n\")(r,i)}return\"function\"!=typeof r&&u(\"unknown function pointer with signature \"+e+\": \"+i),r}function pb(e,i){function r(e){n[e]||P[e]||(ja[e]?ja[e].forEach(r):(f.push(e),n[e]=!0))}var f=[],n={};throw i.forEach(r),new qb(e+\": \"+f.map(Ba).join([\", \"]))}function rb(e){return b.___errno_location&&(p[b.___errno_location()>>2]=e),e}function Ga(){return Function(\"return this\")()}function M(e,i){m.f=i;try{var f=m.get(),n=m.get(),t=m.get(),a=0;M.buffer||(M.a=[null,[],[]],M.i=function(e,i){var r=M.a[e];x(r),0===i||10===i?((1===e?b.print:b.printErr)(Ra(r,0)),r.length=0):r.push(i)});for(var l=0;l<t;l++){for(var o=p[n+8*l>>2],u=p[n+(8*l+4)>>2],s=0;s<u;s++)M.i(f,r[o+s]);a+=u}return a}catch(e){return\"undefined\"!=typeof FS&&e instanceof FS.n||F(e),-e.s}}function W(e){this.name=\"ExitStatus\",this.message=\"Program terminated with exit(\"+e+\")\"}function sb(e){function i(){if(!b.calledRun&&(b.calledRun=!0,!ra)){if(sa||(sa=!0,T(Ha)),T(Kb),b.onRuntimeInitialized&&b.onRuntimeInitialized(),b._main&&tb&&b.callMain(e),b.postRun)for(\"function\"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var i=b.postRun.shift();ub.unshift(i)}T(ub)}}if(e=e||b.arguments,null===vb&&(vb=Date.now()),!(0<wb)){if(b.preRun)for(\"function\"==typeof b.preRun&&(b.preRun=[b.preRun]);b.preRun.length;)Hb(b.preRun.shift());T(Va),0<wb||b.calledRun||(b.setStatus?(b.setStatus(\"Running...\"),setTimeout(function(){setTimeout(function(){b.setStatus(\"\")},1),i()},1)):i())}}function xb(e,i){i&&b.noExitRuntime||(!b.noExitRuntime&&(ra=!0,E=Lb,T(yb),b.onExit)&&b.onExit(e),da&&process.exit(e),b.quit(e,new W(e)))}function F(e){b.onAbort&&b.onAbort(e),void 0!==e?(b.print(e),b.m(e),e=JSON.stringify(e)):e=\"\",ra=!0;var i=\"abort(\"+e+\") at \"+Gb()+\"\\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.\";throw zb&&zb.forEach(function(r){i=r(i,e)}),i}b||(b=eval(\"(function() { try { return Module || {} } catch(e) { return {} } })()\"));var ea={},N;for(N in b)b.hasOwnProperty(N)&&(ea[N]=b[N]);var fa=!1,Q=!1,da=!1,Ia=!1;if(b.ENVIRONMENT)if(\"WEB\"===b.ENVIRONMENT)fa=!0;else if(\"WORKER\"===b.ENVIRONMENT)Q=!0;else if(\"NODE\"===b.ENVIRONMENT)da=!0;else{if(\"SHELL\"!==b.ENVIRONMENT)throw Error(\"The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.\");Ia=!0}else fa=\"object\"==typeof window,Q=\"function\"==typeof importScripts,da=\"object\"==typeof process&&!0&&!fa&&!Q,Ia=!fa&&!da&&!Q;if(da){b.print||(b.print=console.log),b.printErr||(b.printErr=console.warn);var Ja,Ka;b.read=function(e,i){Ja||(Ja=__webpack_require__(345)),Ka||(Ka=__webpack_require__(346)),e=Ka.normalize(e);var r=Ja.readFileSync(e);return i?r:r.toString()},b.readBinary=function(e){return e=b.read(e,!0),e.buffer||(e=new Uint8Array(e)),x(e.buffer),e},b.load=function(e){Qa(read(e))},b.thisProgram||(b.thisProgram=1<process.argv.length?process.argv[1].replace(/\\\\/g,\"/\"):\"unknown-program\"),b.arguments=process.argv.slice(2),void 0!==module&&(module.exports=b),process.on(\"uncaughtException\",function(e){if(!(e instanceof W))throw e}),b.inspect=function(){return\"[Emscripten Module object]\"}}else if(Ia)b.print||(b.print=print),\"undefined\"!=typeof printErr&&(b.printErr=printErr),b.read=\"undefined\"!=typeof read?read:function(){throw\"no read() available\"},b.readBinary=function(e){return\"function\"==typeof readbuffer?new Uint8Array(readbuffer(e)):(e=read(e,\"binary\"),x(\"object\"==typeof e),e)},\"undefined\"!=typeof scriptArgs?b.arguments=scriptArgs:void 0!==arguments&&(b.arguments=arguments),\"function\"==typeof quit&&(b.quit=function(e){quit(e)}),eval(\"if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined\");else{if(!fa&&!Q)throw\"Unknown runtime environment. Where are we?\";b.read=function(e){var i=new XMLHttpRequest;return i.open(\"GET\",e,!1),i.send(null),i.responseText},Q&&(b.readBinary=function(e){var i=new XMLHttpRequest;return i.open(\"GET\",e,!1),i.responseType=\"arraybuffer\",i.send(null),new Uint8Array(i.response)}),b.readAsync=function(e,i,r){var f=new XMLHttpRequest;f.open(\"GET\",e,!0),f.responseType=\"arraybuffer\",f.onload=function(){200==f.status||0==f.status&&f.response?i(f.response):r()},f.onerror=r,f.send(null)},void 0!==arguments&&(b.arguments=arguments),\"undefined\"!=typeof console?(b.print||(b.print=function(e){console.log(e)}),b.printErr||(b.printErr=function(e){console.warn(e)})):b.print||(b.print=function(){}),Q&&(b.load=importScripts),void 0===b.setWindowTitle&&(b.setWindowTitle=function(e){document.title=e})}!b.load&&b.read&&(b.load=function(e){Qa(b.read(e))}),b.print||(b.print=function(){}),b.printErr||(b.printErr=b.print),b.arguments||(b.arguments=[]),b.thisProgram||(b.thisProgram=\"./this.program\"),b.quit||(b.quit=function(e,i){throw i}),b.print=b.print,b.m=b.printErr,b.preRun=[],b.postRun=[];for(N in ea)ea.hasOwnProperty(N)&&(b[N]=ea[N]);var ea=void 0,h={g:function(e){return tempRet0=e},P:function(){return tempRet0},W:function(){return E},V:function(e){E=e},B:function(e){switch(e){case\"i1\":case\"i8\":return 1;case\"i16\":return 2;case\"i32\":return 4;case\"i64\":return 8;case\"float\":return 4;case\"double\":return 8;default:return\"*\"===e[e.length-1]?h.p:\"i\"===e[0]?(e=parseInt(e.substr(1)),x(0==e%8),e/8):0}},N:function(e){return Math.max(h.B(e),h.p)},X:16,wa:function(e,i){return\"double\"===i||\"i64\"===i?7&e&&(x(4==(7&e)),e+=4):x(0==(3&e)),e},ia:function(e,i,r){return r||\"i64\"!=e&&\"double\"!=e?e?Math.min(i||(e?h.N(e):0),h.p):Math.min(i,8):8},r:function(e,i,r){return r&&r.length?b[\"dynCall_\"+e].apply(null,[i].concat(r)):b[\"dynCall_\"+e].call(null,i)},k:[],G:function(e){for(var i=0;i<h.k.length;i++)if(!h.k[i])return h.k[i]=e,2*(1+i);throw\"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.\"},U:function(e){h.k[(e-2)/2]=null},h:function(e){h.h.a||(h.h.a={}),h.h.a[e]||(h.h.a[e]=1,b.m(e))},u:{},ka:function(e,i){x(i),h.u[i]||(h.u[i]={});var r=h.u[i];return r[e]||(r[e]=1===i.length?function(){return h.r(i,e)}:2===i.length?function(r){return h.r(i,e,[r])}:function(){return h.r(i,e,Array.prototype.slice.call(arguments))}),r[e]},ja:function(){throw\"You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work\"},D:function(e){var i=E;return E=E+e|0,E=E+15&-16,i},F:function(e){var i=w;return w=w+e|0,w=w+15&-16,i},M:function(e){var i=p[R>>2];return e=-16&(i+e+15|0),p[R>>2]=e,(e=e>=S)&&(xa(),e=!0),e?(p[R>>2]=i,0):i},w:function(e,i){return Math.ceil(e/(i||16))*(i||16)},sa:function(e,i,r){return r?+(e>>>0)+4294967296*+(i>>>0):+(e>>>0)+4294967296*+(0|i)},o:8,p:4,Y:0};h.addFunction=h.G,h.removeFunction=h.U;var ra=0,Sa=\"undefined\"!=typeof TextDecoder?new TextDecoder(\"utf8\"):void 0;b.UTF8ToString=function(e){return Ra(r,e)},\"undefined\"!=typeof TextDecoder&&new TextDecoder(\"utf-16le\");var A,B,r,O,oa,p,I,X,Y,La,w,Ma,E,ta,Na,R;La=w=Ma=E=ta=Na=R=0;var Oa=b.TOTAL_STACK||5242880,S=b.TOTAL_MEMORY||16777216;if(S<Oa&&b.m(\"TOTAL_MEMORY should be larger than TOTAL_STACK, was \"+S+\"! (TOTAL_STACK=\"+Oa+\")\"),A=b.buffer?b.buffer:new ArrayBuffer(S),b.HEAP8=B=new Int8Array(A),b.HEAP16=O=new Int16Array(A),b.HEAP32=p=new Int32Array(A),b.HEAPU8=r=new Uint8Array(A),b.HEAPU16=oa=new Uint16Array(A),b.HEAPU32=I=new Uint32Array(A),b.HEAPF32=X=new Float32Array(A),b.HEAPF64=Y=new Float64Array(A),p[0]=1668509029,O[1]=25459,115!==r[2]||99!==r[3])throw\"Runtime error: expected the system to be little-endian!\";b.HEAP=void 0,b.buffer=A,b.HEAP8=B,b.HEAP16=O,b.HEAP32=p,b.HEAPU8=r,b.HEAPU16=oa,b.HEAPU32=I,b.HEAPF32=X,b.HEAPF64=Y;var Va=[],Ha=[],Kb=[],yb=[],ub=[],sa=!1;Math.imul&&-5===Math.imul(4294967295,5)||(Math.imul=function(e,i){var r=65535&e,f=65535&i;return r*f+((e>>>16)*f+r*(i>>>16)<<16)|0}),Math.pa=Math.imul,Math.clz32||(Math.clz32=function(e){e>>>=0;for(var i=0;32>i;i++)if(e&1<<31-i)return i;return 32}),Math.da=Math.clz32,Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Math.trunc=Math.trunc;var Bb=Math.abs,Eb=Math.ceil,Db=Math.floor,Cb=Math.min,wb=0;b.preloadedImages={},b.preloadedAudios={};var ua=[function(e,i){window.asmDomHelpers.domApi.removeAttribute(e,b.UTF8ToString(i))},function(e,i,r){window.asmDomHelpers.domApi.setAttribute(e,b.UTF8ToString(i),b.UTF8ToString(r))},function(e){window.asmDomHelpers.nodes[e].asmDomRaws=[]},function(e,i){window.asmDomHelpers.nodes[e][b.UTF8ToString(i)]=void 0},function(e,i,r){r=b.UTF8ToString(r),window.asmDomHelpers.nodes[i][r]=window.asmDomHelpers.functionCallback(e,r),window.asmDomHelpers.nodes[i].asmDomRaws.push(r)},function(e){return window.asmDomHelpers.domApi.createTextNode(b.UTF8ToString(e))},function(e){return window.asmDomHelpers.domApi.createComment(b.UTF8ToString(e))},function(e,i){return window.asmDomHelpers.domApi.createElementNS(b.UTF8ToString(e),b.UTF8ToString(i))},function(e){return window.asmDomHelpers.domApi.createElement(b.UTF8ToString(e))},function(e,i){window.asmDomHelpers.domApi.appendChild(e,i)},function(e,i){window.asmDomHelpers.domApi.appendChild(e,window.asmDomHelpers.domApi.createTextNode(b.UTF8ToString(i)))},function(e,i,r){window.asmDomHelpers.domApi.insertBefore(e,i,window.asmDomHelpers.domApi.nextSibling(r))},function(e,i,r){window.asmDomHelpers.domApi.insertBefore(e,i,r)},function(e,i,r){window.asmDomHelpers.domApi.insertBefore(e,i,r)},function(e){window.asmDomHelpers.domApi.removeChild(e)},function(e){window.asmDomHelpers.domApi.setTextContent(e,\"\")},function(e,i){window.asmDomHelpers.domApi.setTextContent(e,b.UTF8ToString(i))},function(e,i){var r=window.asmDomHelpers.domApi.parentNode(i);0!==r&&(window.asmDomHelpers.domApi.insertBefore(r,e,window.asmDomHelpers.domApi.nextSibling(i)),window.asmDomHelpers.domApi.removeChild(i))},function(){window.onhashchange=function(){window.todomvc.onhashchange(window.location.hash.substr(2)||\"all\")}},function(){window.asmDomHelpers.functionCallback=function(e,i){return function(r){return b.functionCallback(e,i,r)}}},function(){window.todomvc={onhashchange:b.onhashchange}}];La=h.o,w=La+16912,Ha.push({t:function(){Mb()}},{t:function(){Nb()}},{t:function(){Ob()}}),G([252,12,0,0,23,14,0,0,128,3,0,0,0,0,0,0,212,12,0,0,152,14,0,0,220,13,0,0,51,14,0,0,0,0,0,0,1,0,0,0,56,0,0,0,0,0,0,0,212,12,0,0,114,14,0,0,252,12,0,0,171,23,0,0,88,0,0,0,0,0,0,0,212,12,0,0,116,23,0,0,212,12,0,0,34,24,0,0,252,12,0,0,82,26,0,0,144,0,0,0,0,0,0,0,212,12,0,0,117,25,0,0,252,12,0,0,234,25,0,0,88,0,0,0,0,0,0,0,212,12,0,0,194,25,0,0,212,12,0,0,224,26,0,0,252,12,0,0,187,28,0,0,144,0,0,0,0,0,0,0,212,12,0,0,19,27,0,0,252,12,0,0,74,28,0,0,88,0,0,0,0,0,0,0,212,12,0,0,96,27,0,0,252,12,0,0,175,27,0,0,224,0,0,0,0,0,0,0,212,12,0,0,138,27,0,0,212,12,0,0,19,28,0,0,252,12,0,0,113,31,0,0,144,0,0,0,0,0,0,0,212,12,0,0,73,29,0,0,220,13,0,0,50,31,0,0,0,0,0,0,1,0,0,0,56,0,0,0,0,0,0,0,252,12,0,0,69,30,0,0,88,0,0,0,0,0,0,0,212,12,0,0,158,29,0,0,252,12,0,0,249,30,0,0,104,3,0,0,0,0,0,0,252,12,0,0,64,32,0,0,144,0,0,0,0,0,0,0,164,13,0,0,19,32,0,0,0,0,0,0,96,1,0,0,192,13,0,0,42,32,0,0,252,12,0,0,18,34,0,0,144,0,0,0,0,0,0,0,212,12,0,0,187,32,0,0,252,12,0,0,121,33,0,0,224,0,0,0,0,0,0,0,212,12,0,0,16,33,0,0,252,12,0,0,144,35,0,0,144,0,0,0,0,0,0,0,212,12,0,0,168,34,0,0,252,12,0,0,39,35,0,0,224,0,0,0,0,0,0,0,212,12,0,0,253,34,0,0,252,12,0,0,123,36,0,0,144,0,0,0,0,0,0,0,212,12,0,0,38,36,0,0,252,12,0,0,23,38,0,0,144,0,0,0,0,0,0,0,212,12,0,0,17,37,0,0,252,12,0,0,176,37,0,0,224,0,0,0,0,0,0,0,212,12,0,0,102,37,0,0,252,12,0,0,2,39,0,0,144,0,0,0,0,0,0,0,212,12,0,0,173,38,0,0,252,12,0,0,115,40,0,0,88,2,0,0,0,0,0,0,212,12,0,0,152,39,0,0,252,12,0,0,12,40,0,0,88,0,0,0,0,0,0,0,212,12,0,0,229,39,0,0,212,12,0,0,240,40,0,0,252,12,0,0,54,42,0,0,144,2,0,0,0,0,0,0,212,12,0,0,18,41,0,0,252,12,0,0,172,41,0,0,88,0,0,0,0,0,0,0,212,12,0,0,95,41,0,0,212,12,0,0,205,42,0,0,252,12,0,0,190,43,0,0,176,2,0,0,0,0,0,0,212,12,0,0,22,43,0,0,212,12,0,0,50,44,0,0,220,13,0,0,235,48,0,0,0,0,0,0,1,0,0,0,56,0,0,0,0,0,0,0,212,12,0,0,204,48,0,0,212,12,0,0,173,48,0,0,212,12,0,0,142,48,0,0,212,12,0,0,111,48,0,0,212,12,0,0,80,48,0,0,212,12,0,0,49,48,0,0,212,12,0,0,18,48,0,0,212,12,0,0,243,47,0,0,212,12,0,0,212,47,0,0,212,12,0,0,181,47,0,0,212,12,0,0,150,47,0,0,212,12,0,0,119,47,0,0,252,12,0,0,23,59,0,0,120,3,0,0,0,0,0,0,212,12,0,0,47,59,0,0,220,13,0,0,70,59,0,0,0,0,0,0,2,0,0,0,48,3,0,0,2,0,0,0,64,3,0,0,2,0,0,0,252,12,0,0,104,59,0,0,72,3,0,0,0,0,0,0,212,12,0,0,132,59,0,0,212,12,0,0,49,60,0,0,252,12,0,0,145,60,0,0,152,3,0,0,0,0,0,0,252,12,0,0,62,60,0,0,168,3,0,0,0,0,0,0,212,12,0,0,95,60,0,0,252,12,0,0,108,60,0,0,136,3,0,0,0,0,0,0,252,12,0,0,130,61,0,0,128,3,0,0,0,0,0,0,252,12,0,0,146,61,0,0,128,3,0,0,0,0,0,0,252,12,0,0,164,61,0,0,192,3,0,0,0,0,0,0,252,12,0,0,181,61,0,0,192,3,0,0,0,0,0,0,252,12,0,0,198,61,0,0,208,3,0,0,0,0,0,0,252,12,0,0,250,61,0,0,152,3,0,0,0,0,0,0,252,12,0,0,214,61,0,0,16,4,0,0,0,0,0,0,252,12,0,0,28,62,0,0,152,3,0,0,0,0,0,0,136,13,0,0,68,62,0,0,136,13,0,0,70,62,0,0,136,13,0,0,73,62,0,0,136,13,0,0,75,62,0,0,136,13,0,0,77,62,0,0,136,13,0,0,79,62,0,0,136,13,0,0,81,62,0,0,136,13,0,0,83,62,0,0,136,13,0,0,85,62,0,0,136,13,0,0,87,62,0,0,136,13,0,0,89,62,0,0,136,13,0,0,91,62,0,0,136,13,0,0,93,62,0,0,136,13,0,0,95,62,0,0,252,12,0,0,97,62,0,0,152,3,0,0,0,0,0,0,252,12,0,0,134,62,0,0,136,3,0,0,0,0,0,0,24,0,0,0,136,4,0,0,32,0,0,0,24,0,0,0,0,0,0,0,8,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,128,4,0,0,24,0,0,0,64,4,0,0,32,0,0,0,0,0,0,0,64,0,0,0,3,0,0,0,4,0,0,0,2,0,0,0,1,0,0,0,5,0,0,0,6,0,0,0,1,0,0,0,1,0,0,0,3,0,0,0,0,0,0,0,152,2,0,0,7,0,0,0,8,0,0,0,4,0,0,0,2,0,0,0,9,0,0,0,10,0,0,0,3,0,0,0,2,0,0,0,5,0,0,0,0,0,0,0,96,2,0,0,11,0,0,0,12,0,0,0,6,0,0,0,4,0,0,0,13,0,0,0,14,0,0,0,5,0,0,0,3,0,0,0,7,0,0,0,0,0,0,0,40,2,0,0,15,0,0,0,16,0,0,0,8,0,0,0,6,0,0,0,17,0,0,0,18,0,0,0,7,0,0,0,4,0,0,0,9,0,0,0,0,0,0,0,64,1,0,0,19,0,0,0,20,0,0,0,10,0,0,0,8,0,0,0,21,0,0,0,22,0,0,0,5,0,0,0,6,0,0,0,11,0,0,0,0,0,0,0,232,0,0,0,23,0,0,0,24,0,0,0,12,0,0,0,9,0,0,0,25,0,0,0,26,0,0,0,7,0,0,0,8,0,0,0,13,0,0,0,0,0,0,0,152,0,0,0,27,0,0,0,28,0,0,0,14,0,0,0,10,0,0,0,29,0,0,0,30,0,0,0,9,0,0,0,10,0,0,0,15,0,0,0,0,0,0,0,96,0,0,0,31,0,0,0,32,0,0,0,16,0,0,0,11,0,0,0,33,0,0,0,34,0,0,0,11,0,0,0,12,0,0,0,17,0,0,0,0,0,0,0,120,0,0,0,3,0,0,0,35,0,0,0,18,0,0,0,12,0,0,0,36,0,0,0,37,0,0,0,2,0,0,0,13,0,0,0,19,0,0,0,0,0,0,0,176,0,0,0,3,0,0,0,38,0,0,0,20,0,0,0,13,0,0,0,39,0,0,0,40,0,0,0,3,0,0,0,14,0,0,0,21,0,0,0,0,0,0,0,200,0,0,0,41,0,0,0,42,0,0,0,22,0,0,0,14,0,0,0,43,0,0,0,44,0,0,0,4,0,0,0,15,0,0,0,23,0,0,0,0,0,0,0,24,1,0,0,45,0,0,0,46,0,0,0,24,0,0,0,15,0,0,0,47,0,0,0,48,0,0,0,5,0,0,0,16,0,0,0,25,0,0,0,0,0,0,0,48,1,0,0,49,0,0,0,50,0,0,0,51,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,26,0,0,0,27,0,0,0,2,0,0,0,28,0,0,0,64,4,0,0,24,0,0,0,0,0,0,0,16,2,0,0,52,0,0,0,53,0,0,0,29,0,0,0,16,0,0,0,54,0,0,0,55,0,0,0,17,0,0,0,18,0,0,0,30,0,0,0,0,0,0,0,224,1,0,0,56,0,0,0,57,0,0,0,31,0,0,0,17,0,0,0,58,0,0,0,59,0,0,0,19,0,0,0,20,0,0,0,32,0,0,0,0,0,0,0,200,1,0,0,60,0,0,0,61,0,0,0,33,0,0,0,18,0,0,0,62,0,0,0,63,0,0,0,21,0,0,0,22,0,0,0,34,0,0,0,0,0,0,0,152,1,0,0,64,0,0,0,65,0,0,0,35,0,0,0,19,0,0,0,66,0,0,0,67,0,0,0,23,0,0,0,24,0,0,0,36,0,0,0,0,0,0,0,104,1,0,0,68,0,0,0,69,0,0,0,37,0,0,0,20,0,0,0,70,0,0,0,71,0,0,0,25,0,0,0,26,0,0,0,38,0,0,0,0,0,0,0,128,1,0,0,72,0,0,0,73,0,0,0,39,0,0,0,21,0,0,0,74,0,0,0,75,0,0,0,6,0,0,0,27,0,0,0,40,0,0,0,0,0,0,0,176,1,0,0,41,0,0,0,76,0,0,0,41,0,0,0,22,0,0,0,77,0,0,0,78,0,0,0,7,0,0,0,28,0,0,0,42,0,0,0,0,0,0,0,248,1,0,0,41,0,0,0,79,0,0,0,43,0,0,0,23,0,0,0,80,0,0,0,81,0,0,0,8,0,0,0,29,0,0,0,44,0,0,0,0,0,0,0,64,2,0,0,3,0,0,0,82,0,0,0,45,0,0,0,24,0,0,0,83,0,0,0,84,0,0,0,9,0,0,0,30,0,0,0,46,0,0,0,0,0,0,0,120,2,0,0,85,0,0,0,86,0,0,0,47,0,0,0,25,0,0,0,87,0,0,0,88,0,0,0,10,0,0,0,31,0,0,0,48,0,0,0,24,0,0,0,32,0,0,0,40,9,0,0,20,0,0,0,67,46,85,84,70,45,56,0,0,0,0,0,0,0,0,0,0,0,0,0,222,18,4,149,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,12,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,192,3,0,0,192,4,0,0,192,5,0,0,192,6,0,0,192,7,0,0,192,8,0,0,192,9,0,0,192,10,0,0,192,11,0,0,192,12,0,0,192,13,0,0,192,14,0,0,192,15,0,0,192,16,0,0,192,17,0,0,192,18,0,0,192,19,0,0,192,20,0,0,192,21,0,0,192,22,0,0,192,23,0,0,192,24,0,0,192,25,0,0,192,26,0,0,192,27,0,0,192,28,0,0,192,29,0,0,192,30,0,0,192,31,0,0,192,0,0,0,179,1,0,0,195,2,0,0,195,3,0,0,195,4,0,0,195,5,0,0,195,6,0,0,195,7,0,0,195,8,0,0,195,9,0,0,195,10,0,0,195,11,0,0,195,12,0,0,195,13,0,0,211,14,0,0,195,15,0,0,195,0,0,12,187,1,0,12,195,2,0,12,195,3,0,12,195,4,0,12,211,5,0,0,0,0,0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,8,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,7,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,211,0,0,0,1,0,0,0,11,0,0,0,13,0,0,0,17,0,0,0,19,0,0,0,23,0,0,0,29,0,0,0,31,0,0,0,37,0,0,0,41,0,0,0,43,0,0,0,47,0,0,0,53,0,0,0,59,0,0,0,61,0,0,0,67,0,0,0,71,0,0,0,73,0,0,0,79,0,0,0,83,0,0,0,89,0,0,0,97,0,0,0,101,0,0,0,103,0,0,0,107,0,0,0,109,0,0,0,113,0,0,0,121,0,0,0,127,0,0,0,131,0,0,0,137,0,0,0,139,0,0,0,143,0,0,0,149,0,0,0,151,0,0,0,157,0,0,0,163,0,0,0,167,0,0,0,169,0,0,0,173,0,0,0,179,0,0,0,181,0,0,0,187,0,0,0,191,0,0,0,193,0,0,0,197,0,0,0,199,0,0,0,209,0,0,0,0,0,0,0,72,3,0,0,49,0,0,0,89,0,0,0,51,0,0,0,3,0,0,0,4,0,0,0,3,0,0,0,50,0,0,0,51,0,0,0,4,0,0,0,52,0,0,0,1,0,0,0,0,0,0,0,136,3,0,0,90,0,0,0,91,0,0,0,92,0,0,0,93,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,176,3,0,0,90,0,0,0,94,0,0,0,92,0,0,0,93,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,192,3,0,0,95,0,0,0,96,0,0,0,53,0,0,0,0,0,0,0,208,3,0,0,97,0,0,0,98,0,0,0,54,0,0,0,0,0,0,0,224,3,0,0,95,0,0,0,99,0,0,0,53,0,0,0,0,0,0,0,240,3,0,0,95,0,0,0,100,0,0,0,53,0,0,0,0,0,0,0,0,4,0,0,97,0,0,0,101,0,0,0,54,0,0,0,0,0,0,0,48,4,0,0,90,0,0,0,102,0,0,0,92,0,0,0,93,0,0,0,5,0,0,0,0,0,0,0,32,4,0,0,90,0,0,0,103,0,0,0,92,0,0,0,93,0,0,0,6,0,0,0,0,0,0,0,176,4,0,0,90,0,0,0,104,0,0,0,92,0,0,0,93,0,0,0,7,0,0,0,0,0,0,0,192,4,0,0,90,0,0,0,105,0,0,0,92,0,0,0,93,0,0,0,4,0,0,0,3,0,0,0,3,0,0,0,3,0,0,0,168,65,0,0,102,117,110,99,116,105,111,110,67,97,108,108,98,97,99,107,0,105,105,105,105,105,0,78,83,116,51,95,95,50,49,55,98,97,100,95,102,117,110,99,116,105,111,110,95,99,97,108,108,69,0,78,83,116,51,95,95,50,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,0,78,83,116,51,95,95,50,50,49,95,95,98,97,115,105,99,95,115,116,114,105,110,103,95,99,111,109,109,111,110,73,76,98,49,69,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,0,104,116,116,112,58,47,47,119,119,119,46,119,51,46,111,114,103,47,50,48,48,48,47,115,118,103,0,102,111,114,101,105,103,110,79,98,106,101,99,116,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,114,101,109,111,118,101,65,116,116,114,105,98,117,116,101,39,93,40,32,36,48,44,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,49,41,32,41,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,115,101,116,65,116,116,114,105,98,117,116,101,39,93,40,32,36,48,44,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,49,41,44,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,50,41,32,41,59,32,125,0,119,105,110,100,111,119,0,97,115,109,68,111,109,72,101,108,112,101,114,115,0,110,111,100,101,115,0,117,110,111,114,100,101,114,101,100,95,109,97,112,58,58,97,116,58,32,107,101,121,32,110,111,116,32,102,111,117,110,100,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,110,111,100,101,115,39,93,91,36,48,93,91,39,97,115,109,68,111,109,82,97,119,115,39,93,32,61,32,91,93,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,110,111,100,101,115,39,93,91,36,48,93,91,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,49,41,93,32,61,32,117,110,100,101,102,105,110,101,100,59,32,125,0,123,32,118,97,114,32,107,101,121,32,61,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,50,41,59,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,110,111,100,101,115,39,93,91,36,49,93,91,107,101,121,93,32,61,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,102,117,110,99,116,105,111,110,67,97,108,108,98,97,99,107,39,93,40,36,48,44,32,107,101,121,41,59,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,110,111,100,101,115,39,93,91,36,49,93,91,39,97,115,109,68,111,109,82,97,119,115,39,93,46,112,117,115,104,40,107,101,121,41,59,32,125,0,123,32,114,101,116,117,114,110,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,99,114,101,97,116,101,84,101,120,116,78,111,100,101,39,93,40,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,48,41,32,41,59,32,125,0,123,32,114,101,116,117,114,110,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,99,114,101,97,116,101,67,111,109,109,101,110,116,39,93,40,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,48,41,32,41,59,32,125,0,123,32,114,101,116,117,114,110,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,99,114,101,97,116,101,69,108,101,109,101,110,116,78,83,39,93,40,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,48,41,44,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,49,41,32,41,59,32,125,0,123,32,114,101,116,117,114,110,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,99,114,101,97,116,101,69,108,101,109,101,110,116,39,93,40,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,48,41,32,41,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,97,112,112,101,110,100,67,104,105,108,100,39,93,40,36,48,44,32,36,49,41,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,97,112,112,101,110,100,67,104,105,108,100,39,93,40,32,36,48,44,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,99,114,101,97,116,101,84,101,120,116,78,111,100,101,39,93,40,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,49,41,32,41,32,41,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,105,110,115,101,114,116,66,101,102,111,114,101,39,93,40,36,48,44,32,36,49,44,32,36,50,41,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,114,101,109,111,118,101,67,104,105,108,100,39,93,40,36,48,41,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,105,110,115,101,114,116,66,101,102,111,114,101,39,93,40,32,36,48,44,32,36,49,44,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,110,101,120,116,83,105,98,108,105,110,103,39,93,40,36,50,41,32,41,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,105,110,115,101,114,116,66,101,102,111,114,101,39,93,40,36,48,44,32,36,49,44,32,36,50,41,59,32,125,0,109,97,112,58,58,97,116,58,32,32,107,101,121,32,110,111,116,32,102,111,117,110,100,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,115,101,116,84,101,120,116,67,111,110,116,101,110,116,39,93,40,36,48,44,32,34,34,41,59,32,125,0,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,115,101,116,84,101,120,116,67,111,110,116,101,110,116,39,93,40,32,36,48,44,32,77,111,100,117,108,101,91,39,85,84,70,56,84,111,83,116,114,105,110,103,39,93,40,36,49,41,32,41,59,32,125,0,116,97,103,78,97,109,101,0,99,108,97,115,115,78,97,109,101,0,100,111,109,65,112,105,0,97,100,100,78,111,100,101,0,123,32,118,97,114,32,112,97,114,101,110,116,32,61,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,112,97,114,101,110,116,78,111,100,101,39,93,40,36,49,41,59,32,105,102,32,40,112,97,114,101,110,116,32,33,61,61,32,48,41,32,123,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,105,110,115,101,114,116,66,101,102,111,114,101,39,93,40,32,112,97,114,101,110,116,44,32,36,48,44,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,110,101,120,116,83,105,98,108,105,110,103,39,93,40,36,49,41,32,41,59,32,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,100,111,109,65,112,105,39,93,91,39,114,101,109,111,118,101,67,104,105,108,100,39,93,40,36,49,41,59,32,125,32,125,0,119,105,110,100,111,119,91,39,97,115,109,68,111,109,72,101,108,112,101,114,115,39,93,91,39,102,117,110,99,116,105,111,110,67,97,108,108,98,97,99,107,39,93,32,61,32,102,117,110,99,116,105,111,110,40,118,110,111,100,101,44,32,99,97,108,108,98,97,99,107,41,32,123,32,114,101,116,117,114,110,32,102,117,110,99,116,105,111,110,40,101,118,101,110,116,41,32,123,32,114,101,116,117,114,110,32,77,111,100,117,108,101,91,39,102,117,110,99,116,105,111,110,67,97,108,108,98,97,99,107,39,93,40,118,110,111,100,101,44,32,99,97,108,108,98,97,99,107,44,32,101,118,101,110,116,41,59,32,125,59,32,125,59,0,111,110,104,97,115,104,99,104,97,110,103,101,0,118,105,105,0,99,111,109,112,108,101,116,101,100,0,97,99,116,105,118,101,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,54,70,105,108,116,101,114,69,78,83,48,95,49,48,84,111,100,111,70,105,108,116,101,114,69,69,52,36,95,49,55,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,54,70,105,108,116,101,114,69,78,83,51,95,49,48,84,111,100,111,70,105,108,116,101,114,69,69,52,36,95,49,55,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,54,95,69,69,70,78,83,51,95,53,84,111,100,111,115,69,83,57,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,98,97,115,101,73,70,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,53,84,111,100,111,115,69,83,52,95,69,69,69,0,115,101,99,116,105,111,110,0,99,108,97,115,115,0,116,111,100,111,97,112,112,0,111,110,99,108,105,99,107,0,104,101,97,100,101,114,0,116,111,100,111,115,0,105,110,112,117,116,0,112,108,97,99,101,104,111,108,100,101,114,0,87,104,97,116,32,110,101,101,100,115,32,116,111,32,98,101,32,100,111,110,101,63,0,118,97,108,117,101,0,111,110,107,101,121,100,111,119,110,0,98,108,111,99,107,0,110,111,110,101,0,100,105,115,112,108,97,121,58,32,0,115,116,121,108,101,0,116,111,103,103,108,101,45,97,108,108,0,99,104,101,99,107,101,100,0,116,111,100,111,45,108,105,115,116,0,102,111,111,116,101,114,0,116,111,100,111,45,99,111,117,110,116,0,115,116,114,111,110,103,0,32,105,116,101,109,0,32,108,101,102,116,0,102,105,108,116,101,114,115,0,115,101,108,101,99,116,101,100,0,65,108,108,0,65,99,116,105,118,101,0,35,47,99,111,109,112,108,101,116,101,100,0,67,111,109,112,108,101,116,101,100,0,98,117,116,116,111,110,0,99,108,101,97,114,45,99,111,109,112,108,101,116,101,100,0,67,108,101,97,114,32,99,111,109,112,108,101,116,101,100,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,48,95,53,84,111,100,111,115,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,69,52,36,95,49,50,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,55,65,114,99,104,105,118,101,69,118,69,52,36,95,49,53,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,55,65,114,99,104,105,118,101,69,118,69,52,36,95,49,53,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,70,78,83,51,95,53,84,111,100,111,115,69,83,56,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,51,95,53,84,111,100,111,115,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,69,52,36,95,49,50,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,65,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,98,97,115,101,73,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,48,95,53,84,111,100,111,115,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,69,52,36,95,49,49,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,57,84,111,103,103,108,101,65,108,108,69,98,69,52,36,95,49,54,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,54,84,111,103,103,108,101,69,98,69,51,36,95,54,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,54,84,111,103,103,108,101,69,98,69,51,36,95,54,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,70,78,83,51,95,52,84,97,115,107,69,83,56,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,98,97,115,101,73,70,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,84,97,115,107,69,83,52,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,57,84,111,103,103,108,101,65,108,108,69,98,69,52,36,95,49,54,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,70,78,83,51,95,53,84,111,100,111,115,69,83,56,95,69,69,69,0,116,97,114,103,101,116,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,51,95,53,84,111,100,111,115,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,69,52,36,95,49,49,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,65,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,48,95,53,84,111,100,111,115,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,69,52,36,95,49,48,0,107,101,121,67,111,100,101,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,51,65,100,100,69,78,83,116,51,95,95,50,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,99,78,83,50,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,78,83,50,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,69,52,36,95,49,51,0,97,108,108,111,99,97,116,111,114,60,84,62,58,58,97,108,108,111,99,97,116,101,40,115,105,122,101,95,116,32,110,41,32,39,110,39,32,101,120,99,101,101,100,115,32,109,97,120,105,109,117,109,32,115,117,112,112,111,114,116,101,100,32,115,105,122,101,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,51,65,100,100,69,78,83,95,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,69,52,36,95,49,51,78,83,56,95,73,83,66,95,69,69,70,78,83,51,95,53,84,111,100,111,115,69,83,68,95,69,69,69,0,119,115,116,114,105,110,103,95,99,111,110,118,101,114,116,58,32,116,111,95,98,121,116,101,115,32,101,114,114,111,114,0,78,83,116,51,95,95,50,49,50,99,111,100,101,99,118,116,95,117,116,102,56,73,119,76,109,49,49,49,52,49,49,49,69,76,78,83,95,49,50,99,111,100,101,99,118,116,95,109,111,100,101,69,48,69,69,69,0,78,83,116,51,95,95,50,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,119,69,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,51,95,53,84,111,100,111,115,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,69,52,36,95,49,48,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,65,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,99,111,110,115,111,108,101,0,99,108,105,99,107,101,100,0,108,111,103,0,80,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,0,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,80,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,83,52,95,69,69,0,101,100,105,116,105,110,103,0,107,101,121,0,100,105,118,0,116,111,103,103,108,101,0,111,110,100,98,108,99,108,105,99,107,0,100,101,115,116,114,111,121,0,111,110,98,108,117,114,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,48,95,52,84,97,115,107,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,78,83,51,95,73,70,118,105,69,69,69,69,51,36,95,53,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,49,48,67,111,109,109,105,116,69,100,105,116,69,78,83,116,51,95,95,50,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,99,78,83,50,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,78,83,50,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,69,51,36,95,56,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,49,48,67,111,109,109,105,116,69,100,105,116,69,78,83,95,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,69,51,36,95,56,78,83,56,95,73,83,66,95,69,69,70,78,83,51,95,52,84,97,115,107,69,83,68,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,51,95,52,84,97,115,107,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,78,83,53,95,73,70,118,105,69,69,69,69,51,36,95,53,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,67,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,48,95,52,84,97,115,107,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,78,83,51,95,73,70,118,105,69,69,69,69,51,36,95,52,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,49,48,67,97,110,99,101,108,69,100,105,116,69,118,69,51,36,95,57,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,49,48,67,97,110,99,101,108,69,100,105,116,69,118,69,51,36,95,57,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,70,78,83,51,95,52,84,97,115,107,69,83,56,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,51,95,52,84,97,115,107,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,78,83,53,95,73,70,118,105,69,69,69,69,51,36,95,52,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,67,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,48,95,52,84,97,115,107,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,78,83,51,95,73,70,118,105,69,69,69,69,51,36,95,51,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,51,95,52,84,97,115,107,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,78,83,53,95,73,70,118,105,69,69,69,69,51,36,95,51,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,67,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,48,95,52,84,97,115,107,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,78,83,51,95,73,70,118,105,69,69,69,69,51,36,95,50,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,57,83,116,97,114,116,69,100,105,116,69,118,69,51,36,95,55,0,119,115,116,114,105,110,103,95,99,111,110,118,101,114,116,58,32,102,114,111,109,95,98,121,116,101,115,32,101,114,114,111,114,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,54,65,99,116,105,111,110,57,83,116,97,114,116,69,100,105,116,69,118,69,51,36,95,55,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,70,78,83,51,95,52,84,97,115,107,69,83,56,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,51,95,52,84,97,115,107,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,78,83,53,95,73,70,118,105,69,69,69,69,51,36,95,50,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,67,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,48,95,52,84,97,115,107,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,78,83,51,95,73,70,118,105,69,69,69,69,51,36,95,49,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,118,105,101,119,69,78,83,51,95,52,84,97,115,107,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,78,83,53,95,73,70,118,105,69,69,69,69,51,36,95,49,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,67,95,69,69,70,98,78,49,48,101,109,115,99,114,105,112,116,101,110,51,118,97,108,69,69,69,69,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,48,95,53,84,111,100,111,115,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,69,52,36,95,50,48,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,54,82,101,109,111,118,101,69,105,69,52,36],\"i8\",4,h.o),G([95,49,52,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,54,82,101,109,111,118,101,69,105,69,52,36,95,49,52,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,70,78,83,51,95,53,84,111,100,111,115,69,83,56,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,51,95,53,84,111,100,111,115,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,69,52,36,95,50,48,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,65,95,69,69,70,118,105,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,98,97,115,101,73,70,118,105,69,69,69,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,48,95,53,84,111,100,111,115,69,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,118,78,83,51,95,73,70,83,49,95,83,49,95,69,69,69,69,69,69,69,52,36,95,49,57,0,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,54,77,111,100,105,102,121,69,105,78,83,116,51,95,95,50,56,102,117,110,99,116,105,111,110,73,70,78,83,95,52,116,97,115,107,52,84,97,115,107,69,83,53,95,69,69,69,69,52,36,95,49,56,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,54,65,99,116,105,111,110,54,77,111,100,105,102,121,69,105,78,83,95,56,102,117,110,99,116,105,111,110,73,70,78,83,50,95,52,116,97,115,107,52,84,97,115,107,69,83,55,95,69,69,69,69,52,36,95,49,56,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,65,95,69,69,70,78,83,51,95,53,84,111,100,111,115,69,83,68,95,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,52,118,105,101,119,69,78,83,51,95,53,84,111,100,111,115,69,78,83,95,56,102,117,110,99,116,105,111,110,73,70,118,78,83,53,95,73,70,83,52,95,83,52,95,69,69,69,69,69,69,69,52,36,95,49,57,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,65,95,69,69,70,118,78,83,53,95,73,70,78,83,50,95,52,116,97,115,107,52,84,97,115,107,69,83,69,95,69,69,69,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,98,97,115,101,73,70,118,78,83,95,56,102,117,110,99,116,105,111,110,73,70,78,55,116,111,100,111,109,118,99,52,116,97,115,107,52,84,97,115,107,69,83,53,95,69,69,69,69,69,69,0,90,49,49,98,101,102,111,114,101,80,97,116,99,104,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,53,84,111,100,111,115,69,69,51,36,95,48,0,119,105,110,100,111,119,91,39,111,110,104,97,115,104,99,104,97,110,103,101,39,93,32,61,32,102,117,110,99,116,105,111,110,40,41,32,123,32,119,105,110,100,111,119,91,39,116,111,100,111,109,118,99,39,93,91,39,111,110,104,97,115,104,99,104,97,110,103,101,39,93,40,119,105,110,100,111,119,91,39,108,111,99,97,116,105,111,110,39,93,91,39,104,97,115,104,39,93,91,39,115,117,98,115,116,114,39,93,40,50,41,32,124,124,32,39,97,108,108,39,41,59,32,125,59,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,102,117,110,99,73,90,49,49,98,101,102,111,114,101,80,97,116,99,104,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,53,84,111,100,111,115,69,69,51,36,95,48,78,83,95,57,97,108,108,111,99,97,116,111,114,73,83,53,95,69,69,70,118,78,83,95,56,102,117,110,99,116,105,111,110,73,70,83,52,95,83,52,95,69,69,69,69,69,69,0,78,83,116,51,95,95,50,49,48,95,95,102,117,110,99,116,105,111,110,54,95,95,98,97,115,101,73,70,118,78,83,95,56,102,117,110,99,116,105,111,110,73,70,78,55,116,111,100,111,109,118,99,53,116,111,100,111,115,53,84,111,100,111,115,69,83,53,95,69,69,69,69,69,69,0,119,105,110,100,111,119,91,39,116,111,100,111,109,118,99,39,93,32,61,32,123,32,39,111,110,104,97,115,104,99,104,97,110,103,101,39,58,32,77,111,100,117,108,101,91,39,111,110,104,97,115,104,99,104,97,110,103,101,39,93,44,32,125,59,0,100,111,99,117,109,101,110,116,0,113,117,101,114,121,83,101,108,101,99,116,111,114,0,115,116,100,58,58,98,97,115,105,99,95,115,116,114,105,110,103,60,117,110,115,105,103,110,101,100,32,99,104,97,114,62,0,115,116,100,58,58,119,115,116,114,105,110,103,0,101,109,115,99,114,105,112,116,101,110,58,58,118,97,108,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,115,105,103,110,101,100,32,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,99,104,97,114,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,115,104,111,114,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,115,104,111,114,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,105,110,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,108,111,110,103,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,110,115,105,103,110,101,100,32,108,111,110,103,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,56,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,56,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,49,54,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,49,54,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,105,110,116,51,50,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,117,105,110,116,51,50,95,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,102,108,111,97,116,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,100,111,117,98,108,101,62,0,101,109,115,99,114,105,112,116,101,110,58,58,109,101,109,111,114,121,95,118,105,101,119,60,108,111,110,103,32,100,111,117,98,108,101,62,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,101,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,100,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,102,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,109,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,108,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,106,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,105,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,116,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,115,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,104,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,97,69,69,0,78,49,48,101,109,115,99,114,105,112,116,101,110,49,49,109,101,109,111,114,121,95,118,105,101,119,73,99,69,69,0,78,83,116,51,95,95,50,49,50,98,97,115,105,99,95,115,116,114,105,110,103,73,104,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,104,69,69,78,83,95,57,97,108,108,111,99,97,116,111,114,73,104,69,69,69,69,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,45,43,32,32,32,48,88,48,120,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,78,65,78,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,110,97,110,0,76,67,95,67,84,89,80,69,0,0,0,0,76,67,95,78,85,77,69,82,73,67,0,0,76,67,95,84,73,77,69,0,0,0,0,0,76,67,95,67,79,76,76,65,84,69,0,0,76,67,95,77,79,78,69,84,65,82,89,0,76,67,95,77,69,83,83,65,71,69,83,0,76,67,95,65,76,76,0,76,65,78,71,0,67,46,85,84,70,45,56,0,80,79,83,73,88,0,77,85,83,76,95,76,79,67,80,65,84,72,0,108,97,98,101,108,0,40,110,117,108,108,41,0,78,83,116,51,95,95,50,54,108,111,99,97,108,101,53,102,97,99,101,116,69,0,67,0,78,83,116,51,95,95,50,49,50,99,111,100,101,99,118,116,95,98,97,115,101,69,0,78,83,116,51,95,95,50,55,99,111,100,101,99,118,116,73,119,99,49,49,95,95,109,98,115,116,97,116,101,95,116,69,69,0,78,83,116,51,95,95,50,49,52,95,95,99,111,100,101,99,118,116,95,117,116,102,56,73,119,69,69,0,78,83,116,51,95,95,50,49,52,95,95,115,104,97,114,101,100,95,99,111,117,110,116,69,0,37,100,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,83,116,57,101,120,99,101,112,116,105,111,110,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,115,116,100,58,58,101,120,99,101,112,116,105,111,110,0,83,116,49,49,108,111,103,105,99,95,101,114,114,111,114,0,83,116,49,51,114,117,110,116,105,109,101,95,101,114,114,111,114,0,83,116,49,50,108,101,110,103,116,104,95,101,114,114,111,114,0,83,116,49,50,111,117,116,95,111,102,95,114,97,110,103,101,0,83,116,49,49,114,97,110,103,101,95,101,114,114,111,114,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,51,95,95,102,117,110,100,97,109,101,110,116,97,108,95,116,121,112,101,95,105,110,102,111,69,0,118,0,68,110,0,98,0,99,0,104,0,97,0,115,0,116,0,105,0,106,0,108,0,109,0,102,0,100,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,102,117,110,99,116,105,111,110,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,49,95,95,118,109,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,33,0,46,0,115,116,100,58,58,115,116,114,105,110,103,0,102,97,108,115,101,0,99,104,97,114,0,115,105,103,110,101,100,32,99,104,97,114,0,117,110,115,105,103,110,101,100,32,99,104,97,114,0,115,104,111,114,116,0,117,110,115,105,103,110,101,100,32,115,104,111,114,116,0,105,100,0,118,111,105,100,0,98,111,111,108,0,105,110,116,0,117,110,115,105,103,110,101,100,32,105,110,116,0,108,111,110,103,0,117,110,115,105,103,110,101,100,32,108,111,110,103,0,102,108,111,97,116,0,100,111,117,98,108,101,0],\"i8\",4,h.o+10240);var Pb=w;w+=16,b._i64Subtract=Qb,b._i64Add=Rb;var Xa=void 0,U={},P={},ja={},Ya=void 0,Za=void 0,ka=[],t={l:0,j:[],b:{},L:function(e){if(!e||t.b[e])return e;for(var i in t.b)if(t.b[i].v===e)return i;return e},H:function(e){e&&t.b[e].d++},ea:function(e){if(e){var i=t.b[e];x(0<i.d),i.d--,0!==i.d||i.C||(i.A&&b.dynCall_vi(i.A,e),delete t.b[e],___cxa_free_exception(e))}},ba:function(e){e&&(t.b[e].d=0)}};b._memset=Sb;var Jb={},Da=[],v=[{},{value:void 0},{value:null},{value:!0},{value:!1}];b._bitshift64Shl=Tb;var va={},Pa=1,m={f:0,get:function(){return m.f+=4,p[m.f-4>>2]},ma:function(){return wa(m.get())},ha:function(){var e=m.get(),i=m.get();return x(0<=e?0===i:-1===i),e},oa:function(){x(0===m.get())}};b._bitshift64Lshr=Ub;var ib=w;w+=16;var J={},qb=void 0;b._memcpy=Vb;var Wb=G([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],\"i8\",2);b._llvm_cttz_i32=Xb,b.___udivmoddi4=Yb,b.___udivdi3=Zb,b._sbrk=$b,b._memmove=ac,b.___uremdi3=bc,b._llvm_bswap_i32=cc,Wa(),Ya=b.BindingError=ia(Error,\"BindingError\"),Za=b.InternalError=ia(Error,\"InternalError\"),eb(),qa(J),qb=b.UnboundTypeError=ia(Error,\"UnboundTypeError\"),yb.push(function(){var e=b._fflush;if(e&&e(0),e=M.i){var i=M.a;i[1].length&&e(1,10),i[2].length&&e(2,10)}}),R=G(1,\"i32\",2),Ma=E=h.w(w),ta=Ma+Oa,Na=h.w(ta),p[R>>2]=Na,b.J={Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:NaN,Infinity:1/0},b.K={abort:F,assert:x,enlargeMemory:function(){xa()},getTotalMemory:function(){return S},abortOnCannotGrowMemory:xa,invoke_iiii:function(e,i,r,f){try{return b.dynCall_iiii(e,i,r,f)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_viiiii:function(e,i,r,f,n,t){try{b.dynCall_viiiii(e,i,r,f,n,t)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_vi:function(e,i){try{b.dynCall_vi(e,i)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_vii:function(e,i,r){try{b.dynCall_vii(e,i,r)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_ii:function(e,i){try{return b.dynCall_ii(e,i)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_viii:function(e,i,r,f){try{b.dynCall_viii(e,i,r,f)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_v:function(e){try{b.dynCall_v(e)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_iiiiiiiii:function(e,i,r,f,n,t,a,l,o){try{return b.dynCall_iiiiiiiii(e,i,r,f,n,t,a,l,o)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_iiiii:function(e,i,r,f,n){try{return b.dynCall_iiiii(e,i,r,f,n)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_viiiiii:function(e,i,r,f,n,t,a){try{b.dynCall_viiiiii(e,i,r,f,n,t,a)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_iii:function(e,i,r){try{return b.dynCall_iii(e,i,r)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_iiiiii:function(e,i,r,f,n,t){try{return b.dynCall_iiiiii(e,i,r,f,n,t)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},invoke_viiii:function(e,i,r,f,n){try{b.dynCall_viiii(e,i,r,f,n)}catch(e){if(\"number\"!=typeof e&&\"longjmp\"!==e)throw e;b.setThrew(1,0)}},_pthread_getspecific:function(e){return va[e]||0},___lock:function(){},floatReadValueFromPointer:hb,simpleReadValueFromPointer:pa,__emval_call_void_method:function(e,i,r,f){e=ka[e],i=D(i),r=aa(r),e(i,r,null,f)},___resumeException:function(e){throw t.l||(t.l=e),e},_pthread_key_create:function(e){return 0==e?22:(p[e>>2]=Pa,va[Pa]=0,Pa++,0)},__embind_register_memory_view:function(e,i,r){function f(e){e>>=2;var i=I;return new n(i.buffer,i[e+1],i[e])}var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][i];r=z(r),H(e,{name:r,fromWireType:f,argPackAdvance:8,readValueFromPointer:f},{R:!0})},throwInternalError:Aa,get_first_emval:db,_abort:function(){b.abort()},__emval_addMethodCaller:ab,requireHandle:D,___gxx_personality_v0:function(){},___unlock:function(){},extendError:ia,init_emval:eb,___cxa_allocate_exception:function(e){return L(e)},__ZSt18uncaught_exceptionv:V,___buildEnvironment:qa,_emscripten_asm_const_ii:function(e,i){return ua[e](i)},getShiftFromSize:na,__emval_get_property:function(e,i){return e=D(e),i=D(i),K(e[i])},___syscall91:function(e,i){m.f=i;try{var r=m.get(),f=m.get(),n=m.T[r];if(!n)return 0;if(f===n.qa){var t=FS.na(n.fd);m.fa(r,t,f,n.flags),FS.ua(t),m.T[r]=null,n.Z&&y(n.ta)}return 0}catch(e){return\"undefined\"!=typeof FS&&e instanceof FS.n||F(e),-e.s}},__emval_as:function(e,i,r){e=D(e),i=la(i,\"emval::as\");var f=[],n=K(f);return p[r>>2]=n,i.toWireType(f,e)},___cxa_begin_catch:function(e){var i=t.b[e];return i&&!i.j&&(i.j=!0,V.a--),i&&(i.C=!1),t.j.push(e),t.H(t.L(e)),e},___setErrNo:rb,__emval_register:K,__embind_register_void:function(e,i){i=z(i),H(e,{S:!0,name:i,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},_emscripten_memcpy_big:function(e,i,f){return r.set(r.subarray(i,i+f),e),e},__embind_register_bool:function(e,i,r,f,n){var t=na(r);i=z(i),H(e,{name:i,fromWireType:function(e){return!!e},toWireType:function(e,i){return i?f:n},argPackAdvance:8,readValueFromPointer:function(e){var f;if(1===r)f=B;else if(2===r)f=O;else{if(4!==r)throw new TypeError(\"Unknown boolean type size: \"+i);f=p}return this.fromWireType(f[e>>t])},e:null})},_emscripten_asm_const_v:function(e){return ua[e]()},___cxa_find_matching_catch:Z,__emval_incref:function(e){4<e&&(v[e].d+=1)},_embind_repr:ma,__embind_register_std_wstring:function(e,i,r){r=z(r);var f,n;2===i?(f=function(){return oa},n=1):4===i&&(f=function(){return I},n=2),H(e,{name:r,fromWireType:function(e){for(var i=f(),r=I[e>>2],t=Array(r),a=e+4>>n,l=0;l<r;++l)t[l]=String.fromCharCode(i[a+l]);return y(e),t.join(\"\")},toWireType:function(e,r){var t=f(),a=r.length,l=L(4+a*i);I[l>>2]=a;for(var o=l+4>>n,u=0;u<a;++u)t[o+u]=r.charCodeAt(u);return null!==e&&e.push(y,l),l},argPackAdvance:8,readValueFromPointer:pa,e:function(e){y(e)}})},__emval_get_global:function(e){return 0===e?K(Ga()):(e=aa(e),K(Ga()[e]))},createNamedFunction:za,embind_init_charCodes:Wa,__emval_take_value:function(e,i){return e=la(e,\"_emval_take_value\"),K(e.readValueFromPointer(i))},readLatin1String:z,getStringOrSymbol:aa,throwUnboundTypeError:pb,craftInvokerFunction:jb,__embind_register_integer:function(e,i,r,f,n){function t(e){return e}i=z(i),-1===n&&(n=4294967295);var a=na(r);if(0===f)var l=32-8*r,t=function(e){return e<<l>>>l};var o=-1!=i.indexOf(\"unsigned\");H(e,{name:i,fromWireType:t,toWireType:function(e,r){if(\"number\"!=typeof r&&\"boolean\"!=typeof r)throw new TypeError('Cannot convert \"'+ma(r)+'\" to '+this.name);if(r<f||r>n)throw new TypeError('Passing a number \"'+ma(r)+'\" from JS side to C/C++ side to an argument of type \"'+i+'\", which is outside the valid range ['+f+\", \"+n+\"]!\");return o?r>>>0:0|r},argPackAdvance:8,readValueFromPointer:gb(i,a,0!==f),e:null})},_pthread_once:ba,__emval_decref:Ea,_getenv:ca,exposePublicSymbol:lb,runDestructors:Fa,requireRegisteredType:la,makeLegalFunctionName:ha,___map_file:function(){return rb(1),-1},integerReadValueFromPointer:gb,__emval_set_property:function(e,i,r){e=D(e),i=D(i),r=D(r),e[i]=r},heap32VectorToArray:mb,__emval_lookupTypes:bb,whenDependentTypesAreResolved:$a,_emscripten_asm_const_iii:function(e,i,r){return ua[e](i,r)},__emval_call_method:function(e,i,r,f,n){return e=ka[e],i=D(i),r=aa(r),e(i,r,fb(f),n)},__emval_run_destructors:function(e){Fa(v[e].value),Ea(e)},_pthread_setspecific:function(e,i){return e in va?(va[e]=i,0):22},___syscall146:M,_emscripten_asm_const_iiii:function(e,i,r,f){return ua[e](i,r,f)},registerType:H,__emval_allocateDestructors:fb,__emval_strictly_equals:function(e,i){return e=D(e),i=D(i),e===i},__embind_register_function:function(e,i,r,f,n,t){var a=mb(i,r);e=z(e),n=ob(f,n),lb(e,function(){pb(\"Cannot call \"+e+\" due to unbound types\",a)},i-1),$a([],a,function(r){return r=[r[0],null].concat(r.slice(1)),nb(e,jb(e,r,null,n,t),i-1),[]})},__emval_new_cstring:function(e){return K(aa(e))},___syscall6:function(e,i){m.f=i;try{var r=m.O();return FS.close(r),0}catch(e){return\"undefined\"!=typeof FS&&e instanceof FS.n||F(e),-e.s}},throwBindingError:u,ensureOverloadTable:kb,count_emval_handles:cb,___cxa_throw:function(e,i,r){throw t.b[e]={xa:e,v:e,type:i,A:r,d:0,j:!1,C:!1},t.l=e,\"uncaught_exception\"in V?V.a++:V.a=1,e},requireFunction:ob,__embind_register_float:function(e,i,r){r=na(r),i=z(i),H(e,{name:i,fromWireType:function(e){return e},toWireType:function(e,i){if(\"number\"!=typeof i&&\"boolean\"!=typeof i)throw new TypeError('Cannot convert \"'+ma(i)+'\" to '+this.name);return i},argPackAdvance:8,readValueFromPointer:hb(i,r),e:null})},new_:Ca,___syscall140:function(e,i){m.f=i;try{var r=m.O();m.get();var f=m.get(),n=m.get(),t=m.get();return FS.ra(r,f,t),p[n>>2]=r.position,r.Q&&0===f&&0===t&&(r.Q=null),0}catch(e){return\"undefined\"!=typeof FS&&e instanceof FS.n||F(e),-e.s}},getTypeName:Ba,__embind_register_std_string:function(e,i){i=z(i),H(e,{name:i,fromWireType:function(e){for(var i=I[e>>2],f=Array(i),n=0;n<i;++n)f[n]=String.fromCharCode(r[e+4+n]);return y(e),f.join(\"\")},toWireType:function(e,i){function f(e,i){return e[i]}function n(e,i){return e.charCodeAt(i)}i instanceof ArrayBuffer&&(i=new Uint8Array(i));var t;i instanceof Uint8Array?t=f:i instanceof Uint8ClampedArray?t=f:i instanceof Int8Array?t=f:\"string\"==typeof i?t=n:u(\"Cannot pass non-string to std::string\");var a=i.length,l=L(4+a);I[l>>2]=a;for(var o=0;o<a;++o){var s=t(i,o);255<s&&(y(l),u(\"String has UTF-16 code units that do not fit in 8 bits\")),r[l+4+o]=s}return null!==e&&e.push(y,l),l},argPackAdvance:8,readValueFromPointer:pa,e:function(e){y(e)}})},replacePublicSymbol:nb,emval_get_global:Ga,__embind_register_emval:function(e,i){i=z(i),H(e,{name:i,fromWireType:function(e){var i=v[e].value;return Ea(e),i},toWireType:function(e,i){return K(i)},argPackAdvance:8,readValueFromPointer:pa,e:null})},__emval_get_method_caller:function(e,i){for(var r=bb(e,i),f=r[0],n=f.name+\"_$\"+r.slice(1).map(function(e){return e.name}).join(\"_\")+\"$\",t=[\"retType\"],a=[f],l=\"\",o=0;o<e-1;++o)l+=(0!==o?\", \":\"\")+\"arg\"+o,t.push(\"argType\"+o),a.push(r[1+o]);for(var n=\"return function \"+ha(\"methodCaller_\"+n)+\"(handle, name, destructors, args) {\\n\",u=0,o=0;o<e-1;++o)n+=\" var arg\"+o+\" = argType\"+o+\".readValueFromPointer(args\"+(u?\"+\"+u:\"\")+\");\\n\",u+=r[o+1].argPackAdvance;for(n+=\" var rv = handle[name](\"+l+\");\\n\",o=0;o<e-1;++o)r[o+1].deleteObject&&(n+=\" argType\"+o+\".deleteObject(arg\"+o+\");\\n\");return f.S||(n+=\" return retType.toWireType(destructors, rv);\\n\"),t.push(n+\"};\\n\"),r=Ca(Function,t).apply(null,a),ab(r)},DYNAMICTOP_PTR:R,tempDoublePtr:Pb,ABORT:ra,STACKTOP:E,STACK_MAX:ta,cttz_i8:Wb};var k=function(e,i,r){\"use asm\";var f=new e.Int8Array(r);var n=new e.Int16Array(r);var t=new e.Int32Array(r);var a=new e.Uint8Array(r);var l=new e.Uint16Array(r);var o=new e.Uint32Array(r);var u=new e.Float32Array(r);var s=new e.Float64Array(r);var b=i.DYNAMICTOP_PTR|0;var c=i.tempDoublePtr|0;var h=i.ABORT|0;var k=i.STACKTOP|0;var d=i.STACK_MAX|0;var w=i.cttz_i8|0;var v=0;var _=0;var p=0;var m=0;var y=e.NaN,g=e.Infinity;var T=0,A=0,E=0,C=0,S=0;var x=0;var M=e.Math.floor;var F=e.Math.abs;var P=e.Math.sqrt;var R=e.Math.pow;var O=e.Math.cos;var I=e.Math.sin;var N=e.Math.tan;var L=e.Math.acos;var D=e.Math.asin;var U=e.Math.atan;var H=e.Math.atan2;var W=e.Math.exp;var B=e.Math.log;var j=e.Math.ceil;var z=e.Math.imul;var V=e.Math.min;var G=e.Math.max;var q=e.Math.clz32;var K=i.abort;var J=i.assert;var Y=i.enlargeMemory;var X=i.getTotalMemory;var Z=i.abortOnCannotGrowMemory;var Q=i.invoke_iiii;var $=i.invoke_viiiii;var ee=i.invoke_vi;var ie=i.invoke_vii;var re=i.invoke_ii;var fe=i.invoke_viii;var ne=i.invoke_v;var te=i.invoke_iiiiiiiii;var ae=i.invoke_iiiii;var le=i.invoke_viiiiii;var oe=i.invoke_iii;var ue=i.invoke_iiiiii;var se=i.invoke_viiii;var be=i._pthread_getspecific;var ce=i.___lock;var he=i.floatReadValueFromPointer;var ke=i.simpleReadValueFromPointer;var de=i.__emval_call_void_method;var we=i.___resumeException;var ve=i._pthread_key_create;var _e=i.__embind_register_memory_view;var pe=i.throwInternalError;var me=i.get_first_emval;var ye=i._abort;var ge=i.__emval_addMethodCaller;var Te=i.requireHandle;var Ae=i.___gxx_personality_v0;var Ee=i.___unlock;var Ce=i.extendError;var Se=i.init_emval;var xe=i.___cxa_allocate_exception;var Me=i.__ZSt18uncaught_exceptionv;var Fe=i.___buildEnvironment;var Pe=i._emscripten_asm_const_ii;var Re=i.getShiftFromSize;var Oe=i.__emval_get_property;var Ie=i.___syscall91;var Ne=i.__emval_as;var Le=i.___cxa_begin_catch;var De=i.___setErrNo;var Ue=i.__emval_register;var He=i.__embind_register_void;var We=i._emscripten_memcpy_big;var Be=i.__embind_register_bool;var je=i._emscripten_asm_const_v;var ze=i.___cxa_find_matching_catch;var Ve=i.__emval_incref;var Ge=i._embind_repr;var qe=i.__embind_register_std_wstring;var Ke=i.__emval_get_global;var Je=i.createNamedFunction;var Ye=i.embind_init_charCodes;var Xe=i.__emval_take_value;var Ze=i.readLatin1String;var Qe=i.getStringOrSymbol;var $e=i.throwUnboundTypeError;var ei=i.craftInvokerFunction;var ii=i.__embind_register_integer;var ri=i._pthread_once;var fi=i.__emval_decref;var ni=i._getenv;var ti=i.exposePublicSymbol;var ai=i.runDestructors;var li=i.requireRegisteredType;var oi=i.makeLegalFunctionName;var ui=i.___map_file;var si=i.integerReadValueFromPointer;var bi=i.__emval_set_property;var ci=i.heap32VectorToArray;var hi=i.__emval_lookupTypes;var ki=i.whenDependentTypesAreResolved;var di=i._emscripten_asm_const_iii;var wi=i.__emval_call_method;var vi=i.__emval_run_destructors;var _i=i._pthread_setspecific;var pi=i.___syscall146;var mi=i._emscripten_asm_const_iiii;var yi=i.registerType;var gi=i.__emval_allocateDestructors;var Ti=i.__emval_strictly_equals;var Ai=i.__embind_register_function;var Ei=i.__emval_new_cstring;var Ci=i.___syscall6;var Si=i.throwBindingError;var xi=i.ensureOverloadTable;var Mi=i.count_emval_handles;var Fi=i.___cxa_throw;var Pi=i.requireFunction;var Ri=i.__embind_register_float;var Oi=i.new_;var Ii=i.___syscall140;var Ni=i.getTypeName;var Li=i.__embind_register_std_string;var Di=i.replacePublicSymbol;var Ui=i.emval_get_global;var Hi=i.__embind_register_emval;var Wi=i.__emval_get_method_caller;var Bi=0;function ji(e,i){e=e|0;i=i|0;var r=0,a=0,l=0,o=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0,T=0,A=0,E=0,C=0,S=0,x=0,M=0,F=0,P=0,R=0,O=0,I=0,N=0,L=0,D=0,U=0,H=0,W=0,B=0,j=0,z=0,V=0,G=0,q=0,K=0,J=0,Y=0,X=0,Z=0,Q=0,$=0;$=k;k=k+3008|0;o=t[e+20>>2]|0;r=t[e+16>>2]|0;if((o|0)==(r|0))g=0;else{l=0;a=0;do{a=((f[r+(l<<5)+16>>0]^1)&255)+a|0;l=l+1|0}while(l>>>0<o-r>>5>>>0);g=a}a=t[e+28>>2]|0;if((a|0)==2)if(o-r>>5){if(o-r>>5>>>0>134217727)au();s=Vt(o-r|0)|0;r=t[e+16>>2]|0;o=t[e+20>>2]|0;if((r|0)==(o|0)){Q=s;r=s}else{l=s;a=r;r=s;do{t[l>>2]=t[a>>2];$f(l+4|0,a+4|0);n[l+16>>1]=n[a+16>>1]|0;xf(l+20|0,a+20|0);a=a+32|0;l=r+32|0;r=l}while((a|0)!=(o|0));Q=s}}else{Q=0;r=0}else{t[$+360>>2]=0;b=$+360+4|0;t[b>>2]=0;t[$+360+8>>2]=0;if((o|0)==(r|0)){r=0;a=0}else{l=0;while(1){e:do{switch(a|0){case 0:{o=r+(l<<5)|0;s=r+(l<<5)+16|0;if(f[s>>0]|0){a=t[b>>2]|0;if((a|0)==(t[$+360+8>>2]|0)){Nr($+360|0,o);break e}else{t[a>>2]=t[o>>2];$f(a+4|0,r+(l<<5)+4|0);n[a+16>>1]=n[s>>1]|0;xf(a+20|0,r+(l<<5)+20|0);t[b>>2]=a+32;break e}}break}case 1:{o=r+(l<<5)|0;s=r+(l<<5)+16|0;if(!(f[s>>0]|0)){a=t[b>>2]|0;if((a|0)==(t[$+360+8>>2]|0)){Nr($+360|0,o);break e}else{t[a>>2]=t[o>>2];$f(a+4|0,r+(l<<5)+4|0);n[a+16>>1]=n[s>>1]|0;xf(a+20|0,r+(l<<5)+20|0);t[b>>2]=a+32;break e}}break}default:{}}}while(0);l=l+1|0;r=t[e+16>>2]|0;if(l>>>0>=(t[e+20>>2]|0)-r>>5>>>0)break;a=t[e+28>>2]|0}r=t[b>>2]|0;a=t[$+360>>2]|0}Q=a}t[$+2956>>2]=0;Z=$+2956+4|0;t[Z>>2]=0;t[$+2956+8>>2]=0;e:do{if((r|0)!=(Q|0)){m=$+360+4|0;d=$+280+16|0;y=$+280+28|0;v=$+280+44|0;w=$+232+16|0;h=Q;p=r-Q>>5;o=0;s=0;_=0;while(1){t[$+360>>2]=t[h+(_<<5)>>2];$f(m,h+(_<<5)+4|0);n[$+360+16>>1]=n[h+(_<<5)+16>>1]|0;xf($+360+20|0,h+(_<<5)+20|0);t[$+2968>>2]=t[$+360>>2];$f($+2968+4|0,m);n[$+2968+16>>1]=n[$+360+16>>1]|0;xf($+2968+20|0,$+360+20|0);a=t[i+16>>2]|0;do{if(a)if((a|0)==(i|0)){t[d>>2]=$+280;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$+280|0);break}else{t[d>>2]=Ru[t[(t[a>>2]|0)+8>>2]&63](a)|0;break}else t[d>>2]=0}while(0);t[$+280+24>>2]=t[$+360>>2];$f(y,m);n[$+280+40>>1]=n[$+360+16>>1]|0;xf(v,$+360+20|0);t[$+336+16>>2]=0;l=Vt(64)|0;t[l>>2]=1380;a=t[d>>2]|0;do{if(a)if((a|0)==($+280|0)){t[l+24>>2]=l+8;Pu[t[(t[a>>2]|0)+12>>2]&31](a,l+8|0);break}else{t[l+24>>2]=a;t[d>>2]=0;break}else t[l+24>>2]=0}while(0);t[l+32>>2]=t[$+280+24>>2];t[l+36>>2]=t[y>>2];t[l+36+4>>2]=t[y+4>>2];t[l+36+8>>2]=t[y+8>>2];t[y>>2]=0;t[y+4>>2]=0;t[y+8>>2]=0;n[l+48>>1]=n[$+280+40>>1]|0;t[l+52>>2]=t[v>>2];t[l+52+4>>2]=t[v+4>>2];t[l+52+8>>2]=t[v+8>>2];t[v>>2]=0;t[v+4>>2]=0;t[v+8>>2]=0;t[$+336+16>>2]=l;a=t[i+16>>2]|0;do{if(a)if((a|0)==(i|0)){t[w>>2]=$+232;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$+232|0);break}else{t[w>>2]=Ru[t[(t[a>>2]|0)+8>>2]&63](a)|0;break}else t[w>>2]=0}while(0);t[$+256+16>>2]=0;l=Vt(32)|0;t[l>>2]=1424;a=t[w>>2]|0;do{if(a)if((a|0)==($+232|0)){t[l+24>>2]=l+8;Pu[t[(t[a>>2]|0)+12>>2]&31](a,l+8|0);break}else{t[l+24>>2]=a;t[w>>2]=0;break}else t[l+24>>2]=0}while(0);t[$+256+16>>2]=l;c=zi($+2968|0,$+336|0,$+256|0)|0;a=t[$+2956+8>>2]|0;if(o>>>0>=a>>>0){b=t[$+2956>>2]|0;s=s-b|0;if(((s>>2)+1|0)>>>0>1073741823){D=51;break}a=a-b>>2>>>0<536870911?a-b>>1>>>0<((s>>2)+1|0)>>>0?(s>>2)+1|0:a-b>>1:1073741823;if(!a)l=0;else{if(a>>>0>1073741823){D=54;break}l=Vt(a<<2)|0}o=l+(s>>2<<2)|0;t[o>>2]=c;if((s|0)>0)Vr(o+(0-(s>>2)<<2)|0,b|0,s|0)|0;t[$+2956>>2]=o+(0-(s>>2)<<2);t[Z>>2]=o+4;t[$+2956+8>>2]=l+(a<<2);if(!b){s=o+4|0;l=o+4|0}else{pu(b);s=o+4|0;l=o+4|0}}else{t[o>>2]=c;l=(t[Z>>2]|0)+4|0;t[Z>>2]=l;s=l}a=t[$+256+16>>2]|0;if((a|0)!=($+256|0)){if(a|0)Fu[t[(t[a>>2]|0)+20>>2]&127](a)}else Fu[t[(t[a>>2]|0)+16>>2]&127](a);a=t[w>>2]|0;if((a|0)!=($+232|0)){if(a|0)Fu[t[(t[a>>2]|0)+20>>2]&127](a)}else Fu[t[(t[a>>2]|0)+16>>2]&127](a);a=t[$+336+16>>2]|0;if((a|0)!=($+336|0)){if(a|0)Fu[t[(t[a>>2]|0)+20>>2]&127](a)}else Fu[t[(t[a>>2]|0)+16>>2]&127](a);if((f[$+280+52+3>>0]|0)<0)pu(t[v>>2]|0);if((f[y+11>>0]|0)<0)pu(t[y>>2]|0);a=t[d>>2]|0;if((a|0)!=($+280|0)){if(a|0)Fu[t[(t[a>>2]|0)+20>>2]&127](a)}else Fu[t[(t[a>>2]|0)+16>>2]&127](a);if((f[$+2968+28+3>>0]|0)<0)pu(t[$+2968+20>>2]|0);if((f[$+2968+4+11>>0]|0)<0)pu(t[$+2968+4>>2]|0);if((f[$+360+28+3>>0]|0)<0)pu(t[$+360+20>>2]|0);if((f[m+11>>0]|0)<0)pu(t[m>>2]|0);_=_+1|0;if(_>>>0>=p>>>0)break e;else o=l}if((D|0)==51)au();else if((D|0)==54){$=xe(8)|0;ao($,7681);t[$>>2]=3404;Fi($|0,992,95)}}}while(0);t[$+2944+8>>2]=0;f[$+2944+11>>0]=7;f[$+2944>>0]=f[6235]|0;f[$+2944+1>>0]=f[6236]|0;f[$+2944+2>>0]=f[6237]|0;f[$+2944+3>>0]=f[6238]|0;f[$+2944+4>>0]=f[6239]|0;f[$+2944+5>>0]=f[6240]|0;f[$+2944+6>>0]=f[6241]|0;f[$+2944+7>>0]=0;t[$+2840>>2]=0;t[$+2840+4>>2]=0;t[$+2840+8>>2]=0;f[$+2840+11>>0]=5;f[$+2840>>0]=f[6243]|0;f[$+2840+1>>0]=f[6244]|0;f[$+2840+2>>0]=f[6245]|0;f[$+2840+3>>0]=f[6246]|0;f[$+2840+4>>0]=f[6247]|0;f[$+2840+5>>0]=0;X=$+2840+12|0;t[$+2840+20>>2]=0;f[X+11>>0]=7;f[X>>0]=f[6249]|0;f[X+1>>0]=f[6250]|0;f[X+2>>0]=f[6251]|0;f[X+3>>0]=f[6252]|0;f[X+4>>0]=f[6253]|0;f[X+5>>0]=f[6254]|0;f[X+6>>0]=f[6255]|0;f[X+7>>0]=0;lr($+2864|0,$+2840|0,1);t[$+192+8>>2]=0;f[$+192+11>>0]=7;f[$+192>>0]=f[6257]|0;f[$+192+1>>0]=f[6258]|0;f[$+192+2>>0]=f[6259]|0;f[$+192+3>>0]=f[6260]|0;f[$+192+4>>0]=f[6261]|0;f[$+192+5>>0]=f[6262]|0;f[$+192+6>>0]=f[6263]|0;f[$+192+7>>0]=0;t[$+192+16>>2]=1468;t[$+192+20>>2]=55;t[$+192+32>>2]=$+192+16;rr($+2816|0,$+192|0,1);nn($+2884|0,$+2864|0,$+2816|0);t[$+2792>>2]=0;t[$+2792+4>>2]=0;t[$+2792+8>>2]=0;f[$+2792+11>>0]=6;f[$+2792>>0]=f[6265]|0;f[$+2792+1>>0]=f[6266]|0;f[$+2792+2>>0]=f[6267]|0;f[$+2792+3>>0]=f[6268]|0;f[$+2792+4>>0]=f[6269]|0;f[$+2792+5>>0]=f[6270]|0;f[$+2792+6>>0]=0;t[$+2688>>2]=0;t[$+2688+4>>2]=0;t[$+2688+8>>2]=0;f[$+2688+11>>0]=5;f[$+2688>>0]=f[6243]|0;f[$+2688+1>>0]=f[6244]|0;f[$+2688+2>>0]=f[6245]|0;f[$+2688+3>>0]=f[6246]|0;f[$+2688+4>>0]=f[6247]|0;f[$+2688+5>>0]=0;Y=$+2688+12|0;t[Y>>2]=0;t[Y+4>>2]=0;t[Y+8>>2]=0;f[Y+11>>0]=6;f[Y>>0]=f[6265]|0;f[Y+1>>0]=f[6266]|0;f[Y+2>>0]=f[6267]|0;f[Y+3>>0]=f[6268]|0;f[Y+4>>0]=f[6269]|0;f[Y+5>>0]=f[6270]|0;f[Y+6>>0]=0;lr($+2712|0,$+2688|0,1);t[$+2668>>2]=0;t[$+2668+4>>2]=0;t[$+2668+8>>2]=0;t[$+2668+12>>2]=0;u[$+2668+16>>2]=1;t[$+2648>>2]=0;t[$+2648+4>>2]=0;t[$+2648+8>>2]=0;t[$+2648+12>>2]=0;u[$+2648+16>>2]=1;Kf($+2732|0,$+2712|0,$+2668|0,$+2648|0);t[$+2624>>2]=0;t[$+2624+4>>2]=0;t[$+2624+8>>2]=0;f[$+2624+11>>0]=2;n[$+2624>>1]=12648;f[$+2624+2>>0]=0;t[$+2612>>2]=0;t[$+2612+4>>2]=0;t[$+2612+8>>2]=0;f[$+2612+11>>0]=5;f[$+2612>>0]=f[6272]|0;f[$+2612+1>>0]=f[6273]|0;f[$+2612+2>>0]=f[6274]|0;f[$+2612+3>>0]=f[6275]|0;f[$+2612+4>>0]=f[6276]|0;f[$+2612+5>>0]=0;s=Vt(112)|0;$f(s,$+2624|0);t[s+12>>2]=0;t[s+12+4>>2]=0;t[s+12+8>>2]=0;$f(s+24|0,$+2612|0);t[s+36>>2]=0;t[s+36+4>>2]=0;t[s+36+8>>2]=0;t[s+36+12>>2]=0;u[s+52>>2]=1;t[s+56>>2]=0;t[s+56+4>>2]=0;t[s+56+8>>2]=0;t[s+56+12>>2]=0;u[s+72>>2]=1;t[s+76>>2]=0;t[s+76+4>>2]=0;t[s+76+8>>2]=0;t[s+76+12>>2]=0;u[s+92>>2]=1;t[s+100>>2]=0;t[s+104>>2]=0;t[s+108>>2]=0;t[$+2600>>2]=0;t[$+2600+4>>2]=0;t[$+2600+8>>2]=0;f[$+2600+11>>0]=5;f[$+2600>>0]=f[6278]|0;f[$+2600+1>>0]=f[6279]|0;f[$+2600+2>>0]=f[6280]|0;f[$+2600+3>>0]=f[6281]|0;f[$+2600+4>>0]=f[6282]|0;f[$+2600+5>>0]=0;t[$+2448>>2]=0;t[$+2448+4>>2]=0;t[$+2448+8>>2]=0;f[$+2448+11>>0]=2;n[$+2448>>1]=25705;f[$+2448+2>>0]=0;K=$+2448+12|0;t[K>>2]=0;t[K+4>>2]=0;t[K+8>>2]=0;f[K+11>>0]=8;t[K>>2]=762799470;t[K+4>>2]=1868853108;f[$+2448+20>>0]=0;G=$+2448+24|0;t[G>>2]=0;t[G+4>>2]=0;t[G+8>>2]=0;f[G+11>>0]=5;f[G>>0]=f[6243]|0;f[G+1>>0]=f[6244]|0;f[G+2>>0]=f[6245]|0;f[G+3>>0]=f[6246]|0;f[G+4>>0]=f[6247]|0;f[G+5>>0]=0;J=$+2448+36|0;t[J>>2]=0;t[J+4>>2]=0;t[J+8>>2]=0;f[J+11>>0]=8;t[J>>2]=762799470;t[J+4>>2]=1868853108;f[$+2448+44>>0]=0;q=$+2448+48|0;t[q>>2]=0;t[q+4>>2]=0;t[q+8>>2]=0;a=Vt(16)|0;t[q>>2]=a;t[$+2448+56>>2]=-2147483632;t[$+2448+52>>2]=11;c=a;l=6284;h=c+11|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[a+11>>0]=0;V=$+2448+60|0;t[V>>2]=0;t[V+4>>2]=0;t[V+8>>2]=0;a=Vt(32)|0;t[V>>2]=a;t[$+2448+68>>2]=-2147483616;t[$+2448+64>>2]=22;c=a;l=6296;h=c+22|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[a+22>>0]=0;lr($+2520|0,$+2448|0,3);j=f[e+4+11>>0]|0;z=j<<24>>24<0?t[e+8>>2]|0:j&255;a=Vi(z+4|0)|0;t[a>>2]=z;Vr(a+4|0,(j<<24>>24<0?t[e+4>>2]|0:e+4|0)|0,z|0)|0;t[$+360>>2]=a;a=Xe(32,$+360|0)|0;t[$+2408>>2]=0;t[$+2408+4>>2]=0;t[$+2408+8>>2]=0;f[$+2408+11>>0]=5;f[$+2408>>0]=f[6319]|0;f[$+2408+1>>0]=f[6320]|0;f[$+2408+2>>0]=f[6321]|0;f[$+2408+3>>0]=f[6322]|0;f[$+2408+4>>0]=f[6323]|0;f[$+2408+5>>0]=0;t[$+2408+12>>2]=a;ar($+2424|0,$+2408|0,1);a=t[i+16>>2]|0;do{if(a)if((a|0)==(i|0)){t[$+128+16>>2]=$+128;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$+128|0);a=t[$+128+16>>2]|0;z=$+128+16|0;break}else{a=Ru[t[(t[a>>2]|0)+8>>2]&63](a)|0;t[$+128+16>>2]=a;z=$+128+16|0;break}else{t[$+128+16>>2]=0;a=0;z=$+128+16|0}}while(0);t[$+152>>2]=0;t[$+152+4>>2]=0;t[$+152+8>>2]=0;f[$+152+11>>0]=9;c=$+152|0;l=6325;h=c+9|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[$+152+9>>0]=0;do{if(a)if((a|0)==($+128|0)){t[$+360+16>>2]=$+360;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$+360|0);a=$+360+16|0;break}else{t[$+360+16>>2]=a;t[z>>2]=0;a=$+360+16|0;break}else{t[$+360+16>>2]=0;a=$+360+16|0}}while(0);t[$+152+32>>2]=0;o=Vt(32)|0;t[o>>2]=1512;l=t[a>>2]|0;do{if(l){if((l|0)!=($+360|0)){t[o+24>>2]=l;D=103;break}t[o+24>>2]=o+8;Pu[t[(t[l>>2]|0)+12>>2]&31](l,o+8|0);a=t[a>>2]|0;t[$+152+32>>2]=o;if((a|0)==($+360|0)){Fu[t[(t[a>>2]|0)+16>>2]&127](a);break}if(a|0)Fu[t[(t[a>>2]|0)+20>>2]&127](a)}else{a=o+24|0;D=103}}while(0);if((D|0)==103){t[a>>2]=0;t[$+152+32>>2]=o}rr($+2388|0,$+152|0,1);Kf($+2540|0,$+2520|0,$+2424|0,$+2388|0);m=Vt(112)|0;Yn(m,$+2600|0,$+2540|0);j=Vt(8)|0;t[$+2636>>2]=j;t[$+2636+8>>2]=j+8;t[j>>2]=s;t[j+4>>2]=m;t[$+2636+4>>2]=j+8;m=Vt(112)|0;kf(m,$+2792|0,$+2732|0,$+2636|0);t[$+2376+8>>2]=0;f[$+2376+11>>0]=7;f[$+2376>>0]=f[6235]|0;f[$+2376+1>>0]=f[6236]|0;f[$+2376+2>>0]=f[6237]|0;f[$+2376+3>>0]=f[6238]|0;f[$+2376+4>>0]=f[6239]|0;f[$+2376+5>>0]=f[6240]|0;f[$+2376+6>>0]=f[6241]|0;f[$+2376+7>>0]=0;t[$+2248>>2]=0;t[$+2248+4>>2]=0;t[$+2248+8>>2]=0;f[$+2248+11>>0]=5;f[$+2248>>0]=f[6243]|0;f[$+2248+1>>0]=f[6244]|0;f[$+2248+2>>0]=f[6245]|0;f[$+2248+3>>0]=f[6246]|0;f[$+2248+4>>0]=f[6247]|0;f[$+2248+5>>0]=0;B=$+2248+12|0;t[B>>2]=0;t[B+4>>2]=0;t[B+8>>2]=0;f[B+11>>0]=4;t[B>>2]=1852399981;f[$+2248+16>>0]=0;W=$+2248+24|0;c=(t[e+20>>2]|0)!=(t[e+16>>2]|0);t[$+2224>>2]=0;t[$+2224+4>>2]=0;t[$+2224+8>>2]=0;l=c?5:4;f[$+2224+11>>0]=l;Vr($+2224|0,(c?6335:6341)|0,l|0)|0;f[$+2224+l>>0]=0;Ra($+2224|0,6346)|0;l=t[$+2224>>2]|0;t[$+2236>>2]=t[$+2224+4>>2];n[$+2236+4>>1]=n[$+2224+4+4>>1]|0;f[$+2236+6>>0]=f[$+2224+4+6>>0]|0;c=f[$+2224+11>>0]|0;t[$+2224>>2]=0;t[$+2224+4>>2]=0;t[$+2224+8>>2]=0;t[W>>2]=0;t[W+4>>2]=0;t[W+8>>2]=0;f[W+11>>0]=5;f[W>>0]=f[6356]|0;f[W+1>>0]=f[6357]|0;f[W+2>>0]=f[6358]|0;f[W+3>>0]=f[6359]|0;f[W+4>>0]=f[6360]|0;f[W+5>>0]=0;t[$+2248+36>>2]=l;t[$+2248+40>>2]=t[$+2236>>2];n[$+2248+40+4>>1]=n[$+2236+4>>1]|0;f[$+2248+40+6>>0]=f[$+2236+6>>0]|0;f[$+2248+47>>0]=c;t[$+2236>>2]=0;n[$+2236+4>>1]=0;f[$+2236+6>>0]=0;lr($+2296|0,$+2248|0,2);t[$+2204>>2]=0;t[$+2204+4>>2]=0;t[$+2204+8>>2]=0;t[$+2204+12>>2]=0;u[$+2204+16>>2]=1;t[$+2184>>2]=0;t[$+2184+4>>2]=0;t[$+2184+8>>2]=0;t[$+2184+12>>2]=0;u[$+2184+16>>2]=1;Kf($+2316|0,$+2296|0,$+2204|0,$+2184|0);t[$+2160>>2]=0;t[$+2160+4>>2]=0;t[$+2160+8>>2]=0;f[$+2160+11>>0]=5;f[$+2160>>0]=f[6278]|0;f[$+2160+1>>0]=f[6279]|0;f[$+2160+2>>0]=f[6280]|0;f[$+2160+3>>0]=f[6281]|0;f[$+2160+4>>0]=f[6282]|0;f[$+2160+5>>0]=0;t[$+2032>>2]=0;t[$+2032+4>>2]=0;t[$+2032+8>>2]=0;f[$+2032+11>>0]=5;f[$+2032>>0]=f[6243]|0;f[$+2032+1>>0]=f[6244]|0;f[$+2032+2>>0]=f[6245]|0;f[$+2032+3>>0]=f[6246]|0;f[$+2032+4>>0]=f[6247]|0;f[$+2032+5>>0]=0;f[$+2032+12+11>>0]=10;c=$+2032+12|0;l=6362;h=c+10|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[$+2032+12+10>>0]=0;U=$+2032+24|0;t[U>>2]=0;t[U+4>>2]=0;t[U+8>>2]=0;f[U+11>>0]=4;t[U>>2]=1701869940;f[$+2032+28>>0]=0;H=$+2032+36|0;t[H>>2]=0;t[H+4>>2]=0;t[H+8>>2]=0;f[H+11>>0]=8;t[H>>2]=1667590243;t[H+4>>2]=2020565611;f[$+2032+44>>0]=0;lr($+2080|0,$+2032|0,2);t[$+360>>2]=(g|0)==0&1;a=Xe(1104,$+360|0)|0;t[$+1992+8>>2]=0;f[$+1992+11>>0]=7;f[$+1992>>0]=f[6373]|0;f[$+1992+1>>0]=f[6374]|0;f[$+1992+2>>0]=f[6375]|0;f[$+1992+3>>0]=f[6376]|0;f[$+1992+4>>0]=f[6377]|0;f[$+1992+5>>0]=f[6378]|0;f[$+1992+6>>0]=f[6379]|0;f[$+1992+7>>0]=0;t[$+1992+12>>2]=a;ar($+2008|0,$+1992|0,1);a=t[i+16>>2]|0;do{if(a)if((a|0)==(i|0)){t[$+64+16>>2]=$+64;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$+64|0);a=t[$+64+16>>2]|0;L=$+64+16|0;break}else{a=Ru[t[(t[a>>2]|0)+8>>2]&63](a)|0;t[$+64+16>>2]=a;L=$+64+16|0;break}else{t[$+64+16>>2]=0;a=0;L=$+64+16|0}}while(0);t[$+88+8>>2]=0;f[$+88+11>>0]=7;f[$+88>>0]=f[6257]|0;f[$+88+1>>0]=f[6258]|0;f[$+88+2>>0]=f[6259]|0;f[$+88+3>>0]=f[6260]|0;f[$+88+4>>0]=f[6261]|0;f[$+88+5>>0]=f[6262]|0;f[$+88+6>>0]=f[6263]|0;f[$+88+7>>0]=0;do{if(a)if((a|0)==($+64|0)){t[$+360+16>>2]=$+360;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$+360|0);a=$+360+16|0;break}else{t[$+360+16>>2]=a;t[L>>2]=0;a=$+360+16|0;break}else{t[$+360+16>>2]=0;a=$+360+16|0}}while(0);t[$+88+32>>2]=0;o=Vt(32)|0;t[o>>2]=1556;l=t[a>>2]|0;do{if(l){if((l|0)!=($+360|0)){t[o+24>>2]=l;D=122;break}t[o+24>>2]=o+8;Pu[t[(t[l>>2]|0)+12>>2]&31](l,o+8|0);a=t[a>>2]|0;t[$+88+32>>2]=o;if((a|0)==($+360|0)){Fu[t[(t[a>>2]|0)+16>>2]&127](a);break}if(a|0)Fu[t[(t[a>>2]|0)+20>>2]&127](a)}else{a=o+24|0;D=122}}while(0);if((D|0)==122){t[a>>2]=0;t[$+88+32>>2]=o}rr($+1972|0,$+88|0,1);Kf($+2100|0,$+2080|0,$+2008|0,$+1972|0);a=Vt(112)|0;Yn(a,$+2160|0,$+2100|0);t[$+1960>>2]=0;t[$+1960+4>>2]=0;t[$+1960+8>>2]=0;f[$+1960+11>>0]=2;n[$+1960>>1]=27765;f[$+1960+2>>0]=0;t[$+1856>>2]=0;t[$+1856+4>>2]=0;t[$+1856+8>>2]=0;f[$+1856+11>>0]=5;f[$+1856>>0]=f[6243]|0;f[$+1856+1>>0]=f[6244]|0;f[$+1856+2>>0]=f[6245]|0;f[$+1856+3>>0]=f[6246]|0;f[$+1856+4>>0]=f[6247]|0;f[$+1856+5>>0]=0;N=$+1856+12|0;t[N>>2]=0;t[N+4>>2]=0;t[N+8>>2]=0;f[N+11>>0]=9;c=N;l=6381;h=c+9|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[N+9>>0]=0;lr($+1880|0,$+1856|0,1);t[$+1832>>2]=0;t[$+1832+4>>2]=0;t[$+1832+8>>2]=0;t[$+1832+12>>2]=0;u[$+1832+16>>2]=1;t[$+1812>>2]=0;t[$+1812+4>>2]=0;t[$+1812+8>>2]=0;t[$+1812+12>>2]=0;u[$+1812+16>>2]=1;Kf($+1900|0,$+1880|0,$+1832|0,$+1812|0);_=Vt(112)|0;kf(_,$+1960|0,$+1900|0,$+2956|0);I=Vt(8)|0;t[$+2172>>2]=I;t[$+2172+8>>2]=I+8;t[I>>2]=a;t[I+4>>2]=_;t[$+2172+4>>2]=I+8;_=Vt(112)|0;kf(_,$+2376|0,$+2316|0,$+2172|0);t[$+1800>>2]=0;t[$+1800+4>>2]=0;t[$+1800+8>>2]=0;f[$+1800+11>>0]=6;f[$+1800>>0]=f[6391]|0;f[$+1800+1>>0]=f[6392]|0;f[$+1800+2>>0]=f[6393]|0;f[$+1800+3>>0]=f[6394]|0;f[$+1800+4>>0]=f[6395]|0;f[$+1800+5>>0]=f[6396]|0;f[$+1800+6>>0]=0;t[$+1672>>2]=0;t[$+1672+4>>2]=0;t[$+1672+8>>2]=0;f[$+1672+11>>0]=5;f[$+1672>>0]=f[6243]|0;f[$+1672+1>>0]=f[6244]|0;f[$+1672+2>>0]=f[6245]|0;f[$+1672+3>>0]=f[6246]|0;f[$+1672+4>>0]=f[6247]|0;f[$+1672+5>>0]=0;O=$+1672+12|0;t[O>>2]=0;t[O+4>>2]=0;t[O+8>>2]=0;f[O+11>>0]=6;f[O>>0]=f[6391]|0;f[O+1>>0]=f[6392]|0;f[O+2>>0]=f[6393]|0;f[O+3>>0]=f[6394]|0;f[O+4>>0]=f[6395]|0;f[O+5>>0]=f[6396]|0;f[O+6>>0]=0;R=$+1672+24|0;c=(t[e+20>>2]|0)!=(t[e+16>>2]|0);t[$+1648>>2]=0;t[$+1648+4>>2]=0;t[$+1648+8>>2]=0;l=c?5:4;f[$+1648+11>>0]=l;Vr($+1648|0,(c?6335:6341)|0,l|0)|0;f[$+1648+l>>0]=0;Ra($+1648|0,6346)|0;l=t[$+1648>>2]|0;t[$+1660>>2]=t[$+1648+4>>2];n[$+1660+4>>1]=n[$+1648+4+4>>1]|0;f[$+1660+6>>0]=f[$+1648+4+6>>0]|0;c=f[$+1648+11>>0]|0;t[$+1648>>2]=0;t[$+1648+4>>2]=0;t[$+1648+8>>2]=0;t[R>>2]=0;t[R+4>>2]=0;t[R+8>>2]=0;f[R+11>>0]=5;f[R>>0]=f[6356]|0;f[R+1>>0]=f[6357]|0;f[R+2>>0]=f[6358]|0;f[R+3>>0]=f[6359]|0;f[R+4>>0]=f[6360]|0;f[R+5>>0]=0;t[$+1672+36>>2]=l;t[$+1672+40>>2]=t[$+1660>>2];n[$+1672+40+4>>1]=n[$+1660+4>>1]|0;f[$+1672+40+6>>0]=f[$+1660+6>>0]|0;f[$+1672+47>>0]=c;t[$+1660>>2]=0;n[$+1660+4>>1]=0;f[$+1660+6>>0]=0;lr($+1720|0,$+1672|0,2);t[$+1628>>2]=0;t[$+1628+4>>2]=0;t[$+1628+8>>2]=0;t[$+1628+12>>2]=0;u[$+1628+16>>2]=1;t[$+1608>>2]=0;t[$+1608+4>>2]=0;t[$+1608+8>>2]=0;t[$+1608+12>>2]=0;u[$+1608+16>>2]=1;Kf($+1740|0,$+1720|0,$+1628|0,$+1608|0);t[$+1584>>2]=0;t[$+1584+4>>2]=0;t[$+1584+8>>2]=0;f[$+1584+11>>0]=4;t[$+1584>>2]=1851879539;f[$+1584+4>>0]=0;t[$+1480>>2]=0;t[$+1480+4>>2]=0;t[$+1480+8>>2]=0;f[$+1480+11>>0]=5;f[$+1480>>0]=f[6243]|0;f[$+1480+1>>0]=f[6244]|0;f[$+1480+2>>0]=f[6245]|0;f[$+1480+3>>0]=f[6246]|0;f[$+1480+4>>0]=f[6247]|0;f[$+1480+5>>0]=0;f[$+1480+12+11>>0]=10;c=$+1480+12|0;l=6398;h=c+10|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[$+1480+12+10>>0]=0;lr($+1504|0,$+1480|0,1);t[$+1456>>2]=0;t[$+1456+4>>2]=0;t[$+1456+8>>2]=0;t[$+1456+12>>2]=0;u[$+1456+16>>2]=1;t[$+1436>>2]=0;t[$+1436+4>>2]=0;t[$+1436+8>>2]=0;t[$+1436+12>>2]=0;u[$+1436+16>>2]=1;Kf($+1524|0,$+1504|0,$+1456|0,$+1436|0);t[$+1412>>2]=0;t[$+1412+4>>2]=0;t[$+1412+8>>2]=0;f[$+1412+11>>0]=6;f[$+1412>>0]=f[6409]|0;f[$+1412+1>>0]=f[6410]|0;f[$+1412+2>>0]=f[6411]|0;f[$+1412+3>>0]=f[6412]|0;f[$+1412+4>>0]=f[6413]|0;f[$+1412+5>>0]=f[6414]|0;f[$+1412+6>>0]=0;vt($+1400|0,g);l=Vt(112)|0;$f(l,$+1412|0);t[l+12>>2]=0;t[l+12+4>>2]=0;t[l+12+8>>2]=0;$f(l+24|0,$+1400|0);t[l+36>>2]=0;t[l+36+4>>2]=0;t[l+36+8>>2]=0;t[l+36+12>>2]=0;u[l+52>>2]=1;t[l+56>>2]=0;t[l+56+4>>2]=0;t[l+56+8>>2]=0;t[l+56+12>>2]=0;u[l+72>>2]=1;t[l+76>>2]=0;t[l+76+4>>2]=0;t[l+76+8>>2]=0;t[l+76+12>>2]=0;u[l+92>>2]=1;t[l+100>>2]=0;t[l+104>>2]=0;t[l+108>>2]=0;a=(g|0)==1;t[$+1364>>2]=0;t[$+1364+4>>2]=0;t[$+1364+8>>2]=0;f[$+1364+11>>0]=(a^1)&1;if(!a)Vr($+1364|0,15953,(a^1)&1|0)|0;f[$+1364+((a^1)&1)>>0]=0;Ra($+1364|0,6416)|0;t[$+1376>>2]=t[$+1364>>2];t[$+1376+4>>2]=t[$+1364+4>>2];t[$+1376+8>>2]=t[$+1364+8>>2];t[$+1364>>2]=0;t[$+1364+4>>2]=0;t[$+1364+8>>2]=0;za($+1376|0)|0;t[$+1388>>2]=t[$+1376>>2];t[$+1388+4>>2]=t[$+1376+4>>2];t[$+1388+8>>2]=t[$+1376+8>>2];t[$+1376>>2]=0;t[$+1376+4>>2]=0;t[$+1376+8>>2]=0;a=Vt(112)|0;c=a;h=c+52|0;do{t[c>>2]=0;c=c+4|0}while((c|0)<(h|0));u[a+52>>2]=1;t[a+56>>2]=0;t[a+56+4>>2]=0;t[a+56+8>>2]=0;t[a+56+12>>2]=0;u[a+72>>2]=1;t[a+76>>2]=0;t[a+76+4>>2]=0;t[a+76+8>>2]=0;t[a+76+12>>2]=0;u[a+92>>2]=1;t[a+100>>2]=0;t[a+104>>2]=0;t[a+108>>2]=0;Lt(a+24|0,$+1388|0)|0;P=Vt(8)|0;t[$+1424>>2]=P;t[$+1424+8>>2]=P+8;t[P>>2]=l;t[P+4>>2]=a;t[$+1424+4>>2]=P+8;d=Vt(112)|0;kf(d,$+1584|0,$+1524|0,$+1424|0);t[$+1352>>2]=0;t[$+1352+4>>2]=0;t[$+1352+8>>2]=0;f[$+1352+11>>0]=2;n[$+1352>>1]=27765;f[$+1352+2>>0]=0;t[$+1248>>2]=0;t[$+1248+4>>2]=0;t[$+1248+8>>2]=0;f[$+1248+11>>0]=5;f[$+1248>>0]=f[6243]|0;f[$+1248+1>>0]=f[6244]|0;f[$+1248+2>>0]=f[6245]|0;f[$+1248+3>>0]=f[6246]|0;f[$+1248+4>>0]=f[6247]|0;f[$+1248+5>>0]=0;F=$+1248+12|0;t[$+1248+20>>2]=0;f[F+11>>0]=7;f[F>>0]=f[6428]|0;f[F+1>>0]=f[6429]|0;f[F+2>>0]=f[6430]|0;f[F+3>>0]=f[6431]|0;f[F+4>>0]=f[6432]|0;f[F+5>>0]=f[6433]|0;f[F+6>>0]=f[6434]|0;f[F+7>>0]=0;lr($+1272|0,$+1248|0,1);t[$+1224>>2]=0;t[$+1224+4>>2]=0;t[$+1224+8>>2]=0;t[$+1224+12>>2]=0;u[$+1224+16>>2]=1;t[$+1204>>2]=0;t[$+1204+4>>2]=0;t[$+1204+8>>2]=0;t[$+1204+12>>2]=0;u[$+1204+16>>2]=1;Kf($+1292|0,$+1272|0,$+1224|0,$+1204|0);t[$+1180>>2]=0;t[$+1180+4>>2]=0;t[$+1180+8>>2]=0;f[$+1180+11>>0]=2;n[$+1180>>1]=26988;f[$+1180+2>>0]=0;t[$+1168>>2]=0;t[$+1168+4>>2]=0;t[$+1168+8>>2]=0;f[$+1168+11>>0]=1;f[$+1168>>0]=97;f[$+1168+1>>0]=0;x=(t[e+28>>2]|0)==2;t[$+1040>>2]=0;t[$+1040+4>>2]=0;t[$+1040+8>>2]=0;f[$+1040+11>>0]=5;f[$+1040>>0]=f[6243]|0;f[$+1040+1>>0]=f[6244]|0;f[$+1040+2>>0]=f[6245]|0;f[$+1040+3>>0]=f[6246]|0;f[$+1040+4>>0]=f[6247]|0;f[$+1040+5>>0]=0;M=$+1040+12|0;t[M>>2]=0;t[M+4>>2]=0;t[M+8>>2]=0;a=x?8:0;f[M+11>>0]=a;if(x)Vr(M|0,6436,a|0)|0;f[M+a>>0]=0;S=$+1040+24|0;t[S>>2]=0;t[S+4>>2]=0;t[S+8>>2]=0;f[S+11>>0]=4;t[S>>2]=1717924456;f[$+1040+28>>0]=0;x=$+1040+36|0;t[x>>2]=0;t[x+4>>2]=0;t[x+8>>2]=0;f[x+11>>0]=2;n[x>>1]=12067;f[x+2>>0]=0;lr($+1088|0,$+1040|0,2);t[$+1016>>2]=0;t[$+1016+4>>2]=0;t[$+1016+8>>2]=0;t[$+1016+12>>2]=0;u[$+1016+16>>2]=1;t[$+996>>2]=0;t[$+996+4>>2]=0;t[$+996+8>>2]=0;t[$+996+12>>2]=0;u[$+996+16>>2]=1;Kf($+1108|0,$+1088|0,$+1016|0,$+996|0);t[$+984+4>>2]=0;t[$+984+4+4>>2]=0;f[$+984+11>>0]=3;f[$+984>>0]=f[6445]|0;f[$+984+1>>0]=f[6446]|0;f[$+984+2>>0]=f[6447]|0;f[$+984+3>>0]=0;a=Vt(112)|0;Jn(a,$+1168|0,$+1108|0,$+984|0);s=Vt(112)|0;$f(s,$+1180|0);c=s+12|0;h=c+40|0;do{t[c>>2]=0;c=c+4|0}while((c|0)<(h|0));u[s+52>>2]=1;t[s+56>>2]=0;t[s+56+4>>2]=0;t[s+56+8>>2]=0;t[s+56+12>>2]=0;u[s+72>>2]=1;t[s+76>>2]=0;t[s+76+4>>2]=0;t[s+76+8>>2]=0;t[s+76+12>>2]=0;u[s+92>>2]=1;t[s+100>>2]=0;t[s+104>>2]=0;t[s+108>>2]=0;E=Vt(4)|0;t[s+100>>2]=E;t[s+108>>2]=E+4;t[E>>2]=a;t[s+104>>2]=E+4;t[$+972>>2]=0;t[$+972+4>>2]=0;t[$+972+8>>2]=0;f[$+972+11>>0]=2;n[$+972>>1]=26988;f[$+972+2>>0]=0;t[$+960>>2]=0;t[$+960+4>>2]=0;t[$+960+8>>2]=0;f[$+960+11>>0]=1;f[$+960>>0]=97;f[$+960+1>>0]=0;E=(t[e+28>>2]|0)==1;t[$+832>>2]=0;t[$+832+4>>2]=0;t[$+832+8>>2]=0;f[$+832+11>>0]=5;f[$+832>>0]=f[6243]|0;f[$+832+1>>0]=f[6244]|0;f[$+832+2>>0]=f[6245]|0;f[$+832+3>>0]=f[6246]|0;f[$+832+4>>0]=f[6247]|0;f[$+832+5>>0]=0;C=$+832+12|0;t[C>>2]=0;t[C+4>>2]=0;t[C+8>>2]=0;a=E?8:0;f[C+11>>0]=a;if(E)Vr(C|0,6436,a|0)|0;f[C+a>>0]=0;A=$+832+24|0;t[A>>2]=0;t[A+4>>2]=0;t[A+8>>2]=0;f[A+11>>0]=4;t[A>>2]=1717924456;f[$+832+28>>0]=0;E=$+832+36|0;t[E>>2]=0;t[E+4>>2]=0;t[E+8>>2]=0;f[E+11>>0]=8;t[E>>2]=1667313443;t[E+4>>2]=1702259060;f[$+832+44>>0]=0;lr($+880|0,$+832|0,2);t[$+808>>2]=0;t[$+808+4>>2]=0;t[$+808+8>>2]=0;t[$+808+12>>2]=0;u[$+808+16>>2]=1;t[$+788>>2]=0;t[$+788+4>>2]=0;t[$+788+8>>2]=0;t[$+788+12>>2]=0;u[$+788+16>>2]=1;Kf($+900|0,$+880|0,$+808|0,$+788|0);t[$+776>>2]=0;t[$+776+4>>2]=0;t[$+776+8>>2]=0;f[$+776+11>>0]=6;f[$+776>>0]=f[6449]|0;f[$+776+1>>0]=f[6450]|0;f[$+776+2>>0]=f[6451]|0;f[$+776+3>>0]=f[6452]|0;f[$+776+4>>0]=f[6453]|0;f[$+776+5>>0]=f[6454]|0;f[$+776+6>>0]=0;a=Vt(112)|0;Jn(a,$+960|0,$+900|0,$+776|0);o=Vt(112)|0;$f(o,$+972|0);c=o+12|0;h=c+40|0;do{t[c>>2]=0;c=c+4|0}while((c|0)<(h|0));u[o+52>>2]=1;t[o+56>>2]=0;t[o+56+4>>2]=0;t[o+56+8>>2]=0;t[o+56+12>>2]=0;u[o+72>>2]=1;t[o+76>>2]=0;t[o+76+4>>2]=0;t[o+76+8>>2]=0;t[o+76+12>>2]=0;u[o+92>>2]=1;t[o+100>>2]=0;t[o+104>>2]=0;t[o+108>>2]=0;g=Vt(4)|0;t[o+100>>2]=g;t[o+108>>2]=g+4;t[g>>2]=a;t[o+104>>2]=g+4;t[$+764>>2]=0;t[$+764+4>>2]=0;t[$+764+8>>2]=0;f[$+764+11>>0]=2;n[$+764>>1]=26988;f[$+764+2>>0]=0;t[$+752>>2]=0;t[$+752+4>>2]=0;t[$+752+8>>2]=0;f[$+752+11>>0]=1;f[$+752>>0]=97;f[$+752+1>>0]=0;g=(t[e+28>>2]|0)==0;t[$+624>>2]=0;t[$+624+4>>2]=0;t[$+624+8>>2]=0;f[$+624+11>>0]=5;f[$+624>>0]=f[6243]|0;f[$+624+1>>0]=f[6244]|0;f[$+624+2>>0]=f[6245]|0;f[$+624+3>>0]=f[6246]|0;f[$+624+4>>0]=f[6247]|0;f[$+624+5>>0]=0;T=$+624+12|0;t[T>>2]=0;t[T+4>>2]=0;t[T+8>>2]=0;a=g?8:0;f[T+11>>0]=a;if(g)Vr(T|0,6436,a|0)|0;f[T+a>>0]=0;y=$+624+24|0;t[y>>2]=0;t[y+4>>2]=0;t[y+8>>2]=0;f[y+11>>0]=4;t[y>>2]=1717924456;f[$+624+28>>0]=0;g=$+624+36|0;t[g>>2]=0;t[g+4>>2]=0;t[g+8>>2]=0;a=Vt(16)|0;t[g>>2]=a;t[$+624+44>>2]=-2147483632;t[$+624+40>>2]=11;c=a;l=6456;h=c+11|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[a+11>>0]=0;lr($+672|0,$+624|0,2);t[$+604>>2]=0;t[$+604+4>>2]=0;t[$+604+8>>2]=0;t[$+604+12>>2]=0;u[$+604+16>>2]=1;t[$+584>>2]=0;t[$+584+4>>2]=0;t[$+584+8>>2]=0;t[$+584+12>>2]=0;u[$+584+16>>2]=1;Kf($+692|0,$+672|0,$+604|0,$+584|0);t[$+572>>2]=0;t[$+572+4>>2]=0;t[$+572+8>>2]=0;f[$+572+11>>0]=9;c=$+572|0;l=6468;h=c+9|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[$+572+9>>0]=0;a=Vt(112)|0;Jn(a,$+752|0,$+692|0,$+572|0);l=Vt(112)|0;$f(l,$+764|0);c=l+12|0;h=c+40|0;do{t[c>>2]=0;c=c+4|0}while((c|0)<(h|0));u[l+52>>2]=1;t[l+56>>2]=0;t[l+56+4>>2]=0;t[l+56+8>>2]=0;t[l+56+12>>2]=0;u[l+72>>2]=1;t[l+76>>2]=0;t[l+76+4>>2]=0;t[l+76+8>>2]=0;t[l+76+12>>2]=0;u[l+92>>2]=1;t[l+100>>2]=0;t[l+104>>2]=0;t[l+108>>2]=0;p=Vt(4)|0;t[l+100>>2]=p;t[l+108>>2]=p+4;t[p>>2]=a;t[l+104>>2]=p+4;p=Vt(12)|0;t[$+1192>>2]=p;t[$+1192+8>>2]=p+12;t[p>>2]=s;t[p+4>>2]=o;t[p+8>>2]=l;t[$+1192+4>>2]=p+12;s=Vt(112)|0;kf(s,$+1352|0,$+1292|0,$+1192|0);t[$+560>>2]=0;t[$+560+4>>2]=0;t[$+560+8>>2]=0;f[$+560+11>>0]=6;f[$+560>>0]=f[6478]|0;f[$+560+1>>0]=f[6479]|0;f[$+560+2>>0]=f[6480]|0;f[$+560+3>>0]=f[6481]|0;f[$+560+4>>0]=f[6482]|0;f[$+560+5>>0]=f[6483]|0;f[$+560+6>>0]=0;t[$+432>>2]=0;t[$+432+4>>2]=0;t[$+432+8>>2]=0;f[$+432+11>>0]=5;f[$+432>>0]=f[6243]|0;f[$+432+1>>0]=f[6244]|0;f[$+432+2>>0]=f[6245]|0;f[$+432+3>>0]=f[6246]|0;f[$+432+4>>0]=f[6247]|0;f[$+432+5>>0]=0;v=$+432+12|0;t[v>>2]=0;t[v+4>>2]=0;t[v+8>>2]=0;a=Vt(16)|0;t[v>>2]=a;t[$+432+20>>2]=-2147483632;t[$+432+16>>2]=15;c=a;l=6485;h=c+15|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[a+15>>0]=0;w=$+432+24|0;a=(t[e+20>>2]|0)!=(t[e+16>>2]|0);t[$+412>>2]=0;t[$+412+4>>2]=0;t[$+412+8>>2]=0;e=a?5:4;f[$+412+11>>0]=e;Vr($+412|0,(a?6335:6341)|0,e|0)|0;f[$+412+e>>0]=0;Ra($+412|0,6346)|0;e=t[$+412>>2]|0;t[$+424>>2]=t[$+412+4>>2];n[$+424+4>>1]=n[$+412+4+4>>1]|0;f[$+424+6>>0]=f[$+412+4+6>>0]|0;a=f[$+412+11>>0]|0;t[$+412>>2]=0;t[$+412+4>>2]=0;t[$+412+8>>2]=0;t[w>>2]=0;t[w+4>>2]=0;t[w+8>>2]=0;f[w+11>>0]=5;f[w>>0]=f[6356]|0;f[w+1>>0]=f[6357]|0;f[w+2>>0]=f[6358]|0;f[w+3>>0]=f[6359]|0;f[w+4>>0]=f[6360]|0;f[w+5>>0]=0;t[$+432+36>>2]=e;t[$+432+40>>2]=t[$+424>>2];n[$+432+40+4>>1]=n[$+424+4>>1]|0;f[$+432+40+6>>0]=f[$+424+6>>0]|0;f[$+432+47>>0]=a;t[$+424>>2]=0;n[$+424+4>>1]=0;f[$+424+6>>0]=0;lr($+480|0,$+432|0,2);a=t[i+16>>2]|0;do{if(a)if((a|0)==(i|0)){t[$+16>>2]=$;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$);a=t[$+16>>2]|0;b=$+16|0;break}else{a=Ru[t[(t[a>>2]|0)+8>>2]&63](a)|0;t[$+16>>2]=a;b=$+16|0;break}else{t[$+16>>2]=0;a=0;b=$+16|0}}while(0);t[$+24+8>>2]=0;f[$+24+11>>0]=7;f[$+24>>0]=f[6257]|0;f[$+24+1>>0]=f[6258]|0;f[$+24+2>>0]=f[6259]|0;f[$+24+3>>0]=f[6260]|0;f[$+24+4>>0]=f[6261]|0;f[$+24+5>>0]=f[6262]|0;f[$+24+6>>0]=f[6263]|0;f[$+24+7>>0]=0;do{if(a)if((a|0)==($|0)){t[$+360+16>>2]=$+360;Pu[t[(t[a>>2]|0)+12>>2]&31](a,$+360|0);a=$+360+16|0;break}else{t[$+360+16>>2]=a;t[b>>2]=0;a=$+360+16|0;break}else{t[$+360+16>>2]=0;a=$+360+16|0}}while(0);t[$+24+32>>2]=0;o=Vt(32)|0;t[o>>2]=1600;l=t[a>>2]|0;do{if(l){if((l|0)!=($+360|0)){t[o+24>>2]=l;D=149;break}t[o+24>>2]=o+8;Pu[t[(t[l>>2]|0)+12>>2]&31](l,o+8|0);a=t[a>>2]|0;t[$+24+32>>2]=o;if((a|0)==($+360|0)){Fu[t[(t[a>>2]|0)+16>>2]&127](a);break}if(a|0)Fu[t[(t[a>>2]|0)+20>>2]&127](a)}else{a=o+24|0;D=149}}while(0);if((D|0)==149){t[a>>2]=0;t[$+24+32>>2]=o}rr($+392|0,$+24|0,1);nn($+500|0,$+480|0,$+392|0);o=Vt(16)|0;t[$+360>>2]=o;t[$+360+8>>2]=-2147483632;t[$+360+4>>2]=15;c=o;l=6501;h=c+15|0;do{f[c>>0]=f[l>>0]|0;c=c+1|0;l=l+1|0}while((c|0)<(h|0));f[o+15>>0]=0;a=Vt(112)|0;Jn(a,$+560|0,$+500|0,$+360|0);l=Vt(12)|0;t[$+1596>>2]=l;t[$+1596+8>>2]=l+12;t[l>>2]=d;t[l+4>>2]=s;t[l+8>>2]=a;t[$+1596+4>>2]=l+12;s=Vt(112)|0;kf(s,$+1800|0,$+1740|0,$+1596|0);a=Vt(12)|0;t[$+2804>>2]=a;t[$+2804+8>>2]=a+12;t[a>>2]=m;t[a+4>>2]=_;t[a+8>>2]=s;t[$+2804+4>>2]=a+12;s=Vt(112)|0;kf(s,$+2944|0,$+2884|0,$+2804|0);if(a|0){t[$+2804+4>>2]=a;pu(a)}if(l|0){t[$+1596+4>>2]=l;pu(l)}pu(o);rf($+500|0);a=t[$+392+8>>2]|0;if(a|0)do{o=a;a=t[a>>2]|0;l=t[o+40>>2]|0;do{if((l|0)==(o+24|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((a|0)!=0);a=t[$+392>>2]|0;t[$+392>>2]=0;if(a|0)pu(a);a=t[$+24+32>>2]|0;do{if((a|0)==($+24+16|0))Fu[t[(t[a>>2]|0)+16>>2]&127](a);else{if(!a)break;Fu[t[(t[a>>2]|0)+20>>2]&127](a)}}while(0);if((f[$+24+11>>0]|0)<0)pu(t[$+24>>2]|0);a=t[b>>2]|0;do{if((a|0)==($|0))Fu[t[(t[a>>2]|0)+16>>2]&127](a);else{if(!a)break;Fu[t[(t[a>>2]|0)+20>>2]&127](a)}}while(0);a=t[$+480+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+480>>2]|0;t[$+480>>2]=0;if(a|0)pu(a);if((f[$+432+36+11>>0]|0)<0)pu(t[$+432+36>>2]|0);if((f[w+11>>0]|0)<0)pu(t[w>>2]|0);if((f[v+11>>0]|0)<0)pu(t[v>>2]|0);if((f[$+432+11>>0]|0)<0)pu(t[$+432>>2]|0);if((f[$+412+11>>0]|0)<0)pu(t[$+412>>2]|0);if(p|0){t[$+1192+4>>2]=p;pu(p)}rf($+692|0);a=t[$+584>>2]|0;t[$+584>>2]=0;if(a|0)pu(a);a=t[$+604>>2]|0;t[$+604>>2]=0;if(a|0)pu(a);a=t[$+672+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+672>>2]|0;t[$+672>>2]=0;if(a|0)pu(a);if((f[g+11>>0]|0)<0)pu(t[g>>2]|0);if((f[y+11>>0]|0)<0)pu(t[y>>2]|0);if((f[T+11>>0]|0)<0)pu(t[T>>2]|0);if((f[$+624+11>>0]|0)<0)pu(t[$+624>>2]|0);rf($+900|0);a=t[$+788>>2]|0;t[$+788>>2]=0;if(a|0)pu(a);a=t[$+808>>2]|0;t[$+808>>2]=0;if(a|0)pu(a);a=t[$+880+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+880>>2]|0;t[$+880>>2]=0;if(a|0)pu(a);if((f[E+11>>0]|0)<0)pu(t[E>>2]|0);if((f[A+11>>0]|0)<0)pu(t[A>>2]|0);if((f[C+11>>0]|0)<0)pu(t[C>>2]|0);if((f[$+832+11>>0]|0)<0)pu(t[$+832>>2]|0);rf($+1108|0);a=t[$+996>>2]|0;t[$+996>>2]=0;if(a|0)pu(a);a=t[$+1016>>2]|0;t[$+1016>>2]=0;if(a|0)pu(a);a=t[$+1088+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+1088>>2]|0;t[$+1088>>2]=0;if(a|0)pu(a);if((f[x+11>>0]|0)<0)pu(t[x>>2]|0);if((f[S+11>>0]|0)<0)pu(t[S>>2]|0);if((f[M+11>>0]|0)<0)pu(t[M>>2]|0);if((f[$+1040+11>>0]|0)<0)pu(t[$+1040>>2]|0);rf($+1292|0);a=t[$+1204>>2]|0;t[$+1204>>2]=0;if(a|0)pu(a);a=t[$+1224>>2]|0;t[$+1224>>2]=0;if(a|0)pu(a);a=t[$+1272+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+1272>>2]|0;t[$+1272>>2]=0;if(a|0)pu(a);if((f[F+11>>0]|0)<0)pu(t[F>>2]|0);if((f[$+1248+11>>0]|0)<0)pu(t[$+1248>>2]|0);if(P|0){t[$+1424+4>>2]=P;pu(P)}if((f[$+1388+11>>0]|0)<0)pu(t[$+1388>>2]|0);if((f[$+1376+11>>0]|0)<0)pu(t[$+1376>>2]|0);if((f[$+1364+11>>0]|0)<0)pu(t[$+1364>>2]|0);if((f[$+1400+11>>0]|0)<0)pu(t[$+1400>>2]|0);rf($+1524|0);a=t[$+1436>>2]|0;t[$+1436>>2]=0;if(a|0)pu(a);a=t[$+1456>>2]|0;t[$+1456>>2]=0;if(a|0)pu(a);a=t[$+1504+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+1504>>2]|0;t[$+1504>>2]=0;if(a|0)pu(a);if((f[$+1480+12+11>>0]|0)<0)pu(t[$+1480+12>>2]|0);if((f[$+1480+11>>0]|0)<0)pu(t[$+1480>>2]|0);rf($+1740|0);a=t[$+1608>>2]|0;t[$+1608>>2]=0;if(a|0)pu(a);a=t[$+1628>>2]|0;t[$+1628>>2]=0;if(a|0)pu(a);a=t[$+1720+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+1720>>2]|0;t[$+1720>>2]=0;if(a|0)pu(a);if((f[$+1672+36+11>>0]|0)<0)pu(t[$+1672+36>>2]|0);if((f[R+11>>0]|0)<0)pu(t[R>>2]|0);if((f[O+11>>0]|0)<0)pu(t[O>>2]|0);if((f[$+1672+11>>0]|0)<0)pu(t[$+1672>>2]|0);if((f[$+1648+11>>0]|0)<0)pu(t[$+1648>>2]|0);if(I|0){t[$+2172+4>>2]=I;pu(I)}rf($+1900|0);a=t[$+1812>>2]|0;t[$+1812>>2]=0;if(a|0)pu(a);a=t[$+1832>>2]|0;t[$+1832>>2]=0;if(a|0)pu(a);a=t[$+1880+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+1880>>2]|0;t[$+1880>>2]=0;if(a|0)pu(a);if((f[N+11>>0]|0)<0)pu(t[N>>2]|0);if((f[$+1856+11>>0]|0)<0)pu(t[$+1856>>2]|0);rf($+2100|0);a=t[$+1972+8>>2]|0;if(a|0)do{o=a;a=t[a>>2]|0;l=t[o+40>>2]|0;do{if((l|0)==(o+24|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((a|0)!=0);a=t[$+1972>>2]|0;t[$+1972>>2]=0;if(a|0)pu(a);a=t[$+88+32>>2]|0;do{if((a|0)==($+88+16|0))Fu[t[(t[a>>2]|0)+16>>2]&127](a);else{if(!a)break;Fu[t[(t[a>>2]|0)+20>>2]&127](a)}}while(0);if((f[$+88+11>>0]|0)<0)pu(t[$+88>>2]|0);a=t[L>>2]|0;do{if((a|0)==($+64|0))Fu[t[(t[a>>2]|0)+16>>2]&127](a);else{if(!a)break;Fu[t[(t[a>>2]|0)+20>>2]&127](a)}}while(0);a=t[$+2008+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;fi(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2008>>2]|0;t[$+2008>>2]=0;if(a|0)pu(a);fi(t[$+1992+12>>2]|0);if((f[$+1992+11>>0]|0)<0)pu(t[$+1992>>2]|0);fi(0);a=t[$+2080+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2080>>2]|0;t[$+2080>>2]=0;if(a|0)pu(a);if((f[H+11>>0]|0)<0)pu(t[H>>2]|0);if((f[U+11>>0]|0)<0)pu(t[U>>2]|0);if((f[$+2032+12+11>>0]|0)<0)pu(t[$+2032+12>>2]|0);if((f[$+2032+11>>0]|0)<0)pu(t[$+2032>>2]|0);rf($+2316|0);a=t[$+2184>>2]|0;t[$+2184>>2]=0;if(a|0)pu(a);a=t[$+2204>>2]|0;t[$+2204>>2]=0;if(a|0)pu(a);a=t[$+2296+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2296>>2]|0;t[$+2296>>2]=0;if(a|0)pu(a);if((f[$+2248+36+11>>0]|0)<0)pu(t[$+2248+36>>2]|0);if((f[W+11>>0]|0)<0)pu(t[W>>2]|0);if((f[B+11>>0]|0)<0)pu(t[B>>2]|0);if((f[$+2248+11>>0]|0)<0)pu(t[$+2248>>2]|0);if((f[$+2224+11>>0]|0)<0)pu(t[$+2224>>2]|0);if(j|0){t[$+2636+4>>2]=j;pu(j)}rf($+2540|0);a=t[$+2388+8>>2]|0;if(a|0)do{o=a;a=t[a>>2]|0;l=t[o+40>>2]|0;do{if((l|0)==(o+24|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((a|0)!=0);a=t[$+2388>>2]|0;t[$+2388>>2]=0;if(a|0)pu(a);a=t[$+152+32>>2]|0;do{if((a|0)==($+152+16|0))Fu[t[(t[a>>2]|0)+16>>2]&127](a);else{if(!a)break;Fu[t[(t[a>>2]|0)+20>>2]&127](a)}}while(0);if((f[$+152+11>>0]|0)<0)pu(t[$+152>>2]|0);a=t[z>>2]|0;do{if((a|0)==($+128|0))Fu[t[(t[a>>2]|0)+16>>2]&127](a);else{if(!a)break;Fu[t[(t[a>>2]|0)+20>>2]&127](a)}}while(0);a=t[$+2424+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;fi(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2424>>2]|0;t[$+2424>>2]=0;if(a|0)pu(a);fi(t[$+2408+12>>2]|0);if((f[$+2408+11>>0]|0)<0)pu(t[$+2408>>2]|0);fi(0);a=t[$+2520+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2520>>2]|0;t[$+2520>>2]=0;if(a|0)pu(a);if((f[V+11>>0]|0)<0)pu(t[V>>2]|0);if((f[q+11>>0]|0)<0)pu(t[q>>2]|0);if((f[J+11>>0]|0)<0)pu(t[J>>2]|0);if((f[G+11>>0]|0)<0)pu(t[G>>2]|0);if((f[K+11>>0]|0)<0)pu(t[K>>2]|0);if((f[$+2448+11>>0]|0)<0)pu(t[$+2448>>2]|0);if((f[$+2612+11>>0]|0)<0)pu(t[$+2612>>2]|0);if((f[$+2624+11>>0]|0)<0)pu(t[$+2624>>2]|0);rf($+2732|0);a=t[$+2648+8>>2]|0;if(a|0)do{o=a;a=t[a>>2]|0;l=t[o+40>>2]|0;do{if((l|0)==(o+24|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((a|0)!=0);a=t[$+2648>>2]|0;t[$+2648>>2]=0;if(a|0)pu(a);a=t[$+2668+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;fi(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2668>>2]|0;t[$+2668>>2]=0;if(a|0)pu(a);a=t[$+2712+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2712>>2]|0;t[$+2712>>2]=0;if(a|0)pu(a);if((f[Y+11>>0]|0)<0)pu(t[Y>>2]|0);if((f[$+2688+11>>0]|0)<0)pu(t[$+2688>>2]|0);if((f[$+2792+11>>0]|0)<0)pu(t[$+2792>>2]|0);rf($+2884|0);a=t[$+2816+8>>2]|0;if(a|0)do{o=a;a=t[a>>2]|0;l=t[o+40>>2]|0;do{if((l|0)==(o+24|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((a|0)!=0);a=t[$+2816>>2]|0;t[$+2816>>2]=0;if(a|0)pu(a);a=t[$+192+32>>2]|0;do{if((a|0)==($+192+16|0))Fu[t[(t[a>>2]|0)+16>>2]&127](a);else{if(!a)break;Fu[t[(t[a>>2]|0)+20>>2]&127](a)}}while(0);if((f[$+192+11>>0]|0)<0)pu(t[$+192>>2]|0);a=t[$+2864+8>>2]|0;if(a|0)do{l=a;a=t[a>>2]|0;if((f[l+20+11>>0]|0)<0)pu(t[l+20>>2]|0);if((f[l+8+11>>0]|0)<0)pu(t[l+8>>2]|0);pu(l)}while((a|0)!=0);a=t[$+2864>>2]|0;t[$+2864>>2]=0;if(a|0)pu(a);if((f[X+11>>0]|0)<0)pu(t[X>>2]|0);if((f[$+2840+11>>0]|0)<0)pu(t[$+2840>>2]|0);if((f[$+2944+11>>0]|0)<0)pu(t[$+2944>>2]|0);a=t[$+2956>>2]|0;if(a|0){l=t[Z>>2]|0;if((l|0)!=(a|0))t[Z>>2]=l+(~((l+-4-a|0)>>>2)<<2);pu(a)}l=Q;if(!Q){k=$;return s|0}if((r|0)!=(l|0))do{if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);a=r+-28|0;r=r+-32|0;if((f[a+11>>0]|0)<0)pu(t[a>>2]|0)}while((r|0)!=(l|0));pu(Q);k=$;return s|0}function zi(e,i,r){e=e|0;i=i|0;r=r|0;var l=0,o=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0,T=0,A=0,E=0,C=0,S=0,x=0,M=0,F=0,P=0,R=0,O=0,I=0;I=k;k=k+1456|0;t[I+1416>>2]=0;t[I+1416+4>>2]=0;t[I+1416+8>>2]=0;f[I+1416+11>>0]=2;n[I+1416>>1]=26988;f[I+1416+2>>0]=0;h=f[e+17>>0]|0;o=(f[e+16>>0]|0)!=0&h<<24>>24==0&1;t[I+1240>>2]=0;t[I+1240+4>>2]=0;t[I+1240+8>>2]=0;f[I+1240+11>>0]=9;s=I+1240|0;b=5987;c=s+9|0;do{f[s>>0]=f[b>>0]|0;s=s+1|0;b=b+1|0}while((s|0)<(c|0));f[I+1240+9>>0]=0;f[I+1240+12>>0]=o;b=I+1240+16|0;t[I+1240+24>>2]=0;f[b+11>>0]=7;f[b>>0]=f[8330]|0;f[b+1>>0]=f[8331]|0;f[b+2>>0]=f[8332]|0;f[b+3>>0]=f[8333]|0;f[b+4>>0]=f[8334]|0;f[b+5>>0]=f[8335]|0;f[b+6>>0]=f[8336]|0;f[b+7>>0]=0;f[I+1240+28>>0]=h;t[I+1428+4>>2]=0;c=I+1428+8|0;t[c>>2]=0;O=I+1428+4|0;t[I+1428>>2]=O;s=mr(I+1428|0,O,I+352|0,I+1440|0,I+1240|0)|0;if(!(t[s>>2]|0)){l=Vt(32)|0;$f(l+16|0,I+1240|0);f[l+28>>0]=o;o=t[I+352>>2]|0;t[l>>2]=0;t[l+4>>2]=0;t[l+8>>2]=o;t[s>>2]=l;o=t[t[I+1428>>2]>>2]|0;if(o){t[I+1428>>2]=o;l=t[s>>2]|0}Rr(t[I+1428+4>>2]|0,l);t[c>>2]=(t[c>>2]|0)+1}s=mr(I+1428|0,O,I+352|0,I+1440|0,b)|0;if(!(t[s>>2]|0)){l=Vt(32)|0;$f(l+16|0,b);f[l+28>>0]=h;o=t[I+352>>2]|0;t[l>>2]=0;t[l+4>>2]=0;t[l+8>>2]=o;t[s>>2]=l;o=t[t[I+1428>>2]>>2]|0;if(o){t[I+1428>>2]=o;l=t[s>>2]|0}Rr(t[I+1428+4>>2]|0,l);t[c>>2]=(t[c>>2]|0)+1}t[I+1272>>2]=0;t[I+1272+4>>2]=0;t[I+1272+8>>2]=0;l=t[I+1428>>2]|0;if((l|0)!=(O|0))do{if(f[l+28>>0]|0){P=l+16|0;R=f[P+11>>0]|0;qf(I+1272|0,R<<24>>24<0?t[P>>2]|0:P,R<<24>>24<0?t[l+20>>2]|0:R&255)|0}o=t[l+4>>2]|0;if(!o){o=l+8|0;s=t[o>>2]|0;if((t[s>>2]|0)==(l|0))l=s;else do{R=t[o>>2]|0;o=R+8|0;l=t[o>>2]|0}while((t[l>>2]|0)!=(R|0))}else{l=o;while(1){o=t[l>>2]|0;if(!o)break;else l=o}}}while((l|0)!=(O|0));t[I+1288>>2]=0;t[I+1288+4>>2]=0;t[I+1288+8>>2]=0;f[I+1288+11>>0]=5;f[I+1288>>0]=f[6243]|0;f[I+1288+1>>0]=f[6244]|0;f[I+1288+2>>0]=f[6245]|0;f[I+1288+3>>0]=f[6246]|0;f[I+1288+4>>0]=f[6247]|0;f[I+1288+5>>0]=0;P=I+1288+12|0;t[P>>2]=t[I+1272>>2];t[P+4>>2]=t[I+1272+4>>2];t[P+8>>2]=t[I+1272+8>>2];t[I+1272>>2]=0;t[I+1272+4>>2]=0;t[I+1272+8>>2]=0;vt(I+1440|0,t[e>>2]|0);F=I+1288+24|0;t[I+1288+28>>2]=0;t[I+1288+28+4>>2]=0;f[F+11>>0]=3;f[F>>0]=f[8338]|0;f[F+1>>0]=f[8339]|0;f[F+2>>0]=f[8340]|0;f[F+3>>0]=0;R=I+1288+36|0;t[R>>2]=t[I+1440>>2];t[R+4>>2]=t[I+1440+4>>2];t[R+8>>2]=t[I+1440+8>>2];t[I+1440>>2]=0;t[I+1440+4>>2]=0;t[I+1440+8>>2]=0;lr(I+1336|0,I+1288|0,2);t[I+1220>>2]=0;t[I+1220+4>>2]=0;t[I+1220+8>>2]=0;t[I+1220+12>>2]=0;u[I+1220+16>>2]=1;t[I+1200>>2]=0;t[I+1200+4>>2]=0;t[I+1200+8>>2]=0;t[I+1200+12>>2]=0;u[I+1200+16>>2]=1;Kf(I+1356|0,I+1336|0,I+1220|0,I+1200|0);t[I+1176+4>>2]=0;t[I+1176+4+4>>2]=0;f[I+1176+11>>0]=3;f[I+1176>>0]=f[8342]|0;f[I+1176+1>>0]=f[8343]|0;f[I+1176+2>>0]=f[8344]|0;f[I+1176+3>>0]=0;t[I+1072>>2]=0;t[I+1072+4>>2]=0;t[I+1072+8>>2]=0;f[I+1072+11>>0]=5;f[I+1072>>0]=f[6243]|0;f[I+1072+1>>0]=f[6244]|0;f[I+1072+2>>0]=f[6245]|0;f[I+1072+3>>0]=f[6246]|0;f[I+1072+4>>0]=f[6247]|0;f[I+1072+5>>0]=0;M=I+1072+12|0;t[M>>2]=0;t[M+4>>2]=0;t[M+8>>2]=0;f[M+11>>0]=4;t[M>>2]=2003134838;f[I+1072+16>>0]=0;lr(I+1096|0,I+1072|0,1);t[I+1052>>2]=0;t[I+1052+4>>2]=0;t[I+1052+8>>2]=0;t[I+1052+12>>2]=0;u[I+1052+16>>2]=1;t[I+1032>>2]=0;t[I+1032+4>>2]=0;t[I+1032+8>>2]=0;t[I+1032+12>>2]=0;u[I+1032+16>>2]=1;Kf(I+1116|0,I+1096|0,I+1052|0,I+1032|0);t[I+1008>>2]=0;t[I+1008+4>>2]=0;t[I+1008+8>>2]=0;f[I+1008+11>>0]=5;f[I+1008>>0]=f[6278]|0;f[I+1008+1>>0]=f[6279]|0;f[I+1008+2>>0]=f[6280]|0;f[I+1008+3>>0]=f[6281]|0;f[I+1008+4>>0]=f[6282]|0;f[I+1008+5>>0]=0;t[I+880>>2]=0;t[I+880+4>>2]=0;t[I+880+8>>2]=0;f[I+880+11>>0]=4;t[I+880>>2]=1701869940;f[I+880+4>>0]=0;S=I+880+12|0;t[S>>2]=0;t[S+4>>2]=0;t[S+8>>2]=0;f[S+11>>0]=8;t[S>>2]=1667590243;t[S+4>>2]=2020565611;f[I+880+20>>0]=0;C=I+880+24|0;t[C>>2]=0;t[C+4>>2]=0;t[C+8>>2]=0;f[C+11>>0]=5;f[C>>0]=f[6243]|0;f[C+1>>0]=f[6244]|0;f[C+2>>0]=f[6245]|0;f[C+3>>0]=f[6246]|0;f[C+4>>0]=f[6247]|0;f[C+5>>0]=0;x=I+880+36|0;t[x>>2]=0;t[x+4>>2]=0;t[x+8>>2]=0;f[x+11>>0]=6;f[x>>0]=f[8346]|0;f[x+1>>0]=f[8347]|0;f[x+2>>0]=f[8348]|0;f[x+3>>0]=f[8349]|0;f[x+4>>0]=f[8350]|0;f[x+5>>0]=f[8351]|0;f[x+6>>0]=0;lr(I+928|0,I+880|0,2);t[I+352>>2]=a[e+16>>0];l=Xe(1104,I+352|0)|0;t[I+840+8>>2]=0;f[I+840+11>>0]=7;f[I+840>>0]=f[6373]|0;f[I+840+1>>0]=f[6374]|0;f[I+840+2>>0]=f[6375]|0;f[I+840+3>>0]=f[6376]|0;f[I+840+4>>0]=f[6377]|0;f[I+840+5>>0]=f[6378]|0;f[I+840+6>>0]=f[6379]|0;f[I+840+7>>0]=0;t[I+840+12>>2]=l;ar(I+856|0,I+840|0,1);l=t[i+16>>2]|0;do{if(l)if((l|0)==(i|0)){t[I+288+16>>2]=I+288;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+288|0);l=t[I+288+16>>2]|0;E=I+288+16|0;break}else{l=Ru[t[(t[l>>2]|0)+8>>2]&63](l)|0;t[I+288+16>>2]=l;E=I+288+16|0;break}else{t[I+288+16>>2]=0;l=0;E=I+288+16|0}}while(0);t[I+312+8>>2]=0;f[I+312+11>>0]=7;f[I+312>>0]=f[6257]|0;f[I+312+1>>0]=f[6258]|0;f[I+312+2>>0]=f[6259]|0;f[I+312+3>>0]=f[6260]|0;f[I+312+4>>0]=f[6261]|0;f[I+312+5>>0]=f[6262]|0;f[I+312+6>>0]=f[6263]|0;f[I+312+7>>0]=0;do{if(l)if((l|0)==(I+288|0)){t[I+352+16>>2]=I+352;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+352|0);l=I+352+16|0;break}else{t[I+352+16>>2]=l;t[E>>2]=0;l=I+352+16|0;break}else{t[I+352+16>>2]=0;l=I+352+16|0}}while(0);t[I+312+32>>2]=0;s=Vt(32)|0;t[s>>2]=1876;o=t[l>>2]|0;do{if(o){if((o|0)!=(I+352|0)){t[s+24>>2]=o;T=32;break}t[s+24>>2]=s+8;Pu[t[(t[o>>2]|0)+12>>2]&31](o,s+8|0);l=t[l>>2]|0;t[I+312+32>>2]=s;if((l|0)==(I+352|0)){Fu[t[(t[l>>2]|0)+16>>2]&127](l);break}if(l|0)Fu[t[(t[l>>2]|0)+20>>2]&127](l)}else{l=s+24|0;T=32}}while(0);if((T|0)==32){t[l>>2]=0;t[I+312+32>>2]=s}rr(I+816|0,I+312|0,1);Kf(I+948|0,I+928|0,I+856|0,I+816|0);v=Vt(112)|0;Yn(v,I+1008|0,I+948|0);t[I+804>>2]=0;t[I+804+4>>2]=0;t[I+804+8>>2]=0;f[I+804+11>>0]=5;f[I+804>>0]=f[15114]|0;f[I+804+1>>0]=f[15115]|0;f[I+804+2>>0]=f[15116]|0;f[I+804+3>>0]=f[15117]|0;f[I+804+4>>0]=f[15118]|0;f[I+804+5>>0]=0;l=t[i+16>>2]|0;do{if(l)if((l|0)==(i|0)){t[I+224+16>>2]=I+224;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+224|0);l=t[I+224+16>>2]|0;A=I+224+16|0;break}else{l=Ru[t[(t[l>>2]|0)+8>>2]&63](l)|0;t[I+224+16>>2]=l;A=I+224+16|0;break}else{t[I+224+16>>2]=0;l=0;A=I+224+16|0}}while(0);f[I+248+11>>0]=10;s=I+248|0;b=8353;c=s+10|0;do{f[s>>0]=f[b>>0]|0;s=s+1|0;b=b+1|0}while((s|0)<(c|0));f[I+248+10>>0]=0;do{if(l)if((l|0)==(I+224|0)){t[I+352+16>>2]=I+352;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+352|0);l=I+352+16|0;break}else{t[I+352+16>>2]=l;t[A>>2]=0;l=I+352+16|0;break}else{t[I+352+16>>2]=0;l=I+352+16|0}}while(0);t[I+248+32>>2]=0;s=Vt(32)|0;t[s>>2]=1920;o=t[l>>2]|0;do{if(o){if((o|0)!=(I+352|0)){t[s+24>>2]=o;T=51;break}t[s+24>>2]=s+8;Pu[t[(t[o>>2]|0)+12>>2]&31](o,s+8|0);l=t[l>>2]|0;t[I+248+32>>2]=s;if((l|0)==(I+352|0)){Fu[t[(t[l>>2]|0)+16>>2]&127](l);break}if(l|0)Fu[t[(t[l>>2]|0)+20>>2]&127](l)}else{l=s+24|0;T=51}}while(0);if((T|0)==51){t[l>>2]=0;t[I+248+32>>2]=s}rr(I+724|0,I+248|0,1);t[I+744>>2]=0;t[I+744+4>>2]=0;t[I+744+8>>2]=0;t[I+744+12>>2]=0;u[I+744+16>>2]=1;t[I+744+20>>2]=0;t[I+744+20+4>>2]=0;t[I+744+20+8>>2]=0;t[I+744+20+12>>2]=0;u[I+744+36>>2]=1;ir(I+744+40|0,I+724|0);w=Vt(112)|0;Jn(w,I+804|0,I+744|0,e+4|0);t[I+712>>2]=0;t[I+712+4>>2]=0;t[I+712+8>>2]=0;f[I+712+11>>0]=6;f[I+712>>0]=f[6478]|0;f[I+712+1>>0]=f[6479]|0;f[I+712+2>>0]=f[6480]|0;f[I+712+3>>0]=f[6481]|0;f[I+712+4>>0]=f[6482]|0;f[I+712+5>>0]=f[6483]|0;f[I+712+6>>0]=0;t[I+608>>2]=0;t[I+608+4>>2]=0;t[I+608+8>>2]=0;f[I+608+11>>0]=5;f[I+608>>0]=f[6243]|0;f[I+608+1>>0]=f[6244]|0;f[I+608+2>>0]=f[6245]|0;f[I+608+3>>0]=f[6246]|0;f[I+608+4>>0]=f[6247]|0;f[I+608+5>>0]=0;g=I+608+12|0;t[I+608+20>>2]=0;f[g+11>>0]=7;f[g>>0]=f[8364]|0;f[g+1>>0]=f[8365]|0;f[g+2>>0]=f[8366]|0;f[g+3>>0]=f[8367]|0;f[g+4>>0]=f[8368]|0;f[g+5>>0]=f[8369]|0;f[g+6>>0]=f[8370]|0;f[g+7>>0]=0;lr(I+632|0,I+608|0,1);l=t[r+16>>2]|0;do{if(l)if((l|0)==(r|0)){t[I+128+16>>2]=I+128;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+128|0);p=I+128+16|0;break}else{t[I+128+16>>2]=Ru[t[(t[l>>2]|0)+8>>2]&63](l)|0;p=I+128+16|0;break}else{t[I+128+16>>2]=0;p=I+128+16|0}}while(0);t[I+128+24>>2]=t[e>>2];y=I+128+28|0;$f(y,e+4|0);n[I+128+40>>1]=n[e+16>>1]|0;m=I+128+44|0;xf(m,e+20|0);t[I+184+8>>2]=0;f[I+184+11>>0]=7;f[I+184>>0]=f[6257]|0;f[I+184+1>>0]=f[6258]|0;f[I+184+2>>0]=f[6259]|0;f[I+184+3>>0]=f[6260]|0;f[I+184+4>>0]=f[6261]|0;f[I+184+5>>0]=f[6262]|0;f[I+184+6>>0]=f[6263]|0;f[I+184+7>>0]=0;l=t[p>>2]|0;do{if(l)if((l|0)==(I+128|0)){t[I+352+16>>2]=I+352;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+352|0);o=I+352+16|0;break}else{t[I+352+16>>2]=l;t[p>>2]=0;o=I+352+16|0;break}else{t[I+352+16>>2]=0;o=I+352+16|0}}while(0);s=t[I+128+24>>2]|0;t[I+352+24>>2]=s;d=I+352+28|0;t[d>>2]=t[y>>2];t[d+4>>2]=t[y+4>>2];t[d+8>>2]=t[y+8>>2];t[y>>2]=0;t[y+4>>2]=0;t[y+8>>2]=0;c=n[I+128+40>>1]|0;n[I+352+40>>1]=c;r=I+352+44|0;t[r>>2]=t[m>>2];t[r+4>>2]=t[m+4>>2];t[r+8>>2]=t[m+8>>2];t[m>>2]=0;t[m+4>>2]=0;t[m+8>>2]=0;t[I+184+32>>2]=0;h=Vt(64)|0;t[h>>2]=1964;l=t[o>>2]|0;do{if(l)if((l|0)==(I+352|0)){t[h+24>>2]=h+8;Pu[t[(t[l>>2]|0)+12>>2]&31](l,h+8|0);o=t[o>>2]|0;b=o;s=t[I+352+24>>2]|0;l=n[I+352+40>>1]|0;break}else{t[h+24>>2]=l;t[o>>2]=0;b=0;l=c;o=0;break}else{t[h+24>>2]=0;b=0;l=c;o=0}}while(0);t[h+32>>2]=s;t[h+36>>2]=t[d>>2];t[h+36+4>>2]=t[d+4>>2];t[h+36+8>>2]=t[d+8>>2];t[d>>2]=0;t[d+4>>2]=0;t[d+8>>2]=0;n[h+48>>1]=l;t[h+52>>2]=t[r>>2];t[h+52+4>>2]=t[r+4>>2];t[h+52+8>>2]=t[r+8>>2];t[r>>2]=0;t[r+4>>2]=0;t[r+8>>2]=0;t[I+184+32>>2]=h;if((o|0)!=(I+352|0)){if(b|0)Fu[t[(t[b>>2]|0)+20>>2]&127](b)}else Fu[t[(t[b>>2]|0)+16>>2]&127](b);rr(I+588|0,I+184|0,1);nn(I+652|0,I+632|0,I+588|0);d=Vt(112)|0;Yn(d,I+712|0,I+652|0);_=Vt(12)|0;t[I+1020>>2]=_;t[I+1020+8>>2]=_+12;t[_>>2]=v;t[_+4>>2]=w;t[_+8>>2]=d;t[I+1020+4>>2]=_+12;d=Vt(112)|0;kf(d,I+1176|0,I+1116|0,I+1020|0);t[I+576>>2]=0;t[I+576+4>>2]=0;t[I+576+8>>2]=0;f[I+576+11>>0]=5;f[I+576>>0]=f[6278]|0;f[I+576+1>>0]=f[6279]|0;f[I+576+2>>0]=f[6280]|0;f[I+576+3>>0]=f[6281]|0;f[I+576+4>>0]=f[6282]|0;f[I+576+5>>0]=0;t[I+472>>2]=0;t[I+472+4>>2]=0;t[I+472+8>>2]=0;f[I+472+11>>0]=5;f[I+472>>0]=f[6243]|0;f[I+472+1>>0]=f[6244]|0;f[I+472+2>>0]=f[6245]|0;f[I+472+3>>0]=f[6246]|0;f[I+472+4>>0]=f[6247]|0;f[I+472+5>>0]=0;v=I+472+12|0;t[v>>2]=0;t[v+4>>2]=0;t[v+8>>2]=0;f[v+11>>0]=4;t[v>>2]=1953064037;f[I+472+16>>0]=0;lr(I+496|0,I+472|0,1);r=f[e+28+3>>0]|0;w=r<<24>>24<0?t[e+24>>2]|0:r&255;l=Vi((w<<2)+4|0)|0;t[l>>2]=w;oa(l+4|0,r<<24>>24<0?t[e+20>>2]|0:e+20|0,w)|0;t[I+352>>2]=l;l=Xe(256,I+352|0)|0;t[I+432>>2]=0;t[I+432+4>>2]=0;t[I+432+8>>2]=0;f[I+432+11>>0]=5;f[I+432>>0]=f[6319]|0;f[I+432+1>>0]=f[6320]|0;f[I+432+2>>0]=f[6321]|0;f[I+432+3>>0]=f[6322]|0;f[I+432+4>>0]=f[6323]|0;f[I+432+5>>0]=0;t[I+432+12>>2]=l;ar(I+448|0,I+432|0,1);l=t[i+16>>2]|0;do{if(l)if((l|0)==(i|0)){t[I+24+16>>2]=I+24;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+24|0);l=t[I+24+16>>2]|0;w=I+24+16|0;break}else{l=Ru[t[(t[l>>2]|0)+8>>2]&63](l)|0;t[I+24+16>>2]=l;w=I+24+16|0;break}else{t[I+24+16>>2]=0;l=0;w=I+24+16|0}}while(0);t[I+48>>2]=0;t[I+48+4>>2]=0;t[I+48+8>>2]=0;f[I+48+11>>0]=6;f[I+48>>0]=f[8372]|0;f[I+48+1>>0]=f[8373]|0;f[I+48+2>>0]=f[8374]|0;f[I+48+3>>0]=f[8375]|0;f[I+48+4>>0]=f[8376]|0;f[I+48+5>>0]=f[8377]|0;f[I+48+6>>0]=0;do{if(l)if((l|0)==(I+24|0)){t[I+352+16>>2]=I+352;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+352|0);l=I+352+16|0;break}else{t[I+352+16>>2]=l;t[w>>2]=0;l=I+352+16|0;break}else{t[I+352+16>>2]=0;l=I+352+16|0}}while(0);t[I+48+32>>2]=0;s=Vt(32)|0;t[s>>2]=2008;o=t[l>>2]|0;do{if(o){if((o|0)!=(I+352|0)){t[s+24>>2]=o;T=89;break}t[s+24>>2]=s+8;Pu[t[(t[o>>2]|0)+12>>2]&31](o,s+8|0);l=t[l>>2]|0;t[I+48+32>>2]=s;if((l|0)==(I+352|0)){Fu[t[(t[l>>2]|0)+16>>2]&127](l);break}if(l|0)Fu[t[(t[l>>2]|0)+20>>2]&127](l)}else{l=s+24|0;T=89}}while(0);if((T|0)==89){t[l>>2]=0;t[I+48+32>>2]=s}l=t[i+16>>2]|0;do{if(l)if((l|0)==(i|0)){t[I+16>>2]=I;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I);l=t[I+16>>2]|0;r=I+16|0;break}else{l=Ru[t[(t[l>>2]|0)+8>>2]&63](l)|0;t[I+16>>2]=l;r=I+16|0;break}else{t[I+16>>2]=0;l=0;r=I+16|0}}while(0);h=I+48+40|0;t[h>>2]=0;t[h+4>>2]=0;t[h+8>>2]=0;f[h+11>>0]=9;s=h;b=6325;c=s+9|0;do{f[s>>0]=f[b>>0]|0;s=s+1|0;b=b+1|0}while((s|0)<(c|0));f[h+9>>0]=0;do{if(l)if((l|0)==(I|0)){t[I+352+16>>2]=I+352;Pu[t[(t[l>>2]|0)+12>>2]&31](l,I+352|0);l=I+352+16|0;break}else{t[I+352+16>>2]=l;t[r>>2]=0;l=I+352+16|0;break}else{t[I+352+16>>2]=0;l=I+352+16|0}}while(0);t[I+48+72>>2]=0;s=Vt(32)|0;t[s>>2]=2052;o=t[l>>2]|0;do{if(!o){l=s+24|0;T=108}else{if((o|0)!=(I+352|0)){t[s+24>>2]=o;T=108;break}t[s+24>>2]=s+8;Pu[t[(t[o>>2]|0)+12>>2]&31](o,s+8|0);l=t[l>>2]|0;t[I+48+72>>2]=s;if((l|0)==(I+352|0)){Fu[t[(t[l>>2]|0)+16>>2]&127](l);break}if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((T|0)==108){t[l>>2]=0;t[I+48+72>>2]=s}rr(I+408|0,I+48|0,2);Kf(I+516|0,I+496|0,I+448|0,I+408|0);b=Vt(112)|0;Yn(b,I+576|0,I+516|0);l=Vt(8)|0;t[I+1188>>2]=l;t[I+1188+8>>2]=l+8;t[l>>2]=d;t[l+4>>2]=b;t[I+1188+4>>2]=l+8;b=Vt(112)|0;kf(b,I+1416|0,I+1356|0,I+1188|0);if(l|0){t[I+1188+4>>2]=l;pu(l)}rf(I+516|0);l=t[I+408+8>>2]|0;if(l|0)do{s=l;l=t[l>>2]|0;o=t[s+40>>2]|0;do{if((o|0)==(s+24|0))Fu[t[(t[o>>2]|0)+16>>2]&127](o);else{if(!o)break;Fu[t[(t[o>>2]|0)+20>>2]&127](o)}}while(0);if((f[s+8+11>>0]|0)<0)pu(t[s+8>>2]|0);pu(s)}while((l|0)!=0);l=t[I+408>>2]|0;t[I+408>>2]=0;if(l|0)pu(l);l=t[I+48+72>>2]|0;do{if((l|0)==(I+48+56|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[h+11>>0]|0)<0)pu(t[h>>2]|0);l=t[I+48+32>>2]|0;do{if((l|0)==(I+48+16|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[I+48+11>>0]|0)<0)pu(t[I+48>>2]|0);l=t[r>>2]|0;do{if((l|0)==(I|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);l=t[w>>2]|0;do{if((l|0)==(I+24|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);l=t[I+448+8>>2]|0;if(l|0)do{o=l;l=t[l>>2]|0;fi(t[o+20>>2]|0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((l|0)!=0);l=t[I+448>>2]|0;t[I+448>>2]=0;if(l|0)pu(l);fi(t[I+432+12>>2]|0);if((f[I+432+11>>0]|0)<0)pu(t[I+432>>2]|0);fi(0);l=t[I+496+8>>2]|0;if(l|0)do{o=l;l=t[l>>2]|0;if((f[o+20+11>>0]|0)<0)pu(t[o+20>>2]|0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((l|0)!=0);l=t[I+496>>2]|0;t[I+496>>2]=0;if(l|0)pu(l);if((f[v+11>>0]|0)<0)pu(t[v>>2]|0);if((f[I+472+11>>0]|0)<0)pu(t[I+472>>2]|0);if(_|0){t[I+1020+4>>2]=_;pu(_)}rf(I+652|0);l=t[I+588+8>>2]|0;if(l|0)do{s=l;l=t[l>>2]|0;o=t[s+40>>2]|0;do{if((o|0)==(s+24|0))Fu[t[(t[o>>2]|0)+16>>2]&127](o);else{if(!o)break;Fu[t[(t[o>>2]|0)+20>>2]&127](o)}}while(0);if((f[s+8+11>>0]|0)<0)pu(t[s+8>>2]|0);pu(s)}while((l|0)!=0);l=t[I+588>>2]|0;t[I+588>>2]=0;if(l|0)pu(l);l=t[I+184+32>>2]|0;do{if((l|0)==(I+184+16|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[I+184+11>>0]|0)<0)pu(t[I+184>>2]|0);if((f[I+128+52+3>>0]|0)<0)pu(t[m>>2]|0);if((f[y+11>>0]|0)<0)pu(t[y>>2]|0);l=t[p>>2]|0;do{if((l|0)==(I+128|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);l=t[I+632+8>>2]|0;if(l|0)do{o=l;l=t[l>>2]|0;if((f[o+20+11>>0]|0)<0)pu(t[o+20>>2]|0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((l|0)!=0);l=t[I+632>>2]|0;t[I+632>>2]=0;if(l|0)pu(l);if((f[g+11>>0]|0)<0)pu(t[g>>2]|0);if((f[I+608+11>>0]|0)<0)pu(t[I+608>>2]|0);rf(I+744|0);l=t[I+724+8>>2]|0;if(l|0)do{s=l;l=t[l>>2]|0;o=t[s+40>>2]|0;do{if((o|0)==(s+24|0))Fu[t[(t[o>>2]|0)+16>>2]&127](o);else{if(!o)break;Fu[t[(t[o>>2]|0)+20>>2]&127](o)}}while(0);if((f[s+8+11>>0]|0)<0)pu(t[s+8>>2]|0);pu(s)}while((l|0)!=0);l=t[I+724>>2]|0;t[I+724>>2]=0;if(l|0)pu(l);l=t[I+248+32>>2]|0;do{if((l|0)==(I+248+16|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[I+248+11>>0]|0)<0)pu(t[I+248>>2]|0);l=t[A>>2]|0;do{if((l|0)==(I+224|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);rf(I+948|0);l=t[I+816+8>>2]|0;if(l|0)do{s=l;l=t[l>>2]|0;o=t[s+40>>2]|0;do{if((o|0)==(s+24|0))Fu[t[(t[o>>2]|0)+16>>2]&127](o);else{if(!o)break;Fu[t[(t[o>>2]|0)+20>>2]&127](o)}}while(0);if((f[s+8+11>>0]|0)<0)pu(t[s+8>>2]|0);pu(s)}while((l|0)!=0);l=t[I+816>>2]|0;t[I+816>>2]=0;if(l|0)pu(l);l=t[I+312+32>>2]|0;do{if((l|0)==(I+312+16|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);if((f[I+312+11>>0]|0)<0)pu(t[I+312>>2]|0);l=t[E>>2]|0;do{if((l|0)==(I+288|0))Fu[t[(t[l>>2]|0)+16>>2]&127](l);else{if(!l)break;Fu[t[(t[l>>2]|0)+20>>2]&127](l)}}while(0);l=t[I+856+8>>2]|0;if(l|0)do{o=l;l=t[l>>2]|0;fi(t[o+20>>2]|0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((l|0)!=0);l=t[I+856>>2]|0;t[I+856>>2]=0;if(l|0)pu(l);fi(t[I+840+12>>2]|0);if((f[I+840+11>>0]|0)<0)pu(t[I+840>>2]|0);fi(0);l=t[I+928+8>>2]|0;if(l|0)do{o=l;l=t[l>>2]|0;if((f[o+20+11>>0]|0)<0)pu(t[o+20>>2]|0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((l|0)!=0);l=t[I+928>>2]|0;t[I+928>>2]=0;if(l|0)pu(l);if((f[x+11>>0]|0)<0)pu(t[x>>2]|0);if((f[C+11>>0]|0)<0)pu(t[C>>2]|0);if((f[S+11>>0]|0)<0)pu(t[S>>2]|0);if((f[I+880+11>>0]|0)<0)pu(t[I+880>>2]|0);rf(I+1116|0);l=t[I+1032>>2]|0;t[I+1032>>2]=0;if(l|0)pu(l);l=t[I+1052>>2]|0;t[I+1052>>2]=0;if(l|0)pu(l);l=t[I+1096+8>>2]|0;if(l|0)do{o=l;l=t[l>>2]|0;if((f[o+20+11>>0]|0)<0)pu(t[o+20>>2]|0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((l|0)!=0);l=t[I+1096>>2]|0;t[I+1096>>2]=0;if(l|0)pu(l);if((f[M+11>>0]|0)<0)pu(t[M>>2]|0);if((f[I+1072+11>>0]|0)<0)pu(t[I+1072>>2]|0);rf(I+1356|0);l=t[I+1200>>2]|0;t[I+1200>>2]=0;if(l|0)pu(l);l=t[I+1220>>2]|0;t[I+1220>>2]=0;if(l|0)pu(l);l=t[I+1336+8>>2]|0;if(l|0)do{o=l;l=t[l>>2]|0;if((f[o+20+11>>0]|0)<0)pu(t[o+20>>2]|0);if((f[o+8+11>>0]|0)<0)pu(t[o+8>>2]|0);pu(o)}while((l|0)!=0);l=t[I+1336>>2]|0;t[I+1336>>2]=0;if(l|0)pu(l);if((f[R+11>>0]|0)<0)pu(t[R>>2]|0);if((f[F+11>>0]|0)<0)pu(t[F>>2]|0);if((f[P+11>>0]|0)<0)pu(t[P>>2]|0);if((f[I+1288+11>>0]|0)<0)pu(t[I+1288>>2]|0);if((f[I+1272+11>>0]|0)>=0){O=t[O>>2]|0;sn(O);k=I;return b|0}pu(t[I+1272>>2]|0);O=t[O>>2]|0;sn(O);k=I;return b|0}function Vi(e){e=e|0;var i=0,r=0,f=0,n=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0;g=k;k=k+16|0;do{if(e>>>0<245){c=e>>>0<11?16:e+11&-8;s=t[4068]|0;if(s>>>(c>>>3)&3|0){r=16312+((s>>>(c>>>3)&1^1)+(c>>>3)<<1<<2)|0;e=t[r+8>>2]|0;i=t[e+8>>2]|0;if((r|0)==(i|0))t[4068]=s&~(1<<(s>>>(c>>>3)&1^1)+(c>>>3));else{t[i+12>>2]=r;t[r+8>>2]=i}y=(s>>>(c>>>3)&1^1)+(c>>>3)<<3;t[e+4>>2]=y|3;t[e+y+4>>2]=t[e+y+4>>2]|1;y=e+8|0;k=g;return y|0}b=t[4070]|0;if(c>>>0>b>>>0){if(s>>>(c>>>3)|0){e=s>>>(c>>>3)<<(c>>>3)&(2<<(c>>>3)|0-(2<<(c>>>3)));f=((e&0-e)+-1|0)>>>(((e&0-e)+-1|0)>>>12&16);n=f>>>(f>>>5&8)>>>(f>>>(f>>>5&8)>>>2&4);n=(f>>>5&8|((e&0-e)+-1|0)>>>12&16|f>>>(f>>>5&8)>>>2&4|n>>>1&2|n>>>(n>>>1&2)>>>1&1)+(n>>>(n>>>1&2)>>>(n>>>(n>>>1&2)>>>1&1))|0;f=t[16312+(n<<1<<2)+8>>2]|0;e=t[f+8>>2]|0;if((16312+(n<<1<<2)|0)==(e|0)){t[4068]=s&~(1<<n);e=s&~(1<<n)}else{t[e+12>>2]=16312+(n<<1<<2);t[16312+(n<<1<<2)+8>>2]=e;e=s}t[f+4>>2]=c|3;t[f+c+4>>2]=(n<<3)-c|1;t[f+c+((n<<3)-c)>>2]=(n<<3)-c;if(b|0){r=t[4073]|0;if(!(e&1<<(b>>>3))){t[4068]=e|1<<(b>>>3);e=16312+(b>>>3<<1<<2)+8|0;i=16312+(b>>>3<<1<<2)|0}else{e=16312+(b>>>3<<1<<2)+8|0;i=t[16312+(b>>>3<<1<<2)+8>>2]|0}t[e>>2]=r;t[i+12>>2]=r;t[r+8>>2]=i;t[r+12>>2]=16312+(b>>>3<<1<<2)}t[4070]=(n<<3)-c;t[4073]=f+c;y=f+8|0;k=g;return y|0}u=t[4069]|0;if(u){i=((u&0-u)+-1|0)>>>(((u&0-u)+-1|0)>>>12&16);r=i>>>(i>>>5&8)>>>(i>>>(i>>>5&8)>>>2&4);r=t[16576+((i>>>5&8|((u&0-u)+-1|0)>>>12&16|i>>>(i>>>5&8)>>>2&4|r>>>1&2|r>>>(r>>>1&2)>>>1&1)+(r>>>(r>>>1&2)>>>(r>>>(r>>>1&2)>>>1&1))<<2)>>2]|0;i=(t[r+4>>2]&-8)-c|0;e=t[r+16+(((t[r+16>>2]|0)==0&1)<<2)>>2]|0;if(!e){o=i;l=r}else{do{l=(t[e+4>>2]&-8)-c|0;o=l>>>0<i>>>0;i=o?l:i;r=o?e:r;e=t[e+16+(((t[e+16>>2]|0)==0&1)<<2)>>2]|0}while((e|0)!=0);o=i;l=r}a=l+c|0;if(l>>>0<a>>>0){n=t[l+24>>2]|0;e=t[l+12>>2]|0;do{if((e|0)==(l|0)){i=l+20|0;e=t[i>>2]|0;if(!e){i=l+16|0;e=t[i>>2]|0;if(!e){r=0;break}}while(1){f=e+20|0;r=t[f>>2]|0;if(r|0){e=r;i=f;continue}f=e+16|0;r=t[f>>2]|0;if(!r)break;else{e=r;i=f}}t[i>>2]=0;r=e}else{r=t[l+8>>2]|0;t[r+12>>2]=e;t[e+8>>2]=r;r=e}}while(0);do{if(n|0){e=t[l+28>>2]|0;i=(r|0)==0;if((l|0)==(t[16576+(e<<2)>>2]|0)){t[16576+(e<<2)>>2]=r;if(i){t[4069]=u&~(1<<e);break}}else{t[n+16+(((t[n+16>>2]|0)!=(l|0)&1)<<2)>>2]=r;if(i)break}t[r+24>>2]=n;e=t[l+16>>2]|0;if(e|0){t[r+16>>2]=e;t[e+24>>2]=r}e=t[l+20>>2]|0;if(e|0){t[r+20>>2]=e;t[e+24>>2]=r}}}while(0);if(o>>>0<16){y=o+c|0;t[l+4>>2]=y|3;y=l+y+4|0;t[y>>2]=t[y>>2]|1}else{t[l+4>>2]=c|3;t[a+4>>2]=o|1;t[a+o>>2]=o;if(b|0){r=t[4073]|0;if(!(1<<(b>>>3)&s)){t[4068]=1<<(b>>>3)|s;e=16312+(b>>>3<<1<<2)+8|0;i=16312+(b>>>3<<1<<2)|0}else{e=16312+(b>>>3<<1<<2)+8|0;i=t[16312+(b>>>3<<1<<2)+8>>2]|0}t[e>>2]=r;t[i+12>>2]=r;t[r+8>>2]=i;t[r+12>>2]=16312+(b>>>3<<1<<2)}t[4070]=o;t[4073]=a}y=l+8|0;k=g;return y|0}}}}else if(e>>>0<=4294967231){c=e+11&-8;f=t[4069]|0;if(f){if((e+11|0)>>>8)if(c>>>0>16777215)u=31;else{u=(e+11|0)>>>8<<((((e+11|0)>>>8)+1048320|0)>>>16&8);u=14-((u+520192|0)>>>16&4|(((e+11|0)>>>8)+1048320|0)>>>16&8|((u<<((u+520192|0)>>>16&4))+245760|0)>>>16&2)+(u<<((u+520192|0)>>>16&4)<<(((u<<((u+520192|0)>>>16&4))+245760|0)>>>16&2)>>>15)|0;u=c>>>(u+7|0)&1|u<<1}else u=0;e=t[16576+(u<<2)>>2]|0;e:do{if(!e){r=0-c|0;e=0;i=0;m=57}else{l=0-c|0;a=0;o=c<<((u|0)==31?0:25-(u>>>1)|0);i=0;while(1){r=(t[e+4>>2]&-8)-c|0;if(r>>>0<l>>>0)if(!r){r=0;n=e;i=e;m=61;break e}else i=e;else r=l;n=t[e+20>>2]|0;e=t[e+16+(o>>>31<<2)>>2]|0;a=(n|0)==0|(n|0)==(e|0)?a:n;n=(e|0)==0;if(n){e=a;m=57;break}else{l=r;o=o<<((n^1)&1)}}}}while(0);if((m|0)==57){if((e|0)==0&(i|0)==0){e=2<<u;if(!((e|0-e)&f))break;b=((e|0-e)&f&0-((e|0-e)&f))+-1|0;i=b>>>(b>>>12&16)>>>(b>>>(b>>>12&16)>>>5&8);e=i>>>(i>>>2&4)>>>(i>>>(i>>>2&4)>>>1&2);e=t[16576+((b>>>(b>>>12&16)>>>5&8|b>>>12&16|i>>>2&4|i>>>(i>>>2&4)>>>1&2|e>>>1&1)+(e>>>(e>>>1&1))<<2)>>2]|0;i=0}if(!e){o=r;u=i}else{n=e;m=61}}if((m|0)==61)while(1){m=0;e=(t[n+4>>2]&-8)-c|0;b=e>>>0<r>>>0;e=b?e:r;i=b?n:i;n=t[n+16+(((t[n+16>>2]|0)==0&1)<<2)>>2]|0;if(!n){o=e;u=i;break}else{r=e;m=61}}if((u|0)!=0?o>>>0<((t[4070]|0)-c|0)>>>0:0){l=u+c|0;if(u>>>0>=l>>>0){y=0;k=g;return y|0}a=t[u+24>>2]|0;e=t[u+12>>2]|0;do{if((e|0)==(u|0)){i=u+20|0;e=t[i>>2]|0;if(!e){i=u+16|0;e=t[i>>2]|0;if(!e){e=0;break}}while(1){n=e+20|0;r=t[n>>2]|0;if(r|0){e=r;i=n;continue}n=e+16|0;r=t[n>>2]|0;if(!r)break;else{e=r;i=n}}t[i>>2]=0}else{y=t[u+8>>2]|0;t[y+12>>2]=e;t[e+8>>2]=y}}while(0);do{if(a){i=t[u+28>>2]|0;r=(e|0)==0;if((u|0)==(t[16576+(i<<2)>>2]|0)){t[16576+(i<<2)>>2]=e;if(r){t[4069]=f&~(1<<i);f=f&~(1<<i);break}}else{t[a+16+(((t[a+16>>2]|0)!=(u|0)&1)<<2)>>2]=e;if(r)break}t[e+24>>2]=a;i=t[u+16>>2]|0;if(i|0){t[e+16>>2]=i;t[i+24>>2]=e}i=t[u+20>>2]|0;if(i){t[e+20>>2]=i;t[i+24>>2]=e}}}while(0);do{if(o>>>0>=16){t[u+4>>2]=c|3;t[l+4>>2]=o|1;t[l+o>>2]=o;r=o>>>3;if(o>>>0<256){e=t[4068]|0;if(!(e&1<<r)){t[4068]=e|1<<r;e=16312+(r<<1<<2)+8|0;i=16312+(r<<1<<2)|0}else{e=16312+(r<<1<<2)+8|0;i=t[16312+(r<<1<<2)+8>>2]|0}t[e>>2]=l;t[i+12>>2]=l;t[l+8>>2]=i;t[l+12>>2]=16312+(r<<1<<2);break}e=o>>>8;if(e)if(o>>>0>16777215)e=31;else{y=e<<((e+1048320|0)>>>16&8)<<(((e<<((e+1048320|0)>>>16&8))+520192|0)>>>16&4);e=14-(((e<<((e+1048320|0)>>>16&8))+520192|0)>>>16&4|(e+1048320|0)>>>16&8|(y+245760|0)>>>16&2)+(y<<((y+245760|0)>>>16&2)>>>15)|0;e=o>>>(e+7|0)&1|e<<1}else e=0;r=16576+(e<<2)|0;t[l+28>>2]=e;t[l+16+4>>2]=0;t[l+16>>2]=0;i=1<<e;if(!(i&f)){t[4069]=i|f;t[r>>2]=l;t[l+24>>2]=r;t[l+12>>2]=l;t[l+8>>2]=l;break}i=o<<((e|0)==31?0:25-(e>>>1)|0);r=t[r>>2]|0;while(1){if((t[r+4>>2]&-8|0)==(o|0)){m=97;break}f=r+16+(i>>>31<<2)|0;e=t[f>>2]|0;if(!e){m=96;break}else{i=i<<1;r=e}}if((m|0)==96){t[f>>2]=l;t[l+24>>2]=r;t[l+12>>2]=l;t[l+8>>2]=l;break}else if((m|0)==97){m=r+8|0;y=t[m>>2]|0;t[y+12>>2]=l;t[m>>2]=l;t[l+8>>2]=y;t[l+12>>2]=r;t[l+24>>2]=0;break}}else{y=o+c|0;t[u+4>>2]=y|3;y=u+y+4|0;t[y>>2]=t[y>>2]|1}}while(0);y=u+8|0;k=g;return y|0}}}else c=-1}while(0);r=t[4070]|0;if(r>>>0>=c>>>0){i=r-c|0;e=t[4073]|0;if(i>>>0>15){y=e+c|0;t[4073]=y;t[4070]=i;t[y+4>>2]=i|1;t[y+i>>2]=i;t[e+4>>2]=c|3}else{t[4070]=0;t[4073]=0;t[e+4>>2]=r|3;t[e+r+4>>2]=t[e+r+4>>2]|1}y=e+8|0;k=g;return y|0}n=t[4071]|0;if(n>>>0>c>>>0){p=n-c|0;t[4071]=p;y=t[4074]|0;m=y+c|0;t[4074]=m;t[m+4>>2]=p|1;t[y+4>>2]=c|3;y=y+8|0;k=g;return y|0}if(!(t[4186]|0)){t[4188]=4096;t[4187]=4096;t[4189]=-1;t[4190]=-1;t[4191]=0;t[4179]=0;t[g>>2]=g&-16^1431655768;t[4186]=g&-16^1431655768;e=4096}else e=t[4188]|0;a=c+48|0;l=c+47|0;u=e+l|0;o=0-e|0;if((u&o)>>>0<=c>>>0){y=0;k=g;return y|0}e=t[4178]|0;if(e|0?(b=t[4176]|0,(b+(u&o)|0)>>>0<=b>>>0?1:(b+(u&o)|0)>>>0>e>>>0):0){y=0;k=g;return y|0}e:do{if(!(t[4179]&4)){i=t[4074]|0;i:do{if(i){r=16720;while(1){e=t[r>>2]|0;if(e>>>0<=i>>>0?(d=r+4|0,(e+(t[d>>2]|0)|0)>>>0>i>>>0):0)break;e=t[r+8>>2]|0;if(!e){m=118;break i}else r=e}if((u-n&o)>>>0<2147483647){e=Pt(u-n&o|0)|0;if((e|0)==((t[r>>2]|0)+(t[d>>2]|0)|0))if((e|0)==(-1|0))e=u-n&o;else{l=e;a=u-n&o;m=135;break e}else{f=e;r=u-n&o;m=126}}else e=0}else m=118}while(0);do{if((m|0)==118){i=Pt(0)|0;if((i|0)!=(-1|0)?(w=t[4187]|0,w=((w+-1&i|0)==0?0:(w+-1+i&0-w)-i|0)+(u&o)|0,h=t[4176]|0,w>>>0>c>>>0&w>>>0<2147483647):0){d=t[4178]|0;if(d|0?(w+h|0)>>>0<=h>>>0|(w+h|0)>>>0>d>>>0:0){e=0;break}e=Pt(w|0)|0;if((e|0)==(i|0)){l=i;a=w;m=135;break e}else{f=e;r=w;m=126}}else e=0}}while(0);do{if((m|0)==126){i=0-r|0;if(!(a>>>0>r>>>0&(r>>>0<2147483647&(f|0)!=(-1|0))))if((f|0)==(-1|0)){e=0;break}else{l=f;a=r;m=135;break e}e=t[4188]|0;e=l-r+e&0-e;if(e>>>0>=2147483647){l=f;a=r;m=135;break e}if((Pt(e|0)|0)==(-1|0)){Pt(i|0)|0;e=0;break}else{l=f;a=e+r|0;m=135;break e}}}while(0);t[4179]=t[4179]|4;m=133}else{e=0;m=133}}while(0);if(((m|0)==133?(u&o)>>>0<2147483647:0)?(v=Pt(u&o|0)|0,_=Pt(0)|0,p=(_-v|0)>>>0>(c+40|0)>>>0,!((v|0)==(-1|0)|p^1|v>>>0<_>>>0&((v|0)!=(-1|0)&(_|0)!=(-1|0))^1)):0){l=v;a=p?_-v|0:e;m=135}if((m|0)==135){e=(t[4176]|0)+a|0;t[4176]=e;if(e>>>0>(t[4177]|0)>>>0)t[4177]=e;u=t[4074]|0;do{if(u){n=16720;while(1){e=t[n>>2]|0;f=n+4|0;i=t[f>>2]|0;if((l|0)==(e+i|0)){m=145;break}r=t[n+8>>2]|0;if(!r)break;else n=r}if(((m|0)==145?(t[n+12>>2]&8|0)==0:0)?u>>>0<l>>>0&u>>>0>=e>>>0:0){t[f>>2]=i+a;m=(u+8&7|0)==0?0:0-(u+8)&7;y=(t[4071]|0)+(a-m)|0;t[4074]=u+m;t[4071]=y;t[u+m+4>>2]=y|1;t[u+m+y+4>>2]=40;t[4075]=t[4190];break}if(l>>>0<(t[4072]|0)>>>0)t[4072]=l;r=l+a|0;i=16720;while(1){if((t[i>>2]|0)==(r|0)){m=153;break}e=t[i+8>>2]|0;if(!e)break;else i=e}if((m|0)==153?(t[i+12>>2]&8|0)==0:0){t[i>>2]=l;b=i+4|0;t[b>>2]=(t[b>>2]|0)+a;b=l+8|0;b=l+((b&7|0)==0?0:0-b&7)|0;e=r+((r+8&7|0)==0?0:0-(r+8)&7)|0;s=b+c|0;o=e-b-c|0;t[b+4>>2]=c|3;do{if((e|0)!=(u|0)){if((e|0)==(t[4073]|0)){y=(t[4070]|0)+o|0;t[4070]=y;t[4073]=s;t[s+4>>2]=y|1;t[s+y>>2]=y;break}l=t[e+4>>2]|0;if((l&3|0)==1){e:do{if(l>>>0<256){i=t[e+8>>2]|0;r=t[e+12>>2]|0;if((r|0)==(i|0)){t[4068]=t[4068]&~(1<<(l>>>3));break}else{t[i+12>>2]=r;t[r+8>>2]=i;break}}else{a=t[e+24>>2]|0;i=t[e+12>>2]|0;do{if((i|0)==(e|0)){i=t[e+16+4>>2]|0;if(!i){i=t[e+16>>2]|0;if(!i){i=0;break}else n=e+16|0}else n=e+16+4|0;while(1){f=i+20|0;r=t[f>>2]|0;if(r|0){i=r;n=f;continue}f=i+16|0;r=t[f>>2]|0;if(!r)break;else{i=r;n=f}}t[n>>2]=0}else{y=t[e+8>>2]|0;t[y+12>>2]=i;t[i+8>>2]=y}}while(0);if(!a)break;r=t[e+28>>2]|0;f=(i|0)==0;do{if((e|0)!=(t[16576+(r<<2)>>2]|0)){t[a+16+(((t[a+16>>2]|0)!=(e|0)&1)<<2)>>2]=i;if(f)break e}else{t[16576+(r<<2)>>2]=i;if(!f)break;t[4069]=t[4069]&~(1<<r);break e}}while(0);t[i+24>>2]=a;r=t[e+16>>2]|0;if(r|0){t[i+16>>2]=r;t[r+24>>2]=i}r=t[e+16+4>>2]|0;if(!r)break;t[i+20>>2]=r;t[r+24>>2]=i}}while(0);e=e+(l&-8)|0;n=(l&-8)+o|0}else n=o;r=e+4|0;t[r>>2]=t[r>>2]&-2;t[s+4>>2]=n|1;t[s+n>>2]=n;r=n>>>3;if(n>>>0<256){e=t[4068]|0;if(!(e&1<<r)){t[4068]=e|1<<r;e=16312+(r<<1<<2)+8|0;i=16312+(r<<1<<2)|0}else{e=16312+(r<<1<<2)+8|0;i=t[16312+(r<<1<<2)+8>>2]|0}t[e>>2]=s;t[i+12>>2]=s;t[s+8>>2]=i;t[s+12>>2]=16312+(r<<1<<2);break}e=n>>>8;do{if(!e)i=0;else{if(n>>>0>16777215){i=31;break}i=e<<((e+1048320|0)>>>16&8)<<(((e<<((e+1048320|0)>>>16&8))+520192|0)>>>16&4);i=14-(((e<<((e+1048320|0)>>>16&8))+520192|0)>>>16&4|(e+1048320|0)>>>16&8|(i+245760|0)>>>16&2)+(i<<((i+245760|0)>>>16&2)>>>15)|0;i=n>>>(i+7|0)&1|i<<1}}while(0);f=16576+(i<<2)|0;t[s+28>>2]=i;t[s+16+4>>2]=0;t[s+16>>2]=0;e=t[4069]|0;r=1<<i;if(!(e&r)){t[4069]=e|r;t[f>>2]=s;t[s+24>>2]=f;t[s+12>>2]=s;t[s+8>>2]=s;break}i=n<<((i|0)==31?0:25-(i>>>1)|0);r=t[f>>2]|0;while(1){if((t[r+4>>2]&-8|0)==(n|0)){m=194;break}f=r+16+(i>>>31<<2)|0;e=t[f>>2]|0;if(!e){m=193;break}else{i=i<<1;r=e}}if((m|0)==193){t[f>>2]=s;t[s+24>>2]=r;t[s+12>>2]=s;t[s+8>>2]=s;break}else if((m|0)==194){m=r+8|0;y=t[m>>2]|0;t[y+12>>2]=s;t[m>>2]=s;t[s+8>>2]=y;t[s+12>>2]=r;t[s+24>>2]=0;break}}else{y=(t[4071]|0)+o|0;t[4071]=y;t[4074]=s;t[s+4>>2]=y|1}}while(0);y=b+8|0;k=g;return y|0}i=16720;while(1){e=t[i>>2]|0;if(e>>>0<=u>>>0?(y=e+(t[i+4>>2]|0)|0,y>>>0>u>>>0):0)break;i=t[i+8>>2]|0}n=y+-47+((y+-47+8&7|0)==0?0:0-(y+-47+8)&7)|0;n=n>>>0<(u+16|0)>>>0?u:n;e=l+8|0;e=(e&7|0)==0?0:0-e&7;m=l+e|0;e=a+-40-e|0;t[4074]=m;t[4071]=e;t[m+4>>2]=e|1;t[m+e+4>>2]=40;t[4075]=t[4190];t[n+4>>2]=27;t[n+8>>2]=t[4180];t[n+8+4>>2]=t[4181];t[n+8+8>>2]=t[4182];t[n+8+12>>2]=t[4183];t[4180]=l;t[4181]=a;t[4183]=0;t[4182]=n+8;e=n+24|0;do{m=e;e=e+4|0;t[e>>2]=7}while((m+8|0)>>>0<y>>>0);if((n|0)!=(u|0)){t[n+4>>2]=t[n+4>>2]&-2;t[u+4>>2]=n-u|1;t[n>>2]=n-u;if((n-u|0)>>>0<256){r=16312+((n-u|0)>>>3<<1<<2)|0;e=t[4068]|0;if(!(e&1<<((n-u|0)>>>3))){t[4068]=e|1<<((n-u|0)>>>3);e=r+8|0;i=r}else{e=r+8|0;i=t[r+8>>2]|0}t[e>>2]=u;t[i+12>>2]=u;t[u+8>>2]=i;t[u+12>>2]=r;break}if((n-u|0)>>>8)if((n-u|0)>>>0>16777215)i=31;else{i=(n-u|0)>>>8<<((((n-u|0)>>>8)+1048320|0)>>>16&8);i=14-((i+520192|0)>>>16&4|(((n-u|0)>>>8)+1048320|0)>>>16&8|((i<<((i+520192|0)>>>16&4))+245760|0)>>>16&2)+(i<<((i+520192|0)>>>16&4)<<(((i<<((i+520192|0)>>>16&4))+245760|0)>>>16&2)>>>15)|0;i=(n-u|0)>>>(i+7|0)&1|i<<1}else i=0;f=16576+(i<<2)|0;t[u+28>>2]=i;t[u+20>>2]=0;t[u+16>>2]=0;e=t[4069]|0;r=1<<i;if(!(e&r)){t[4069]=e|r;t[f>>2]=u;t[u+24>>2]=f;t[u+12>>2]=u;t[u+8>>2]=u;break}i=n-u<<((i|0)==31?0:25-(i>>>1)|0);r=t[f>>2]|0;while(1){if((t[r+4>>2]&-8|0)==(n-u|0)){m=216;break}f=r+16+(i>>>31<<2)|0;e=t[f>>2]|0;if(!e){m=215;break}else{i=i<<1;r=e}}if((m|0)==215){t[f>>2]=u;t[u+24>>2]=r;t[u+12>>2]=u;t[u+8>>2]=u;break}else if((m|0)==216){m=r+8|0;y=t[m>>2]|0;t[y+12>>2]=u;t[m>>2]=u;t[u+8>>2]=y;t[u+12>>2]=r;t[u+24>>2]=0;break}}}else{y=t[4072]|0;if((y|0)==0|l>>>0<y>>>0)t[4072]=l;t[4180]=l;t[4181]=a;t[4183]=0;t[4077]=t[4186];t[4076]=-1;e=0;do{y=16312+(e<<1<<2)|0;t[y+12>>2]=y;t[y+8>>2]=y;e=e+1|0}while((e|0)!=32);y=l+8|0;y=(y&7|0)==0?0:0-y&7;m=l+y|0;y=a+-40-y|0;t[4074]=m;t[4071]=y;t[m+4>>2]=y|1;t[m+y+4>>2]=40;t[4075]=t[4190]}}while(0);e=t[4071]|0;if(e>>>0>c>>>0){p=e-c|0;t[4071]=p;y=t[4074]|0;m=y+c|0;t[4074]=m;t[m+4>>2]=p|1;t[y+4>>2]=c|3;y=y+8|0;k=g;return y|0}}t[4223]=12;y=0;k=g;return y|0}function Gi(e){e=e|0;var i=0,r=0,f=0,n=0,a=0,l=0,o=0,u=0,s=0;e:do{if(e>>>0<212)e=t[(_t(2840,3032,e)|0)>>2]|0;else{a=(_t(3032,3224,e-(((e>>>0)/210|0)*210|0)|0)|0)-3032>>2;l=(e>>>0)/210|0;i=((e>>>0)/210|0)*210|0;f=0;while(1){e=(t[3032+(a<<2)>>2]|0)+i|0;r=5;while(1){if(r>>>0>=47){n=211;r=f;o=8;break}i=t[2840+(r<<2)>>2]|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0)break e;if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){e=f;break}else r=r+1|0}i:do{if((o|0)==8){r:while(1){o=0;i=(e>>>0)/(n>>>0)|0;do{if(i>>>0>=n>>>0)if((e|0)!=(z(i,n)|0)){i=n+10|0;if(((e>>>0)/(i>>>0)|0)>>>0>=i>>>0)if((e|0)!=(z((e>>>0)/(i>>>0)|0,i)|0)){i=n+12|0;if(((e>>>0)/(i>>>0)|0)>>>0>=i>>>0)if((e|0)!=(z((e>>>0)/(i>>>0)|0,i)|0)){i=n+16|0;if(((e>>>0)/(i>>>0)|0)>>>0>=i>>>0)if((e|0)!=(z((e>>>0)/(i>>>0)|0,i)|0)){i=n+18|0;if(((e>>>0)/(i>>>0)|0)>>>0>=i>>>0)if((e|0)!=(z((e>>>0)/(i>>>0)|0,i)|0)){i=n+22|0;if(((e>>>0)/(i>>>0)|0)>>>0>=i>>>0)if((e|0)!=(z((e>>>0)/(i>>>0)|0,i)|0)){i=n+28|0;if(((e>>>0)/(i>>>0)|0)>>>0>=i>>>0)if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0))f=9;else{i=n+30|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+36|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+40|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+42|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+46|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+52|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+58|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+60|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+66|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+70|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+72|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+78|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+82|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+88|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+96|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+100|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+102|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+106|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+108|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+112|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+120|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+126|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+130|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+136|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+138|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+142|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+148|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+150|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+156|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+162|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+166|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+168|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+172|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+178|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+180|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+186|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+190|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+192|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+196|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+198|0;if(((e>>>0)/(i>>>0)|0)>>>0<i>>>0){f=1;r=e;break}if((e|0)==(z((e>>>0)/(i>>>0)|0,i)|0)){f=9;break}i=n+208|0;u=((e>>>0)/(i>>>0)|0)>>>0<i>>>0;s=(e|0)==(z((e>>>0)/(i>>>0)|0,i)|0);f=u?1:s?9:0;i=u|s?i:n+210|0;r=u?e:r}else{f=1;r=e}}else f=9;else{f=1;r=e}}else f=9;else{f=1;r=e}}else f=9;else{f=1;r=e}}else f=9;else{f=1;r=e}}else f=9;else{f=1;r=e}}else{f=9;i=n}else{f=1;i=n;r=e}}while(0);switch(f&15){case 9:{e=r;break i}case 0:{n=i;o=8;break}default:break r}}if(!f)e=r;else{e=r;break e}}}while(0);f=a+1|0;i=((f|0)==48&1)+l|0;a=(f|0)==48?0:f;l=i;i=i*210|0;f=e}}}while(0);return e|0}function qi(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0,T=0,A=0,E=0,C=0,S=0,x=0,M=0;M=k;k=k+32|0;t[i+96>>2]=t[e+96>>2];Yi(e,i);Qi(e,i);sr(e,i);o=f[i+24+11>>0]|0;if(o<<24>>24<0)r=t[i+28>>2]|0;else r=o&255;if(r|0){a=o<<24>>24<0?t[i+28>>2]|0:o&255;r=f[e+24+11>>0]|0;e:do{if((a|0)==((r<<24>>24<0?t[e+28>>2]|0:r&255)|0)){n=t[i+24>>2]|0;l=o<<24>>24<0?n:i+24|0;r=r<<24>>24<0?t[e+24>>2]|0:e+24|0;if(o<<24>>24<0){if(!a){k=M;return}if(!(wt(l,r,a)|0)){k=M;return}else{r=t[i+96>>2]|0;break}}if(!a){k=M;return}if((n&255)<<24>>24==(f[r>>0]|0)){n=o&255;a=i+24|0}else{r=t[i+96>>2]|0;n=i+24|0;break}while(1){n=n+-1|0;a=a+1|0;if(!n)break;r=r+1|0;if((f[a>>0]|0)!=(f[r>>0]|0)){y=114;break e}}k=M;return}else y=114}while(0);do{if((y|0)==114){r=t[i+96>>2]|0;if(o<<24>>24<0){n=t[i+24>>2]|0;break}else{n=i+24|0;break}}}while(0);di(16,r|0,n|0)|0;k=M;return}o=t[i+100>>2]|0;a=t[i+104>>2]|0;l=t[e+104>>2]|0;n=t[e+100>>2]|0;if((o|0)==(a|0)){if((n|0)!=(l|0)){Pe(14,t[(t[n>>2]|0)+96>>2]|0)|0;if(!((l-n>>2)+-1|0)){k=M;return}else r=1;do{Pe(14,t[(t[(t[e+100>>2]|0)+(r<<2)>>2]|0)+96>>2]|0)|0;r=r+1|0}while(r>>>0<=((l-n>>2)+-1|0)>>>0);k=M;return}r=f[e+24+11>>0]|0;if(r<<24>>24<0)r=t[e+28>>2]|0;else r=r&255;if(!r){k=M;return}Pe(15,t[i+96>>2]|0)|0;k=M;return}if((n|0)==(l|0)){r=f[e+24+11>>0]|0;if(r<<24>>24<0)r=t[e+28>>2]|0;else r=r&255;if(!r){r=a;n=o;a=o}else{Pe(15,t[i+96>>2]|0)|0;a=t[i+100>>2]|0;r=t[i+104>>2]|0;n=a}l=t[i+96>>2]|0;n=(r-n>>2)+-1|0;mi(13,l|0,hr(t[a>>2]|0)|0,0)|0;if(!n){k=M;return}else r=1;do{mi(13,l|0,hr(t[(t[i+100>>2]|0)+(r<<2)>>2]|0)|0,0)|0;r=r+1|0}while(r>>>0<=n>>>0);k=M;return}x=t[i+96>>2]|0;if(l-n>>2){if(l-n>>2>>>0>1073741823)au();a=Vt(l-n|0)|0;r=t[e+100>>2]|0;n=(t[e+104>>2]|0)-r|0;if((n|0)>0){Vr(a|0,r|0,n|0)|0;S=a;r=a+(n>>>2<<2)|0;n=a;C=a}else{S=a;r=a;n=a;C=a}}else{S=0;r=0;n=0;C=0}u=r-n|0;r=t[i+100>>2]|0;l=(t[i+104>>2]|0)-r|0;e:do{if(!((u|0)<4|(l|0)<4)){_=t[r>>2]|0;a=r;s=r;c=r;h=r;d=0;o=r;e=r;m=_;b=(l>>2)+-1|0;v=t[r+((l>>2)+-1<<2)>>2]|0;A=0;E=(u>>2)+-1|0;p=t[n+((u>>2)+-1<<2)>>2]|0;u=0;r=0;w=t[n>>2]|0;i:while(1){r:do{if(!w){w=r+1|0;y=o;g=e;n=A;l=E;r=w;w=t[C+(w<<2)>>2]|0}else{if(!p){p=E+-1|0;y=o;g=e;n=A;l=p;p=t[C+(p<<2)>>2]|0;break}if(!_){n=A+1|0;_=t[o+(n<<2)>>2]|0;y=o;g=o;m=_;l=E;break}if(!v){v=b+-1|0;y=o;g=e;b=v;v=t[e+(v<<2)>>2]|0;n=A;l=E;break}if(Hr(w,_)|0){qi(w,_);w=r+1|0;n=A+1|0;g=t[i+100>>2]|0;_=t[g+(n<<2)>>2]|0;a=g;s=g;c=g;h=g;y=g;m=_;l=E;r=w;w=t[C+(w<<2)>>2]|0;break}if(Hr(p,v)|0){qi(p,v);p=E+-1|0;v=b+-1|0;n=t[i+100>>2]|0;a=n;s=n;c=n;h=n;y=n;g=n;b=v;v=t[n+(v<<2)>>2]|0;n=A;l=p;p=t[C+(p<<2)>>2]|0;break}if(Hr(w,v)|0){qi(w,v);mi(11,x|0,t[w+96>>2]|0,t[p+96>>2]|0)|0;w=r+1|0;v=b+-1|0;n=t[i+100>>2]|0;a=n;s=n;c=n;h=n;y=n;g=n;b=v;v=t[n+(v<<2)>>2]|0;n=A;l=E;r=w;w=t[C+(w<<2)>>2]|0;break}if(Hr(p,_)|0){qi(p,_);mi(12,x|0,t[p+96>>2]|0,t[w+96>>2]|0)|0;p=E+-1|0;n=A+1|0;g=t[i+100>>2]|0;_=t[g+(n<<2)>>2]|0;a=g;s=g;c=g;h=g;y=g;m=_;l=p;p=t[C+(p<<2)>>2]|0;break}if(!u){e=Vt(12)|0;t[e+4>>2]=0;t[e+8>>2]=0;t[e>>2]=e+4;if((r|0)>(E|0)){d=e;T=e}else{o=r;while(1){a=t[C+(o<<2)>>2]|0;n=f[a+12+11>>0]|0;if(n<<24>>24<0)n=t[a+16>>2]|0;else n=n&255;if(n|0){$f(M,a+12|0);t[M+12>>2]=o;l=Wr(e,M+16|0,M)|0;if(!(t[l>>2]|0)){n=Vt(32)|0;t[n+16>>2]=t[M>>2];t[n+16+4>>2]=t[M+4>>2];t[n+16+8>>2]=t[M+8>>2];t[M>>2]=0;t[M+4>>2]=0;t[M+8>>2]=0;t[n+28>>2]=t[M+12>>2];a=t[M+16>>2]|0;t[n>>2]=0;t[n+4>>2]=0;t[n+8>>2]=a;t[l>>2]=n;a=t[t[e>>2]>>2]|0;if(a){t[e>>2]=a;n=t[l>>2]|0}Rr(t[e+4>>2]|0,n);t[e+8>>2]=(t[e+8>>2]|0)+1}if((f[M+11>>0]|0)<0)pu(t[M>>2]|0)}if((o|0)<(E|0))o=o+1|0;else{d=e;T=e;break}}}}else T=u;c=_+12|0;n=t[T+4>>2]|0;f:do{if(n|0){u=f[c+11>>0]|0;s=u<<24>>24<0?t[_+16>>2]|0:u&255;u=u<<24>>24<0?t[c>>2]|0:c;n:while(1){o=n+16|0;l=f[o+11>>0]|0;e=l<<24>>24<0?t[n+20>>2]|0:l&255;a=e>>>0<s>>>0?e:s;do{if(a){a=wt(u,l<<24>>24<0?t[o>>2]|0:o,a)|0;if(!a){y=50;break}if((a|0)<0)y=52;else y=53}else y=50}while(0);if((y|0)==50)if(s>>>0<e>>>0)y=52;else y=53;if((y|0)!=52)if((y|0)==53){y=0;a=s>>>0<e>>>0?s:e;do{if(a){a=wt(l<<24>>24<0?t[o>>2]|0:o,u,a)|0;if(!a){y=55;break}if((a|0)>=0)break n}else y=55}while(0);if((y|0)==55?(y=0,e>>>0>=s>>>0):0)break;n=n+4|0}n=t[n>>2]|0;if(!n)break f}n=t[(Wr(T,M+16|0,c)|0)>>2]|0;if(!n){y=61;break i}u=t[C+(t[n+28>>2]<<2)>>2]|0;o=f[u+11>>0]|0;e=o<<24>>24<0?t[u+4>>2]|0:o&255;n=f[m+11>>0]|0;n:do{if((e|0)==((n<<24>>24<0?t[_+4>>2]|0:n&255)|0)){a=t[u>>2]|0;l=o<<24>>24<0?a:u;n=n<<24>>24<0?t[_>>2]|0:_;t:do{if(o<<24>>24<0){if(!e)break;if(wt(l,n,e)|0){y=70;break n}}else{if(!e)break;if((a&255)<<24>>24==(f[n>>0]|0)){a=o&255;l=u}else{y=70;break n}while(1){a=a+-1|0;l=l+1|0;if(!a)break t;n=n+1|0;if((f[l>>0]|0)!=(f[n>>0]|0)){y=70;break n}}}}while(0);qi(u,_);n=t[(Wr(T,M+16|0,c)|0)>>2]|0;if(!n){y=72;break i}t[C+(t[n+28>>2]<<2)>>2]=0;mi(12,x|0,t[u+96>>2]|0,t[w+96>>2]|0)|0}else y=70}while(0);if((y|0)==70){g=hr(_)|0;mi(12,x|0,g|0,t[w+96>>2]|0)|0}n=A+1|0;g=t[i+100>>2]|0;_=t[g+(n<<2)>>2]|0;a=g;s=g;c=g;h=g;y=g;m=_;l=E;u=T;break r}}while(0);n=hr(_)|0;mi(12,x|0,n|0,t[w+96>>2]|0)|0;n=A+1|0;g=t[i+100>>2]|0;_=t[g+(n<<2)>>2]|0;a=g;s=g;c=g;h=g;y=g;m=_;l=E;u=T}}while(0);e=(r|0)>(l|0);o=(n|0)>(b|0);if(o|e)break e;else{o=y;e=g;A=n;E=l}}if((y|0)==61){M=xe(8)|0;ao(M,5328);t[M>>2]=3424;Fi(M|0,1008,95)}else if((y|0)==72){M=xe(8)|0;ao(M,5328);t[M>>2]=3424;Fi(M|0,1008,95)}}else{h=r;c=r;d=0;a=r;s=r;e=(u|0)<4;o=(l|0)<4;b=(l>>2)+-1|0;n=0;l=(u>>2)+-1|0;u=0;r=0}}while(0);e:do{if(e){r=b+1|0;o=n>>>0>b>>>0;if(r>>>0>(((t[i+104>>2]|0)-h>>2)+-1|0)>>>0){if(o)break;while(1){r=n+1|0;mi(13,x|0,hr(t[a+(n<<2)>>2]|0)|0,0)|0;if(r>>>0>b>>>0)break e;a=t[i+100>>2]|0;n=r}}else{l=t[(t[c+(r<<2)>>2]|0)+96>>2]|0;if(o)break;else a=s;while(1){r=n+1|0;mi(13,x|0,hr(t[a+(n<<2)>>2]|0)|0,l|0)|0;if(r>>>0>b>>>0)break e;a=t[i+100>>2]|0;n=r}}}else if(!(r>>>0>l>>>0|o^1))do{Pe(14,t[(t[C+(r<<2)>>2]|0)+96>>2]|0)|0;r=r+1|0}while(r>>>0<=l>>>0)}while(0);if(u|0){un(t[u+4>>2]|0);pu(d)}if(!C){k=M;return}pu(S);k=M;return}function Ki(e,i,r,n,l,o){e=e|0;i=+i;r=r|0;n=n|0;l=l|0;o=o|0;var u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0,T=0,A=0,E=0,C=0,S=0,M=0;M=k;k=k+560|0;S=M+524|0;t[M>>2]=0;C=M+512+12|0;Dl(i)|0;if((x|0)<0){A=1;T=13060;i=-i}else{A=(l&2049|0)!=0&1;T=(l&2048|0)==0?(l&1|0)==0?13061:13066:13063}Dl(i)|0;E=x&2146435072;do{if(E>>>0<2146435072|(E|0)==2146435072&0<0){d=+su(i,M)*2;if(d!=0)t[M>>2]=(t[M>>2]|0)+-1;if((o|32|0)==97){h=(o&32|0)==0?T:T+9|0;c=A|2;do{if(!(n>>>0>11|(12-n|0)==0)){u=12-n|0;i=8;do{u=u+-1|0;i=i*16}while((u|0)!=0);if((f[h>>0]|0)==45){i=-(i+(-d-i));break}else{i=d+i-i;break}}else i=d}while(0);s=t[M>>2]|0;u=(s|0)<0?0-s|0:s;u=jn(u,((u|0)<0)<<31>>31,C)|0;if((u|0)==(C|0)){f[M+512+11>>0]=48;u=M+512+11|0}f[u+-1>>0]=(s>>31&2)+43;b=u+-2|0;f[b>>0]=o+15;s=M+524|0;while(1){E=~~i;u=s+1|0;f[s>>0]=a[13091+E>>0]|o&32;i=(i-+(E|0))*16;if((u-S|0)==1?!((l&8|0)==0&((n|0)<1&i==0)):0){f[u>>0]=46;u=s+2|0}if(!(i!=0))break;else s=u}S=u-S|0;u=(n|0)!=0&(S+-2|0)<(n|0)?n+2|0:S;$n(e,32,r,C-b+c+u|0,l);wo(e,h,c);$n(e,48,r,C-b+c+u|0,l^65536);wo(e,M+524|0,S);$n(e,48,u-S|0,0,0);wo(e,b,C-b|0);$n(e,32,r,C-b+c+u|0,l^8192);u=C-b+c+u|0;break}s=(n|0)<0?6:n;if(d!=0){b=(t[M>>2]|0)+-28|0;t[M>>2]=b;i=d*268435456}else{b=t[M>>2]|0;i=d}E=(b|0)<0?M+8|0:M+8+288|0;c=E;do{y=~~i>>>0;t[c>>2]=y;c=c+4|0;i=(i-+(y>>>0))*1e9}while(i!=0);if((b|0)>0){u=E;do{n=(b|0)<29?b:29;b=c+-4|0;if(b>>>0>=u>>>0){h=0;do{m=fl(t[b>>2]|0,0,n|0)|0;m=Wl(m|0,x|0,h|0,0)|0;y=x;p=Aa(m|0,y|0,1e9,0)|0;t[b>>2]=p;h=po(m|0,y|0,1e9,0)|0;b=b+-4|0}while(b>>>0>=u>>>0);if(h){u=u+-4|0;t[u>>2]=h}}while(1){if(c>>>0<=u>>>0)break;b=c+-4|0;if(!(t[b>>2]|0))c=b;else break}b=(t[M>>2]|0)-n|0;t[M>>2]=b}while((b|0)>0)}else u=E;if((b|0)<0){do{n=0-b|0;n=(n|0)<9?n:9;if(u>>>0<c>>>0){h=0;b=u;do{y=t[b>>2]|0;t[b>>2]=(y>>>n)+h;h=z(y&(1<<n)+-1,1e9>>>n)|0;b=b+4|0}while(b>>>0<c>>>0);u=(t[u>>2]|0)==0?u+4|0:u;if(!h)b=c;else{t[c>>2]=h;b=c+4|0}}else{u=(t[u>>2]|0)==0?u+4|0:u;b=c}c=(o|32|0)==102?E:u;c=(b-c>>2|0)>(((s+25|0)/9|0)+1|0)?c+(((s+25|0)/9|0)+1<<2)|0:b;b=(t[M>>2]|0)+n|0;t[M>>2]=b}while((b|0)<0);_=c}else _=c;if(u>>>0<_>>>0){b=(E-u>>2)*9|0;h=t[u>>2]|0;if(h>>>0<10)c=b;else{c=10;do{c=c*10|0;b=b+1|0}while(h>>>0>=c>>>0);c=b}}else c=0;n=s-((o|32|0)!=102?c:0)+(((s|0)!=0&(o|32|0)==103)<<31>>31)|0;if((n|0)<(((_-E>>2)*9|0)+-9|0)){b=E+4+(((n+9216|0)/9|0)+-1024<<2)|0;if((((n+9216|0)%9|0)+1|0)<9){h=10;n=((n+9216|0)%9|0)+1|0;do{h=h*10|0;n=n+1|0}while((n|0)!=9)}else h=10;w=t[b>>2]|0;v=(w>>>0)%(h>>>0)|0;n=(b+4|0)==(_|0);if(!(n&(v|0)==0)){d=(((w>>>0)/(h>>>0)|0)&1|0)==0?9007199254740992:9007199254740994;y=(h|0)/2|0;i=v>>>0<y>>>0?.5:n&(v|0)==(y|0)?1:1.5;if(A){y=(f[T>>0]|0)==45;d=y?-d:d;i=y?-i:i}t[b>>2]=w-v;if(d+i!=d){y=w-v+h|0;t[b>>2]=y;if(y>>>0>999999999)while(1){c=b+-4|0;t[b>>2]=0;if(c>>>0<u>>>0){u=u+-4|0;t[u>>2]=0}y=(t[c>>2]|0)+1|0;t[c>>2]=y;if(y>>>0>999999999)b=c;else{b=c;break}}c=(E-u>>2)*9|0;n=t[u>>2]|0;if(n>>>0>=10){h=10;do{h=h*10|0;c=c+1|0}while(n>>>0>=h>>>0)}}}m=b+4|0;y=u;u=_>>>0>m>>>0?m:_}else{y=u;u=_}m=u;while(1){if(m>>>0<=y>>>0){p=0;break}u=m+-4|0;if(!(t[u>>2]|0))m=u;else{p=1;break}}n=0-c|0;do{if((o|32|0)==103){_=(c|0)>-5?((((s|0)!=0^1)&1)+s|0)>(c|0):0;h=(_?-1:-2)+o|0;s=(((s|0)!=0^1)&1)+s+-1+(_?n:0)|0;if(!(l&8)){if(p?(g=t[m+-4>>2]|0,(g|0)!=0):0)if(!((g>>>0)%10|0)){b=10;u=0;do{b=b*10|0;u=u+1|0}while(!((g>>>0)%(b>>>0)|0|0))}else u=0;else u=9;b=((m-E>>2)*9|0)+-9|0;if((h|32|0)==102){b=b-u|0;b=(b|0)>0?b:0;v=0;s=(s|0)<(b|0)?s:b;b=h;break}else{b=b+c-u|0;b=(b|0)>0?b:0;v=0;s=(s|0)<(b|0)?s:b;b=h;break}}else{v=l&8;b=h}}else{v=l&8;b=o}}while(0);w=s|v;h=(b|32|0)==102;if(h){_=0;u=(c|0)>0?c:0}else{u=(c|0)<0?n:c;u=jn(u,((u|0)<0)<<31>>31,C)|0;if((C-u|0)<2)do{u=u+-1|0;f[u>>0]=48}while((C-u|0)<2);f[u+-1>>0]=(c>>31&2)+43;u=u+-2|0;f[u>>0]=b;_=u;u=C-u|0}u=A+1+s+((w|0)!=0&1)+u|0;$n(e,32,r,u,l);wo(e,T,A);$n(e,48,r,u,l^65536);if(h){h=y>>>0>E>>>0?E:y;c=h;do{b=jn(t[c>>2]|0,0,M+524+9|0)|0;if((c|0)==(h|0)){if((b|0)==(M+524+9|0)){f[M+524+8>>0]=48;b=M+524+8|0}}else if(b>>>0>(M+524|0)>>>0){Df(M+524|0,48,b-S|0)|0;do{b=b+-1|0}while(b>>>0>(M+524|0)>>>0)}wo(e,b,M+524+9-b|0);c=c+4|0}while(c>>>0<=E>>>0);if(w|0)wo(e,16046,1);if((s|0)>0&c>>>0<m>>>0)while(1){b=jn(t[c>>2]|0,0,M+524+9|0)|0;if(b>>>0>(M+524|0)>>>0){Df(M+524|0,48,b-S|0)|0;do{b=b+-1|0}while(b>>>0>(M+524|0)>>>0)}wo(e,b,(s|0)<9?s:9);c=c+4|0;b=s+-9|0;if(!((s|0)>9&c>>>0<m>>>0)){s=b;break}else s=b}$n(e,48,s+9|0,9,0)}else{w=p?m:y+4|0;if((s|0)>-1){n=(v|0)==0;h=y;do{b=jn(t[h>>2]|0,0,M+524+9|0)|0;if((b|0)==(M+524+9|0)){f[M+524+8>>0]=48;b=M+524+8|0}do{if((h|0)==(y|0)){c=b+1|0;wo(e,b,1);if(n&(s|0)<1){b=c;break}wo(e,16046,1);b=c}else{if(b>>>0<=(M+524|0)>>>0)break;Df(M+524|0,48,b+(0-S)|0)|0;do{b=b+-1|0}while(b>>>0>(M+524|0)>>>0)}}while(0);E=M+524+9-b|0;wo(e,b,(s|0)>(E|0)?E:s);s=s-E|0;h=h+4|0}while(h>>>0<w>>>0&(s|0)>-1)}$n(e,48,s+18|0,18,0);wo(e,_,C-_|0)}$n(e,32,r,u,l^8192)}else{u=A+3|0;$n(e,32,r,u,l&-65537);wo(e,T,A);wo(e,i!=i|0!=0?o&32|0?14999:13087:o&32|0?13079:13083,3);$n(e,32,r,u,l^8192)}}while(0);k=M;return((u|0)<(r|0)?r:u)|0}function Ji(e,i,r,a,l){e=e|0;i=i|0;r=r|0;a=a|0;l=l|0;var o=0,u=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0,T=0,A=0;A=k;k=k+64|0;t[A+16>>2]=i;T=A+24+40|0;w=i;i=0;o=0;c=0;e:while(1){do{if((i|0)>-1)if((o|0)>(2147483647-i|0)){t[4223]=75;i=-1;break}else{i=o+i|0;break}}while(0);o=f[w>>0]|0;if(!(o<<24>>24)){g=87;break}else u=w;i:while(1){switch(o<<24>>24){case 37:{o=u;g=9;break i}case 0:{o=u;break i}default:{}}y=u+1|0;t[A+16>>2]=y;o=f[y>>0]|0;u=y}i:do{if((g|0)==9)while(1){g=0;if((f[o+1>>0]|0)!=37)break i;u=u+1|0;o=o+2|0;t[A+16>>2]=o;if((f[o>>0]|0)==37)g=9;else break}}while(0);u=u-w|0;if(e|0)wo(e,w,u);if(u|0){w=o;o=u;continue}b=o+1|0;u=(f[b>>0]|0)+-48|0;if(u>>>0<10){y=(f[o+2>>0]|0)==36;_=y?u:-1;d=y?1:c;b=y?o+3|0:b}else{_=-1;d=c}t[A+16>>2]=b;o=f[b>>0]|0;i:do{if(((o<<24>>24)+-32|0)>>>0<32){h=o;c=0;u=(o<<24>>24)+-32|0;while(1){o=1<<u;if(!(o&75913)){o=h;h=c;break i}c=c|o;b=b+1|0;t[A+16>>2]=b;o=f[b>>0]|0;u=(o<<24>>24)+-32|0;if(u>>>0>=32){h=c;break}else h=o}}else h=0}while(0);if(o<<24>>24==42){u=b+1|0;o=(f[u>>0]|0)+-48|0;if(o>>>0<10?(f[b+2>>0]|0)==36:0){t[l+(o<<2)>>2]=10;c=1;o=b+3|0;u=t[a+((f[u>>0]|0)+-48<<3)>>2]|0}else{if(d|0){i=-1;break}if(e|0){c=(t[r>>2]|0)+(4-1)&~(4-1);y=t[c>>2]|0;t[r>>2]=c+4;c=0;o=u;u=y}else{c=0;o=u;u=0}}t[A+16>>2]=o;m=(u|0)<0;b=o;v=m?h|8192:h;y=c;m=m?0-u|0:u}else{o=Wt(A+16|0)|0;if((o|0)<0){i=-1;break}b=t[A+16>>2]|0;v=h;y=d;m=o}do{if((f[b>>0]|0)==46){o=b+1|0;if((f[o>>0]|0)!=42){t[A+16>>2]=o;h=Wt(A+16|0)|0;o=t[A+16>>2]|0;break}o=b+2|0;u=(f[o>>0]|0)+-48|0;if(u>>>0<10?(f[b+3>>0]|0)==36:0){t[l+(u<<2)>>2]=10;h=t[a+((f[o>>0]|0)+-48<<3)>>2]|0;o=b+4|0;t[A+16>>2]=o;break}if(y|0){i=-1;break e}if(e|0){p=(t[r>>2]|0)+(4-1)&~(4-1);u=t[p>>2]|0;t[r>>2]=p+4}else u=0;t[A+16>>2]=o;h=u}else{o=b;h=-1}}while(0);d=0;while(1){if(((f[o>>0]|0)+-65|0)>>>0>57){i=-1;break e}p=o+1|0;t[A+16>>2]=p;u=f[(f[o>>0]|0)+-65+(12586+(d*58|0))>>0]|0;if(((u&255)+-1|0)>>>0<8){o=p;d=u&255}else break}if(!(u<<24>>24)){i=-1;break}b=(_|0)>-1;do{if(u<<24>>24==19)if(b){i=-1;break e}else g=49;else{if(b){t[l+(_<<2)>>2]=u&255;_=a+(_<<3)|0;g=t[_+4>>2]|0;t[A>>2]=t[_>>2];t[A+4>>2]=g;g=49;break}if(!e){i=0;break e}Dr(A,u&255,r)}}while(0);if((g|0)==49?(g=0,(e|0)==0):0){w=p;o=0;c=y;continue}c=f[o>>0]|0;c=(d|0)!=0&(c&15|0)==3?c&-33:c;u=v&-65537;_=(v&8192|0)==0?v:u;i:do{switch(c|0){case 110:switch((d&255)<<24>>24){case 0:{t[t[A>>2]>>2]=i;w=p;o=0;c=y;continue e}case 1:{t[t[A>>2]>>2]=i;w=p;o=0;c=y;continue e}case 2:{w=t[A>>2]|0;t[w>>2]=i;t[w+4>>2]=((i|0)<0)<<31>>31;w=p;o=0;c=y;continue e}case 3:{n[t[A>>2]>>1]=i;w=p;o=0;c=y;continue e}case 4:{f[t[A>>2]>>0]=i;w=p;o=0;c=y;continue e}case 6:{t[t[A>>2]>>2]=i;w=p;o=0;c=y;continue e}case 7:{w=t[A>>2]|0;t[w>>2]=i;t[w+4>>2]=((i|0)<0)<<31>>31;w=p;o=0;c=y;continue e}default:{w=p;o=0;c=y;continue e}}case 112:{o=_|8;u=h>>>0>8?h:8;c=120;g=61;break}case 88:case 120:{o=_;u=h;g=61;break}case 111:{w=t[A>>2]|0;v=t[A+4>>2]|0;u=ra(w,v,T)|0;d=u;o=_;u=(_&8|0)==0|(h|0)>(T-u|0)?h:T-u+1|0;b=0;h=13050;g=67;break}case 105:case 100:{o=t[A>>2]|0;u=t[A+4>>2]|0;if((u|0)<0){o=ol(0,0,o|0,u|0)|0;u=x;t[A>>2]=o;t[A+4>>2]=u;b=1;c=13050;g=66;break i}else{b=(_&2049|0)!=0&1;c=(_&2048|0)==0?(_&1|0)==0?13050:13052:13051;g=66;break i}}case 117:{o=t[A>>2]|0;u=t[A+4>>2]|0;b=0;c=13050;g=66;break}case 99:{f[A+24+39>>0]=t[A>>2];w=A+24+39|0;d=u;c=1;b=0;u=13050;o=T;break}case 109:{o=lu(t[4223]|0)|0;g=71;break}case 115:{o=t[A>>2]|0;o=o|0?o:15120;g=71;break}case 67:{t[A+8>>2]=t[A>>2];t[A+8+4>>2]=0;t[A>>2]=A+8;o=A+8|0;h=-1;g=75;break}case 83:{o=t[A>>2]|0;if(!h){$n(e,32,m,0,_);o=0;g=84}else g=75;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{w=p;o=Ki(e,+s[A>>3],m,h,_,c)|0;c=y;continue e}default:{d=_;c=h;b=0;u=13050;o=T}}}while(0);i:do{if((g|0)==61){w=t[A>>2]|0;v=t[A+4>>2]|0;d=Gt(w,v,T,c&32)|0;h=(o&8|0)==0|(w|0)==0&(v|0)==0;b=h?0:2;h=h?13050:13050+(c>>4)|0;g=67}else if((g|0)==66){w=o;v=u;d=jn(o,u,T)|0;o=_;u=h;h=c;g=67}else if((g|0)==71){g=0;_=cf(o,h)|0;w=o;d=u;c=(_|0)==0?h:_-o|0;b=0;u=13050;o=(_|0)==0?o+h|0:_}else if((g|0)==75){g=0;b=0;u=0;d=o;while(1){c=t[d>>2]|0;if(!c)break;u=vo(A+20|0,c)|0;if((u|0)<0|u>>>0>(h-b|0)>>>0)break;b=u+b|0;if(h>>>0>b>>>0)d=d+4|0;else break}if((u|0)<0){i=-1;break e}$n(e,32,m,b,_);if(!b){o=0;g=84}else{c=0;while(1){u=t[o>>2]|0;if(!u){o=b;g=84;break i}u=vo(A+20|0,u)|0;c=u+c|0;if((c|0)>(b|0)){o=b;g=84;break i}wo(e,A+20|0,u);if(c>>>0>=b>>>0){o=b;g=84;break}else o=o+4|0}}}}while(0);if((g|0)==67){g=0;c=(w|0)!=0|(v|0)!=0;_=c|(u|0)!=0;c=T-d+((c^1)&1)|0;w=_?d:T;d=(u|0)>-1?o&-65537:o;c=_?(u|0)>(c|0)?u:c:u;u=h;o=T}else if((g|0)==84){g=0;$n(e,32,m,o,_^8192);w=p;o=(m|0)>(o|0)?m:o;c=y;continue}_=o-w|0;v=(c|0)<(_|0)?_:c;c=v+b|0;o=(m|0)<(c|0)?c:m;$n(e,32,o,c,d);wo(e,u,b);$n(e,48,o,c,d^65536);$n(e,48,v,_,0);wo(e,w,_);$n(e,32,o,c,d^8192);w=p;c=y}e:do{if((g|0)==87)if(!e)if(!c)i=0;else{i=1;while(1){o=t[l+(i<<2)>>2]|0;if(!o)break;Dr(a+(i<<3)|0,o,r);i=i+1|0;if((i|0)>=10){i=1;break e}}while(1){i=i+1|0;if((i|0)>=10){i=1;break e}if(t[l+(i<<2)>>2]|0){i=-1;break}}}}while(0);k=A;return i|0}function Yi(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;if((t[e+48>>2]|0)==0?(t[i+48>>2]|0)==0:0)return;r=t[e+44>>2]|0;if(r|0)do{n=r+8|0;if(!(dr(i+36|0,n)|0)){if((f[n+11>>0]|0)<0)n=t[n>>2]|0;di(0,t[i+96>>2]|0,n|0)|0}r=t[r>>2]|0}while((r|0)!=0);r=t[i+44>>2]|0;if(!r)return;do{p=r;e:do{if(dr(e+36|0,p+8|0)|0){w=f[p+8+11>>0]|0;v=w<<24>>24<0?t[p+8>>2]|0:p+8|0;w=w<<24>>24<0?t[p+12>>2]|0:w&255;if(w>>>0>3){l=v;n=w;o=w;while(1){_=z(a[l>>0]|a[l+1>>0]<<8|a[l+2>>0]<<16|a[l+3>>0]<<24,1540483477)|0;n=(z(_>>>24^_,1540483477)|0)^(z(n,1540483477)|0);o=o+-4|0;if(o>>>0<=3)break;else l=l+4|0}o=v+((w+-4&-4)+4)|0;l=w+-4-(w+-4&-4)|0}else{o=v;n=w;l=w}switch(l|0){case 3:{n=a[o+2>>0]<<16^n;m=20;break}case 2:{m=20;break}case 1:{m=21;break}default:{}}if((m|0)==20){n=a[o+1>>0]<<8^n;m=21}if((m|0)==21){m=0;n=z(a[o>>0]^n,1540483477)|0}_=z(n>>>13^n,1540483477)|0;d=t[e+40>>2]|0;i:do{if(d){if(d+-1&d)if((_>>>15^_)>>>0<d>>>0)n=_>>>15^_;else n=((_>>>15^_)>>>0)%(d>>>0)|0;else n=(_>>>15^_)&d+-1;l=t[(t[e+36>>2]|0)+(n<<2)>>2]|0;if((l|0)!=0?(y=t[l>>2]|0,(y|0)!=0):0){if(!(d+-1&d)){if(!w){l=y;while(1){v=t[l+4>>2]|0;if(!((v|0)==(_>>>15^_|0)|(v&d+-1|0)==(n|0))){m=62;break i}v=f[l+8+11>>0]|0;if(!((v<<24>>24<0?t[l+12>>2]|0:v&255)|0)){n=l;break i}l=t[l>>2]|0;if(!l){m=62;break i}}}else k=y;while(1){h=t[k+4>>2]|0;if(!((h|0)==(_>>>15^_|0)|(h&d+-1|0)==(n|0))){m=62;break i}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0)){n=k;break i}else break;if((o&255)<<24>>24!=(f[v>>0]|0))break;b=l&255;l=h;o=v;do{b=b+-1|0;l=l+1|0;if(!b){n=k;break i}o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}while(0);k=t[k>>2]|0;if(!k){m=62;break i}}}if(!w){o=y;while(1){l=t[o+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){m=62;break i}}v=f[o+8+11>>0]|0;if(!((v<<24>>24<0?t[o+12>>2]|0:v&255)|0)){n=o;break i}o=t[o>>2]|0;if(!o){m=62;break i}}}else k=y;while(1){l=t[k+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){m=62;break i}}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0)){n=k;break i}else break;if((o&255)<<24>>24==(f[v>>0]|0)){b=l&255;l=h;o=v;do{b=b+-1|0;l=l+1|0;if(!b){n=k;break i}o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);k=t[k>>2]|0;if(!k){m=62;break}}}else m=62}else{n=0;m=62}}while(0);if((m|0)==62){m=0;b=Vt(32)|0;$f(b+8|0,p+8|0);t[b+20>>2]=0;t[b+20+4>>2]=0;t[b+20+8>>2]=0;t[b+4>>2]=_>>>15^_;t[b>>2]=0;c=+(((t[e+48>>2]|0)+1|0)>>>0);s=+u[e+52>>2];do{if((d|0)==0|c>+(d>>>0)*s){n=~~+j(+(c/s))>>>0;uf(e+36|0,((d>>>0<3|(d+-1&d|0)!=0)&1|d<<1)>>>0<n>>>0?n:(d>>>0<3|(d+-1&d|0)!=0)&1|d<<1);n=t[e+40>>2]|0;if(!(n+-1&n)){o=n;n=n+-1&(_>>>15^_);break}if((_>>>15^_)>>>0<n>>>0){o=n;n=_>>>15^_}else{o=n;n=((_>>>15^_)>>>0)%(n>>>0)|0}}else o=d}while(0);l=(t[e+36>>2]|0)+(n<<2)|0;n=t[l>>2]|0;if(!n){t[b>>2]=t[e+44>>2];t[e+44>>2]=b;t[l>>2]=e+44;n=t[b>>2]|0;if(n|0){n=t[n+4>>2]|0;l=o+-1|0;if(l&o){if(n>>>0>=o>>>0)n=(n>>>0)%(o>>>0)|0}else n=n&l;n=(t[e+36>>2]|0)+(n<<2)|0;m=75}}else{t[b>>2]=t[n>>2];m=75}if((m|0)==75){m=0;t[n>>2]=b}t[e+48>>2]=(t[e+48>>2]|0)+1;n=b}b=n+20|0;v=f[b+11>>0]|0;d=v<<24>>24<0?t[n+24>>2]|0:v&255;h=p+20+11|0;o=f[h>>0]|0;l=t[p+24>>2]|0;if((d|0)==((o<<24>>24<0?l:o&255)|0)){k=t[b>>2]|0;w=v<<24>>24<0?k:b;n=o<<24>>24<0?t[p+20>>2]|0:p+20|0;if(v<<24>>24<0){if(!d)break;if(!(wt(w,n,d)|0))break;else{n=p+20|0;m=85;break}}if(d|0)if((k&255)<<24>>24==(f[n>>0]|0)){k=v&255;while(1){k=k+-1|0;b=b+1|0;if(!k)break e;n=n+1|0;if((f[b>>0]|0)!=(f[n>>0]|0)){n=p+20|0;m=85;break}}}else{n=p+20|0;m=85}}else{n=p+20|0;m=85}}else{o=f[p+20+11>>0]|0;l=t[p+24>>2]|0;h=p+20+11|0;n=p+20|0;m=85}}while(0);do{if((m|0)==85){m=0;if(((o<<24>>24<0?l:o&255)|0)==5)l=(En(n,16060,5)|0)==0;else l=0;o=t[i+96>>2]|0;if((f[p+8+11>>0]|0)<0)b=t[p+8>>2]|0;else b=p+8|0;if(l){di(0,o|0,b|0)|0;break}if((f[h>>0]|0)<0)n=t[p+20>>2]|0;mi(1,o|0,b|0,n|0)|0}}while(0);r=t[r>>2]|0}while((r|0)!=0);return}function Xi(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0;w=k;k=k+80|0;b=Vt(20)|0;Vl(b);t[b+12>>2]=1114111;t[b+16>>2]=0;t[b>>2]=1820;t[w+8>>2]=0;t[w+8+4>>2]=0;t[w+8+8>>2]=0;t[w+8+12>>2]=0;t[w+8+16>>2]=0;t[w+8+20>>2]=0;t[w+8+24>>2]=b;t[w+8+28>>2]=0;t[w+8+28+4>>2]=0;c=w+8+36|0;h=f[i+8+3>>0]|0;d=h<<24>>24<0?t[i>>2]|0:i;h=h<<24>>24<0?t[i+4>>2]|0:h&255;t[c>>2]=0;e:do{if(b){t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;if(h<<2>>1>>>0>4294967279)au();if(h<<2>>1>>>0<11){f[e+11>>0]=h<<2>>1;if(!(h<<2>>1))i=e;else{i=e;a=7}}else{i=Vt((h<<2>>1)+16&-16)|0;t[e>>2]=i;t[e+8>>2]=(h<<2>>1)+16&-16|-2147483648;t[e+4>>2]=h<<2>>1;a=7}if((a|0)==7)Df(i|0,0,h<<2>>1|0)|0;f[i+(h<<2>>1)>>0]=0;do{if(h){if((f[e+11>>0]|0)<0)i=(t[e+8>>2]&2147483647)+-1|0;else i=10;vn(e,i);i=t[w+8+28+4>>2]|0;t[w>>2]=t[w+8+28>>2];t[w+4>>2]=i;i=f[e+11>>0]|0;if(i<<24>>24<0){s=e+4|0;n=t[e>>2]|0;i=t[e+4>>2]|0}else{s=e+4|0;n=e;i=i&255}u=t[w+8+24>>2]|0;r=d;l=n;i=n+i|0;o=t[c>>2]|0;i:while(1){i=Nu[t[(t[u>>2]|0)+12>>2]&7](u,w,r,d+(h<<2)|0,w+52|0,l,i,w+48|0)|0;a=t[w+52>>2]|0;b=r;o=(a-b>>2)+o|0;if((a|0)==(r|0)){a=61;break}switch(i|0){case 3:{a=18;break i}case 0:{a=50;break i}case 1:break;default:{a=61;break i}}if((f[e+11>>0]|0)<0)i=t[e>>2]|0;else i=e;n=(t[w+48>>2]|0)-i|0;vn(e,n<<1);i=f[e+11>>0]|0;if(i<<24>>24<0){a=t[e>>2]|0;i=t[s>>2]|0}else{a=e;i=i&255}r=t[w+52>>2]|0;if(r>>>0>=(d+(h<<2)|0)>>>0){a=59;break}else{l=a+n|0;i=a+i|0}}if((a|0)==18){t[c>>2]=o;if((f[e+11>>0]|0)<0)i=t[e>>2]|0;else i=e;vn(e,l-i|0);i=f[e+11>>0]|0;if(i<<24>>24<0){o=t[e+4>>2]|0;a=(t[e+8>>2]&2147483647)+-1|0}else{o=i&255;a=10}u=d+(h<<2)-b|0;do{if(u|0){if(i<<24>>24<0){n=t[e>>2]|0;l=t[e+4>>2]|0}else{n=e;l=i&255}if(!(n>>>0<=r>>>0&(n+l|0)>>>0>r>>>0)){if((a-o|0)>>>0<u>>>0){rn(e,a,o+u-a|0,o,o);i=f[e+11>>0]|0}if(i<<24>>24<0)a=t[e>>2]|0;else a=e;i=a+o|0;if((r|0)!=(d+(h<<2)|0)){n=o-b|0;while(1){f[i>>0]=f[r>>0]|0;r=r+1|0;if((r|0)==(d+(h<<2)|0))break;else i=i+1|0}i=a+(d+(h<<2)+n)|0}f[i>>0]=0;i=o+u|0;if((f[e+11>>0]|0)<0){t[e+4>>2]=i;break}else{f[e+11>>0]=i;break}}else{t[w+56>>2]=0;t[w+56+4>>2]=0;t[w+56+8>>2]=0;if(u>>>0>4294967279)au();if(u>>>0<11){f[w+56+11>>0]=u;i=w+56|0}else{i=Vt(u+16&-16)|0;t[w+56>>2]=i;t[w+56+8>>2]=u+16&-16|-2147483648;t[w+56+4>>2]=u}if((r|0)!=(d+(h<<2)|0)){n=i;while(1){f[n>>0]=f[r>>0]|0;r=r+1|0;if((r|0)==(d+(h<<2)|0))break;else n=n+1|0}i=i+u|0}f[i>>0]=0;d=f[w+56+11>>0]|0;i=t[w+56>>2]|0;qf(e,d<<24>>24<0?i:w+56|0,d<<24>>24<0?t[w+56+4>>2]|0:d&255)|0;if(d<<24>>24<0)pu(i);break}}}while(0);o=w;u=e+11|0;a=62;break}else if((a|0)==50){t[c>>2]=o;if((f[e+11>>0]|0)<0)i=t[e>>2]|0;else i=e;vn(e,(t[w+48>>2]|0)-i|0);o=w;u=e+11|0;a=62;break}else if((a|0)==59){t[c>>2]=o;i=e+11|0;break}else if((a|0)==61){t[c>>2]=o;i=e+11|0;break}}else{o=t[w+8+28+4>>2]|0;t[w>>2]=t[w+8+28>>2];t[w+4>>2]=o;o=w;u=e+11|0;a=62}}while(0);do{if((a|0)==62){i=f[u>>0]|0;if(i<<24>>24<0){n=t[e+4>>2]|0;i=(t[e+8>>2]&2147483647)+-1|0}else{n=i&255;i=10}vn(e,i);i=f[u>>0]|0;if(i<<24>>24<0){r=t[e>>2]|0;l=e+4|0;a=t[e+4>>2]|0}else{r=e;l=e+4|0;a=i&255}r=r+n|0;i=t[w+8+24>>2]|0;n=r;r=r+a|0;i:while(1){switch(Hu[t[(t[i>>2]|0)+20>>2]&7](i,w,n,r,w+56|0)|0){case 3:{a=70;break i}case 0:{a=73;break i}case 1:break;default:{a=82;break i}}if((f[u>>0]|0)<0)r=t[e>>2]|0;else r=e;n=(t[w+56>>2]|0)-r|0;vn(e,n<<1);r=f[u>>0]|0;if(r<<24>>24<0){a=t[e>>2]|0;r=t[l>>2]|0}else{a=e;r=r&255}n=a+n|0;r=a+r|0}if((a|0)==70){if((f[u>>0]|0)<0)r=t[e>>2]|0;else r=e;vn(e,n-r|0)}else if((a|0)==73){if((f[u>>0]|0)<0)r=t[e>>2]|0;else r=e;vn(e,(t[w+56>>2]|0)-r|0)}else if((a|0)==82){i=u;break}break e}}while(0);if((f[i>>0]|0)<0){pu(t[e>>2]|0);a=86}else a=86}else a=86}while(0);do{if((a|0)==86){d=f[w+8+11>>0]|0;if(!((d<<24>>24<0?t[w+8+4>>2]|0:d&255)|0)){w=xe(8)|0;io(w,7897);t[w>>2]=3444;Fi(w|0,1024,97)}else{$f(e,w+8|0);i=t[w+8+24>>2]|0;break}}}while(0);if(i|0)Fu[t[(t[i>>2]|0)+4>>2]&127](i);if((f[w+8+20+3>>0]|0)<0)pu(t[w+8+12>>2]|0);if((f[w+8+11>>0]|0)>=0){k=w;return}pu(t[w+8>>2]|0);k=w;return}function Zi(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;y=k;k=k+80|0;t[y+8>>2]=t[r>>2];m=y+8+4|0;t[m>>2]=t[r+4>>2];t[m+4>>2]=t[r+4+4>>2];t[m+8>>2]=t[r+4+8>>2];t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;n[y+8+16>>1]=n[r+16>>1]|0;p=y+8+20|0;t[p>>2]=t[r+20>>2];t[p+4>>2]=t[r+20+4>>2];t[p+8>>2]=t[r+20+8>>2];t[r+20>>2]=0;t[r+20+4>>2]=0;t[r+20+8>>2]=0;f[y+8+17>>0]=1;_=Vt(20)|0;Vl(_);t[_+12>>2]=1114111;t[_+16>>2]=0;t[_>>2]=1820;d=f[m+11>>0]|0;w=d<<24>>24<0?t[m>>2]|0:m;d=d<<24>>24<0?t[y+8+8>>2]|0:d&255;if(!_){y=xe(8)|0;io(y,9614);t[y>>2]=3444;Fi(y|0,1024,97)}t[y+40>>2]=0;t[y+40+4>>2]=0;t[y+40+8>>2]=0;if(d<<1>>>0>1073741807)au();do{if(d<<1>>>0<2){f[y+40+8+3>>0]=d<<1;if(!d){t[y+40+(d<<1<<2)>>2]=0;a=65}else{i=y+40|0;a=10}}else if(((d<<1)+4&-4)>>>0>1073741823){y=xe(8)|0;ao(y,7681);t[y>>2]=3404;Fi(y|0,992,95)}else{i=Vt(((d<<1)+4&-4)<<2)|0;t[y+40>>2]=i;t[y+40+8>>2]=(d<<1)+4&-4|-2147483648;t[y+40+4>>2]=d<<1;a=10;break}}while(0);e:do{if((a|0)==10){Ga(i,d<<1)|0;t[i+(d<<1<<2)>>2]=0;if(!d)a=65;else{v=y+40+8+3|0;if((f[v>>0]|0)<0)i=(t[y+40+8>>2]&2147483647)+-1|0;else i=1;kn(y+40|0,i);t[y>>2]=0;t[y+4>>2]=0;i=f[v>>0]|0;if(i<<24>>24<0){b=y+40|0;s=y+40+4|0;c=y+40|0;a=t[y+40>>2]|0;i=t[y+40+4>>2]|0}else{b=y+40|0;s=y+40+4|0;c=y+40|0;a=y+40|0;i=i&255}r=w;u=a;i=a+(i<<2)|0;i:while(1){i=Nu[t[(t[_>>2]|0)+16>>2]&7](_,y,r,w+d|0,y+56|0,u,i,y+52|0)|0;h=r;if((t[y+56>>2]|0)==(r|0)){i=2;a=59;break}switch(i|0){case 3:{a=19;break i}case 0:{a=49;break i}case 1:break;default:{a=59;break i}}if((f[v>>0]|0)<0)i=t[b>>2]|0;else i=c;a=(t[y+52>>2]|0)-i|0;kn(y+40|0,a>>1);i=f[v>>0]|0;if(i<<24>>24<0){l=t[b>>2]|0;o=t[s>>2]|0}else{l=c;o=i&255}r=t[y+56>>2]|0;if(r>>>0<(w+d|0)>>>0){u=l+(a>>2<<2)|0;i=l+(o<<2)|0}else{a=58;break}}do{if((a|0)==19){if((f[v>>0]|0)<0)i=t[b>>2]|0;else i=c;kn(y+40|0,u-i>>2);i=f[v>>0]|0;if(i<<24>>24<0){a=(t[y+40+8>>2]&2147483647)+-1|0;o=t[y+40+4>>2]|0}else{a=1;o=i&255}u=w+d-h>>2;if(!u){i=0;a=59}else{c=i<<24>>24<0?t[y+40>>2]|0:y+40|0;if(!(c>>>0<=r>>>0?(c+((i<<24>>24<0?t[y+40+4>>2]|0:i&255)<<2)|0)>>>0>r>>>0:0)){if((a-o|0)>>>0<u>>>0){Wf(y+40|0,a,o+u-a|0,o,o);i=f[v>>0]|0}l=i<<24>>24<0;a=l?t[y+40>>2]|0:y+40|0;i=a+(o<<2)|0;if((r|0)!=(w+d|0)){while(1){t[i>>2]=t[r>>2];r=r+4|0;if((r|0)==(w+d|0))break;else i=i+4|0}i=a+(((w+d+-4-h|0)>>>2)+1+o<<2)|0}t[i>>2]=0;i=o+u|0;if(l){t[y+40+4>>2]=i;i=0;a=59;break}else{f[v>>0]=i;i=0;a=59;break}}t[y+60>>2]=0;t[y+60+4>>2]=0;t[y+60+8>>2]=0;if(u>>>0>1073741807)au();do{if(u>>>0>=2)if((u+4&-4)>>>0>1073741823){y=xe(8)|0;ao(y,7681);t[y>>2]=3404;Fi(y|0,992,95)}else{i=Vt((u+4&-4)<<2)|0;t[y+60>>2]=i;t[y+60+8>>2]=u+4&-4|-2147483648;t[y+60+4>>2]=u;o=(u+4&-4|-2147483648)>>>24&255;l=(u+4&-4|-2147483648)>>>24&255;break}else{f[y+60+8+3>>0]=u;o=1;l=u&255;i=y+60|0}}while(0);if((r|0)!=(w+d|0)){a=i;while(1){t[a>>2]=t[r>>2];r=r+4|0;if((r|0)==(w+d|0))break;else a=a+4|0}i=i+(((w+d+-4-h|0)>>>2)+1<<2)|0}t[i>>2]=0;w=o<<24>>24<0;i=t[y+60>>2]|0;Gf(y+40|0,w?i:y+60|0,w?t[y+60+4>>2]|0:o&255)|0;if(l<<24>>24<0)pu(i);i=0;a=59}}else if((a|0)==49){if((f[v>>0]|0)<0)i=t[b>>2]|0;else i=c;kn(y+40|0,(t[y+52>>2]|0)-i>>2);i=0;a=59}}while(0);do{if((a|0)==59)if(!i)if(!_)break e;else{a=65;break e}else{i=f[v>>0]|0;break}}while(0);if(i<<24>>24>=0){y=xe(8)|0;io(y,9614);t[y>>2]=3444;Fi(y|0,1024,97)}pu(t[y+40>>2]|0);y=xe(8)|0;io(y,9614);t[y>>2]=3444;Fi(y|0,1024,97)}}}while(0);if((a|0)==65)Fu[t[(t[_>>2]|0)+4>>2]&127](_);if((f[y+8+28+3>>0]|0)<0){t[t[p>>2]>>2]=0;t[y+8+24>>2]=0;ff(p);t[p>>2]=t[y+40>>2];t[p+4>>2]=t[y+40+4>>2];t[p+8>>2]=t[y+40+8>>2];v=t[y+8>>2]|0;_=n[y+8+16>>1]|0;t[e>>2]=v;v=e+4|0;t[v>>2]=t[m>>2];t[v+4>>2]=t[m+4>>2];t[v+8>>2]=t[m+8>>2];t[m>>2]=0;t[m+4>>2]=0;t[m+8>>2]=0;m=e+16|0;n[m>>1]=_;e=e+20|0;t[e>>2]=t[p>>2];t[e+4>>2]=t[p+4>>2];t[e+8>>2]=t[p+8>>2];k=y;return}else{t[p>>2]=0;f[y+8+28+3>>0]=0;ff(p);t[p>>2]=t[y+40>>2];t[p+4>>2]=t[y+40+4>>2];t[p+8>>2]=t[y+40+8>>2];v=t[y+8>>2]|0;_=n[y+8+16>>1]|0;t[e>>2]=v;v=e+4|0;t[v>>2]=t[m>>2];t[v+4>>2]=t[m+4>>2];t[v+8>>2]=t[m+8>>2];t[m>>2]=0;t[m+4>>2]=0;t[m+8>>2]=0;m=e+16|0;n[m>>1]=_;e=e+20|0;t[e>>2]=t[p>>2];t[e+4>>2]=t[p+4>>2];t[e+8>>2]=t[p+8>>2];k=y;return}}function Qi(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0;g=k;k=k+16|0;if((t[e+68>>2]|0)==0?(t[i+68>>2]|0)==0:0){k=g;return}r=Ke(4005)|0;d=Ei(4012)|0;v=Oe(r|0,d|0)|0;fi(d|0);d=Ei(4026)|0;w=Oe(v|0,d|0)|0;fi(d|0);t[g>>2]=t[i+96>>2];d=Xe(1152,g|0)|0;m=Oe(w|0,d|0)|0;fi(d|0);fi(w|0);fi(v|0);fi(r|0);r=t[e+64>>2]|0;if(r|0)do{n=r+8|0;if(!(dr(i+56|0,n)|0)){if((f[n+11>>0]|0)<0)n=t[n>>2]|0;v=Ei(n|0)|0;bi(m|0,v|0,1);fi(v|0);fi(1)}r=t[r>>2]|0}while((r|0)!=0);r=t[i+64>>2]|0;e:do{if(r|0){i:while(1){v=r;w=v+8+11|0;do{if(dr(e+56|0,v+8|0)|0){h=f[w>>0]|0;d=h<<24>>24<0?t[v+8>>2]|0:v+8|0;h=h<<24>>24<0?t[v+12>>2]|0:h&255;if(h>>>0>3){i=d;n=h;l=h;while(1){c=z(a[i>>0]|a[i+1>>0]<<8|a[i+2>>0]<<16|a[i+3>>0]<<24,1540483477)|0;n=(z(c>>>24^c,1540483477)|0)^(z(n,1540483477)|0);l=l+-4|0;if(l>>>0<=3)break;else i=i+4|0}l=d+((h+-4&-4)+4)|0;i=h+-4-(h+-4&-4)|0}else{l=d;n=h;i=h}switch(i|0){case 3:{n=a[l+2>>0]<<16^n;y=20;break}case 2:{y=20;break}case 1:{y=21;break}default:{}}if((y|0)==20){n=a[l+1>>0]<<8^n;y=21}if((y|0)==21){y=0;n=z(a[l>>0]^n,1540483477)|0}c=z(n>>>13^n,1540483477)|0;s=t[e+60>>2]|0;if(!s){y=65;break i}if(s+-1&s)if((c>>>15^c)>>>0<s>>>0)b=c>>>15^c;else b=((c>>>15^c)>>>0)%(s>>>0)|0;else b=(c>>>15^c)&s+-1;n=t[(t[e+56>>2]|0)+(b<<2)>>2]|0;if(!n){y=65;break i}n=t[n>>2]|0;if(!n){y=65;break i}r:do{if(!(s+-1&s)){if(!h)while(1){i=t[n+4>>2]|0;if(!((i|0)==(c>>>15^c|0)|(i&s+-1|0)==(b|0))){y=65;break i}if((i|0)==(c>>>15^c|0)?(d=f[n+8+11>>0]|0,((d<<24>>24<0?t[n+12>>2]|0:d&255)|0)==0):0)break r;n=t[n>>2]|0;if(!n){y=65;break i}}while(1){i=t[n+4>>2]|0;if(!((i|0)==(c>>>15^c|0)|(i&s+-1|0)==(b|0))){y=65;break i}do{if((i|0)==(c>>>15^c|0)?(p=n+8|0,_=f[p+11>>0]|0,((_<<24>>24<0?t[n+12>>2]|0:_&255)|0)==(h|0)):0){i=t[p>>2]|0;if(_<<24>>24<0)if(!(wt(i,d,h)|0))break r;else break;if((i&255)<<24>>24!=(f[d>>0]|0))break;i=_&255;l=p;o=d;do{i=i+-1|0;l=l+1|0;if(!i){y=64;break r}o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}while(0);n=t[n>>2]|0;if(!n){y=65;break i}}}else{if(!h)while(1){i=t[n+4>>2]|0;if((i|0)==(c>>>15^c|0)){d=f[n+8+11>>0]|0;if(!((d<<24>>24<0?t[n+12>>2]|0:d&255)|0))break r}else{if(i>>>0>=s>>>0)i=(i>>>0)%(s>>>0)|0;if((i|0)!=(b|0)){y=65;break i}}n=t[n>>2]|0;if(!n){y=65;break i}}while(1){i=t[n+4>>2]|0;do{if((i|0)==(c>>>15^c|0)){u=n+8|0;i=f[u+11>>0]|0;if(((i<<24>>24<0?t[n+12>>2]|0:i&255)|0)==(h|0)){l=t[u>>2]|0;if(i<<24>>24<0)if(!(wt(l,d,h)|0))break r;else break;if((l&255)<<24>>24!=(f[d>>0]|0))break;o=i&255;i=u;l=d;do{o=o+-1|0;i=i+1|0;if(!o){y=64;break r}l=l+1|0}while((f[i>>0]|0)==(f[l>>0]|0))}}else{if(i>>>0>=s>>>0)i=(i>>>0)%(s>>>0)|0;if((i|0)!=(b|0)){y=65;break i}}}while(0);n=t[n>>2]|0;if(!n){y=65;break i}}}}while(0);if((y|0)==64){y=0;if(!n){y=65;break i}}if(Ti(t[v+20>>2]|0,t[n+20>>2]|0)|0){n=f[w>>0]|0;i=t[v+12>>2]|0;if(((n<<24>>24<0?i:n&255)|0)==5){if(En(v+8|0,6319,5)|0){n=f[w>>0]|0;i=t[v+12>>2]|0;y=70}}else y=70;if((y|0)==70){y=0;if(((n<<24>>24<0?i:n&255)|0)!=7)break;if(En(v+8|0,6373,7)|0)break}if((f[w>>0]|0)<0)n=t[v+8>>2]|0;else n=v+8|0;d=Ei(n|0)|0;h=Oe(m|0,d|0)|0;fi(d|0);d=Ti(t[v+20>>2]|0,h|0)|0;fi(h|0);if(!d)y=75}else y=75}else y=75}while(0);if((y|0)==75){y=0;if((f[w>>0]|0)<0)n=t[v+8>>2]|0;else n=v+8|0;w=Ei(n|0)|0;bi(m|0,w|0,t[v+20>>2]|0);fi(w|0)}r=t[r>>2]|0;if(!r)break e}if((y|0)==65){g=xe(8)|0;ao(g,4032);t[g>>2]=3424;Fi(g|0,1008,95)}}}while(0);fi(m|0);k=g;return}function $i(e,i){e=e|0;i=i|0;var r=0,a=0,l=0,o=0,u=0,s=0;s=k;k=k+176|0;r=t[i+16>>2]|0;do{if(r)if((r|0)==(i|0)){t[s+16>>2]=s;Pu[t[(t[r>>2]|0)+12>>2]&31](r,s);break}else{t[s+16>>2]=r;t[i+16>>2]=0;break}else t[s+16>>2]=0}while(0);t[s+80>>2]=t[e+4>>2];$f(s+80+4|0,e+8|0);t[s+80+16>>2]=0;l=s+80+20|0;t[l>>2]=0;t[s+80+24>>2]=0;r=(t[e+24>>2]|0)-(t[e+20>>2]|0)|0;if(r>>5|0){if(r>>5>>>0>134217727)au();i=Vt(r)|0;t[l>>2]=i;t[s+80+16>>2]=i;t[s+80+24>>2]=i+(r>>5<<5);r=t[e+20>>2]|0;a=t[e+24>>2]|0;if((r|0)!=(a|0))do{t[i>>2]=t[r>>2];$f(i+4|0,r+4|0);n[i+16>>1]=n[r+16>>1]|0;xf(i+20|0,r+20|0);r=r+32|0;i=(t[l>>2]|0)+32|0;t[l>>2]=i}while((r|0)!=(a|0))}t[s+80+28>>2]=t[e+32>>2];r=t[s+16>>2]|0;do{if(r)if((r|0)==(s|0)){t[s+24+16>>2]=s+24;Pu[t[(t[r>>2]|0)+12>>2]&31](r,s+24|0);break}else{t[s+24+16>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;break}else t[s+24+16>>2]=0}while(0);t[s+144>>2]=t[s+80>>2];$f(s+144+4|0,s+80+4|0);t[s+144+16>>2]=0;e=s+144+20|0;t[e>>2]=0;t[s+144+24>>2]=0;r=(t[l>>2]|0)-(t[s+80+16>>2]|0)|0;if(r>>5|0){if(r>>5>>>0>134217727)au();i=Vt(r)|0;t[e>>2]=i;t[s+144+16>>2]=i;t[s+144+24>>2]=i+(r>>5<<5);r=t[s+80+16>>2]|0;a=t[l>>2]|0;if((r|0)!=(a|0))do{t[i>>2]=t[r>>2];$f(i+4|0,r+4|0);n[i+16>>1]=n[r+16>>1]|0;xf(i+20|0,r+20|0);r=r+32|0;i=(t[e>>2]|0)+32|0;t[e>>2]=i}while((r|0)!=(a|0))}t[s+144+28>>2]=t[s+80+28>>2];r=t[s+24+16>>2]|0;if(!r){s=xe(4)|0;t[s>>2]=1256;Fi(s|0,8,1)}Ou[t[(t[r>>2]|0)+24>>2]&15](s+112|0,r,s+144|0);r=t[s+144+16>>2]|0;if(r|0){i=t[e>>2]|0;if((i|0)!=(r|0)){do{t[e>>2]=i+-32;if((f[i+-4+3>>0]|0)<0)pu(t[i+-12>>2]|0);i=i+-28|0;if((f[i+11>>0]|0)<0)pu(t[i>>2]|0);i=t[e>>2]|0}while((i|0)!=(r|0));r=t[s+144+16>>2]|0}pu(r)}if((f[s+144+4+11>>0]|0)<0)pu(t[s+144+4>>2]|0);r=t[s+24+16>>2]|0;if((r|0)!=(s+24|0)){if(r|0)Fu[t[(t[r>>2]|0)+20>>2]&127](r)}else Fu[t[(t[r>>2]|0)+16>>2]&127](r);r=t[s+80+16>>2]|0;if(r|0){i=t[l>>2]|0;if((i|0)!=(r|0)){do{t[l>>2]=i+-32;if((f[i+-4+3>>0]|0)<0)pu(t[i+-12>>2]|0);i=i+-28|0;if((f[i+11>>0]|0)<0)pu(t[i>>2]|0);i=t[l>>2]|0}while((i|0)!=(r|0));r=t[s+80+16>>2]|0}pu(r)}if((f[s+80+4+11>>0]|0)<0)pu(t[s+80+4>>2]|0);t[s+48>>2]=t[s+112>>2];$f(s+48+4|0,s+112+4|0);t[s+48+16>>2]=0;o=s+48+20|0;t[o>>2]=0;t[s+48+24>>2]=0;u=s+112+20|0;r=(t[u>>2]|0)-(t[s+112+16>>2]|0)|0;if(r>>5|0){if(r>>5>>>0>134217727)au();i=Vt(r)|0;t[o>>2]=i;t[s+48+16>>2]=i;t[s+48+24>>2]=i+(r>>5<<5);r=t[s+112+16>>2]|0;a=t[u>>2]|0;if((r|0)!=(a|0))do{t[i>>2]=t[r>>2];$f(i+4|0,r+4|0);n[i+16>>1]=n[r+16>>1]|0;xf(i+20|0,r+20|0);r=r+32|0;i=(t[o>>2]|0)+32|0;t[o>>2]=i}while((r|0)!=(a|0))}t[s+48+28>>2]=t[s+112+28>>2];l=t[4065]|0;t[s+144>>2]=t[s+48>>2];$f(s+144+4|0,s+48+4|0);t[s+144+16>>2]=0;e=s+144+20|0;t[e>>2]=0;t[s+144+24>>2]=0;r=(t[o>>2]|0)-(t[s+48+16>>2]|0)|0;if(r>>5|0){if(r>>5>>>0>134217727)au();i=Vt(r)|0;t[e>>2]=i;t[s+144+16>>2]=i;t[s+144+24>>2]=i+(r>>5<<5);r=t[s+48+16>>2]|0;a=t[o>>2]|0;if((r|0)!=(a|0))do{t[i>>2]=t[r>>2];$f(i+4|0,r+4|0);n[i+16>>1]=n[r+16>>1]|0;xf(i+20|0,r+20|0);r=r+32|0;i=(t[e>>2]|0)+32|0;t[e>>2]=i}while((r|0)!=(a|0))}t[s+144+28>>2]=t[s+48+28>>2];a=cr(s+144|0)|0;r=t[s+144+16>>2]|0;if(r|0){i=t[e>>2]|0;if((i|0)!=(r|0)){do{t[e>>2]=i+-32;if((f[i+-4+3>>0]|0)<0)pu(t[i+-12>>2]|0);i=i+-28|0;if((f[i+11>>0]|0)<0)pu(t[i>>2]|0);i=t[e>>2]|0}while((i|0)!=(r|0));r=t[s+144+16>>2]|0}pu(r)}if((f[s+144+4+11>>0]|0)<0)pu(t[s+144+4>>2]|0);if(hn(l,a)|0)je(18);r=t[s+48+16>>2]|0;if(r|0){i=t[o>>2]|0;if((i|0)!=(r|0)){do{t[o>>2]=i+-32;if((f[i+-4+3>>0]|0)<0)pu(t[i+-12>>2]|0);i=i+-28|0;if((f[i+11>>0]|0)<0)pu(t[i>>2]|0);i=t[o>>2]|0}while((i|0)!=(r|0));r=t[s+48+16>>2]|0}pu(r)}if((f[s+48+4+11>>0]|0)<0)pu(t[s+48+4>>2]|0);r=t[s+112+16>>2]|0;if(r|0){i=t[u>>2]|0;if((i|0)!=(r|0)){do{t[u>>2]=i+-32;if((f[i+-4+3>>0]|0)<0)pu(t[i+-12>>2]|0);i=i+-28|0;if((f[i+11>>0]|0)<0)pu(t[i>>2]|0);i=t[u>>2]|0}while((i|0)!=(r|0));r=t[s+112+16>>2]|0}pu(r)}if((f[s+112+4+11>>0]|0)<0)pu(t[s+112+4>>2]|0);r=t[s+16>>2]|0;if((r|0)==(s|0)){Fu[t[(t[r>>2]|0)+16>>2]&127](r);k=s;return}if(!r){k=s;return}Fu[t[(t[r>>2]|0)+20>>2]&127](r);k=s;return}function er(){var e=0,i=0,r=0,a=0,l=0,o=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0;_=k;k=k+288|0;if((f[16184]|0)==0?so(16184)|0:0)f[16905]=1;f[16905]=1;je(19);je(20);t[_+112>>2]=1;v=_+112+4|0;t[v>>2]=0;t[v+4>>2]=0;t[v+8>>2]=0;f[v+11>>0]=0;f[v>>0]=0;t[_+112+16>>2]=0;t[_+112+20>>2]=0;t[_+112+24>>2]=0;t[_+112+28>>2]=2;w=Ke(11454)|0;t[_>>2]=0;t[_+4>>2]=0;t[_+8>>2]=0;f[_+11>>0]=8;t[_>>2]=1685025838;t[_+4>>2]=1886413167;f[_+8>>0]=0;if((f[16232]|0)==0?so(16232)|0:0)t[4067]=Wi(2,2308)|0;d=t[4067]|0;e=f[_+11>>0]|0;r=e<<24>>24<0?t[_+4>>2]|0:e&255;a=Vi(r+4|0)|0;t[a>>2]=r;Vr(a+4|0,(e<<24>>24<0?t[_>>2]|0:_)|0,r|0)|0;t[_+16>>2]=a;h=+wi(d|0,w|0,11463,_+268|0,_+16|0);d=~~h>>>0;vi(t[_+268>>2]|0);t[_+80>>2]=t[_+112>>2];$f(_+80+4|0,v);t[_+80+16>>2]=0;a=_+80+20|0;t[a>>2]=0;t[_+80+24>>2]=0;r=t[_+112+20>>2]|0;e=t[_+112+16>>2]|0;if(r-e>>5|0){if(r-e>>5>>>0>134217727)au();i=Vt(r-e|0)|0;t[a>>2]=i;t[_+80+16>>2]=i;t[_+80+24>>2]=i+(r-e>>5<<5);if((e|0)!=(r|0))do{t[i>>2]=t[e>>2];$f(i+4|0,e+4|0);n[i+16>>1]=n[e+16>>1]|0;xf(i+20|0,e+20|0);e=e+32|0;i=(t[a>>2]|0)+32|0;t[a>>2]=i}while((e|0)!=(r|0))}t[_+80+28>>2]=t[_+112+28>>2];c=cr(_+80|0)|0;e=t[_+80+16>>2]|0;if(e|0){i=t[a>>2]|0;if((i|0)!=(e|0)){do{t[a>>2]=i+-32;if((f[i+-4+3>>0]|0)<0)pu(t[i+-12>>2]|0);i=i+-28|0;if((f[i+11>>0]|0)<0)pu(t[i>>2]|0);i=t[a>>2]|0}while((i|0)!=(e|0));e=t[_+80+16>>2]|0}pu(e)}if((f[_+80+4+11>>0]|0)<0)pu(t[_+80+4>>2]|0);i=Ei(5508)|0;r=Oe(d|0,i|0)|0;fi(i|0);Mf(_+256|0,r);fi(r|0);r=f[_+256+11>>0]|0;i=r<<24>>24<0?t[_+256>>2]|0:_+256|0;r=r<<24>>24<0?t[_+256+4>>2]|0:r&255;if(r|0){e=i;do{f[e>>0]=jo(f[e>>0]|0)|0;e=e+1|0}while((e|0)!=(i+r|0))}o=Ei(16118)|0;a=Oe(d|0,o|0)|0;fi(o|0);Mf(_+196|0,a);t[_+208>>2]=0;t[_+208+4>>2]=0;t[_+208+8>>2]=0;f[_+208+11>>0]=2;n[_+208>>1]=25705;f[_+208+2>>0]=0;o=_+208+12|0;t[o>>2]=t[_+196>>2];t[o+4>>2]=t[_+196+4>>2];t[o+8>>2]=t[_+196+8>>2];t[_+196>>2]=0;t[_+196+4>>2]=0;t[_+196+8>>2]=0;r=_+208+24|0;s=Ei(5516)|0;l=Oe(d|0,s|0)|0;fi(s|0);Mf(_+184|0,l);t[r>>2]=0;t[r+4>>2]=0;t[r+8>>2]=0;f[r+11>>0]=5;f[r>>0]=f[6243]|0;f[r+1>>0]=f[6244]|0;f[r+2>>0]=f[6245]|0;f[r+3>>0]=f[6246]|0;f[r+4>>0]=f[6247]|0;f[r+5>>0]=0;s=_+208+36|0;t[s>>2]=t[_+184>>2];t[s+4>>2]=t[_+184+4>>2];t[s+8>>2]=t[_+184+8>>2];t[_+184>>2]=0;t[_+184+4>>2]=0;t[_+184+8>>2]=0;lr(_+268|0,_+208|0,2);t[_+164>>2]=0;t[_+164+4>>2]=0;t[_+164+8>>2]=0;t[_+164+12>>2]=0;u[_+164+16>>2]=1;t[_+144>>2]=0;t[_+144+4>>2]=0;t[_+144+8>>2]=0;t[_+144+12>>2]=0;u[_+144+16>>2]=1;nr(_+16|0,_+268|0);fr(_+16+20|0,_+164|0);ir(_+16+40|0,_+144|0);b=Vt(112)|0;Yn(b,_+256|0,_+16|0);rf(_+16|0);t[_+144>>2]=0;t[_+164>>2]=0;e=t[_+268+8>>2]|0;if(e|0)do{i=e;e=t[e>>2]|0;if((f[i+20+11>>0]|0)<0)pu(t[i+20>>2]|0);if((f[i+8+11>>0]|0)<0)pu(t[i+8>>2]|0);pu(i)}while((e|0)!=0);e=t[_+268>>2]|0;t[_+268>>2]=0;if(e|0)pu(e);if((f[s+11>>0]|0)<0)pu(t[s>>2]|0);if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);if((f[o+11>>0]|0)<0)pu(t[o>>2]|0);if((f[_+208+11>>0]|0)<0)pu(t[_+208>>2]|0);fi(l|0);fi(a|0);e=Ke(4005)|0;s=Ei(4012)|0;i=Oe(e|0,s|0)|0;fi(s|0);s=Ei(5526)|0;r=Oe(i|0,s|0)|0;fi(s|0);if((f[16192]|0)==0?so(16192)|0:0)t[4064]=Wi(2,1268)|0;s=t[4064]|0;Ve(d|0);t[_+16>>2]=~~h>>>0;h=+wi(s|0,r|0,5533,_+268|0,_+16|0);vi(t[_+268>>2]|0);t[b+96>>2]=~~h;fi(r|0);fi(i|0);fi(e|0);e=hn(b,c)|0;if((f[_+256+11>>0]|0)<0)pu(t[_+256>>2]|0);if(e|0)je(18);fi(d|0);if((f[_+11>>0]|0)<0)pu(t[_>>2]|0);fi(w|0);r=t[_+112+16>>2]|0;if(r|0){e=t[_+112+20>>2]|0;if((e|0)!=(r|0)){do{if((f[e+-4+3>>0]|0)<0)pu(t[e+-12>>2]|0);i=e+-28|0;e=e+-32|0;if((f[i+11>>0]|0)<0)pu(t[i>>2]|0)}while((e|0)!=(r|0));t[_+112+20>>2]=r}pu(r)}if((f[v+11>>0]|0)>=0){k=_;return 0}pu(t[v>>2]|0);k=_;return 0}function ir(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;t[e+12>>2]=0;t[e+16>>2]=t[i+16>>2];uf(e,t[i+4>>2]|0);i=t[i+8>>2]|0;if(!i)return;_=i;p=i;while(1){v=_+8|0;k=f[v+11>>0]|0;d=k<<24>>24<0?t[v>>2]|0:v;k=k<<24>>24<0?t[_+12>>2]|0:k&255;if(k>>>0>3){r=d;i=k;o=k;while(1){w=z(a[r>>0]|a[r+1>>0]<<8|a[r+2>>0]<<16|a[r+3>>0]<<24,1540483477)|0;i=(z(w>>>24^w,1540483477)|0)^(z(i,1540483477)|0);o=o+-4|0;if(o>>>0<=3)break;else r=r+4|0}o=d+((k+-4&-4)+4)|0;r=k+-4-(k+-4&-4)|0}else{o=d;i=k;r=k}switch(r|0){case 3:{i=a[o+2>>0]<<16^i;m=8;break}case 2:{m=8;break}case 1:{m=9;break}default:{}}if((m|0)==8){i=a[o+1>>0]<<8^i;m=9}if((m|0)==9){m=0;i=z(a[o>>0]^i,1540483477)|0}w=z(i>>>13^i,1540483477)|0;h=t[e+4>>2]|0;e:do{if(h){if(h+-1&h)if((w>>>15^w)>>>0<h>>>0)i=w>>>15^w;else i=((w>>>15^w)>>>0)%(h>>>0)|0;else i=(w>>>15^w)&h+-1;r=t[(t[e>>2]|0)+(i<<2)>>2]|0;if((r|0)!=0?(y=t[r>>2]|0,(y|0)!=0):0){if(!(h+-1&h)){if(!k){r=y;while(1){d=t[r+4>>2]|0;if(!((d|0)==(w>>>15^w|0)|(d&h+-1|0)==(i|0))){m=50;break e}d=f[r+8+11>>0]|0;if(!((d<<24>>24<0?t[r+12>>2]|0:d&255)|0))break e;r=t[r>>2]|0;if(!r){m=50;break e}}}else c=y;while(1){b=t[c+4>>2]|0;if(!((b|0)==(w>>>15^w|0)|(b&h+-1|0)==(i|0))){m=50;break e}b=c+8|0;r=f[b+11>>0]|0;do{if(((r<<24>>24<0?t[c+12>>2]|0:r&255)|0)==(k|0)){o=t[b>>2]|0;if(r<<24>>24<0)if(!(wt(o,d,k)|0))break e;else break;if((o&255)<<24>>24==(f[d>>0]|0)){s=r&255;r=b;o=d;do{s=s+-1|0;r=r+1|0;if(!s)break e;o=o+1|0}while((f[r>>0]|0)==(f[o>>0]|0))}}}while(0);c=t[c>>2]|0;if(!c){m=50;break e}}}if(!k){o=y;while(1){r=t[o+4>>2]|0;if((r|0)!=(w>>>15^w|0)){if(r>>>0>=h>>>0)r=(r>>>0)%(h>>>0)|0;if((r|0)!=(i|0)){m=50;break e}}d=f[o+8+11>>0]|0;if(!((d<<24>>24<0?t[o+12>>2]|0:d&255)|0))break e;o=t[o>>2]|0;if(!o){m=50;break e}}}else c=y;while(1){r=t[c+4>>2]|0;if((r|0)!=(w>>>15^w|0)){if(r>>>0>=h>>>0)r=(r>>>0)%(h>>>0)|0;if((r|0)!=(i|0)){m=50;break e}}b=c+8|0;r=f[b+11>>0]|0;do{if(((r<<24>>24<0?t[c+12>>2]|0:r&255)|0)==(k|0)){o=t[b>>2]|0;if(r<<24>>24<0)if(!(wt(o,d,k)|0))break e;else break;if((o&255)<<24>>24==(f[d>>0]|0)){s=r&255;r=b;o=d;do{s=s+-1|0;r=r+1|0;if(!s)break e;o=o+1|0}while((f[r>>0]|0)==(f[o>>0]|0))}}}while(0);c=t[c>>2]|0;if(!c){m=50;break}}}else m=50}else{i=0;m=50}}while(0);if((m|0)==50){m=0;s=Vt(48)|0;$f(s+8|0,v);r=t[_+40>>2]|0;do{if(r)if((r|0)==(_+24|0)){t[s+40>>2]=s+24;Pu[t[(t[r>>2]|0)+12>>2]&31](r,s+24|0);break}else{t[s+40>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;break}else t[s+40>>2]=0}while(0);t[s+4>>2]=w>>>15^w;t[s>>2]=0;l=+(((t[e+12>>2]|0)+1|0)>>>0);n=+u[e+16>>2];do{if((h|0)==0|l>+(h>>>0)*n){i=~~+j(+(l/n))>>>0;uf(e,((h>>>0<3|(h+-1&h|0)!=0)&1|h<<1)>>>0<i>>>0?i:(h>>>0<3|(h+-1&h|0)!=0)&1|h<<1);i=t[e+4>>2]|0;if(!(i+-1&i)){o=i;i=i+-1&(w>>>15^w);break}if((w>>>15^w)>>>0<i>>>0){o=i;i=w>>>15^w}else{o=i;i=((w>>>15^w)>>>0)%(i>>>0)|0}}else o=h}while(0);r=(t[e>>2]|0)+(i<<2)|0;i=t[r>>2]|0;if(!i){t[s>>2]=t[e+8>>2];t[e+8>>2]=s;t[r>>2]=e+8;i=t[s>>2]|0;if(i|0){i=t[i+4>>2]|0;r=o+-1|0;if(r&o){if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0}else i=i&r;i=(t[e>>2]|0)+(i<<2)|0;m=68}}else{t[s>>2]=t[i>>2];m=68}if((m|0)==68){m=0;t[i>>2]=s}t[e+12>>2]=(t[e+12>>2]|0)+1}i=t[p>>2]|0;if(!i)break;else{_=i;p=i}}return}function rr(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;t[e+12>>2]=0;u[e+16>>2]=1;if(!r)return;m=i;do{w=f[m+11>>0]|0;v=w<<24>>24<0?t[m>>2]|0:m;w=w<<24>>24<0?t[m+4>>2]|0:w&255;if(w>>>0>3){l=v;n=w;o=w;while(1){_=z(a[l>>0]|a[l+1>>0]<<8|a[l+2>>0]<<16|a[l+3>>0]<<24,1540483477)|0;n=(z(_>>>24^_,1540483477)|0)^(z(n,1540483477)|0);o=o+-4|0;if(o>>>0<=3)break;else l=l+4|0}o=v+((w+-4&-4)+4)|0;l=w+-4-(w+-4&-4)|0}else{o=v;n=w;l=w}switch(l|0){case 3:{n=a[o+2>>0]<<16^n;p=8;break}case 2:{p=8;break}case 1:{p=9;break}default:{}}if((p|0)==8){n=a[o+1>>0]<<8^n;p=9}if((p|0)==9){p=0;n=z(a[o>>0]^n,1540483477)|0}_=z(n>>>13^n,1540483477)|0;d=t[e+4>>2]|0;e:do{if(d){if(d+-1&d)if((_>>>15^_)>>>0<d>>>0)n=_>>>15^_;else n=((_>>>15^_)>>>0)%(d>>>0)|0;else n=(_>>>15^_)&d+-1;l=t[(t[e>>2]|0)+(n<<2)>>2]|0;if((l|0)!=0?(y=t[l>>2]|0,(y|0)!=0):0){if(!(d+-1&d)){if(!w){l=y;while(1){v=t[l+4>>2]|0;if(!((v|0)==(_>>>15^_|0)|(v&d+-1|0)==(n|0))){p=50;break e}v=f[l+8+11>>0]|0;if(!((v<<24>>24<0?t[l+12>>2]|0:v&255)|0))break e;l=t[l>>2]|0;if(!l){p=50;break e}}}else k=y;while(1){h=t[k+4>>2]|0;if(!((h|0)==(_>>>15^_|0)|(h&d+-1|0)==(n|0))){p=50;break e}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0))break e;else break;if((o&255)<<24>>24==(f[v>>0]|0)){c=l&255;l=h;o=v;do{c=c+-1|0;l=l+1|0;if(!c)break e;o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);k=t[k>>2]|0;if(!k){p=50;break e}}}if(!w){o=y;while(1){l=t[o+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){p=50;break e}}v=f[o+8+11>>0]|0;if(!((v<<24>>24<0?t[o+12>>2]|0:v&255)|0))break e;o=t[o>>2]|0;if(!o){p=50;break e}}}else k=y;while(1){l=t[k+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){p=50;break e}}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0))break e;else break;if((o&255)<<24>>24==(f[v>>0]|0)){c=l&255;l=h;o=v;do{c=c+-1|0;l=l+1|0;if(!c)break e;o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);k=t[k>>2]|0;if(!k){p=50;break}}}else p=50}else{n=0;p=50}}while(0);if((p|0)==50){p=0;c=Vt(48)|0;$f(c+8|0,m);l=t[m+32>>2]|0;do{if(l)if((l|0)==(m+16|0)){t[c+40>>2]=c+24;Pu[t[(t[l>>2]|0)+12>>2]&31](l,c+24|0);break}else{t[c+40>>2]=Ru[t[(t[l>>2]|0)+8>>2]&63](l)|0;break}else t[c+40>>2]=0}while(0);t[c+4>>2]=_>>>15^_;t[c>>2]=0;b=+(((t[e+12>>2]|0)+1|0)>>>0);s=+u[e+16>>2];do{if((d|0)==0|b>+(d>>>0)*s){n=~~+j(+(b/s))>>>0;uf(e,((d>>>0<3|(d+-1&d|0)!=0)&1|d<<1)>>>0<n>>>0?n:(d>>>0<3|(d+-1&d|0)!=0)&1|d<<1);n=t[e+4>>2]|0;if(!(n+-1&n)){o=n;n=n+-1&(_>>>15^_);break}if((_>>>15^_)>>>0<n>>>0){o=n;n=_>>>15^_}else{o=n;n=((_>>>15^_)>>>0)%(n>>>0)|0}}else o=d}while(0);l=(t[e>>2]|0)+(n<<2)|0;n=t[l>>2]|0;if(!n){t[c>>2]=t[e+8>>2];t[e+8>>2]=c;t[l>>2]=e+8;n=t[c>>2]|0;if(n|0){n=t[n+4>>2]|0;l=o+-1|0;if(l&o){if(n>>>0>=o>>>0)n=(n>>>0)%(o>>>0)|0}else n=n&l;n=(t[e>>2]|0)+(n<<2)|0;p=68}}else{t[c>>2]=t[n>>2];p=68}if((p|0)==68){p=0;t[n>>2]=c}t[e+12>>2]=(t[e+12>>2]|0)+1}m=m+40|0}while((m|0)!=(i+(r*40|0)|0));return}function fr(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;t[e+12>>2]=0;t[e+16>>2]=t[i+16>>2];uf(e,t[i+4>>2]|0);i=t[i+8>>2]|0;if(!i)return;_=i;p=i;while(1){v=_+8|0;k=f[v+11>>0]|0;d=k<<24>>24<0?t[v>>2]|0:v;k=k<<24>>24<0?t[_+12>>2]|0:k&255;if(k>>>0>3){r=d;i=k;o=k;while(1){w=z(a[r>>0]|a[r+1>>0]<<8|a[r+2>>0]<<16|a[r+3>>0]<<24,1540483477)|0;i=(z(w>>>24^w,1540483477)|0)^(z(i,1540483477)|0);o=o+-4|0;if(o>>>0<=3)break;else r=r+4|0}o=d+((k+-4&-4)+4)|0;r=k+-4-(k+-4&-4)|0}else{o=d;i=k;r=k}switch(r|0){case 3:{i=a[o+2>>0]<<16^i;m=8;break}case 2:{m=8;break}case 1:{m=9;break}default:{}}if((m|0)==8){i=a[o+1>>0]<<8^i;m=9}if((m|0)==9){m=0;i=z(a[o>>0]^i,1540483477)|0}w=z(i>>>13^i,1540483477)|0;h=t[e+4>>2]|0;e:do{if(h){if(h+-1&h)if((w>>>15^w)>>>0<h>>>0)i=w>>>15^w;else i=((w>>>15^w)>>>0)%(h>>>0)|0;else i=(w>>>15^w)&h+-1;r=t[(t[e>>2]|0)+(i<<2)>>2]|0;if((r|0)!=0?(y=t[r>>2]|0,(y|0)!=0):0){if(!(h+-1&h)){if(!k){r=y;while(1){d=t[r+4>>2]|0;if(!((d|0)==(w>>>15^w|0)|(d&h+-1|0)==(i|0))){m=50;break e}d=f[r+8+11>>0]|0;if(!((d<<24>>24<0?t[r+12>>2]|0:d&255)|0))break e;r=t[r>>2]|0;if(!r){m=50;break e}}}else c=y;while(1){b=t[c+4>>2]|0;if(!((b|0)==(w>>>15^w|0)|(b&h+-1|0)==(i|0))){m=50;break e}b=c+8|0;r=f[b+11>>0]|0;do{if(((r<<24>>24<0?t[c+12>>2]|0:r&255)|0)==(k|0)){o=t[b>>2]|0;if(r<<24>>24<0)if(!(wt(o,d,k)|0))break e;else break;if((o&255)<<24>>24==(f[d>>0]|0)){s=r&255;r=b;o=d;do{s=s+-1|0;r=r+1|0;if(!s)break e;o=o+1|0}while((f[r>>0]|0)==(f[o>>0]|0))}}}while(0);c=t[c>>2]|0;if(!c){m=50;break e}}}if(!k){o=y;while(1){r=t[o+4>>2]|0;if((r|0)!=(w>>>15^w|0)){if(r>>>0>=h>>>0)r=(r>>>0)%(h>>>0)|0;if((r|0)!=(i|0)){m=50;break e}}d=f[o+8+11>>0]|0;if(!((d<<24>>24<0?t[o+12>>2]|0:d&255)|0))break e;o=t[o>>2]|0;if(!o){m=50;break e}}}else c=y;while(1){r=t[c+4>>2]|0;if((r|0)!=(w>>>15^w|0)){if(r>>>0>=h>>>0)r=(r>>>0)%(h>>>0)|0;if((r|0)!=(i|0)){m=50;break e}}b=c+8|0;r=f[b+11>>0]|0;do{if(((r<<24>>24<0?t[c+12>>2]|0:r&255)|0)==(k|0)){o=t[b>>2]|0;if(r<<24>>24<0)if(!(wt(o,d,k)|0))break e;else break;if((o&255)<<24>>24==(f[d>>0]|0)){s=r&255;r=b;o=d;do{s=s+-1|0;r=r+1|0;if(!s)break e;o=o+1|0}while((f[r>>0]|0)==(f[o>>0]|0))}}}while(0);c=t[c>>2]|0;if(!c){m=50;break}}}else m=50}else{i=0;m=50}}while(0);if((m|0)==50){m=0;s=Vt(24)|0;$f(s+8|0,v);_=t[_+20>>2]|0;t[s+20>>2]=_;Ve(_|0);t[s+4>>2]=w>>>15^w;t[s>>2]=0;l=+(((t[e+12>>2]|0)+1|0)>>>0);n=+u[e+16>>2];do{if((h|0)==0|l>+(h>>>0)*n){i=~~+j(+(l/n))>>>0;uf(e,((h>>>0<3|(h+-1&h|0)!=0)&1|h<<1)>>>0<i>>>0?i:(h>>>0<3|(h+-1&h|0)!=0)&1|h<<1);i=t[e+4>>2]|0;if(!(i+-1&i)){o=i;i=i+-1&(w>>>15^w);break}if((w>>>15^w)>>>0<i>>>0){o=i;i=w>>>15^w}else{o=i;i=((w>>>15^w)>>>0)%(i>>>0)|0}}else o=h}while(0);r=(t[e>>2]|0)+(i<<2)|0;i=t[r>>2]|0;if(!i){t[s>>2]=t[e+8>>2];t[e+8>>2]=s;t[r>>2]=e+8;i=t[s>>2]|0;if(i|0){i=t[i+4>>2]|0;r=o+-1|0;if(r&o){if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0}else i=i&r;i=(t[e>>2]|0)+(i<<2)|0;m=63}}else{t[s>>2]=t[i>>2];m=63}if((m|0)==63){m=0;t[i>>2]=s}t[e+12>>2]=(t[e+12>>2]|0)+1}i=t[p>>2]|0;if(!i)break;else{_=i;p=i}}return}function nr(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;t[e+12>>2]=0;t[e+16>>2]=t[i+16>>2];uf(e,t[i+4>>2]|0);i=t[i+8>>2]|0;if(!i)return;_=i;p=i;while(1){v=_+8|0;k=f[v+11>>0]|0;d=k<<24>>24<0?t[v>>2]|0:v;k=k<<24>>24<0?t[_+12>>2]|0:k&255;if(k>>>0>3){r=d;i=k;o=k;while(1){w=z(a[r>>0]|a[r+1>>0]<<8|a[r+2>>0]<<16|a[r+3>>0]<<24,1540483477)|0;i=(z(w>>>24^w,1540483477)|0)^(z(i,1540483477)|0);o=o+-4|0;if(o>>>0<=3)break;else r=r+4|0}o=d+((k+-4&-4)+4)|0;r=k+-4-(k+-4&-4)|0}else{o=d;i=k;r=k}switch(r|0){case 3:{i=a[o+2>>0]<<16^i;m=8;break}case 2:{m=8;break}case 1:{m=9;break}default:{}}if((m|0)==8){i=a[o+1>>0]<<8^i;m=9}if((m|0)==9){m=0;i=z(a[o>>0]^i,1540483477)|0}w=z(i>>>13^i,1540483477)|0;h=t[e+4>>2]|0;e:do{if(h){if(h+-1&h)if((w>>>15^w)>>>0<h>>>0)i=w>>>15^w;else i=((w>>>15^w)>>>0)%(h>>>0)|0;else i=(w>>>15^w)&h+-1;r=t[(t[e>>2]|0)+(i<<2)>>2]|0;if((r|0)!=0?(y=t[r>>2]|0,(y|0)!=0):0){if(!(h+-1&h)){if(!k){r=y;while(1){d=t[r+4>>2]|0;if(!((d|0)==(w>>>15^w|0)|(d&h+-1|0)==(i|0))){m=50;break e}d=f[r+8+11>>0]|0;if(!((d<<24>>24<0?t[r+12>>2]|0:d&255)|0))break e;r=t[r>>2]|0;if(!r){m=50;break e}}}else c=y;while(1){b=t[c+4>>2]|0;if(!((b|0)==(w>>>15^w|0)|(b&h+-1|0)==(i|0))){m=50;break e}b=c+8|0;r=f[b+11>>0]|0;do{if(((r<<24>>24<0?t[c+12>>2]|0:r&255)|0)==(k|0)){o=t[b>>2]|0;if(r<<24>>24<0)if(!(wt(o,d,k)|0))break e;else break;if((o&255)<<24>>24==(f[d>>0]|0)){s=r&255;r=b;o=d;do{s=s+-1|0;r=r+1|0;if(!s)break e;o=o+1|0}while((f[r>>0]|0)==(f[o>>0]|0))}}}while(0);c=t[c>>2]|0;if(!c){m=50;break e}}}if(!k){o=y;while(1){r=t[o+4>>2]|0;if((r|0)!=(w>>>15^w|0)){if(r>>>0>=h>>>0)r=(r>>>0)%(h>>>0)|0;if((r|0)!=(i|0)){m=50;break e}}d=f[o+8+11>>0]|0;if(!((d<<24>>24<0?t[o+12>>2]|0:d&255)|0))break e;o=t[o>>2]|0;if(!o){m=50;break e}}}else c=y;while(1){r=t[c+4>>2]|0;if((r|0)!=(w>>>15^w|0)){if(r>>>0>=h>>>0)r=(r>>>0)%(h>>>0)|0;if((r|0)!=(i|0)){m=50;break e}}b=c+8|0;r=f[b+11>>0]|0;do{if(((r<<24>>24<0?t[c+12>>2]|0:r&255)|0)==(k|0)){o=t[b>>2]|0;if(r<<24>>24<0)if(!(wt(o,d,k)|0))break e;else break;if((o&255)<<24>>24==(f[d>>0]|0)){s=r&255;r=b;o=d;do{s=s+-1|0;r=r+1|0;if(!s)break e;o=o+1|0}while((f[r>>0]|0)==(f[o>>0]|0))}}}while(0);c=t[c>>2]|0;if(!c){m=50;break}}}else m=50}else{i=0;m=50}}while(0);if((m|0)==50){m=0;s=Vt(32)|0;$f(s+8|0,v);$f(s+20|0,_+20|0);t[s+4>>2]=w>>>15^w;t[s>>2]=0;l=+(((t[e+12>>2]|0)+1|0)>>>0);n=+u[e+16>>2];do{if((h|0)==0|l>+(h>>>0)*n){i=~~+j(+(l/n))>>>0;uf(e,((h>>>0<3|(h+-1&h|0)!=0)&1|h<<1)>>>0<i>>>0?i:(h>>>0<3|(h+-1&h|0)!=0)&1|h<<1);i=t[e+4>>2]|0;if(!(i+-1&i)){o=i;i=i+-1&(w>>>15^w);break}if((w>>>15^w)>>>0<i>>>0){o=i;i=w>>>15^w}else{o=i;i=((w>>>15^w)>>>0)%(i>>>0)|0}}else o=h}while(0);r=(t[e>>2]|0)+(i<<2)|0;i=t[r>>2]|0;if(!i){t[s>>2]=t[e+8>>2];t[e+8>>2]=s;t[r>>2]=e+8;i=t[s>>2]|0;if(i|0){i=t[i+4>>2]|0;r=o+-1|0;if(r&o){if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0}else i=i&r;i=(t[e>>2]|0)+(i<<2)|0;m=63}}else{t[s>>2]=t[i>>2];m=63}if((m|0)==63){m=0;t[i>>2]=s}t[e+12>>2]=(t[e+12>>2]|0)+1}i=t[p>>2]|0;if(!i)break;else{_=i;p=i}}return}function tr(e){e=e|0;var i=0,r=0,f=0,n=0,a=0,l=0,o=0,u=0,s=0;if(!e)return;i=t[4072]|0;r=t[e+-4>>2]|0;s=e+-8+(r&-8)|0;do{if(!(r&1)){f=t[e+-8>>2]|0;if(!(r&3))return;a=e+-8+(0-f)|0;l=f+(r&-8)|0;if(a>>>0<i>>>0)return;if((a|0)==(t[4073]|0)){e=t[s+4>>2]|0;if((e&3|0)!=3){o=a;u=a;i=l;break}t[4070]=l;t[s+4>>2]=e&-2;t[a+4>>2]=l|1;t[a+l>>2]=l;return}if(f>>>0<256){e=t[a+8>>2]|0;i=t[a+12>>2]|0;if((i|0)==(e|0)){t[4068]=t[4068]&~(1<<(f>>>3));o=a;u=a;i=l;break}else{t[e+12>>2]=i;t[i+8>>2]=e;o=a;u=a;i=l;break}}n=t[a+24>>2]|0;e=t[a+12>>2]|0;do{if((e|0)==(a|0)){e=t[a+16+4>>2]|0;if(!e){e=t[a+16>>2]|0;if(!e){e=0;break}else f=a+16|0}else f=a+16+4|0;while(1){r=e+20|0;i=t[r>>2]|0;if(i|0){e=i;f=r;continue}r=e+16|0;i=t[r>>2]|0;if(!i)break;else{e=i;f=r}}t[f>>2]=0}else{u=t[a+8>>2]|0;t[u+12>>2]=e;t[e+8>>2]=u}}while(0);if(n){i=t[a+28>>2]|0;r=(e|0)==0;if((a|0)==(t[16576+(i<<2)>>2]|0)){t[16576+(i<<2)>>2]=e;if(r){t[4069]=t[4069]&~(1<<i);o=a;u=a;i=l;break}}else{t[n+16+(((t[n+16>>2]|0)!=(a|0)&1)<<2)>>2]=e;if(r){o=a;u=a;i=l;break}}t[e+24>>2]=n;i=t[a+16>>2]|0;if(i|0){t[e+16>>2]=i;t[i+24>>2]=e}i=t[a+16+4>>2]|0;if(i){t[e+20>>2]=i;t[i+24>>2]=e;o=a;u=a;i=l}else{o=a;u=a;i=l}}else{o=a;u=a;i=l}}else{o=e+-8|0;u=e+-8|0;i=r&-8}}while(0);if(o>>>0>=s>>>0)return;r=t[s+4>>2]|0;if(!(r&1))return;if(!(r&2)){e=t[4073]|0;if((s|0)==(t[4074]|0)){s=(t[4071]|0)+i|0;t[4071]=s;t[4074]=u;t[u+4>>2]=s|1;if((u|0)!=(e|0))return;t[4073]=0;t[4070]=0;return}if((s|0)==(e|0)){s=(t[4070]|0)+i|0;t[4070]=s;t[4073]=o;t[u+4>>2]=s|1;t[o+s>>2]=s;return}n=(r&-8)+i|0;do{if(r>>>0<256){i=t[s+8>>2]|0;e=t[s+12>>2]|0;if((e|0)==(i|0)){t[4068]=t[4068]&~(1<<(r>>>3));break}else{t[i+12>>2]=e;t[e+8>>2]=i;break}}else{a=t[s+24>>2]|0;e=t[s+12>>2]|0;do{if((e|0)==(s|0)){e=t[s+16+4>>2]|0;if(!e){e=t[s+16>>2]|0;if(!e){r=0;break}else f=s+16|0}else f=s+16+4|0;while(1){r=e+20|0;i=t[r>>2]|0;if(i|0){e=i;f=r;continue}r=e+16|0;i=t[r>>2]|0;if(!i)break;else{e=i;f=r}}t[f>>2]=0;r=e}else{r=t[s+8>>2]|0;t[r+12>>2]=e;t[e+8>>2]=r;r=e}}while(0);if(a|0){e=t[s+28>>2]|0;i=(r|0)==0;if((s|0)==(t[16576+(e<<2)>>2]|0)){t[16576+(e<<2)>>2]=r;if(i){t[4069]=t[4069]&~(1<<e);break}}else{t[a+16+(((t[a+16>>2]|0)!=(s|0)&1)<<2)>>2]=r;if(i)break}t[r+24>>2]=a;e=t[s+16>>2]|0;if(e|0){t[r+16>>2]=e;t[e+24>>2]=r}e=t[s+16+4>>2]|0;if(e|0){t[r+20>>2]=e;t[e+24>>2]=r}}}}while(0);t[u+4>>2]=n|1;t[o+n>>2]=n;if((u|0)==(t[4073]|0)){t[4070]=n;return}}else{t[s+4>>2]=r&-2;t[u+4>>2]=i|1;t[o+i>>2]=i;n=i}r=n>>>3;if(n>>>0<256){e=t[4068]|0;if(!(e&1<<r)){t[4068]=e|1<<r;e=16312+(r<<1<<2)+8|0;i=16312+(r<<1<<2)|0}else{e=16312+(r<<1<<2)+8|0;i=t[16312+(r<<1<<2)+8>>2]|0}t[e>>2]=u;t[i+12>>2]=u;t[u+8>>2]=i;t[u+12>>2]=16312+(r<<1<<2);return}e=n>>>8;if(e)if(n>>>0>16777215)i=31;else{i=e<<((e+1048320|0)>>>16&8)<<(((e<<((e+1048320|0)>>>16&8))+520192|0)>>>16&4);i=14-(((e<<((e+1048320|0)>>>16&8))+520192|0)>>>16&4|(e+1048320|0)>>>16&8|(i+245760|0)>>>16&2)+(i<<((i+245760|0)>>>16&2)>>>15)|0;i=n>>>(i+7|0)&1|i<<1}else i=0;f=16576+(i<<2)|0;t[u+28>>2]=i;t[u+20>>2]=0;t[u+16>>2]=0;e=t[4069]|0;r=1<<i;do{if(e&r){i=n<<((i|0)==31?0:25-(i>>>1)|0);r=t[f>>2]|0;while(1){if((t[r+4>>2]&-8|0)==(n|0)){e=73;break}f=r+16+(i>>>31<<2)|0;e=t[f>>2]|0;if(!e){e=72;break}else{i=i<<1;r=e}}if((e|0)==72){t[f>>2]=u;t[u+24>>2]=r;t[u+12>>2]=u;t[u+8>>2]=u;break}else if((e|0)==73){o=r+8|0;s=t[o>>2]|0;t[s+12>>2]=u;t[o>>2]=u;t[u+8>>2]=s;t[u+12>>2]=r;t[u+24>>2]=0;break}}else{t[4069]=e|r;t[f>>2]=u;t[u+24>>2]=f;t[u+12>>2]=u;t[u+8>>2]=u}}while(0);s=(t[4076]|0)+-1|0;t[4076]=s;if(!s)e=16728;else return;while(1){e=t[e>>2]|0;if(!e)break;else e=e+8|0}t[4076]=-1;return}function ar(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;t[e+12>>2]=0;u[e+16>>2]=1;if(!r)return;m=i;do{w=f[m+11>>0]|0;v=w<<24>>24<0?t[m>>2]|0:m;w=w<<24>>24<0?t[m+4>>2]|0:w&255;if(w>>>0>3){l=v;n=w;o=w;while(1){_=z(a[l>>0]|a[l+1>>0]<<8|a[l+2>>0]<<16|a[l+3>>0]<<24,1540483477)|0;n=(z(_>>>24^_,1540483477)|0)^(z(n,1540483477)|0);o=o+-4|0;if(o>>>0<=3)break;else l=l+4|0}o=v+((w+-4&-4)+4)|0;l=w+-4-(w+-4&-4)|0}else{o=v;n=w;l=w}switch(l|0){case 3:{n=a[o+2>>0]<<16^n;p=8;break}case 2:{p=8;break}case 1:{p=9;break}default:{}}if((p|0)==8){n=a[o+1>>0]<<8^n;p=9}if((p|0)==9){p=0;n=z(a[o>>0]^n,1540483477)|0}_=z(n>>>13^n,1540483477)|0;d=t[e+4>>2]|0;e:do{if(d){if(d+-1&d)if((_>>>15^_)>>>0<d>>>0)n=_>>>15^_;else n=((_>>>15^_)>>>0)%(d>>>0)|0;else n=(_>>>15^_)&d+-1;l=t[(t[e>>2]|0)+(n<<2)>>2]|0;if((l|0)!=0?(y=t[l>>2]|0,(y|0)!=0):0){if(!(d+-1&d)){if(!w){l=y;while(1){v=t[l+4>>2]|0;if(!((v|0)==(_>>>15^_|0)|(v&d+-1|0)==(n|0))){p=50;break e}v=f[l+8+11>>0]|0;if(!((v<<24>>24<0?t[l+12>>2]|0:v&255)|0))break e;l=t[l>>2]|0;if(!l){p=50;break e}}}else k=y;while(1){h=t[k+4>>2]|0;if(!((h|0)==(_>>>15^_|0)|(h&d+-1|0)==(n|0))){p=50;break e}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0))break e;else break;if((o&255)<<24>>24==(f[v>>0]|0)){c=l&255;l=h;o=v;do{c=c+-1|0;l=l+1|0;if(!c)break e;o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);k=t[k>>2]|0;if(!k){p=50;break e}}}if(!w){o=y;while(1){l=t[o+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){p=50;break e}}v=f[o+8+11>>0]|0;if(!((v<<24>>24<0?t[o+12>>2]|0:v&255)|0))break e;o=t[o>>2]|0;if(!o){p=50;break e}}}else k=y;while(1){l=t[k+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){p=50;break e}}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0))break e;else break;if((o&255)<<24>>24==(f[v>>0]|0)){c=l&255;l=h;o=v;do{c=c+-1|0;l=l+1|0;if(!c)break e;o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);k=t[k>>2]|0;if(!k){p=50;break}}}else p=50}else{n=0;p=50}}while(0);if((p|0)==50){p=0;c=Vt(24)|0;$f(c+8|0,m);v=t[m+12>>2]|0;t[c+20>>2]=v;Ve(v|0);t[c+4>>2]=_>>>15^_;t[c>>2]=0;b=+(((t[e+12>>2]|0)+1|0)>>>0);s=+u[e+16>>2];do{if((d|0)==0|b>+(d>>>0)*s){n=~~+j(+(b/s))>>>0;uf(e,((d>>>0<3|(d+-1&d|0)!=0)&1|d<<1)>>>0<n>>>0?n:(d>>>0<3|(d+-1&d|0)!=0)&1|d<<1);n=t[e+4>>2]|0;if(!(n+-1&n)){o=n;n=n+-1&(_>>>15^_);break}if((_>>>15^_)>>>0<n>>>0){o=n;n=_>>>15^_}else{o=n;n=((_>>>15^_)>>>0)%(n>>>0)|0}}else o=d}while(0);l=(t[e>>2]|0)+(n<<2)|0;n=t[l>>2]|0;if(!n){t[c>>2]=t[e+8>>2];t[e+8>>2]=c;t[l>>2]=e+8;n=t[c>>2]|0;if(n|0){n=t[n+4>>2]|0;l=o+-1|0;if(l&o){if(n>>>0>=o>>>0)n=(n>>>0)%(o>>>0)|0}else n=n&l;n=(t[e>>2]|0)+(n<<2)|0;p=63}}else{t[c>>2]=t[n>>2];p=63}if((p|0)==63){p=0;t[n>>2]=c}t[e+12>>2]=(t[e+12>>2]|0)+1}m=m+16|0}while((m|0)!=(i+(r<<4)|0));return}function lr(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;t[e+12>>2]=0;u[e+16>>2]=1;if(!r)return;m=i;do{w=f[m+11>>0]|0;v=w<<24>>24<0?t[m>>2]|0:m;w=w<<24>>24<0?t[m+4>>2]|0:w&255;if(w>>>0>3){l=v;n=w;o=w;while(1){_=z(a[l>>0]|a[l+1>>0]<<8|a[l+2>>0]<<16|a[l+3>>0]<<24,1540483477)|0;n=(z(_>>>24^_,1540483477)|0)^(z(n,1540483477)|0);o=o+-4|0;if(o>>>0<=3)break;else l=l+4|0}o=v+((w+-4&-4)+4)|0;l=w+-4-(w+-4&-4)|0}else{o=v;n=w;l=w}switch(l|0){case 3:{n=a[o+2>>0]<<16^n;p=8;break}case 2:{p=8;break}case 1:{p=9;break}default:{}}if((p|0)==8){n=a[o+1>>0]<<8^n;p=9}if((p|0)==9){p=0;n=z(a[o>>0]^n,1540483477)|0}_=z(n>>>13^n,1540483477)|0;d=t[e+4>>2]|0;e:do{if(d){if(d+-1&d)if((_>>>15^_)>>>0<d>>>0)n=_>>>15^_;else n=((_>>>15^_)>>>0)%(d>>>0)|0;else n=(_>>>15^_)&d+-1;l=t[(t[e>>2]|0)+(n<<2)>>2]|0;if((l|0)!=0?(y=t[l>>2]|0,(y|0)!=0):0){if(!(d+-1&d)){if(!w){l=y;while(1){v=t[l+4>>2]|0;if(!((v|0)==(_>>>15^_|0)|(v&d+-1|0)==(n|0))){p=50;break e}v=f[l+8+11>>0]|0;if(!((v<<24>>24<0?t[l+12>>2]|0:v&255)|0))break e;l=t[l>>2]|0;if(!l){p=50;break e}}}else k=y;while(1){h=t[k+4>>2]|0;if(!((h|0)==(_>>>15^_|0)|(h&d+-1|0)==(n|0))){p=50;break e}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0))break e;else break;if((o&255)<<24>>24==(f[v>>0]|0)){c=l&255;l=h;o=v;do{c=c+-1|0;l=l+1|0;if(!c)break e;o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);k=t[k>>2]|0;if(!k){p=50;break e}}}if(!w){o=y;while(1){l=t[o+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){p=50;break e}}v=f[o+8+11>>0]|0;if(!((v<<24>>24<0?t[o+12>>2]|0:v&255)|0))break e;o=t[o>>2]|0;if(!o){p=50;break e}}}else k=y;while(1){l=t[k+4>>2]|0;if((l|0)!=(_>>>15^_|0)){if(l>>>0>=d>>>0)l=(l>>>0)%(d>>>0)|0;if((l|0)!=(n|0)){p=50;break e}}h=k+8|0;l=f[h+11>>0]|0;do{if(((l<<24>>24<0?t[k+12>>2]|0:l&255)|0)==(w|0)){o=t[h>>2]|0;if(l<<24>>24<0)if(!(wt(o,v,w)|0))break e;else break;if((o&255)<<24>>24==(f[v>>0]|0)){c=l&255;l=h;o=v;do{c=c+-1|0;l=l+1|0;if(!c)break e;o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);k=t[k>>2]|0;if(!k){p=50;break}}}else p=50}else{n=0;p=50}}while(0);if((p|0)==50){p=0;c=Vt(32)|0;$f(c+8|0,m);$f(c+20|0,m+12|0);t[c+4>>2]=_>>>15^_;t[c>>2]=0;b=+(((t[e+12>>2]|0)+1|0)>>>0);s=+u[e+16>>2];do{if((d|0)==0|b>+(d>>>0)*s){n=~~+j(+(b/s))>>>0;uf(e,((d>>>0<3|(d+-1&d|0)!=0)&1|d<<1)>>>0<n>>>0?n:(d>>>0<3|(d+-1&d|0)!=0)&1|d<<1);n=t[e+4>>2]|0;if(!(n+-1&n)){o=n;n=n+-1&(_>>>15^_);break}if((_>>>15^_)>>>0<n>>>0){o=n;n=_>>>15^_}else{o=n;n=((_>>>15^_)>>>0)%(n>>>0)|0}}else o=d}while(0);l=(t[e>>2]|0)+(n<<2)|0;n=t[l>>2]|0;if(!n){t[c>>2]=t[e+8>>2];t[e+8>>2]=c;t[l>>2]=e+8;n=t[c>>2]|0;if(n|0){n=t[n+4>>2]|0;l=o+-1|0;if(l&o){if(n>>>0>=o>>>0)n=(n>>>0)%(o>>>0)|0}else n=n&l;n=(t[e>>2]|0)+(n<<2)|0;p=63}}else{t[c>>2]=t[n>>2];p=63}if((p|0)==63){p=0;t[n>>2]=c}t[e+12>>2]=(t[e+12>>2]|0)+1}m=m+24|0}while((m|0)!=(i+(r*24|0)|0));return}function or(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;v=f[i+11>>0]|0;_=v<<24>>24<0?t[i>>2]|0:i;v=v<<24>>24<0?t[i+4>>2]|0:v&255;if(v>>>0>3){s=_;h=v;b=v;while(1){p=z(a[s>>0]|a[s+1>>0]<<8|a[s+2>>0]<<16|a[s+3>>0]<<24,1540483477)|0;h=(z(p>>>24^p,1540483477)|0)^(z(h,1540483477)|0);b=b+-4|0;if(b>>>0<=3)break;else s=s+4|0}c=_+((v+-4&-4)+4)|0;s=h;b=v+-4-(v+-4&-4)|0}else{c=_;s=v;b=v}switch(b|0){case 3:{k=a[c+2>>0]<<16^s;y=6;break}case 2:{k=s;y=6;break}case 1:{d=s;y=7;break}default:w=s}if((y|0)==6){d=a[c+1>>0]<<8^k;y=7}if((y|0)==7)w=z(a[c>>0]^d,1540483477)|0;p=z(w>>>13^w,1540483477)|0;w=t[e+4>>2]|0;e:do{if(w){if(w+-1&w)if((p>>>15^p)>>>0<w>>>0)d=p>>>15^p;else d=((p>>>15^p)>>>0)%(w>>>0)|0;else d=(p>>>15^p)&w+-1;s=t[(t[e>>2]|0)+(d<<2)>>2]|0;if((s|0)!=0?(n=t[s>>2]|0,(n|0)!=0):0){if(!(w+-1&w)){if(!v){r=n;while(1){_=t[r+4>>2]|0;if(!((_|0)==(p>>>15^p|0)|(_&w+-1|0)==(d|0))){r=d;break e}_=f[r+8+11>>0]|0;if(!((_<<24>>24<0?t[r+12>>2]|0:_&255)|0)){s=r;break}r=t[r>>2]|0;if(!r){r=d;break e}}e=s+20|0;return e|0}else s=n;i:while(1){k=t[s+4>>2]|0;if(!((k|0)==(p>>>15^p|0)|(k&w+-1|0)==(d|0))){r=d;break e}k=s+8|0;b=f[k+11>>0]|0;do{if(((b<<24>>24<0?t[s+12>>2]|0:b&255)|0)==(v|0)){c=t[k>>2]|0;if(b<<24>>24<0)if(!(wt(c,_,v)|0)){y=63;break i}else break;if((c&255)<<24>>24==(f[_>>0]|0)){h=b&255;b=k;c=_;do{h=h+-1|0;b=b+1|0;if(!h){y=63;break i}c=c+1|0}while((f[b>>0]|0)==(f[c>>0]|0))}}}while(0);s=t[s>>2]|0;if(!s){r=d;break e}}if((y|0)==63){e=s+20|0;return e|0}}if(!v){while(1){r=t[n+4>>2]|0;if((r|0)!=(p>>>15^p|0)){if(r>>>0>=w>>>0)r=(r>>>0)%(w>>>0)|0;if((r|0)!=(d|0)){r=d;break e}}_=f[n+8+11>>0]|0;if(!((_<<24>>24<0?t[n+12>>2]|0:_&255)|0)){s=n;break}n=t[n>>2]|0;if(!n){r=d;break e}}e=s+20|0;return e|0}i:while(1){s=t[n+4>>2]|0;if((s|0)!=(p>>>15^p|0)){if(s>>>0>=w>>>0)s=(s>>>0)%(w>>>0)|0;if((s|0)!=(d|0)){r=d;break e}}h=n+8|0;s=f[h+11>>0]|0;do{if(((s<<24>>24<0?t[n+12>>2]|0:s&255)|0)==(v|0)){b=t[h>>2]|0;if(s<<24>>24<0)if(!(wt(b,_,v)|0)){s=n;y=63;break i}else break;if((b&255)<<24>>24==(f[_>>0]|0)){c=s&255;s=h;b=_;do{c=c+-1|0;s=s+1|0;if(!c){s=n;y=63;break i}b=b+1|0}while((f[s>>0]|0)==(f[b>>0]|0))}}}while(0);n=t[n>>2]|0;if(!n){r=d;break e}}if((y|0)==63){e=s+20|0;return e|0}}else r=d}else r=0}while(0);b=Vt(32)|0;t[b+8>>2]=t[i>>2];t[b+8+4>>2]=t[i+4>>2];t[b+8+8>>2]=t[i+8>>2];t[i>>2]=0;t[i+4>>2]=0;t[i+8>>2]=0;t[b+20>>2]=0;t[b+20+4>>2]=0;t[b+20+8>>2]=0;t[b+4>>2]=p>>>15^p;t[b>>2]=0;o=+(((t[e+12>>2]|0)+1|0)>>>0);l=+u[e+16>>2];do{if((w|0)==0|o>+(w>>>0)*l){r=~~+j(+(o/l))>>>0;uf(e,((w>>>0<3|(w+-1&w|0)!=0)&1|w<<1)>>>0<r>>>0?r:(w>>>0<3|(w+-1&w|0)!=0)&1|w<<1);r=t[e+4>>2]|0;if(!(r+-1&r)){s=r;r=r+-1&(p>>>15^p);break}if((p>>>15^p)>>>0<r>>>0){s=r;r=p>>>15^p}else{s=r;r=((p>>>15^p)>>>0)%(r>>>0)|0}}else s=w}while(0);n=(t[e>>2]|0)+(r<<2)|0;r=t[n>>2]|0;if(!r){t[b>>2]=t[e+8>>2];t[e+8>>2]=b;t[n>>2]=e+8;r=t[b>>2]|0;if(r|0){r=t[r+4>>2]|0;n=s+-1|0;if(n&s){if(r>>>0>=s>>>0)r=(r>>>0)%(s>>>0)|0}else r=r&n;m=(t[e>>2]|0)+(r<<2)|0;y=61}}else{t[b>>2]=t[r>>2];m=r;y=61}if((y|0)==61)t[m>>2]=b;t[e+12>>2]=(t[e+12>>2]|0)+1;e=b;e=e+20|0;return e|0}function ur(e,i,r,n){e=e|0;i=i|0;r=r|0;n=n|0;var l=0,o=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0,g=0;g=k;k=k+16|0;y=t[i>>2]|0;v=f[r+11>>0]|0;_=v<<24>>24<0?t[r>>2]|0:r;v=v<<24>>24<0?t[r+4>>2]|0:v&255;if(v>>>0>3){o=_;i=v;c=v;while(1){p=z(a[o>>0]|a[o+1>>0]<<8|a[o+2>>0]<<16|a[o+3>>0]<<24,1540483477)|0;i=(z(p>>>24^p,1540483477)|0)^(z(i,1540483477)|0);c=c+-4|0;if(c>>>0<=3)break;else o=o+4|0}c=_+((v+-4&-4)+4)|0;o=v+-4-(v+-4&-4)|0}else{c=_;i=v;o=v}switch(o|0){case 3:{i=a[c+2>>0]<<16^i;m=6;break}case 2:{m=6;break}case 1:{m=7;break}default:{}}if((m|0)==6){i=a[c+1>>0]<<8^i;m=7}if((m|0)==7)i=z(a[c>>0]^i,1540483477)|0;p=z(i>>>13^i,1540483477)|0;w=t[y+80>>2]|0;e:do{if(w){if(w+-1&w)if((p>>>15^p)>>>0<w>>>0)i=p>>>15^p;else i=((p>>>15^p)>>>0)%(w>>>0)|0;else i=(p>>>15^p)&w+-1;o=t[(t[y+76>>2]|0)+(i<<2)>>2]|0;if((o|0)!=0?(l=t[o>>2]|0,(l|0)!=0):0){if(!(w+-1&w)){if(!v)while(1){_=t[l+4>>2]|0;if(!((_|0)==(p>>>15^p|0)|(_&w+-1|0)==(i|0))){m=48;break e}_=f[l+8+11>>0]|0;if(!((_<<24>>24<0?t[l+12>>2]|0:_&255)|0))break e;l=t[l>>2]|0;if(!l){m=48;break e}}while(1){d=t[l+4>>2]|0;if(!((d|0)==(p>>>15^p|0)|(d&w+-1|0)==(i|0))){m=48;break e}d=l+8|0;o=f[d+11>>0]|0;do{if(((o<<24>>24<0?t[l+12>>2]|0:o&255)|0)==(v|0)){c=t[d>>2]|0;if(o<<24>>24<0)if(!(wt(c,_,v)|0))break e;else break;if((c&255)<<24>>24==(f[_>>0]|0)){h=o&255;o=d;c=_;do{h=h+-1|0;o=o+1|0;if(!h)break e;c=c+1|0}while((f[o>>0]|0)==(f[c>>0]|0))}}}while(0);l=t[l>>2]|0;if(!l){m=48;break e}}}if(!v)while(1){o=t[l+4>>2]|0;if((o|0)!=(p>>>15^p|0)){if(o>>>0>=w>>>0)o=(o>>>0)%(w>>>0)|0;if((o|0)!=(i|0)){m=48;break e}}_=f[l+8+11>>0]|0;if(!((_<<24>>24<0?t[l+12>>2]|0:_&255)|0))break e;l=t[l>>2]|0;if(!l){m=48;break e}}while(1){o=t[l+4>>2]|0;if((o|0)!=(p>>>15^p|0)){if(o>>>0>=w>>>0)o=(o>>>0)%(w>>>0)|0;if((o|0)!=(i|0)){m=48;break e}}d=l+8|0;o=f[d+11>>0]|0;do{if(((o<<24>>24<0?t[l+12>>2]|0:o&255)|0)==(v|0)){c=t[d>>2]|0;if(o<<24>>24<0)if(!(wt(c,_,v)|0))break e;else break;if((c&255)<<24>>24==(f[_>>0]|0)){h=o&255;o=d;c=_;do{h=h+-1|0;o=o+1|0;if(!h)break e;c=c+1|0}while((f[o>>0]|0)==(f[c>>0]|0))}}}while(0);l=t[l>>2]|0;if(!l){m=48;break}}}else m=48}else{i=0;m=48}}while(0);if((m|0)==48){l=Vt(48)|0;$f(l+8|0,r);t[l+40>>2]=0;t[l+4>>2]=p>>>15^p;t[l>>2]=0;b=+(((t[y+88>>2]|0)+1|0)>>>0);s=+u[y+92>>2];do{if((w|0)==0|b>+(w>>>0)*s){i=~~+j(+(b/s))>>>0;uf(y+76|0,((w>>>0<3|(w+-1&w|0)!=0)&1|w<<1)>>>0<i>>>0?i:(w>>>0<3|(w+-1&w|0)!=0)&1|w<<1);i=t[y+80>>2]|0;if(!(i+-1&i)){c=i;i=i+-1&(p>>>15^p);break}if((p>>>15^p)>>>0<i>>>0){c=i;i=p>>>15^p}else{c=i;i=((p>>>15^p)>>>0)%(i>>>0)|0}}else c=w}while(0);o=(t[y+76>>2]|0)+(i<<2)|0;i=t[o>>2]|0;if(!i){t[l>>2]=t[y+84>>2];t[y+84>>2]=l;t[o>>2]=y+84;i=t[l>>2]|0;if(i|0){i=t[i+4>>2]|0;o=c+-1|0;if(o&c){if(i>>>0>=c>>>0)i=(i>>>0)%(c>>>0)|0}else i=i&o;i=(t[y+76>>2]|0)+(i<<2)|0;m=61}}else{t[l>>2]=t[i>>2];m=61}if((m|0)==61)t[i>>2]=l;t[y+88>>2]=(t[y+88>>2]|0)+1}n=t[n>>2]|0;t[g+8>>2]=n;Ve(n|0);l=t[l+40>>2]|0;if(!l){g=xe(4)|0;t[g>>2]=1256;Fi(g|0,8,1)}else{t[g>>2]=(Uu[t[(t[l>>2]|0)+24>>2]&31](l,g+8|0)|0)&1;t[e>>2]=Xe(1104,g|0)|0;fi(t[g+8>>2]|0);k=g;return}}function sr(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;if((t[e+88>>2]|0)==0?(t[i+88>>2]|0)==0:0)return;Pe(2,t[i+96>>2]|0)|0;e=t[e+84>>2]|0;e:do{if(e|0)while(1){d=e;w=f[d+8+11>>0]|0;v=t[d+8>>2]|0;k=w<<24>>24<0?v:d+8|0;h=w<<24>>24<0?t[d+12>>2]|0:w&255;if(h>>>0>3){n=k;r=h;l=h;while(1){c=z(a[n>>0]|a[n+1>>0]<<8|a[n+2>>0]<<16|a[n+3>>0]<<24,1540483477)|0;r=(z(c>>>24^c,1540483477)|0)^(z(r,1540483477)|0);l=l+-4|0;if(l>>>0<=3)break;else n=n+4|0}l=k+((h+-4&-4)+4)|0;n=h+-4-(h+-4&-4)|0}else{l=k;r=h;n=h}switch(n|0){case 3:{r=a[l+2>>0]<<16^r;y=12;break}case 2:{y=12;break}case 1:{y=13;break}default:{}}if((y|0)==12){r=a[l+1>>0]<<8^r;y=13}if((y|0)==13){y=0;r=z(a[l>>0]^r,1540483477)|0}c=z(r>>>13^r,1540483477)|0;s=t[i+80>>2]|0;i:do{if(s){if(s+-1&s)if((c>>>15^c)>>>0<s>>>0)b=c>>>15^c;else b=((c>>>15^c)>>>0)%(s>>>0)|0;else b=(c>>>15^c)&s+-1;r=t[(t[i+76>>2]|0)+(b<<2)>>2]|0;if((r|0)!=0?(p=t[r>>2]|0,(p|0)!=0):0){r:do{if(!(s+-1&s)){if(!h){n=p;while(1){r=t[n+4>>2]|0;if(!((c>>>15^c|0)==(r|0)|(r&s+-1|0)==(b|0))){y=57;break i}if((c>>>15^c|0)==(r|0)?(k=f[n+8+11>>0]|0,((k<<24>>24<0?t[n+12>>2]|0:k&255)|0)==0):0)break i;n=t[n>>2]|0;if(!n){y=57;break i}}}else r=p;while(1){n=t[r+4>>2]|0;if(!((c>>>15^c|0)==(n|0)|(n&s+-1|0)==(b|0))){y=57;break i}do{if((c>>>15^c|0)==(n|0)?(m=r+8|0,_=f[m+11>>0]|0,((_<<24>>24<0?t[r+12>>2]|0:_&255)|0)==(h|0)):0){n=t[m>>2]|0;if(_<<24>>24<0)if(!(wt(n,k,h)|0))break i;else break;if((n&255)<<24>>24==(f[k>>0]|0)){n=_&255;l=m;o=k;do{n=n+-1|0;l=l+1|0;if(!n)break r;o=o+1|0}while((f[l>>0]|0)==(f[o>>0]|0))}}}while(0);r=t[r>>2]|0;if(!r){y=57;break i}}}else{if(!h){n=p;while(1){r=t[n+4>>2]|0;if((c>>>15^c|0)==(r|0)){k=f[n+8+11>>0]|0;if(!((k<<24>>24<0?t[n+12>>2]|0:k&255)|0))break i}else{if(r>>>0>=s>>>0)r=(r>>>0)%(s>>>0)|0;if((r|0)!=(b|0)){y=57;break i}}n=t[n>>2]|0;if(!n){y=57;break i}}}else r=p;while(1){n=t[r+4>>2]|0;do{if((c>>>15^c|0)==(n|0)){u=r+8|0;n=f[u+11>>0]|0;if(((n<<24>>24<0?t[r+12>>2]|0:n&255)|0)==(h|0)){l=t[u>>2]|0;if(n<<24>>24<0)if(!(wt(l,k,h)|0))break i;else break;if((l&255)<<24>>24==(f[k>>0]|0)){o=n&255;n=u;l=k;do{o=o+-1|0;n=n+1|0;if(!o)break r;l=l+1|0}while((f[n>>0]|0)==(f[l>>0]|0))}}}else{if(n>>>0>=s>>>0)n=(n>>>0)%(s>>>0)|0;if((n|0)!=(b|0)){y=57;break i}}}while(0);r=t[r>>2]|0;if(!r){y=57;break i}}}}while(0);if(!r)y=57}else y=57}else y=57}while(0);if((y|0)==57){y=0;di(3,t[i+96>>2]|0,(w<<24>>24<0?v:d+8|0)|0)|0}e=t[e>>2]|0;if(!e)break e}}while(0);e=t[i+84>>2]|0;if(!e)return;do{r=e+8|0;if((f[r+11>>0]|0)<0)r=t[r>>2]|0;mi(4,i|0,t[i+96>>2]|0,r|0)|0;e=t[e>>2]|0}while((e|0)!=0);return}function br(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0;w=k;k=k+80|0;b=t[r>>2]|0;t[w+32>>2]=b;h=w+32+4|0;t[h>>2]=t[r+4>>2];t[h+4>>2]=t[r+4+4>>2];t[h+8>>2]=t[r+4+8>>2];t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;d=w+32+16|0;c=w+32+20|0;l=t[r+16>>2]|0;t[d>>2]=l;o=t[r+20>>2]|0;t[c>>2]=o;a=t[r+24>>2]|0;t[w+32+24>>2]=a;t[r+24>>2]=0;t[r+20>>2]=0;t[r+16>>2]=0;t[w+32+28>>2]=t[r+28>>2];$f(w+64|0,i+4|0);t[w>>2]=b;$f(w+4|0,w+64|0);f[w+16>>0]=0;f[w+17>>0]=0;t[w+24>>2]=0;t[w+24+4>>2]=0;f[w+28+3>>0]=0;t[w+20>>2]=0;if(o>>>0>=a>>>0){if(((o-l>>5)+1|0)>>>0>134217727)au();r=a-l>>5>>>0<67108863?a-l>>4>>>0<((o-l>>5)+1|0)>>>0?(o-l>>5)+1|0:a-l>>4:134217727;do{if(r)if(r>>>0>134217727){w=xe(8)|0;ao(w,7681);t[w>>2]=3404;Fi(w|0,992,95)}else{i=Vt(r<<5)|0;a=t[c>>2]|0;u=t[d>>2]|0;break}else{a=o;u=l;i=0}}while(0);b=i+(o-l>>5<<5)|0;s=i+(r<<5)|0;t[b>>2]=t[w>>2];r=i+(o-l>>5<<5)+4|0;t[r>>2]=t[w+4>>2];t[r+4>>2]=t[w+4+4>>2];t[r+8>>2]=t[w+4+8>>2];t[w+4>>2]=0;t[w+4+4>>2]=0;t[w+4+8>>2]=0;n[i+(o-l>>5<<5)+16>>1]=n[w+16>>1]|0;o=i+(o-l>>5<<5)+20|0;t[o>>2]=t[w+20>>2];t[o+4>>2]=t[w+20+4>>2];t[o+8>>2]=t[w+20+8>>2];t[w+20>>2]=0;t[w+20+4>>2]=0;t[w+20+8>>2]=0;if((a|0)==(u|0)){r=b;l=a}else{i=b;r=b;do{o=a;a=a+-32|0;t[i+-32>>2]=t[a>>2];l=i+-28|0;t[l>>2]=t[o+-28>>2];t[l+4>>2]=t[o+-28+4>>2];t[l+8>>2]=t[o+-28+8>>2];t[o+-28>>2]=0;t[o+-28+4>>2]=0;t[o+-28+8>>2]=0;n[i+-16>>1]=n[o+-16>>1]|0;l=i+-12|0;t[l>>2]=t[o+-12>>2];t[l+4>>2]=t[o+-12+4>>2];t[l+8>>2]=t[o+-12+8>>2];t[o+-12>>2]=0;t[o+-12+4>>2]=0;t[o+-12+8>>2]=0;i=r+-32|0;r=i}while((a|0)!=(u|0));l=t[d>>2]|0;a=t[c>>2]|0}t[d>>2]=r;t[c>>2]=b+32;t[w+32+24>>2]=s;i=l;if((a|0)!=(i|0))do{if((f[a+-4+3>>0]|0)<0)pu(t[a+-12>>2]|0);r=a+-28|0;a=a+-32|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0)}while((a|0)!=(i|0));if(l|0)pu(l);if((f[w+28+3>>0]|0)<0)pu(t[w+20>>2]|0)}else{t[o>>2]=t[w>>2];t[o+4>>2]=t[w+4>>2];t[o+4+4>>2]=t[w+4+4>>2];t[o+4+8>>2]=t[w+4+8>>2];t[w+4>>2]=0;t[w+4+4>>2]=0;t[w+4+8>>2]=0;n[o+16>>1]=n[w+16>>1]|0;t[o+20>>2]=t[w+20>>2];t[o+20+4>>2]=t[w+20+4>>2];t[o+20+8>>2]=t[w+20+8>>2];t[w+20>>2]=0;t[w+20+4>>2]=0;t[w+20+8>>2]=0;t[c>>2]=(t[c>>2]|0)+32}if((f[w+4+11>>0]|0)<0)pu(t[w+4>>2]|0);if((f[w+64+11>>0]|0)<0)pu(t[w+64>>2]|0);t[w>>2]=0;t[w+4>>2]=0;t[w+8>>2]=0;if((f[h+11>>0]|0)<0){f[t[h>>2]>>0]=0;t[w+32+8>>2]=0;af(h);t[h>>2]=t[w>>2];t[h+4>>2]=t[w+4>>2];t[h+8>>2]=t[w+8>>2];o=t[w+32>>2]|0;u=t[d>>2]|0;s=t[c>>2]|0;b=t[w+32+24>>2]|0;c=t[w+32+28>>2]|0;d=o+1|0;t[w+32>>2]=d;t[e>>2]=d;d=e+4|0;t[d>>2]=t[h>>2];t[d+4>>2]=t[h+4>>2];t[d+8>>2]=t[h+8>>2];h=e+16|0;d=e+20|0;t[h>>2]=u;t[d>>2]=s;d=e+24|0;t[d>>2]=b;d=e+28|0;t[d>>2]=c;k=w;return}else{f[h>>0]=0;f[h+11>>0]=0;af(h);t[h>>2]=t[w>>2];t[h+4>>2]=t[w+4>>2];t[h+8>>2]=t[w+8>>2];o=t[w+32>>2]|0;u=t[d>>2]|0;s=t[c>>2]|0;b=t[w+32+24>>2]|0;c=t[w+32+28>>2]|0;d=o+1|0;t[w+32>>2]=d;t[e>>2]=d;d=e+4|0;t[d>>2]=t[h>>2];t[d+4>>2]=t[h+4>>2];t[d+8>>2]=t[h+8>>2];h=e+16|0;d=e+20|0;t[h>>2]=u;t[d>>2]=s;d=e+24|0;t[d>>2]=b;d=e+28|0;t[d>>2]=c;k=w;return}}function cr(e){e=e|0;var i=0,r=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0;c=k;k=k+128|0;t[c+80>>2]=t[e>>2];b=c+80+4|0;$f(b,e+4|0);t[c+80+16>>2]=0;s=c+80+20|0;t[s>>2]=0;t[c+80+24>>2]=0;o=(t[e+20>>2]|0)-(t[e+16>>2]|0)|0;if(o>>5){if(o>>5>>>0>134217727)au();l=Vt(o)|0;t[s>>2]=l;t[c+80+16>>2]=l;t[c+80+24>>2]=l+(o>>5<<5);i=t[e+16>>2]|0;a=t[e+20>>2]|0;if((i|0)==(a|0)){u=l;r=l;a=l+(o>>5<<5)|0;i=c+80+24|0}else{r=l;do{t[r>>2]=t[i>>2];$f(r+4|0,i+4|0);n[r+16>>1]=n[i+16>>1]|0;xf(r+20|0,i+20|0);i=i+32|0;r=(t[s>>2]|0)+32|0;t[s>>2]=r}while((i|0)!=(a|0));u=t[c+80+16>>2]|0;a=t[c+80+24>>2]|0;i=c+80+24|0}}else{u=0;r=0;a=0;i=c+80+24|0}h=t[e+28>>2]|0;t[c+80+28>>2]=h;v=t[c+80>>2]|0;w=t[c+80+4>>2]|0;t[c+112>>2]=t[c+80+8>>2];n[c+112+4>>1]=n[c+80+8+4>>1]|0;f[c+112+6>>0]=f[c+80+8+6>>0]|0;d=f[c+80+15>>0]|0;t[b>>2]=0;t[b+4>>2]=0;t[b+8>>2]=0;t[i>>2]=0;t[s>>2]=0;t[c+80+16>>2]=0;l=c+24+16|0;t[l>>2]=0;o=Vt(36)|0;t[o>>2]=1336;t[o+4>>2]=v;t[o+8>>2]=w;t[o+12>>2]=t[c+112>>2];n[o+12+4>>1]=n[c+112+4>>1]|0;f[o+12+6>>0]=f[c+112+6>>0]|0;f[o+19>>0]=d;t[c+112>>2]=0;n[c+112+4>>1]=0;f[c+112+6>>0]=0;t[o+20>>2]=u;t[o+24>>2]=r;t[o+28>>2]=a;t[o+32>>2]=h;t[l>>2]=o;i=t[4054]|0;if((i|0)==16200){Pu[t[(t[4050]|0)+12>>2]&31](16200,c+24|0);i=t[4054]|0;Fu[t[(t[i>>2]|0)+16>>2]&127](i);t[4054]=t[l>>2];t[l>>2]=c+24;i=c+24|0}else{t[l>>2]=i;t[4054]=o}if((i|0)!=(c+24|0)){if(i|0)Fu[t[(t[i>>2]|0)+20>>2]&127](i)}else Fu[t[(t[i>>2]|0)+16>>2]&127](i);i=t[c+80+16>>2]|0;if(i|0){r=t[s>>2]|0;if((r|0)!=(i|0)){do{t[s>>2]=r+-32;if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);r=r+-28|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);r=t[s>>2]|0}while((r|0)!=(i|0));i=t[c+80+16>>2]|0}pu(i)}if((f[b+11>>0]|0)<0)pu(t[b>>2]|0);t[c+48>>2]=t[e>>2];$f(c+48+4|0,e+4|0);t[c+48+16>>2]=0;l=c+48+20|0;t[l>>2]=0;t[c+48+24>>2]=0;i=(t[e+20>>2]|0)-(t[e+16>>2]|0)|0;if(i>>5|0){if(i>>5>>>0>134217727)au();r=Vt(i)|0;t[l>>2]=r;t[c+48+16>>2]=r;t[c+48+24>>2]=r+(i>>5<<5);i=t[e+16>>2]|0;a=t[e+20>>2]|0;if((i|0)!=(a|0))do{t[r>>2]=t[i>>2];$f(r+4|0,i+4|0);n[r+16>>1]=n[i+16>>1]|0;xf(r+20|0,i+20|0);i=i+32|0;r=(t[l>>2]|0)+32|0;t[l>>2]=r}while((i|0)!=(a|0))}t[c+48+28>>2]=t[e+28>>2];i=t[4054]|0;do{if(i)if((i|0)==16200){t[c+16>>2]=c;Pu[t[(t[4050]|0)+12>>2]&31](16200,c);break}else{t[c+16>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;break}else t[c+16>>2]=0}while(0);t[4065]=ji(c+48|0,c)|0;i=t[c+16>>2]|0;if((i|0)!=(c|0)){if(i|0)Fu[t[(t[i>>2]|0)+20>>2]&127](i)}else Fu[t[(t[i>>2]|0)+16>>2]&127](i);i=t[c+48+16>>2]|0;if(i|0){r=t[l>>2]|0;if((r|0)!=(i|0)){do{t[l>>2]=r+-32;if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);r=r+-28|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);r=t[l>>2]|0}while((r|0)!=(i|0));i=t[c+48+16>>2]|0}pu(i)}if((f[c+48+4+11>>0]|0)>=0){v=t[4065]|0;k=c;return v|0}pu(t[c+48+4>>2]|0);v=t[4065]|0;k=c;return v|0}function hr(e){e=e|0;var i=0,r=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0;h=k;k=k+16|0;i=f[e+11>>0]|0;if(i<<24>>24<0)r=t[e+4>>2]|0;else r=i&255;if(!r){if((f[e+24+11>>0]|0)<0)i=t[e+24>>2]|0;else i=e+24|0;t[e+96>>2]=Pe(5,i|0)|0;e=e+96|0;e=t[e>>2]|0;k=h;return e|0}if(((i<<24>>24<0?t[e+4>>2]|0:i&255)|0)==1?(En(e,16044,1)|0)==0:0){if((f[e+24+11>>0]|0)<0)i=t[e+24>>2]|0;else i=e+24|0;t[e+96>>2]=Pe(6,i|0)|0;e=e+96|0;e=t[e>>2]|0;k=h;return e|0}t[h>>2]=0;t[h+4>>2]=0;t[h+8>>2]=0;f[h+11>>0]=2;n[h>>1]=29550;f[h+2>>0]=0;if(dr(e+36|0,h)|0){t[h>>2]=0;t[h+4>>2]=0;t[h+8>>2]=0;f[h+11>>0]=2;n[h>>1]=29550;f[h+2>>0]=0;i=or(e+36|0,h)|0;if((f[e+11>>0]|0)<0)r=t[e>>2]|0;else r=e;t[e+96>>2]=di(7,((f[i+11>>0]|0)<0?t[i>>2]|0:i)|0,r|0)|0;if((f[h+11>>0]|0)<0)pu(t[h>>2]|0);t[h>>2]=0;t[h+4>>2]=0;t[h+8>>2]=0;f[h+11>>0]=2;n[h>>1]=29550;f[h+2>>0]=0;c=wr(e+36|0,h)|0;if(c|0){o=t[e+40>>2]|0;i=t[c+4>>2]|0;s=(o+-1&o|0)==0;if(!s)if(i>>>0<o>>>0)u=i;else u=(i>>>0)%(o>>>0)|0;else u=o+-1&i;r=(t[e+36>>2]|0)+(u<<2)|0;b=t[r>>2]|0;while(1){i=t[b>>2]|0;if((i|0)==(c|0))break;else b=i}if((b|0)!=(e+44|0)){i=t[b+4>>2]|0;if(!s){if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0}else i=i&o+-1;if((i|0)==(u|0))a=c;else l=35}else l=35;do{if((l|0)==35){i=t[c>>2]|0;if(i|0){i=t[i+4>>2]|0;if(!s){if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0}else i=i&o+-1;if((i|0)==(u|0)){a=c;break}}t[r>>2]=0;a=c}}while(0);i=t[a>>2]|0;if(i){r=t[i+4>>2]|0;if(!s){if(r>>>0>=o>>>0)r=(r>>>0)%(o>>>0)|0}else r=r&o+-1;if((r|0)!=(u|0)){t[(t[e+36>>2]|0)+(r<<2)>>2]=b;i=t[c>>2]|0}}t[b>>2]=i;t[a>>2]=0;t[e+48>>2]=(t[e+48>>2]|0)+-1;if((f[c+20+11>>0]|0)<0)pu(t[c+20>>2]|0);if((f[c+8+11>>0]|0)<0)pu(t[c+8>>2]|0);pu(c)}}else{if((f[e+11>>0]|0)<0)i=t[e>>2]|0;else i=e;t[e+96>>2]=Pe(8,i|0)|0}i=t[4063]|0;Yi(i,e);Qi(i,e);sr(i,e);i=t[e+100>>2]|0;if((i|0)!=(t[e+104>>2]|0)){r=0;do{c=t[e+96>>2]|0;di(9,c|0,hr(t[i+(r<<2)>>2]|0)|0)|0;r=r+1|0;i=t[e+100>>2]|0}while((r|0)!=((t[e+104>>2]|0)-i>>2|0));i=e+96|0;e=t[i>>2]|0;k=h;return e|0}i=f[e+24+11>>0]|0;if(i<<24>>24<0)r=t[e+28>>2]|0;else r=i&255;if(!r){e=e+96|0;e=t[e>>2]|0;k=h;return e|0}if(i<<24>>24<0)i=t[e+24>>2]|0;else i=e+24|0;di(10,t[e+96>>2]|0,i|0)|0;e=e+96|0;e=t[e>>2]|0;k=h;return e|0}function kr(e,i,r,n){e=e|0;i=i|0;r=r|0;n=n|0;var l=0,o=0,u=0,s=0,b=0;l=t[i>>2]|0;if((n|0)!=0?(o=t[n>>2]|0,(o|0)!=0):0)if(!e){u=l;n=r;b=25}else{t[n>>2]=0;u=l;s=r;b=43}else b=5;e:do{if((b|0)==5){if(t[t[895]>>2]|0)if(e|0){n=r;b=15;break}else{o=r;b=14;break}if(!e){r=wn(l)|0;b=60;break}i:do{if(r){o=r;while(1){n=f[l>>0]|0;if(!(n<<24>>24))break;l=l+1|0;t[e>>2]=n<<24>>24&57343;o=o+-1|0;if(!o)break i;else e=e+4|0}t[e>>2]=0;t[i>>2]=0;r=r-o|0;b=60;break e}}while(0);t[i>>2]=l;b=60}}while(0);e:while(1){i:do{if((b|0)==14){n=o;while(1){o=f[l>>0]|0;if(((o&255)+-1|0)>>>0<127?(l&3|0)==0:0){o=t[l>>2]|0;if(!((o+-16843009|o)&-2139062144)){do{l=l+4|0;n=n+-4|0;o=t[l>>2]|0}while(!((o+-16843009|o)&-2139062144|0));o=o&255;s=n}else{o=o&255;s=n}}else s=n;n=o&255;if((n+-1|0)>>>0>=127)break;l=l+1|0;n=s+-1|0}if((n+-194|0)>>>0>50){n=s;b=54}else{o=t[2388+(n+-194<<2)>>2]|0;u=l+1|0;n=s;b=25;continue e}}else if((b|0)==15){r:do{if(n){while(1){o=f[l>>0]|0;do{if(((o&255)+-1|0)>>>0<127?n>>>0>4&(l&3|0)==0:0){s=l;while(1){l=t[s>>2]|0;if((l+-16843009|l)&-2139062144|0){b=38;break}t[e>>2]=l&255;t[e+4>>2]=a[s+1>>0];t[e+8>>2]=a[s+2>>0];l=s+4|0;u=e+16|0;t[e+12>>2]=a[s+3>>0];n=n+-4|0;if(n>>>0>4){s=l;e=u}else{b=37;break}}if((b|0)==37){o=f[l>>0]|0;s=n;e=u;break}else if((b|0)==38){o=l&255;l=s;s=n;break}}else s=n}while(0);n=o&255;if((n+-1|0)>>>0>=127)break;l=l+1|0;t[e>>2]=n;n=s+-1|0;if(!n)break r;else e=e+4|0}if((n+-194|0)>>>0>50){n=s;b=54;break i}o=t[2388+(n+-194<<2)>>2]|0;u=l+1|0;b=43;continue e}}while(0);t[i>>2]=l;b=60;continue e}else if((b|0)==25){b=(a[u>>0]|0)>>>3;if((b+-16|b+(o>>26))>>>0>7)b=52;else{l=u+1|0;if(o&33554432){if((f[l>>0]&-64)<<24>>24!=-128){b=52;break}l=u+2|0;if(o&524288){if((f[l>>0]&-64)<<24>>24!=-128){b=52;break}l=u+3|0}}o=n+-1|0;b=14;continue e}}else if((b|0)==43){b=0;n=a[u>>0]|0;if(((n>>>3)+-16|(n>>>3)+(o>>26))>>>0>7){n=s;b=52}else{l=u+1|0;o=n+-128|o<<6;do{if((o|0)<0){n=(a[l>>0]|0)+-128|0;if(n>>>0>63){l=u+-1|0;r=e;break i}l=u+2|0;if((n|o<<6|0)<0){l=(a[l>>0]|0)+-128|0;if(l>>>0>63){l=u+-1|0;r=e;break i}else{o=l|(n|o<<6)<<6;l=u+3|0;break}}else o=n|o<<6}}while(0);t[e>>2]=o;n=s+-1|0;e=e+4|0;b=15;continue e}}else if((b|0)==60)return r|0}while(0);if((b|0)==52){b=0;l=u+-1|0;if(!o){o=f[l>>0]|0;b=54}else r=e}if((b|0)==54)if(!(o<<24>>24)){if(e|0){t[e>>2]=0;t[i>>2]=0}r=r-n|0;b=60;continue}else r=e;t[4223]=84;if(!r){r=-1;b=60;continue}t[i>>2]=l;r=-1;b=60}return 0}function dr(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0;d=f[i+11>>0]|0;v=d<<24>>24<0?t[i>>2]|0:i;d=d<<24>>24<0?t[i+4>>2]|0:d&255;if(d>>>0>3){i=v;l=d;r=d;while(1){n=z(a[i>>0]|a[i+1>>0]<<8|a[i+2>>0]<<16|a[i+3>>0]<<24,1540483477)|0;l=(z(n>>>24^n,1540483477)|0)^(z(l,1540483477)|0);r=r+-4|0;if(r>>>0<=3)break;else i=i+4|0}n=v+((d+-4&-4)+4)|0;i=l;r=d+-4-(d+-4&-4)|0}else{n=v;i=d;r=d}switch(r|0){case 3:{o=a[n+2>>0]<<16^i;b=6;break}case 2:{o=i;b=6;break}case 1:{u=i;b=7;break}default:s=i}if((b|0)==6){u=a[n+1>>0]<<8^o;b=7}if((b|0)==7)s=z(a[n>>0]^u,1540483477)|0;s=z(s>>>13^s,1540483477)|0;o=t[e+4>>2]|0;if(!o){v=0;return v|0}if(o+-1&o)if((s>>>15^s)>>>0<o>>>0)u=s>>>15^s;else u=((s>>>15^s)>>>0)%(o>>>0)|0;else u=(s>>>15^s)&o+-1;i=t[(t[e>>2]|0)+(u<<2)>>2]|0;if(!i){v=0;return v|0}r=t[i>>2]|0;if(!r){v=0;return v|0}if(!(o+-1&o)){if(!d){n=r;while(1){i=t[n+4>>2]|0;if(!((s>>>15^s|0)==(i|0)|(i&o+-1|0)==(u|0))){n=0;b=50;break}if((s>>>15^s|0)==(i|0)?(b=f[n+8+11>>0]|0,((b<<24>>24<0?t[n+12>>2]|0:b&255)|0)==0):0){b=50;break}n=t[n>>2]|0;if(!n){n=0;b=50;break}}if((b|0)==50)return n|0}else h=r;e:while(1){i=t[h+4>>2]|0;if(!((s>>>15^s|0)==(i|0)|(i&o+-1|0)==(u|0))){n=0;b=50;break}do{if((s>>>15^s|0)==(i|0)?(k=h+8|0,c=f[k+11>>0]|0,((c<<24>>24<0?t[h+12>>2]|0:c&255)|0)==(d|0)):0){i=t[k>>2]|0;if(c<<24>>24<0)if(!(wt(i,v,d)|0)){n=h;b=50;break e}else break;if((i&255)<<24>>24==(f[v>>0]|0)){i=c&255;n=k;l=v;do{i=i+-1|0;n=n+1|0;if(!i){n=h;b=50;break e}l=l+1|0}while((f[n>>0]|0)==(f[l>>0]|0))}}}while(0);h=t[h>>2]|0;if(!h){n=0;b=50;break}}if((b|0)==50)return n|0}if(!d){while(1){i=t[r+4>>2]|0;if((s>>>15^s|0)==(i|0)){k=f[r+8+11>>0]|0;if(!((k<<24>>24<0?t[r+12>>2]|0:k&255)|0)){n=r;b=50;break}}else{if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0;if((i|0)!=(u|0)){n=0;b=50;break}}r=t[r>>2]|0;if(!r){n=0;b=50;break}}if((b|0)==50)return n|0}else w=r;e:while(1){i=t[w+4>>2]|0;do{if((s>>>15^s|0)==(i|0)){l=w+8|0;i=f[l+11>>0]|0;if(((i<<24>>24<0?t[w+12>>2]|0:i&255)|0)==(d|0)){r=t[l>>2]|0;if(i<<24>>24<0)if(!(wt(r,v,d)|0)){n=w;b=50;break e}else break;if((r&255)<<24>>24==(f[v>>0]|0)){n=i&255;i=l;r=v;do{n=n+-1|0;i=i+1|0;if(!n){n=w;b=50;break e}r=r+1|0}while((f[i>>0]|0)==(f[r>>0]|0))}}}else{if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0;if((i|0)!=(u|0)){n=0;b=50;break e}}}while(0);w=t[w>>2]|0;if(!w){n=0;b=50;break}}if((b|0)==50)return n|0;return 0}function wr(e,i){e=e|0;i=i|0;var r=0,n=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0,v=0;d=f[i+11>>0]|0;v=d<<24>>24<0?t[i>>2]|0:i;d=d<<24>>24<0?t[i+4>>2]|0:d&255;if(d>>>0>3){i=v;l=d;r=d;while(1){n=z(a[i>>0]|a[i+1>>0]<<8|a[i+2>>0]<<16|a[i+3>>0]<<24,1540483477)|0;l=(z(n>>>24^n,1540483477)|0)^(z(l,1540483477)|0);r=r+-4|0;if(r>>>0<=3)break;else i=i+4|0}n=v+((d+-4&-4)+4)|0;i=l;r=d+-4-(d+-4&-4)|0}else{n=v;i=d;r=d}switch(r|0){case 3:{o=a[n+2>>0]<<16^i;b=6;break}case 2:{o=i;b=6;break}case 1:{u=i;b=7;break}default:s=i}if((b|0)==6){u=a[n+1>>0]<<8^o;b=7}if((b|0)==7)s=z(a[n>>0]^u,1540483477)|0;s=z(s>>>13^s,1540483477)|0;o=t[e+4>>2]|0;if(!o){v=0;return v|0}if(o+-1&o)if((s>>>15^s)>>>0<o>>>0)u=s>>>15^s;else u=((s>>>15^s)>>>0)%(o>>>0)|0;else u=(s>>>15^s)&o+-1;i=t[(t[e>>2]|0)+(u<<2)>>2]|0;if(!i){v=0;return v|0}r=t[i>>2]|0;if(!r){v=0;return v|0}if(!(o+-1&o)){if(!d){n=r;while(1){i=t[n+4>>2]|0;if(!((i|0)==(s>>>15^s|0)|(i&o+-1|0)==(u|0))){n=0;b=50;break}if((i|0)==(s>>>15^s|0)?(b=f[n+8+11>>0]|0,((b<<24>>24<0?t[n+12>>2]|0:b&255)|0)==0):0){b=50;break}n=t[n>>2]|0;if(!n){n=0;b=50;break}}if((b|0)==50)return n|0}else h=r;e:while(1){i=t[h+4>>2]|0;if(!((i|0)==(s>>>15^s|0)|(i&o+-1|0)==(u|0))){n=0;b=50;break}do{if((i|0)==(s>>>15^s|0)?(k=h+8|0,c=f[k+11>>0]|0,((c<<24>>24<0?t[h+12>>2]|0:c&255)|0)==(d|0)):0){i=t[k>>2]|0;if(c<<24>>24<0)if(!(wt(i,v,d)|0)){n=h;b=50;break e}else break;if((i&255)<<24>>24==(f[v>>0]|0)){i=c&255;n=k;l=v;do{i=i+-1|0;n=n+1|0;if(!i){n=h;b=50;break e}l=l+1|0}while((f[n>>0]|0)==(f[l>>0]|0))}}}while(0);h=t[h>>2]|0;if(!h){n=0;b=50;break}}if((b|0)==50)return n|0}if(!d){while(1){i=t[r+4>>2]|0;if((i|0)==(s>>>15^s|0)){k=f[r+8+11>>0]|0;if(!((k<<24>>24<0?t[r+12>>2]|0:k&255)|0)){n=r;b=50;break}}else{if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0;if((i|0)!=(u|0)){n=0;b=50;break}}r=t[r>>2]|0;if(!r){n=0;b=50;break}}if((b|0)==50)return n|0}else w=r;e:while(1){i=t[w+4>>2]|0;do{if((i|0)==(s>>>15^s|0)){l=w+8|0;i=f[l+11>>0]|0;if(((i<<24>>24<0?t[w+12>>2]|0:i&255)|0)==(d|0)){r=t[l>>2]|0;if(i<<24>>24<0)if(!(wt(r,v,d)|0)){n=w;b=50;break e}else break;if((r&255)<<24>>24==(f[v>>0]|0)){n=i&255;i=l;r=v;do{n=n+-1|0;i=i+1|0;if(!n){n=w;b=50;break e}r=r+1|0}while((f[i>>0]|0)==(f[r>>0]|0))}}}else{if(i>>>0>=o>>>0)i=(i>>>0)%(o>>>0)|0;if((i|0)!=(u|0)){n=0;b=50;break e}}}while(0);w=t[w>>2]|0;if(!w){n=0;b=50;break}}if((b|0)==50)return n|0;return 0}function vr(e){e=e|0;var i=0,r=0,n=0,a=0,l=0,o=0,u=0,s=0,b=0;b=k;k=k+16|0;t[b+4>>2]=0;t[b+4+4>>2]=0;f[b+11>>0]=3;f[b>>0]=f[8338]|0;f[b+1>>0]=f[8339]|0;f[b+2>>0]=f[8340]|0;f[b+3>>0]=0;if(dr(e+36|0,b)|0){t[b+4>>2]=0;t[b+4+4>>2]=0;f[b+11>>0]=3;f[b>>0]=f[8338]|0;f[b+1>>0]=f[8339]|0;f[b+2>>0]=f[8340]|0;f[b+3>>0]=0;Lt(e+12|0,or(e+36|0,b)|0)|0;if((f[b+11>>0]|0)<0)pu(t[b>>2]|0);t[b+4>>2]=0;t[b+4+4>>2]=0;f[b+11>>0]=3;f[b>>0]=f[8338]|0;f[b+1>>0]=f[8339]|0;f[b+2>>0]=f[8340]|0;f[b+3>>0]=0;s=wr(e+36|0,b)|0;if(s|0){a=t[e+40>>2]|0;i=t[s+4>>2]|0;o=(a+-1&a|0)==0;if(!o)if(i>>>0<a>>>0)l=i;else l=(i>>>0)%(a>>>0)|0;else l=a+-1&i;n=(t[e+36>>2]|0)+(l<<2)|0;u=t[n>>2]|0;while(1){i=t[u>>2]|0;if((i|0)==(s|0))break;else u=i}if((u|0)!=(e+44|0)){i=t[u+4>>2]|0;if(!o){if(i>>>0>=a>>>0)i=(i>>>0)%(a>>>0)|0}else i=i&a+-1;if((i|0)==(l|0))n=s;else r=18}else r=18;do{if((r|0)==18){i=t[s>>2]|0;if(i|0){i=t[i+4>>2]|0;if(!o){if(i>>>0>=a>>>0)i=(i>>>0)%(a>>>0)|0}else i=i&a+-1;if((i|0)==(l|0)){n=s;break}}t[n>>2]=0;n=s}}while(0);i=t[n>>2]|0;if(i){r=t[i+4>>2]|0;if(!o){if(r>>>0>=a>>>0)r=(r>>>0)%(a>>>0)|0}else r=r&a+-1;if((r|0)!=(l|0)){t[(t[e+36>>2]|0)+(r<<2)>>2]=u;i=t[s>>2]|0}}t[u>>2]=i;t[n>>2]=0;t[e+48>>2]=(t[e+48>>2]|0)+-1;if((f[s+20+11>>0]|0)<0)pu(t[s+20>>2]|0);if((f[s+8+11>>0]|0)<0)pu(t[s+8>>2]|0);pu(s)}}r=(f[e+11>>0]|0)<0;if(r)i=t[e>>2]|0;else i=e;if((f[i>>0]|0)==115){if(r)i=t[e>>2]|0;else i=e;if((f[i+1>>0]|0)==118){if(r)i=t[e>>2]|0;else i=e;if((f[i+2>>0]|0)==103)df(e)}}i=t[e+100>>2]|0;l=t[e+104>>2]|0;e:do{if((i|0)!=(l|0)){do{if(!(t[i>>2]|0))break e;i=i+4|0}while((i|0)!=(l|0));k=b;return}}while(0);if((i|0)==(l|0)){k=b;return}r=i+4|0;if((r|0)==(l|0))r=l;else{a=i;while(1){n=t[r>>2]|0;if(!n)n=a;else{t[a>>2]=n;i=a+4|0;n=i}r=r+4|0;if((r|0)==(l|0))break;else a=n}r=t[e+104>>2]|0}if((i|0)==(r|0)){k=b;return}t[e+104>>2]=r+(~((r+-4-i|0)>>>2)<<2);k=b;return}function _r(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0;if(!i){r=t[e>>2]|0;t[e>>2]=0;if(r|0)pu(r);t[e+4>>2]=0;return}if(i>>>0>1073741823){e=xe(8)|0;ao(e,7681);t[e>>2]=3404;Fi(e|0,992,95)}w=Vt(i<<2)|0;r=t[e>>2]|0;t[e>>2]=w;if(r|0)pu(r);t[e+4>>2]=i;r=0;do{t[(t[e>>2]|0)+(r<<2)>>2]=0;r=r+1|0}while((r|0)!=(i|0));a=t[e+8>>2]|0;if(!a)return;r=t[a+4>>2]|0;if(i+-1&i){if(r>>>0>=i>>>0)r=(r>>>0)%(i>>>0)|0}else r=r&i+-1;t[(t[e>>2]|0)+(r<<2)>>2]=e+8;n=t[a>>2]|0;if(!n)return;else{l=a;o=n;n=a}e:while(1){w=l;a=o;d=n;i:while(1){n=a;while(1){a=t[n+4>>2]|0;if(i+-1&i){if(a>>>0>=i>>>0)a=(a>>>0)%(i>>>0)|0}else a=a&i+-1;if((a|0)==(r|0))break;l=(t[e>>2]|0)+(a<<2)|0;if(!(t[l>>2]|0))break i;l=t[n>>2]|0;r:do{if(!l)l=n;else{h=n+8|0;c=f[h+11>>0]|0;k=c<<24>>24<0?t[n+12>>2]|0:c&255;if(c<<24>>24<0){if(!k){o=n;while(1){k=f[l+8+11>>0]|0;if((k<<24>>24<0?t[l+12>>2]|0:k&255)|0){l=o;break r}o=t[l>>2]|0;if(!o)break r;else{k=l;l=o;o=k}}}else u=n;while(1){s=l+8|0;o=f[s+11>>0]|0;if((k|0)!=((o<<24>>24<0?t[l+12>>2]|0:o&255)|0)){l=u;break r}if(wt(t[h>>2]|0,o<<24>>24<0?t[s>>2]|0:s,k)|0){l=u;break r}o=t[l>>2]|0;if(!o)break r;else{u=l;l=o}}}if(!k){o=n;while(1){k=f[l+8+11>>0]|0;if((k<<24>>24<0?t[l+12>>2]|0:k&255)|0){l=o;break r}o=t[l>>2]|0;if(!o)break r;else{k=l;l=o;o=k}}}b=n;while(1){u=l+8|0;o=f[u+11>>0]|0;if((k|0)!=((o<<24>>24<0?t[l+12>>2]|0:o&255)|0)){l=b;break r}o=o<<24>>24<0?t[u>>2]|0:u;if((t[h>>2]&255)<<24>>24==(f[o>>0]|0)){u=c&255;s=h}else{l=b;break r}while(1){u=u+-1|0;s=s+1|0;if(!u)break;o=o+1|0;if((f[s>>0]|0)!=(f[o>>0]|0)){l=b;break r}}o=t[l>>2]|0;if(!o)break;else{b=l;l=o}}}}while(0);t[d>>2]=t[l>>2];t[l>>2]=t[t[(t[e>>2]|0)+(a<<2)>>2]>>2];t[t[(t[e>>2]|0)+(a<<2)>>2]>>2]=n;n=t[w>>2]|0;if(!n){r=45;break e}}a=t[n>>2]|0;if(!a){r=45;break e}else{w=n;d=n}}t[l>>2]=d;o=t[n>>2]|0;if(!o){r=45;break}else{l=n;r=a}}if((r|0)==45)return}function pr(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;y=k;k=k+96|0;d=t[r>>2]|0;p=t[r+4>>2]|0;t[y+24>>2]=t[r+8>>2];n[y+24+4>>1]=n[r+8+4>>1]|0;f[y+24+6>>0]=f[r+8+6>>0]|0;m=f[r+15>>0]|0;t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;w=t[r+16>>2]|0;v=t[r+20>>2]|0;_=t[r+24>>2]|0;t[r+24>>2]=0;t[r+20>>2]=0;t[r+16>>2]=0;s=t[r+28>>2]|0;if((v|0)==(w|0)){t[e>>2]=d;i=e+4|0;t[i>>2]=p;i=e+8|0;t[i>>2]=t[y+24>>2];n[i+4>>1]=n[y+24+4>>1]|0;f[i+6>>0]=f[y+24+6>>0]|0;i=e+15|0;f[i>>0]=m;m=e+16|0;i=e+20|0;t[m>>2]=w;t[i>>2]=v;i=e+24|0;t[i>>2]=_;i=e+28|0;t[i>>2]=s;k=y;return}h=y+64+4|0;b=y+64+20|0;c=0;do{l=w+(c<<5)|0;r=t[l>>2]|0;if((r|0)==(t[i+32>>2]|0)){t[y+32>>2]=r;o=w+(c<<5)+4|0;$f(y+32+4|0,o);a=w+(c<<5)+16|0;n[y+32+16>>1]=n[a>>1]|0;u=w+(c<<5)+20|0;xf(y+32+20|0,u);r=t[i+24>>2]|0;do{if(r)if((r|0)==(i+8|0)){t[y+16>>2]=y;Pu[t[(t[r>>2]|0)+12>>2]&31](r,y);break}else{t[y+16>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;break}else t[y+16>>2]=0}while(0);Xf(y+64|0,y+32|0,y);t[l>>2]=t[y+64>>2];if((f[o+11>>0]|0)<0){f[t[o>>2]>>0]=0;t[w+(c<<5)+8>>2]=0;r=o}else{f[o>>0]=0;f[o+11>>0]=0;r=o}af(o);t[r>>2]=t[h>>2];t[r+4>>2]=t[h+4>>2];t[r+8>>2]=t[h+8>>2];t[h>>2]=0;t[h+4>>2]=0;t[h+8>>2]=0;n[a>>1]=n[y+64+16>>1]|0;r=w+(c<<5)+28+3|0;if((f[r>>0]|0)<0){t[t[u>>2]>>2]=0;t[w+(c<<5)+24>>2]=0}else{t[u>>2]=0;f[r>>0]=0}ff(u);t[u>>2]=t[b>>2];t[u+4>>2]=t[b+4>>2];t[u+8>>2]=t[b+8>>2];t[b>>2]=0;t[b+4>>2]=0;t[b+8>>2]=0;if((f[h+11>>0]|0)<0)pu(t[h>>2]|0);r=t[y+16>>2]|0;if((r|0)!=(y|0)){if(r|0)Fu[t[(t[r>>2]|0)+20>>2]&127](r)}else Fu[t[(t[r>>2]|0)+16>>2]&127](r);if((f[y+32+28+3>>0]|0)<0)pu(t[y+32+20>>2]|0);if((f[y+32+4+11>>0]|0)<0)pu(t[y+32+4>>2]|0)}c=c+1|0}while(c>>>0<v-w>>5>>>0);t[e>>2]=d;i=e+4|0;t[i>>2]=p;i=e+8|0;t[i>>2]=t[y+24>>2];n[i+4>>1]=n[y+24+4>>1]|0;f[i+6>>0]=f[y+24+6>>0]|0;i=e+15|0;f[i>>0]=m;m=e+16|0;i=e+20|0;t[m>>2]=w;t[i>>2]=v;i=e+24|0;t[i>>2]=_;i=e+28|0;t[i>>2]=s;k=y;return}function mr(e,i,r,n,a){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;var l=0,o=0,u=0,s=0,b=0,c=0,h=0,k=0,d=0,w=0;do{if((e+4|0)!=(i|0)){u=f[i+16+11>>0]|0;b=u<<24>>24<0?t[i+20>>2]|0:u&255;c=f[a+11>>0]|0;k=c<<24>>24<0?t[a+4>>2]|0:c&255;l=b>>>0<k>>>0?b:k;if((l|0)!=0?(o=wt(c<<24>>24<0?t[a>>2]|0:a,u<<24>>24<0?t[i+16>>2]|0:i+16|0,l)|0,(o|0)!=0):0){if((o|0)<0)break}else w=4;if((w|0)==4?k>>>0<b>>>0:0)break;l=k>>>0<b>>>0?k:b;if((l|0)!=0?(s=wt(u<<24>>24<0?t[i+16>>2]|0:i+16|0,c<<24>>24<0?t[a>>2]|0:a,l)|0,(s|0)!=0):0){if((s|0)>=0)w=36}else w=20;if((w|0)==20?b>>>0>=k>>>0:0)w=36;if((w|0)==36){t[r>>2]=i;t[n>>2]=i;r=n;return r|0}b=t[i+4>>2]|0;if(!b){l=t[i+8>>2]|0;if((t[l>>2]|0)!=(i|0)){o=i+8|0;do{d=t[o>>2]|0;o=d+8|0;l=t[o>>2]|0}while((t[l>>2]|0)!=(d|0))}}else{l=b;while(1){o=t[l>>2]|0;if(!o)break;else l=o}}do{if((l|0)!=(e+4|0)){n=l+16|0;u=f[n+11>>0]|0;s=u<<24>>24<0?t[l+20>>2]|0:u&255;o=s>>>0<k>>>0?s:k;if((o|0)!=0?(h=wt(c<<24>>24<0?t[a>>2]|0:a,u<<24>>24<0?t[n>>2]|0:n,o)|0,(h|0)!=0):0){if((h|0)<0)break}else w=30;if((w|0)==30?k>>>0<s>>>0:0)break;r=Wr(e,r,a)|0;return r|0}}while(0);if(!b){t[r>>2]=i;r=i+4|0;return r|0}else{t[r>>2]=l;r=l;return r|0}}}while(0);h=t[i>>2]|0;do{if((t[e>>2]|0)==(i|0))l=i;else{if(!h){o=i;while(1){l=t[o+8>>2]|0;if((t[l>>2]|0)==(o|0))o=l;else{o=l;break}}}else{o=h;while(1){l=t[o+4>>2]|0;if(!l)break;else o=l}}l=o;b=o+16|0;n=f[a+11>>0]|0;c=n<<24>>24<0?t[a+4>>2]|0:n&255;s=f[b+11>>0]|0;u=s<<24>>24<0?t[o+20>>2]|0:s&255;o=c>>>0<u>>>0?c:u;if((o|0)!=0?(d=wt(s<<24>>24<0?t[b>>2]|0:b,n<<24>>24<0?t[a>>2]|0:a,o)|0,(d|0)!=0):0){if((d|0)<0)break}else w=12;if((w|0)==12?u>>>0<c>>>0:0)break;r=Wr(e,r,a)|0;return r|0}}while(0);if(!h){t[r>>2]=i;r=i;return r|0}else{i=l;t[r>>2]=i;r=i+4|0;return r|0}return 0}function yr(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,d=0,w=0,v=0,_=0,p=0,m=0,y=0;m=k;k=k+96|0;h=t[r>>2]|0;_=t[r+4>>2]|0;t[m+24>>2]=t[r+8>>2];n[m+24+4>>1]=n[r+8+4>>1]|0;f[m+24+6>>0]=f[r+8+6>>0]|0;p=f[r+15>>0]|0;t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;d=t[r+16>>2]|0;w=t[r+20>>2]|0;v=t[r+24>>2]|0;t[r+24>>2]=0;t[r+20>>2]=0;t[r+16>>2]=0;u=t[r+28>>2]|0;if((w|0)==(d|0)){t[e>>2]=h;i=e+4|0;t[i>>2]=_;i=e+8|0;t[i>>2]=t[m+24>>2];n[i+4>>1]=n[m+24+4>>1]|0;f[i+6>>0]=f[m+24+6>>0]|0;i=e+15|0;f[i>>0]=p;p=e+16|0;i=e+20|0;t[p>>2]=d;t[i>>2]=w;i=e+24|0;t[i>>2]=v;i=e+28|0;t[i>>2]=u;k=m;return}c=m+64+4|0;s=m+64+20|0;b=0;do{r=d+(b<<5)|0;t[m+32>>2]=t[r>>2];l=d+(b<<5)+4|0;$f(m+32+4|0,l);a=d+(b<<5)+16|0;n[m+32+16>>1]=n[a>>1]|0;o=d+(b<<5)+20|0;xf(m+32+20|0,o);y=f[i+4>>0]|0;t[m>>2]=1732;f[m+4>>0]=y;t[m+16>>2]=m;Xf(m+64|0,m+32|0,m);t[r>>2]=t[m+64>>2];if((f[l+11>>0]|0)<0){f[t[l>>2]>>0]=0;t[d+(b<<5)+8>>2]=0;r=l}else{f[l>>0]=0;f[l+11>>0]=0;r=l}af(l);t[r>>2]=t[c>>2];t[r+4>>2]=t[c+4>>2];t[r+8>>2]=t[c+8>>2];t[c>>2]=0;t[c+4>>2]=0;t[c+8>>2]=0;n[a>>1]=n[m+64+16>>1]|0;r=d+(b<<5)+28+3|0;if((f[r>>0]|0)<0){t[t[o>>2]>>2]=0;t[d+(b<<5)+24>>2]=0}else{t[o>>2]=0;f[r>>0]=0}ff(o);t[o>>2]=t[s>>2];t[o+4>>2]=t[s+4>>2];t[o+8>>2]=t[s+8>>2];t[s>>2]=0;t[s+4>>2]=0;t[s+8>>2]=0;if((f[c+11>>0]|0)<0)pu(t[c>>2]|0);r=t[m+16>>2]|0;if((r|0)!=(m|0)){if(r|0)Fu[t[(t[r>>2]|0)+20>>2]&127](r)}else Fu[t[(t[r>>2]|0)+16>>2]&127](r);if((f[m+32+28+3>>0]|0)<0)pu(t[m+32+20>>2]|0);if((f[m+32+4+11>>0]|0)<0)pu(t[m+32+4>>2]|0);b=b+1|0}while(b>>>0<w-d>>5>>>0);t[e>>2]=h;i=e+4|0;t[i>>2]=_;i=e+8|0;t[i>>2]=t[m+24>>2];n[i+4>>1]=n[m+24+4>>1]|0;f[i+6>>0]=f[m+24+6>>0]|0;i=e+15|0;f[i>>0]=p;i=e+16|0;y=e+20|0;t[i>>2]=d;t[y>>2]=w;y=e+24|0;t[y>>2]=v;y=e+28|0;t[y>>2]=u;k=m;return}function gr(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;var a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0,k=0,d=0;if(!i)if(!f){if(n|0){t[n>>2]=(e>>>0)%(r>>>0);t[n+4>>2]=0}f=0;n=(e>>>0)/(r>>>0)>>>0;return(x=f,n)|0}else{if(!n){f=0;n=0;return(x=f,n)|0}t[n>>2]=e|0;t[n+4>>2]=i&0;f=0;n=0;return(x=f,n)|0}do{if(r){if(f|0){l=(q(f|0)|0)-(q(i|0)|0)|0;if(l>>>0<=31){h=l+1|0;o=e>>>((l+1|0)>>>0)&l-31>>31|i<<31-l;c=i>>>((l+1|0)>>>0)&l-31>>31;a=0;l=e<<31-l;break}if(!n){f=0;n=0;return(x=f,n)|0}t[n>>2]=e|0;t[n+4>>2]=i|i&0;f=0;n=0;return(x=f,n)|0}if(r-1&r|0){l=(q(r|0)|0)+33-(q(i|0)|0)|0;h=l;o=32-l-1>>31&i>>>((l-32|0)>>>0)|(i<<32-l|e>>>(l>>>0))&l-32>>31;c=l-32>>31&i>>>(l>>>0);a=e<<64-l&32-l>>31;l=(i<<64-l|e>>>((l-32|0)>>>0))&32-l>>31|e<<32-l&l-33>>31;break}if(n|0){t[n>>2]=r-1&e;t[n+4>>2]=0}if((r|0)==1){f=i|i&0;n=e|0|0;return(x=f,n)|0}else{n=Kt(r|0)|0;f=i>>>(n>>>0)|0;n=i<<32-n|e>>>(n>>>0)|0;return(x=f,n)|0}}else{if(!f){if(n|0){t[n>>2]=(i>>>0)%(r>>>0);t[n+4>>2]=0}f=0;n=(i>>>0)/(r>>>0)>>>0;return(x=f,n)|0}if(!e){if(n|0){t[n>>2]=0;t[n+4>>2]=(i>>>0)%(f>>>0)}r=0;n=(i>>>0)/(f>>>0)>>>0;return(x=r,n)|0}if(!(f-1&f)){if(n|0){t[n>>2]=e|0;t[n+4>>2]=f-1&i|i&0}r=0;n=i>>>((Kt(f|0)|0)>>>0);return(x=r,n)|0}l=(q(f|0)|0)-(q(i|0)|0)|0;if(l>>>0<=30){h=l+1|0;o=i<<31-l|e>>>((l+1|0)>>>0);c=i>>>((l+1|0)>>>0);a=0;l=e<<31-l;break}if(!n){f=0;n=0;return(x=f,n)|0}t[n>>2]=e|0;t[n+4>>2]=i|i&0;f=0;n=0;return(x=f,n)|0}}while(0);if(!h){u=l;i=c;e=0;l=0}else{s=Wl(r|0|0,f|f&0|0,-1,-1)|0;b=x;u=l;i=c;e=h;l=0;do{d=u;u=a>>>31|u<<1;a=l|a<<1;d=o<<1|d>>>31|0;k=o>>>31|i<<1|0;ol(s|0,b|0,d|0,k|0)|0;h=x;c=h>>31|((h|0)<0?-1:0)<<1;l=c&1;o=ol(d|0,k|0,c&(r|0)|0,(((h|0)<0?-1:0)>>31|((h|0)<0?-1:0)<<1)&(f|f&0)|0)|0;i=x;e=e-1|0}while((e|0)!=0);e=0}if(n|0){t[n>>2]=o;t[n+4>>2]=i}k=(a|0)>>>31|u<<1|(0<<1|a>>>31)&0|e;d=(a<<1|0>>>31)&-2|l;return(x=k,d)|0}function Tr(e,i,r,n,a){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;var l=0,o=0,u=0;e:do{if(!(Ro(e,t[i+8>>2]|0)|0)){if(!(Ro(e,t[i>>2]|0)|0)){o=t[e+12>>2]|0;ht(e+16|0,i,r,n,a);if((o|0)<=1)break;l=t[e+8>>2]|0;if((l&2|0)==0?(t[i+36>>2]|0)!=1:0){if(!(l&1)){l=e+24|0;while(1){if(f[i+54>>0]|0)break e;if((t[i+36>>2]|0)==1)break e;ht(l,i,r,n,a);l=l+8|0;if(l>>>0>=(e+16+(o<<3)|0)>>>0)break e}}else l=e+24|0;while(1){if(f[i+54>>0]|0)break e;if((t[i+36>>2]|0)==1?(t[i+24>>2]|0)==1:0)break e;ht(l,i,r,n,a);l=l+8|0;if(l>>>0>=(e+16+(o<<3)|0)>>>0)break e}}else l=e+24|0;while(1){if(f[i+54>>0]|0)break e;ht(l,i,r,n,a);l=l+8|0;if(l>>>0>=(e+16+(o<<3)|0)>>>0)break e}}if((t[i+16>>2]|0)!=(r|0)?(t[i+20>>2]|0)!=(r|0):0){t[i+32>>2]=n;if((t[i+44>>2]|0)==4)break;n=t[e+12>>2]|0;i:do{if((n|0)>0){o=0;l=0;u=e+16|0;r:do{f[i+52>>0]=0;f[i+53>>0]=0;ft(u,i,r,r,1,a);if(f[i+54>>0]|0)break;do{if(f[i+53>>0]|0){if(!(f[i+52>>0]|0))if(!(t[e+8>>2]&1)){l=1;break r}else{l=1;break}if((t[i+24>>2]|0)==1){o=22;break i}if(!(t[e+8>>2]&2)){o=22;break i}else{o=1;l=1}}}while(0);u=u+8|0}while(u>>>0<(e+16+(n<<3)|0)>>>0);if(o)o=21;else o=18}else{l=0;o=18}}while(0);if((o|0)==18){t[i+20>>2]=r;t[i+40>>2]=(t[i+40>>2]|0)+1;if((t[i+36>>2]|0)==1?(t[i+24>>2]|0)==2:0){f[i+54>>0]=1;if(l)o=22;else l=4}else o=21}if((o|0)==21)if(l)o=22;else l=4;if((o|0)==22)l=3;t[i+44>>2]=l;break}if((n|0)==1)t[i+32>>2]=1}else wa(i,r,n)}while(0);return}function Ar(e,i){e=e|0;i=i|0;var r=0,f=0,n=0,a=0,l=0,o=0,u=0,s=0;s=k;k=k+112|0;r=t[i+16>>2]|0;do{if(r)if((r|0)==(i|0)){t[s+16>>2]=s;Pu[t[(t[r>>2]|0)+12>>2]&31](r,s);r=t[s+16>>2]|0;u=s+16|0;break}else{t[s+16>>2]=r;t[i+16>>2]=0;u=s+16|0;break}else{t[s+16>>2]=0;r=0;u=s+16|0}}while(0);l=t[e+32>>2]|0;do{if(r){if((r|0)==(s|0)){t[s+24+16>>2]=s+24;Pu[t[(t[r>>2]|0)+12>>2]&31](r,s+24|0);r=t[s+24+16>>2]|0;i=s+24+16|0}else{r=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;t[s+24+16>>2]=r;i=s+24+16|0}if(r)if((r|0)==(s+24|0)){t[s+72+16>>2]=s+72;Pu[t[(t[r>>2]|0)+12>>2]&31](r,s+72|0);n=s+72|0;r=s+72+16|0;break}else{t[s+72+16>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;n=s+72|0;r=s+72+16|0;break}else{r=s+72|0;o=12}}else{t[s+24+16>>2]=0;r=s+72|0;i=s+24+16|0;o=12}}while(0);if((o|0)==12){t[s+72+16>>2]=0;n=r;r=s+72+16|0}t[s+72+24>>2]=l;t[s+48+16>>2]=0;a=Vt(40)|0;t[a>>2]=2272;f=t[r>>2]|0;do{if(f){if((f|0)!=(n|0)){t[a+24>>2]=f;o=21;break}t[a+24>>2]=a+8;Pu[t[(t[f>>2]|0)+12>>2]&31](f,a+8|0);r=t[r>>2]|0;t[a+32>>2]=t[s+72+24>>2];t[s+48+16>>2]=a;if((r|0)==(f|0)){Fu[t[(t[f>>2]|0)+16>>2]&127](f);break}if(r|0)Fu[t[(t[r>>2]|0)+20>>2]&127](r)}else{r=a+24|0;o=21}}while(0);if((o|0)==21){t[r>>2]=0;t[a+32>>2]=l;t[s+48+16>>2]=a}r=t[e+24>>2]|0;if(!r){s=xe(4)|0;t[s>>2]=1256;Fi(s|0,8,1)}Pu[t[(t[r>>2]|0)+24>>2]&31](r,s+48|0);r=t[s+48+16>>2]|0;if((r|0)!=(s+48|0)){if(r|0)Fu[t[(t[r>>2]|0)+20>>2]&127](r)}else Fu[t[(t[r>>2]|0)+16>>2]&127](r);r=t[i>>2]|0;if((r|0)!=(s+24|0)){if(r|0)Fu[t[(t[r>>2]|0)+20>>2]&127](r)}else Fu[t[(t[r>>2]|0)+16>>2]&127](r);r=t[u>>2]|0;if((r|0)==(s|0)){Fu[t[(t[r>>2]|0)+16>>2]&127](r);k=s;return}if(!r){k=s;return}Fu[t[(t[r>>2]|0)+20>>2]&127](r);k=s;return}function Er(e,i,r,n,l,o,u,s){e=e|0;i=i|0;r=r|0;n=n|0;l=l|0;o=o|0;u=u|0;s=s|0;var b=0,c=0,h=0,k=0;t[r>>2]=e;t[o>>2]=n;e=t[r>>2]|0;if(((((s&4|0)!=0?(i-e|0)>2:0)?(f[e>>0]|0)==-17:0)?(f[e+1>>0]|0)==-69:0)?(f[e+2>>0]|0)==-65:0){t[r>>2]=e+3;e=e+3|0}e:do{if(e>>>0<i>>>0){k=t[o>>2]|0;b=e;while(1){if(k>>>0>=l>>>0){e=1;break e}h=f[b>>0]|0;s=b+1|0;do{if(h<<24>>24>-1){if((h&255)>>>0>u>>>0){e=2;break e}t[k>>2]=h&255;e=s}else{if((h&255)<194){e=2;break e}e=b+2|0;n=i-b|0;if((h&255)<224){if((n|0)<2){e=1;break e}n=a[s>>0]|0;if((n&192|0)!=128){e=2;break e}if((n&63|(h&255)<<6&1984)>>>0>u>>>0){e=2;break e}t[k>>2]=n&63|(h&255)<<6&1984;break}c=b+3|0;if((h&255)<240){if((n|0)<3){e=1;break e}n=f[e>>0]|0;e=a[s>>0]|0;switch(h<<24>>24){case-32:{if((e&224|0)!=160){e=2;break e}break}case-19:{if((e&224|0)!=128){e=2;break e}break}default:if((e&192|0)!=128){e=2;break e}}if((n&192|0)!=128){e=2;break e}if((e<<6&4032|(h&255)<<12&61440|n&63)>>>0>u>>>0){e=2;break e}t[k>>2]=e<<6&4032|(h&255)<<12&61440|n&63;e=c;break}if((h&255)>=245){e=2;break e}if((n|0)<4){e=1;break e}s=f[s>>0]|0;n=f[e>>0]|0;e=f[c>>0]|0;switch(h<<24>>24){case-16:{if((s+112&255)>=48){e=2;break e}break}case-12:{if((s&240|0)!=128){e=2;break e}break}default:if((s&192|0)!=128){e=2;break e}}if((n&192|0)!=128){e=2;break e}if((e&192|0)!=128){e=2;break e}if(((s&255)<<12&258048|(h&255)<<18&1835008|(n&255)<<6&4032|e&63)>>>0>u>>>0){e=2;break e}t[k>>2]=(s&255)<<12&258048|(h&255)<<18&1835008|(n&255)<<6&4032|e&63;e=b+4|0}}while(0);t[r>>2]=e;k=(t[o>>2]|0)+4|0;t[o>>2]=k;b=t[r>>2]|0;if(b>>>0>=i>>>0){e=0;break}}}else e=0}while(0);return e|0}function Cr(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0;c=k;k=k+272|0;do{if(!(f[i>>0]|0)){i=ni(15075)|0;if(i|0?f[i>>0]|0:0)break;i=ni(15003+(e*12|0)|0)|0;if(i|0?f[i>>0]|0:0)break;i=ni(15082)|0;if(i|0?f[i>>0]|0:0)break;i=15087}}while(0);r=0;e:do{switch(f[i+r>>0]|0){case 47:case 0:break e;default:{}}r=r+1|0}while(r>>>0<15);n=f[i>>0]|0;if(n<<24>>24!=46?(f[i+r>>0]|0)==0:0)if(n<<24>>24==67)b=15;else{s=i;b=16}else{i=15087;b=15}if((b|0)==15)if(!(f[i+1>>0]|0))b=18;else{s=i;b=16}e:do{if((b|0)==16)if((It(s,15087)|0)!=0?(It(s,15095)|0)!=0:0){i=t[4215]|0;if(i|0)do{if(!(It(s,i+8|0)|0))break e;i=t[i+24>>2]|0}while((i|0)!=0);ce(16864);i=t[4215]|0;i:do{if(i|0){while(1){if(!(It(s,i+8|0)|0))break;i=t[i+24>>2]|0;if(!i)break i}Ee(16864);break e}}while(0);i:do{if(((t[4194]|0)==0?(a=ni(15101)|0,(a|0)!=0):0)?(f[a>>0]|0)!=0:0){u=254-r|0;o=r+1|0;n=a;while(1){l=Lf(n)|0;i=f[l>>0]|0;a=((i<<24>>24!=0)<<31>>31)+(l-n)|0;if(a>>>0<u>>>0){Vr(c+8|0,n|0,a|0)|0;f[c+8+a>>0]=47;Vr(c+8+a+1|0,s|0,r|0)|0;f[c+8+(o+a)>>0]=0;a=ui(c+8|0,c|0)|0;if(a|0)break;i=f[l>>0]|0}n=l+(i<<24>>24!=0&1)|0;if(!(f[n>>0]|0)){b=41;break i}}i=Vi(28)|0;n=t[c>>2]|0;if(!i){Ka(a,n);b=41;break}else{t[i>>2]=a;t[i+4>>2]=n;Vr(i+8|0,s|0,r|0)|0;f[i+8+r>>0]=0;t[i+24>>2]=t[4215];t[4215]=i;break}}else b=41}while(0);if((b|0)==41){i=Vi(28)|0;if(i){t[i>>2]=2344;t[i+4>>2]=20;Vr(i+8|0,s|0,r|0)|0;f[i+8+r>>0]=0;t[i+24>>2]=t[4215];t[4215]=i}}Ee(16864);i=(e|0)==0&(i|0)==0?2316:i}else{i=s;b=18}}while(0);do{if((b|0)==18){if((e|0)==0?(f[i+1>>0]|0)==46:0){i=2316;break}i=0}}while(0);k=c;return i|0}function Sr(e,i,r,n,a,l,o,u){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;l=l|0;o=o|0;u=u|0;var s=0,b=0,c=0,h=0,d=0,w=0;w=k;k=k+16|0;e:do{if((r|0)!=(n|0)){s=r;while(1){if(!(f[s>>0]|0))break;s=s+1|0;if((s|0)==(n|0)){s=n;break}}t[u>>2]=l;t[a>>2]=r;if((l|0)==(o|0))d=30;else{while(1){h=t[i+4>>2]|0;t[w>>2]=t[i>>2];t[w+4>>2]=h;h=s;b=Ul(t[e+8>>2]|0)|0;c=Br(l,a,h-r|0,o-l>>2,i)|0;if(b|0)Ul(b)|0;if((c|0)==-1){d=9;break}l=(t[u>>2]|0)+(c<<2)|0;t[u>>2]=l;r=t[a>>2]|0;if((l|0)==(o|0)){d=27;break}if((s|0)==(n|0))s=n;else{s=Ul(t[e+8>>2]|0)|0;r=zr(l,r,1,i)|0;if(s|0)Ul(s)|0;if(r|0){r=2;break}t[u>>2]=(t[u>>2]|0)+4;r=(t[a>>2]|0)+1|0;t[a>>2]=r;i:do{if((r|0)==(n|0))s=n;else{s=r;while(1){if(!(f[s>>0]|0))break i;s=s+1|0;if((s|0)==(n|0)){s=n;break}}}}while(0);l=t[u>>2]|0}if((l|0)==(o|0)|(r|0)==(n|0)){d=30;break e}}if((d|0)==27){d=30;break}i:do{if((d|0)==9){t[u>>2]=l;r:do{if((r|0)!=(t[a>>2]|0)){s=l;f:while(1){l=Ul(t[e+8>>2]|0)|0;s=zr(s,r,h-r|0,w)|0;if(l|0)Ul(l)|0;switch(s|0){case-1:{d=14;break f}case-2:{d=15;break f}case 0:{s=1;break}default:{}}r=r+s|0;s=(t[u>>2]|0)+4|0;t[u>>2]=s;if((r|0)==(t[a>>2]|0))break r}if((d|0)==14){t[a>>2]=r;r=2;break i}else if((d|0)==15){t[a>>2]=r;r=1;break i}}}while(0);t[a>>2]=r;r=(r|0)!=(n|0)&1}}while(0)}}else{t[u>>2]=l;t[a>>2]=r;d=30}}while(0);if((d|0)==30)r=(r|0)!=(n|0)&1;k=w;return r|0}function xr(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0,s=0,b=0;b=k;k=k+32|0;t[b>>2]=t[r>>2];t[b+4>>2]=t[r+4>>2];t[b+4+4>>2]=t[r+4+4>>2];t[b+4+8>>2]=t[r+4+8>>2];t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;a=t[r+16>>2]|0;t[b+16>>2]=a;s=t[r+20>>2]|0;t[b+20>>2]=s;t[b+24>>2]=t[r+24>>2];t[r+24>>2]=0;t[r+20>>2]=0;t[r+16>>2]=0;t[b+28>>2]=t[r+28>>2];e:do{if((a|0)==(s|0))l=5;else{r=t[i+4>>2]|0;while(1){if((t[a>>2]|0)==(r|0)){l=5;break e}a=a+32|0;if((a|0)==(s|0)){a=s;r=s;break}}}}while(0);if((l|0)==5){r=a;if((a|0)==(s|0))a=s;else{l=r;e:while(1){a=t[i+4>>2]|0;do{u=r;r=u+32|0;if((u+32|0)==(s|0))break e;o=t[u+32>>2]|0}while((o|0)==(a|0));t[l>>2]=o;if((f[l+4+11>>0]|0)<0){f[t[l+4>>2]>>0]=0;t[l+8>>2]=0;a=l+4|0}else{f[l+4>>0]=0;f[l+4+11>>0]=0;a=l+4|0}af(l+4|0);t[a>>2]=t[u+36>>2];t[a+4>>2]=t[u+36+4>>2];t[a+8>>2]=t[u+36+8>>2];t[u+36>>2]=0;t[u+36+4>>2]=0;t[u+36+8>>2]=0;n[l+16>>1]=n[u+48>>1]|0;if((f[l+28+3>>0]|0)<0){t[t[l+20>>2]>>2]=0;t[l+24>>2]=0}else{t[l+20>>2]=0;f[l+28+3>>0]=0}ff(l+20|0);t[l+20>>2]=t[u+52>>2];t[l+20+4>>2]=t[u+52+4>>2];t[l+20+8>>2]=t[u+52+8>>2];t[u+52>>2]=0;t[u+52+4>>2]=0;t[u+52+8>>2]=0;l=l+32|0}a=t[b+20>>2]|0;r=l}}jr(b+16|0,r,a);t[e>>2]=t[b>>2];t[e+4>>2]=t[b+4>>2];t[e+4+4>>2]=t[b+4+4>>2];t[e+4+8>>2]=t[b+4+8>>2];t[b+4>>2]=0;t[b+4+4>>2]=0;t[b+4+8>>2]=0;t[e+16>>2]=t[b+16>>2];t[e+20>>2]=t[b+20>>2];t[e+24>>2]=t[b+24>>2];t[b+24>>2]=0;t[b+20>>2]=0;t[b+16>>2]=0;t[e+28>>2]=t[b+28>>2];k=b;return}function Mr(e,i,r,n,a,l,o,u){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;l=l|0;o=o|0;u=u|0;var s=0,b=0,c=0,h=0;c=k;k=k+16|0;e:do{if((r|0)==(n|0))i=r;else{i=r;while(1){if(!(t[i>>2]|0))break e;i=i+4|0;if((i|0)==(n|0)){i=n;break}}}}while(0);t[u>>2]=l;t[a>>2]=r;e:do{if(!((l|0)==(o|0)|(r|0)==(n|0))){i:while(1){s=Ul(t[e+8>>2]|0)|0;b=Gr(l,a,i-r>>2,o-l|0)|0;if(s|0)Ul(s)|0;switch(b|0){case 0:{r=1;break e}case-1:{h=8;break i}default:{}}l=(t[u>>2]|0)+b|0;t[u>>2]=l;if((l|0)==(o|0)){h=30;break}if((i|0)==(n|0)){i=n;r=t[a>>2]|0}else{r=Ul(t[e+8>>2]|0)|0;i=Ef(c,0)|0;if(r|0)Ul(r)|0;if((i|0)==-1){r=2;h=29;break}r=t[u>>2]|0;if(i>>>0>(o-r|0)>>>0){r=1;h=29;break}if(i|0?(b=f[c>>0]|0,t[u>>2]=r+1,f[r>>0]=b,i+-1|0):0){r=i+-1|0;i=c;do{i=i+1|0;b=t[u>>2]|0;s=f[i>>0]|0;t[u>>2]=b+1;f[b>>0]=s;r=r+-1|0}while((r|0)!=0)}r=(t[a>>2]|0)+4|0;t[a>>2]=r;r:do{if((r|0)==(n|0))i=n;else{i=r;while(1){if(!(t[i>>2]|0))break r;i=i+4|0;if((i|0)==(n|0)){i=n;break}}}}while(0);l=t[u>>2]|0}if((l|0)==(o|0)|(r|0)==(n|0)){h=31;break e}}if((h|0)==8){t[u>>2]=l;i:do{if((r|0)!=(t[a>>2]|0)){i=l;do{n=t[r>>2]|0;l=Ul(t[e+8>>2]|0)|0;i=Ef(i,n)|0;if(l|0)Ul(l)|0;if((i|0)==-1)break i;i=(t[u>>2]|0)+i|0;t[u>>2]=i;r=r+4|0}while((r|0)!=(t[a>>2]|0))}}while(0);t[a>>2]=r;r=2;break}else if((h|0)==29)break;else if((h|0)==30){r=t[a>>2]|0;h=31;break}}else h=31}while(0);if((h|0)==31)r=(r|0)!=(n|0)&1;k=c;return r|0}function Fr(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0;u=k;k=k+32|0;t[u>>2]=t[r>>2];t[u+4>>2]=t[r+4>>2];t[u+4+4>>2]=t[r+4+4>>2];t[u+4+8>>2]=t[r+4+8>>2];t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;i=t[r+16>>2]|0;t[u+16>>2]=i;o=t[r+20>>2]|0;t[u+20>>2]=o;t[u+24>>2]=t[r+24>>2];t[r+24>>2]=0;t[r+20>>2]=0;t[r+16>>2]=0;t[u+28>>2]=t[r+28>>2];e:do{if((i|0)==(o|0))l=4;else while(1){if(f[i+16>>0]|0){l=4;break e}i=i+32|0;if((i|0)==(o|0)){a=o;i=o;break}}}while(0);if((l|0)==4){r=i;if((i|0)==(o|0)){a=o;i=r}else{i=r;e:while(1){do{l=r;r=l+32|0;if((l+32|0)==(o|0))break e}while((f[l+48>>0]|0)!=0);t[i>>2]=t[l+32>>2];if((f[i+4+11>>0]|0)<0){f[t[i+4>>2]>>0]=0;t[i+8>>2]=0;a=i+4|0}else{f[i+4>>0]=0;f[i+4+11>>0]=0;a=i+4|0}af(i+4|0);t[a>>2]=t[l+36>>2];t[a+4>>2]=t[l+36+4>>2];t[a+8>>2]=t[l+36+8>>2];t[l+36>>2]=0;t[l+36+4>>2]=0;t[l+36+8>>2]=0;n[i+16>>1]=n[l+48>>1]|0;if((f[i+28+3>>0]|0)<0){t[t[i+20>>2]>>2]=0;t[i+24>>2]=0}else{t[i+20>>2]=0;f[i+28+3>>0]=0}ff(i+20|0);t[i+20>>2]=t[l+52>>2];t[i+20+4>>2]=t[l+52+4>>2];t[i+20+8>>2]=t[l+52+8>>2];t[l+52>>2]=0;t[l+52+4>>2]=0;t[l+52+8>>2]=0;i=i+32|0}a=t[u+20>>2]|0}}jr(u+16|0,i,a);t[e>>2]=t[u>>2];t[e+4>>2]=t[u+4>>2];t[e+4+4>>2]=t[u+4+4>>2];t[e+4+8>>2]=t[u+4+8>>2];t[u+4>>2]=0;t[u+4+4>>2]=0;t[u+4+8>>2]=0;t[e+16>>2]=t[u+16>>2];t[e+20>>2]=t[u+20>>2];t[e+24>>2]=t[u+24>>2];t[u+24>>2]=0;t[u+20>>2]=0;t[u+16>>2]=0;t[e+28>>2]=t[u+28>>2];k=u;return}function Pr(e,i,r,n,t){e=e|0;i=i|0;r=r|0;n=n|0;t=t|0;var l=0,o=0,u=0,s=0,b=0,c=0,h=0,k=0;if(((i-e|0)>2&(t&4|0)!=0?(f[e>>0]|0)==-17:0)?(f[e+1>>0]|0)==-69:0)l=(f[e+2>>0]|0)==-65?e+3|0:e;else l=e;t=l;e:do{if((r|0)!=0&l>>>0<i>>>0){k=0;do{h=f[l>>0]|0;u=l+1|0;do{if(h<<24>>24>-1)if((h&255)>>>0>n>>>0)break e;else l=u;else{if((h&255)<194)break e;b=l+2|0;o=i-t|0;if((h&255)<224){if((o|0)<2)break e;l=a[u>>0]|0;if((l&192|0)!=128)break e;if((l&63|(h&255)<<6&1984)>>>0>n>>>0)break e;else{l=b;break}}c=l+3|0;if((h&255)<240){if((o|0)<3)break e;o=f[b>>0]|0;l=a[u>>0]|0;switch(h<<24>>24){case-32:{if((l&224|0)!=160)break e;break}case-19:{if((l&224|0)!=128)break e;break}default:if((l&192|0)!=128)break e}if((o&192|0)!=128)break e;if((l<<6&4032|(h&255)<<12&61440|o&63)>>>0>n>>>0)break e;else{l=c;break}}if((o|0)<4|(h&255)>244)break e;s=f[u>>0]|0;u=f[b>>0]|0;o=f[c>>0]|0;switch(h<<24>>24){case-16:{if((s+112&255)>=48)break e;break}case-12:{if((s&240|0)!=128)break e;break}default:if((s&192|0)!=128)break e}if((u&192|0)!=128)break e;if((o&192|0)!=128)break e;if(((s&255)<<12&258048|(h&255)<<18&1835008|(u&255)<<6&4032|o&63)>>>0>n>>>0)break e;else l=l+4|0}}while(0);k=k+1|0;t=l}while(k>>>0<r>>>0&l>>>0<i>>>0)}}while(0);return t-e|0}function Rr(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0;f[i+12>>0]=(i|0)==(e|0)&1;if((i|0)==(e|0))return;while(1){a=i+8|0;l=t[a>>2]|0;if(f[l+12>>0]|0){r=23;break}n=t[l+8>>2]|0;r=t[n>>2]|0;if((r|0)==(l|0)){r=t[n+4>>2]|0;if(!r){r=7;break}if(!(f[r+12>>0]|0))i=r+12|0;else{r=7;break}}else{if(!r){r=16;break}if(!(f[r+12>>0]|0))i=r+12|0;else{r=16;break}}f[l+12>>0]=1;f[n+12>>0]=(n|0)==(e|0)&1;f[i>>0]=1;if((n|0)==(e|0)){r=23;break}else i=n}if((r|0)==7){if((t[l>>2]|0)==(i|0))i=l;else{r=t[l+4>>2]|0;i=t[r>>2]|0;t[l+4>>2]=i;if(!i)i=n;else{t[i+8>>2]=l;i=t[l+8>>2]|0}t[r+8>>2]=i;i=t[l+8>>2]|0;t[((t[i>>2]|0)==(l|0)?i:i+4|0)>>2]=r;t[r>>2]=l;t[l+8>>2]=r;i=r;n=t[r+8>>2]|0}f[i+12>>0]=1;f[n+12>>0]=0;i=t[n>>2]|0;r=t[i+4>>2]|0;t[n>>2]=r;if(r|0)t[r+8>>2]=n;l=n+8|0;t[i+8>>2]=t[l>>2];a=t[l>>2]|0;t[((t[a>>2]|0)==(n|0)?a:a+4|0)>>2]=i;t[i+4>>2]=n;t[l>>2]=i;return}else if((r|0)==16){if((t[l>>2]|0)==(i|0)){e=i+4|0;r=t[e>>2]|0;t[l>>2]=r;if(r){t[r+8>>2]=l;n=t[l+8>>2]|0}t[a>>2]=n;n=t[l+8>>2]|0;t[((t[n>>2]|0)==(l|0)?n:n+4|0)>>2]=i;t[e>>2]=l;t[l+8>>2]=i;n=t[a>>2]|0}else i=l;f[i+12>>0]=1;f[n+12>>0]=0;l=n+4|0;i=t[l>>2]|0;r=t[i>>2]|0;t[l>>2]=r;if(r|0)t[r+8>>2]=n;l=n+8|0;t[i+8>>2]=t[l>>2];a=t[l>>2]|0;t[((t[a>>2]|0)==(n|0)?a:a+4|0)>>2]=i;t[i>>2]=n;t[l>>2]=i;return}else if((r|0)==23)return}function Or(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0,o=0;a=k;k=k+80|0;n=t[i>>2]|0;t[i>>2]=0;l=Ei(7348)|0;i=Oe(n|0,l|0)|0;fi(l|0);l=Ei(6319)|0;r=Oe(i|0,l|0)|0;fi(l|0);o=+Ne(r|0,256,a+60|0);l=t[a+60>>2]|0;Af(a+36|0,~~o>>>0);vi(l|0);Xi(a+48|0,a+36|0);if((f[a+36+8+3>>0]|0)<0)pu(t[a+36>>2]|0);fi(r|0);fi(i|0);l=Ei(7574)|0;i=Oe(n|0,l|0)|0;fi(l|0);o=+Ne(i|0,1152,a+60|0);vi(t[a+60>>2]|0);if((~~o|0)==13){l=f[a+48+11>>0]|0;r=t[a+48+4>>2]|0;fi(i|0);if((l<<24>>24<0?r:l&255)|0){$f(a+24|0,a+48|0);$f(a+60|0,a+24|0);i=Vt(16)|0;t[i>>2]=2096;t[i+4>>2]=t[a+60>>2];t[i+4+4>>2]=t[a+60+4>>2];t[i+4+8>>2]=t[a+60+8>>2];t[a+16>>2]=i;i=t[e+24>>2]|0;if(!i){l=xe(4)|0;t[l>>2]=1256;Fi(l|0,8,1)}Pu[t[(t[i>>2]|0)+24>>2]&31](i,a);i=t[a+16>>2]|0;if((i|0)!=(a|0)){if(i|0)Fu[t[(t[i>>2]|0)+20>>2]&127](i)}else Fu[t[(t[i>>2]|0)+16>>2]&127](i);if((f[a+24+11>>0]|0)<0){pu(t[a+24>>2]|0);i=a+48+11|0}else i=a+48+11|0}else i=a+48+11|0}else{fi(i|0);i=a+48+11|0}if((f[i>>0]|0)>=0){fi(n|0);k=a;return 1}pu(t[a+48>>2]|0);fi(n|0);k=a;return 1}function Ir(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0,o=0;a=k;k=k+80|0;n=t[i>>2]|0;t[i>>2]=0;l=Ei(7348)|0;i=Oe(n|0,l|0)|0;fi(l|0);l=Ei(6319)|0;r=Oe(i|0,l|0)|0;fi(l|0);o=+Ne(r|0,256,a+60|0);l=t[a+60>>2]|0;Af(a+36|0,~~o>>>0);vi(l|0);Xi(a+48|0,a+36|0);if((f[a+36+8+3>>0]|0)<0)pu(t[a+36>>2]|0);fi(r|0);fi(i|0);l=Ei(7574)|0;i=Oe(n|0,l|0)|0;fi(l|0);o=+Ne(i|0,1152,a+60|0);vi(t[a+60>>2]|0);if((~~o|0)==13){l=f[a+48+11>>0]|0;r=t[a+48+4>>2]|0;fi(i|0);if((l<<24>>24<0?r:l&255)|0){$f(a+24|0,a+48|0);$f(a+60|0,a+24|0);i=Vt(16)|0;t[i>>2]=1776;t[i+4>>2]=t[a+60>>2];t[i+4+4>>2]=t[a+60+4>>2];t[i+4+8>>2]=t[a+60+8>>2];t[a+16>>2]=i;i=t[e+24>>2]|0;if(!i){l=xe(4)|0;t[l>>2]=1256;Fi(l|0,8,1)}Pu[t[(t[i>>2]|0)+24>>2]&31](i,a);i=t[a+16>>2]|0;if((i|0)!=(a|0)){if(i|0)Fu[t[(t[i>>2]|0)+20>>2]&127](i)}else Fu[t[(t[i>>2]|0)+16>>2]&127](i);if((f[a+24+11>>0]|0)<0){pu(t[a+24>>2]|0);i=a+48+11|0}else i=a+48+11|0}else i=a+48+11|0}else{fi(i|0);i=a+48+11|0}if((f[i>>0]|0)>=0){fi(n|0);k=a;return 1}pu(t[a+48>>2]|0);fi(n|0);k=a;return 1}function Nr(e,i){e=e|0;i=i|0;var r=0,a=0,l=0,o=0,u=0,s=0,b=0;r=t[e>>2]|0;l=(t[e+4>>2]|0)-r>>5;if((l+1|0)>>>0>134217727)au();r=(t[e+8>>2]|0)-r|0;r=r>>5>>>0<67108863?r>>4>>>0<(l+1|0)>>>0?l+1|0:r>>4:134217727;do{if(r)if(r>>>0>134217727){e=xe(8)|0;ao(e,7681);t[e>>2]=3404;Fi(e|0,992,95)}else{a=Vt(r<<5)|0;break}else a=0}while(0);s=a+(l<<5)|0;u=a+(r<<5)|0;t[s>>2]=t[i>>2];$f(a+(l<<5)+4|0,i+4|0);n[a+(l<<5)+16>>1]=n[i+16>>1]|0;xf(a+(l<<5)+20|0,i+20|0);o=t[e>>2]|0;r=t[e+4>>2]|0;if((r|0)==(o|0)){a=s;l=o;r=o}else{i=s;a=s;do{l=r;r=r+-32|0;t[i+-32>>2]=t[r>>2];b=i+-28|0;t[b>>2]=t[l+-28>>2];t[b+4>>2]=t[l+-28+4>>2];t[b+8>>2]=t[l+-28+8>>2];t[l+-28>>2]=0;t[l+-28+4>>2]=0;t[l+-28+8>>2]=0;n[i+-16>>1]=n[l+-16>>1]|0;b=i+-12|0;t[b>>2]=t[l+-12>>2];t[b+4>>2]=t[l+-12+4>>2];t[b+8>>2]=t[l+-12+8>>2];t[l+-12>>2]=0;t[l+-12+4>>2]=0;t[l+-12+8>>2]=0;i=a+-32|0;a=i}while((r|0)!=(o|0));l=t[e>>2]|0;r=t[e+4>>2]|0}t[e>>2]=a;t[e+4>>2]=s+32;t[e+8>>2]=u;i=l;if((r|0)!=(i|0))do{if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);a=r+-28|0;r=r+-32|0;if((f[a+11>>0]|0)<0)pu(t[a>>2]|0)}while((r|0)!=(i|0));if(!l)return;pu(l);return}function Lr(e,i,r,n,a,l,o,u){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;l=l|0;o=o|0;u=u|0;var s=0;t[r>>2]=e;t[l>>2]=n;if(u&2)if((a-n|0)<3)e=1;else{t[l>>2]=n+1;f[n>>0]=-17;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=-69;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=-65;s=4}else s=4;e:do{if((s|0)==4){e=t[r>>2]|0;if(e>>>0<i>>>0)while(1){u=t[e>>2]|0;if(u>>>0>o>>>0|(u&-2048|0)==55296){e=2;break e}do{if(u>>>0>=128){if(u>>>0<2048){e=t[l>>2]|0;if((a-e|0)<2){e=1;break e}t[l>>2]=e+1;f[e>>0]=u>>>6|192;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=u&63|128;break}e=t[l>>2]|0;if(u>>>0<65536){if((a-e|0)<3){e=1;break e}t[l>>2]=e+1;f[e>>0]=u>>>12|224;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=u>>>6&63|128;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=u&63|128;break}else{if((a-e|0)<4){e=1;break e}t[l>>2]=e+1;f[e>>0]=u>>>18|240;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=u>>>12&63|128;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=u>>>6&63|128;s=t[l>>2]|0;t[l>>2]=s+1;f[s>>0]=u&63|128;break}}else{e=t[l>>2]|0;if((a-e|0)<1){e=1;break e}t[l>>2]=e+1;f[e>>0]=u}}while(0);e=(t[r>>2]|0)+4|0;t[r>>2]=e;if(e>>>0>=i>>>0){e=0;break}}else e=0}}while(0);return e|0}function Dr(e,i,r){e=e|0;i=i|0;r=r|0;var f=0,n=0,a=0;e:do{if(i>>>0<=20)do{switch(i|0){case 9:{f=(t[r>>2]|0)+(4-1)&~(4-1);i=t[f>>2]|0;t[r>>2]=f+4;t[e>>2]=i;break e}case 10:{i=(t[r>>2]|0)+(4-1)&~(4-1);f=t[i>>2]|0;t[r>>2]=i+4;t[e>>2]=f;t[e+4>>2]=((f|0)<0)<<31>>31;break e}case 11:{i=(t[r>>2]|0)+(4-1)&~(4-1);f=t[i>>2]|0;t[r>>2]=i+4;t[e>>2]=f;t[e+4>>2]=0;break e}case 12:{n=(t[r>>2]|0)+(8-1)&~(8-1);i=t[n>>2]|0;f=t[n+4>>2]|0;t[r>>2]=n+8;t[e>>2]=i;t[e+4>>2]=f;break e}case 13:{f=(t[r>>2]|0)+(4-1)&~(4-1);n=t[f>>2]|0;t[r>>2]=f+4;t[e>>2]=(n&65535)<<16>>16;t[e+4>>2]=(((n&65535)<<16>>16|0)<0)<<31>>31;break e}case 14:{f=(t[r>>2]|0)+(4-1)&~(4-1);n=t[f>>2]|0;t[r>>2]=f+4;t[e>>2]=n&65535;t[e+4>>2]=0;break e}case 15:{f=(t[r>>2]|0)+(4-1)&~(4-1);n=t[f>>2]|0;t[r>>2]=f+4;t[e>>2]=(n&255)<<24>>24;t[e+4>>2]=(((n&255)<<24>>24|0)<0)<<31>>31;break e}case 16:{f=(t[r>>2]|0)+(4-1)&~(4-1);n=t[f>>2]|0;t[r>>2]=f+4;t[e>>2]=n&255;t[e+4>>2]=0;break e}case 17:{n=(t[r>>2]|0)+(8-1)&~(8-1);a=+s[n>>3];t[r>>2]=n+8;s[e>>3]=a;break e}case 18:{n=(t[r>>2]|0)+(8-1)&~(8-1);a=+s[n>>3];t[r>>2]=n+8;s[e>>3]=a;break e}default:break e}}while(0)}while(0);return}function Ur(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0,o=0;o=k;k=k+16|0;e:do{if(!e){n=t[i>>2]|0;r=t[n>>2]|0;if(!r)r=0;else{e=0;while(1){if(r>>>0>127){r=Ef(o,r)|0;if((r|0)==-1){r=-1;break e}}else r=1;e=r+e|0;n=n+4|0;r=t[n>>2]|0;if(!r){r=e;break}}}}else{i:do{if(r>>>0>3){a=t[i>>2]|0;n=r;l=e;while(1){e=t[a>>2]|0;if((e+-1|0)>>>0>126){if(!e)break;e=Ef(l,e)|0;if((e|0)==-1){r=-1;break e}n=n-e|0;e=l+e|0}else{f[l>>0]=e;a=t[i>>2]|0;n=n+-1|0;e=l+1|0}a=a+4|0;t[i>>2]=a;if(n>>>0<=3)break i;else l=e}f[l>>0]=0;t[i>>2]=0;r=r-n|0;break e}else n=r}while(0);if(n){a=t[i>>2]|0;l=e;while(1){e=t[a>>2]|0;if((e+-1|0)>>>0>126){if(!e){e=19;break}e=Ef(o,e)|0;if((e|0)==-1){r=-1;break e}if(n>>>0<e>>>0){e=22;break}Ef(l,t[a>>2]|0)|0;n=n-e|0;e=l+e|0}else{f[l>>0]=e;a=t[i>>2]|0;n=n+-1|0;e=l+1|0}a=a+4|0;t[i>>2]=a;if(!n)break e;else l=e}if((e|0)==19){f[l>>0]=0;t[i>>2]=0;r=r-n|0;break}else if((e|0)==22){r=r-n|0;break}}}}while(0);k=o;return r|0}function Hr(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0,o=0;n=f[e+12+11>>0]|0;l=n<<24>>24<0?t[e+16>>2]|0:n&255;r=f[i+12+11>>0]|0;if((l|0)!=((r<<24>>24<0?t[i+16>>2]|0:r&255)|0)){i=0;return i|0}a=t[e+12>>2]|0;o=n<<24>>24<0?a:e+12|0;r=r<<24>>24<0?t[i+12>>2]|0:i+12|0;e:do{if(n<<24>>24<0){if(l|0?wt(o,r,l)|0:0){i=0;return i|0}}else if(l|0){if((a&255)<<24>>24==(f[r>>0]|0)){n=n&255;a=e+12|0}else{i=0;return i|0}while(1){n=n+-1|0;a=a+1|0;if(!n)break e;r=r+1|0;if((f[a>>0]|0)!=(f[r>>0]|0)){r=0;break}}return r|0}}while(0);n=f[e+11>>0]|0;o=n<<24>>24<0?t[e+4>>2]|0:n&255;r=f[i+11>>0]|0;if((o|0)!=((r<<24>>24<0?t[i+4>>2]|0:r&255)|0)){i=0;return i|0}a=t[e>>2]|0;l=n<<24>>24<0?a:e;r=r<<24>>24<0?t[i>>2]|0:i;if(n<<24>>24<0){if(!o){i=1;return i|0}i=(wt(l,r,o)|0)==0;return i|0}if(!o){i=1;return i|0}if((a&255)<<24>>24==(f[r>>0]|0))n=n&255;else{i=0;return i|0}while(1){n=n+-1|0;e=e+1|0;if(!n){r=1;e=17;break}r=r+1|0;if((f[e>>0]|0)!=(f[r>>0]|0)){r=0;e=17;break}}if((e|0)==17)return r|0;return 0}function Wr(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0;n=t[e+4>>2]|0;if(!n){t[i>>2]=e+4;h=e+4|0;return h|0}s=f[r+11>>0]|0;h=s<<24>>24<0?t[r+4>>2]|0:s&255;s=s<<24>>24<0?t[r>>2]|0:r;e=e+4|0;while(1){l=n+16|0;a=f[l+11>>0]|0;o=a<<24>>24<0?t[n+20>>2]|0:a&255;r=o>>>0<h>>>0?o:h;if((r|0)!=0?(c=wt(s,a<<24>>24<0?t[l>>2]|0:l,r)|0,(c|0)!=0):0)if((c|0)<0)u=8;else u=10;else if(h>>>0<o>>>0)u=8;else u=10;if((u|0)==8){r=t[n>>2]|0;if(!r){u=9;break}else e=n}else if((u|0)==10){u=0;r=h>>>0<o>>>0?h:o;if((r|0)!=0?(b=wt(a<<24>>24<0?t[l>>2]|0:l,s,r)|0,(b|0)!=0):0){if((b|0)>=0){u=16;break}}else u=12;if((u|0)==12?(0,o>>>0>=h>>>0):0){u=16;break}e=n+4|0;r=t[e>>2]|0;if(!r){u=15;break}}n=r}if((u|0)==9){t[i>>2]=n;h=n;return h|0}else if((u|0)==15){t[i>>2]=n;h=e;return h|0}else if((u|0)==16){t[i>>2]=n;h=e;return h|0}return 0}function Br(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;var a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0;h=k;k=k+1040|0;u=t[i>>2]|0;t[h>>2]=u;o=e|0?f:256;l=e|0?e:h+8|0;e:do{if((o|0)!=0&(u|0)!=0){a=u;f=0;s=r;b=l;while(1){l=s>>>2;r=l>>>0>=o>>>0;if(!(s>>>0>131|r)){r=s;l=b;break e}a=r?o:l;r=s-a|0;a=kr(b,h,a,n)|0;if((a|0)==-1)break;l=(b|0)==(h+8|0);o=o-(l?0:a)|0;l=l?b:b+(a<<2)|0;f=a+f|0;u=t[h>>2]|0;if((o|0)!=0&(u|0)!=0){a=u;s=r;b=l}else{a=u;break e}}u=t[h>>2]|0;a=u;f=-1;o=0;l=b}else{a=u;f=0}}while(0);e:do{if((u|0)!=0?(o|0)!=0&(r|0)!=0:0){a=u;u=r;while(1){r=zr(l,a,u,n)|0;if((r+2|0)>>>0<3)break;a=a+r|0;u=u-r|0;o=o+-1|0;f=f+1|0;if(!((o|0)!=0&(u|0)!=0)){c=13;break}else l=l+4|0}if((c|0)==13){t[h>>2]=a;break}t[h>>2]=a;switch(r|0){case-1:{f=-1;break e}case 0:{t[h>>2]=0;a=0;break e}default:{t[n>>2]=0;break e}}}}while(0);if(e|0)t[i>>2]=a;k=h;return f|0}function jr(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0;if((i|0)==(r|0))return;u=t[e+4>>2]|0;if((u|0)!=(r|0)){do{t[i>>2]=t[r>>2];l=i+4|0;o=r+4|0;if((f[l+11>>0]|0)<0){f[t[l>>2]>>0]=0;t[i+8>>2]=0;a=l}else{f[l>>0]=0;f[l+11>>0]=0;a=l}af(l);t[a>>2]=t[o>>2];t[a+4>>2]=t[o+4>>2];t[a+8>>2]=t[o+8>>2];t[o>>2]=0;t[o+4>>2]=0;t[o+8>>2]=0;n[i+16>>1]=n[r+16>>1]|0;l=i+20|0;o=r+20|0;a=i+28+3|0;if((f[a>>0]|0)<0){t[t[l>>2]>>2]=0;t[i+24>>2]=0}else{t[l>>2]=0;f[a>>0]=0}ff(l);t[l>>2]=t[o>>2];t[l+4>>2]=t[o+4>>2];t[l+8>>2]=t[o+8>>2];t[o>>2]=0;t[o+4>>2]=0;t[o+8>>2]=0;r=r+32|0;i=i+32|0}while((r|0)!=(u|0));r=t[e+4>>2]|0}if((r|0)==(i|0))return;do{t[e+4>>2]=r+-32;if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);r=r+-28|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);r=t[e+4>>2]|0}while((r|0)!=(i|0));return}function zr(e,i,r,n){e=e|0;i=i|0;r=r|0;n=n|0;var a=0,l=0,o=0,u=0,s=0;s=k;k=k+16|0;o=(n|0)==0?16856:n;n=t[o>>2]|0;e:do{if(!i)if(!n)n=0;else u=17;else{l=(e|0)==0?s:e;if(!r)n=-2;else{if(!n){n=f[i>>0]|0;if(n<<24>>24>-1){t[l>>2]=n&255;n=n<<24>>24!=0&1;break}if(!(t[t[895]>>2]|0)){t[l>>2]=n<<24>>24&57343;n=1;break}if(((n&255)+-194|0)>>>0>50){u=17;break}n=t[2388+((n&255)+-194<<2)>>2]|0;if(r+-1|0){a=r+-1|0;i=i+1|0;u=11}}else{a=r;u=11}i:do{if((u|0)==11){e=f[i>>0]|0;if((((e&255)>>>3)+-16|((e&255)>>>3)+(n>>26))>>>0>7){u=17;break e}while(1){i=i+1|0;n=n<<6|(e&255)+-128;a=a+-1|0;if((n|0)>=0)break;if(!a)break i;e=f[i>>0]|0;if((e&-64)<<24>>24!=-128){u=17;break e}}t[o>>2]=0;t[l>>2]=n;n=r-a|0;break e}}while(0);t[o>>2]=n;n=-2}}}while(0);if((u|0)==17){t[o>>2]=0;t[4223]=84;n=-1}k=s;return n|0}function Vr(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0;if((r|0)>=8192)return We(e|0,i|0,r|0)|0;l=e|0;a=e+r|0;if((e&3)==(i&3)){while(e&3){if(!r)return l|0;f[e>>0]=f[i>>0]|0;e=e+1|0;i=i+1|0;r=r-1|0}r=a&-4|0;n=r-64|0;while((e|0)<=(n|0)){t[e>>2]=t[i>>2];t[e+4>>2]=t[i+4>>2];t[e+8>>2]=t[i+8>>2];t[e+12>>2]=t[i+12>>2];t[e+16>>2]=t[i+16>>2];t[e+20>>2]=t[i+20>>2];t[e+24>>2]=t[i+24>>2];t[e+28>>2]=t[i+28>>2];t[e+32>>2]=t[i+32>>2];t[e+36>>2]=t[i+36>>2];t[e+40>>2]=t[i+40>>2];t[e+44>>2]=t[i+44>>2];t[e+48>>2]=t[i+48>>2];t[e+52>>2]=t[i+52>>2];t[e+56>>2]=t[i+56>>2];t[e+60>>2]=t[i+60>>2];e=e+64|0;i=i+64|0}while((e|0)<(r|0)){t[e>>2]=t[i>>2];e=e+4|0;i=i+4|0}}else{r=a-4|0;while((e|0)<(r|0)){f[e>>0]=f[i>>0]|0;f[e+1>>0]=f[i+1>>0]|0;f[e+2>>0]=f[i+2>>0]|0;f[e+3>>0]=f[i+3>>0]|0;e=e+4|0;i=i+4|0}}while((e|0)<(a|0)){f[e>>0]=f[i>>0]|0;e=e+1|0;i=i+1|0}return l|0}function Gr(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;var n=0,a=0,l=0,o=0,u=0,s=0,b=0;b=k;k=k+272|0;s=t[i>>2]|0;t[b>>2]=s;a=e|0?f:256;l=e|0?e:b+8|0;e:do{if((a|0)!=0&(s|0)!=0){n=s;f=0;o=a;u=r;r=s;while(1){a=u>>>0>=o>>>0;if(!(u>>>0>32|a)){a=r;break e}n=a?o:u;u=u-n|0;n=Ur(l,b,n)|0;if((n|0)==-1)break;a=(l|0)==(b+8|0);o=o-(a?0:n)|0;l=a?l:l+n|0;f=n+f|0;a=t[b>>2]|0;if((o|0)!=0&(a|0)!=0){n=a;r=a}else{n=a;break e}}a=t[b>>2]|0;n=a;f=-1;o=0}else{n=s;f=0;o=a;u=r;a=s}}while(0);do{if((a|0)!=0?(o|0)!=0&(u|0)!=0:0){n=a;a=u;while(1){r=Ef(l,t[n>>2]|0)|0;if((r+1|0)>>>0<2){a=9;break}n=n+4|0;a=a+-1|0;o=o-r|0;f=r+f|0;if(!((a|0)!=0&(o|0)!=0)){a=11;break}else l=l+r|0}if((a|0)==9){n=(r|0)==0?0:n;t[b>>2]=n;f=(r|0)==0?f:-1;break}else if((a|0)==11){t[b>>2]=n;break}}}while(0);if(e|0)t[i>>2]=n;k=b;return f|0}function qr(){He(1088,16121);Be(1104,16126,1,1,0);ii(1112,16066,1,-128,127);ii(1128,16071,1,-128,127);ii(1120,16083,1,0,255);ii(1136,16097,2,-32768,32767);ii(1144,16103,2,0,65535);ii(1152,16131,4,-2147483648,2147483647);ii(1160,16135,4,0,-1);ii(1168,16148,4,-2147483648,2147483647);ii(1176,16153,4,0,-1);Ri(1184,16167,4);Ri(1192,16173,8);Li(32,16048);Li(696,11477);qe(256,4,11510);Hi(24,11523);_e(720,0,11539);_e(728,0,11569);_e(736,1,11606);_e(744,2,11645);_e(752,3,11676);_e(760,4,11716);_e(768,5,11745);_e(776,4,11783);_e(784,5,11813);_e(728,0,11852);_e(736,1,11884);_e(744,2,11917);_e(752,3,11950);_e(760,4,11984);_e(768,5,12017);_e(792,6,12051);_e(800,7,12082);_e(808,7,12114);return}function Kr(e,i,r){e=e|0;i=i|0;r=r|0;var f=0,n=0,a=0,l=0,o=0,u=0,s=0;o=k;k=k+48|0;a=t[e+28>>2]|0;t[o+32>>2]=a;a=(t[e+20>>2]|0)-a|0;t[o+32+4>>2]=a;t[o+32+8>>2]=i;t[o+32+12>>2]=r;t[o>>2]=t[e+60>>2];t[o+4>>2]=o+32;t[o+8>>2]=2;i=Mo(pi(146,o|0)|0)|0;e:do{if((a+r|0)!=(i|0)){f=o+32|0;n=2;a=a+r|0;while(1){if((i|0)<0)break;a=a-i|0;u=t[f+4>>2]|0;s=i>>>0>u>>>0;f=s?f+8|0:f;n=(s<<31>>31)+n|0;u=i-(s?u:0)|0;t[f>>2]=(t[f>>2]|0)+u;t[f+4>>2]=(t[f+4>>2]|0)-u;t[o+16>>2]=t[e+60>>2];t[o+16+4>>2]=f;t[o+16+8>>2]=n;i=Mo(pi(146,o+16|0)|0)|0;if((a|0)==(i|0)){l=3;break e}}t[e+16>>2]=0;t[e+28>>2]=0;t[e+20>>2]=0;t[e>>2]=t[e>>2]|32;if((n|0)==2)r=0;else r=r-(t[f+4>>2]|0)|0}else l=3}while(0);if((l|0)==3){s=t[e+44>>2]|0;t[e+16>>2]=s+(t[e+48>>2]|0);t[e+28>>2]=s;t[e+20>>2]=s}k=o;return r|0}function Jr(e){e=e|0;var i=0,r=0,f=0,a=0;a=Vt(36)|0;t[a>>2]=1336;t[a+4>>2]=t[e+4>>2];$f(a+8|0,e+8|0);t[a+20>>2]=0;t[a+24>>2]=0;t[a+28>>2]=0;i=(t[e+24>>2]|0)-(t[e+20>>2]|0)|0;if(!(i>>5)){f=a+32|0;e=e+32|0;e=t[e>>2]|0;t[f>>2]=e;return a|0}if(i>>5>>>0>134217727)au();r=Vt(i)|0;t[a+24>>2]=r;t[a+20>>2]=r;t[a+28>>2]=r+(i>>5<<5);i=t[e+20>>2]|0;f=t[e+24>>2]|0;if((i|0)==(f|0)){f=a+32|0;e=e+32|0;e=t[e>>2]|0;t[f>>2]=e;return a|0}do{t[r>>2]=t[i>>2];$f(r+4|0,i+4|0);n[r+16>>1]=n[i+16>>1]|0;xf(r+20|0,i+20|0);i=i+32|0;r=(t[a+24>>2]|0)+32|0;t[a+24>>2]=r}while((i|0)!=(f|0));f=a+32|0;e=e+32|0;e=t[e>>2]|0;t[f>>2]=e;return a|0}function Yr(e,i){e=e|0;i=i|0;var r=0,f=0,a=0;t[i>>2]=1336;t[i+4>>2]=t[e+4>>2];$f(i+8|0,e+8|0);t[i+20>>2]=0;t[i+24>>2]=0;t[i+28>>2]=0;r=(t[e+24>>2]|0)-(t[e+20>>2]|0)|0;if(!(r>>5)){i=i+32|0;e=e+32|0;e=t[e>>2]|0;t[i>>2]=e;return}if(r>>5>>>0>134217727)au();f=Vt(r)|0;t[i+24>>2]=f;t[i+20>>2]=f;t[i+28>>2]=f+(r>>5<<5);r=t[e+20>>2]|0;a=t[e+24>>2]|0;if((r|0)==(a|0)){i=i+32|0;e=e+32|0;e=t[e>>2]|0;t[i>>2]=e;return}do{t[f>>2]=t[r>>2];$f(f+4|0,r+4|0);n[f+16>>1]=n[r+16>>1]|0;xf(f+20|0,r+20|0);r=r+32|0;f=(t[i+24>>2]|0)+32|0;t[i+24>>2]=f}while((r|0)!=(a|0));i=i+32|0;e=e+32|0;e=t[e>>2]|0;t[i>>2]=e;return}function Xr(e,i,r,n,a){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;var l=0;do{if(!(Ro(e,t[i+8>>2]|0)|0)){if(!(Ro(e,t[i>>2]|0)|0)){l=t[e+8>>2]|0;Mu[t[(t[l>>2]|0)+24>>2]&3](l,i,r,n,a);break}if((t[i+16>>2]|0)!=(r|0)?(t[i+20>>2]|0)!=(r|0):0){t[i+32>>2]=n;if((t[i+44>>2]|0)==4)break;f[i+52>>0]=0;f[i+53>>0]=0;e=t[e+8>>2]|0;Du[t[(t[e>>2]|0)+20>>2]&3](e,i,r,r,1,a);if(f[i+53>>0]|0)if(!(f[i+52>>0]|0)){n=3;l=11}else n=3;else{n=4;l=11}if((l|0)==11){t[i+20>>2]=r;t[i+40>>2]=(t[i+40>>2]|0)+1;if((t[i+36>>2]|0)==1?(t[i+24>>2]|0)==2:0)f[i+54>>0]=1}t[i+44>>2]=n;break}if((n|0)==1)t[i+32>>2]=1}else wa(i,r,n)}while(0);return}function Zr(e,i,r){e=e|0;i=i|0;r=r|0;var a=0;a=k;k=k+32|0;t[a>>2]=t[r>>2];t[a+4>>2]=t[r+4>>2];t[a+4+4>>2]=t[r+4+4>>2];t[a+4+8>>2]=t[r+4+8>>2];t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;n[a+16>>1]=n[r+16>>1]|0;t[a+20>>2]=t[r+20>>2];t[a+20+4>>2]=t[r+20+4>>2];t[a+20+8>>2]=t[r+20+8>>2];t[r+20>>2]=0;t[r+20+4>>2]=0;t[r+20+8>>2]=0;Lt(a+4|0,i+4|0)|0;f[a+17>>0]=0;Il(a+20|0)|0;t[e>>2]=t[a>>2];t[e+4>>2]=t[a+4>>2];t[e+4+4>>2]=t[a+4+4>>2];t[e+4+8>>2]=t[a+4+8>>2];t[a+4>>2]=0;t[a+4+4>>2]=0;t[a+4+8>>2]=0;n[e+16>>1]=n[a+16>>1]|0;t[e+20>>2]=t[a+20>>2];t[e+20+4>>2]=t[a+20+4>>2];t[e+20+8>>2]=t[a+20+8>>2];k=a;return}function Qr(e,i,r,n,a,l){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;l=l|0;var o=0,u=0,s=0,b=0;if(Ro(e,t[i+8>>2]|0)|0)Jf(i,r,n,a);else{o=f[i+52>>0]|0;u=f[i+53>>0]|0;s=t[e+12>>2]|0;f[i+52>>0]=0;f[i+53>>0]=0;ft(e+16|0,i,r,n,a,l);e:do{if((s|0)>1){b=e+24|0;do{if(f[i+54>>0]|0)break e;if(!(f[i+52>>0]|0)){if(f[i+53>>0]|0?(t[e+8>>2]&1|0)==0:0)break e}else{if((t[i+24>>2]|0)==1)break e;if(!(t[e+8>>2]&2))break e}f[i+52>>0]=0;f[i+53>>0]=0;ft(b,i,r,n,a,l);b=b+8|0}while(b>>>0<(e+16+(s<<3)|0)>>>0)}}while(0);f[i+52>>0]=o;f[i+53>>0]=u}return}function $r(e,i,r){e=e|0;i=i|0;r=r|0;var f=0,n=0,a=0,l=0,o=0;o=k;k=k+64|0;t[r>>2]=t[t[r>>2]>>2];if(!(ba(e,i)|0))if(((i|0)!=0?(n=tf(i,1056)|0,(n|0)!=0):0)?(t[n+8>>2]&~t[e+8>>2]|0)==0:0){e=t[e+12>>2]|0;if(!(Ro(e,t[n+12>>2]|0)|0)?!(Ro(e,1088)|0):0)if((((e|0)!=0?(l=tf(e,904)|0,(l|0)!=0):0)?(f=t[n+12>>2]|0,(f|0)!=0):0)?(a=tf(f,904)|0,(a|0)!=0):0){e=o+4|0;i=e+52|0;do{t[e>>2]=0;e=e+4|0}while((e|0)<(i|0));t[o>>2]=a;t[o+8>>2]=l;t[o+12>>2]=-1;t[o+48>>2]=1;Wu[t[(t[a>>2]|0)+28>>2]&7](a,o,t[r>>2]|0,1);if((t[o+24>>2]|0)==1){t[r>>2]=t[o+16>>2];e=1}else e=0}else e=0;else e=1}else e=0;else e=1;k=o;return e|0}function ef(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0,o=0,u=0,s=0,b=0,c=0,h=0;h=(t[e>>2]|0)+1794895138|0;n=_o(t[e+8>>2]|0,h)|0;b=_o(t[e+12>>2]|0,h)|0;c=_o(t[e+16>>2]|0,h)|0;e:do{if((n>>>0<i>>>2>>>0?b>>>0<(i-(n<<2)|0)>>>0&c>>>0<(i-(n<<2)|0)>>>0:0)?((c|b)&3|0)==0:0){s=0;while(1){o=n>>>1;u=s+o|0;a=_o(t[e+((u<<1)+(b>>>2)<<2)>>2]|0,h)|0;l=_o(t[e+((u<<1)+(b>>>2)+1<<2)>>2]|0,h)|0;if(!(l>>>0<i>>>0&a>>>0<(i-l|0)>>>0)){n=0;break e}if(f[e+(l+a)>>0]|0){n=0;break e}a=It(r,e+l|0)|0;if(!a)break;if((n|0)==1){n=0;break e}else{s=(a|0)<0?s:u;n=(a|0)<0?o:n-o|0}}a=_o(t[e+((u<<1)+(c>>>2)<<2)>>2]|0,h)|0;n=_o(t[e+((u<<1)+(c>>>2)+1<<2)>>2]|0,h)|0;if(n>>>0<i>>>0&a>>>0<(i-n|0)>>>0)n=(f[e+(n+a)>>0]|0)==0?e+n|0:0;else n=0}else n=0}while(0);return n|0}function rf(e){e=e|0;var i=0,r=0,n=0;i=t[e+48>>2]|0;if(i|0)do{n=i;i=t[i>>2]|0;r=t[n+40>>2]|0;if((r|0)!=(n+24|0)){if(r|0)Fu[t[(t[r>>2]|0)+20>>2]&127](r)}else Fu[t[(t[r>>2]|0)+16>>2]&127](r);if((f[n+8+11>>0]|0)<0)pu(t[n+8>>2]|0);pu(n)}while((i|0)!=0);i=t[e+40>>2]|0;t[e+40>>2]=0;if(i|0)pu(i);i=t[e+28>>2]|0;if(i|0)do{r=i;i=t[i>>2]|0;fi(t[r+20>>2]|0);if((f[r+8+11>>0]|0)<0)pu(t[r+8>>2]|0);pu(r)}while((i|0)!=0);i=t[e+20>>2]|0;t[e+20>>2]=0;if(i|0)pu(i);i=t[e+8>>2]|0;if(i|0)do{r=i;i=t[i>>2]|0;if((f[r+20+11>>0]|0)<0)pu(t[r+20>>2]|0);if((f[r+8+11>>0]|0)<0)pu(t[r+8>>2]|0);pu(r)}while((i|0)!=0);i=t[e>>2]|0;t[e>>2]=0;if(!i)return;pu(i);return}function ff(e){e=e|0;var i=0,r=0,n=0,a=0,l=0,o=0;n=f[e+8+3>>0]|0;if(n<<24>>24<0){o=t[e+4>>2]|0;r=(t[e+8>>2]&2147483647)+-1|0}else{o=n&255;r=1}i=o>>>0<2;l=i?1:(o+4&-4)+-1|0;do{if((l|0)!=(r|0)){do{if(i){r=t[e>>2]|0;if(n<<24>>24<0){i=e;n=0;a=12}else{uo(e,r,(n&255)+1|0);pu(r);a=14}}else{if((l+1|0)>>>0>1073741823)ye();i=Vt(l+1<<2)|0;if(n<<24>>24<0){n=1;r=t[e>>2]|0;a=12;break}else{uo(i,e,(n&255)+1|0);a=13;break}}}while(0);if((a|0)==12){uo(i,r,(t[e+4>>2]|0)+1|0);pu(r);if(n)a=13;else a=14}if((a|0)==13){t[e+8>>2]=l+1|-2147483648;t[e+4>>2]=o;t[e>>2]=i;break}else if((a|0)==14){f[e+8+3>>0]=o;break}}}while(0);return}function nf(e,i,r){e=e|0;i=i|0;r=r|0;var l=0,o=0,u=0,s=0,b=0,c=0,h=0;l=k;k=k+16|0;c=t[r>>2]|0;b=t[r+4>>2]|0;t[l+8>>2]=t[r+8>>2];n[l+8+4>>1]=n[r+8+4>>1]|0;f[l+8+6>>0]=f[r+8+6>>0]|0;s=f[r+15>>0]|0;t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;h=n[r+16>>1]|0;u=t[r+20>>2]|0;t[l>>2]=t[r+24>>2];n[l+4>>1]=n[r+24+4>>1]|0;f[l+6>>0]=f[r+24+6>>0]|0;o=f[r+31>>0]|0;t[r+20>>2]=0;t[r+20+4>>2]=0;t[r+20+8>>2]=0;i=a[i+4>>0]|0|h&-256;t[e>>2]=c;t[e+4>>2]=b;t[e+8>>2]=t[l+8>>2];n[e+8+4>>1]=n[l+8+4>>1]|0;f[e+8+6>>0]=f[l+8+6>>0]|0;f[e+15>>0]=s;n[e+16>>1]=i;t[e+20>>2]=u;t[e+24>>2]=t[l>>2];n[e+24+4>>1]=n[l+4>>1]|0;f[e+24+6>>0]=f[l+6>>0]|0;f[e+31>>0]=o;k=l;return}function tf(e,i){e=e|0;i=i|0;var r=0,a=0,l=0,o=0;o=k;k=k+64|0;a=t[e>>2]|0;l=e+(t[a+-8>>2]|0)|0;a=t[a+-4>>2]|0;t[o>>2]=i;t[o+4>>2]=e;t[o+8>>2]=920;i=Ro(a,i)|0;e=o+12|0;r=e+40|0;do{t[e>>2]=0;e=e+4|0}while((e|0)<(r|0));n[o+12+40>>1]=0;f[o+12+42>>0]=0;e:do{if(i){t[o+48>>2]=1;Du[t[(t[a>>2]|0)+20>>2]&3](a,o,l,l,1,0);i=(t[o+24>>2]|0)==1?l:0}else{Mu[t[(t[a>>2]|0)+24>>2]&3](a,o,l,1,0);switch(t[o+36>>2]|0){case 0:{i=((t[o+40>>2]|0)==1?(t[o+28>>2]|0)==1:0)&(t[o+32>>2]|0)==1?t[o+20>>2]|0:0;break e}case 1:break;default:{i=0;break e}}if((t[o+24>>2]|0)!=1?!(((t[o+40>>2]|0)==0?(t[o+28>>2]|0)==1:0)&(t[o+32>>2]|0)==1):0){i=0;break}i=t[o+16>>2]|0}}while(0);k=o;return i|0}function af(e){e=e|0;var i=0,r=0,n=0,a=0,l=0,o=0;n=f[e+11>>0]|0;if(n<<24>>24<0){o=t[e+4>>2]|0;r=(t[e+8>>2]&2147483647)+-1|0}else{o=n&255;r=10}i=o>>>0<11;l=i?10:(o+16&-16)+-1|0;do{if((l|0)!=(r|0)){do{if(i){r=t[e>>2]|0;if(n<<24>>24<0){i=e;n=0;a=10}else{Yl(e,r,(n&255)+1|0)|0;pu(r);a=12}}else{i=Vt(l+1|0)|0;if(n<<24>>24<0){n=1;r=t[e>>2]|0;a=10;break}else{Yl(i,e,(n&255)+1|0)|0;a=11;break}}}while(0);if((a|0)==10){Yl(i,r,(t[e+4>>2]|0)+1|0)|0;pu(r);if(n)a=11;else a=12}if((a|0)==11){t[e+8>>2]=l+1|-2147483648;t[e+4>>2]=o;t[e>>2]=i;break}else if((a|0)==12){f[e+11>>0]=o;break}}}while(0);return}function lf(e,i,r){e=e|0;i=i|0;r=r|0;i=k;k=k+32|0;t[i>>2]=t[r>>2];t[i+4>>2]=t[r+4>>2];t[i+4+4>>2]=t[r+4+4>>2];t[i+4+8>>2]=t[r+4+8>>2];t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;n[i+16>>1]=n[r+16>>1]|0;t[i+20>>2]=t[r+20>>2];t[i+20+4>>2]=t[r+20+4>>2];t[i+20+8>>2]=t[r+20+8>>2];t[r+20>>2]=0;t[r+20+4>>2]=0;t[r+20+8>>2]=0;f[i+17>>0]=0;Il(i+20|0)|0;t[e>>2]=t[i>>2];t[e+4>>2]=t[i+4>>2];t[e+4+4>>2]=t[i+4+4>>2];t[e+4+8>>2]=t[i+4+8>>2];t[i+4>>2]=0;t[i+4+4>>2]=0;t[i+4+8>>2]=0;n[e+16>>1]=n[i+16>>1]|0;t[e+20>>2]=t[i+20>>2];t[e+20+4>>2]=t[i+20+4>>2];t[e+20+8>>2]=t[i+20+8>>2];k=i;return}function of(e){e=e|0;var i=0,r=0,n=0,a=0;a=k;k=k+32|0;i=f[e+11>>0]|0;r=t[e+4>>2]|0;if(((i<<24>>24<0?r:i&255)|0)==9)if(!(En(e,5987,9)|0))i=0;else{i=f[e+11>>0]|0;r=t[e+4>>2]|0;n=4}else n=4;if((n|0)==4)if(((i<<24>>24<0?r:i&255)|0)==6){i=(En(e,5997,6)|0)==0;i=i?1:2}else i=2;t[a>>2]=1292;t[a+4>>2]=i;t[a+16>>2]=a;i=t[4054]|0;if(!i){a=xe(4)|0;t[a>>2]=1256;Fi(a|0,8,1)}Pu[t[(t[i>>2]|0)+24>>2]&31](i,a);i=t[a+16>>2]|0;if((i|0)==(a|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);k=a;return}if(!i){k=a;return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);k=a;return}function uf(e,i){e=e|0;i=i|0;var r=0,f=0;if((i|0)!=1){if(i+-1&i)i=Gi(i)|0}else i=2;f=t[e+4>>2]|0;if(i>>>0>f>>>0){_r(e,i);return}if(i>>>0>=f>>>0)return;r=~~+j(+(+((t[e+12>>2]|0)>>>0)/+u[e+16>>2]))>>>0;if(f>>>0>2&(f+-1&f|0)==0)r=1<<32-(q(r+-1|0)|0);else r=Gi(r)|0;i=i>>>0<r>>>0?r:i;if(i>>>0>=f>>>0)return;_r(e,i);return}function sf(e,i,r,n){e=e|0;i=i|0;r=r|0;n=n|0;var a=0,l=0,o=0;o=k;k=k+32|0;t[o+16>>2]=i;a=t[r>>2]|0;t[o+4>>2]=0;t[o+4+4>>2]=0;t[o+4+8>>2]=0;if(a>>>0>4294967279)au();if(a>>>0<11){f[o+4+11>>0]=a;if(!a)i=o+4|0;else{i=o+4|0;l=6}}else{i=Vt(a+16&-16)|0;t[o+4>>2]=i;t[o+4+8>>2]=a+16&-16|-2147483648;t[o+4+4>>2]=a;l=6}if((l|0)==6)Vr(i|0,r+4|0,a|0)|0;f[i+a>>0]=0;t[o>>2]=n;Wu[e&7](o+20|0,o+16|0,o+4|0,o);Ve(t[o+20>>2]|0);i=t[o+20>>2]|0;fi(i|0);fi(t[o>>2]|0);if((f[o+4+11>>0]|0)>=0){k=o;return i|0}pu(t[o+4>>2]|0);k=o;return i|0}function bf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0;l=k;k=k+224|0;n=l+80|0;a=n+40|0;do{t[n>>2]=0;n=n+4|0}while((n|0)<(a|0));t[l+120>>2]=t[r>>2];if((Ji(0,i,l+120|0,l,l+80|0)|0)<0)r=-1;else{a=t[e>>2]|0;if((f[e+74>>0]|0)<1)t[e>>2]=a&-33;if(!(t[e+48>>2]|0)){n=t[e+44>>2]|0;t[e+44>>2]=l+136;t[e+28>>2]=l+136;t[e+20>>2]=l+136;t[e+48>>2]=80;t[e+16>>2]=l+136+80;r=Ji(e,i,l+120|0,l,l+80|0)|0;if(n){xu[t[e+36>>2]&7](e,0,0)|0;r=(t[e+20>>2]|0)==0?-1:r;t[e+44>>2]=n;t[e+48>>2]=0;t[e+16>>2]=0;t[e+28>>2]=0;t[e+20>>2]=0}}else r=Ji(e,i,l+120|0,l,l+80|0)|0;i=t[e>>2]|0;t[e>>2]=i|a&32;r=(i&32|0)==0?r:-1}k=l;return r|0}function cf(e,i){e=e|0;i=i|0;var r=0,n=0;e:do{if((i|0)!=0&(e&3|0)!=0){r=i;while(1){if(!(f[e>>0]|0))break e;e=e+1|0;i=r+-1|0;if((i|0)!=0&(e&3|0)!=0)r=i;else{r=i;i=(i|0)!=0;n=4;break}}}else{r=i;i=(i|0)!=0;n=4}}while(0);e:do{if((n|0)==4)if(i){if(f[e>>0]|0){i:do{if(r>>>0>3)while(1){i=t[e>>2]|0;if((i&-2139062144^-2139062144)&i+-16843009|0)break;e=e+4|0;r=r+-4|0;if(r>>>0<=3){n=10;break i}}else n=10}while(0);if((n|0)==10)if(!r){r=0;break}while(1){if(!(f[e>>0]|0))break e;e=e+1|0;r=r+-1|0;if(!r){r=0;break}}}}else r=0}while(0);return(r|0?e:0)|0}function hf(e,i,r,n,a,l,o,u){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;l=l|0;o=o|0;u=u|0;var s=0,b=0;if((1073741806-i|0)>>>0<r>>>0)au();if((f[e+8+3>>0]|0)<0)b=t[e>>2]|0;else b=e;if(i>>>0<536870887){r=(r+i|0)>>>0<i<<1>>>0?i<<1:r+i|0;r=r>>>0<2?2:r+4&-4;if(r>>>0>1073741823)ye();else s=r}else s=1073741807;r=Vt(s<<2)|0;if(a|0)uo(r,b,a);if(o|0)uo(r+(a<<2)|0,u,o);if(n-l-a|0)uo(r+(a<<2)+(o<<2)|0,b+(a<<2)+(l<<2)|0,n-l-a|0);if((i|0)!=1)pu(b);t[e>>2]=r;t[e+8>>2]=s|-2147483648;t[e+4>>2]=n-l+o;Uo(r+(n-l+o<<2)|0,0);return}function kf(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;var n=0;$f(e,i);t[e+12>>2]=0;t[e+12+4>>2]=0;t[e+12+8>>2]=0;t[e+12+12>>2]=0;t[e+12+16>>2]=0;t[e+12+20>>2]=0;Bn(e+36|0,r);t[e+100>>2]=0;t[e+104>>2]=0;t[e+108>>2]=0;r=(t[f+4>>2]|0)-(t[f>>2]|0)|0;if(!(r>>2)){vr(e);return}if(r>>2>>>0>1073741823)au();n=Vt(r)|0;t[e+104>>2]=n;t[e+100>>2]=n;t[e+108>>2]=n+(r>>2<<2);i=t[f>>2]|0;r=(t[f+4>>2]|0)-i|0;if((r|0)<=0){vr(e);return}Vr(n|0,i|0,r|0)|0;t[e+104>>2]=n+(r>>>2<<2);vr(e);return}function df(e){e=e|0;var i=0,r=0,a=0;a=k;k=k+16|0;t[a>>2]=0;t[a+4>>2]=0;t[a+8>>2]=0;f[a+11>>0]=2;n[a>>1]=29550;f[a+2>>0]=0;ja(or(e+36|0,a)|0)|0;if((f[a+11>>0]|0)<0)pu(t[a>>2]|0);r=f[e+11>>0]|0;if(((r<<24>>24<0?t[e+4>>2]|0:r&255)|0)==13?(En(e,3782,13)|0)==0:0){k=a;return}i=t[e+100>>2]|0;if((i|0)==(t[e+104>>2]|0)){k=a;return}r=0;do{df(t[i+(r<<2)>>2]|0);r=r+1|0;i=t[e+100>>2]|0}while((r|0)!=((t[e+104>>2]|0)-i>>2|0));k=a;return}function wf(e,i,r){e=e|0;i=i|0;r=r|0;var a=0,l=0,o=0,u=0,s=0,b=0,c=0;a=k;k=k+16|0;c=t[r>>2]|0;b=t[r+4>>2]|0;t[a>>2]=t[r+8>>2];n[a+4>>1]=n[r+8+4>>1]|0;f[a+6>>0]=f[r+8+6>>0]|0;s=f[r+15>>0]|0;t[r+4>>2]=0;t[r+4+4>>2]=0;t[r+4+8>>2]=0;u=t[r+16>>2]|0;o=t[r+20>>2]|0;l=t[r+24>>2]|0;t[r+24>>2]=0;t[r+20>>2]=0;t[r+16>>2]=0;i=t[i+4>>2]|0;t[e>>2]=c;t[e+4>>2]=b;t[e+8>>2]=t[a>>2];n[e+8+4>>1]=n[a+4>>1]|0;f[e+8+6>>0]=f[a+6>>0]|0;f[e+15>>0]=s;t[e+16>>2]=u;t[e+20>>2]=o;t[e+24>>2]=l;t[e+28>>2]=i;k=a;return}function vf(e,i,r,n,a,l,o,u){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;l=l|0;o=o|0;u=u|0;var s=0,b=0;if((-18-i|0)>>>0<r>>>0)au();if((f[e+11>>0]|0)<0)b=t[e>>2]|0;else b=e;if(i>>>0<2147483623){s=(r+i|0)>>>0<i<<1>>>0?i<<1:r+i|0;s=s>>>0<11?11:s+16&-16}else s=-17;r=Vt(s)|0;if(a|0)Yl(r,b,a)|0;if(o|0)Yl(r+a|0,u,o)|0;if(n-l-a|0)Yl(r+a+o|0,b+a+l|0,n-l-a|0)|0;if((i|0)!=10)pu(b);t[e>>2]=r;t[e+8>>2]=s|-2147483648;t[e+4>>2]=n-l+o;Ho(r+(n-l+o)|0,0);return}function _f(){var e=0,i=0,r=0,f=0;f=k;k=k+48|0;e=ga()|0;if(e|0?(r=t[e>>2]|0,r|0):0){e=t[r+48>>2]|0;i=t[r+48+4>>2]|0;if(!((e&-256|0)==1126902528&(i|0)==1129074247)){t[f+24>>2]=15400;Ll(15350,f+24|0)}if((e|0)==1126902529&(i|0)==1129074247)e=t[r+44>>2]|0;else e=r+80|0;t[f+36>>2]=e;r=t[r>>2]|0;e=t[r+4>>2]|0;if(Zf(896,r,f+36|0)|0){r=t[f+36>>2]|0;r=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;t[f>>2]=15400;t[f+4>>2]=e;t[f+8>>2]=r;Ll(15264,f)}else{t[f+16>>2]=15400;t[f+16+4>>2]=e;Ll(15309,f+16|0)}}Ll(15388,f+32|0)}function pf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0;l=k;k=k+16|0;n=f[i+11>>0]|0;if(n<<24>>24<0)a=t[i+4>>2]|0;else a=n&255;while(1){if(n<<24>>24<0)n=t[i>>2]|0;else n=i;t[l>>2]=r;n=nl(n,a+1|0,0,l)|0;if((n|0)>-1)if(n>>>0>a>>>0)a=n;else break;else a=a<<1|1;vn(i,a);n=f[i+11>>0]|0}vn(i,n);t[e>>2]=t[i>>2];t[e+4>>2]=t[i+4>>2];t[e+8>>2]=t[i+8>>2];t[i>>2]=0;t[i+4>>2]=0;t[i+8>>2]=0;k=l;return}function mf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0,o=0;n=f[e+11>>0]|0;if(n<<24>>24<0){l=t[e+4>>2]|0;a=(t[e+8>>2]&2147483647)+-1|0}else{l=n&255;a=10}o=l+r|0;if((a-l|0)>>>0>=r>>>0){if(r|0){if(n<<24>>24<0)n=t[e>>2]|0;else n=e;if(l){Kl(n+r|0,n,l)|0;i=n>>>0<=i>>>0&(n+l|0)>>>0>i>>>0?i+r|0:i}Kl(n,i,r)|0;if((f[e+11>>0]|0)<0)t[e+4>>2]=o;else f[e+11>>0]=o;Ho(n+o|0,0)}}else vf(e,a,o-a|0,l,0,0,r,i);return e|0}function yf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0;n=t[r+16>>2]|0;if(!n){if(!(Rt(r)|0)){n=t[r+16>>2]|0;a=5}}else a=5;e:do{if((a|0)==5){a=t[r+20>>2]|0;if((n-a|0)>>>0<i>>>0){xu[t[r+36>>2]&7](r,e,i)|0;break}i:do{if((f[r+75>>0]|0)>-1){l=i;while(1){if(!l){n=i;break i}n=l+-1|0;if((f[e+n>>0]|0)==10)break;else l=n}if((xu[t[r+36>>2]&7](r,e,l)|0)>>>0<l>>>0)break e;a=t[r+20>>2]|0;n=i-l|0;e=e+l|0}else n=i}while(0);Vr(a|0,e|0,n|0)|0;t[r+20>>2]=(t[r+20>>2]|0)+n}}while(0);return}function gf(e,i){e=e|0;i=i|0;var r=0,n=0;n=k;k=k+32|0;r=t[i>>2]|0;t[i>>2]=0;i=(it(r)|0)&1;t[n>>2]=1732;f[n+4>>0]=i;t[n+16>>2]=n;i=t[e+24>>2]|0;if(!i){n=xe(4)|0;t[n>>2]=1256;Fi(n|0,8,1)}Pu[t[(t[i>>2]|0)+24>>2]&31](i,n);i=t[n+16>>2]|0;if((i|0)==(n|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);fi(r|0);k=n;return 1}if(!i){fi(r|0);k=n;return 1}Fu[t[(t[i>>2]|0)+20>>2]&127](i);fi(r|0);k=n;return 1}function Tf(e,i){e=e|0;i=i|0;var r=0,n=0;n=k;k=k+32|0;r=t[i>>2]|0;t[i>>2]=0;i=(it(r)|0)&1;t[n>>2]=1688;f[n+4>>0]=i;t[n+16>>2]=n;i=t[e+24>>2]|0;if(!i){n=xe(4)|0;t[n>>2]=1256;Fi(n|0,8,1)}Pu[t[(t[i>>2]|0)+24>>2]&31](i,n);i=t[n+16>>2]|0;if((i|0)==(n|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);fi(r|0);k=n;return 1}if(!i){fi(r|0);k=n;return 1}Fu[t[(t[i>>2]|0)+20>>2]&127](i);fi(r|0);k=n;return 1}function Af(e,i){e=e|0;i=i|0;var r=0,n=0;r=t[i>>2]|0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;if(r>>>0>1073741807)au();do{if(r>>>0<2){f[e+8+3>>0]=r;if(!r){i=e;i=i+(r<<2)|0;t[i>>2]=0;return}}else if((r+4&-4)>>>0>1073741823){i=xe(8)|0;ao(i,7681);t[i>>2]=3404;Fi(i|0,992,95)}else{n=Vt((r+4&-4)<<2)|0;t[e>>2]=n;t[e+8>>2]=r+4&-4|-2147483648;t[e+4>>2]=r;e=n;break}}while(0);oa(e,i+4|0,r)|0;n=e;n=n+(r<<2)|0;t[n>>2]=0;return}function Ef(e,i){e=e|0;i=i|0;do{if(e){if(i>>>0<128){f[e>>0]=i;e=1;break}if(!(t[t[895]>>2]|0))if((i&-128|0)==57216){f[e>>0]=i;e=1;break}else{t[4223]=84;e=-1;break}if(i>>>0<2048){f[e>>0]=i>>>6|192;f[e+1>>0]=i&63|128;e=2;break}if(i>>>0<55296|(i&-8192|0)==57344){f[e>>0]=i>>>12|224;f[e+1>>0]=i>>>6&63|128;f[e+2>>0]=i&63|128;e=3;break}if((i+-65536|0)>>>0<1048576){f[e>>0]=i>>>18|240;f[e+1>>0]=i>>>12&63|128;f[e+2>>0]=i>>>6&63|128;f[e+3>>0]=i&63|128;e=4;break}else{t[4223]=84;e=-1;break}}else e=1}while(0);return e|0}function Cf(e,i,r,n,a){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;var l=0;l=k;k=k+16|0;t[a>>2]=r;i=Ul(t[e+8>>2]|0)|0;e=Ef(l,0)|0;if(i|0)Ul(i)|0;switch(e|0){case 0:case-1:{i=2;break}default:{i=t[a>>2]|0;if((e+-1|0)>>>0<=(n-i|0)>>>0)if((e+-1|0)!=0?(n=f[l>>0]|0,t[a>>2]=i+1,f[i>>0]=n,(e+-2|0)!=0):0){i=e+-2|0;e=l;do{e=e+1|0;n=t[a>>2]|0;r=f[e>>0]|0;t[a>>2]=n+1;f[n>>0]=r;i=i+-1|0}while((i|0)!=0);i=0}else i=0;else i=1}}k=l;return i|0}function Sf(e,i,r){e=e|0;i=i|0;r=r|0;var f=0,n=0,a=0,l=0;l=k;k=k+32|0;e:do{if(!(Do(r)|0)){n=0;a=0;do{f=(1<<n&e|0)!=0;if((r|0)==0|f)f=Cr(n,f?i:16904)|0;else f=t[r+(n<<2)>>2]|0;a=((f|0)!=0&1)+a|0;t[l+(n<<2)>>2]=f;n=n+1|0}while((n|0)!=6);switch(a|0){case 0:{r=16832;break e}case 1:{if((t[l>>2]|0)==2316){r=2364;break e}break}default:{}}}else{f=0;do{if(1<<f&e|0)t[r+(f<<2)>>2]=Cr(f,i)|0;f=f+1|0}while((f|0)!=6)}}while(0);k=l;return r|0}function xf(e,i){e=e|0;i=i|0;var r=0,n=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;if((f[i+8+3>>0]|0)<0){r=t[i>>2]|0;i=t[i+4>>2]|0;if(i>>>0>1073741807)au();do{if(i>>>0>=2)if((i+4&-4)>>>0>1073741823)ye();else{n=Vt((i+4&-4)<<2)|0;t[e>>2]=n;t[e+8>>2]=i+4&-4|-2147483648;t[e+4>>2]=i;break}else{f[e+8+3>>0]=i;n=e}}while(0);uo(n,r,i);Uo(n+(i<<2)|0,0)}else{t[e>>2]=t[i>>2];t[e+4>>2]=t[i+4>>2];t[e+8>>2]=t[i+8>>2]}return}function Mf(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0;l=k;k=k+16|0;a=+Ne(i|0,32,l|0);r=t[l>>2]|0;n=t[~~a>>>0>>2]|0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;if(n>>>0>4294967279)au();if(n>>>0<11){f[e+11>>0]=n;if(!n){e=e+n|0;f[e>>0]=0;vi(r|0);k=l;return}else i=e}else{i=Vt(n+16&-16)|0;t[e>>2]=i;t[e+8>>2]=n+16&-16|-2147483648;t[e+4>>2]=n}Vr(i|0,(~~a>>>0)+4|0,n|0)|0;e=i;e=e+n|0;f[e>>0]=0;vi(r|0);k=l;return}function Ff(e,i){e=e|0;i=i|0;var r=0,f=0;f=k;k=k+32|0;e=t[e+24>>2]|0;r=t[i>>2]|0;t[i>>2]=0;t[f>>2]=2140;t[f+16>>2]=f;if(!e){f=xe(4)|0;t[f>>2]=1256;Fi(f|0,8,1)}Pu[t[(t[e>>2]|0)+24>>2]&31](e,f);e=t[f+16>>2]|0;if((e|0)==(f|0)){Fu[t[(t[e>>2]|0)+16>>2]&127](e);i=r;fi(i|0);k=f;return 1}if(!e){i=r;fi(i|0);k=f;return 1}Fu[t[(t[e>>2]|0)+20>>2]&127](e);i=r;fi(i|0);k=f;return 1}function Pf(e,i){e=e|0;i=i|0;var r=0,f=0;f=k;k=k+32|0;e=t[e+24>>2]|0;r=t[i>>2]|0;t[i>>2]=0;t[f>>2]=2184;t[f+16>>2]=f;if(!e){f=xe(4)|0;t[f>>2]=1256;Fi(f|0,8,1)}Pu[t[(t[e>>2]|0)+24>>2]&31](e,f);e=t[f+16>>2]|0;if((e|0)==(f|0)){Fu[t[(t[e>>2]|0)+16>>2]&127](e);i=r;fi(i|0);k=f;return 1}if(!e){i=r;fi(i|0);k=f;return 1}Fu[t[(t[e>>2]|0)+20>>2]&127](e);i=r;fi(i|0);k=f;return 1}function Rf(e,i){e=e|0;i=i|0;var r=0,f=0;f=k;k=k+32|0;e=t[e+24>>2]|0;r=t[i>>2]|0;t[i>>2]=0;t[f>>2]=1644;t[f+16>>2]=f;if(!e){f=xe(4)|0;t[f>>2]=1256;Fi(f|0,8,1)}Pu[t[(t[e>>2]|0)+24>>2]&31](e,f);e=t[f+16>>2]|0;if((e|0)==(f|0)){Fu[t[(t[e>>2]|0)+16>>2]&127](e);i=r;fi(i|0);k=f;return 1}if(!e){i=r;fi(i|0);k=f;return 1}Fu[t[(t[e>>2]|0)+20>>2]&127](e);i=r;fi(i|0);k=f;return 1}function Of(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1380;r=t[e+24>>2]|0;do{if(r)if((r|0)==(e+8|0)){t[i+24>>2]=i+8;r=t[e+24>>2]|0;Pu[t[(t[r>>2]|0)+12>>2]&31](r,i+8|0);break}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;break}else t[i+24>>2]=0}while(0);t[i+32>>2]=t[e+32>>2];$f(i+36|0,e+36|0);n[i+48>>1]=n[e+48>>1]|0;xf(i+52|0,e+52|0);return}function If(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1964;r=t[e+24>>2]|0;do{if(r)if((r|0)==(e+8|0)){t[i+24>>2]=i+8;r=t[e+24>>2]|0;Pu[t[(t[r>>2]|0)+12>>2]&31](r,i+8|0);break}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;break}else t[i+24>>2]=0}while(0);t[i+32>>2]=t[e+32>>2];$f(i+36|0,e+36|0);n[i+48>>1]=n[e+48>>1]|0;xf(i+52|0,e+52|0);return}function Nf(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0;l=k;k=k+16|0;n=t[i>>2]|0;t[l>>2]=0;t[l+4>>2]=0;t[l+8>>2]=0;if(n>>>0>4294967279)au();if(n>>>0<11){f[l+11>>0]=n;if(!n)r=l;else{r=l;a=6}}else{r=Vt(n+16&-16)|0;t[l>>2]=r;t[l+8>>2]=n+16&-16|-2147483648;t[l+4>>2]=n;a=6}if((a|0)==6)Vr(r|0,i+4|0,n|0)|0;f[r+n>>0]=0;Fu[e&127](l);if((f[l+11>>0]|0)>=0){k=l;return}pu(t[l>>2]|0);k=l;return}function Lf(e){e=e|0;var i=0;e:do{if(!(e&3))i=4;else while(1){switch(f[e>>0]|0){case 0:case 58:break e;default:{}}e=e+1|0;if(!(e&3)){i=4;break e}}}while(0);e:do{if((i|0)==4){i=t[e>>2]|0;i:do{if(!((i&-2139062144^-2139062144)&i+-16843009))do{if((i&-2139062144^-2139062144)&(i^976894522)+-16843009|0)break i;e=e+4|0;i=t[e>>2]|0}while(!((i&-2139062144^-2139062144)&i+-16843009|0))}while(0);while(1)switch(f[e>>0]|0){case 0:case 58:break e;default:e=e+1|0}}}while(0);return e|0}function Df(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0;n=e+r|0;i=i&255;if((r|0)>=67){while(e&3){f[e>>0]=i;e=e+1|0}a=i|i<<8|i<<16|i<<24;while((e|0)<=((n&-4)-64|0)){t[e>>2]=a;t[e+4>>2]=a;t[e+8>>2]=a;t[e+12>>2]=a;t[e+16>>2]=a;t[e+20>>2]=a;t[e+24>>2]=a;t[e+28>>2]=a;t[e+32>>2]=a;t[e+36>>2]=a;t[e+40>>2]=a;t[e+44>>2]=a;t[e+48>>2]=a;t[e+52>>2]=a;t[e+56>>2]=a;t[e+60>>2]=a;e=e+64|0}while((e|0)<(n&-4|0)){t[e>>2]=a;e=e+4|0}}while((e|0)<(n|0)){f[e>>0]=i;e=e+1|0}return n-r|0}function Uf(e){e=e|0;var i=0,r=0;r=Vt(64)|0;t[r>>2]=1380;i=t[e+24>>2]|0;do{if(i)if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);break}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;break}else t[r+24>>2]=0}while(0);t[r+32>>2]=t[e+32>>2];$f(r+36|0,e+36|0);n[r+48>>1]=n[e+48>>1]|0;xf(r+52|0,e+52|0);return r|0}function Hf(e){e=e|0;var i=0,r=0;r=Vt(64)|0;t[r>>2]=1964;i=t[e+24>>2]|0;do{if(i)if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);break}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;break}else t[r+24>>2]=0}while(0);t[r+32>>2]=t[e+32>>2];$f(r+36|0,e+36|0);n[r+48>>1]=n[e+48>>1]|0;xf(r+52|0,e+52|0);return r|0}function Wf(e,i,r,n,a){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;var l=0,o=0;if((1073741807-i|0)>>>0<r>>>0)au();if((f[e+8+3>>0]|0)<0)o=t[e>>2]|0;else o=e;if(i>>>0<536870887){r=(r+i|0)>>>0<i<<1>>>0?i<<1:r+i|0;r=r>>>0<2?2:r+4&-4;if(r>>>0>1073741823)ye();else l=r}else l=1073741807;r=Vt(l<<2)|0;if(a|0)uo(r,o,a);if(n-a|0)uo(r+(a<<2)|0,o+(a<<2)|0,n-a|0);if((i|0)!=1)pu(o);t[e>>2]=r;t[e+8>>2]=l|-2147483648;return}function Bf(e,i,r,n,a){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;do{if(!(Ro(e,t[i+8>>2]|0)|0)){if(Ro(e,t[i>>2]|0)|0){if((t[i+16>>2]|0)!=(r|0)?(t[i+20>>2]|0)!=(r|0):0){t[i+32>>2]=n;t[i+20>>2]=r;t[i+40>>2]=(t[i+40>>2]|0)+1;if((t[i+36>>2]|0)==1?(t[i+24>>2]|0)==2:0)f[i+54>>0]=1;t[i+44>>2]=4;break}if((n|0)==1)t[i+32>>2]=1}}else wa(i,r,n)}while(0);return}function jf(e,i,r,n){e=e|0;i=i|0;r=r|0;n=n|0;var a=0,l=0;e:do{if(!(Ro(e,t[i+8>>2]|0)|0)){a=t[e+12>>2]|0;pt(e+16|0,i,r,n);if((a|0)>1){l=e+24|0;do{pt(l,i,r,n);if(f[i+54>>0]|0)break e;l=l+8|0}while(l>>>0<(e+16+(a<<3)|0)>>>0)}}else Xn(i,r,n)}while(0);return}function zf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0;n=f[e+11>>0]|0;if(n<<24>>24<0)a=(t[e+8>>2]&2147483647)+-1|0;else a=10;do{if(a>>>0>=r>>>0){if(n<<24>>24<0)n=t[e>>2]|0;else n=e;Kl(n,i,r)|0;Ho(n+r|0,0);if((f[e+11>>0]|0)<0){t[e+4>>2]=r;break}else{f[e+11>>0]=r;break}}else{if(n<<24>>24<0)n=t[e+4>>2]|0;else n=n&255;vf(e,a,r-a|0,n,0,n,r,i)}}while(0);return e|0}function Vf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0,o=0,u=0;u=k;k=k+128|0;n=u;a=2716;l=n+124|0;do{t[n>>2]=t[a>>2];n=n+4|0;a=a+4|0}while((n|0)<(l|0));if((i+-1|0)>>>0>2147483646)if(!i){i=1;e=u+124|0;o=4}else{t[4223]=75;e=-1}else o=4;if((o|0)==4){o=-2-e|0;o=i>>>0>o>>>0?o:i;t[u+48>>2]=o;t[u+20>>2]=e;t[u+44>>2]=e;e=e+o|0;t[u+16>>2]=e;t[u+28>>2]=e;e=bf(u,15261,r)|0;if(o){o=t[u+20>>2]|0;f[o+(((o|0)==(t[u+16>>2]|0))<<31>>31)>>0]=0}}k=u;return e|0}function Gf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0,o=0;n=f[e+8+3>>0]|0;if(n<<24>>24<0){o=t[e+4>>2]|0;a=(t[e+8>>2]&2147483647)+-1|0}else{o=n&255;a=1}l=o+r|0;if((a-o|0)>>>0>=r>>>0){if(r|0){if(n<<24>>24<0)n=t[e>>2]|0;else n=e;uo(n+(o<<2)|0,i,r);if((f[e+8+3>>0]|0)<0)t[e+4>>2]=l;else f[e+8+3>>0]=l;Uo(n+(l<<2)|0,0)}}else hf(e,a,l-a|0,o,o,0,r,i);return e|0}function qf(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0,l=0,o=0;n=f[e+11>>0]|0;if(n<<24>>24<0){o=t[e+4>>2]|0;a=(t[e+8>>2]&2147483647)+-1|0}else{o=n&255;a=10}l=o+r|0;if((a-o|0)>>>0>=r>>>0){if(r|0){if(n<<24>>24<0)n=t[e>>2]|0;else n=e;Yl(n+o|0,i,r)|0;if((f[e+11>>0]|0)<0)t[e+4>>2]=l;else f[e+11>>0]=l;Ho(n+l|0,0)}}else vf(e,a,l-a|0,o,o,0,r,i);return e|0}function Kf(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;nr(e,i);fr(e+20|0,r);ir(e+40|0,f);return}function Jf(e,i,r,n){e=e|0;i=i|0;r=r|0;n=n|0;f[e+53>>0]=1;do{if((t[e+4>>2]|0)==(r|0)){f[e+52>>0]=1;r=t[e+16>>2]|0;if(!r){t[e+16>>2]=i;t[e+24>>2]=n;t[e+36>>2]=1;if(!((n|0)==1?(t[e+48>>2]|0)==1:0))break;f[e+54>>0]=1;break}if((r|0)!=(i|0)){t[e+36>>2]=(t[e+36>>2]|0)+1;f[e+54>>0]=1;break}r=t[e+24>>2]|0;if((r|0)==2){t[e+24>>2]=n;r=n}if((r|0)==1?(t[e+48>>2]|0)==1:0)f[e+54>>0]=1}}while(0);return}function Yf(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0;if(i|0){r=f[e+8+3>>0]|0;if(r<<24>>24<0){l=t[e+4>>2]|0;n=(t[e+8>>2]&2147483647)+-1|0}else{l=r&255;n=1}a=l+i|0;if((n-l|0)>>>0<i>>>0){Wf(e,n,a-n|0,l,l);r=f[e+8+3>>0]|0}if(r<<24>>24<0)r=t[e>>2]|0;else r=e;go(r+(l<<2)|0,i);if((f[e+8+3>>0]|0)<0)t[e+4>>2]=a;else f[e+8+3>>0]=a;Uo(r+(a<<2)|0,0)}return e|0}function Xf(e,i,r){e=e|0;i=i|0;r=r|0;var a=0;a=k;k=k+32|0;t[a>>2]=t[i>>2];$f(a+4|0,i+4|0);n[a+16>>1]=n[i+16>>1]|0;xf(a+20|0,i+20|0);r=t[r+16>>2]|0;if(!r){a=xe(4)|0;t[a>>2]=1256;Fi(a|0,8,1)}Ou[t[(t[r>>2]|0)+24>>2]&15](e,r,a);if((f[a+28+3>>0]|0)<0)pu(t[a+20>>2]|0);if((f[a+4+11>>0]|0)>=0){k=a;return}pu(t[a+4>>2]|0);k=a;return}function Zf(e,i,r){e=e|0;i=i|0;r=r|0;var f=0,n=0,a=0;a=k;k=k+64|0;if(!(Ro(e,i)|0))if((i|0)!=0?(n=tf(i,904)|0,(n|0)!=0):0){i=a+4|0;f=i+52|0;do{t[i>>2]=0;i=i+4|0}while((i|0)<(f|0));t[a>>2]=n;t[a+8>>2]=e;t[a+12>>2]=-1;t[a+48>>2]=1;Wu[t[(t[n>>2]|0)+28>>2]&7](n,a,t[r>>2]|0,1);if((t[a+24>>2]|0)==1){t[r>>2]=t[a+16>>2];i=1}else i=0}else i=0;else i=1;k=a;return i|0}function Qf(e,i){e=e|0;i=i|0;var r=0,n=0,a=0,l=0;if(i|0){r=f[e+11>>0]|0;if(r<<24>>24<0){l=t[e+4>>2]|0;n=(t[e+8>>2]&2147483647)+-1|0}else{l=r&255;n=10}a=l+i|0;if((n-l|0)>>>0<i>>>0){rn(e,n,a-n|0,l,l);r=f[e+11>>0]|0}if(r<<24>>24<0)r=t[e>>2]|0;else r=e;bo(r+l|0,i)|0;if((f[e+11>>0]|0)<0)t[e+4>>2]=a;else f[e+11>>0]=a;Ho(r+a|0,0)}return e|0}function $f(e,i){e=e|0;i=i|0;var r=0,n=0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;if((f[i+11>>0]|0)<0){r=t[i>>2]|0;i=t[i+4>>2]|0;if(i>>>0>4294967279)au();if(i>>>0<11)f[e+11>>0]=i;else{n=Vt(i+16&-16)|0;t[e>>2]=n;t[e+8>>2]=i+16&-16|-2147483648;t[e+4>>2]=i;e=n}Yl(e,r,i)|0;Ho(e+i|0,0)}else{t[e>>2]=t[i>>2];t[e+4>>2]=t[i+4>>2];t[e+8>>2]=t[i+8>>2]}return}function en(e){e=e|0;var i=0,r=0,n=0;i=t[e+100>>2]|0;r=(t[e+104>>2]|0)-i>>2;if(r){n=r;do{n=n+-1|0;r=t[i+(n<<2)>>2]|0;if(r){en(r);pu(r);i=t[e+100>>2]|0}}while((n|0)!=0)}if(i|0){r=t[e+104>>2]|0;if((r|0)!=(i|0))t[e+104>>2]=r+(~((r+-4-i|0)>>>2)<<2);pu(i)}rf(e+36|0);if((f[e+24+11>>0]|0)<0)pu(t[e+24>>2]|0);if((f[e+12+11>>0]|0)<0)pu(t[e+12>>2]|0);if((f[e+11>>0]|0)>=0)return;pu(t[e>>2]|0);return}function rn(e,i,r,n,a){e=e|0;i=i|0;r=r|0;n=n|0;a=a|0;var l=0,o=0;if((-17-i|0)>>>0<r>>>0)au();if((f[e+11>>0]|0)<0)o=t[e>>2]|0;else o=e;if(i>>>0<2147483623){l=(r+i|0)>>>0<i<<1>>>0?i<<1:r+i|0;l=l>>>0<11?11:l+16&-16}else l=-17;r=Vt(l)|0;if(a|0)Yl(r,o,a)|0;if(n-a|0)Yl(r+a|0,o+a|0,n-a|0)|0;if((i|0)!=10)pu(o);t[e>>2]=r;t[e+8>>2]=l|-2147483648;return}function fn(e,i){e=e|0;i=i|0;var r=0;r=k;k=k+32|0;e=t[e+24>>2]|0;i=t[i>>2]|0;t[r>>2]=2228;t[r+4>>2]=i;t[r+16>>2]=r;if(!e){r=xe(4)|0;t[r>>2]=1256;Fi(r|0,8,1)}Pu[t[(t[e>>2]|0)+24>>2]&31](e,r);e=t[r+16>>2]|0;if((e|0)==(r|0)){Fu[t[(t[e>>2]|0)+16>>2]&127](e);k=r;return}if(!e){k=r;return}Fu[t[(t[e>>2]|0)+20>>2]&127](e);k=r;return}function nn(e,i,r){e=e|0;i=i|0;r=r|0;nr(e,i);t[e+20>>2]=0;t[e+20+4>>2]=0;t[e+20+8>>2]=0;t[e+20+12>>2]=0;u[e+36>>2]=1;ir(e+40|0,r);return}function tn(e){e=e|0;var i=0,r=0;t[e>>2]=1336;i=t[e+20>>2]|0;if(i|0){r=t[e+24>>2]|0;if((r|0)!=(i|0)){do{t[e+24>>2]=r+-32;if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);r=r+-28|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);r=t[e+24>>2]|0}while((r|0)!=(i|0));i=t[e+20>>2]|0}pu(i)}if((f[e+8+11>>0]|0)>=0){pu(e);return}pu(t[e+8>>2]|0);pu(e);return}function an(e){e=e|0;var i=0,r=0;i=t[e+20>>2]|0;if(i|0){r=t[e+24>>2]|0;if((r|0)!=(i|0)){do{t[e+24>>2]=r+-32;if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);r=r+-28|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);r=t[e+24>>2]|0}while((r|0)!=(i|0));i=t[e+20>>2]|0}pu(i)}if((f[e+8+11>>0]|0)>=0){pu(e);return}pu(t[e+8>>2]|0);pu(e);return}function ln(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;var a=0,l=0,o=0,u=0;e:do{if((r|0)==(f|0)|(n|0)==0)r=0;else{o=r;r=0;u=0;while(1){l=Ul(t[e+8>>2]|0)|0;a=Po(o,f-o|0,i)|0;if(l|0)Ul(l)|0;switch(a|0){case-2:case-1:break e;case 0:{a=1;break}default:{}}o=o+a|0;r=a+r|0;u=u+1|0;if((o|0)==(f|0)|u>>>0>=n>>>0)break e}}}while(0);return r|0}function on(e){e=e|0;var i=0,r=0;t[e>>2]=1336;i=t[e+20>>2]|0;if(i|0){r=t[e+24>>2]|0;if((r|0)!=(i|0)){do{t[e+24>>2]=r+-32;if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);r=r+-28|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);r=t[e+24>>2]|0}while((r|0)!=(i|0));i=t[e+20>>2]|0}pu(i)}if((f[e+8+11>>0]|0)>=0)return;pu(t[e+8>>2]|0);return}function un(e){e=e|0;if(!e)return;un(t[e>>2]|0);un(t[e+4>>2]|0);if((f[e+16+11>>0]|0)<0)pu(t[e+16>>2]|0);pu(e);return}function sn(e){e=e|0;if(!e)return;sn(t[e>>2]|0);sn(t[e+4>>2]|0);if((f[e+16+11>>0]|0)<0)pu(t[e+16>>2]|0);pu(e);return}function bn(e){e=e|0;var i=0,r=0;i=t[e+20>>2]|0;if(i|0){r=t[e+24>>2]|0;if((r|0)!=(i|0)){do{t[e+24>>2]=r+-32;if((f[r+-4+3>>0]|0)<0)pu(t[r+-12>>2]|0);r=r+-28|0;if((f[r+11>>0]|0)<0)pu(t[r>>2]|0);r=t[e+24>>2]|0}while((r|0)!=(i|0));i=t[e+20>>2]|0}pu(i)}if((f[e+8+11>>0]|0)>=0)return;pu(t[e+8>>2]|0);return}function cn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=2272;r=t[e+24>>2]|0;do{if(r)if((r|0)==(e+8|0)){t[i+24>>2]=i+8;r=t[e+24>>2]|0;Pu[t[(t[r>>2]|0)+12>>2]&31](r,i+8|0);break}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;break}else t[i+24>>2]=0}while(0);t[i+32>>2]=t[e+32>>2];return}function hn(e,i){e=e|0;i=i|0;var r=0;if((f[16184]|0)==0?so(16184)|0:0)f[16905]=1;r=t[4062]|0;if((r|0)!=(e|0)&(r|0)!=0){r=0;return r|0}if((e|0)==(i|0)){r=e;return r|0}t[4062]=i;if(Hr(e,i)|0)qi(e,i);else{r=hr(i)|0;di(17,r|0,t[e+96>>2]|0)|0}if((e|0)==0|(f[16905]|0)==0){r=i;return r|0}en(e);pu(e);r=i;return r|0}function kn(e,i){e=e|0;i=i|0;var r=0,n=0;r=f[e+8+3>>0]|0;if(r<<24>>24<0)n=t[e+4>>2]|0;else n=r&255;do{if(n>>>0>=i>>>0)if(r<<24>>24<0){Uo((t[e>>2]|0)+(i<<2)|0,0);t[e+4>>2]=i;break}else{Uo(e+(i<<2)|0,0);f[e+8+3>>0]=i;break}else Yf(e,i-n|0)|0}while(0);return}function dn(e){e=e|0;var i=0,r=0;r=Vt(40)|0;t[r>>2]=2272;i=t[e+24>>2]|0;do{if(i)if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);break}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;break}else t[r+24>>2]=0}while(0);t[r+32>>2]=t[e+32>>2];return r|0}function wn(e){e=e|0;var i=0,r=0,n=0;e:do{if(!(e&3)){i=e;n=4}else{i=e;r=e;while(1){if(!(f[r>>0]|0))break e;r=r+1|0;i=r;if(!(i&3)){i=r;n=4;break}}}}while(0);if((n|0)==4){while(1){r=t[i>>2]|0;if(!((r&-2139062144^-2139062144)&r+-16843009))i=i+4|0;else break}if((r&255)<<24>>24)do{i=i+1|0}while((f[i>>0]|0)!=0)}return i-e|0}function vn(e,i){e=e|0;i=i|0;var r=0,n=0;r=f[e+11>>0]|0;if(r<<24>>24<0)n=t[e+4>>2]|0;else n=r&255;do{if(n>>>0>=i>>>0)if(r<<24>>24<0){Ho((t[e>>2]|0)+i|0,0);t[e+4>>2]=i;break}else{Ho(e+i|0,0);f[e+11>>0]=i;break}else Qf(e,i-n|0)|0}while(0);return}function _n(e,i){e=+e;i=i|0;var r=0,f=0,n=0;s[c>>3]=e;r=t[c>>2]|0;f=t[c+4>>2]|0;n=al(r|0,f|0,52)|0;switch(n&2047){case 0:{if(e!=0){e=+_n(e*0x10000000000000000,i);r=(t[i>>2]|0)+-64|0}else r=0;t[i>>2]=r;break}case 2047:break;default:{t[i>>2]=(n&2047)+-1022;t[c>>2]=r;t[c+4>>2]=f&-2146435073|1071644672;e=+s[c>>3]}}return+e}function pn(){var e=0,i=0,r=0;Ai(3584,4,1232,3601,1,4);e=Vt(112)|0;i=e;r=i+52|0;do{t[i>>2]=0;i=i+4|0}while((i|0)<(r|0));u[e+52>>2]=1;t[e+56>>2]=0;t[e+56+4>>2]=0;t[e+56+8>>2]=0;t[e+56+12>>2]=0;u[e+72>>2]=1;t[e+76>>2]=0;t[e+76+4>>2]=0;t[e+76+8>>2]=0;t[e+76+12>>2]=0;u[e+92>>2]=1;t[e+100>>2]=0;t[e+104>>2]=0;t[e+108>>2]=0;t[4063]=e;return}function mn(e){e=e|0;var i=0;t[e>>2]=1380;if((f[e+60+3>>0]|0)<0)pu(t[e+52>>2]|0);if((f[e+36+11>>0]|0)<0)pu(t[e+36>>2]|0);i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function yn(e){e=e|0;var i=0;t[e>>2]=1964;if((f[e+60+3>>0]|0)<0)pu(t[e+52>>2]|0);if((f[e+36+11>>0]|0)<0)pu(t[e+36>>2]|0);i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function gn(e,i){e=e|0;i=i|0;var r=0,f=0,n=0;f=k;k=k+16|0;r=t[e+24>>2]|0;n=t[e+32>>2]|0;e=t[i>>2]|0;t[i>>2]=0;t[f>>2]=n;if(!r){n=xe(4)|0;t[n>>2]=1256;Fi(n|0,8,1)}else{Pu[t[(t[r>>2]|0)+24>>2]&31](r,f);fi(e|0);k=f;return 1}return 0}function Tn(e){e=e|0;var i=0;if((f[e+60+3>>0]|0)<0)pu(t[e+52>>2]|0);if((f[e+36+11>>0]|0)<0)pu(t[e+36>>2]|0);i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function An(e,i){e=e|0;i=i|0;var r=0,n=0;r=0;while(1){if((a[13107+r>>0]|0)==(e|0)){n=2;break}r=r+1|0;if((r|0)==87){r=87;e=13195;n=5;break}}if((n|0)==2)if(!r)r=13195;else{e=13195;n=5}if((n|0)==5)while(1){do{n=e;e=e+1|0}while((f[n>>0]|0)!=0);r=r+-1|0;if(!r){r=e;break}else n=5}return iu(r,t[i+20>>2]|0)|0}function En(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,a=0;n=f[e+11>>0]|0;if(n<<24>>24<0)a=t[e+4>>2]|0;else a=n&255;if((r|0)==-1)au();if(n<<24>>24<0)n=t[e>>2]|0;else n=e;e=a>>>0>r>>>0;n=Ol(n,i,e?r:a)|0;if(!n)return(a>>>0<r>>>0?-1:e&1)|0;else return n|0;return 0}function Cn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=2052;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function Sn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=2008;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function xn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1920;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function Mn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1876;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function Fn(){var e=0,i=0,r=0;r=k;k=k+16|0;f[r>>0]=10;e=t[652]|0;if(!e)if(!(Rt(2592)|0)){e=t[652]|0;i=4}else e=-1;else i=4;do{if((i|0)==4){i=t[653]|0;if(!(i>>>0>=e>>>0|(f[2667]|0)==10)){t[653]=i+1;f[i>>0]=10;e=10;break}if((xu[t[2628>>2]&7](2592,r,1)|0)==1)e=a[r>>0]|0;else e=-1}}while(0);k=r;return e|0}function Pn(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=2052;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function Rn(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=2008;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function On(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=1920;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function In(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=1876;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function Nn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1600;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function Ln(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1556;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function Dn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1512;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function Un(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=1600;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function Hn(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=1556;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function Wn(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=1512;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function Bn(e,i){e=e|0;i=i|0;nr(e,i);fr(e+20|0,i+20|0);ir(e+40|0,i+40|0);return}function jn(e,i,r){e=e|0;i=i|0;r=r|0;var n=0;if(i>>>0>0|(i|0)==0&e>>>0>4294967295)while(1){n=Aa(e|0,i|0,10,0)|0;r=r+-1|0;f[r>>0]=n&255|48;n=e;e=po(e|0,i|0,10,0)|0;if(!(i>>>0>9|(i|0)==9&n>>>0>4294967295))break;else i=x}if(e)while(1){r=r+-1|0;f[r>>0]=(e>>>0)%10|0|48;if(e>>>0<10)break;else e=(e>>>0)/10|0}return r|0}function zn(e){e=e|0;var i=0;t[e>>2]=1380;if((f[e+60+3>>0]|0)<0)pu(t[e+52>>2]|0);if((f[e+36+11>>0]|0)<0)pu(t[e+36>>2]|0);i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Vn(e){e=e|0;var i=0;t[e>>2]=1964;if((f[e+60+3>>0]|0)<0)pu(t[e+52>>2]|0);if((f[e+36+11>>0]|0)<0)pu(t[e+36>>2]|0);i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Gn(e,i){e=e|0;i=i|0;var r=0;t[i>>2]=1424;r=t[e+24>>2]|0;if(!r){t[i+24>>2]=0;return}if((r|0)==(e+8|0)){t[i+24>>2]=i+8;e=t[e+24>>2]|0;Pu[t[(t[e>>2]|0)+12>>2]&31](e,i+8|0);return}else{t[i+24>>2]=Ru[t[(t[r>>2]|0)+8>>2]&63](r)|0;return}}function qn(e){e=e|0;var i=0,r=0;r=Vt(32)|0;t[r>>2]=1424;i=t[e+24>>2]|0;if(!i){t[r+24>>2]=0;return r|0}if((i|0)==(e+8|0)){t[r+24>>2]=r+8;Pu[t[(t[i>>2]|0)+12>>2]&31](i,r+8|0);return r|0}else{t[r+24>>2]=Ru[t[(t[i>>2]|0)+8>>2]&63](i)|0;return r|0}return 0}function Kn(e){e=e|0;var i=0;if((f[e+60+3>>0]|0)<0)pu(t[e+52>>2]|0);if((f[e+36+11>>0]|0)<0)pu(t[e+36>>2]|0);i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Jn(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;$f(e,i);t[e+12>>2]=0;t[e+12+4>>2]=0;t[e+12+8>>2]=0;$f(e+24|0,f);Bn(e+36|0,r);t[e+100>>2]=0;t[e+104>>2]=0;t[e+108>>2]=0;vr(e);return}function Yn(e,i,r){e=e|0;i=i|0;r=r|0;$f(e,i);t[e+12>>2]=0;t[e+12+4>>2]=0;t[e+12+8>>2]=0;t[e+12+12>>2]=0;t[e+12+16>>2]=0;t[e+12+20>>2]=0;Bn(e+36|0,r);t[e+100>>2]=0;t[e+104>>2]=0;t[e+108>>2]=0;vr(e);return}function Xn(e,i,r){e=e|0;i=i|0;r=r|0;var n=0;n=t[e+16>>2]|0;do{if(n){if((n|0)!=(i|0)){t[e+36>>2]=(t[e+36>>2]|0)+1;t[e+24>>2]=2;f[e+54>>0]=1;break}if((t[e+24>>2]|0)==2)t[e+24>>2]=r}else{t[e+16>>2]=i;t[e+24>>2]=r;t[e+36>>2]=1}}while(0);return}function Zn(e,i,r,f,n,a,l,o){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;a=a|0;l=l|0;o=o|0;i=k;k=k+16|0;t[i+4>>2]=r;t[i>>2]=a;l=Lr(r,f,i+4|0,a,l,i,t[e+12>>2]|0,t[e+16>>2]|0)|0;t[n>>2]=t[i+4>>2];t[o>>2]=t[i>>2];k=i;return l|0}function Qn(e,i,r,f,n,a,l,o){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;a=a|0;l=l|0;o=o|0;i=k;k=k+16|0;t[i+4>>2]=r;t[i>>2]=a;l=Er(r,f,i+4|0,a,l,i,t[e+12>>2]|0,t[e+16>>2]|0)|0;t[n>>2]=t[i+4>>2];t[o>>2]=t[i>>2];k=i;return l|0}function $n(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;var t=0;t=k;k=k+256|0;if((r|0)>(f|0)&(n&73728|0)==0){Df(t|0,i|0,((r-f|0)>>>0<256?r-f|0:256)|0)|0;if((r-f|0)>>>0>255){i=r-f|0;do{wo(e,t,256);i=i+-256|0}while(i>>>0>255);i=r-f&255}else i=r-f|0;wo(e,t,i)}k=t;return}function et(e,i,r,f,n,a){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;a=a|0;if(Ro(e,t[i+8>>2]|0)|0)Jf(i,r,f,n);else{e=t[e+8>>2]|0;Du[t[(t[e>>2]|0)+20>>2]&3](e,i,r,f,n,a)}return}function it(e){e=e|0;var i=0,r=0,f=0,n=0;r=k;k=k+16|0;n=Ei(7348)|0;e=Oe(e|0,n|0)|0;fi(n|0);n=Ei(6373)|0;f=Oe(e|0,n|0)|0;fi(n|0);i=+Ne(f|0,1104,r|0);vi(t[r>>2]|0);fi(f|0);fi(e|0);k=r;return i!=0|0}function rt(e){e=e|0;var i=0,r=0,n=0;r=k;k=k+16|0;e=Ke(8191)|0;i=Ei(8199)|0;if((f[16224]|0)==0?so(16224)|0:0)t[4066]=Wi(2,1860)|0;n=t[4066]|0;Ve(i|0);t[r>>2]=i;de(n|0,e|0,8207,r|0);fi(i|0);fi(e|0);k=r;return 1}function ft(e,i,r,f,n,a){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;a=a|0;var l=0,o=0;l=t[e+4>>2]|0;if(!(l&1))o=l>>8;else o=t[(t[f>>2]|0)+(l>>8)>>2]|0;e=t[e>>2]|0;Du[t[(t[e>>2]|0)+20>>2]&3](e,i,r,f+o|0,l&2|0?n:2,a);return}function nt(e){e=e|0;var i=0;t[e>>2]=2052;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function tt(e){e=e|0;var i=0;t[e>>2]=2008;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function at(e){e=e|0;var i=0;t[e>>2]=1920;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function lt(e){e=e|0;var i=0;t[e>>2]=1876;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function ot(e){e=e|0;var i=0;t[e>>2]=1600;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function ut(e){e=e|0;var i=0;t[e>>2]=1556;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function st(e){e=e|0;var i=0;t[e>>2]=1512;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function bt(e){e=e|0;var i=0;t[e>>2]=2272;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function ct(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;if(Ro(e,t[i+8>>2]|0)|0)Xn(i,r,f);else{e=t[e+8>>2]|0;Wu[t[(t[e>>2]|0)+28>>2]&7](e,i,r,f)}return}function ht(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;var a=0,l=0;a=t[e+4>>2]|0;if(!(a&1))l=a>>8;else l=t[(t[r>>2]|0)+(a>>8)>>2]|0;e=t[e>>2]|0;Mu[t[(t[e>>2]|0)+24>>2]&3](e,i,r+l|0,a&2|0?f:2,n);return}function kt(e){e=e|0;var i=0;t[e>>2]=1424;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function dt(e){e=e|0;var i=0;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);pu(e);return}if(!i){pu(e);return}Fu[t[(t[i>>2]|0)+20>>2]&127](i);pu(e);return}function wt(e,i,r){e=e|0;i=i|0;r=r|0;var n=0,t=0;e:do{if(!r)e=0;else{while(1){n=f[e>>0]|0;t=f[i>>0]|0;if(n<<24>>24!=t<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else{e=e+1|0;i=i+1|0}}e=(n&255)-(t&255)|0}}while(0);return e|0}function vt(e,i){e=e|0;i=i|0;var r=0;r=k;k=k+16|0;la(r);pf(e,r,i);Gl(r);k=r;return}function _t(e,i,r){e=e|0;i=i|0;r=r|0;var f=0,n=0,a=0;if(i-e>>2){f=e;i=i-e>>2;while(1){a=(i|0)/2|0;e=f+(a<<2)|0;n=(t[e>>2]|0)>>>0<r>>>0;i=n?i+-1-a|0:a;e=n?e+4|0:f;if(!i)break;else f=e}}return e|0}function pt(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;var n=0,a=0;n=t[e+4>>2]|0;if(!(n&1))a=n>>8;else a=t[(t[r>>2]|0)+(n>>8)>>2]|0;e=t[e>>2]|0;Wu[t[(t[e>>2]|0)+28>>2]&7](e,i,r+a|0,n&2|0?f:2);return}function mt(){var e=0,i=0,r=0;r=(f[2667]|0)==10;do{if((t[667]|0)<0){if(!r?(e=t[653]|0,e>>>0<(t[652]|0)>>>0):0){t[653]=e+1;f[e>>0]=10;break}Fn()|0}else{if(!r?(i=t[653]|0,i>>>0<(t[652]|0)>>>0):0){t[653]=i+1;f[i>>0]=10;break}Fn()|0}}while(0);return}function yt(e){e=e|0;var i=0;t[e>>2]=2052;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function gt(e){e=e|0;var i=0;t[e>>2]=2008;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Tt(e){e=e|0;var i=0;t[e>>2]=1920;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function At(e){e=e|0;var i=0;t[e>>2]=1876;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Et(e){e=e|0;var i=0;t[e>>2]=1600;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Ct(e){e=e|0;var i=0;t[e>>2]=1556;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function St(e){e=e|0;var i=0;t[e>>2]=1512;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function xt(e,i,r){e=e|0;i=i|0;r=r|0;var f=0;f=k;k=k+32|0;t[f>>2]=t[e+60>>2];t[f+4>>2]=0;t[f+8>>2]=i;t[f+12>>2]=f+20;t[f+16>>2]=r;if((Mo(Ii(140,f|0)|0)|0)<0){t[f+20>>2]=-1;e=-1}else e=t[f+20>>2]|0;k=f;return e|0}function Mt(e){e=e|0;var i=0;t[e>>2]=2272;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Ft(e){e=e|0;var i=0;t[e>>2]=1424;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function Pt(e){e=e|0;var i=0,r=0;r=e+15&-16|0;i=t[b>>2]|0;e=i+r|0;if((r|0)>0&(e|0)<(i|0)|(e|0)<0){Z()|0;De(12);return-1}t[b>>2]=e;if((e|0)>(X()|0)?(Y()|0)==0:0){t[b>>2]=i;De(12);return-1}return i|0}function Rt(e){e=e|0;var i=0;i=f[e+74>>0]|0;f[e+74>>0]=i+255|i;i=t[e>>2]|0;if(!(i&8)){t[e+8>>2]=0;t[e+4>>2]=0;i=t[e+44>>2]|0;t[e+28>>2]=i;t[e+20>>2]=i;t[e+16>>2]=i+(t[e+48>>2]|0);i=0}else{t[e>>2]=i|32;i=-1}return i|0}function Ot(e){e=e|0;var i=0;i=t[e+24>>2]|0;if((i|0)==(e+8|0)){Fu[t[(t[i>>2]|0)+16>>2]&127](i);return}if(!i)return;Fu[t[(t[i>>2]|0)+20>>2]&127](i);return}function It(e,i){e=e|0;i=i|0;var r=0,n=0;r=f[e>>0]|0;n=f[i>>0]|0;if(!(r<<24>>24==0?1:r<<24>>24!=n<<24>>24))do{e=e+1|0;i=i+1|0;r=f[e>>0]|0;n=f[i>>0]|0}while(!(r<<24>>24==0?1:r<<24>>24!=n<<24>>24));return(r&255)-(n&255)|0}function Nt(e,i,r,f,n,a){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;a=a|0;if(Ro(e,t[i+8>>2]|0)|0)Jf(i,r,f,n);return}function Lt(e,i){e=e|0;i=i|0;var r=0;if((e|0)!=(i|0)){r=f[i+11>>0]|0;zf(e,r<<24>>24<0?t[i>>2]|0:i,r<<24>>24<0?t[i+4>>2]|0:r&255)|0}return e|0}function Dt(e,i){e=e|0;i=i|0;var r=0,f=0;f=wn(i)|0;r=Vt(f+13|0)|0;t[r>>2]=f;t[r+4>>2]=f;t[r+8>>2]=0;r=No(r)|0;Vr(r|0,i|0,f+1|0)|0;t[e>>2]=r;return}function Ut(e,i){e=e|0;i=i|0;var r=0;r=k;k=k+16|0;e=t[e+4>>2]|0;t[r>>2]=t[i>>2];t[i>>2]=0;e=Ru[e&63](r)|0;fi(t[r>>2]|0);k=r;return e|0}function Ht(e,i,r){e=e|0;i=i|0;r=r|0;var n=0;if((i|0)<(e|0)&(e|0)<(i+r|0)){n=e;i=i+r|0;e=e+r|0;while((r|0)>0){e=e-1|0;i=i-1|0;r=r-1|0;f[e>>0]=f[i>>0]|0}e=n}else Vr(e,i,r)|0;return e|0}function Wt(e){e=e|0;var i=0,r=0,n=0;i=t[e>>2]|0;r=(f[i>>0]|0)+-48|0;if(r>>>0<10){n=i;i=0;do{i=(i*10|0)+r|0;n=n+1|0;t[e>>2]=n;r=(f[n>>0]|0)+-48|0}while(r>>>0<10)}else i=0;return i|0}function Bt(e){e=e|0;var i=0;if((f[e+8+3>>0]|0)<0)i=t[e>>2]|0;else i=e;Uo(i,0);if((f[e+8+3>>0]|0)<0)t[e+4>>2]=0;else f[e+8+3>>0]=0;return e|0}function jt(e){e=e|0;var i=0;i=Ul(t[e+8>>2]|0)|0;if(i|0)Ul(i)|0;i=t[e+8>>2]|0;if(!i)return 1;i=Ul(i)|0;e=tu()|0;if(i|0)Ul(i)|0;return(e|0)==1|0}function zt(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;if(Ro(e,t[i+8>>2]|0)|0)Xn(i,r,f);return}function Vt(e){e=e|0;var i=0;i=(e|0)==0?1:e;e=Vi(i)|0;e:do{if(!e)do{e=zo()|0;if(!e){e=0;break e}Iu[e&3]();e=Vi(i)|0}while(!(e|0))}while(0);return e|0}function Gt(e,i,r,n){e=e|0;i=i|0;r=r|0;n=n|0;if(!((e|0)==0&(i|0)==0))do{r=r+-1|0;f[r>>0]=a[13091+(e&15)>>0]|0|n;e=al(e|0,i|0,4)|0;i=x}while(!((e|0)==0&(i|0)==0));return r|0}function qt(e){e=e|0;var i=0;i=Vt(16)|0;t[i>>2]=2096;$f(i+4|0,e+4|0);return i|0}function Kt(e){e=e|0;var i=0;i=f[w+(e&255)>>0]|0;if((i|0)<8)return i|0;i=f[w+(e>>8&255)>>0]|0;if((i|0)<8)return i+8|0;i=f[w+(e>>16&255)>>0]|0;if((i|0)<8)return i+16|0;return(f[w+(e>>>24)>>0]|0)+24|0}function Jt(e){e=e|0;var i=0;i=Vt(16)|0;t[i>>2]=1776;$f(i+4|0,e+4|0);return i|0}function Yt(e,i){e=e|0;i=i|0;t[i>>2]=2096;$f(i+4|0,e+4|0);return}function Xt(){var e=0,i=0;i=ga()|0;if((i|0?(e=t[i>>2]|0,e|0):0)?(t[e+48>>2]&-256|0)==1126902528?(t[e+48+4>>2]|0)==1129074247:0:0)Ql(t[e+12>>2]|0);Ql(Vo()|0)}function Zt(e,i){e=e|0;i=i|0;t[i>>2]=1776;$f(i+4|0,e+4|0);return}function Qt(e,i,r){e=e|0;i=i|0;r=r|0;var f=0;f=k;k=k+16|0;t[f>>2]=t[r>>2];e=xu[t[(t[e>>2]|0)+16>>2]&7](e,i,f)|0;if(e)t[r>>2]=t[f>>2];k=f;return e&1|0}function $t(e){e=e|0;t[e>>2]=2096;if((f[e+4+11>>0]|0)>=0){pu(e);return}pu(t[e+4>>2]|0);pu(e);return}function ea(e){e=e|0;t[e>>2]=1776;if((f[e+4+11>>0]|0)>=0){pu(e);return}pu(t[e+4>>2]|0);pu(e);return}function ia(e){e=e|0;if((f[e+4+11>>0]|0)>=0){pu(e);return}pu(t[e+4>>2]|0);pu(e);return}function ra(e,i,r){e=e|0;i=i|0;r=r|0;if(!((e|0)==0&(i|0)==0))do{r=r+-1|0;f[r>>0]=e&7|48;e=al(e|0,i|0,3)|0;i=x}while(!((e|0)==0&(i|0)==0));return r|0}function fa(e,i,r){e=e|0;i=i|0;r=r|0;var f=0,n=0;n=t[e+20>>2]|0;f=(t[e+16>>2]|0)-n|0;f=f>>>0>r>>>0?r:f;Vr(n|0,i|0,f|0)|0;t[e+20>>2]=(t[e+20>>2]|0)+f;return r|0}function na(e){e=e|0;t[e>>2]=2096;if((f[e+4+11>>0]|0)>=0)return;pu(t[e+4>>2]|0);return}function ta(e){e=e|0;var i=0;e=t[e+8>>2]|0;if(e){i=Ul(e)|0;e=tu()|0;if(i)Ul(i)|0}else e=1;return e|0}function aa(e){e=e|0;t[e>>2]=1776;if((f[e+4+11>>0]|0)>=0)return;pu(t[e+4>>2]|0);return}function la(e){e=e|0;t[e>>2]=0;t[e+4>>2]=0;t[e+8>>2]=0;vn(e,10);return}function oa(e,i,r){e=e|0;i=i|0;r=r|0;var f=0;if(r|0){f=e;while(1){r=r+-1|0;t[f>>2]=t[i>>2];if(!r)break;else{f=f+4|0;i=i+4|0}}}return e|0}function ua(e,i,r,f,n,t,a,l,o){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;t=t|0;a=a|0;l=l|0;o=o|0;return Nu[e&7](i|0,r|0,f|0,n|0,t|0,a|0,l|0,o|0)|0}function sa(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;return Pr(r,f,n,t[e+12>>2]|0,t[e+16>>2]|0)|0}function ba(e,i){e=e|0;i=i|0;if(Ro(e,i)|0)e=1;else e=Ro(i,1096)|0;return e|0}function ca(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==8464?e+4|0:0)|0}function ha(e){e=e|0;var i=0;e=Wo(t[e>>2]|0)|0;i=t[e+8>>2]|0;t[e+8>>2]=i+-1;if((i+-1|0)<0)pu(e);return}function ka(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==10514?e+8|0:0)|0}function da(e){e=e|0;if((f[e+4+11>>0]|0)>=0)return;pu(t[e+4>>2]|0);return}function wa(e,i,r){e=e|0;i=i|0;r=r|0;if((t[e+4>>2]|0)==(i|0)?(t[e+28>>2]|0)!=1:0)t[e+28>>2]=r;return}function va(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==8379?e+8|0:0)|0}function _a(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==8872?e+8|0:0)|0}function pa(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==9254?e+8|0:0)|0}function ma(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==9489?e+8|0:0)|0}function ya(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==9901?e+8|0:0)|0}function ga(){var e=0,i=0;e=k;k=k+16|0;if(!(ri(16880,2)|0)){i=be(t[4221]|0)|0;k=e;return i|0}else Ll(15539,e);return 0}function Ta(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==7582?e+4|0:0)|0}function Aa(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;var n=0;n=k;k=k+16|0;gr(e,i,r,f,n|0)|0;k=n;return(x=t[n+4>>2]|0,t[n>>2]|0)|0}function Ea(e){e=e|0;var i=0;i=Vt(8)|0;t[i>>2]=1292;t[i+4>>2]=t[e+4>>2];return i|0}function Ca(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==6517?e+8|0:0)|0}function Sa(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==6931?e+8|0:0)|0}function xa(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==7497?e+8|0:0)|0}function Ma(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==10591?e+8|0:0)|0}function Fa(e){e=e|0;var i=0;i=k;k=k+16|0;tr(e);if(!(_i(t[4221]|0,0)|0)){k=i;return}else Ll(15638,i)}function Pa(e,i){e=e|0;i=i|0;t[i>>2]=1292;t[i+4>>2]=t[e+4>>2];return}function Ra(e,i){e=e|0;i=i|0;return mf(e,i,fu(i)|0)|0}function Oa(e){e=e|0;var i=0;i=Vt(8)|0;t[i>>2]=1688;f[i+4>>0]=f[e+4>>0]|0;return i|0}function Ia(e){e=e|0;var i=0;i=Vt(8)|0;t[i>>2]=2228;t[i+4>>2]=t[e+4>>2];return i|0}function Na(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==10136?e+8|0:0)|0}function La(e,i){e=e|0;i=i|0;t[i>>2]=1688;f[i+4>>0]=f[e+4>>0]|0;return}function Da(e){e=e|0;var i=0;i=Vt(8)|0;t[i>>2]=1732;f[i+4>>0]=f[e+4>>0]|0;return i|0}function Ua(e,i){e=e|0;i=i|0;t[i>>2]=2228;t[i+4>>2]=t[e+4>>2];return}function Ha(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==6004?e+4|0:0)|0}function Wa(e,i){e=e|0;i=i|0;t[i>>2]=1732;f[i+4>>0]=f[e+4>>0]|0;return}function Ba(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==11030?e+4|0:0)|0}function ja(e){e=e|0;return zf(e,3755,fu(3755)|0)|0}function za(e){e=e|0;return qf(e,6422,fu(6422)|0)|0}function Va(e){e=e|0;var i=0;i=k;k=k+16|0;t[i>>2]=gu(t[e+60>>2]|0)|0;e=Mo(Ci(6,i|0)|0)|0;k=i;return e|0}function Ga(e,i){e=e|0;i=i|0;var r=0;if(i|0){r=e;while(1){i=i+-1|0;t[r>>2]=0;if(!i)break;else r=r+4|0}}return e|0}function qa(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==7008?e+4|0:0)|0}function Ka(e,i){e=e|0;i=i|0;var r=0;r=k;k=k+16|0;t[r>>2]=e;t[r+4>>2]=i;Mo(Ie(91,r|0)|0)|0;k=r;return}function Ja(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==8957?e+4|0:0)|0}function Ya(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==6594?e+4|0:0)|0}function Xa(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==10213?e+4|0:0)|0}function Za(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==9574?e+4|0:0)|0}function Qa(e){e=e|0;var i=0;t[e>>2]=3232;i=t[e+8>>2]|0;if((i|0)!=(Bl()|0))Zo(t[e+8>>2]|0);return}function $a(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==7050?e+4|0:0)|0}function el(){var e=0;e=k;k=k+16|0;if(!(ve(16884,107)|0)){k=e;return}else Ll(15588,e)}function il(e){e=e|0;var i=0;i=Vt(8)|0;t[i>>2]=1468;t[i+4>>2]=t[e+4>>2];return i|0}function rl(e,i,r,f,n,t,a){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;t=t|0;a=a|0;Du[e&3](i|0,r|0,f|0,n|0,t|0,a|0)}function fl(e,i,r){e=e|0;i=i|0;r=r|0;if((r|0)<32){x=i<<r|(e&(1<<r)-1<<32-r)>>>32-r;return e<<r}x=e<<r-32;return 0}function nl(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;r=k;k=k+16|0;t[r>>2]=f;f=Vf(e,i,r)|0;k=r;return f|0}function tl(e,i){e=e|0;i=i|0;t[i>>2]=1468;t[i+4>>2]=t[e+4>>2];return}function al(e,i,r){e=e|0;i=i|0;r=r|0;if((r|0)<32){x=i>>>r;return e>>>r|(i&(1<<r)-1)<<32-r}x=0;return i>>>r-32|0}function ll(){}function ol(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;f=i-f-(r>>>0>e>>>0|0)>>>0;return(x=f,e-r>>>0|0)|0}function ul(e,i,r,f,n,t){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;t=t|0;return Hu[e&7](i|0,r|0,f|0,n|0,t|0)|0}function sl(e){e=e|0;var i=0,r=0;r=(wn(e)|0)+1|0;i=Vi(r)|0;if(!i)i=0;else Vr(i|0,e|0,r|0)|0;return i|0}function bl(e,i){e=e|0;i=i|0;t[i>>2]=2140;return}function cl(e,i){e=e|0;i=i|0;if(!i)i=0;else i=ef(t[i>>2]|0,t[i+4>>2]|0,e)|0;return(i|0?i:e)|0}function hl(e,i){e=e|0;i=i|0;t[i>>2]=1644;return}function kl(e,i){e=e|0;i=i|0;t[i>>2]=2184;return}function dl(e){e=e|0;return 400}function wl(e,i){e=e|0;i=i|0;return((t[i+4>>2]|0)==8211?e+4|0:0)|0}function vl(e,i,r){e=e|0;i=i|0;r=r|0;return Ro(e,i)|0}function _l(e){e=e|0;return 624}function pl(e){e=e|0;return 376}function ml(e){e=e|0;return 424}function yl(e){e=e|0;return 472}function gl(e){e=e|0;return 496}function Tl(e){e=e|0;return 544}function Al(e){e=e|0;e=Vt(8)|0;t[e>>2]=2140;return e|0}function El(e){e=e|0;e=Vt(8)|0;t[e>>2]=1644;return e|0}function Cl(e){e=e|0;return 296}function Sl(e){e=e|0;e=Vt(8)|0;t[e>>2]=2184;return e|0}function xl(e,i,r,f,n,t){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;t=t|0;Mu[e&3](i|0,r|0,f|0,n|0,t|0)}function Ml(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;t[n>>2]=r;return 3}function Fl(e){e=e|0;return 112}function Pl(e){e=e|0;return 168}function Rl(e){e=e|0;return 248}function Ol(e,i,r){e=e|0;i=i|0;r=r|0;if(!r)r=0;else r=wt(e,i,r)|0;return r|0}function Il(e){e=e|0;return Bt(e)|0}function Nl(e){e=e|0;return 648}function Ll(e,i){e=e|0;i=i|0;var r=0;r=k;k=k+16|0;t[r>>2]=i;bf(2592,e,r)|0;mt();ye()}function Dl(e){e=+e;var i=0;s[c>>3]=e;i=t[c>>2]|0;x=t[c+4>>2]|0;return i|0}function Ul(e){e=e|0;var i=0;i=t[895]|0;if(e|0)t[895]=(e|0)==(-1|0)?16808:e;return((i|0)==16808?-1:i)|0}function Hl(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;return Lu[e&1](i|0,r|0,f|0,n|0)|0}function Wl(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;return(x=i+f+(e+r>>>0>>>0<e>>>0|0)>>>0,e+r>>>0|0)|0}function Bl(){if((f[16240]|0)==0?so(16240)|0:0)t[4219]=Sf(2147483647,15149,0)|0;return t[4219]|0}function jl(e){e=e|0;return 568}function zl(e,i,r,f,n,t,a,l){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;t=t|0;a=a|0;l=l|0;K(7);return 0}function Vl(e){e=e|0;t[e+4>>2]=-1;t[e>>2]=3232;t[e+8>>2]=Bl()|0;return}function Gl(e){e=e|0;if((f[e+11>>0]|0)<0)pu(t[e>>2]|0);return}function ql(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;Wu[e&7](i|0,r|0,f|0,n|0)}function Kl(e,i,r){e=e|0;i=i|0;r=r|0;if(r|0)Ht(e|0,i|0,r|0)|0;return e|0}function Jl(e){e=e|0;return 80}function Yl(e,i,r){e=e|0;i=i|0;r=r|0;if(r|0)Vr(e|0,i|0,r|0)|0;return e|0}function Xl(e){e=e|0;return 680}function Zl(e){e=e|0;if(e|0)Fu[t[(t[e>>2]|0)+4>>2]&127](e);return}function Ql(e){e=e|0;var i=0;i=k;k=k+16|0;Iu[e&3]();Ll(15691,i)}function $l(e){e=e|0;return 192}function eo(e){e=e|0;return 448}function io(e,i){e=e|0;i=i|0;t[e>>2]=3384;Dt(e+4|0,i);return}function ro(e){e=e|0;return 136}function fo(e){e=e|0;return 592}function no(e){e=e|0;return 520}function to(e){e=e|0;if(!e)e=0;else e=(tf(e,1056)|0)!=0;return e&1|0}function ao(e,i){e=e|0;i=i|0;t[e>>2]=3364;Dt(e+4|0,i);return}function lo(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;return xu[e&7](i|0,r|0,f|0)|0}function oo(e){e=e|0;return 216}function uo(e,i,r){e=e|0;i=i|0;r=r|0;if(r|0)oa(e,i,r)|0;return}function so(e){e=e|0;if((f[e>>0]|0)==1)e=0;else{f[e>>0]=1;e=1}return e|0}function bo(e,i){e=e|0;i=i|0;if(i|0)Df(e|0,0,i|0)|0;return e|0}function co(e,i,r){e=e|0;i=i|0;r=r|0;return 0}function ho(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;Ou[e&15](i|0,r|0,f|0)}function ko(e){e=e|0;var i=0;i=k;k=k+e|0;k=k+15&-16;return i|0}function wo(e,i,r){e=e|0;i=i|0;r=r|0;if(!(t[e>>2]&32))yf(i,r,e);return}function vo(e,i){e=e|0;i=i|0;if(!e)e=0;else e=Ef(e,i)|0;return e|0}function _o(e,i){e=e|0;i=i|0;var r=0;r=Eo(e|0)|0;return((i|0)==0?e:r)|0}function po(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;return gr(e,i,r,f,0)|0}function mo(e){e=e|0;Qa(e);pu(e);return}function yo(e){e=e|0;t[e>>2]=3384;ha(e+4|0);return}function go(e,i){e=e|0;i=i|0;if(i|0)Ga(e,i)|0;return}function To(e){e=e|0;t[e>>2]=3364;ha(e+4|0);return}function Ao(e){e=e|0;return((t[e+16>>2]&4|0)==0?4:7)|0}function Eo(e){e=e|0;return(e&255)<<24|(e>>8&255)<<16|(e>>16&255)<<8|e>>>24|0}function Co(e,i,r){e=e|0;i=i|0;r=r|0;return Uu[e&31](i|0,r|0)|0}function So(e){e=e|0;return 336}function xo(e,i,r,f,n,t){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;t=t|0;K(9)}function Mo(e){e=e|0;if(e>>>0>4294963200){t[4223]=0-e;e=-1}return e|0}function Fo(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;K(11);return 0}function Po(e,i,r){e=e|0;i=i|0;r=r|0;return zr(0,e,i,r|0?r:16872)|0}function Ro(e,i){e=e|0;i=i|0;return(e|0)==(i|0)|0}function Oo(){t[4054]=0;Ai(5970,2,1276,5983,26,106);return}function Io(e,i){e=e|0;i=i|0;if(!v){v=e;_=i}}function No(e){e=e|0;return e+12|0}function Lo(e,i,r){e=e|0;i=i|0;r=r|0;Pu[e&31](i|0,r|0)}function Do(e){e=e|0;return(e|0)!=2364&((e|0)!=0&(e|0)!=16832)&1|0}function Uo(e,i){e=e|0;i=i|0;t[e>>2]=i;return}function Ho(e,i){e=e|0;i=i|0;f[e>>0]=i;return}function Wo(e){e=e|0;return e+-12|0}function Bo(e,i,r,f,n){e=e|0;i=i|0;r=r|0;f=f|0;n=n|0;K(1)}function jo(e){e=e|0;var i=0;i=(cu(e)|0)==0;return(i?e:e|32)|0}function zo(){var e=0;e=t[4222]|0;t[4222]=e+0;return e|0}function Vo(){var e=0;e=t[818]|0;t[818]=e+0;return e|0}function Go(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;K(8);return 0}function qo(e){e=e|0;yo(e);pu(e);return}function Ko(e){e=e|0;Le(e|0)|0;Xt()}function Jo(e,i){e=e|0;i=i|0;return Ru[e&63](i|0)|0}function Yo(e){e=e|0;To(e);pu(e);return}function Xo(e){e=e|0;return gu(t[e+4>>2]|0)|0}function Zo(e){e=e|0;if(Do(e)|0)tr(e);return}function Qo(e,i){e=e|0;i=i|0;k=e;d=i}function $o(e,i,r,f){e=e|0;i=i|0;r=r|0;f=f|0;K(12)}function eu(e,i){e=e|0;i=i|0;Fu[e&127](i|0)}function iu(e,i){e=e|0;i=i|0;return cl(e,i)|0}function ru(e){e=e|0;return sl(t[e+4>>2]|0)|0}function fu(e){e=e|0;return wn(e)|0}function nu(e,i,r){e=e|0;i=i|0;r=r|0;K(0);return 0}function tu(){return(t[t[895]>>2]|0?4:1)|0}function au(){ye()}function lu(e){e=e|0;return An(e,t[895]|0)|0}function ou(e){e=e|0;pu(e);return}function uu(e){e=e|0;return 0}function su(e,i){e=+e;i=i|0;return+ +_n(e,i)}function bu(e,i,r){e=e|0;i=i|0;r=r|0;K(5)}function cu(e){e=e|0;return(e+-65|0)>>>0<26|0}function hu(e,i){e=e|0;i=i|0;K(10);return 0}function ku(e){e=e|0;return 15731}function du(e){e=e|0;Iu[e&3]()}function wu(e,i){e=e|0;i=i|0;K(3)}function vu(e){e=e|0;return}function _u(e){e=e|0;k=e}function pu(e){e=e|0;tr(e);return}function mu(e){e=e|0;x=e}function yu(){return 16768}function gu(e){e=e|0;return e|0}function Tu(e){e=e|0;K(4);return 0}function Au(){return x|0}function Eu(){return k|0}function Cu(e){e=e|0;K(2)}function Su(){K(6)}var xu=[nu,Kr,xt,fa,Zf,vl,$r,co];var Mu=[Bo,Bf,Xr,Tr];var Fu=[Cu,vu,ou,vu,ou,vu,ou,on,tn,bn,an,zn,mn,Kn,Tn,Ft,kt,Ot,dt,vu,ou,vu,ou,St,st,Ot,dt,Ct,ut,Ot,dt,Et,ot,Ot,dt,ou,vu,ou,ou,vu,ou,vu,ou,vu,ou,aa,ea,da,ia,Qa,mo,Zl,At,lt,Ot,dt,Tt,at,Ot,dt,Vn,yn,Kn,Tn,gt,tt,Ot,dt,yt,nt,Ot,dt,na,$t,da,ia,ou,vu,ou,ou,vu,ou,ou,vu,ou,Mt,bt,Ot,dt,mo,vu,ou,vu,vu,ou,To,Yo,yo,qo,Yo,Yo,qo,ou,ou,ou,ou,of,Fa,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu,Cu];var Pu=[wu,Pa,Yr,$i,Of,Ar,Gn,fn,tl,Dn,Ln,Nn,hl,La,Wa,Zt,Mn,xn,If,Sn,Cn,Yt,bl,kl,Ua,cn,Nf,wu,wu,wu,wu,wu];var Ru=[Tu,ku,Ea,Jl,Jr,Xl,Uf,_l,qn,jl,il,So,Wn,Rl,Hn,Pl,Un,Fl,El,ro,Oa,$l,Da,oo,Jt,Cl,uu,uu,Ao,In,Tl,On,gl,Hf,yl,Rn,ml,Pn,pl,qt,dl,Al,eo,Sl,no,Ia,fo,dn,Nl,Va,jt,uu,ta,Xo,Xo,rt,Tu,Tu,Tu,Tu,Tu,Tu,Tu,Tu];var Ou=[bu,wf,Fr,yr,nf,br,Zr,lf,Zi,xr,pr,bu,bu,bu,bu,bu];var Iu=[Su,_f,el,Su];var Nu=[zl,Zn,Qn,Mr,Sr,zl,zl,zl];var Lu=[Go,sf];var Du=[xo,Nt,et,Qr];var Uu=[hu,Ha,Ba,ka,Na,Ut,wl,Ir,xa,Tf,Sa,Rf,Ca,Ya,qa,$a,Ta,gf,ya,Pf,ma,gn,pa,Ff,_a,Or,va,ca,Ja,Za,Xa,Ma];var Hu=[Fo,Ml,sa,Cf,ln,Fo,Fo,Fo];var Wu=[$o,zt,ct,jf,ur,$o,$o,$o];return{_llvm_bswap_i32:Eo,_main:er,_i64Subtract:ol,_memset:Df,setThrew:Io,dynCall_viii:ho,_bitshift64Lshr:al,_bitshift64Shl:fl,__GLOBAL__sub_I_index_cpp:Oo,dynCall_iiiiiiiii:ua,___cxa_is_pointer_type:to,dynCall_iii:Co,_llvm_cttz_i32:Kt,_sbrk:Pt,_memcpy:Vr,stackAlloc:ko,dynCall_vii:Lo,___uremdi3:Aa,dynCall_vi:eu,__GLOBAL__sub_I_asm_dom_cpp:pn,getTempRet0:Au,__GLOBAL__sub_I_bind_cpp:qr,___udivmoddi4:gr,setTempRet0:mu,_i64Add:Wl,dynCall_iiii:lo,_emscripten_get_global_libc:yu,dynCall_iiiii:Hl,___getTypeName:ru,dynCall_ii:Jo,___udivdi3:po,dynCall_iiiiii:ul,stackSave:Eu,dynCall_viiiii:xl,___cxa_can_catch:Qt,_free:tr,runPostSets:ll,dynCall_viiii:ql,dynCall_viiiiii:rl,establishStackSpace:Qo,_memmove:Ht,stackRestore:_u,_malloc:Vi,dynCall_v:du}}(b.J,b.K,A);b._main=k._main,b.stackSave=k.stackSave,b.getTempRet0=k.getTempRet0;var Sb=b._memset=k._memset;b.setThrew=k.setThrew;var Zb=b.___udivdi3=k.___udivdi3,Ub=b._bitshift64Lshr=k._bitshift64Lshr,Tb=b._bitshift64Shl=k._bitshift64Shl;b.___cxa_is_pointer_type=k.___cxa_is_pointer_type;var Xb=b._llvm_cttz_i32=k._llvm_cttz_i32,$b=b._sbrk=k._sbrk,Vb=b._memcpy=k._memcpy;b.stackAlloc=k.stackAlloc;var bc=b.___uremdi3=k.___uremdi3,Mb=b.__GLOBAL__sub_I_asm_dom_cpp=k.__GLOBAL__sub_I_asm_dom_cpp,Qb=b._i64Subtract=k._i64Subtract,Ob=b.__GLOBAL__sub_I_bind_cpp=k.__GLOBAL__sub_I_bind_cpp,Yb=b.___udivmoddi4=k.___udivmoddi4;b.setTempRet0=k.setTempRet0;var Rb=b._i64Add=k._i64Add;b._emscripten_get_global_libc=k._emscripten_get_global_libc;var Ib=b.___getTypeName=k.___getTypeName,Nb=b.__GLOBAL__sub_I_index_cpp=k.__GLOBAL__sub_I_index_cpp,cc=b._llvm_bswap_i32=k._llvm_bswap_i32;b.___cxa_can_catch=k.___cxa_can_catch;var y=b._free=k._free;b.runPostSets=k.runPostSets,b.establishStackSpace=k.establishStackSpace;var ac=b._memmove=k._memmove;b.stackRestore=k.stackRestore;var L=b._malloc=k._malloc;b.dynCall_iiii=k.dynCall_iiii,b.dynCall_viiiii=k.dynCall_viiiii,b.dynCall_vi=k.dynCall_vi,b.dynCall_vii=k.dynCall_vii,b.dynCall_ii=k.dynCall_ii,b.dynCall_viii=k.dynCall_viii,b.dynCall_v=k.dynCall_v,b.dynCall_iiiiiiiii=k.dynCall_iiiiiiiii,b.dynCall_iiiii=k.dynCall_iiiii,b.dynCall_viiiiii=k.dynCall_viiiiii,b.dynCall_iii=k.dynCall_iii,b.dynCall_iiiiii=k.dynCall_iiiiii,b.dynCall_viiii=k.dynCall_viiii,h.D=b.stackAlloc,h.W=b.stackSave,h.V=b.stackRestore,h.ga=b.establishStackSpace,h.g=b.setTempRet0,h.P=b.getTempRet0,b.asm=k,W.prototype=Error(),W.prototype.constructor=W;var Lb,vb=null;b.callMain=b.aa=function(e){function i(){for(var e=0;3>e;e++)f.push(0)}e=e||[],sa||(sa=!0,T(Ha));var r=e.length+1,f=[G(ya(b.thisProgram),\"i8\",0)];i();for(var n=0;n<r-1;n+=1)f.push(G(ya(e[n]),\"i8\",0)),i();f.push(0),f=G(f,\"i32\",0);try{xb(b._main(r,f,0),!0)}catch(i){i instanceof W||(\"SimulateInfiniteLoop\"==i?b.noExitRuntime=!0:((e=i)&&\"object\"==typeof i&&i.stack&&(e=[i,i.stack]),b.m(\"exception thrown: \"+e),b.quit(1,i)))}},b.run=b.run=sb,b.exit=b.exit=xb;var zb=[];if(b.abort=b.abort=F,b.preInit)for(\"function\"==typeof b.preInit&&(b.preInit=[b.preInit]);0<b.preInit.length;)b.preInit.pop()();var tb=!0;return b.noInitialRun&&(tb=!1),b.noExitRuntime=!0,sb(),b}}module.exports=ga()}).call(exports,__webpack_require__(344))},344:function(e,i){function r(){throw new Error(\"setTimeout has not been defined\")}function f(){throw new Error(\"clearTimeout has not been defined\")}function n(e){if(s===setTimeout)return setTimeout(e,0);if((s===r||!s)&&setTimeout)return s=setTimeout,setTimeout(e,0);try{return s(e,0)}catch(i){try{return s.call(null,e,0)}catch(i){return s.call(this,e,0)}}}function t(e){if(b===clearTimeout)return clearTimeout(e);if((b===f||!b)&&clearTimeout)return b=clearTimeout,clearTimeout(e);try{return b(e)}catch(i){try{return b.call(null,e)}catch(i){return b.call(this,e)}}}function a(){d&&h&&(d=!1,h.length?k=h.concat(k):w=-1,k.length&&l())}function l(){if(!d){var e=n(a);d=!0;for(var i=k.length;i;){for(h=k,k=[];++w<i;)h&&h[w].run();w=-1,i=k.length}h=null,d=!1,t(e)}}function o(e,i){this.fun=e,this.array=i}function u(){}var s,b,c=e.exports={};!function(){try{s=\"function\"==typeof setTimeout?setTimeout:r}catch(e){s=r}try{b=\"function\"==typeof clearTimeout?clearTimeout:f}catch(e){b=f}}();var h,k=[],d=!1,w=-1;c.nextTick=function(e){var i=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)i[r-1]=arguments[r];k.push(new o(e,i)),1!==k.length||d||n(l)},o.prototype.run=function(){this.fun.apply(null,this.array)},c.title=\"browser\",c.browser=!0,c.env={},c.argv=[],c.version=\"\",c.versions={},c.on=u,c.addListener=u,c.once=u,c.off=u,c.removeListener=u,c.removeAllListeners=u,c.emit=u,c.prependListener=u,c.prependOnceListener=u,c.listeners=function(e){return[]},c.binding=function(e){throw new Error(\"process.binding is not supported\")},c.cwd=function(){return\"/\"},c.chdir=function(e){throw new Error(\"process.chdir is not supported\")},c.umask=function(){return 0}},345:function(e,i){},346:function(e,i,r){(function(e){function r(e,i){for(var r=0,f=e.length-1;f>=0;f--){var n=e[f];\".\"===n?e.splice(f,1):\"..\"===n?(e.splice(f,1),r++):r&&(e.splice(f,1),r--)}if(i)for(;r--;r)e.unshift(\"..\");return e}function f(e,i){if(e.filter)return e.filter(i);for(var r=[],f=0;f<e.length;f++)i(e[f],f,e)&&r.push(e[f]);return r}var n=/^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/,t=function(e){return n.exec(e).slice(1)};i.resolve=function(){for(var i=\"\",n=!1,t=arguments.length-1;t>=-1&&!n;t--){var a=t>=0?arguments[t]:e.cwd();if(\"string\"!=typeof a)throw new TypeError(\"Arguments to path.resolve must be strings\");a&&(i=a+\"/\"+i,n=\"/\"===a.charAt(0))}return i=r(f(i.split(\"/\"),function(e){return!!e}),!n).join(\"/\"),(n?\"/\":\"\")+i||\".\"},i.normalize=function(e){var n=i.isAbsolute(e),t=\"/\"===a(e,-1);return e=r(f(e.split(\"/\"),function(e){return!!e}),!n).join(\"/\"),e||n||(e=\".\"),e&&t&&(e+=\"/\"),(n?\"/\":\"\")+e},i.isAbsolute=function(e){return\"/\"===e.charAt(0)},i.join=function(){var e=Array.prototype.slice.call(arguments,0);return i.normalize(f(e,function(e,i){if(\"string\"!=typeof e)throw new TypeError(\"Arguments to path.join must be strings\");return e}).join(\"/\"))},i.relative=function(e,r){function f(e){for(var i=0;i<e.length&&\"\"===e[i];i++);for(var r=e.length-1;r>=0&&\"\"===e[r];r--);return i>r?[]:e.slice(i,r-i+1)}e=i.resolve(e).substr(1),r=i.resolve(r).substr(1);for(var n=f(e.split(\"/\")),t=f(r.split(\"/\")),a=Math.min(n.length,t.length),l=a,o=0;o<a;o++)if(n[o]!==t[o]){l=o;break}for(var u=[],o=l;o<n.length;o++)u.push(\"..\");return u=u.concat(t.slice(l)),u.join(\"/\")},i.sep=\"/\",i.delimiter=\":\",i.dirname=function(e){var i=t(e),r=i[0],f=i[1];return r||f?(f&&(f=f.substr(0,f.length-1)),r+f):\".\"},i.basename=function(e,i){var r=t(e)[2];return i&&r.substr(-1*i.length)===i&&(r=r.substr(0,r.length-i.length)),r},i.extname=function(e){return t(e)[3]};var a=\"b\"===\"ab\".substr(-1)?function(e,i,r){return e.substr(i,r)}:function(e,i,r){return i<0&&(i=e.length+i),e.substr(i,r)}}).call(i,r(344))}});", "file_path": "website/static/examples/todomvc/1.bundle.js", "rank": 72, "score": 19325.114512819146 }, { "content": "webpackJsonp([0],{342:function(module,exports,__webpack_require__){(function(process){function la(){return function(b){function ab(n){eval.call(null,n)}function z(n,e){n||B(\"Assertion failed: \"+e)}function Sb(n){var e;switch(e=\"i32\",\"*\"===e.charAt(e.length-1)&&(e=\"i32\"),e){case\"i1\":case\"i8\":return r[n>>0];case\"i16\":return S[n>>1];case\"i32\":case\"i64\":return p[n>>2];case\"float\":return ba[n>>2];case\"double\":return ca[n>>3];default:B(\"invalid type for setValue: \"+e)}return null}function O(n,e,t){var a,i,o;\"number\"==typeof n?(i=!0,o=n):(i=!1,o=n.length);var l,c=\"string\"==typeof e?e:null;if(l=4==t?a:[\"function\"==typeof P?P:h.F,h.D,h.F,h.M][void 0===t?2:t](Math.max(o,c?1:e.length)),i){for(a=l,z(0==(3&l)),n=l+(-4&o);a<n;a+=4)p[a>>2]=0;for(n=l+o;a<n;)r[a++>>0]=0;return l}if(\"i8\"===c)return n.subarray||n.slice?u.set(n,l):u.set(new Uint8Array(n),l),l;a=0;for(var s,f;a<o;){var b=n[a];if(\"function\"==typeof b&&(b=h.na(b)),0===(t=c||e[a]))a++;else{\"i64\"==t&&(t=\"i32\"),i=l+a;var m=t,m=m||\"i8\";switch(\"*\"===m.charAt(m.length-1)&&(m=\"i32\"),m){case\"i1\":case\"i8\":r[i>>0]=b;break;case\"i16\":S[i>>1]=b;break;case\"i32\":p[i>>2]=b;break;case\"i64\":tempI64=[b>>>0,(tempDouble=b,1<=+Tb(tempDouble)?0<tempDouble?(0|Ub(+Vb(tempDouble/4294967296),4294967295))>>>0:~~+Wb((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],p[i>>2]=tempI64[0],p[i+4>>2]=tempI64[1];break;case\"float\":ba[i>>2]=b;break;case\"double\":ca[i>>3]=b;break;default:B(\"invalid type for setValue: \"+m)}f!==t&&(s=h.B(t),f=t),a+=s}}return l}function Fa(n){var e;if(0===e||!n)return\"\";for(var r,t=0,a=0;(r=u[n+a>>0],t|=r,0!=r||e)&&(a++,!e||a!=e););if(e||(e=a),r=\"\",128>t){for(;0<e;)t=String.fromCharCode.apply(String,u.subarray(n,n+Math.min(e,1024))),r=r?r+t:t,n+=1024,e-=1024;return r}return b.UTF8ToString(n)}function bb(n,e){for(var r=e;n[r];)++r;if(16<r-e&&n.subarray&&cb)return cb.decode(n.subarray(e,r));for(var t,a,i,o,u,l,r=\"\";;){if(!(t=n[e++]))return r;128&t?(a=63&n[e++],192==(224&t)?r+=String.fromCharCode((31&t)<<6|a):(i=63&n[e++],224==(240&t)?t=(15&t)<<12|a<<6|i:(o=63&n[e++],240==(248&t)?t=(7&t)<<18|a<<12|i<<6|o:(u=63&n[e++],248==(252&t)?t=(3&t)<<24|a<<18|i<<12|o<<6|u:(l=63&n[e++],t=(1&t)<<30|a<<24|i<<18|o<<12|u<<6|l))),65536>t?r+=String.fromCharCode(t):(t-=65536,r+=String.fromCharCode(55296|t>>10,56320|1023&t)))):r+=String.fromCharCode(t)}}function db(n,e,r,t){if(0<t){t=r+t-1;for(var a=0;a<n.length;++a){var i=n.charCodeAt(a);if(55296<=i&&57343>=i&&(i=65536+((1023&i)<<10)|1023&n.charCodeAt(++a)),127>=i){if(r>=t)break;e[r++]=i}else{if(2047>=i){if(r+1>=t)break;e[r++]=192|i>>6}else{if(65535>=i){if(r+2>=t)break;e[r++]=224|i>>12}else{if(2097151>=i){if(r+3>=t)break;e[r++]=240|i>>18}else{if(67108863>=i){if(r+4>=t)break;e[r++]=248|i>>24}else{if(r+5>=t)break;e[r++]=252|i>>30,e[r++]=128|i>>24&63}e[r++]=128|i>>18&63}e[r++]=128|i>>12&63}e[r++]=128|i>>6&63}e[r++]=128|63&i}}e[r]=0}}function eb(n){for(var e=0,r=0;r<n.length;++r){var t=n.charCodeAt(r);55296<=t&&57343>=t&&(t=65536+((1023&t)<<10)|1023&n.charCodeAt(++r)),127>=t?++e:e=2047>=t?e+2:65535>=t?e+3:2097151>=t?e+4:67108863>=t?e+5:e+6}return e}function Xb(n){return n.replace(/__Z[\\w\\d_]+/g,function(n){var e;n:{var r=b.___cxa_demangle||b.__cxa_demangle;if(r)try{var t=n.substr(1),a=eb(t)+1,i=P(a);db(t,u,i,a);var o=P(4),l=r(i,0,0,o);if(0===Sb(o)&&l){e=Fa(l);break n}}catch(n){}finally{i&&E(i),o&&E(o),l&&E(l)}else h.h(\"warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling\");e=n}return n===e?n:n+\" [\"+e+\"]\"})}function Yb(){var n;n:{if(n=Error(),!n.stack){try{throw Error(0)}catch(e){n=e}if(!n.stack){n=\"(no stack trace available)\";break n}}n=n.stack.toString()}return b.extraStackTrace&&(n+=\"\\n\"+b.extraStackTrace()),Xb(n)}function Ga(n,e){return 0<n%e&&(n+=e-n%e),n}function Ha(){b.HEAP8=r=new Int8Array(v),b.HEAP16=S=new Int16Array(v),b.HEAP32=p=new Int32Array(v),b.HEAPU8=u=new Uint8Array(v),b.HEAPU16=ma=new Uint16Array(v),b.HEAPU32=J=new Uint32Array(v),b.HEAPF32=ba=new Float32Array(v),b.HEAPF64=ca=new Float64Array(v)}function fb(){var n=b.usingWasm?Ia:gb,e=2147483648-n;if(p[M>>2]>e)return!1;var r=t;for(t=Math.max(t,Zb);t<p[M>>2];)t=536870912>=t?Ga(2*t,n):Math.min(Ga((3*t+2147483648)/4,n),e);return(n=b.reallocBuffer(t))&&n.byteLength==t?(b.buffer=v=n,Ha(),!0):(t=r,!1)}function W(n){for(;0<n.length;){var e=n.shift();if(\"function\"==typeof e)e();else{var r=e.t;\"number\"==typeof r?void 0===e.q?b.dynCall_v(r):b.dynCall_vi(r,e.q):r(void 0===e.q?null:e.q)}}}function $b(n){hb.unshift(n)}function Ja(n){var e=Array(eb(n)+1);return db(n,e,0,e.length),e}function ib(){T++,b.monitorRunDependencies&&b.monitorRunDependencies(T)}function jb(){if(T--,b.monitorRunDependencies&&b.monitorRunDependencies(T),0==T&&(null!==Ka&&(clearInterval(Ka),Ka=null),da)){var n=da;da=null,n()}}function kb(){for(var n=Array(256),e=0;256>e;++e)n[e]=String.fromCharCode(e);lb=n}function F(n){for(var e=\"\";u[n];)e+=lb[u[n++]];return e}function na(n){if(void 0===n)return\"_unknown\";n=n.replace(/[^a-zA-Z0-9_]/g,\"$\");var e=n.charCodeAt(0);return 48<=e&&57>=e?\"_\"+n:n}function La(n,e){return n=na(n),new Function(\"body\",\"return function \"+n+'() {\\n \"use strict\"; return body.apply(this, arguments);\\n};\\n')(e)}function oa(n,e){var r=La(e,function(n){this.name=e,this.message=n,void 0!==(n=Error(n).stack)&&(this.stack=this.toString()+\"\\n\"+n.replace(/^Error(:[^\\n]*)?\\n/,\"\"))});return r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return void 0===this.message?this.name:this.name+\": \"+this.message},r}function y(n){throw new mb(n)}function Ma(n){throw new nb(n)}function ob(n,e,r){function t(e){e=r(e),e.length!==n.length&&Ma(\"Mismatched type converter count\");for(var t=0;t<n.length;++t)K(n[t],e[t])}n.forEach(function(n){pa[n]=e});var a=Array(e.length),i=[],o=0;e.forEach(function(n,e){U.hasOwnProperty(n)?a[e]=U[n]:(i.push(n),X.hasOwnProperty(n)||(X[n]=[]),X[n].push(function(){a[e]=U[n],++o===i.length&&t(a)}))}),0===i.length&&t(a)}function K(n,e,r){if(r=r||{},!(\"argPackAdvance\"in e))throw new TypeError(\"registerType registeredInstance requires argPackAdvance\");var t=e.name;if(n||y('type \"'+t+'\" must have a positive integer typeid pointer'),U.hasOwnProperty(n)){if(r.R)return;y(\"Cannot register type '\"+t+\"' twice\")}U[n]=e,delete pa[n],X.hasOwnProperty(n)&&(e=X[n],delete X[n],e.forEach(function(n){n()}))}function pb(n){var e=qa.length;return qa.push(n),e}function Na(n){n=ac(n);var e=F(n);return E(n),e}function ra(n,e){var r=U[n];return void 0===r&&y(e+\" has unknown type \"+Na(n)),r}function qb(n,e){for(var r=Array(n),t=0;t<n;++t)r[t]=ra(p[(e>>2)+t],\"parameter \"+t);return r}function Oa(n,e){if(!(n instanceof Function))throw new TypeError(\"new_ called with constructor type \"+typeof n+\" which is not a function\");var r=La(n.name||\"unknownFunctionName\",function(){});r.prototype=n.prototype;var r=new r,t=n.apply(r,e);return t instanceof Object?t:r}function Y(){return!!Y.a}function ea(){var n=x.l;if(!n)return 0|(h.g(0),0);var e=x.b[n],r=e.type;if(!r)return 0|(h.g(0),n);var t=Array.prototype.slice.call(arguments);b.___cxa_is_pointer_type(r),ea.buffer||(ea.buffer=P(4)),p[ea.buffer>>2]=n;for(var n=ea.buffer,a=0;a<t.length;a++)if(t[a]&&b.___cxa_can_catch(t[a],r,n))return n=p[n>>2],e.v=n,0|(h.g(t[a]),n);return n=p[n>>2],0|(h.g(r),n)}function fa(n){var e=bc[n];return void 0===e?F(n):e}function rb(){for(var n=0,e=5;e<C.length;++e)void 0!==C[e]&&++n;return n}function sb(){for(var n=5;n<C.length;++n)if(void 0!==C[n])return C[n];return null}function tb(){b.count_emval_handles=rb,b.get_first_emval=sb}function N(n){switch(n){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var e=Pa.length?Pa.pop():C.length;return C[e]={d:1,value:n},e}}function G(n){return n||y(\"Cannot use deleted val. handle = \"+n),C[n].value}function ub(n){var e=[];return p[n>>2]=N(e),e}function ga(n,e){ga.a||(ga.a={}),n in ga.a||(b.dynCall_v(e),ga.a[n]=1)}function Qa(n){4<n&&0==--C[n].d&&(C[n]=void 0,Pa.push(n))}function sa(n){if(null===n)return\"null\";var e=typeof n;return\"object\"===e||\"array\"===e||\"function\"===e?n.toString():\"\"+n}function ta(n){switch(n){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(\"Unknown type size: \"+n)}}function vb(n,e,t){switch(e){case 0:return t?function(n){return r[n]}:function(n){return u[n]};case 1:return t?function(n){return S[n>>1]}:function(n){return ma[n>>1]};case 2:return t?function(n){return p[n>>2]}:function(n){return J[n>>2]};default:throw new TypeError(\"Unknown integer type: \"+n)}}function ua(n){return this.fromWireType(J[n>>2])}function wb(n,e){switch(e){case 2:return function(n){return this.fromWireType(ba[n>>2])};case 3:return function(n){return this.fromWireType(ca[n>>3])};default:throw new TypeError(\"Unknown float type: \"+n)}}function va(n){var e,t;va.i?(t=p[xb>>2],e=p[t>>2]):(va.i=!0,L.USER=L.LOGNAME=\"web_user\",L.PATH=\"/\",L.PWD=\"/\",L.HOME=\"/home/web_user\",L.LANG=\"C\",L._=b.thisProgram,e=O(1024,\"i8\",2),t=O(256,\"i8*\",2),p[t>>2]=e,p[xb>>2]=t);var a,i=[],o=0;for(a in n)if(\"string\"==typeof n[a]){var u=a+\"=\"+n[a];i.push(u),o+=u.length}if(1024<o)throw Error(\"Environment size exceeded TOTAL_ENV_SIZE!\");for(n=0;n<i.length;n++){o=u=i[n],a=e;for(var l=0;l<o.length;++l)r[a++>>0]=o.charCodeAt(l);r[a>>0]=0,p[t+4*n>>2]=e,e+=u.length+1}p[t+4*i.length>>2]=0}function ha(n){return 0===n?0:(n=Fa(n),L.hasOwnProperty(n)?(ha.a&&E(ha.a),ha.a=O(Ja(L[n]),\"i8\",0),ha.a):0)}function Ra(n){for(;n.length;){var e=n.pop();n.pop()(e)}}function yb(n,e,r,t,a){var i=e.length;2>i&&y(\"argTypes array size mismatch! Must at least get return value and 'this' types!\");var o=null!==e[1]&&null!==r,u=\"\",l=\"\";for(r=0;r<i-2;++r)u+=(0!==r?\", \":\"\")+\"arg\"+r,l+=(0!==r?\", \":\"\")+\"arg\"+r+\"Wired\";n=\"return function \"+na(n)+\"(\"+u+\") {\\nif (arguments.length !== \"+(i-2)+\") {\\nthrowBindingError('function \"+n+\" called with ' + arguments.length + ' arguments, expected \"+(i-2)+\" args!');\\n}\\n\";var c=!1;for(r=1;r<e.length;++r)if(null!==e[r]&&void 0===e[r].e){c=!0;break}c&&(n+=\"var destructors = [];\\n\");var s=c?\"destructors\":\"null\",u=\"throwBindingError invoker fn runDestructors retType classParam\".split(\" \");for(t=[y,t,a,Ra,e[0],e[1]],o&&(n+=\"var thisWired = classParam.toWireType(\"+s+\", this);\\n\"),r=0;r<i-2;++r)n+=\"var arg\"+r+\"Wired = argType\"+r+\".toWireType(\"+s+\", arg\"+r+\"); // \"+e[r+2].name+\"\\n\",u.push(\"argType\"+r),t.push(e[r+2]);if(o&&(l=\"thisWired\"+(0<l.length?\", \":\"\")+l),i=\"void\"!==e[0].name,n+=(i?\"var rv = \":\"\")+\"invoker(fn\"+(0<l.length?\", \":\"\")+l+\");\\n\",c)n+=\"runDestructors(destructors);\\n\";else for(r=o?1:2;r<e.length;++r)o=1===r?\"thisWired\":\"arg\"+(r-2)+\"Wired\",null!==e[r].e&&(n+=o+\"_dtor(\"+o+\"); // \"+e[r].name+\"\\n\",u.push(o+\"_dtor\"),t.push(e[r].e));return i&&(n+=\"var ret = retType.fromWireType(rv);\\nreturn ret;\\n\"),u.push(n+\"}\\n\"),Oa(Function,u).apply(null,t)}function zb(n,e,r){if(void 0===n[e].c){var t=n[e];n[e]=function(){return n[e].c.hasOwnProperty(arguments.length)||y(\"Function '\"+r+\"' called with an invalid number of arguments (\"+arguments.length+\") - expects one of (\"+n[e].c+\")!\"),n[e].c[arguments.length].apply(this,arguments)},n[e].c=[],n[e].c[t.I]=t}}function Ab(n,e,r){b.hasOwnProperty(n)?((void 0===r||void 0!==b[n].c&&void 0!==b[n].c[r])&&y(\"Cannot register public name '\"+n+\"' twice\"),zb(b,n,n),b.hasOwnProperty(r)&&y(\"Cannot register multiple overloads of a function with the same number of arguments (\"+r+\")!\"),b[n].c[r]=e):(b[n]=e,void 0!==r&&(b[n].xa=r))}function Bb(n,e){for(var r=[],t=0;t<n;t++)r.push(p[(e>>2)+t]);return r}function Cb(n,e,r){b.hasOwnProperty(n)||Ma(\"Replacing nonexistant public symbol\"),void 0!==b[n].c&&void 0!==r?b[n].c[r]=e:(b[n]=e,b[n].I=r)}function Db(n,e){n=F(n);var r;if(void 0!==b[\"FUNCTION_TABLE_\"+n])r=b[\"FUNCTION_TABLE_\"+n][e];else if(\"undefined\"!=typeof FUNCTION_TABLE)r=FUNCTION_TABLE[e];else{r=b.asm[\"dynCall_\"+n],void 0===r&&void 0===(r=b.asm[\"dynCall_\"+n.replace(/f/g,\"d\")])&&y(\"No dynCall invoker for signature: \"+n);for(var t=[],a=1;a<n.length;++a)t.push(\"a\"+a);a=\"return function dynCall_\"+n+\"_\"+e+\"(\"+t.join(\", \")+\") {\\n\",a+=\" return dynCall(rawFunction\"+(t.length?\", \":\"\")+t.join(\", \")+\");\\n\",r=new Function(\"dynCall\",\"rawFunction\",a+\"};\\n\")(r,e)}return\"function\"!=typeof r&&y(\"unknown function pointer with signature \"+n+\": \"+e),r}function Eb(n,e){function r(n){a[n]||U[n]||(pa[n]?pa[n].forEach(r):(t.push(n),a[n]=!0))}var t=[],a={};throw e.forEach(r),new Fb(n+\": \"+t.map(Na).join([\", \"]))}function Gb(n){return b.___errno_location&&(p[b.___errno_location()>>2]=n),n}function Sa(){return Function(\"return this\")()}function Q(n,e){m.f=e;try{var r=m.get(),t=m.get(),a=m.get(),i=0;Q.buffer||(Q.a=[null,[],[]],Q.i=function(n,e){var r=Q.a[n];z(r),0===e||10===e?((1===n?b.print:b.printErr)(bb(r,0)),r.length=0):r.push(e)});for(var o=0;o<a;o++){for(var l=p[t+8*o>>2],c=p[t+(8*o+4)>>2],s=0;s<c;s++)Q.i(r,u[l+s]);i+=c}return i}catch(n){return\"undefined\"!=typeof FS&&n instanceof FS.n||B(n),-n.s}}function Z(n){this.name=\"ExitStatus\",this.message=\"Program terminated with exit(\"+n+\")\",this.status=n}function Ta(n){function e(){if(!b.calledRun&&(b.calledRun=!0,!wa)){if(xa||(xa=!0,W(Ua)),W(cc),b.onRuntimeInitialized&&b.onRuntimeInitialized(),b._main&&Hb&&b.callMain(n),b.postRun)for(\"function\"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var e=b.postRun.shift();Ib.unshift(e)}W(Ib)}}if(n=n||b.arguments,null===Jb&&(Jb=Date.now()),!(0<T)){if(b.preRun)for(\"function\"==typeof b.preRun&&(b.preRun=[b.preRun]);b.preRun.length;)$b(b.preRun.shift());W(hb),0<T||b.calledRun||(b.setStatus?(b.setStatus(\"Running...\"),setTimeout(function(){setTimeout(function(){b.setStatus(\"\")},1),e()},1)):e())}}function Kb(n,e){e&&b.noExitRuntime||(!b.noExitRuntime&&(wa=!0,H=dc,W(Lb),b.onExit)&&b.onExit(n),aa&&process.exit(n),b.quit(n,new Z(n)))}function B(n){b.onAbort&&b.onAbort(n),void 0!==n?(b.print(n),b.m(n),n=JSON.stringify(n)):n=\"\",wa=!0;var e=\"abort(\"+n+\") at \"+Yb()+\"\\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.\";throw Mb&&Mb.forEach(function(r){e=r(e,n)}),e}b||(b=eval(\"(function() { try { return Module || {} } catch(e) { return {} } })()\"));var ia={},R;for(R in b)b.hasOwnProperty(R)&&(ia[R]=b[R]);var ja=!1,V=!1,aa=!1,ya=!1;if(b.ENVIRONMENT)if(\"WEB\"===b.ENVIRONMENT)ja=!0;else if(\"WORKER\"===b.ENVIRONMENT)V=!0;else if(\"NODE\"===b.ENVIRONMENT)aa=!0;else{if(\"SHELL\"!==b.ENVIRONMENT)throw Error(\"The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.\");ya=!0}else ja=\"object\"==typeof window,V=\"function\"==typeof importScripts,aa=\"object\"==typeof process&&!0&&!ja&&!V,ya=!ja&&!aa&&!V;if(aa){b.print||(b.print=console.log),b.printErr||(b.printErr=console.warn);var Va,Wa;b.read=function(n,e){Va||(Va=__webpack_require__(345)),Wa||(Wa=__webpack_require__(346)),n=Wa.normalize(n);var r=Va.readFileSync(n);return e?r:r.toString()},b.readBinary=function(n){return n=b.read(n,!0),n.buffer||(n=new Uint8Array(n)),z(n.buffer),n},b.load=function(n){ab(read(n))},b.thisProgram||(b.thisProgram=1<process.argv.length?process.argv[1].replace(/\\\\/g,\"/\"):\"unknown-program\"),b.arguments=process.argv.slice(2),void 0!==module&&(module.exports=b),process.on(\"uncaughtException\",function(n){if(!(n instanceof Z))throw n}),b.inspect=function(){return\"[Emscripten Module object]\"}}else if(ya)b.print||(b.print=print),\"undefined\"!=typeof printErr&&(b.printErr=printErr),b.read=\"undefined\"!=typeof read?read:function(){throw\"no read() available\"},b.readBinary=function(n){return\"function\"==typeof readbuffer?new Uint8Array(readbuffer(n)):(n=read(n,\"binary\"),z(\"object\"==typeof n),n)},\"undefined\"!=typeof scriptArgs?b.arguments=scriptArgs:void 0!==arguments&&(b.arguments=arguments),\"function\"==typeof quit&&(b.quit=function(n){quit(n)}),eval(\"if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined\");else{if(!ja&&!V)throw\"Unknown runtime environment. Where are we?\";b.read=function(n){var e=new XMLHttpRequest;return e.open(\"GET\",n,!1),e.send(null),e.responseText},V&&(b.readBinary=function(n){var e=new XMLHttpRequest;return e.open(\"GET\",n,!1),e.responseType=\"arraybuffer\",e.send(null),new Uint8Array(e.response)}),b.readAsync=function(n,e,r){var t=new XMLHttpRequest;t.open(\"GET\",n,!0),t.responseType=\"arraybuffer\",t.onload=function(){200==t.status||0==t.status&&t.response?e(t.response):r()},t.onerror=r,t.send(null)},void 0!==arguments&&(b.arguments=arguments),\"undefined\"!=typeof console?(b.print||(b.print=function(n){console.log(n)}),b.printErr||(b.printErr=function(n){console.warn(n)})):b.print||(b.print=function(){}),V&&(b.load=importScripts),void 0===b.setWindowTitle&&(b.setWindowTitle=function(n){document.title=n})}!b.load&&b.read&&(b.load=function(n){ab(b.read(n))}),b.print||(b.print=function(){}),b.printErr||(b.printErr=b.print),b.arguments||(b.arguments=[]),b.thisProgram||(b.thisProgram=\"./this.program\"),b.quit||(b.quit=function(n,e){throw e}),b.print=b.print,b.m=b.printErr,b.preRun=[],b.postRun=[];for(R in ia)ia.hasOwnProperty(R)&&(b[R]=ia[R]);var ia=void 0,h={g:function(n){return tempRet0=n},P:function(){return tempRet0},W:function(){return H},V:function(n){H=n},B:function(n){switch(n){case\"i1\":case\"i8\":return 1;case\"i16\":return 2;case\"i32\":return 4;case\"i64\":return 8;case\"float\":return 4;case\"double\":return 8;default:return\"*\"===n[n.length-1]?h.p:\"i\"===n[0]?(n=parseInt(n.substr(1)),z(0==n%8),n/8):0}},N:function(n){return Math.max(h.B(n),h.p)},X:16,ya:function(n,e){return\"double\"===e||\"i64\"===e?7&n&&(z(4==(7&n)),n+=4):z(0==(3&n)),n},ka:function(n,e,r){return r||\"i64\"!=n&&\"double\"!=n?n?Math.min(e||(n?h.N(n):0),h.p):Math.min(e,8):8},r:function(n,e,r){return r&&r.length?b[\"dynCall_\"+n].apply(null,[e].concat(r)):b[\"dynCall_\"+n].call(null,e)},k:[],G:function(n){for(var e=0;e<h.k.length;e++)if(!h.k[e])return h.k[e]=n,2*(1+e);throw\"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.\"},U:function(n){h.k[(n-2)/2]=null},h:function(n){h.h.a||(h.h.a={}),h.h.a[n]||(h.h.a[n]=1,b.m(n))},u:{},ma:function(n,e){z(e),h.u[e]||(h.u[e]={});var r=h.u[e];return r[n]||(r[n]=1===e.length?function(){return h.r(e,n)}:2===e.length?function(r){return h.r(e,n,[r])}:function(){return h.r(e,n,Array.prototype.slice.call(arguments))}),r[n]},la:function(){throw\"You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work\"},D:function(n){var e=H;return H=H+n|0,H=H+15&-16,e},F:function(n){var e=D;return D=D+n|0,D=D+15&-16,e},M:function(n){var e=p[M>>2];return n=-16&(e+n+15|0),p[M>>2]=n,n>=t&&!fb()?(p[M>>2]=e,0):e},w:function(n,e){return Math.ceil(n/(e||16))*(e||16)},ua:function(n,e,r){return r?+(n>>>0)+4294967296*+(e>>>0):+(n>>>0)+4294967296*+(0|e)},o:1024,p:4,Y:0};h.addFunction=h.G,h.removeFunction=h.U;var wa=0,cb=\"undefined\"!=typeof TextDecoder?new TextDecoder(\"utf8\"):void 0;b.UTF8ToString=function(n){return bb(u,n)},\"undefined\"!=typeof TextDecoder&&new TextDecoder(\"utf-16le\");var Ia=65536,gb=16777216,Zb=16777216,v,r,u,S,ma,p,J,ba,ca,za,D,Xa,H,Aa,Ya,M;za=D=Xa=H=Aa=Ya=M=0,b.reallocBuffer||(b.reallocBuffer=function(n){var e;try{if(ArrayBuffer.a)e=ArrayBuffer.a(v,n);else{var t=r;e=new ArrayBuffer(n),new Int8Array(e).set(t)}}catch(n){return!1}return!!ec(e)&&e});var Ba;try{(Ba=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,\"byteLength\").get))(new ArrayBuffer(4))}catch(n){Ba=function(n){return n.byteLength}}var Za=b.TOTAL_STACK||5242880,t=b.TOTAL_MEMORY||16777216;if(t<Za&&b.m(\"TOTAL_MEMORY should be larger than TOTAL_STACK, was \"+t+\"! (TOTAL_STACK=\"+Za+\")\"),b.buffer?v=b.buffer:\"object\"==typeof WebAssembly&&\"function\"==typeof WebAssembly.Memory?(b.wasmMemory=new WebAssembly.Memory({initial:t/Ia}),v=b.wasmMemory.buffer):v=new ArrayBuffer(t),Ha(),p[0]=1668509029,S[1]=25459,115!==u[2]||99!==u[3])throw\"Runtime error: expected the system to be little-endian!\";b.HEAP=void 0,b.buffer=v,b.HEAP8=r,b.HEAP16=S,b.HEAP32=p,b.HEAPU8=u,b.HEAPU16=ma,b.HEAPU32=J,b.HEAPF32=ba,b.HEAPF64=ca;var hb=[],Ua=[],cc=[],Lb=[],Ib=[],xa=!1;if(Math.imul&&-5===Math.imul(4294967295,5)||(Math.imul=function(n,e){var r=65535&n,t=65535&e;return r*t+((n>>>16)*t+r*(e>>>16)<<16)|0}),Math.ra=Math.imul,!Math.fround){var Nb=new Float32Array(1);Math.fround=function(n){return Nb[0]=n,Nb[0]}}Math.ia=Math.fround,Math.clz32||(Math.clz32=function(n){n>>>=0;for(var e=0;32>e;e++)if(n&1<<31-e)return e;return 32}),Math.da=Math.clz32,Math.trunc||(Math.trunc=function(n){return 0>n?Math.ceil(n):Math.floor(n)}),Math.trunc=Math.trunc;var Tb=Math.abs,Wb=Math.ceil,Vb=Math.floor,Ub=Math.min,T=0,Ka=null,da=null;b.preloadedImages={},b.preloadedAudios={};var I=null;!function(a){function c(n){n=Ga(n,a.usingWasm?Ia:gb);var e=a.buffer,r=e.byteLength;if(!a.usingWasm)return u.__growWasmMemory((n-r)/65536),a.buffer!==e?a.buffer:null;try{return-1!==a.wasmMemory.grow((n-r)/65536)?a.buffer=a.wasmMemory.buffer:null}catch(n){return null}}function e(n,e){var r=m;if(0>n.indexOf(\".\"))r=(r||{})[n];else var t=n.split(\".\"),r=(r||{})[t[0]],r=(r||{})[t[1]];return e&&(r=(r||{})[e]),void 0===r&&B(\"bad lookupImport to (\"+n+\").\"+e),r}function d(n){var e=a.buffer;n.byteLength<e.byteLength&&a.printErr(\"the new buffer in mergeMemory is smaller than the previous one. in native wasm, we should grow memory here\");var e=new Int8Array(e),r=new Int8Array(n);I||e.set(r.subarray(a.STATIC_BASE,a.STATIC_BASE+a.STATIC_BUMP),a.STATIC_BASE),r.set(e),b.buffer=v=n,Ha()}function f(){try{var n;if(a.wasmBinary)n=a.wasmBinary,n=new Uint8Array(n);else{if(!a.readBinary)throw\"on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)\";n=a.readBinary(q)}return n}catch(n){B(n)}}function g(){return a.wasmBinary||\"function\"!=typeof fetch?new Promise(function(n){n(f())}):fetch(q,{ea:\"same-origin\"}).then(function(n){if(!n.ok)throw\"failed to load wasm binary file at '\"+q+\"'\";return n.arrayBuffer()})}function k(b,c,d){return\"function\"==typeof a.asm&&a.asm!==r||(a.asmPreload?a.asm=a.asmPreload:eval(a.read(p))),\"function\"!=typeof a.asm?(a.printErr(\"asm evalling did not set the module properly\"),!1):a.asm(b,c,d)}function l(n,e){function r(n){u=n.exports,u.memory&&d(u.memory),a.asm=u,a.usingWasm=!0,jb()}if(\"object\"!=typeof WebAssembly)return a.printErr(\"no native wasm support detected\"),!1;if(!(a.wasmMemory instanceof WebAssembly.Memory))return a.printErr(\"no native wasm Memory in use\"),!1;if(e.memory=a.wasmMemory,m.global={NaN:NaN,Infinity:1/0},m[\"global.Math\"]=n.Math,m.env=e,ib(),a.instantiateWasm)try{return a.instantiateWasm(m,r)}catch(n){return a.printErr(\"Module.instantiateWasm callback failed with error: \"+n),!1}return g().then(function(n){return WebAssembly.instantiate(n,m)}).then(function(n){r(n.instance)}).catch(function(n){a.printErr(\"failed to asynchronously prepare wasm: \"+n),B(n)}),{}}var n=a.wasmJSMethod||\"native-wasm\";a.wasmJSMethod=n;var h=a.wasmTextFile||\"app.wast\",q=a.wasmBinaryFile||\"app.wasm\",p=a.asmjsCodeFile||\"app.asm.js\";\"function\"==typeof a.locateFile&&(h=a.locateFile(h),q=a.locateFile(q),p=a.locateFile(p));var m={global:null,env:null,asm2wasm:{\"f64-rem\":function(n,e){return n%e},\"f64-to-int\":function(n){return 0|n},\"i32s-div\":function(n,e){return(0|n)/(0|e)|0},\"i32u-div\":function(n,e){return(n>>>0)/(e>>>0)>>>0},\"i32s-rem\":function(n,e){return(0|n)%(0|e)|0},\"i32u-rem\":function(n,e){return(n>>>0)%(e>>>0)>>>0},debugger:function(){}},parent:a},u=null;a.asmPreload=a.asm;var t=a.reallocBuffer;a.reallocBuffer=function(n){return\"asmjs\"===x?t(n):c(n)};var x=\"\";a.asm=function(r,t,i){if(!t.table){var o=a.wasmTableSize;void 0===o&&(o=1024);var c=a.wasmMaxTableSize;t.table=\"object\"==typeof WebAssembly&&\"function\"==typeof WebAssembly.Table?void 0!==c?new WebAssembly.Table({initial:o,maximum:c,element:\"anyfunc\"}):new WebAssembly.Table({initial:o,element:\"anyfunc\"}):Array(o),a.wasmTable=t.table}t.memoryBase||(t.memoryBase=a.STATIC_BASE),t.tableBase||(t.tableBase=0);for(var s,o=n.split(\",\"),c=0;c<o.length;c++){var b=o[c];if(x=b,\"native-wasm\"===b){if(s=l(r,t))break}else if(\"asmjs\"===b){if(s=k(r,t,i))break}else if(\"interpret-asm2wasm\"===b||\"interpret-s-expr\"===b||\"interpret-binary\"===b){var _=r,y=t,v=i;if(\"function\"!=typeof WasmJS)a.printErr(\"WasmJS not detected - polyfill not bundled?\"),b=!1;else{if(s=WasmJS({}),s.outside=a,s.info=m,s.lookupImport=e,z(v===a.buffer),m.global=_,m.env=y,z(v===a.buffer),y.memory=v,z(y.memory instanceof ArrayBuffer),s.providedTotalMemory=a.buffer.byteLength,_=void 0,_=\"interpret-binary\"===b?f():a.read(\"interpret-asm2wasm\"==b?p:h),y=void 0,\"interpret-asm2wasm\"==b)y=s._malloc(_.length+1),s.writeAsciiToMemory(_,y),s._load_asm2wasm(y);else if(\"interpret-s-expr\"===b)y=s._malloc(_.length+1),s.writeAsciiToMemory(_,y),s._load_s_expr2wasm(y);else{if(\"interpret-binary\"!==b)throw\"what? \"+b;y=s._malloc(_.length),s.HEAPU8.set(_,y),s._load_binary2wasm(y,_.length)}s._free(y),s._instantiate(y),a.newBuffer&&(d(a.newBuffer),a.newBuffer=null),b=u=s.asmExports}if(s=b)break}else B(\"bad method: \"+b)}if(!s)throw\"no binaryen method succeeded. consider enabling more options, like interpreting, if you want that: https://github.com/kripken/emscripten/wiki/WebAssembly#binaryen-methods\";return s};var r=a.asm}(b);var Ca=[function(n,e){window.asmDomHelpers.domApi.removeAttribute(n,b.UTF8ToString(e))},function(n,e,r){window.asmDomHelpers.domApi.setAttribute(n,b.UTF8ToString(e),b.UTF8ToString(r))},function(n){window.asmDomHelpers.nodes[n].asmDomRaws=[]},function(n,e){window.asmDomHelpers.nodes[n][b.UTF8ToString(e)]=void 0},function(n,e,r){r=b.UTF8ToString(r),window.asmDomHelpers.nodes[e][r]=window.asmDomHelpers.functionCallback(n,r),window.asmDomHelpers.nodes[e].asmDomRaws.push(r)},function(n){return window.asmDomHelpers.domApi.createTextNode(b.UTF8ToString(n))},function(n){return window.asmDomHelpers.domApi.createComment(b.UTF8ToString(n))},function(n,e){return window.asmDomHelpers.domApi.createElementNS(b.UTF8ToString(n),b.UTF8ToString(e))},function(n){return window.asmDomHelpers.domApi.createElement(b.UTF8ToString(n))},function(n,e){window.asmDomHelpers.domApi.appendChild(n,e)},function(n,e){window.asmDomHelpers.domApi.appendChild(n,window.asmDomHelpers.domApi.createTextNode(b.UTF8ToString(e)))},function(n,e,r){window.asmDomHelpers.domApi.insertBefore(n,e,window.asmDomHelpers.domApi.nextSibling(r))},function(n,e,r){window.asmDomHelpers.domApi.insertBefore(n,e,r)},function(n,e,r){window.asmDomHelpers.domApi.insertBefore(n,e,r)},function(n){window.asmDomHelpers.domApi.removeChild(n)},function(n){window.asmDomHelpers.domApi.setTextContent(n,\"\")},function(n,e){window.asmDomHelpers.domApi.setTextContent(n,b.UTF8ToString(e))},function(n,e){var r=window.asmDomHelpers.domApi.parentNode(e);0!==r&&(window.asmDomHelpers.domApi.insertBefore(r,n,window.asmDomHelpers.domApi.nextSibling(e)),window.asmDomHelpers.domApi.removeChild(e))},function(){window.onhashchange=function(){window.todomvc.onhashchange(window.location.hash.substr(2)||\"all\")}},function(){window.asmDomHelpers.functionCallback=function(n,e){return function(r){return b.functionCallback(n,e,r)}}},function(){window.todomvc={onhashchange:b.onhashchange}}];za=h.o,D=za+17936,Ua.push({t:function(){fc()}},{t:function(){gc()}},{t:function(){hc()}}),I=0<=b.wasmJSMethod.indexOf(\"asmjs\")||0<=b.wasmJSMethod.indexOf(\"interpret-asm2wasm\")?\"app.js.mem\":null,b.STATIC_BASE=za,b.STATIC_BUMP=17936;var ic=D;D+=16,b._i64Subtract=jc,b._i64Add=kc;var lb=void 0,X={},U={},pa={},mb=void 0,nb=void 0,qa=[],x={l:0,j:[],b:{},L:function(n){if(!n||x.b[n])return n;for(var e in x.b)if(x.b[e].v===n)return e;return n},H:function(n){n&&x.b[n].d++},fa:function(n){if(n){var e=x.b[n];z(0<e.d),e.d--,0!==e.d||e.C||(e.A&&b.dynCall_vi(e.A,n),delete x.b[n],___cxa_free_exception(n))}},ba:function(n){n&&(x.b[n].d=0)}};b._memset=lc;var bc={},Pa=[],C=[{},{value:void 0},{value:null},{value:!0},{value:!1}];b._bitshift64Shl=mc;var Da={},$a=1,m={f:0,get:function(){return m.f+=4,p[m.f-4>>2]},oa:function(){return Fa(m.get())},ja:function(){var n=m.get(),e=m.get();return z(0<=n?0===e:-1===e),n},qa:function(){z(0===m.get())}};b._bitshift64Lshr=nc;var xb=D;D+=16;var L={},Fb=void 0;b._memcpy=oc;var ka=O([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],\"i8\",2);b.___udivmoddi4=pc,b.___udivdi3=qc,b._sbrk=rc,b._memmove=sc,b.___uremdi3=tc,b._llvm_bswap_i32=uc,kb(),mb=b.BindingError=oa(Error,\"BindingError\"),nb=b.InternalError=oa(Error,\"InternalError\"),tb(),va(L),Fb=b.UnboundTypeError=oa(Error,\"UnboundTypeError\"),Lb.push(function(){var n=b._fflush;if(n&&n(0),n=Q.i){var e=Q.a;e[1].length&&n(1,10),e[2].length&&n(2,10)}}),M=O(1,\"i32\",2),Xa=H=h.w(D),Aa=Xa+Za,Ya=h.w(Aa),p[M>>2]=Ya,b.wasmTableSize=318,b.wasmMaxTableSize=318,b.J={Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:NaN,Infinity:1/0,byteLength:Ba},b.K={abort:B,assert:z,enlargeMemory:fb,getTotalMemory:function(){return t},abortOnCannotGrowMemory:function(){B(\"Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value \"+t+\", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 \")},invoke_iiii:function(n,e,r,t){try{return b.dynCall_iiii(n,e,r,t)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_viiiii:function(n,e,r,t,a,i){try{b.dynCall_viiiii(n,e,r,t,a,i)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_vi:function(n,e){try{b.dynCall_vi(n,e)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_vii:function(n,e,r){try{b.dynCall_vii(n,e,r)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_ii:function(n,e){try{return b.dynCall_ii(n,e)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_viii:function(n,e,r,t){try{b.dynCall_viii(n,e,r,t)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_v:function(n){try{b.dynCall_v(n)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_iiiiiiiii:function(n,e,r,t,a,i,o,u,l){try{return b.dynCall_iiiiiiiii(n,e,r,t,a,i,o,u,l)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_iiiii:function(n,e,r,t,a){try{return b.dynCall_iiiii(n,e,r,t,a)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_viiiiii:function(n,e,r,t,a,i,o){try{b.dynCall_viiiiii(n,e,r,t,a,i,o)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_iii:function(n,e,r){try{return b.dynCall_iii(n,e,r)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_iiiiii:function(n,e,r,t,a,i){try{return b.dynCall_iiiiii(n,e,r,t,a,i)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},invoke_viiii:function(n,e,r,t,a){try{b.dynCall_viiii(n,e,r,t,a)}catch(n){if(\"number\"!=typeof n&&\"longjmp\"!==n)throw n;b.setThrew(1,0)}},_pthread_getspecific:function(n){return Da[n]||0},___lock:function(){},floatReadValueFromPointer:wb,simpleReadValueFromPointer:ua,__emval_call_void_method:function(n,e,r,t){n=qa[n],e=G(e),r=fa(r),n(e,r,null,t)},___resumeException:function(n){throw x.l||(x.l=n),n},_pthread_key_create:function(n){return 0==n?22:(p[n>>2]=$a,Da[$a]=0,$a++,0)},__embind_register_memory_view:function(n,e,r){function t(n){n>>=2;var e=J;return new a(e.buffer,e[n+1],e[n])}var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];r=F(r),K(n,{name:r,fromWireType:t,argPackAdvance:8,readValueFromPointer:t},{R:!0})},throwInternalError:Ma,get_first_emval:sb,_abort:function(){b.abort()},__emval_addMethodCaller:pb,requireHandle:G,___gxx_personality_v0:function(){},___unlock:function(){},extendError:oa,init_emval:tb,___cxa_allocate_exception:function(n){return P(n)},__ZSt18uncaught_exceptionv:Y,___buildEnvironment:va,_emscripten_asm_const_ii:function(n,e){return Ca[n](e)},getShiftFromSize:ta,__emval_get_property:function(n,e){return n=G(n),e=G(e),N(n[e])},___syscall91:function(n,e){m.f=e;try{var r=m.get(),t=m.get(),a=m.T[r];if(!a)return 0;if(t===a.sa){var i=FS.pa(a.fd);m.ga(r,i,t,a.flags),FS.wa(i),m.T[r]=null,a.Z&&E(a.va)}return 0}catch(n){return\"undefined\"!=typeof FS&&n instanceof FS.n||B(n),-n.s}},__emval_as:function(n,e,r){n=G(n),e=ra(e,\"emval::as\");var t=[],a=N(t);return p[r>>2]=a,e.toWireType(t,n)},_llvm_cttz_i32:function(n){n|=0;var e=0,e=0|r[ka+(255&n)>>0];return 8>(0|e)?0|e:8>(0|(e=0|r[ka+(n>>8&255)>>0]))?e+8|0:(e=0|r[ka+(n>>16&255)>>0],8>(0|e)?e+16|0:24+(0|r[ka+(n>>>24)>>0])|0)},___setErrNo:Gb,__emval_register:N,__embind_register_void:function(n,e){e=F(e),K(n,{S:!0,name:e,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},_emscripten_memcpy_big:function(n,e,r){return u.set(u.subarray(e,e+r),n),n},__embind_register_bool:function(n,e,t,a,i){var o=ta(t);e=F(e),K(n,{name:e,fromWireType:function(n){return!!n},toWireType:function(n,e){return e?a:i},argPackAdvance:8,readValueFromPointer:function(n){var a;if(1===t)a=r;else if(2===t)a=S;else{if(4!==t)throw new TypeError(\"Unknown boolean type size: \"+e);a=p}return this.fromWireType(a[n>>o])},e:null})},_emscripten_asm_const_v:function(n){return Ca[n]()},___cxa_find_matching_catch:ea,__emval_incref:function(n){4<n&&(C[n].d+=1)},_embind_repr:sa,__embind_register_std_wstring:function(n,e,r){r=F(r);var t,a;2===e?(t=function(){return ma},a=1):4===e&&(t=function(){return J},a=2),K(n,{name:r,fromWireType:function(n){for(var e=t(),r=J[n>>2],i=Array(r),o=n+4>>a,u=0;u<r;++u)i[u]=String.fromCharCode(e[o+u]);return E(n),i.join(\"\")},toWireType:function(n,r){var i=t(),o=r.length,u=P(4+o*e);J[u>>2]=o;for(var l=u+4>>a,c=0;c<o;++c)i[l+c]=r.charCodeAt(c);return null!==n&&n.push(E,u),u},argPackAdvance:8,readValueFromPointer:ua,e:function(n){E(n)}})},__emval_get_global:function(n){return 0===n?N(Sa()):(n=fa(n),N(Sa()[n]))},createNamedFunction:La,___cxa_throw:function(n,e,r){throw x.b[n]={za:n,v:n,type:e,A:r,d:0,j:!1,C:!1},x.l=n,\"uncaught_exception\"in Y?Y.a++:Y.a=1,n},embind_init_charCodes:kb,__emval_take_value:function(n,e){return n=ra(n,\"_emval_take_value\"),N(n.readValueFromPointer(e))},readLatin1String:F,getStringOrSymbol:fa,throwUnboundTypeError:Eb,craftInvokerFunction:yb,__embind_register_integer:function(n,e,r,t,a){function i(n){return n}e=F(e),-1===a&&(a=4294967295);var o=ta(r);if(0===t)var u=32-8*r,i=function(n){return n<<u>>>u};var l=-1!=e.indexOf(\"unsigned\");K(n,{name:e,fromWireType:i,toWireType:function(n,r){if(\"number\"!=typeof r&&\"boolean\"!=typeof r)throw new TypeError('Cannot convert \"'+sa(r)+'\" to '+this.name);if(r<t||r>a)throw new TypeError('Passing a number \"'+sa(r)+'\" from JS side to C/C++ side to an argument of type \"'+e+'\", which is outside the valid range ['+t+\", \"+a+\"]!\");return l?r>>>0:0|r},argPackAdvance:8,readValueFromPointer:vb(e,o,0!==t),e:null})},_pthread_once:ga,__emval_decref:Qa,_getenv:ha,exposePublicSymbol:Ab,runDestructors:Ra,requireRegisteredType:ra,makeLegalFunctionName:na,___map_file:function(){return Gb(1),-1},integerReadValueFromPointer:vb,__emval_set_property:function(n,e,r){n=G(n),e=G(e),r=G(r),n[e]=r},heap32VectorToArray:Bb,__emval_lookupTypes:qb,whenDependentTypesAreResolved:ob,_emscripten_asm_const_iii:function(n,e,r){return Ca[n](e,r)},__emval_call_method:function(n,e,r,t,a){return n=qa[n],e=G(e),r=fa(r),n(e,r,ub(t),a)},__emval_run_destructors:function(n){Ra(C[n].value),Qa(n)},emval_get_global:Sa,_emscripten_asm_const_iiii:function(n,e,r,t){return Ca[n](e,r,t)},registerType:K,__emval_allocateDestructors:ub,__emval_strictly_equals:function(n,e){return n=G(n),e=G(e),n===e},__embind_register_function:function(n,e,r,t,a,i){var o=Bb(e,r);n=F(n),a=Db(t,a),Ab(n,function(){Eb(\"Cannot call \"+n+\" due to unbound types\",o)},e-1),ob([],o,function(r){return r=[r[0],null].concat(r.slice(1)),Cb(n,yb(n,r,null,a,i),e-1),[]})},__emval_new_cstring:function(n){return N(fa(n))},___syscall6:function(n,e){m.f=e;try{var r=m.O();return FS.close(r),0}catch(n){return\"undefined\"!=typeof FS&&n instanceof FS.n||B(n),-n.s}},throwBindingError:y,ensureOverloadTable:zb,__embind_register_emval:function(n,e){e=F(e),K(n,{name:e,fromWireType:function(n){var e=C[n].value;return Qa(n),e},toWireType:function(n,e){return N(e)},argPackAdvance:8,readValueFromPointer:ua,e:null})},___cxa_begin_catch:function(n){var e=x.b[n];return e&&!e.j&&(e.j=!0,Y.a--),e&&(e.C=!1),x.j.push(n),x.H(x.L(n)),n},requireFunction:Db,__embind_register_float:function(n,e,r){r=ta(r),e=F(e),K(n,{name:e,fromWireType:function(n){return n},toWireType:function(n,e){if(\"number\"!=typeof e&&\"boolean\"!=typeof e)throw new TypeError('Cannot convert \"'+sa(e)+'\" to '+this.name);return e},argPackAdvance:8,readValueFromPointer:wb(e,r),e:null})},new_:Oa,___syscall140:function(n,e){m.f=e;try{var r=m.O();m.get();var t=m.get(),a=m.get(),i=m.get();return FS.ta(r,t,i),p[a>>2]=r.position,r.Q&&0===t&&0===i&&(r.Q=null),0}catch(n){return\"undefined\"!=typeof FS&&n instanceof FS.n||B(n),-n.s}},getTypeName:Na,_pthread_setspecific:function(n,e){return n in Da?(Da[n]=e,0):22},__embind_register_std_string:function(n,e){e=F(e),K(n,{name:e,fromWireType:function(n){for(var e=J[n>>2],r=Array(e),t=0;t<e;++t)r[t]=String.fromCharCode(u[n+4+t]);return E(n),r.join(\"\")},toWireType:function(n,e){function r(n,e){return n[e]}function t(n,e){return n.charCodeAt(e)}e instanceof ArrayBuffer&&(e=new Uint8Array(e));var a;e instanceof Uint8Array?a=r:e instanceof Uint8ClampedArray?a=r:e instanceof Int8Array?a=r:\"string\"==typeof e?a=t:y(\"Cannot pass non-string to std::string\");var i=e.length,o=P(4+i);J[o>>2]=i;for(var l=0;l<i;++l){var c=a(e,l);255<c&&(E(o),y(\"String has UTF-16 code units that do not fit in 8 bits\")),u[o+4+l]=c}return null!==n&&n.push(E,o),o},argPackAdvance:8,readValueFromPointer:ua,e:function(n){E(n)}})},replacePublicSymbol:Cb,count_emval_handles:rb,___syscall146:Q,__emval_get_method_caller:function(n,e){for(var r=qb(n,e),t=r[0],a=t.name+\"_$\"+r.slice(1).map(function(n){return n.name}).join(\"_\")+\"$\",i=[\"retType\"],o=[t],u=\"\",l=0;l<n-1;++l)u+=(0!==l?\", \":\"\")+\"arg\"+l,i.push(\"argType\"+l),o.push(r[1+l]);for(var a=\"return function \"+na(\"methodCaller_\"+a)+\"(handle, name, destructors, args) {\\n\",c=0,l=0;l<n-1;++l)a+=\" var arg\"+l+\" = argType\"+l+\".readValueFromPointer(args\"+(c?\"+\"+c:\"\")+\");\\n\",c+=r[l+1].argPackAdvance;for(a+=\" var rv = handle[name](\"+u+\");\\n\",l=0;l<n-1;++l)r[l+1].deleteObject&&(a+=\" argType\"+l+\".deleteObject(arg\"+l+\");\\n\");return t.S||(a+=\" return retType.toWireType(destructors, rv);\\n\"),i.push(a+\"};\\n\"),r=Oa(Function,i).apply(null,o),pb(r)},DYNAMICTOP_PTR:M,tempDoublePtr:ic,ABORT:wa,STACKTOP:H,STACK_MAX:Aa,cttz_i8:ka};var Ob=b.asm(b.J,b.K,v);b.asm=Ob,b._main=function(){return b.asm._main.apply(null,arguments)},b.stackSave=function(){return b.asm.stackSave.apply(null,arguments)},b.getTempRet0=function(){return b.asm.getTempRet0.apply(null,arguments)};var qc=b.___udivdi3=function(){return b.asm.___udivdi3.apply(null,arguments)};b.setThrew=function(){return b.asm.setThrew.apply(null,arguments)};var nc=b._bitshift64Lshr=function(){return b.asm._bitshift64Lshr.apply(null,arguments)},mc=b._bitshift64Shl=function(){return b.asm._bitshift64Shl.apply(null,arguments)};b.___cxa_is_pointer_type=function(){return b.asm.___cxa_is_pointer_type.apply(null,arguments)};var lc=b._memset=function(){return b.asm._memset.apply(null,arguments)},rc=b._sbrk=function(){return b.asm._sbrk.apply(null,arguments)},oc=b._memcpy=function(){return b.asm._memcpy.apply(null,arguments)};b.stackAlloc=function(){return b.asm.stackAlloc.apply(null,arguments)};var tc=b.___uremdi3=function(){return b.asm.___uremdi3.apply(null,arguments)},fc=b.__GLOBAL__sub_I_asm_dom_cpp=function(){return b.asm.__GLOBAL__sub_I_asm_dom_cpp.apply(null,arguments)},jc=b._i64Subtract=function(){return b.asm._i64Subtract.apply(null,arguments)},hc=b.__GLOBAL__sub_I_bind_cpp=function(){return b.asm.__GLOBAL__sub_I_bind_cpp.apply(null,arguments)},pc=b.___udivmoddi4=function(){return b.asm.___udivmoddi4.apply(null,arguments)};b.setTempRet0=function(){return b.asm.setTempRet0.apply(null,arguments)};var kc=b._i64Add=function(){return b.asm._i64Add.apply(null,arguments)};b._emscripten_get_global_libc=function(){return b.asm._emscripten_get_global_libc.apply(null,arguments)};var ac=b.___getTypeName=function(){return b.asm.___getTypeName.apply(null,arguments)},gc=b.__GLOBAL__sub_I_index_cpp=function(){return b.asm.__GLOBAL__sub_I_index_cpp.apply(null,arguments)},uc=b._llvm_bswap_i32=function(){return b.asm._llvm_bswap_i32.apply(null,arguments)};b.___cxa_can_catch=function(){return b.asm.___cxa_can_catch.apply(null,arguments)};var E=b._free=function(){return b.asm._free.apply(null,arguments)};b.runPostSets=function(){return b.asm.runPostSets.apply(null,arguments)},b.establishStackSpace=function(){return b.asm.establishStackSpace.apply(null,arguments)};var sc=b._memmove=function(){return b.asm._memmove.apply(null,arguments)};b.stackRestore=function(){return b.asm.stackRestore.apply(null,arguments)};var P=b._malloc=function(){return b.asm._malloc.apply(null,arguments)},ec=b._emscripten_replace_memory=function(){return b.asm._emscripten_replace_memory.apply(null,arguments)};if(b.dynCall_iiii=function(){return b.asm.dynCall_iiii.apply(null,arguments)},b.dynCall_viiiii=function(){return b.asm.dynCall_viiiii.apply(null,arguments)},b.dynCall_vi=function(){return b.asm.dynCall_vi.apply(null,arguments)},b.dynCall_vii=function(){return b.asm.dynCall_vii.apply(null,arguments)},b.dynCall_ii=function(){return b.asm.dynCall_ii.apply(null,arguments)},b.dynCall_viii=function(){return b.asm.dynCall_viii.apply(null,arguments)},b.dynCall_v=function(){return b.asm.dynCall_v.apply(null,arguments)},b.dynCall_iiiiiiiii=function(){return b.asm.dynCall_iiiiiiiii.apply(null,arguments)},b.dynCall_iiiii=function(){return b.asm.dynCall_iiiii.apply(null,arguments)},b.dynCall_viiiiii=function(){return b.asm.dynCall_viiiiii.apply(null,arguments)},b.dynCall_iii=function(){return b.asm.dynCall_iii.apply(null,arguments)},b.dynCall_iiiiii=function(){return b.asm.dynCall_iiiiii.apply(null,arguments)},b.dynCall_viiii=function(){return b.asm.dynCall_viiii.apply(null,arguments)},h.D=b.stackAlloc,h.W=b.stackSave,h.V=b.stackRestore,h.ha=b.establishStackSpace,h.g=b.setTempRet0,h.P=b.getTempRet0,b.asm=Ob,I)if(\"function\"==typeof b.locateFile?I=b.locateFile(I):b.memoryInitializerPrefixURL&&(I=b.memoryInitializerPrefixURL+I),aa||ya){var vc=b.readBinary(I);u.set(vc,h.o)}else{var Qb=function(){b.readAsync(I,Pb,function(){throw\"could not load memory initializer \"+I})};ib();var Pb=function(n){n.byteLength&&(n=new Uint8Array(n)),u.set(n,h.o),b.memoryInitializerRequest&&delete b.memoryInitializerRequest.response,jb()};if(b.memoryInitializerRequest){var Rb=function(){var n=b.memoryInitializerRequest;200!==n.status&&0!==n.status?(console.warn(\"a problem seems to have happened with Module.memoryInitializerRequest, status: \"+n.status+\", retrying \"+I),Qb()):Pb(n.response)};b.memoryInitializerRequest.response?setTimeout(Rb,0):b.memoryInitializerRequest.addEventListener(\"load\",Rb)}else Qb()}Z.prototype=Error(),Z.prototype.constructor=Z;var dc,Jb=null,da=function n(){b.calledRun||Ta(),b.calledRun||(da=n)};b.callMain=b.aa=function(n){function e(){for(var n=0;3>n;n++)t.push(0)}n=n||[],xa||(xa=!0,W(Ua));var r=n.length+1,t=[O(Ja(b.thisProgram),\"i8\",0)];e();for(var a=0;a<r-1;a+=1)t.push(O(Ja(n[a]),\"i8\",0)),e();t.push(0),t=O(t,\"i32\",0);try{Kb(b._main(r,t,0),!0)}catch(e){e instanceof Z||(\"SimulateInfiniteLoop\"==e?b.noExitRuntime=!0:((n=e)&&\"object\"==typeof e&&e.stack&&(n=[e,e.stack]),b.m(\"exception thrown: \"+n),b.quit(1,e)))}},b.run=b.run=Ta,b.exit=b.exit=Kb;var Mb=[];if(b.abort=b.abort=B,b.preInit)for(\"function\"==typeof b.preInit&&(b.preInit=[b.preInit]);0<b.preInit.length;)b.preInit.pop()();var Hb=!0;return b.noInitialRun&&(Hb=!1),b.noExitRuntime=!0,Ta(),b}}module.exports=la()}).call(exports,__webpack_require__(344))},344:function(n,e){function r(){throw new Error(\"setTimeout has not been defined\")}function t(){throw new Error(\"clearTimeout has not been defined\")}function a(n){if(s===setTimeout)return setTimeout(n,0);if((s===r||!s)&&setTimeout)return s=setTimeout,setTimeout(n,0);try{return s(n,0)}catch(e){try{return s.call(null,n,0)}catch(e){return s.call(this,n,0)}}}function i(n){if(f===clearTimeout)return clearTimeout(n);if((f===t||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(n);try{return f(n)}catch(e){try{return f.call(null,n)}catch(e){return f.call(this,n)}}}function o(){d&&p&&(d=!1,p.length?m=p.concat(m):h=-1,m.length&&u())}function u(){if(!d){var n=a(o);d=!0;for(var e=m.length;e;){for(p=m,m=[];++h<e;)p&&p[h].run();h=-1,e=m.length}p=null,d=!1,i(n)}}function l(n,e){this.fun=n,this.array=e}function c(){}var s,f,b=n.exports={};!function(){try{s=\"function\"==typeof setTimeout?setTimeout:r}catch(n){s=r}try{f=\"function\"==typeof clearTimeout?clearTimeout:t}catch(n){f=t}}();var p,m=[],d=!1,h=-1;b.nextTick=function(n){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];m.push(new l(n,e)),1!==m.length||d||a(u)},l.prototype.run=function(){this.fun.apply(null,this.array)},b.title=\"browser\",b.browser=!0,b.env={},b.argv=[],b.version=\"\",b.versions={},b.on=c,b.addListener=c,b.once=c,b.off=c,b.removeListener=c,b.removeAllListeners=c,b.emit=c,b.prependListener=c,b.prependOnceListener=c,b.listeners=function(n){return[]},b.binding=function(n){throw new Error(\"process.binding is not supported\")},b.cwd=function(){return\"/\"},b.chdir=function(n){throw new Error(\"process.chdir is not supported\")},b.umask=function(){return 0}},345:function(n,e){},346:function(n,e,r){(function(n){function r(n,e){for(var r=0,t=n.length-1;t>=0;t--){var a=n[t];\".\"===a?n.splice(t,1):\"..\"===a?(n.splice(t,1),r++):r&&(n.splice(t,1),r--)}if(e)for(;r--;r)n.unshift(\"..\");return n}function t(n,e){if(n.filter)return n.filter(e);for(var r=[],t=0;t<n.length;t++)e(n[t],t,n)&&r.push(n[t]);return r}var a=/^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/,i=function(n){return a.exec(n).slice(1)};e.resolve=function(){for(var e=\"\",a=!1,i=arguments.length-1;i>=-1&&!a;i--){var o=i>=0?arguments[i]:n.cwd();if(\"string\"!=typeof o)throw new TypeError(\"Arguments to path.resolve must be strings\");o&&(e=o+\"/\"+e,a=\"/\"===o.charAt(0))}return e=r(t(e.split(\"/\"),function(n){return!!n}),!a).join(\"/\"),(a?\"/\":\"\")+e||\".\"},e.normalize=function(n){var a=e.isAbsolute(n),i=\"/\"===o(n,-1);return n=r(t(n.split(\"/\"),function(n){return!!n}),!a).join(\"/\"),n||a||(n=\".\"),n&&i&&(n+=\"/\"),(a?\"/\":\"\")+n},e.isAbsolute=function(n){return\"/\"===n.charAt(0)},e.join=function(){var n=Array.prototype.slice.call(arguments,0);return e.normalize(t(n,function(n,e){if(\"string\"!=typeof n)throw new TypeError(\"Arguments to path.join must be strings\");return n}).join(\"/\"))},e.relative=function(n,r){function t(n){for(var e=0;e<n.length&&\"\"===n[e];e++);for(var r=n.length-1;r>=0&&\"\"===n[r];r--);return e>r?[]:n.slice(e,r-e+1)}n=e.resolve(n).substr(1),r=e.resolve(r).substr(1);for(var a=t(n.split(\"/\")),i=t(r.split(\"/\")),o=Math.min(a.length,i.length),u=o,l=0;l<o;l++)if(a[l]!==i[l]){u=l;break}for(var c=[],l=u;l<a.length;l++)c.push(\"..\");return c=c.concat(i.slice(u)),c.join(\"/\")},e.sep=\"/\",e.delimiter=\":\",e.dirname=function(n){var e=i(n),r=e[0],t=e[1];return r||t?(t&&(t=t.substr(0,t.length-1)),r+t):\".\"},e.basename=function(n,e){var r=i(n)[2];return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},e.extname=function(n){return i(n)[3]};var o=\"b\"===\"ab\".substr(-1)?function(n,e,r){return n.substr(e,r)}:function(n,e,r){return e<0&&(e=n.length+e),n.substr(e,r)}}).call(e,r(344))}});", "file_path": "website/static/examples/todomvc/0.bundle.js", "rank": 73, "score": 19325.114512819146 }, { "content": "---\n\nid: h\n\ntitle: h\n\n---\n\n\n\nYou can create vnodes using `h` function. `h` accepts a tag/selector as a `std::string`, an optional `Data` struct and an optional `std::string` or a vector of children. Here is the list of signatures:\n\n\n\n```c++\n\nVNode* h(const std::string& sel);\n\nVNode* h(const std::string& sel, const std::string& text);\n\nVNode* h(const std::string& text, true); // used to create text nodes\n\nVNode* h(const std::string& sel, const Data& data);\n\nVNode* h(const std::string& sel, const Children& children);\n\nVNode* h(const std::string& sel, VNode* child);\n\nVNode* h(const std::string& sel, const Data& data, const std::string& text);\n\nVNode* h(const std::string& sel, const Data& data, const Children& children);\n\nVNode* h(const std::string& sel, const Data& data, VNode* child);\n\n```\n\n\n\nThe data object contains optional attributes, optional props and optional callbacks. Also, attributes can contain 2 special keys:\n\n- `ns`: the namespace URI to associate with the element\n\n- `key`: this property is used to keep pointers to DOM nodes that existed previously to avoid recreating them if it is unnecessary. This is very useful for things like list reordering.\n\n\n\nHere is an example, please use our `typedef` to do that:\n\n\n\n```c++\n\n// typedef std::function<bool(emscripten::val)> Callback;\n\n\n\n// typedef std::unordered_map<std::string, std::string> Attrs;\n\n// typedef std::unordered_map<std::string, emscripten::val> Props;\n\n// typedef std::unordered_map<std::string, Callback> Callbacks;\n\n\n\n// typedef std::vector<VNode*> Children;\n\n\n\nVNode* vnode = h(\"div\",\n\n Data(\n\n Attrs {{\"style\", \"color: #000\"}}\n\n ),\n\n Children {\n\n h(\"h1\", string(\"Headline\")),\n\n h(\"p\", string(\"A paragraph\")),\n\n }\n\n);\n\n\n\nVNode* vnode2 = h(\"div\",\n\n Data(\n\n Attrs {\n\n {\"id\", \"an-id\"}, // node.setAttribute('id', 'an-id')\n\n {\"key\", \"foo\"},\n\n {\"class\", \"foo\"}, // node.setAttribute('class', 'foo')\n\n {\"data-foo\", \"bar\"} // a dataset attribute\n\n },\n\n Props {\n\n {\"foo\", emscripten::val(7)} // node.foo = 7\n\n },\n\n Callbacks {\n\n // function pointer\n\n {\"ondblclick\", onDblClick},\n\n // lambda\n\n {\"onclick\", [](emscripten::val e) -> bool {\n\n // do stuff...\n\n return true;\n\n }}\n\n }\n\n )\n\n);\n", "file_path": "docs/h.md", "rank": 74, "score": 35.89491921196725 }, { "content": "#include \"VNode.hpp\"\n\n#ifndef ASMDOM_JS_SIDE\n\n\t#include <emscripten/val.h>\n\n\t#include <emscripten/bind.h>\n\n#endif\n\n#include <cstdint>\n\n#include <string>\n\n#include <unordered_map>\n\n\n\nnamespace asmdom {\n\n\n\n\tunsigned int currentHash = 0;\n\n\tstd::unordered_map<std::string, unsigned int> hashes;\n\n\n\n\tvoid VNode::normalize(const bool injectSvgNamespace) {\n\n\t\tif (!(hash & isNormalized)) {\n\n\t\t\tif (data.attrs.count(\"key\")) {\n\n\t\t\t\thash |= hasKey;\n\n\t\t\t\tkey = data.attrs[\"key\"];\n\n\t\t\t\tdata.attrs.erase(\"key\");\n", "file_path": "cpp/VNode/VNode.cpp", "rank": 75, "score": 34.8074000437537 }, { "content": "#include \"VNode.hpp\"\n\n#ifndef ASMDOM_JS_SIDE\n\n\t#include <emscripten/val.h>\n\n\t#include <emscripten/bind.h>\n\n#endif\n\n#include <cstdint>\n\n#include <string>\n\n#include <unordered_map>\n\n\n\nnamespace asmdom {\n\n\n\n\tunsigned int currentHash = 0;\n\n\tstd::unordered_map<std::string, unsigned int> hashes;\n\n\n\n\tvoid VNode::normalize(const bool injectSvgNamespace) {\n\n\t\tif (!(hash & isNormalized)) {\n\n\t\t\tif (data.attrs.count(\"key\")) {\n\n\t\t\t\thash |= hasKey;\n\n\t\t\t\tkey = data.attrs[\"key\"];\n\n\t\t\t\tdata.attrs.erase(\"key\");\n", "file_path": "src/cpp/VNode/VNode.cpp", "rank": 76, "score": 34.807400043753695 }, { "content": "### h\n\n\n\nYou can create vnodes using `h` function. `h` accepts a tag/selector as a `std::string`, an optional `Data` struct and an optional `std::string` or a vector of children. Here is the list of signatures:\n\n\n\n```c++\n\nVNode* h(const std::string& sel);\n\nVNode* h(const std::string& sel, const std::string& text);\n\nVNode* h(const std::string& text, true); // used to create text nodes\n\nVNode* h(const std::string& sel, const Data& data);\n\nVNode* h(const std::string& sel, const Children& children);\n\nVNode* h(const std::string& sel, VNode* child);\n\nVNode* h(const std::string& sel, const Data& data, const std::string& text);\n\nVNode* h(const std::string& sel, const Data& data, const Children& children);\n\nVNode* h(const std::string& sel, const Data& data, VNode* child);\n\n```\n\n\n\nThe data object contains optional attributes, optional props and optional callbacks. Also, attributes can contain 2 special keys:\n\n- `ns`: the namespace URI to associate with the element\n\n- `key`: this property is used to keep pointers to DOM nodes that existed previously to avoid recreating them if it is unnecessary. This is very useful for things like list reordering.\n\n\n\nAnd callbacks can contain a special key:\n\n- `ref`: a callback that provides a way to access DOM nodes, you can learn more about that [here](#ref)\n\n\n\nHere is an example, please use our `typedef` to do that:\n\n\n\n```c++\n\n// typedef std::function<bool(emscripten::val)> Callback;\n\n\n\n// typedef std::unordered_map<std::string, std::string> Attrs;\n\n// typedef std::unordered_map<std::string, emscripten::val> Props;\n\n// typedef std::unordered_map<std::string, Callback> Callbacks;\n\n\n\n// typedef std::vector<VNode*> Children;\n\n\n\nVNode* vnode = h(\"div\",\n\n Data(\n\n Attrs {{\"style\", \"color: #000\"}}\n\n ),\n\n Children {\n\n h(\"h1\", string(\"Headline\")),\n\n h(\"p\", string(\"A paragraph\")),\n\n }\n\n);\n\n\n\nVNode* vnode2 = h(\"div\",\n\n Data(\n\n Attrs {\n\n {\"id\", \"an-id\"}, // node.setAttribute('id', 'an-id')\n\n {\"key\", \"foo\"},\n\n {\"class\", \"foo\"}, // node.setAttribute('class', 'foo')\n\n {\"data-foo\", \"bar\"} // a dataset attribute\n\n },\n\n Props {\n\n {\"foo\", emscripten::val(7)} // node.foo = 7\n\n },\n\n Callbacks {\n\n // function pointer\n\n {\"ondblclick\", onDblClick},\n\n // lambda\n\n {\"onclick\", [](emscripten::val e) -> bool {\n\n // do stuff...\n\n return true;\n\n }},\n\n // ref\n\n {\"ref\", divRef}\n\n }\n\n )\n\n);\n\n```\n\n\n", "file_path": "docs/cpp.md", "rank": 77, "score": 34.41145824499168 }, { "content": "#ifndef asmdom_h_hpp\n\n#define asmdom_h_hpp\n\n\n\n#include \"../VNode/VNode.hpp\"\n\n#include <vector>\n\n#include <string>\n\n#include <map>\n\n\n\nnamespace asmdom {\n\n\n\n\tVNode* h(const std::string& sel);\n\n\tVNode* h(const std::string& sel, const std::string& text);\n\n\tVNode* h(const std::string& sel, const bool text);\n\n\tVNode* h(const std::string& sel, const Data& data);\n\n\tVNode* h(const std::string& sel, const Children& children);\n\n\tVNode* h(const std::string& sel, VNode* child);\n\n\tVNode* h(const std::string& sel, const Data& data, const std::string& text);\n\n\tVNode* h(const std::string& sel, const Data& data, const Children& children);\n\n\tVNode* h(const std::string& sel, const Data& data, VNode* child);\n\n\n\n}\n\n\n\n#endif\n", "file_path": "cpp/h/h.hpp", "rank": 78, "score": 32.741799154355604 }, { "content": "#ifndef asmdom_h_hpp\n\n#define asmdom_h_hpp\n\n\n\n#include \"../VNode/VNode.hpp\"\n\n#include <vector>\n\n#include <string>\n\n#include <map>\n\n\n\nnamespace asmdom {\n\n\n\n\tVNode* h(const std::string& sel);\n\n\tVNode* h(const std::string& sel, const std::string& text);\n\n\tVNode* h(const std::string& sel, const bool text);\n\n\tVNode* h(const std::string& sel, const Data& data);\n\n\tVNode* h(const std::string& sel, const Children& children);\n\n\tVNode* h(const std::string& sel, VNode* child);\n\n\tVNode* h(const std::string& sel, const Data& data, const std::string& text);\n\n\tVNode* h(const std::string& sel, const Data& data, const Children& children);\n\n\tVNode* h(const std::string& sel, const Data& data, VNode* child);\n\n\n\n}\n\n\n\n#endif\n", "file_path": "src/cpp/h/h.hpp", "rank": 79, "score": 32.7417991543556 }, { "content": "#include \"../../../src/cpp/asm-dom.hpp\"\n\n#include <string>\n\n#include <emscripten/val.h>\n\n\n\nusing namespace asmdom;\n\n\n\nint main() {\n\n\tConfig config;\n\n\tconfig.unsafePatch = true;\n\n\tinit(config);\n\n\n\n\tVNode* oldVnode = h(\"div\",\n\n\t\tData(\n\n\t\t\tAttrs {\n\n\t\t\t\t{\"id\", \"root\"}\n\n\t\t\t}\n\n\t\t),\n\n\t\tChildren {\n\n\t\t\th(\"Here is an \\\"Hello\\\" component that accepts a \\\"name\\\" attribute, and emit a \\\"change\\\" event, please open the console\", true),\n\n\t\t\th(\"br\"),\n", "file_path": "examples/webcomponents - cpp/src/app.cpp", "rank": 80, "score": 31.969219920296553 }, { "content": "# Table of Contents\n\n\n\n- [Inline Example](#inline-example)\n\n- [Installation](#installation)\n\n- [Examples](#examples)\n\n- [Documentation](#documentation)\n\n\t- [init](#init)\n\n\t- [h](#h)\n\n\t- [patch](#patch)\n\n\t- [toVNode](#tovnode)\n\n\t- [toHTML](#tohtml)\n\n - [deleteVNode](#deletevnode)\n\n- [Notes](#notes)\n\n\t- [memory management](#memory-management)\n\n\t- [boolean attributes](#boolean-attributes)\n\n\t- [string encoding](#string-encoding)\n\n - [ref](#ref)\n\n - [fragments](#fragments)\n\n- [Helpers](#helpers)\n\n - [svg](#svg)\n\n- [Server side rendering](#server-side-rendering)\n\n- [WebComponents](#webcomponents)\n\n - [Using WebComponents in asm-dom](#using-webcomponents-in-asm-dom)\n\n - [Using asm-dom in WebComponents](#using-asm-dom-in-webcomponents)\n\n- [Structuring applications](#structuring-applications)\n\n\n\n## Inline Example\n\n\n\n```c++\n\n#include \"asm-dom.hpp\"\n\n\n\nusing namespace asmdom;\n\n\n\nint main() {\n\n Config config = Config();\n\n init(config);\n\n\n\n VNode* vnode = h(\"div\",\n\n Data(\n\n Callbacks {\n\n {\"onclick\", [](emscripten::val e) -> bool {\n\n emscripten::val::global(\"console\").call<void>(\"log\", emscripten::val(\"clicked\"));\n\n return true;\n\n }}\n\n }\n\n ),\n\n Children {\n\n h(\"span\",\n\n Data(\n\n Attrs {\n\n {\"style\", \"font-weight: bold\"}\n\n }\n\n ),\n\n std::string(\"This is bold\")\n\n ),\n\n h(\" and this is just normal text\", true),\n\n h(\"a\",\n\n Data(\n\n Attrs {\n\n {\"href\", \"/foo\"}\n\n }\n\n ),\n\n std::string(\"I'll take you places!\")\n\n )\n\n }\n\n );\n\n\n\n // Patch into empty DOM element – this modifies the DOM as a side effect\n\n patch(\n\n emscripten::val::global(\"document\").call<emscripten::val>(\n\n \"getElementById\",\n\n std::string(\"root\")\n\n ),\n\n vnode\n", "file_path": "docs/cpp.md", "rank": 81, "score": 30.95161275510599 }, { "content": " void normalize() { normalize(false); };\n\n\n\n // contains selector for elements and fragments, text for comments and textNodes\n\n std::string sel;\n\n std::string key;\n\n std::string ns;\n\n unsigned int hash = 0;\n\n Data data;\n\n int elm = 0;\n\n std::vector<VNode*> children;\n\n };\n\n\n\n void deleteVNode(const VNode* const vnode);\n\n\n\n typedef std::vector<VNode*> Children;\n\n\n\n}\n\n\n\n#endif\n", "file_path": "src/cpp/VNode/VNode.hpp", "rank": 82, "score": 30.356355743028875 }, { "content": " void normalize() { normalize(false); };\n\n\n\n // contains selector for elements and fragments, text for comments and textNodes\n\n std::string sel;\n\n std::string key;\n\n std::string ns;\n\n unsigned int hash = 0;\n\n Data data;\n\n int elm = 0;\n\n std::vector<VNode*> children;\n\n };\n\n\n\n void deleteVNode(const VNode* const vnode);\n\n\n\n typedef std::vector<VNode*> Children;\n\n\n\n}\n\n\n\n#endif\n", "file_path": "cpp/VNode/VNode.hpp", "rank": 83, "score": 30.35635574302887 }, { "content": "#include \"diff.hpp\"\n\n#include \"../VNode/VNode.hpp\"\n\n#include <emscripten.h>\n\n#include <emscripten/val.h>\n\n#include <iterator>\n\n#include <cstdint>\n\n#include <map>\n\n\n\nnamespace asmdom {\n\n\n\n\tvoid diffAttrs(VNode* __restrict__ const oldVnode, VNode* __restrict__ const vnode) {\n\n\t\tAttrs& oldAttrs = oldVnode->data.attrs;\n\n\t\tAttrs& attrs = vnode->data.attrs;\n\n\n\n\t\tfor (const auto& it : oldAttrs) {\n\n\t\t\tif (!attrs.count(it.first)) {\n\n\t\t\t\tEM_ASM_({\n\n\t\t\t\t\tModule.removeAttribute(\n\n\t\t\t\t\t\t$0,\n\n\t\t\t\t\t\tModule['UTF8ToString']($1)\n", "file_path": "cpp/Diff/diff.cpp", "rank": 84, "score": 30.094523288767537 }, { "content": "#include \"diff.hpp\"\n\n#include \"../VNode/VNode.hpp\"\n\n#include <emscripten.h>\n\n#include <emscripten/val.h>\n\n#include <iterator>\n\n#include <cstdint>\n\n#include <map>\n\n\n\nnamespace asmdom {\n\n\n\n\tvoid diffAttrs(VNode* __restrict__ const oldVnode, VNode* __restrict__ const vnode) {\n\n\t\tAttrs& oldAttrs = oldVnode->data.attrs;\n\n\t\tAttrs& attrs = vnode->data.attrs;\n\n\n\n\t\tfor (const auto& it : oldAttrs) {\n\n\t\t\tif (!attrs.count(it.first)) {\n\n\t\t\t\tEM_ASM_({\n\n\t\t\t\t\tModule.removeAttribute(\n\n\t\t\t\t\t\t$0,\n\n\t\t\t\t\t\tModule['UTF8ToString']($1)\n", "file_path": "src/cpp/Diff/diff.cpp", "rank": 85, "score": 30.094523288767533 }, { "content": "---\n\nid: inline-example\n\ntitle: Inline example\n\n---\n\n\n\n```\n\n#include \"asm-dom.hpp\"\n\n\n\nusing namespace asmdom;\n\n\n\nint main() {\n\n Config config = Config();\n\n init(config);\n\n\n\n // asm-dom can be used with a JSX like syntax thanks to gccx\n\n VNode* vnode = (\n\n <div\n\n onclick={[](emscripten::val e) -> bool {\n\n emscripten::val::global(\"console\").call<void>(\"log\", emscripten::val(\"clicked\"));\n\n return true;\n\n }}\n\n >\n\n <span style=\"font-weight: bold\">This is bold</span>\n\n and this is just normal text\n\n <a href=\"/foo\">I'll take you places!</a>\n\n </div>\n\n );\n\n\n\n // Patch into empty DOM element – this modifies the DOM as a side effect\n\n patch(\n\n emscripten::val::global(\"document\").call<emscripten::val>(\n\n \"getElementById\",\n\n std::string(\"root\")\n\n ),\n\n vnode\n\n );\n\n\n\n // without gccx\n\n VNode* newVnode = h(\"div\",\n\n Data(\n\n Callbacks {\n\n {\"onclick\", [](emscripten::val e) -> bool {\n\n emscripten::val::global(\"console\").call<void>(\"log\", emscripten::val(\"another click\"));\n\n return true;\n\n }}\n\n }\n\n ),\n\n Children {\n\n h(\"span\",\n\n Data(\n\n Attrs {\n\n {\"style\", \"font-weight: normal; font-style: italic\"}\n\n }\n\n ),\n\n std::string(\"This is now italic type\")\n\n ),\n\n h(\" and this is just normal text\", true),\n\n h(\"a\",\n\n Data(\n\n Attrs {\n\n {\"href\", \"/bar\"}\n\n }\n\n ),\n\n std::string(\"I'll take you places!\")\n\n )\n\n }\n\n );\n\n\n\n // Second `patch` invocation\n\n patch(vnode, newVnode); // asm-dom efficiently updates the old view to the new state\n\n\n\n return 0;\n\n};\n\n```\n", "file_path": "docs/inline-example.md", "rank": 86, "score": 29.954219294694354 }, { "content": " );\n\n\n\n VNode* newVnode = h(\"div\",\n\n Data(\n\n Callbacks {\n\n {\"onclick\", [](emscripten::val e) -> bool {\n\n emscripten::val::global(\"console\").call<void>(\"log\", emscripten::val(\"another click\"));\n\n return true;\n\n }}\n\n }\n\n ),\n\n Children {\n\n h(\"span\",\n\n Data(\n\n Attrs {\n\n {\"style\", \"font-weight: normal; font-style: italic\"}\n\n }\n\n ),\n\n std::string(\"This is now italic type\")\n\n ),\n\n h(\" and this is just normal text\", true),\n\n h(\"a\",\n\n Data(\n\n Attrs {\n\n {\"href\", \"/bar\"}\n\n }\n\n ),\n\n std::string(\"I'll take you places!\")\n\n )\n\n }\n\n );\n\n\n\n // Second `patch` invocation\n\n patch(vnode, newVnode); // asm-dom efficiently updates the old view to the new state\n\n\n\n return 0;\n\n};\n\n```\n\n\n", "file_path": "docs/cpp.md", "rank": 87, "score": 29.612596759772053 }, { "content": "\t\t\t\tdata.attrs.insert(\n\n\t\t\t\t\tstd::make_pair(\n\n\t\t\t\t\t\tnode[\"attributes\"][i][\"nodeName\"].as<std::string>(),\n\n\t\t\t\t\t\tnode[\"attributes\"][i][\"nodeValue\"].as<std::string>()\n\n\t\t\t\t\t)\n\n\t\t\t\t);\n\n\t\t\t}\n\n\n\n\t\t\tChildren children;\n\n\t\t\ti = 0;\n\n\t\t\tfor(int n = node[\"childNodes\"][\"length\"].as<int>(); i < n; ++i) {\n\n\t\t\t\tchildren.push_back(toVNode(node[\"childNodes\"][i]));\n\n\t\t\t}\n\n\n\n\t\t\tvnode = h(sel, data, children);\n\n\t\t// isText\n\n\t\t} else if (nodeType == 3) {\n\n\t\t\tvnode = h(node[\"textContent\"].as<std::string>(), true);\n\n\t\t// isComment\n\n\t\t} else if (nodeType == 8) {\n", "file_path": "cpp/toVNode/toVNode.cpp", "rank": 88, "score": 28.945683094327393 }, { "content": "\t\t\t\tdata.attrs.insert(\n\n\t\t\t\t\tstd::make_pair(\n\n\t\t\t\t\t\tnode[\"attributes\"][i][\"nodeName\"].as<std::string>(),\n\n\t\t\t\t\t\tnode[\"attributes\"][i][\"nodeValue\"].as<std::string>()\n\n\t\t\t\t\t)\n\n\t\t\t\t);\n\n\t\t\t}\n\n\n\n\t\t\tChildren children;\n\n\t\t\ti = 0;\n\n\t\t\tfor(int n = node[\"childNodes\"][\"length\"].as<int>(); i < n; ++i) {\n\n\t\t\t\tchildren.push_back(toVNode(node[\"childNodes\"][i]));\n\n\t\t\t}\n\n\n\n\t\t\tvnode = h(sel, data, children);\n\n\t\t// isText\n\n\t\t} else if (nodeType == 3) {\n\n\t\t\tvnode = h(node[\"textContent\"].as<std::string>(), true);\n\n\t\t// isComment\n\n\t\t} else if (nodeType == 8) {\n", "file_path": "src/cpp/toVNode/toVNode.cpp", "rank": 89, "score": 28.945683094327393 }, { "content": "\t\t\t\t\t\t++it;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\n\n\t\t\t\tbool addNS = injectSvgNamespace || (sel[0] == 's' && sel[1] == 'v' && sel[2] == 'g');\n\n\t\t\t\tif (addNS) {\n\n\t\t\t\t\thash |= hasNS;\n\n\t\t\t\t\tns = \"http://www.w3.org/2000/svg\";\n\n\t\t\t\t}\n\n\n\n\t\t\t\tif (!data.attrs.empty()) hash |= hasAttrs;\n\n\t\t\t\t#ifndef ASMDOM_JS_SIDE\n\n\t\t\t\t\tif (!data.props.empty()) hash |= hasProps;\n\n\t\t\t\t\tif (!data.callbacks.empty()) hash |= hasCallbacks;\n\n\t\t\t\t#endif\n\n\t\t\t\tif (!children.empty()) {\n\n\t\t\t\t\thash |= hasDirectChildren;\n\n\n\n\t\t\t\t\tChildren::size_type i = children.size();\n\n\t\t\t\t\twhile (i--) {\n", "file_path": "src/cpp/VNode/VNode.cpp", "rank": 90, "score": 28.22300466671482 }, { "content": "\t\t\t\t\t\t++it;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\n\n\t\t\t\tbool addNS = injectSvgNamespace || (sel[0] == 's' && sel[1] == 'v' && sel[2] == 'g');\n\n\t\t\t\tif (addNS) {\n\n\t\t\t\t\thash |= hasNS;\n\n\t\t\t\t\tns = \"http://www.w3.org/2000/svg\";\n\n\t\t\t\t}\n\n\n\n\t\t\t\tif (!data.attrs.empty()) hash |= hasAttrs;\n\n\t\t\t\t#ifndef ASMDOM_JS_SIDE\n\n\t\t\t\t\tif (!data.props.empty()) hash |= hasProps;\n\n\t\t\t\t\tif (!data.callbacks.empty()) hash |= hasCallbacks;\n\n\t\t\t\t#endif\n\n\t\t\t\tif (!children.empty()) {\n\n\t\t\t\t\thash |= hasDirectChildren;\n\n\n\n\t\t\t\t\tChildren::size_type i = children.size();\n\n\t\t\t\t\twhile (i--) {\n", "file_path": "cpp/VNode/VNode.cpp", "rank": 91, "score": 28.22300466671482 }, { "content": "\t\t\tstd::string(\"root\")\n\n\t\t),\n\n\t\toldVnode\n\n\t);\n\n\n\n VNode* newVnode = h(\"div\",\n\n\t\tData(\n\n\t\t\tAttrs {\n\n\t\t\t\t{\"id\", \"root\"}\n\n\t\t\t}\n\n\t\t),\n\n\t\tChildren {\n\n\t\t\th(\"Here is an \\\"Hello\\\" component that accepts a \\\"name\\\" attribute, and emit a \\\"change\\\" event, please open the console\", true),\n\n\t\t\th(\"br\"),\n\n\t\t\th(\"br\"),\n\n\t\t\th(\"hello-component\",\n\n\t\t\t\tData(\n\n\t\t\t\t\tAttrs {\n\n\t\t\t\t\t\t{\"name\", \"asm-dom\"}\n\n\t\t\t\t\t},\n", "file_path": "examples/webcomponents - cpp/src/app.cpp", "rank": 92, "score": 27.63749474442623 }, { "content": "\t\t\t)\n\n\t\t)\n\n\t);\n\n\tpatch(getRoot(), vnode);\n\n\temscripten::val elm = getBodyFirstChild();\n\n\tassertEquals(elm[\"firstChild\"][\"namespaceURI\"], emscripten::val(svgNamespace));\n\n\tdeleteVNode(vnode);\n\n};\n\n\n\nvoid shouldInjectSvgNamespace() {\n\n\tstd::string svgNamespace = \"http://www.w3.org/2000/svg\";\n\n\tstd::string XHTMLNamespace = \"http://www.w3.org/1999/xhtml\";\n\n\tVNode* vnode = h(\"svg\",\n\n\t\tChildren {\n\n\t\t\th(\"foreignObject\",\n\n\t\t\t\tChildren {\n\n\t\t\t\t\th(\"div\",\n\n\t\t\t\t\t\tChildren {\n\n\t\t\t\t\t\t\th(\"I am HTML embedded in SVG\", true)\n\n\t\t\t\t\t\t}\n", "file_path": "test/cpp/patch/patch.cpp", "rank": 93, "score": 27.459388117126462 }, { "content": "\t\t\t{\"foo\", \"bar\"}\n\n\t\t}),\n\n\t\t\"I am a string\"\n\n\t);\n\n\tdeleteVNode(vnode);\n\n};\n\n\n\nvoid shouldCreateAVNodeWithAttrsAndChildren() {\n\n\tVNode* vnode = h(\"div\", \n\n\t\tData(Attrs {\n\n\t\t\t{\"foo\", \"bar\"}\n\n\t\t}),\n\n\t\tChildren {h(\"span\"), h(\"i\")}\n\n\t);\n\n\tdeleteVNode(vnode);\n\n};\n\n\n\nvoid shouldCreateAVNodeWithText() {\n\n\tVNode* vnode = h(\"this is a text\", true);\n\n\tdeleteVNode(vnode);\n", "file_path": "test/cpp/h/h.cpp", "rank": 94, "score": 27.06887725750645 }, { "content": " ): callbacks(dataCallbacks) {};\n\n #endif\n\n\n\n Attrs attrs;\n\n #ifndef ASMDOM_JS_SIDE\n\n Props props;\n\n Callbacks callbacks;\n\n #endif\n\n };\n\n\n\n struct VNode {\n\n private:\n\n void normalize(const bool injectSvgNamespace);\n\n public:\n\n VNode(\n\n const std::string& nodeSel\n\n ): sel(nodeSel) {};\n\n VNode(\n\n const std::string& nodeSel,\n\n const std::string& nodeText\n", "file_path": "src/cpp/VNode/VNode.hpp", "rank": 95, "score": 26.80231856613464 }, { "content": " ): callbacks(dataCallbacks) {};\n\n #endif\n\n\n\n Attrs attrs;\n\n #ifndef ASMDOM_JS_SIDE\n\n Props props;\n\n Callbacks callbacks;\n\n #endif\n\n };\n\n\n\n struct VNode {\n\n private:\n\n void normalize(const bool injectSvgNamespace);\n\n public:\n\n VNode(\n\n const std::string& nodeSel\n\n ): sel(nodeSel) {};\n\n VNode(\n\n const std::string& nodeSel,\n\n const std::string& nodeText\n", "file_path": "cpp/VNode/VNode.hpp", "rank": 96, "score": 26.802318566134637 }, { "content": "#include \"toVNode.hpp\"\n\n#include \"../VNode/VNode.hpp\"\n\n#include \"../h/h.hpp\"\n\n#include <emscripten/val.h>\n\n#include <algorithm>\n\n#include <string>\n\n\n\nnamespace asmdom {\n\n\n\n\tVNode* toVNode(const emscripten::val& node) {\n\n\t\tVNode* vnode;\n\n\t\tint nodeType = node[\"nodeType\"].as<int>();\n\n\t\t// isElement\n\n\t\tif (nodeType == 1) {\n\n\t\t\tstd::string sel = node[\"tagName\"].as<std::string>();\n\n\t\t\tstd::transform(sel.begin(), sel.end(), sel.begin(), ::tolower);\n\n\n\n\t\t\tData data;\n\n\t\t\tint i = node[\"attributes\"][\"length\"].as<int>();\n\n\t\t\twhile (i--) {\n", "file_path": "cpp/toVNode/toVNode.cpp", "rank": 97, "score": 26.619749987932067 }, { "content": "#include \"toVNode.hpp\"\n\n#include \"../VNode/VNode.hpp\"\n\n#include \"../h/h.hpp\"\n\n#include <emscripten/val.h>\n\n#include <algorithm>\n\n#include <string>\n\n\n\nnamespace asmdom {\n\n\n\n\tVNode* toVNode(const emscripten::val& node) {\n\n\t\tVNode* vnode;\n\n\t\tint nodeType = node[\"nodeType\"].as<int>();\n\n\t\t// isElement\n\n\t\tif (nodeType == 1) {\n\n\t\t\tstd::string sel = node[\"tagName\"].as<std::string>();\n\n\t\t\tstd::transform(sel.begin(), sel.end(), sel.begin(), ::tolower);\n\n\n\n\t\t\tData data;\n\n\t\t\tint i = node[\"attributes\"][\"length\"].as<int>();\n\n\t\t\twhile (i--) {\n", "file_path": "src/cpp/toVNode/toVNode.cpp", "rank": 98, "score": 26.619749987932064 }, { "content": "## Inline Example\n\n\n\n```jsx\n\n#include \"asm-dom.hpp\"\n\n\n\nusing namespace asmdom;\n\n\n\nint main() {\n\n Config config = Config();\n\n init(config);\n\n\n\n // asm-dom can be used with a JSX like syntax thanks to gccx\n\n VNode* vnode = (\n\n <div\n\n onclick={[](emscripten::val e) -> bool {\n\n emscripten::val::global(\"console\").call<void>(\"log\", emscripten::val(\"clicked\"));\n\n return true;\n\n }}\n\n >\n\n <span style=\"font-weight: bold\">This is bold</span>\n\n and this is just normal text\n\n <a href=\"/foo\">I'll take you places!</a>\n\n </div>\n\n );\n\n\n\n // Patch into empty DOM element – this modifies the DOM as a side effect\n\n patch(\n\n emscripten::val::global(\"document\").call<emscripten::val>(\n\n \"getElementById\",\n\n std::string(\"root\")\n\n ),\n\n vnode\n\n );\n\n\n\n // without gccx\n\n VNode* newVnode = h(\"div\",\n\n Data(\n\n Callbacks {\n\n {\"onclick\", [](emscripten::val e) -> bool {\n\n emscripten::val::global(\"console\").call<void>(\"log\", emscripten::val(\"another click\"));\n\n return true;\n\n }}\n\n }\n\n ),\n\n Children {\n\n h(\"span\",\n\n Data(\n\n Attrs {\n\n {\"style\", \"font-weight: normal; font-style: italic\"}\n\n }\n\n ),\n\n std::string(\"This is now italic type\")\n\n ),\n\n h(\" and this is just normal text\", true),\n\n h(\"a\",\n\n Data(\n\n Attrs {\n\n {\"href\", \"/bar\"}\n\n }\n\n ),\n\n std::string(\"I'll take you places!\")\n\n )\n\n }\n\n );\n\n\n\n // Second `patch` invocation\n\n patch(vnode, newVnode); // asm-dom efficiently updates the old view to the new state\n\n\n\n return 0;\n\n};\n\n```\n\n\n\n## Getting started\n\n\n\nasm-dom aims to be used from C++, however it can be used also from javascript, here you can find the doc of both:\n\n\n\n- [C++ docs](https://mbasso.github.io/asm-dom/docs/installation.html)\n\n- [JS docs](https://github.com/mbasso/asm-dom/blob/master/docs/js.md)\n\n\n", "file_path": "README.md", "rank": 99, "score": 26.598121220685346 } ]
C++
lite/kernels/cuda/lookup_table_compute_test.cc
jameswu2014/Paddle-Lite
827e349ac8eb769a873fe9b3aa961af8b8b20a96
#include "lite/kernels/cuda/lookup_table_compute.h" #include <gtest/gtest.h> #include <cmath> #include <memory> #include <string> #include <utility> #include <vector> #include "lite/core/op_registry.h" namespace paddle { namespace lite { namespace kernels { namespace cuda { using Tensor = lite::Tensor; void LookupTableComputeRef(const operators::LookupTableParam& param) { auto* ids_t = param.Ids; auto* output_t = param.Out; int64_t padding_idx = param.padding_idx; auto* ids = ids_t->data<int64_t>(); int64_t ids_numel = ids_t->dims().production(); auto* table_t = param.W; int64_t row_number = table_t->dims()[0]; int64_t row_width = table_t->dims()[1]; auto* table = table_t->data<float>(); auto* output = output_t->mutable_data<float>(); memset(output, 0, output_t->dims().production() * sizeof(float)); for (int64_t i = 0; i < ids_numel; ++i) { if (padding_idx != -1 && ids[i] == padding_idx) { memset(output + i * row_width, 0, row_width * sizeof(float)); } else { CHECK_LT(ids[i], row_number); CHECK_GE(ids[i], 0); memcpy(output + i * row_width, table + ids[i] * row_width, row_width * sizeof(float)); } } } TEST(lookup_table_cuda, retrieve_op) { auto lookup_table = KernelRegistry::Global().Create<TARGET(kCUDA), PRECISION(kFloat)>( "lookup_table"); ASSERT_FALSE(lookup_table.empty()); ASSERT_TRUE(lookup_table.front()); } TEST(lookup_table_cuda, init) { LookupTableCompute lookup_table; ASSERT_EQ(lookup_table.precision(), PRECISION(kFloat)); ASSERT_EQ(lookup_table.target(), TARGET(kCUDA)); } TEST(lookup_table_cuda, compute) { LookupTableCompute lookup_table; std::unique_ptr<KernelContext> ctx(new KernelContext); auto& context = ctx->As<CUDAContext>(); operators::LookupTableParam param; Tensor w, ids, out; Tensor w_cpu, ids_cpu, out_cpu; Tensor w_ref, ids_ref, out_ref; int64_t padding_idx = 0; int vocab_size = 128; int emb_size = 64; int ids_h = 50; int ids_w = 30; auto w_dim = DDim({vocab_size, emb_size}); auto ids_dim = DDim({ids_h, ids_w}); auto out_dim = DDim({ids_h, ids_w, emb_size}); int w_num = w_dim.production(); int ids_num = ids_dim.production(); int out_num = out_dim.production(); w.Resize(w_dim); ids.Resize(ids_dim); out.Resize(out_dim); w_cpu.Resize(w_dim); ids_cpu.Resize(ids_dim); out_cpu.Resize(out_dim); w_ref.Resize(w_dim); ids_ref.Resize(ids_dim); out_ref.Resize(out_dim); auto* out_data = out.mutable_data<float>(TARGET(kCUDA)); auto* w_cpu_data = w_cpu.mutable_data<float>(); auto* ids_cpu_data = ids_cpu.mutable_data<int64_t>(); auto* out_cpu_data = out_cpu.mutable_data<float>(); auto* w_ref_data = w_ref.mutable_data<float>(); auto* ids_ref_data = ids_ref.mutable_data<int64_t>(); auto* out_ref_data = out_ref.mutable_data<float>(); for (int i = 0; i < w_num; i++) { w_cpu_data[i] = static_cast<float>(i + 1) / (w_num + 1); w_ref_data[i] = static_cast<float>(i + 1) / (w_num + 1); } for (int i = 0; i < ids_num; i++) { ids_cpu_data[i] = i % vocab_size; ids_ref_data[i] = i % vocab_size; } w.Assign<float, lite::DDim, TARGET(kCUDA)>(w_cpu_data, w_dim); ids.Assign<int64_t, lite::DDim, TARGET(kCUDA)>(ids_cpu_data, ids_dim); param.W = &w; param.Ids = &ids; param.Out = &out; param.padding_idx = padding_idx; lookup_table.SetParam(param); cudaStream_t stream; cudaStreamCreate(&stream); context.SetExecStream(stream); lookup_table.SetContext(std::move(ctx)); lookup_table.Launch(); cudaDeviceSynchronize(); CopySync<TARGET(kCUDA)>( out_cpu_data, out_data, sizeof(float) * out.numel(), IoDirection::DtoH); param.W = &w_ref; param.Ids = &ids_ref; param.Out = &out_ref; LookupTableComputeRef(param); for (int i = 0; i < out_num; i++) { EXPECT_NEAR(out_cpu_data[i], out_ref_data[i], 1e-5); } } } } } } USE_LITE_KERNEL(lookup_table, kCUDA, kFloat, kNCHW, def);
#include "lite/kernels/cuda/lookup_table_compute.h" #include <gtest/gtest.h> #include <cmath> #include <memory> #include <string> #include <utility> #include <vector> #include "lite/core/op_registry.h" namespace paddle { namespace lite { namespace kernels { namespace cuda { using Tensor = lite::Tensor;
TEST(lookup_table_cuda, retrieve_op) { auto lookup_table = KernelRegistry::Global().Create<TARGET(kCUDA), PRECISION(kFloat)>( "lookup_table"); ASSERT_FALSE(lookup_table.empty()); ASSERT_TRUE(lookup_table.front()); } TEST(lookup_table_cuda, init) { LookupTableCompute lookup_table; ASSERT_EQ(lookup_table.precision(), PRECISION(kFloat)); ASSERT_EQ(lookup_table.target(), TARGET(kCUDA)); } TEST(lookup_table_cuda, compute) { LookupTableCompute lookup_table; std::unique_ptr<KernelContext> ctx(new KernelContext); auto& context = ctx->As<CUDAContext>(); operators::LookupTableParam param; Tensor w, ids, out; Tensor w_cpu, ids_cpu, out_cpu; Tensor w_ref, ids_ref, out_ref; int64_t padding_idx = 0; int vocab_size = 128; int emb_size = 64; int ids_h = 50; int ids_w = 30; auto w_dim = DDim({vocab_size, emb_size}); auto ids_dim = DDim({ids_h, ids_w}); auto out_dim = DDim({ids_h, ids_w, emb_size}); int w_num = w_dim.production(); int ids_num = ids_dim.production(); int out_num = out_dim.production(); w.Resize(w_dim); ids.Resize(ids_dim); out.Resize(out_dim); w_cpu.Resize(w_dim); ids_cpu.Resize(ids_dim); out_cpu.Resize(out_dim); w_ref.Resize(w_dim); ids_ref.Resize(ids_dim); out_ref.Resize(out_dim); auto* out_data = out.mutable_data<float>(TARGET(kCUDA)); auto* w_cpu_data = w_cpu.mutable_data<float>(); auto* ids_cpu_data = ids_cpu.mutable_data<int64_t>(); auto* out_cpu_data = out_cpu.mutable_data<float>(); auto* w_ref_data = w_ref.mutable_data<float>(); auto* ids_ref_data = ids_ref.mutable_data<int64_t>(); auto* out_ref_data = out_ref.mutable_data<float>(); for (int i = 0; i < w_num; i++) { w_cpu_data[i] = static_cast<float>(i + 1) / (w_num + 1); w_ref_data[i] = static_cast<float>(i + 1) / (w_num + 1); } for (int i = 0; i < ids_num; i++) { ids_cpu_data[i] = i % vocab_size; ids_ref_data[i] = i % vocab_size; } w.Assign<float, lite::DDim, TARGET(kCUDA)>(w_cpu_data, w_dim); ids.Assign<int64_t, lite::DDim, TARGET(kCUDA)>(ids_cpu_data, ids_dim); param.W = &w; param.Ids = &ids; param.Out = &out; param.padding_idx = padding_idx; lookup_table.SetParam(param); cudaStream_t stream; cudaStreamCreate(&stream); context.SetExecStream(stream); lookup_table.SetContext(std::move(ctx)); lookup_table.Launch(); cudaDeviceSynchronize(); CopySync<TARGET(kCUDA)>( out_cpu_data, out_data, sizeof(float) * out.numel(), IoDirection::DtoH); param.W = &w_ref; param.Ids = &ids_ref; param.Out = &out_ref; LookupTableComputeRef(param); for (int i = 0; i < out_num; i++) { EXPECT_NEAR(out_cpu_data[i], out_ref_data[i], 1e-5); } } } } } } USE_LITE_KERNEL(lookup_table, kCUDA, kFloat, kNCHW, def);
void LookupTableComputeRef(const operators::LookupTableParam& param) { auto* ids_t = param.Ids; auto* output_t = param.Out; int64_t padding_idx = param.padding_idx; auto* ids = ids_t->data<int64_t>(); int64_t ids_numel = ids_t->dims().production(); auto* table_t = param.W; int64_t row_number = table_t->dims()[0]; int64_t row_width = table_t->dims()[1]; auto* table = table_t->data<float>(); auto* output = output_t->mutable_data<float>(); memset(output, 0, output_t->dims().production() * sizeof(float)); for (int64_t i = 0; i < ids_numel; ++i) { if (padding_idx != -1 && ids[i] == padding_idx) { memset(output + i * row_width, 0, row_width * sizeof(float)); } else { CHECK_LT(ids[i], row_number); CHECK_GE(ids[i], 0); memcpy(output + i * row_width, table + ids[i] * row_width, row_width * sizeof(float)); } } }
function_block-full_function
[ { "content": "namespace paddle {\n\nnamespace lite {\n\n\n\ntemplate <typename Dtype>\n\nvoid fill_tensor_host_const_impl(Dtype* dio, Dtype value, int64_t size) {\n\n for (int64_t i = 0; i < size; ++i) {\n\n dio[i] = value;\n\n }\n\n}\n\n/**\n\n * \\brief Fill the host tensor buffer with rand value.\n\n * \\param tensor The reference of input tensor.\n\n */\n\nvoid fill_tensor_const(Tensor& tensor, float value) { // NOLINT\n\n int64_t size = tensor.numel();\n\n PrecisionType type = tensor.precision();\n\n switch (type) {\n\n case PRECISION(kInt8):\n\n fill_tensor_host_const_impl(\n\n tensor.mutable_data<int8_t>(), static_cast<signed char>(value), size);\n\n break;\n\n case PRECISION(kInt32):\n\n fill_tensor_host_const_impl(\n\n tensor.mutable_data<int>(), static_cast<int>(value), size);\n\n break;\n\n case PRECISION(kFloat):\n\n fill_tensor_host_const_impl(\n\n tensor.mutable_data<float>(), static_cast<float>(value), size);\n\n break;\n\n default:\n\n LOG(FATAL) << \"data type: \" << PrecisionRepr(type)\n\n << \" is unsupported now\";\n\n }\n\n}\n\n\n\ntemplate <typename Dtype>\n\nvoid fill_tensor_host_rand_impl(Dtype* dio, int64_t size) {\n\n for (int64_t i = 0; i < size; ++i) {\n\n Dtype rand_x = static_cast<Dtype>(rand() % 256); // NOLINT\n\n dio[i] = (rand_x - 128) / 128;\n\n }\n\n}\n\ntemplate <>\n\nvoid fill_tensor_host_rand_impl<signed char>(signed char* dio, int64_t size) {\n\n for (int64_t i = 0; i < size; ++i) {\n\n dio[i] = rand() % 256 - 128; // NOLINT\n\n }\n\n}\n\ntemplate <>\n\nvoid fill_tensor_host_rand_impl<unsigned char>(unsigned char* dio,\n\n int64_t size) {\n\n for (int64_t i = 0; i < size; ++i) {\n\n dio[i] = rand() % 256; // NOLINT\n\n }\n\n}\n\n/**\n\n * \\brief Fill the host tensor buffer with rand value.\n\n * \\param The reference of input tensor.\n\n */\n\nvoid fill_tensor_rand(Tensor& tensor) { // NOLINT\n\n int64_t size = tensor.numel();\n\n PrecisionType type = tensor.precision();\n\n switch (type) {\n\n case PRECISION(kInt8):\n\n fill_tensor_host_rand_impl(tensor.mutable_data<int8_t>(), size);\n\n break;\n\n case PRECISION(kInt32):\n\n fill_tensor_host_rand_impl(tensor.mutable_data<int>(), size);\n\n break;\n\n case PRECISION(kFloat):\n\n fill_tensor_host_rand_impl(tensor.mutable_data<float>(), size);\n\n break;\n\n default:\n\n LOG(FATAL) << \"data type: \" << PrecisionRepr(type)\n\n << \" is unsupported now\";\n\n }\n\n}\n\n\n\ntemplate <typename Dtype>\n\nvoid fill_tensor_host_rand_impl2(Dtype* dio,\n\n Dtype vstart,\n\n Dtype vend,\n\n int64_t size) {\n\n std::random_device rd;\n\n std::mt19937 gen(rd());\n\n std::uniform_real_distribution<float> dis(0, 1.f);\n\n for (int64_t i = 0; i < size; ++i) {\n\n Dtype random_num = static_cast<Dtype>(vstart + (vend - vstart) * dis(gen));\n\n dio[i] = random_num;\n\n }\n\n}\n\n\n\n/**\n\n * \\brief Fill the host tensor buffer with rand value from vstart to vend.\n\n * \\param tensor The reference of input tensor.\n\n */\n\nvoid fill_tensor_rand(Tensor& tensor, float vstart, float vend) { // NOLINT\n\n int64_t size = tensor.numel();\n\n PrecisionType type = tensor.precision();\n\n switch (type) {\n\n case PRECISION(kInt8):\n\n fill_tensor_host_rand_impl2(tensor.mutable_data<int8_t>(),\n\n static_cast<signed char>(vstart),\n\n static_cast<signed char>(vend),\n\n size);\n\n break;\n\n case PRECISION(kInt32):\n\n fill_tensor_host_rand_impl2(tensor.mutable_data<int>(),\n\n static_cast<int>(vstart),\n\n static_cast<int>(vend),\n\n size);\n\n break;\n\n case PRECISION(kFloat):\n\n fill_tensor_host_rand_impl2(\n\n tensor.mutable_data<float>(), vstart, vend, size);\n\n break;\n\n default:\n\n LOG(FATAL) << \"data type: \" << PrecisionRepr(type)\n\n << \" is unsupported now\";\n\n }\n\n}\n\n\n\ntemplate <typename Dtype>\n\nvoid print_tensor_host_impl(const Dtype* din, int64_t size, int64_t width);\n\n\n\ntemplate <>\n\nvoid print_tensor_host_impl(const float* din, int64_t size, int64_t width) {\n\n for (int i = 0; i < size; ++i) {\n\n printf(\"%.6f \", din[i]);\n\n if ((i + 1) % width == 0) {\n\n printf(\"\\n\");\n\n }\n\n }\n\n printf(\"\\n\");\n\n}\n\n\n\ntemplate <>\n\nvoid print_tensor_host_impl(const int* din, int64_t size, int64_t width) {\n\n for (int i = 0; i < size; ++i) {\n\n printf(\"%d \", din[i]);\n\n if ((i + 1) % width == 0) {\n\n printf(\"\\n\");\n\n }\n\n }\n\n printf(\"\\n\");\n\n}\n\n\n\ntemplate <>\n\nvoid print_tensor_host_impl(const signed char* din,\n\n int64_t size,\n\n int64_t width) {\n\n for (int i = 0; i < size; ++i) {\n\n printf(\"%d \", din[i]);\n\n if ((i + 1) % width == 0) {\n\n printf(\"\\n\");\n\n }\n\n }\n\n printf(\"\\n\");\n\n}\n\n/**\n\n * \\brief Print the data in host tensor.\n\n * \\param tensor The reference of input tensor.\n\n */\n\nvoid print_tensor(const Tensor& tensor) {\n\n printf(\"host tensor data size: %ld\\n\", tensor.numel());\n\n int64_t size = tensor.numel();\n\n int64_t width = tensor.dims()[tensor.dims().size() - 1];\n\n PrecisionType type = tensor.precision();\n\n switch (type) {\n\n case PRECISION(kInt8):\n\n print_tensor_host_impl(tensor.data<int8_t>(), size, width);\n\n break;\n\n case PRECISION(kInt32):\n\n print_tensor_host_impl(tensor.data<int>(), size, width);\n\n break;\n\n case PRECISION(kFloat):\n\n print_tensor_host_impl(tensor.data<float>(), size, width);\n\n break;\n\n default:\n\n LOG(FATAL) << \"data type: \" << PrecisionRepr(type)\n\n << \" is unsupported now\";\n\n }\n\n}\n\n\n\ntemplate <typename Dtype>\n\ndouble tensor_mean_value_host_impl(const Dtype* din, int64_t size) {\n\n double sum = 0.0;\n\n for (int64_t i = 0; i < size; ++i) {\n\n sum += din[i];\n\n }\n\n return sum / size;\n\n}\n\n\n\ndouble tensor_mean(const Tensor& tensor) {\n\n int64_t size = tensor.numel();\n\n PrecisionType type = tensor.precision();\n\n switch (type) {\n\n case PRECISION(kInt8):\n\n return tensor_mean_value_host_impl(tensor.data<int8_t>(), size);\n\n case PRECISION(kInt32):\n\n return tensor_mean_value_host_impl(tensor.data<int>(), size);\n\n case PRECISION(kFloat):\n\n return tensor_mean_value_host_impl(tensor.data<float>(), size);\n\n default:\n\n LOG(FATAL) << \"data type: \" << PrecisionRepr(type)\n\n << \" is unsupported now\";\n\n }\n\n return 0.0;\n\n}\n\n\n\ntemplate <typename dtype>\n\nvoid data_diff_kernel(const dtype* src1_truth,\n\n const dtype* src2,\n\n int size,\n\n double& max_ratio, // NOLINT\n\n double& max_diff) { // NOLINT\n\n const double eps = 1e-6f;\n\n max_diff = fabs(src1_truth[0] - src2[0]);\n\n max_ratio = fabs(max_diff) / (std::abs(src1_truth[0]) + eps);\n\n for (int i = 1; i < size; ++i) {\n\n double diff = fabs(src1_truth[i] - src2[i]);\n\n double ratio = fabs(diff) / (std::abs(src1_truth[i]) + eps);\n\n if (max_ratio < ratio) {\n\n max_diff = diff;\n\n max_ratio = ratio;\n\n }\n\n }\n\n}\n\n\n\nvoid tensor_cmp_host(const Tensor& src1_basic,\n\n const Tensor& src2,\n\n double& max_ratio, // NOLINT\n\n double& max_diff) { // NOLINT\n\n max_ratio = 0.;\n\n max_diff = 0.;\n\n int64_t size = src1_basic.numel();\n\n CHECK_EQ(size, src2.numel()) << \"ERROR: tensor_cmp_host: wrong shape\";\n\n auto ptype1 = PrecisionRepr(src1_basic.precision());\n\n auto ptype2 = PrecisionRepr(src2.precision());\n\n CHECK_EQ(ptype1, ptype2) << \"ERROR: tensor_cmp_host: wrong data type\";\n\n if (size == 0) return;\n\n switch (src1_basic.precision()) {\n\n case PRECISION(kFloat):\n\n data_diff_kernel(src1_basic.data<float>(),\n\n src2.data<float>(),\n\n size,\n\n max_ratio,\n\n max_diff);\n\n return;\n\n case PRECISION(kInt32):\n\n data_diff_kernel(\n\n src1_basic.data<int>(), src2.data<int>(), size, max_ratio, max_diff);\n\n return;\n\n case PRECISION(kInt8):\n\n data_diff_kernel(src1_basic.data<int8_t>(),\n\n src2.data<int8_t>(),\n\n size,\n\n max_ratio,\n\n max_diff);\n\n return;\n\n default:\n\n LOG(FATAL) << \"data type: \" << PrecisionRepr(src1_basic.precision())\n\n << \" is unsupported now\";\n\n }\n\n}\n\n\n\ntemplate <typename dtype>\n\nvoid tensor_diff_kernel(const dtype* src1,\n\n const dtype* src2,\n\n dtype* dst,\n\n int64_t size) {\n\n for (int i = 0; i < size; ++i) {\n\n dst[i] = src1[i] - src2[i];\n\n }\n\n}\n\nvoid tensor_diff(const Tensor& t1, const Tensor& t2, Tensor& tdiff) { // NOLINT\n\n int64_t size1 = t1.numel();\n\n int64_t size2 = t2.numel();\n\n int64_t size_out = tdiff.numel();\n\n CHECK_EQ(size1, size2) << \"ERROR: tensor_diff: wrong shape\";\n\n CHECK_EQ(size1, size_out) << \"ERROR: tensor_diff: wrong shape\";\n\n auto ptype1 = PrecisionRepr(t1.precision());\n\n auto ptype2 = PrecisionRepr(t2.precision());\n\n auto ptype3 = PrecisionRepr(tdiff.precision());\n\n CHECK_EQ(ptype1, ptype2) << \"ERROR: tensor_diff: wrong data type\";\n\n CHECK_EQ(ptype1, ptype3) << \"ERROR: tensor_diff: wrong data type\";\n\n switch (t1.precision()) {\n\n case PRECISION(kFloat):\n\n tensor_diff_kernel(t1.data<float>(),\n\n t2.data<float>(),\n\n tdiff.mutable_data<float>(),\n\n size1);\n\n return;\n\n case PRECISION(kInt32):\n\n tensor_diff_kernel(\n\n t1.data<int>(), t2.data<int>(), tdiff.mutable_data<int>(), size1);\n\n case PRECISION(kInt8):\n\n tensor_diff_kernel(t1.data<int8_t>(),\n\n t2.data<int8_t>(),\n\n tdiff.mutable_data<int8_t>(),\n\n size1);\n\n return;\n\n default:\n\n LOG(FATAL) << \"data type: \" << ptype1 << \" is unsupported now\";\n\n }\n\n}\n\n\n\n} // namespace lite\n", "file_path": "lite/tests/utils/tensor_utils.h", "rank": 0, "score": 255534.75451987787 }, { "content": "namespace paddle {\n\nnamespace lite {\n\nnamespace cuda {\n\n\n\nstatic const char* CublasErrorInfo(int error) {\n\n switch (error) {\n\n#define LITE_CUBLAS_ERROR_INFO(xx) \\\n\n case xx: \\\n\n return #xx; \\\n\n break;\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_NOT_INITIALIZED);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_ALLOC_FAILED);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_INVALID_VALUE);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_ARCH_MISMATCH);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_MAPPING_ERROR);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_EXECUTION_FAILED);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_INTERNAL_ERROR);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_NOT_SUPPORTED);\n\n LITE_CUBLAS_ERROR_INFO(CUBLAS_STATUS_LICENSE_ERROR);\n\n#undef LITE_CUBLAS_ERROR_INFO\n\n default:\n\n return \"unknown error\";\n\n }\n\n}\n\n\n\nstatic const char* CudnnGetErrorInfo(cudnnStatus_t status) {\n\n switch (status) {\n\n case CUDNN_STATUS_SUCCESS:\n\n return \"CUDNN_STATUS_SUCCESS\";\n\n case CUDNN_STATUS_NOT_INITIALIZED:\n\n return \"CUDNN_STATUS_NOT_INITIALIZED\";\n\n case CUDNN_STATUS_ALLOC_FAILED:\n\n return \"CUDNN_STATUS_ALLOC_FAILED\";\n\n case CUDNN_STATUS_BAD_PARAM:\n\n return \"CUDNN_STATUS_BAD_PARAM\";\n\n case CUDNN_STATUS_INTERNAL_ERROR:\n\n return \"CUDNN_STATUS_INTERNAL_ERROR\";\n\n case CUDNN_STATUS_INVALID_VALUE:\n\n return \"CUDNN_STATUS_INVALID_VALUE\";\n\n case CUDNN_STATUS_ARCH_MISMATCH:\n\n return \"CUDNN_STATUS_ARCH_MISMATCH\";\n\n case CUDNN_STATUS_MAPPING_ERROR:\n\n return \"CUDNN_STATUS_MAPPING_ERROR\";\n\n case CUDNN_STATUS_EXECUTION_FAILED:\n\n return \"CUDNN_STATUS_EXECUTION_FAILED\";\n\n case CUDNN_STATUS_NOT_SUPPORTED:\n\n return \"CUDNN_STATUS_NOT_SUPPORTED\";\n\n case CUDNN_STATUS_LICENSE_ERROR:\n\n return \"CUDNN_STATUS_LICENSE_ERROR\";\n\n#if CUDNN_VERSION_MIN(6, 0, 0)\n\n case CUDNN_STATUS_RUNTIME_PREREQUISITE_MISSING:\n\n return \"CUDNN_STATUS_RUNTIME_PREREQUISITE_MISSING\";\n\n#endif\n\n#if CUDNN_VERSION_MIN(7, 0, 0)\n\n case CUDNN_STATUS_RUNTIME_IN_PROGRESS:\n\n return \"CUDNN_STATUS_RUNTIME_IN_PROGRESS\";\n\n case CUDNN_STATUS_RUNTIME_FP_OVERFLOW:\n\n return \"CUDNN_STATUS_RUNTIME_FP_OVERFLOW\";\n\n#endif\n\n }\n\n return \"Unknown cudnn status\";\n\n}\n\n\n\n} // namespace cuda\n\n} // namespace lite\n", "file_path": "lite/backends/cuda/cuda_utils.h", "rank": 1, "score": 255512.6691959605 }, { "content": "def gen_use_kernel_statement(op_type, target, precision, layout, alias):\n\n return 'USE_LITE_KERNEL(%s, %s, %s, %s, %s);' %(\n\n op_type, target, precision, layout, alias\n", "file_path": "lite/tools/cmake_tools/utils.py", "rank": 2, "score": 252332.48424462817 }, { "content": "namespace paddle {\n\nnamespace lite {\n\n\n\nstatic std::string string_format(const std::string fmt_str, ...) {\n\n /* Reserve two times as much as the length of the fmt_str */\n\n int final_n, n = (static_cast<int>(fmt_str.size())) * 2;\n\n std::unique_ptr<char[]> formatted;\n\n va_list ap;\n\n while (1) {\n\n formatted.reset(\n\n new char[n]); /* Wrap the plain char array into the unique_ptr */\n\n std::strcpy(&formatted[0], fmt_str.c_str()); // NOLINT\n\n va_start(ap, fmt_str);\n\n final_n = vsnprintf(&formatted[0], n, fmt_str.c_str(), ap);\n\n va_end(ap);\n\n if (final_n < 0 || final_n >= n)\n\n n += abs(final_n - n + 1);\n\n else\n\n break;\n\n }\n\n return std::string(formatted.get());\n\n}\n\n\n\ntemplate <typename T>\n\nstatic std::string to_string_with_precision(const T& v, const int n = 6) {\n\n STL::stringstream ss;\n\n ss.precision(n);\n\n // ss << std::fixed << v;\n\n return ss.str();\n\n}\n\n\n\ntemplate <typename T>\n\nstd::string Join(const std::vector<T>& vec, const std::string& delim) {\n\n if (vec.empty()) return \"\";\n\n\n\n STL::stringstream ss;\n\n for (size_t i = 0; i < vec.size() - 1; i++) ss << vec[i] << delim;\n\n if (!vec.empty()) {\n\n ss << vec.back();\n\n }\n\n\n\n return ss.str();\n\n}\n\n\n\nstatic std::string Repr(const std::string& x) { return \"\\\"\" + x + \"\\\"\"; }\n\n\n\nstatic std::string Repr(const std::vector<std::string>& v) {\n\n std::vector<std::string> tmp;\n\n std::transform(\n\n v.begin(), v.end(), std::back_inserter(tmp), [](const std::string& x) {\n\n return Repr(x);\n\n });\n\n return \"{\" + Join(tmp, \",\") + \"}\";\n\n}\n\n\n\nstatic std::vector<std::string> Split(const std::string& original,\n\n const std::string& separator) {\n\n std::vector<std::string> results;\n\n std::string::size_type pos1, pos2;\n\n pos2 = original.find(separator);\n\n pos1 = 0;\n\n while (std::string::npos != pos2) {\n\n results.push_back(original.substr(pos1, pos2 - pos1));\n\n pos1 = pos2 + separator.size();\n\n pos2 = original.find(separator, pos1);\n\n }\n\n if (pos1 != original.length()) {\n\n results.push_back(original.substr(pos1));\n\n }\n\n return results;\n\n}\n\n\n", "file_path": "lite/utils/string.h", "rank": 3, "score": 250355.4525267517 }, { "content": " protected Tensor(long cppTensorPointer, boolean readOnly, PaddlePredictor predictor) {\n\n this.cppTensorPointer = cppTensorPointer;\n\n this.readOnly = readOnly;\n\n this.predictor = predictor;\n", "file_path": "lite/api/android/jni/src/com/baidu/paddle/lite/Tensor.java", "rank": 4, "score": 245973.8217904087 }, { "content": "namespace paddle {\n\nnamespace lite {\n\nnamespace cuda {\n\nnamespace math {\n\n\n\nenum class BinaryOperation {\n\n kADD = 0,\n\n kMUL = 1,\n\n kDIV = 2,\n\n};\n\n\n\ntemplate <typename T>\n\n__device__ T binary_calc(T x, T y, BinaryOperation type);\n\n\n\ntemplate <>\n\n__device__ __forceinline__ float binary_calc(float x,\n\n float y,\n\n BinaryOperation type) {\n\n if (type == BinaryOperation::kADD) return x + y;\n\n if (type == BinaryOperation::kMUL) return x * y;\n\n if (type == BinaryOperation::kDIV) return x / y;\n\n}\n\n\n\ntemplate <typename T>\n\n__device__ T from_float(float x);\n\n\n\ntemplate <>\n\n__device__ __forceinline__ float from_float<float>(float x) {\n\n return x;\n\n}\n\n\n\ntemplate <>\n\n__device__ __forceinline__ half from_float<half>(float x) {\n\n return __float2half(x);\n\n}\n\n\n\ntemplate <>\n\n__device__ __forceinline__ int8_t from_float<int8_t>(float x) {\n\n x = fmaxf(x, std::numeric_limits<char>::min());\n\n x = fminf(x, std::numeric_limits<char>::max());\n\n return __float2int_rn(x);\n\n}\n\n\n\n} // namespace math\n\n} // namespace cuda\n", "file_path": "lite/backends/cuda/math/utils.h", "rank": 5, "score": 239588.99824187157 }, { "content": "inline int CUDA_GET_BLOCKS(const int N) {\n\n return (N + CUDA_NUM_THREADS - 1) / CUDA_NUM_THREADS;\n", "file_path": "lite/backends/cuda/cuda_utils.h", "rank": 6, "score": 238210.9485606099 }, { "content": "const int CUDA_NUM_THREADS = 512;\n", "file_path": "lite/backends/cuda/cuda_utils.h", "rank": 7, "score": 238203.71388274716 }, { "content": "namespace paddle {\n\nnamespace lite {\n\nnamespace subgraph {\n\nnamespace npu {\n\n\n\n// Type/tensor converters for converting Paddle type/tensor to HiAI type/tensor\n\nbool HasInputArg(const OpInfo* op_info,\n\n const Scope* scope,\n\n const std::string& argname);\n\n\n\nge::DataType CvtPrecisionType(PrecisionType itype);\n\n\n\nge::Format CvtDataLayoutType(DataLayoutType itype);\n\n\n\n// Padding the shape to 4-dimensions(NCHW) for HiAI\n\nstd::vector<int64_t> CvtShape(const std::vector<int64_t>& in_shape);\n\n\n\nstd::vector<int64_t> CvtShape(const DDim& in_dims);\n\n\n\nge::TensorPtr CvtTensor(const Tensor& in_tensor,\n\n std::vector<int64_t> out_shape = {},\n\n DataLayoutType in_layout = DATALAYOUT(kNCHW));\n\n\n\nint CvtActMode(std::string act_type);\n\n\n\nbool CheckShape(DDim origin_dims, hiai::TensorDimension device_dims);\n\n\n\n} // namespace npu\n\n} // namespace subgraph\n\n} // namespace lite\n", "file_path": "lite/kernels/npu/bridges/utility.h", "rank": 8, "score": 237818.8146631684 }, { "content": "namespace paddle {\n\nnamespace lite {\n\nnamespace subgraph {\n\nnamespace bm {\n\n\n\nstd::string UniqueName(const std::string& prefix);\n\n\n\nbool HasInputArg(const OpInfo* op_info,\n\n const Scope* scope,\n\n const std::string& argname);\n\n\n\n} // namespace bm\n\n} // namespace subgraph\n\n} // namespace lite\n", "file_path": "lite/kernels/bm/bridges/utility.h", "rank": 9, "score": 237811.63305188392 }, { "content": "namespace paddle {\n\nnamespace lite {\n\nnamespace subgraph {\n\nnamespace xpu {\n\n\n\n// Type/tensor converters for converting Paddle type/tensor to XPU type/tensor\n\nbool HasInputArg(const OpInfo* op_info,\n\n const Scope* scope,\n\n const std::string& argname);\n\n\n\nxtcl::DataType CvtPrecisionType(PrecisionType in_type);\n\n\n\nDLDataType CvtDLDataType(PrecisionType in_type);\n\nDLDeviceType CvtDLDeviceType(TargetType in_type);\n\n\n\ntemplate <typename T>\n\nxtcl::Array<T> CvtShape(const std::vector<int>& in_shape) {\n\n xtcl::Array<T> out_shape;\n\n for (auto dim : in_shape) {\n\n out_shape.push_back(dim);\n\n }\n\n return out_shape;\n\n}\n\n\n\ntemplate <typename T>\n\nxtcl::Array<T> CvtShape(const std::vector<int64_t>& in_shape) {\n\n return CvtShape<T>(std::vector<int>(in_shape.begin(), in_shape.end()));\n\n}\n\n\n\ntemplate <typename T>\n\nxtcl::Array<T> CvtShape(const DDim& in_dims) {\n\n return CvtShape<T>(in_dims.Vectorize());\n\n}\n\n\n\nstd::shared_ptr<xtcl::xNDArray> CvtTensor(\n\n const Tensor& in_tensor,\n\n std::vector<int64_t> out_shape = {},\n\n DataLayoutType in_layout = DATALAYOUT(kNCHW));\n\n\n\n} // namespace xpu\n\n} // namespace subgraph\n", "file_path": "lite/kernels/xpu/bridges/utility.h", "rank": 10, "score": 237811.63305188392 }, { "content": "namespace paddle {\n\nnamespace lite {\n\nnamespace subgraph {\n\nnamespace mlu {\n\n\n\nvoid transpose(float* input_data,\n\n float* output_data,\n\n std::vector<int> input_shape,\n\n std::vector<int> axis);\n\nint scale2position(float scale);\n\nvoid dequant(float* dst, int8_t* src, size_t size, float scale);\n\n\n\nvoid dequant(float* dst,\n\n int8_t* src,\n\n size_t size_o,\n\n size_t size,\n\n size_t size_in,\n\n std::vector<float> scales);\n\n\n\ntemplate <typename T>\n\nstd::vector<T> recip(std::vector<T> x);\n\n// Type/tensor converters for converting Paddle type/tensor to MLU type/tensor\n\nbool HasInputArg(const OpInfo* op_info,\n\n const Scope* scope,\n\n const std::string& argname);\n\n\n\ncnmlActiveFunction_t OpTypeToCNMLActType(std::string op_type);\n\n\n\ninline const ::paddle::lite::DDimLite DimNHWC2NCHW(\n\n const ::paddle::lite::DDimLite& dim) {\n\n return ::paddle::lite::DDimLite(\n\n std::vector<int64_t>({dim[0], dim[3], dim[1], dim[2]}));\n\n}\n\n\n\ninline const ::paddle::lite::DDimLite DimNCHW2NHWC(\n\n const ::paddle::lite::DDimLite& dim) {\n\n return ::paddle::lite::DDimLite(\n\n std::vector<int64_t>({dim[0], dim[2], dim[3], dim[1]}));\n\n}\n\n\n\ninline const std::vector<int64_t> DimNHWC2NCHW(\n\n const std::vector<int64_t>& dim) {\n\n return std::vector<int64_t>({dim[0], dim[3], dim[1], dim[2]});\n\n}\n\n\n\ninline const std::vector<int64_t> DimNCHW2NHWC(\n\n const std::vector<int64_t>& dim) {\n\n return std::vector<int64_t>({dim[0], dim[2], dim[3], dim[1]});\n\n}\n\n\n\ntemplate <paddle::lite_api::PrecisionType>\n\nstruct FPTypeTraits {};\n\n\n\ntemplate <>\n\nstruct FPTypeTraits<paddle::lite_api::PrecisionType::kFloat> {\n\n typedef float T;\n\n};\n\n\n\ntemplate <>\n\nstruct FPTypeTraits<paddle::lite_api::PrecisionType::kFP16> {\n\n typedef ::paddle::lite::fluid::float16 T;\n\n};\n\n\n\n} // namespace mlu\n\n} // namespace subgraph\n\n} // namespace lite\n", "file_path": "lite/kernels/mlu/bridges/utility.h", "rank": 11, "score": 237811.63305188392 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include <memory>\n\n#include \"lite/backends/cuda/blas.h\"\n\n#include \"lite/backends/cuda/math/gemm.h\"\n\n#include \"lite/core/kernel.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace cuda {\n\n\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute.h", "rank": 12, "score": 227284.95803448363 }, { "content": "struct LITE_API Tensor {\n\n explicit Tensor(void* raw);\n\n explicit Tensor(const void* raw);\n\n\n\n void Resize(const shape_t& shape);\n\n\n\n /// Readonly data.\n\n template <typename T>\n\n const T* data() const;\n\n\n\n template <typename T>\n\n T* mutable_data(TargetType type = TargetType::kHost) const;\n\n\n\n template <typename T, TargetType type = TargetType::kHost>\n\n void CopyFromCpu(const T* data);\n\n\n\n template <typename T>\n\n void CopyToCpu(T* data) const;\n\n /// Shape of the tensor.\n\n shape_t shape() const;\n", "file_path": "lite/api/paddle_api.h", "rank": 13, "score": 225681.5354032466 }, { "content": "/// Zero Copy Tensor.\n\nclass Tensor {\n\n public:\n\n using ddim_t = std::vector<int64_t>;\n\n\n\n Tensor(const void *raw_tensor, void *raw_mutable_tensor)\n\n : raw_tensor_(raw_tensor), raw_mutable_tensor_(raw_mutable_tensor) {}\n\n\n\n void Resize(const ddim_t &shape);\n\n template <typename T>\n\n const T *data() const;\n\n template <typename T>\n\n T *mutable_data();\n\n\n\n ddim_t shape() const;\n\n\n\n private:\n\n const void *raw_tensor_;\n\n void *raw_mutable_tensor_{};\n\n};\n\n\n\n/*\n\n * Predictor for the generated code.\n\n */\n", "file_path": "lite/gen_code/paddle_infer.h", "rank": 14, "score": 222740.07193910875 }, { "content": "namespace ge {\n\n/*\n\n * Pads a tensor.\n\n * <Input>\n\n * x : the input tensor\n\n * padding : the input tensor must be 2-D\n\n * constant_values : constant values must be a scalar\n\n * <Output>\n\n * y : the output tensor\n\n * <Attr>\n\n * mode : 0: CONSTANT, 1: REFLECT, 2: SYMMETRIC, 3:EDGE.\n\n * <Added in HiAI version>\n\n * 100.320.010.010\n\n */\n\nREG_OP(Pad)\n\n .INPUT(x, TensorType({DT_FLOAT, DT_INT32}))\n\n .INPUT(padding, TensorType({DT_INT32}))\n\n .OPTIONAL_INPUT(constant_values, TensorType({DT_INT32, DT_FLOAT}))\n\n .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32}))\n\n .ATTR(mode, AttrValue::INT{0})\n\n .OP_END()\n\n\n\n /*\n\n * The operation pads input according to the paddings and constant_values.\n\n * <Input>\n\n * x : The input tensor.\n\n * paddings : The values of paddings, as a role of dimensions to be added\n\n * on the input tensor x, must be a Const-OP. constant_values : A tensor of\n\n * the same type as x, that indicates the value to use for padding input,\n\n * must be a Const-OP.\n\n * <Output>\n\n * y : The output tensor.\n\n * <Added in HiAI version>\n\n * 100.320.010.010\n\n */\n\n REG_OP(PadV2)\n\n .INPUT(x, TensorType({DT_FLOAT, DT_INT32}))\n\n .INPUT(paddings, TensorType({DT_INT32}))\n\n .INPUT(constant_values, TensorType({DT_FLOAT, DT_INT32}))\n\n .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32}))\n\n .OP_END()\n\n\n\n /*\n\n * Computes instance norm\n\n * <Input>\n\n * x : Input tensor which supports 4D dimension format.\n\n * scale : A tesnor, multiple to result\n\n * bias : A tensor, add to result\n\n * <Output>\n\n * y : Output tensor\n\n * <Attr>\n\n * reduction_indices : The dimensions to reduce\n\n * epsilon : A very small float number used to avoid dividing by zero.\n\n * <Added in HiAI version>\n\n * 100.320.010.010\n\n */\n\n REG_OP(InstanceNorm)\n\n .INPUT(x, TensorType({DT_FLOAT}))\n\n .INPUT(scale, TensorType({DT_FLOAT}))\n\n .INPUT(bias, TensorType({DT_FLOAT}))\n\n .OUTPUT(y, TensorType({DT_FLOAT}))\n\n .REQUIRED_ATTR(reduction_indices, AttrValue::LIST_INT)\n\n .ATTR(epsilon, AttrValue::FLOAT{1e-7f})\n\n .OP_END()\n\n\n\n /*\n\n * Multiplies slices of two tensors in batches.\n\n * <Input>\n\n * x : The input tensor\n\n * y : The input tensor\n\n * <Output>\n\n * z : The output tensor\n\n * <Attr>\n\n * adj_x : adj_x is true, the input tensor x is transposed, otherwise\n\n * it will not be transposed. Default is false (The current version only\n\n * supports false).\n\n * adj_y : adj_y is true, the input tensor y is transposed, otherwise\n\n * it will not be transposed. Default is false.\n\n * <Added in HiAI version>\n\n * 100.320.010.010\n\n */\n\n REG_OP(BatchMatMul)\n\n .INPUT(x, TensorType({DT_FLOAT}))\n\n .INPUT(y, TensorType({DT_FLOAT}))\n\n .OUTPUT(z, TensorType({DT_FLOAT}))\n\n .ATTR(adj_x, AttrValue::BOOL{false})\n\n .ATTR(adj_y, AttrValue::BOOL{false})\n\n .OP_END()\n\n\n", "file_path": "lite/kernels/npu/bridges/utility.h", "rank": 15, "score": 222215.252806341 }, { "content": " class func kernelFunctionName(param: ConvParam<P>, useAggressiveOptimization: Bool = false) -> String? {\n\n if GlobalConfig.shared.computePrecision == .Float16 {\n\n if param.filter.width == 1 && param.filter.height == 1 {\n\n return \"conv_add_relu_1x1_half\"\n\n } else if param.filter.channel == 1 && param.filter.n == param.input.tensorDim[1] {\n\n if useAggressiveOptimization {\n\n let couldUseWinograd = param.filter.width == 3 && param.filter.height == 3\n\n && (param.filter.n ?? Int.max) <= 16 && param.stride[0] == 1 && param.stride[1] == 1\n\n && param.dilations[0] == 1 && param.dilations[1] == 1\n\n if couldUseWinograd {\n\n return \"depthwise_conv_add_relu_3x3_half_winograd\"\n\n }\n\n }\n\n return \"depthwise_conv_add_relu_3x3_half\"\n\n } else if param.filter.width == 3 && param.filter.height == 3 {\n\n if param.groups == 1 {\n\n return \"conv_add_relu_3x3_half\"\n\n } else {\n\n return \"group_conv_add_relu_3x3_half\"\n\n }\n", "file_path": "metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvKernel.swift", "rank": 16, "score": 220986.3410792252 }, { "content": "namespace paddle_mobile {\n\nnamespace framework {\n\n\n\nvoid TensorCopy(const Tensor& src, Tensor* dst);\n\n\n\ntemplate <typename T>\n\nvoid TensorFromVector(const std::vector<T>& src, Tensor* dst);\n\n\n\ntemplate <typename T>\n\nvoid TensorFromVector(const std::vector<T>& src, Tensor* dst) {\n\n auto src_ptr = static_cast<const void*>(src.data());\n\n dst->Resize({static_cast<int64_t>(src.size())});\n\n auto dst_ptr = static_cast<void*>(dst->mutable_data<T>());\n\n auto size = src.size() * sizeof(T);\n\n\n\n memory::Copy(dst_ptr, src_ptr, size);\n\n}\n\n\n\n} // namespace framework\n", "file_path": "mobile/src/framework/tensor_util.h", "rank": 17, "score": 220396.9726373456 }, { "content": "class MatchMatrixTensorCompute\n\n : public KernelLite<TARGET(kCUDA), PRECISION(kFloat), DATALAYOUT(kNCHW)> {\n\n public:\n\n using param_t = operators::MatchMatrixTensorParam;\n\n\n\n void PrepareForRun() override;\n\n void Run() override;\n\n virtual ~MatchMatrixTensorCompute() = default;\n\n\n\n private:\n\n std::unique_ptr<lite::cuda::math::Gemm<float, float>> gemm_impl_;\n\n lite::Tensor _input_l_transform;\n\n lite::Tensor _input_l_transform_reorganize;\n\n lite::Tensor _output_tmp;\n\n lite::Tensor _offset_r;\n\n};\n\n\n\n} // namespace cuda\n\n} // namespace kernels\n\n} // namespace lite\n\n} // namespace paddle\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute.h", "rank": 18, "score": 220111.21398519207 }, { "content": "namespace paddle_mobile {\n\nnamespace operators {\n\n\n\n#ifdef WRITE_TO_ARRAY_OP\n\nDECLARE_KERNEL(WriteToArray, WriteToArrayParam);\n\n#endif // WRITE_TO_ARRAY_OP\n\n\n\n#ifdef READ_FROM_ARRAY_OP\n\nDECLARE_KERNEL(ReadFromArray, ReadFromArrayParam);\n\n#endif // READ_FROM_ARRAY_OP\n\n\n\n} // namespace operators\n", "file_path": "mobile/src/operators/kernel/tensor_array_read_write_kernel.h", "rank": 19, "score": 216602.42354207576 }, { "content": " struct KernelArgs kernel;\n", "file_path": "lite/backends/fpga/KD/llapi/zynqmp_api.h", "rank": 20, "score": 216209.37200961626 }, { "content": "using paddle_mobile::framework::Tensor;\n", "file_path": "mobile/test/test_helper.h", "rank": 21, "score": 215541.9313529423 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include \"lite/kernels/cuda/match_matrix_tensor_compute.h\"\n\n#include <gtest/gtest.h>\n\n#include <memory>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/api/test_helper.h\"\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute_test.cc", "rank": 22, "score": 215021.24844726457 }, { "content": "\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace cuda {\n\n\n\nusing Tensor = lite::Tensor;\n\n\n\nTEST(match_matrix_tensor, normal) {\n\n std::unique_ptr<KernelContext> ctx(new KernelContext);\n\n auto& context = ctx->As<CUDAContext>();\n\n\n\n MatchMatrixTensorCompute kernel;\n\n operators::MatchMatrixTensorParam param;\n\n\n\n // prepare ins and outs tensor in gpu, including size and lod\n\n int ix = 5, iy = 4, h = 2, dim_t = 2;\n\n Tensor x, w, y, out, tmp;\n\n x.Resize({ix, h});\n\n w.Resize({h, dim_t, h});\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute_test.cc", "rank": 23, "score": 215020.8807236698 }, { "content": " 133,\n\n 7,\n\n 33,\n\n 59,\n\n 27,\n\n 125,\n\n 223,\n\n 323,\n\n 455,\n\n 587,\n\n 557,\n\n 793,\n\n 1029};\n\n for (int i = 0; i < out.numel(); i++) {\n\n EXPECT_NEAR(out_cpu_data[i], ref_results[i], 1e-5);\n\n }\n\n}\n\n\n\n} // namespace cuda\n\n} // namespace kernels\n\n} // namespace lite\n\n} // namespace paddle\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute_test.cc", "rank": 24, "score": 215004.16799982186 }, { "content": " param.out = &out;\n\n param.tmp = &tmp;\n\n kernel.SetParam(param);\n\n\n\n cudaStream_t stream;\n\n cudaStreamCreate(&stream);\n\n context.SetExecStream(stream);\n\n kernel.SetContext(std::move(ctx));\n\n kernel.Launch();\n\n cudaDeviceSynchronize();\n\n\n\n auto* out_cpu_data = out_cpu.mutable_data<float>();\n\n auto* out_data = out.mutable_data<float>(TARGET(kCUDA));\n\n CopySync<TARGET(kCUDA)>(\n\n out_cpu_data, out_data, sizeof(float) * out.numel(), IoDirection::DtoH);\n\n std::vector<float> ref_results = {5,\n\n 23,\n\n 41,\n\n 17,\n\n 75,\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute_test.cc", "rank": 25, "score": 214989.93246457807 }, { "content": " auto* y_cpu_data = y_cpu.mutable_data<float>();\n\n for (int i = 0; i < x_cpu.numel(); ++i) {\n\n x_cpu_data[i] = static_cast<float>(i);\n\n }\n\n for (int i = 0; i < w_cpu.numel(); ++i) {\n\n w_cpu_data[i] = static_cast<float>(i);\n\n }\n\n for (int i = 0; i < y_cpu.numel(); ++i) {\n\n y_cpu_data[i] = static_cast<float>(i);\n\n }\n\n\n\n // cpu tensor data assigin to gpu tensor\n\n x.Assign<float, lite::DDim, TARGET(kCUDA)>(x_cpu_data, x_cpu.dims());\n\n w.Assign<float, lite::DDim, TARGET(kCUDA)>(w_cpu_data, w_cpu.dims());\n\n y.Assign<float, lite::DDim, TARGET(kCUDA)>(y_cpu_data, y_cpu.dims());\n\n\n\n param.x = &x;\n\n param.w = &w;\n\n param.y = &y;\n\n param.dim_t = dim_t;\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute_test.cc", "rank": 26, "score": 214989.8924270521 }, { "content": " y.Resize({iy, h});\n\n out.Resize({18, 1});\n\n tmp.Resize({20, 1});\n\n LoD x_lod{};\n\n x_lod.push_back({0, 2, 5});\n\n x.set_lod(x_lod);\n\n LoD y_lod{};\n\n y_lod.push_back({0, 3, 4});\n\n y.set_lod(y_lod);\n\n\n\n // init ins tensor in cpu\n\n Tensor x_cpu, w_cpu, y_cpu, out_cpu, tmp_cpu;\n\n x_cpu.Resize({ix, h});\n\n w_cpu.Resize({h, dim_t, h});\n\n y_cpu.Resize({iy, h});\n\n out_cpu.Resize({18, 1});\n\n tmp_cpu.Resize({20, 1});\n\n\n\n auto* x_cpu_data = x_cpu.mutable_data<float>();\n\n auto* w_cpu_data = w_cpu.mutable_data<float>();\n", "file_path": "lite/kernels/cuda/match_matrix_tensor_compute_test.cc", "rank": 27, "score": 214976.40041202228 }, { "content": "enum PaddleMobileLogLevel: String {\n\n case Info = \"Info\"\n\n case Warning = \"Warning\"\n\n case FatalError = \"FatalError\"\n\n}\n\n\n", "file_path": "metal/paddle-mobile/paddle-mobile/Src/Framework/Utils.swift", "rank": 28, "score": 214591.79848432934 }, { "content": " int tensor_output_length;\n", "file_path": "lite/tools/debug/debug_utils.h", "rank": 29, "score": 213893.65816180725 }, { "content": "# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n\n\ndef gen_use_kernel_statement(op_type, target, precision, layout, alias):\n\n return 'USE_LITE_KERNEL(%s, %s, %s, %s, %s);' %(\n\n op_type, target, precision, layout, alias\n\n )\n", "file_path": "lite/tools/cmake_tools/utils.py", "rank": 30, "score": 211628.1311451618 }, { "content": " PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor;\n", "file_path": "mobile/src/framework/framework.pb-c.h", "rank": 31, "score": 211342.252310206 }, { "content": " class func kernelFunctionName(param: ConvAddReluParam<P>, useAggressiveOptimization: Bool = false) -> String? {\n\n if GlobalConfig.shared.computePrecision == .Float16 {\n\n if param.filter.width == 1 && param.filter.height == 1 {\n\n return \"conv_add_relu_1x1_half\"\n\n } else if param.filter.width == 3 && param.filter.height == 3 {\n\n if param.filter.channel == 1 && param.filter.n == param.input.tensorDim[1] {\n\n if useAggressiveOptimization {\n\n let couldUseWinograd = param.filter.width == 3 && param.filter.height == 3\n\n && (param.filter.n ?? Int.max) <= 16 && param.stride[0] == 1 && param.stride[1] == 1\n\n && param.dilations[0] == 1 && param.dilations[1] == 1\n\n if couldUseWinograd {\n\n return \"depthwise_conv_add_relu_3x3_half_winograd\"\n\n }\n\n }\n\n return \"depthwise_conv_add_relu_3x3_half\"\n\n } else {\n\n if param.groups == 1 {\n\n return \"conv_add_relu_3x3_half\"\n\n } else {\n\n return \"group_conv_add_relu_3x3_half\"\n", "file_path": "metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddReluKernel.swift", "rank": 32, "score": 210118.27324862327 }, { "content": "class SeqSortedseqTranseUtil {\n\n public:\n\n explicit SeqSortedseqTranseUtil(bool is_reverse = false, bool is_bi = false)\n\n : _is_reverse(is_reverse),\n\n _is_bi(is_bi),\n\n _dev_map_vec(nullptr),\n\n _dev_map_vec_length(0) {}\n\n\n\n ~SeqSortedseqTranseUtil() {\n\n if (_dev_map_vec != nullptr) {\n\n TargetWrapperCuda::Free(static_cast<void*>(_dev_map_vec));\n\n }\n\n }\n\n\n\n std::vector<int>& get_length_index() { return _length_index; }\n\n std::vector<int>& get_emit_offset_vec() { return _emit_offset_vec; }\n\n std::vector<int>& get_map_vec() { return _map_vec; }\n\n int* get_dev_map_vec() { return _dev_map_vec; }\n\n int get_emit_length() { return _emit_length; }\n\n\n", "file_path": "lite/kernels/cuda/search_grnn_compute.h", "rank": 33, "score": 209275.85949290774 }, { "content": " PaddleMobile__Framework__Proto__VarType__TensorDesc *tensor;\n", "file_path": "mobile/tools/quantification/src/framework.pb-c.h", "rank": 34, "score": 207357.6369241859 }, { "content": " struct KernelArgs kernel;\n", "file_path": "mobile/src/fpga/common/fpga_common.h", "rank": 35, "score": 205537.0257513299 }, { "content": " kern_type kernel;\n", "file_path": "mobile/src/operators/math/gemm/strategy.h", "rank": 36, "score": 205537.0257513299 }, { "content": "# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n\n\nfrom __future__ import print_function\n\nimport sys\n\nimport logging\n\nfrom ast import RegisterLiteKernelParser\n\n\n\nif len(sys.argv) != 5:\n\n print(\"Error: parse_kernel_registry.py requires four inputs!\")\n\n exit(1)\n\nops_list_path = sys.argv[1]\n\ndest_path = sys.argv[2]\n\nminkernels_list_path = sys.argv[3]\n\ntailored = sys.argv[4]\n\n\n\nout_lines = [\n\n '#pragma once',\n\n '#include \"paddle_lite_factory_helper.h\"',\n\n '',\n\n]\n\nminlines = set()\n\nif tailored == \"ON\":\n\n with open(minkernels_list_path) as fd:\n\n for line in fd:\n\n minlines.add(line.strip())\n\nwith open(ops_list_path) as f:\n\n paths = set([path for path in f])\n\n for path in paths:\n\n with open(path.strip()) as g:\n\n c = g.read()\n\n kernel_parser = RegisterLiteKernelParser(c)\n\n kernel_parser.parse()\n\n\n\n for k in kernel_parser.kernels:\n\n kernel = \"%s, %s, %s, %s, %s\" % (\n\n k.op_type,\n\n k.target,\n\n k.precision,\n\n k.data_layout,\n\n k.alias,\n\n )\n\n if tailored == \"ON\":\n\n if kernel not in minlines: continue\n\n key = \"USE_LITE_KERNEL(%s, %s, %s, %s, %s);\" % (\n\n k.op_type,\n\n k.target,\n\n k.precision,\n\n k.data_layout,\n\n k.alias,\n\n )\n\n out_lines.append(key)\n\n\n\nwith open(dest_path, 'w') as f:\n\n logging.info(\"write kernel list to %s\" % dest_path)\n\n f.write('\\n'.join(out_lines))\n", "file_path": "lite/tools/cmake_tools/parse_kernel_registry.py", "rank": 37, "score": 202545.94133795216 }, { "content": "func paddleMobileLog(_ msg: String, logLevel: PaddleMobileLogLevel = .Info, file: String = #file, line: Int = #line, function: String = #function, callStack: Array<String>? = nil) {\n\n var msg = \"PaddleMobileLog-\\(logLevel.rawValue): \\(msg) -file: \\(file) -line: \\(line) -function:\\(function)\"\n\n if let callStack = callStack {\n\n msg.append(contentsOf: \" -calling stack: \\(callStack)\")\n\n }\n\n print(msg)\n\n}\n", "file_path": "metal/paddle-mobile/paddle-mobile/Src/Framework/Utils.swift", "rank": 38, "score": 201891.87599195918 }, { "content": " struct KernelArgs kernel;\n", "file_path": "mobile/src/fpga/KD/llapi/zynqmp_api.h", "rank": 39, "score": 201795.26838443568 }, { "content": "USE_LITE_OP(hard_sigmoid)\n", "file_path": "lite/api/_paddle_use_ops.h", "rank": 40, "score": 201777.9485396591 }, { "content": "# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n\n\nfrom __future__ import print_function\n\nimport sys\n\nimport logging\n\nfrom ast import RegisterLiteKernelParser\n\nfrom ast import RegisterLiteOpParser\n\n\n\nif len(sys.argv) != 4:\n\n print(\"Error: record_supported_kernel_op.py requires three inputs!\")\n\n exit(1)\n\nkernels_list_path = sys.argv[1]\n\nops_list_path = sys.argv[2]\n\nkernel_op_map_dest_path = sys.argv[3]\n\n\n\n\n\nout_lines = [\n\n'''\n\n// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include<vector>\n\n#include<map>\n\n#include<string>\n\n\n\nconst std::vector<std::vector<std::string>> supported_ops_target = {\n\n'''\n\n]\n\n\n\nops_lines=[]\n\n\n\n# valid targets and valid_ops\n\nvalid_targets = [\"kUnk\", \"kHost\", \"kX86\", \"kCUDA\", \"kARM\", \"kOpenCL\", \"kAny\", \"kFPGA\", \"kNPU\", \"kXPU\"]\n\nvalid_ops = [[],[],[],[],[],[],[],[],[],[]]\n\nclass TargetType:\n\n kUnk = 0\n\n kHost = 1\n\n kX86 = 2\n\n kCUDA = 3\n\n kARM = 4\n\n kOpenCL = 5\n\n kFPGA = 7\n\n kNPU = 8\n\n kXPU = 9\n\n kAny = 6 # any target\n\n\n\n# record op_info of valid kernels into `valid_ops` according to different target type\n\nwith open(kernels_list_path) as f:\n\n paths = set([path for path in f])\n\n for path in paths:\n\n with open(path.strip()) as g:\n\n c = g.read()\n\n kernel_parser = RegisterLiteKernelParser(c)\n\n kernel_parser.parse()\n\n for k in kernel_parser.kernels:\n\n if hasattr(TargetType, k.target):\n\n index=getattr(TargetType, k.target)\n\n valid_ops[index].append(k.op_type)\n\n\n\n# clear the repeated ops\n\nfor target in valid_targets:\n\n index = getattr(TargetType, target)\n\n valid_ops[index] = list(set(valid_ops[index]))\n\n\n\npaths = set()\n\nwith open(ops_list_path) as f:\n\n paths = set([path for path in f])\n\n for path in paths:\n\n str_info = open(path.strip()).read()\n\n op_parser = RegisterLiteOpParser(str_info)\n\n ops = op_parser.parse()\n\n for op in ops:\n\n if \"_grad\" in op:\n\n continue\n\n out = ' {\"%s\", { \"' % op\n\n op_targets = []\n\n for target in valid_targets:\n\n if op in valid_ops[getattr(TargetType, target)]:\n\n op_targets.append(target)\n\n if len(op_targets) > 0:\n\n out = out +'\", \"'.join(op_targets)+ '\" }}'\n\n else:\n\n # unknow type op: kUnk = 0\n\n valid_ops[0].append(op)\n\n out = out +'kUnk\" }}'\n\n ops_lines.append(out)\n\n\n\nwith open(kernel_op_map_dest_path, 'w') as f:\n\n logging.info(\"write kernel list to %s\" % kernel_op_map_dest_path)\n\n f.write('\\n'.join(out_lines))\n\n # write kernels into head file\n\n for target in valid_targets:\n\n if len(valid_ops[getattr(TargetType, target)]) == 0 :\n\n f.write(\"\\n // %s_OPS: \" %target)\n\n f.write('\\n {},')\n\n else:\n\n f.write(\"\\n // %s_OPS: \" %target)\n\n f.write('\\n {\"')\n\n f.write('\",\"'.join(valid_ops[getattr(TargetType, target)]))\n\n f.write('\"},\\n')\n\n f.write('};')\n\n # write op info into head file\n\n f.write('\\nconst std::map<std::string, std::vector<std::string>> supported_ops={\\n')\n\n f.write(',\\n'.join(ops_lines))\n\n f.write('\\n};')\n", "file_path": "lite/tools/cmake_tools/record_supported_kernel_op.py", "rank": 41, "score": 199127.0419954339 }, { "content": "# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n\n\nfrom __future__ import print_function\n\nimport sys\n\nimport logging\n\nfrom ast import RegisterLiteKernelParser\n\nfrom utils import *\n\n\n\nif len(sys.argv) != 4:\n\n print(\"Error: create_fake_kernel_registry.py requires three inputs!\")\n\n exit(1)\n\nops_list_path = sys.argv[1]\n\ndest_path = sys.argv[2]\n\nkernelmap_path = sys.argv[3]\n\n\n\nout_lines = [\n\n '#pragma once',\n\n '#include \"lite/core/op_registry.h\"',\n\n '#include \"lite/core/kernel.h\"',\n\n '#include \"lite/core/type_system.h\"',\n\n '',\n\n]\n\n\n\nfake_kernel = '''\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\nclass %s : public KernelLite<TARGET(%s), PRECISION(%s), DATALAYOUT(%s)> {\n\n public:\n\n void PrepareForRun() override {}\n\n\n\n void Run() override {}\n\n\n\n virtual ~%s() = default;\n\n};\n\n\n\n} // namespace lite\n\n} // namespace paddle\n\n'''\n\n\n\n# create .h file to store kernel&source relationship\n\nkernel_src_map_lines = [\n\n'''\n\n// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include<map>\n\n// ATTENTION This can only include in a .cc file.\n\n\n\nconst std::map<std::string, std::string> kernel2path_map{\n\n\n\n'''\n\n]\n\n\n\n\n\nwith open(ops_list_path) as f:\n\n paths = set([path for path in f])\n\n for path in paths:\n\n print('path', path)\n\n with open(path.strip()) as g:\n\n c = g.read()\n\n kernel_parser = RegisterLiteKernelParser(c)\n\n kernel_parser.parse()\n\n\n\n for k in kernel_parser.kernels:\n\n kernel_name = \"{op_type}_{target}_{precision}_{data_layout}_{alias}_class\".format(\n\n op_type = k.op_type,\n\n target = k.target,\n\n precision = k.precision,\n\n data_layout = k.data_layout,\n\n alias = k.alias,\n\n )\n\n\n\n kernel_define = fake_kernel % (\n\n kernel_name,\n\n k.target,\n\n k.precision,\n\n k.data_layout,\n\n kernel_name,\n\n )\n\n\n\n out_lines.append(kernel_define)\n\n out_lines.append(\"\")\n\n\n\n\n\n key = \"REGISTER_LITE_KERNEL(%s, %s, %s, %s, %s, %s)\" % (\n\n k.op_type,\n\n k.target,\n\n k.precision,\n\n k.data_layout,\n\n '::paddle::lite::' + kernel_name,\n\n k.alias,\n\n )\n\n out_lines.append(key)\n\n\n\n for input in k.inputs:\n\n io = ' .BindInput(\"%s\", {%s})' % (input.name, input.type)\n\n out_lines.append(io)\n\n for output in k.outputs:\n\n io = ' .BindOutput(\"%s\", {%s})' % (output.name, output.type)\n\n out_lines.append(io)\n\n out_lines.append(\" .Finalize();\")\n\n out_lines.append(\"\")\n\n out_lines.append(gen_use_kernel_statement(k.op_type, k.target, k.precision, k.data_layout, k.alias))\n\n\n\n index = path.rindex('/')\n\n filename = path[index + 1:]\n\n map_element = ' {\"%s,%s,%s,%s,%s\", \"%s\"},' % (\n\n k.op_type,\n\n k.target,\n\n k.precision,\n\n k.data_layout,\n\n k.alias,\n\n filename.strip()\n\n )\n\n kernel_src_map_lines.append(map_element)\n\nwith open(dest_path, 'w') as f:\n\n logging.info(\"write kernel list to %s\" % dest_path)\n\n f.write('\\n'.join(out_lines))\n\n\n\nwith open(kernelmap_path, 'w') as fd:\n\n logging.info(\"write kernel map to %s\" % dest_path)\n\n kernel_src_map_lines.append(' {\" \", \" \"}')\n\n kernel_src_map_lines.append('};')\n\n fd.write('\\n'.join(kernel_src_map_lines))\n", "file_path": "lite/tools/cmake_tools/create_fake_kernel_registry.py", "rank": 42, "score": 199127.0419954339 }, { "content": "class Blas : public lite::cuda::BlasBase {\n\n public:\n\n void sgemm(cublasOperation_t transa,\n\n cublasOperation_t transb, //\n\n int m,\n\n int n,\n\n int k, //\n\n const T* alpha, //\n\n const T* A,\n\n int lda, //\n\n const T* B,\n\n int ldb, //\n\n const T* beta, //\n\n T* C,\n\n int ldc) const {\n\n CHECK_EQ(CUBLAS_STATUS_SUCCESS,\n\n cublasSgemm(handle_, //\n\n CUBLAS_OP_N,\n\n CUBLAS_OP_N, //\n\n m,\n", "file_path": "lite/backends/cuda/blas.h", "rank": 43, "score": 197628.58746921842 }, { "content": "# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n\n\nimport re\n\nimport os\n\nimport sys\n\n\n\ndef gen_opencl_kernels():\n\n source = \"\"\"\n\n #pragma\n\n #ifdef PADDLE_MOBILE_CL\n\n #include <map>\n\n #include <string>\n\n #include <vector>\n\n namespace paddle_mobile {\n\n // func name => source\n\n extern const std::map<std::string, std::vector<unsigned char>> opencl_kernels = {\n\n %s\n\n };\n\n // file name => header\n\n extern const std::map<std::string, std::vector<unsigned char>> opencl_headers = {\n\n %s\n\n };\n\n }\n\n #endif\n\n \"\"\"\n\n\n\n def string_to_hex(str):\n\n hex_list = []\n\n for i in range(len(code_str)):\n\n hex_ = hex(ord(code_str[i]))\n\n hex_list.append(hex_)\n\n return hex_list\n\n\n\n def clean_source(content):\n\n new_content = re.sub(r\"/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/\", \"\", content, flags=re.DOTALL)\n\n lines = new_content.split(\"\\n\")\n\n new_lines = []\n\n for i in range(len(lines)):\n\n line = lines[i]\n\n line = re.sub(r\"//.*$\", \"\", line)\n\n line = line.strip()\n\n if line == \"\":\n\n continue\n\n new_lines.append(line)\n\n new_content = \"\\n\".join(new_lines)\n\n return new_content\n\n\n\n infile = open(\"cl_kernel/cl_common.h\", \"r\")\n\n common_content = infile.read()\n\n infile.close()\n\n common_content = clean_source(common_content)\n\n\n\n infile = open(\"cl_kernel/conv_kernel.inc.cl\", \"r\")\n\n inc_content = infile.read()\n\n infile.close()\n\n inc_content = clean_source(inc_content)\n\n\n\n def get_header_raw(content):\n\n lines = content.split(\"\\n\")\n\n new_lines = []\n\n for line in lines:\n\n if \"__kernel void\" in line:\n\n break\n\n new_lines.append(line)\n\n header = \"\\n\".join(new_lines)\n\n return header\n\n common_header = get_header_raw(common_content)\n\n inc_header = get_header_raw(inc_content)\n\n\n\n def get_header(content):\n\n lines = content.split(\"\\n\")\n\n new_lines = []\n\n for line in lines:\n\n if \"__kernel void\" in line:\n\n break\n\n new_lines.append(line)\n\n for i in range(len(new_lines)):\n\n if \"#include \\\"conv_kernel.inc.cl\\\"\" in new_lines[i]:\n\n new_lines[i] = inc_header\n\n header = \"\\n\".join(new_lines)\n\n new_lines = header.split(\"\\n\")\n\n for i in range(len(new_lines)):\n\n if \"#include \\\"cl_common.h\\\"\" in new_lines[i]:\n\n new_lines[i] = common_header\n\n header = \"\\n\".join(new_lines)\n\n return header\n\n\n\n def get_funcs(content):\n\n funcs = {}\n\n lines = content.split(\"\\n\")\n\n first_kernel_idx = None\n\n for i in range(len(lines)):\n\n if \"__kernel void\" in lines[i]:\n\n first_kernel_idx = i\n\n break\n\n if first_kernel_idx is None:\n\n return funcs\n\n lines = lines[first_kernel_idx:]\n\n func = []\n\n name = \"\"\n\n for line in lines:\n\n if \"__kernel void\" in line:\n\n if name != \"\":\n\n funcs[name] = \"\\n\".join(func)\n\n name = \"\"\n\n func = []\n\n pattern = re.compile(\"__kernel void ([^(]+)\\(\")\n\n match = pattern.search(line)\n\n name = match.group(1)\n\n func.append(line)\n\n if name != \"\":\n\n funcs[name] = \"\\n\".join(func)\n\n name = \"\"\n\n func = []\n\n return funcs\n\n\n\n filenames = os.listdir(\"cl_kernel\")\n\n file_count = len(filenames)\n\n\n\n headers = {}\n\n funcs = {}\n\n for i in range(file_count):\n\n filename = filenames[i]\n\n infile = open(\"cl_kernel/\" + filename, \"r\")\n\n content = infile.read()\n\n infile.close()\n\n content = clean_source(content)\n\n header = get_header(content)\n\n headers[filename] = header\n\n funcs_temp = get_funcs(content)\n\n for key in funcs_temp:\n\n funcs[key] = funcs_temp[key]\n\n\n\n core1 = \"\"\n\n core2 = \"\"\n\n\n\n for i in range(len(funcs)):\n\n func_name = list(funcs.keys())[i]\n\n content = funcs[func_name]\n\n if content == \"\":\n\n content = \" \"\n\n hexes = []\n\n for char in content:\n\n hexes.append(hex(ord(char)))\n\n core = \" {\\\"%s\\\", {\" % func_name\n\n for item in hexes:\n\n core += str(item) + \", \"\n\n core = core[: -2]\n\n core += \"}}\"\n\n if i != len(funcs) - 1:\n\n core += \",\\n\"\n\n core1 += core\n\n\n\n for i in range(len(headers)):\n\n file_name = list(headers.keys())[i]\n\n content = headers[file_name]\n\n if content == \"\":\n\n content = \" \"\n\n hexes = []\n\n for char in content:\n\n hexes.append(hex(ord(char)))\n\n core = \" {\\\"%s\\\", {\" % file_name\n\n for item in hexes:\n\n core += str(item) + \", \"\n\n core = core[: -2]\n\n core += \"}}\"\n\n if i != len(headers) - 1:\n\n core += \",\\n\"\n\n core2 += core\n\n source = source % (core1, core2)\n\n print(source)\n\n\n\ndef gen_empty_opencl_kernels():\n\n source = \"\"\"\n\n #pragma\n\n #ifdef PADDLE_MOBILE_CL\n\n #include <map>\n\n #include <string>\n\n #include <vector>\n\n namespace paddle_mobile {\n\n // func name => source\n\n extern const std::map<std::string, std::vector<unsigned char>> opencl_kernels = {\n\n };\n\n // file name => header\n\n extern const std::map<std::string, std::vector<unsigned char>> opencl_headers = {\n\n };\n\n }\n\n #endif\n\n \"\"\"\n\n print(source)\n\n\n\nif __name__ == \"__main__\":\n\n if sys.argv[1] == \"0\":\n\n gen_empty_opencl_kernels()\n\n elif sys.argv[1] == \"1\":\n\n gen_opencl_kernels()\n", "file_path": "mobile/src/operators/kernel/cl/gen_code.py", "rank": 44, "score": 195163.21044827887 }, { "content": "USE_MIR_PASS(elementwise_mul_constant_eliminate_pass)\n", "file_path": "lite/api/paddle_use_passes.h", "rank": 45, "score": 194709.26901659297 }, { "content": " open class func isWinoGrad(functionName: String?) -> Bool {\n\n if let functionName = functionName {\n\n return functionName.hasSuffix(\"winograd\")\n\n }\n\n return false\n\n }\n\n}\n", "file_path": "metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvKernel.swift", "rank": 46, "score": 192934.45877853732 }, { "content": "namespace paddle {\n\nnamespace lite {\n\n\n\nstatic bool IsFileExists(const std::string& path) {\n\n std::ifstream file(path);\n\n bool res = file.is_open();\n\n if (res) {\n\n file.close();\n\n }\n\n return res;\n\n}\n\n\n\n// ARM mobile not support mkdir in C++\n\nstatic void MkDirRecur(const std::string& path) {\n\n#ifndef LITE_WITH_ARM\n\n if (system(string_format(\"mkdir -p %s\", path.c_str()).c_str()) != 0) {\n\n LOG(ERROR) << \"Cann't mkdir \" << path;\n\n }\n\n#else // On ARM\n\n CHECK_NE(mkdir(path.c_str(), S_IRWXU), -1) << \"Cann't mkdir \" << path;\n\n#endif\n\n}\n\n\n\n// read buffer from file\n\nstatic std::string ReadFile(const std::string& filename) {\n\n std::ifstream ifile(filename.c_str());\n\n if (!ifile.is_open()) {\n\n LOG(FATAL) << \"Open file: [\" << filename << \"] failed.\";\n\n }\n\n std::ostringstream buf;\n\n char ch;\n\n while (buf && ifile.get(ch)) buf.put(ch);\n\n ifile.close();\n\n return buf.str();\n\n}\n\n\n\n// read lines from file\n\nstatic std::vector<std::string> ReadLines(const std::string& filename) {\n\n std::ifstream ifile(filename.c_str());\n\n if (!ifile.is_open()) {\n\n LOG(FATAL) << \"Open file: [\" << filename << \"] failed.\";\n\n }\n\n std::vector<std::string> res;\n\n std::string tmp;\n\n while (getline(ifile, tmp)) res.push_back(tmp);\n\n ifile.close();\n\n return res;\n\n}\n\n\n\nstatic void WriteLines(const std::vector<std::string>& lines,\n\n const std::string& filename) {\n\n std::ofstream ofile(filename.c_str());\n\n if (!ofile.is_open()) {\n\n LOG(FATAL) << \"Open file: [\" << filename << \"] failed.\";\n\n }\n\n for (const auto& line : lines) {\n\n ofile << line << \"\\n\";\n\n }\n\n ofile.close();\n\n}\n\n\n\nstatic bool IsDir(const std::string& path) {\n\n DIR* dir_fd = opendir(path.c_str());\n\n if (dir_fd == nullptr) return false;\n\n closedir(dir_fd);\n\n return true;\n\n}\n\n\n\nstatic std::vector<std::string> ListDir(const std::string& path,\n\n bool only_dir = false) {\n\n if (!IsDir(path)) {\n\n LOG(FATAL) << \"[\" << path << \"] is not a valid dir path.\";\n\n }\n\n\n\n std::vector<std::string> paths;\n\n DIR* parent_dir_fd = opendir(path.c_str());\n\n dirent* dp;\n\n while ((dp = readdir(parent_dir_fd)) != nullptr) {\n\n // Exclude '.', '..' and hidden dir\n\n std::string name(dp->d_name);\n\n if (name == \".\" || name == \"..\" || name[0] == '.') continue;\n\n if (IsDir(Join<std::string>({path, name}, \"/\"))) {\n\n paths.push_back(name);\n\n }\n\n }\n\n closedir(parent_dir_fd);\n\n return paths;\n\n}\n\n\n\n} // namespace lite\n", "file_path": "lite/utils/io.h", "rank": 47, "score": 192845.45809687697 }, { "content": "namespace paddle {\n\nnamespace lite {\n\n\n\ntemplate <typename T>\n\ninline size_t hash_combine(size_t s, const T& v) {\n\n std::hash<T> h;\n\n return (s ^ h(v)) + 0x9e3779b9 + (s << 6) + (s >> 2);\n\n}\n\n\n\n} // namespace lite\n", "file_path": "lite/utils/hash.h", "rank": 48, "score": 192845.45809687697 }, { "content": "#include <memory>\n\n#include <string>\n\n#include <unordered_set>\n\n#include <utility>\n\n#include <vector>\n\n\n\n#ifndef LITE_ON_TINY_PUBLISH\n\n#include \"lite/api/cxx_api.h\"\n\n#include \"lite/api/paddle_use_passes.h\"\n\n#endif\n\n\n\n#include \"lite/api/light_api.h\"\n\n#include \"lite/api/paddle_api.h\"\n\n#include \"lite/api/paddle_use_kernels.h\"\n\n#include \"lite/api/paddle_use_ops.h\"\n\n#include \"lite/core/tensor.h\"\n\n\n\nnamespace py = pybind11;\n\n\n\nnamespace paddle {\n", "file_path": "lite/api/python/pybind/pybind.cc", "rank": 49, "score": 68.44104970270057 }, { "content": "#include <set>\n\n#include <string>\n\n#include <unordered_map>\n\n#include <unordered_set>\n\n#include <utility>\n\n#include <vector>\n\n\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/mir/pass.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace mir {\n\n\n\n/*\n\n * MemoryOptimizePass will\n\n */\n", "file_path": "lite/core/mir/memory_optimize_pass.h", "rank": 50, "score": 58.58259257677669 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include <memory>\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/conv_op.h", "rank": 51, "score": 58.23444864461494 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include \"lite/kernels/arm/merge_lod_tensor_compute.h\"\n\n#include <string>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/backends/arm/math/funcs.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/core/type_system.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace arm {\n\n\n", "file_path": "lite/kernels/arm/merge_lod_tensor_compute.cc", "rank": 52, "score": 57.05379400230365 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include \"lite/kernels/arm/split_lod_tensor_compute.h\"\n\n#include <string>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/backends/arm/math/funcs.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/core/type_system.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace arm {\n\n\n", "file_path": "lite/kernels/arm/split_lod_tensor_compute.cc", "rank": 53, "score": 57.05379400230365 }, { "content": "#define PADDLE_LITE_API_H_\n\n#include <memory>\n\n#include <string>\n\n#include <vector>\n\n#include \"paddle_place.h\" // NOLINT\n\n\n\nnamespace paddle {\n\nnamespace lite_api {\n\n\n\nusing shape_t = std::vector<int64_t>;\n\nusing lod_t = std::vector<std::vector<uint64_t>>;\n\n\n", "file_path": "lite/api/paddle_api.h", "rank": 54, "score": 57.05102472277268 }, { "content": "#include <vector>\n\n#include \"lite/api/paddle_use_kernels.h\"\n\n#include \"lite/api/paddle_use_ops.h\"\n\n#include \"lite/core/context.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/model_parser/compatible_pb.h\"\n\n#include \"lite/model_parser/cpp/op_desc.h\"\n\n#include \"lite/model_parser/model_parser.h\"\n\n#include \"lite/model_parser/pb/program_desc.h\"\n\n\n\nDEFINE_string(optimized_model, \"\", \"\");\n\nDEFINE_string(generated_code_file, \"__generated_code__.cc\", \"\");\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace gencode {\n\n\n\n// Manually construct a program.\n\nTEST(gen_code, manual) {\n", "file_path": "lite/gen_code/gen_code_test.cc", "rank": 55, "score": 55.76675064240869 }, { "content": "#endif\n\n#ifdef LITE_WITH_OPENCL\n\n#include <unordered_map>\n\n#include \"lite/backends/opencl/cl_context.h\"\n\n#include \"lite/backends/opencl/cl_runtime.h\"\n\n#endif\n\n\n\n#include <map>\n\n#include <memory>\n\n#include <set>\n\n#include <string>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/core/device_info.h\"\n\n#include \"lite/core/target_wrapper.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/utils/all.h\"\n\n#include \"lite/utils/env.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\ntemplate <TargetType Type>\n", "file_path": "lite/core/context.h", "rank": 56, "score": 55.4433134763796 }, { "content": "#include <gflags/gflags.h>\n\n#include <time.h>\n\n#include <algorithm>\n\n#include <chrono> // NOLINT\n\n#include <fstream>\n\n#include <limits>\n\n#include <map>\n\n#include <memory>\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/utils/cp_logging.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n#include \"lite/utils/string.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace profile {\n\n\n", "file_path": "lite/core/profile/basic_profiler.h", "rank": 57, "score": 55.01847386695421 }, { "content": "#include <algorithm>\n\n#include <map>\n\n#include <memory>\n\n#include <string>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/api/paddle_api.h\"\n\n#include \"lite/core/context.h\"\n\n#include \"lite/core/program.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/core/types.h\"\n\n#include \"lite/model_parser/model_parser.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\n/*\n\n * The light weight predictor, mainly for mobile. It loads an optimized model,\n\n * and will not depend on the MIR or perform latter optimization.\n\n */\n", "file_path": "lite/api/light_api.h", "rank": 58, "score": 54.88397094617804 }, { "content": "#ifndef LITE_WITH_FPGA\n\n\n\n#include <algorithm>\n\n#include <functional> // for multiplies\n\n#include <memory>\n\n#include <numeric>\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/memory.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n", "file_path": "lite/core/tensor.h", "rank": 59, "score": 54.838554350653965 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include <memory>\n\n#include <vector>\n\n#include \"lite/backends/cuda/blas.h\"\n\n#include \"lite/backends/cuda/math/gemm.h\"\n\n#include \"lite/core/kernel.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace cuda {\n\n\n", "file_path": "lite/kernels/cuda/search_grnn_compute.h", "rank": 60, "score": 54.618194824129745 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <list>\n\n#include <memory>\n\n#include <string>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace mir {\n\n\n\n// Node in a MIR graph.\n", "file_path": "lite/core/mir/node.h", "rank": 61, "score": 54.52799577058406 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include <set>\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\nusing FeedFetchList = std::vector<lite::Tensor>;\n\n\n", "file_path": "lite/core/variable.h", "rank": 62, "score": 54.306276297606225 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/fake_channel_wise_dequantize_max_abs.h", "rank": 63, "score": 54.303280577690145 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/fake_quantize_moving_avg_max_abs.h", "rank": 64, "score": 54.30328057769015 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/fake_quantize_dequantize_moving_avg_max_abs.h", "rank": 65, "score": 54.303280577690145 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/fc_op.h", "rank": 66, "score": 54.303280577690145 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/fake_quantize_range_abs_max.h", "rank": 67, "score": 54.30328057769014 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/conv_transpose_op.h", "rank": 68, "score": 54.303280577690145 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/subgraph_op.h", "rank": 69, "score": 54.303280577690145 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace operators {\n\n\n", "file_path": "lite/operators/fake_dequantize_max_abs.h", "rank": 70, "score": 54.303280577690145 }, { "content": "#include <vector>\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/kernels/mlu/bridges/tensor.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace subgraph {\n\nnamespace mlu {\n\n\n\n// The Context of the converters which used for converting the ops of subgraph\n\n// to the MLU IR graph\n", "file_path": "lite/kernels/mlu/bridges/graph.h", "rank": 71, "score": 54.177489728385325 }, { "content": "#include \"lite/kernels/mlu/bridges/paddle_use_bridges.h\"\n\n#include \"lite/kernels/mlu/bridges/utility.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace mlu {} // namespace mlu\n\n} // namespace kernels\n\n} // namespace lite\n\n} // namespace paddle\n\n\n\nREGISTER_LITE_KERNEL(\n\n subgraph,\n\n kMLU,\n\n kFloat,\n\n kNHWC,\n\n paddle::lite::kernels::mlu::SubgraphCompute<PRECISION(kFloat)>,\n\n def_kFloat)\n\n .BindInput(\"Inputs\", {LiteType::GetTensorTy(TARGET(kMLU))})\n\n .BindOutput(\"Outputs\", {LiteType::GetTensorTy(TARGET(kMLU))})\n", "file_path": "lite/kernels/mlu/subgraph_compute.cc", "rank": 72, "score": 54.13658197982407 }, { "content": "#include <memory>\n\n#include <numeric>\n\n#include <string>\n\n#include <unordered_map>\n\n#include <unordered_set>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/core/mir/node.h\"\n\n#include \"lite/core/mir/ssa_graph.h\"\n\n#include \"lite/model_parser/pb/op_desc.h\"\n\n#include \"lite/utils/cp_logging.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n#include \"lite/utils/string.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace mir {\n", "file_path": "lite/core/mir/pattern_matcher.h", "rank": 73, "score": 53.86465062203099 }, { "content": "#include <vector>\n\n#include \"lite/backends/opencl/cl_include.h\"\n\n#include \"lite/backends/opencl/cl_utility.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\nextern const std::map<std::string, std::vector<unsigned char>>\n\n opencl_kernels_files;\n\n\n", "file_path": "lite/backends/opencl/cl_runtime.h", "rank": 74, "score": 53.74093750529305 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include <memory>\n\n#include <vector>\n\n#include \"lite/backends/cuda/math/cudnn_pool.h\"\n\n#include \"lite/core/kernel.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace cuda {\n\n\n", "file_path": "lite/kernels/cuda/pool_compute.h", "rank": 75, "score": 53.57645986491071 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include <vector>\n\n#include \"lite/backends/opencl/cl_include.h\"\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/kernels/opencl/image_helper.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n#include \"lite/utils/string.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace opencl {\n\n\n", "file_path": "lite/kernels/opencl/pool_buffer_compute.cc", "rank": 76, "score": 53.5712932446531 }, { "content": "#include \"lite/backends/arm/math/funcs.h\"\n\n#include \"lite/backends/arm/math/gru_utils.h\"\n\n#include \"lite/backends/arm/math/sequence2batch.h\"\n\n#include \"lite/backends/arm/math/sgemm.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/core/type_system.h\"\n\n#include \"lite/kernels/fpga/gru_compute.h\"\n\n\n\n#include \"lite/backends/fpga/KD/debugger.hpp\"\n\n#include \"lite/backends/fpga/KD/pes/gru_util.hpp\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace fpga {\n\n\n\nusing float16 = zynqmp::float16;\n\n\n\ninline lite_api::ActivationType get_gru_act_type(const std::string& type) {\n", "file_path": "lite/kernels/fpga/gru_compute.cc", "rank": 77, "score": 53.2852307026015 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include <vector>\n\n#include \"lite/backends/opencl/cl_include.h\"\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n#include \"lite/utils/string.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace opencl {\n\n\n", "file_path": "lite/kernels/opencl/mul_buffer_compute.cc", "rank": 78, "score": 53.25090215270318 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include <vector>\n\n#include \"lite/backends/opencl/cl_include.h\"\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n#include \"lite/utils/string.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace opencl {\n\n\n", "file_path": "lite/kernels/opencl/fc_buffer_compute.cc", "rank": 79, "score": 53.250902152703176 }, { "content": "#include <string>\n\n#include <tuple>\n\n#include <unordered_map>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/api/paddle_lite_factory_helper.h\"\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_lite.h\"\n\n#include \"lite/core/target_wrapper.h\"\n\n#include \"lite/utils/all.h\"\n\n#include \"lite/utils/macros.h\"\n\n\n\nusing LiteType = paddle::lite::Type;\n\n\n", "file_path": "lite/core/op_registry.h", "rank": 80, "score": 53.04969156043397 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include <vector>\n\n#include \"lite/backends/opencl/cl_half.h\"\n\n#include \"lite/backends/opencl/cl_include.h\"\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/kernels/opencl/image_helper.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n#include \"lite/utils/string.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace opencl {\n\n\n", "file_path": "lite/kernels/opencl/scale_image_compute.cc", "rank": 81, "score": 53.00435527940007 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <xtcl/xtcl.h>\n\n#include <memory>\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/kernels/npu/bridges/engine.h\"\n\n#include \"lite/kernels/npu/bridges/registry.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace xpu {\n\n\n", "file_path": "lite/kernels/xpu/subgraph_compute.h", "rank": 82, "score": 52.90760967469896 }, { "content": "#include \"lite/api/paddle_use_ops.h\"\n\n#include \"lite/api/paddle_use_passes.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/core/tensor.h\"\n\n\n\n// For training.\n\nDEFINE_string(startup_program_path, \"\", \"\");\n\nDEFINE_string(main_program_path, \"\", \"\");\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\n#ifndef LITE_WITH_LIGHT_WEIGHT_FRAMEWORK\n\nTEST(CXXApi, test) {\n\n const lite::Tensor* out = RunHvyModel();\n\n LOG(INFO) << out << \" memory size \" << out->data_size();\n\n for (int i = 0; i < 10; i++) {\n\n LOG(INFO) << \"out \" << out->data<float>()[i];\n\n }\n\n LOG(INFO) << \"dims \" << out->dims();\n", "file_path": "lite/api/cxx_api_test.cc", "rank": 83, "score": 52.63924623231082 }, { "content": "// for analysis and runtime.\n\n\n\n#include <map>\n\n#include <string>\n\n#include <typeinfo>\n\n#include <unordered_map>\n\n#include <unordered_set>\n\n#include <vector>\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/core/version.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\n// Type is the definition of all the types that supported by the Variable that\n\n// represents as the input and output of an operator or kernel.\n\n// The DNN system is simple, just a list of operators, and the architecture\n\n// can not process that many data types as a compiler, or that will turn out to\n\n// a chaos.\n", "file_path": "lite/core/type_system.h", "rank": 84, "score": 52.59936112077476 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n#include <cuda.h>\n\n#include <cuda_runtime.h>\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/core/context.h\"\n\n#include \"lite/core/tensor.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace cuda {\n\nnamespace math {\n\n\n\ntemplate <typename T>\n", "file_path": "lite/backends/cuda/math/transpose.h", "rank": 85, "score": 52.54822404836966 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <memory>\n\n#include <string>\n\n#include <vector>\n\n#include \"HiAiModelManagerService.h\"\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/kernels/npu/bridges/engine.h\"\n\n#include \"lite/kernels/npu/bridges/registry.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace npu {\n\n\n", "file_path": "lite/kernels/npu/subgraph_compute.h", "rank": 86, "score": 52.438543931546874 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include <gtest/gtest.h>\n\n#include <cmath>\n\n#include <string>\n\n#include \"lite/api/paddle_use_kernels.h\"\n\n#include \"lite/api/paddle_use_ops.h\"\n\n#include \"lite/core/arena/framework.h\"\n\n#include \"lite/tests/utils/fill_data.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n", "file_path": "lite/tests/kernels/dropout_compute_test.cc", "rank": 87, "score": 52.31897135682582 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include <gtest/gtest.h>\n\n#include <cmath>\n\n#include <string>\n\n#include \"lite/api/paddle_use_kernels.h\"\n\n#include \"lite/api/paddle_use_ops.h\"\n\n#include \"lite/core/arena/framework.h\"\n\n#include \"lite/tests/utils/fill_data.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n", "file_path": "lite/tests/kernels/mul_compute_test.cc", "rank": 88, "score": 52.31897135682582 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n#pragma once\n\n\n\n#include <memory>\n\n#include <string>\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/cp_logging.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace opencl {\n\n\n", "file_path": "lite/kernels/opencl/elementwise_add_buffer_compute.h", "rank": 89, "score": 52.28028556559979 }, { "content": "#include \"lite/api/paddle_use_ops.h\"\n\n#include \"lite/api/paddle_use_passes.h\"\n\n#include \"lite/api/test_helper.h\"\n\n#include \"lite/core/op_registry.h\"\n\n\n\nDEFINE_string(input_img_txt_path,\n\n \"\",\n\n \"if set input_img_txt_path, read the img filename as input.\");\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n\nvoid TestModel(const std::vector<Place>& valid_places) {\n\n lite::Predictor predictor;\n\n std::vector<std::string> passes;\n\n predictor.Build(FLAGS_model_dir, \"\", \"\", valid_places, passes);\n\n\n\n auto* input_tensor = predictor.GetInput(0);\n\n input_tensor->Resize(DDim(std::vector<DDim::value_type>({1, 3, 224, 224})));\n\n auto* data = input_tensor->mutable_data<float>();\n", "file_path": "lite/api/test_resnet50_lite_bm.cc", "rank": 90, "score": 52.0477086791038 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n#pragma once\n\n\n\n#include <memory>\n\n#include <string>\n\n#include \"lite/backends/opencl/cl_half.h\"\n\n#include \"lite/core/kernel.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/cp_logging.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace opencl {\n\n\n", "file_path": "lite/kernels/opencl/elementwise_add_image_compute.h", "rank": 91, "score": 51.888252010826065 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include \"lite/kernels/arm/collect_fpn_proposals_compute.h\"\n\n#include <string>\n\n#include <vector>\n\n#include \"lite/backends/arm/math/funcs.h\"\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/core/tensor.h\"\n\n#include \"lite/core/type_system.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace arm {\n\n\n", "file_path": "lite/kernels/arm/collect_fpn_proposals_compute.cc", "rank": 92, "score": 51.4348343304081 }, { "content": " */\n\n\n\n#include <algorithm>\n\n#include <map>\n\n#include <set>\n\n#include <string>\n\n#include <unordered_map>\n\n#include <vector>\n\n#include \"lite/core/framework.pb.h\"\n\n#include \"lite/model_parser/desc_apis.h\"\n\n#include \"lite/utils/all.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace pb {\n\n\n\nusing Attribute =\n\n variant<int, float, bool, std::vector<std::string>, std::vector<int>>;\n\nusing VariableNameMap = std::map<std::string, std::vector<std::string>>;\n\n\n\n/*\n\n * The lite::OpDesc, an light-weight implementation of wrapper of proto::OpDesc.\n\n * Unlike the original one in framework::OpDesc, we remove the local members\n\n * except the desc_, to avoid the inconsistent state, which is normal in the\n\n * original interface and results in bugs.\n\n */\n", "file_path": "lite/model_parser/pb/op_desc.h", "rank": 93, "score": 51.30599064486783 }, { "content": "#include \"lite/kernels/opencl/image_helper.h\"\n\n#include \"lite/operators/op_params.h\"\n\n#include \"lite/utils/replace_stl/stream.h\"\n\n#include \"lite/utils/string.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace kernels {\n\nnamespace opencl {\n\n\n", "file_path": "lite/kernels/opencl/pool_image_compute.cc", "rank": 94, "score": 51.12241246722656 }, { "content": "#include <iomanip>\n\n#include <memory>\n\n#include <string>\n\n#include <unordered_map>\n\n#include <utility>\n\n#include <vector>\n\n#include \"lite/core/op_registry.h\"\n\n#include \"lite/core/program.h\"\n\n#include \"lite/core/scope.h\"\n\n#include \"lite/core/types.h\"\n\n#include \"lite/model_parser/cpp/op_desc.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\nnamespace arena {\n\n\n\n/*\n\n * Init data and prepare the op.\n\n */\n", "file_path": "lite/core/arena/framework.h", "rank": 95, "score": 50.959855015370614 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include \"lite/kernels/cuda/pool_compute.h\"\n\n#include <gtest/gtest.h>\n\n#include <memory>\n\n#include <string>\n\n#include <utility>\n\n#include <vector>\n", "file_path": "lite/kernels/cuda/pool_compute_test.cc", "rank": 96, "score": 50.77834012558882 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#include \"lite/kernels/cuda/dropout_compute.h\"\n\n#include <gtest/gtest.h>\n\n#include <memory>\n\n#include <string>\n\n#include <utility>\n\n#include <vector>\n", "file_path": "lite/kernels/cuda/dropout_compute_test.cc", "rank": 97, "score": 50.77834012558881 }, { "content": "// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n\n\n#pragma once\n\n\n\n#include <algorithm>\n\n#include <functional> // for multiplies\n\n#include <memory>\n\n#include <numeric>\n\n#include <string>\n\n#include <vector>\n\n\n\n#include \"lite/backends/fpga/KD/tensor.hpp\"\n\n#include \"lite/core/memory.h\"\n\n\n\nnamespace paddle {\n\nnamespace lite {\n\n\n", "file_path": "lite/backends/fpga/lite_tensor.h", "rank": 99, "score": 50.61309862687358 } ]
C++
kt-nn/src/main/cpp/LayerImage.cpp
viveret/kotlin-tiny-dnn
0f33d497384fe14b34edaa705642d67a15fadc66
#include "pocketn2.h" extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniConstructor( JNIEnv *env, jobject thiz, jlong width, jlong height, jlong depth, tiny_dnn::image_type format) { auto fn = [&]() { auto size = new shape3d(width, height, depth); return (jlong)(void*) new tiny_dnn::image<unsigned char>(*size, format); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT void JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniResize(JNIEnv *env, jobject thiz, jlong handle, jlong width, jlong height) { auto fn = [&]() { ((tiny_dnn::image<unsigned char> *) handle)->resize(width, height); return true; }; jboolean ret; jniTryCatch(env, fn, ret); } extern "C" JNIEXPORT jbyteArray JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetPixelData(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char>*) handle)->data(); }; std::vector<unsigned char> ret; if (!jniTryCatch(env, fn, ret)) { ret = std::vector<unsigned char>(0); } jbyte* jbyteBuffer = new jbyte[ret.size()]; std::copy(ret.begin(), ret.end(), jbyteBuffer); jbyteArray ret2 = env->NewByteArray((jsize)ret.size()); env->SetByteArrayRegion(ret2, 0, (jsize)ret.size(), jbyteBuffer); return ret2; } extern "C" JNIEXPORT jint JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetFormat(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->type(); }; tiny_dnn::image_type ret; if (jniTryCatch(env, fn, ret)) { return (jint) ret; } else { return -1; } } extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetWidth(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->width(); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetHeight(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->height(); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetDepth(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->depth(); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT jboolean JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniEmpty(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->empty(); }; jboolean ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return (jboolean) false; } }
#include "pocketn2.h" extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniConstructor( JNIEnv *env, jobject thiz, jlong width, jlong height, jlong depth, tiny_dnn::image_type format) { auto fn = [&]() { auto size = new shape3d(width, height, depth); return (jlong)(void*) new tiny_dnn::image<unsigned char>(*size, format); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT void JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniResize(JNIEnv *env, jobject thiz, jlong handle, jlong width, jlong height) { auto fn = [&]() { ((tiny_dnn::image<unsigned char> *) handle)->resize(width, height); return true; }; jboolean ret; jniTryCatch(env, fn, ret); } extern "C" JNIEXPORT jbyteArray JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetPixelData(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char>*) handle)->data(); }; std::vector<unsigned char> ret; if (!jniTryCatch(env, fn, ret))
r); return ret2; } extern "C" JNIEXPORT jint JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetFormat(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->type(); }; tiny_dnn::image_type ret; if (jniTryCatch(env, fn, ret)) { return (jint) ret; } else { return -1; } } extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetWidth(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->width(); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetHeight(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->height(); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT jlong JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniGetDepth(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->depth(); }; jlong ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return -1; } } extern "C" JNIEXPORT jboolean JNICALL Java_com_viveret_tinydnn_data_graphics_LayerImage_jniEmpty(JNIEnv *env, jobject thiz, jlong handle) { auto fn = [&]() { return ((tiny_dnn::image<unsigned char> *) handle)->empty(); }; jboolean ret; if (jniTryCatch(env, fn, ret)) { return ret; } else { return (jboolean) false; } }
{ ret = std::vector<unsigned char>(0); } jbyte* jbyteBuffer = new jbyte[ret.size()]; std::copy(ret.begin(), ret.end(), jbyteBuffer); jbyteArray ret2 = env->NewByteArray((jsize)ret.size()); env->SetByteArrayRegion(ret2, 0, (jsize)ret.size(), jbyteBuffe
function_block-random_span
[ { "content": "class GeneratePackageAction(val size: Int, val includeFitTo: Boolean, val path: String): ProjectAction {\n\n override val name: String = \"@Generate Package\"\n\n override fun doAction(project: NeuralNetProject): OnSelectedResult { return OnSelectedResult(true) }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/project/actions/GeneratePackageAction.kt", "rank": 0, "score": 102494.37675809007 }, { "content": "class BasicTrainingConfig(override val batchSize: Long, override val epochs: Int, override val optimizer: Optimizer, override val dataMethod: DataMethod, override val fitToOutput: Boolean, override val percentToInclude: Double) : TrainingMethod", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/train/BasicTrainingConfig.kt", "rank": 1, "score": 67319.99017134808 }, { "content": "class Sizes {\n\n companion object {\n\n val CNN_TASK_SIZE = 128 // todo: Check this\n\n }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/constants/Sizes.kt", "rank": 2, "score": 52334.01902063993 }, { "content": "class CMUMovieSummaryCorpusFormat(context: Context) : DataSliceReader {\n\n override val openRoles: Array<DataRole>\n\n get() = TODO(\"not implemented\") //To change initializer of created properties use File | Settings | File Templates.\n\n\n\n override fun read(destination: DataValues, offset: Int, amountToRead: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputSelection: InputSelection) {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun getInt(attr: DataAttr): Int? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun getString(attr: DataAttr): String? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 3, "score": 52324.161453783134 }, { "content": "class OnlineMovieReviewSentimentsFormat(context: Context) : DataSliceReader {\n\n override val openRoles: Array<DataRole>\n\n get() = TODO(\"not implemented\") //To change initializer of created properties use File | Settings | File Templates.\n\n\n\n override fun read(destination: DataValues, offset: Int, amountToRead: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputSelection: InputSelection) {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun getInt(attr: DataAttr): Int? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun getString(attr: DataAttr): String? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 4, "score": 52324.161453783134 }, { "content": "class MnistDataSliceFormat(val context: Context) : BufferedSingleDataSliceReader() {\n\n override fun vectReader(role: DataRole): VectReader? = if (role == DataRole.Input)\n\n MnistImageVectReader(true, 2051, context)\n\n else\n\n MnistOutputVectReader(false, 2049, context)\n\n\n\n override fun labelReader(role: DataRole): LabelReader? = if (role == DataRole.InputLabels)\n\n MnistLabelReader(false, 2051, context)\n\n else\n\n MnistLabelReader(false, 2049, context)\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 5, "score": 52144.11684978119 }, { "content": " for (x in 2 until 30) {\n\n vectBuffer[y * 32 + x] = (rawBytes[(y - 2) * 28 + (x - 2)] - 128) / 128.0f\n\n }\n\n vectBuffer[y * 32 + 30] = 0.0f\n\n vectBuffer[y * 32 + 31] = 0.0f\n\n }\n\n } else {\n\n for (i in 0 until vectBuffer.size) {\n\n vectBuffer[i] = (rawBytes[i] - 128) / 128.0f\n\n }\n\n }\n\n destination[offset + vectIndex] = Vect(vectBuffer, outputVectSize)\n\n if (destination[offset + vectIndex].vals.size != outputVectSize) {\n\n throw java.lang.Exception(\"destination[offset + vectIndex].vals.size != outputVectSize\")\n\n }\n\n numVectsRead++\n\n }\n\n return numVectsRead\n\n }\n\n\n\n override val isOpen = true\n\n\n\n override fun close() = this.inputStream.close()\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 6, "score": 50765.524158045824 }, { "content": "\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n var numVectsRead = 0\n\n for (vectIndex in 0 until min(count, destination.size - offset)) {\n\n val n = Companion.read(inputStream, rawBytes, true)\n\n if (n <= 0) {\n\n return numVectsRead\n\n }\n\n\n\n if (outputVectSize != rawBytes.size) {\n\n for (x in 0 until 32) {\n\n vectBuffer[0 * 32 + x] = 0.0f\n\n vectBuffer[1 * 32 + x] = 0.0f\n\n vectBuffer[30 * 32 + x] = 0.0f\n\n vectBuffer[31 * 32 + x] = 0.0f\n\n }\n\n\n\n for (y in 2 until 30) {\n\n vectBuffer[y * 32 + 0] = 0.0f\n\n vectBuffer[y * 32 + 1] = 0.0f\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 7, "score": 50765.266537508636 }, { "content": " if (numLabelsRead < destination.size) {\n\n destination[numLabelsRead] = (buf[v] + 0L)\n\n numLabelsRead++\n\n } else {\n\n break\n\n }\n\n }\n\n } else {\n\n break\n\n }\n\n }\n\n return numLabelsRead\n\n }\n\n\n\n override val isOpen: Boolean = true\n\n\n\n override fun close() = this.inputStream.close()\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 8, "score": 50764.796549137565 }, { "content": "\n\n vectBuffer[labelBuffer[vectIndex].toInt()] = 1.0f\n\n destination[offset + vectIndex] = Vect(vectBuffer, 10)\n\n }\n\n return numVectsRead\n\n }\n\n\n\n override val isOpen = true\n\n\n\n override fun close() = this.inputStream.close()\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 9, "score": 50761.47629584083 }, { "content": " val numItems get() = dims[0]\n\n\n\n fun openIdx(inputStream: BetterInputStream) {\n\n val tmp = resolveCompressionType(inputStream)\n\n this.stream = tmp.info\n\n this.inputStream = DataInputStream(tmp.stream)\n\n\n\n// val buffer = StringBuffer()\n\n// var inputStr = inputStream.readLine()\n\n// while (inputStr.isNotEmpty()) {\n\n// buffer.append(tmp)\n\n// Log.e(\"com.viveret.pocketn2\", inputStr)\n\n// inputStr = inputStream.readLine()\n\n// }\n\n//\n\n// throw UserException(buffer.toString())\n\n\n\n val lastChar = this.stream.name.substring(0, this.stream.name.length - \"-ubyte\".length).last()\n\n this.dims = IntArray(lastChar.toString().toInt())\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 10, "score": 50761.41727393914 }, { "content": " val magicNumber = this.inputStream.readInt()\n\n if (this.magicNumber != magicNumber) {\n\n throw Exception(\"Invalid ${this.javaClass.name} magic number for ${this.stream.name} ($magicNumber != ${this.magicNumber})\")\n\n }\n\n\n\n for (d in 0 until this.dims.size) {\n\n this.dims[d] = this.inputStream.readInt()\n\n }\n\n }\n\n\n\n fun resolveCompressionType(inputStream: BetterInputStream): CompressedStream {\n\n for (comp in CompressionType.values()) {\n\n if (comp.extension == inputStream.source.extension) {\n\n return CompressedStream(comp, inputStream.source, inputStream.currentStream)\n\n }\n\n }\n\n throw Exception(\"Could not resolve compression type for $inputStream\")\n\n }\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 11, "score": 50760.47893832468 }, { "content": "package com.viveret.tinydnn.data.formats\n\n\n\nimport android.content.Context\n\nimport com.viveret.tinydnn.basis.*\n\nimport com.viveret.tinydnn.data.io.InputSelection\n\nimport com.viveret.tinydnn.data.io.LabelReader\n\nimport com.viveret.tinydnn.data.io.VectReader\n\nimport com.viveret.tinydnn.error.UserException\n\nimport com.viveret.tinydnn.project.NeuralNetProject\n\nimport java.io.DataInputStream\n\nimport java.io.InputStream\n\nimport java.lang.IllegalArgumentException\n\nimport java.util.zip.GZIPInputStream\n\nimport kotlin.math.min\n\n\n\n@Mime([\"image/*\", \"application/gzip\"])\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 12, "score": 50757.850088096624 }, { "content": " for (vectIndex in 0 until numberOfVectsToRead) {\n\n val line = this.readLine()\n\n val summaryString = if (line.size > 9) line[9].toLowerCase() else \"\"\n\n val summaryText = FloatArray(if (count > 0) count else summaryString.length, if (normalizeBytes) {\n\n { i -> if (i < summaryString.length) summaryString[i].toFloat() / Char.MAX_VALUE.toFloat() else 0.0f }\n\n } else {\n\n { i -> if (i < summaryString.length) summaryString[i].toFloat() else 0.0f }\n\n })\n\n destination[vectIndex] = Vect(summaryText, summaryText.size)\n\n numVectsRead++\n\n }\n\n return numVectsRead\n\n }\n\n\n\n override val isOpen = true\n\n\n\n override fun close() = this.inputStream.close()\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 13, "score": 50513.05513145763 }, { "content": " val line = this.readLine()\n\n val summaryString = if (line.isNotEmpty()) line[0] else \"\"\n\n val summaryText = FloatArray(if (count > 0) count.toInt() else summaryString.length, if (normalizeBytes) {\n\n { i -> if (i < summaryString.length) summaryString[i].toFloat() / Char.MAX_VALUE.toFloat() else 0.0f }\n\n } else {\n\n { i -> if (i < summaryString.length) summaryString[i].toFloat() else 0.0f }\n\n })\n\n destination[vectIndex] = Vect(summaryText, summaryText.size)\n\n numVectsRead++\n\n }\n\n return numVectsRead\n\n }\n\n\n\n override val isOpen = true\n\n\n\n override fun close() = this.inputStream.close()\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 14, "score": 50512.37041675875 }, { "content": " for (vectIndex in 0 until numberOfVectsToRead) {\n\n val line = this.readLine()\n\n if (line.size > 8) {\n\n val categoriesJsonArray = line[8]\n\n val categories = outputLabels.map { x -> categoriesJsonArray.indexOf(x, ignoreCase = true) }\n\n val probabilities = FloatArray(categories.size) { i -> if (categories[i] >= 0) 1.0f else 0.0f}\n\n destination[numVectsRead] = Vect(probabilities, probabilities.size)\n\n numVectsRead++\n\n }\n\n }\n\n return numVectsRead\n\n }\n\n\n\n override val isOpen: Boolean = true\n\n\n\n override fun close() = this.inputStream.close()\n\n }\n\n\n\n companion object {\n\n val outputLabels = arrayOf(\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 15, "score": 50512.0435685665 }, { "content": " for (vectIndex in 0 until numberOfVectsToRead) {\n\n val line = this.readLine()\n\n if (line.size > 1) {\n\n val probabilities = FloatArray(1) { line[1].toFloat() }\n\n destination[numVectsRead] = Vect(probabilities, probabilities.size)\n\n numVectsRead++\n\n }\n\n }\n\n } catch (e: EOFException) {\n\n this.isOpen = false\n\n this.close()\n\n }\n\n return numVectsRead\n\n }\n\n\n\n override var isOpen: Boolean = true\n\n\n\n override fun close() = this.inputStream.close()\n\n }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 16, "score": 50511.20958010563 }, { "content": " \"Legal\",\n\n \"LGBT\",\n\n \"Life\",\n\n \"Linguistics\",\n\n \"Literature\",\n\n \"Malayalam\",\n\n \"Manners\",\n\n \"Marriage\",\n\n \"Martial\",\n\n \"Media\",\n\n \"Medical\",\n\n \"Melodrama\",\n\n \"Mockumentary\",\n\n \"Monster\",\n\n \"Motion\",\n\n \"Movie\",\n\n \"Music\",\n\n \"Mystery\",\n\n \"Natural\",\n\n \"New\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 17, "score": 50507.91476430281 }, { "content": " \"Action\",\n\n \"Adaptation\",\n\n \"Adventure\",\n\n \"Age\",\n\n \"Americana\",\n\n \"Amp\",\n\n \"Animation\",\n\n \"Anime\",\n\n \"Anthology\",\n\n \"Anthropology\",\n\n \"Archaeology\",\n\n \"Art\",\n\n \"Auto\",\n\n \"Avantgarde\",\n\n \"Backstage\",\n\n \"Biker\",\n\n \"Biographical\",\n\n \"Biography\",\n\n \"Biopic\",\n\n \"Black\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 18, "score": 50507.86634557604 }, { "content": " \"Blackandwhite\",\n\n \"Blaxploitation\",\n\n \"Bmovie\",\n\n \"Bollywood\",\n\n \"British\",\n\n \"Buddy\",\n\n \"Childhood\",\n\n \"Childrens\",\n\n \"ChildrensFamily\",\n\n \"Chinese\",\n\n \"Christian\",\n\n \"Christmas\",\n\n \"Cinema\",\n\n \"Clef\",\n\n \"CMovie\",\n\n \"Combat\",\n\n \"Comedy\",\n\n \"Coming\",\n\n \"Computer\",\n\n \"Concert\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 19, "score": 50507.80089700449 }, { "content": "// vals.fitTo!!.format = this\n\n// vals\n\n// } else {\n\n// val vals = TrainingDataValues(inputVects, inputLabels)\n\n// vals.format = this\n\n// vals\n\n// }\n\n// }\n\n\n\n fun readLabels(purpose: DataRole, file: File): ArrayList<Long> {\n\n throw Exception()\n\n }\n\n// override val inputVectReader = SummaryVectReader(true)\n\n// override val inputLabelReader\n\n// get() = throw Exception()\n\n// override val fitToVectReader = MovieMetaDataReader(false)\n\n// override val fitToLabelReader\n\n// get() = throw Exception()\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 20, "score": 50506.99854023048 }, { "content": "// vals.format = this\n\n// vals.fitTo!!.format = this\n\n// vals\n\n// } else {\n\n// val vals = TrainingDataValues(inputVects, inputLabels)\n\n// vals.format = this\n\n// vals\n\n// }\n\n// }\n\n\n\n fun readLabels(purpose: DataRole, file: File, metaInfo: Stream): ArrayList<Long> {\n\n throw Exception()\n\n }\n\n\n\n// override val inputVectReader = ReviewVectReader(true)\n\n// override val inputLabelReader\n\n// get() = throw Exception()\n\n// override val fitToVectReader = SentimentVectReader(false)\n\n// override val fitToLabelReader\n\n// get() = throw Exception()\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 21, "score": 50506.92485345919 }, { "content": "// val inputVects = readVects(DataRole.Input, tasks.getValue(inputFile), inputFile, this.inputVectReader, project!!.get().in_data_size())\n\n// val inputLabels = if (labelFile != null && tasks.containsKey(labelFile)) readLabels(DataRole.InputLabels, tasks.getValue(labelFile)) else ArrayList()\n\n// val vals = DataValues(inputVects, inputLabels)\n\n// vals.format = this\n\n// return vals\n\n// }\n\n\n\n// override fun read(tasks: Map<Stream, File>, dataSuite: StreamPackage, project: NeuralNetProject?): TrainingDataValues? {\n\n// val inputFile = dataSuite.streams.getValue(DataRole.Input)\n\n// val labelFile = dataSuite.streams[DataRole.InputLabels]\n\n// val fitToFile = dataSuite.streams[DataRole.FitTo]\n\n// val fitToLabelsFile = dataSuite.streams[DataRole.FitToLabels]\n\n// val inputVects = readVects(DataRole.Input, tasks.getValue(inputFile), inputFile, this.inputVectReader, project!!.get().in_data_size())\n\n// val inputLabels = if (labelFile != null && tasks.containsKey(labelFile)) readLabels(DataRole.InputLabels, tasks.getValue(labelFile)) else ArrayList()\n\n//\n\n// return if (fitToFile != null && tasks.containsKey(fitToFile)) {\n\n// val fitToVects = readVects(DataRole.FitTo, tasks.getValue(fitToFile), fitToFile, this.fitToVectReader, project.get().out_data_size())\n\n// val fitToLabels = if (fitToLabelsFile != null && tasks.containsKey(fitToLabelsFile)) readLabels(DataRole.FitToLabels, tasks.getValue(fitToLabelsFile)) else ArrayList()\n\n// val vals = TrainingDataValues(inputVects, inputLabels, fitToVects, fitToLabels)\n\n// vals.format = this\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 22, "score": 50506.86848410764 }, { "content": "// val inputVects = readVects(DataRole.Input, tasks.getValue(inputFile), inputFile, this.inputVectReader, project!!.get().in_data_size())\n\n// val inputLabels = if (labelFile != null && tasks.containsKey(labelFile)) readLabels(DataRole.InputLabels, tasks.getValue(labelFile), labelFile) else ArrayList()\n\n// val vals = DataValues(inputVects, inputLabels)\n\n// vals.format = this\n\n// return vals\n\n// }\n\n\n\n// override fun read(tasks: Map<Stream, File>, dataSuite: StreamPackage, project: NeuralNetProject?): TrainingDataValues? {\n\n// val inputFile = dataSuite.streams.getValue(DataRole.Input)\n\n// val labelFile = dataSuite.streams[DataRole.InputLabels]\n\n// val fitToFile = dataSuite.streams[DataRole.FitTo]\n\n// val fitToLabelsFile = dataSuite.streams[DataRole.FitToLabels]\n\n//\n\n// val inputVects = readVects(DataRole.Input, tasks.getValue(inputFile), inputFile, this.inputVectReader, project!!.get().in_data_size())\n\n// val inputLabels = if (labelFile != null && tasks.containsKey(labelFile)) readLabels(DataRole.InputLabels, tasks.getValue(labelFile), labelFile) else ArrayList()\n\n//\n\n// return if (fitToFile != null && tasks.containsKey(fitToFile)) {\n\n// val fitToVects = readVects(DataRole.FitTo, tasks.getValue(fitToFile), fitToFile, this.fitToVectReader, project.get().out_data_size())\n\n// val fitToLabels = if (fitToLabelsFile != null && tasks.containsKey(fitToLabelsFile)) readLabels(DataRole.FitToLabels, tasks.getValue(fitToLabelsFile), fitToLabelsFile) else ArrayList()\n\n// val vals = TrainingDataValues(inputVects, inputLabels, fitToVects, fitToLabels)\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 23, "score": 50506.8448113798 }, { "content": " \"Noir\",\n\n \"Parody\",\n\n \"Period\",\n\n \"Piece\",\n\n \"Plague\",\n\n \"Political\",\n\n \"Porn\",\n\n \"PreCode\",\n\n \"Prison\",\n\n \"Problem\",\n\n \"Propaganda\",\n\n \"Psychological\",\n\n \"Racing\",\n\n \"Realism\",\n\n \"Release\",\n\n \"Religious\",\n\n \"Remake\",\n\n \"Road\",\n\n \"Roadshow\",\n\n \"Rockumentary\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 24, "score": 50504.10730824937 }, { "content": "package com.viveret.tinydnn.data.formats\n\n\n\nimport android.content.Context\n\nimport com.viveret.tinydnn.basis.*\n\nimport com.viveret.tinydnn.data.DataValues\n\nimport com.viveret.tinydnn.data.io.*\n\nimport com.viveret.tinydnn.data.train.DataSliceReader\n\nimport com.viveret.tinydnn.project.NeuralNetProject\n\nimport java.io.EOFException\n\nimport java.io.File\n\nimport java.util.*\n\nimport java.util.regex.Pattern\n\n\n\n@Mime(arrayOf(\"text/csv\"))\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 25, "score": 50504.10730824937 }, { "content": " \"Cop\",\n\n \"Costume\",\n\n \"Courtroom\",\n\n \"Creature\",\n\n \"Crime\",\n\n \"Cult\",\n\n \"Culture\",\n\n \"Dance\",\n\n \"Delinquency\",\n\n \"Detective\",\n\n \"Disaster\",\n\n \"Disaster\",\n\n \"Docudrama\",\n\n \"Documentary\",\n\n \"Dogme\",\n\n \"Domestic\",\n\n \"Doomsday\",\n\n \"Drama\",\n\n \"Dystopia\",\n\n \"Educational\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 26, "score": 50504.10730824937 }, { "content": " \"Romance\",\n\n \"Romantic\",\n\n \"Samurai\",\n\n \"Satire\",\n\n \"Science\",\n\n \"SciFi\",\n\n \"Screwball\",\n\n \"Serial\",\n\n \"Sex\",\n\n \"Sexploitation\",\n\n \"Short\",\n\n \"Silent\",\n\n \"Sink\",\n\n \"Slapstick\",\n\n \"Slasher\",\n\n \"Slice\",\n\n \"Social\",\n\n \"Society\",\n\n \"Softcore\",\n\n \"Sorcery\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 27, "score": 50504.10730824937 }, { "content": "package com.viveret.tinydnn.data.formats\n\n\n\nimport android.content.Context\n\nimport com.viveret.tinydnn.basis.*\n\nimport com.viveret.tinydnn.data.DataValues\n\nimport com.viveret.tinydnn.data.io.*\n\nimport com.viveret.tinydnn.data.train.DataSliceReader\n\nimport com.viveret.tinydnn.project.NeuralNetProject\n\nimport java.io.File\n\nimport java.util.*\n\n\n\n@Mime([\"text/plain\"])\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 28, "score": 50504.10730824937 }, { "content": " \"Gothic\",\n\n \"Gross\",\n\n \"Grossout\",\n\n \"Gulf\",\n\n \"Heavenly\",\n\n \"Heist\",\n\n \"Historical\",\n\n \"History\",\n\n \"Holiday\",\n\n \"Hollywood\",\n\n \"Horror\",\n\n \"Hybrid\",\n\n \"Indie\",\n\n \"Interest\",\n\n \"Issues\",\n\n \"Japanese\",\n\n \"Juvenile\",\n\n \"Kitchen\",\n\n \"Language\",\n\n \"Law\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 29, "score": 50504.10730824937 }, { "content": " override fun getBoolean(attr: DataAttr): Boolean? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Boolean {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun vectReader(role: DataRole): VectReader? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun labelReader(role: DataRole): LabelReader? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n// override fun getDataValues(tasks: Map<Stream, File>, dataSuite: StreamPackage, project: NeuralNetProject?): DataValues {\n\n// val inputFile = dataSuite.streams.getValue(DataRole.Input)\n\n// val labelFile = dataSuite.streams[DataRole.InputLabels]\n\n//\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 30, "score": 50504.10730824937 }, { "content": " \"Space\",\n\n \"Spaghetti\",\n\n \"Sports\",\n\n \"Spy\",\n\n \"Stoner\",\n\n \"Stop\",\n\n \"Story\",\n\n \"Superhero\",\n\n \"Supernatural\",\n\n \"Surrealism\",\n\n \"Suspense\",\n\n \"Sword\",\n\n \"Teen\",\n\n \"Television\",\n\n \"Theatrical\",\n\n \"Themed\",\n\n \"Thriller\",\n\n \"Time\",\n\n \"Tollywood\",\n\n \"Tragedy\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 31, "score": 50504.10730824937 }, { "content": " \"Tragicomedy\",\n\n \"Travel\",\n\n \"War\",\n\n \"Wave\",\n\n \"Western\",\n\n \"Women\",\n\n \"World\"\n\n )\n\n}\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 32, "score": 50504.10730824937 }, { "content": " override fun getBoolean(attr: DataAttr): Boolean? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Boolean {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun vectReader(role: DataRole): VectReader? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun labelReader(role: DataRole): LabelReader? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n//\n\n// override fun getDataValues(tasks: Map<Stream, File>, dataSuite: StreamPackage, project: NeuralNetProject?): DataValues {\n\n// val inputFile = dataSuite.streams.getValue(DataRole.Input)\n\n// val labelFile = dataSuite.streams[DataRole.InputLabels]\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 33, "score": 50504.10730824937 }, { "content": " \"Ensemble\",\n\n \"Epic\",\n\n \"Erotic\",\n\n \"Errors\",\n\n \"Escape\",\n\n \"Existentialism\",\n\n \"Experimental\",\n\n \"Family\",\n\n \"FamilyOriented\",\n\n \"Fan\",\n\n \"Fantasy\",\n\n \"Feature\",\n\n \"Feminist\",\n\n \"Fiction\",\n\n \"Filipino\",\n\n \"Future\",\n\n \"Gangster\",\n\n \"Gay\",\n\n \"Gender\",\n\n \"Giallo\",\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 34, "score": 50504.10730824937 }, { "content": "enum class LayerImageFormat {\n\n GrayScale,\n\n RGB,\n\n BGR\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/enums/LayerImageFormat.kt", "rank": 35, "score": 50252.888872172014 }, { "content": "enum class FileFormat(val stringResId: Int) {\n\n Binary(R.string.binary),\n\n PortableBinary(R.string.portable_binary),\n\n Json(R.string.json)\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/enums/FileFormat.kt", "rank": 36, "score": 49514.0084661761 }, { "content": " enum class CompressionType(val extension: String) {\n\n NONE(\"\"),\n\n GZIP(\".gz\"),\n\n ZIP(\".zip\"),\n\n TAR(\".tar\"),\n\n }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 37, "score": 49272.51986522511 }, { "content": "class PowerLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_power\", \"\")\n\n constructor(@UserField(UserFields.PreviousLayer) prevLayer: LayerBase,\n\n @CustomUserField(\"@factor\", \"@factor_hint\", InputType.TYPE_NUMBER_FLAG_DECIMAL) factor: Double,\n\n @CustomUserField(\"@scale\", \"@scale_hint\", InputType.TYPE_NUMBER_FLAG_DECIMAL) scale: Double) :\n\n this(staticConstructor(prevLayer.nativeObjectHandle, factor, scale))\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(prevLayer: Long, factor: Double, scale: Double): Long\n\n\n\n fun attach(handle: Long): PowerLayer = PowerLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/PowerLayer.kt", "rank": 38, "score": 48807.850196483174 }, { "content": "class LrnLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n /**\n\n * @param in_width [in] the width of input data\n\n * @param in_height [in] the height of input data\n\n * @param local_size [in] the number of channels(depths) to sum over\n\n * @param alpha [in] the scaling parameter (Fill to caffe's LRN)\n\n * @param beta [in] the scaling parameter (Fill to caffe's LRN)\n\n *\n\n float_t alpha = 1.0,\n\n float_t beta = 5.0,\n\n norm_region region = norm_region::across_channels\n\n **/\n\n @UserConstructor(\"@layer_lrn\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @CustomUserField(\"@local_size\", \"@local_size_hint\", InputType.TYPE_CLASS_NUMBER) local_size: Long,\n\n @CustomUserField(\"@alpha\", \"@alpha_hint\", InputType.TYPE_NUMBER_FLAG_DECIMAL) alpha: Double,\n\n @CustomUserField(\"@beta\", \"@beta_hint\", InputType.TYPE_NUMBER_FLAG_DECIMAL) beta: Double) :\n\n this(staticConstructor(in_width, in_height, local_size, alpha, beta))\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/LrnLayer.kt", "rank": 39, "score": 48807.850196483174 }, { "content": "class DropoutLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n /**\n\n * @param in_dim [Long] number of elements of the input\n\n * @param dropout_rate [Double] (0-1) fraction of the input units to be dropped\n\n **/\n\n @UserConstructor(\"@layer_dropout\", \"\")\n\n constructor(@UserField(UserFields.InDim) in_dim: Long,\n\n @CustomUserField(\"@dropout_rate\", \"@dropout_rate_hint\", 0) dropout_rate: Double) :\n\n this(staticConstructor(in_dim, dropout_rate))\n\n\n\n @UserConstructor(\"@layer_dropout\", \"\")\n\n constructor(@UserField(UserFields.PreviousLayer) prevLayer: LayerBase,\n\n @CustomUserField(\"@dropout_rate\", \"@dropout_rate_hint\", 0) dropout_rate: Double) :\n\n this(prevLayer.out_data_size(), dropout_rate)\n\n\n\n companion object {\n\n /**\n\n * @param in_dim [Long] number of elements of the input\n\n * @param dropout_rate [Double] (0-1) fraction of the input units to be dropped\n\n */\n\n @JvmStatic\n\n external fun staticConstructor(in_dim: Long, dropout_rate: Double): Long\n\n\n\n fun wrap(handle: Long): DropoutLayer = DropoutLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/DropoutLayer.kt", "rank": 40, "score": 48807.850196483174 }, { "content": "class ConvolutionalLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_conv\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.WindowSize) window_size: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @UserField(UserFields.OutChannels) out_channels: Long,\n\n @UserField(UserFields.Padding) pad_type: Padding,\n\n @UserField(UserFields.HasBias) has_bias: Boolean,\n\n @UserField(UserFields.StrideX) w_stride: Long,\n\n @UserField(UserFields.StrideY) h_stride: Long) : this(staticConstructor(in_width, in_height, window_size, window_size, in_channels, out_channels, pad_type.ordinal, has_bias, w_stride, h_stride)) {\n\n // backend_t backend_type = core::default_engine()\n\n }\n\n\n\n @UserConstructor(\"@layer_conv\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.WindowSize) window_size: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @UserField(UserFields.OutChannels) out_channels: Long,\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/ConvolutionalLayer.kt", "rank": 41, "score": 48807.850196483174 }, { "content": "class DeconvolutionalLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_deconv\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.WindowSize) window_size: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @UserField(UserFields.OutChannels) out_channels: Long,\n\n @UserField(UserFields.Padding) pad_type: Padding,\n\n @UserField(UserFields.HasBias) has_bias: Boolean,\n\n @UserField(UserFields.StrideX) w_stride: Long,\n\n @UserField(UserFields.StrideY) h_stride: Long) : this(staticConstructor(in_width, in_height, window_size, in_channels, out_channels, pad_type.ordinal, has_bias, w_stride, h_stride)) {\n\n // backend_t backend_type = core::default_engine()\n\n }\n\n\n\n @UserConstructor(\"@layer_deconv\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.WindowSize) window_size: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @UserField(UserFields.OutChannels) out_channels: Long,\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/DeconvolutionalLayer.kt", "rank": 42, "score": 48807.850196483174 }, { "content": "class TanhLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_tanh\", \"\")\n\n constructor() : this(staticConstructor())\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(): Long\n\n\n\n fun attach(handle: Long): TanhLayer = TanhLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/TanhLayer.kt", "rank": 43, "score": 48807.850196483174 }, { "content": "class AsinhLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_asinh\", \"\")\n\n constructor() : this(staticConstructor())\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(): Long\n\n\n\n fun attach(handle: Long): AsinhLayer = AsinhLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/AsinhLayer.kt", "rank": 44, "score": 48807.850196483174 }, { "content": "class SigmoidLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_sigmoid\", \"\")\n\n constructor() : this(staticConstructor())\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(): Long\n\n\n\n fun attach(handle: Long): SigmoidLayer = SigmoidLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/SigmoidLayer.kt", "rank": 45, "score": 48807.850196483174 }, { "content": "class RecurrentLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle)\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/RecurrentLayer.kt", "rank": 46, "score": 48807.850196483174 }, { "content": "class LinearLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n /**\n\n * @param dim [in] number of elements\n\n * @param scale [in] factor by which to multiply\n\n * @param bias [in] bias term\n\n **/\n\n @UserConstructor(\"@layer_linear\", \"\")\n\n constructor(@UserField(UserFields.InDim) dim: Long,\n\n @CustomUserField(\"@scale\", \"@scale_hint\", InputType.TYPE_NUMBER_FLAG_DECIMAL) scale: Double,\n\n @UserField(UserFields.Bias) bias: Double) :\n\n this(staticConstructor(dim, scale, bias)) {\n\n // backend_t backend_type = core::default_engine()\n\n }\n\n\n\n /**\n\n * @param dim [in] number of elements\n\n * @param scale [in] factor by which to multiply\n\n * @param bias [in] bias term\n\n **/\n\n @UserConstructor(\"@layer_linear\", \"\")\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/LinearLayer.kt", "rank": 47, "score": 48807.850196483174 }, { "content": "class SliceLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_slice\", \"\")\n\n constructor(@UserField(UserFields.PreviousLayer) prevLayer: LayerBase,\n\n @CustomUserField(\"@slice_type\", \"@slice_type_hint\", InputType.TYPE_CLASS_NUMBER) slice_type: Long,\n\n @CustomUserField(\"@num_outputs\", \"@num_outputs_hint\", InputType.TYPE_CLASS_NUMBER) num_outputs: Long) :\n\n this(staticConstructor(prevLayer.nativeObjectHandle, slice_type, num_outputs))\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(prevLayer: Long, slice_type: Long, num_outputs: Long): Long\n\n\n\n fun wrap(handle: Long): SliceLayer = SliceLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/SliceLayer.kt", "rank": 48, "score": 48807.850196483174 }, { "content": "class AverageUnpoolingLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n// average_unpooling_layer\n\n\n\n /**\n\n * @param in_width [in] width of input image\n\n * @param in_height [in] height of input image\n\n * @param in_channels [in] the number of input image channels(depth)\n\n * @param pool_size [in] factor by which to downscale\n\n */\n\n @UserConstructor(\"@layer_avg_unpool\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @UserField(UserFields.PoolSize) pool_size: Long) : this(staticConstructor(in_width, in_height, in_channels, pool_size))\n\n\n\n /**\n\n * @param in_width [in] width of input image\n\n * @param in_height [in] height of input image\n\n * @param in_channels [in] the number of input image channels(depth)\n\n * @param pool_size [in] factor by which to downscale\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/AverageUnpoolingLayer.kt", "rank": 49, "score": 48345.29684132943 }, { "content": "class FullyConnectedLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_fc\", \"\")\n\n constructor(@UserField(UserFields.InDim) in_dim: Long,\n\n @UserField(UserFields.OutDim) out_dim: Long,\n\n @UserField(UserFields.HasBias) has_bias: Boolean) : this(staticConstructor(in_dim, out_dim, has_bias))\n\n\n\n @UserConstructor(\"@layer_fc\", \"\")\n\n constructor(@UserField(UserFields.PreviousLayer) prevLayer: LayerBase,\n\n @UserField(UserFields.OutDim) out_dim: Long,\n\n @UserField(UserFields.HasBias) has_bias: Boolean) : this(prevLayer.out_data_size(), out_dim, has_bias)\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(in_dim: Long,\n\n out_dim: Long,\n\n has_bias: Boolean): Long\n\n\n\n fun wrap(handle: Long): FullyConnectedLayer = FullyConnectedLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/FullyConnectedLayer.kt", "rank": 50, "score": 48345.29684132943 }, { "content": "class BatchNormLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n /**\n\n * @param prev_layer [LayerBase] previous layer to be connected with this layer\n\n * @param epsilon [Double] small positive value to avoid zero-division\n\n * @param momentum [Double] momentum in the computation of the exponential average of the mean/stddev of the data\n\n **/\n\n @UserConstructor(\"@layer_batch_norm\", \"\")\n\n constructor(@UserField(UserFields.PreviousLayer) prev_layer: LayerBase,\n\n @CustomUserField(\"@epsilon\", \"@epsilon_hint\", InputType.TYPE_NUMBER_FLAG_DECIMAL) epsilon: Double,\n\n @CustomUserField(\"@momentum\", \"@momentum_hint\", InputType.TYPE_NUMBER_FLAG_DECIMAL) momentum: Double) :\n\n this(staticConstructor(prev_layer.nativeObjectHandle, epsilon, momentum))\n\n\n\n /**\n\n * @param prev_layer [LayerBase] previous layer to be connected with this layer\n\n **/\n\n @UserConstructor(\"@layer_batch_norm\", \"\")\n\n constructor(@UserField(UserFields.PreviousLayer) prev_layer: LayerBase) :\n\n this(staticConstructor(prev_layer.nativeObjectHandle, 0.00001, 0.999))\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(prev_layer: Long, epsilon: Double, momentum: Double): Long\n\n\n\n fun attach(handle: Long): BatchNormLayer = BatchNormLayer(handle) // batch_normalization_layer\n\n }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/BatchNormLayer.kt", "rank": 51, "score": 48345.29684132943 }, { "content": "class SoftMaxLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_soft_max\", \"\")\n\n constructor(@UserField(UserFields.InDim) in_dim: Long,\n\n @UserField(UserFields.OutDim) out_dim: Long) : this(staticConstructor(in_dim, out_dim))\n\n\n\n @UserConstructor(\"@layer_soft_max\", \"\")\n\n constructor(@UserField(UserFields.InWidth) width: Long,\n\n @UserField(UserFields.InHeight) height: Long,\n\n @CustomUserField(\"@nmaps\", \"@nmaps_hint\", InputType.TYPE_CLASS_NUMBER) nmaps: Long) : this(\n\n staticConstructor(width, height, nmaps)\n\n )\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(inDim: Long, outDim: Long): Long\n\n\n\n @JvmStatic\n\n external fun staticConstructor(width: Long, height: Long, inChannels: Long): Long\n\n\n\n fun attach(handle: Long): SoftMaxLayer = SoftMaxLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/SoftMaxLayer.kt", "rank": 52, "score": 48345.29684132943 }, { "content": "class ReLuLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n @UserConstructor(\"@layer_relu\", \"\")\n\n constructor(@UserField(UserFields.InWidth) width: Long,\n\n @UserField(UserFields.InHeight) height: Long,\n\n @CustomUserField(\"@nmaps\", \"@nmaps_hint\", InputType.TYPE_CLASS_NUMBER) nmaps: Long) : this(\n\n staticConstructor(width, height, nmaps)\n\n )\n\n\n\n companion object {\n\n @JvmStatic\n\n external fun staticConstructor(width: Long, height: Long, nmaps: Long): Long\n\n\n\n fun attach(handle: Long): ReLuLayer = ReLuLayer(handle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/ReLuLayer.kt", "rank": 53, "score": 48345.29684132943 }, { "content": "class AveragePoolingLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n /**\n\n * @param in_width [in] width of input image\n\n * @param in_height [in] height of input image\n\n * @param in_channels [in] the number of input image channels(depth)\n\n * @param pool_size [in] factor by which to downscale\n\n */\n\n @UserConstructor(\"@layer_avg_pool\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @UserField(UserFields.PoolSize) pool_size: Long) : this(staticConstructor(in_width, in_height, in_channels, pool_size))\n\n\n\n /**\n\n * @param in_width [in] width of input image\n\n * @param in_height [in] height of input image\n\n * @param in_channels [in] the number of input image channels(depth)\n\n * @param pool_size [in] factor by which to downscale\n\n */\n\n @UserConstructor(\"@layer_avg_pool\", \"\")\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/AveragePoolingLayer.kt", "rank": 54, "score": 48345.29684132943 }, { "content": "class MaxUnpoolingLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n /**\n\n * @param in_width [in] width of input image\n\n * @param in_height [in] height of input image\n\n * @param in_channels [in] the number of input image channels(depth)\n\n * @param pooling_size [in] factor by which to downscale\n\n * @param stride [in] interval at which to apply the filters to the input\n\n **/\n\n @UserConstructor(\"@layer_max_unpool\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @CustomUserField(\"@unpooling_size\", \"@unpool_size_hint\", InputType.TYPE_CLASS_NUMBER) unpooling_size: Long,\n\n @UserField(UserFields.Stride) stride: Long) :\n\n this(staticConstructor(in_width, in_height, in_channels, unpooling_size, stride))\n\n\n\n companion object {\n\n\n\n /**\n\n * @param in_width [in] width of input image\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/MaxUnpoolingLayer.kt", "rank": 55, "score": 48345.29684132943 }, { "content": "class MaxPoolingLayer private constructor(nativeObjectHandle: Long) : LayerBase(nativeObjectHandle) {\n\n /**\n\n * @param in_width [in] width of input image\n\n * @param in_height [in] height of input image\n\n * @param in_channels [in] the number of input image channels(depth)\n\n * @param pooling_size [in] factor by which to downscale\n\n **/\n\n @UserConstructor(\"@layer_max_pool\", \"\")\n\n constructor(@UserField(UserFields.InWidth) in_width: Long,\n\n @UserField(UserFields.InHeight) in_height: Long,\n\n @UserField(UserFields.InChannels) in_channels: Long,\n\n @UserField(UserFields.PoolSize) pooling_size: Long) :\n\n this(staticConstructor(in_width, in_height, in_channels, pooling_size))\n\n\n\n\n\n\n\n /**\n\n * @param in_width [in] width of input image\n\n * @param in_height [in] height of input image\n\n * @param in_channels [in] the number of input image channels(depth)\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/MaxPoolingLayer.kt", "rank": 56, "score": 48345.29684132943 }, { "content": " class MnistLabelReader(normalizeBytes: Boolean, magicNumber: Int, context: Context) :\n\n IdxReader(normalizeBytes, magicNumber, context), LabelReader {\n\n override val supportsSeek: Boolean = false\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputStream: BetterInputStream) {\n\n this.openIdx(inputStream)\n\n }\n\n\n\n override fun read(destination: Array<Long>, offset: Int, count: Int): Int {\n\n var numLabelsRead = 0\n\n val buf = ByteArray(min(count, destination.size))\n\n\n\n while (numLabelsRead < destination.size) {\n\n val n = inputStream.read(buf)\n\n if (n > 0) {\n\n for (v in 0 until n) {\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 57, "score": 48099.56921589261 }, { "content": " class MnistImageVectReader(normalizeBytes: Boolean, magicNumber: Int, context: Context) :\n\n IdxReader(normalizeBytes, magicNumber, context), VectReader {\n\n override val supportsSeek: Boolean = false\n\n val outputVectSize = 32 * 32\n\n private lateinit var rawBytes: ByteArray\n\n val width get() = dims[1]\n\n val height get() = dims[2]\n\n\n\n val vectBuffer = FloatArray(outputVectSize)\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int =\n\n inputStream.skipBytes(rawBytes.size * offset) / rawBytes.size\n\n\n\n override fun open(inputStream: BetterInputStream) {\n\n this.openIdx(inputStream)\n\n rawBytes = ByteArray(width * height)\n\n if (rawBytes.isEmpty()) {\n\n throw java.lang.Exception(\"Invalid elementCount (dims: ${dims.joinToString(\", \")})\")\n\n }\n\n }\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 58, "score": 47871.64873760177 }, { "content": " class MnistOutputVectReader(normalizeBytes: Boolean, magicNumber: Int, context: Context) :\n\n IdxReader(normalizeBytes, magicNumber, context), VectReader {\n\n\n\n val outputVectSize = 10\n\n val vectBuffer = FloatArray(outputVectSize)\n\n override val supportsSeek: Boolean = false\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int =\n\n inputStream.skipBytes(offset) // * outputVectSize\n\n\n\n override fun open(inputStream: BetterInputStream) = this.openIdx(inputStream)\n\n\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n val labelBuffer = ByteArray(min(count, destination.size - offset))\n\n val numVectsRead = Companion.read(inputStream, labelBuffer, false)\n\n\n\n for (vectIndex in 0 until numVectsRead) {\n\n for (i in 0 until vectBuffer.size) {\n\n vectBuffer[i] = 0.0f\n\n }\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 59, "score": 47871.64873760177 }, { "content": "class SaveConfig(val outputFile: File, val saveFormat: FileFormat, val saveWhat: ContentType) {\n\n override fun toString(): String = \"$saveWhat as $saveFormat at ${outputFile.absolutePath}\"\n\n private var myIsSaved = false\n\n\n\n val isSaved\n\n get() = this.myIsSaved\n\n\n\n fun saved() {\n\n this.myIsSaved = true\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/SaveConfig.kt", "rank": 60, "score": 47871.64873760177 }, { "content": "enum class DataMethod(val stringResId: Int, val minInSize: Int, val maxInSize: Int = Int.MAX_VALUE) {\n\n BinaryGate(R.string.data_method_binary_gate, 2, 3),\n\n TextFile(R.string.data_method_text_file, 1, Int.MAX_VALUE),\n\n BinaryFile(R.string.data_method_binary_file, 1),\n\n Camera(R.string.data_method_camera, 9),\n\n Microphone(R.string.data_method_microphone, Int.MAX_VALUE),\n\n Sensors(R.string.data_method_sensors, Int.MAX_VALUE),\n\n GPS(R.string.data_method_gps, Int.MAX_VALUE),\n\n Canvas(R.string.data_method_canvas, 9);\n\n\n\n fun supports(inSize: Long): Boolean = this.minInSize <= inSize && inSize < this.maxInSize\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/DataMethod.kt", "rank": 61, "score": 47709.939996856156 }, { "content": " class CompressedStream(val compressionType: CompressionType, val info: Stream, stream: InputStream) {\n\n val stream: InputStream = when (compressionType) {\n\n CompressionType.NONE -> stream\n\n CompressionType.GZIP -> GZIPInputStream(stream)\n\n else -> stream\n\n }\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 62, "score": 47645.8780810688 }, { "content": "class SequentialNetworkModelWithWeights private constructor(nativeObjectHandle: Long) : AbstractNetworkModelWithWeights(nativeObjectHandle) {\n\n constructor(name: String? = null) : this(staticConstructor(name))\n\n\n\n constructor(name: String, file: File) : this(name) {\n\n load(file.canonicalPath)\n\n }\n\n\n\n fun addLayer(layer: Layer<*>): SequentialNetworkModelWithWeights {\n\n jniAddLayer(nativeObjectHandle, layer.nativeObjectHandle)\n\n return this\n\n }\n\n\n\n fun insertLayer(insertPosition: Long, layer: Layer<*>): SequentialNetworkModelWithWeights {\n\n jniInsertLayer(nativeObjectHandle, insertPosition, layer.nativeObjectHandle)\n\n return this\n\n }\n\n\n\n override fun toString(): String = name\n\n fun removeLayers() {\n\n jniRemoveLayers(this.nativeObjectHandle)\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/network/SequentialNetworkModelWithWeights.kt", "rank": 63, "score": 47446.00266496375 }, { "content": "class GraphNetworkModelWithWeights private constructor(nativeObjectHandle: Long) : AbstractNetworkModelWithWeights(nativeObjectHandle) {\n\n\n\n @JvmOverloads\n\n constructor(name: String? = null) : this(staticConstructor(name))\n\n\n\n companion object {\n\n private external fun staticConstructor(name: String?): Long\n\n private external fun jniAddLayer(handle: Long, layerHandle: Long)\n\n\n\n fun attach(nativeObjectHandle: Long): GraphNetworkModelWithWeights = GraphNetworkModelWithWeights(nativeObjectHandle)\n\n }\n\n}\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/network/GraphNetworkModelWithWeights.kt", "rank": 64, "score": 47446.00266496375 }, { "content": " class SummaryVectReader(normalizeBytes: Boolean) : TsvReader(normalizeBytes, false), VectReader {\n\n override fun getInt(attr: DataAttr): Int? = null\n\n\n\n override fun getString(attr: DataAttr): String? = null\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? = null\n\n\n\n override val supportsSeek: Boolean = false\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputStream: BetterInputStream) {\n\n this.openTsv(inputStream)\n\n }\n\n\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n val numberOfVectsToRead = destination.size\n\n var numVectsRead = 0\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 65, "score": 47422.22697232004 }, { "content": " class MovieMetaDataReader(normalizeBytes: Boolean) : TsvReader(normalizeBytes, false), VectReader {\n\n override fun getInt(attr: DataAttr): Int? = null\n\n\n\n override fun getString(attr: DataAttr): String? = null\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? = null\n\n\n\n override val supportsSeek: Boolean = false\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputStream: BetterInputStream) {\n\n this.openTsv(inputStream)\n\n }\n\n\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n val numberOfVectsToRead = destination.size\n\n var numVectsRead = 0\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/CMUMovieSummaryCorpusFormat.kt", "rank": 66, "score": 47200.66570315362 }, { "content": " open class IdxReader(val normalizeBytes: Boolean, val magicNumber: Int, val context: Context): AttributeResolver {\n\n override fun getInt(attr: DataAttr): Int? {\n\n return when (attr) {\n\n DataAttr.ElementCount -> numItems\n\n DataAttr.ElementByteSize -> dims.reduce { a, b -> a * b } / numItems\n\n else -> null\n\n }\n\n }\n\n\n\n override fun getString(attr: DataAttr): String? {\n\n return null\n\n }\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? {\n\n return null\n\n }\n\n\n\n lateinit var stream: Stream\n\n lateinit var inputStream: DataInputStream\n\n lateinit var dims: IntArray\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/MnistDataSliceFormat.kt", "rank": 67, "score": 46981.16511798429 }, { "content": " class ReviewVectReader(normalizeBytes: Boolean) : TsvReader(normalizeBytes, false, delimiter = Regex(Pattern.quote(\"|\"))), VectReader {\n\n override val supportsSeek: Boolean = false\n\n override fun getInt(attr: DataAttr): Int? = null\n\n\n\n override fun getString(attr: DataAttr): String? = null\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? = null\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputStream: BetterInputStream) {\n\n this.openTsv(inputStream)\n\n }\n\n\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n val numberOfVectsToRead = destination.size\n\n var numVectsRead = 0\n\n for (vectIndex in 0 until numberOfVectsToRead) {\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 68, "score": 46548.23206399297 }, { "content": " class SentimentVectReader(normalizeBytes: Boolean) : TsvReader(normalizeBytes, false, delimiter = Regex(Pattern.quote(\"|\"))), VectReader {\n\n override val supportsSeek: Boolean = false\n\n override fun getInt(attr: DataAttr): Int? = null\n\n\n\n override fun getString(attr: DataAttr): String? = null\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? = null\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputStream: BetterInputStream) {\n\n this.openTsv(inputStream)\n\n }\n\n\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n val numberOfVectsToRead = destination.size\n\n var numVectsRead = 0\n\n try {\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/OnlineMovieReviewSentimentsFormat.kt", "rank": 69, "score": 46548.23206399297 }, { "content": "package com.viveret.tinydnn.constants\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/constants/Sizes.kt", "rank": 70, "score": 44430.044115947974 }, { "content": "package com.viveret.tinydnn.data.formats\n\n\n\nannotation class Mime(val mimes: Array<String>) {\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Mime.kt", "rank": 71, "score": 43375.678235804335 }, { "content": "package com.viveret.tinydnn.enums\n\n\n\nimport com.viveret.tinydnn.R\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/enums/FileFormat.kt", "rank": 72, "score": 43375.678235804335 }, { "content": " try {\n\n for (vectIndex in 0 until numberOfVectsToRead) {\n\n for (i in 0 until floatArray.size) {\n\n floatArray[i] = 0.0f\n\n }\n\n floatArray[inputStream.readByte().toInt()] = 1.0f\n\n destination[vectIndex] = Vect(floatArray, floatArray.size)\n\n numVectsRead++\n\n var skipCount = vectLength\n\n while (skipCount > 0) {\n\n skipCount -= inputStream.skip(skipCount)\n\n }\n\n }\n\n } catch (e: EOFException) {\n\n this.close()\n\n }\n\n return numVectsRead\n\n }\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 73, "score": 43010.29388185302 }, { "content": " val bytesRead = inputStream.read(byteArray, 0, bytesLeft)\n\n if (bytesRead < 0) {\n\n break\n\n }\n\n for (i in 0 until bytesRead) {\n\n floatArray[totalBytesRead + i] = (byteArray[i].toUByte().toFloat() + 128.0f) / 255.0f\n\n }\n\n bytesLeft -= bytesRead\n\n totalBytesRead += bytesRead\n\n }\n\n if (bytesLeft > 0) {\n\n throw Exception(\"Not enough image data read (should have been $vectLength, but only read $totalBytesRead)\")\n\n }\n\n return Vect(floatArray, floatArray.size)\n\n }\n\n\n\n val isOpen = myIsOpen\n\n\n\n fun close() = this.inputStream.close()\n\n }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 74, "score": 43009.1136153087 }, { "content": " while (numVectsRead < numberOfVectsToRead) {\n\n while (inputStream.skip(1) < 1L);\n\n destination[numVectsRead] = readImage()\n\n numVectsRead++\n\n }\n\n } catch (e: EOFException) {\n\n this.close()\n\n }\n\n return numVectsRead\n\n }\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 75, "score": 43006.3836211835 }, { "content": "package com.viveret.tinydnn.data.formats\n\n\n\nimport android.content.Context\n\nimport com.viveret.tinydnn.basis.*\n\nimport com.viveret.tinydnn.data.io.InputSelection\n\nimport com.viveret.tinydnn.data.io.LabelReader\n\nimport com.viveret.tinydnn.data.io.VectReader\n\nimport com.viveret.tinydnn.project.NeuralNetProject\n\nimport java.io.BufferedInputStream\n\nimport java.io.DataInputStream\n\nimport java.io.EOFException\n\n\n\n// https://github.com/tiny-dnn/tiny-dnn/blob/1c5259477b8b4eab376cc19fd1d55ae965ef5e5a/tiny_dnn/io/cifar10_parser.h\n\n@Mime(arrayOf(\"application/cifar10\"))\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 76, "score": 43006.3836211835 }, { "content": "package com.viveret.tinydnn.enums\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/enums/LayerImageFormat.kt", "rank": 77, "score": 43006.3836211835 }, { "content": " if (vects.seek(relativeTo, offset) < offset) {\n\n return false\n\n }\n\n }\n\n for (labels in labelReaders.values) {\n\n if (labels.seek(relativeTo, offset) < offset) {\n\n return false\n\n }\n\n }\n\n return true\n\n }\n\n\n\n private fun nearestPowerOfTwo(count: Int): Int = max(1, Integer.highestOneBit(count - 1) shl 1)\n\n\n\n companion object {\n\n fun read(stream: DataInputStream, buffer: ByteArray, require: Boolean): Int {\n\n var bytesLeft = buffer.size\n\n while (bytesLeft > 0) {\n\n val n = stream.read(buffer, buffer.size - bytesLeft, bytesLeft)\n\n if (n > 0) {\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 78, "score": 41941.9006182602 }, { "content": " bytesLeft -= n\n\n } else if (buffer.size != bytesLeft && require) {\n\n throw UserException(\"Stream ended unexpectedly (${buffer.size - bytesLeft}/${buffer.size} bytes read)\")\n\n } else {\n\n return buffer.size - bytesLeft\n\n }\n\n }\n\n return buffer.size\n\n }\n\n }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 79, "score": 41940.392259448505 }, { "content": "\n\n override fun getInt(attr: DataAttr): Int? {\n\n for (r in vectReaders.values.plus(labelReaders.values.filterIsInstance<AttributeResolver>())) {\n\n val ret = r.getInt(attr)\n\n if (ret != null) {\n\n return ret\n\n }\n\n }\n\n return null\n\n }\n\n\n\n override fun getString(attr: DataAttr): String? {\n\n for (r in vectReaders.values.plus(labelReaders.values.filterIsInstance<AttributeResolver>())) {\n\n val ret = r.getString(attr)\n\n if (ret != null) {\n\n return ret\n\n }\n\n }\n\n return null\n\n }\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 80, "score": 41940.30737811155 }, { "content": "\n\n override fun getBoolean(attr: DataAttr): Boolean? {\n\n for (r in vectReaders.values.plus(labelReaders.values.filterIsInstance<AttributeResolver>())) {\n\n val ret = r.getBoolean(attr)\n\n if (ret != null) {\n\n return ret\n\n }\n\n }\n\n return null\n\n }\n\n\n\n override fun open(inputSelection: InputSelection) {\n\n for (kvp in inputSelection) {\n\n val role = kvp.key\n\n val stream = kvp.value\n\n\n\n when (role) {\n\n DataRole.Input, DataRole.FitTo -> {\n\n val vectReader = vectReader(role)!!\n\n vectReaders[role] = vectReader\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 81, "score": 41939.550817004536 }, { "content": " total += n\n\n }\n\n }\n\n\n\n for (labelReader in labelReaders) {\n\n val destinationLabels = destination[labelReader.key]?.labels\n\n if (destinationLabels != null) {\n\n val n = labelReader.value.read(destinationLabels, offset, amountToRead)\n\n if (n < 1) {\n\n return n\n\n }\n\n total += n\n\n }\n\n }\n\n\n\n return total / (vectReaders.size + labelReaders.size)\n\n }\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Boolean {\n\n for (vects in vectReaders.values) {\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 82, "score": 41939.23610352422 }, { "content": "\n\n// for (v in vects.entries.toList()) {\n\n// if (v.value.size < count) {\n\n// vects[v.key] = Array(nearestPowerOfTwo(count)) { Vect.empty }\n\n// }\n\n// }\n\n//\n\n// for (label in labels.entries.toList()) {\n\n// if (label.value.size < count) {\n\n// labels[label.key] = Array(nearestPowerOfTwo(count)) { 0L }\n\n// }\n\n// }\n\n\n\n for (vectReader in vectReaders) {\n\n val destinationVects = destination[vectReader.key]?.vects\n\n if (destinationVects != null) {\n\n val n = vectReader.value.read(destinationVects, offset, amountToRead)\n\n if (n < 1) {\n\n return n\n\n }\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 83, "score": 41939.044654405225 }, { "content": " vectReader.open(stream)\n\n }\n\n DataRole.InputLabels, DataRole.FitToLabels -> {\n\n val labelReader = labelReader(role)!!\n\n labelReaders[role] = labelReader\n\n labelReader.open(stream)\n\n }\n\n DataRole.NA -> {\n\n\n\n }\n\n }\n\n }\n\n }\n\n\n\n override fun read(\n\n destination: DataValues,\n\n offset: Int,\n\n amountToRead: Int\n\n ): Int {\n\n var total = 0\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 84, "score": 41935.289595225506 }, { "content": "package com.viveret.tinydnn.data.formats\n\n\n\nimport com.viveret.tinydnn.basis.*\n\nimport com.viveret.tinydnn.data.DataValues\n\nimport com.viveret.tinydnn.data.io.InputSelection\n\nimport com.viveret.tinydnn.data.io.LabelReader\n\nimport com.viveret.tinydnn.data.io.VectReader\n\nimport com.viveret.tinydnn.data.train.DataSliceReader\n\nimport com.viveret.tinydnn.error.UserException\n\nimport java.io.DataInputStream\n\nimport java.lang.IllegalArgumentException\n\nimport kotlin.math.max\n\nimport kotlin.math.min\n\n\n\nabstract class BufferedSingleDataSliceReader : DataSliceReader {\n\n private val vectReaders = HashMap<DataRole, VectReader>()\n\n private val labelReaders = HashMap<DataRole, LabelReader>()\n\n\n\n override val openRoles: Array<DataRole>\n\n get() = vectReaders.keys.union(labelReaders.keys).toTypedArray()\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/BufferedSingleDataSliceReader.kt", "rank": 85, "score": 41935.289595225506 }, { "content": "open class Optimizer(override val nativeObjectHandle: Long) : JniObject\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/optimizer/Optimizer.kt", "rank": 86, "score": 40662.34486875575 }, { "content": " open class Cifar10FileReader(val context: Context) {\n\n lateinit var stream: Stream\n\n lateinit var inputStream: DataInputStream\n\n private var myIsOpen = false\n\n protected var persistBufferIndex = 0\n\n\n\n fun openIdx(inputStream: BetterInputStream) {\n\n this.stream = inputStream.source\n\n this.inputStream = DataInputStream(BufferedInputStream(inputStream.currentStream))\n\n this.myIsOpen = true\n\n }\n\n\n\n fun readImage(): Vect {\n\n val vectLength = 32 * 32 * 3\n\n val byteArray = ByteArray(vectLength)\n\n val floatArray = FloatArray(vectLength)\n\n\n\n var bytesLeft = vectLength\n\n var totalBytesRead = 0\n\n while (bytesLeft > 0) {\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 87, "score": 40587.48915260842 }, { "content": "class Vect private constructor(override val nativeObjectHandle: Long) : JniObject {\n\n constructor(vals: FloatArray, requiredSize: Int) : this(staticConstructor(vals, requiredSize))\n\n\n\n constructor(vals: ArrayList<Int>, requiredSize: Int) : this(vals.map { x -> x.toFloat() }.toFloatArray(), requiredSize)\n\n\n\n override fun toString(): String {\n\n val sb = StringBuilder(\"${vals.size} [\")\n\n if (vals.isNotEmpty()) {\n\n for (f in vals) {\n\n sb.append(f)\n\n sb.append(\", \")\n\n }\n\n sb.setLength(sb.length - 2)\n\n }\n\n sb.append(\"]\")\n\n return sb.toString()\n\n }\n\n\n\n val vals: FloatArray = jniGetElements(nativeObjectHandle)\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/basis/Vect.kt", "rank": 88, "score": 40340.79025431731 }, { "content": "open class LayerBase(nativeObjectHandle: Long) : Layer<Any>, IModel<Layer<Any>> {\n\n override var nativeObjectHandle: Long = 0\n\n protected set\n\n\n\n override var color: Int = 0\n\n\n\n override val prevNodes: List<Node>\n\n get() = emptyList() // TODO: implement\n\n\n\n override val nextNodes: List<Node>\n\n get() = emptyList() // TODO: implement\n\n\n\n override val next: List<Edge>\n\n get() = emptyList() // TODO: implement\n\n\n\n override val prev: List<Edge>\n\n get() = emptyList() // TODO: implement\n\n\n\n init {\n\n this.nativeObjectHandle = nativeObjectHandle\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/LayerBase.kt", "rank": 89, "score": 40340.79025431731 }, { "content": "class ConnectionTable(override val nativeObjectHandle: Long) : JniObject {\n\n constructor(vals: BooleanArray, rows: Int, columns: Int) : this(staticConstructor(vals, rows, columns))\n\n\n\n constructor(vals: ArrayList<Boolean>, rows: Int, columns: Int) : this(vals.toBooleanArray(), rows, columns)\n\n\n\n val vals: BooleanArray = jniGetElements(nativeObjectHandle)\n\n\n\n override fun equals(other: Any?): Boolean = other is ConnectionTable && this.vals.contentEquals(other.vals)\n\n\n\n override fun toString(): String {\n\n val sb = StringBuilder(\"[\")\n\n if (vals.isNotEmpty()) {\n\n for (f in vals) {\n\n sb.append(f)\n\n sb.append(\", \")\n\n }\n\n sb.setLength(sb.length - 2)\n\n }\n\n sb.append(\"]\")\n\n return sb.toString()\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/layer/ConnectionTable.kt", "rank": 90, "score": 40340.79025431731 }, { "content": "class AddLayerAction(newLayer: LayerBase) : ProjectAction {\n\n override val name: String = \"@save\"\n\n override fun doAction(project: NeuralNetProject): OnSelectedResult { return OnSelectedResult(true) }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/project/actions/AddLayerAction.kt", "rank": 91, "score": 40277.66597802761 }, { "content": "class Index3D private constructor(override val nativeObjectHandle: Long) : JniObject {\n\n\n\n internal val width: Long\n\n get() = jniGetWidth(nativeObjectHandle)\n\n\n\n internal val height: Long\n\n get() = jniGetHeight(nativeObjectHandle)\n\n\n\n internal val depth: Long\n\n get() = jniGetDepth(nativeObjectHandle)\n\n\n\n constructor(width: Long, height: Long, depth: Long) : this(staticConstructor(width, height, depth))\n\n\n\n constructor() : this(staticConstructor())\n\n\n\n internal fun reshape(width: Long, height: Long, depth: Long) {\n\n jniReshape(nativeObjectHandle, width, height, depth)\n\n }\n\n\n\n internal fun get_index(x: Long, y: Long, channel: Long): Long = jniGetIndex(nativeObjectHandle, x, y, channel)\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/basis/Index3D.kt", "rank": 92, "score": 39712.70045166281 }, { "content": "class Cifar10Parser(val context: Context) : BufferedSingleDataSliceReader() {\n\n\n\n override fun getInt(attr: DataAttr): Int? {\n\n// return when (attr) {\n\n// DataAttr.ByteCount ->\n\n// }\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun getString(attr: DataAttr): String? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Boolean {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun vectReader(role: DataRole): VectReader? = if (role == DataRole.Input)\n\n Cifar10InputReader(context)\n\n else\n\n Cifar10FitToReader(context)\n\n\n\n override fun labelReader(role: DataRole): LabelReader? = null\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 93, "score": 39632.15586880199 }, { "content": " class Cifar10FitToReader(context: Context) : Cifar10FileReader(context), VectReader {\n\n override val supportsSeek: Boolean = false\n\n override fun getInt(attr: DataAttr): Int? = null\n\n\n\n override fun getString(attr: DataAttr): String? = null\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? = null\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int {\n\n TODO(\"not implemented\") //To change body of created functions use File | Settings | File Templates.\n\n }\n\n\n\n override fun open(inputStream: BetterInputStream) = this.openIdx(inputStream)\n\n\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n val numberOfVectsToRead = destination.size\n\n val vectLength = 32 * 32 * 3L\n\n val possibleOutputs = 10\n\n var numVectsRead = 0\n\n val floatArray = FloatArray(possibleOutputs)\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 94, "score": 39323.62754298734 }, { "content": " class Cifar10InputReader(context: Context) : Cifar10FileReader(context), VectReader {\n\n override val supportsSeek: Boolean = false\n\n\n\n override fun getInt(attr: DataAttr): Int? = null\n\n\n\n override fun getString(attr: DataAttr): String? = null\n\n\n\n override fun getBoolean(attr: DataAttr): Boolean? = null\n\n\n\n override fun seek(relativeTo: AnchorPoint, offset: Int): Int {\n\n return 0\n\n }\n\n\n\n override fun open(inputStream: BetterInputStream) = this.openIdx(inputStream)\n\n\n\n override fun read(destination: Array<Vect>, offset: Int, count: Int): Int {\n\n val numberOfVectsToRead = destination.size\n\n var numVectsRead = 0\n\n\n\n try {\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/data/formats/Cifar10Parser.kt", "rank": 95, "score": 39323.62754298734 }, { "content": "class InsertLayerAction(insertLayerPosition: Long, newLayer: LayerBase) : ProjectAction {\n\n override val name: String = \"Insert Layer\"\n\n override fun doAction(project: NeuralNetProject): OnSelectedResult { return OnSelectedResult(true) }\n\n}", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/project/actions/InsertLayerAction.kt", "rank": 96, "score": 39052.074947301095 }, { "content": "open class AbstractNetworkModelWithWeights(override val nativeObjectHandle: Long) : INetworkModelWithWeights {\n\n override fun sameModelAs(other: INetworkModel): Boolean {\n\n if (this.layer_size() == other.layer_size()) {\n\n for (i in 0 until this.layer_size()) {\n\n val layer = this.layerAt(i)\n\n val otherLayer = other.layerAt(i)\n\n if (layer is LayerBase && otherLayer is LayerBase) {\n\n if (!layer.sameModelAs(otherLayer)) {\n\n return false\n\n }\n\n } else {\n\n return false\n\n }\n\n }\n\n return true\n\n } else {\n\n return false\n\n }\n\n }\n\n\n", "file_path": "kt-nn/src/main/java/com/viveret/tinydnn/network/AbstractNetworkModelWithWeights.kt", "rank": 97, "score": 38513.42356809479 } ]
C++
src/core-util/pipe.cpp
rocksat/mLib
1bd996008200b54d0984e957264e03faa24651d2
#ifdef _WIN32 #include <AccCtrl.h> #include <Aclapi.h> namespace ml { Pipe::Pipe() { m_handle = nullptr; } Pipe::~Pipe() { closePipe(); } void Pipe::closePipe() { if(m_handle != nullptr) { FlushFileBuffers(m_handle); DisconnectNamedPipe(m_handle); CloseHandle(m_handle); m_handle = nullptr; } } void Pipe::createPipe(const std::string &pipeName, bool block) { closePipe(); const UINT PipeBufferSize = 100000; DWORD dwRes; PSID pEveryoneSID = nullptr, pAdminSID = nullptr; PACL pACL = nullptr; PSECURITY_DESCRIPTOR pSD = nullptr; EXPLICIT_ACCESS ea[1]; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY; SECURITY_ATTRIBUTES attributes; HKEY hkSub = nullptr; BOOL success = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID); MLIB_ASSERT_STR(success != FALSE, "AllocateAndInitializeSid failed in Pipe::CreatePipe"); ZeroMemory(&ea, sizeof(EXPLICIT_ACCESS)); ea[0].grfAccessPermissions = FILE_ALL_ACCESS; ea[0].grfAccessMode = SET_ACCESS; ea[0].grfInheritance= NO_INHERITANCE; ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID; ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; ea[0].Trustee.ptstrName = (LPTSTR) pEveryoneSID; dwRes = SetEntriesInAcl(1, ea, nullptr, &pACL); MLIB_ASSERT_STR(dwRes == ERROR_SUCCESS, "SetEntriesInAcl failed in Pipe::CreatePipe"); pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); MLIB_ASSERT_STR(pSD != nullptr, "LocalAlloc failed in Pipe::CreatePipe"); success = InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION); MLIB_ASSERT_STR(success != FALSE, "InitializeSecurityDescriptor failed in Pipe::CreatePipe"); success = SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE); MLIB_ASSERT_STR(success != FALSE, "SetSecurityDescriptorDacl failed in Pipe::CreatePipe"); attributes.nLength = sizeof(SECURITY_ATTRIBUTES); attributes.lpSecurityDescriptor = pSD; attributes.bInheritHandle = FALSE; std::string fullPipeName = std::string("\\\\.\\pipe\\") + pipeName; m_handle = CreateNamedPipeA( fullPipeName.c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, PipeBufferSize, PipeBufferSize, NMPWAIT_USE_DEFAULT_WAIT, &attributes); MLIB_ASSERT_STR(m_handle != INVALID_HANDLE_VALUE, "CreateNamedPipe failed in Pipe::CreatePipe"); if(block) { std::cout << "Pipe created, waiting for connection" << std::endl; BOOL Connected = (ConnectNamedPipe(m_handle, nullptr) != 0); MLIB_ASSERT_STR(Connected != FALSE, "ConnectNamedPipe failed in Pipe::CreatePipe"); std::cout << "Connected" << std::endl; } else { } } void Pipe::connectToLocalPipe(const std::string &pipeName) { connectToPipe(std::string("\\\\.\\pipe\\") + pipeName); } void Pipe::connectToPipe(const std::string &pipeName) { closePipe(); bool done = false; while(!done) { m_handle = CreateFileA( pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr); if(m_handle != INVALID_HANDLE_VALUE) { done = true; } Sleep(100); } DWORD mode = PIPE_READMODE_BYTE; BOOL success = SetNamedPipeHandleState( m_handle, &mode, nullptr, nullptr); MLIB_ASSERT_STR(success != FALSE, "SetNamedPipeHandleState failed in Pipe::ConnectToPipe"); } bool Pipe::messagePresent() { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::MessagePresent"); DWORD BytesReady = 0; DWORD BytesLeft = 0; BOOL success = PeekNamedPipe( m_handle, nullptr, 0, nullptr, &BytesReady, &BytesLeft); return (BytesReady > 0); } bool Pipe::readMessage(std::vector<BYTE> &Message) { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::ReadMessage"); DWORD BytesReady = 0; BOOL success = PeekNamedPipe( m_handle, nullptr, 0, nullptr, &BytesReady, nullptr); MLIB_ASSERT_STR(success != FALSE, "PeekNamedPipe failed in Pipe::ReadMessage"); Message.resize(BytesReady); if(BytesReady == 0) { return false; } DWORD BytesRead; success = ReadFile( m_handle, &Message[0], (DWORD)Message.size(), &BytesRead, nullptr); MLIB_ASSERT_STR(success != FALSE && BytesRead > 0, "ReadFile failed in Pipe::ReadMessage"); return true; } void Pipe::sendMessage(const std::vector<BYTE> &Message) { sendMessage(&Message[0], (UINT)Message.size()); } void Pipe::sendMessage(const std::string &message) { sendMessage((const BYTE *)message.c_str(), (UINT)message.size()); std::string endLine; endLine.push_back('\n'); sendMessage((const BYTE *)endLine.c_str(), 1); } void Pipe::sendMessage(const BYTE *Message, UINT MessageLength) { if(Message == nullptr || MessageLength == 0) return; MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::SendMessage"); DWORD BytesWritten; BOOL success = WriteFile( m_handle, Message, MessageLength, &BytesWritten, nullptr); if (success == FALSE) MLIB_WARNING("WriteFile failed in Pipe::ReadMessage"); if (BytesWritten != MessageLength) MLIB_WARNING("WriteFile failed to send entire message in Pipe::ReadMessage"); } UINT Pipe::activeInstances() { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::ActiveInstances"); DWORD Instances; BOOL success = GetNamedPipeHandleState( m_handle, nullptr, &Instances, nullptr, nullptr, nullptr, 0); MLIB_ASSERT_STR(success != FALSE, "GetNamedPipeHandleState failed in Pipe::ActiveInstances"); return Instances; } std::string Pipe::userName() { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::UserName"); char buffer[512]; BOOL success = GetNamedPipeHandleStateA( m_handle, nullptr, nullptr, nullptr, nullptr, buffer, 512); MLIB_ASSERT_STR(success != FALSE, "GetNamedPipeHandleState failed in Pipe::UserName"); return std::string(buffer); } bool Pipe::valid() { return (m_handle != nullptr); } } #endif
#ifdef _WIN32 #include <AccCtrl.h> #include <Aclapi.h> namespace ml { Pipe::Pipe() { m_handle = nullptr; } Pipe::~Pipe() { closePipe(); } void Pipe::closePipe() { if(m_handle != nullptr) { FlushFileBuffers(m_handle); DisconnectNamedPipe(m_handle); CloseHandle(m_handle); m_handle = nullptr; } } void Pipe::createPipe(const std::string &pipeName, bool block) { closePipe(); const UINT PipeBufferSize = 100000; DWORD dwRes; PSID pEveryoneSID = nullptr, pAdminSID = nullptr; PACL pACL = nullptr; PSECURITY_DESCRIPTOR pSD = nullptr; EXPLICIT_ACCESS ea[1]; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY; SECURITY_ATTRIBUTES attributes; HKEY hkSub = nullptr; BOOL success = AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID); MLIB_ASSERT_STR(success != FALSE, "AllocateAndInitializeSid failed in Pipe::CreatePipe"); ZeroMemory(&ea, sizeof(EXPLICIT_ACCESS)); ea[0].grfAccessPermissions = FILE_ALL_ACCESS; ea[0].grfAccessMode = SET_ACCESS; ea[0].grfInheritance= NO_INHERITANCE; ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID; ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; ea[0].Trustee.ptstrName = (LPTSTR) pEveryoneSID; dwRes = SetEntriesInAcl(1, ea, nullptr, &pACL); MLIB_ASSERT_STR(dwRes == ERROR_SUCCESS, "SetEntriesInAcl failed in Pipe::CreatePipe"); pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); MLIB_ASSERT_STR(pSD != nullptr, "LocalAlloc failed in Pipe::CreatePipe"); success = InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION); MLIB_ASSERT_STR(success != FALSE, "InitializeSecurityDescriptor failed in Pipe::CreatePipe"); success = SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE); MLIB_ASSERT_STR(success != FALSE, "SetSecurityDescriptorDacl failed in Pipe::CreatePipe"); attributes.nLength = sizeof(SECURITY_ATTRIBUTES); attributes.lpSecurityDescriptor = pSD; attributes.bInheritHandle = FALSE; std::string fullPipeName = std::string("\\\\.\\pipe\\") + pipeName; m_handle = CreateNamedPipeA( fullPipeName.c_str(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, PipeBufferSize, PipeBufferSize, NMPWAIT_USE_DEFAULT_WAIT, &attributes); MLIB_ASSERT_STR(m_handle != INVALID_HANDLE_VALUE, "CreateNamedPipe failed in Pipe::CreatePipe"); if(block) { std::cout << "Pipe created, waiting for connection" << std::endl; BOOL Connected = (ConnectNamedPipe(m_handle, nullptr) != 0); MLIB_ASSERT_STR(Connected != FALSE, "ConnectNamedPipe failed in Pipe::CreatePipe"); std::cout << "Connected" << std::endl; } else { } } void Pipe::connectToLocalPipe(const std::string &pipeName) { connectToPipe(std::string("\\\\.\\pipe\\") + pipeName); } void Pipe::connectToPipe(const std::string &pipeName) { closePipe(); bool done = false; while(!done) { m_handle = CreateFileA( pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, nullptr); if(m_handle != INVALID_HANDLE_VALUE) { done = true; } Sleep(100); } DWORD mode = PIPE_READMODE_BYTE; BOOL success = SetNamedPipeHandleState( m_handle, &mode, nullptr, nullptr); MLIB_ASSERT_STR(success != FALSE, "SetNamedPipeHandleState failed in Pipe::ConnectToPipe"); } bool Pipe::messagePresent() { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invali
m_handle, nullptr, 0, nullptr, &BytesReady, &BytesLeft); return (BytesReady > 0); } bool Pipe::readMessage(std::vector<BYTE> &Message) { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::ReadMessage"); DWORD BytesReady = 0; BOOL success = PeekNamedPipe( m_handle, nullptr, 0, nullptr, &BytesReady, nullptr); MLIB_ASSERT_STR(success != FALSE, "PeekNamedPipe failed in Pipe::ReadMessage"); Message.resize(BytesReady); if(BytesReady == 0) { return false; } DWORD BytesRead; success = ReadFile( m_handle, &Message[0], (DWORD)Message.size(), &BytesRead, nullptr); MLIB_ASSERT_STR(success != FALSE && BytesRead > 0, "ReadFile failed in Pipe::ReadMessage"); return true; } void Pipe::sendMessage(const std::vector<BYTE> &Message) { sendMessage(&Message[0], (UINT)Message.size()); } void Pipe::sendMessage(const std::string &message) { sendMessage((const BYTE *)message.c_str(), (UINT)message.size()); std::string endLine; endLine.push_back('\n'); sendMessage((const BYTE *)endLine.c_str(), 1); } void Pipe::sendMessage(const BYTE *Message, UINT MessageLength) { if(Message == nullptr || MessageLength == 0) return; MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::SendMessage"); DWORD BytesWritten; BOOL success = WriteFile( m_handle, Message, MessageLength, &BytesWritten, nullptr); if (success == FALSE) MLIB_WARNING("WriteFile failed in Pipe::ReadMessage"); if (BytesWritten != MessageLength) MLIB_WARNING("WriteFile failed to send entire message in Pipe::ReadMessage"); } UINT Pipe::activeInstances() { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::ActiveInstances"); DWORD Instances; BOOL success = GetNamedPipeHandleState( m_handle, nullptr, &Instances, nullptr, nullptr, nullptr, 0); MLIB_ASSERT_STR(success != FALSE, "GetNamedPipeHandleState failed in Pipe::ActiveInstances"); return Instances; } std::string Pipe::userName() { MLIB_ASSERT_STR(m_handle != nullptr, "Pipe invalid in Pipe::UserName"); char buffer[512]; BOOL success = GetNamedPipeHandleStateA( m_handle, nullptr, nullptr, nullptr, nullptr, buffer, 512); MLIB_ASSERT_STR(success != FALSE, "GetNamedPipeHandleState failed in Pipe::UserName"); return std::string(buffer); } bool Pipe::valid() { return (m_handle != nullptr); } } #endif
d in Pipe::MessagePresent"); DWORD BytesReady = 0; DWORD BytesLeft = 0; BOOL success = PeekNamedPipe(
function_block-random_span
[ { "content": "class Pipe\n\n{\n\npublic:\n\n Pipe();\n\n ~Pipe();\n\n \n\n //\n\n // Connection\n\n //\n\n void closePipe();\n\n void createPipe(const std::string &pipeName, bool block);\n\n void connectToLocalPipe(const std::string &pipeName);\n\n void connectToPipe(const std::string &pipeName);\n\n\n\n //\n\n // Messaging\n\n //\n\n bool messagePresent();\n\n bool readMessage(std::vector<BYTE> &message);\n\n void sendMessage(const BYTE *message, UINT messageLength);\n", "file_path": "include/core-util/pipe.h", "rank": 0, "score": 129534.93628995217 }, { "content": "namespace ml\n\n{\n\n\n\n//\n\n// These should be moved back into vec1 -> vec6...\n\n//\n\n#ifdef LINUX\n\n template<> const vec3f vec3f::origin;\n\n template<> const vec3f vec3f::eX;\n\n template<> const vec3f vec3f::eY;\n\n template<> const vec3f vec3f::eZ;\n\n\n\n template<> const vec3d vec3d::origin;\n\n template<> const vec3d vec3d::eX;\n\n template<> const vec3d vec3d::eY;\n\n template<> const vec3d vec3d::eZ;\n\n template<> const vec6d vec6d::origin;\n\n template<> const vec6f vec6f::origin;\n\n\n\n template<> const vec4f vec4f::origin;\n\n template<> const vec4f vec4f::eX;\n\n template<> const vec4f vec4f::eY;\n\n template<> const vec4f vec4f::eZ;\n\n template<> const vec4f vec4f::eW;\n\n\n\n template<> const vec4d vec4d::origin;\n\n template<> const vec4d vec4d::eX;\n\n template<> const vec4d vec4d::eY;\n\n template<> const vec4d vec4d::eZ;\n\n template<> const vec4d vec4d::eW;\n\n\n\n template<> const vec2f vec2f::origin;\n\n template<> const vec2f vec2f::eX;\n\n template<> const vec2f vec2f::eY;\n\n\n\n template<> const vec2d vec2d::origin;\n\n template<> const vec2d vec2d::eX;\n\n template<> const vec2d vec2d::eY;\n\n\n\n template<> const vec1f vec1f::origin;\n\n template<> const vec1f vec1f::eX;\n\n\n\n template<> const vec1d vec1d::origin;\n\n template<> const vec1d vec1d::eX;\n\n#else\n\n template<> const vec3f vec3f::origin(0.0f, 0.0f, 0.0f);\n\n template<> const vec3f vec3f::eX(1.0f, 0.0f, 0.0f);\n\n template<> const vec3f vec3f::eY(0.0f, 1.0f, 0.0f);\n\n template<> const vec3f vec3f::eZ(0.0f, 0.0f, 1.0f);\n\n\n\n template<> const vec3d vec3d::origin(0.0, 0.0, 0.0);\n\n template<> const vec3d vec3d::eX(1.0, 0.0, 0.0);\n\n template<> const vec3d vec3d::eY(0.0, 1.0, 0.0);\n\n template<> const vec3d vec3d::eZ(0.0, 0.0, 1.0);\n\n template<> const vec6d vec6d::origin(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);\n\n template<> const vec6f vec6f::origin(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);\n\n\n\n template<> const vec4f vec4f::origin(0.0f, 0.0f, 0.0f, 0.0f);\n\n template<> const vec4f vec4f::eX(1.0f, 0.0f, 0.0f, 0.0f);\n\n template<> const vec4f vec4f::eY(0.0f, 1.0f, 0.0f, 0.0f);\n\n template<> const vec4f vec4f::eZ(0.0f, 0.0f, 1.0f, 0.0f);\n\n template<> const vec4f vec4f::eW(0.0f, 0.0f, 0.0f, 1.0f);\n\n\n\n template<> const vec4d vec4d::origin(0.0, 0.0, 0.0, 0.0);\n\n template<> const vec4d vec4d::eX(1.0, 0.0, 0.0, 0.0);\n\n template<> const vec4d vec4d::eY(0.0, 1.0, 0.0, 0.0);\n\n template<> const vec4d vec4d::eZ(0.0, 0.0, 1.0, 0.0);\n\n template<> const vec4d vec4d::eW(0.0, 0.0, 0.0, 1.0);\n\n\n\n template<> const vec2f vec2f::origin(0.0f, 0.0f);\n\n template<> const vec2f vec2f::eX(1.0f, 0.0f);\n\n template<> const vec2f vec2f::eY(0.0f, 1.0f);\n\n\n\n template<> const vec2d vec2d::origin(0.0, 0.0);\n\n template<> const vec2d vec2d::eX(1.0, 0.0);\n\n template<> const vec2d vec2d::eY(0.0, 1.0);\n\n\n\n template<> const vec1f vec1f::origin(0.0f);\n\n template<> const vec1f vec1f::eX(1.0f);\n\n\n\n template<> const vec1d vec1d::origin(0.0);\n\n template<> const vec1d vec1d::eX(1.0);\n\n#endif\n", "file_path": "include/mLibCore.h", "rank": 1, "score": 117067.78497250365 }, { "content": "\t\tconst T& getMinValue() const;\n", "file_path": "include/core-base/grid3.h", "rank": 2, "score": 114569.82462346312 }, { "content": "\t\tconst T& getMinValue() const;\n", "file_path": "include/core-base/grid2.h", "rank": 3, "score": 114569.82462346312 }, { "content": "namespace ml\n\n{\n\n\n\nnamespace math\n\n{\n\n\tstatic const double PI = 3.1415926535897932384626433832795028842;\n\n\tstatic const float PIf = 3.14159265358979323846f;\n\n\n\n\tinline float degreesToRadians(float x) {\n\n\t\treturn x * (PIf / 180.0f);\n\n\t}\n\n\n\n\tinline float radiansToDegrees(float x) {\n\n\t\treturn x * (180.0f / PIf);\n\n\t}\n\n\n\n\tinline double degreesToRadians(double x) {\n\n\t\treturn x * (PI / 180.0);\n\n\t}\n\n\n\n\tinline double radiansToDegrees(double x) {\n\n\t\treturn x * (180.0 / PI);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline bool floatEqual(T v0, T v1, T eps = (T)0.000001) {\n\n\t\treturn (std::abs(v0 - v1) <= eps);\n\n\t}\n\n\n\n\n\n\ttemplate<class T>\n\n\tinline T linearMap(T s1, T e1, T s2, T e2, T start) {\n\n\t\treturn ((start - s1) * (e2 - s2) / (e1 - s1) + s2);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T linearMapClamped(T s1, T e1, T s2, T e2, T start) {\n\n\t\tif (start <= s1) return s2;\n\n\t\tif (start >= e1) return e2;\n\n\t\treturn ((start - s1) * (e2 - s2) / (e1 - s1) + s2);\n\n\t}\n\n\n\n\ttemplate<class T, class U>\n\n#if __cplusplus >= 201103L || defined __cpp_decltype\n\n\tinline auto lerp(T left, T right, U s) -> decltype(left * s) {\n\n\t\treturn static_cast<decltype(left * s)>(left + (right - left) * s);\n\n#else\n\n\tinline T lerp(T left, T right, U s) {\n\n\t\treturn static_cast<T>(left + (right - left) * s);\n\n#endif\n\n\t}\n\n\n\n\tinline int mod(int x, size_t M) {\n\n\t\tif (x >= 0) { return (x % M); }\n\n\t\telse { return ((x + (x / static_cast<int>(M) + 2) * static_cast<int>(M)) % M); }\n\n\t}\n\n\n\n\ttemplate <class T> inline T square(T x) {\n\n\t\treturn x * x;\n\n\t}\n\n\n\n\ttemplate <class T> inline T min(T A, T B) {\n\n\t\tif (A < B) { return A; }\n\n\t\telse { return B; }\n\n\t}\n\n\n\n\ttemplate <class T> inline T min(T A, T B, T C) {\n\n\t\tif (A < B && A < C) { return A; }\n\n\t\telse if (B < C) { return B; }\n\n\t\telse { return C; }\n\n\t}\n\n\n\n\ttemplate <class T> inline T max(T A, T B) {\n\n\t\tif (A > B) { return A; }\n\n\t\telse { return B; }\n\n\t}\n\n\n\n\ttemplate <class T> inline T max(T A, T B, T C) {\n\n\t\tif (A > B && A > C) { return A; }\n\n\t\telse if (B > C) { return B; }\n\n\t\telse { return C; }\n\n\t}\n\n\n\n template <class T> inline T max(T A, T B, T C, T D) {\n\n return max(max(A, B), max(C, D));\n\n }\n\n\n\n template <class T> inline unsigned int maxIndex(T A, T B, T C) {\n\n if (A > B && A > C) { return 0; }\n\n else if (B > C) { return 1; }\n\n else { return 2; }\n\n }\n\n\n\n\t//! returns the clamped value between min and max\n\n\ttemplate<class T>\n\n\tinline T clamp(T x, T pMin, T pMax) {\n\n\t\tif (x < pMin) { return pMin; }\n\n\t\tif (x > pMax) { return pMax; }\n\n\t\treturn x;\n\n\t}\n\n\n\n template<class T>\n\n inline long int floor(T x)\n\n {\n\n return (long int)std::floor(x);\n\n }\n\n\n\n template<class T>\n\n inline long int ceil(T x)\n\n {\n\n return (long int)std::ceil(x);\n\n }\n\n\n\n\ttemplate<class T>\n\n\tinline T abs(T x) {\n\n\t\t//TODO compile check that it's not an unsigned variable type\n\n\t\tif (x < 0) { return -x; }\n\n\t\treturn x;\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T sqrt(T x) {\n\n\t\treturn std::sqrt(x);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T pow(T x, T e) {\n\n\t\treturn std::pow(x, e);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T exp(T x) {\n\n\t\treturn std::exp(x);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T log(T x) {\n\n\t\treturn std::log(x);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline int round(const T& f) {\n\n\t\treturn (f > (T)0.0) ? (int)floor(f + (T)0.5) : (int)ceil(f - (T)0.5);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T frac(const T& val) {\n\n\t\treturn (val - floor(val));\n\n\t}\n\n\n\n\n\n\ttemplate<class T>\n\n\tinline bool isPower2(const T& x) {\n\n\t\treturn (x & (x - 1)) == 0;\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T nextLargeestPow2(T x) {\n\n\t\tx |= (x >> 1);\n\n\t\tx |= (x >> 2);\n\n\t\tx |= (x >> 4);\n\n\t\tx |= (x >> 8);\n\n\t\tx |= (x >> 16);\n\n\t\treturn (x + 1);\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tinline T log2Integer(T x) {\n\n\t\tT r = 0;\n\n\t\twhile (x >>= 1) { r++; }\n\n\t\treturn r;\n\n\t}\n\n\n\n\n\n\t//! non-zero 32-bit integer value to compute the log base 10 of\n\n\ttemplate<class T>\n\n\tinline T log10Integer(T x) {\n\n\t\tT r; // result goes here\n\n\n\n\t\tconst unsigned int PowersOf10[] = {\n\n\t\t\t1, 10, 100, 1000, 10000, 100000,\n\n\t\t\t1000000, 10000000, 100000000, 1000000000\n\n\t\t};\n\n\n\n\t\tT t = (log2Integer(x) + 1) * 1233 >> 12; // (use a lg2 method from above)\n\n\t\tr = t - (x < PowersOf10[t]);\n\n\t\treturn r;\n\n\t}\n\n\n\n\t//! returns -1 if negative, 0 if 0, +1 if positive\n\n\ttemplate <typename T>\n\n\tinline int sign(T val) {\n\n\t\treturn (T(0) < val) - (val < T(0));\n\n\t}\n\n\n\n\t//! returns -1 if negative; +1 otherwise (includes 0)\n\n\ttemplate <typename T>\n\n\tinline int sgn(T val) {\n\n\t\treturn val < 0 ? -1 : 1;\n\n\t}\n\n\n\n\t//! solves a^2 + bx + c = 0\n\n\ttemplate<typename T>\n\n\tinline void quadraticFormula(T a, T b, T c, T& x0, T& x1) {\n\n\t\tT tmp = (T) - 0.5 * (b + (T)sgn(b) * sqrt(b * b - (T)4 * a * c));\n\n\t\tx0 = tmp / a;\n\n\t\tx1 = c / tmp;\n\n\t}\n\n\n\n\t//! L2 squared distance metric\n\n\ttemplate<typename T>\n\n\tinline T distSqL2(const std::vector<T> &a, const std::vector<T> &b) {\n\n\t\tT result = T(0.0);\n\n\t\tfor (size_t i = 0; i < a.size(); i++)\n\n\t\t{\n\n\t\t\tT diff = a[i] - b[i];\n\n\t\t\tresult += diff * diff;\n\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\n\n\t//! L2 distance metric\n\n\ttemplate<typename T>\n\n\tinline T distL2(const std::vector<T> &a, const std::vector<T> &b) {\n\n\t\treturn sqrt(distSqL2(a, b));\n\n\t}\n\n\n\n\t//! L1 distance metric\n\n\ttemplate<typename T>\n\n\tinline T distL1(const std::vector<T> &a, const std::vector<T> &b) {\n\n\t\tT result = T(0.0);\n\n\t\tconst size_t size = a.size();\n\n\t\tconst T* aPtr = a.data();\n\n\t\tconst T* bPtr = b.data();\n\n\t\tfor (size_t i = 0; i < size; i++)\n\n\t\t{\n\n\t\t\tconst T diff = aPtr[i] - bPtr[i];\n\n\t\t\tresult += std::abs(diff);\n\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\n\n\t//! computes sin(phi) and cos(phi)\n\n\ttemplate<typename T>\n\n\tinline void sincos(T phi, T& sinPhi, T& cosPhi) {\n\n\t\tsinPhi = std::sin(phi);\n\n\t\tcosPhi = std::cos(phi);\n\n\t}\n\n\t//! computes sin(phi) and cos(phi)\n\n\ttemplate<typename T>\n\n\tinline void sincos(T phi, T* sinPhi, T* cosPhi) {\n\n\t\tsincos(phi, *sinPhi, *cosPhi);\n\n\t}\n\n\n\n\t//! counts the number of bits in an unsigned integer \n\n\tinline unsigned int numberOfSetBits(unsigned int i) {\n\n\t\ti = i - ((i >> 1) & 0x55555555);\n\n\t\ti = (i & 0x33333333) + ((i >> 2) & 0x33333333);\n\n\t\treturn (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;\n\n\t}\n\n\n\n\t//! counts the number of bits in an integer \n\n\tinline int numberOfSetBits(int i) {\n\n\t\ti = i - ((i >> 1) & 0x55555555);\n\n\t\ti = (i & 0x33333333) + ((i >> 2) & 0x33333333);\n\n\t\treturn (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;\n\n\t}\n\n\n\n\t//! generates a random number (uniform distribution)\n\n\ttemplate<typename T>\n\n\tinline T randomUniform(T _min, T _max) {\n\n\t\tstatic std::random_device rd;\n\n\t\tstatic std::mt19937 gen(rd());\n\n\t\tstd::uniform_real_distribution<T> dis(_min, _max);\n\n\t\treturn dis(gen);\n\n\t}\n\n\ttemplate<> \n\n\tinline int randomUniform(int _min, int _max) {\n\n\t\tstatic std::random_device rd;\n\n\t\tstatic std::mt19937 gen(rd());\n\n\t\tstd::uniform_int_distribution<> dis(_min, _max);\n\n\t\treturn dis(gen);\n\n\t}\n\n\ttemplate<> \n\n\tinline unsigned int randomUniform(unsigned int _min, unsigned int _max) {\n\n\t\tstatic std::random_device rd;\n\n\t\tstatic std::mt19937 gen(rd());\n\n\t\tstd::uniform_int_distribution<> dis(_min, _max);\n\n\t\treturn dis(gen);\n\n\t}\n\n\n\n\n\n\t//! generates a random number (normal distribution)\n\n\ttemplate<typename T>\n\n\tinline T randomNormal(T mean, T stddev) {\n\n\t\tstatic std::random_device rd;\n\n\t\tstatic std::mt19937 gen(rd());\n\n\t\tstd::normal_distribution<T> dis(mean, stddev);\n\n\t\treturn dis(gen);\n\n\t}\n\n\n\n\t//! flips a coin: 50% chance to retrun true; otherwise false\n\n\tinline bool randomCointoss() {\n\n\t\tif (randomUniform(0.0f, 1.0f) > 0.5f) return false;\t//there may be some bias\n\n\t\telse return true;\n\n\t}\n\n\n\n} // namespace math\n\n\n\nnamespace util\n\n{\n\n\t//! reads from a vector with an index that is clamped to be in-bounds.\n\n\ttemplate<class T>\n\n\tconst T& clampedRead(const std::vector<T> &v, int index)\n\n\t{\n\n\t\tif (index < 0) return v[0];\n\n\t\tif (index >= v.size()) return v[v.size() - 1];\n\n\t\treturn v[index];\n\n\t}\n\n\n\n\ttemplate<class T>\n\n\tbool validIndex(const std::vector<T> &v, int index)\n\n\t{\n\n\t\treturn (index >= 0 && index < v.size());\n\n\t}\n\n\n\n //\n\n // iterator helpers\n\n //\n\n template<class container, class assignFunction>\n\n void fill(container &c, assignFunction func) {\n\n int i = 0;\n\n for(auto &x : c) {\n\n x = func(i++);\n\n }\n\n }\n\n\n\n\tinline std::string getTimeString() {\n\n\t\tauto t = std::time(nullptr);\n\n\t\tauto tm = *std::localtime(&t);\n\n#if __GNUC__ && __GNUC__ < 5\n\n #pragma message (\"std::put_time not available in gcc version < 5\")\n\n return std::string();\n\n#else\n\n\t\tstd::stringstream ss; ss << std::put_time(&tm, \"%Y-%m-%d_%H-%M-%S\");\n\n\t\treturn ss.str();\n\n#endif\n\n\t}\n\n\n\n\tinline UINT64 getTime() {\n\n\t\tUINT64 res = std::time(NULL);\n\n\t\treturn res;\n\n\t}\n\n\n\n\t//\n\n\t// hashing\n\n\t//\n\n\tUINT32 hash32(const BYTE* start, UINT length);\n\n\tUINT64 hash64(const BYTE* start, UINT length);\n\n\n\n\ttemplate <class T> inline UINT32 hash32(const T& obj) {\n\n\t\treturn hash32((const BYTE*)&obj, sizeof(T));\n\n\t}\n\n\n\n\ttemplate <class T> inline UINT64 hash64(const T& obj) {\n\n\t\treturn hash64((const BYTE*)&obj, sizeof(T));\n\n\t}\n\n\n\n\t//\n\n\t// casting\n\n\t//\n\n\tinline UINT castBoolToUINT(bool b) {\n\n\t\tif (b) { return 1; }\n\n\t\telse { return 0; }\n\n\t}\n\n\n\n\ttemplate <class T> inline BYTE boundToByte(T value) {\n\n\t\tif (value < 0) { value = 0; }\n\n\t\tif (value > 255) { value = 255; }\n\n\t\treturn BYTE(value);\n\n\t}\n\n\n\n\ttemplate <class T> inline short boundToShort(T value) {\n\n\t\tif (value <= std::numeric_limits<short>::min()) { return std::numeric_limits<short>::min(); }\n\n\t\tif (value >= std::numeric_limits<short>::max()) { return std::numeric_limits<short>::max(); }\n\n\t\treturn short(value);\n\n\t}\n\n\n\n\t//i/o\n\n\tstd::istream& safeGetline(std::istream& is, std::string& t);\n\n\n\n\t//\n\n\t// file utility\n\n\t//\n\n\tbool fileExists(const std::string& filename);\n\n\t//! returns the file size in bytes\n\n\tsize_t getFileSize(const std::string& filename);\n\n\tvoid copyFile(const std::string& sourceFile, const std::string& destFile);\n\n\tvoid renameFile(const std::string& oldFilename, const std::string& newFilename);\n\n\n\n\t//\n\n\t// There are OS-specific functions\n\n\t//\n\n\tvoid messageBox(const char* string);\n\n\tvoid messageBox(const std::string& S);\n\n\tvoid copyStringToClipboard(const std::string& S);\n\n\tstd::string loadStringFromClipboard();\n\n int runCommand(const std::string& command);\n\n\tint runCommand(const std::string& executablePath, const std::string& commandLine, bool Blocking);\n\n\tvoid makeDirectory(const std::string& directory);\n\n void deleteDirectory(const std::string& directory);\n\n\tvoid clearDirectory(const std::string& directory);\n\n void deleteFile(const std::string& file);\n\n\tbool moveFile(const std::string& currentFile, const std::string& newFile);\n\n\tbool directoryExists(const std::string& directory);\n\n\tstd::string getWorkingDirectory();\t//returns the current working directory\n\n\tbool setWorkingDirectory(const std::string& dir);\t//sets a new working directory; returns true if successful\n\n\tstd::string getExecutablePath();\t//returns the path of the program executable\n\n \n\n inline void runSystemCommand(const std::string &s)\n\n {\n\n\t\t//TODO fix it: this should in theroy call s = util::replace(s, \"/\", \"\\\\\");\n\n system(s.c_str());\n\n }\n\n\n\n\t//\n\n\t// Returns the next line in the given file\n\n\t//\n\n\tstd::vector<std::string> splitPath(const std::string& path);\n\n std::string directoryFromPath(const std::string &path);\n\n std::string fileNameFromPath(const std::string &path);\n\n std::string removeExtensions(const std::string &path);\n\n\tstd::string getNextLine(std::ifstream& file);\n\n\tstd::vector<BYTE> getFileData(const std::string& filename);\n\n\n\n\t//\n\n\t// Returns the set of all lines in the given file\n\n\t//\n\n\tstd::vector<std::string> getFileLines(std::ifstream& file, UINT minLineLength = 0);\n\n\tstd::vector<std::string> getFileLines(const std::string& filename, UINT minLineLength = 0);\n\n\n\n\t//! Save lines to file\n\n\tvoid writeToFile(const std::string &line, const std::string& filename);\n\n\tvoid saveLinesToFile(const std::vector<std::string>& lines, const std::string& filename);\n\n\n\n\t//\n\n\t// FILE wrappers\n\n\t//\n\n\tinline FILE* checkedFOpen(const char* filename, const char* mode) {\n\n if (!util::fileExists(filename) && std::string(mode) == \"rb\")\n\n {\n\n std::cout << \"File not found: \" << filename << std::endl;\n\n return nullptr;\n\n }\n\n\t\tFILE* file = fopen(filename, mode);\n\n\t\tMLIB_ASSERT_STR(file != nullptr && !ferror(file), std::string(\"Failed to open file: \") + std::string(filename));\n\n\t\treturn file;\n\n\t}\n\n\n\n inline FILE* checkedFOpen(const std::string &filename, const char* mode) {\n\n return checkedFOpen(filename.c_str(), mode);\n\n }\n\n\n\n\tinline void checkedFRead(void* dest, UINT64 elementSize, UINT64 elementCount, FILE* file) {\n\n\t\tUINT64 elementsRead = fread(dest, elementSize, elementCount, file);\n\n\t\tMLIB_ASSERT_STR(!ferror(file) && elementsRead == elementCount, \"fread failed\");\n\n\t}\n\n\n\n\tinline void checkedFWrite(const void* Src, UINT64 elementSize, UINT64 elementCount, FILE* file) {\n\n\t\tUINT64 elementsWritten = fwrite(Src, elementSize, elementCount, file);\n\n\t\tMLIB_ASSERT_STR(!ferror(file) && elementsWritten == elementCount, \"fwrite failed\");\n\n\t}\n\n\n\n\tinline void checkedFSeek(UINT offset, FILE* file) {\n\n\t\tint result = fseek(file, offset, SEEK_SET); (void) result; // Silence unused warning\n\n\t\tMLIB_ASSERT_STR(!ferror(file) && result == 0, \"fseek failed\");\n\n\t}\n\n\n\n template<class T, class U>\n\n void insert(T &vec, const U &iterable)\n\n {\n\n vec.insert(iterable.begin(), iterable.end());\n", "file_path": "include/core-util/utility.h", "rank": 4, "score": 114296.85816059839 }, { "content": "namespace ml {\n\n\n\nnamespace intersection {\n\n\n\n //2D line-line intersection\n\n template <class T>\n\n bool intersectLine2Line2(const Line2<T> &lineA, const Line2<T> &lineB, vec2<T> &result)\n\n {\n\n //\n\n // http://www.ahinson.com/algorithms_general/Sections/Geometry/ParametricLineIntersection.pdf\n\n //\n\n\n\n const vec2<T> d21 = lineA.dir();\n\n const vec2<T> d43 = lineB.dir();\n\n const vec2<T> d31 = lineB.p0() - lineA.p0();\n\n\n\n const float d = d43.x * d21.y - d21.x * d43.y;\n\n if (d == 0.0f)\n\n {\n\n return false;\n\n }\n\n \n\n //(bx(cy - ay) + by(ax - cx)) / (dx.by - dy.bx)\n\n const float tA = (d43.x * d31.y - d31.x * d43.y) / d;\n\n result = lineA.p0() + tA * lineA.dir();\n\n\n\n //float distA = distSq(lineA, result);\n\n //float distB = distSq(lineB, result);\n\n\n\n return true;\n\n }\n\n\n\n //2D line-line intersection\n\n template <class T>\n\n bool intersectLineSegment2LineSegment2(const LineSegment2<T> &lineA, const LineSegment2<T> &lineB, vec2<T> &result)\n\n {\n\n //\n\n // http://www.ahinson.com/algorithms_general/Sections/Geometry/ParametricLineIntersection.pdf\n\n //\n\n\n\n const vec2<T> d21 = lineA.delta();\n\n const vec2<T> d43 = lineB.delta();\n\n const vec2<T> d31 = lineB.p0() - lineA.p0();\n\n\n\n const float d = d43.x * d21.y - d21.x * d43.y;\n\n if (d == 0.0f)\n\n {\n\n return false;\n\n }\n\n\n\n //(bx(cy - ay) + by(ax - cx)) / (dx.by - dy.bx)\n\n const float tA = (d43.x * d31.y - d31.x * d43.y) / d;\n\n const float tB = (d21.x * d31.y - d31.x * d21.y) / d;\n\n if (tA < 0.0f || tA > 1.0f || tB < 0.0f || tB > 1.0f)\n\n return false;\n\n \n\n result = lineA.p0() + tA * lineA.delta();\n\n\n\n //float distA = distSq(lineA, result);\n\n //float distB = distSq(lineB, result);\n\n\n\n return true;\n\n }\n\n\n\n template <class FloatType>\n\n bool intersectRayTriangle(\n\n const Triangle<FloatType>& triangle, const Ray<FloatType> &r, FloatType& _t, FloatType& _u, FloatType& _v, FloatType tmin = (FloatType)0, FloatType tmax = std::numeric_limits<FloatType>::max(), bool intersectOnlyFrontFaces = false)\n\n {\n\n return intersectRayTriangle(triangle.vertices[0], triangle.vertices[1], triangle.vertices[2], r, _t, _u, _v, tmin, tmax, intersectOnlyFrontFaces);\n\n }\n\n\n\n\t//triangle ray\n\n\ttemplate <class FloatType>\n\n\tbool intersectRayTriangle(\n\n\t\tconst vec3<FloatType>& v0, const vec3<FloatType>& v1, const vec3<FloatType>& v2, const Ray<FloatType> &r, FloatType& _t, FloatType& _u, FloatType& _v, FloatType tmin = (FloatType)0, FloatType tmax = std::numeric_limits<FloatType>::max(), bool intersectOnlyFrontFaces = false) \n\n\t{\n\n\t\tconst vec3<FloatType> &d = r.getDirection();\n\n\t\tconst vec3<FloatType> &p = r.getOrigin();\n\n\n\n\t\tvec3<FloatType> e1 = v1 - v0;\n\n\t\tvec3<FloatType> e2 = v2 - v0;\n\n\n\n\t\tif (intersectOnlyFrontFaces) {\n\n\t\t\tvec3<FloatType> n = e1^e2; n.normalize();\n\n\t\t\tif ((d | n) > (FloatType)0.0) return false;\n\n\t\t}\n\n\n\n\t\tvec3<FloatType> h = d^e2;\n\n\t\tFloatType a = e1 | h;\n\n\n\n\t\t//if (a > -0.0000000001 && a < 0.0000000001) return false;\n\n\t\tif (a == (FloatType)0.0 || a == -(FloatType)0.0)\treturn false;\n\n\n\n\t\tFloatType f = (FloatType)1.0/a;\n\n\t\tvec3<FloatType> s = p - v0;\n\n\t\tFloatType u = f * (s | h);\n\n\n\n\t\tif (u < (FloatType)0.0 || u > (FloatType)1.0)\treturn false;\n\n\n\n\t\tvec3<FloatType> q = s^e1;\n\n\t\tFloatType v = f * (d | q);\n\n\n\n\t\tif (v < (FloatType)0.0 || u + v > (FloatType)1.0)\treturn false;\n\n\n\n\t\t// at this stage we can compute t to find out where the intersection point is on the line\n\n\t\tFloatType t = f * (e2 | q);\n\n\n\n\t\t//if (t > 0.0000000001 && t < r.t) {\n\n\t\t//if (t < _t) {\n\n\t\tif (t <= tmax && t >= tmin) {\n\n\t\t\t_t = t;\n\n\t\t\t_u = u;\n\n\t\t\t_v = v;\n\n\t\t\treturn true;\n\n\t\t} else {\n\n\t\t\treturn false;\n\n\t\t}\n\n\n\n\t}\n\n\n\n\t//triangle ray\n\n\ttemplate <class FloatType>\n\n\tbool intersectRayBox(\n\n\t\tconst vec3<FloatType>& boxmin, vec3<FloatType>& boxmax, const Ray<FloatType> &r, FloatType& _tmin, FloatType& _tmax, FloatType tmin = (FloatType)0, FloatType tmax = std::numeric_limits<FloatType>::max())\n\n\t{\n\n\t\tconst FloatType t0 = tmin;\n\n\t\tconst FloatType t1 = tmax;\n\n\n\n\t\tFloatType txmin, txmax, tymin, tymax, tzmin, tzmax;\n\n\n\n\t\tauto sign = r.getSign();\n\n\t\tauto origin = r.getOrigin();\n\n\t\tauto invDir = r.getInverseDirection();\n\n\n\n\t\tvec6<FloatType> parameters(boxmin, boxmax);\n\n\t\ttxmin = (parameters[sign.x * 3] - origin.x) * invDir.x;\n\n\t\ttxmax = (parameters[3 - sign.x * 3] - origin.x) * invDir.x;\n\n\t\ttymin = (parameters[sign.y * 3 + 1] - origin.y) * invDir.y;\n\n\t\ttymax = (parameters[3 - sign.y * 3 + 1] - origin.y) * invDir.y;\n\n\n\n\t\tif ((txmin > tymax) || (tymin > txmax)) return false;\n\n\n\n\t\tif (tymin > txmin)\ttxmin = tymin;\n\n\t\tif (tymax < txmax)\ttxmax = tymax;\n\n\n\n\t\ttzmin = (parameters[sign.z * 3 + 2] - origin.z) * invDir.z;\n\n\t\ttzmax = (parameters[3 - sign.z * 3 + 2] - origin.z) * invDir.z;\n\n\n\n\t\tif ((txmin > tzmax) || (tzmin > txmax))\n\n\t\t\treturn false;\n\n\t\tif (tzmin > txmin)\n\n\t\t\ttxmin = tzmin;\n\n\t\tif (tzmax < txmax)\n\n\t\t\ttxmax = tzmax;\n\n\t\t_tmin = std::max(t0, txmin);\n\n\t\t_tmax = std::min(t1, txmax);\n\n\t\treturn ((txmin <= t1) && (txmax >= t0));\n\n\t}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t// sort so that a<=b \n\n\ttemplate<class FloatType>\n\n\tvoid SORT(FloatType& a, FloatType& b) {\n\n\t\tif (a > b) {\n\n\t\t\tstd::swap(a,b);\n\n\t\t}\n\n\t}\n\n\n\n\t// this edge to edge test is based on Franlin Antonio's gem:\n\n //\"Faster Line Segment Intersection\", in Graphics Gems III,\n\n //pp. 199-202\n\n\ttemplate<class FloatType> \n\n\tbool EDGE_EDGE_TEST(\n\n\t\tconst vec3<FloatType>& V0, \n\n\t\tconst vec3<FloatType>& U0, \n\n\t\tconst vec3<FloatType>& U1,\n\n\t\tunsigned short i0, unsigned short i1,\n\n\t\tvec2<FloatType>& a,\n\n\t\tvec2<FloatType>& b, \n\n\t\tvec2<FloatType>& c,\n\n\t\tFloatType& d,\n\n\t\tFloatType& e,\n\n\t\tFloatType& f) \n\n\t{\n\n\n\n\t\tb.x = U0[i0] - U1[i0];\n\n\t\tb.y = U0[i1] - U1[i1];\n\n\t\tc.x = V0[i0] - U0[i0];\n\n\t\tc.y = V0[i1] - U0[i1];\n\n\n\n\t\tf = a.y*b.x - a.x*b.y;\n\n\t\td = b.y*c.x - b.x*c.y;\n\n\n\n\t\tif((f>0 && d>=0 && d<=f) || (f<0 && d<=0 && d>=f)) \t{ \n\n\t\t\te=a.x*c.y-a.y*c.x; \n\n\t\t\tif (f>0)\t{ \n\n\t\t\t\tif(e>=0 && e<=f) {return true;} \n\n\t\t\t} else { \n\n\t\t\t\tif(e<=0 && e>=f) {return true;} \n\n\t\t\t} \n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\t\n\n\n\n\ttemplate<class FloatType> \n\n\tbool EDGE_AGAINST_TRI_EDGES(\n\n\t\tconst vec3<FloatType>& V0,\n\n\t\tconst vec3<FloatType>& V1,\n\n\t\tconst vec3<FloatType>& U0,\n\n\t\tconst vec3<FloatType>& U1,\n\n\t\tconst vec3<FloatType>& U2,\n\n\t\tunsigned short i0, unsigned short i1)\n\n\t{\n\n\t\tvec2<FloatType> a, b, c;\n\n\t\tFloatType e,d,f; \n\n\t\ta.x = V1[i0]-V0[i0]; \n\n\t\ta.y = V1[i1]-V0[i1]; \n\n\t\t//test edge U0,U1 against V0,V1 \n\n\t\tif (EDGE_EDGE_TEST(V0,U0,U1,i0,i1,a,b,c,d,e,f)) return true; \n\n\t\t//test edge U1,U2 against V0,V1 \n\n\t\tif (EDGE_EDGE_TEST(V0,U1,U2,i0,i1,a,b,c,d,e,f)) return true; \n\n\t\t//test edge U2,U1 against V0,V1 \n\n\t\tif (EDGE_EDGE_TEST(V0,U2,U0,i0,i1,a,b,c,d,e,f)) return true;\n\n\n\n\t\treturn false;\n\n\t}\n\n\n\n\n\n\ttemplate<class FloatType> \n\n\tbool POINT_IN_TRI(\n\n\t\tconst vec3<FloatType>& V0,\n\n\t\tconst vec3<FloatType>& U0,\n\n\t\tconst vec3<FloatType>& U1,\n\n\t\tconst vec3<FloatType>& U2,\n\n\t\tunsigned short i0, unsigned short i1) \n\n\t{ \n\n\t\tFloatType a,b,c,d0,d1,d2; \n\n\t\t//is T1 completely inside T2? \n\n\t\t//check if V0 is inside tri(U0,U1,U2)\n\n\t\ta=U1[i1]-U0[i1]; \n\n\t\tb=-(U1[i0]-U0[i0]); \n\n\t\tc=-a*U0[i0]-b*U0[i1]; \n\n\t\td0=a*V0[i0]+b*V0[i1]+c; \n\n\n\n\t\ta=U2[i1]-U1[i1]; \n\n\t\tb=-(U2[i0]-U1[i0]); \n\n\t\tc=-a*U1[i0]-b*U1[i1]; \n\n\t\td1=a*V0[i0]+b*V0[i1]+c; \n\n\n\n\t\ta=U0[i1]-U2[i1]; \n\n\t\tb=-(U0[i0]-U2[i0]); \n\n\t\tc=-a*U2[i0]-b*U2[i1]; \n\n\t\td2=a*V0[i0]+b*V0[i1]+c; \n\n\t\tif (d0*d1 > (FloatType)0.0) { \n\n\t\t\tif (d0*d2 > (FloatType)0.0) return true; \n\n\t\t} \n\n\t\treturn false;\n\n\t}\n\n\n\n\n\n\ttemplate<class FloatType>\n\n\tbool coplanar_tri_tri(\n\n\t\tconst vec3<FloatType>& N,\n\n\t\tconst vec3<FloatType>& V0,\n\n\t\tconst vec3<FloatType>& V1,\n\n\t\tconst vec3<FloatType>& V2,\n\n\t\tconst vec3<FloatType>& U0,\n\n\t\tconst vec3<FloatType>& U1,\n\n\t\tconst vec3<FloatType>& U2)\n\n\t{\n\n\t\tvec3<FloatType> A;\n\n\t\tshort i0,i1;\n\n\t\t// first project onto an axis-aligned plane, that maximizes the area \n\n\t\t// of the triangles, compute indices: i0,i1. \n\n\t\tA[0] = math::abs(N[0]);\n\n\t\tA[1] = math::abs(N[1]);\n\n\t\tA[2] = math::abs(N[2]);\n\n\t\tif(A[0]>A[1])\t{\n\n\t\t\tif(A[0]>A[2])\t{\n\n\t\t\t\ti0=1; // A[0] is greatest\n\n\t\t\t\ti1=2;\n\n\t\t\t} else\t{\n\n\t\t\t\ti0=0; // A[2] is greatest\n\n\t\t\t\ti1=1;\n\n\t\t\t}\n\n\t\t} \n\n\t\telse // A[0]<=A[1] \n\n\t\t{\n\n\t\t\tif(A[2]>A[1]) {\n\n\t\t\t\ti0=0; // A[2] is greatest \n\n\t\t\t\ti1=1;\n\n\t\t\t} else {\n\n\t\t\t\ti0=0; // A[1] is greatest \n\n\t\t\t\ti1=2;\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\t// test all edges of triangle 1 against the edges of triangle 2 \n\n\t\tif (EDGE_AGAINST_TRI_EDGES(V0,V1,U0,U1,U2,i0,i1))\treturn true;\n\n\t\tif (EDGE_AGAINST_TRI_EDGES(V1,V2,U0,U1,U2,i0,i1))\treturn true;\n\n\t\tif (EDGE_AGAINST_TRI_EDGES(V2,V0,U0,U1,U2,i0,i1))\treturn true;\n\n\n\n\t\t// finally, test if tri1 is totally contained in tri2 or vice versa \n\n\t\tif (POINT_IN_TRI(V0,U0,U1,U2,i0,i1)) return true;\n\n\t\tif (POINT_IN_TRI(U0,V0,V1,V2,i0,i1)) return true;\n\n\n\n\t\treturn false;\n\n\t}\n\n\n\n\n\n\t//returns true if coplanar\n\n\ttemplate<class FloatType>\n\n\tbool NEWCOMPUTE_INTERVALS(\n\n\t\tconst vec3<FloatType>& v0,\n\n\t\tconst vec3<FloatType>& v1,\n\n\t\tconst vec3<FloatType>& v2,\n\n\t\tconst vec3<FloatType>& u0,\n\n\t\tconst vec3<FloatType>& u1,\n\n\t\tconst vec3<FloatType>& u2,\n\n\t\tconst vec3<FloatType>& n1,\n\n\t\tFloatType& VV0,FloatType& VV1,FloatType& VV2, \n\n\t\tFloatType& D0, FloatType& D1, FloatType& D2, \n\n\t\tFloatType& D0D1, FloatType& D0D2,\n\n\t\tFloatType& A, FloatType& B, FloatType& C, FloatType& X0, FloatType& X1) \n\n\t{\n\n\t\tif(D0D1>(FloatType)0.0)\n\n\t\t{\n\n\t\t\t// here we know that D0D2<=0.0\n\n\t\t\t// that is D0, D1 are on the same side, D2 on the other or on the plane\n\n\t\t\tA=VV2; B=(VV0-VV2)*D2; C=(VV1-VV2)*D2; X0=D2-D0; X1=D2-D1;\n\n\t\t}\t\n\n\t\telse if(D0D2>(FloatType)0.0)\n\n\t\t{ \n\n\t\t\t// here we know that d0d1<=0.0\n\n\t\t\tA=VV1; B=(VV0-VV1)*D1; C=(VV2-VV1)*D1; X0=D1-D0; X1=D1-D2;\n\n\t\t}\n\n\t\telse if(D1*D2>(FloatType)0.0 || D0!=(FloatType)0.0)\n\n\t\t{\n\n\t\t\t// here we know that d0d1<=0.0 or that D0!=0.0\n\n\t\t\tA=VV0; B=(VV1-VV0)*D0; C=(VV2-VV0)*D0; X0=D0-D1; X1=D0-D2; \n\n\t\t} \n\n\t\telse if(D1!=(FloatType)0.0)\n\n\t\t{\n\n\t\t\tA=VV1; B=(VV0-VV1)*D1; C=(VV2-VV1)*D1; X0=D1-D0; X1=D1-D2;\n\n\t\t}\n\n\t\telse if(D2!=(FloatType)0.0)\n\n\t\t{\n\n\t\t\tA=VV2; B=(VV0-VV2)*D2; C=(VV1-VV2)*D2; X0=D2-D0; X1=D2-D1;\n\n\t\t}\n\n\t\telse\n\n\t\t{\n\n\t\t\t//triangles are co-planar\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\n\n\ttemplate<class FloatType>\n\n\tbool intersectTriangleTriangle(\n\n\t\tconst vec3<FloatType> &v0,\n\n\t\tconst vec3<FloatType> &v1,\n\n\t\tconst vec3<FloatType> &v2,\n\n\t\tconst vec3<FloatType> &u0,\n\n\t\tconst vec3<FloatType> &u1,\n\n\t\tconst vec3<FloatType> &u2) \n\n\t{\n\n\t\tconst bool USE_EPSILON_TEST = true;\n\n\t\tconst FloatType EPSILON = (FloatType)0.000001;\n\n\n\n\t\t//compute plane equation of triangle(V0,V1,V2)\n\n\t\tvec3<FloatType> e1 = v1 - v0;\n\n\t\tvec3<FloatType> e2 = v2 - v0;\n\n\t\tvec3<FloatType> n1 = e1 ^ e2;\n\n\t\tFloatType d1 = - n1 | v0;\n\n\t\t//plane equation 1: N1.X+d1=0 */\n\n\n\n\t\t//put U0,U1,U2 into plane equation 1 to compute signed distances to the plane\n\n\t\tFloatType du0 = (n1 | u0)+d1;\n\n\t\tFloatType du1 = (n1 | u1)+d1;\n\n\t\tFloatType du2 = (n1 | u2)+d1;\n\n\n\n\t\t//co-planarity robustness check\n\n//#if USE_EPSILON_TEST==TRUE\n\n\t\tif (USE_EPSILON_TEST) {\n\n\t\t\tif(math::abs(du0)<EPSILON) du0=(FloatType)0.0;\n\n\t\t\tif(math::abs(du1)<EPSILON) du1=(FloatType)0.0;\n\n\t\t\tif(math::abs(du2)<EPSILON) du2=(FloatType)0.0;\n\n\t\t}\n\n//#endif\n\n\t\tFloatType du0du1 = du0*du1;\n\n\t\tFloatType du0du2 = du0*du2;\n\n\n\n\t\tif (du0du1 > (FloatType)0.0 && du0du2 > (FloatType)0.0) //same sign on all of them + not equal 0 ? \n\n\t\t\treturn false;\t\t\t\t\t\t\t\t\t\t//no intersection occurs\n\n\n\n\t\t// compute plane of triangle (U0,U1,U2) \n\n\t\te1 = u1 - u0;\n\n\t\te2 = u2 - u0;\n\n\t\tvec3<FloatType> n2 = e1 ^ e2;\n\n\t\tFloatType d2 = -(n2 | u0);\n\n\t\t// plane equation 2: N2.X+d2=0 \n\n\n\n\t\t// put V0,V1,V2 into plane equation 2 \n\n\t\tFloatType dv0 = (n2 | v0)+d2;\n\n\t\tFloatType dv1 = (n2 | v1)+d2;\n\n\t\tFloatType dv2 = (n2 | v2)+d2;\n\n\n\n//#if USE_EPSILON_TEST==TRUE\n\n\t\tif (USE_EPSILON_TEST) {\n\n\t\t\tif(math::abs(dv0)<EPSILON) dv0 = (FloatType)0.0;\n\n\t\t\tif(math::abs(dv1)<EPSILON) dv1 = (FloatType)0.0;\n\n\t\t\tif(math::abs(dv2)<EPSILON) dv2 = (FloatType)0.0;\n\n\t\t}\n\n//#endif\n\n\n\n\t\tFloatType dv0dv1=dv0*dv1;\n\n\t\tFloatType dv0dv2=dv0*dv2;\n\n\n\n\t\tif(dv0dv1>(FloatType)0.0 && dv0dv2>(FloatType)0.0) //same sign on all of them + not equal 0 ?\n\n\t\t\treturn false; // no intersection occurs\n\n\n\n\t\t// compute direction of intersection line\n\n\t\tvec3<FloatType> D = (n1^n2);\n\n\n\n\t\t// compute and index to the largest component of D\n\n\t\tFloatType max = (FloatType)math::abs(D[0]);\n\n\t\tunsigned int index=0;\n\n\t\tFloatType bb=(FloatType)math::abs(D[1]);\n\n\t\tFloatType cc=(FloatType)math::abs(D[2]);\n\n\t\tif(bb>max) max=bb,index=1;\n\n\t\tif(cc>max) max=cc,index=2;\n\n\n\n\t\t// this is the simplified projection onto L\n\n\t\tFloatType vp0=v0[index];\n\n\t\tFloatType vp1=v1[index];\n\n\t\tFloatType vp2=v2[index];\n\n\n\n\t\tFloatType up0=u0[index];\n\n\t\tFloatType up1=u1[index];\n\n\t\tFloatType up2=u2[index];\n\n\n\n\t\t// compute interval for triangle 1\n\n\t\tFloatType a,b,c,x0,x1;\n\n\t\tif (NEWCOMPUTE_INTERVALS(u0,u1,u2,v0,v1,v2,n1,vp0,vp1,vp2,dv0,dv1,dv2,dv0dv1,dv0dv2,a,b,c,x0,x1)) {\n\n\t\t\treturn (coplanar_tri_tri(n1,v0,v1,v2,u0,u1,u2));\t//triangles are a co-planar\n\n\t\t}\n\n\n\n\t\t// compute interval for triangle 2 \n\n\t\tFloatType d,e,f,y0,y1;\n\n\t\tif (NEWCOMPUTE_INTERVALS(u0,u1,u2,v0,v1,v2,n1,up0,up1,up2,du0,du1,du2,du0du1,du0du2,d,e,f,y0,y1)) {\n\n\t\t\treturn (coplanar_tri_tri(n1,v0,v1,v2,u0,u1,u2));\t//triangles are a co-planar\n\n\t\t}\n\n\n\n\t\tFloatType xx,yy,xxyy,tmp;\n\n\t\txx=x0*x1;\n\n\t\tyy=y0*y1;\n\n\t\txxyy=xx*yy;\n\n\n\n\t\tvec2<FloatType> isect1, isect2;\n\n\n\n\t\ttmp=a*xxyy;\n\n\t\tisect1[0]=tmp+b*x1*yy;\n\n\t\tisect1[1]=tmp+c*x0*yy;\n\n\n\n\t\ttmp=d*xxyy;\n\n\t\tisect2[0]=tmp+e*xx*y1;\n\n\t\tisect2[1]=tmp+f*xx*y0;\n\n\n\n\t\tSORT(isect1[0],isect1[1]);\n\n\t\tSORT(isect2[0],isect2[1]);\n\n\n\n\t\tif(isect1[1]<isect2[0] || isect2[1]<isect1[0]) return false;\n\n\t\treturn true;\n\n\n\n\t}\n\n\n\n\n\n\n\n//\n\n////////////////////////////////////////////////////////\n\n//// Triangle ABBB: http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/code/tribox3.txt\n\n////////////////////////////////////////////////////////\n\n//\ttemplate<class FloatType>\n\n//\tvoid FINDMINMAX(FloatType x0, FloatType x1, FloatType x2, FloatType& min, FloatType& max) {\n\n//\t\tmin = max = x0;\n\n//\t\tif(x1<min) min=x1;\n\n//\t\tif(x1>max) max=x1;\n\n//\t\tif(x2<min) min=x2;\n\n//\t\tif(x2>max) max=x2;\n\n//\t}\n\n//\n\n//\n\n//\t//I think this test is somehow broken :) - it's not being used at this point...\n\n//\ttemplate<class FloatType>\n\n//\tbool intersectTriangleABBB2(\n\n//\t\tconst vec3<FloatType> &bbBoxMin,\n\n//\t\tconst vec3<FloatType> &bbBoxMax,\n\n//\t\tconst vec3<FloatType> &t0,\n\n//\t\tconst vec3<FloatType> &t1,\n\n//\t\tconst vec3<FloatType> &t2) \n\n//\t{\n\n//\t\tconst vec3<FloatType> boxcenter = (FloatType)0.5*(bbBoxMax + bbBoxMin);\n\n//\t\tconst vec3<FloatType> boxhalfsize = (FloatType)0.5*(bbBoxMax - bbBoxMin);\n\n//\n\n//\t\t//use separating axis theorem to test overlap between triangle and box\n\n//\t\t//need to test for overlap in these directions:\n\n//\t\t//1) the {x,y,z}-directions (actually, since we use the AABB of the triangle \n\n//\t\t//we do not even need to test these) \n\n//\t\t//2) normal of the triangle \n\n//\t\t//3) crossproduct(edge from tri, {x,y,z}-directin)\n\n//\t\t//this gives 3x3=9 more tests\n\n//\n\n//\t\t// float axis[3];\n\n//\t\tFloatType min,max,p0,p1,p2,rad,fex,fey,fez;\t\t// -NJMP- \"d\" local variable removed\n\n//\t\t\t\t\n\n//\t\t//This is the fastest branch on Sun \n\n//\t\t//move everything so that the boxcenter is in (0,0,0)\n\n//\t\tvec3<FloatType> v0 = t0 - boxcenter;\n\n//\t\tvec3<FloatType> v1 = t1 - boxcenter;\n\n//\t\tvec3<FloatType> v2 = t2 - boxcenter;\n\n//\n\n//\t\t//compute triangle edges\n\n//\t\tvec3<FloatType> e0 = v1 - v0;\t//tri edge 0\n\n//\t\tvec3<FloatType> e1 = v2 - v1;\t//tri edge 1\n\n//\t\tvec3<FloatType> e2 = v0 - v2;\t//tri edge 2\n\n//\t\t\n\n//\t\t//Bullet 3:\n\n//\t\t//test the 9 tests first (this was faster)\n\n//\n\n//\t\tfex = math::abs(e0.x);\n\n//\t\tfey = math::abs(e0.y);\n\n//\t\tfez = math::abs(e0.z);\n\n//\n\n//\t\t//AXISTEST_X01(e0.z, e0.y, fez, fey);\n\n//\t\t{\n\n//\t\t\tFloatType a = e0.z;\n\n//\t\t\tFloatType b = e0.y;\n\n//\t\t\tFloatType fa = fez;\n\n//\t\t\tFloatType fb = fey;\n\n//\t\t\tp0 = a*v0.y - b*v0.z;\t\n\n//\t\t\tp2 = a*v2.y - b*v2.z;\n\n//\t\t\tif(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \n\n//\t\t\trad = fa * boxhalfsize.y + fb * boxhalfsize.z; \n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\t\t\n\n//\t\t//AXISTEST_Y02(e0.z, e0.x, fez, fex);\n\n//\t\t{\n\n//\t\t\tFloatType a = e0.z;\n\n//\t\t\tFloatType b = e0.x;\n\n//\t\t\tFloatType fa = fez;\n\n//\t\t\tFloatType fb = fex;\n\n//\t\t\tp0 = -a*v0.x + b*v0.z;\n\n//\t\t\tp2 = -a*v2.x + b*v2.z;\n\n//\t\t\tif(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;}\n\n//\t\t\trad = fa * boxhalfsize.x + fb * boxhalfsize.z;\n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\t\t//AXISTEST_Z12(e0.y, e0.x, fey, fex);\n\n//\t\t{\n\n//\t\t\tFloatType a = e0.y;\n\n//\t\t\tFloatType b = e0.x;\n\n//\t\t\tFloatType fa = fey;\n\n//\t\t\tFloatType fb = fex;\n\n//\t\t\tp1 = a*v1.x - b*v1.y;\n\n//\t\t\tp2 = a*v2.x - b*v2.y;\n\n//\t\t\tif(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;}\n\n//\t\t\trad = fa * boxhalfsize.x + fb * boxhalfsize.y;\n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\n\n//\t\tfex = math::abs(e1.x);\n\n//\t\tfey = math::abs(e1.y);\n\n//\t\tfez = math::abs(e1.x);\n\n//\n\n//\t\t//AXISTEST_X01(e1[Z], e1[Y], fez, fey);\n\n//\t\t{\n\n//\t\t\tFloatType a = e1.z;\n\n//\t\t\tFloatType b = e1.y;\n\n//\t\t\tFloatType fa = fez;\n\n//\t\t\tFloatType fb = fey;\n\n//\t\t\tp0 = a*v0.y - b*v0.z;\t\n\n//\t\t\tp2 = a*v2.y - b*v2.z;\n\n//\t\t\tif(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} \n\n//\t\t\trad = fa * boxhalfsize.y + fb * boxhalfsize.z; \n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\t\t//AXISTEST_Y02(e1[Z], e1[X], fez, fex);\n\n//\t\t{\n\n//\t\t\tFloatType a = e1.z;\n\n//\t\t\tFloatType b = e1.x;\n\n//\t\t\tFloatType fa = fez;\n\n//\t\t\tFloatType fb = fex;\n\n//\t\t\tp0 = -a*v0.x + b*v0.z;\n\n//\t\t\tp2 = -a*v2.x + b*v2.z;\n\n//\t\t\tif(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;}\n\n//\t\t\trad = fa * boxhalfsize.x + fb * boxhalfsize.z;\n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\t\t//AXISTEST_Z0(e1[Y], e1[X], fey, fex);\n\n//\t\t{\n\n//\t\t\tFloatType a = e1.y;\n\n//\t\t\tFloatType b = e1.x;\n\n//\t\t\tFloatType fa = fey;\n\n//\t\t\tFloatType fb = fex;\n\n//\t\t\tp0 = a*v0.x - b*v0.y;\t\n\n//\t\t\tp1 = a*v1.x - b*v1.y;\n\n//\t\t\tif(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;}\n\n//\t\t\trad = fa * boxhalfsize.x + fb * boxhalfsize.y;\n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\n\n//\t\tfex = math::abs(e2.x);\n\n//\t\tfey = math::abs(e2.y);\n\n//\t\tfez = math::abs(e2.z);\n\n//\n\n//\t\t//AXISTEST_X2(e2[Z], e2[Y], fez, fey);\n\n//\t\t{\n\n//\t\t\tFloatType a = e2.z;\n\n//\t\t\tFloatType b = e2.y;\n\n//\t\t\tFloatType fa = fez;\n\n//\t\t\tFloatType fb = fey;\n\n//\t\t\tp0 = a*v0.y - b*v0.z;\n\n//\t\t\tp1 = a*v1.y - b*v1.z;\n\n//\t\t\tif(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;}\n\n//\t\t\trad = fa * boxhalfsize.y + fb * boxhalfsize.z;\n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\t\t//AXISTEST_Y1(e2[Z], e2[X], fez, fex);\n\n//\t\t{\n\n//\t\t\tFloatType a = e2.z;\n\n//\t\t\tFloatType b = e2.x;\n\n//\t\t\tFloatType fa = fez;\n\n//\t\t\tFloatType fb = fex;\n\n//\t\t\tp0 = -a*v0.x + b*v0.x;\n\n//\t\t\tp1 = -a*v1.x + b*v1.x;\n\n//\t\t\tif(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;}\n\n//\t\t\trad = fa * boxhalfsize.x + fb * boxhalfsize.z;\n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\t\t//AXISTEST_Z12(e2[Y], e2[X], fey, fex);\n\n//\t\t{\n\n//\t\t\tFloatType a = e2.y;\n\n//\t\t\tFloatType b = e2.x;\n\n//\t\t\tFloatType fa = fey;\n\n//\t\t\tFloatType fb = fex;\n\n//\t\t\tp1 = a*v1.x - b*v1.y;\n\n//\t\t\tp2 = a*v2.x - b*v2.y;\n\n//\t\t\tif(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;}\n\n//\t\t\trad = fa * boxhalfsize.x + fb * boxhalfsize.y;\n\n//\t\t\tif(min>rad || max<-rad) return false;\n\n//\t\t}\n\n//\t\t\n\n//\t\t//Bullet 1:\n\n//\t\t//first test overlap in the {x,y,z}-directions\n\n//\t\t//find min, max of the triangle each direction, and test for overlap in\n\n//\t\t//that direction -- this is equivalent to testing a minimal AABB around\n\n//\t\t//the triangle against the AABB\n\n//\t\t\n\n//\t\t//test in X-direction\n\n//\t\tFINDMINMAX(v0.x,v1.x,v2.x,min,max);\n\n//\t\tif(min>boxhalfsize.x || max<-boxhalfsize.x) return false;\n\n//\n\n//\t\t//test in Y-direction\n\n//\t\tFINDMINMAX(v0.y,v1.y,v2.y,min,max);\n\n//\t\tif(min>boxhalfsize.y || max<-boxhalfsize.y) return false;\n\n//\t\t\n\n//\t\t//test in Z-direction\n\n//\t\tFINDMINMAX(v0.z,v1.z,v2.z,min,max);\n\n//\t\tif(min>boxhalfsize.z || max<-boxhalfsize.z) return false;\n\n//\t\t\n\n//\t\t//Bullet 2:\n\n//\t\t//test if the box intersects the plane of the triangle \n\n//\t\t//compute plane equation of triangle: normal*x+d=0\n\n//\n\n//\t\tvec3<FloatType> normal = e0 ^ e1;\n\n//\n\n//\t\t// -NJMP- (line removed here)\n\n//\t\t//if(!planeBoxOverlap(normal,v0,boxhalfsize)) return false;\t// -NJMP-\n\n//\t\t{\n\n//\t\t\tvec3<FloatType> vert = v0;\n\n//\t\t\tvec3<FloatType> maxbox = boxhalfsize;\n\n//\t\t\t//int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3])\t// -NJMP-\n\n//\n\n//\t\t\tvec3<FloatType> vmin,vmax;\n\n//\n\n//\t\t\tfor (unsigned int q = 0; q<=2; q++) {\n\n//\t\t\t\tFloatType v = vert[q];\t\t\t\t\t// -NJMP-\n\n//\t\t\t\tif (normal[q]>0.0f) {\n\n//\t\t\t\t\tvmin[q]=-maxbox[q] - v;\t// -NJMP-\n\n//\t\t\t\t\tvmax[q]= maxbox[q] - v;\t// -NJMP-\n\n//\t\t\t\t} else {\n\n//\t\t\t\t\tvmin[q]= maxbox[q] - v;\t// -NJMP-\n\n//\t\t\t\t\tvmax[q]=-maxbox[q] - v;\t// -NJMP-\n\n//\t\t\t\t}\n\n//\t\t\t}\n\n//\n\n//\t\t\tif ((normal | vmin) > (FloatType)0.0) return false;\t// -NJMP-\n\n//\t\t\tif ((normal | vmax) >= (FloatType)0.0) return true;\t// -NJMP-\n\n//\n\n//\t\t\treturn false;\n\n//\t\t}\t\t\n\n//\n\n//\t\treturn true; //box and triangle overlaps \n\n//\t}\n\n\n\n\n\n\n\n\t//! returns 1 if intersects; 0 if front; -1 if back\n\n\ttemplate<class FloatType>\n\n\tint intersectBoxPlane(\n\n\t\tconst vec3<FloatType>& bbBoxMin,\n\n\t\tconst vec3<FloatType>& bbBoxMax,\n\n\t\tconst Plane<FloatType>& plane) \n\n\t{\n\n\t\tFloatType BOX_PLANE_EPSILON = (FloatType)0.00001;\n\n\n\n\t\tvec3<FloatType> center = (FloatType)0.5 * (bbBoxMin + bbBoxMax);\n\n\t\tvec3<FloatType> extent = bbBoxMax - center;\n\n\t\tFloatType _fOrigin = plane.getNormal() | center;\n\n\t\tFloatType _fMaximumExtent = extent | math::abs(plane.getNormal());\n\n\t\tFloatType _fmin = _fOrigin - _fMaximumExtent;\n\n\t\tFloatType _fmax = _fOrigin + _fMaximumExtent;\n\n\n\n\t\tif (plane.getDistance() > _fmax + BOX_PLANE_EPSILON) {\n\n\t\t\treturn -1;\n\n\t\t\t//return G_BACK_PLANE; // 0\n\n\t\t}\n\n\n\n\t\tif (plane.getDistance() + BOX_PLANE_EPSILON >=_fmin) {\n\n\t\t\treturn 1;\n\n\t\t\t//return G_COLLIDE_PLANE; //1\n\n\t\t}\n\n\t\treturn 0;\n\n\t\t//return G_FRONT_PLANE;//2\n\n\t}\n\n\n\n\n\n#define TEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,i_dir_0,i_dir_1,i_comp_0,i_comp_1)\\\n\n{\\\n\n\tconst FloatType dir0 = -edge[i_dir_0];\\\n\n\tconst FloatType dir1 = edge[i_dir_1];\\\n\n\tFloatType pmin = pointa[i_comp_0]*dir0 + pointa[i_comp_1]*dir1;\\\n\n\tFloatType pmax = pointb[i_comp_0]*dir0 + pointb[i_comp_1]*dir1;\\\n\n\tif(pmin>pmax)\\\n\n\t{\\\n\n\tstd::swap(pmin,pmax); \\\n\n\t}\\\n\n\tconst FloatType abs_dir0 = absolute_edge[i_dir_0];\\\n\n\tconst FloatType abs_dir1 = absolute_edge[i_dir_1];\\\n\n\tconst FloatType rad = _extend[i_comp_0] * abs_dir0 + _extend[i_comp_1] * abs_dir1;\\\n\n\tif(pmin>rad || -rad>pmax) return false;\\\n\n}\\\n\n\n\n\n\n#define TEST_CROSS_EDGE_BOX_X_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\\\n\n{\\\n\n\tTEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,2,1,1,2);\\\n\n}\\\n\n\n\n#define TEST_CROSS_EDGE_BOX_Y_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\\\n\n{\\\n\n\tTEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,0,2,2,0);\\\n\n}\\\n\n\n\n#define TEST_CROSS_EDGE_BOX_Z_AXIS_MCR(edge,absolute_edge,pointa,pointb,_extend)\\\n\n{\\\n\n\tTEST_CROSS_EDGE_BOX_MCR(edge,absolute_edge,pointa,pointb,_extend,1,0,0,1);\\\n\n}\\\n\n\n\n\n\n\t////////////from BULLET///////////////\n\n\ttemplate<class FloatType>\n\n\tbool intersectTriangleAABB(\n\n\t\tconst vec3<FloatType> &bbBoxMin,\n\n\t\tconst vec3<FloatType> &bbBoxMax,\n\n\t\tconst vec3<FloatType> &p0,\n\n\t\tconst vec3<FloatType> &p1,\n\n\t\tconst vec3<FloatType> &p2) \n\n\t{\n\n\t\t//TODO\n\n\t\t//if(!collide_plane(triangle_plane)) return false;\n\n\t\tif (intersectBoxPlane(bbBoxMin, bbBoxMax, Plane<FloatType>(p0,p1,p2)) != 1) return false;\n\n\n\n\t\tvec3<FloatType> center = (FloatType)0.5 * (bbBoxMin + bbBoxMax);\n\n\t\tvec3<FloatType> extent = bbBoxMax - center;\n\n\n\n\t\tconst vec3<FloatType> v1(p0 - center);\n\n\t\tconst vec3<FloatType> v2(p1 - center);\n\n\t\tconst vec3<FloatType> v3(p2 - center);\n\n\n\n\t\t//First axis\n\n\t\tvec3<FloatType> diff(v2 - v1);\n\n\t\tvec3<FloatType> abs_diff = math::abs(diff);\n\n\t\t//Test With X axis\n\n\t\tTEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v1,v3,extent);\n\n\t\t//Test With Y axis\n\n\t\tTEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v1,v3,extent);\n\n\t\t//Test With Z axis\n\n\t\tTEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v1,v3,extent);\n\n\n\n\n\n\t\tdiff = v3 - v2;\n\n\t\tabs_diff = math::abs(diff);\n\n\t\t//Test With X axis\n\n\t\tTEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v2,v1,extent);\n\n\t\t//Test With Y axis\n\n\t\tTEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v2,v1,extent);\n\n\t\t//Test With Z axis\n\n\t\tTEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v2,v1,extent);\n\n\n\n\t\tdiff = v1 - v3;\n\n\t\tabs_diff = math::abs(diff);\n\n\t\t//Test With X axis\n\n\t\tTEST_CROSS_EDGE_BOX_X_AXIS_MCR(diff,abs_diff,v3,v2,extent);\n\n\t\t//Test With Y axis\n\n\t\tTEST_CROSS_EDGE_BOX_Y_AXIS_MCR(diff,abs_diff,v3,v2,extent);\n\n\t\t//Test With Z axis\n\n\t\tTEST_CROSS_EDGE_BOX_Z_AXIS_MCR(diff,abs_diff,v3,v2,extent);\n\n\n\n\t\treturn true;\n\n\n\n\t}\n\n\n\n\ttemplate<class FloatType> \n\n\tFloatType halfEdgeTest(const vec2<FloatType>& p1, const vec2<FloatType>& p2, const vec2<FloatType>& p3) {\n\n\t\treturn (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);\n\n\t}\n\n\n\n\t//2d test whether the point inside of the triangle (eps makes the triangle bigger)\n\n\ttemplate<class FloatType>\n\n\tbool intersectTrianglePoint(\n\n\t\tconst vec2<FloatType> &v1,\n\n\t\tconst vec2<FloatType> &v2,\n\n\t\tconst vec2<FloatType> &v3,\n\n\t\tconst vec2<FloatType> &pt) \n\n\t{\n\n\t\tbool b1, b2, b3;\n\n\n\n\t\tb1 = halfEdgeTest(pt, v1, v2) < (FloatType)0.0;\n\n\t\tb2 = halfEdgeTest(pt, v2, v3) < (FloatType)0.0;\n\n\t\tb3 = halfEdgeTest(pt, v3, v1) < (FloatType)0.0;\n\n\n\n\t\treturn ((b1 == b2) && (b2 == b3));\n\n\t}\n\n\n\n\ttemplate<class FloatType>\n\n\tbool intersectOBBOBB(\n\n\t\tconst vec3<FloatType>& anchor0, const vec3<FloatType>* axesScaled0,\n\n\t\tconst vec3<FloatType>& anchor1, const vec3<FloatType>* axesScaled1) \n\n\t{\n\n\t\tstruct Result\n\n\t\t{\n\n\t\t\t// The 'epsilon' value must be nonnegative.\n\n\t\t\tResult(FloatType inEpsilon = (FloatType)0) {\n\n\t\t\t\tif (inEpsilon >= (FloatType)0)\t{\n\n\t\t\t\t\tepsilon = inEpsilon;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tepsilon = (FloatType)0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\n\t\t\tbool intersect;\n\n\t\t\tFloatType epsilon;\n\n\t\t\tint separating[2];\n", "file_path": "include/core-graphics/intersection.h", "rank": 5, "score": 114296.85816059839 }, { "content": "namespace ml {\n\n\n\n\n\n////\n\n//// TODO: this should be moved into an intersect class\n\n////\n\n//namespace math {\n\n//bool triangleIntersectTriangle(const ml::vec3f &t0v0, const ml::vec3f &t0v1, const ml::vec3f &t0v2, const ml::vec3f &t1v0, const ml::vec3f &t1v1, const ml::vec3f &t1v2);\n\n//\n\n//bool triangleIntersectTriangle(const ml::vec3f t0[3], const ml::vec3f t1[3]);\n\n//}\n\n\n\n\n\ntemplate <class T>\n\nT distSq(const vec2<T> &ptA, const vec2<T> &ptB)\n\n{\n\n return vec2<T>::distSq(ptA, ptB);\n\n}\n\n\n\ntemplate <class T>\n\nT distSq(const vec3<T> &ptA, const vec3<T> &ptB)\n\n{\n\n return vec3<T>::distSq(ptA, ptB);\n\n}\n\n\n\ntemplate <class T>\n\nT distSq(const LineSegment2<T> &seg, const vec2<T> &p)\n\n{\n\n const vec2<T> &v = seg.p0();\n\n const vec2<T> &w = seg.p1();\n\n \n\n //\n\n // http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment\n\n // Return minimum distance between line segment vw and point p\n\n //\n\n const T l2 = distSq(v, w); // i.e. |w-v|^2 - avoid a sqrt\n\n if (l2 == (T)0.0) return distSq(p, v); // v == w case\n\n\n\n //\n\n // Consider the line extending the segment, parameterized as v + t (w - v).\n\n // We find projection of point p onto the line. \n\n // It falls where t = [(p-v) . (w-v)] / |w-v|^2\n\n //\n\n const T t = ((p - v) | (w - v)) / l2;\n\n if (t < (T)0.0) return distSq(p, v); // Beyond the 'v' end of the segment\n\n else if (t > (T)1.0) return distSq(p, w); // Beyond the 'w' end of the segment\n\n const vec2<T> projection = v + t * (w - v); // Projection falls on the segment\n\n return distSq(p, projection);\n\n}\n\n\n\ntemplate <class T>\n\nT distSq(const Line2<T> &line, const vec2<T> &pt)\n\n{\n\n const vec2<T> diff = line.dir();\n\n const T d = diff.lengthSq();\n\n const vec2<T> p0 = line.p0();\n\n const vec2<T> p1 = line.p0() + line.dir();\n\n T n = fabs(diff.y * pt.x - diff.x * pt.y + p1.x * p0.y - p1.y * p0.x);\n\n return n / d;\n\n}\n\n\n\ntemplate <class T>\n\nT distSq(const OrientedBoundingBox3<T> &box, const vec3<T> &pt)\n\n{\n\n //\n\n // This is wrong, this file is just meant as an example of the dist interface\n\n //\n\n return vec3<T>::distSq(box.getCenter(), pt);\n\n}\n\n\n\ntemplate <class T>\n\nT distSq(const vec3<T> &pt, const OrientedBoundingBox3<T> &box)\n\n{\n\n return distSq(box, pt);\n\n}\n\n\n\n//\n\n// code adapted from http://geomalgorithms.com/a07-_distance.html#dist3D_Segment_to_Segment\n\n//\n\ntemplate <class T>\n\ndouble distSq(const LineSegment2<T> &s0, const LineSegment2<T> &s1)\n\n{\n\n const vec2<T> u = s0.delta();\n\n const vec2<T> v = s1.delta();\n\n const vec2<T> w = s0.p0() - s1.p0();\n\n double a = vec2<T>::dot(u, u); // always >= 0\n\n double b = vec2<T>::dot(u, v);\n\n double c = vec2<T>::dot(v, v); // always >= 0\n\n double d = vec2<T>::dot(u, w);\n\n double e = vec2<T>::dot(v, w);\n\n double D = a * c - b * b; // always >= 0\n\n double sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0\n\n double tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0\n\n\n\n // compute the line parameters of the two closest points\n\n if (D < 1e-6) { // the lines are almost parallel\n\n sN = 0.0; // force using point P0 on segment S1\n\n sD = 1.0; // to prevent possible division by 0.0 later\n\n tN = e;\n\n tD = c;\n\n }\n\n else { // get the closest points on the infinite lines\n\n sN = (b*e - c*d);\n\n tN = (a*e - b*d);\n\n if (sN < 0.0) { // sc < 0 => the s=0 edge is visible\n\n sN = 0.0;\n\n tN = e;\n\n tD = c;\n\n }\n\n else if (sN > sD) { // sc > 1 => the s=1 edge is visible\n\n sN = sD;\n\n tN = e + b;\n\n tD = c;\n\n }\n\n }\n\n\n\n if (tN < 0.0) { // tc < 0 => the t=0 edge is visible\n\n tN = 0.0;\n\n // recompute sc for this edge\n\n if (-d < 0.0)\n\n sN = 0.0;\n\n else if (-d > a)\n\n sN = sD;\n\n else {\n\n sN = -d;\n\n sD = a;\n\n }\n\n }\n\n else if (tN > tD) { // tc > 1 => the t=1 edge is visible\n\n tN = tD;\n\n // recompute sc for this edge\n\n if ((-d + b) < 0.0)\n\n sN = 0;\n\n else if ((-d + b) > a)\n\n sN = sD;\n\n else {\n\n sN = (-d + b);\n\n sD = a;\n\n }\n\n }\n\n // finally do the division to get sc and tc\n\n sc = (std::abs(sN) < 1e-6 ? 0.0 : sN / sD);\n\n tc = (std::abs(tN) < 1e-6 ? 0.0 : tN / tD);\n\n\n\n // get the difference of the two closest points\n\n const vec2<T> dP = w + ((float)sc * u) - ((float)tc * v); // = S1(sc) - S2(tc)\n\n\n\n return dP.lengthSq(); // return the closest distance\n\n}\n\n\n\ntemplate <class T, class U>\n\ndouble distSq(const std::vector<T> &collectionA, const std::vector<U> &collectionB)\n\n{\n\n double minDistSq = std::numeric_limits<double>::max();\n\n for (const T &a : collectionA)\n\n {\n\n for (const U &b : collectionB)\n\n {\n\n double curDistSq = distSq(a, b);\n\n if (curDistSq < minDistSq)\n\n {\n\n minDistSq = curDistSq;\n\n }\n\n }\n\n }\n\n return minDistSq;\n\n}\n\n\n\ntemplate <class A, class B>\n\ndouble dist(const A &a, const B &b)\n\n{\n\n return sqrt(distSq(a, b));\n\n}\n\n\n", "file_path": "include/core-graphics/dist.h", "rank": 6, "score": 114296.85816059839 }, { "content": "namespace ml {\n\n\n\n\n\n//! Quaternions are used to describe rotations\n\ntemplate <class FloatType> class Quaternion {\n\n\tpublic:\n\n\t\t//! construct a quaternion that does no rotation\n\n\t\tQuaternion() : m_Real(1), m_Imag(0,0,0) {}\n\n\n\n\t\tQuaternion(FloatType r, FloatType i, FloatType j, FloatType k) {\n\n\t\t\tm_Real = r;\n\n\t\t\tm_Imag = vec3<FloatType>(i,j,k);\n\n\t\t}\n\n\n\n\t\t//! construct a quaternion explicitly\n\n\t\tQuaternion( FloatType real, const vec3<FloatType>& imag ) : m_Real(real), m_Imag(imag) {}\n\n\n\n\t\t//! construct a quaternion given a rotation-axis and an angle (in degrees)\n\n\t\tQuaternion( const vec3<FloatType>& axis, FloatType angle ) {\n\n\t\t\tFloatType halfAngleRad = ( FloatType ) math::PI * angle / ( FloatType ) 360.0;\n\n\t\t\tFloatType axisLength = axis.length();\n\n\t\t\tif ( axisLength > Quaternion<FloatType>::eps ) {\n\n\t\t\t\tm_Real = cos( halfAngleRad );\n\n\t\t\t\tm_Imag = axis * ( sin( halfAngleRad ) / axisLength );\n\n\t\t\t} else {\n\n\t\t\t\tm_Real = 1;\n\n\t\t\t\tm_Imag = vec3<FloatType>( 0, 0, 0 );\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\t//! Constructs a quaternion between a start and end point\n\n\t\tQuaternion(const vec3<FloatType>& from, const vec3<FloatType>& to) {\n\n\t\t\t//vec3<FloatType> vecHalf = (from + to).getNormalized();\n\n\t\t\t//m_Real = vecHalf | to;\n\n\t\t\t//m_Imag = vecHalf ^ to;\n\n\n\n\t\t\tvec3<FloatType> v0 = from.getNormalized();\n\n\t\t\tvec3<FloatType> v1 = to.getNormalized();\n\n\n\n\t\t\tconst FloatType d = v0 | v1;\n\n\t\t\tif (d >= (FloatType)1.0) // If dot == 1, vectors are the same\n\n\t\t\t{\n\n\t\t\t\tsetIdentity();\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\telse if (d <= (FloatType)-1.0) // exactly opposite\n\n\t\t\t{\n\n\t\t\t\tvec3<FloatType> axis(1.0, 0.0, 0.0);\n\n\t\t\t\taxis = axis ^ v0;\n\n\t\t\t\tif (axis.length()==0)\n\n\t\t\t\t{\n\n\t\t\t\t\taxis = vec3<FloatType>(0.0,1.0,0.0);\n\n\t\t\t\t\taxis = axis ^ v0;\n\n\t\t\t\t}\n\n\t\t\t\tm_Imag = axis.getNormalized();\n\n\t\t\t\tm_Real = 0;\n\n\t\t\t\tnormalize();\n\n\t\t\t\treturn;\n\n\t\t\t\t//return set(axis.X, axis.Y, axis.Z, 0).normalize();\n\n\t\t\t}\n\n\n\n\t\t\tconst FloatType s = sqrt( (1+d)*2 ); // optimize inv_sqrt\n\n\t\t\tconst FloatType invs = (FloatType)1.0 / s;\n\n\t\t\tconst vec3<FloatType> c = (v0^v1)*invs;\n\n\t\t\tm_Imag = c;\n\n\t\t\tm_Real = s*(FloatType)0.5;\n\n\t\t\tnormalize();\n\n\t\t\t//return set(c.X, c.Y, c.Z, s * 0.5f).normalize();\n\n\t\t}\n\n\n\n\n\n\t\tinline float sgn(float x) {return (x >= 0.0f) ? +1.0f : -1.0f;}\n\n\n\n\t\tQuaternion(const Matrix4x4<FloatType>& m) {\n\n\t\t\tassert(m.isAffine());\n\n\t\t\tconstructFromMatrix(m.getMatrix3x3());\n\n\t\t}\n\n\n\n\t\t//! construct a quaternion based on a matrix: todo check that!\n\n\t\tQuaternion(const Matrix3x3<FloatType>& m) {\n\n\t\t\tconstructFromMatrix(m);\n\n\t\t}\n\n\n\n\t\t//! sets the quaternion to 1,0,0,0 (i.e., no rotation)\n\n\t\tinline void setIdentity() {\n\n\t\t\tm_Real = 1;\n\n\t\t\tm_Imag = vec3<FloatType>(0,0,0);\n\n\t\t}\n\n\n\n\t\t//! query the real part of the quaternion\n\n\t\tinline FloatType real() const;\n\n\t\t//! query the imaginary part of the quaternion\n\n\t\tinline vec3<FloatType> imag() const;\n\n\n\n\t\t//! return quaternion as LinAl vector\n\n\t\t//inline doubleVec LinAlVec() const;\n\n\n\n\t\t//! set real part of the quaternion\n\n\t\tinline void setReal( const FloatType r );\n\n\n\n\t\t//! set imaginary part of the quaternion\n\n\t\tinline void setImag( const vec3<FloatType>& imag );\n\n\n\n\t\t//! query the axis of the rotation described by the quaternion\n\n\t\tvec3<FloatType> axis() const;\n\n\t\t//! query the angle of the rotation described by the quaternion in radians\n\n\t\tinline FloatType angleRad() const;\n\n\t\t//! query the angle of the rotation described by the quaternion in degrees\n\n\t\tinline FloatType angleDeg() const;\n\n\t\t//! query the transformation-matrix of the rotation described by the quaternion\n\n\t\tinline Matrix4x4<FloatType> matrix4x4() const {\n\n\t\t\treturn Matrix4x4<FloatType>(matrix3x3());\n\n\t\t}\n\n\t\tinline Matrix3x3<FloatType> matrix3x3() const {\n\n\n\n\t\t\tQuaternion q = getNormalized();\n\n\t\t\tMatrix3x3<FloatType> m;\n\n\t\t\tm(0,0) = q.m_Real*q.m_Real + q.m_Imag[0]*q.m_Imag[0] - q.m_Imag[1]*q.m_Imag[1] - q.m_Imag[2]*q.m_Imag[2];\n\n\t\t\tm(0,1) = (FloatType)2.0 * (q.m_Imag[0]*q.m_Imag[1] - q.m_Real*q.m_Imag[2]);\n\n\t\t\tm(0,2) = (FloatType)2.0 * (q.m_Imag[0]*q.m_Imag[2] + q.m_Real*q.m_Imag[1]);\n\n\n\n\t\t\tm(1,0) = (FloatType)2.0 * (q.m_Imag[0]*q.m_Imag[1] + q.m_Real*q.m_Imag[2]);\n\n\t\t\tm(1,1) = q.m_Real*q.m_Real - q.m_Imag[0]*q.m_Imag[0] + q.m_Imag[1]*q.m_Imag[1] - q.m_Imag[2]*q.m_Imag[2];\n\n\t\t\tm(1,2) = (FloatType)2.0 * (q.m_Imag[1]*q.m_Imag[2] - q.m_Real*q.m_Imag[0]);\n\n\n\n\t\t\tm(2,0) = (FloatType)2.0 * (q.m_Imag[0]*q.m_Imag[2] - q.m_Real*q.m_Imag[1]);\n\n\t\t\tm(2,1) = (FloatType)2.0 * (q.m_Imag[1]*q.m_Imag[2] + q.m_Real*q.m_Imag[0]);\n\n\t\t\tm(2,2) = q.m_Real*q.m_Real - q.m_Imag[0]*q.m_Imag[0] - q.m_Imag[1]*q.m_Imag[1] + q.m_Imag[2]*q.m_Imag[2];\n\n\n\n\t\t\treturn m;\n\n\t\t}\n\n\n\n\t\t//! returns the squared length of the quaternion\n\n\t\tinline FloatType sqrLength() const;\n\n\t\t//! returns the length of the quaternion\n\n\t\tinline FloatType length() const;\n\n\n\n\t\t//! return the normalized quaternion as a copy\n\n\t\tinline Quaternion getNormalized() const;\n\n\t\t//! sets the length of the quaternion to one\n\n\t\tinline void normalize();\n\n\n\n\t\t//! the absolute-value of a quaternion is its length\n\n\t\t//inline FloatType abs(const Quaternion& q);\n\n\t\t//! the multiplication operator that allows the scalar value to precede the quaternion\n\n\t\t//inline Quaternion operator* (FloatType r, const Quaternion& q);\n\n\n\n\n\n\t\t//! add two quaternions\n\n\t\tinline Quaternion operator+ ( const Quaternion& b ) const;\n\n\t\t//! add quaternion b to operand\n\n\t\tinline void operator+=( const Quaternion& b );\n\n\n\n\t\tinline vec3<FloatType> operator* (const vec3<FloatType>& v) const {\n\n\t\t\tvec3<FloatType> uv = m_Imag ^ v;\n\n\t\t\tvec3<FloatType> uuv = m_Imag ^ uv;\n\n\t\t\tuv *= ((FloatType)2.0 * m_Real);\n\n\t\t\tuuv *= (FloatType)2.0f;\n\n\t\t\treturn v + uv + uuv;\n\n\t\t}\n\n\n\n\t\t//! multiply two quaternions\n\n\t\tinline Quaternion operator* ( const Quaternion& b ) const;\n\n\t\t//! multiply quaternions b to operand\n\n\t\tinline Quaternion operator*=( const Quaternion& b );\n\n\n\n\t\t//! scale quaternion with a scalar\n\n\t\tinline Quaternion operator* ( FloatType r ) const;\n\n\t\t//! multiply quaternion with a scalar\n\n\n\n\t\tinline void operator*=( FloatType r );\n\n\t\t//! divide quaternion by scalar\n\n\t\tinline Quaternion operator/ ( FloatType r ) const;\n\n\t\t//! divide quaternion by scalar\n\n\t\tinline void operator/=( FloatType r );\n\n\n\n\t\t//! returns the scalar-product of the quaternion with the argument\n\n\t\tinline FloatType scalarProd( const Quaternion& b ) const;\n\n\n\n\t\t//! return the conjugated quaternion\n\n\t\tinline Quaternion getConjugated() const;\n\n\n\n\t\t//! return the quaternion that performs the inverse rotation\n\n\t\tinline Quaternion getInverse() const;\n\n\t\t//! set the quaternion to the one that performs the inverse rotation\n\n\t\tinline void invert();\n\n\n\n\t\t//! calculates a spherical linear interpolation between the quaternions\n\n\t\t/*! If t==0 the result is the quaternion from which the method was called.\n\n\t\t If t==1 the result is the quaternion q2.\n\n\t\t between the quaternions are weighted\n\n\t\t*/\n\n\t\tQuaternion slerp( const Quaternion& q2, FloatType t ) const;\n\n\n\n\tprivate:\n\n\t\t\n\n\t\tvoid constructFromMatrix( const Matrix3x3<FloatType>& m )\n\n\t\t{\n\n\t\t\tFloatType m00 = m(0,0);\tFloatType m01 = m(0,1);\tFloatType m02 = m(0,2);\n\n\t\t\tFloatType m10 = m(1,0);\tFloatType m11 = m(1,1);\tFloatType m12 = m(1,2);\n\n\t\t\tFloatType m20 = m(2,0);\tFloatType m21 = m(2,1);\tFloatType m22 = m(2,2);\n\n\n\n\t\t\tFloatType tr = m00 + m11 + m22;\n\n\n\n\t\t\tFloatType qw, qx, qy, qz;\n\n\t\t\tif (tr > 0) { \n\n\t\t\t\tFloatType S = sqrt(tr+(FloatType)1.0) * 2; // S=4*qw \n\n\t\t\t\tqw = (FloatType)0.25 * S;\n\n\t\t\t\tqx = (m21 - m12) / S;\n\n\t\t\t\tqy = (m02 - m20) / S; \n\n\t\t\t\tqz = (m10 - m01) / S; \n\n\t\t\t} else if ((m00 > m11)&(m00 > m22)) { \n\n\t\t\t\tFloatType S = sqrt((FloatType)1.0 + m00 - m11 - m22) * (FloatType)2; // S=4*qx \n\n\t\t\t\tqw = (m21 - m12) / S;\n\n\t\t\t\tqx = (FloatType)0.25 * S;\n\n\t\t\t\tqy = (m01 + m10) / S; \n\n\t\t\t\tqz = (m02 + m20) / S; \n\n\t\t\t} else if (m11 > m22) { \n\n\t\t\t\tFloatType S = sqrt((FloatType)1.0 + m11 - m00 - m22) * (FloatType)2; // S=4*qy\n\n\t\t\t\tqw = (m02 - m20) / S;\n\n\t\t\t\tqx = (m01 + m10) / S; \n\n\t\t\t\tqy = (FloatType)0.25 * S;\n\n\t\t\t\tqz = (m12 + m21) / S; \n\n\t\t\t} else { \n\n\t\t\t\tFloatType S = sqrt((FloatType)1.0 + m22 - m00 - m11) * (FloatType)2; // S=4*qz\n\n\t\t\t\tqw = (m10 - m01) / S;\n\n\t\t\t\tqx = (m02 + m20) / S;\n\n\t\t\t\tqy = (m12 + m21) / S;\n\n\t\t\t\tqz = (FloatType)0.25 * S;\n\n\t\t\t}\n\n\t\t\tm_Real = qw;\n\n\t\t\tm_Imag = vec3<FloatType>(qx,qy,qz);\n\n\n\n\t\t\t/*\n\n\t\t\tFloatType r11 = m(0,0);\tFloatType r12 = m(0,1);\tFloatType r13 = m(0,2);\n\n\t\t\tFloatType r21 = m(1,0);\tFloatType r22 = m(1,1);\tFloatType r23 = m(1,2);\n\n\t\t\tFloatType r31 = m(2,0);\tFloatType r32 = m(2,1);\tFloatType r33 = m(2,2);\n\n\n\n\t\t\tFloatType q0 = ( r11 + r22 + r33 + 1.0f) / 4.0f;\n\n\t\t\tFloatType q1 = ( r11 - r22 - r33 + 1.0f) / 4.0f;\n\n\t\t\tFloatType q2 = (-r11 + r22 - r33 + 1.0f) / 4.0f;\n\n\t\t\tFloatType q3 = (-r11 - r22 + r33 + 1.0f) / 4.0f;\n\n\t\t\tif(q0 < 0.0f) q0 = 0.0f;\n\n\t\t\tif(q1 < 0.0f) q1 = 0.0f;\n\n\t\t\tif(q2 < 0.0f) q2 = 0.0f;\n\n\t\t\tif(q3 < 0.0f) q3 = 0.0f;\n\n\t\t\tq0 = sqrt(q0);\n\n\t\t\tq1 = sqrt(q1);\n\n\t\t\tq2 = sqrt(q2);\n\n\t\t\tq3 = sqrt(q3);\n\n\t\t\tif(q0 >= q1 && q0 >= q2 && q0 >= q3) {\n\n\t\t\tq0 *= +1.0f;\n\n\t\t\tq1 *= sgn(r32 - r23);\n\n\t\t\tq2 *= sgn(r13 - r31);\n\n\t\t\tq3 *= sgn(r21 - r12);\n\n\t\t\t} else if(q1 >= q0 && q1 >= q2 && q1 >= q3) {\n\n\t\t\tq0 *= sgn(r32 - r23);\n\n\t\t\tq1 *= +1.0f;\n\n\t\t\tq2 *= sgn(r21 + r12);\n\n\t\t\tq3 *= sgn(r13 + r31);\n\n\t\t\t} else if(q2 >= q0 && q2 >= q1 && q2 >= q3) {\n\n\t\t\tq0 *= sgn(r13 - r31);\n\n\t\t\tq1 *= sgn(r21 + r12);\n\n\t\t\tq2 *= +1.0f;\n\n\t\t\tq3 *= sgn(r32 + r23);\n\n\t\t\t} else if(q3 >= q0 && q3 >= q1 && q3 >= q2) {\n\n\t\t\tq0 *= sgn(r21 - r12);\n\n\t\t\tq1 *= sgn(r31 + r13);\n\n\t\t\tq2 *= sgn(r32 + r23);\n\n\t\t\tq3 *= +1.0f;\n\n\t\t\t} else {\n\n\t\t\tprintf(\"coding error\\n\");\n\n\t\t\t}\n\n\t\t\tFloatType r = vec4<FloatType>(q0, q1, q2, q3).length();\n\n\t\t\tq0 /= r;\n\n\t\t\tq1 /= r;\n\n\t\t\tq2 /= r;\n\n\t\t\tq3 /= r;\n\n\n\n\t\t\tre = q3;\n\n\t\t\tim = vec3<FloatType>(q0,q1,q2);\n\n\t\t\t*/\n\n\t\t}\n\n\n\n\n\n\t\tFloatType m_Real;\t\t\t//! the real part of the quaternion\n\n\t\tvec3<FloatType> m_Imag;\t//! the imaginary part of the quaternion\n\n\n\n\t\t//! read a quaternion from a stream\n\n\t\ttemplate <class T> friend std::istream& operator>> ( std::istream& s, Quaternion<FloatType>& q );\n\n\n\n\t\tstatic const FloatType eps;\n", "file_path": "include/core-math/quaternion.h", "rank": 7, "score": 114296.85816059839 }, { "content": "namespace ml {\n\n\n\ntemplate<class T>\n\nstruct Triangle\n\n{\n\n Triangle() {}\n\n Triangle(const vec3<T> &v0, const vec3<T> &v1, const vec3<T> &v2)\n\n {\n\n vertices[0] = v0;\n\n vertices[1] = v1;\n\n vertices[2] = v2;\n\n }\n\n vec3<T> getNormal() const\n\n {\n\n return ml::math::triangleNormal(vertices[0], vertices[1], vertices[2]);\n\n }\n\n\n\n\tfloat getArea() const {\n\n\t\tvec3f ab = vertices[1] - vertices[0];\n\n\t\tvec3f ac = vertices[2] - vertices[0];\n\n\t\tfloat len = ab.length() * ac.length();\n\n\t\tfloat cosTheta = (ab | ac) / len;\n\n\t\tif (fabs(cosTheta + 1) < 0.00001f || fabs(cosTheta - 1) < 0.00001f) {\n\n\t\t\treturn 0;\n\n\t\t}\n\n\t\tfloat theta = std::acos(cosTheta);\n\n\t\tfloat area (0.5f * len * std::sin(theta));\n\n\t\tMLIB_ASSERT(area > 0);\n\n\t\treturn area;\n\n\t}\n\n\n\n vec3<T> vertices[3];\n\n\n\n};\n\n\n\ntypedef Triangle<float> Trianglef;\n\ntypedef Triangle<double> Triangled;\n\n\n", "file_path": "include/core-graphics/triangle.h", "rank": 8, "score": 114296.85816059839 }, { "content": "namespace ml {\n\n\n\n\tnamespace OpenMeshLoader {\n\n\n\n\t\ttypedef OpenMesh::TriMesh_ArrayKernelT<OpenMesh::DefaultTraits> Mesh;\n\n\n\n\t\tstatic TriMeshf load(const std::string& filename) {\n\n\t\t\tMLIB_ASSERT_STR(util::fileExists(filename), \"File not found: \" + filename + \"\\nWorking directory: \" + util::getWorkingDirectory());\n\n\n\n\t\t\tnamespace io = OpenMesh::IO;\n\n\t\t\tio::Options opts = io::Options::VertexColor | io::Options::VertexNormal;\n\n\n\n\t\t\tMesh mesh;\n\n\t\t\tmesh.request_vertex_colors();\n\n\t\t\tmesh.request_vertex_normals();\n\n\n\n\t\t\t// Avoid OpenMesh spewing warnings to console by temporary redirection of cerr\n\n\t\t\t//TODO(ms): Figure out if there's a cleaner way to do this\n\n\t\t\tstd::streambuf *cerrSaved = std::cerr.rdbuf();\n\n\t\t\tstd::stringstream ss;\n\n\t\t\tstd::cerr.rdbuf(ss.rdbuf());\n\n\t\t\tif (!io::read_mesh(mesh, filename, opts)) {\n\n\t\t\t\tMLIB_ERROR(\"error reading from \" + filename);\n\n\t\t\t}\n\n\t\t\tstd::cerr.rdbuf(cerrSaved);\n\n\t\t\tstd::cout << \"done loading \" << filename << std::endl;\n\n\n\n\t\t\tconst size_t nVertices = mesh.n_vertices();\n\n\t\t\tconst size_t nIndices = mesh.n_faces() * 3; // Should always be tri meshes\n\n\t\t\tstd::vector<ml::TriMeshf::Vertex> vertices(nVertices);\n\n\t\t\tstd::vector<UINT> indices(nIndices);\n\n\n\n\t\t\tml::TriMeshf::Vertex mv;\n\n\t\t\tUINT currVertIdx = 0;\n\n\t\t\tfor (Mesh::VertexIter vIt = mesh.vertices_begin(); vIt != mesh.vertices_end(); ++vIt, currVertIdx++) {\n\n\t\t\t\tconst Mesh::Point& p = mesh.point(*vIt); // p is vec3f\n\n\t\t\t\tconst Mesh::Normal& n = mesh.normal(*vIt).normalized(); // n is vec3f\n\n\t\t\t\tconst Mesh::Color& c = mesh.color(*vIt); // c is vec3uc\n\n\t\t\t\tmv.position = p.data();\n\n\t\t\t\tmv.normal = n.data();\n\n\t\t\t\tmv.color = vec4f(c[0] / 255.0f, c[1] / 255.0f, c[2] / 255.0f, 1.0f);\n\n\t\t\t\tvertices[currVertIdx] = mv;\n\n\t\t\t}\n\n\t\t\tUINT currIndexIdx = 0;\n\n\t\t\tfor (Mesh::FaceIter fIt = mesh.faces_begin(); fIt != mesh.faces_end(); ++fIt) {\n\n\t\t\t\tfor (Mesh::FaceVertexIter fvIt = mesh.fv_iter(*fIt);\n\n\t\t\t\t\tfvIt != mesh.fv_end(*fIt); fvIt++, currIndexIdx++) {\n\n\t\t\t\t\tindices[currIndexIdx] = fvIt->idx();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\n\t\t\tMLIB_ASSERT_STR(currVertIdx == nVertices, \"nVertices != vertices parsed\");\n\n\t\t\tMLIB_ASSERT_STR(currIndexIdx == nIndices, \"nIndices != indices parsed\");\n\n\n\n\t\t\treturn TriMeshf(vertices, indices, /* computeNormals=*/ false, /*hasNormals=*/ true, /*hasTexCoords=*/ true, /*hasColors=*/ true);\n\n\t\t}\n\n\n\n\t} // namespace OpenMeshLoader\n\n\n", "file_path": "include/ext-openmesh/loader.h", "rank": 9, "score": 114296.85816059839 }, { "content": "namespace ml\n\n{\n\n\n\n\ttemplate <class T> class Grid3\n\n\t{\n\n\tpublic:\n\n\t\tGrid3();\n\n\t\tGrid3(size_t dimX, size_t dimY, size_t dimZ);\n\n\t\tGrid3(size_t dimX, size_t dimY, size_t dimZ, const T &value);\n\n\t\tGrid3(const vec3ul& dim) : Grid3(dim.x, dim.y, dim.z) {}\n\n\t\tGrid3(const vec3ul& dim, const T& value) : Grid3(dim.x, dim.y, dim.z, value) {}\n\n\n\n\t\tGrid3(const Grid3<T> &grid);\n\n\t\tGrid3(Grid3<T> &&grid);\n\n\t\tGrid3(size_t dimX, size_t dimY, size_t dimZ, const std::function< T(size_t x, size_t y, size_t z) > &fillFunction);\n\n\n\n\t\t~Grid3();\n\n\n\n\t\t//! adl swap\n\n\t\tfriend void swap(Grid3& a, Grid3& b) {\n\n\t\t\tstd::swap(a.m_dimX, b.m_dimX);\n\n\t\t\tstd::swap(a.m_dimY, b.m_dimY);\n\n\t\t\tstd::swap(a.m_dimZ, b.m_dimZ);\n\n\t\t\tstd::swap(a.m_data, b.m_data);\n\n\t\t}\n\n\n\n\t\tGrid3<T>& operator=(const Grid3<T>& grid);\n\n\t\tGrid3<T>& operator=(Grid3<T>&& grid);\n\n\n\n\t\tvoid allocate(size_t dimX, size_t dimY, size_t dimZ);\n\n\t\tvoid allocate(size_t dimX, size_t dimY, size_t dimZ, const T &value);\n\n\t\tvoid allocate(const vec3ul& dim) {\t\t\t\t\t\tallocate(dim.x, dim.y, dim.z);\t\t\t\t}\n\n\t\tvoid allocate(const vec3ul& dim, const T& value) {\t\tallocate(dim.x, dim.y, dim.z, value);\t\t}\n\n\n\n\t\t//\n\n\t\t// Accessors\n\n\t\t//\n\n\t\tinline T& operator() (size_t x, size_t y, size_t z)\t{\n\n\t\t\tMLIB_ASSERT(x < getDimX() && y < getDimY() && z < getDimZ());\n\n\t\t\treturn m_data[getDimX()*getDimY()*z + getDimX()*y + x];\n\n\t\t}\n\n\n\n\t\tinline const T& operator() (size_t x, size_t y, size_t z) const\t{\n\n\t\t\tMLIB_ASSERT(x < getDimX() && y < getDimY() && z < getDimZ());\n\n\t\t\treturn m_data[getDimX()*getDimY()*z + getDimX()*y + x];\n\n\t\t}\n\n\n\n\t\tinline T& operator() (const vec3ul& coord)\t{\n\n\t\t\treturn (*this)(coord.x, coord.y, coord.z);\n\n\t\t}\n\n\n\n\t\tinline const T& operator() (const vec3ul& coord) const\t{\n\n\t\t\treturn (*this)(coord.x, coord.y, coord.z);\n\n\t\t}\n\n\n\n\t\tinline size_t getDimX() const\t{\n\n\t\t\treturn m_dimX;\n\n\t\t}\n\n\t\tinline size_t getDimY() const\t{\n\n\t\t\treturn m_dimY;\n\n\t\t}\n\n\t\tinline size_t getDimZ() const\t{\n\n\t\t\treturn m_dimZ;\n\n\t\t}\n\n\n\n\t\tinline vec3ul getDimensions() const {\n\n\t\t\treturn vec3ul(getDimX(), getDimY(), getDimZ());\n\n\t\t}\n\n\n\n\t\tsize_t getNumElements() const {\n\n\t\t\treturn m_dimX * m_dimY * m_dimZ;\n\n\t\t}\n\n\n\n\t\tinline bool isSquare() const\t{\n\n\t\t\treturn (m_dimX == m_dimY && m_dimY == m_dimZ);\n\n\t\t}\n\n\t\tinline T* getData()\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\t\tinline const T* getData() const\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\n\n\t\tinline Grid3<T>& operator += (const Grid3<T>& right)\n\n\t\t{\n\n\t\t\tMLIB_ASSERT(getDimensions() == right.getDimensions());\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] += right.m_data[i];\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\t\tinline Grid3<T>& operator += (T value)\n\n\t\t{\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] += value;\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\t\tinline Grid3<T>& operator *= (T value)\n\n\t\t{\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] *= value;\n\n\t\t\t}\n\n\t\t\treturn *this;\n", "file_path": "include/core-base/grid3.h", "rank": 10, "score": 114296.85816059839 }, { "content": "namespace ml\n\n{\n\n\ttemplate <class T> class Grid2\n\n\t{\n\n\tpublic:\n\n\t\tGrid2();\n\n\t\tGrid2(size_t dimX, size_t dimY);\n\n\t\tGrid2(size_t dimX, size_t dimY, const T &value);\n\n\t\tGrid2(const vec2ul& dim) : Grid2(dim.x, dim.y) {}\n\n\t\tGrid2(const vec2ul& dim, const T& value) : Grid2(dim.x, dim.y, value) {}\n\n\n\n\t\tGrid2(const Grid2<T> &grid);\n\n\t\tGrid2(Grid2<T> &&grid);\n\n\t\tGrid2(size_t dimX, size_t dimY, const std::function< T(size_t x, size_t y) > &fillFunction);\n\n\n\n\t\t~Grid2();\n\n\n\n\t\t//! adl swap\n\n\t\tfriend void swap(Grid2& a, Grid2& b) {\n\n\t\t\tstd::swap(a.m_dimX, b.m_dimX);\n\n\t\t\tstd::swap(a.m_dimY, b.m_dimY);\n\n\t\t\tstd::swap(a.m_data, b.m_data);\n\n\t\t}\n\n\n\n\t\tGrid2<T>& operator=(const Grid2<T> &grid);\n\n\t\tGrid2<T>& operator=(Grid2<T> &&grid);\n\n\n\n\t\tvoid allocate(size_t dimX, size_t dimY);\n\n\t\tvoid allocate(size_t dimX, size_t dimY, const T& value);\n\n\t\tvoid allocate(const vec2ul& dim) { allocate(dim.x, dim.y); }\n\n\t\tvoid allocate(const vec2ul& dim, const T& value) { allocate(dim.x, dim.y, value); }\n\n\n\n\t\t//\n\n\t\t// Accessors\n\n\t\t//\n\n\t\tinline T& operator() (size_t x, size_t y)\t{\n\n\t\t\tMLIB_ASSERT(x < m_dimX && y < m_dimY);\n\n\t\t\treturn m_data[getDimX()*y + x];\n\n\t\t}\n\n\t\tinline const T& operator() (size_t x, size_t y) const\t{\n\n\t\t\tMLIB_ASSERT(x < m_dimX && y < m_dimY);\n\n\t\t\treturn m_data[getDimX()*y + x];\n\n\t\t}\n\n\n\n\t\tinline T& operator() (const vec2ul& coord)\t{\n\n\t\t\treturn (*this)(coord.x, coord.y);\n\n\t\t}\n\n\n\n\t\tinline const T& operator() (const vec2ul& coord) const\t{\n\n\t\t\treturn (*this)(coord.x, coord.y);\n\n\t\t}\n\n\n\n\t\tinline size_t getDimX() const\t{\n\n\t\t\treturn m_dimX;\n\n\t\t}\n\n\n\n\t\tinline size_t getDimY() const\t{\n\n\t\t\treturn m_dimY;\n\n\t\t}\n\n\n\n\t\tinline vec2ul getDimensions() const {\n\n\t\t\treturn vec2ul(m_dimX, m_dimY);\n\n\t\t}\n\n\n\n\t\tinline size_t getNumElements() const\t{\n\n\t\t\treturn m_dimX * m_dimY;\n\n\t\t}\n\n\n\n\t\tinline bool isSquare() const\t{\n\n\t\t\treturn (m_dimX == m_dimY);\n\n\t\t}\n\n\n\n\t\tinline T* getData()\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\n\n\t\tinline const T* getData() const\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\n\n\n\n\t\tinline Grid2<T>& operator += (const Grid2<T>& right) {\n\n\t\t\tMLIB_ASSERT(getDimensions() == right.getDimensions());\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] += right.m_data[i];\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\tinline Grid2<T>& operator += (T value) {\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++)\n\n\t\t\t\tm_data[i] += value;\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\tinline Grid2<T>& operator *= (T value)\n\n\t\t{\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] *= value;\n\n\t\t\t}\n\n\t\t\treturn *this;\n", "file_path": "include/core-base/grid2.h", "rank": 11, "score": 114296.85816059839 }, { "content": "namespace ml {\n\n\t//////////////////////////////////////////////////////////////////////////\n\n\t// TriMesh Operations (simplification, fairing etc)\t\t\t\t\t\t//\n\n\t//////////////////////////////////////////////////////////////////////////\n\n\n\n\tnamespace OpenMeshTriMesh {\n\n\n\n\n\n\t\t//struct Traits : OpenMesh::DefaultTraits\n\n\t\t//{\n\n\t\t//\ttypedef OpenMesh::Vec3f Point;\n\n\t\t//\ttypedef OpenMesh::Vec3f Normal; \n\n\t\t//\ttypedef OpenMesh::Vec4f Color;\n\n\t\t//\ttypedef OpenMesh::Vec2f TexCoord2D;\n\n\n\n\t\t//\t//VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color | OpenMesh::Attributes::TexCoord2D );\n\n\t\t//\t//FaceAttributes(Attributes::Status | Attributes::Normal);\n\n\t\t//\t//EdgeAttributes(Attributes::Status);\n\n\t\t//};\n\n\n\n\t\t//struct Traits : OpenMesh::DefaultTraits\n\n\t\t//{\n\n\t\t//\ttypedef OpenMesh::Vec3f Point;\n\n\t\t//\ttypedef OpenMesh::Vec3f Normal; \n\n\t\t//\ttypedef OpenMesh::Vec3uc Color;\n\n\t\t//\ttypedef float Scalar;\n\n\n\n\n\n\t\t//\tVertexAttributes(OpenMesh::Attributes::Status| OpenMesh::Attributes::Normal | OpenMesh::Attributes::Color );\n\n\t\t//\tFaceAttributes(OpenMesh::Attributes::Status | OpenMesh::Attributes::Normal);\n\n\t\t//\tEdgeAttributes(OpenMesh::Attributes::Status);\n\n\t\t//};\n\n\n\n\t\ttypedef OpenMesh::TriMesh_ArrayKernelT<> Mesh;\t\t\t\t\t//mesh type\n\n\t\ttypedef OpenMesh::Decimater::DecimaterT< Mesh > Decimater;\t\t\t\t// Decimater type\n\n\t\ttypedef OpenMesh::Decimater::ModQuadricT< Mesh >::Handle HModQuadric;\t// Decimation Module Handle type\n\n\n\n\n\n\t\t/*\n\n\t\tstatic bool Vec3fless(const OpenMesh::Vec3f& v0, const OpenMesh::Vec3f& v1)\n\n\t\t{\n\n\t\t\tif (v0[0] < v1[0]) return true;\n\n\t\t\tif (v0[0] > v1[0]) return false;\n\n\t\t\tif (v0[1] < v1[1]) return true;\n\n\t\t\tif (v0[1] > v1[1]) return false;\n\n\t\t\tif (v0[2] < v1[2]) return true;\n\n\n\n\t\t\treturn false;\n\n\t\t}\n\n\n\n\n\n\t\tunsigned int removeDuplicateVertices(std::vector<OpenMesh::Vec3f>& verts, std::vector<unsigned int>& tris)\n\n\t\t{\n\n\t\t\tint numV = (int)verts.size();\n\n\t\t\tint numT = (int)tris.size();\n\n\n\n\t\t\tstd::map<OpenMesh::Vec3f, int, bool(*)(const OpenMesh::Vec3f&, const OpenMesh::Vec3f&)> pts(Vec3fless);\n\n\n\n\t\t\tstd::vector<unsigned int> vertexLookUp;\n\n\t\t\tvertexLookUp.resize(numV);\n\n\t\t\tstd::vector<OpenMesh::Vec3f> new_verts;\n\n\n\n\t\t\tint cnt = 0;\n\n\t\t\tfor(int i1 = 0; i1 < numV; i1++)\n\n\t\t\t{\n\n\t\t\t\tOpenMesh::Vec3f pt = verts[i1];\n\n\n\n\t\t\t\tstd::map<OpenMesh::Vec3f, int, bool(*)(const OpenMesh::Vec3f&, const OpenMesh::Vec3f&)>::iterator it = pts.find(pt);\n\n\n\n\t\t\t\tif(it != pts.end())\n\n\t\t\t\t{\n\n\t\t\t\t\tvertexLookUp[i1] = it->second;\n\n\t\t\t\t}\n\n\t\t\t\telse\n\n\t\t\t\t{\n\n\t\t\t\t\tpts.insert(std::make_pair(pt, cnt));\n\n\t\t\t\t\tnew_verts.push_back(pt);\n\n\t\t\t\t\tvertexLookUp[i1] = cnt;\n\n\t\t\t\t\tcnt++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\n\t\t\t// Update triangles\n\n\t\t\tfor(std::vector<unsigned int>::iterator it = tris.begin(); it != tris.end(); it++)\n\n\t\t\t{\n\n\t\t\t\t*it = vertexLookUp[*it];\n\n\t\t\t}\n\n\n\n\t\t\tstd::cerr << \"Removed \" << numV-cnt << \" duplicate vertices of \" << numV << \" vertices\" << std::endl;\n\n\t\t\tverts = std::vector<OpenMesh::Vec3f>(new_verts.begin(), new_verts.end());\n\n\n\n\t\t\treturn cnt;\n\n\t\t}\n\n\n\n\n\n\t\tvoid removeDuplicateVertices(Mesh& mesh) {\n\n\n\n\t\t\tstd::vector<unsigned int> indices;\n\n\t\t\tstd::vector<OpenMesh::Vec3f> vertices;\n\n\t\t\t//iterate over all faces\n\n\t\t\tfor (unsigned int i = 0; i < mesh.n_faces(); i++) {\n\n\t\t\t\tOpenMesh::FaceHandle fh(i);\n\n\t\t\t\t//iterate over all vertices in a face\n\n\t\t\t\tfor (Mesh::FaceVertexIter fv_it = mesh.fv_begin(fh); fv_it!=mesh.fv_end(fh); fv_it++) {\n\n\t\t\t\t\tvertices.push_back(mesh.point(fv_it.handle()));\n\n\t\t\t\t}\n\n\t\t\t\tindices.push_back(3 * i + 0); indices.push_back(3 * i + 1); indices.push_back(3 * i + 2);\n\n\t\t\t}\n\n\n\n\t\t\t// Create an indexed face set out of the marching cube triangle soup.\n\n\t\t\tunsigned int cnt = removeDuplicateVertices(vertices, indices);\n\n\n\n\t\t\t// Convert indexed face set triangle mesh into directed edge data structure.\n\n\t\t\tMesh n;\n\n\t\t\tMesh::VertexHandle* vhandle = new Mesh::VertexHandle[cnt];\n\n\n\n\t\t\tfor(unsigned int i = 0; i<cnt; i++)\t{\n\n\t\t\t\tvhandle[i] = n.add_vertex(vertices[i]);\n\n\t\t\t}\n\n\n\n\t\t\tstd::vector<Mesh::VertexHandle> face_vhandles;\n\n\t\t\tstd::cout << indices.size()/3 << std::endl;\n\n\t\t\tstd::cout << vertices.size() << std::endl;\n\n\t\t\tfor(unsigned int i = 0; i<indices.size()/3; i++)\n\n\t\t\t{\n\n\t\t\t\tif(indices[3*i+0] >= cnt ||indices[3*i+1] >= cnt || indices[3*i+2] >= cnt)\n\n\t\t\t\t{\n\n\t\t\t\t\tstd::cout << \"error\" << std::endl;\n\n\t\t\t\t\tgetchar();\n\n\t\t\t\t}\n\n\n\n\t\t\t\t// Check if triangle is degenerated\t\n\n\t\t\t\tif((vhandle[indices[3*i+0]] != vhandle[indices[3*i+1]]) && (vhandle[indices[3*i+1]] != vhandle[indices[3*i+2]]) && (vhandle[indices[3*i+0]] != vhandle[indices[3*i+2]]))\n\n\t\t\t\t{\n\n\t\t\t\t\tface_vhandles.clear();\n\n\t\t\t\t\tface_vhandles.push_back(vhandle[indices[3*i+0]]);\n\n\t\t\t\t\tface_vhandles.push_back(vhandle[indices[3*i+1]]);\n\n\t\t\t\t\tface_vhandles.push_back(vhandle[indices[3*i+2]]);\n\n\t\t\t\t\tn.add_face(face_vhandles);\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\n\t\t\tdelete [] vhandle;\n\n\n\n\t\t\tmesh = n;\n\n\t\t}\n\n\t\t*/\n\n\t\t\n\n\n\n\t\tstatic void convertToOpenMesh(const TriMeshf& triMesh, Mesh& out, bool keepVertexAttributes = false) {\n\n\t\t\tout.clear();\n\n\n\n\t\t\tif (keepVertexAttributes == false) {\n\n\t\t\t\tstd::vector< Mesh::VertexHandle > vHandles;\n\n\t\t\t\tvHandles.reserve(triMesh.getVertices().size());\n\n\n\n\t\t\t\t//TODO ADD NORMALS\n\n\n\n\t\t\t\tfor (const auto& v : triMesh.getVertices()) {\n\n\t\t\t\t\tvHandles.push_back(out.add_vertex(Mesh::Point(v.position.x, v.position.y, v.position.z)));\n\n\t\t\t\t\t//vHandles.push_back(out.add_vertex(\n\n\t\t\t\t\t//\tMesh::Point(v.position.x, v.position.y, v.position.z),\n\n\t\t\t\t\t//\tMesh::Normal(v.normal.x, v.normal.y, v.normal.z),\n\n\t\t\t\t\t//\tMesh::Color(v.color.x, v.color.y, v.color.z, v.color.w),\n\n\t\t\t\t\t//\tMesh::TexCoord2D(v.texCoord.x, v.texCoord.y)\n\n\t\t\t\t\t//\t));\t\n\n\t\t\t\t}\n\n\n\n\t\t\t\tfor (const auto& f : triMesh.getIndices()) {\n\n\t\t\t\t\tout.add_face(vHandles[f.x], vHandles[f.y], vHandles[f.z]);\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tthrow MLIB_EXCEPTION(\"TODO implement\");\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\tstatic void convertToTriMesh(Mesh& mesh, TriMeshf& out, bool keepVertexAttributes = false) {\n\n\n\n\t\t\tMeshDataf mData;\n\n\t\t\tif (keepVertexAttributes == false) {\n\n\t\t\t\tmData.m_Vertices.resize(mesh.n_vertices());\n\n\t\t\t\tfor (unsigned int i = 0; i < mesh.n_vertices(); i++) {\n\n\t\t\t\t\tconst auto& v = mesh.point(Mesh::VertexHandle(i));\n\n\t\t\t\t\tmData.m_Vertices[i] = vec3f(v.data()[0], v.data()[1], v.data()[2]);\n\n\t\t\t\t}\n\n\n\n\t\t\t\tmData.m_FaceIndicesVertices.resize(mesh.n_faces());\n\n\t\t\t\tfor (unsigned int i = 0; i < mesh.n_faces(); i++) {\n\n\t\t\t\t\tconst auto& f = mesh.face(Mesh::FaceHandle(i));\n\n\t\t\t\t\tauto iter = mesh.fv_iter(Mesh::FaceHandle(i));\n\n\t\t\t\t\tmData.m_FaceIndicesVertices[i][0] = iter->idx();\n\n\t\t\t\t\titer++;\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\tmData.m_FaceIndicesVertices[i][1] = iter->idx();\n\n\t\t\t\t\titer++;\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\tmData.m_FaceIndicesVertices[i][2] = iter->idx();\t\t\t\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tthrow MLIB_EXCEPTION(\"TODO implement\");\n\n\t\t\t}\n\n\t\t\tout = TriMeshf(mData);\n\n\t\t}\n\n\n\n\t\t//! decimates a mesh to a specific target vertex number; REVOMES ALSO ALL COLOR/NORMAL/TEXCOORD data\n\n\t\tstatic void decimate(TriMeshf& triMesh, size_t targetNumVertices, bool keepVertexAttributes = false) {\n\n\n\n\t\t\tMesh mesh;\t\t\t\t\t\t\t\t\t// a mesh object\n\n\t\t\tconvertToOpenMesh(triMesh, mesh, keepVertexAttributes);\n\n\t\t\t//std::cout << \"size before: \" << mesh.n_vertices() << std::endl;\n\n\t\t\t//removeDuplicateVertices(mesh);\n\n\t\t\t//std::cout << \"size after: \" << mesh.n_vertices() << std::endl;\n\n\n\n\t\t\tDecimater decimater(mesh);\t\t\t\t\t\t// a decimater object, connected to a mesh\n\n\t\t\tHModQuadric hModQuadric;\t\t\t\t\t\t\t// use a quadric module\n\n\t\t\tdecimater.add( hModQuadric );\t\t\t\t\t\t// register module at the decimater\n\n\t\t\tdecimater.initialize();\t\t\t\t\t\t\t\t// let the decimater initialize the mesh and the modules\n\n\t\t\tdecimater.decimate_to(targetNumVertices);\t\t\t// do decimation\n\n\t\t\tmesh.garbage_collection();\n\n\t\t\tconvertToTriMesh(mesh, triMesh, keepVertexAttributes);\n\n\t\t\t\n\n\t\t}\n\n\n\n\t}\t//namespace OpenMeshTriMesh\n", "file_path": "include/ext-openmesh/triMesh.h", "rank": 12, "score": 111716.39242068584 }, { "content": "namespace ml {\n\n\n\ntemplate <class T> class DenseMatrix\n\n{\n\npublic:\n\n\tDenseMatrix()\n\n\t{\n\n\t\tm_rows = 0;\n\n\t\tm_cols = 0;\n\n\t}\n\n\n\n\tDenseMatrix(const DenseMatrix<T>& s)\n\n\t{\n\n\t\tm_rows = s.m_rows;\n\n\t\tm_cols = s.m_cols;\n\n\t\tm_data = s.m_data;\n\n\t}\n\n\n\n DenseMatrix(DenseMatrix<T> &&s)\n\n\t{\n\n\t\tm_rows = s.m_rows;\n\n\t\tm_cols = s.m_cols;\n\n\t\ts.m_rows = 0;\n\n\t\ts.m_cols = 0;\n\n\t\tm_data = std::move(s.m_data);\n\n\t}\n\n\n\n explicit DenseMatrix(size_t squareDimension)\n\n\t{\n\n\t\tm_rows = (UINT)squareDimension;\n\n m_cols = (UINT)squareDimension;\n\n\t\tm_data.resize(m_rows * m_cols);\n\n\t}\n\n\n\n\texplicit DenseMatrix(const MathVector<T> &diagonal)\n\n\t{\n\n\t\tm_rows = diagonal.size();\n\n\t\tm_cols = diagonal.size();\n\n\t\tm_data.resize(m_rows * m_cols);\n\n\t\tfor(UINT row = 0; row < m_rows; row++)\n\n\t\t{\n\n\t\t\tfor(UINT col = 0; col < m_cols; col++)\n\n\t\t\t\t(*this)(row, col) = 0.0;\n\n\t\t\t(*this)(row, row) = diagonal[row];\n\n\t\t}\n\n\n\n\t}\n\n\n\n DenseMatrix(size_t rows, size_t cols, T clearValue = (T)0.0)\n\n\t{\n\n\t\tm_rows = rows;\n\n m_cols = cols;\n\n m_data.resize(m_rows * m_cols, clearValue);\n\n\t}\n\n\n\n\tDenseMatrix(size_t rows, size_t cols, const T* values) {\n\n\t\tm_rows = rows;\n\n\t\tm_cols = cols;\n\n\t\tm_data.resize(m_rows * m_cols);\n\n\n\n\t\tfor (size_t i = 0; i < rows*cols; i++) {\n\n\t\t\tm_data[i] = values[i];\n\n\t\t}\n\n\t}\n\n\n\n\tDenseMatrix(const std::string &s, MatrixStringFormat format)\n\n\t{\n\n\t\tif(format == MatrixStringFormatMathematica)\n\n\t\t{\n\n\t\t\t//\n\n\t\t\t// this is really a dense format and should be loaded as such, then cast into a SparseMatrix\n\n\t\t\t//\n\n\t\t\tstd::vector<std::string> data = ml::util::split(s,\"},{\");\n\n\t\t\tm_rows = data.size();\n\n\t\t\tm_cols = util::split(data[0], \",\").size();\n\n\t\t\tm_data.resize(m_rows * m_cols);\n\n\n\n\t\t\tfor (size_t row = 0; row < m_rows; row++) {\n\n\t\t\t\tstd::vector<std::string> values = ml::util::split(data[row], \",\");\n\n\t\t\t\tfor (size_t col = 0; col < values.size(); col++) {\n\n\t\t\t\t\tconst std::string s = ml::util::replace(ml::util::replace(values[col], \"{\",\"\"), \"}\",\"\");\n\n\t\t\t\t\t(*this)(row, col) = (T)std::stod(s);\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\telse\n\n\t\t{\n\n\t\t\tMLIB_ERROR(\"invalid matrix string format\");\n\n\t\t}\n\n\t}\n\n\n\n DenseMatrix(const Matrix4x4<T> &m)\n\n {\n\n m_rows = 4;\n\n m_cols = 4;\n\n m_data.resize(16);\n\n for (unsigned int element = 0; element < m_data.size(); element++)\n\n m_data[element] = m[element];\n\n }\n\n\n\n\tDenseMatrix(const Matrix3x3<T> &m)\n\n\t{\n\n\t\tm_rows = 3;\n\n\t\tm_cols = 3;\n\n\t\tm_data.resize(9);\n\n\t\tfor (unsigned int element = 0; element < m_data.size(); element++)\n\n\t\t\tm_data[element] = m[element];\n\n\t}\n\n\n\n\tDenseMatrix(const Matrix2x2<T> &m)\n\n\t{\n\n\t\tm_rows = 2;\n\n\t\tm_cols = 2;\n\n\t\tm_data.resize(4);\n\n\t\tfor (unsigned int element = 0; element < m_data.size(); element++)\n\n\t\t\tm_data[element] = m[element];\n\n\t}\n\n\n\n void resize(size_t rows, size_t cols, T clearValue = (T)0.0)\n\n\t{\n\n\t\tm_rows = rows;\n\n\t\tm_cols = cols;\n\n\t\tm_data.resize(m_rows * m_cols, clearValue);\n", "file_path": "include/core-math/denseMatrix.h", "rank": 13, "score": 111716.39242068584 }, { "content": "namespace ml\n\n{\n\n\n\n\n\n//linear system solver\n\ntemplate<class D> class LinearSolverEigen : public LinearSolver<D>\n\n{\n\npublic:\n\n\tenum Method\n\n\t{\n\n\t\tLLT,\n\n\t\tLDLT,\n\n\t\tLU, //Inferior to LLT for symmetric problems\n\n\t\tQR, //Extremely slow\n\n\t\tConjugateGradient_Diag,\n\n\t\tBiCGSTAB_Diag,\n\n\t\tBiCGSTAB_LUT,\n\n\t\tProfile,\n\n\t};\n\n\n\n\tLinearSolverEigen(Method method = ConjugateGradient_Diag, double tolerance = 1e-10)\n\n\t{\n\n\t\tm_method = method;\n\n m_tolerance = tolerance;\n\n\t}\n\n\n\n\tMathVector<D> solve(const SparseMatrix<D> &A, const MathVector<D> &b)\n\n\t{\n\n\t\tMLIB_ASSERT_STR(A.square() && b.size() == A.rows(), \"invalid solve dimensions\");\n\n\t\tEigen::SparseMatrix<D> eigenMatrix;\n\n std::cout << \"Making eigen matrix...\";\n\n\t\teigenutil::makeEigenMatrix(A, eigenMatrix);\n\n std::cout << \"done\" << std::endl;\n\n\t\treturn solve(eigenMatrix, b);\n\n\t}\n\n\n\n\tMathVector<D> solve(const Eigen::SparseMatrix<D> &A, const MathVector<D> &b)\n\n\t{\n\n\t\treturn solveUsingMethod(A, b, m_method);\n\n\t}\n\n\n\n\tMathVector<D> solveLeastSquares(const SparseMatrix<D> &A, const MathVector<D> &b)\n\n\t{\n\n\t\tEigen::SparseMatrix<D> eigenMatrix;\n\n\t\teigenutil::makeEigenMatrix(A, eigenMatrix);\n\n return solveLeastSquaresQR(eigenMatrix, b);\n\n\t}\n\n\n\n MathVector<D> solveLeastSquaresNormalEquations(const SparseMatrix<D> &A, const MathVector<D> &b)\n\n {\n\n Eigen::SparseMatrix<D> eigenMatrix;\n\n eigenutil::makeEigenMatrix(A, eigenMatrix);\n\n return solveUsingMethod(eigenMatrix.transpose() * eigenMatrix, A.transpose() * b, m_method);\n\n }\n\n\n\n MathVector<D> solveLeastSquaresManualCG(const SparseMatrix<D> &A, const MathVector<D> &bBase, UINT maxIterations, bool verbose = false)\n\n {\n\n SparseMatrix<D> ATranspose = A.transpose();\n\n const MathVector<D> &b = ATranspose * bBase;\n\n\n\n Eigen::SparseMatrix<D> eigenA, eigenAt;\n\n eigenutil::makeEigenMatrix(A, eigenA);\n\n eigenAt = eigenA.transpose();\n\n\n\n const UINT n = (UINT)b.size();\n\n\n\n MathVector<D> dInverse = A.selfTransposeDiagonal();\n\n auto invert = [](D& x) { x = (D)1.0 / x; };\n\n for_each(dInverse.begin(), dInverse.end(), invert);\n\n\n\n auto eigenMultiply = [&](const MathVector<D> &x) {\n\n Eigen::VectorXf temp = eigenAt * (eigenA * eigenutil::makeEigenVector(x));\n\n return eigenutil::dumpEigenVector(temp);\n\n };\n\n\n\n MathVector<D> x(n, 0.0);\n\n MathVector<D> r = b - eigenMultiply(x);\n\n MathVector<D> z = dInverse * r;\n\n MathVector<D> p = z;\n\n\n\n for (UINT iteration = 0; iteration < maxIterations; iteration++)\n\n {\n\n const D gamma = r | z;\n\n\n\n if (fabs(gamma) < 1e-20) break;\n\n \n\n //FloatType alpha = gamma / SparseMatrix<FloatType>::quadratic(A, p);\n\n const D alphaDenom = MathVector<D>::dot(p, eigenMultiply(p));\n\n \n\n std::cout << \"alphaDenom: \" << alphaDenom << std::endl;\n\n\n\n const D alpha = gamma / alphaDenom;\n\n\n\n x = x + alpha * p;\n\n r = r - alpha * eigenMultiply(p);\n\n\n\n if (*std::max_element(r.begin(), r.end()) <= m_tolerance && *std::min_element(r.begin(), r.end()) >= -m_tolerance)\tbreak;\n\n\n\n z = dInverse * r;\n\n const D beta = (z | r) / gamma;\n\n p = z + beta * p;\n\n }\n\n return x;\n\n }\n\n\n\n\tMathVector<D> solveLeastSquaresQR(const Eigen::SparseMatrix<D> &A, const MathVector<D> &b)\n\n\t{\n\n\t\tstd::cout << \"Solving least-squares problem using QR\" << std::endl;\n\n\n\n const Eigen::Matrix<D, Eigen::Dynamic, 1> bEigen = eigenutil::makeEigenVector(b);\n\n Eigen::SparseQR< Eigen::SparseMatrix<D>, Eigen::COLAMDOrdering<int> > factorization(A);\n\n //Eigen::SparseQR< Eigen::SparseMatrix<D>, Eigen::NaturalOrdering<int> > factorization(A);\n\n\t\tEigen::Matrix<D, Eigen::Dynamic, 1> x = factorization.solve(bEigen);\n\n\n\n\t\treturn eigenutil::dumpEigenVector(x);\n\n\t}\n\n\n\nprivate:\n\n\tMathVector<D> solveUsingMethod(const Eigen::SparseMatrix<D> &A, const MathVector<D> &b, Method method)\n\n\t{\n\n\t\tComponentTimer timer(\"Solving using method: \" + getMethodName(method));\n\n\t\t\n\n\t\tconst auto bEigen = eigenutil::makeEigenVector(b);\n\n Eigen::Matrix<D, Eigen::Dynamic, 1> x;\n\n\n\n\t\tif(method == LLT)\n\n\t\t{\n\n\t\t\tEigen::SimplicialLLT< Eigen::SparseMatrix<D> > factorization(A);\n\n\t\t\tx = factorization.solve(bEigen);\n\n\t\t}\n\n\t\telse if(method == LDLT)\n\n\t\t{\n\n\t\t\tEigen::SimplicialLDLT< Eigen::SparseMatrix<D> > factorization(A);\n\n\t\t\tx = factorization.solve(bEigen);\n\n\t\t}\n\n\t\telse if(method == LU)\n\n\t\t{\n\n\t\t\tEigen::SparseLU< Eigen::SparseMatrix<D> > factorization(A);\n\n\t\t\tx = factorization.solve(bEigen);\n\n\t\t}\n\n\t\telse if(method == QR)\n\n\t\t{\n\n\t\t\tEigen::SparseQR< Eigen::SparseMatrix<D>, Eigen::COLAMDOrdering<int> > factorization(A);\n\n\t\t\tx = factorization.solve(bEigen);\n\n\t\t}\n\n\t\telse if(method == ConjugateGradient_Diag)\n\n\t\t{\n\n\t\t\tEigen::ConjugateGradient< Eigen::SparseMatrix<D>, Eigen::Lower, Eigen::DiagonalPreconditioner<D> > solver;\n\n solver.setTolerance((D)m_tolerance);\n\n\t\t\tsolver.compute(A);\n\n\t\t\tx = solver.solve(bEigen);\n\n\t\t\t//Console::log(\"Iterations: \" + std::string(solver.iterations()));\n\n\t\t\t//Console::log(\"Error: \" + std::string(solver.error()));\n\n\t\t}\n\n\t\telse if(method == BiCGSTAB_Diag)\n\n\t\t{\n\n\t\t\tEigen::BiCGSTAB< Eigen::SparseMatrix<D>, Eigen::DiagonalPreconditioner<D > > solver;\n\n solver.setTolerance((D)m_tolerance);\n\n\t\t\tsolver.compute(A);\n\n\t\t\tx = solver.solve(bEigen);\n\n\t\t\t//Console::log(\"Iterations: \" + std::string(solver.iterations()));\n\n\t\t\t//Console::log(\"Error: \" + std::string(solver.error()));\n\n\t\t}\n\n\t\telse if(method == BiCGSTAB_LUT)\n\n\t\t{\n\n\t\t\tEigen::BiCGSTAB< Eigen::SparseMatrix<D>, Eigen::IncompleteLUT<D > > solver;\n\n solver.setTolerance((D)m_tolerance);\n\n\t\t\tsolver.compute(A);\n\n\t\t\tx = solver.solve(bEigen);\n\n\t\t\t//Console::log(\"Iterations: \" + std::string(solver.iterations()));\n\n\t\t\t//Console::log(\"Error: \" + std::string(solver.error()));\n\n\t\t}\n\n\t\telse if(method == Profile)\n\n\t\t{\n\n\t\t\tstd::cout << \"Profiling all eigen linear solvers\" << std::endl;\n\n\t\t\tconst int methodCount = (int)Profile;\n\n\t\t\tstd::vector< MathVector<D> > results(methodCount);\n\n\t\t\tfor(int methodIndex = 0; methodIndex < methodCount; methodIndex++)\n\n\t\t\t{\n\n\t\t\t\tresults[methodIndex] = solveUsingMethod(A, b, (Method)methodIndex);\n\n\t\t\t\tif(methodIndex != 0)\n\n\t\t\t\t{\n\n\t\t\t\t\tdouble maxDeviation = 0.0;\n\n\t\t\t\t\tfor(UINT variableIndex = 0; variableIndex < b.size(); variableIndex++)\n\n\t\t\t\t\t\tmaxDeviation = std::max<double>(maxDeviation, fabs(results[methodIndex][variableIndex] - results[0][variableIndex]));\n\n\t\t\t\t\tstd::cout << \"Max deviation from LLT: \" << std::to_string(maxDeviation) << std::endl;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn results[0];\n\n\t\t}\n\n\t\telse\n\n\t\t{\n\n\t\t\tMLIB_ERROR(\"Unknown method\");\n\n\t\t}\n\n\n\n\t\treturn eigenutil::dumpEigenVector(x);\n\n\t}\n\n\n\n\tstatic std::string getMethodName(Method m)\n\n\t{\n\n\t\tswitch(m)\n\n\t\t{\n\n\t\tcase LLT: return \"LLT\";\n\n\t\tcase LDLT: return \"LDLT\";\n\n\t\tcase LU: return \"LU\";\n\n\t\tcase QR: return \"QR\";\n\n\t\tcase ConjugateGradient_Diag: return \"ConjugateGradient_Diag\";\n\n\t\tcase BiCGSTAB_Diag: return \"BiCGSTAB_Diag\";\n\n\t\tcase BiCGSTAB_LUT: return \"BiCGSTAB_LUT\";\n\n\t\tcase Profile: return \"Profile\";\n\n\t\tdefault: return \"Unknown\";\n\n\t\t}\n\n\t}\n\n\n\n\tMethod m_method;\n\n double m_tolerance;\n\n};\n\n\n\n\n\n//eigenvalue decomposition\n\ntemplate<class FloatType> class EigenSolverEigen : public EigenSolver < FloatType >\n\n{\n\npublic:\n\n\tvoid eigenSystemInternal(const DenseMatrix<FloatType> &M, FloatType **eigenvectors, FloatType *eigenvalues) const {\n\n\t\tEigen::MatrixXd mat;\n\n\t\teigenutil::makeEigenMatrix(M, mat);\n\n\t\tEigen::EigenSolver<Eigen::MatrixXd> eigenSolver(mat);\n\n\t\t\n\n\t\tfor (unsigned int i = 0; i < M.rows(); i++) {\n\n\t\t\teigenvalues[i] = (FloatType)eigenSolver.eigenvalues()[i].real();\n\n\t\t\teigenSolver.eigenvalues();\n\n\t\t\tfor (unsigned int j = 0; j < M.cols(); j++) {\n\n\t\t\t\teigenvectors[i][j] = (FloatType)eigenSolver.eigenvectors()(i, j).real();\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n};\n\n\n\ntypedef EigenSolverEigen<float> EigenSolverEigenf;\n\ntypedef EigenSolverEigen<double> EigenSolverEigend;\n\n\n\n\n\ntemplate<class FloatType> class EigenWrapper \n\n{\n\npublic:\n\n\t//! given a set of 3d correspondences determine a rotation and translation vector\n\n\tstatic Matrix4x4<FloatType> kabsch(const std::vector<vec3<FloatType>>& source, const std::vector<vec3<FloatType>>& target, vec3<FloatType>& eigenvalues, bool printDebug = false) {\n\n\t\tif (source.size() != target.size()) throw MLIB_EXCEPTION(\"invalid dimensions\");\n\n\t\tif (source.size() < 3) throw MLIB_EXCEPTION(\"need at least 3 points\");\n\n\t\t//{\n\n\t\t//\tconst auto& P = source;\n\n\t\t//\tconst auto& Q = target;\n\n\n\n\t\t//\t//compute mean p0\n\n\t\t//\tvec3<FloatType> p0(0, 0, 0);\n\n\t\t//\tfor (size_t i = 0; i < P.size(); i++) {\n\n\t\t//\t\tp0 += P[i];\n\n\t\t//\t}\n\n\t\t//\tp0 /= (FloatType)P.size();\n\n\n\n\t\t//\t//compute mean p1\n\n\t\t//\tvec3<FloatType> q0(0, 0, 0);\n\n\t\t//\tfor (size_t i = 0; i < Q.size(); i++) {\n\n\t\t//\t\tq0 += Q[i];\n\n\t\t//\t}\n\n\t\t//\tq0 /= (FloatType)Q.size();\n\n\n\n\t\t//\t//compute covariance matrix\n\n\t\t//\tMatrix3x3<FloatType> C;\tC.setZero();\n\n\t\t//\tfor (size_t i = 0; i < source.size(); i++) {\n\n\t\t//\t\tC = C + Matrix3x3<FloatType>::tensorProduct(P[i] - p0, Q[i] - q0);\n\n\t\t//\t}\n\n\n\n\t\t//\t//convert to eigen\n\n\t\t//\tEigen::Matrix3d Ce;\n\n\t\t//\tfor (unsigned int i = 0; i < 3; i++) {\n\n\t\t//\t\tfor (unsigned int j = 0; j < 3; j++) {\n\n\t\t//\t\t\tCe(i, j) = C(i, j);\n\n\t\t//\t\t}\n\n\t\t//\t}\n\n\n\n\t\t//\t// SVD\n\n\t\t//\tEigen::JacobiSVD<Eigen::Matrix3d> svd(Ce, Eigen::ComputeThinU | Eigen::ComputeThinV);\n\n\n\n\t\t//\tEigen::Matrix3d V = svd.matrixU();\n\n\t\t//\tEigen::Vector3d S = svd.singularValues();\n\n\t\t//\tEigen::Matrix3d W = svd.matrixV();\n\n\t\t//\tEigen::Matrix3d I = Eigen::Matrix3d::Identity();\n\n\n\n\t\t//\tif ((V * W.transpose()).determinant() < 0)\n\n\t\t//\t\tI(3 - 1, 3 - 1) = -1;\n\n\n\n\t\t//\t// Recover the rotation and translation\n\n\t\t//\tEigen::Matrix3d resRot = W * I * V.transpose();\n\n\t\t//\tEigen::Vector3d resTrans = Eigen::Vector3d(q0.x, q0.y, q0.z) - resRot*Eigen::Vector3d(p0.x, p0.y, p0.z);\n\n\n\n\t\t//\tMatrix4x4<FloatType> ret;\n\n\t\t//\tfor (unsigned int i = 0; i < 3; i++) {\n\n\t\t//\t\tfor (unsigned int j = 0; j < 3; j++) {\n\n\t\t//\t\t\tret(i, j) = (FloatType)resRot(i, j);\n\n\t\t//\t\t}\n\n\t\t//\t}\n\n\t\t//\tret(3, 0) = ret(3, 1) = ret(3, 2) = 0;\tret(3, 3) = 1;\n\n\t\t//\tret(0, 3) = (FloatType)resTrans(0);\n\n\t\t//\tret(1, 3) = (FloatType)resTrans(1);\n\n\t\t//\tret(2, 3) = (FloatType)resTrans(2);\n\n\t\t//\treturn ret;\n\n\t\t//}\n\n\n\n\n\n\t\tEigen::MatrixXd P(3, source.size());\n\n\t\tfor (size_t i = 0; i < source.size(); i++) {\n\n\t\t\tP(0, i) = source[i].x;\n\n\t\t\tP(1, i) = source[i].y;\n\n\t\t\tP(2, i) = source[i].z;\n\n\t\t}\n\n\t\tEigen::MatrixXd Q(3, target.size());\n\n\t\tfor (size_t i = 0; i < target.size(); i++) {\n\n\t\t\tQ(0, i) = target[i].x;\n\n\t\t\tQ(1, i) = target[i].y;\n\n\t\t\tQ(2, i) = target[i].z;\n\n\t\t}\n\n\t\tEigen::VectorXd weights(source.size());\n\n\t\tfor (unsigned int i = 0; i < weights.size(); i++) {\n\n\t\t\tweights[i] = 1.0;\n\n\t\t}\n\n\t\t\t \n\n\t\t//if (P.cols() != Q.cols() || P.rows() != Q.rows())\n\n\t\t//\tHelpers::ExitWithMessage(\"Helpers::Kabsch: P and Q have different dimensions\");\n\n\t\tsize_t D = P.rows(); // dimension of the space\n\n\t\tsize_t N = P.cols(); // number of points\n\n\t\tEigen::VectorXd\tnormalizedWeights = Eigen::VectorXd(weights.size());\n\n\n\n\t\t// normalize weights to sum to 1\n\n\t\t{\n\n\t\t\tdouble\tsumWeights = 0;\n\n\t\t\tfor (unsigned int i = 0; i < weights.size(); i++)\n\n\t\t\t{\n\n\t\t\t\tsumWeights += weights(i);\n\n\t\t\t}\n\n\t\t\tnormalizedWeights = weights * (1.0 / sumWeights);\n\n\t\t}\n\n\n\n\t\t// Centroids\n\n\t\tEigen::VectorXd\tp0 = P * normalizedWeights;\n\n\t\tEigen::VectorXd\tq0 = Q * normalizedWeights;\n\n\t\tEigen::VectorXd v1 = Eigen::VectorXd::Ones(N);\n\n\n\n\n\n\t\tEigen::MatrixXd P_centred = P - p0*v1.transpose(); // translating P to center the origin\n\n\t\tEigen::MatrixXd Q_centred = Q - q0*v1.transpose(); // translating Q to center the origin\n\n\n\n\t\t// Covariance between both matrices\n\n\t\tEigen::MatrixXd C = P_centred * normalizedWeights.asDiagonal() * Q_centred.transpose();\n\n\n\n\t\t// SVD\n\n\t\tEigen::JacobiSVD<Eigen::MatrixXd> svd(C, Eigen::ComputeThinU | Eigen::ComputeThinV);\n\n\n\n\t\tEigen::MatrixXd V = svd.matrixU();\n\n\t\tEigen::VectorXd S = svd.singularValues();\n\n\t\tEigen::MatrixXd W = svd.matrixV();\n\n\t\tEigen::MatrixXd I = Eigen::MatrixXd::Identity(D, D);\n\n\t\tif (printDebug) {\n\n\t\t\tstd::cout << \"AtA:\" << std::endl;\n\n\t\t\tfor (unsigned int i = 0; i < C.rows(); i++) {\n\n\t\t\t\tfor (unsigned int j = 0; j < C.cols(); j++)\n\n\t\t\t\t\tstd::cout << C(i, j) << \" \";\n\n\t\t\t\tstd::cout << std::endl;\n\n\t\t\t}\n\n\t\t\tstd::cout << \"eigenvalues: \" << S[0] << \", \" << S[1] << \", \" << S[2] << std::endl;\n\n\t\t}\n\n\n\n\t\teigenvalues[0] = (FloatType)S[0];\n\n\t\teigenvalues[1] = (FloatType)S[1];\n\n\t\teigenvalues[2] = (FloatType)S[2];\n\n\n\n\t\tif ((V * W.transpose()).determinant() < 0)\n\n\t\t\tI(D - 1, D - 1) = -1;\n\n\n\n\t\t// Recover the rotation and translation\n\n\t\tEigen::MatrixXd resRot = W * I * V.transpose();\n\n\t\tEigen::VectorXd resTrans = q0 - resRot*p0;\n\n\n\n\t\tMatrix4x4<FloatType> ret;\n\n\t\tfor (unsigned int i = 0; i < 3; i++) {\n\n\t\t\tfor (unsigned int j = 0; j < 3; j++) {\n\n\t\t\t\tret(i, j) = (FloatType)resRot(i, j);\n\n\t\t\t}\n\n\t\t}\n\n\t\tret(3, 0) = ret(3, 1) = ret(3, 2) = 0;\tret(3, 3) = 1;\n\n\t\tret(0, 3) = (FloatType)resTrans(0);\n\n\t\tret(1, 3) = (FloatType)resTrans(1);\n\n\t\tret(2, 3) = (FloatType)resTrans(2);\n\n\t\treturn ret;\n\n\t}\n\n\n\n\n\n\tstatic FloatType reProjectionError(const std::vector < vec3<FloatType> >& source, const std::vector < vec3<FloatType> >& target, const Matrix4x4<FloatType>& trans) {\n\n\t\tif (source.size() != target.size()) throw MLIB_EXCEPTION(\"invalid dimension\");\n\n\n\n\t\tFloatType res = 0;\n\n\t\tfor (size_t i = 0; i < source.size(); i++) {\n\n\t\t\tFloatType distSq = vec3<FloatType>::distSq(trans * source[i], target[i]);\n\n\t\t\tres += distSq;\n\n\t\t}\n\n\t\treturn res;\n\n\t}\n\n\n\n\t//! squared re-projection errors\n\n\tstatic void reProjectionErrors(const std::vector < vec3<FloatType> >& source, const std::vector < vec3<FloatType> >& target, const Matrix4x4<FloatType>& trans, std::vector<FloatType>& residuals) {\n\n\t\tif (source.size() != target.size()) throw MLIB_EXCEPTION(\"invalid dimension\");\n\n\n\n\t\tresiduals.resize(source.size(), 0);\n\n\t\tfor (size_t i = 0; i < source.size(); i++) {\n\n\t\t\tresiduals[i] = vec3<FloatType>::distSq(trans * source[i], target[i]);\n\n\t\t}\n\n\t}\n\n\n\n\t//! returns eigenvalues\n\n\tstatic vec3<FloatType> covarianceSVD(const std::vector<vec3<FloatType>>& points) {\n\n\t\tif (points.size() < 3) throw MLIB_EXCEPTION(\"need at least 3 points\");\n\n\t\tvec3<FloatType> eigenvalues;\n\n\n\n\t\tEigen::MatrixXd P(3, points.size());\n\n\t\tfor (size_t i = 0; i < points.size(); i++) {\n\n\t\t\tP(0, i) = points[i].x;\n\n\t\t\tP(1, i) = points[i].y;\n\n\t\t\tP(2, i) = points[i].z;\n\n\t\t}\n\n\t\tEigen::VectorXd weights(points.size());\n\n\t\tfor (unsigned int i = 0; i < weights.size(); i++) {\n\n\t\t\tweights[i] = 1.0;\n\n\t\t}\n\n\n\n\t\tsize_t D = P.rows(); // dimension of the space\n\n\t\tsize_t N = P.cols(); // number of points\n\n\t\tEigen::VectorXd\tnormalizedWeights = Eigen::VectorXd(weights.size());\n\n\n\n\t\t// normalize weights to sum to 1\n\n\t\t{\n\n\t\t\tdouble\tsumWeights = 0;\n\n\t\t\tfor (unsigned int i = 0; i < weights.size(); i++)\n\n\t\t\t{\n\n\t\t\t\tsumWeights += weights(i);\n\n\t\t\t}\n\n\t\t\tnormalizedWeights = weights * (1.0 / sumWeights);\n\n\t\t}\n\n\n\n\t\t// Centroids\n\n\t\tEigen::VectorXd\tp0 = P * normalizedWeights;\n\n\t\tEigen::VectorXd v1 = Eigen::VectorXd::Ones(N);\n\n\t\tEigen::MatrixXd P_centred = P - p0*v1.transpose(); // translating P to center the origin\n\n\n\n\t\t// Covariance between both matrices\n\n\t\tEigen::MatrixXd C = P_centred * normalizedWeights.asDiagonal() * P_centred.transpose();\n\n\n\n\t\t// SVD\n\n\t\tEigen::JacobiSVD<Eigen::MatrixXd> svd(C, Eigen::ComputeThinU | Eigen::ComputeThinV);\n\n\n\n\t\t//Eigen::MatrixXd V = svd.matrixU();\n\n\t\tEigen::VectorXd S = svd.singularValues();\n\n\t\t//Eigen::MatrixXd W = svd.matrixV();\n\n\n\n\t\teigenvalues[0] = (FloatType)S[0];\n\n\t\teigenvalues[1] = (FloatType)S[1];\n\n\t\teigenvalues[2] = (FloatType)S[2];\n\n\n\n\t\treturn eigenvalues;\n\n\t}\n", "file_path": "include/ext-eigen/eigenSolver.h", "rank": 14, "score": 111716.39242068584 }, { "content": "namespace ml {\n\nnamespace meshutil {\n\n\n\nTriMeshf createPointCloudTemplate(const TriMeshf& templateMesh, const std::vector<vec3f>& points, const std::vector<vec4f>& colors = std::vector<vec4f>());\n\nTriMeshf createUnifiedMesh(const std::vector< std::pair<const TriMeshf*, mat4f> >& meshes);\n\nTriMeshf createUnifiedMesh(const std::vector<std::pair<TriMeshf, mat4f>>& meshes);\n\nTriMeshf createUnifiedMesh(const std::vector<TriMeshf>& meshes);\n\n\n\n} // namespace meshutil\n", "file_path": "include/core-mesh/meshUtil.h", "rank": 15, "score": 111716.39242068584 }, { "content": "namespace ml\n\n{\n\n\n\ntemplate <class T> class TaskList\n\n{\n\npublic:\n\n void insert(const T &task)\n\n {\n\n m_mutex.lock();\n\n m_tasks.push_back(task);\n\n m_mutex.unlock();\n\n }\n\n\n\n bool done()\n\n {\n\n m_mutex.lock();\n\n bool result = (m_tasks.size() == 0);\n\n m_mutex.unlock();\n\n return result;\n\n }\n\n\n\n UINT64 tasksLeft()\n\n {\n\n m_mutex.lock();\n\n UINT64 result = m_tasks.size();\n\n m_mutex.unlock();\n\n return result;\n\n }\n\n\n\n bool getNextTask(T &nextTask)\n\n {\n\n m_mutex.lock();\n\n if(m_tasks.size() == 0)\n\n {\n\n m_mutex.unlock();\n\n return false;\n\n }\n\n\n\n nextTask = m_tasks.back();\n\n m_tasks.pop_back();\n\n m_mutex.unlock();\n\n return true;\n\n }\n\n\n\nprivate:\n\n std::mutex m_mutex;\n\n std::vector<T> m_tasks;\n\n};\n\n\n", "file_path": "include/core-multithreading/taskList.h", "rank": 16, "score": 111716.39242068584 }, { "content": "namespace ml\n\n{\n\n\n\nstruct RGBColor : public vec4uc\n\n{\n\n RGBColor() {}\n\n RGBColor(BYTE _r, BYTE _g, BYTE _b)\n\n\t{\n\n\t\tr = _r;\n\n\t\tg = _g;\n\n\t\tb = _b;\n\n\t\ta = 255;\n\n\t}\n\n RGBColor(BYTE _r, BYTE _g, BYTE _b, BYTE _a)\n\n\t{\n\n\t\tr = _r;\n\n\t\tg = _g;\n\n\t\tb = _b;\n\n\t\ta = _a;\n", "file_path": "include/core-graphics/RGBColor.h", "rank": 17, "score": 111716.39242068584 }, { "content": "namespace ml {\n\nnamespace math {\n\n\n\ntemplate<class T>\n\nMatrix3x3<T> covarianceMatrix(const std::vector< vec3<T> >& points) \n\n{\n\n\tauto mean = std::accumulate(points.begin(), points.end(), vec3<T>::origin) / (T)points.size();\n\n\n\n\tMatrix3x3<T> covariance;\n\n\tcovariance.setZero();\n\n\n\n\tfor (const auto& p : points)\n\n\t{\n\n\t\tauto recenteredPt = p - mean;\n\n\t\tauto tensor = Matrix3x3<T>::tensorProduct(recenteredPt, recenteredPt);\n\n\t\tfor (int y = 0; y < 3; y++)\n\n\t\t\tfor (int x = 0; x < 3; x++)\n\n\t\t\t\tcovariance(y, x) += tensor(y, x);\n\n\t}\n\n\n\n\tcovariance /= (T)(points.size() - 1);\n\n\n\n\treturn covariance;\n\n}\n\n\n\ntemplate<class T>\n\nMatrix2x2<T> covarianceMatrix(const std::vector< vec2<T> >& points)\n\n{\n\n\tauto mean = std::accumulate(points.begin(), points.end(), vec2<T>::origin) / (T)points.size();\n\n\n\n\tMatrix2x2<T> covariance;\n\n\tcovariance.setZero();\n\n\n\n\tfor (const auto& p : points)\n\n\t{\n\n\t\tauto recenteredPt = p - mean;\n\n\t\tauto tensor = Matrix2x2<T>::tensorProduct(recenteredPt, recenteredPt);\n\n\t\tfor (int y = 0; y < 2; y++)\n\n\t\t\tfor (int x = 0; x < 2; x++)\n\n\t\t\t\tcovariance(y, x) += tensor(y, x);\n\n\t}\n\n\n\n\tcovariance /= (T)(points.size() - 1);\n\n\n\n\treturn covariance;\n\n}\n\n\n\n\n\n//\n\n// returns the <axis, eigenvalue> pairs for the PCA of the given 3D points.\n\n//\n\ntemplate <class T>\n\nvector< std::pair<vec3<T>, T> > pointSetPCA(const std::vector< vec3<T> > &points)\n\n{\n\n\tauto system = covarianceMatrix(points).eigenSystem();\n\n const auto &v = system.eigenvectors;\n\n \n\n vector< std::pair<vec3<T>, T> > result;\n\n result.push_back(std::make_pair(vec3<T>(v(0, 0), v(0, 1), v(0, 2)), system.eigenvalues[0]));\n\n result.push_back(std::make_pair(vec3<T>(v(1, 0), v(1, 1), v(1, 2)), system.eigenvalues[1]));\n\n result.push_back(std::make_pair(vec3<T>(v(2, 0), v(2, 1), v(2, 2)), system.eigenvalues[2]));\n\n return result;\n\n}\n\n\n\n//\n\n// returns the <axis, eigenvalue> pairs for the PCA of the given 2D points.\n\n//\n\ntemplate <class T>\n\nvector< std::pair<vec2<T>, T> > pointSetPCA(const std::vector< vec2<T> > &points)\n\n{\n\n\tauto system = covarianceMatrix(points).eigenSystem();\n\n const auto &v = system.eigenvectors;\n\n\n\n vector< std::pair<vec2<T>, T> > result;\n\n result.push_back(std::make_pair(vec2<T>(v(0, 0), v(1, 0)), system.eigenvalues[0]));\n\n result.push_back(std::make_pair(vec2<T>(v(0, 1), v(1, 1)), system.eigenvalues[1]));\n\n return result;\n\n}\n\n\n\n\n\n}\n", "file_path": "include/core-math/mathUtil.h", "rank": 18, "score": 111716.39242068584 }, { "content": "namespace ml {\n\n\n\n\tstruct PlyHeader {\n\n\t\tstruct PlyPropertyHeader {\n\n\t\t\tPlyPropertyHeader() {\n\n\t\t\t\tbyteSize = 0;\n\n\t\t\t}\n\n\t\t\tstd::string name;\n\n\t\t\tstd::string nameType;\n\n\t\t\tunsigned int byteSize;\n\n\t\t};\n\n\t\tPlyHeader(std::ifstream& file) {\n\n\t\t\tm_numVertices = (unsigned int)-1;\n\n\t\t\tm_numFaces = (unsigned int)-1;\n\n\t\t\tm_bHasNormals = false;\n\n\t\t\tm_bHasColors = false;\n\n\n\n\t\t\tread(file);\n\n\t\t}\n\n\t\tPlyHeader() {\n\n\t\t\tm_numVertices = (unsigned int)-1;\n\n\t\t\tm_numFaces = (unsigned int)-1;\n\n\t\t\tm_bHasNormals = false;\n\n\t\t\tm_bHasColors = false;\n\n\t\t}\n\n\t\tunsigned int m_numVertices;\n\n\t\tunsigned int m_numFaces;\n\n\t\tstd::map<std::string, std::vector<PlyPropertyHeader>> m_properties;\n\n\t\tbool m_bBinary;\n\n\t\tbool m_bHasNormals;\n\n\t\tbool m_bHasColors;\n\n\n\n\t\tvoid read(std::ifstream& file) {\n\n\t\t\tstd::string activeElement = \"\";\n\n\t\t\tstd::string line;\n\n\t\t\tutil::safeGetline(file, line);\n\n\t\t\twhile (line.find(\"end_header\") == std::string::npos) {\n\n\t\t\t\tPlyHeaderLine(line, *this, activeElement);\n\n\t\t\t\tutil::safeGetline(file, line);\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\tstatic void PlyHeaderLine(const std::string& line, PlyHeader& header, std::string& activeElement) {\n\n\n\n\t\t\tstd::stringstream ss(line);\n\n\t\t\tstd::string currWord;\n\n\t\t\tss >> currWord;\n\n\n\n\n\n\t\t\tif (currWord == \"element\") {\n\n\t\t\t\tss >> currWord;\n\n\t\t\t\tactiveElement = currWord;\n\n\t\t\t\tif (currWord == \"vertex\") {\n\n\t\t\t\t\tss >> header.m_numVertices;\n\n\t\t\t\t}\n\n\t\t\t\telse if (currWord == \"face\") {\n\n\t\t\t\t\tss >> header.m_numFaces;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse if (currWord == \"format\") {\n\n\t\t\t\tss >> currWord;\n\n\t\t\t\tif (currWord == \"binary_little_endian\")\t{\n\n\t\t\t\t\theader.m_bBinary = true;\n\n\t\t\t\t}\n\n\t\t\t\telse {\n\n\t\t\t\t\theader.m_bBinary = false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\telse if (currWord == \"property\") {\n\n\t\t\t\tif (!util::endsWith(line, \"vertex_indices\") && !util::endsWith(line, \"vertex_index\")) {\n\n\t\t\t\t\tPlyHeader::PlyPropertyHeader p;\n\n\t\t\t\t\tss >> p.nameType;\n\n\t\t\t\t\tss >> p.name;\n\n\t\t\t\t\tif (activeElement == \"vertex\") {\n\n\t\t\t\t\t\tif (p.name == \"nx\")\theader.m_bHasNormals = true;\n\n\t\t\t\t\t\tif (p.name == \"red\") header.m_bHasColors = true;\n\n\t\t\t\t\t}\n\n\n\n\t\t\t\t\tif (p.nameType == \"double\") p.byteSize = 8;\n\n\t\t\t\t\telse if (p.nameType == \"float\" || p.nameType == \"int\" || p.nameType == \"uint\") p.byteSize = 4;\n\n\t\t\t\t\telse if (p.nameType == \"ushort\" || p.nameType == \"short\") p.byteSize = 2;\n\n\t\t\t\t\telse if (p.nameType == \"uchar\" || p.nameType == \"char\") p.byteSize = 1;\n\n\t\t\t\t\telse {\n\n\t\t\t\t\t\tthrow MLIB_EXCEPTION(\"unkown data type\");\n\n\t\t\t\t\t}\n\n\t\t\t\t\theader.m_properties[activeElement].push_back(p);\n\n\t\t\t\t}\n\n\t\t\t\telse {\n\n\t\t\t\t\t//property belonging to unknown element\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n", "file_path": "include/core-mesh/plyHeader.h", "rank": 19, "score": 111716.39242068584 }, { "content": "namespace ml {\n\n\n\ntemplate<class FloatType> class LinearSolver\n\n{\n\npublic:\n\n\tvirtual MathVector<FloatType> solve(const SparseMatrix<FloatType> &A, const MathVector<FloatType> &b) = 0;\n\n\tvirtual MathVector<FloatType> solveLeastSquares(const SparseMatrix<FloatType> &A, const MathVector<FloatType> &b) = 0;\n\n\tstatic FloatType solveError(const SparseMatrix<FloatType> &A, const MathVector<FloatType> &x, const MathVector<FloatType> &b)\n\n\t{\n\n\t\t//.map([](T n) {return std::string(n);})\n\n\t\t//return (A * x - b).map([](D x) {return fabs(x);}).maxValue();\n\n\t\tFloatType res = (FloatType)0.0;\n\n\t\tstd::vector<FloatType> Ax = A*x;\n\n\t\tfor (size_t i = 0; i < Ax.size(); i++) {\n\n\t\t\tres += (Ax[i] - b[i])*(Ax[i] - b[i]);\n\n\t\t} \n\n\t\treturn std::sqrt(res);\n\n\t}\n\n};\n\n\n\ntemplate<class FloatType> class LinearSolverConjugateGradient : public LinearSolver<FloatType>\n\n{\n\npublic:\n\n\tLinearSolverConjugateGradient(UINT maxIterations = 10000, FloatType tolerance = 1e-10)\n\n\t{\n\n\t\tm_maxIterations = maxIterations;\n\n\t\tm_tolerance = tolerance;\n\n\t}\n\n\n\n\tMathVector<FloatType> solve(const SparseMatrix<FloatType> &A, const MathVector<FloatType> &b)\n\n\t{\n\n\t\tMLIB_ASSERT_STR(A.square() && b.size() == A.rows(), \"invalid solve dimensions\");\n\n\t\tconst UINT n = (UINT)b.size();\n\n\n\n\t\t//std::vector<D> dInverse = A.diagonal().map([](D x) {return (D)1.0 / x;});\n\n\t\tMathVector<FloatType> dInverse = A.diagonal();\n\n\t\tauto invert = [] (FloatType& x) { x = (FloatType)1.0/x; };\n\n\t\tfor_each(dInverse.begin(), dInverse.end(), invert);\n\n\n\n\t\tMathVector<FloatType> x(n, 0.0);\n\n\t\tMathVector<FloatType> r = b - A * x;\n\n\t\tMathVector<FloatType> z = dInverse * r;\n\n\t\tMathVector<FloatType> p = z;\n\n\n\n\t\tfor(UINT iteration = 0; iteration < m_maxIterations; iteration++)\n\n\t\t{\n\n\t\t\tFloatType gamma = r | z;\n\n\t\t\tif(fabs(gamma) < 1e-20) break;\n\n\t\t\tFloatType alpha = gamma / SparseMatrix<FloatType>::quadratic(A, p);\n\n\t\t\tx = x + alpha * p;\n\n\t\t\tr = r - alpha * (A * p);\n\n\n\n\t\t\tif (*std::max_element(r.begin(), r.end()) <= m_tolerance && *std::min_element(r.begin(), r.end()) >= -m_tolerance)\tbreak;\n\n\n\n\t\t\tz = dInverse * r;\n\n\t\t\tFloatType beta = (z | r) / gamma;\n\n\t\t\tp = z + beta * p;\n\n\t\t}\n\n\t\treturn x;\n\n\t}\n\n\n\n\tMathVector<FloatType> solveLeastSquares(const SparseMatrix<FloatType> &A, const MathVector<FloatType> &b)\n\n\t{\n\n\t\tauto Atranspose = A.transpose();\n\n\t\treturn solve(Atranspose * A, Atranspose * b);\n\n\t}\n\n\n\nprivate:\n\n\tUINT m_maxIterations;\n\n\tFloatType m_tolerance;\n", "file_path": "include/core-math/linearSolver.h", "rank": 20, "score": 111716.39242068584 }, { "content": "namespace ml {\n\n\n\nnamespace BaseImageHelper {\n\n\n\n inline vec3f convertHSVtoRGB(const vec3f& hsv) {\n\n float H = hsv[0];\n\n float S = hsv[1];\n\n float V = hsv[2];\n\n\n\n float hd = H / 60.0f;\n\n unsigned int h = (unsigned int)hd;\n\n float f = hd - h;\n\n\n\n float p = V*(1.0f - S);\n\n float q = V*(1.0f - S*f);\n\n float t = V*(1.0f - S*(1.0f - f));\n\n\n\n if (h == 0 || h == 6)\n\n {\n\n return vec3f(V, t, p);\n\n }\n\n else if (h == 1)\n\n {\n\n return vec3f(q, V, p);\n\n }\n\n else if (h == 2)\n\n {\n\n return vec3f(p, V, t);\n\n }\n\n else if (h == 3)\n\n {\n\n return vec3f(p, q, V);\n\n }\n\n else if (h == 4)\n\n {\n\n return vec3f(t, p, V);\n\n }\n\n else\n\n {\n\n return vec3f(V, p, q);\n\n }\n\n }\n\n\n\n\t//! untested!\n\n\tinline vec3f convertRGBtoHSV(const vec3f& rgb)\n\n\t{\n\n\t\tvec3f hsv;\n\n\t\tconst float r = rgb.r;\n\n\t\tconst float g = rgb.g;\n\n\t\tconst float b = rgb.b;\n\n\n\n\t\tfloat min, max, delta;\n\n\t\tmin = std::min(std::min(r, g), b);\n\n\t\tmax = std::max(std::max(r, g), b);\n\n\t\thsv[2] = max;\t\t\t\t// v\n\n\t\tdelta = max - min;\n\n\t\tif (max != 0)\n\n\t\t\thsv[1] = delta / max;\t\t// s\n\n\t\telse {\n\n\t\t\t// r = g = b = 0\t\t// s = 0, v is undefined\n\n\t\t\thsv[1] = 0;\n\n\t\t\thsv[0] = -1; // undefined hue\n\n\t\t\treturn hsv;\n\n\t\t}\n\n\t\tif (r == max)\n\n\t\t\thsv[0] = (g - b) / delta;\t\t// between yellow & magenta\n\n\t\telse if (g == max)\n\n\t\t\thsv[0] = 2 + (b - r) / delta;\t// between cyan & yellow\n\n\t\telse\n\n\t\t\thsv[0] = 4 + (r - g) / delta;\t// between magenta & cyan\n\n\t\thsv[0] *= 60;\t\t\t\t// degrees\n\n\t\tif (hsv[0] < 0)\n\n\t\t\thsv[0] += 360;\n\n\t\treturn hsv;\n\n\t}\n\n\n\n\tinline vec3f convertDepthToHSV(float depth, float depthMin = 0.0f, float depthMax = 1.0f) {\n\n\t\tfloat depthZeroOne = (depth - depthMin) / (depthMax - depthMin);\n\n\t\tfloat x = 1.0f - depthZeroOne;\n\n\t\tif (x < 0.0f)\tx = 0.0f;\n\n\t\tif (x > 1.0f)\tx = 1.0f;\n\n\t\treturn vec3f(240.0f*x, 1.0f, 0.5f);\n\n\t}\n\n\n\n inline vec3f convertDepthToRGB(float depth, float depthMin = 0.0f, float depthMax = 1.0f) {\n\n float depthZeroOne = (depth - depthMin) / (depthMax - depthMin);\n\n float x = 1.0f - depthZeroOne;\n\n if (x < 0.0f)\tx = 0.0f;\n\n if (x > 1.0f)\tx = 1.0f;\n\n return convertHSVtoRGB(vec3f(240.0f*x, 1.0f, 0.5f));\n", "file_path": "include/core-base/baseImageHelper.h", "rank": 21, "score": 109307.4030553778 }, { "content": "namespace ml {\n\n\n\n//******************************************************************************************\n\n\n\n#define NR_TINY 1.0e-20f\t// A small number.\n\n#define NR_END 1\n\n//#define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau);a[k][l]=h+s*(g-h*tau)\n\n#define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau);a[k][l]=h+s*(g-h*tau)\n\n\n\n//******************************************************************************************\n\n\n\n\n\n/* free a float vector allocated with vector() */\n\n#ifndef NR_FREE_VECTOR\n\n#define NR_FREE_VECTOR\n\ntemplate <class T>\n\nvoid nr_free_vector(T *v, long nl, long) {\n\n\tfree((char*) (v+nl-NR_END));\n\n};\n\n#endif\n\n\n\n\n\n//******************************************************************************************\n\n\t\n\n\n\n/* Numerical Recipes standard error handler */\n\n#ifndef NR_ERROR\n\n\t#define NR_ERROR\n\n\tstatic void nr_error(const char *error_text) {\n\n\t\tstd::cerr << \"Numerical Recipes run-time error...\" << std::endl;\n\n\t\tstd::cerr << error_text << std::endl;\n\n\t\tstd::cerr << \"...now exiting to system...\" << std::endl;\n\n\t\texit(EXIT_FAILURE);\n\n\t}\n\n#endif\n\n\n\n\n\n//******************************************************************************************\n\n\n\n\n\n/* allocate a float vector with subscript range v[nl..nh] */\n\n#ifndef NR_VECTOR\n\n\t#define NR_VECTOR\n\n\ttemplate <class T>\n\n\tT* nr_vector(long nl, long nh) {\n\n\t\tT *v;\n\n\t\tv=(T *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(T)));\n\n\t\tif (!v) nr_error(\"allocation failure in vector()\");\n\n\t\treturn v-nl+NR_END;\n\n\t}\n\n#endif\n\n\n\n\n\n//******************************************************************************************\n\n\n\n\n\n/*!\n\n Given a matrix a[1..n][1..n], this routine replaces it by the LU decomposition\n\n of a rowwise permutation of itself. a and n are input. a is output, arranged\n\n as in equation (2.3.14) above; indx[1..n] is an output vector that records the\n\n row permutation effected by the partial pivoting: d is output as +- 1 depending\n\n whether the number of row interchanges was even or odd, respectively. This \n\n routine is used in combination with 'lubksb' to solve linear equations or\n\n invert a matrix.\n\n */\n\ntemplate<class T>\n\nvoid ludcmp(T **a, int n, int *indx, T *d) {\n\n\n\n\tint i,imax,j,k;\n\n\tT big,dum,sum,temp;\n\n\tT *vv;\n\n\n\n\tvv=nr_vector<T>(1,n);\n\n\t*d=1.0;\n\n\n\n // Loop over rows to get the implicit scaling information\n\n\tfor (i=1;i<=n;i++) {\n\n\t\tbig=0.0;\n\n \n\n\t\tfor (j=1;j<=n;j++) {\n\n\t\t\tif ((temp=fabs(a[i][j])) > big)\n\n\t\t\t\tbig=temp;\n\n\t\t}\n\n \n\n\t\tif (big == 0.0) // No nonzero largest element.\n\n\t\t\tnr_error(\"Singular matrix in routine ludcmp\");\n\n\n\n // No nonzero largest element.\n\n\t\tvv[i]=1.0f/big; \n\n\t}\n\n\n\n // This is the loop over columns of Crout s method.\n\n\tfor (j=1;j<=n;j++) {\n\n\n\n // This is equation (2.3.12) except for i = j.\n\n\t\tfor (i=1;i<j;i++) {\n\n\t\t\tsum=a[i][j];\n\n\n\n\t\t\tfor (k=1;k<i;k++)\n\n\t\t\t\tsum -= a[i][k]*a[k][j];\n\n\n\n\t\t\ta[i][j]=sum;\n\n\t\t} \n\n\n\n // Initialize for the search for largest pivot element.\n\n\t\tbig=0.0;\n\n\n\n // This is i = j of equation (2.3.12) and i = j+1. . .N of equation (2.3.13).\n\n\t\tfor (i=j;i<=n;i++) {\n\n\t\t\tsum=a[i][j];\n\n\n\n\t\t\tfor (k=1;k<j;k++)\n\n\t\t\t\tsum -= a[i][k]*a[k][j];\n\n\n\n\t\t\ta[i][j]=sum;\n\n\n\n // Is the gure of merit for the pivot better than the best so far?\n\n\t\t\tif ( (dum=vv[i]*fabs(sum)) >= big) { \n\n\t\t\t\tbig=dum;\n\n\t\t\t\timax=i;\n\n\t\t\t}\n\n\t\t}\n\n\n\n // Do we need to interchange rows?\n\n\t\tif (j != imax) {\n\n \n\n // Yes, do so...\n\n\t\t\tfor (k=1;k<=n;k++) {\n\n\t\t\t\tdum=a[imax][k];\n\n\t\t\t\ta[imax][k]=a[j][k];\n\n\t\t\t\ta[j][k]=dum;\n\n\t\t\t}\n\n\n\n // ...and change the parity of d.\n\n\t\t\t*d = -(*d);\n\n\n\n // Also interchange the scale factor.\n\n\t\t\tvv[imax]=vv[j];\n\n\t\t}\n\n\n\n\n\n\t\tindx[j]=imax;\n\n\n\n\t\tif (a[j][j] == 0.0)\n\n\t\t\ta[j][j]=NR_TINY;\n\n \n\n // If the pivot element is zero the matrix is singular (at least to the precision of the algorithm). For some applications on singular matrices, it is desirable to substitute TINY for zero.\n\n\t\tif (j != n) {\n\n // Now, nally, divide by the pivot element.\n\n\t\t\tdum=1.0f/(a[j][j]);\n\n\t\t\tfor (i=j+1;i<=n;i++)\n\n\t\t\t\ta[i][j] *= dum;\n\n\t\t}\n\n\t}\n\n\tnr_free_vector(vv,1,n);\n\n}\n\n\n\n\n\n//******************************************************************************************\n\n\n\n\n\n/*!\n\n Solves the set of n linear equations A�X = B. Here a[1..n][1..n] is input,\n\n not as the matrix A but rather as its LU decomposition, determined by the\n\n routine ludcmp. indx[1..n] is input as the permutation vector returned by\n\n ludcmp. b[1..n] is input as the right-hand side vector B, and returns with\n\n the solution vector X. a, n, and indx are not modifed by this routine and\n\n can be left in place for successive calls with different right-hand sides b.\n\n */\n\ntemplate <class T>\n\nvoid lubksb(T **a, int n, int *indx, T b[]) {\n\n\n\n\tint i,ii=0,ip,j;\n\n\tT sum;\n\n\n\n // When ii is set to a positive value, it will become the index of the \n\n // first nonvanishing element of b. Wenow do the forward substitution,\n\n // equation (2.3.6). The only new wrinkle is to unscramble the permutation\n\n // as we go.\n\n\tfor (i=1;i<=n;i++) { \n\n\t\tip=indx[i];\n\n\t\tsum=b[ip];\n\n\t\tb[ip]=b[i];\n\n\n\n\t\tif (ii)\n\n\t\t\tfor (j=ii;j<=i-1;j++)\n\n\t\t\t\tsum -= a[i][j]*b[j];\n\n\t\telse if (sum) // A nonzero element was encountered, so from now on we will have to do the sums in the loop above.\n\n\t\t\tii=i;\n\n\n\n\t\tb[i]=sum;\n\n\t}\n\n\n\n // Now we do the backsubstitution, equation (2.3.7).\n\n\tfor (i=n;i>=1;i--) {\n\n\t\tsum=b[i];\n\n\t\tfor (j=i+1;j<=n;j++) \n\n\t\t\tsum -= a[i][j]*b[j];\n\n\n\n // Store a component of the solution vector X.\n\n\t\tb[i]=sum/a[i][i];\n\n\t}\n\n}\n\n\n\n\n\n//******************************************************************************************\n\n\n\n\n\n///*!\n\n// L�st das LGS a*x = b.\n\n// */\n\n//void solveLU(float **a, int n, float b[]) {\n\n//\n\n// float d;\n\n// int* indx = new int[n+1];\n\n//\n\n// nr_ludcmp(a, n, indx, &d);\n\n// lubksb(a, n, indx, b);\n\n//}\n\n\t\t\n\n\n\n//******************************************************************************************\n\n\n\ntemplate<typename T>\n\ninline const T SQR(const T a)\n\n{return a*a;}\n\n\n\ntemplate<typename T>\n\ninline const T SIGN(const T &a, const T &b)\n\n{return b >= 0 ? (a >= 0 ? a : -a) : (a >= 0 ? -a : a);}\n\n// inline float SIGN(const float &a, const double &b)\n\n// {return b >= 0 ? (a >= 0 ? a : -a) : (a >= 0 ? -a : a);}\n\n// inline float SIGN(const double &a, const float &b)\n\n// {return b >= 0 ? (a >= 0 ? a : -a) : (a >= 0 ? -a : a);}\n\n// template<typename T>\n\n// inline const T MAX(const T &a, const T &b)\n\n// {return b > a ? (b) : (a);}\n\n// template<typename T>\n\n// inline const T MIN(const T &a, const T &b)\n\n// {return b < a ? (b) : (a);}\n\n\n\ntemplate<typename T>\n\nT pythag(const T a, const T b)\n\n{\n\n\tT absa,absb;\n\n\tabsa=std::abs(a);\n\n\tabsb=std::abs(b);\n\n\tif (absa > absb)\n\n\t\treturn absa*std::sqrt((T)1.0+SQR(absb/absa));\n\n\telse\n\n\t\treturn (absb == 0.0 ? (T)0.0 : absb*std::sqrt((T)1.0+SQR(absa/absb)));\n\n}\n\n\n\n//******************************************************************************************\n\n\n\ntemplate<typename T>\n\nbool jacobi(T **a, int n, T d[], T **v, int *nrot) {\n\n\tint j,iq,ip,i;\n\n\tT tresh,theta,tau,t,sm,s,h,g,c;\n\n\tT *b,*z;\n\n\n\n\tb=nr_vector<T>(1,n);\n\n\tz=nr_vector<T>(1,n);\n\n\tfor (ip=1;ip<=n;ip++) {\n\n\t\tfor (iq=1;iq<=n;iq++) v[ip][iq]=(T)0.0;\n\n\t\tv[ip][ip]=(T)1.0;\n\n\t}\n\n\tfor (ip=1;ip<=n;ip++) {\n\n\t\tb[ip]=d[ip]=a[ip][ip];\n\n\t\tz[ip]=(T)0.0;\n\n\t}\n\n\t*nrot=0;\n\n\tfor (i=1;i<=50;i++) {\n\n\t\tsm=(T)0.0;\n\n\t\tfor (ip=1;ip<=n-1;ip++) {\n\n\t\t\tfor (iq=ip+1;iq<=n;iq++)\n\n\t\t\t\tsm += fabs(a[ip][iq]);\n\n\t\t\t}\n\n\t\t\tif (sm == 0.0) {\n\n\t\t\t\tnr_free_vector(z,1,n);\n\n\t\t\t\tnr_free_vector(b,1,n);\n\n\t\t\t\treturn true;\n\n\t\t\t}\n\n\t\t\tif (i < 4)\n\n\t\t\t\ttresh=(T)0.2*sm/(n*n);\n\n\t\t\telse\n\n\t\t\t\ttresh=(T)0.0;\n\n\t\t\tfor (ip=1;ip<=n-1;ip++) {\n\n\t\t\t\tfor (iq=ip+1;iq<=n;iq++) {\n\n\t\t\t\t\tg=(T)100.0*fabs(a[ip][iq]);\n\n\t\t\t\t\tif (i > 4 && (T)(fabs(d[ip])+g) == (T)fabs(d[ip]) && (T)(fabs(d[iq])+g) == (T)fabs(d[iq]))\n\n\t\t\t\t\t\ta[ip][iq]=(T)0.0;\n\n\t\t\t\t\telse if (fabs(a[ip][iq]) > tresh) {\n\n\t\t\t\t\t\th=d[iq]-d[ip];\n\n\t\t\t\t\t\tif ((T)(fabs(h)+g) == (T)fabs(h))\n\n\t\t\t\t\t\t\tt=(a[ip][iq])/h;\n\n\t\t\t\t\t\telse {\n\n\t\t\t\t\t\t\ttheta=(T)0.5*h/(a[ip][iq]);\n\n\t\t\t\t\t\t\tt=(T)1.0/(fabs(theta)+sqrt((T)1.0+theta*theta));\n\n\t\t\t\t\t\t\tif (theta < 0.0)\n\n\t\t\t\t\t\t\t\tt = -t;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tc=(T)1.0/sqrt(1+t*t);\n\n\t\t\t\t\t\ts=t*c;\n\n\t\t\t\t\t\ttau=s/((T)1.0+c);\n\n\t\t\t\t\t\th=t*a[ip][iq];\n\n\t\t\t\t\t\tz[ip] -= (T)h;\n\n\t\t\t\t\t\tz[iq] += (T)h;\n\n\t\t\t\t\t\td[ip] -= (T)h;\n\n\t\t\t\t\t\td[iq] += (T)h;\n\n\t\t\t\t\t\ta[ip][iq]=(T)0.0;\n\n\t\t\t\t\t\tfor (j=1;j<=ip-1;j++) {\n\n\t\t\t\t\t\t\tROTATE(a,j,ip,j,iq);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (j=ip+1;j<=iq-1;j++) {\n\n\t\t\t\t\t\t\tROTATE(a,ip,j,j,iq);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (j=iq+1;j<=n;j++) {\n\n\t\t\t\t\t\t\tROTATE(a,ip,j,iq,j);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (j=1;j<=n;j++) {\n\n\t\t\t\t\t\t\tROTATE(v,j,ip,j,iq);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t++(*nrot);\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfor (ip=1;ip<=n;ip++) {\n\n\t\t\t\tb[ip] += z[ip];\n\n\t\t\t\td[ip]=b[ip];\n\n\t\t\t\tz[ip]=(T)0.0;\n\n\t\t\t}\n\n\t\t}\n\n\treturn false;\n\n}\n\n\n\n//******************************************************************************************\n\n\n\n//! Computes the SVD decomposition of a. Returns 'true' on success, otherwise 'false'\n\ntemplate<typename T>\n\nbool svdcmp(T **a, int m, int n, T w[], T **v)\n\n{\n\n\tint flag,i,its,j,jj,k,l,nm;\n\n\tT anorm,c,f,g,h,s,scale,x,y,z,*rv1;\n\n\n\n\trv1=nr_vector<T>(1,n);\n\n\tg=scale=anorm=0.0;\n\n\tfor (i=1;i<=n;i++) {\n\n\t\tl=i+1;\n\n\t\trv1[i]=scale*g;\n\n\t\tg=s=scale=0.0;\n\n\t\tif (i <= m) {\n\n\t\t\tfor (k=i;k<=m;k++) scale += std::abs(a[k][i]);\n\n\t\t\tif (scale) {\n\n\t\t\t\tfor (k=i;k<=m;k++) {\n\n\t\t\t\t\ta[k][i] /= scale;\n\n\t\t\t\t\ts += a[k][i]*a[k][i];\n\n\t\t\t\t}\n\n\t\t\t\tf=a[i][i];\n\n\t\t\t\tg = -SIGN(std::sqrt(s),f);\n\n\t\t\t\th=f*g-s;\n\n\t\t\t\ta[i][i]=f-g;\n\n\t\t\t\tfor (j=l;j<=n;j++) {\n\n\t\t\t\t\tfor (s=0.0,k=i;k<=m;k++) s += a[k][i]*a[k][j];\n\n\t\t\t\t\tf=s/h;\n\n\t\t\t\t\tfor (k=i;k<=m;k++) a[k][j] += f*a[k][i];\n\n\t\t\t\t}\n\n\t\t\t\tfor (k=i;k<=m;k++) a[k][i] *= scale;\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\tw[i]=scale *g;\n\n\n\n\t\tg=s=scale=0.0;\n\n\t\tif (i <= m && i != n) {\n\n\t\t\tfor (k=l;k<=n;k++) scale += std::abs(a[i][k]);\n\n\t\t\tif (scale) {\n\n\t\t\t\tfor (k=l;k<=n;k++) {\n\n\t\t\t\t\ta[i][k] /= scale;\n\n\t\t\t\t\ts += a[i][k]*a[i][k];\n\n\t\t\t\t}\n\n\t\t\t\tf=a[i][l];\n\n\t\t\t\tg = -SIGN(std::sqrt(s),f);\n\n\t\t\t\th=f*g-s;\n\n\t\t\t\ta[i][l]=f-g;\n\n\t\t\t\tfor (k=l;k<=n;k++) rv1[k]=a[i][k]/h;\n\n\t\t\t\tfor (j=l;j<=m;j++) {\n\n\t\t\t\t\tfor (s=0.0,k=l;k<=n;k++) s += a[j][k]*a[i][k];\n\n\t\t\t\t\tfor (k=l;k<=n;k++) a[j][k] += s*rv1[k];\n\n\t\t\t\t}\n\n\t\t\t\tfor (k=l;k<=n;k++) a[i][k] *= scale;\n\n\t\t\t}\n\n\t\t}\n\n\t\tanorm=std::max(anorm,(std::abs(w[i])+std::abs(rv1[i])));\n\n\t}\n\n\n\n\tfor (i=n;i>=1;i--) {\n\n\t\tif (i < n) {\n\n\t\t\tif (g) {\n\n\t\t\t\tfor (j=l;j<=n;j++)\n\n\t\t\t\t\tv[j][i]=(a[i][j]/a[i][l])/g;\n\n\t\t\t\tfor (j=l;j<=n;j++) {\n\n\t\t\t\t\tfor (s=0.0,k=l;k<=n;k++) s += a[i][k]*v[k][j];\n\n\t\t\t\t\tfor (k=l;k<=n;k++) v[k][j] += s*v[k][i];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfor (j=l;j<=n;j++) v[i][j]=v[j][i]=0.0;\n\n\t\t}\n\n\t\tv[i][i]=1.0;\n\n\t\tg=rv1[i];\n\n\t\tl=i;\n\n\t}\n\n\tfor (i=std::min(m,n);i>=1;i--) {\n\n\t\tl=i+1;\n\n\t\tg=w[i];\n\n\t\tfor (j=l;j<=n;j++) a[i][j]=0.0;\n\n\t\tif (g) {\n\n\t\t\tg=(T)1.0/g;\n\n\t\t\tfor (j=l;j<=n;j++) {\n\n\t\t\t\tfor (s=0.0,k=l;k<=m;k++) s += a[k][i]*a[k][j];\n\n\t\t\t\tf=(s/a[i][i])*g;\n\n\t\t\t\tfor (k=i;k<=m;k++) a[k][j] += f*a[k][i];\n\n\t\t\t}\n\n\t\t\tfor (j=i;j<=m;j++) a[j][i] *= g;\n\n\t\t} else for (j=i;j<=m;j++) a[j][i]=0.0;\n\n\t\t++a[i][i];\n\n\t}\n\n\n\n\tfor (k=n;k>=1;k--) {\n\n\t\tfor (its=1;its<=30;its++) {\n\n\t\t\tflag=1;\n\n\t\t\tfor (l=k;l>=1;l--) {\n\n\t\t\t\tnm=l-1;\n\n\t\t\t\tif ((T)(std::abs(rv1[l])+anorm) == anorm) {\n\n\t\t\t\t\tflag=0;\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t\tif ((T)(std::abs(w[nm])+anorm) == anorm) break;\n\n\t\t\t}\n\n\t\t\tif (flag) {\n\n\t\t\t\tc=0.0;\n\n\t\t\t\ts=1.0;\n\n\t\t\t\tfor (i=l;i<=k;i++) {\n\n\t\t\t\t\tf=s*rv1[i];\n\n\t\t\t\t\trv1[i]=c*rv1[i];\n\n\t\t\t\t\tif ((T)(std::abs(f)+anorm) == anorm) break;\n\n\t\t\t\t\tg=w[i];\n\n\t\t\t\t\th=pythag(f,g);\n\n\t\t\t\t\tw[i]=h;\n\n\t\t\t\t\th=(T)1.0/h;\n\n\t\t\t\t\tc=g*h;\n\n\t\t\t\t\ts = -f*h;\n\n\t\t\t\t\tfor (j=1;j<=m;j++) {\n\n\t\t\t\t\t\ty=a[j][nm];\n\n\t\t\t\t\t\tz=a[j][i];\n\n\t\t\t\t\t\ta[j][nm]=y*c+z*s;\n\n\t\t\t\t\t\ta[j][i]=z*c-y*s;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tz=w[k];\n\n\t\t\tif (l == k) {\n\n\t\t\t\tif (z < 0.0) {\n\n\t\t\t\t\tw[k] = -z;\n\n\t\t\t\t\tfor (j=1;j<=n;j++)\n\n\t\t\t\t\t\tv[j][k] = -v[j][k];\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tif (its == 30) {\n\n\t\t\t\t//std::cerr << \"NR Error: no convergence in 30 svdcmp iterations\" << std::endl;\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\n\n\t\t\tx=w[l];\n\n\t\t\tnm=k-1;\n\n\n\n\t\t\t//std::cerr << \"nm: \" << nm << std::endl;\n\n\n\n\t\t\ty=w[nm];\n\n\t\t\tg=rv1[nm];\n\n\t\t\th=rv1[k];\n\n\t\t\tf=((y-z)*(y+z)+(g-h)*(g+h))/((T)2.0*h*y);\n\n\t\t\tg=pythag(f,(T)1.0);\n\n\t\t\tf=((x-z)*(x+z)+h*((y/(f+SIGN(g,f)))-h))/x;\n\n\t\t\tc=s=1.0;\n\n\t\t\tfor (j=l;j<=nm;j++) {\n\n\n\n\t\t\t\ti=j+1;\n\n\t\t\t\tg=rv1[i];\n\n\t\t\t\ty=w[i];\n\n\t\t\t\th=s*g;\n\n\t\t\t\tg=c*g;\n\n\t\t\t\tz=pythag(f,h);\n\n\t\t\t\trv1[j]=z;\n\n\t\t\t\tc=f/z;\n\n\t\t\t\ts=h/z;\n\n\t\t\t\tf=x*c+g*s;\n\n\t\t\t\tg = g*c-x*s;\n\n\t\t\t\th=y*s;\n\n\t\t\t\ty *= c;\n\n\n\n\n\n\t\t\t\tfor (jj=1;jj<=n;jj++) {\n\n\t\t\t\t\tx=v[jj][j];\n\n\t\t\t\t\tz=v[jj][i];\n\n\t\t\t\t\tv[jj][j]=x*c+z*s;\n\n\t\t\t\t\tv[jj][i]=z*c-x*s;\n\n\t\t\t\t}\n\n\t\t\t\tz=pythag(f,h);\n\n\t\t\t\tw[j]=z;\n\n\t\t\t\tif (z) {\n\n\t\t\t\t\tz=(T)1.0/z;\n\n\t\t\t\t\tc=f*z;\n\n\t\t\t\t\ts=h*z;\n\n\t\t\t\t}\n\n\t\t\t\tf=c*g+s*y;\n\n\t\t\t\tx=c*y-s*g;\n\n\t\t\t\tfor (jj=1;jj<=m;jj++) {\n\n\t\t\t\t\ty=a[jj][j];\n\n\t\t\t\t\tz=a[jj][i];\n\n\t\t\t\t\ta[jj][j]=y*c+z*s;\n\n\t\t\t\t\ta[jj][i]=z*c-y*s;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\trv1[l]=0.0;\n\n\t\t\trv1[k]=f;\n\n\t\t\tw[k]=x;\n\n\t\t}\n\n\t}\n\n\tnr_free_vector(rv1,1,n);\n\n\n\n\treturn true;\n\n}\n\n\n\n\n\n//******************************************************************************************\n\n\n\n//******************************************************************************************\n\n\n\n//! Computes the SVD decomposition of a. Returns 'true' on success, otherwise 'false'\n\ntemplate<typename T>\n\nbool svdcmpZeroBased(T **a, int m, int n, T w[], T **v)\n\n{\n\n\tint flag,i,its,j,jj,k,l,nm;\n\n\tT anorm,c,f,g,h,s,scale,x,y,z,*rv1;\n\n\n\n\n\n\trv1=nr_vector<T>(0,n);\n\n\tg=scale=anorm=0.0;\n\n\tfor (i=0;i<n;i++) {\n\n\t\tl=i+1;\n\n\t\trv1[i]=scale*g;\n\n\t\tg=s=scale=0.0;\n\n\t\tif (i < m) {\n\n\t\t\tfor (k=i;k<m;k++) scale += std::abs(a[k][i]);\n\n\t\t\tif (scale) {\n\n\t\t\t\tfor (k=i;k<m;k++) {\n\n\t\t\t\t\ta[k][i] /= scale;\n\n\t\t\t\t\ts += a[k][i]*a[k][i];\n\n\t\t\t\t}\n\n\t\t\t\tf=a[i][i];\n\n\t\t\t\tg = -SIGN(std::sqrt(s),f);\n\n\t\t\t\th=f*g-s;\n\n\t\t\t\ta[i][i]=f-g;\n\n\t\t\t\tfor (j=l;j<n;j++) {\n\n\t\t\t\t\tfor (s=0.0,k=i;k<m;k++) s += a[k][i]*a[k][j];\n\n\t\t\t\t\tf=s/h;\n\n\t\t\t\t\tfor (k=i;k<m;k++) a[k][j] += f*a[k][i];\n\n\t\t\t\t}\n\n\t\t\t\tfor (k=i;k<m;k++) a[k][i] *= scale;\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\tw[i]=scale *g;\n\n\n\n\t\tg=s=scale=0.0;\n\n\t\tif (i < m && i != (n-1)) {\n\n\t\t\tfor (k=l;k<n;k++) scale += std::abs(a[i][k]);\n\n\t\t\tif (scale) {\n\n\t\t\t\tfor (k=l;k<n;k++) {\n\n\t\t\t\t\ta[i][k] /= scale;\n\n\t\t\t\t\ts += a[i][k]*a[i][k];\n\n\t\t\t\t}\n\n\t\t\t\tf=a[i][l];\n\n\t\t\t\tg = -SIGN(std::sqrt(s),f);\n\n\t\t\t\th=f*g-s;\n\n\t\t\t\ta[i][l]=f-g;\n\n\t\t\t\tfor (k=l;k<n;k++) rv1[k]=a[i][k]/h;\n\n\t\t\t\tfor (j=l;j<m;j++) {\n\n\t\t\t\t\tfor (s=0.0,k=l;k<n;k++) s += a[j][k]*a[i][k];\n\n\t\t\t\t\tfor (k=l;k<n;k++) a[j][k] += s*rv1[k];\n\n\t\t\t\t}\n\n\t\t\t\tfor (k=l;k<n;k++) a[i][k] *= scale;\n\n\t\t\t}\n\n\t\t}\n\n\t\tanorm=std::max(anorm,(std::abs(w[i])+std::abs(rv1[i])));\n\n\t}\n\n\n\n\tfor (i=(n-1);i>=0;i--) {\n\n\t\tif (i < (n-1)) {\n\n\t\t\tif (g) {\n\n\t\t\t\tfor (j=l;j<n;j++)\n\n\t\t\t\t\tv[j][i]=(a[i][j]/a[i][l])/g;\n\n\t\t\t\tfor (j=l;j<n;j++) {\n\n\t\t\t\t\tfor (s=0.0,k=l;k<n;k++) s += a[i][k]*v[k][j];\n\n\t\t\t\t\tfor (k=l;k<n;k++) v[k][j] += s*v[k][i];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfor (j=l;j<n;j++) v[i][j]=v[j][i]=0.0;\n\n\t\t}\n\n\t\tv[i][i]=1.0;\n\n\t\tg=rv1[i];\n\n\t\tl=i;\n\n\t}\n\n\tfor (i=std::min(m,n)-1;i>=0;i--) {\n\n\t\tl=i+1;\n\n\t\tg=w[i];\n\n\t\tfor (j=l;j<n;j++) a[i][j]=0.0;\n\n\t\tif (g) {\n\n\t\t\tg=(T)1.0/g;\n\n\t\t\tfor (j=l;j<n;j++) {\n\n\t\t\t\tfor (s=0.0,k=l;k<m;k++) s += a[k][i]*a[k][j];\n\n\t\t\t\tf=(s/a[i][i])*g;\n\n\t\t\t\tfor (k=i;k<m;k++) a[k][j] += f*a[k][i];\n\n\t\t\t}\n\n\t\t\tfor (j=i;j<m;j++) a[j][i] *= g;\n\n\t\t} else for (j=i;j<m;j++) a[j][i]=0.0;\n\n\t\t++a[i][i];\n\n\t}\n\n\n\n\tfor (k=(n-1);k>=0;k--) {\n\n\t\tfor (its=1;its<=30;its++) {\n\n\t\t\tflag=1;\n\n\t\t\tfor (l=k;l>=0;l--) {\n\n\t\t\t\tnm=l-1;\n\n\t\t\t\tif ((T)(std::abs(rv1[l])+anorm) == anorm) {\n\n\t\t\t\t\tflag=0;\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t\tif ((T)(std::abs(w[nm])+anorm) == anorm) break;\n\n\t\t\t}\n\n\t\t\tif (flag) {\n\n\t\t\t\tc=0.0;\n\n\t\t\t\ts=1.0;\n\n\t\t\t\tfor (i=l;i<k;i++) {\n\n\t\t\t\t\tf=s*rv1[i];\n\n\t\t\t\t\trv1[i]=c*rv1[i];\n\n\t\t\t\t\tif ((T)(std::abs(f)+anorm) == anorm) break;\n\n\t\t\t\t\tg=w[i];\n\n\t\t\t\t\th=pythag(f,g);\n\n\t\t\t\t\tw[i]=h;\n\n\t\t\t\t\th=(T)1.0/h;\n\n\t\t\t\t\tc=g*h;\n\n\t\t\t\t\ts = -f*h;\n\n\t\t\t\t\tfor (j=0;j<m;j++) {\n\n\t\t\t\t\t\ty=a[j][nm];\n\n\t\t\t\t\t\tz=a[j][i];\n\n\t\t\t\t\t\ta[j][nm]=y*c+z*s;\n\n\t\t\t\t\t\ta[j][i]=z*c-y*s;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tz=w[k];\n\n\t\t\tif (l == k) {\n\n\t\t\t\tif (z < 0.0) {\n\n\t\t\t\t\tw[k] = -z;\n\n\t\t\t\t\tfor (j=0;j<n;j++)\n\n\t\t\t\t\t\tv[j][k] = -v[j][k];\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tif (its == 30) {\n\n\t\t\t\t//std::cerr << \"NR Error: no convergence in 30 svdcmp iterations\" << std::endl;\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\n\n\n\n\t\t\tx=w[l];\n\n\t\t\tnm=k-1; // <- k-1?\n\n\n\n\t\t\tstd::cerr << \"nm: \" << nm << std::endl;\n\n\n\n\t\t\ty=w[nm];\n\n\t\t\tg=rv1[nm];\n\n\t\t\th=rv1[k];\n\n\t\t\tf=((y-z)*(y+z)+(g-h)*(g+h))/((T)2.0*h*y);\n\n\t\t\tg=pythag(f,(T)1.0);\n\n\t\t\tf=((x-z)*(x+z)+h*((y/(f+SIGN(g,f)))-h))/x;\n\n\t\t\tc=s=1.0;\n\n\t\t\tfor (j=l;j<nm;j++) {\n\n\n\n\t\t\t//for (int xx = 0; xx < n; xx++) {\n\n\t\t\t//\tfor (int yy = 0; yy < n; yy++) {\n\n\t\t\t//\t\tstd::cerr << a[xx][yy] << \" \";\n\n\t\t\t//\t}\n\n\t\t\t//\tstd::cerr << std::endl;\n\n\t\t\t//}\n\n\t\t\t//std::cerr << std::endl;\n\n\n\n\t\t\t\ti=j+1;\n\n\t\t\t\tg=rv1[i];\n\n\t\t\t\ty=w[i];\n\n\t\t\t\th=s*g;\n\n\t\t\t\tg=c*g;\n\n\t\t\t\tz=pythag(f,h);\n\n\t\t\t\trv1[j]=z;\n\n\t\t\t\tc=f/z;\n\n\t\t\t\ts=h/z;\n\n\t\t\t\tf=x*c+g*s;\n\n\t\t\t\tg = g*c-x*s;\n\n\t\t\t\th=y*s;\n\n\t\t\t\ty *= c;\n\n\n\n\n\n\t\t\t\tfor (jj=0;jj<n;jj++) {\n\n\t\t\t\t\tx=v[jj][j];\n\n\t\t\t\t\tz=v[jj][i];\n\n\t\t\t\t\tv[jj][j]=x*c+z*s;\n\n\t\t\t\t\tv[jj][i]=z*c-x*s;\n\n\t\t\t\t}\n\n\t\t\t\tz=pythag(f,h);\n\n\t\t\t\tw[j]=z;\n\n\t\t\t\tif (z) {\n\n\t\t\t\t\tz=(T)1.0/z;\n\n\t\t\t\t\tc=f*z;\n\n\t\t\t\t\ts=h*z;\n\n\t\t\t\t}\n\n\t\t\t\tf=c*g+s*y;\n\n\t\t\t\tx=c*y-s*g;\n\n\t\t\t\tfor (jj=0;jj<m;jj++) {\n\n\t\t\t\t\ty=a[jj][j];\n\n\t\t\t\t\tz=a[jj][i];\n\n\t\t\t\t\ta[jj][j]=y*c+z*s;\n\n\t\t\t\t\ta[jj][i]=z*c-y*s;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\trv1[l]=0.0;\n\n\t\t\trv1[k]=f;\n\n\t\t\tw[k]=x;\n\n\t\t}\n\n\t}\n\n\tnr_free_vector(rv1,0,n);\n\n\n\n\treturn true;\n\n}\n\n\n\n\n\n//******************************************************************************************\n\n\n\n\n\ntemplate<typename T>\n\nvoid svbksb(T **u, T w[], T **v, int m, int n, T b[], T x[])\n\n{\n\n\tint jj,j,i;\n\n\tT s,*tmp;\n\n\n\n\ttmp=nr_vector<T>(1,n);\n\n\tfor (j=1;j<=n;j++) {\n\n\t\ts=0.0;\n\n\t\tif (w[j]) {\n\n\t\t\tfor (i=1;i<=m;i++)\n\n\t\t\t\ts += u[i][j]*b[i];\n\n\t\t\ts /= w[j];\n\n\t\t}\n\n\t\ttmp[j]=s;\n\n\t}\n\n\tfor (j=1;j<=n;j++) {\n\n\t\ts=0.0;\n\n\t\tfor (jj=1;jj<=n;jj++)\n\n\t\t\ts += v[j][jj]*tmp[jj];\n\n\t\tx[j]=s;\n\n\t}\n\n\tnr_free_vector(tmp,1,n);\n\n}\n\n\n\n\n\n#undef NR_END\n\n#undef NR_TINY\n\n\n", "file_path": "include/core-math/numericalRecipesTemplates.h", "rank": 22, "score": 109307.4030553778 }, { "content": "namespace ml {\n\n\n\n////////////////////////////////////////\n\n// Conversions for free image warper ///\n\n////////////////////////////////////////\n\n\n\n\n\n//////////////////////\n\n// Data Read Helper //\n\n//////////////////////\n\n\n\n//BYTE\n\ntemplate<class T>\tinline void convertFromBYTE(T& output, const BYTE* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromBYTE<unsigned char>(unsigned char& output, const BYTE* input) {\n\n\toutput = input[0];\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec3d>(vec3d& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0;\t\n\n\toutput.y = input[0]/255.0;\t\n\n\toutput.x = input[0]/255.0;\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec4d>(vec4d& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0;\n\n\toutput.y = input[0]/255.0;\n\n\toutput.x = input[0]/255.0;\n\n\toutput.w = 1.0;\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec3f>(vec3f& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0f;\t\n\n\toutput.y = input[0]/255.0f;\t\n\n\toutput.x = input[0]/255.0f;\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec4f>(vec4f& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0f;\n\n\toutput.y = input[0]/255.0f;\n\n\toutput.x = input[0]/255.0f;\n\n\toutput.w = 1.0f;\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec3i>(vec3i& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[0];\t\n\n\toutput.x = input[0];\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec4i>(vec4i& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[0];\t\n\n\toutput.x = input[0];\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec3ui>(vec3ui& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[0];\t\n\n\toutput.x = input[0];\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec4ui>(vec4ui& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[0];\t\n\n\toutput.x = input[0];\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec3uc>(vec3uc& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[0];\t\n\n\toutput.x = input[0];\n\n}\n\ntemplate<>\tinline void convertFromBYTE<vec4uc>(vec4uc& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[0];\t\n\n\toutput.x = input[0];\n\n\toutput.w = 255;\n\n}\n\n\n\n//BYTE3\n\ntemplate<class T>\tinline void convertFromBYTE3(T& output, const BYTE* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec3d>(vec3d& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0;\t\n\n\toutput.y = input[1]/255.0;\t\n\n\toutput.x = input[2]/255.0;\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec4d>(vec4d& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0;\n\n\toutput.y = input[1]/255.0;\n\n\toutput.x = input[2]/255.0;\n\n\toutput.w = 1.0;\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec3f>(vec3f& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0f;\t\n\n\toutput.y = input[1]/255.0f;\t\n\n\toutput.x = input[2]/255.0f;\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec4f>(vec4f& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0f;\n\n\toutput.y = input[1]/255.0f;\n\n\toutput.x = input[2]/255.0f;\n\n\toutput.w = 1.0f;\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec3i>(vec3i& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec4i>(vec4i& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec3ui>(vec3ui& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec4ui>(vec4ui& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec3uc>(vec3uc& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n}\n\ntemplate<>\tinline void convertFromBYTE3<vec4uc>(vec4uc& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n\toutput.w = 255;\n\n}\n\n\n\n\n\n//BYTE4\n\ntemplate<class T>\tinline void convertFromBYTE4(T& output, const BYTE* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec3d>(vec3d& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0;\t\n\n\toutput.y = input[1]/255.0;\t\n\n\toutput.x = input[2]/255.0;\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec4d>(vec4d& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0;\n\n\toutput.y = input[1]/255.0;\n\n\toutput.x = input[2]/255.0;\n\n\toutput.w = input[3]/255.0;\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec3f>(vec3f& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0f;\t\n\n\toutput.y = input[1]/255.0f;\t\n\n\toutput.x = input[2]/255.0f;\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec4f>(vec4f& output, const BYTE* input) {\n\n\toutput.z = input[0]/255.0f;\n\n\toutput.y = input[1]/255.0f;\n\n\toutput.x = input[2]/255.0f;\n\n\toutput.w = input[3]/255.0f;\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec3i>(vec3i& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec4i>(vec4i& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n\toutput.w = input[3];\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec3ui>(vec3ui& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec4ui>(vec4ui& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n\toutput.w = input[3];\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec3uc>(vec3uc& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n}\n\ntemplate<>\tinline void convertFromBYTE4<vec4uc>(vec4uc& output, const BYTE* input) {\n\n\toutput.z = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.x = input[2];\n\n\toutput.w = input[3];\n\n}\n\n\n\n\n\n//USHORT\n\ntemplate<class T>\tinline void convertFromUSHORT(T& output, const unsigned short* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromUSHORT<unsigned short>(unsigned short& output, const unsigned short* input) {\n\n\toutput = *input;\n\n}\n\ntemplate<>\tinline void convertFromUSHORT<float>(float& output, const unsigned short* input) {\n\n\toutput = (float)*input;\n\n\toutput /= 1000.0f;\n\n}\n\ntemplate<>\tinline void convertFromUSHORT<double>(double& output, const unsigned short* input) {\n\n\toutput = (double)*input;\n\n\toutput /= 1000.0;\n\n}\n\n\n\n//USHORT3\n\ntemplate<class T>\tinline void convertFromUSHORT3(T& output, const unsigned short* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromUSHORT3<vec3d>(vec3d& output, const unsigned short* input) {\n\n\toutput.z = (double)input[0];\n\n\toutput.y = (double)input[1];\n\n\toutput.x = (double)input[2];\n\n}\n\ntemplate<>\tinline void convertFromUSHORT3<vec3f>(vec3f& output, const unsigned short* input) {\n\n\toutput.z = (float)input[0];\n\n\toutput.y = (float)input[1];\n\n\toutput.x = (float)input[2];\n\n}\n\ntemplate<>\tinline void convertFromUSHORT3<vec3us>(vec3us& output, const unsigned short* input) {\n\n\toutput.z = input[0];\n\n\toutput.y = input[1];\n\n\toutput.x = input[2];\n\n}\n\n\n\ntemplate<>\tinline void convertFromUSHORT3<unsigned short>(unsigned short& output, const unsigned short* input) {\n\n\toutput = input[0];\n\n}\n\n\n\n//USHORT4\n\ntemplate<class T>\tinline void convertFromUSHORT4(T& output, const unsigned short* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromUSHORT4<vec4d>(vec4d& output, const unsigned short* input) {\n\n\toutput.z = (double)input[0];\n\n\toutput.y = (double)input[1];\n\n\toutput.x = (double)input[2];\n\n\toutput.w = (double)input[3];\n\n}\n\ntemplate<>\tinline void convertFromUSHORT4<vec4us>(vec4us& output, const unsigned short* input) {\n\n\toutput.z = input[0];\n\n\toutput.y = input[1];\n\n\toutput.x = input[2];\n\n\toutput.w = input[3];\n\n}\n\ntemplate<>\tinline void convertFromUSHORT4<vec4uc>(vec4uc& output, const unsigned short* input) {\n\n\t//this is a hard-coded HDR to non-HDR conversion\n\n\toutput.z = (unsigned char)(input[0] / 256);\n\n\toutput.y = (unsigned char)(input[1] / 256);\n\n\toutput.x = (unsigned char)(input[2] / 256);\n\n\toutput.w = (unsigned char)(input[3] / 256);\n\n}\n\n\n\ntemplate<>\tinline void convertFromUSHORT4<vec3d>(vec3d& output, const unsigned short* input) {\n\n\toutput.x = (double)input[0];\n\n\toutput.y = (double)input[1];\n\n\toutput.z = (double)input[2];\n\n}\n\ntemplate<>\tinline void convertFromUSHORT4<vec3us>(vec3us& output, const unsigned short* input) {\n\n\toutput.z = input[0];\n\n\toutput.y = input[1];\n\n\toutput.x = input[2];\n\n}\n\n\n\ntemplate<>\tinline void convertFromUSHORT4<unsigned short>(unsigned short& output, const unsigned short* input) {\n\n\toutput = input[0];\n\n}\n\n\n\n//FLOAT\n\ntemplate<class T>\tinline void convertFromFLOAT(T& output, const float* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromFLOAT<float>(float& output, const float* input) {\n\n\toutput = input[0];\n\n}\n\n\n\n//FLOAT3\n\ntemplate<class T>\tinline void convertFromFLOAT3(T& output, const float* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromFLOAT3<vec3f>(vec3f& output, const float* input) {\n\n\toutput.x = input[0];\n\n\toutput.y = input[1];\n\n\toutput.z = input[2];\n\n}\n\ntemplate<>\tinline void convertFromFLOAT3<vec4f>(vec4f& output, const float* input) {\n\n\toutput.x = input[0];\n\n\toutput.y = input[1];\n\n\toutput.z = input[2];\n\n\toutput.w = 1;\n\n}\n\n\n\n//FLOAT4\n\ntemplate<class T>\tinline void convertFromFLOAT4(T& output, const float* input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertFromFLOAT4<vec4f>(vec4f& output, const float* input) {\n\n\toutput.x = input[0];\n\n\toutput.y = input[1];\n\n\toutput.z = input[2];\n\n\toutput.w = input[3];\n\n}\n\n\n\n///////////////////////\n\n// DATA WRITE HELPER //\n\n///////////////////////\n\n\n\n//VEC3UC\n\ntemplate<class T>\tinline void convertToVEC3UC(vec3uc& output, const T& input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec3d>(vec3uc& output, const vec3d& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0);\t\n\n\toutput.y = (unsigned char)(input[1]*255.0);\t\n\n\toutput.z = (unsigned char)(input[2]*255.0);\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec4d>(vec3uc& output, const vec4d& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0);\t\n\n\toutput.y = (unsigned char)(input[1]*255.0);\t\n\n\toutput.z = (unsigned char)(input[2]*255.0);\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec3f>(vec3uc& output, const vec3f& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0f);\n\n\toutput.y = (unsigned char)(input[1]*255.0f);\n\n\toutput.z = (unsigned char)(input[2]*255.0f);\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec4f>(vec3uc& output, const vec4f& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0f);\t\n\n\toutput.y = (unsigned char)(input[1]*255.0f);\t\n\n\toutput.z = (unsigned char)(input[2]*255.0f);\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec3i>(vec3uc& output, const vec3i& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec4i>(vec3uc& output, const vec4i& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec3ui>(vec3uc& output, const vec3ui& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec4ui>(vec3uc& output, const vec4ui& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec3uc>(vec3uc& output, const vec3uc& input) {\n\n\toutput.x = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.z = input[2];\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<vec4uc>(vec3uc& output, const vec4uc& input) {\n\n\toutput.x = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.z = input[2];\n\n}\n\ntemplate<>\tinline void convertToVEC3UC<float>(vec3uc& output, const float& input) {\n\n\tconvertToVEC3UC(output, vec3f(input));\n\n}\n\n\n\n\n\n\n\n\n\n//VEC4UC\n\ntemplate<class T>\tinline void convertToVEC4UC(vec4uc& output, const T& input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec3d>(vec4uc& output, const vec3d& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0);\t\n\n\toutput.y = (unsigned char)(input[1]*255.0);\t\n\n\toutput.z = (unsigned char)(input[2]*255.0);\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec4d>(vec4uc& output, const vec4d& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0);\t\n\n\toutput.y = (unsigned char)(input[1]*255.0);\t\n\n\toutput.z = (unsigned char)(input[2]*255.0);\n\n\toutput.w = (unsigned char)(input[3]*255.0);\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec3f>(vec4uc& output, const vec3f& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0f);\n\n\toutput.y = (unsigned char)(input[1]*255.0f);\n\n\toutput.z = (unsigned char)(input[2]*255.0f);\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec4f>(vec4uc& output, const vec4f& input) {\n\n\toutput.x = (unsigned char)(input[0]*255.0);\n\n\toutput.y = (unsigned char)(input[1]*255.0);\n\n\toutput.z = (unsigned char)(input[2]*255.0);\n\n\toutput.w = (unsigned char)(input[3]*255.0f);\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec3i>(vec4uc& output, const vec3i& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec4i>(vec4uc& output, const vec4i& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n\toutput.w = (unsigned char)input[3];\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec3ui>(vec4uc& output, const vec3ui& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec4ui>(vec4uc& output, const vec4ui& input) {\n\n\toutput.x = (unsigned char)input[0];\t\n\n\toutput.y = (unsigned char)input[1];\t\n\n\toutput.z = (unsigned char)input[2];\n\n\toutput.w = (unsigned char)input[3];\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec3uc>(vec4uc& output, const vec3uc& input) {\n\n\toutput.x = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.z = input[2];\n\n\toutput.w = 255;\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<vec4uc>(vec4uc& output, const vec4uc& input) {\n\n\toutput.x = input[0];\t\n\n\toutput.y = input[1];\t\n\n\toutput.z = input[2];\n\n\toutput.w = input[3];\n\n}\n\ntemplate<>\tinline void convertToVEC4UC<float>(vec4uc& output, const float& input) {\n\n\tconvertToVEC4UC(output, vec4f(input));\n\n}\n\n\n\n//UCHAR\n\ntemplate<class T>\tinline void convertToUCHAR(unsigned char& output, const T& input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertToUCHAR<unsigned char>(unsigned char& output, const unsigned char& input) {\n\n\toutput = input;\n\n}\n\n\n\n//USHORT\n\ntemplate<class T>\tinline void convertToUSHORT(unsigned short& output, const T& input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\n\n\ntemplate<>\tinline void convertToUSHORT<unsigned short>(unsigned short& output, const unsigned short& input) {\n\n\toutput = input;\n\n}\n\ntemplate<>\tinline void convertToUSHORT<float>(unsigned short& output, const float& input) {\n\n\toutput = (unsigned short)(input * 1000.0f);\n\n}\n\ntemplate<>\tinline void convertToUSHORT<double>(unsigned short& output, const double& input) {\n\n\toutput = (unsigned short)(input * 1000.0);\n\n}\n\n\n\n//USHORT3\n\ntemplate<class T>\tinline void convertToUSHORT3(vec3us& output, const T& input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\ntemplate<>\tinline void convertToUSHORT3<vec3us>(vec3us& output, const vec3us& input) {\n\n\toutput.x = input[0];\n\n\toutput.y = input[1];\n\n\toutput.z = input[2];\n\n}\n\n\n\n// FLOAT4\n\ntemplate<class T> inline void convertToFLOAT4(vec4f& output, const T& input) {\n\n\tthrow MLIB_EXCEPTION(\"Invalid Data Conversion\");\n\n\t//static_assert(false, \"Function should never be called\");\n\n}\n\n\n\ntemplate<> inline void convertToFLOAT4(vec4f& output, const vec4f& input) {\n\n\toutput.x = input[0];\n\n\toutput.y = input[1];\n\n\toutput.z = input[2];\n\n\toutput.w = input[3];\n\n}\n\n\n", "file_path": "include/ext-freeimage/freeImageWrapperHelper.h", "rank": 23, "score": 107053.34736134949 }, { "content": "struct hash<ml::vec3i> {\n\n\tsize_t operator()(const ml::vec3i& v) const {\n\n\t\t//TODO larger prime number (64 bit) to match size_t\n\n\t\tconst size_t p0 = 73856093;\n\n\t\tconst size_t p1 = 19349669;\n\n\t\tconst size_t p2 = 83492791;\n\n\t\tconst size_t res = ((size_t)v.x * p0)^((size_t)v.y * p1)^((size_t)v.z * p2);\n\n\t\treturn res;\n\n\t}\n\n};\n\n\n\n}\n\n\n\nnamespace ml {\n\n\n\ntemplate<class T> class SparseGrid3;\n\ntemplate<class T> std::ostream& operator<<(std::ostream& s, const SparseGrid3<T>& g);\n\n\n\ntemplate<class T>\n", "file_path": "include/core-util/sparseGrid3.h", "rank": 24, "score": 100469.61501833152 }, { "content": "class UIConnection\n\n{\n\n public:\n\n void init(const std::string &executableFile, const std::string &pipeBaseName);\n\n void readMessages();\n\n void sendMessage(const std::string &message);\n\n\n\n inline std::vector<std::string>& messages()\n\n {\n\n return m_messages;\n\n }\n\n private:\n\n std::vector<std::string> m_messages;\n\n Pipe m_writeToUIPipe;\n\n Pipe m_readFromUIPipe;\n\n};\n\n\n\n} // namespace ml\n\n\n\n#endif // _WIN32\n\n\n\n#endif // CORE_UTIL_UICONNECTION_H_\n", "file_path": "include/core-util/UIConnection.h", "rank": 25, "score": 90555.72170157364 }, { "content": "class BlockedPCA\n\n{\n\npublic:\n\n\tstruct Subset\n\n\t{\n\n\t\tSubset() {\n\n\t\t\tstartDim = std::numeric_limits<int>::min();\n\n\t\t\tdimCount = 0;\n\n\t\t}\n\n\t\tPCA<T> pca;\n\n\t\tint startDim;\n\n\t\tint dimCount;\n\n\t};\n\n\n\n\tBlockedPCA() {}\n\n\n\n\ttypedef std::function<EigenSystem<T>(const DenseMatrix<T> &m)> EigenSolverFunc;\n\n\n\n // points is a matrix with dimensions (# data points, # dimensions)\n\n void init(const DenseMatrix<T> &points, size_t subsetCount, const EigenSolverFunc &eigenSolver);\n", "file_path": "include/core-math/blockedPCA.h", "rank": 26, "score": 90536.60635000178 }, { "content": " void sendMessage(const std::vector<BYTE> &message);\n\n\tvoid sendMessage(const std::string &message);\n\n\n\n //\n\n // Query\n\n //\n\n UINT activeInstances();\n\n std::string userName();\n\n bool valid();\n\n \n\nprivate:\n\n\n\n#ifdef _WIN32\n\n void* m_handle;\n\n#endif\n\n};\n\n\n\n} // namespace ml\n\n\n\n#endif // CORE_UTIL_PIPE_H_\n", "file_path": "include/core-util/pipe.h", "rank": 27, "score": 87589.10392079601 }, { "content": "\n\n#ifndef CORE_UTIL_PIPE_H_\n\n#define CORE_UTIL_PIPE_H_\n\n\n\nnamespace ml\n\n{\n\n\n", "file_path": "include/core-util/pipe.h", "rank": 28, "score": 87579.8554646706 }, { "content": "#ifndef CORE_UTIL_UICONNECTION_H_\n\n#define CORE_UTIL_UICONNECTION_H_\n\n\n\n#ifdef _WIN32\n\n\n\n#include <string>\n\n\n\nnamespace ml {\n\n\n", "file_path": "include/core-util/UIConnection.h", "rank": 29, "score": 84118.54702494279 }, { "content": " \n\n void save(const std::string &baseFilename) const;\n\n void load(const std::string &baseFilename);\n\n\n\n\tvoid transform(const std::vector<T> &input, size_t reducedTotalDimension, std::vector<T> &result) const;\n\n void transform(const T *input, size_t reducedTotalDimension, T *result) const;\n\n\n\n\t//void inverseTransform(const std::vector<T> &input, std::vector<T> &result) const;\n\n //void inverseTransform(const T *input, size_t reducedSubsetDimension, T *result) const;\n\n\n\n\tsize_t subsetCount() const\n\n\t{\n\n\t\treturn _subsets.size();\n\n\t}\n\n\n\nprivate:\n\n\n\n\tstd::vector< Subset > _subsets;\n\n\tsize_t _totalDimensions;\n\n};\n\n\n\n#include \"blockedPCA.cpp\"\n\n\n\ntypedef BlockedPCA<float> BlockedPCAf;\n\ntypedef BlockedPCA<double> BlockedPCAd;\n\n\n\n}\n", "file_path": "include/core-math/blockedPCA.h", "rank": 30, "score": 84102.06181306837 }, { "content": "namespace ml {\n\n\n\ntemplate <class T>\n", "file_path": "include/core-math/blockedPCA.h", "rank": 31, "score": 84099.46702866376 }, { "content": "#include <string>\n\n\n\ntemplate<class T>\n\nvoid BlockedPCA<T>::init(const DenseMatrix<T> &points, size_t subsetCount, const EigenSolverFunc &eigenSolver)\n\n{\n\n\tconst size_t n = points.rows();\n\n\tconst size_t dimension = points.cols();\n\n std::cout << \"Initializing blocked PCA, \" << n << \" points, \" << dimension << \" total dims, \" << subsetCount << \" subsets\" << std::endl;\n\n\t\n\n\t_subsets.resize(subsetCount);\n\n\n\n\tint allocatedDims = 0;\n\n\tint subsetIndex = 0;\n\n\twhile (allocatedDims < dimension)\n\n\t{\n\n\t\t_subsets[subsetIndex].dimCount++;\n\n\t\tallocatedDims++;\n\n\t\tsubsetIndex = (subsetIndex + 1) % subsetCount;\n\n\t}\n\n\n", "file_path": "include/core-math/blockedPCA.cpp", "rank": 32, "score": 80876.45026738239 }, { "content": "\tfor (int subsetIndex = 0; subsetIndex < subsetCount; subsetIndex++)\n\n\t{\n\n\t\tconst Subset &s = _subsets[subsetIndex];\n\n\t\tconst int reducedDim = std::min((int)reducedSubsetDimension, s.dimCount);\n\n\t\ts.pca.transform(input + s.startDim, reducedDim, result + subsetIndex * reducedSubsetDimension);\n\n\t}\n\n}*/\n\n\n\ntemplate<class T>\n\nvoid BlockedPCA<T>::save(const std::string &baseFilename) const\n\n{\n\n BinaryDataStreamFile file(baseFilename + \".dat\", true);\n\n\tsize_t subsetCount = _subsets.size();\n\n file << subsetCount << _totalDimensions;\n\n\tfor (int i = 0; i < subsetCount; i++)\n\n\t{\n\n\t\tfile << _subsets[i].startDim << _subsets[i].dimCount;\n\n\t\t_subsets[i].pca.save(baseFilename + \"_\" + std::to_string(i) + \".dat\");\n\n\t}\n\n file.close();\n", "file_path": "include/core-math/blockedPCA.cpp", "rank": 33, "score": 80874.0124499291 }, { "content": "\tif (result.size() != reducedTotalDimension)\n\n\t\tresult.resize(reducedTotalDimension);\n\n\ttransform(input.data(), reducedTotalDimension, result.data());\n\n}\n\n\n\n/*template<class T>\n\nvoid BlockedPCA<T>::inverseTransform(const std::vector<T> &input, std::vector<T> &result) const\n\n{\n\n\tif (result.size() != _totalDimensions)\n\n\t\tresult.resize(_totalDimensions);\n\n\tinverseTransform(input.data(), input.size() / _subsets.size() + 1, result.data());\n\n}*/\n\n\n\ntemplate<class T>\n\nvoid BlockedPCA<T>::transform(const T *input, size_t reducedTotalDimension, T *result) const\n\n{\n\n\tconst size_t subsetCount = _subsets.size();\n\n\tconst int reducedSubsetDimension = reducedTotalDimension / subsetCount;\n\n\tfor (int i = 0; i < reducedTotalDimension; i++)\n\n\t\tresult[i] = 0;\n", "file_path": "include/core-math/blockedPCA.cpp", "rank": 34, "score": 80873.99318543648 }, { "content": "\n\n\n\n}\n\n\n\ntemplate<class T>\n\nvoid BlockedPCA<T>::load(const std::string &baseFilename)\n\n{\n\n BinaryDataStreamFile file(baseFilename + \".dat\", false);\n\n\tsize_t subsetCount;\n\n\tfile >> subsetCount >> _totalDimensions;\n\n\t_subsets.resize(subsetCount);\n\n\tfor (int i = 0; i < subsetCount; i++)\n\n\t{\n\n\t\tfile >> _subsets[i].startDim >> _subsets[i].dimCount;\n\n\t\t_subsets[i].pca.load(baseFilename + \"_\" + std::to_string(i) + \".dat\");\n\n\t}\n\n //file.closeStream();\n\n}\n", "file_path": "include/core-math/blockedPCA.cpp", "rank": 35, "score": 80872.87837289697 }, { "content": "\t_totalDimensions = 0;\n\n\tfor (int i = 0; i < subsetCount; i++)\n\n\t{\n\n\t\t_subsets[i].startDim = _totalDimensions;\n\n\t\t_totalDimensions += _subsets[i].dimCount;\n\n\t}\n\n\n\n\tfor (Subset &s : _subsets)\n\n\t{\n\n\t\tDenseMatrix<T> subpoints(n, s.dimCount);\n\n\t\tfor (int p = 0; p < n; p++)\n\n\t\t\tfor (int d = 0; d < s.dimCount; d++)\n\n\t\t\t\tsubpoints(p, d) = points(p, d + s.startDim);\n\n\t\ts.pca.init(subpoints, eigenSolver);\n\n\t}\n\n}\n\n\n\ntemplate<class T>\n\nvoid BlockedPCA<T>::transform(const std::vector<T> &input, size_t reducedTotalDimension, std::vector<T> &result) const\n\n{\n", "file_path": "include/core-math/blockedPCA.cpp", "rank": 36, "score": 80872.77354153874 }, { "content": "\n\n\tfor (int subsetIndex = 0; subsetIndex < subsetCount; subsetIndex++)\n\n\t{\n\n\t\tconst Subset &s = _subsets[subsetIndex];\n\n\t\t\n\n\t\tint reducedDim = std::min((int)reducedSubsetDimension, s.dimCount);\n\n\t\tif (subsetIndex * reducedSubsetDimension + reducedDim >= reducedTotalDimension)\n\n\t\t\treducedDim = reducedTotalDimension - subsetIndex * reducedSubsetDimension;\n\n\n\n\t\ts.pca.transform(input + s.startDim, reducedDim, result + subsetIndex * reducedSubsetDimension);\n\n\t}\n\n}\n\n\n\n/*template<class T>\n\nvoid BlockedPCA<T>::inverseTransform(const T *input, size_t reducedSubsetDimension, T *result) const\n\n{\n\n\tconst size_t subsetCount = _subsets.size();\n\n\tfor (int i = 0; i < reducedSubsetDimension * subsetCount; i++)\n\n\t\tresult[i] = 0;\n\n\n", "file_path": "include/core-math/blockedPCA.cpp", "rank": 37, "score": 80871.53013783309 }, { "content": "1. about\n\n--------\n\n\n\nPNG is a file format to store raster images losslessly with good compression,\n\nsupporting different color types and alpha channel.\n\n\n\nLodePNG is a PNG codec according to the Portable Network Graphics (PNG)\n\nSpecification (Second Edition) - W3C Recommendation 10 November 2003.\n\n\n\nThe specifications used are:\n\n\n\n*) Portable Network Graphics (PNG) Specification (Second Edition):\n\n http://www.w3.org/TR/2003/REC-PNG-20031110\n\n*) RFC 1950 ZLIB Compressed Data Format version 3.3:\n\n http://www.gzip.org/zlib/rfc-zlib.html\n\n*) RFC 1951 DEFLATE Compressed Data Format Specification ver 1.3:\n\n http://www.gzip.org/zlib/rfc-deflate.html\n\n\n\nThe most recent version of LodePNG can currently be found at\n\nhttp://lodev.org/lodepng/\n", "file_path": "include/ext-lodepng/lodepng.h", "rank": 38, "score": 74795.05860612052 }, { "content": "LodePNGColorMode info_raw\n\n-------------------------\n\n\n\nYou specify the color type of the raw image that you give to the input here,\n\nincluding a possible transparent color key and palette you happen to be using in\n\nyour raw image data.\n\n\n\nBy default, 32-bit color is assumed, meaning your input has to be in RGBA\n\nformat with 4 bytes (unsigned chars) per pixel.\n\n\n", "file_path": "include/ext-lodepng/lodepng.h", "rank": 39, "score": 72546.6177228952 }, { "content": "\t\tstruct constIterator\n\n\t\t{\n\n\t\t\tconstIterator(const Grid2<T> *_grid)\n\n\t\t\t{\n\n\t\t\t\tx = 0;\n\n\t\t\t\ty = 0;\n\n\t\t\t\tgrid = _grid;\n\n\t\t\t}\n\n\t\t\tconstIterator(const constIterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tgrid = i.grid;\n", "file_path": "include/core-base/grid2.h", "rank": 40, "score": 72530.7943996911 }, { "content": "\t\tstruct constIterator\n\n\t\t{\n\n\t\t\tconstIterator(const Grid3<T> *_grid)\n\n\t\t\t{\n\n\t\t\t\tx = 0;\n\n\t\t\t\ty = 0;\n\n\t\t\t\tz = 0;\n\n\t\t\t\tgrid = _grid;\n\n\t\t\t}\n\n\t\t\tconstIterator(const constIterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tz = i.z;\n\n\t\t\t\tgrid = i.grid;\n", "file_path": "include/core-base/grid3.h", "rank": 41, "score": 72530.7943996911 }, { "content": "class MemoryBlock\n\n{\n\npublic: // Offer external access to the current allocation and deallocation routines, so that when we change our minds about these later on, we won't need to update dependent code.\n\n static uint8_t* allocate (size_t size) { return (uint8_t*) std::malloc(size); }\n\n static uint8_t* reallocate (uint8_t* data, size_t size) { return (uint8_t*) std::realloc(data, size); }\n\n static void deallocate (uint8_t* data) { std::free(data); }\n\n\n\npublic:\n\n\n\n // Public direct access to the data\n\n uint8_t * Data;\n\n size_t Size;\n\n size_t AllocatedSize; // total allocated size for Data. May be bigger than Size.\n\n\n\nprivate:\n\n\n\n bool _freeWhenDone;\n\n \n\n typedef std::function<void(void)> ReleaseFunction;\n\n \n", "file_path": "include/ext-depthcamera/sensorData/uplinksimple_memory.h", "rank": 42, "score": 72528.84198273739 }, { "content": "using namespace ml;", "file_path": "test/frameworkD3D11/mLibInclude.h", "rank": 43, "score": 70130.36571445582 }, { "content": "using namespace std;\n", "file_path": "test/D3D11VS2015/mLibInclude.h", "rank": 44, "score": 70130.36571445582 }, { "content": "using namespace ml;", "file_path": "test/testWindows/src/mLibInclude.h", "rank": 45, "score": 70130.36571445582 }, { "content": "#ifndef CORE_BASE_GRID2D_H_\n\n#define CORE_BASE_GRID2D_H_\n\n\n\nnamespace ml\n\n{\n\n\ttemplate <class T> class Grid2\n\n\t{\n\n\tpublic:\n\n\t\tGrid2();\n\n\t\tGrid2(size_t dimX, size_t dimY);\n\n\t\tGrid2(size_t dimX, size_t dimY, const T &value);\n\n\t\tGrid2(const vec2ul& dim) : Grid2(dim.x, dim.y) {}\n\n\t\tGrid2(const vec2ul& dim, const T& value) : Grid2(dim.x, dim.y, value) {}\n\n\n\n\t\tGrid2(const Grid2<T> &grid);\n\n\t\tGrid2(Grid2<T> &&grid);\n\n\t\tGrid2(size_t dimX, size_t dimY, const std::function< T(size_t x, size_t y) > &fillFunction);\n\n\n\n\t\t~Grid2();\n\n\n\n\t\t//! adl swap\n\n\t\tfriend void swap(Grid2& a, Grid2& b) {\n\n\t\t\tstd::swap(a.m_dimX, b.m_dimX);\n\n\t\t\tstd::swap(a.m_dimY, b.m_dimY);\n\n\t\t\tstd::swap(a.m_data, b.m_data);\n\n\t\t}\n\n\n\n\t\tGrid2<T>& operator=(const Grid2<T> &grid);\n\n\t\tGrid2<T>& operator=(Grid2<T> &&grid);\n\n\n\n\t\tvoid allocate(size_t dimX, size_t dimY);\n\n\t\tvoid allocate(size_t dimX, size_t dimY, const T& value);\n\n\t\tvoid allocate(const vec2ul& dim) { allocate(dim.x, dim.y); }\n\n\t\tvoid allocate(const vec2ul& dim, const T& value) { allocate(dim.x, dim.y, value); }\n\n\n\n\t\t//\n\n\t\t// Accessors\n\n\t\t//\n\n\t\tinline T& operator() (size_t x, size_t y)\t{\n\n\t\t\tMLIB_ASSERT(x < m_dimX && y < m_dimY);\n\n\t\t\treturn m_data[getDimX()*y + x];\n\n\t\t}\n\n\t\tinline const T& operator() (size_t x, size_t y) const\t{\n\n\t\t\tMLIB_ASSERT(x < m_dimX && y < m_dimY);\n\n\t\t\treturn m_data[getDimX()*y + x];\n\n\t\t}\n\n\n\n\t\tinline T& operator() (const vec2ul& coord)\t{\n\n\t\t\treturn (*this)(coord.x, coord.y);\n\n\t\t}\n\n\n\n\t\tinline const T& operator() (const vec2ul& coord) const\t{\n\n\t\t\treturn (*this)(coord.x, coord.y);\n\n\t\t}\n\n\n\n\t\tinline size_t getDimX() const\t{\n\n\t\t\treturn m_dimX;\n\n\t\t}\n\n\n\n\t\tinline size_t getDimY() const\t{\n\n\t\t\treturn m_dimY;\n\n\t\t}\n\n\n\n\t\tinline vec2ul getDimensions() const {\n\n\t\t\treturn vec2ul(m_dimX, m_dimY);\n\n\t\t}\n\n\n\n\t\tinline size_t getNumElements() const\t{\n\n\t\t\treturn m_dimX * m_dimY;\n\n\t\t}\n\n\n\n\t\tinline bool isSquare() const\t{\n\n\t\t\treturn (m_dimX == m_dimY);\n\n\t\t}\n\n\n\n\t\tinline T* getData()\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\n\n\t\tinline const T* getData() const\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\n\n\n\n\t\tinline Grid2<T>& operator += (const Grid2<T>& right) {\n\n\t\t\tMLIB_ASSERT(getDimensions() == right.getDimensions());\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] += right.m_data[i];\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\tinline Grid2<T>& operator += (T value) {\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++)\n\n\t\t\t\tm_data[i] += value;\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\tinline Grid2<T>& operator *= (T value)\n\n\t\t{\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] *= value;\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\tinline Grid2<T> operator * (T value)\n\n\t\t{\n\n\t\t\tGrid2<T> result(m_dimX, m_dimY);\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tresult.m_data[i] = m_data[i] * value;\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\n\n\t\t//\n\n\t\t// Modifiers\n\n\t\t//\n\n\t\tvoid setValues(const T &value);\n\n\n\n\t\tvoid fill(const std::function< T(size_t x, size_t y) > &fillFunction);\n\n\n\n\t\tstd::vector<T> toStdVector() const\n\n\t\t{\n\n\t\t\tstd::vector<T> result;\n\n\t\t\tfor (size_t i = 0; i < m_dimX * m_dimY; i++)\n\n\t\t\t\tresult.push_back(i);\n\n\t\t\treturn result;\n\n\t\t}\n\n\n\n\t\t//\n\n\t\t// Query\n\n\t\t//\n\n\t\tinline bool isValidCoordinate(size_t x, size_t y) const\n\n\t\t{\n\n\t\t\treturn (x < m_dimX && y < m_dimY);\n\n\t\t}\n\n inline bool isValidCoordinate(vec2ul& coord) const\n\n {\n\n\t\t\treturn (coord.x < m_dimX && coord.y < m_dimY);\n\n }\n\n\n\n\t\tvec2ul getMaxIndex() const;\n\n\t\tconst T& getMaxValue() const;\n\n\t\tvec2ul getMinIndex() const;\n\n\t\tconst T& getMinValue() const;\n\n\n\n\t\tstd::string toString(bool verbose = true) const {\n\n\t\t\tstd::stringstream ss;\n\n\t\t\tss << \"grid dim: \" << getDimensions() << \"\\n\";\n\n\t\t\tif (verbose) {\n\n\t\t\t\tfor (size_t y = 0; y < m_dimY; y++) {\n\n\t\t\t\t\tss << \"\\t\";\n\n\t\t\t\t\tfor (size_t x = 0; x < m_dimX; x++) {\n\n\t\t\t\t\t\tss << (*this)(x, y) << \" \";\n\n\t\t\t\t\t}\n\n\t\t\t\t\tss << \"\\n\";\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn ss.str();\n\n\t\t}\n\n\n\n\t\t//\n\n\t\t// TODO: rename\n\n\t\t//\n\n\t\tvoid setRow(size_t row, const std::vector<T>& values)\n\n\t\t{\n\n\t\t\tfor (size_t col = 0; col < m_dimY; col++) m_data[row * m_dimX + col] = values[col];\n\n\t\t}\n\n\n\n\t\tvoid setCol(size_t col, const std::vector<T>& values)\n\n\t\t{\n\n\t\t\tfor (size_t row = 0; row < m_dimX; row++) m_data[row * m_dimX + col] = values[row];\n\n\t\t}\n\n\n\n\t\tstd::vector<T> getRow(size_t y) const\n\n\t\t{\n\n\t\t\tstd::vector<T> result(m_dimX);\n\n\t\t\tconst T *CPtr = m_data;\n\n\t\t\tfor (size_t x = 0; x < m_dimX; x++)\n\n\t\t\t{\n\n\t\t\t\tresult[x] = CPtr[y * m_dimX + x];\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\n\n\t\tstd::vector<T> getCol(size_t x) const\n\n\t\t{\n\n\t\t\tstd::vector<T> result(m_dimY);\n\n\t\t\tconst T *CPtr = m_data;\n\n\t\t\tfor (size_t y = 0; y < m_dimY; y++)\n\n\t\t\t{\n\n\t\t\t\tresult[y] = CPtr[y * m_dimX + x];\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\n\n\n\n\t\t//\n\n\t\t// Grid2 iterators\n\n\t\t//\n\n\t\tstruct iteratorEntry\n\n\t\t{\n\n\t\t\titeratorEntry(size_t _x, size_t _y, T &_value)\n\n\t\t\t\t: x(_x), y(_y), value(_value)\n\n\t\t\t{\n\n\n\n\t\t\t}\n\n\t\t\tsize_t x;\n\n\t\t\tsize_t y;\n\n\t\t\tT &value;\n\n\t\t};\n\n\n\n\t\tstruct constIteratorEntry\n\n\t\t{\n\n\t\t\tconstIteratorEntry(size_t _x, size_t _y, const T &_value)\n\n\t\t\t\t: x(_x), y(_y), value(_value)\n\n\t\t\t{\n\n\n\n\t\t\t}\n\n\t\t\tsize_t x;\n\n\t\t\tsize_t y;\n\n\t\t\tconst T &value;\n\n\t\t};\n\n\n\n\n\n\t\tstruct iterator\n\n\t\t{\n\n\t\t\titerator(Grid2<T> *_grid)\n\n\t\t\t{\n\n\t\t\t\tx = 0;\n\n\t\t\t\ty = 0;\n\n\t\t\t\tgrid = _grid;\n\n\t\t\t}\n\n\t\t\titerator(const iterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t}\n\n\t\t\t~iterator() {}\n\n\t\t\titerator& operator=(const iterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\titerator& operator++()\n\n\t\t\t{\n\n\t\t\t\tx++;\n\n\t\t\t\tif (x == grid->getDimX())\n\n\t\t\t\t{\n\n\t\t\t\t\tx = 0;\n\n\t\t\t\t\ty++;\n\n\t\t\t\t\tif (y == grid->getDimY())\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tgrid = nullptr;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\titeratorEntry operator* () const\n\n\t\t\t{\n\n\t\t\t\treturn iteratorEntry(x, y, (*grid)(x, y));\n\n\t\t\t}\n\n\n\n\t\t\tbool operator != (const iterator &i) const\n\n\t\t\t{\n\n\t\t\t\treturn i.grid != grid;\n\n\t\t\t}\n\n\n\n\t\t\ttemplate<class U>\n\n\t\t\tfriend void swap(iterator &a, iterator &b);\n\n\n\n\t\t\tsize_t x, y;\n\n\n\n\t\tprivate:\n\n\t\t\tGrid2<T> *grid;\n\n\t\t};\n\n\n\n\t\tstruct constIterator\n\n\t\t{\n\n\t\t\tconstIterator(const Grid2<T> *_grid)\n\n\t\t\t{\n\n\t\t\t\tx = 0;\n\n\t\t\t\ty = 0;\n\n\t\t\t\tgrid = _grid;\n\n\t\t\t}\n\n\t\t\tconstIterator(const constIterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t}\n\n\t\t\t~constIterator() {}\n\n\t\t\tconstIterator& operator=(const constIterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\tconstIterator& operator++()\n\n\t\t\t{\n\n\t\t\t\tx++;\n\n\t\t\t\tif (x == grid->getDimX())\n\n\t\t\t\t{\n\n\t\t\t\t\tx = 0;\n\n\t\t\t\t\ty++;\n\n\t\t\t\t\tif (y == grid->getDimY())\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tgrid = nullptr;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\tconstIteratorEntry operator* () const\n\n\t\t\t{\n\n\t\t\t\treturn constIteratorEntry(x, y, (*grid)(x, y));\n\n\t\t\t}\n\n\n\n\t\t\tbool operator != (const constIterator &i) const\n\n\t\t\t{\n\n\t\t\t\treturn i.grid != grid;\n\n\t\t\t}\n\n\n\n\t\t\ttemplate<class U>\n\n\t\t\tfriend void swap(const constIterator &a, const constIterator &b);\n\n\n\n\t\t\tsize_t x, y;\n\n\n\n\t\tprivate:\n\n\t\t\tconst Grid2<T> *grid;\n\n\t\t};\n\n\n\n\n\n\t\titerator begin()\n\n\t\t{\n\n\t\t\treturn iterator(this);\n\n\t\t}\n\n\n\n\t\titerator end()\n\n\t\t{\n\n\t\t\treturn iterator(NULL);\n\n\t\t}\n\n\n\n\t\tconstIterator begin() const\n\n\t\t{\n\n\t\t\treturn constIterator(this);\n\n\t\t}\n\n\n\n\t\tconstIterator end() const\n\n\t\t{\n\n\t\t\treturn constIterator(NULL);\n\n\t\t}\n\n\n\n\tprotected:\n\n\t\tT* m_data;\n\n\t\tsize_t m_dimX, m_dimY;\n\n\t};\n\n\n\n\ttemplate <class T> inline bool operator == (const Grid2<T> &a, const Grid2<T> &b)\n\n\t{\n\n\t\tif (a.getDimensions() != b.getDimensions()) return false;\n\n\t\tconst size_t totalEntries = a.getNumElements();\n\n\t\tfor (size_t i = 0; i < totalEntries; i++) {\n\n\t\t\tif (a.getData()[i] != b.getData()[i])\treturn false;\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n\n\n\ttemplate <class T> inline bool operator != (const Grid2<T> &a, const Grid2<T> &b)\n\n\t{\n\n\t\treturn !(a == b);\n\n\t}\n\n\n\n\t//! writes to a stream\n\n\ttemplate <class T>\n\n\tinline std::ostream& operator<<(std::ostream& s, const Grid2<T>& g)\n\n\t{\n\n\t\ts << g.toString();\n\n\t\treturn s;\n\n\t}\n\n\n\n\t//! serialization (output)\n\n\ttemplate<class BinaryDataBuffer, class BinaryDataCompressor, class T>\n\n\tinline BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& operator<<(BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& s, const Grid2<T>& g) {\n\n\t\t\n\n\t\ts << (UINT64)g.getDimX() << (UINT64)g.getDimY();\n\n\t\t\n\n\t\tif (std::is_pod<T>::value) {\n\n\t\t\ts.writeData((const BYTE*)g.getData(), sizeof(T)*g.getNumElements());\n\n\t\t}\n\n\t\telse {\n\n\t\t\tconst size_t numElements = g.getNumElements();\n\n\t\t\ts.reserve(sizeof(T) * numElements);\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\ts << g.getData()[i];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn s;\n\n\t}\n\n\n\n\t//! serialization (input)\n\n\ttemplate<class BinaryDataBuffer, class BinaryDataCompressor, class T>\n\n\tinline BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& operator>>(BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& s, Grid2<T>& g) {\n\n\t\t\n\n\t\tUINT64 dimX, dimY;\n\n\t\ts >> dimX >> dimY;\n\n\t\tg.allocate(dimX, dimY);\n\n\n\n\t\tif (std::is_pod<T>::value) {\n\n\t\t\ts.readData((BYTE*)g.getData(), sizeof(T)*g.getNumElements());\n\n\t\t}\n\n\t\telse {\n\n\t\t\tconst size_t numElements = g.getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\ts >> g.getData()[i];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn s;\n\n\t}\n\n\n\n\ttypedef Grid2<float> Grid2f;\n\n typedef Grid2<int> Grid2i;\n\n\ttypedef Grid2<double> Grid2d;\n\n typedef Grid2<unsigned char> Grid2uc;\n\n\n\n}\n\n\n\n#include \"grid2.cpp\"\n\n\n", "file_path": "include/core-base/grid2.h", "rank": 46, "score": 70120.89655092818 }, { "content": "#ifndef CORE_BASE_GRID3D_H_\n\n#define CORE_BASE_GRID3D_H_\n\n\n\nnamespace ml\n\n{\n\n\n\n\ttemplate <class T> class Grid3\n\n\t{\n\n\tpublic:\n\n\t\tGrid3();\n\n\t\tGrid3(size_t dimX, size_t dimY, size_t dimZ);\n\n\t\tGrid3(size_t dimX, size_t dimY, size_t dimZ, const T &value);\n\n\t\tGrid3(const vec3ul& dim) : Grid3(dim.x, dim.y, dim.z) {}\n\n\t\tGrid3(const vec3ul& dim, const T& value) : Grid3(dim.x, dim.y, dim.z, value) {}\n\n\n\n\t\tGrid3(const Grid3<T> &grid);\n\n\t\tGrid3(Grid3<T> &&grid);\n\n\t\tGrid3(size_t dimX, size_t dimY, size_t dimZ, const std::function< T(size_t x, size_t y, size_t z) > &fillFunction);\n\n\n\n\t\t~Grid3();\n\n\n\n\t\t//! adl swap\n\n\t\tfriend void swap(Grid3& a, Grid3& b) {\n\n\t\t\tstd::swap(a.m_dimX, b.m_dimX);\n\n\t\t\tstd::swap(a.m_dimY, b.m_dimY);\n\n\t\t\tstd::swap(a.m_dimZ, b.m_dimZ);\n\n\t\t\tstd::swap(a.m_data, b.m_data);\n\n\t\t}\n\n\n\n\t\tGrid3<T>& operator=(const Grid3<T>& grid);\n\n\t\tGrid3<T>& operator=(Grid3<T>&& grid);\n\n\n\n\t\tvoid allocate(size_t dimX, size_t dimY, size_t dimZ);\n\n\t\tvoid allocate(size_t dimX, size_t dimY, size_t dimZ, const T &value);\n\n\t\tvoid allocate(const vec3ul& dim) {\t\t\t\t\t\tallocate(dim.x, dim.y, dim.z);\t\t\t\t}\n\n\t\tvoid allocate(const vec3ul& dim, const T& value) {\t\tallocate(dim.x, dim.y, dim.z, value);\t\t}\n\n\n\n\t\t//\n\n\t\t// Accessors\n\n\t\t//\n\n\t\tinline T& operator() (size_t x, size_t y, size_t z)\t{\n\n\t\t\tMLIB_ASSERT(x < getDimX() && y < getDimY() && z < getDimZ());\n\n\t\t\treturn m_data[getDimX()*getDimY()*z + getDimX()*y + x];\n\n\t\t}\n\n\n\n\t\tinline const T& operator() (size_t x, size_t y, size_t z) const\t{\n\n\t\t\tMLIB_ASSERT(x < getDimX() && y < getDimY() && z < getDimZ());\n\n\t\t\treturn m_data[getDimX()*getDimY()*z + getDimX()*y + x];\n\n\t\t}\n\n\n\n\t\tinline T& operator() (const vec3ul& coord)\t{\n\n\t\t\treturn (*this)(coord.x, coord.y, coord.z);\n\n\t\t}\n\n\n\n\t\tinline const T& operator() (const vec3ul& coord) const\t{\n\n\t\t\treturn (*this)(coord.x, coord.y, coord.z);\n\n\t\t}\n\n\n\n\t\tinline size_t getDimX() const\t{\n\n\t\t\treturn m_dimX;\n\n\t\t}\n\n\t\tinline size_t getDimY() const\t{\n\n\t\t\treturn m_dimY;\n\n\t\t}\n\n\t\tinline size_t getDimZ() const\t{\n\n\t\t\treturn m_dimZ;\n\n\t\t}\n\n\n\n\t\tinline vec3ul getDimensions() const {\n\n\t\t\treturn vec3ul(getDimX(), getDimY(), getDimZ());\n\n\t\t}\n\n\n\n\t\tsize_t getNumElements() const {\n\n\t\t\treturn m_dimX * m_dimY * m_dimZ;\n\n\t\t}\n\n\n\n\t\tinline bool isSquare() const\t{\n\n\t\t\treturn (m_dimX == m_dimY && m_dimY == m_dimZ);\n\n\t\t}\n\n\t\tinline T* getData()\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\t\tinline const T* getData() const\t{\n\n\t\t\treturn m_data;\n\n\t\t}\n\n\n\n\t\tinline Grid3<T>& operator += (const Grid3<T>& right)\n\n\t\t{\n\n\t\t\tMLIB_ASSERT(getDimensions() == right.getDimensions());\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] += right.m_data[i];\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\t\tinline Grid3<T>& operator += (T value)\n\n\t\t{\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] += value;\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\t\tinline Grid3<T>& operator *= (T value)\n\n\t\t{\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tm_data[i] *= value;\n\n\t\t\t}\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\tinline Grid3<T> operator * (T value)\n\n\t\t{\n\n\t\t\tGrid3<T> result(m_dimX, m_dimY, m_dimZ);\n\n\t\t\tconst size_t numElements = getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\tresult.m_data[i] = m_data[i] * value;\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\n\n\t\t//\n\n\t\t// Modifiers\n\n\t\t//\n\n\t\tvoid setValues(const T &value);\n\n\n\n\t\tvoid fill(const std::function<T(size_t x, size_t y, size_t z)> &fillFunction);\n\n\n\n\t\t//\n\n\t\t// Query\n\n\t\t//\n\n\t\tinline bool isValidCoordinate(size_t x, size_t y, size_t z) const\n\n\t\t{\n\n\t\t\treturn (x < m_dimX && y < m_dimY && z < m_dimZ);\n\n\t\t}\n\n inline bool isValidCoordinate(const vec3ul& coord) const\n\n {\n\n return (coord.x < m_dimX && coord.y < m_dimY && coord.z < m_dimZ);\n\n }\n\n\n\n\t\tvec3ul getMaxIndex() const;\n\n\t\tconst T& getMaxValue() const;\n\n\t\tvec3ul getMinIndex() const;\n\n\t\tconst T& getMinValue() const;\n\n\n\n\t\tstd::string toString(bool verbose = true) const {\n\n\t\t\tstd::stringstream ss;\n\n\t\t\tss << \"grid dim: \" << getDimensions() << \"\\n\";\n\n\t\t\tif (verbose) {\n\n\t\t\t\tfor (size_t z = 0; z < m_dimZ; z++) {\n\n\t\t\t\t\tss << \"slice \" << z << std::endl;\n\n\t\t\t\t\tfor (size_t y = 0; y < m_dimY; y++) {\n\n\t\t\t\t\t\tss << \"\\t\";\n\n\t\t\t\t\t\tfor (size_t x = 0; x < m_dimX; x++) {\n\n\t\t\t\t\t\t\tss << (*this)(x, y, z) << \" \";\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tss << \"\\n\";\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn ss.str();\n\n\t\t}\n\n\n\n\t\t//\n\n\t\t// Grid3 iterators\n\n\t\t//\n\n\t\tstruct iteratorEntry\n\n\t\t{\n\n\t\t\titeratorEntry(size_t _x, size_t _y, size_t _z, T &_value)\n\n\t\t\t\t: x(_x), y(_y), z(_z), value(_value)\n\n\t\t\t{\n\n\n\n\t\t\t}\n\n\t\t\tsize_t x;\n\n\t\t\tsize_t y;\n\n\t\t\tsize_t z;\n\n\t\t\tT &value;\n\n\t\t};\n\n\n\n\t\tstruct constIteratorEntry\n\n\t\t{\n\n\t\t\tconstIteratorEntry(size_t _x, size_t _y, size_t _z, const T &_value)\n\n\t\t\t\t: x(_x), y(_y), z(_z), value(_value)\n\n\t\t\t{\n\n\n\n\t\t\t}\n\n\t\t\tsize_t x;\n\n\t\t\tsize_t y;\n\n\t\t\tsize_t z;\n\n\t\t\tconst T &value;\n\n\t\t};\n\n\n\n\n\n\t\tstruct iterator\n\n\t\t{\n\n\t\t\titerator(Grid3<T> *_grid)\n\n\t\t\t{\n\n\t\t\t\tx = 0;\n\n\t\t\t\ty = 0;\n\n\t\t\t\tz = 0;\n\n\t\t\t\tgrid = _grid;\n\n\t\t\t}\n\n\t\t\titerator(const iterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tz = i.z;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t}\n\n\t\t\t~iterator() {}\n\n\t\t\titerator& operator=(const iterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tz = i.z;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\titerator& operator++()\n\n\t\t\t{\n\n\t\t\t\tx++;\n\n\t\t\t\tif (x == grid->getDimX())\n\n\t\t\t\t{\n\n\t\t\t\t\tx = 0;\n\n\t\t\t\t\ty++;\n\n\t\t\t\t\tif (y == grid->getDimY())\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\ty = 0;\n\n\t\t\t\t\t\tz++;\n\n\t\t\t\t\t\tif (z == grid->getDimZ())\n\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tgrid = NULL;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\titeratorEntry operator* () const\n\n\t\t\t{\n\n\t\t\t\treturn iteratorEntry(x, y, z, (*grid)(x, y, z));\n\n\t\t\t}\n\n\n\n\t\t\tbool operator != (const iterator &i) const\n\n\t\t\t{\n\n\t\t\t\treturn i.grid != grid;\n\n\t\t\t}\n\n\n\n\t\t\ttemplate<class U>\n\n\t\t\tfriend void swap(iterator &a, iterator &b);\n\n\n\n\t\t\tsize_t x, y, z;\n\n\n\n\t\tprivate:\n\n\t\t\tGrid3<T> *grid;\n\n\t\t};\n\n\n\n\t\tstruct constIterator\n\n\t\t{\n\n\t\t\tconstIterator(const Grid3<T> *_grid)\n\n\t\t\t{\n\n\t\t\t\tx = 0;\n\n\t\t\t\ty = 0;\n\n\t\t\t\tz = 0;\n\n\t\t\t\tgrid = _grid;\n\n\t\t\t}\n\n\t\t\tconstIterator(const constIterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tz = i.z;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t}\n\n\t\t\t~constIterator() {}\n\n\t\t\tconstIterator& operator=(const constIterator &i)\n\n\t\t\t{\n\n\t\t\t\tx = i.x;\n\n\t\t\t\ty = i.y;\n\n\t\t\t\tz = i.z;\n\n\t\t\t\tgrid = i.grid;\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\tconstIterator& operator++()\n\n\t\t\t{\n\n\t\t\t\tx++;\n\n\t\t\t\tif (x == grid->getDimX())\n\n\t\t\t\t{\n\n\t\t\t\t\tx = 0;\n\n\t\t\t\t\ty++;\n\n\t\t\t\t\tif (y == grid->getDimY())\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\ty = 0;\n\n\t\t\t\t\t\tz++;\n\n\t\t\t\t\t\tif (z == grid->getDimZ())\n\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tgrid = NULL;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn *this;\n\n\t\t\t}\n\n\t\t\tconstIteratorEntry operator* () const\n\n\t\t\t{\n\n\t\t\t\treturn constIteratorEntry(x, y, z, (*grid)(x, y, z));\n\n\t\t\t}\n\n\n\n\t\t\tbool operator != (const constIterator &i) const\n\n\t\t\t{\n\n\t\t\t\treturn i.grid != grid;\n\n\t\t\t}\n\n\n\n\t\t\ttemplate<class U>\n\n\t\t\tfriend void swap(const constIterator &a, const constIterator &b);\n\n\n\n\t\t\tsize_t x, y, z;\n\n\n\n\t\tprivate:\n\n\t\t\tconst Grid3<T> *grid;\n\n\t\t};\n\n\n\n\n\n iterator begin()\n\n {\n\n return iterator(this);\n\n }\n\n\n\n iterator end()\n\n {\n\n return iterator(NULL);\n\n }\n\n\n\n constIterator begin() const\n\n {\n\n return constIterator(this);\n\n }\n\n\n\n constIterator end() const\n\n {\n\n return constIterator(NULL);\n\n }\n\n\n\n\tprotected:\n\n\t\tT* m_data;\n\n\t\tsize_t m_dimX, m_dimY, m_dimZ;\n\n\t};\n\n\n\n\ttemplate <class T> inline bool operator == (const Grid3<T> &a, const Grid3<T> &b)\n\n\t{\n\n\t\tif (a.getDimensions() != b.getDimensions()) return false;\n\n\t\tconst size_t totalEntries = a.getNumElements();\n\n\t\tfor (size_t i = 0; i < totalEntries; i++) {\n\n\t\t\tif (a.getData()[i] != b.getData()[i])\treturn false;\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n\n\n\ttemplate <class T> inline bool operator != (const Grid3<T> &a, const Grid3<T> &b)\n\n\t{\n\n\t\treturn !(a == b);\n\n\t}\n\n\n\n\t//! writes to a stream\n\n\ttemplate <class T>\n\n\tinline std::ostream& operator<<(std::ostream& s, const Grid3<T>& g)\n\n\t{\n\n\t\ts << g.toString();\n\n\t\treturn s;\n\n\t}\n\n\n\n\t//! serialization (output)\n\n\ttemplate<class BinaryDataBuffer, class BinaryDataCompressor, class T>\n\n\tinline BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& operator<<(BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& s, const Grid3<T>& g) {\n\n\t\t\n\n\t\ts << (UINT64)g.getDimX() << (UINT64)g.getDimY() << (UINT64)g.getDimZ();\t\t\n\n\n\n\t\tif (std::is_pod<T>::value) {\n\n\t\t\ts.writeData((const BYTE*)g.getData(), sizeof(T)*g.getNumElements());\n\n\t\t}\n\n\t\telse {\n\n\t\t\tconst size_t numElements = g.getNumElements();\n\n\t\t\ts.reserve(sizeof(T) * numElements);\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\ts << g.getData()[i];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn s;\n\n\t}\n\n\n\n\t//! serialization (input)\n\n\ttemplate<class BinaryDataBuffer, class BinaryDataCompressor, class T>\n\n\tinline BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& operator>>(BinaryDataStream<BinaryDataBuffer, BinaryDataCompressor>& s, Grid3<T>& g) {\n\n\t\t\n\n\t\tUINT64 dimX, dimY, dimZ;\n\n\t\ts >> dimX >> dimY >> dimZ;\n\n\t\tg.allocate(dimX, dimY, dimZ);\n\n\n\n\t\tif (std::is_pod<T>::value) {\n\n\t\t\ts.readData((BYTE*)g.getData(), sizeof(T)*g.getNumElements());\n\n\t\t}\n\n\t\telse { \n\n\t\t\tconst size_t numElements = g.getNumElements();\n\n\t\t\tfor (size_t i = 0; i < numElements; i++) {\n\n\t\t\t\ts >> g.getData()[i];\n\n\t\t\t}\n\n\t\t}\n\n\n\n\t\treturn s;\n\n\t}\n\n\n\n\ttypedef Grid3<float> Grid3f;\n\n\ttypedef Grid3<double> Grid3d;\n\n\ttypedef Grid3<int> Grid3i;\n\n\ttypedef Grid3<unsigned int> Grid3ui;\n\n\ttypedef Grid3<unsigned char> Grid3uc;\n\n\n\n} // namespace ml\n\n\n\n#include \"grid3.cpp\"\n\n\n", "file_path": "include/core-base/grid3.h", "rank": 47, "score": 70120.89655092818 }, { "content": "using namespace ml;", "file_path": "test/testD3D11/src/mLibInclude.h", "rank": 48, "score": 67875.15546222184 }, { "content": "class MemoryBlock;\n\n\n\nbool\n\nencode_image (\n\n graphics_ImageCodec imageCodec,\n\n const uint8_t* inputBuffer,\n\n size_t inputSize,\n\n graphics_PixelFormat inputFormat,\n\n size_t inputWidth,\n\n size_t inputHeight,\n\n MemoryBlock& outputMemoryBlock,\n\n float outputQuality\n\n);\n\n\n\nbool\n\ndecode_image (\n\n graphics_ImageCodec imageCodec,\n\n const uint8_t* inputBuffer,\n\n size_t inputSize,\n\n graphics_PixelFormat outputFormat,\n", "file_path": "include/ext-depthcamera/sensorData/uplinksimple_windows-image-codecs.h", "rank": 49, "score": 67864.1639547313 }, { "content": "function creates a new chunk with the given parameters and appends it. Type is the 4-letter\n\nname of the chunk.\n\n\n", "file_path": "include/ext-lodepng/lodepng.h", "rank": 50, "score": 65767.92552837472 }, { "content": "# define BITSTREAM_SUCCESS 1\n", "file_path": "include/ext-depthcamera/sensorData/uplinksimple_image-codecs.h", "rank": 51, "score": 63780.80149829384 }, { "content": "0. table of contents\n\n--------------------\n\n\n\n 1. about\n\n 1.1. supported features\n\n 1.2. features not supported\n\n 2. C and C++ version\n\n 3. security\n\n 4. decoding\n\n 5. encoding\n\n 6. color conversions\n\n 6.1. PNG color types\n\n 6.2. color conversions\n\n 6.3. padding bits\n\n 6.4. A note about 16-bits per channel and endianness\n\n 7. error values\n\n 8. chunks and PNG editing\n\n 9. compiler support\n\n 10. examples\n\n 10.1. decoder C++ example\n\n 10.2. decoder C example\n\n 11. changes\n\n 12. contact information\n\n\n\n\n", "file_path": "include/ext-lodepng/lodepng.h", "rank": 52, "score": 63640.42024303229 }, { "content": "class Vizzer : public ml::ApplicationCallback\n\n{\n\npublic:\n\n\tvoid init(ml::ApplicationData &app);\n\n\tvoid render(ml::ApplicationData &app);\n\n\tvoid keyDown(ml::ApplicationData &app, UINT key);\n\n\tvoid keyPressed(ml::ApplicationData &app, UINT key);\n\n\tvoid mouseDown(ml::ApplicationData &app, ml::MouseButtonType button);\n\n\tvoid mouseMove(ml::ApplicationData &app);\n\n\tvoid mouseWheel(ml::ApplicationData &app, int wheelDelta);\n\n\tvoid resize(ml::ApplicationData &app);\n\n\n\nprivate:\n\n\tml::D3D11TriMesh m_mesh, m_pointCloud;\n\n\t\n\n ml::D3D11VertexShader m_vsColor;\n\n\tml::D3D11PixelShader m_psColor;\n\n ml::D3D11VertexShader m_vsPointCloud;\n\n ml::D3D11PixelShader m_psPointCloud;\n\n\n\n ml::D3D11Font m_font;\n\n ml::FrameTimer m_timer;\n\n\n\n\tml::D3D11ConstantBuffer<ConstantBuffer> m_constants;\n\n\tml::Cameraf m_camera;\n\n};", "file_path": "test/frameworkD3D11/vizzer.h", "rank": 53, "score": 61063.45101192354 }, { "content": "class AppTest : public ml::ApplicationCallback\n\n{\n\npublic:\n\n\tvoid init(ml::ApplicationData &app);\n\n\tvoid render(ml::ApplicationData &app);\n\n\tvoid keyDown(ml::ApplicationData &app, UINT key);\n\n\tvoid keyPressed(ml::ApplicationData &app, UINT key);\n\n\tvoid mouseDown(ml::ApplicationData &app, ml::MouseButtonType button);\n\n\tvoid mouseMove(ml::ApplicationData &app);\n\n\tvoid mouseWheel(ml::ApplicationData &app, int wheelDelta);\n\n\tvoid resize(ml::ApplicationData &app);\n\n\n\nprivate:\n\n\tml::D3D11TriMesh m_mesh, m_pointCloud;\n\n\t\n\n\tml::D3D11ShaderManager m_shaderManager;\n\n\n\n ml::D3D11Font m_font;\n\n ml::FrameTimer m_timer;\n\n\n\n\tml::D3D11ConstantBuffer<ConstantBuffer> m_constants;\n\n\tml::D3D11Canvas2D m_canvas;\n\n\tml::Cameraf m_camera;\n\n\n\n\tml::D3D11Buffer<vec4f> m_buffer;\n\n};", "file_path": "test/testD3D11/src/appTest.h", "rank": 54, "score": 57587.51320219766 }, { "content": "\t\tclass const_noconst_iterator : public std::iterator<std::random_access_iterator_tag, Face> {\n\n\t\tpublic:\n\n\t\t\ttypedef typename std::conditional<is_const_iterator, const Indices*, Indices*>::type IndicesPtr;\n\n\t\t\ttypedef typename std::conditional<is_const_iterator, const Indices&, Indices&>::type IndicesRef;\n\n\t\t\t//typedef typename std::conditional<is_const_iterator, const Face*, Face*>::type FacePtr;\n\n\t\t\t//typedef typename std::conditional<is_const_iterator, const Face&, Face&>::type FaceRef;\n\n\n\n\t\t\tconst_noconst_iterator(IndicesPtr i, size_t c = 0) {\n\n\t\t\t\tcurr = c;\n\n\t\t\t\tindices = i;\n\n\t\t\t}\n\n\t\t\tconst_noconst_iterator(const_noconst_iterator<false>& other) {\n\n\t\t\t\tcurr = other.getCurr();\n\n\t\t\t\tindices = other.getIndices();\n\n\t\t\t}\n\n\t\t\tconst_noconst_iterator(const_noconst_iterator<false>&& other) {\n\n\t\t\t\tcurr = other.getCurr();\n\n\t\t\t\tindices = other.getIndices();\n\n\t\t\t}\n\n\t\t\tconst_noconst_iterator& operator++() {\n", "file_path": "include/core-mesh/meshData.h", "rank": 55, "score": 56889.48341372573 }, { "content": "\t\t\tclass const_noconst_iterator : public std::iterator<std::random_access_iterator_tag, unsigned int> {\n\n\t\t\tpublic:\n\n\t\t\t\t//typedef typename std::conditional<is_const_iterator, const Indices*, Indices*>::type IndicesPtr;\n\n\t\t\t\t//typedef typename std::conditional<is_const_iterator, const Indices&, Indices&>::type IndicesRef;\n\n\t\t\t\ttypedef typename std::conditional<is_const_iterator, const Face*, Face*>::type FacePtr;\n\n\t\t\t\ttypedef typename std::conditional<is_const_iterator, const Face&, Face&>::type FaceRef;\n\n\t\t\t\ttypedef typename std::conditional<is_const_iterator, const unsigned int*, unsigned int*>::type uintPtr;\n\n\t\t\t\ttypedef typename std::conditional<is_const_iterator, const unsigned int&, unsigned int&>::type uintRef;\n\n\n\n\t\t\t\tconst_noconst_iterator(FacePtr f, unsigned int c = 0) {\n\n\t\t\t\t\tface = f;\n\n\t\t\t\t\tcurr = c;\n\n\t\t\t\t}\n\n\t\t\t\tconst_noconst_iterator(const_noconst_iterator<false>& other) {\n\n\t\t\t\t\tface = other.getFace();\n\n\t\t\t\t\tcurr = other.getCurr();\n\n\t\t\t\t}\n\n\t\t\t\tconst_noconst_iterator(const_noconst_iterator<false>&& other) {\n\n\t\t\t\t\tface = other.getFace();\n\n\t\t\t\t\tcurr = other.getCurr();\n", "file_path": "include/core-mesh/meshData.h", "rank": 56, "score": 55396.20514602116 }, { "content": "\tm_writeToUIPipe.connectToLocalPipe(pipeBaseName + \"WriteToUI\");\n\n\tstd::cout << \"UI pipes created\" << std::endl;\n\n}\n\n\n\nvoid UIConnection::readMessages()\n\n{\n\n\twhile(m_readFromUIPipe.messagePresent())\n\n\t{\n\n\t\tstd::vector<BYTE> message;\n\n\t\tm_readFromUIPipe.readMessage(message);\n\n\t\tmessage.push_back(0);\n\n\t\tstd::string s = std::string((const char *)&message[0]);\n\n\t\tif(s.size() > 0)\n\n\t\t{\n\n\t\t\tm_messages.push_back(s);\n\n\t\t}\n\n\t}\n\n}\n\n\n\nvoid UIConnection::sendMessage(const std::string &message)\n\n{\n\n\tm_writeToUIPipe.sendMessage(message);\n\n}\n\n\n\n} // namespace ml\n\n\n\n#endif // _WIN32\n", "file_path": "src/core-util/UIConnection.cpp", "rank": 71, "score": 44293.11499438051 }, { "content": "\n\n#ifdef _WIN32\n\n\n\nnamespace ml {\n\n\n\nvoid UIConnection::init(const std::string &executableFile, const std::string &pipeBaseName)\n\n{\n\n if (!util::fileExists(executableFile))\n\n {\n\n std::cout << \"File not found: \" << executableFile << std::endl;\n\n std::cout << \"Working directory: \" << util::getWorkingDirectory() << std::endl;\n\n std::cin.get();\n\n return;\n\n }\n\n if (executableFile.size() > 0 && util::runCommand(executableFile, \"\", false) != 0)\n\n\t{\n\n\t\tstd::cout << \"Failed to launch UI\" << std::endl;\n\n\t\treturn;\n\n\t}\n\n\tm_readFromUIPipe.createPipe(pipeBaseName + \"ReadFromUI\", false);\n", "file_path": "src/core-util/UIConnection.cpp", "rank": 72, "score": 44292.01047746015 }, { "content": " for (auto &v : points)\n", "file_path": "include/core-util/uniformAccelerator.h", "rank": 73, "score": 43642.1978238596 }, { "content": "\n\n#include \"mLibZLib.h\"\n\n\n\nnamespace ml\n\n{\n\n\n\nnamespace mBase\n\n{\n\n\n", "file_path": "include/ext-mbase/mBase.h", "rank": 74, "score": 39667.907900534075 }, { "content": "{\n\n std::ifstream file(filename, std::ios::binary | std::ios::in);\n\n boost::archive::binary_iarchive archive(file);\n\n archive >> object;\n\n file.close();\n\n}\n\n\n\n} // namespace ml\n\n\n\nnamespace boost {\n\nnamespace serialization {\n\n\n\n\n\n /*template<class Archive, class T>\n\n void save(Archive & ar, const ml::vec2<T>& p, const unsigned int version)\n\n {\n\n ar & p.array;\n\n }\n\n template<class Archive, class T>\n\n void load(Archive & ar, ml::vec2<T>& p, const unsigned int version)\n", "file_path": "include/ext-boost/serialization.h", "rank": 75, "score": 39666.31335317743 }, { "content": "\n\n#ifndef CORE_MATH_POINT6D_H_\n\n#define CORE_MATH_POINT6D_H_\n\n\n\n#include \"vec4.h\"\n\n\n\n#include <iostream>\n\n#include <cmath>\n\n#include <cstdlib>\n\n#include <cassert>\n\n\n\nnamespace ml {\n\n\n\n//! 6D vector.\n\ntemplate <class T>\n", "file_path": "include/core-math/vec6.h", "rank": 76, "score": 39666.299908420966 }, { "content": "\n\n#ifndef CORE_MATH_POINT4D_H_\n\n#define CORE_MATH_POINT4D_H_\n\n\n\n#include \"vec3.h\"\n\n\n\n#include <iostream>\n\n#include <cmath>\n\n#include <cstdlib>\n\n#include <cassert>\n\n\n\nnamespace ml {\n\n\n\n//! 4D vector.\n\ntemplate <class T>\n", "file_path": "include/core-math/vec4.h", "rank": 77, "score": 39666.299908420966 }, { "content": "\n\n#ifndef CORE_MATH_POINT2D_H_\n\n#define CORE_MATH_POINT2D_H_\n\n\n\n#include \"vec1.h\"\n\n\n\n#include <iostream>\n\n#include <cmath>\n\n#include <iostream>\n\n#include <cassert>\n\n\n\nnamespace ml {\n\n\n\n//! 2D vector\n\ntemplate <class T>\n", "file_path": "include/core-math/vec2.h", "rank": 78, "score": 39666.299908420966 }, { "content": "\n\n#ifndef CORE_MATH_POINT3D_H_\n\n#define CORE_MATH_POINT3D_H_\n\n\n\n\n\n#include <iostream>\n\n#include <cmath>\n\n\n\n#include \"vec2.h\"\n\n\n\nnamespace ml {\n\n\n\n//! 3D vector.\n\ntemplate <class T>\n", "file_path": "include/core-math/vec3.h", "rank": 79, "score": 39666.24425571382 }, { "content": " //\n\n b = ml::OBB3f(v[0], v[1], v[2], v[3]);\n\n}\n\n\n\ntemplate<class Archive>\n\ninline void serialize(Archive& ar, ml::TriMesh<float>::Vertex& v, const unsigned int version) {\n\n ar & v.position & v.normal & v.color & v.texCoord;\n\n}\n\n\n\ntemplate<class Archive, class T>\n\ninline void serialize(Archive& ar, ml::Material<T>& m, const unsigned int version) {\n\n ar & m.m_name & m.m_ambient & m.m_diffuse & m.m_specular & m.m_shiny & m.m_TextureFilename_Ka & m.m_TextureFilename_Kd & m.m_TextureFilename_Ks;\n\n}\n\n\n\n} // namespace serialization\n\n} // namespace boost\n\n\n\n// TODO: Move this to an appropriate test file\n\nstatic void testBoostSerialization() {\n\n\tnamespace io = boost::iostreams;\n", "file_path": "include/ext-boost/serialization.h", "rank": 80, "score": 39665.82565453641 }, { "content": "\n\n#ifndef CORE_MATH_POINT1D_H_\n\n#define CORE_MATH_POINT1D_H_\n\n\n\n#include <iostream>\n\n#include <cmath>\n\n#include <iostream>\n\n#include <cassert>\n\n\n\nnamespace ml {\n\n\n\n//! 1D vector (I know it's a joke, but we need it for compatibility reasons)\n\ntemplate <class T>\n", "file_path": "include/core-math/vec1.h", "rank": 81, "score": 39665.74965676637 }, { "content": "#include <boost/asio/streambuf.hpp>\n\n#include <boost/iostreams/filtering_streambuf.hpp>\n\n#include <boost/iostreams/filtering_stream.hpp>\n\n#include <boost/iostreams/filter/zlib.hpp>\n\n#include <boost/iostreams/filter/gzip.hpp>\n\n#include <boost/iostreams/traits.hpp>\n\n\n\n\n\nnamespace ml {\n\n\n", "file_path": "include/ext-boost/serialization.h", "rank": 82, "score": 39665.46824229566 }, { "content": "\n\n} // namespace ml\n\n\n\n\n\n#ifndef UINT\n\ntypedef unsigned int UINT;\n\n#endif\n\n\n\n#ifndef UCHAR\n\ntypedef unsigned char UCHAR;\n\n#endif\n\n\n\n#ifndef INT64\n\n#ifdef WIN32\n\ntypedef __int64 INT64;\n\n#else\n\ntypedef int64_t INT64;\n\n#endif\n\n#endif\n\n\n", "file_path": "include/core-base/common.h", "rank": 83, "score": 39665.42170848908 }, { "content": "\tvoid createFromPoints( const vec3<FloatType>* points ) \n\n\t{\n\n\t\tm_Normal = ((points[1] - points[0])^(points[2] - points[0])).getNormalized();\n\n\t\tm_Distance = (m_Normal | points[0]);\n\n\t\t//make sure normal points away from origin (i.e., distance is positive)\n\n\t\tif (m_Distance < (FloatType)0) {\n\n\t\t\tm_Distance = -m_Distance;\n\n\t\t\tm_Normal = -m_Normal;\n\n\t\t}\t\n\n\t}\n\n\n\n\tvec3<FloatType> m_Normal;\n\n\tFloatType m_Distance;\n\n};\n\n\n\ntypedef Plane<float> Planef;\n\ntypedef Plane<double> Planed;\n\n\n\n} //namespace ml\n\n\n\n\n\n#endif\n", "file_path": "include/core-graphics/plane.h", "rank": 84, "score": 39664.87796805659 }, { "content": "\t}\n\n\n\n\t//! equal operator\n\n\tinline bool operator==(const Matrix3x3<FloatType>& other) const {\n\n\t\tfor (unsigned i = 0; i < 9; i++) {\n\n\t\t\tif (matrix[i] != other[i]) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n\n\n\t//! not equal operator\n\n\tinline bool operator!=(const Matrix3x3<FloatType>& other) const {\n\n\t\treturn !(*this == other);\n\n\t}\n\n\n\n\n\n\t//! overwrite the matrix with an identity-matrix\n\n\tvoid setIdentity() {\n\n\t\tsetScale(1.0, 1.0, 1.0);\n\n\t}\n", "file_path": "include/core-math/matrix3x3.h", "rank": 85, "score": 39664.694194789605 }, { "content": "#include <cmath>\n\n#include <climits>\n\n#include <vector>\n\n\n\n\n\nnamespace ml {\n\n\n\n\tusing std::vector;\n\n\n\n\tstatic const double PI = 3.1415926535897932;\n\n\tstatic const double AD_l = 0.6931471805599453;\n\n\tstatic const double AD_a = 5.7133631526454228;\n\n\tstatic const double AD_b = 3.4142135623730950;\n\n\tstatic const double AD_c = -1.6734053240284925;\n\n\tstatic const double AD_p = 0.9802581434685472;\n\n\tstatic const double AD_A = 5.6005707569738080;\n\n\tstatic const double AD_B = 3.3468106480569850;\n\n\tstatic const double AD_H = 0.0026106723602095;\n\n\tstatic const double AD_D = 0.0857864376269050;\n\n\n", "file_path": "include/core-math/rng.h", "rank": 86, "score": 39663.91175750314 }, { "content": "//\n\n#include \"../src/core-multithreading/threadPool.cpp\"\n\n#include \"../src/core-multithreading/workerThread.cpp\"\n\n\n\n//\n\n// core-graphics source files\n\n//\n\n#include \"../src/core-graphics/RGBColor.cpp\"\n\n\n\n//\n\n// core-mesh source files\n\n//\n\n#include \"../src/core-mesh/meshUtil.cpp\"\n\n\n\n#ifdef LINUX\n\nnamespace ml\n\n{\n\n template<> const vec3f vec3f::origin(0.0f, 0.0f, 0.0f);\n\n template<> const vec3f vec3f::eX(1.0f, 0.0f, 0.0f);\n\n template<> const vec3f vec3f::eY(0.0f, 1.0f, 0.0f);\n", "file_path": "include/mLibCore.cpp", "rank": 87, "score": 39663.681422823625 }, { "content": " For greyscale PNGs, r, g and b will all 3 be set to the same.\n\n\n\n When decoding, by default you can ignore this information, since LodePNG sets\n\n pixels with this key to transparent already in the raw RGBA output.\n\n\n\n The color key is only supported for color types 0 and 2.\n\n */\n\n unsigned key_defined; /*is a transparent color key given? 0 = false, 1 = true*/\n\n unsigned key_r; /*red/greyscale component of color key*/\n\n unsigned key_g; /*green component of color key*/\n\n unsigned key_b; /*blue component of color key*/\n\n} LodePNGColorMode;\n\n\n\n/*init, cleanup and copy functions to use with this struct*/\n\nvoid lodepng_color_mode_init(LodePNGColorMode* info);\n\nvoid lodepng_color_mode_cleanup(LodePNGColorMode* info);\n\n/*return value is error code (0 means no error)*/\n\nunsigned lodepng_color_mode_copy(LodePNGColorMode* dest, const LodePNGColorMode* source);\n\n\n\nvoid lodepng_palette_clear(LodePNGColorMode* info);\n", "file_path": "include/ext-lodepng/lodepng.h", "rank": 88, "score": 39663.6541305654 }, { "content": "\n\n//\n\n// core-math source files\n\n//\n\n#include \"../src/core-math/rng.cpp\"\n\n#include \"../src/core-math/triangleIntersection.cpp\"\n\n\n\n//\n\n// core-util source files\n\n//\n\n#include \"../src/core-util/utility.cpp\"\n\n#include \"../src/core-util/windowsUtil.cpp\"\n\n#include \"../src/core-util/directory.cpp\"\n\n#include \"../src/core-util/timer.cpp\"\n\n#include \"../src/core-util/pipe.cpp\"\n\n#include \"../src/core-util/UIConnection.cpp\"\n\n#include \"../src/core-util/eventMap.cpp\"\n\n\n\n//\n\n// core-multithreading source files\n", "file_path": "include/mLibCore.cpp", "rank": 89, "score": 39663.62825750759 }, { "content": "\t\tfor (unsigned i = 0; i < 4; i++) {\n\n\t\t\tif (matrix[i] != other[i]) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n\n\n\t//! not equal operator\n\n\tinline bool operator!=(const Matrix2x2<FloatType>& other) const {\n\n\t\treturn !(*this == other);\n\n\t}\n\n\n\n\t//! overwrite the matrix with an identity-matrix\n\n\tvoid setIdentity() {\n\n\t\tsetScale(1.0, 1.0);\n\n\t}\n\n\tstatic Matrix2x2 identity() {\n\n\t\tMatrix2x2 res;\tres.setIdentity();\n\n\t\treturn res;\n\n\t}\n\n\n", "file_path": "include/core-math/matrix2x2.h", "rank": 90, "score": 39663.35783815503 }, { "content": "#include <functional>\n\n#include <algorithm>\n\n#include <fstream>\n\n#include <memory>\n\n#include <thread>\n\n#include <mutex>\n\n#include <map>\n\n#include <unordered_set>\n\n#include <unordered_map>\n\n#include <numeric>\n\n#include <type_traits>\n\n#include <array>\n\n#include <set>\n\n#include <utility>\n\n#include <limits>\n\n#include <tuple>\n\n#include <complex>\n\n#include <queue> \n\n#include <random>\n\n#include <iomanip>\n\n#include <boost/serialization/array_wrapper.hpp>\n\n\n\n\n\nnamespace boost {\n\nnamespace serialization {\n\n\n", "file_path": "include/core-base/common.h", "rank": 91, "score": 39663.12586983609 }, { "content": "#endif\n\n\n\n#ifndef MLIB_QUIET\n\n#define MLIB_WARNING(s) ml::warningFunctionMLIB(std::string(FUNCTION_LINE_STRING) + std::string() + \": \" + std::string(s))\n\nvoid warningFunctionMLIB(const std::string &description);\n\n#else\n\n#define MLIB_WARNING(s)\n\n#endif\n\n\n\n#define MLIB_ERROR(s) ml::errorFunctionMLIB(std::string(FUNCTION_LINE_STRING) + \": \" + std::string(s))\n\nvoid errorFunctionMLIB(const std::string &description);\n\n\n\n#if defined(DEBUG) || defined(_DEBUG)\n\n#define MLIB_ASSERT_STR(b,s) { if(!(b)) ml::assertFunctionMLIB(b, std::string(FUNCTION_LINE_STRING) + \": \" + std::string(s)); }\n\n#define MLIB_ASSERT(b) { if(!(b)) ml::assertFunctionMLIB(b, FUNCTION_LINE_STRING); }\n\nvoid assertFunctionMLIB(bool statement, const std::string &description);\n\n#else\n\n#define MLIB_ASSERT_STR(b,s)\n\n#define MLIB_ASSERT(b)\n\n#endif\n", "file_path": "include/core-base/common.h", "rank": 92, "score": 39662.99561783957 }, { "content": "\t\tstatic Matrix4x4<FloatType> viewMatrix(const vec3<FloatType>& eye, const vec3<FloatType>& lookDir, const vec3<FloatType>& up, const vec3<FloatType>& right);\n\n\n\n\tprivate:\n\n\t\tvoid update();\n\n\n\n\t\tvec3<FloatType> m_eye, m_right, m_look, m_up;\n\n\t\tvec3<FloatType> m_worldUp;\n\n\t\tMatrix4x4<FloatType> m_view;\n\n\t\tMatrix4x4<FloatType> m_projection;\n\n\t\tMatrix4x4<FloatType> m_viewProjection;\n\n\n\n\t\tFloatType m_fieldOfView, m_aspect, m_zNear, m_zFar;\n\n\t};\n\n\n\n\ttypedef Camera<float> Cameraf;\n\n\ttypedef Camera<double> Camerad;\n\n\n\n} // namespace ml\n\n\n\n#include \"camera.cpp\"\n\n\n\n#endif // CORE_GRAPHICS_CAMERA_H_\n", "file_path": "include/core-graphics/camera.h", "rank": 93, "score": 39662.654205831706 }, { "content": "namespace ml {\n\n\n\ntemplate <class T>\n", "file_path": "include/core-math/PCA.h", "rank": 94, "score": 39662.30722021725 }, { "content": " inline void serialize(Archive& ar, ml::vec4<T>& p, const unsigned int version) {\n\n boost::serialization::split_free(ar, p, version);\n\n }*/\n\n/*#else // MLIB_USE_ARRAY_SERIALIZATION\n\n\n\ntemplate<class Archive, class T>\n\ninline void serialize(Archive& ar, ml::vec2<T>& p, const unsigned int version) {\n\n ar & p.x & p.y;\n\n}\n\n\n\ntemplate<class Archive, class T>\n\ninline void serialize(Archive& ar, ml::vec3<T>& p, const unsigned int version) {\n\n ar & p.x & p.y & p.z;\n\n}\n\n\n\ntemplate<class Archive, class T>\n\ninline void serialize(Archive& ar, ml::vec4<T>& p, const unsigned int version) {\n\n ar & p.x & p.y & p.z & p.w;\n\n}\n\n\n", "file_path": "include/ext-boost/serialization.h", "rank": 95, "score": 39662.04231093855 }, { "content": "\tstd::string loadStringFromClipboard()\n\n\t{\n\n\t\treturn \"\";\n\n\t}\n\n\n\n\tsize_t getFileSize(const std::string &filename)\n\n\t{\n\n\t\tstruct stat statbuf;\n\n\t\tint success = stat(filename.c_str(), &statbuf);\n\n\t\tMLIB_ASSERT_STR(success == 0, std::string(\"stat failed on \") + filename);\n\n\t\treturn statbuf.st_size;\n\n\t}\n\n\n\n\t// Create a process with the given command line, and wait until it returns\n\n\tint runCommand(const std::string &executablePath, const std::string &commandLine, bool block)\n\n\t{\n\n\t\treturn 0;\n\n\t}\n\n\n\n\tvoid makeDirectory(const std::string &directory)\n\n\t{\n\n\t\tmkdir(directory.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);\n\n\t}\n\n#endif\n\n} // namespace util\n\n\n\n} // namespace ml", "file_path": "src/core-util/utility.cpp", "rank": 96, "score": 28.102065230987947 }, { "content": "\n\n# include \"./memory.h\"\n\n\n\nnamespace uplinksimple {\n\n\n\n//------------------------------------------------------------------------------\n\n\n\ninline\n\nMemoryBlock::MemoryBlock() :\n\n_freeWhenDone(false), Size(0), AllocatedSize(0), Data(nullptr), _releaseFunction(nullptr)\n\n{\n\n}\n\n\n\ninline\n\nMemoryBlock::~MemoryBlock()\n\n{\n\n this->freeMemory();\n\n}\n\n\n\ninline void\n", "file_path": "include/ext-depthcamera/sensorData/uplinksimple_memory.h", "rank": 97, "score": 27.76990334882083 }, { "content": "private:\n\n\tstatic void workerThreadEntry( WorkerThread *context );\n\n\tvoid enterThreadTaskLoop();\n\n\n\n bool m_done;\n\n std::thread *m_thread;\n\n\n\n\tUINT m_threadIndex;\n\n ThreadLocalStorage *m_storage;\n\n\n\n TaskList<WorkerThreadTask*> *m_tasks;\n\n};\n\n\n\n} // namespace ml\n\n\n\n#endif // CORE_MULTITHREADING_WORKERTHREAD_H_\n", "file_path": "include/core-multithreading/workerThread.h", "rank": 98, "score": 23.61490072323182 }, { "content": "\n\n this->Data = data;\n\n this->Size = size;\n\n this->AllocatedSize = size; // FIXME: this may not be true, it may be bigger, we could take an additional parameter.\n\n this->_freeWhenDone = freeWhenDone;\n\n _releaseFunction = releaseFunction;\n\n }\n\n\n\n // Resize the memory block as efficiently as possible.\n\n void Resize(size_t size, bool preserveData = false, bool reallocIfShrinking = false);\n\n\n\n#if __OBJC__\n\n // For now, we don't allow Objective C blocks, since in that case we would need to call Block_copy.\n\n // Use a C++11 lambda instead. Thus the following overloads are disabled for safety.\n\n // FIXME: we could actually implement these if we wanted to.\n\n MemoryBlock(uint8_t* data, size_t size, bool freeWhenDone, void(^releaseFunction)(void)) = delete;\n\n void ReplaceWith(uint8_t* data, size_t size, bool freeWhenDone, void(^releaseFunction)(void)) = delete;\n\n#endif\n\n\n\npublic: // Convenience methods.\n", "file_path": "include/ext-depthcamera/sensorData/uplinksimple_memory.h", "rank": 99, "score": 22.695220074242677 } ]
C++
libcat/src/cat_storage_resmgr.cpp
shadow-paw/cat
975749c9d716687f1bd74c80d474fed6065768de
#include "cat_storage_resmgr.h" #include <new> #include <string.h> #include <png.h> using namespace cat; ResourceManager::ResourceManager(VFS* vfs) { m_contextready = false; m_vfs = vfs; } ResourceManager::~ResourceManager() { fini(); } bool ResourceManager::init() { return true; } void ResourceManager::fini() { context_lost(); m_shaders.clear(); m_texs.clear(); } void ResourceManager::context_lost() { if (!m_contextready) return; m_contextready = false; for (auto& it : m_shaders) { it.second.first.shader->fini(); } for (auto& it : m_texs) { it.second.first->release(); } } bool ResourceManager::context_restored() { if (m_contextready) return true; m_contextready = true; for (auto it: m_shaders) { reload_shader(&it.second.first, it.first); } for (auto it : m_texs) { reload_tex(it.second.first, it.first); } return true; } const Shader* ResourceManager::retain_shader(const std::string& name, const std::unordered_map<int, std::string>& uniforms, const std::unordered_map<int, std::string>& attrs) { Buffer buffer; auto cached = m_shaders.find(name); if (cached!=m_shaders.end()) { auto& pair = cached->second; pair.second ++; return pair.first.shader; } Shader* shader = new (std::nothrow) Shader(); if (!shader) return nullptr; if (m_contextready) { if (!m_vfs->read(name, &buffer)) return nullptr; if (!shader->init((const char*)buffer.ptr(), (const char*)buffer.ptr())) { delete shader; return nullptr; } shader->bind(); for (auto it : uniforms) { shader->bind_uniform(it.first, it.second.c_str()); } for (auto it : attrs) { shader->bind_attr(it.first, it.second.c_str()); } shader->unbind(); } m_shaders.emplace(name, std::make_pair(SHADER_DATA{ shader, uniforms, attrs }, 1)); return shader; } bool ResourceManager::reload_shader(SHADER_DATA* sd, const std::string& name) { std::string path(name); Buffer buffer; if (!m_vfs->read(path, &buffer)) return false; if (!sd->shader->init((const char*)buffer.ptr(), (const char*)buffer.ptr())) return false; sd->shader->bind(); for (auto it : sd->uniforms) { sd->shader->bind_uniform(it.first, it.second.c_str()); } for (auto it : sd->attrs) { sd->shader->bind_attr(it.first, it.second.c_str()); } sd->shader->unbind(); return true; } bool ResourceManager::release_shader(const std::string& name) { auto cached = m_shaders.find(name); if (cached == m_shaders.end()) return false; auto& pair = cached->second; pair.second --; if (pair.second == 0) { delete pair.first.shader; m_shaders.erase(name); } return true; } bool ResourceManager::release_shader(const Shader* shader) { if (shader == nullptr ) return false; for (auto it=m_shaders.begin(); it!=m_shaders.end(); ++it) { auto& pair = it->second; if (pair.first.shader != shader) continue; pair.second --; if (pair.second == 0) { delete pair.first.shader; m_shaders.erase(it); } return true; } return false; } const Texture* ResourceManager::retain_tex(const std::string& name) { Buffer buffer; auto cached = m_texs.find(name); if (cached!=m_texs.end()) { auto& pair = cached->second; pair.second ++; return pair.first; } Texture* tex = new (std::nothrow) Texture(); if (!tex) return nullptr; if (m_contextready) { if (!m_vfs->read(name, &buffer)) return nullptr; if (!load_tex_png(tex, buffer)) { delete tex; return nullptr; } } m_texs.emplace(name, std::make_pair(tex, 1)); return tex; } bool ResourceManager::reload_tex(Texture* tex, const std::string& name) { Buffer buffer; if (!m_vfs->read(name.c_str(), &buffer)) return false; return load_tex_png(tex, buffer); } bool ResourceManager::release_tex(const std::string& name) { auto cached = m_texs.find(name); if (cached == m_texs.end()) return false; auto& pair = cached->second; pair.second --; if (pair.second == 0) { delete pair.first; m_texs.erase(name); } return true; } bool ResourceManager::release_tex(const Texture* tex) { if (tex == nullptr ) return false; for (auto it=m_texs.begin(); it!=m_texs.end(); ++it) { auto& pair = it->second; if (pair.first != tex) continue; pair.second --; if (pair.second == 0) { delete pair.first; m_texs.erase(it); } return true; } return false; } const Buffer* ResourceManager::retain_raw(const std::string& name) { auto cached = m_raws.find(name); if (cached != m_raws.end()) { auto& pair = cached->second; pair.second++; return pair.first; } Buffer* buffer = new Buffer(); if (!m_vfs->read(name, buffer)) { delete buffer; return nullptr; } m_raws.emplace(name, std::make_pair(buffer, 1)); return buffer; } bool ResourceManager::release_raw(const std::string& name) { auto cached = m_raws.find(name); if (cached == m_raws.end()) return false; auto& pair = cached->second; pair.second--; if (pair.second == 0) { delete pair.first; m_raws.erase(name); } return true; } bool ResourceManager::release_raw(const Buffer* buffer) { if (buffer == nullptr) return false; for (auto it = m_raws.begin(); it != m_raws.end(); ++it) { auto& pair = it->second; if (pair.first != buffer) continue; pair.second--; if (pair.second == 0) { delete pair.first; m_raws.erase(it); } return true; } return false; } typedef struct { Buffer* buffer; size_t offset; } PNGBufferReader; void _png_read(png_structp png, png_bytep data, png_size_t size) { PNGBufferReader* br = (PNGBufferReader*) png_get_io_ptr(png); if ( br->offset + size <= br->buffer->size() ) { memcpy ( data, br->buffer->ptr() + br->offset, size ); br->offset += size; } } bool ResourceManager::load_tex_png(Texture* tex, Buffer& buf) { Texture::Format format; unsigned int width, height; uint8_t* pixel = nullptr; png_structp png = NULL; png_infop info = NULL; png_bytepp row_pointers; size_t row_bytes; PNGBufferReader bufreader; if (png_sig_cmp(buf.ptr(), 0, 8)) goto fail; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png == NULL) goto fail; info = png_create_info_struct(png); if (info == NULL) goto fail; if (setjmp(png_jmpbuf(png))) goto fail; bufreader.buffer = &buf; bufreader.offset = 8; png_set_read_fn(png, &bufreader, _png_read); png_set_sig_bytes(png, 8); png_read_png(png, info, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND, NULL); switch ( png_get_color_type(png, info) ) { case PNG_COLOR_TYPE_RGBA: format = Texture::Format::RGBA; break; case PNG_COLOR_TYPE_RGB: format = Texture::Format::RGB; break; default: goto fail; } row_bytes = png_get_rowbytes(png, info); width = (unsigned int)png_get_image_width(png, info); height = (unsigned int)png_get_image_height(png, info); if (width > 4096 || height > 4096) goto fail; pixel = new (std::nothrow) uint8_t[row_bytes * height]; if (!pixel) goto fail; row_pointers = png_get_rows(png, info); for (unsigned int i = 0; i < height; i++) { memcpy( pixel + (row_bytes * (height-1-i)), row_pointers[i], row_bytes ); } png_destroy_read_struct(&png, &info, NULL); tex->update(format, (int)width, (int)height, pixel); delete pixel; return true; fail: png_destroy_read_struct(&png, &info, NULL); delete pixel; return false; }
#include "cat_storage_resmgr.h" #include <new> #include <string.h> #include <png.h> using namespace cat; ResourceManager::ResourceManager(VFS* vfs) { m_contextready = false; m_vfs = vfs; } ResourceManager::~ResourceManager() { fini(); } bool ResourceManager::init() { return true; } void ResourceManager::fini() { context_lost(); m_shaders.clear(); m_texs.clear(); } void ResourceManager::context_lost() { if (!m_contextready) return; m_contextready = false; for (auto& it : m_shaders) { it.second.first.shader->fini(); } for (auto& it : m_texs) { it.second.first->release(); } }
const Shader* ResourceManager::retain_shader(const std::string& name, const std::unordered_map<int, std::string>& uniforms, const std::unordered_map<int, std::string>& attrs) { Buffer buffer; auto cached = m_shaders.find(name); if (cached!=m_shaders.end()) { auto& pair = cached->second; pair.second ++; return pair.first.shader; } Shader* shader = new (std::nothrow) Shader(); if (!shader) return nullptr; if (m_contextready) { if (!m_vfs->read(name, &buffer)) return nullptr; if (!shader->init((const char*)buffer.ptr(), (const char*)buffer.ptr())) { delete shader; return nullptr; } shader->bind(); for (auto it : uniforms) { shader->bind_uniform(it.first, it.second.c_str()); } for (auto it : attrs) { shader->bind_attr(it.first, it.second.c_str()); } shader->unbind(); } m_shaders.emplace(name, std::make_pair(SHADER_DATA{ shader, uniforms, attrs }, 1)); return shader; } bool ResourceManager::reload_shader(SHADER_DATA* sd, const std::string& name) { std::string path(name); Buffer buffer; if (!m_vfs->read(path, &buffer)) return false; if (!sd->shader->init((const char*)buffer.ptr(), (const char*)buffer.ptr())) return false; sd->shader->bind(); for (auto it : sd->uniforms) { sd->shader->bind_uniform(it.first, it.second.c_str()); } for (auto it : sd->attrs) { sd->shader->bind_attr(it.first, it.second.c_str()); } sd->shader->unbind(); return true; } bool ResourceManager::release_shader(const std::string& name) { auto cached = m_shaders.find(name); if (cached == m_shaders.end()) return false; auto& pair = cached->second; pair.second --; if (pair.second == 0) { delete pair.first.shader; m_shaders.erase(name); } return true; } bool ResourceManager::release_shader(const Shader* shader) { if (shader == nullptr ) return false; for (auto it=m_shaders.begin(); it!=m_shaders.end(); ++it) { auto& pair = it->second; if (pair.first.shader != shader) continue; pair.second --; if (pair.second == 0) { delete pair.first.shader; m_shaders.erase(it); } return true; } return false; } const Texture* ResourceManager::retain_tex(const std::string& name) { Buffer buffer; auto cached = m_texs.find(name); if (cached!=m_texs.end()) { auto& pair = cached->second; pair.second ++; return pair.first; } Texture* tex = new (std::nothrow) Texture(); if (!tex) return nullptr; if (m_contextready) { if (!m_vfs->read(name, &buffer)) return nullptr; if (!load_tex_png(tex, buffer)) { delete tex; return nullptr; } } m_texs.emplace(name, std::make_pair(tex, 1)); return tex; } bool ResourceManager::reload_tex(Texture* tex, const std::string& name) { Buffer buffer; if (!m_vfs->read(name.c_str(), &buffer)) return false; return load_tex_png(tex, buffer); } bool ResourceManager::release_tex(const std::string& name) { auto cached = m_texs.find(name); if (cached == m_texs.end()) return false; auto& pair = cached->second; pair.second --; if (pair.second == 0) { delete pair.first; m_texs.erase(name); } return true; } bool ResourceManager::release_tex(const Texture* tex) { if (tex == nullptr ) return false; for (auto it=m_texs.begin(); it!=m_texs.end(); ++it) { auto& pair = it->second; if (pair.first != tex) continue; pair.second --; if (pair.second == 0) { delete pair.first; m_texs.erase(it); } return true; } return false; } const Buffer* ResourceManager::retain_raw(const std::string& name) { auto cached = m_raws.find(name); if (cached != m_raws.end()) { auto& pair = cached->second; pair.second++; return pair.first; } Buffer* buffer = new Buffer(); if (!m_vfs->read(name, buffer)) { delete buffer; return nullptr; } m_raws.emplace(name, std::make_pair(buffer, 1)); return buffer; } bool ResourceManager::release_raw(const std::string& name) { auto cached = m_raws.find(name); if (cached == m_raws.end()) return false; auto& pair = cached->second; pair.second--; if (pair.second == 0) { delete pair.first; m_raws.erase(name); } return true; } bool ResourceManager::release_raw(const Buffer* buffer) { if (buffer == nullptr) return false; for (auto it = m_raws.begin(); it != m_raws.end(); ++it) { auto& pair = it->second; if (pair.first != buffer) continue; pair.second--; if (pair.second == 0) { delete pair.first; m_raws.erase(it); } return true; } return false; } typedef struct { Buffer* buffer; size_t offset; } PNGBufferReader; void _png_read(png_structp png, png_bytep data, png_size_t size) { PNGBufferReader* br = (PNGBufferReader*) png_get_io_ptr(png); if ( br->offset + size <= br->buffer->size() ) { memcpy ( data, br->buffer->ptr() + br->offset, size ); br->offset += size; } } bool ResourceManager::load_tex_png(Texture* tex, Buffer& buf) { Texture::Format format; unsigned int width, height; uint8_t* pixel = nullptr; png_structp png = NULL; png_infop info = NULL; png_bytepp row_pointers; size_t row_bytes; PNGBufferReader bufreader; if (png_sig_cmp(buf.ptr(), 0, 8)) goto fail; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png == NULL) goto fail; info = png_create_info_struct(png); if (info == NULL) goto fail; if (setjmp(png_jmpbuf(png))) goto fail; bufreader.buffer = &buf; bufreader.offset = 8; png_set_read_fn(png, &bufreader, _png_read); png_set_sig_bytes(png, 8); png_read_png(png, info, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND, NULL); switch ( png_get_color_type(png, info) ) { case PNG_COLOR_TYPE_RGBA: format = Texture::Format::RGBA; break; case PNG_COLOR_TYPE_RGB: format = Texture::Format::RGB; break; default: goto fail; } row_bytes = png_get_rowbytes(png, info); width = (unsigned int)png_get_image_width(png, info); height = (unsigned int)png_get_image_height(png, info); if (width > 4096 || height > 4096) goto fail; pixel = new (std::nothrow) uint8_t[row_bytes * height]; if (!pixel) goto fail; row_pointers = png_get_rows(png, info); for (unsigned int i = 0; i < height; i++) { memcpy( pixel + (row_bytes * (height-1-i)), row_pointers[i], row_bytes ); } png_destroy_read_struct(&png, &info, NULL); tex->update(format, (int)width, (int)height, pixel); delete pixel; return true; fail: png_destroy_read_struct(&png, &info, NULL); delete pixel; return false; }
bool ResourceManager::context_restored() { if (m_contextready) return true; m_contextready = true; for (auto it: m_shaders) { reload_shader(&it.second.first, it.first); } for (auto it : m_texs) { reload_tex(it.second.first, it.first); } return true; }
function_block-full_function
[ { "content": "namespace cat {\n\n// ----------------------------------------------------------------------------\n\n// UI Event\n\n// ----------------------------------------------------------------------------\n\nstruct TouchEvent {\n\n enum EventType { TouchDown, TouchUp, TouchMove, Scroll };\n\n EventType type;\n\n Timestamp timestamp;\n\n int pointer_id;\n\n int x, y;\n\n int scroll;\n\n unsigned int button;\n\n};\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_type.h", "rank": 0, "score": 111131.72797081895 }, { "content": "namespace cat {\n\n// ----------------------------------------------------------------------------\n\nenum Platform {\n\n Windows,\n\n Mac,\n\n IOS,\n\n Android\n\n};\n\n// ----------------------------------------------------------------------------\n\nstruct PlatformSpecificData {\n\n#if defined(PLATFORM_WIN32) || defined(PLATFORM_WIN64)\n\n HWND rootview;\n\n#elif defined(PLATFORM_MAC)\n\n void* rootview; \n\n std::string res_path;\n\n#elif defined(PLATFORM_IOS)\n\n void* rootview;\n\n std::string res_path;\n\n#elif defined(PLATFORM_ANDROID)\n\n jobject rootview; \n\n jobject asset_manager;\n\n#else\n\n #error Not Implemented!\n\n#endif\n\n};\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_platform.h", "rank": 1, "score": 111131.72797081895 }, { "content": "namespace cat {\n\n// ----------------------------------------------------------------------------\n\nstruct SoundEffect {\n\n std::string name;\n\n#if defined(PLATFORM_WIN32) || defined(PLATFORM_WIN64)\n\n // TODO\n\n#elif defined(PLATFORM_ANDROID)\n\n jint sound_id;\n\n#elif defined(PLATFORM_MAC) || defined(PLATFORM_IOS)\n\n // TODO\n\n#else\n\n #error Not Implemented!\n\n#endif\n\n};\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_sound_type.h", "rank": 2, "score": 109776.59968231563 }, { "content": "protected:\n\n KernelApi* kernel() const { return m_kernel; }\n\n void exit() { m_running = false; }\n\nprivate:\n\n KernelApi* m_kernel;\n\n bool m_running;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_APPLICATION_H__\n", "file_path": "libcat/include/cat_application.h", "rank": 3, "score": 74482.12800558213 }, { "content": "#ifndef __CAT_APPLICATION_H__\n\n#define __CAT_APPLICATION_H__\n\n\n\n#include \"cat_platform.h\"\n\n#include \"cat_type.h\"\n\n#include \"cat_storage_vfs.h\"\n\n#include \"cat_storage_resmgr.h\"\n\n#include \"cat_gfx_renderer.h\"\n\n#include \"cat_kernel_api.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_application.h", "rank": 4, "score": 74480.44885523155 }, { "content": "#ifndef __CAT_KERNEL_H__\n\n#define __CAT_KERNEL_H__\n\n\n\n#include <memory>\n\n#include <list>\n\n#include <mutex>\n\n#include \"cat_platform.h\"\n\n#include \"cat_type.h\"\n\n#include \"cat_gfx_renderer.h\"\n\n#include \"cat_storage_vfs.h\"\n\n#include \"cat_storage_resmgr.h\"\n\n#include \"cat_time_service.h\"\n\n#include \"cat_net_service.h\"\n\n#include \"cat_sound_service.h\"\n\n#include \"cat_ui_service.h\"\n\n#include \"cat_kernel_api.h\"\n\n#include \"cat_application.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_kernel.h", "rank": 5, "score": 74480.10104261873 }, { "content": " TimeService m_time;\n\n NetService m_net;\n\n SoundService m_sound;\n\n UIService m_ui;\n\n std::list<std::unique_ptr<Application>> m_apps;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_KERNEL_H__\n", "file_path": "libcat/include/cat_kernel.h", "rank": 6, "score": 74474.2493084975 }, { "content": " enum EventType { TouchDown, TouchUp, TouchMove, Scroll };\n", "file_path": "libcat/include/cat_type.h", "rank": 7, "score": 74469.93769006683 }, { "content": " int x, y;\n", "file_path": "libcat/include/cat_type.h", "rank": 8, "score": 74469.93769006683 }, { "content": "\n\npublic:\n\n // Kernel API\n\n virtual bool run(Application* app);\n\n virtual const PlatformSpecificData* psd() { return &m_psd; }\n\n virtual VFS* vfs() { return &m_vfs; }\n\n virtual Renderer* renderer() { return &m_renderer; }\n\n virtual ResourceManager* res() { return &m_res; }\n\n virtual TimeService* time() { return &m_time; }\n\n virtual NetService* net() { return &m_net; }\n\n virtual SoundService* sound() { return &m_sound; }\n\n virtual UIService* ui() { return &m_ui; }\n\n\n\nprivate:\n\n bool m_resumed;\n\n std::mutex m_bigkernellock;\n\n PlatformSpecificData m_psd;\n\n VFS m_vfs;\n\n Renderer m_renderer;\n\n ResourceManager m_res;\n", "file_path": "libcat/include/cat_kernel.h", "rank": 9, "score": 74469.77399484403 }, { "content": " std::string name;\n", "file_path": "libcat/include/cat_sound_type.h", "rank": 10, "score": 72938.24344016364 }, { "content": " EventType type;\n", "file_path": "libcat/include/cat_type.h", "rank": 11, "score": 72938.24344016364 }, { "content": " int scroll;\n", "file_path": "libcat/include/cat_type.h", "rank": 12, "score": 72938.24344016364 }, { "content": " unsigned int button;\n", "file_path": "libcat/include/cat_type.h", "rank": 13, "score": 72938.24344016364 }, { "content": " Timestamp timestamp;\n", "file_path": "libcat/include/cat_type.h", "rank": 14, "score": 72938.24344016364 }, { "content": "#ifndef __CAT_DATA_OBSERVABLE_H__\n\n#define __CAT_DATA_OBSERVABLE_H__\n\n\n\n#include <functional>\n\n#include <vector>\n\n#include <mutex>\n\n#include \"cat_data_uniqueid.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\ntemplate <class T>\n\nusing Observer = std::function<void(const T& data)>;\n\n// ----------------------------------------------------------------------------\n\ntemplate <class T>\n", "file_path": "libcat/include/cat_data_observable.h", "rank": 15, "score": 72397.35223855551 }, { "content": " glActiveTexture(GL_TEXTURE0 + unit);\n\n glBindTexture(GL_TEXTURE_2D, 0);\n\n }\n\n bool update(Texture::Format format, int width, int height, const void* pixel, bool antialias=true);\n\n bool capture_screen(const Rect2i& rect);\n\n void release();\n\nprivate:\n\n int m_width, m_height;\n\n GLuint m_tex;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_GFX_TEX_H__\n", "file_path": "libcat/include/cat_gfx_tex.h", "rank": 16, "score": 72395.72737878114 }, { "content": "// -----------------------------------------------------------\n\ntemplate <class HANDLE, typename T>\n\nvoid TimerQueue<HANDLE,T>::remove(std::function<bool(const HANDLE& handle, const T& data)> comparator) {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n for (auto it = m_queue.begin(); it != m_queue.end();) {\n\n if (comparator(it->handle, it->message)) {\n\n it = m_queue.erase(it);\n\n } else {\n\n ++it;\n\n }\n\n }\n\n}\n\n// -----------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_TIME_QUEUE_H__\n", "file_path": "libcat/include/cat_time_queue.h", "rank": 17, "score": 72393.89580723364 }, { "content": " [mapped, mapper, observer](const T& data) -> void {\n\n MAP new_mapped = mapper(data);\n\n if (*mapped == new_mapped) return; // Custom class might overload ==\n\n *mapped = std::move(new_mapped);\n\n observer(*mapped);\n\n },\n\n [mapped]() -> void {\n\n delete mapped;\n\n }\n\n );\n\n}\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_DATA_OBSERVABLE_H__\n", "file_path": "libcat/include/cat_data_observable.h", "rank": 18, "score": 72393.85205898354 }, { "content": " void resume();\n\n\n\n void context_lost();\n\n bool context_restored();\n\n void resize(int width, int height);\n\n void render(Renderer* r, Timestamp now);\n\n bool touch(TouchEvent ev);\n\n\n\nprivate:\n\n KernelApi* m_kernel;\n\n Size2i m_size;\n\n float m_scale;\n\n Widget* m_desktop;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_UI_SERVICE_H__\n", "file_path": "libcat/include/cat_ui_service.h", "rank": 19, "score": 72393.48594742568 }, { "content": " int get_value() const { return m_value; }\n\n\n\nprotected:\n\n virtual void cb_move();\n\n virtual void cb_resize();\n\n virtual bool cb_touch(const TouchEvent& ev, bool handled);\n\n virtual void cb_render(Renderer* r, Timestamp now);\n\n\n\nprotected:\n\n Orentation m_orentation;\n\n int m_min, m_max, m_value;\n\n Rect2i m_thumbrc;\n\n bool m_dragging;\n\n int m_dragx, m_dragy;\n\n void update_thumbrc();\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_UI_SILDER_H__\n", "file_path": "libcat/include/cat_ui_slider.h", "rank": 20, "score": 72393.11191268197 }, { "content": " bool init();\n\n //! Cleanup service\n\n void fini();\n\n //! Called from kernel when the app is put to background\n\n void pause();\n\n //! Called from kernel when the app is resume to foreground\n\n void resume();\n\n //! Called from kernel to poll for event\n\n void poll();\n\n\n\nprivate:\n\n HttpManager m_http;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_NET_SERVICE_H__\n", "file_path": "libcat/include/cat_net_service.h", "rank": 21, "score": 72392.86114498693 }, { "content": "#ifndef __CAT_TIME_TYPE_H__\n\n#define __CAT_TIME_TYPE_H__\n\n\n\n#include <functional>\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\ntypedef unsigned long Timestamp;\n\ntypedef std::function<void(Timestamp)> TimerFunction;\n\n// -----------------------------------------------------------\n\ntemplate <typename T>\n", "file_path": "libcat/include/cat_time_type.h", "rank": 22, "score": 72392.47420428839 }, { "content": " bool init();\n\n //! Cleanup service\n\n void fini();\n\n //! Called from kernel when the app is put to background\n\n void pause();\n\n //! Called from kernel when the app is resume to foreground\n\n void resume();\n\n //! Called from kernel to process timer events\n\n bool timer();\n\n\n\nprivate:\n\n TimerQueue<TimerDelegate<int>*,int> m_delegates;\n\n TimerQueue<TimerFunction, int> m_functions;\n\n Timestamp m_last, m_tick;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_TIME_SERVICE_H__\n", "file_path": "libcat/include/cat_time_service.h", "rank": 23, "score": 72392.36130756332 }, { "content": " virtual bool cb_touch(const TouchEvent& ev, bool handled);\n\n virtual void cb_render(Renderer* r, unsigned long now);\n\n\n\nprotected:\n\n TextStyle m_textstyle;\n\n void update_font();\n\n void update_textcolor();\n\n\n\nprivate:\n\n std::string m_text;\n\n bool m_native_show;\n\n#if defined(PLATFORM_WIN32) || defined(PLATFORM_WIN64)\n\n HWND m_native_ctrl;\n\n HFONT m_font;\n\n#elif defined(PLATFORM_MAC) || defined(PLATFORM_IOS)\n\n void* m_native_ctrl;\n\n#elif defined(PLATFORM_ANDROID)\n\n jobject m_native_ctrl;\n\n#else\n\n #error Not Implemented!\n\n#endif\n\n void native_show(bool show);\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_UI_EDIT_H__\n", "file_path": "libcat/include/cat_ui_edit.h", "rank": 24, "score": 72392.19683350365 }, { "content": " } return false;\n\n}\n\ntemplate <class... ARG>\n\nvoid Emitter<ARG...>::emit(int ev, const ARG&... arg) {\n\n std::lock_guard<std::recursive_mutex> lock(m_mutex);\n\n auto map_it = m_map.find(ev);\n\n if (map_it == m_map.end()) return;\n\n auto& list = map_it->second;\n\n for (auto it = list.begin(); it!=list.end(); ) {\n\n if (it->active) {\n\n it->handler(ev, arg...);\n\n if (it->once) {\n\n it = list.erase(it);\n\n } else {\n\n ++it;\n\n }\n\n } else {\n\n it = list.erase(it);\n\n }\n\n }\n\n}\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_DATA_EMITTER_H__\n", "file_path": "libcat/include/cat_data_emitter.h", "rank": 25, "score": 72391.58348699508 }, { "content": "#ifndef __CAT_GFX_DRAWABLE_H__\n\n#define __CAT_GFX_DRAWABLE_H__\n\n\n\n#include <string>\n\n#include \"cat_platform.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n#include \"cat_gfx_tex.h\"\n\n#include \"cat_gfx_drawablecanvas.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_drawable.h", "rank": 26, "score": 72391.51507409126 }, { "content": "#ifndef __CAT_UI_ANIMATOR_H__\n\n#define __CAT_UI_ANIMATOR_H__\n\n\n\n#include <memory>\n\n#include <functional>\n\n#include \"cat_ui_interpolator.h\"\n\n#include \"cat_time_type.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_ui_animator.h", "rank": 27, "score": 72391.50970602762 }, { "content": "#ifndef __CAT_GFX_VBO_H__\n\n#define __CAT_GFX_VBO_H__\n\n\n\n#include <stdint.h>\n\n#include <stddef.h>\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_vbo.h", "rank": 28, "score": 72391.48700224642 }, { "content": "#ifndef __CAT_GFX_IBO_H__\n\n#define __CAT_GFX_IBO_H__\n\n\n\n#include <stdint.h>\n\n#include <stddef.h>\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_ibo.h", "rank": 29, "score": 72391.48700224642 }, { "content": "#ifndef __CAT_UI_SERVICE_H__\n\n#define __CAT_UI_SERVICE_H__\n\n\n\n#include \"cat_platform.h\"\n\n#include \"cat_type.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_time_type.h\"\n\n#include \"cat_ui_widget.h\"\n\n#include \"cat_gfx_renderer.h\"\n\n#include \"cat_kernel_api.h\"\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_ui_service.h", "rank": 30, "score": 72391.4788086736 }, { "content": "#ifndef __CAT_TIME_SERVICE_H__\n\n#define __CAT_TIME_SERVICE_H__\n\n\n\n#include <functional>\n\n#include \"cat_time_type.h\"\n\n#include \"cat_time_queue.h\"\n\n#include \"cat_data_copyable.h\"\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_time_service.h", "rank": 31, "score": 72391.46745872602 }, { "content": "#ifndef __CAT_SOUND_SERVICE_H__\n\n#define __CAT_SOUND_SERVICE_H__\n\n\n\n#include <string>\n\n#include <utility>\n\n#include <unordered_map>\n\n#include \"cat_platform.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_sound_type.h\"\n\n#include \"cat_sound_effects.h\"\n\n#include \"cat_sound_player.h\"\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_sound_service.h", "rank": 32, "score": 72391.44434359489 }, { "content": "#ifndef __CAT_SOUND_EFFECTS_H__\n\n#define __CAT_SOUND_EFFECTS_H__\n\n\n\n#include <string>\n\n#include <utility>\n\n#include <unordered_map>\n\n#include \"cat_platform.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_sound_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\n//! Sound Effects\n", "file_path": "libcat/include/cat_sound_effects.h", "rank": 33, "score": 72391.40294023076 }, { "content": "#ifndef __CAT_UTIL_STRING_H__\n\n#define __CAT_UTIL_STRING_H__\n\n\n\n#include <string>\n\n#include <vector>\n\n#include <functional>\n\n#include \"cat_platform.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\n//! String utility\n", "file_path": "libcat/include/cat_util_string.h", "rank": 34, "score": 72391.40136989688 }, { "content": "#ifndef __CAT_STORAGE_VFS_H__\n\n#define __CAT_STORAGE_VFS_H__\n\n\n\n#include <string>\n\n#include <memory>\n\n#include <unordered_map>\n\n#include \"cat_storage_driver.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_storage_vfs.h", "rank": 35, "score": 72391.40136989688 }, { "content": "#ifndef __CAT_GFX_SHADER_H__\n\n#define __CAT_GFX_SHADER_H__\n\n\n\n#include <stdint.h>\n\n#include <stddef.h>\n\n#include <string>\n\n#include <glm/glm.hpp>\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_shader.h", "rank": 36, "score": 72391.39323202283 }, { "content": "#ifndef __CAT_GFX_RENDERER_H__\n\n#define __CAT_GFX_RENDERER_H__\n\n\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n#include \"cat_gfx_draw2d.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_renderer.h", "rank": 37, "score": 72391.3534000044 }, { "content": "#ifndef __CAT_UI_PANE_H__\n\n#define __CAT_UI_PANE_H__\n\n\n\n#include \"cat_ui_widget.h\"\n\n#include \"cat_gfx_type.h\"\n\n#include \"cat_gfx_draw2d.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_ui_pane.h", "rank": 38, "score": 72391.3534000044 }, { "content": "#ifndef __CAT_GFX_FBO_H__\n\n#define __CAT_GFX_FBO_H__\n\n\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n#include \"cat_gfx_tex.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_fbo.h", "rank": 39, "score": 72391.3534000044 }, { "content": "#ifndef __CAT_KERNEL_API_H__\n\n#define __CAT_KERNEL_API_H__\n\n\n\n#include \"cat_platform.h\"\n\n#include \"cat_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_kernel_api.h", "rank": 40, "score": 72391.29943387712 }, { "content": "#ifndef __CAT_STORAGE_RESMGR_H__\n\n#define __CAT_STORAGE_RESMGR_H__\n\n\n\n#include <stdint.h>\n\n#include <stddef.h>\n\n#include <string>\n\n#include <memory>\n\n#include <list>\n\n#include <functional>\n\n#include <unordered_map>\n\n#include <utility>\n\n#include \"cat_storage_vfs.h\"\n\n#include \"cat_gfx_shader.h\"\n\n#include \"cat_gfx_tex.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_storage_resmgr.h", "rank": 41, "score": 72391.28502367808 }, { "content": "#ifndef __CAT_UI_WIDGET_H__\n\n#define __CAT_UI_WIDGET_H__\n\n\n\n#include <vector>\n\n#include <string>\n\n#include \"cat_platform.h\"\n\n#include \"cat_type.h\"\n\n#include \"cat_kernel_api.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n#include \"cat_gfx_texref.h\"\n\n#include \"cat_gfx_draw2d.h\"\n\n#include \"cat_time_queue.h\"\n\n#include \"cat_data_event.h\"\n\n#include \"cat_ui_animator.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_ui_widget.h", "rank": 42, "score": 72391.26874445612 }, { "content": "#ifndef __CAT_STORAGE_DRIVER_H__\n\n#define __CAT_STORAGE_DRIVER_H__\n\n\n\n#include <string>\n\n#include \"cat_data_buffer.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_storage_driver.h", "rank": 43, "score": 72391.1601636303 }, { "content": "#ifndef __CAT_DATA_EMITTER_H__\n\n#define __CAT_DATA_EMITTER_H__\n\n\n\n#include <mutex>\n\n#include <functional>\n\n#include <unordered_map>\n\n#include <vector>\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\ntemplate <class... ARG>\n", "file_path": "libcat/include/cat_data_emitter.h", "rank": 44, "score": 72391.16445880146 }, { "content": "#ifndef __CAT_UTIL_JNI_H__\n\n#define __CAT_UTIL_JNI_H__\n\n#if defined (PLATFORM_ANDROID)\n\n\n\n#include <jni.h>\n\n#include <string>\n\n#include \"cat_data_copyable.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_util_jni.h", "rank": 45, "score": 72391.16230224296 }, { "content": "#ifndef __CAT_DATA_BUFFER_H__\n\n#define __CAT_DATA_BUFFER_H__\n\n\n\n#include <stdint.h>\n\n#include <stddef.h>\n\n#include <string>\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\n//! Convenient Buffer\n", "file_path": "libcat/include/cat_data_buffer.h", "rank": 46, "score": 72391.16565897419 }, { "content": "#ifndef __CAT_NET_SERVICE_H__\n\n#define __CAT_NET_SERVICE_H__\n\n\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_net_http.h\"\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_net_service.h", "rank": 47, "score": 72391.13506601962 }, { "content": "#ifndef __CAT_UI_BUTTON_H__\n\n#define __CAT_UI_BUTTON_H__\n\n\n\n#include \"cat_ui_label.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_ui_button.h", "rank": 48, "score": 72391.13506601962 }, { "content": "#ifndef __CAT_GFX_TEX_H__\n\n#define __CAT_GFX_TEX_H__\n\n\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_tex.h", "rank": 49, "score": 72391.13506601962 }, { "content": "#ifndef __CAT_UI_LABEL_H__\n\n#define __CAT_UI_LABEL_H__\n\n\n\n#include \"cat_ui_widget.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_ui_label.h", "rank": 50, "score": 72391.13506601962 }, { "content": "#ifndef __CAT_UI_EFFECTVIEW_H__\n\n#define __CAT_UI_EFFECTVIEW_H__\n\n\n\n#include \"cat_ui_widget.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_ui_effectview.h", "rank": 51, "score": 72391.13506601962 }, { "content": "#ifndef __CAT_UI_SILDER_H__\n\n#define __CAT_UI_SILDER_H__\n\n\n\n#include \"cat_ui_widget.h\"\n\n#include \"cat_gfx_type.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_ui_slider.h", "rank": 52, "score": 72391.13506601962 }, { "content": "#ifndef __CAT_DATA_EVENTHANDLER_H__\n\n#define __CAT_DATA_EVENTHANDLER_H__\n\n\n\n#include <functional>\n\n#include <vector>\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_data_event.h", "rank": 53, "score": 72391.12686137139 }, { "content": "#ifndef __CAT_GFX_DRAW2D_H__\n\n#define __CAT_GFX_DRAW2D_H__\n\n\n\n#include <string>\n\n#include <unordered_map>\n\n#include <vector>\n\n#include <glm/glm.hpp>\n\n#include \"cat_platform.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_type.h\"\n\n#include \"cat_gfx_type.h\"\n\n#include \"cat_gfx_shader.h\"\n\n#include \"cat_gfx_vbo.h\"\n\n#include \"cat_gfx_fbo.h\"\n\n#include \"cat_gfx_tex.h\"\n\n#include \"cat_gfx_texref.h\"\n\n#include \"cat_gfx_drawable.h\"\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_gfx_draw2d.h", "rank": 54, "score": 72391.11623997023 }, { "content": " if (m_seed < m_limit_hi) {\n\n return m_seed++;\n\n } return m_invalid;\n\n}\n\n// ----------------------------------------------------------------------------\n\ntemplate <typename T, typename TIMESTAMP>\n\nbool UniqueId<T, TIMESTAMP>::release(const T& id, TIMESTAMP now) {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n m_list.push_back({ now, id });\n\n return true;\n\n}\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_DATA_UNIQUEID_H__\n\n\n", "file_path": "libcat/include/cat_data_uniqueid.h", "rank": 55, "score": 72390.93167395085 }, { "content": "#ifndef __CAT_TIME_QUEUE_H__\n\n#define __CAT_TIME_QUEUE_H__\n\n\n\n#include <list>\n\n#include <mutex>\n\n#include \"cat_time_type.h\"\n\n\n\nnamespace cat {\n\n// -----------------------------------------------------------\n\n//! Delta queue implementation\n\ntemplate <class HANDLE, typename T>\n", "file_path": "libcat/include/cat_time_queue.h", "rank": 56, "score": 72390.87127967754 }, { "content": "#ifndef __CAT_GFX_DRAWABLECANVAS_H__\n\n#define __CAT_GFX_DRAWABLECANVAS_H__\n\n\n\n#include <stdint.h>\n\n#include \"cat_platform.h\"\n\n#include \"cat_type.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_gfx_type.h\"\n\n#include \"cat_gfx_tex.h\"\n\n\n\n#if defined(PLATFORM_MAC)\n\n #include <ApplicationServices/ApplicationServices.h>\n\n#elif defined(PLATFORM_IOS)\n\n #include <CoreGraphics/CoreGraphics.h>\n\n #include <CoreText/CoreText.h>\n\n#endif\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_drawablecanvas.h", "rank": 57, "score": 72390.83703006535 }, { "content": "#ifndef __CAT_GFX_TYPE_H__\n\n#define __CAT_GFX_TYPE_H__\n\n\n\n#include <stdint.h>\n\n#include \"cat_gfx_opengl.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\n// Shader Data\n\n// ----------------------------------------------------------------------------\n\n#pragma pack(push,1)\n", "file_path": "libcat/include/cat_gfx_type.h", "rank": 58, "score": 72390.74389252026 }, { "content": "#ifndef __CAT_NET_HTTP_H__\n\n#define __CAT_NET_HTTP_H__\n\n\n\n#if defined(PLATFORM_WIN32) || defined(PLATFORM_WIN64)\n\n #define WIN32_LEAN_AND_MEAN\n\n #include <windows.h>\n\n #include <wininet.h>\n\n #undef WIN32_LEAN_AND_MEAN\n\n#endif\n\n\n\n#include <stdint.h>\n\n#include <functional>\n\n#include <list>\n\n#include <unordered_map>\n\n#include <mutex>\n\n#include <condition_variable>\n\n#include <thread>\n\n#include <atomic>\n\n#include \"cat_platform.h\"\n\n#include \"cat_data_copyable.h\"\n\n#include \"cat_data_buffer.h\"\n\n#include \"cat_data_uniqueid.h\"\n\n#include \"cat_time_type.h\"\n\n\n\nnamespace cat {\n", "file_path": "libcat/include/cat_net_http.h", "rank": 59, "score": 72390.66021857432 }, { "content": "#ifndef __CAT_GFX_TEXREF_H__\n\n#define __CAT_GFX_TEXREF_H__\n\n\n\n#include \"cat_gfx_tex.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_gfx_texref.h", "rank": 60, "score": 72390.47784504117 }, { "content": "#ifndef __CAT_UI_EDIT_H__\n\n#define __CAT_UI_EDIT_H__\n\n\n\n#include \"cat_ui_widget.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_ui_edit.h", "rank": 61, "score": 72390.47784504117 }, { "content": "#ifndef __CAT_SOUND_PLAYER_H__\n\n#define __CAT_SOUND_PLAYER_H__\n\n\n\n#include <string>\n\n#include \"cat_platform.h\"\n\n#if defined(PLATFORM_WIN32) || defined(PLATFORM_WIN64)\n\n #include <mfobjects.h>\n\n #include <mfidl.h>\n\n #pragma comment(lib, \"shlwapi\")\n\n #pragma comment(lib, \"mf.lib\")\n\n #pragma comment(lib, \"mfplat.lib\")\n\n #pragma comment(lib, \"mfuuid.lib\")\n\n#elif defined(PLATFORM_ANDROID)\n\n #include <SLES/OpenSLES.h>\n\n#endif\n\n#include \"cat_data_event.h\"\n\n#include \"cat_data_copyable.h\"\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_sound_player.h", "rank": 62, "score": 72390.12245641976 }, { "content": "#ifndef __CAT_DATA_UNIQUEID_H__\n\n#define __CAT_DATA_UNIQUEID_H__\n\n\n\n#include <deque>\n\n#include <mutex>\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\ntemplate <typename...> class UniqueId;\n\n//! Unique ID Generator without timeout\n\ntemplate <typename T>\n", "file_path": "libcat/include/cat_data_uniqueid.h", "rank": 63, "score": 72390.10042352315 }, { "content": " //! Trim space(' ') from begin and end of string\n\n //! \\param s string to trim\n\n //! \\return string with trimmed space\n\n static std::string trim(const std::string& s);\n\n //! spliy string with delimiter\n\n //! \\param s string to split\n\n //! \\param delimiter delimiter, e.g. \",\"\n\n //! \\param should_trim true to trim space\n\n //! \\return vector of splitted string\n\n static std::vector<std::string> split(const std::string& s, const std::string& delimiter, bool should_trim = false);\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n // ----------------------------------------------------------------------------\n\n\n\n#endif // __CAT_UTIL_STRING_H__\n", "file_path": "libcat/include/cat_util_string.h", "rank": 64, "score": 72389.64750847573 }, { "content": " Texture m_tex;\n\n int m_width, m_height;\n\n bool m_dirty;\n\n TextStyle m_textstyle;\n\n DrawableCanvas m_canvas;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_GFX_DRAWABLE_H__\n", "file_path": "libcat/include/cat_gfx_drawable.h", "rank": 65, "score": 72389.53524087046 }, { "content": " Draw2D* draw2d();\n\n void dirty();\n\nprivate:\n\n KernelApi* m_kernel; // hide from widget, access throw helper\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_UI_WIDGET_H__\n\n\n\n\n\n\n", "file_path": "libcat/include/cat_ui_widget.h", "rank": 66, "score": 72389.47378758661 }, { "content": " it->handler(obj, args...);\n\n ++it;\n\n } else {\n\n it = m_handlers.erase(it);\n\n }\n\n } return handled;\n\n }\n\nprivate:\n\n struct NODE {\n\n HANDLER handler;\n\n bool active;\n\n };\n\n std::vector<NODE> m_handlers;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_DATA_EVENTHANDLER_H__\n", "file_path": "libcat/include/cat_data_event.h", "rank": 67, "score": 72389.33057583081 }, { "content": "private:\n\n bool initGL();\n\n\n\nprivate:\n\n bool m_contextready;\n\n bool m_dirty;\n\n int m_width, m_height;\n\n#if defined(PLATFORM_WIN32) || defined(PLATFORM_WIN64) || defined(PLATFORM_MAC)\n\n GLuint m_vao;\n\n#elif defined(PLATFORM_IOS) || defined(PLATFORM_ANDROID)\n\n // NOTHING\n\n#else\n\n #error Not Implemented!\n\n#endif\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_GFX_RENDERER_H__\n", "file_path": "libcat/include/cat_gfx_renderer.h", "rank": 68, "score": 72389.31894916363 }, { "content": " virtual void cb_pause(bool paused) {}\n\n virtual void cb_visible(bool b) {}\n\n virtual void cb_enable(bool b) {}\n\n virtual bool cb_timer(Timestamp now, int code) { return false; }\n\n virtual bool cb_touch(const TouchEvent& ev, bool handled) { return false; }\n\n virtual void cb_render(Renderer* r, Timestamp now) {}\n\n virtual void cb_context_lost() {}\n\n virtual bool cb_context_restored() { return true; }\n\n\n\nprotected: // Helper function for widget\n\n void update_absrect();\n\n void update_absopacity(float parent_absopacity);\n\n void post_timer(Timestamp delay, int code);\n\n void remove_timer();\n\n void capture(Texture* tex, const Rect2i& rect);\n\n uint32_t apply_opacity(uint32_t color) const;\n\n\n\nprotected:\n\n Widget* m_parent;\n\n std::vector<Widget*> m_childs;\n", "file_path": "libcat/include/cat_ui_widget.h", "rank": 69, "score": 72389.24480244784 }, { "content": " std::vector<NODE> list;\n\n auto em = m_map.emplace(ev, list);\n\n if (!em.second) return false;\n\n em.first->second.push_back({ handler, true, true });\n\n } else {\n\n map_it->second.push_back({ handler, true, true });\n\n } return true;\n\n}\n\ntemplate <class... ARG>\n\nbool Emitter<ARG...>::remove(int ev, HANDLER handler) {\n\n auto handler_p = handler.template target<HANDLER>();\n\n std::lock_guard<std::recursive_mutex> lock(m_mutex);\n\n auto map_it = m_map.find(ev);\n\n if (map_it == m_map.end()) return false;\n\n auto& list = map_it->second;\n\n for (auto& node: list) {\n\n if (handler_p == node.handler.template target<HANDLER>()) {\n\n node.active = false;\n\n return true;\n\n }\n", "file_path": "libcat/include/cat_data_emitter.h", "rank": 70, "score": 72389.22608346224 }, { "content": " const uint8_t* ptr() const { return m_buffer; }\n\n //! Default cast to uint8_t*, i.e. uint8_t* p = buffer;\n\n operator uint8_t*() { return m_buffer; }\n\n operator const uint8_t*() const { return m_buffer; }\n\n //! Get size of the buffer\n\n //! \\return length, in bytes, of the buffer\n\n size_t size() const { return m_size; }\n\n\n\n //! Resize buffer\n\n //! The behaviour is as if calling C realloc()\n\n //! \\param size New size of the buffer, in bytes\n\n //! \\return true if success, false if failed and no side-effect\n\n bool realloc(size_t size);\n\n //! Free the underlying memory\n\n //! Buffer will reset to empty state\n\n void free();\n\n //! Reduce size of the buffer\n\n //! \\return true if success, false if failed and no side-effect\n\n bool shrink(size_t s);\n\n //! Make this buffer point to a copy of the memory region\n", "file_path": "libcat/include/cat_data_buffer.h", "rank": 71, "score": 72389.18781738853 }, { "content": " //! If the buffer contain any data it will be free'd.\n\n //! \\param mem Memory to copy\n\n //! \\param size Size of the memory region, in bytes\n\n //! \\return true if success, false if failed and no side-effect\n\n bool assign(const void* mem, size_t size);\n\n //! Copy memory region to this buffer\n\n //! i.e. memcpy(this->ptr()[offset], mem, size);\n\n //! \\param offset Offset of this buffer\n\n //! \\param mem Memory to copy\n\n //! \\param size Size of the memory region, in bytes\n\n //! \\return true if success, false if failed and no side-effect, eg. buffer is too small.\n\n bool copy(size_t offset, const void* mem, size_t size);\n\n\n\n //! Move Assignment\n\n //! \\param o Buffer to move\n\n //! \\return Buffer acquired the input buffer\n\n Buffer& operator=(Buffer&& o);\n\n //! Make this buffer point to a copy of the string's memory, including zero terminator\n\n //! \\param o string to copy\n\n //! \\return Buffer containing a copy of the string\n", "file_path": "libcat/include/cat_data_buffer.h", "rank": 72, "score": 72388.8634283136 }, { "content": "// Emitter\n\n// ----------------------------------------------------------------------------\n\ntemplate <class... ARG>\n\nbool Emitter<ARG...>::on(int ev, HANDLER handler) {\n\n std::lock_guard<std::recursive_mutex> lock(m_mutex);\n\n auto map_it = m_map.find(ev);\n\n if (map_it == m_map.end()) {\n\n std::vector<NODE> list;\n\n auto em = m_map.emplace(ev, list);\n\n if (!em.second) return false;\n\n em.first->second.push_back({handler, true, false});\n\n } else {\n\n map_it->second.push_back({handler, true, false});\n\n } return true;\n\n}\n\ntemplate <class... ARG>\n\nbool Emitter<ARG...>::once(int ev, HANDLER handler) {\n\n std::lock_guard<std::recursive_mutex> lock(m_mutex);\n\n auto map_it = m_map.find(ev);\n\n if (map_it == m_map.end()) {\n", "file_path": "libcat/include/cat_data_emitter.h", "rank": 73, "score": 72388.8012854072 }, { "content": " void uniform(unsigned int slot, const glm::vec3* v, size_t count) const;\n\n void uniform(unsigned int slot, const glm::vec4* v, size_t count) const;\n\n void uniform(unsigned int slot, const glm::mat4* m, size_t count) const;\n\nprivate:\n\n GLuint compile(GLenum type, const std::string& code);\n\n std::string preprocessor(GLenum type, const std::string& code) const;\n\nprivate:\n\n GLuint m_program, m_vs, m_fs;\n\n GLint m_attr[64];\n\n GLint m_uniform[64];\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_GFX_SHADER_H__\n", "file_path": "libcat/include/cat_gfx_shader.h", "rank": 74, "score": 72387.79953214181 }, { "content": " for (auto it = m_queue.begin(); it != m_queue.end(); ++it) {\n\n if (tick < it->tick) {\n\n it->tick -= tick;\n\n m_queue.insert(it, NODE{ tick, handle, message });\n\n return true;\n\n } else {\n\n tick -= it->tick;\n\n }\n\n }\n\n }\n\n m_queue.push_back(NODE{ tick, handle, message });\n\n return true;\n\n}\n\n// -----------------------------------------------------------\n\ntemplate <class HANDLE, typename T>\n\nbool TimerQueue<HANDLE,T>::get(Timestamp tick, HANDLE* handle, T* msg) {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n auto node = m_queue.begin();\n\n\tif (node == m_queue.end()) return false;\n\n m_tick += tick;\n", "file_path": "libcat/include/cat_time_queue.h", "rank": 75, "score": 72387.66824670963 }, { "content": "private:\n\n struct SHADER_DATA {\n\n Shader* shader;\n\n std::unordered_map<int, std::string> uniforms, attrs;\n\n };\n\n bool reload_shader(SHADER_DATA* sd, const std::string& name);\n\n bool reload_tex (Texture* tex, const std::string& name);\n\n\n\nprivate:\n\n bool load_tex_png(Texture* tex, Buffer& buf);\n\n\n\nprivate:\n\n bool m_contextready;\n\n VFS* m_vfs;\n\n // map { name, pair { res, refcount} }\n\n std::unordered_map<std::string, std::pair<SHADER_DATA, int>> m_shaders;\n\n std::unordered_map<std::string, std::pair<Texture*, int>> m_texs;\n\n std::unordered_map<std::string, std::pair<Buffer*, int>> m_raws;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_STORAGE_RESMGR_H__\n", "file_path": "libcat/include/cat_storage_resmgr.h", "rank": 76, "score": 72387.26902378182 }, { "content": " unsigned int m_id;\n\n Rect2i m_rect, m_absrect;\n\n bool m_clipping;\n\n uint32_t m_bgcolor;\n\n float m_opacity, m_absopacity;\n\n bool m_enable, m_visible;\n\n std::vector<TextureRef> m_texrefs;\n\nprivate:\n\n // called from UISystem or internal signal propagate\n\n void context_lost();\n\n bool context_restored();\n\n void render(Renderer* r, Timestamp now);\n\n bool touch(const TouchEvent& ev, bool handled);\n\n void notify_uiscaled();\n\n void notify_pause(bool paused);\n\n void notify_visible(bool b);\n\n void notify_enable(bool b);\n\n\n\nprotected:\n\n KernelApi* kernel() const { return m_kernel; }\n", "file_path": "libcat/include/cat_ui_widget.h", "rank": 77, "score": 72387.2129847259 }, { "content": " void set_size(const Size2i& size);\n\n const Point2i& get_origin() const { return m_rect.origin; }\n\n const Size2i& get_size() const { return m_rect.size; }\n\n void bring_tofront();\n\n // ------------------------------------------------------------------ Size and Position\n\n\n\n // ------------------------------------------------------------------ Flags\n\n void set_visible(bool b);\n\n bool is_visible() const { return m_visible; }\n\n void set_enable(bool b);\n\n bool is_enabled() const { return m_enable; }\n\n void set_clipping(bool clipping);\n\n bool is_clipping() const { return m_clipping; }\n\n // ------------------------------------------------------------------ Flags\n\n\n\n // ------------------------------------------------------------------ Visual\n\n void set_bgcolor(uint32_t color);\n\n uint32_t get_bgcolor() const { return m_bgcolor; }\n\n void set_opacity(float opacity);\n\n float get_opacity() const { return m_opacity; }\n", "file_path": "libcat/include/cat_ui_widget.h", "rank": 78, "score": 72387.14337911557 }, { "content": "#if defined(PLATFORM_WIN32) || defined(PLATFORM_WIN64)\n\n HINTERNET m_internet;\n\n struct INET_PARAM {\n\n HttpManager* manager;\n\n HTTP_ID http_id;\n\n };\n\n static void CALLBACK cb_inet_status(HINTERNET handle, DWORD_PTR ud, DWORD status, LPVOID info, DWORD infolen);\n\n void cb_inet_status(HINTERNET handle, INET_PARAM* param, DWORD status, LPVOID info, DWORD infolen);\n\n#elif defined(PLATFORM_ANDROID)\n\n static const size_t RBUF_SIZE = 4096;\n\n#elif defined(PLATFORM_MAC) || defined(PLATFORM_IOS)\n\n // Nothing\n\n#else\n\n #error Not Implemented!\n\n#endif\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_NET_HTTP_H__\n", "file_path": "libcat/include/cat_net_http.h", "rank": 79, "score": 72386.608260557 }, { "content": "#ifndef __CAT_UTIL_LOG_H__\n\n#define __CAT_UTIL_LOG_H__\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n", "file_path": "libcat/include/cat_util_log.h", "rank": 80, "score": 72386.58156754496 }, { "content": "#ifndef __CAT_DATA_COPYABLE_H__\n\n#define __CAT_DATA_COPYABLE_H__\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\ntemplate <class T>\n", "file_path": "libcat/include/cat_data_copyable.h", "rank": 81, "score": 72386.44861328091 }, { "content": "#ifndef __CAT_UI_INTERPOLATOR_H__\n\n#define __CAT_UI_INTERPOLATOR_H__\n\n\n\nnamespace cat {\n\n// ----------------------------------------------------------------------------\n\n//! Animation Interpolator Interface\n", "file_path": "libcat/include/cat_ui_interpolator.h", "rank": 82, "score": 72386.38378463012 }, { "content": " //! \\param comparator a function return true if the timer should be removed\n\n void remove(std::function<bool(const HANDLE& handle, const T& data)> comparator);\n\n\n\nprivate:\n\n struct NODE {\n\n Timestamp tick;\n\n HANDLE handle;\n\n T message;\n\n };\n\n std::mutex m_mutex;\n\n std::list<NODE> m_queue;\n\n unsigned long m_tick;\n\n};\n\n// -----------------------------------------------------------\n\ntemplate <class HANDLE, typename T>\n\nbool TimerQueue<HANDLE,T>::post(Timestamp tick, const HANDLE& handle, const T& message) {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n if (m_queue.size() == 0) {\n\n m_tick = 0;\n\n } else {\n", "file_path": "libcat/include/cat_time_queue.h", "rank": 83, "score": 72386.3156428288 }, { "content": " if (m_tick >= node->tick) {\n\n m_tick -= node->tick;\n\n *handle = node->handle;\n\n *msg = node->message;\n\n m_queue.erase(node);\n\n return true;\n\n } return false;\n\n}\n\n// -----------------------------------------------------------\n\ntemplate <class HANDLE, typename T>\n\nvoid TimerQueue<HANDLE,T>::remove(const HANDLE& handle) {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n for (auto it = m_queue.begin(); it != m_queue.end();) {\n\n if (it->handle == handle) {\n\n it = m_queue.erase(it);\n\n } else {\n\n ++it;\n\n }\n\n }\n\n}\n", "file_path": "libcat/include/cat_time_queue.h", "rank": 84, "score": 72386.30110734177 }, { "content": " m_ids.release(subscribe_id);\n\n } else {\n\n ++it;\n\n }\n\n }\n\n}\n\n// ----------------------------------------------------------------------------\n\ntemplate <class T>\n\nvoid Observable<T>::notify() {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n for (auto& sub: m_subs) {\n\n sub.observer(m_data);\n\n }\n\n}\n\n// ----------------------------------------------------------------------------\n\ntemplate <class T>\n\ntemplate <class MAP>\n\ntypename Observable<T>::Canceller Observable<T>::distinct(std::function<MAP(const T& data)> mapper, Observer<MAP> observer) {\n\n MAP* mapped = new MAP();\n\n return subscribe(\n", "file_path": "libcat/include/cat_data_observable.h", "rank": 85, "score": 72386.11802604175 }, { "content": " //! Call java static method\n\n //! See java manual for detail: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/types.html\n\n //! \\param clazz java class handle obtained from FindClass\n\n //! \\param method method id obtained by GetMethodID\n\n //! \\param arg optioanl arguments\n\n //! \\return object return by the method\n\n //! \\sa FindClass, GetMethodID\n\n template <class... ARG>\n\n jobject CallStaticObjectMethod(jclass clazz, jmethodID method, ARG... arg) {\n\n return m_env->CallStaticObjectMethod(clazz, method, arg...);\n\n }\n\n // Field\n\n // ------------------------------------------------------------------------\n\n void SetIntField(jobject o, const char* field, jint v) {\n\n jclass jclazz = (jclass)m_env->GetObjectClass(o);\n\n m_env->SetIntField(o, m_env->GetFieldID(jclazz, field, \"I\"), v);\n\n }\n\nprivate:\n\n static JavaVM* s_vm;\n\n bool m_attached;\n\n JNIEnv* m_env;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // PLATFORM_ANDROID\n\n#endif // __CAT_PLATFORM_ANDROID_JNI_H__\n", "file_path": "libcat/include/cat_util_jni.h", "rank": 86, "score": 72386.11455136804 }, { "content": " Buffer& operator=(const std::string& o);\n\nprivate:\n\n uint8_t* m_buffer;\n\n size_t m_size, m_allocated;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_DATA_BUFFER_H__\n", "file_path": "libcat/include/cat_data_buffer.h", "rank": 87, "score": 72386.01891943434 }, { "content": " return true;\n\n}\n\n// ----------------------------------------------------------------------------\n\ntemplate <typename T>\n\nvoid UniqueId<T>::reset() {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n m_seed = m_limit_lo;\n\n m_list.clear();\n\n}\n\n// ----------------------------------------------------------------------------\n\ntemplate <typename T>\n\nT UniqueId<T>::fetch() {\n\n std::lock_guard<std::mutex> lock(m_mutex);\n\n if (!m_list.empty()) {\n\n auto id = m_list.front();\n\n m_list.pop_front();\n\n return id;\n\n }\n\n if (m_seed < m_limit_hi) {\n\n return m_seed++;\n", "file_path": "libcat/include/cat_data_uniqueid.h", "rank": 88, "score": 72385.88880872734 }, { "content": " rect_width, rect_height,\n\n glut_texImage2D;\n\n jobject bitmap, canvas, paint, rect;\n\n } m_jni; \n\n#else\n\n #error Not Implemented!\n\n#endif\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_GFX_DRAWABLECANVAS_H__\n", "file_path": "libcat/include/cat_gfx_drawablecanvas.h", "rank": 89, "score": 72385.54916872477 }, { "content": " std::unordered_multimap<std::string, TextEntry> m_texts;\n\n Drawable m_drawable[kTextTextureMax];\n\n struct {\n\n int plane, x, y, height;\n\n } m_textcursor;\n\n\n\n float convert_y(int h) const;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_GFX_DRAW2D_H__\n", "file_path": "libcat/include/cat_gfx_draw2d.h", "rank": 90, "score": 72385.30382611163 }, { "content": " void set_texture(unsigned int index, const std::string& name, int u0, int v0, int u1, int v1, int border_u = 0, int border_v = 0);\n\n void set_texture(unsigned int index, const char* name, int u0, int v0, int u1, int v1, int border_u = 0, int border_v = 0);\n\n // ------------------------------------------------------------------ Visual\n\n\n\n // ------------------------------------------------------------------ Actions\n\n bool perform_click();\n\n // ------------------------------------------------------------------ Actions\n\n\n\n // ------------------------------------------------------------------ Parent & Child\n\n Widget* parent() { return m_parent; }\n\n bool attach(Widget* child);\n\n void detach(Widget* child);\n\n void remove_childs();\n\n Widget* child_at(unsigned int index) const;\n\n Widget* child_withid(unsigned int id) const;\n\n // ------------------------------------------------------------------ Parent & Child\n\n\n\nprotected:\n\n virtual void cb_move() {}\n\n virtual void cb_resize() {}\n", "file_path": "libcat/include/cat_ui_widget.h", "rank": 91, "score": 72385.1589186552 }, { "content": " static const int MAX_STREAM = 32;\n\n const PlatformSpecificData* m_psd;\n\n std::unordered_map<std::string, std::pair<SoundEffect*, int>> m_sounds;\n\n#if defined(PLATFORM_ANDROID)\n\n jobject m_soundpool;\n\n#endif\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_SOUND_EFFECTS_H__\n", "file_path": "libcat/include/cat_sound_effects.h", "rank": 92, "score": 72385.07327974931 }, { "content": " virtual VFS* vfs() = 0;\n\n virtual Renderer* renderer() = 0;\n\n virtual ResourceManager* res() = 0;\n\n virtual TimeService* time() = 0;\n\n virtual NetService* net() = 0;\n\n virtual SoundService* sound() = 0;\n\n virtual UIService* ui() = 0;\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat\n\n\n\n#endif // __CAT_KERNEL_API_H__\n", "file_path": "libcat/include/cat_kernel_api.h", "rank": 93, "score": 72384.96312506417 }, { "content": " void remove_timer(TimerDelegate<int>* handler);\n\n //! Remove timer assocated with the handler and with the message\n\n //! Any timer not fired yet will be discarded\n\n //! \\param handler Callback handler when timer expire\n\n //! \\param message user-defined message to pass to handler\n\n void remove_timer(TimerDelegate<int>* handler, int message);\n\n\n\n //! Post a timer to time service's queue\n\n //! The handler will be invoked from main thread upon tick time has reached\n\n //! \\param handler Callback handler when timer expire\n\n //! \\param tick How long for time timer, in milliseconds\n\n //! \\return true if success, false if failed and no side-effect\n\n bool post_timer(TimerFunction handler, Timestamp tick);\n\n //! Remove timer assocated with the handler\n\n //! Any timer not fired yet will be discarded\n\n //! \\param handler Callback handler when timer expire\n\n void remove_timer(TimerFunction handler);\n\n\n\nprivate:\n\n //! Initialize service\n", "file_path": "libcat/include/cat_time_service.h", "rank": 94, "score": 72384.95209524238 }, { "content": " int fontsize;\n\n uint32_t color;\n\n unsigned int padding_x, padding_y;\n\n\n\n TextStyle() {\n\n appearance = TextStyle::Appearance::Normal;\n\n gravity = TextStyle::Gravity::Left | TextStyle::Gravity::Top;\n\n fontsize = 12;\n\n color = 0xffffffff;\n\n padding_x = padding_y = 0;\n\n }\n\n};\n\n// ----------------------------------------------------------------------------\n\n} // namespace cat::gfx\n\n\n\n#endif // __CAT_GFX_TYPE_H__\n", "file_path": "libcat/include/cat_gfx_type.h", "rank": 95, "score": 72384.75228613474 }, { "content": " }\n\n //! Release a global reference\n\n //! \\param o an global reference obtained from NewGlobalRef\n\n //! \\sa NewGlobalRef\n\n void DeleteGlobalRef(jobject o) {\n\n if (o) m_env->DeleteGlobalRef(o);\n\n }\n\n // String\n\n // ------------------------------------------------------------------------\n\n //! Create a java compatible string (java.lang.String)\n\n //! \\param utf8 utf8 null-terminated string\n\n //! \\return java string object\n\n jstring NewStringUTF(const char* utf8) {\n\n return m_env->NewStringUTF(utf8);\n\n }\n\n //! Create a java compatible string (java.lang.String)\n\n //! \\param utf8 utf8 string\n\n //! \\return java string object\n\n jstring NewStringUTF(const std::string& utf8) {\n\n return m_env->NewStringUTF(utf8.c_str());\n", "file_path": "libcat/include/cat_util_jni.h", "rank": 96, "score": 72384.58589763426 }, { "content": " bool render_text();\n\n void clipping_update();\n\n\n\nprivate:\n\n Shader* m_shaders[Effect::Thermo + 1];\n\n VBO m_vbo;\n\n int\t\tm_width, m_height, m_scaled_height;\n\n float m_scale;\n\n std::vector<Rect2i> m_clipping;\n\n // render target\n\n FBO m_fbo;\n\n Texture* m_render_target;\n\n\n\n // uniform values\n\n struct {\n\n glm::vec2 center_multiplier;\n\n struct {\n\n bool enabled;\n\n GLint x, y;\n\n GLsizei w, h;\n", "file_path": "libcat/include/cat_gfx_draw2d.h", "rank": 97, "score": 72384.2978123781 }, { "content": " HttpConnection();\n\n HttpConnection(HttpConnection&& o);\n\n ~HttpConnection();\n\n };\n\nprivate:\n\n const Timestamp HTTPID_REUSE_TIMEOUT = 5000;\n\n const int POLL_INTERVAL = 100;\n\n std::atomic<bool> m_thread_started;\n\n std::thread* m_thread;\n\n std::mutex m_added_mutex, m_working_mutex, m_completed_mutex;\n\n std::condition_variable m_condvar;\n\n std::list<HttpConnection> m_added, m_working, m_completed;\n\n UniqueId<HTTP_ID,Timestamp> m_unique;\n\n bool m_worker_running;\n\n\n\n void worker_thread();\n\n bool cb_conn_created(HttpConnection* conn);\n\n bool cb_conn_cancelled(HttpConnection* conn);\n\n bool cb_conn_progress(HttpConnection* conn);\n\n\n", "file_path": "libcat/include/cat_net_http.h", "rank": 98, "score": 72384.26066503637 }, { "content": " void fill(const Rect2i& rect, uint32_t color, const Texture* tex, unsigned long t, const Shader* shader);\n\n void fill(const Rect2i& rect, uint32_t color, const TextureRef& texref, unsigned long t, const Shader* shader);\n\n // Text support\n\n void calctext(Size2i* size, const std::string& utf8, const TextStyle& style);\n\n void drawtext(const Rect2i& rect, const std::string& utf8, const TextStyle& style, float opacity = 1.0f);\n\n // clipping\n\n void clipping_push(const Rect2i& rect);\n\n void clipping_pop();\n\n // render to texture\n\n void target(Texture* tex);\n\n // Load compatible shader\n\n const Shader* retain_2dshader(ResourceManager* res, const std::string& name);\n\n void release_2dshader(ResourceManager* res, const Shader* shader);\n\n\n\nprivate:\n\n Draw2D(Renderer* r);\n\n ~Draw2D();\n\n bool init();\n\n void fini();\n\n void resize(int width, int height);\n", "file_path": "libcat/include/cat_gfx_draw2d.h", "rank": 99, "score": 72384.25842307937 } ]
C++
examples/classes/slider/sliderx.cpp
pierrebestwork/owl642
3f4aa9ec0febc52acd3523f0b6ba063d5e388365
#include <owl/applicat.h> #include <owl/framewin.h> #include <owl/slider.h> #include <owl/gauge.h> #include <owl/static.h> using namespace owl; class TMainWindow : public TWindow { public: TMainWindow(); protected: virtual void SetupWindow(); void EvTimer(uint timerId); private: enum { IDC_THERMOSTAT = 201, IDC_HEATERTIME, IDC_OUTSIDETEMP, IDC_STATICTEMP, IDC_STATICTIME, IDC_STATICOTEMP, IDC_THERMOMETER, }; enum {IDT_REFRESH = 1}; double Temp; bool IsHeaterOn; TStatic TempStatic; TGauge ThermometerGauge; THSlider ThermostatSlider; TStatic HysteresisStatic; TVSlider HysteresisSlider; TStatic OutsideTempStatic; TVSlider OutsideTempSlider; void UpdateTemp(); void UpdateHysteresis(uint = 0); void UpdateOutsideTemp(uint = 0); void SimulateHeater(); DECLARE_RESPONSE_TABLE(TMainWindow); }; DEFINE_RESPONSE_TABLE1(TMainWindow, TWindow) EV_WM_TIMER, EV_CHILD_NOTIFY_ALL_CODES(IDC_HEATERTIME, UpdateHysteresis), EV_CHILD_NOTIFY_ALL_CODES(IDC_OUTSIDETEMP, UpdateOutsideTemp), END_RESPONSE_TABLE; TMainWindow::TMainWindow() : TWindow(0, 0, 0), Temp(40.0), IsHeaterOn(false), TempStatic(this, IDC_STATICTEMP, "", 110, 30, 160, 17, 0), ThermometerGauge(this, "%d\xB0", IDC_THERMOMETER, 70, 70, 240, 24, true, 2), ThermostatSlider(this, IDC_THERMOSTAT, 70, 110, 240, 40), HysteresisStatic(this, IDC_STATICTIME, "", 4, 10, 160, 17, 0), HysteresisSlider(this, IDC_HEATERTIME, 20, 30, 32, 160), OutsideTempStatic(this, IDC_STATICOTEMP, "", 216, 10, 160, 17, 0), OutsideTempSlider(this, IDC_OUTSIDETEMP, 330, 30, 32, 160) { MoveWindow(0, 0, 380, 200); SetBkgndColor(TColor::Sys3dFace); TempStatic.ModifyStyle(0, SS_CENTER); ThermostatSlider.ModifyStyle(0, TBS_AUTOTICKS); HysteresisStatic.ModifyStyle(0, SS_LEFT); HysteresisSlider.ModifyStyle(0, TBS_AUTOTICKS); OutsideTempStatic.ModifyStyle(0, SS_RIGHT); OutsideTempSlider.ModifyStyle(0, TBS_AUTOTICKS); } void TMainWindow::SetupWindow() { TWindow::SetupWindow(); ThermometerGauge.SetRange(40, 120); ThermometerGauge.SetValue(80); ThermostatSlider.SetRange(40, 120); ThermostatSlider.SetRuler(10, false); ThermostatSlider.SetPosition(80); HysteresisSlider.SetRange(0, 10); HysteresisSlider.SetRuler(5, false); HysteresisSlider.SetPosition(5); OutsideTempSlider.SetRange(20, 90); OutsideTempSlider.SetRuler(10, false); OutsideTempSlider.SetPosition(40); SetTimer(IDT_REFRESH, 1000); UpdateTemp(); UpdateHysteresis(); UpdateOutsideTemp(); } void TMainWindow::EvTimer(uint ) { SimulateHeater(); UpdateTemp(); } void TMainWindow::UpdateTemp() { std::ostringstream s; s << "Heater is " << (IsHeaterOn ? "on" : "off"); TempStatic.SetText(s.str()); ThermometerGauge.SetValue(static_cast<int>(Temp + 0.5)); } void TMainWindow::UpdateHysteresis(uint) { std::ostringstream s; s << HysteresisSlider.GetPosition() << "\xB0 hysteresis"; HysteresisStatic.SetText(s.str()); } void TMainWindow::UpdateOutsideTemp(uint) { std::ostringstream s; s << OutsideTempSlider.GetPosition() << "\xB0 outside"; OutsideTempStatic.SetText(s.str()); } void TMainWindow::SimulateHeater() { Temp += (IsHeaterOn ? 2.0 : 0.0) + (OutsideTempSlider.GetPosition() - Temp) / 40.0; int tempSetting = ThermostatSlider.GetPosition(); int hysteresis = HysteresisSlider.GetPosition(); double lowTriggerTemp = tempSetting - hysteresis; double highTriggerTemp = tempSetting + hysteresis; if (!IsHeaterOn && Temp <= lowTriggerTemp) IsHeaterOn = true; else if (IsHeaterOn && Temp >= highTriggerTemp) IsHeaterOn = false; } class THomeHeaterSimulator : public TApplication { public: THomeHeaterSimulator() : TApplication("Home Heater Simulator") {} protected: virtual void InitMainWindow() { TFrameWindow* frame = new TFrameWindow(0, GetName(), new TMainWindow, true); frame->ModifyStyle(WS_SIZEBOX | WS_MAXIMIZEBOX, 0); frame->EnableKBHandler(); SetMainWindow(frame); } }; int OwlMain(int, char* []) { THomeHeaterSimulator app; return app.Run(); }
#include <owl/applicat.h> #include <owl/framewin.h> #include <owl/slider.h> #include <owl/gauge.h> #include <owl/static.h> using namespace owl; class TMainWindow : public TWindow { public: TMainWindow(); protected: virtual void SetupWindow(); void EvTimer(uint timerId); private: enum { IDC_THERMOSTAT = 201, IDC_HEATERTIME, IDC_OUTSIDETEMP, IDC_STATICTEMP, IDC_STATICTIME, IDC_STATICOTEMP, IDC_THERMOMETER, }; enum {IDT_REFRESH = 1}; double Temp; bool IsHeaterOn; TStatic TempStatic; TGauge ThermometerGauge; THSlider ThermostatSlider; TStatic HysteresisStatic; TVSlider HysteresisSlider; TStatic OutsideTempStatic; TVSlider OutsideTempSlider; void UpdateTemp(); void UpdateHysteresis(uint = 0); void UpdateOutsideTemp(uint = 0); void SimulateHeater(); DECLARE_RESPONSE_TABLE(TMainWindow); }; DEFINE_RESPONSE_TABLE1(TMainWindow, TWindow) EV_WM_TIMER, EV_CHILD_NOTIFY_ALL_CODES(IDC_HEATERTIME, UpdateHysteresis), EV_CHILD_NOTIFY_ALL_CODES(IDC_OUTSIDETEMP, UpdateOutsideTemp), END_RESPONSE_TABLE; TMainWindow::TMainWindow() : TWindow(0, 0, 0), Temp(40.0), IsHeaterOn(false), TempStatic(this, IDC_STATICTEMP, "", 110, 30, 160, 17, 0), ThermometerGauge(this, "%d\xB0", IDC_THERMOMETER, 70, 70, 240, 24, true, 2), ThermostatSlider(this, IDC_THERMOSTAT, 70, 110, 240, 40), HysteresisStatic(this, IDC_STATICTIME, "", 4, 10, 160, 17, 0), HysteresisSlider(this, IDC_HEATERTIME, 20, 30, 32, 160), OutsideTempStatic(this, IDC_STATICOTEMP, "", 216, 10, 160, 17, 0), OutsideTempSlider(this, IDC_OUTSIDETEMP, 330, 30, 32, 160) { MoveWindow(0, 0, 380, 200); SetBkgndColor(TColor::Sys3dFace); TempStatic.ModifyStyle(0, SS_CENTER); ThermostatSlider.ModifyStyle(0, TBS_AUTOTICKS); HysteresisStatic.ModifyStyle(0, SS_LEFT); HysteresisSlider.ModifyStyle(0, TBS_AUTOTICKS); OutsideTempStatic.ModifyStyle(0, SS_RIGHT); OutsideTempSlider.ModifyStyle(0, TBS_AUTOTICKS); } void TMainWindow::SetupWindow() { TWindow::SetupWindow(); ThermometerGauge.SetRange(40, 120); ThermometerGauge.SetValue(80); ThermostatSlider.SetRange(40, 120); ThermostatSlider.SetRuler(10, false); ThermostatSlider.SetPosition(80); HysteresisSlider.SetRange(0, 10); HysteresisSlider.SetRuler(5, false); HysteresisSlider.SetPosition(5); OutsideTempSlider.SetRange(20, 90); OutsideTempSlider.SetRuler(10, false); OutsideTempSlider.SetPosition(40); SetTimer(IDT_REFRESH, 1000); UpdateTemp(); UpdateHysteresis(); UpdateOutsideTemp(); } void TMainWindow::EvTimer(uint ) { SimulateHeater(); UpdateTemp(); } void TMainWindow::UpdateTemp() { std::ostringstream s; s << "Heater is " << (IsHeaterOn ? "on" : "off"); TempStatic.SetText(s.str()); ThermometerGauge.SetValue(static_cast<int>(Temp + 0.5)); } void TMainWindow::UpdateHysteresis(uint) { std::ostringstream s; s << HysteresisSlider.GetPosition() << "\xB0 hysteresis"; HysteresisStatic.SetText(s.str()); } void TMainWindow::UpdateOutsideTemp(uint) { std::ostringstream s; s << OutsideTempSlider.GetPosition() << "\xB0 outside"; OutsideTempStatic.SetText(s.str()); } void TMainWindow::SimulateHeater() { Temp += (IsHeaterOn ? 2.0 : 0.0) + (OutsideTempSlider.GetPosition() - Temp) / 40.0; int tempSetting = ThermostatSlider.GetPosition(); int hysteresis = HysteresisSlider.GetPosition(); double lowTriggerTemp = tempSetting - hysteresis; double highTriggerTemp = tempSetting + hysteresis;
} class THomeHeaterSimulator : public TApplication { public: THomeHeaterSimulator() : TApplication("Home Heater Simulator") {} protected: virtual void InitMainWindow() { TFrameWindow* frame = new TFrameWindow(0, GetName(), new TMainWindow, true); frame->ModifyStyle(WS_SIZEBOX | WS_MAXIMIZEBOX, 0); frame->EnableKBHandler(); SetMainWindow(frame); } }; int OwlMain(int, char* []) { THomeHeaterSimulator app; return app.Run(); }
if (!IsHeaterOn && Temp <= lowTriggerTemp) IsHeaterOn = true; else if (IsHeaterOn && Temp >= highTriggerTemp) IsHeaterOn = false;
if_condition
[ { "content": "//----------------------------------------------------------------------------\n\nclass OWLEXTCLASS TNotebook : public virtual owl::TWindow {\n\n public:\n\n //--- redefined functions ---\n\n TNotebook(int tabloc = 0);\n\n ~TNotebook();\n\n void SetTabCnt(int tabcnt, int firsttab = 0, int activetab = 0);\n\n\n\n int GetScrollPos(int bar);\n\n void GetScrollRange(int bar, int& low, int& high);\n\n int SetScrollPos(int bar, int pos, bool redraw = true);\n\n void SetScrollRange(int bar, int minPos, int maxPos, bool redraw = true);\n\n\n\n protected:\n\n owl::TRect nbcrect; // current rect for notebook control area\n\n owl::TRect vsbrect; // rect for vertical scroll bar\n\n owl::TRect hsbrect; // rect for horizontal scroll bar\n\n owl::TRect tsbrect; // rect for tabs scroll bar\n\n owl::TRect tabsrect; // rect for set of tabs\n\n owl::TRect clientrect; // size of client area after our controls\n\n owl::TRect clientprev; // to detect window size changes\n", "file_path": "include/owlext/notebook.h", "rank": 0, "score": 407334.3646340945 }, { "content": "//\n\n/// \\class TOleWindow\n\n// ~~~~~ ~~~~~~~~~~\n\n/// The generic OLE2 window. Use as a client of a frame window.\n\n//\n\n/// Derived from TWindow, TOleWindow provides support for embedding objects in a\n\n/// compound document and serves as the client of a frame window. A compound\n\n/// document, such as the one TOleWindow supports, can contain many different types\n\n/// of embedded objects, from spreadsheets to bitmaps. In addition to providing\n\n/// support for a variety of basic window operations, TOleWindow also implements\n\n/// several OLE-related operations, among them\n\n/// - Responding to drag and drop events\n\n/// - In-place editing (the process whereby an embedded object can be\n\n/// edited without having to switch to its associated server application)\n\n/// - Activating an embedded object's server application\n\n/// - Creating views for the container application\n\n/// - Transmitting a document's scaling information between a\n\n/// container's and a server's view windows\n\n///\n\n/// TOleWindow has the ability to determine whether it's acting as a server or a\n\n/// container. If it is a container, TOleWindow has a pointer to a TOcView or if it\n\n/// is a server, TOleWindow establishes a pointer to a TOcRemView. From the\n\n/// server's point of view, every remote view has a corresponding TOleWindow.\n\n///\n\n/// Through its many event-handling member functions, TOleWindow communicates with\n\n/// ObjectComponents to implement container and server support for embedded objects,\n\n/// update views, and respond to a variety of menu commands associated with the\n\n/// typical command identifiers (for example, CM_FILEMENU). It also supports\n\n/// OLE-specific verbs such as those activated from the Edit menu (for example, Edit\n\n/// and Open). These commands and verbs can originate from various sources such as a\n\n/// menu selection, a radio button, or even an internal program message.\n\n///\n\n/// Conversely, ObjectComponents talks to ObjectWindows by means of the various\n\n/// EV_OC_Xxxx messages. Some of these messages, such as EV_OC_VIEWPARTINVALID,\n\n/// implement container support while others, such as EV_OC_VIEWCLOSE, implement\n\n/// server support.\n\n///\n\n/// For any user-defined classes derived from TOleWindow, you need to choose which\n\n/// functions are appropriate. If you want to provide additional server support, you\n\n/// need to define only those functions that implement server messages; if you want\n\n/// to provide container support, you need to define only those functions that\n\n/// provide additional container support.\n\n///\n\n/// For example, the data embedded in the container application (a compound document\n\n/// having one or more embedded objects) and the data embedded in the server\n\n/// application (a single OLE object with or without other embedded objects) can be\n\n/// written to storage and loaded from storage. If you're using TOleWindow without\n\n/// TOleView, you have to manipulate the storage by talking directly to the\n\n/// ObjectComponents class, TOcDocument.\n\n///\n\n/// In addition to communicating with ObjectComponents classes, TOleWindow supports\n\n/// many transactions as a result of its interaction with other ObjectWindows\n\n/// classes. By virtue of its derivation from TWindow, naturally it inherits much of\n\n/// TWindow's functionality.\n\nclass _OCFCLASS TOleWindow : virtual public owl::TWindow {\n\n public:\n\n TOleWindow(owl::TWindow* parent = 0, owl::TModule* module = 0);\n\n ~TOleWindow();\n\n\n\n // Accessors\n\n //\n\n TOcDocument* GetOcDoc();\n\n TOcView* GetOcView();\n\n TOcRemView* GetOcRemView();\n\n TOcApp* GetOcApp();\n\n bool HasActivePart();\n\n bool SelectEmbedded();\n\n\n\n /// \\name Query about current state\n\n /// @{\n\n bool IsOpenEditing() const;\n\n bool IsRemote() const;\n\n /// @}\n\n\n", "file_path": "include/ocf/olewindo.h", "rank": 1, "score": 400074.44328590285 }, { "content": "//----------------------------------------------------------------------------\n\nclass OWLEXTCLASS TNotebook : public virtual owl::TWindow {\n\n public:\n\n //--- redefined functions ---\n\n TNotebook(int tabloc = 0);\n\n ~TNotebook();\n\n void SetTabCnt(int tabcnt, int firsttab = 0, int activetab = 0);\n\n\n\n int GetScrollPos(int bar);\n\n void GetScrollRange(int bar, int& low, int& high);\n\n int SetScrollPos(int bar, int pos, bool redraw = true);\n\n void SetScrollRange(int bar, int minPos, int maxPos, bool redraw = true);\n\n\n\n protected:\n\n owl::TRect nbcrect; // current rect for notebook control area\n\n owl::TRect vsbrect; // rect for vertical scroll bar\n\n owl::TRect hsbrect; // rect for horizontal scroll bar\n\n owl::TRect tsbrect; // rect for tabs scroll bar\n\n owl::TRect tabsrect; // rect for set of tabs\n\n owl::TRect clientrect; // size of client area after our controls\n\n owl::TRect clientprev; // to detect window size changes\n", "file_path": "include_xp/owlext/notebook.h", "rank": 2, "score": 400066.5735165527 }, { "content": "//\n\n/// \\class TOleWindow\n\n// ~~~~~ ~~~~~~~~~~\n\n/// The generic OLE2 window. Use as a client of a frame window.\n\n//\n\n/// Derived from TWindow, TOleWindow provides support for embedding objects in a\n\n/// compound document and serves as the client of a frame window. A compound\n\n/// document, such as the one TOleWindow supports, can contain many different types\n\n/// of embedded objects, from spreadsheets to bitmaps. In addition to providing\n\n/// support for a variety of basic window operations, TOleWindow also implements\n\n/// several OLE-related operations, among them\n\n/// - Responding to drag and drop events\n\n/// - In-place editing (the process whereby an embedded object can be\n\n/// edited without having to switch to its associated server application)\n\n/// - Activating an embedded object's server application\n\n/// - Creating views for the container application\n\n/// - Transmitting a document's scaling information between a\n\n/// container's and a server's view windows\n\n///\n\n/// TOleWindow has the ability to determine whether it's acting as a server or a\n\n/// container. If it is a container, TOleWindow has a pointer to a TOcView or if it\n\n/// is a server, TOleWindow establishes a pointer to a TOcRemView. From the\n\n/// server's point of view, every remote view has a corresponding TOleWindow.\n\n///\n\n/// Through its many event-handling member functions, TOleWindow communicates with\n\n/// ObjectComponents to implement container and server support for embedded objects,\n\n/// update views, and respond to a variety of menu commands associated with the\n\n/// typical command identifiers (for example, CM_FILEMENU). It also supports\n\n/// OLE-specific verbs such as those activated from the Edit menu (for example, Edit\n\n/// and Open). These commands and verbs can originate from various sources such as a\n\n/// menu selection, a radio button, or even an internal program message.\n\n///\n\n/// Conversely, ObjectComponents talks to ObjectWindows by means of the various\n\n/// EV_OC_Xxxx messages. Some of these messages, such as EV_OC_VIEWPARTINVALID,\n\n/// implement container support while others, such as EV_OC_VIEWCLOSE, implement\n\n/// server support.\n\n///\n\n/// For any user-defined classes derived from TOleWindow, you need to choose which\n\n/// functions are appropriate. If you want to provide additional server support, you\n\n/// need to define only those functions that implement server messages; if you want\n\n/// to provide container support, you need to define only those functions that\n\n/// provide additional container support.\n\n///\n\n/// For example, the data embedded in the container application (a compound document\n\n/// having one or more embedded objects) and the data embedded in the server\n\n/// application (a single OLE object with or without other embedded objects) can be\n\n/// written to storage and loaded from storage. If you're using TOleWindow without\n\n/// TOleView, you have to manipulate the storage by talking directly to the\n\n/// ObjectComponents class, TOcDocument.\n\n///\n\n/// In addition to communicating with ObjectComponents classes, TOleWindow supports\n\n/// many transactions as a result of its interaction with other ObjectWindows\n\n/// classes. By virtue of its derivation from TWindow, naturally it inherits much of\n\n/// TWindow's functionality.\n\nclass _OCFCLASS TOleWindow : virtual public owl::TWindow {\n\n public:\n\n TOleWindow(owl::TWindow* parent = 0, owl::TModule* module = 0);\n\n ~TOleWindow();\n\n\n\n // Accessors\n\n //\n\n TOcDocument* GetOcDoc();\n\n TOcView* GetOcView();\n\n TOcRemView* GetOcRemView();\n\n TOcApp* GetOcApp();\n\n bool HasActivePart();\n\n bool SelectEmbedded();\n\n\n\n /// \\name Query about current state\n\n /// @{\n\n bool IsOpenEditing() const;\n\n bool IsRemote() const;\n\n /// @}\n\n\n", "file_path": "include_xp/ocf/olewindo.h", "rank": 3, "score": 393267.0868690066 }, { "content": "/// \\addtogroup ctrl\n\n/// @{\n\n//\n\n//\n\n/// \\class TControl\n\n// ~~~~~ ~~~~~~~~\n\n/// TControl unifies its derived control classes, such as TScrollBar,\n\n/// TControlGadget, and TButton. Control objects of derived classes are used to\n\n/// represent control interface elements. A control object must be used to create a\n\n/// control in a parent TWindow object or a derived window. A control object can be\n\n/// used to facilitate communication between your application and the controls of a\n\n/// TDialog object. TControl is a streamable class.\n\n//\n\nclass _OWLCLASS TControl : virtual public TWindow {\n\n public:\n\n TControl(TWindow* parent,\n\n int id,\n\n LPCTSTR title,\n\n int x, int y, int w, int h,\n\n TModule* module = 0);\n\n\n\n TControl(TWindow* parent,\n\n int id,\n\n const tstring& title,\n\n int x, int y, int w, int h,\n\n TModule* module = 0);\n\n\n\n TControl(TWindow* parent, int resourceId, TModule* module = 0);\n\n TControl(TWindow* parent, int resourceId, const tstring& title, TModule* = 0);\n\n ~TControl();\n\n\n\n protected:\n\n\n", "file_path": "include/owl/control.h", "rank": 4, "score": 385706.69759973907 }, { "content": "//\n\n/// \\class TMDIClient\n\n// ~~~~~ ~~~~~~~~~~\n\n/// Multiple Document Interface (MDI) client windows (represented by a TMDIClient\n\n/// object) manage the MDI child windows of a TMDIFrame parent. TMDIClient is a\n\n/// streamable class.\n\nclass _OWLCLASS TMDIClient : public virtual TWindow {\n\n public:\n\n TMDIClient(TModule* module = 0);\n\n ~TMDIClient();\n\n\n\n virtual bool CloseChildren();\n\n TMDIChild* GetActiveMDIChild();\n\n\n\n // Member functions to arrange the MDI children\n\n //\n\n virtual void ArrangeIcons();\n\n virtual void CascadeChildren();\n\n virtual void TileChildren(int tile = MDITILE_VERTICAL);\n\n\n\n // Override member functions defined by TWindow\n\n //\n\n bool PreProcessMsg(MSG& msg);\n\n bool Create();\n\n\n\n /// \\name Child factory functions\n", "file_path": "include/owl/mdi.h", "rank": 5, "score": 385699.2688526326 }, { "content": "//\n\n/// \\class TDialog\n\n// ~~~~~ ~~~~~~~\n\nclass _OWLCLASS TDialog : virtual public TWindow {\n\n public:\n\n // standard constructor\n\n TDialog(TWindow* parent, TResId resId, TModule* module = 0);\n\n // construct from pointer to template\n\n explicit TDialog(TWindow* parent, const DLGTEMPLATE& dlgTemplate, TAutoDelete = AutoDelete, TModule* module = 0);\n\n // Not usual,to avoid ambiquaity, construct from handle to template\n\n explicit TDialog(HGLOBAL hTemplate, TWindow* parent, TAutoDelete = AutoDelete, TModule* module=0);\n\n\n\n ~TDialog();\n\n\n\n //\n\n /// Override this to process messages within the dialog function.\n\n /// For most messages, 1 should be returned if the message is handled, and 0 if it is not.\n\n /// Some special messages require a message-specific return value other than this:\n\n /// WM_CHARTOITEM, WM_COMPAREITEM, WM_CTL*, WM_INITDIALOG, WM_QUERYDRAGICON and WM_VKEYTOITEM.\n\n /// See the Windows API documentation for details.\n\n //\n\n virtual INT_PTR DialogFunction(TMsgId, TParam1, TParam2);\n\n\n", "file_path": "include/owl/dialog.h", "rank": 6, "score": 385699.1461937049 }, { "content": "/// \\addtogroup mixin\n\n/// @{\n\n//\n\n/// \\class TTinyCaption\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Derived from TWindow, TTinyCaption is a mix-in class that handles a set of\n\n/// non-client events to produce a smaller caption bar for a window. Whenever it\n\n/// displays the caption bar, TTinyCaption checks the window style and handles the\n\n/// WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX display attributes. Thus, you can use\n\n/// TTinyCaption to set the attributes of the tiny caption bar before enabling the\n\n/// caption. For example,\n\n/// \\code\n\n/// Attr.Style = WS_POPUP | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX |\n\n/// WS_MAXIMIZEBOX;\n\n/// \\endcode\n\n/// TTinyCaption provides functions that let you manipulate frame types, border\n\n/// styles, and menus. You can adjust the height of the caption bar or accept the\n\n/// default height, which is about one-half the height of a standard caption bar. If\n\n/// you set CloseBox to true, then the window will close when you click the close\n\n/// box instead of displaying the system menu.\n\n/// The sample program OWLCMD.CPP on BC5.02 distribution disk displays the following\n\n/// tiny caption bar:\n\n/// \\image html bm263.BMP\n\n///\n\n/// If you are using TTinyCaption as a mix-in class that does partial event\n\n/// handling, call the DoXxxx function in the mix-in class (instead of the EvXxxx\n\n/// function) to avoid duplicating default processing. The following example from\n\n/// OWLCMD.CPP (a sample program on your distribution disk) illustrates this\n\n/// process:\n\n/// \\code\n\n/// void TMyFrame::EvSysCommand(uint cmdType,TPoint& p)\n\n/// {\n\n/// if (TTinyCaption::DoSysCommand(cmdType, p) == esPartial)\n\n/// FrameWindow::EvSysCommand(cmdType, p);\n\n/// \\endcode\n\n/// The TFLoatingFrame class can be used with TTinyCaption to produce a close box.\n\n/// See the sample programs OWLCMD.CPP and MDIFILE.CPP on BC5.0x distribution disk for\n\n/// examples of how to use TTinyCaption.\n\n//\n\nclass _OWLCLASS TTinyCaption : public virtual TWindow {\n\n protected:\n\n TTinyCaption();\n\n ~TTinyCaption();\n\n\n\n /// Pass closeBox=true to replace SystemMenu box with a box that will\n\n /// close window when clicked\n\n /// Used for floating palettes, etc.\n\n //\n\n void EnableTinyCaption(int ch=0, bool closeBox=false);\n\n\n\n // Controller class must handle events that call these mixin handlers\n\n //\n\n TEventStatus DoNCHitTest(const TPoint& screenPt, uint& evRes);\n\n TEventStatus DoNCPaint();\n\n TEventStatus DoNCCalcSize(bool calcValidRects,\n\n NCCALCSIZE_PARAMS & calcSize, uint& evRes);\n\n TEventStatus DoNCLButtonDown(uint hitTest, const TPoint& screenPt);\n\n TEventStatus DoMouseMove(uint hitTest, const TPoint& screenPt);\n\n TEventStatus DoLButtonUp(uint hitTest, const TPoint& screenPt);\n", "file_path": "include/owl/tinycapt.h", "rank": 7, "score": 377930.84013892873 }, { "content": "/// \\addtogroup ctrl\n\n/// @{\n\n//\n\n//\n\n/// \\class TControl\n\n// ~~~~~ ~~~~~~~~\n\n/// TControl unifies its derived control classes, such as TScrollBar,\n\n/// TControlGadget, and TButton. Control objects of derived classes are used to\n\n/// represent control interface elements. A control object must be used to create a\n\n/// control in a parent TWindow object or a derived window. A control object can be\n\n/// used to facilitate communication between your application and the controls of a\n\n/// TDialog object. TControl is a streamable class.\n\n//\n\nclass _OWLCLASS TControl : virtual public TWindow {\n\n public:\n\n TControl(TWindow* parent,\n\n int id,\n\n LPCTSTR title,\n\n int x, int y, int w, int h,\n\n TModule* module = 0);\n\n\n\n TControl(TWindow* parent,\n\n int id,\n\n const tstring& title,\n\n int x, int y, int w, int h,\n\n TModule* module = 0);\n\n\n\n TControl(TWindow* parent, int resourceId, TModule* module = 0);\n\n TControl(TWindow* parent, int resourceId, const tstring& title, TModule* = 0);\n\n ~TControl();\n\n\n\n protected:\n\n\n", "file_path": "include_xp/owl/control.h", "rank": 8, "score": 377930.1224662765 }, { "content": "//\n\n/// \\class TLayoutWindow\n\n// ~~~~~ ~~~~~~~~~~~~~\n\n/// Derived from TWindow, TLayoutWindow provides functionality for defining the\n\n/// layout metrics for a window. By using layout constraints, you can create windows\n\n/// whose position and size are proportional to another window's dimensions, so that\n\n/// one window constrains the size of the other window. Toolbars and status bars are\n\n/// examples of constrained windows.\n\n///\n\n/// When specifying the layout metrics for a window, there are several options:\n\n/// e.g. in the horizontal direction,\n\n///\n\n/// Two Edge Constraints in X and Width\n\n/// - 1. left edge and right edge\n\n/// - 2. center edge and right edge\n\n/// - 3. left edge and center edge\n\n///\n\n/// Edge Constraint and Size constraint in X and Width\n\n/// - 4. left edge and size\n\n/// - 5. right edge and size\n\n/// - 6. center edge and size\n\n///\n\n/// The same holds true in the vertical direction for Y and Height\n\n///\n\n/// It is also possible to specify \"lmAsIs\" in which case we use the windows\n\n/// current value\n\n///\n\n/// Specifying \"lmAbsolute\" means that we will use whatever is in data member\n\n/// \"Value\"\n\n///\n\n/// We just name the fields \"X\" and \"Width\" and \"Y\" and \"Height\",\n\n/// although its okay to place a right or center edge constraint in the\n\n/// \"Width\" field and its also okay to place a right edge constraint in\n\n/// the \"X\" field (i.e. option #3)\n\n///\n\n/// However, it's NOT okay to place a width constraint in the \"X\" or\n\n/// \"Height\" fields or a height constraint in the \"Y\" or \"Width\" fields.\n\n//\n\nclass _OWLCLASS TLayoutWindow : virtual public TWindow {\n\n public:\n\n TLayoutWindow(TWindow* parent,\n\n LPCTSTR title = 0,\n\n TModule* module = 0);\n\n TLayoutWindow(TWindow* parent, const tstring& title, TModule* = 0);\n\n ~TLayoutWindow();\n\n\n\n /// Causes the receiver to size/position its children according to the\n\n /// specified layout metrics\n\n ///\n\n /// If you change the layout metrics for a child window call Layout()\n\n /// to have the changes take effect\n\n ///\n\n // !BB\n\n // !BB Consider making Layout virtual. Beta users have requested so that\n\n // !BB they can enhance it: For example, one user wants Layout to use\n\n // !BB 'DeferWindowPos' API to minimize flicker and avoid dirty repaints\n\n // !BB in cases where the child windows overlap. Sounds like a fair\n\n // !BB request to me\n", "file_path": "include/owl/layoutwi.h", "rank": 9, "score": 377926.6100713834 }, { "content": "", "file_path": "include/owl/window.h", "rank": 10, "score": 377925.6109908797 }, { "content": "//\n\n/// \\class TFrameWindow\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Derived from TWindow, TFrameWindow controls such window-specific behavior as\n\n/// keyboard navigation and command processing for client windows. For example, when\n\n/// a window is reactivated, TFrameWindow is responsible for restoring a window's\n\n/// input focus and for adding menu bar and icon support. TFrameWindow is a\n\n/// streamable class.\n\n///\n\n/// In terms of window areas, the frame area consists of the border, system menus,\n\n/// toolbars and status bars whereas the client area excludes these areas. Although\n\n/// frame windows can support a client window, the frame window remains separate\n\n/// from the client window so that you can change the client window without\n\n/// affecting the frame window.\n\n///\n\n/// ObjectWindows uses this frame and client structure for both TFrameWindow and\n\n/// TMDIChild classes. Both these classes can hold a client class. Having a separate\n\n/// class for the client area of the window adds more flexibility to your program.\n\n/// For example, this separate client area, which might be a dialog box, can be\n\n/// moved into another frame window, either a main window or an MDI child window.\n\n///\n\n/// TFrameWindow adds the notion of a client window, keyboard navigation, and special\n\n/// processing for commands (see member function EvCommand() )\n\n///\n\n/// See TFloatingFrame for a description of a floating frame with the same default\n\n/// functionality as a frame window.\n\n//\n\nclass _OWLCLASS TFrameWindow : virtual public TWindow {\n\n public:\n\n TFrameWindow(TWindow* parent,\n\n LPCTSTR title = 0,\n\n TWindow* clientWnd = 0,\n\n bool shrinkToClient = false,\n\n TModule* module = 0);\n\n\n\n TFrameWindow(\n\n TWindow* parent,\n\n const tstring& title,\n\n TWindow* client = 0,\n\n bool shrinkToClient = false,\n\n TModule* = 0);\n\n\n\n TFrameWindow(HWND hWnd, TModule* module = 0);\n\n ~TFrameWindow();\n\n\n\n // Menubar manipulating functions\n\n //\n", "file_path": "include/owl/framewin.h", "rank": 11, "score": 377925.07875378284 }, { "content": "/// \\addtogroup mixin\n\n/// @{\n\n/// \\class TClipboardViewer\n\n// ~~~~~ ~~~~~~~~~~~~~~~~\n\n/// Mix-in class that registers as a clipboard viewer when the user interface\n\n/// element is created and removes itself from the clipboard-viewer chain when\n\n/// it is destroyed\n\n//\n\nclass _OWLCLASS TClipboardViewer : virtual public TWindow {\n\n protected:\n\n TClipboardViewer();\n\n TClipboardViewer(HWND hWnd, TModule* module = 0);\n\n\n\n TEventStatus DoChangeCBChain(HWND hWndRemoved, HWND hWndNext);\n\n TEventStatus DoDestroy();\n\n TEventStatus DoDrawClipboard(); ///< pass to next window in clipboard-viewer chain\n\n\n\n // Override method defined by TWindow\n\n //\n\n void SetupWindow();\n\n\n\n // Message response functions\n\n //\n\n void EvChangeCBChain(HWND hWndRemoved, HWND hWndNext);\n\n void EvDestroy();\n\n void EvDrawClipboard(); ///< pass to next window in clipboard-viewer chain\n\n\n\n HWND GetNextWindow() const;\n", "file_path": "include/owl/clipview.h", "rank": 12, "score": 377922.8564432664 }, { "content": "//\n\n/// \\class TMDIClient\n\n// ~~~~~ ~~~~~~~~~~\n\n/// Multiple Document Interface (MDI) client windows (represented by a TMDIClient\n\n/// object) manage the MDI child windows of a TMDIFrame parent. TMDIClient is a\n\n/// streamable class.\n\nclass _OWLCLASS TMDIClient : public virtual TWindow {\n\n public:\n\n TMDIClient(TModule* module = 0);\n\n ~TMDIClient();\n\n\n\n virtual bool CloseChildren();\n\n TMDIChild* GetActiveMDIChild();\n\n\n\n // Member functions to arrange the MDI children\n\n //\n\n virtual void ArrangeIcons();\n\n virtual void CascadeChildren();\n\n virtual void TileChildren(int tile = MDITILE_VERTICAL);\n\n\n\n // Override member functions defined by TWindow\n\n //\n\n bool PreProcessMsg(MSG& msg);\n\n bool Create();\n\n\n\n /// \\name Child factory functions\n", "file_path": "include_xp/owl/mdi.h", "rank": 13, "score": 377922.69371917006 }, { "content": "//\n\n/// \\class TDialog\n\n// ~~~~~ ~~~~~~~\n\nclass _OWLCLASS TDialog : virtual public TWindow {\n\n public:\n\n // standard constructor\n\n TDialog(TWindow* parent, TResId resId, TModule* module = 0);\n\n // construct from pointer to template\n\n explicit TDialog(TWindow* parent, const DLGTEMPLATE& dlgTemplate, TAutoDelete = AutoDelete, TModule* module = 0);\n\n // Not usual,to avoid ambiquaity, construct from handle to template\n\n explicit TDialog(HGLOBAL hTemplate, TWindow* parent, TAutoDelete = AutoDelete, TModule* module=0);\n\n\n\n ~TDialog();\n\n\n\n //\n\n /// Override this to process messages within the dialog function.\n\n /// For most messages, 1 should be returned if the message is handled, and 0 if it is not.\n\n /// Some special messages require a message-specific return value other than this:\n\n /// WM_CHARTOITEM, WM_COMPAREITEM, WM_CTL*, WM_INITDIALOG, WM_QUERYDRAGICON and WM_VKEYTOITEM.\n\n /// See the Windows API documentation for details.\n\n //\n\n virtual INT_PTR DialogFunction(TMsgId, TParam1, TParam2);\n\n\n", "file_path": "include_xp/owl/dialog.h", "rank": 14, "score": 377922.57106024236 }, { "content": "/// \\addtogroup mixin\n\n/// @{\n\n//\n\n/// \\class TTinyCaption\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Derived from TWindow, TTinyCaption is a mix-in class that handles a set of\n\n/// non-client events to produce a smaller caption bar for a window. Whenever it\n\n/// displays the caption bar, TTinyCaption checks the window style and handles the\n\n/// WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX display attributes. Thus, you can use\n\n/// TTinyCaption to set the attributes of the tiny caption bar before enabling the\n\n/// caption. For example,\n\n/// \\code\n\n/// Attr.Style = WS_POPUP | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX |\n\n/// WS_MAXIMIZEBOX;\n\n/// \\endcode\n\n/// TTinyCaption provides functions that let you manipulate frame types, border\n\n/// styles, and menus. You can adjust the height of the caption bar or accept the\n\n/// default height, which is about one-half the height of a standard caption bar. If\n\n/// you set CloseBox to true, then the window will close when you click the close\n\n/// box instead of displaying the system menu.\n\n/// The sample program OWLCMD.CPP on BC5.02 distribution disk displays the following\n\n/// tiny caption bar:\n\n/// \\image html bm263.BMP\n\n///\n\n/// If you are using TTinyCaption as a mix-in class that does partial event\n\n/// handling, call the DoXxxx function in the mix-in class (instead of the EvXxxx\n\n/// function) to avoid duplicating default processing. The following example from\n\n/// OWLCMD.CPP (a sample program on your distribution disk) illustrates this\n\n/// process:\n\n/// \\code\n\n/// void TMyFrame::EvSysCommand(uint cmdType,TPoint& p)\n\n/// {\n\n/// if (TTinyCaption::DoSysCommand(cmdType, p) == esPartial)\n\n/// FrameWindow::EvSysCommand(cmdType, p);\n\n/// \\endcode\n\n/// The TFLoatingFrame class can be used with TTinyCaption to produce a close box.\n\n/// See the sample programs OWLCMD.CPP and MDIFILE.CPP on BC5.0x distribution disk for\n\n/// examples of how to use TTinyCaption.\n\n//\n\nclass _OWLCLASS TTinyCaption : public virtual TWindow {\n\n protected:\n\n TTinyCaption();\n\n ~TTinyCaption();\n\n\n\n /// Pass closeBox=true to replace SystemMenu box with a box that will\n\n /// close window when clicked\n\n /// Used for floating palettes, etc.\n\n //\n\n void EnableTinyCaption(int ch=0, bool closeBox=false);\n\n\n\n // Controller class must handle events that call these mixin handlers\n\n //\n\n TEventStatus DoNCHitTest(const TPoint& screenPt, uint& evRes);\n\n TEventStatus DoNCPaint();\n\n TEventStatus DoNCCalcSize(bool calcValidRects,\n\n NCCALCSIZE_PARAMS & calcSize, uint& evRes);\n\n TEventStatus DoNCLButtonDown(uint hitTest, const TPoint& screenPt);\n\n TEventStatus DoMouseMove(uint hitTest, const TPoint& screenPt);\n\n TEventStatus DoLButtonUp(uint hitTest, const TPoint& screenPt);\n", "file_path": "include_xp/owl/tinycapt.h", "rank": 15, "score": 370663.0490213869 }, { "content": "//\n\n/// \\class TLayoutWindow\n\n// ~~~~~ ~~~~~~~~~~~~~\n\n/// Derived from TWindow, TLayoutWindow provides functionality for defining the\n\n/// layout metrics for a window. By using layout constraints, you can create windows\n\n/// whose position and size are proportional to another window's dimensions, so that\n\n/// one window constrains the size of the other window. Toolbars and status bars are\n\n/// examples of constrained windows.\n\n///\n\n/// When specifying the layout metrics for a window, there are several options:\n\n/// e.g. in the horizontal direction,\n\n///\n\n/// Two Edge Constraints in X and Width\n\n/// - 1. left edge and right edge\n\n/// - 2. center edge and right edge\n\n/// - 3. left edge and center edge\n\n///\n\n/// Edge Constraint and Size constraint in X and Width\n\n/// - 4. left edge and size\n\n/// - 5. right edge and size\n\n/// - 6. center edge and size\n\n///\n\n/// The same holds true in the vertical direction for Y and Height\n\n///\n\n/// It is also possible to specify \"lmAsIs\" in which case we use the windows\n\n/// current value\n\n///\n\n/// Specifying \"lmAbsolute\" means that we will use whatever is in data member\n\n/// \"Value\"\n\n///\n\n/// We just name the fields \"X\" and \"Width\" and \"Y\" and \"Height\",\n\n/// although its okay to place a right or center edge constraint in the\n\n/// \"Width\" field and its also okay to place a right edge constraint in\n\n/// the \"X\" field (i.e. option #3)\n\n///\n\n/// However, it's NOT okay to place a width constraint in the \"X\" or\n\n/// \"Height\" fields or a height constraint in the \"Y\" or \"Width\" fields.\n\n//\n\nclass _OWLCLASS TLayoutWindow : virtual public TWindow {\n\n public:\n\n TLayoutWindow(TWindow* parent,\n\n LPCTSTR title = 0,\n\n TModule* module = 0);\n\n TLayoutWindow(TWindow* parent, const tstring& title, TModule* = 0);\n\n ~TLayoutWindow();\n\n\n\n /// Causes the receiver to size/position its children according to the\n\n /// specified layout metrics\n\n ///\n\n /// If you change the layout metrics for a child window call Layout()\n\n /// to have the changes take effect\n\n ///\n\n // !BB\n\n // !BB Consider making Layout virtual. Beta users have requested so that\n\n // !BB they can enhance it: For example, one user wants Layout to use\n\n // !BB 'DeferWindowPos' API to minimize flicker and avoid dirty repaints\n\n // !BB in cases where the child windows overlap. Sounds like a fair\n\n // !BB request to me\n", "file_path": "include_xp/owl/layoutwi.h", "rank": 16, "score": 370658.8189538415 }, { "content": "", "file_path": "include_xp/owl/window.h", "rank": 17, "score": 370657.81987333787 }, { "content": "//\n\n/// \\class TFrameWindow\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Derived from TWindow, TFrameWindow controls such window-specific behavior as\n\n/// keyboard navigation and command processing for client windows. For example, when\n\n/// a window is reactivated, TFrameWindow is responsible for restoring a window's\n\n/// input focus and for adding menu bar and icon support. TFrameWindow is a\n\n/// streamable class.\n\n///\n\n/// In terms of window areas, the frame area consists of the border, system menus,\n\n/// toolbars and status bars whereas the client area excludes these areas. Although\n\n/// frame windows can support a client window, the frame window remains separate\n\n/// from the client window so that you can change the client window without\n\n/// affecting the frame window.\n\n///\n\n/// ObjectWindows uses this frame and client structure for both TFrameWindow and\n\n/// TMDIChild classes. Both these classes can hold a client class. Having a separate\n\n/// class for the client area of the window adds more flexibility to your program.\n\n/// For example, this separate client area, which might be a dialog box, can be\n\n/// moved into another frame window, either a main window or an MDI child window.\n\n///\n\n/// TFrameWindow adds the notion of a client window, keyboard navigation, and special\n\n/// processing for commands (see member function EvCommand() )\n\n///\n\n/// See TFloatingFrame for a description of a floating frame with the same default\n\n/// functionality as a frame window.\n\n//\n\nclass _OWLCLASS TFrameWindow : virtual public TWindow {\n\n public:\n\n TFrameWindow(TWindow* parent,\n\n LPCTSTR title = 0,\n\n TWindow* clientWnd = 0,\n\n bool shrinkToClient = false,\n\n TModule* module = 0);\n\n\n\n TFrameWindow(\n\n TWindow* parent,\n\n const tstring& title,\n\n TWindow* client = 0,\n\n bool shrinkToClient = false,\n\n TModule* = 0);\n\n\n\n TFrameWindow(HWND hWnd, TModule* module = 0);\n\n ~TFrameWindow();\n\n\n\n // Menubar manipulating functions\n\n //\n", "file_path": "include_xp/owl/framewin.h", "rank": 18, "score": 370657.28763624094 }, { "content": "/// \\addtogroup mixin\n\n/// @{\n\n/// \\class TClipboardViewer\n\n// ~~~~~ ~~~~~~~~~~~~~~~~\n\n/// Mix-in class that registers as a clipboard viewer when the user interface\n\n/// element is created and removes itself from the clipboard-viewer chain when\n\n/// it is destroyed\n\n//\n\nclass _OWLCLASS TClipboardViewer : virtual public TWindow {\n\n protected:\n\n TClipboardViewer();\n\n TClipboardViewer(HWND hWnd, TModule* module = 0);\n\n\n\n TEventStatus DoChangeCBChain(HWND hWndRemoved, HWND hWndNext);\n\n TEventStatus DoDestroy();\n\n TEventStatus DoDrawClipboard(); ///< pass to next window in clipboard-viewer chain\n\n\n\n // Override method defined by TWindow\n\n //\n\n void SetupWindow();\n\n\n\n // Message response functions\n\n //\n\n void EvChangeCBChain(HWND hWndRemoved, HWND hWndNext);\n\n void EvDestroy();\n\n void EvDrawClipboard(); ///< pass to next window in clipboard-viewer chain\n\n\n\n HWND GetNextWindow() const;\n", "file_path": "include_xp/owl/clipview.h", "rank": 19, "score": 370655.06532572454 }, { "content": "//\n\n/// \\class TGadgetWindow\n\n// ~~~~~ ~~~~~~~~~~~~~\n\n/// Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a\n\n/// window and lets you dynamically arrange tool bars. You can specify the following\n\n/// attributes of these gadgets:\n\n/// - \\c \\b Horizontal or vertical tiling. Positions the gadgets horizontally\n\n/// or vertically within the inner rectangle (the area excluding borders and\n\n/// margins).\n\n/// - \\c \\b Gadget font. Default font to use for gadgets and for calculating\n\n/// layout units. For font information, see the description of TGadgetWindowFont.\n\n/// - \\c \\b Left, right, top, and bottom margins. Specified in pixels, layout\n\n/// units (based on the window font), or border units (the width or height of a thin\n\n/// window border).\n\n/// - \\c \\b Measurement units. Specified in pixels, layout units, or border\n\n/// units.\n\n/// - \\c \\b Gadget window size. A gadget window can shrink-wrap its width,\n\n/// height, or both to fit around its gadgets. By default, horizontally tiled\n\n/// gadgets shrink-wrap to fit the height of the window and vertically tiled gadgets\n\n/// shrink-wrap to fit the width of the window.\n\n///\n\n/// TGadgetWindow is the base class for the following derived classes: TControlBar,\n\n/// TMessageBar, TToolBox, and TStatusBar.\n\n//\n\nclass _OWLCLASS TGadgetWindow : virtual public TWindow, public TGadgetList {\n\n public:\n\n\n\n /// Enumeration describing how gadgets should be laid out within the\n\n /// gadget window.\n\n /// TGadgetWindow::TileGadgets actually tiles the gadgets in the direction\n\n /// requested.\n\n //\n\n enum TTileDirection {\n\n Horizontal, ///< Arrange gadgets in a row\n\n Vertical, ///< Arrange gadgets in a column\n\n Rectangular ///< Arrange gadgets in rows and columns (2-D grid)\n\n };\n\n\n\n TGadgetWindow(TWindow* parent = 0,\n\n TTileDirection direction = Horizontal,\n\n TFont* font = 0,\n\n TModule* module = 0);\n\n ~TGadgetWindow();\n\n\n", "file_path": "include/owl/gadgetwi.h", "rank": 20, "score": 365108.1774613823 }, { "content": "/// ipstream, a specialized input stream derivative of pstream, is the base class\n\n/// for reading (extracting) streamable objects.\n\nclass _OWLCLASS ipstream : virtual public pstream {\n\n friend class TStreamableClass;\n\n public:\n\n\n\n ipstream( std::streambuf * );\n\n\n\n std::streampos tellg();\n\n ipstream& seekg( std::streampos );\n\n ipstream& seekg( std::streamoff, std::ios::seekdir );\n\n\n\n uint8 readByte();\n\n void readBytes( void *, size_t );\n\n void freadBytes( void * data, size_t sz );\n\n\n\n uint32 readWord();\n\n uint16 readWord16();\n\n uint32 readWord32();\n\n\n\n LPSTR readString();\n\n LPSTR readString( LPSTR , unsigned );\n", "file_path": "include/owl/objstrm.h", "rank": 21, "score": 362082.70979881054 }, { "content": "class _OWLCLASS fpbase : virtual public pstream {\n\n public:\n\n\n\n enum { openprot = 0666 }; // default open mode\n\n fpbase();\n\n fpbase( LPCSTR, int, int = openprot );\n\n fpbase( LPCWSTR, int, int = openprot );\n\n\n\n void open( LPCSTR, int, int = openprot );\n\n void open( LPCWSTR, int, int = openprot );\n\n\n\n void close();\n\n void setbuf( LPSTR, int );\n\n std::filebuf * rdbuf();\n\n\n\n private:\n\n\n\n std::filebuf buf;\n\n};\n\n\n\n/// \\class ifpstream\n\n/// Base class for reading streamable objects from file streams\n\n//\n\n/// ifpstream is a simple \"mix\" of its bases, fpbase and ipstream. It provides the\n\n/// base class reading (extracting) streamable objects from file streams.\n\n\n", "file_path": "include/owl/objstrm.h", "rank": 22, "score": 362076.0603763752 }, { "content": "class _OWLCLASS opstream : virtual public pstream {\n\n public:\n\n\n\n opstream( std::streambuf * );\n\n virtual ~opstream();\n\n\n\n std::streampos tellp();\n\n opstream& seekp( std::streampos );\n\n opstream& seekp( std::streamoff, std::ios::seekdir );\n\n opstream& flush();\n\n\n\n void writeByte( uint8 );\n\n void writeBytes( const void *, size_t );\n\n void fwriteBytes( const void *data, size_t sz );\n\n\n\n void writeWord( uint32 );\n\n void writeWord16( uint16 );\n\n void writeWord32( uint32 );\n\n\n\n void writeString( const char * );\n", "file_path": "include/owl/objstrm.h", "rank": 23, "score": 362076.0603763752 }, { "content": "//\n\n/// \\class TGadgetWindow\n\n// ~~~~~ ~~~~~~~~~~~~~\n\n/// Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a\n\n/// window and lets you dynamically arrange tool bars. You can specify the following\n\n/// attributes of these gadgets:\n\n/// - \\c \\b Horizontal or vertical tiling. Positions the gadgets horizontally\n\n/// or vertically within the inner rectangle (the area excluding borders and\n\n/// margins).\n\n/// - \\c \\b Gadget font. Default font to use for gadgets and for calculating\n\n/// layout units. For font information, see the description of TGadgetWindowFont.\n\n/// - \\c \\b Left, right, top, and bottom margins. Specified in pixels, layout\n\n/// units (based on the window font), or border units (the width or height of a thin\n\n/// window border).\n\n/// - \\c \\b Measurement units. Specified in pixels, layout units, or border\n\n/// units.\n\n/// - \\c \\b Gadget window size. A gadget window can shrink-wrap its width,\n\n/// height, or both to fit around its gadgets. By default, horizontally tiled\n\n/// gadgets shrink-wrap to fit the height of the window and vertically tiled gadgets\n\n/// shrink-wrap to fit the width of the window.\n\n///\n\n/// TGadgetWindow is the base class for the following derived classes: TControlBar,\n\n/// TMessageBar, TToolBox, and TStatusBar.\n\n//\n\nclass _OWLCLASS TGadgetWindow : virtual public TWindow, public TGadgetList {\n\n public:\n\n\n\n /// Enumeration describing how gadgets should be laid out within the\n\n /// gadget window.\n\n /// TGadgetWindow::TileGadgets actually tiles the gadgets in the direction\n\n /// requested.\n\n //\n\n enum TTileDirection {\n\n Horizontal, ///< Arrange gadgets in a row\n\n Vertical, ///< Arrange gadgets in a column\n\n Rectangular ///< Arrange gadgets in rows and columns (2-D grid)\n\n };\n\n\n\n TGadgetWindow(TWindow* parent = 0,\n\n TTileDirection direction = Horizontal,\n\n TFont* font = 0,\n\n TModule* module = 0);\n\n ~TGadgetWindow();\n\n\n", "file_path": "include_xp/owl/gadgetwi.h", "rank": 24, "score": 359418.09093715064 }, { "content": "class OWLEXTCLASS THarborManagement : virtual public owl::TEventHandler\n\n{\n\n public:\n\n THarborManagement(LPCTSTR registryName);\n\n ~THarborManagement();\n\n\n\n void InsertToolbarMenuItem(owl::TCommandEnabler& ce, int offset);\n\n // Insert the \"Toolbar >\" menu item at the menu item specified by ce + offset\n\n\n\n owl::tstring GetRegistryName() { return RegistryName; }\n\n static int GetInternVersion() { return InternVersion; }\n\n THarborEx* GetHarbor() { return Harbor; }\n\n\n\n void LoadSettings();\n\n void SaveSettings();\n\n\n\n protected:\n\n\n\n // simple wrapper functions to harbor\n\n //\n", "file_path": "include/owlext/harborex.h", "rank": 25, "score": 354707.133613911 }, { "content": "/// ipstream, a specialized input stream derivative of pstream, is the base class\n\n/// for reading (extracting) streamable objects.\n\nclass _OWLCLASS ipstream : virtual public pstream {\n\n friend class TStreamableClass;\n\n public:\n\n\n\n ipstream( std::streambuf * );\n\n\n\n std::streampos tellg();\n\n ipstream& seekg( std::streampos );\n\n ipstream& seekg( std::streamoff, std::ios::seek_dir );\n\n\n\n uint8 readByte();\n\n void readBytes( void *, size_t );\n\n void freadBytes( void * data, size_t sz );\n\n\n\n uint32 readWord();\n\n uint16 readWord16();\n\n uint32 readWord32();\n\n\n\n LPSTR readString();\n\n LPSTR readString( LPSTR , unsigned );\n", "file_path": "include_xp/owl/objstrm.h", "rank": 26, "score": 353114.13871851773 }, { "content": "class _OWLCLASS fpbase : virtual public pstream {\n\n public:\n\n\n\n enum { openprot = 0666 }; // default open mode\n\n fpbase();\n\n fpbase( LPCSTR, int, int = openprot );\n\n fpbase( LPCWSTR, int, int = openprot );\n\n\n\n void open( LPCSTR, int, int = openprot );\n\n void open( LPCWSTR, int, int = openprot );\n\n\n\n void close();\n\n void setbuf( LPSTR, int );\n\n std::filebuf * rdbuf();\n\n\n\n private:\n\n\n\n std::filebuf buf;\n\n};\n\n\n\n/// \\class ifpstream\n\n/// Base class for reading streamable objects from file streams\n\n//\n\n/// ifpstream is a simple \"mix\" of its bases, fpbase and ipstream. It provides the\n\n/// base class reading (extracting) streamable objects from file streams.\n\n\n", "file_path": "include_xp/owl/objstrm.h", "rank": 27, "score": 353107.4892960823 }, { "content": "class _OWLCLASS opstream : virtual public pstream {\n\n public:\n\n\n\n opstream( std::streambuf * );\n\n virtual ~opstream();\n\n\n\n std::streampos tellp();\n\n opstream& seekp( std::streampos );\n\n opstream& seekp( std::streamoff, std::ios::seek_dir );\n\n opstream& flush();\n\n\n\n void writeByte( uint8 );\n\n void writeBytes( const void *, size_t );\n\n void fwriteBytes( const void *data, size_t sz );\n\n\n\n void writeWord( uint32 );\n\n void writeWord16( uint16 );\n\n void writeWord32( uint32 );\n\n\n\n void writeString( const char * );\n", "file_path": "include_xp/owl/objstrm.h", "rank": 28, "score": 353107.4892960823 }, { "content": "class OWLEXTCLASS THarborManagement : virtual public owl::TEventHandler\n\n{\n\n public:\n\n THarborManagement(LPCTSTR registryName);\n\n ~THarborManagement();\n\n\n\n void InsertToolbarMenuItem(owl::TCommandEnabler& ce, int offset);\n\n // Insert the \"Toolbar >\" menu item at the menu item specified by ce + offset\n\n\n\n owl::tstring GetRegistryName() { return RegistryName; }\n\n static int GetInternVersion() { return InternVersion; }\n\n THarborEx* GetHarbor() { return Harbor; }\n\n\n\n void LoadSettings();\n\n void SaveSettings();\n\n\n\n protected:\n\n\n\n // simple wrapper functions to harbor\n\n //\n", "file_path": "include_xp/owlext/harborex.h", "rank": 29, "score": 348317.8006131571 }, { "content": "", "file_path": "include/owlext/dockingex.h", "rank": 30, "score": 339440.3509334037 }, { "content": "#define DECLARE_DIAG_STATIC_GROUP(group)\\\n\n class TDiagGroup##group : public ::owl::TDiagBase {\\\n\n DECLARE_DIAG_GROUP_COMMON(group)\n\n\n\n#define DIAG_DEFINE_GROUP_COMMON(group)\\\n\n TDiagGroup##group::TDiagGroup##group(LPCSTR name,bool enable, int level) : ::owl::TDiagBase(name, enable, level) {}\\\n\n ::owl::TModule* TDiagGroup##group::GetDiagModule() {return &::owl::GetGlobalModule();}\n\n\n\n#define _DIAG_DEFINE_GROUP_(group, enable, level, t)\\\n\n DECLARE_DIAG_GROUP(group, t);\\\n\n DIAG_DEFINE_GROUP_COMMON(group)\n\n\n\n#define _DIAG_DEFINE_GROUP_STATIC(group, enable, level)\\\n\n DECLARE_DIAG_STATIC_GROUP(group);\\\n\n DIAG_DEFINE_GROUP_COMMON(group);\\\n\n TDiagGroup##group __OwlDiagGroup##group(#group, enable, level)\n\n\n\n//\n\n// DLN: Define OwlDiagGroupDef without redefining TDiagGroupDef.\n\n//\n\n#define OWL_DIAG_DEFINE_GROUP(group, enable, level) \\\n", "file_path": "include/owl/private/checks.h", "rank": 31, "score": 339102.09671043337 }, { "content": "//\n\n/// \\class TView\n\n// ~~~~~ ~~~~~\n\n/// Abstract base class for view access from document\n\n//\n\n/// Derived virtually from both TEventHandler and TStreamableBase, TView is the\n\n/// interface presented to a document so it can access its client views. Views then\n\n/// call the document functions to request input and output streams. Views own the\n\n/// streams and are responsible for attaching and deleting them.\n\n///\n\n/// Instead of creating an instance of TView, you create a derived class that can\n\n/// implement TView's virtual functions. The derived class must have a way of\n\n/// knowing the associated window (provided by GetWindow()) and of describing the view\n\n/// (provided by GetViewName()). The view must also be able to display the document\n\n/// title in its window (SetDocTitle()).\n\n/// Classes derived from TView may need to handle several notification messages. For\n\n/// example, if a view is associated with a window that can gain focus, then the\n\n/// view should handle the vnIsWindow notification message.\n\n///\n\n/// View classes can take various forms. For example, a view class can be a window\n\n/// (through inheritance), can contain a window (an embedded object), can reference\n\n/// a window, or can be contained within a window object. A view class might not\n\n/// even have a window, as in the case of a voice mail or a format converter. Some\n\n/// remote views (for example, those displayed by DDE servers) might not have local\n\n/// windows.\n\n///\n\n/// Other viewer classes derived from TView include TEditView, TListBoxView, and\n\n/// TWindowView. These classes display different types of data: TEditView displays\n\n/// unformatted text files, TListBoxView displays text information in a list box, and\n\n/// TWindowView is a basic viewer from which you can derive other types of viewers\n\n/// such as hexadecimal file viewers.\n\n///\n\n/// For OLE-enabled applications, use TOleView, which supports views for embedded\n\n/// objects and compound documents.\n\n//\n\nclass _OWLCLASS TView : virtual public TEventHandler,\n\n virtual public TStreamableBase {\n\n public:\n\n/// These property values, which describe the basic properties of a view, are\n\n/// available in classes derived from TView. They can be used to update and query\n\n/// the attributes of a view. PrevProperty and NextProperty are delimiters for every\n\n/// view's property list.\n\n enum {\n\n PrevProperty = 0, ///< Index of last property in base class.\n\n ViewClass, ///< Name of the C++ class encapsulating the view. (text)\n\n ViewName, ///< Name of the view. (text)\n\n NextProperty, ///< Next index to be used by derived class.\n\n };\n\n\n\n TView(TDocument& doc);\n\n virtual ~TView();\n\n\n\n TDocument& GetDocument();\n\n void SetDocument(TDocument&); // Added by Vidar Hasfjord, 2007-08-27.\n\n\n", "file_path": "include/owl/docview.h", "rank": 32, "score": 337005.8661576925 }, { "content": "//\n\n/// \\class TMDIChild\n\n// ~~~~~ ~~~~~~~~~\n\n/// TMDIChild defines the basic behavior of all MDI child windows. Child windows can\n\n/// be created inside the client area of a parent window. Because child windows\n\n/// exist within, and are restricted to the parent window's borders, the parent\n\n/// window defined before the child is defined. For example, a dialog box is a\n\n/// window that contains child windows, often referred to as dialog box controls.\n\n///\n\n/// To be used as MDI children, classes must be derived from TMDIChild. MDI children\n\n/// can inherit keyboard navigation, focus handling, and icon support from\n\n/// TFrameWindow. TMDIChild is a streamable class.\n\n//\n\nclass _OWLCLASS TMDIChild : virtual public TFrameWindow {\n\n public:\n\n TMDIChild(TMDIClient& parent,\n\n LPCTSTR title = 0,\n\n TWindow* clientWnd = 0,\n\n bool shrinkToClient = false,\n\n TModule* module = 0);\n\n\n\n TMDIChild(TMDIClient& parent,\n\n const tstring& title,\n\n TWindow* clientWnd = 0,\n\n bool shrinkToClient = false,\n\n TModule* module = 0);\n\n\n\n TMDIChild(HWND hWnd, TModule* module = 0);\n\n\n\n ~TMDIChild();\n\n\n\n // Override virtual methods defined by TWindow\n\n //\n", "file_path": "include/owl/mdichild.h", "rank": 33, "score": 337001.25403372035 }, { "content": "/// \\addtogroup module\n\n/// @{\n\n/// \\class TApplication\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Derived from TModule and TMsgThread and virtually derived from TEventHandler,\n\n/// TApplication acts as an object-oriented stand-in for an application module.\n\n/// TApplication and TModule supply the basic behavior required of an application.\n\n/// TApplication member functions create instances of a class, create main windows,\n\n/// and process messages.\n\n///\n\n/// To create an OLE-enabled Doc/View application, you need to derive your\n\n/// application from both TApplication and TOcAppHost.\n\n//\n\nclass _OWLCLASS TApplication : virtual public TEventHandler,\n\n public TModule,\n\n public TMsgThread\n\n{\n\n public:\n\n // Constructors for TApplication. Default args for the ctor allow\n\n // TApplication to access global pointers in the user exe/dll.\n\n // Default OwlAppDictionary can be overridden by passing non-0 appDict arg\n\n //\n\n TApplication\n\n (\n\n const tstring& name = tstring(),\n\n TModule*& = owl::Module,\n\n TAppDictionary* = 0\n\n );\n\n\n\n TApplication\n\n (\n\n const tstring& name,\n\n HINSTANCE hInstance,\n", "file_path": "include/owl/applicat.h", "rank": 34, "score": 337000.9679940208 }, { "content": "//\n\n/// \\class TMDIFrame\n\n// ~~~~~ ~~~~~~~~~\n\n/// Multiple Document Interface (MDI) frame windows, represented by TMDIFrame, are\n\n/// overlapped windows that serve as main windows of MDI-compliant applications.\n\n/// TMDIFrame objects automatically handle creating and initializing an MDI client\n\n/// window (represented by a TMDIClient object) required by Windows. TMDIFrame sets\n\n/// window style WS_CLIPCHILDREN by default so that minimal flicker occurs when the\n\n/// MDI frame erases its background and the backgrounds of its children. TMDIFrame\n\n/// is a streamable class.\n\n/// Because TMDIFrame is derived from TFrameWindow, it inherits keyboard navigation.\n\n/// As a result, all children of the MDI frame acquire keyboard navigation. However,\n\n/// it's best to enable keyboard navigation only for those children who require it.\n\n///\n\n/// To create an OLE-enabled MDI frame window, use TOleMDIFrame, which inherits\n\n/// functionality from both TMDIFrame and TOleFrame.\n\n//\n\nclass _OWLCLASS TMDIFrame : virtual public TFrameWindow {\n\n public:\n\n TMDIFrame(LPCTSTR title,\n\n TResId menuResId,\n\n TMDIClient& clientWnd = *new TMDIClient,\n\n TModule* module = 0);\n\n\n\n TMDIFrame(\n\n const tstring& title,\n\n TResId menuResId,\n\n TMDIClient& client = *new TMDIClient,\n\n TModule* = 0);\n\n\n\n TMDIFrame(THandle frameHandle, HWND clientHandle, TModule* module = 0);\n\n\n\n // Override virtual functions defined by TFrameWindow or TWindow\n\n //\n\n bool SetMenu(HMENU);\n\n\n\n TMDIClient* GetClientWindow();\n", "file_path": "include/owl/mdi.h", "rank": 35, "score": 336999.0952913848 }, { "content": "", "file_path": "include_xp/owlext/dockingex.h", "rank": 36, "score": 335310.7661409191 }, { "content": "#define DECLARE_DIAG_STATIC_GROUP(group)\\\n\n class TDiagGroup##group : public ::owl::TDiagBase {\\\n\n DECLARE_DIAG_GROUP_COMMON(group)\n\n\n\n#define DIAG_DEFINE_GROUP_COMMON(group)\\\n\n TDiagGroup##group::TDiagGroup##group(LPCSTR name,bool enable, int level) : ::owl::TDiagBase(name, enable, level) {}\\\n\n ::owl::TModule* TDiagGroup##group::GetDiagModule() {return &::owl::GetGlobalModule();}\n\n\n\n#define _DIAG_DEFINE_GROUP_(group, enable, level, t)\\\n\n DECLARE_DIAG_GROUP(group, t);\\\n\n DIAG_DEFINE_GROUP_COMMON(group)\n\n\n\n#define _DIAG_DEFINE_GROUP_STATIC(group, enable, level)\\\n\n DECLARE_DIAG_STATIC_GROUP(group);\\\n\n DIAG_DEFINE_GROUP_COMMON(group);\\\n\n TDiagGroup##group __OwlDiagGroup##group(#group, enable, level)\n\n\n\n//\n\n// DLN: Define OwlDiagGroupDef without redefining TDiagGroupDef.\n\n//\n\n#define OWL_DIAG_DEFINE_GROUP(group, enable, level) \\\n", "file_path": "include_xp/owl/private/checks.h", "rank": 37, "score": 332726.0884290306 }, { "content": "//\n\n// class TFontSample\n\n// ~~~~~ ~~~~~~~~~~~\n\n//\n\nclass _COOLCLASS TFontSample : public owl::TStatic {\n\n public:\n\n TFontSample(owl::TWindow*, int resId, owl::TModule *module = 0);\n\n void SetupWindow ();\n\n void Paint (owl::TDC&, bool, owl::TRect&);\n\n void SetTextColor(const owl::TColor& clr);\n\n void SetBkColor(const owl::TColor& clr);\n\n private:\n\n owl::TColor TextColor;\n\n owl::TColor BkColor;\n\n};\n\n\n", "file_path": "include/coolprj/clrpropdlg.h", "rank": 38, "score": 332166.11083402653 }, { "content": "class OWLEXTCLASS TStaticBitmap : public owl::TStatic {\n\n // Object lifetime methods\n\npublic:\n\n TStaticBitmap(owl::TWindow* parent, owl::TBitmap* user_bitmap, owl::TPalette* user_palette,\n\n int id, int x, int y, int width, int height, bool flag=false,\n\n bool use_aspect=false,bool use_mask=true);\n\n virtual ~TStaticBitmap();\n\n\n\n // Mutators\n\n //\n\npublic:\n\n void SetText(LPTSTR text);\n\n void UpdateBitmap(owl::TBitmap* user_bitmap,int x,int y,int width,int height,\n\n bool use_mask=true);\n\n bool IsOver(owl::TPoint& point);\n\n void Select(bool flag);\n\n\n\n // OWL overrides\n\n //\n\nprotected:\n", "file_path": "include/owlext/staticbm.h", "rank": 39, "score": 332158.9048443418 }, { "content": "//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n// TTabWindow\n\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nclass OWLEXTCLASS TTabWindow : public owl::TWindow {\n\n // Object lifetime methods\n\n //\n\npublic:\n\n TTabWindow(owl::TWindow* parent, owl::TWindow* array[] = 0);\n\n TTabWindow(owl::TWindow* parent, owl::uint32 X, owl::uint32 Y, owl::uint32 W, owl::uint32 H, owl::TWindow* array[] = 0);\n\nprivate:\n\n TTabWindow(); // DISALLOWED METHOD\n\n TTabWindow(const TTabWindow&); // DISALLOWED METHOD\n\n TTabWindow& operator=(const TTabWindow& src); // DISALLOWED METHOD\n\n\n\n // Tabbed-window interface: adding windows, removing windows\n\n //\n\npublic:\n\n virtual void Attach(owl::TWindow* ptr, LPCTSTR title = 0);\n\n virtual void Attach(owl::TWindow* windowArray[]);\n\n virtual owl::TWindow* Detach(owl::int32 index) = 0;\n\n virtual owl::TWindow* Detach(owl::TWindow* ptr)\n\n { return Detach(Retrieve(ptr)); }\n\n virtual owl::TWindow* Retrieve(owl::int32 index)\n", "file_path": "include/owlext/tabwin.h", "rank": 40, "score": 332090.9395855826 }, { "content": "class OWLEXTCLASS TColorPicker : public owl::TWindow {\n\n public:\n\n TColorPicker(owl::TWindow* parent,\n\n const TColorPickerData& data,\n\n owl::TColor startColor,\n\n int refId,\n\n LPCTSTR title = 0,\n\n owl::TModule* module = 0);\n\n virtual ~TColorPicker();\n\n\n\n public:\n\n virtual TGetClassNameReturnType GetClassName();\n\n virtual void GetWindowClass(WNDCLASS& wndClass);\n\n virtual void Paint(owl::TDC& dc, bool erase, owl::TRect& rect);\n\n virtual void SetupWindow();\n\n virtual void ShowPickerWindow(owl::TPoint& pt, owl::TRect& rect);\n\n virtual bool PreProcessMsg(MSG& msg);\n\n virtual owl::TColor GetCurrentChosenColor();\n\n virtual void SetCurrentChosenColor(owl::TColor color);\n\n virtual void NotifyAtParent();\n", "file_path": "include/owlext/colpick.h", "rank": 41, "score": 332090.9395855825 }, { "content": "//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n// TPictDecorator\n\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nclass OWLEXTCLASS TPictDecorator : public owl::TWindow\n\n{\n\n // Object lifetime methods\n\n //\n\npublic:\n\n TPictDecorator(owl::TDib* dib, owl::TWindow& parent);\n\n virtual ~TPictDecorator();\n\n\n\n // OWL overrides\n\n //\n\nprotected:\n\n DECLARE_RESPONSE_TABLE(TPictDecorator);\n\n virtual bool EvEraseBkgnd(HDC hdc);\n\n virtual void EvSize(owl::uint sizeType, const owl::TSize& size);\n\n\n\n /*\n\n // This was how the code was originally written; however, in order to give you\n\n // a demonstration of how to use the TProperty<> mechanism in PROPERTY.H, I've\n\n // chosen to use the TProperty<> mechanism to control the m_pdib member.\n\n\n", "file_path": "include/owlext/pictdeco.h", "rank": 42, "score": 332090.9395855825 }, { "content": "//\n\n/// \\class TView\n\n// ~~~~~ ~~~~~\n\n/// Abstract base class for view access from document\n\n//\n\n/// Derived virtually from both TEventHandler and TStreamableBase, TView is the\n\n/// interface presented to a document so it can access its client views. Views then\n\n/// call the document functions to request input and output streams. Views own the\n\n/// streams and are responsible for attaching and deleting them.\n\n///\n\n/// Instead of creating an instance of TView, you create a derived class that can\n\n/// implement TView's virtual functions. The derived class must have a way of\n\n/// knowing the associated window (provided by GetWindow()) and of describing the view\n\n/// (provided by GetViewName()). The view must also be able to display the document\n\n/// title in its window (SetDocTitle()).\n\n/// Classes derived from TView may need to handle several notification messages. For\n\n/// example, if a view is associated with a window that can gain focus, then the\n\n/// view should handle the vnIsWindow notification message.\n\n///\n\n/// View classes can take various forms. For example, a view class can be a window\n\n/// (through inheritance), can contain a window (an embedded object), can reference\n\n/// a window, or can be contained within a window object. A view class might not\n\n/// even have a window, as in the case of a voice mail or a format converter. Some\n\n/// remote views (for example, those displayed by DDE servers) might not have local\n\n/// windows.\n\n///\n\n/// Other viewer classes derived from TView include TEditView, TListBoxView, and\n\n/// TWindowView. These classes display different types of data: TEditView displays\n\n/// unformatted text files, TListBoxView displays text information in a list box, and\n\n/// TWindowView is a basic viewer from which you can derive other types of viewers\n\n/// such as hexadecimal file viewers.\n\n///\n\n/// For OLE-enabled applications, use TOleView, which supports views for embedded\n\n/// objects and compound documents.\n\n//\n\nclass _OWLCLASS TView : virtual public TEventHandler,\n\n virtual public TStreamableBase {\n\n public:\n\n/// These property values, which describe the basic properties of a view, are\n\n/// available in classes derived from TView. They can be used to update and query\n\n/// the attributes of a view. PrevProperty and NextProperty are delimiters for every\n\n/// view's property list.\n\n enum {\n\n PrevProperty = 0, ///< Index of last property in base class.\n\n ViewClass, ///< Name of the C++ class encapsulating the view. (text)\n\n ViewName, ///< Name of the view. (text)\n\n NextProperty, ///< Next index to be used by derived class.\n\n };\n\n\n\n TView(TDocument& doc);\n\n virtual ~TView();\n\n\n\n TDocument& GetDocument();\n\n void SetDocument(TDocument&); // Added by Vidar Hasfjord, 2007-08-27.\n\n\n", "file_path": "include_xp/owl/docview.h", "rank": 43, "score": 329738.07504015067 }, { "content": "//\n\n/// \\class TDecoratedFrame\n\n// ~~~~~ ~~~~~~~~~~~~~~~\n\n/// TDecoratedFrame automatically positions its client window (you must supply a\n\n/// client window) so that it is the same size as the client rectangle. You can add\n\n/// additional decorations like toolbars and status lines to a window.You can create\n\n/// a TDecoratedFrame without a caption bar by clearing all of the bits in the style\n\n/// data member of the TWindowAttr structure. TDecoratedFrame is a streamable class.\n\n/// It is virtually derived from TFrameWindow and from TLayoutWindow.\n\n///\n\n/// For OLE-enabled applications, use TOleFrame, which creates a decorated frame and\n\n/// manages decorations such as toolbars for the main window of an SDI (Single\n\n/// Document Interface) OLE application.\n\n//\n\nclass _OWLCLASS TDecoratedFrame : virtual public TFrameWindow,\n\n public TLayoutWindow {\n\n public:\n\n TDecoratedFrame(TWindow* parent,\n\n LPCTSTR title,\n\n TWindow* clientWnd,\n\n bool trackMenuSelection = false,\n\n TModule* module = 0);\n\n TDecoratedFrame(TWindow* parent, const tstring& title, TWindow* client, bool trackMenuSelection = false, TModule* = 0);\n\n ~TDecoratedFrame();\n\n\n\n /// Enumeration describing the possible locations of a Gadgetwindow\n\n /// [Used mainly for location of Toolbar and Statusbar standalone\n\n /// and in the context of docking windows]\n\n //\n\n enum TLocation {\n\n None = alNone, ///< No location specified\n\n Top = alTop, ///< Refers to top edge of frame\n\n Bottom = alBottom, ///< Refers to bottom edge of frame\n\n Left = alLeft, ///< Refers to left edge of frame\n", "file_path": "include/owl/decframe.h", "rank": 44, "score": 329736.2586764194 }, { "content": "", "file_path": "include/owl/tabbed.h", "rank": 45, "score": 329735.00801695295 }, { "content": "//\n\n/// \\class TMDIChild\n\n// ~~~~~ ~~~~~~~~~\n\n/// TMDIChild defines the basic behavior of all MDI child windows. Child windows can\n\n/// be created inside the client area of a parent window. Because child windows\n\n/// exist within, and are restricted to the parent window's borders, the parent\n\n/// window defined before the child is defined. For example, a dialog box is a\n\n/// window that contains child windows, often referred to as dialog box controls.\n\n///\n\n/// To be used as MDI children, classes must be derived from TMDIChild. MDI children\n\n/// can inherit keyboard navigation, focus handling, and icon support from\n\n/// TFrameWindow. TMDIChild is a streamable class.\n\n//\n\nclass _OWLCLASS TMDIChild : virtual public TFrameWindow {\n\n public:\n\n TMDIChild(TMDIClient& parent,\n\n LPCTSTR title = 0,\n\n TWindow* clientWnd = 0,\n\n bool shrinkToClient = false,\n\n TModule* module = 0);\n\n\n\n TMDIChild(TMDIClient& parent,\n\n const tstring& title,\n\n TWindow* clientWnd = 0,\n\n bool shrinkToClient = false,\n\n TModule* module = 0);\n\n\n\n TMDIChild(HWND hWnd, TModule* module = 0);\n\n\n\n ~TMDIChild();\n\n\n\n // Override virtual methods defined by TWindow\n\n //\n", "file_path": "include_xp/owl/mdichild.h", "rank": 46, "score": 329733.4629161785 }, { "content": "/// \\addtogroup module\n\n/// @{\n\n/// \\class TApplication\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Derived from TModule and TMsgThread and virtually derived from TEventHandler,\n\n/// TApplication acts as an object-oriented stand-in for an application module.\n\n/// TApplication and TModule supply the basic behavior required of an application.\n\n/// TApplication member functions create instances of a class, create main windows,\n\n/// and process messages.\n\n///\n\n/// To create an OLE-enabled Doc/View application, you need to derive your\n\n/// application from both TApplication and TOcAppHost.\n\n//\n\nclass _OWLCLASS TApplication : virtual public TEventHandler,\n\n public TModule,\n\n public TMsgThread\n\n{\n\n public:\n\n // Constructors for TApplication. Default args for the ctor allow\n\n // TApplication to access global pointers in the user exe/dll.\n\n // Default OwlAppDictionary can be overridden by passing non-0 appDict arg\n\n //\n\n TApplication\n\n (\n\n const tstring& name = tstring(),\n\n TModule*& = owl::Module,\n\n TAppDictionary* = 0\n\n );\n\n\n\n TApplication\n\n (\n\n const tstring& name,\n\n HINSTANCE hInstance,\n", "file_path": "include_xp/owl/applicat.h", "rank": 47, "score": 329733.17687647894 }, { "content": "//\n\n/// \\class TMDIFrame\n\n// ~~~~~ ~~~~~~~~~\n\n/// Multiple Document Interface (MDI) frame windows, represented by TMDIFrame, are\n\n/// overlapped windows that serve as main windows of MDI-compliant applications.\n\n/// TMDIFrame objects automatically handle creating and initializing an MDI client\n\n/// window (represented by a TMDIClient object) required by Windows. TMDIFrame sets\n\n/// window style WS_CLIPCHILDREN by default so that minimal flicker occurs when the\n\n/// MDI frame erases its background and the backgrounds of its children. TMDIFrame\n\n/// is a streamable class.\n\n/// Because TMDIFrame is derived from TFrameWindow, it inherits keyboard navigation.\n\n/// As a result, all children of the MDI frame acquire keyboard navigation. However,\n\n/// it's best to enable keyboard navigation only for those children who require it.\n\n///\n\n/// To create an OLE-enabled MDI frame window, use TOleMDIFrame, which inherits\n\n/// functionality from both TMDIFrame and TOleFrame.\n\n//\n\nclass _OWLCLASS TMDIFrame : virtual public TFrameWindow {\n\n public:\n\n TMDIFrame(LPCTSTR title,\n\n TResId menuResId,\n\n TMDIClient& clientWnd = *new TMDIClient,\n\n TModule* module = 0);\n\n\n\n TMDIFrame(\n\n const tstring& title,\n\n TResId menuResId,\n\n TMDIClient& client = *new TMDIClient,\n\n TModule* = 0);\n\n\n\n TMDIFrame(THandle frameHandle, HWND clientHandle, TModule* module = 0);\n\n\n\n // Override virtual functions defined by TFrameWindow or TWindow\n\n //\n\n bool SetMenu(HMENU);\n\n\n\n TMDIClient* GetClientWindow();\n", "file_path": "include_xp/owl/mdi.h", "rank": 48, "score": 329731.3041738429 }, { "content": "/// \\addtogroup mixin\n\n/// @{\n\n/// \\class TSerializeReceiver\n\n// ~~~~~ ~~~~~~~~~~~~~~~~~~\n\n/// Mix-in class that automatically puts together the block of data sent by\n\n/// TSerializer.\n\n//\n\nclass _OWLCLASS TSerializeReceiver : virtual public TEventHandler {\n\n public:\n\n TSerializeReceiver();\n\n\n\n // Derived classes should override this function to copy the received data.\n\n // passed to it.\n\n //\n\n virtual void DataReceived(uint32 length, void * data);\n\n\n\n protected:\n\n TResult BlockReceived(TParam1, TParam2);\n\n\n\n private:\n\n char * Data;\n\n char * CurPtr;\n\n uint32 Length;\n\n\n\n DECLARE_RESPONSE_TABLE(TSerializeReceiver);\n\n};\n\n\n", "file_path": "include/owl/serialze.h", "rank": 49, "score": 329730.137220553 }, { "content": "//\n\n/// \\class TDocManager\n\n// ~~~~~ ~~~~~~~~~~~\n\n/// TDocManager creates a document manager object that manages the list of current\n\n/// documents and registered templates, handles standard file menu commands, and\n\n/// displays the user-interface for file and view selection boxes. To provide\n\n/// support for documents and views, an instance of TDocManager must be created by\n\n/// the application and attached to the application.\n\n///\n\n/// The document manager normally handles events on behalf of the documents by using\n\n/// a response table to process the standard CM_FILENEW, CM_FILEOPEN, CM_FILECLOSE,\n\n/// CM_FILESAVE, CM_FILESAVEAS, CM_FILEREVERT, CM_FILEPRINT, CM_FILEPRINTERSETUP,\n\n/// and CM_VIEWCREATE File menu commands. In response to a CM_FILENEW or a\n\n/// CM_FILEOPEN command, the document manager creates the appropriate document based\n\n/// on the user's selections. In response to the other commands, the document\n\n/// manager determines which of the open documents contains the view associated with\n\n/// the window that has focus. The menu commands are first sent to the window that\n\n/// is in focus and then through the parent window chain to the main window and\n\n/// finally to the application, which forwards the commands to the document manager.\n\n///\n\n/// When you create a TDocManager or a derived class, you must specify that it has\n\n/// either a multi-document (dmMDI) or single-document (dmSDI) interface. In\n\n/// addition, if you want the document manager to handle the standard file commands,\n\n/// you must OR dmMDI or dmSDI with dmMenu.\n\n///\n\n/// You can also enable or disable the document manager menu options by passing\n\n/// dmSaveEnable or dmNoRevert in the constructor. If you want to enable the\n\n/// File|Save menu option if the document is unmodified, pass the dmSaveEnable flag\n\n/// in the constructor. To disable the \"Revert to Saved\" menu option, pass\n\n/// dmNoRevert in the constructor.\n\n///\n\n/// When the application directly creates a new document and view, it can attach the\n\n/// view to its frame window, create MDI children, float the window, or create a\n\n/// splitter. However, when the document manager creates a new document and view\n\n/// from the File|Open or File|New menu selection, the application doesn't control\n\n/// the process. To give the application control, the document manager sends\n\n/// messages after the new document and view are successfully created. Then, the\n\n/// application can use the information contained in the template to determine how\n\n/// to install the new document or view object.\n\n//\n\nclass _OWLCLASS TDocManager : virtual public TEventHandler,\n\n virtual public TStreamableBase {\n\n public:\n\n TDocManager(int mode, TApplication* app,\n\n TDocTemplate*& templateHead = DocTemplateStaticHead);\n\n virtual ~TDocManager();\n\n\n\n // Retrieve template info: count, list or descriptions\n\n //\n\n int GetTemplateCount(TDocument* ofDocType = 0,\n\n TView* ofViewType = 0);\n\n virtual int GetNewTemplates(TDocTemplate** tplList, int size,\n\n bool newDoc);\n\n virtual int GetSaveTemplates(TDocTemplate** tplList, int size,\n\n TDocument& doc, bool sameDoc);\n\n virtual int GetViewTemplates(TDocTemplate** tplList, int size,\n\n TDocument& doc);\n\n virtual int GetTemplateDescription(TDocTemplate** tpllist,\n\n int tplcount, tchar* buff = 0,\n\n int size = 0);\n", "file_path": "include/owl/docmanag.h", "rank": 50, "score": 329729.0946306224 }, { "content": "//\n\n/// \\class TRecentFiles\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// TRecentFiles implements a most-recent files list, designed to be mixed in with\n\n/// TApplication. The list is appended to the menu with CM_FILEOPEN and CM_FILECLOSE\n\n/// options.\n\n//\n\nclass _OWLCLASS TRecentFiles : virtual public TEventHandler\n\n{\n\n public:\n\n enum { MaxMenuItems = 10 };\n\n\n\n TRecentFiles(const tstring& iniOrKeyName, int numSavedFiles = MaxMenuItems,\n\n int namelen = 30, bool useRegistry=false);\n\n virtual ~TRecentFiles();\n\n\n\n void SaveMenuChoice(LPCTSTR text);\n\n void SaveMenuChoice(const tstring& text) {SaveMenuChoice(text.c_str());}\n\n void RemoveMenuChoice(LPCTSTR text);\n\n void RemoveMenuChoice(const tstring& text) {RemoveMenuChoice(text.c_str());}\n\n bool GetMenuText(int id, LPTSTR text, int maxTextLen);\n\n tstring GetMenuText(int id);\n\n void SetMaxMruItems(int maxValue);\n\n void SetDispLength(const int);\n\n void EnableRegistry(bool enable = true);\n\n int GetMruCount();\n\n\n", "file_path": "include/owl/rcntfile.h", "rank": 51, "score": 329728.4106660548 }, { "content": "class OWLEXTCLASS TDoubleValidator : public owl::TFilterValidator {\n\n public:\n\n TDoubleValidator(double minValue, double maxValue);\n\n\n\n // Override TValidator's virtuals\n\n //\n\n void Error(owl::TWindow* owner);\n\n bool IsValid(LPCTSTR str);\n\n bool IsValidInput(LPTSTR str, bool /*suppressFill*/);\n\n owl::uint Transfer(LPTSTR str, void* buffer, owl::TTransferDirection direction);\n\n int Adjust(owl::tstring& text, owl::uint& begPos, owl::uint& endPos, int amount);\n\n\n\n protected:\n\n double GetMin() {return Min;};\n\n void SetMin(double minValue) {Min=minValue;};\n\n double GetMax() {return Max;}\n\n void SetMax(double maxValue) {Max=maxValue;};\n\n\n\n double Min;\n\n double Max;\n", "file_path": "include/owlext/validate.h", "rank": 52, "score": 329596.40757090016 }, { "content": " class Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n private: \\\n\n cls *object; \\\n\n \\\n\n }; \\\n\n friend class Streamer; \\\n\n friend void ::owl:: READBASEOBJECT( cls ); \\\n\n friend void ::owl:: WRITEBASEOBJECT( cls );\\\n\n friend void ::owl:: READVIRTUALBASE( cls );\\\n\n friend void ::owl:: WRITEVIRTUALBASE( cls )\n\n\n\n#define DECLARE_ABSTRACT_STREAMER( exp, cls, ver ) \\\n\npublic: \\\n", "file_path": "include/owl/objstrm.h", "rank": 53, "score": 327473.28465569124 }, { "content": " class Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n static ::owl::TStreamer *Build( ::owl::TStreamableBase *obj ) \\\n\n { \\\n\n return new Streamer( obj ? obj : new cls(::owl::streamableInit) ); \\\n", "file_path": "include/owl/objstrm.h", "rank": 54, "score": 327473.2846556912 }, { "content": "//\n\n// class TFontSample\n\n// ~~~~~ ~~~~~~~~~~~\n\n//\n\nclass _COOLCLASS TFontSample : public owl::TStatic {\n\n public:\n\n TFontSample(owl::TWindow*, int resId, owl::TModule *module = 0);\n\n void SetupWindow ();\n\n void Paint (owl::TDC&, bool, owl::TRect&);\n\n void SetTextColor(const owl::TColor& clr);\n\n void SetBkColor(const owl::TColor& clr);\n\n private:\n\n owl::TColor TextColor;\n\n owl::TColor BkColor;\n\n};\n\n\n", "file_path": "include_xp/coolprj/clrpropdlg.h", "rank": 55, "score": 326392.9088676855 }, { "content": "class OWLEXTCLASS TStaticBitmap : public owl::TStatic {\n\n // Object lifetime methods\n\npublic:\n\n TStaticBitmap(owl::TWindow* parent, owl::TBitmap* user_bitmap, owl::TPalette* user_palette,\n\n int id, int x, int y, int width, int height, bool flag=false,\n\n bool use_aspect=false,bool use_mask=true);\n\n virtual ~TStaticBitmap();\n\n\n\n // Mutators\n\n //\n\npublic:\n\n void SetText(LPTSTR text);\n\n void UpdateBitmap(owl::TBitmap* user_bitmap,int x,int y,int width,int height,\n\n bool use_mask=true);\n\n bool IsOver(owl::TPoint& point);\n\n void Select(bool flag);\n\n\n\n // OWL overrides\n\n //\n\nprotected:\n", "file_path": "include_xp/owlext/staticbm.h", "rank": 56, "score": 326385.7028780008 }, { "content": "class OWLEXTCLASS TColorPicker : public owl::TWindow {\n\n public:\n\n TColorPicker(owl::TWindow* parent,\n\n const TColorPickerData& data,\n\n owl::TColor startColor,\n\n int refId,\n\n LPCTSTR title = 0,\n\n owl::TModule* module = 0);\n\n virtual ~TColorPicker();\n\n\n\n public:\n\n virtual TGetClassNameReturnType GetClassName();\n\n virtual void GetWindowClass(WNDCLASS& wndClass);\n\n virtual void Paint(owl::TDC& dc, bool erase, owl::TRect& rect);\n\n virtual void SetupWindow();\n\n virtual void ShowPickerWindow(owl::TPoint& pt, owl::TRect& rect);\n\n virtual bool PreProcessMsg(MSG& msg);\n\n virtual owl::TColor GetCurrentChosenColor();\n\n virtual void SetCurrentChosenColor(owl::TColor color);\n\n virtual void NotifyAtParent();\n", "file_path": "include_xp/owlext/colpick.h", "rank": 57, "score": 326317.73761924147 }, { "content": "//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n// TTabWindow\n\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nclass OWLEXTCLASS TTabWindow : public owl::TWindow {\n\n // Object lifetime methods\n\n //\n\npublic:\n\n TTabWindow(owl::TWindow* parent, owl::TWindow* array[] = 0);\n\n TTabWindow(owl::TWindow* parent, owl::uint32 X, owl::uint32 Y, owl::uint32 W, owl::uint32 H, owl::TWindow* array[] = 0);\n\nprivate:\n\n TTabWindow(); // DISALLOWED METHOD\n\n TTabWindow(const TTabWindow&); // DISALLOWED METHOD\n\n TTabWindow& operator=(const TTabWindow& src); // DISALLOWED METHOD\n\n\n\n // Tabbed-window interface: adding windows, removing windows\n\n //\n\npublic:\n\n virtual void Attach(owl::TWindow* ptr, LPCTSTR title = 0);\n\n virtual void Attach(owl::TWindow* windowArray[]);\n\n virtual owl::TWindow* Detach(owl::int32 index) = 0;\n\n virtual owl::TWindow* Detach(owl::TWindow* ptr)\n\n { return Detach(Retrieve(ptr)); }\n\n virtual owl::TWindow* Retrieve(owl::int32 index)\n", "file_path": "include_xp/owlext/tabwin.h", "rank": 58, "score": 326317.73761924147 }, { "content": "//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n// TPictDecorator\n\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nclass OWLEXTCLASS TPictDecorator : public owl::TWindow\n\n{\n\n // Object lifetime methods\n\n //\n\npublic:\n\n TPictDecorator(owl::TDib* dib, owl::TWindow& parent);\n\n virtual ~TPictDecorator();\n\n\n\n // OWL overrides\n\n //\n\nprotected:\n\n DECLARE_RESPONSE_TABLE(TPictDecorator);\n\n virtual bool EvEraseBkgnd(HDC hdc);\n\n virtual void EvSize(owl::uint sizeType, const owl::TSize& size);\n\n\n\n /*\n\n // This was how the code was originally written; however, in order to give you\n\n // a demonstration of how to use the TProperty<> mechanism in PROPERTY.H, I've\n\n // chosen to use the TProperty<> mechanism to control the m_pdib member.\n\n\n", "file_path": "include_xp/owlext/pictdeco.h", "rank": 59, "score": 326317.73761924147 }, { "content": "#define DECLARE_DIAG_GROUP(group, qual)\\\n\n class qual TDiagGroup##group : public ::owl::TDiagBase {\\\n\n DECLARE_DIAG_GROUP_COMMON(group)\n\n\n", "file_path": "include/owl/private/checks.h", "rank": 60, "score": 326076.2512822276 }, { "content": "class _OWLCLASS THlpEnumIt : public HH_ENUM_IT {\n\n public:\n\n THlpEnumIt()\n\n {\n\n ZeroMemory(this,sizeof(HH_ENUM_IT));\n\n cbStruct = sizeof(HH_ENUM_IT);\n\n }\n\n};\n\n\n", "file_path": "include/owl/hlpmanag.h", "rank": 61, "score": 325552.97638301103 }, { "content": "//\n\n/// \\class TDecoratedFrame\n\n// ~~~~~ ~~~~~~~~~~~~~~~\n\n/// TDecoratedFrame automatically positions its client window (you must supply a\n\n/// client window) so that it is the same size as the client rectangle. You can add\n\n/// additional decorations like toolbars and status lines to a window.You can create\n\n/// a TDecoratedFrame without a caption bar by clearing all of the bits in the style\n\n/// data member of the TWindowAttr structure. TDecoratedFrame is a streamable class.\n\n/// It is virtually derived from TFrameWindow and from TLayoutWindow.\n\n///\n\n/// For OLE-enabled applications, use TOleFrame, which creates a decorated frame and\n\n/// manages decorations such as toolbars for the main window of an SDI (Single\n\n/// Document Interface) OLE application.\n\n//\n\nclass _OWLCLASS TDecoratedFrame : virtual public TFrameWindow,\n\n public TLayoutWindow {\n\n public:\n\n TDecoratedFrame(TWindow* parent,\n\n LPCTSTR title,\n\n TWindow* clientWnd,\n\n bool trackMenuSelection = false,\n\n TModule* module = 0);\n\n TDecoratedFrame(TWindow* parent, const tstring& title, TWindow* client, bool trackMenuSelection = false, TModule* = 0);\n\n ~TDecoratedFrame();\n\n\n\n /// Enumeration describing the possible locations of a Gadgetwindow\n\n /// [Used mainly for location of Toolbar and Statusbar standalone\n\n /// and in the context of docking windows]\n\n //\n\n enum TLocation {\n\n None = alNone, ///< No location specified\n\n Top = alTop, ///< Refers to top edge of frame\n\n Bottom = alBottom, ///< Refers to bottom edge of frame\n\n Left = alLeft, ///< Refers to left edge of frame\n", "file_path": "include_xp/owl/decframe.h", "rank": 62, "score": 322928.90225952317 }, { "content": "", "file_path": "include_xp/owl/tabbed.h", "rank": 63, "score": 322927.6516000567 }, { "content": "//\n\n/// \\class THelpFileManager\n\n// ~~~~~ ~~~~~~~~~~~~~~~~\n\n/// THelpFileManager, which is designed to be a mix-in for TApplication, uses the\n\n/// global context table. THelpFileManager looks for the WM_HELP message and calls\n\n/// the help file with the associated context ID.\n\n/// \\todo HTMLHelp should be by default, and discourage using old WinHelp files\n\n/// as they are not well supported under Windows Vista and later\n\n//\n\nclass _OWLCLASS THelpFileManager : virtual public TEventHandler {\n\n public:\n\nDECLARE_CASTABLE;\n\n THelpFileManager(const tstring& helpFileName);\n\n virtual ~THelpFileManager();\n\n\n\n virtual void ActivateHelp(TWindow*, int helpFileContextId, uint hlpCmd = HELP_CONTEXT);\n\n virtual void DeactivateHelp();\n\n\n\n void SetHelpFile(const tstring& helpFileName);\n\n tstring GetHelpFile() const;\n\n\n\n bool GetHelpContextFromControl(THelpContext&, int controlId, HWND ctrl) const;\n\n bool GetHelpContextFromMenu(THelpContext&, int menuId) const;\n\n\n\n void AddContextInfo(TWindow*, int helpId, int menuId, int controlId);\n\n void RemoveContextInfo(TWindow*);\n\n\n\n protected:\n\n virtual bool ProcessHelpMsg (MSG& msg);\n", "file_path": "include/owl/hlpmanag.h", "rank": 64, "score": 322926.6238236667 }, { "content": "/// \\addtogroup mixin\n\n/// @{\n\n/// \\class TSerializeReceiver\n\n// ~~~~~ ~~~~~~~~~~~~~~~~~~\n\n/// Mix-in class that automatically puts together the block of data sent by\n\n/// TSerializer.\n\n//\n\nclass _OWLCLASS TSerializeReceiver : virtual public TEventHandler {\n\n public:\n\n TSerializeReceiver();\n\n\n\n // Derived classes should override this function to copy the received data.\n\n // passed to it.\n\n //\n\n virtual void DataReceived(uint32 length, void * data);\n\n\n\n protected:\n\n TResult BlockReceived(TParam1, TParam2);\n\n\n\n private:\n\n char * Data;\n\n char * CurPtr;\n\n uint32 Length;\n\n\n\n DECLARE_RESPONSE_TABLE(TSerializeReceiver);\n\n};\n\n\n", "file_path": "include_xp/owl/serialze.h", "rank": 65, "score": 322922.78080365673 }, { "content": "//\n\n/// \\class TDocManager\n\n// ~~~~~ ~~~~~~~~~~~\n\n/// TDocManager creates a document manager object that manages the list of current\n\n/// documents and registered templates, handles standard file menu commands, and\n\n/// displays the user-interface for file and view selection boxes. To provide\n\n/// support for documents and views, an instance of TDocManager must be created by\n\n/// the application and attached to the application.\n\n///\n\n/// The document manager normally handles events on behalf of the documents by using\n\n/// a response table to process the standard CM_FILENEW, CM_FILEOPEN, CM_FILECLOSE,\n\n/// CM_FILESAVE, CM_FILESAVEAS, CM_FILEREVERT, CM_FILEPRINT, CM_FILEPRINTERSETUP,\n\n/// and CM_VIEWCREATE File menu commands. In response to a CM_FILENEW or a\n\n/// CM_FILEOPEN command, the document manager creates the appropriate document based\n\n/// on the user's selections. In response to the other commands, the document\n\n/// manager determines which of the open documents contains the view associated with\n\n/// the window that has focus. The menu commands are first sent to the window that\n\n/// is in focus and then through the parent window chain to the main window and\n\n/// finally to the application, which forwards the commands to the document manager.\n\n///\n\n/// When you create a TDocManager or a derived class, you must specify that it has\n\n/// either a multi-document (dmMDI) or single-document (dmSDI) interface. In\n\n/// addition, if you want the document manager to handle the standard file commands,\n\n/// you must OR dmMDI or dmSDI with dmMenu.\n\n///\n\n/// You can also enable or disable the document manager menu options by passing\n\n/// dmSaveEnable or dmNoRevert in the constructor. If you want to enable the\n\n/// File|Save menu option if the document is unmodified, pass the dmSaveEnable flag\n\n/// in the constructor. To disable the \"Revert to Saved\" menu option, pass\n\n/// dmNoRevert in the constructor.\n\n///\n\n/// When the application directly creates a new document and view, it can attach the\n\n/// view to its frame window, create MDI children, float the window, or create a\n\n/// splitter. However, when the document manager creates a new document and view\n\n/// from the File|Open or File|New menu selection, the application doesn't control\n\n/// the process. To give the application control, the document manager sends\n\n/// messages after the new document and view are successfully created. Then, the\n\n/// application can use the information contained in the template to determine how\n\n/// to install the new document or view object.\n\n//\n\nclass _OWLCLASS TDocManager : virtual public TEventHandler,\n\n virtual public TStreamableBase {\n\n public:\n\n TDocManager(int mode, TApplication* app,\n\n TDocTemplate*& templateHead = DocTemplateStaticHead);\n\n virtual ~TDocManager();\n\n\n\n // Retrieve template info: count, list or descriptions\n\n //\n\n int GetTemplateCount(TDocument* ofDocType = 0,\n\n TView* ofViewType = 0);\n\n virtual int GetNewTemplates(TDocTemplate** tplList, int size,\n\n bool newDoc);\n\n virtual int GetSaveTemplates(TDocTemplate** tplList, int size,\n\n TDocument& doc, bool sameDoc);\n\n virtual int GetViewTemplates(TDocTemplate** tplList, int size,\n\n TDocument& doc);\n\n virtual int GetTemplateDescription(TDocTemplate** tpllist,\n\n int tplcount, tchar* buff = 0,\n\n int size = 0);\n", "file_path": "include_xp/owl/docmanag.h", "rank": 66, "score": 322921.7382137262 }, { "content": "//\n\n/// \\class TRecentFiles\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// TRecentFiles implements a most-recent files list, designed to be mixed in with\n\n/// TApplication. The list is appended to the menu with CM_FILEOPEN and CM_FILECLOSE\n\n/// options.\n\n//\n\nclass _OWLCLASS TRecentFiles : virtual public TEventHandler\n\n{\n\n public:\n\n enum { MaxMenuItems = 10 };\n\n\n\n TRecentFiles(const tstring& iniOrKeyName, int numSavedFiles = MaxMenuItems,\n\n int namelen = 30, bool useRegistry=false);\n\n virtual ~TRecentFiles();\n\n\n\n void SaveMenuChoice(LPCTSTR text);\n\n void SaveMenuChoice(const tstring& text) {SaveMenuChoice(text.c_str());}\n\n void RemoveMenuChoice(LPCTSTR text);\n\n void RemoveMenuChoice(const tstring& text) {RemoveMenuChoice(text.c_str());}\n\n bool GetMenuText(int id, LPTSTR text, int maxTextLen);\n\n tstring GetMenuText(int id);\n\n void SetMaxMruItems(int maxValue);\n\n void SetDispLength(const int);\n\n void EnableRegistry(bool enable = true);\n\n int GetMruCount();\n\n\n", "file_path": "include_xp/owl/rcntfile.h", "rank": 67, "score": 322921.0542491586 }, { "content": "class OWLEXTCLASS TDoubleValidator : public owl::TFilterValidator {\n\n public:\n\n TDoubleValidator(double minValue, double maxValue);\n\n\n\n // Override TValidator's virtuals\n\n //\n\n void Error(owl::TWindow* owner);\n\n bool IsValid(LPCTSTR str);\n\n bool IsValidInput(LPTSTR str, bool /*suppressFill*/);\n\n owl::uint Transfer(LPTSTR str, void* buffer, owl::TTransferDirection direction);\n\n int Adjust(owl::tstring& text, owl::uint& begPos, owl::uint& endPos, int amount);\n\n\n\n protected:\n\n double GetMin() {return Min;};\n\n void SetMin(double minValue) {Min=minValue;};\n\n double GetMax() {return Max;}\n\n void SetMax(double maxValue) {Max=maxValue;};\n\n\n\n double Min;\n\n double Max;\n", "file_path": "include_xp/owlext/validate.h", "rank": 68, "score": 322788.7383607943 }, { "content": " class Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n static ::owl::TStreamer *Build( ::owl::TStreamableBase *obj ) \\\n\n { \\\n\n return new Streamer( obj ? obj : new cls(::owl::streamableInit) ); \\\n", "file_path": "include_xp/owl/objstrm.h", "rank": 69, "score": 320993.1855056828 }, { "content": " class Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n private: \\\n\n cls *object; \\\n\n \\\n\n }; \\\n\n friend class Streamer; \\\n\n friend void ::owl:: READBASEOBJECT( cls ); \\\n\n friend void ::owl:: WRITEBASEOBJECT( cls );\\\n\n friend void ::owl:: READVIRTUALBASE( cls );\\\n\n friend void ::owl:: WRITEVIRTUALBASE( cls )\n\n\n\n#define DECLARE_ABSTRACT_STREAMER( exp, cls, ver ) \\\n\npublic: \\\n", "file_path": "include_xp/owl/objstrm.h", "rank": 70, "score": 320993.1855056828 }, { "content": "#define DECLARE_DIAG_GROUP(group, qual)\\\n\n class qual TDiagGroup##group : public ::owl::TDiagBase {\\\n\n DECLARE_DIAG_GROUP_COMMON(group)\n\n\n", "file_path": "include_xp/owl/private/checks.h", "rank": 71, "score": 320058.91134207253 }, { "content": " //--------------------------------------------------\n\n // class TDimMap\n\n // ~~~~~ ~~~~~~~\n\n class TDimMap: public std::map<int,int\n\n #if defined(RWSTD_NO_DEFAULT_TEMPLATES) // for BC++ 5.0x compatibility\n\n ,std::less<int>\n\n #endif\n\n >{\n\n public:\n\n TDimMap(){}\n\n };\n", "file_path": "include/coolprj/coolgrid.h", "rank": 72, "score": 318260.16330297576 }, { "content": "class _OWLCLASS THlpEnumIt : public HH_ENUM_IT {\n\n public:\n\n THlpEnumIt()\n\n {\n\n ZeroMemory(this,sizeof(HH_ENUM_IT));\n\n cbStruct = sizeof(HH_ENUM_IT);\n\n }\n\n};\n\n\n", "file_path": "include_xp/owl/hlpmanag.h", "rank": 73, "score": 317885.9433895659 }, { "content": "//\n\n/// \\class TEnProtected\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Structure sent with EN_PROTECTED notification\n\n//\n\nclass _OWLCLASS TEnProtected : public ENPROTECTED {\n\n public:\n\n/// Allows the notification structure to be transparently treated as an NMHDR\n\n/// structure, thereby eliminating the need to explicitly refer to the NMHDR data\n\n/// member (which is always the first member of notification structures).\n\n operator NMHDR&() { return nmhdr; }\n\n};\n\n\n", "file_path": "include/owl/commctrl.h", "rank": 74, "score": 317024.67862297513 }, { "content": "//\n\n/// \\class THelpFileManager\n\n// ~~~~~ ~~~~~~~~~~~~~~~~\n\n/// THelpFileManager, which is designed to be a mix-in for TApplication, uses the\n\n/// global context table. THelpFileManager looks for the WM_HELP message and calls\n\n/// the help file with the associated context ID.\n\n/// \\todo HTMLHelp should be by default, and discourage using old WinHelp files\n\n/// as they are not well supported under Windows Vista and later\n\n//\n\nclass _OWLCLASS THelpFileManager : virtual public TEventHandler {\n\n public:\n\nDECLARE_CASTABLE;\n\n THelpFileManager(const tstring& helpFileName);\n\n virtual ~THelpFileManager();\n\n\n\n virtual void ActivateHelp(TWindow*, int helpFileContextId, uint hlpCmd = HELP_CONTEXT);\n\n virtual void DeactivateHelp();\n\n\n\n void SetHelpFile(const tstring& helpFileName);\n\n tstring GetHelpFile() const;\n\n\n\n bool GetHelpContextFromControl(THelpContext&, int controlId, HWND ctrl) const;\n\n bool GetHelpContextFromMenu(THelpContext&, int menuId) const;\n\n\n\n void AddContextInfo(TWindow*, int helpId, int menuId, int controlId);\n\n void RemoveContextInfo(TWindow*);\n\n\n\n protected:\n\n virtual bool ProcessHelpMsg (MSG& msg);\n", "file_path": "include_xp/owl/hlpmanag.h", "rank": 75, "score": 316537.2908229128 }, { "content": "//\n\n/// \\class TDragListEventHandler\n\n// ~~~~~ ~~~~~~~~~~~~~~~~~~~~~\n\n/// A TEventHandler mix-in.\n\n/// This class is designed to handle the drag list notifications and\n\n/// forward the messages from the parent window to the TDragList class.\n\n//\n\nclass _OWLCLASS TDragListEventHandler : virtual public TEventHandler {\n\n public:\n\n TResult DragNotify(TParam1, TParam2);\n\n\n\n DECLARE_RESPONSE_TABLE(TDragListEventHandler);\n\n};\n\n/// @}\n\n\n\n// Generic definitions/compiler options (eg. alignment) following the\n\n// definition of classes\n\n#include <owl/posclass.h>\n\n\n\n\n\n} // OWL namespace\n\n\n\n\n\n#endif // OWL_DRAGLIST_H\n\n\n", "file_path": "include/owl/draglist.h", "rank": 76, "score": 316533.76659924124 }, { "content": "class OWLEXTCLASS TGaugeGadget : public owl::TGadget, public owl::TGauge\n\n{\n\n // Object lifetime methods\n\n //\n\npublic:\n\n TGaugeGadget(int id, LPCTSTR title, int width, TBorderStyle = None);\n\n ~TGaugeGadget();\n\n\n\nprotected:\n\n virtual void Paint(owl::TDC& dc, bool erase, owl::TRect& rect);\n\n // Overriden to change the font to the GagdetWindow font\n\n virtual void Paint(owl::TDC& dc)\n\n { owl::TGadget::Paint(dc); }\n\n\n\n virtual void Created();\n\n virtual void Inserted();\n\n virtual void Removed();\n\n\n\n virtual void InvalidateRect(const owl::TRect& rect, bool erase = true);\n\n virtual void Update();\n", "file_path": "include/owlext/gaugegad.h", "rank": 77, "score": 313782.0625820999 }, { "content": " class exp Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n static ::owl::TStreamer *Build( ::owl::TStreamableBase *obj ) \\\n\n { \\\n\n return new Streamer( obj ? obj : new cls(::owl::streamableInit) ); \\\n", "file_path": "include/owl/objstrm.h", "rank": 78, "score": 313471.01186597114 }, { "content": " class exp Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n private: \\\n\n cls *object; \\\n\n \\\n", "file_path": "include/owl/objstrm.h", "rank": 79, "score": 313471.01186597114 }, { "content": " //--------------------------------------------------\n\n // class TDimMap\n\n // ~~~~~ ~~~~~~~\n\n class TDimMap: public std::map<int,int\n\n #if defined(RWSTD_NO_DEFAULT_TEMPLATES) // for BC++ 5.0x compatibility\n\n ,std::less<int>\n\n #endif\n\n >{\n\n public:\n\n TDimMap(){}\n\n };\n", "file_path": "include_xp/coolprj/coolgrid.h", "rank": 80, "score": 312489.02178140247 }, { "content": "//\n\n/// \\class TStatic\n\n// ~~~~~ ~~~~~~~\n\n/// An interface object that represents a static text interface element. Static\n\n/// elements consist of text or graphics that the user does not change. An\n\n/// application, however, can modify the static control. You must use a TStatic\n\n/// object, for example, to create a static control that's used to display a text\n\n/// label such as a copyright notice in a parent TWindow object. TStatic can also be\n\n/// used to make it easier to modify the text of static controls in TDialog objects.\n\n/// See the sample program in the EXAMPLES\\\\OWL\\\\OWLAPI\\\\STATIC directory for an\n\n/// example of a static control.\n\nclass _OWLCLASS TStatic : public TControl {\n\n public:\n\n\n\n //\n\n // For use with GetImage and SetImage.\n\n //\n\n enum TImageType\n\n {\n\n Bitmap = IMAGE_BITMAP,\n\n Icon = IMAGE_ICON,\n\n Cursor = IMAGE_CURSOR,\n\n EnhMetaFile = IMAGE_ENHMETAFILE\n\n };\n\n\n\n TStatic(TWindow* parent, int id, LPCTSTR title, int x, int y, int w, int h,\n\n uint textLen = 0, TModule* = 0);\n\n TStatic(TWindow* parent, int id, const tstring& title, int x, int y, int w, int h,\n\n uint textLen = 0, TModule* = 0);\n\n TStatic(TWindow* parent, int resourceId, uint textLen = 0, TModule* = 0);\n\n TStatic(TWindow* parent, int resourceId, const tstring& title, uint textLimit = 0, TModule* = 0);\n", "file_path": "include/owl/static.h", "rank": 81, "score": 311694.45950468554 }, { "content": "/// \\addtogroup ctrl\n\n/// @{\n\n/// \\class TEdit\n\n// ~~~~~ ~~~~~\n\nclass _OWLCLASS TEdit : public TStatic {\n\n public:\n\n TEdit(TWindow* parent, int id, LPCTSTR text, int x, int y, int w, int h, \n\n uint textLimit = 0, bool multiline = false, TModule* = 0);\n\n TEdit(TWindow* parent, int id, const tstring& text, int x, int y, int w, int h,\n\n uint textLimit = 0, bool multiline = false, TModule* = 0);\n\n TEdit(TWindow* parent, int resourceId, uint textLimit = 0, TModule* = 0);\n\n TEdit(THandle hWnd, TModule* = 0);\n\n\n\n ~TEdit();\n\n\n\n /// Represents a half-open range of positions in the edit control, e.g. a selection range.\n\n /// The default range is [0, -1) for compatibility with TCharRange (see \"richedit.h\").\n\n //\n\n struct TRange\n\n {\n\n TRange(int b = 0, int e = -1) : cpMin(b), cpMax(e) {}\n\n\n\n int GetSize() const {return cpMax - cpMin;}\n\n\n", "file_path": "include/owl/edit.h", "rank": 82, "score": 311686.1116487534 }, { "content": "//\n\n/// \\class THarbor\n\n// ~~~~~ ~~~~~~~\n\n/// THarbor is the object that holds all the docking slips. It performs the actual\n\n/// docking insertion and coordination. It is never visible; it is a window in order\n\n/// to capture the mouse.\n\n//\n\nclass _OWLCLASS THarbor : public TWindow {\n\n public:\n\n THarbor(TDecoratedFrame& df);\n\n ~THarbor();\n\n\n\n /// Dockable window insertion\n\n //\n\n TDockingSlip* Insert(TDockable& dockable,\n\n TAbsLocation location,\n\n const TPoint* where = 0,\n\n TRelPosition position = rpNone,\n\n TDockable* relativeTo = 0);\n\n\n\n /// Move a dockable from one slip to another, programatically\n\n //\n\n void Move(TDockable& dockable,\n\n TAbsLocation location,\n\n const TPoint* where = 0,\n\n TRelPosition position = rpNone,\n\n TDockable* relativeTo = 0);\n", "file_path": "include/owl/docking.h", "rank": 83, "score": 311612.72978272446 }, { "content": "//\n\n/// \\class TDragListEventHandler\n\n// ~~~~~ ~~~~~~~~~~~~~~~~~~~~~\n\n/// A TEventHandler mix-in.\n\n/// This class is designed to handle the drag list notifications and\n\n/// forward the messages from the parent window to the TDragList class.\n\n//\n\nclass _OWLCLASS TDragListEventHandler : virtual public TEventHandler {\n\n public:\n\n TResult DragNotify(TParam1, TParam2);\n\n\n\n DECLARE_RESPONSE_TABLE(TDragListEventHandler);\n\n};\n\n/// @}\n\n\n\n// Generic definitions/compiler options (eg. alignment) following the\n\n// definition of classes\n\n#include <owl/posclass.h>\n\n\n\n\n\n} // OWL namespace\n\n\n\n\n\n#endif // OWL_DRAGLIST_H\n\n\n", "file_path": "include_xp/owl/draglist.h", "rank": 84, "score": 310525.0993161743 }, { "content": "class OWLEXTCLASS TGaugeGadget : public owl::TGadget, public owl::TGauge\n\n{\n\n // Object lifetime methods\n\n //\n\npublic:\n\n TGaugeGadget(int id, LPCTSTR title, int width, TBorderStyle = None);\n\n ~TGaugeGadget();\n\n\n\nprotected:\n\n virtual void Paint(owl::TDC& dc, bool erase, owl::TRect& rect);\n\n // Overriden to change the font to the GagdetWindow font\n\n virtual void Paint(owl::TDC& dc)\n\n { owl::TGadget::Paint(dc); }\n\n\n\n virtual void Created();\n\n virtual void Inserted();\n\n virtual void Removed();\n\n\n\n virtual void InvalidateRect(const owl::TRect& rect, bool erase = true);\n\n virtual void Update();\n", "file_path": "include_xp/owlext/gaugegad.h", "rank": 85, "score": 309228.23079311836 }, { "content": "//\n\n/// \\class TEnProtected\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// Structure sent with EN_PROTECTED notification\n\n//\n\nclass _OWLCLASS TEnProtected : public ENPROTECTED {\n\n public:\n\n/// Allows the notification structure to be transparently treated as an NMHDR\n\n/// structure, thereby eliminating the need to explicitly refer to the NMHDR data\n\n/// member (which is always the first member of notification structures).\n\n operator NMHDR&() { return nmhdr; }\n\n};\n\n\n", "file_path": "include_xp/owl/commctrl.h", "rank": 86, "score": 308683.61905339616 }, { "content": " class exp Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n static ::owl::TStreamer *Build( ::owl::TStreamableBase *obj ) \\\n\n { \\\n\n return new Streamer( obj ? obj : new cls(::owl::streamableInit) ); \\\n", "file_path": "include_xp/owl/objstrm.h", "rank": 87, "score": 307397.60065782623 }, { "content": " class exp Streamer : public ::owl::TNewStreamer \\\n\n { \\\n\n public: \\\n\n \\\n\n Streamer( ::owl::TStreamableBase *obj ); \\\n\n \\\n\n virtual ::owl::uint32 ClassVersion() const \\\n\n { return ver; } \\\n\n \\\n\n virtual void Write( ::owl::opstream& ) const; \\\n\n virtual void *Read( ::owl::ipstream&, ::owl::uint32 ) const; \\\n\n \\\n\n cls *GetObject() const \\\n\n { \\\n\n return object; \\\n\n } \\\n\n \\\n\n private: \\\n\n cls *object; \\\n\n \\\n", "file_path": "include_xp/owl/objstrm.h", "rank": 88, "score": 307397.60065782623 }, { "content": "//\n\n/// \\class TStatic\n\n// ~~~~~ ~~~~~~~\n\n/// An interface object that represents a static text interface element. Static\n\n/// elements consist of text or graphics that the user does not change. An\n\n/// application, however, can modify the static control. You must use a TStatic\n\n/// object, for example, to create a static control that's used to display a text\n\n/// label such as a copyright notice in a parent TWindow object. TStatic can also be\n\n/// used to make it easier to modify the text of static controls in TDialog objects.\n\n/// See the sample program in the EXAMPLES\\\\OWL\\\\OWLAPI\\\\STATIC directory for an\n\n/// example of a static control.\n\nclass _OWLCLASS TStatic : public TControl {\n\n public:\n\n\n\n //\n\n // For use with GetImage and SetImage.\n\n //\n\n enum TImageType\n\n {\n\n Bitmap = IMAGE_BITMAP,\n\n Icon = IMAGE_ICON,\n\n Cursor = IMAGE_CURSOR,\n\n EnhMetaFile = IMAGE_ENHMETAFILE\n\n };\n\n\n\n TStatic(TWindow* parent, int id, LPCTSTR title, int x, int y, int w, int h,\n\n uint textLen = 0, TModule* = 0);\n\n TStatic(TWindow* parent, int id, const tstring& title, int x, int y, int w, int h,\n\n uint textLen = 0, TModule* = 0);\n\n TStatic(TWindow* parent, int resourceId, uint textLen = 0, TModule* = 0);\n\n TStatic(TWindow* parent, int resourceId, const tstring& title, uint textLimit = 0, TModule* = 0);\n", "file_path": "include_xp/owl/static.h", "rank": 89, "score": 305068.96902209695 }, { "content": "//\n\n/// \\class TUrlLink\n\n// ~~~~~ ~~~~~~~~\n\n/// Derived from TStatic, TUrlLink will open the default browser with the given URL\n\n/// when the user clicks on the link.\n\n/// \n\n/// This is a simple hyperlink control that can be plugged into any dialog. The\n\n/// hyperlink is initially colored blue, but changes color when the cursor is over\n\n/// it, and after the user has clicked on it. The cursor that appears when the mouse\n\n/// pointer is over the link can easily be set using SetCursor(), as can the link\n\n/// colors and underlining. The default cursor is a small pointing hand (cursor from\n\n/// OWL.DLL or #106 from the winhlp32.exe). There is also a ToolTip for the link\n\n/// that displays the underlying URL of the control. The control can auto-size\n\n/// itself to fit the size of the caption (to preserve a true hyperlink look and\n\n/// feel). The resizing will honor the SS_CENTERIMAGE, SS_LEFT, SS_RIGHT and\n\n/// SS_CENTER flags. To actually follow the link, \"ShellExecute\" is called to open\n\n/// the URL, but if this fails, then the registry is examined in order to find a\n\n/// likely candidate for .html files. If one is found then this it is launched with\n\n/// the hope that it can handle the URL string supplied. In any case, an error\n\n/// message is displayed on failure.\n\n///\n\n/// Examples\n\n/// - In a dialog constructor:\n\n/// \\code\n\n/// TUrlLink* link = new TUrlLink(this, IDC_LINK);\n\n/// link->SetURL(\"www.automedi.com\");\n\n/// \\endcode\n\n/// - In a dialog resource:\n\n/// \\code\n\n/// CONTROL \"Go To AutoMedia.\", IDC_LINK, \"OWL_UrlLink\", SS_LEFT | WS_CHILD |\n\n/// WS_VISIBLE, 52, 32, 96, 12, 0\n\n/// \\endcode\n\n/// \\image html bm269.BMP\n\n//\n\nclass _OWLCLASS TUrlLink : public TStatic \n\n{\n\n // Construction/destruction\n\n public:\n\n TUrlLink(TWindow* parent, int id,\n\n LPCTSTR title,\n\n int x, int y, int w, int h,\n\n uint textLimit = 0,\n\n TModule* module = 0);\n\n\n\n TUrlLink(TWindow* parent, int id, const tstring& title, int x, int y, int w, int h, uint textLimit = 0, TModule* = 0);\n\n\n\n TUrlLink(TWindow* parent, int resourceId, \n\n uint textLimit = 0, TModule* module = 0);\n\n virtual ~TUrlLink();\n\n\n\n public:\n\n /// \\name Operations\n\n /// @{\n\n void SetURL(LPCTSTR str);\n", "file_path": "include/owl/urllink.h", "rank": 90, "score": 305065.62269515323 }, { "content": "/// \\addtogroup ctrl\n\n/// @{\n\n/// \\class TEdit\n\n// ~~~~~ ~~~~~\n\nclass _OWLCLASS TEdit : public TStatic {\n\n public:\n\n TEdit(TWindow* parent, int id, LPCTSTR text, int x, int y, int w, int h, \n\n uint textLimit = 0, bool multiline = false, TModule* = 0);\n\n TEdit(TWindow* parent, int id, const tstring& text, int x, int y, int w, int h,\n\n uint textLimit = 0, bool multiline = false, TModule* = 0);\n\n TEdit(TWindow* parent, int resourceId, uint textLimit = 0, TModule* = 0);\n\n TEdit(THandle hWnd, TModule* = 0);\n\n\n\n ~TEdit();\n\n\n\n /// Represents a half-open range of positions in the edit control, e.g. a selection range.\n\n /// The default range is [0, -1) for compatibility with TCharRange (see \"richedit.h\").\n\n //\n\n struct TRange\n\n {\n\n TRange(int b = 0, int e = -1) : cpMin(b), cpMax(e) {}\n\n\n\n int GetSize() const {return cpMax - cpMin;}\n\n\n", "file_path": "include_xp/owl/edit.h", "rank": 91, "score": 305060.6211661648 }, { "content": "//\n\n/// \\class TSocketWindow\n\n// ~~~~~ ~~~~~~~~~~~~~\n\n/// Derived from TWindow, a private window used to catch notification messages.\n\n//\n\nclass _OWLCLASS TSocketWindow : public TWindow {\n\n public:\n\n TSocketWindow(TSocket* socketParent);\n\n TSocketWindow& operator =(TSocketWindow& src); // !CQ const?\n\n\n\n void SetNotificationSet(int notificationSet);\n\n void SetNotificationWindow(TWindow* windowNotification);\n\n\n\n int GetLastError();\n\n int StartAcceptNotification();\n\n int StartRegularNotification();\n\n int StartCustomNotification(int selectOptions);\n\n int CancelNotification();\n\n\n\n TSocket* GetSocketParent() const;\n\n void SetSocketParent(TSocket* socket);\n\n\n\n public_data:\n\n static uint MsgSocketNotification; ///< Message used to notify hwndNotification, if hwndNotification is used.\n\n TSocket* SocketParent; ///< Exported so Parent can have easy access to it.\n", "file_path": "include/owl/wsksock.h", "rank": 92, "score": 305000.8518528491 }, { "content": "//\n\n/// \\class TServiceWindow\n\n// ~~~~~ ~~~~~~~~~~~~~~\n\n/// TServiceWindow is a private class created by the TServiceManager to catch\n\n/// notifications.\n\n//\n\nclass _OWLCLASS TServiceWindow : public TWindow {\n\n public:\n\n TServiceWindow(TServiceManager* newServiceManagerParent);\n\n\n\n protected: // CQ add this?\n\n /// Object to pass notifications\n\n //\n\n TServiceManager* ServiceManagerParent;\n\n\n\n TResult DoNotification(TParam1, TParam2);\n\n\n\n DECLARE_RESPONSE_TABLE(TServiceWindow);\n\n};\n\n\n", "file_path": "include/owl/wskservm.h", "rank": 93, "score": 304995.38346793863 }, { "content": "/// \\addtogroup ctrl\n\n/// @{\n\n/// \\class TPictureWindow\n\n// ~~~~~ ~~~~~~~~~~~~~~\n\n/// This class displays a dib in a window in different ways.\n\n/// The dib is owned by the window and will be deleted when the window is\n\n/// deleted.\n\n//\n\nclass _OWLCLASS TPictureWindow : public TWindow {\n\n public:\n\n\n\n /// How to display the bitmap within the window\n\n //\n\n enum TDisplayHow {\n\n UpperLeft = 0, ///< Displays the DIB in the upper left corner of the window\n\n Center, ///< Always centered\n\n Stretch, ///< Stretch to fit or shrink to fit\n\n // Scroll, // implies Upperleft ///TH to be implemented\n\n };\n\n\n\n // constructor and destructor\n\n //\n\n TPictureWindow(TWindow* parent, TDib* dib, TDisplayHow = UpperLeft,\n\n LPCTSTR title = 0, TModule* module = 0);\n\n\n\n TPictureWindow(\n\n TWindow* parent,\n\n TDib* dib,\n", "file_path": "include/owl/pictwind.h", "rank": 94, "score": 304988.67600301513 }, { "content": "//\n\n/// \\class THarbor\n\n// ~~~~~ ~~~~~~~\n\n/// THarbor is the object that holds all the docking slips. It performs the actual\n\n/// docking insertion and coordination. It is never visible; it is a window in order\n\n/// to capture the mouse.\n\n//\n\nclass _OWLCLASS THarbor : public TWindow {\n\n public:\n\n THarbor(TDecoratedFrame& df);\n\n ~THarbor();\n\n\n\n /// Dockable window insertion\n\n //\n\n TDockingSlip* Insert(TDockable& dockable,\n\n TAbsLocation location,\n\n const TPoint* where = 0,\n\n TRelPosition position = rpNone,\n\n TDockable* relativeTo = 0);\n\n\n\n /// Move a dockable from one slip to another, programatically\n\n //\n\n void Move(TDockable& dockable,\n\n TAbsLocation location,\n\n const TPoint* where = 0,\n\n TRelPosition position = rpNone,\n\n TDockable* relativeTo = 0);\n", "file_path": "include_xp/owl/docking.h", "rank": 95, "score": 304987.2393001359 }, { "content": "//\n\n/// \\class TPropertySheet\n\n// ~~~~~ ~~~~~~~~~~~~~~\n\n/// TPropertySheet encapsulates a window which contains one or more overlapping\n\n/// child windows knowns as property pages. The sheet provides a container\n\n/// which display pages allowing the user to view and edit related properties\n\n/// grouped in individual pages.\n\n//\n\nclass _OWLCLASS TPropertySheet : public TWindow {\n\n public:\n\n TPropertySheet(TWindow* parent,\n\n LPCTSTR title,\n\n uint startPage = 0,\n\n bool isWizard = false,\n\n uint32 flags = PSH_DEFAULT,\n\n TModule* module = 0);\n\n TPropertySheet(TWindow* parent,\n\n const tstring& title,\n\n uint startPage = 0,\n\n bool isWizard = false,\n\n uint32 flags = PSH_DEFAULT,\n\n TModule* module = 0);\n\n// !BB // !BB Nice, if you can pull it\n\n// !BB TPropertySheet(TWindow* parent, const PROPSHEETHEADER& propHdr,\n\n// !BB TModule* module = 0);\n\n ~TPropertySheet();\n\n\n\n // Override virtual functions defined by class TWindow\n", "file_path": "include/owl/propsht.h", "rank": 96, "score": 304986.685370984 }, { "content": "/// \\addtogroup print\n\n/// @{\n\n/// \\class TPreviewPage\n\n// ~~~~~ ~~~~~~~~~~~~\n\n/// TPreviewPage encapsulates a window which displays print-preview data.\n\n/// It provides access to the basic information necessary to paint\n\n/// print-preview data: i.e. the printer's DC.\n\n//\n\n/// TPreviewPage displays a page of a document in a print preview window. To obtain\n\n/// the information needed to display the page, TPreviewPage interacts with\n\n/// TPrintPreviewDC and TPrintout. Specifically, it creates a TPrintPreviewDC from\n\n/// the window DC provided in Paint and passes that TPrintPreviewDC object to\n\n/// TPrintout's SetPrintParams member function. The sample program PRINT.CPP\n\n/// displays the following print preview window:\n\n/// \\image html bm243.BMP\n\n//\n\nclass _OWLCLASS TPreviewPage : public TWindow {\n\n public:\n\n TPreviewPage(TWindow* parent,\n\n TPrintout& printout,\n\n TPrintDC& prndc,\n\n TSize& printExtent,\n\n int pagenum = 1);\n\n\n\n void SetPageNumber(int newNum);\n\n int GetPageNumber() const;\n\n\n\n // Overriden TWindow virtual\n\n //\n\n void Paint(TDC& dc, bool, TRect& clip);\n\n\n\n protected:\n\n void EvSize(uint sizeType, const TSize& size);\n\n\n\n protected_data:\n\n int PageNum; ///< Page currently being previewed\n\n TSize PrintExtent; ///< Size of printer device (in pixels)\n\n TPrintout& Printout; ///< Printout which sends the output\n\n TPrintDC& PrintDC; ///< Device context of the printer\n\n\n\n DECLARE_RESPONSE_TABLE(TPreviewPage);\n\n DECLARE_CASTABLE;\n\n};\n\n\n", "file_path": "include/owl/preview.h", "rank": 97, "score": 304984.9451151233 }, { "content": "//\n\n/// \\class TWindowView\n\n// ~~~~~ ~~~~~~~~~~~\n\n/// Derived from both TWindow and TView, TWindowView is a streamable base class that\n\n/// can be used for deriving window-based views. TWindowView's functions override\n\n/// TView's virtual function to provide their own implementation. By deriving a\n\n/// window-view class from TWindow and TView, you add window functionality to the\n\n/// view of your document.\n\nclass _OWLCLASS TWindowView : public TWindow, public TView {\n\n public:\n\n TWindowView(TDocument& doc, TWindow* parent = 0);\n\n ~TWindowView();\n\n\n\n static LPCTSTR StaticName(); ///< put in resource\n\n\n\n // Override virtuals from TWindow\n\n //\n\n bool CanClose();\n\n\n\n // Override virtuals from TView\n\n //\n\n LPCTSTR GetViewName();\n\n TWindow* GetWindow();\n\n bool SetDocTitle(LPCTSTR docname, int index);\n\n using TView::SetDocTitle; ///< String-aware overload\n\n\n\n private:\n\n // Event handlers\n", "file_path": "include/owl/docview.h", "rank": 98, "score": 304097.19188935135 }, { "content": "//\n\n/// \\class TWindowView\n\n// ~~~~~ ~~~~~~~~~~~\n\n/// Derived from both TWindow and TView, TWindowView is a streamable base class that\n\n/// can be used for deriving window-based views. TWindowView's functions override\n\n/// TView's virtual function to provide their own implementation. By deriving a\n\n/// window-view class from TWindow and TView, you add window functionality to the\n\n/// view of your document.\n\nclass _OWLCLASS TWindowView : public TWindow, public TView {\n\n public:\n\n TWindowView(TDocument& doc, TWindow* parent = 0);\n\n ~TWindowView();\n\n\n\n static LPCTSTR StaticName(); ///< put in resource\n\n\n\n // Override virtuals from TWindow\n\n //\n\n bool CanClose();\n\n\n\n // Override virtuals from TView\n\n //\n\n LPCTSTR GetViewName();\n\n TWindow* GetWindow();\n\n bool SetDocTitle(LPCTSTR docname, int index);\n\n using TView::SetDocTitle; ///< String-aware overload\n\n\n\n private:\n\n // Event handlers\n", "file_path": "include_xp/owl/docview.h", "rank": 99, "score": 299035.1525419324 } ]
C++
src/plugins/lackman/packagesmodel.cpp
devel29a/leechcraft
faf5e856010fb785e4bbf3ce7b5c6a5c49f3239a
#include "packagesmodel.h" #include <QIcon> #include <QApplication> #include <util/util.h> #include "core.h" #include "storage.h" #include "pendingmanager.h" namespace LeechCraft { namespace LackMan { PackagesModel::PackagesModel (QObject *parent) : QAbstractItemModel (parent) { } int PackagesModel::columnCount (const QModelIndex&) const { return Columns::MaxColumn; } QVariant PackagesModel::headerData (int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Vertical) return QVariant (); if (role != Qt::DisplayRole) return QVariant (); switch (section) { case Columns::Inst: return tr ("I"); case Columns::Upd: return tr ("U"); case Columns::Name: return tr ("Name"); case Columns::Description: return tr ("Description"); case Columns::Version: return tr ("Version"); case Columns::Size: return tr ("Size"); default: return "unknown"; } } QVariant PackagesModel::data (const QModelIndex& index, int role) const { const auto& lpi = Packages_.at (index.row ()); const int col = index.column (); switch (role) { case Qt::DisplayRole: switch (col) { case Columns::Name: return lpi.Name_; case Columns::Description: return lpi.ShortDescription_; case Columns::Version: return lpi.Version_; case Columns::Size: { const auto size = Core::Instance ().GetStorage ()->GetPackageSize (lpi.PackageID_); return size > 0 ? Util::MakePrettySize (size) : tr ("unknown"); } default: return QVariant (); } case Qt::DecorationRole: return col != Columns::Name ? QVariant () : Core::Instance ().GetIconForLPI (lpi); case Qt::CheckStateRole: { auto pm = Core::Instance ().GetPendingManager (); switch (col) { case Columns::Inst: if (lpi.IsInstalled_) return pm->GetPendingRemove ().contains (lpi.PackageID_) ? Qt::Unchecked : Qt::Checked; else return pm->GetPendingInstall ().contains (lpi.PackageID_) ? Qt::Checked : Qt::Unchecked; case Columns::Upd: if (!lpi.HasNewVersion_) return {}; return pm->GetPendingUpdate ().contains (lpi.PackageID_) ? Qt::Checked : Qt::Unchecked; default: return {}; } } case PMRPackageID: return lpi.PackageID_; case PMRShortDescription: return lpi.ShortDescription_; case PMRLongDescription: return lpi.LongDescription_; case PMRTags: return lpi.Tags_; case PMRInstalled: return lpi.IsInstalled_; case PMRUpgradable: return lpi.HasNewVersion_; case PMRVersion: return lpi.Version_; case PMRThumbnails: case PMRScreenshots: { QStringList result; for (const auto& img : Core::Instance ().GetStorage ()->GetImages (lpi.Name_)) if (img.Type_ == (role == PMRThumbnails ? Image::TThumbnail : Image::TScreenshot)) result << img.URL_; return result; } case PMRSize: return Core::Instance ().GetStorage ()->GetPackageSize (lpi.PackageID_); default: return {}; } } bool PackagesModel::setData (const QModelIndex& index, const QVariant& value, int role) { if (role != Qt::CheckStateRole) return false; const auto& lpi = Packages_.at (index.row ()); const Qt::CheckState state = static_cast<Qt::CheckState> (value.toInt ()); switch (index.column ()) { case Columns::Inst: { const bool isNewState = (state == Qt::Checked && !lpi.IsInstalled_) || (state == Qt::Unchecked && lpi.IsInstalled_); Core::Instance ().GetPendingManager ()-> ToggleInstallRemove (lpi.PackageID_, isNewState, lpi.IsInstalled_); emit dataChanged (index, index); return true; } case Columns::Upd: Core::Instance ().GetPendingManager ()->ToggleUpdate (lpi.PackageID_, state == Qt::Checked); emit dataChanged (index, index); return true; default: return false; } } Qt::ItemFlags PackagesModel::flags (const QModelIndex& index) const { if (!index.isValid ()) return 0; auto flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; const auto& lpi = Packages_.at (index.row ()); switch (index.column ()) { case Columns::Inst: flags |= Qt::ItemIsUserCheckable; break; case Columns::Upd: if (lpi.HasNewVersion_) flags |= Qt::ItemIsUserCheckable; break; } return flags; } QModelIndex PackagesModel::index (int row, int column, const QModelIndex& parent) const { if (!hasIndex (row, column, parent)) return QModelIndex (); return createIndex (row, column); } QModelIndex PackagesModel::parent (const QModelIndex&) const { return QModelIndex (); } int PackagesModel::rowCount (const QModelIndex& parent) const { return parent.isValid () ? 0 : Packages_.size (); } void PackagesModel::AddRow (const ListPackageInfo& lpi) { int size = Packages_.size (); beginInsertRows (QModelIndex (), size, size); Packages_ << lpi; endInsertRows (); } void PackagesModel::UpdateRow (const ListPackageInfo& lpi) { for (int i = 0, size = Packages_.size (); i < size; ++i) if (Packages_.at (i).Name_ == lpi.Name_) { Packages_ [i] = lpi; emit dataChanged (index (i, 0), index (i, columnCount () - 1)); break; } } void PackagesModel::RemovePackage (int packageId) { for (int i = 0, size = Packages_.size (); i < size; ++i) if (Packages_.at (i).PackageID_ == packageId) { beginRemoveRows (QModelIndex (), i, i); Packages_.removeAt (i); endRemoveRows (); break; } } ListPackageInfo PackagesModel::FindPackage (const QString& name) const { const auto pos = std::find_if (Packages_.begin (), Packages_.end (), [&name] (const auto& lpi) { return lpi.Name_ == name; }); return pos != Packages_.end () ? *pos : ListPackageInfo {}; } int PackagesModel::GetRow (int packageId) const { for (int i = 0, size = Packages_.size (); i < size; ++i) if (Packages_.at (i).PackageID_ == packageId) return i; return -1; } void PackagesModel::Clear () { beginResetModel (); Packages_.clear (); endResetModel (); } void PackagesModel::handlePackageInstallRemoveToggled (int id) { const auto row = GetRow (id); if (row == -1) { qWarning () << Q_FUNC_INFO << "unknown package ID" << id; return; } const auto& idx = index (row, Columns::Inst); emit dataChanged (idx, idx); } void PackagesModel::handlePackageUpdateToggled (int id) { const auto row = GetRow (id); if (row == -1) { qWarning () << Q_FUNC_INFO << "unknown package ID" << id; return; } const auto& idx = index (row, Columns::Upd); emit dataChanged (idx, idx); } } }
#include "packagesmodel.h" #include <QIcon> #include <QApplication> #include <util/util.h> #include "core.h" #include "storage.h" #include "pendingmanager.h" namespace LeechCraft { namespace LackMan { PackagesModel::PackagesModel (QObject *parent) : QAbstractItemModel (parent) { } int PackagesModel::columnCount (const QModelIndex&) const { return Columns::MaxColumn; } QVariant PackagesModel::headerData (int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Vertical) return QVariant (); if (role != Qt::DisplayRole) return QVariant (); switch (section) { case Columns::Inst: return tr ("I"); case Columns::Upd: return tr ("U"); case Columns::Name: return tr ("Name"); case Columns::Description: return tr ("Description"); case Columns::Version: return tr ("Version"); case Columns::Size: return tr ("Size"); default: return "unknown"; } } QVariant PackagesModel::data (const QModelIndex& index, int role) const { const auto& lpi = Packages_.at (index.row ()); const int col = index.column (); switch (role) { case Qt::DisplayRole: switch (col) { case Columns::Name: return lpi.Name_; case Columns::Description: return lpi.ShortDescription_; case Columns::Version: return lpi.Version_; case Columns::Size: { const auto size = Core::Instance ().GetStorage ()->GetPackageSize (lpi.PackageID_); return size > 0 ? Util::MakePrettySize (size) : tr ("unknown"); } default: return QVariant (); } case Qt::DecorationRole: return col != Columns::Name ? QVariant () : Core::Instance ().GetIconForLPI (lpi); case Qt::CheckStateRole: { auto pm = Core::Instance ().GetPendingManager (); switch (col) { case Columns::Inst: if (lpi.IsInstalled_) return pm->GetPendingRemove ().contains (lpi.PackageID_) ? Qt::Unchecked : Qt::Checked; else return pm->GetPendingInstall ().contains (lpi.PackageID_) ? Qt::Checked : Qt::Unchecked; case Columns::Upd: if (!lpi.HasNewVersion_) return {}; return pm->GetPendingUpdate ().contains (lpi.PackageID_) ? Qt::Checked : Qt::Unchecked; default: return {}; } } case PMRPackageID: return lpi.PackageID_; case PMRShortDescription: return lpi.ShortDescription_; case PMRLongDescription: return lpi.LongDescription_; case PMRTags: return lpi.Tags_; case PMRInstalled: return lpi.IsInstalled_; case PMRUpgradable: return lpi.HasNewVersion_; case PMRVersion: return lpi.Version_; case PMRThumbnails: case PMRScreenshots: { QStringList result; for (const auto& img : Core::Instance ().GetStorage ()->GetImages (lpi.Name_)) if (img.Type_ == (role == PMRThumbnails ? Image::TThumbnail : Image::TScreenshot)) result << img.URL_; return result; } case PMRSize: return Core::Instance ().GetStorage ()->GetPackageSize (lpi.PackageID_); default: return {}; } } bool PackagesModel::setData (const QModelIndex& index, const QVariant& value, int role) { if (role != Qt::CheckStateRole) return false; const auto& lpi = Packages_.at (index.row ()); const Qt::CheckState state = static_cast<Qt::CheckState> (value.toInt ()); switch (index.column ()) { case Columns::Inst: { const bool isNewState = (state == Qt::Checked && !lpi.IsInstalled_) || (state == Qt::Unchecked && lpi.IsInstalled_); Core::Instance ().GetPendingManager ()-> ToggleInstallRemove (lpi.PackageID_, isNewState, lpi.IsInstalled_); emit dataChanged (index, index); return true; } case Columns::Upd: Core::Instance ().GetPendingManager ()->ToggleUpdate (lpi.PackageID_, state == Qt::Checked); emit dataChanged (index, index); return true; default: return false; } } Qt::ItemFlags PackagesModel::flags (const QModelIndex& index) const { if (!index.isValid ()) return 0; auto flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; const auto& lpi = Packages_.at (index.row ()); switch (index.column ()) { case Columns::Inst: flags |= Qt::ItemIsUserCheckable; break; case Columns::Upd: if (lpi.HasNewVersion_) flags |= Qt::ItemIsUserCheckable; break; } return flags; } QModelIndex PackagesModel::index (int row, int column, const QModelIndex& parent) const { if (!hasIndex (row, column, parent)) return QModelIndex (); return createIndex (row, column); } QModelIndex PackagesModel::parent (const QModelIndex&) const { return QModelIndex (); } int PackagesModel::rowCount (const QModelIndex& parent) const { return parent.isValid () ? 0 : Packages_.size (); } void PackagesModel::AddRow (const ListPackageInfo& lpi) { int size = Packages_.size (); beginInsertRows (QModelIndex (), size, size); Packages_ << lpi; endInsertRows (); } void PackagesModel::UpdateRow (const ListPackageInfo& lpi) { for (int i = 0, size = Packages_.size (); i < size; ++i) if (Packages_.at (i).Name_ == lpi.Name_) { Packages_ [i] = lpi; emit dataChanged (index (i, 0), index (i, columnCount () - 1)); break; } } void PackagesModel::RemovePackage (int packageId) { for (int i = 0, size = Packages_.size (); i < size; ++i) if (Packages_.at (i).PackageID_ == packageId) { beginRemoveRows (QModelIndex (), i, i); Packages_.removeAt (i); endRemoveRows (); break; } }
int PackagesModel::GetRow (int packageId) const { for (int i = 0, size = Packages_.size (); i < size; ++i) if (Packages_.at (i).PackageID_ == packageId) return i; return -1; } void PackagesModel::Clear () { beginResetModel (); Packages_.clear (); endResetModel (); } void PackagesModel::handlePackageInstallRemoveToggled (int id) { const auto row = GetRow (id); if (row == -1) { qWarning () << Q_FUNC_INFO << "unknown package ID" << id; return; } const auto& idx = index (row, Columns::Inst); emit dataChanged (idx, idx); } void PackagesModel::handlePackageUpdateToggled (int id) { const auto row = GetRow (id); if (row == -1) { qWarning () << Q_FUNC_INFO << "unknown package ID" << id; return; } const auto& idx = index (row, Columns::Upd); emit dataChanged (idx, idx); } } }
ListPackageInfo PackagesModel::FindPackage (const QString& name) const { const auto pos = std::find_if (Packages_.begin (), Packages_.end (), [&name] (const auto& lpi) { return lpi.Name_ == name; }); return pos != Packages_.end () ? *pos : ListPackageInfo {}; }
function_block-full_function
[ { "content": "\tconst struct\n\n\t{\n\n\t\ttemplate<typename Vec>\n\n\t\tauto operator() (Vec&& vec) const\n\n\t\t{\n\n\t\t\tusing std::begin;\n\n\t\t\tusing std::end;\n\n\t\t\tusing MP = typename Vec::value_type;\n\n\t\t\treturn std::accumulate (begin (vec), end (vec), Mzero<MP> (), &operator+<MP>);\n\n\t\t}\n\n\n\n\t\ttemplate<typename T>\n\n\t\tauto operator() (const std::initializer_list<T>& vec) const\n\n\t\t{\n\n\t\t\tusing std::begin;\n\n\t\t\tusing std::end;\n\n\t\t\treturn std::accumulate (begin (vec), end (vec), Mzero<T> (), &operator+<T>);\n", "file_path": "src/util/sll/monadplus.h", "rank": 0, "score": 177221.28424854562 }, { "content": "\t\tRole Role_;\n", "file_path": "src/plugins/seekthru/description.h", "rank": 1, "score": 175202.4862516636 }, { "content": "class QModelIndex;\n\n\n\nnamespace LeechCraft\n\n{\n\nnamespace LackMan\n\n{\n", "file_path": "src/plugins/lackman/updatesnotificationmanager.h", "rank": 2, "score": 174864.19954854954 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\tstruct Void\n\n\t{\n\n\t};\n\n}\n", "file_path": "src/util/sll/void.h", "rank": 3, "score": 173773.76307769178 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace HotStreams\n\n{\n\n\tenum StreamItemRoles\n\n\t{\n\n\t\tPristineName = Media::RadioItemRole::MaxRadioRole + 1,\n\n\t\tPlaylistFormat,\n\n\t\tUrlList\n\n\t};\n\n}\n", "file_path": "src/plugins/hotstreams/roles.h", "rank": 4, "score": 173767.20683173736 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace SeekThru\n\n{\n\n\tstruct UrlDescription\n\n\t{\n\n\t\tQString Template_;\n\n\t\tQString Type_;\n\n\t\tqint32 IndexOffset_;\n\n\t\tqint32 PageOffset_;\n\n\n\n\t\tQUrl MakeUrl (const QString&, const QHash<QString, QVariant>&) const;\n\n\t};\n\n\n\n\tQDataStream& operator<< (QDataStream&, const UrlDescription&);\n\n\tQDataStream& operator>> (QDataStream&, UrlDescription&);\n\n\n\n\tstruct QueryDescription\n\n\t{\n\n\t\tenum Role\n\n\t\t{\n\n\t\t\tRoleRequest,\n\n\t\t\tRoleExample,\n\n\t\t\tRoleRelated,\n\n\t\t\tRoleCorrection,\n\n\t\t\tRoleSubset,\n\n\t\t\tRoleSuperset\n\n\t\t};\n\n\n\n\t\tRole Role_;\n\n\t\tQString Title_;\n\n\t\tqint32 TotalResults_;\n\n\t\tQString SearchTerms_;\n\n\t\tqint32 Count_;\n\n\t\tqint32 StartIndex_;\n\n\t\tqint32 StartPage_;\n\n\t\tQString Language_;\n\n\t\tQString InputEncoding_;\n\n\t\tQString OutputEncoding_;\n\n\t};\n\n\n\n\tQDataStream& operator<< (QDataStream&, const QueryDescription&);\n\n\tQDataStream& operator>> (QDataStream&, QueryDescription&);\n\n\n\n\tstruct Description\n\n\t{\n\n\t\tenum SyndicationRight\n\n\t\t{\n\n\t\t\tSROpen,\n\n\t\t\tSRLimited,\n\n\t\t\tSRPrivate,\n\n\t\t\tSRClosed\n\n\t\t};\n\n\n\n\t\tQString ShortName_;\n\n\t\tQString Description_;\n\n\t\tQList<UrlDescription> URLs_;\n\n\t\tQString Contact_;\n\n\t\tQStringList Tags_;\n\n\t\tQString LongName_;\n\n\t\tQList<QueryDescription> Queries_;\n\n\t\tQString Developer_;\n\n\t\tQString Attribution_;\n\n\t\tSyndicationRight Right_;\n\n\t\tbool Adult_;\n\n\t\tQStringList Languages_;\n\n\t\tQStringList InputEncodings_;\n\n\t\tQStringList OutputEncodings_;\n\n\t};\n\n\n\n\tQDataStream& operator<< (QDataStream&, const Description&);\n\n\tQDataStream& operator>> (QDataStream&, Description&);\n\n}\n", "file_path": "src/plugins/seekthru/description.h", "rank": 5, "score": 173765.25990339095 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace LackMan\n\n{\n\n\tbool IsVersionLess (const QString& lver, const QString& rver);\n\n}\n", "file_path": "src/plugins/lackman/versioncomparator.h", "rank": 6, "score": 173688.80166121796 }, { "content": "\t\tconstexpr bool DoesReturnVoid ()\n\n\t\t{\n\n\t\t\tusing Ret_t = decltype (Invoke (std::declval<F> (), *std::declval<Cont> ().begin ()));\n\n\t\t\treturn std::is_same<void, Ret_t>::value;\n", "file_path": "src/util/sll/prelude.h", "rank": 7, "score": 170205.51345004616 }, { "content": "\t\tqint32 TotalResults_;\n", "file_path": "src/plugins/seekthru/description.h", "rank": 8, "score": 170194.5059982768 }, { "content": "\t\tqint32 IndexOffset_;\n", "file_path": "src/plugins/seekthru/description.h", "rank": 9, "score": 170186.89552972573 }, { "content": "\t\tqint32 StartIndex_;\n", "file_path": "src/plugins/seekthru/description.h", "rank": 10, "score": 170186.89552972573 }, { "content": "\t\tQString ShortName_;\n", "file_path": "src/plugins/seekthru/description.h", "rank": 11, "score": 170182.64497321143 }, { "content": "\t\tQString LongName_;\n", "file_path": "src/plugins/seekthru/description.h", "rank": 12, "score": 170182.64497321143 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace LMP\n\n{\n\nnamespace MP3Tunes\n\n{\n\nnamespace Consts\n\n{\n\n\tconst QString PartnerId = \"9999999999\";\n\n}\n\n}\n\n}\n", "file_path": "src/plugins/lmp/plugins/mp3tunes/consts.h", "rank": 13, "score": 167636.01371476747 }, { "content": "\t\t\t\tfunction getNodeIndex(parent, node) {\n\n\t\t\t\t\tvar index = parent.childNodes.length - 1;\n\n\n\n\t\t\t\t\twhile (index > 0 && node !== parent.childNodes[index]) {\n\n\t\t\t\t\t\tindex--;\n\n\t\t\t\t\t}\n\n\n\n\t\t\t\t\treturn index;\n\n\t\t\t\t}\n\n\n", "file_path": "src/plugins/snails/composemessagetab.cpp", "rank": 14, "score": 155919.5956166014 }, { "content": "class TestVersionComparator : public QObject\n\n{\n\n\tQ_OBJECT\n\nprivate slots:\n\n\tvoid doSanityChecks ()\n\n\t{\n\n\t\tQCOMPARE (IsVersionLess (\"0\", \"1\"), true);\n\n\t\tQCOMPARE (IsVersionLess (\"1\", \"1\"), false);\n\n\t\tQCOMPARE (IsVersionLess (\"1\", \"0\"), false);\n\n\t\tQCOMPARE (IsVersionLess (\"1.0\", \"0.1\"), false);\n\n\t\tQCOMPARE (IsVersionLess (\"0.1.0\", \"0.1.0\"), false);\n\n\t\tQCOMPARE (IsVersionLess (\"0.1.0\", \"0.1.1\"), true);\n\n\t\tQCOMPARE (IsVersionLess (\"0.1.1\", \"0.1.0\"), false);\n\n\t\tQCOMPARE (IsVersionLess (\"0.3.70\", \"0.3.71\"), true);\n\n\t\tQCOMPARE (IsVersionLess (\"0.3\", \"0.3.0\"), false);\n\n\t\tQCOMPARE (IsVersionLess (\"0.3.0\", \"0.3\"), false);\n\n\t\tQCOMPARE (IsVersionLess (\"0.3.9999\", \"0.4\"), true);\n\n\t\tQCOMPARE (IsVersionLess (\"0.9999.9999.9999.9999\", \"1\"), true);\n\n\t\tQCOMPARE (IsVersionLess (\"0.3.70-beta1\", \"0.3.70\"), true);\n\n\t\tQCOMPARE (IsVersionLess (\"0.3.70\", \"0.3.70-beta1\"), false);\n", "file_path": "src/plugins/lackman/tests/versioncomparatortest.h", "rank": 15, "score": 152180.90635695378 }, { "content": "DROP INDEX idx_mrss_comments_parent_url_item_parents_hash_item_title_item_;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 16, "score": 151876.37377868124 }, { "content": "DROP INDEX idx_mrss_credits_parent_url_item_parents_hash_item_title_item_u;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 17, "score": 151876.37377868124 }, { "content": "DROP INDEX idx_mrss_thumbnails_parent_url_item_parents_hash_item_title_ite;\n\n\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 18, "score": 151876.37377868124 }, { "content": "DROP INDEX idx_mrss_peerlinks_parent_url_item_parents_hash_item_title_item;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 19, "score": 151876.37377868124 }, { "content": "DROP INDEX idx_mrss_scenes_parent_url_item_parents_hash_item_title_item_ur;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 20, "score": 150100.63790791426 }, { "content": "DROP INDEX idx_items_parents_hash;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 21, "score": 148947.83979391484 }, { "content": "DROP INDEX idx_channels_parent_feed_url;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 22, "score": 146521.0614221275 }, { "content": "DROP INDEX idx_items_parents_hash_unread;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 23, "score": 146521.0614221275 }, { "content": "DROP INDEX idx_items_parents_hash_title_url;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 24, "score": 144209.97464180388 }, { "content": "DROP INDEX idx_channels_parent_feed_url_title;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 25, "score": 144209.97464180388 }, { "content": "DROP INDEX idx_channels_parent_feed_url_title_url;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 26, "score": 142006.49902904505 }, { "content": "\t\tclass CommandResultVisitor : public boost::static_visitor<bool>\n\n\t\t{\n\n\t\t\tQString& Text_;\n\n\t\t\tQObject * const EntryObj_;\n\n\t\tpublic:\n\n\t\t\tCommandResultVisitor (QString& text, QObject *entryObj)\n\n\t\t\t: Text_ (text)\n\n\t\t\t, EntryObj_ { entryObj }\n\n\t\t\t{\n\n\t\t\t}\n\n\n\n\t\t\tbool operator() (bool res) const\n\n\t\t\t{\n\n\t\t\t\treturn res;\n\n\t\t\t}\n\n\n\n\t\t\tbool operator() (const StringCommandResult& result) const\n\n\t\t\t{\n\n\t\t\t\tconst auto msg = new CoreMessage\n\n\t\t\t\t{\n", "file_path": "src/plugins/azoth/chattab.cpp", "rank": 27, "score": 140968.661651006 }, { "content": "DROP INDEX idx_mrss_item_parents_hash_item_title_item_url;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 28, "score": 137893.65470132726 }, { "content": "DROP INDEX idx_enclosures_item_parents_hash_item_title_item_url;\n", "file_path": "src/plugins/aggregator/resources/sql/mysql/remove_db.sql", "rank": 29, "score": 137893.65470132726 }, { "content": "\tclass TrayModel : public Util::RoleNamesMixin<QAbstractItemModel>\n\n#if QT_VERSION >= 0x050000\n\n\t\t\t\t\t, public QAbstractNativeEventFilter\n\n#endif\n\n\t{\n\n\t\tQ_OBJECT\n\n\n\n\t\tbool IsValid_ = false;\n\n\n\n\t\tulong TrayWinID_ = 0;\n\n\t\tint DamageEvent_ = 0;\n\n\n\n\t\tstruct TrayItem\n\n\t\t{\n\n\t\t\tulong WID_;\n\n\t\t};\n\n\t\tQList<TrayItem> Items_;\n\n\n\n\t\tenum Role\n\n\t\t{\n", "file_path": "src/plugins/mellonetray/traymodel.h", "rank": 30, "score": 135907.06181218242 }, { "content": "\tclass WindowsModel : public Util::RoleNamesMixin<QAbstractItemModel>\n\n\t{\n\n\t\tQ_OBJECT\n\n\n\n\t\tstruct WinInfo\n\n\t\t{\n\n\t\t\tulong WID_;\n\n\n\n\t\t\tQString Title_;\n\n\t\t\tQIcon Icon_;\n\n\t\t\tint IconGenID_;\n\n\t\t\tbool IsActive_;\n\n\n\n\t\t\tint DesktopNum_;\n\n\n\n\t\t\tUtil::WinStateFlags State_;\n\n\t\t\tUtil::AllowedActionFlags Actions_;\n\n\t\t};\n\n\t\tQList<WinInfo> Windows_;\n\n\n", "file_path": "src/plugins/krigstask/windowsmodel.h", "rank": 31, "score": 135907.06181218242 }, { "content": "\t\tQString Description_;\n", "file_path": "src/plugins/seekthru/description.h", "rank": 32, "score": 132967.17455534672 }, { "content": "\t\tclass ExprTree<ExprType::LeafStaticPlaceholder, boost::mpl::int_<Idx>, void>\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\ttemplate<typename T>\n\n\t\t\tusing ValueType_t = ValueAtC_t<T, Idx>;\n\n\n\n\t\t\ttemplate<typename T>\n\n\t\t\tQString ToSql (ToSqlState<T>&) const\n\n\t\t\t{\n\n\t\t\t\tstatic_assert (Idx < boost::fusion::result_of::size<T>::type::value, \"Index out of bounds.\");\n\n\t\t\t\treturn detail::GetFieldsNames<T> {} ().at (Idx);\n\n\t\t\t}\n\n\t\t};\n\n\n\n\t\ttemplate<typename T>\n", "file_path": "src/util/db/oral.h", "rank": 33, "score": 126830.03273740326 }, { "content": "<?xml version=\"1.0\" ?><!DOCTYPE TS><TS language=\"uk_UA\" version=\"2.0\">\n\n<context>\n\n <name>LackMan</name>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"30\"/>\n\n <source>Packages</source>\n\n <translation>Пакети</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"45\"/>\n\n <source>Status:</source>\n\n <translation>Статус:</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"53\"/>\n\n <source>All</source>\n\n <translation>Всі</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"58\"/>\n\n <source>Installed</source>\n\n <translation>Встановлені</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"63\"/>\n\n <source>Upgradable</source>\n\n <translation>Оновлювані</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"68\"/>\n\n <source>Not installed</source>\n\n <translation>Не встановлені</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"91\"/>\n\n <source>Search packages...</source>\n\n <translation>Пошук пакетів...</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"123\"/>\n\n <source>Package information</source>\n\n <translation>Інформація про пакет</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"136\"/>\n\n <source>Size:</source>\n\n <translation>Розмір:</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"150\"/>\n\n <source>State:</source>\n\n <translation>Статус:</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"164\"/>\n\n <source>Tags:</source>\n\n <translation>Позначки:</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.ui\" line=\"200\"/>\n\n <source>Pending</source>\n\n <translation>Очікувані</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>LeechCraft::LackMan::Core</name>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"108\"/>\n\n <source>URL</source>\n\n <translation>URL</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"401\"/>\n\n <location filename=\"core.cpp\" line=\"419\"/>\n\n <location filename=\"core.cpp\" line=\"445\"/>\n\n <source>Error updating repository</source>\n\n <translation>Помилка оновлення репозиторію</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"402\"/>\n\n <source>Unable to find repository with URL %1.</source>\n\n <translation>Неможливо знайти репозиторій з адресою %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"420\"/>\n\n <source>While trying to update the repository: %1.</source>\n\n <translation>Під час оновлення репозиторію: %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"446\"/>\n\n <source>Unable to remove the component `%1` which disappeared from the list of components for repo %2.</source>\n\n <translation>Неможливо видалити компонент `%1`, який зник зі списку компонентів для репозиторію %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"492\"/>\n\n <source>Unable to install package</source>\n\n <translation>Неможливо встановити пакет</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"513\"/>\n\n <source>Unable to update package</source>\n\n <translation>Неможливо оновити пакет</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"682\"/>\n\n <location filename=\"core.cpp\" line=\"709\"/>\n\n <location filename=\"core.cpp\" line=\"1078\"/>\n\n <source>Error parsing component</source>\n\n <translation>Помилка розбору компоненту</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"683\"/>\n\n <source>Unable to load package ID for package `%1`-%2</source>\n\n <translation>Неможливо завантажити ідентифікатор пакету для пакету `%1`-%2</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"710\"/>\n\n <source>Unable to save package location for package `%1`-%2 and component %3</source>\n\n <translation>Неможливо зберегти положення пакету для пакету`%1`-%2 і компоненту %3</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"735\"/>\n\n <source>Repositories updated</source>\n\n <translation>Репозиторії оновлено</translation>\n\n </message>\n\n <message numerus=\"yes\">\n\n <location filename=\"core.cpp\" line=\"736\"/>\n\n <source>Got %n new or updated packages, open LackMan tab to view them.</source>\n\n <translation><numerusform>Отримано %n новий або оновлений пакет, відкрийте LackMan для його перегляду.</numerusform><numerusform>Отримано %n нових або оновлених пакетів, відкрийте LackMan для їх перегляду.</numerusform><numerusform>Отримано %n нових або оновлених пакетів, відкрийте LackMan для їх перегляду.</numerusform></translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"756\"/>\n\n <location filename=\"core.cpp\" line=\"833\"/>\n\n <source>Unable to remove package</source>\n\n <translation>Неможливо видалити пакет</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"800\"/>\n\n <location filename=\"core.cpp\" line=\"1247\"/>\n\n <source>Error installing package</source>\n\n <translation>Помилка встановлення пакету</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"801\"/>\n\n <source>Error recording package to the package DB.</source>\n\n <translation>Помилка запису пакету в базу даних пакетів.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1007\"/>\n\n <source>Repository addition error</source>\n\n <translation>Помилка при доданні репозиторія</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1008\"/>\n\n <source>Incorrect URL %1.</source>\n\n <translation>Некоректний URL %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1039\"/>\n\n <source>Error adding/updating repository</source>\n\n <translation>Помилка додавання/оновлення репозиторію</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1040\"/>\n\n <source>While trying to add or update the repository: %1.</source>\n\n <translation>Під час додавання чи оновлення репозиторію: %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1079\"/>\n\n <source>Unable to load component ID for component %1.</source>\n\n <translation>Неможливо завантажити ідентифікатор компоненту для компоненту %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1097\"/>\n\n <location filename=\"core.cpp\" line=\"1116\"/>\n\n <location filename=\"core.cpp\" line=\"1151\"/>\n\n <source>Error handling component</source>\n\n <translation>Помилка обробки компоненту</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1098\"/>\n\n <source>Unable to load packages already present in the component %1.</source>\n\n <translation>Неможливо завантажити пакети, вже присутні в компоненті %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1117\"/>\n\n <source>Unable to load package already present in the component %1.</source>\n\n <translation>Неможливо завантажити пакет, уже присутній в компоненті %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1152\"/>\n\n <source>Unable to remove package which has been removed upstream from %1.</source>\n\n <translation>Неможливо видалити пакет, який був видалений в репозиторії з %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1200\"/>\n\n <source>Error retrieving package</source>\n\n <translation>Помилка отримання пакету</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1201\"/>\n\n <source>Unable to save package %1.</source>\n\n <translation>Неможливо зберегти пакет %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1218\"/>\n\n <source>Error retrieving package icon</source>\n\n <translation>Помилка отримання іконки пакету</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1219\"/>\n\n <source>Unable to retrieve icon for package %1.</source>\n\n <translation>Неможливо отримати іконку для пакету %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1240\"/>\n\n <source>Error while fetching package %1: %2.</source>\n\n <translation>Помилка отримання пакету %1: %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1274\"/>\n\n <source>Package installed</source>\n\n <translation>Пакет встановлено</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1275\"/>\n\n <source>Package %1 installed successfully.</source>\n\n <translation>Пакет %1 встановлено успішно.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1305\"/>\n\n <source>Package updated</source>\n\n <translation>Пакет оновлено</translation>\n\n </message>\n\n <message>\n\n <location filename=\"core.cpp\" line=\"1306\"/>\n\n <source>Package %1 updated successfully.</source>\n\n <translation>Пакет %1 оновлено успішно.</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>LeechCraft::LackMan::PackageProcessor</name>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"48\"/>\n\n <source>Could not find database file for package %1.</source>\n\n <translation>Неможливо знайти базу даних для пакету %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"60\"/>\n\n <source>Could not open database file %1: %2.</source>\n\n <translation>Неможливо відкрити файл бази даних %1: %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"92\"/>\n\n <source>Could not remove file %1: %2.</source>\n\n <translation>Неможливо видалити файл %1: %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"121\"/>\n\n <source>Could not remove directory %1.</source>\n\n <translation>Неможливо видалити теку %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"135\"/>\n\n <source>Could not remove database file %1: %2.</source>\n\n <translation>Неможливо видалити %1: %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"200\"/>\n\n <source>Unable to unpack package archive, unpacker exited with %1: %2.</source>\n\n <translation>Неможливо розпакувати архів з пакетом, розпаковщик вийшов з кодом %1: %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"234\"/>\n\n <source>Unable to get directory for the package: %1.</source>\n\n <translation>Неможливо отримати папку для пакету: %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"270\"/>\n\n <source>Unable to copy files from staging area to destination directory.</source>\n\n <translation>Неможливо скопіювати файли з тимчасової теки в теку призначення.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"303\"/>\n\n <source>Unable to unpack package archive, unpacker died with %1: %2.</source>\n\n <translation>Неможливо розпакувати архів з пакетом, розпаковщик помер з кодом %1: %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"386\"/>\n\n <source>Unable to create staging directory %1.</source>\n\n <translation>Неможливо створити тимчасову теку %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"406\"/>\n\n <source>No URLs for package %1.</source>\n\n <translation>Немає адрес для пакету %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"470\"/>\n\n <source>Could not copy file %1 because of %2.</source>\n\n <translation>Невомжливо скопіювати файл %1 через %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"495\"/>\n\n <source>Unable to create directory %1.</source>\n\n <translation>Неможливо створити теку %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packageprocessor.cpp\" line=\"523\"/>\n\n <source>Unable to remove package %1 while updating to package %2</source>\n\n <translation>Неможливо видалити пакет %1 при оновленні до пакету %2</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>LeechCraft::LackMan::PackagesDelegate</name>\n\n <message>\n\n <location filename=\"packagesdelegate.cpp\" line=\"218\"/>\n\n <source>Remove</source>\n\n <translation>Видалити</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packagesdelegate.cpp\" line=\"223\"/>\n\n <source>Install</source>\n\n <translation>Встановити</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packagesdelegate.cpp\" line=\"245\"/>\n\n <source>Update</source>\n\n <translation>Оновити</translation>\n\n </message>\n\n <message>\n\n <location filename=\"packagesdelegate.cpp\" line=\"355\"/>\n\n <source>Unable to mark package, reverting.</source>\n\n <translation>Неможливо помітити пакет, повертаємося.</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>LeechCraft::LackMan::PendingManager</name>\n\n <message>\n\n <location filename=\"pendingmanager.cpp\" line=\"113\"/>\n\n <source>Package dependencies could not be fulfilled: %1</source>\n\n <translation>Залежності пакету не задоволені: %1</translation>\n\n </message>\n\n <message>\n\n <location filename=\"pendingmanager.cpp\" line=\"173\"/>\n\n <source>To be installed</source>\n\n <translation>Будуть встановлені</translation>\n\n </message>\n\n <message>\n\n <location filename=\"pendingmanager.cpp\" line=\"176\"/>\n\n <source>To be removed</source>\n\n <translation>Для видалення</translation>\n\n </message>\n\n <message>\n\n <location filename=\"pendingmanager.cpp\" line=\"179\"/>\n\n <source>To be updated</source>\n\n <translation>Будуть оновлені</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>LeechCraft::LackMan::Plugin</name>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"68\"/>\n\n <source>Package tags</source>\n\n <translation>Теґи пакету</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"182\"/>\n\n <source>LeechCraft Package Manager.</source>\n\n <translation>Пакетний менеджер для LeechCraft.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"324\"/>\n\n <source>Package information: %1</source>\n\n <translation>Інформація про пакет: %1</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"326\"/>\n\n <source>Package information</source>\n\n <translation>Інформація про пакет</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"331\"/>\n\n <source>not installed</source>\n\n <translation>не встановлено</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"333\"/>\n\n <source>installed; upgradable</source>\n\n <translation>встановлено; можливе оновлення</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"335\"/>\n\n <source>installed</source>\n\n <translation>встановлено</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"341\"/>\n\n <source>unknown</source>\n\n <translation>Невідомий</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"362\"/>\n\n <source>Total size to be downloaded: %1</source>\n\n <translation>Загальний розмір завантаження: %1\n\n</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"369\"/>\n\n <source>Update all repos</source>\n\n <translation>Оновити всі репозиторії</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"378\"/>\n\n <source>Upgrade all packages</source>\n\n <translation>Оновити всі пакети</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"387\"/>\n\n <source>Apply</source>\n\n <translation>Застосувати</translation>\n\n </message>\n\n <message>\n\n <location filename=\"lackman.cpp\" line=\"396\"/>\n\n <source>Cancel</source>\n\n <translation>Скасувати</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>LeechCraft::LackMan::RepoInfoFetcher</name>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"66\"/>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"279\"/>\n\n <source>Error fetching repository</source>\n\n <translation>Помилка отримання репозиторію</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"67\"/>\n\n <source>Could not find plugin to fetch repository information for %1.</source>\n\n <translation>Неможливо знайти модуль для отримання інформації про репозиторій %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"119\"/>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"329\"/>\n\n <source>Error fetching component</source>\n\n <translation>Помилка отримання компоненту</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"120\"/>\n\n <source>Could not find plugin to fetch component information at %1.</source>\n\n <translation>Неможливо знайти модуль для отримання інформації про компонент %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"198\"/>\n\n <source>Error fetching package information</source>\n\n <translation>Помилка отримання інформації про пакет</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"199\"/>\n\n <source>Could not find plugin to fetch package information at %1.</source>\n\n <translation>Неможливо знайти модуль для отримання інформації про пакет %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"280\"/>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"330\"/>\n\n <source>Error downloading file from %1.</source>\n\n <translation>Помилка завантаження з %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"378\"/>\n\n <source>Error fetching package</source>\n\n <translation>Помилка отримання пакету</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"379\"/>\n\n <source>Error fetching package from %1.</source>\n\n <translation>Помилка отримання пакету з %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"391\"/>\n\n <source>Repository unpack error</source>\n\n <translation>Помилка розпакування репозиторію</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"392\"/>\n\n <source>Unable to unpack the repository file. gunzip error: %1. Problematic file is at %2.</source>\n\n <translation>Нможливо розпакувати файл репозиторію. Помилка gunzip: %1. Проблемний файл в %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"412\"/>\n\n <source>Repository parse error</source>\n\n <translation>Помилка розбору репозиторію</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"413\"/>\n\n <source>Unable to parse repository description: %1.</source>\n\n <translation>Помилка розбору опису репозиторію: %1.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"429\"/>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"473\"/>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"515\"/>\n\n <source>Component unpack error</source>\n\n <translation>Помилка розпакування компоненту</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"430\"/>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"474\"/>\n\n <source>Unable to unpack the component file. gunzip error: %1. Problematic file is at %2.</source>\n\n <translation>Нможливо розпакувати файл компоненту. Помилка gunzip: %1. Проблемний файл в %2.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"450\"/>\n\n <source>Component parse error</source>\n\n <translation>Помилка розбору компоненту</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"451\"/>\n\n <source>Unable to parse component %1 description file. More information is available in logs.</source>\n\n <translation>Неможливо розібрати опис компоненту %1. Більше інформації можна знайти в журналі.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"494\"/>\n\n <source>Package parse error</source>\n\n <translation>Помилка розбору пакету</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"495\"/>\n\n <source>Unable to parse package description file. More information is available in logs.</source>\n\n <translation>Неможливо розібрати файл опису пакету. Більше інформації можна знайти в логах.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"repoinfofetcher.cpp\" line=\"516\"/>\n\n <source>Unable to unpack file. Exit code: %1. Problematic file is at %2.</source>\n\n <translation type=\"unfinished\"/>\n\n </message>\n\n</context>\n\n<context>\n\n <name>LeechCraft::LackMan::Storage</name>\n\n <message>\n\n <location filename=\"storage.cpp\" line=\"852\"/>\n\n <source>Package with ID %1 not found.</source>\n\n <translation>Пакет з ID %1 не знайдено.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"storage.cpp\" line=\"922\"/>\n\n <source>Unknown dependency type `%1`.</source>\n\n <translation>Невідомий тип залежності `%1`.</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>QObject</name>\n\n <message>\n\n <location filename=\"xmlparsers.cpp\" line=\"42\"/>\n\n <source>Could not get repo name.</source>\n\n <translation>Неможливо отримати ім&apos;я репозиторія.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"xmlparsers.cpp\" line=\"47\"/>\n\n <source>Could not get repo description.</source>\n\n <translation>Неможливо отримати опис репозиторія.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"xmlparsers.cpp\" line=\"52\"/>\n\n <source>Could not get long repo description.</source>\n\n <translation>Неможливо отримати повний опис репозиторія.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"xmlparsers.cpp\" line=\"58\"/>\n\n <source>Could not get maintainer name.</source>\n\n <translation>Неможливо отримати ім&apos;я супроводжувача.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"xmlparsers.cpp\" line=\"63\"/>\n\n <source>Could not get maintainer email.</source>\n\n <translation>Неможливо отримати пошту супроводжувача.</translation>\n\n </message>\n\n <message>\n\n <location filename=\"xmlparsers.cpp\" line=\"75\"/>\n\n <source>Could not get components.</source>\n\n <translation>Неможливо отримати список компонентів.</translation>\n\n </message>\n\n</context>\n\n<context>\n\n <name>lackmansettings</name>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"2\"/>\n\n <location filename=\"dummy.cpp\" line=\"4\"/>\n\n <source>Repositories</source>\n\n <translation>Репозиторії</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"3\"/>\n\n <source>Repositories list</source>\n\n <translation>Список репозиторіїв</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"5\"/>\n\n <source>Updates</source>\n\n <translation>Оновлення</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"6\"/>\n\n <source>Interval between updates check:</source>\n\n <translation>Інтервал перевірки оновлень</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"7\"/>\n\n <source>8 hours</source>\n\n <translation>8 годин</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"8\"/>\n\n <source>1 day</source>\n\n <translation>1 день</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"9\"/>\n\n <source>2 days</source>\n\n <translation>2 дні</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"10\"/>\n\n <source>4 days</source>\n\n <translation>4 дні</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"11\"/>\n\n <source>1 week</source>\n\n <translation>1 тиждень</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"12\"/>\n\n <source>2 weeks</source>\n\n <translation>2 тижні</translation>\n\n </message>\n\n <message>\n\n <location filename=\"dummy.cpp\" line=\"13\"/>\n\n <source>Never</source>\n\n <translation>Ніколи</translation>\n\n </message>\n\n</context>\n", "file_path": "src/plugins/lackman/leechcraft_lackman_uk_UA.ts", "rank": 34, "score": 123486.57600509137 }, { "content": "\t\tenum SyndicationRight\n\n\t\t{\n\n\t\t\tSROpen,\n\n\t\t\tSRLimited,\n\n\t\t\tSRPrivate,\n\n\t\t\tSRClosed\n", "file_path": "src/plugins/seekthru/description.h", "rank": 35, "score": 120273.18053160491 }, { "content": "\tclass Plugin : public QObject\n\n\t\t\t\t , public IInfo\n\n\t\t\t\t , public IHaveTabs\n\n\t\t\t\t , public IHaveSettings\n\n\t\t\t\t , public IEntityHandler\n\n\t\t\t\t , public IHaveShortcuts\n\n\t\t\t\t , public IHaveRecoverableTabs\n\n\t{\n\n\t\tQ_OBJECT\n\n\t\tQ_INTERFACES (IInfo\n\n\t\t\t\tIHaveTabs\n\n\t\t\t\tIHaveSettings\n\n\t\t\t\tIEntityHandler\n\n\t\t\t\tIHaveShortcuts\n\n\t\t\t\tIHaveRecoverableTabs)\n\n\n\n\t\tLC_PLUGIN_METADATA (\"org.LeechCraft.LackMan\")\n\n\n\n\t\tUtil::XmlSettingsDialog_ptr SettingsDialog_;\n\n\t\tUtil::ShortcutManager *ShortcutMgr_;\n", "file_path": "src/plugins/lackman/lackman.h", "rank": 36, "score": 119406.2355862298 }, { "content": "namespace LeechCraft\n\n{\n\n\tUTIL_API bool operator< (const LeechCraft::Entity&, const LeechCraft::Entity&);\n\n\tUTIL_API bool operator== (const LeechCraft::Entity&, const LeechCraft::Entity&);\n", "file_path": "src/util/structuresops.h", "rank": 37, "score": 118635.26130346378 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace AN\n\n{\n\n\t/** @brief Event cancel pseudo-category.\n\n\t *\n\n\t * This category is used to cancel an event by a given event ID.\n\n\t */\n\n\tconst QString CatEventCancel = \"org.LC.AdvNotifications.Cancel\";\n\n\n\n\t/** @brief Category of Instant Messaging-related events.\n\n\t */\n\n\tconst QString CatIM = \"org.LC.AdvNotifications.IM\";\n\n\t/** @brief Another user has requested our user's attention.\n\n\t */\n\n\tconst QString TypeIMAttention = CatIM + \".AttentionDrawn\";\n\n\t/** @brief Another user has sent our user a file.\n\n\t */\n\n\tconst QString TypeIMIncFile = CatIM + \".IncomingFile\";\n\n\t/** @brief User has received a message in a standard one-to-one chat.\n\n\t */\n\n\tconst QString TypeIMIncMsg = CatIM + \".IncomingMessage\";\n\n\t/** @brief User has been highlighted in a multiuser chat.\n\n\t *\n\n\t * The primary difference from TypeIMMUCMsg is that our user must be\n\n\t * explicitly mentioned in another user's message for this event.\n\n\t *\n\n\t * @sa TypeIMMUCMsg\n\n\t */\n\n\tconst QString TypeIMMUCHighlight = CatIM + \".MUCHighlightMessage\";\n\n\t/** @brief User has been invited to a multiuser chat.\n\n\t */\n\n\tconst QString TypeIMMUCInvite = CatIM + \".MUCInvitation\";\n\n\t/** @brief A message has been sent to a multiuser chat.\n\n\t *\n\n\t * This event should be emitted for each MUC message, even for those\n\n\t * our user isn't mentioned in.\n\n\t *\n\n\t * @sa TypeIMMUCHighlight\n\n\t */\n\n\tconst QString TypeIMMUCMsg = CatIM + \".MUCMessage\";\n\n\t/** @brief Another user in our user's contact list has changed its\n\n\t * status.\n\n\t */\n\n\tconst QString TypeIMStatusChange = CatIM + \".StatusChange\";\n\n\t/** @brief Another user has granted subscription to our user.\n\n\t */\n\n\tconst QString TypeIMSubscrGrant = CatIM + \".Subscr.Granted\";\n\n\t/** @brief Another user has revoked subscription from our user.\n\n\t */\n\n\tconst QString TypeIMSubscrRevoke = CatIM + \".Subscr.Revoked\";\n\n\t/** @brief Another user has requested subscription from our user.\n\n\t */\n\n\tconst QString TypeIMSubscrRequest = CatIM + \".Subscr.Requested\";\n\n\t/** @brief Another user has subscribed to our user.\n\n\t */\n\n\tconst QString TypeIMSubscrSub = CatIM + \".Subscr.Subscribed\";\n\n\t/** @brief Another user has unsubscribed from our user.\n\n\t */\n\n\tconst QString TypeIMSubscrUnsub = CatIM + \".Subscr.Unsubscribed\";\n\n\t/** @brief User's tune has changed.\n\n\t */\n\n\tconst QString TypeIMEventTuneChange = CatIM + \".Event.Tune\";\n\n\t/** @brief User's mood has changed.\n\n\t */\n\n\tconst QString TypeIMEventMoodChange = CatIM + \".Event.Mood\";\n\n\t/** @brief User's activity has changed.\n\n\t */\n\n\tconst QString TypeIMEventActivityChange = CatIM + \".Event.Activity\";\n\n\t/** @brief User's location has changed.\n\n\t */\n\n\tconst QString TypeIMEventLocationChange = CatIM + \".Event.Location\";\n\n\n\n\t/** @brief Category of Organizer-related events.\n\n\t */\n\n\tconst QString CatOrganizer = \"org.LC.AdvNotifications.Organizer\";\n\n\t/** @brief An event due date is coming.\n\n\t */\n\n\tconst QString TypeOrganizerEventDue = CatOrganizer + \".EventDue\";\n\n\n\n\t/** @brief Category of Downloads-related events.\n\n\t */\n\n\tconst QString CatDownloads = \"org.LC.AdvNotifications.Downloads\";\n\n\t/** @brief A download has been finished successfully without errors.\n\n\t */\n\n\tconst QString TypeDownloadFinished = CatDownloads + \".DownloadFinished\";\n\n\t/** @brief A download has been failed.\n\n\t */\n\n\tconst QString TypeDownloadError = CatDownloads + \".DownloadError\";\n\n\n\n\t/** @brief Category of package manager-related events.\n\n\t */\n\n\tconst QString CatPackageManager = \"org.LC.AdvNotifications.PackageManager\";\n\n\t/** @brief A package has been updated.\n\n\t */\n\n\tconst QString TypePackageUpdated = CatPackageManager + \".PackageUpdated\";\n\n\n\n\t/** @brief Category of media player-related events.\n\n\t */\n\n\tconst QString CatMediaPlayer = \"org.LC.AdvNotifications.MediaPlayer\";\n\n\n\n\t/** @brief A media file playback status has been changed.\n\n\t */\n\n\tconst QString TypeMediaPlaybackStatus = CatMediaPlayer + \".PlaybackStatus\";\n\n\n\n\t/** @brief Category for terminal emulation events.\n\n\t */\n\n\tconst QString CatTerminal = \"org.LC.AdvNotifications.Terminal\";\n\n\n\n\t/** @brief A bell has ringed in a terminal window.\n\n\t */\n\n\tconst QString TypeTerminalBell = CatTerminal + \".Bell\";\n\n\n\n\t/** @brief Activity in terminal window.\n\n\t */\n\n\tconst QString TypeTerminalActivity = CatTerminal + \".Activity\";\n\n\n\n\t/** @brief Inactivity in terminal window.\n\n\t */\n\n\tconst QString TypeTerminalInactivity = CatTerminal + \".Inactivity\";\n\n\n\n\t/** @brief Generic notifications that don't fit into any other category.\n\n\t */\n\n\tconst QString CatGeneric = \"org.LC.AdvNotifications.Generic\";\n\n\n\n\t/** @brief Generic type for generic notifications.\n\n\t */\n\n\tconst QString TypeGeneric = CatGeneric + \".Generic\";\n\n\n\n\t/** @brief Describes the notification parameters.\n\n\t */\n\n\tenum NotifyFlag\n\n\t{\n\n\t\t/** @brief No notifications.\n\n\t\t */\n\n\t\tNotifyNone\t\t\t= 0,\n\n\n\n\t\t/** @brief Rule should be triggered only once.\n\n\t\t *\n\n\t\t * This corresponds to the single shot events. That is, after\n\n\t\t * first triggering of the rule it should be disabled and user\n\n\t\t * shouldn't get further notifications.\n\n\t\t */\n\n\t\tNotifySingleShot\t= 1 << 0,\n\n\n\n\t\t/** @brief User should be notified visually.\n\n\t\t *\n\n\t\t * The user should be notified via transient notifications like\n\n\t\t * a non-intrusive tooltip that will hide soon.\n\n\t\t *\n\n\t\t * This is ortogonal to NotifyPersistent.\n\n\t\t *\n\n\t\t * @sa NotifyPersistent\n\n\t\t */\n\n\t\tNotifyTransient\t\t= 1 << 1,\n\n\n\n\t\t/** @brief User should be notified visually via persistent\n\n\t\t * notifications.\n\n\t\t *\n\n\t\t * A persistent notification is something like a tray icon\n\n\t\t * that will be displayed until the user reacts to the event.\n\n\t\t *\n\n\t\t * This is ortogonal to NotifyTransient.\n\n\t\t *\n\n\t\t * @sa NotifyTransient\n\n\t\t */\n\n\t\tNotifyPersistent\t= 1 << 2,\n\n\n\n\t\t/** @brief Notify by playing back an audio file.\n\n\t\t */\n\n\t\tNotifyAudio\t\t\t= 1 << 3\n\n\t};\n\n\tQ_DECLARE_FLAGS (NotifyFlags, NotifyFlag);\n\n\n\n\tnamespace Field\n\n\t{\n\n\t\t/** @brief The URL to the file being played.\n\n\t\t*/\n\n\t\tconst QString MediaPlayerURL = CatMediaPlayer + \".Fields.URL\";\n\n\n\n\t\t/** @brief Playback status of the URL (QString).\n\n\t\t *\n\n\t\t * A string, one of:\n\n\t\t * - Playing\n\n\t\t * - Paused\n\n\t\t * - Stopped\n\n\t\t */\n\n\t\tconst QString MediaPlaybackStatus = CatMediaPlayer + \".Fields.PlaybackStatus\";\n\n\n\n\t\t/** @brief The title of the currently playing media (QString).\n\n\t\t */\n\n\t\tconst QString MediaTitle = CatMediaPlayer + \".Fields.Title\";\n\n\n\n\t\t/** @brief The artist of the currently playing media (QString).\n\n\t\t */\n\n\t\tconst QString MediaArtist = CatMediaPlayer + \".Fields.Artist\";\n\n\n\n\t\t/** @brief The album of the currently playing media (QString).\n\n\t\t */\n\n\t\tconst QString MediaAlbum = CatMediaPlayer + \".Fields.Album\";\n\n\n\n\t\t/** @brief The length of the currently playing media (int).\n\n\t\t */\n\n\t\tconst QString MediaLength = CatMediaPlayer + \".Fields.Length\";\n\n\n\n\t\t/** @brief Whether the terminal window is active (bool).\n\n\t\t */\n\n\t\tconst QString TerminalActive = CatTerminal + \".Fields.Active\";\n\n\n\n\t\t/** @brief General activity name of a contact (QString).\n\n\t\t */\n\n\t\tconst QString IMActivityGeneral = CatIM + \".Fields.Activity.General\";\n\n\t\t/** @brief Specific activity name of a contact (QString).\n\n\t\t */\n\n\t\tconst QString IMActivitySpecific = CatIM + \".Fields.Activity.Specific\";\n\n\t\t/** @brief Accompanying activity text entered by a contact (QString).\n\n\t\t */\n\n\t\tconst QString IMActivityText = CatIM + \".Fields.Activity.Text\";\n\n\n\n\t\t/** @brief General mood name of a contact (QString).\n\n\t\t */\n\n\t\tconst QString IMMoodGeneral = CatIM + \".Fields.Mood.General\";\n\n\t\t/** @brief Accompanying mood text entered by a contact (QString).\n\n\t\t */\n\n\t\tconst QString IMMoodText = CatIM + \".Fields.Mood.Text\";\n\n\n\n\t\t/** @brief Longitude of a contact's position (double).\n\n\t\t */\n\n\t\tconst QString IMLocationLongitude = CatIM + \".Fields.Location.Longitude\";\n\n\t\t/** @brief Latitude of a contact's position (double).\n\n\t\t */\n\n\t\tconst QString IMLocationLatitude = CatIM + \".Fields.Location.Latitude\";\n\n\t\t/** @brief Country a contact is currently in (QString).\n\n\t\t */\n\n\t\tconst QString IMLocationCountry = CatIM + \".Fields.Location.Country\";\n\n\t\t/** @brief Exact locality, like a town or a city, a contact is\n\n\t\t * currently in (QString).\n\n\t\t */\n\n\t\tconst QString IMLocationLocality = CatIM + \".Fields.Location.Locality\";\n\n\t}\n\n}\n", "file_path": "src/interfaces/an/constants.h", "rank": 38, "score": 118635.26130346378 }, { "content": "namespace LeechCraft\n\n{\n\n\tnamespace DataSources\n\n\t{\n\n\t\tenum DataSourceRole\n\n\t\t{\n\n\t\t\tFieldType = Qt::UserRole + 1,\n\n\t\t\tFieldValues,\n\n\t\t\tFieldNonModifiable\n\n\t\t};\n\n\n\n\t\tenum DataFieldType\n\n\t\t{\n\n\t\t\tNone,\n\n\t\t\tString,\n\n\t\t\tUrl,\n\n\t\t\tLocalPath,\n\n\t\t\tInteger,\n\n\t\t\tEnum,\n\n\t\t\tColor,\n\n\t\t\tFont\n\n\t\t};\n\n\t}\n", "file_path": "src/xmlsettingsdialog/datasourceroles.h", "rank": 39, "score": 118635.26130346378 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Liznoo\n\n{\n\n\tstruct BatteryInfo\n\n\t{\n\n\t\tQString ID_;\n\n\n\n\t\tchar Percentage_ = 0;\n\n\n\n\t\t/** Time until battery is fully charged in seconds, or 0 if\n\n\t\t * battery isn't charging.\n\n\t\t */\n\n\t\tqlonglong TimeToFull_;\n\n\t\tqlonglong TimeToEmpty_;\n\n\t\tdouble Voltage_ = 0;\n\n\n\n\t\tdouble Energy_ = 0;\n\n\t\tdouble EnergyFull_ = 0;\n\n\t\tdouble DesignEnergyFull_ = 0;\n\n\t\tdouble EnergyRate_ = 0;\n\n\n\n\t\tQString Technology_;\n\n\n\n\t\tdouble Temperature_;\n\n\n\n\t\tint CyclesCount_ = 0;\n\n\n\n\t\tvoid Dump ();\n\n\t};\n\n}\n", "file_path": "src/plugins/liznoo/batteryinfo.h", "rank": 40, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace CpuLoad\n\n{\n\n\tenum class LoadPriority\n\n\t{\n\n\t\tHigh,\n\n\t\tMedium,\n\n\t\tLow,\n\n\t\tIO,\n\n\n\n\t\t// This one for completeness\n\n\t\tIdle\n\n\t};\n\n\n\n\tstruct LoadTypeInfo\n\n\t{\n\n\t\tdouble LoadPercentage_;\n\n\n\n\t\tLoadTypeInfo& operator-= (const LoadTypeInfo&);\n\n\t};\n\n\n\n\tLoadTypeInfo operator- (const LoadTypeInfo&, const LoadTypeInfo&);\n\n}\n", "file_path": "src/plugins/cpuload/structures.h", "rank": 41, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<typename T>\n\n\tstruct WrapType\n\n\t{\n\n\t\tusing type = T;\n\n\t};\n\n\n\n\ttemplate<typename T>\n\n\tusing WrapType_t = typename WrapType<T>::type;\n\n\n\n\ttemplate<>\n\n\tstruct WrapType<QList<QString>>\n\n\t{\n\n\t\tusing type = QStringList;\n\n\t};\n\n\n\n\ttemplate<typename T1, typename T2, template<typename U> class Container, typename F>\n\n\tauto ZipWith (const Container<T1>& c1, const Container<T2>& c2, F f) -> WrapType_t<Container<std::decay_t<std::result_of_t<F (T1, T2)>>>>\n\n\t{\n\n\t\tWrapType_t<Container<std::decay_t<std::result_of_t<F (T1, T2)>>>> result;\n\n\n\n\t\tusing std::begin;\n\n\t\tusing std::end;\n\n\n\n\t\tauto i1 = begin (c1), e1 = end (c1);\n\n\t\tauto i2 = begin (c2), e2 = end (c2);\n\n\t\tfor ( ; i1 != e1 && i2 != e2; ++i1, ++i2)\n\n\t\t\tresult.push_back (f (*i1, *i2));\n\n\t\treturn result;\n\n\t}\n\n\n\n\ttemplate<typename T1, typename T2,\n\n\t\ttemplate<typename U> class Container,\n\n\t\ttemplate<typename U1, typename U2> class Pair = QPair>\n\n\tauto Zip (const Container<T1>& c1, const Container<T2>& c2) -> Container<Pair<T1, T2>>\n\n\t{\n\n\t\treturn ZipWith (c1, c2,\n\n\t\t\t\t[] (const T1& t1, const T2& t2) -> Pair<T1, T2>\n\n\t\t\t\t\t{ return { t1, t2}; });\n", "file_path": "src/util/sll/prelude.h", "rank": 42, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<typename Applicative>\n\n\tstruct InstanceApplicative;\n\n\n\n\ttemplate<typename AF, typename AV>\n\n\tusing GSLResult_t = typename InstanceApplicative<AF>::template GSLResult<AV>::Type_t;\n\n\n\n\ttemplate<template<typename...> class Applicative, typename... Args, typename T>\n\n\tauto Pure (const T& v)\n\n\t{\n\n\t\treturn InstanceApplicative<Applicative<Args..., T>>::Pure (v);\n\n\t}\n\n\n\n\ttemplate<typename Applicative, typename T>\n\n\tauto Pure (const T& v) -> decltype (InstanceApplicative<Applicative>::Pure (v))\n\n\t{\n\n\t\treturn InstanceApplicative<Applicative>::Pure (v);\n\n\t}\n\n\n\n\ttemplate<typename AF, typename AV>\n\n\tGSLResult_t<AF, AV> GSL (const AF& af, const AV& av)\n\n\t{\n\n\t\treturn InstanceApplicative<AF>::GSL (af, av);\n\n\t}\n\n\n\n\ttemplate<typename AF, typename AV>\n\n\tauto operator* (const AF& af, const AV& av) -> decltype (GSL (af, av))\n\n\t{\n\n\t\treturn GSL (af, av);\n\n\t}\n\n\n\n\t// Implementations\n\n\ttemplate<typename T>\n\n\tstruct InstanceApplicative<boost::optional<T>>\n\n\t{\n\n\t\tusing Type_t = boost::optional<T>;\n\n\n\n\t\ttemplate<typename>\n\n\t\tstruct GSLResult;\n\n\n\n\t\ttemplate<typename V>\n\n\t\tstruct GSLResult<boost::optional<V>>\n\n\t\t{\n\n\t\t\tusing Type_t = boost::optional<std::result_of_t<T (V)>>;\n\n\t\t};\n\n\n\n\t\ttemplate<typename U>\n\n\t\tstatic boost::optional<U> Pure (const U& v)\n\n\t\t{\n\n\t\t\treturn { v };\n\n\t\t}\n\n\n\n\t\ttemplate<typename AV>\n\n\t\tstatic GSLResult_t<Type_t, AV> GSL (const Type_t& f, const AV& v)\n\n\t\t{\n\n\t\t\tif (!f || !v)\n\n\t\t\t\treturn {};\n\n\n\n\t\t\treturn { (*f) (*v) };\n\n\t\t}\n", "file_path": "src/util/sll/applicative.h", "rank": 43, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace AdvancedNotifications\n\n{\n\n\tstruct EventData\n\n\t{\n\n\t\tQString EventID_;\n\n\t\tint Count_;\n\n\t\tQString Category_;\n\n\t\tQStringList VisualPath_;\n\n\t\tQString ExtendedText_;\n\n\t\tQString FullText_;\n\n\t\tQPixmap Pixmap_;\n\n\n\n\t\tQObject_ptr HandlingObject_;\n\n\t\tQStringList Actions_;\n\n\n\n\t\tEntity Canceller_;\n\n\t};\n\n}\n", "file_path": "src/plugins/advancednotifications/eventdata.h", "rank": 44, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<typename T, typename SFINAE = void>\n\n\tstruct InstanceMonadPlus\n\n\t{\n\n\t\tusing UndefinedTag = void;\n\n\t};\n\n\n\n\tnamespace detail\n\n\t{\n\n\t\ttemplate<typename T>\n\n\t\tconstexpr bool IsMonadPlusImpl (int, typename InstanceMonadPlus<T>::UndefinedTag* = nullptr)\n\n\t\t{\n\n\t\t\treturn false;\n\n\t\t}\n\n\n\n\t\ttemplate<typename T>\n\n\t\tconstexpr bool IsMonadPlusImpl (float)\n\n\t\t{\n\n\t\t\treturn true;\n\n\t\t}\n\n\t}\n\n\n\n\ttemplate<typename T>\n\n\tconstexpr bool IsMonadPlus ()\n\n\t{\n\n\t\treturn detail::IsMonadPlusImpl<T> (0);\n\n\t}\n\n\n\n\ttemplate<typename MP>\n\n\tMP Mzero ()\n\n\t{\n\n\t\treturn InstanceMonadPlus<MP>::Mzero ();\n\n\t}\n\n\n\n\tconst struct\n\n\t{\n\n\t\ttemplate<typename MP>\n\n\t\tauto operator() (const MP& m1) const\n\n\t\t{\n\n\t\t\treturn [m1] (const MP& m2) { return InstanceMonadPlus<MP>::Mplus (m1, m2); };\n\n\t\t}\n", "file_path": "src/util/sll/monadplus.h", "rank": 45, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<typename T>\n\n\tstruct InstanceFunctor<QFuture<T>>\n\n\t{\n\n\t\ttemplate<typename F>\n\n\t\tusing FmapResult_t = QFuture<std::decay_t<std::result_of_t<F (T)>>>;\n\n\n\n\t\ttemplate<typename F>\n\n\t\tstatic FmapResult_t<F> Apply (const QFuture<T>& t, const F& f)\n\n\t\t{\n\n\t\t\treturn Sequence (nullptr, t) >>\n\n\t\t\t\t\t[f] (const T& t) { return MakeReadyFuture (f (t)); };\n\n\t\t}\n\n\t};\n", "file_path": "src/util/threads/monadicfuture.h", "rank": 46, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\tnamespace detail\n\n\t{\n\n\t\ttemplate<typename Head, typename... Tail>\n\n\t\tstruct VisitorBase : std::decay_t<Head>, VisitorBase<Tail...>\n\n\t\t{\n\n\t\t\tusing std::decay_t<Head>::operator();\n\n\t\t\tusing VisitorBase<Tail...>::operator();\n\n\n\n\t\t\tVisitorBase (Head&& head, Tail&&... tail)\n\n\t\t\t: std::decay_t<Head> { std::forward<Head> (head) }\n\n\t\t\t, VisitorBase<Tail...> { std::forward<Tail> (tail)... }\n\n\t\t\t{\n\n\t\t\t}\n\n\t\t};\n\n\n\n\t\ttemplate<typename Head>\n\n\t\tstruct VisitorBase<Head> : std::decay_t<Head>\n\n\t\t{\n\n\t\t\tusing std::decay_t<Head>::operator();\n\n\n\n\t\t\tVisitorBase (Head&& head)\n\n\t\t\t: std::decay_t<Head> { std::forward<Head> (head) }\n\n\t\t\t{\n\n\t\t\t}\n\n\t\t};\n\n\n\n\t\ttemplate<typename R, typename... Args>\n\n\t\tstruct Visitor : boost::static_visitor<R>, VisitorBase<Args...>\n\n\t\t{\n\n\t\t\tusing VisitorBase<Args...>::VisitorBase;\n\n\t\t};\n\n\t}\n\n\n\n\ttemplate<typename HeadVar, typename... TailVars, typename... Args>\n\n\tauto Visit (const boost::variant<HeadVar, TailVars...>& v, Args&&... args) ->\n\n\t\t\tdecltype (detail::VisitorBase<Args...> { std::forward<Args> (args)... } (std::declval<HeadVar> ()))\n\n\t{\n\n\t\tusing R_t = decltype (detail::VisitorBase<Args...> { std::forward<Args> (args)... } (std::declval<HeadVar> ()));\n\n\n\n\t\treturn boost::apply_visitor (detail::Visitor<R_t, Args...> { std::forward<Args> (args)... }, v);\n\n\t}\n\n\n\n\ttemplate<typename T, typename... Args>\n\n\tauto InvokeOn (T&& t, Args&&... args) -> decltype (detail::VisitorBase<Args...> { std::forward<Args> (args)... } (std::forward<T> (t)))\n\n\t{\n\n\t\treturn detail::VisitorBase<Args...> { std::forward<Args> (args)... } (std::forward<T> (t));\n\n\t}\n\n}\n", "file_path": "src/util/sll/visitor.h", "rank": 47, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<typename T>\n\n\tstruct InstanceMonad;\n\n\n\n\ttemplate<template<typename...> class Monad, typename... Args, typename V>\n\n\tauto Return (const V& v)\n\n\t{\n\n\t\treturn Pure<Monad, Args...> (v);\n\n\t}\n\n\n\n\ttemplate<typename MV, typename F>\n\n\tusing BindResult_t = typename InstanceMonad<MV>::template BindResult_t<F>;\n\n\n\n\tnamespace detail\n\n\t{\n\n\t\ttemplate<template<typename...> class Monad, typename... Args1, typename... Args2>\n\n\t\tconstexpr bool IsCompatibleMonadImpl (const Monad<Args1...>*, const Monad<Args2...>*, int)\n\n\t\t{\n\n\t\t\treturn std::is_same<\n\n\t\t\t\t\t\tdecltype (Init (Typelist<Args1...> {})),\n\n\t\t\t\t\t\tdecltype (Init (Typelist<Args2...> {}))\n\n\t\t\t\t\t>::value;\n\n\t\t}\n\n\n\n\t\ttemplate<typename T1, typename T2>\n\n\t\tconstexpr bool IsCompatibleMonadImpl (const T1*, const T2*, ...)\n\n\t\t{\n\n\t\t\treturn false;\n\n\t\t}\n\n\n\n\t\ttemplate<typename T>\n\n\t\tconstexpr T* declptr () noexcept\n\n\t\t{\n\n\t\t\treturn nullptr;\n\n\t\t}\n\n\n\n\t\ttemplate<typename T1, typename T2>\n\n\t\tconstexpr bool IsCompatibleMonad ()\n\n\t\t{\n\n\t\t\treturn IsCompatibleMonadImpl (detail::declptr<T1> (), detail::declptr<T2> (), 0);\n\n\t\t}\n\n\t}\n\n\n\n\ttemplate<typename MV, typename F>\n\n\tBindResult_t<MV, F> Bind (const MV& value, const F& f)\n\n\t{\n\n\t\tstatic_assert (detail::IsCompatibleMonad<MV, BindResult_t<MV, F>> (),\n\n\t\t\t\t\"Incompatible function return type\");\n\n\t\treturn InstanceMonad<MV>::Bind (value, f);\n\n\t}\n\n\n\n\ttemplate<typename MV, typename F>\n\n\tauto operator>> (const MV& value, const F& f) -> decltype (Bind (value, f))\n\n\t{\n\n\t\treturn Bind (value, f);\n\n\t}\n\n\n\n\ttemplate<typename MV>\n\n\tauto Do (const MV& value)\n\n\t{\n\n\t\treturn value;\n\n\t}\n\n\n\n\ttemplate<typename MV, typename FHead, typename... FArgs>\n\n\tauto Do (const MV& value, const FHead& fHead, const FArgs&... fArgs)\n\n\t{\n\n\t\treturn Do (Bind (value, fHead), fArgs...);\n\n\t}\n\n\n\n\t// Implementations\n\n\ttemplate<typename T>\n\n\tstruct InstanceMonad<boost::optional<T>>\n\n\t{\n\n\t\ttemplate<typename F>\n\n\t\tusing BindResult_t = std::result_of_t<F (T)>;\n\n\n\n\t\ttemplate<typename F>\n\n\t\tstatic BindResult_t<F> Bind (const boost::optional<T>& value, const F& f)\n\n\t\t{\n\n\t\t\tif (!value)\n\n\t\t\t\treturn {};\n\n\n\n\t\t\treturn f (*value);\n\n\t\t}\n\n\t};\n", "file_path": "src/util/sll/monad.h", "rank": 48, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Dolozhee\n\n{\n\n\tstruct FileInfo\n\n\t{\n\n\t\tQString Name_;\n\n\t\tQString Description_;\n\n\t\tQString Token_;\n\n\t\tQString Mime_;\n\n\t};\n\n}\n", "file_path": "src/plugins/dolozhee/structures.h", "rank": 49, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<typename F>\n\n\tvoid HandleNetworkReply (QObject *context, QNetworkReply *reply, F f)\n\n\t{\n\n\t\tnew Util::SlotClosure<Util::DeleteLaterPolicy>\n\n\t\t{\n\n\t\t\t[reply, f]\n\n\t\t\t{\n\n\t\t\t\treply->deleteLater ();\n\n\t\t\t\tf (reply->readAll ());\n\n\t\t\t},\n\n\t\t\treply,\n\n\t\t\tSIGNAL (finished ()),\n\n\t\t\tcontext\n\n\t\t};\n\n\t}\n\n}\n", "file_path": "src/util/network/handlenetworkreply.h", "rank": 50, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace HotSensors\n\n{\n\n\tstruct Reading\n\n\t{\n\n\t\tQString Name_;\n\n\t\tdouble Value_;\n\n\t\tdouble Max_;\n\n\t\tdouble Crit_;\n\n\t};\n\n\n\n\tusing Readings_t = boost::circular_buffer<Reading>;\n\n\n\n\tusing ReadingsHistory_t = QMap<QString, Readings_t>;\n\n}\n", "file_path": "src/plugins/hotsensors/structures.h", "rank": 51, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace MusicZombie\n\n{\n\n\tQNetworkRequest SetupRequest (QNetworkRequest);\n\n}\n", "file_path": "src/plugins/musiczombie/util.h", "rank": 52, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace HistoryHolder\n\n{\n\n\tstruct HistoryEntry\n\n\t{\n\n\t\tEntity Entity_;\n\n\t\tQDateTime DateTime_;\n\n\t};\n\n\n\n\tQDataStream& operator<< (QDataStream& out, const HistoryEntry&);\n\n\tQDataStream& operator>> (QDataStream& in, HistoryEntry&);\n\n}\n", "file_path": "src/plugins/historyholder/historyentry.h", "rank": 53, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace BitTorrent\n\n{\n\n\tstruct NewTorrentParams\n\n\t{\n\n\t\tQString Output_\n\n\t\t\t, AnnounceURL_\n\n\t\t\t, Comment_\n\n\t\t\t, Path_;\n\n\t\tQDate Date_;\n\n\t\tint PieceSize_;\n\n\t\tQStringList URLSeeds_;\n\n\t\tQStringList DHTNodes_;\n\n\t\tbool DHTEnabled_;\n\n\t};\n\n}\n", "file_path": "src/plugins/bittorrent/newtorrentparams.h", "rank": 54, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace BitTorrent\n\n{\n\n\tstruct FileInfo\n\n\t{\n\n\t\tboost::filesystem::path Path_;\n\n\t\tquint64 Size_;\n\n\t\tint Priority_;\n\n\t\tfloat Progress_;\n\n\t};\n\n}\n", "file_path": "src/plugins/bittorrent/fileinfo.h", "rank": 55, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\t/** @brief An utility typedef for SlotClosure deleting immediately\n\n\t * after firing.\n\n\t *\n\n\t * @sa SlotClosure\n\n\t */\n\n\tusing OneTimeRunner = SlotClosure<DeleteLaterPolicy>;\n\n}\n", "file_path": "src/util/sll/onetimerunner.h", "rank": 56, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Fenet\n\n{\n\n\tstruct WMInfo\n\n\t{\n\n\t\tQString Name_;\n\n\t\tQString Comment_;\n\n\n\n\t\tQStringList ExecNames_;\n\n\n\n\t\tQString Session_;\n\n\n\n\t\tbool SupportsCompositing_;\n\n\t};\n\n\n\n\ttypedef QList<WMInfo> WMInfos_t;\n\n}\n", "file_path": "src/plugins/fenet/wminfo.h", "rank": 57, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Azoth\n\n{\n\nnamespace RIEX\n\n{\n\n\tvoid HandleRIEXItemsSuggested (QList<RIEXItem> items, QObject *from, QString message);\n\n}\n\n}\n", "file_path": "src/plugins/azoth/riexhandler.h", "rank": 58, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\tstruct ServiceInfo\n\n\t{\n\n\t\tQString DefaultHost_;\n\n\t\tint DefaultPort_;\n\n\t\tQByteArray EnvPrefix_;\n\n\n\n\t\tbool UseSslByDefault_ = true;\n\n\t};\n\n\n\n\tUTIL_NETWORK_API QString GetServiceUrl (const ServiceInfo& serviceInfo, const QString& path);\n\n}\n", "file_path": "src/util/network/lcserviceoverride.h", "rank": 59, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\t/** @brief The Functor class is used for types that can be mapped over.\n\n\t *\n\n\t * Minimal complete definition:\n\n\t * - Apply() function and FmapResult_t alias.\n\n\t *\n\n\t * For a reference imolementation please see InstanceFunctor<boost::optional<T>>.\n\n\t *\n\n\t * @tparam T The functor type instantiated with some concrete\n\n\t * containee type.\n\n\t *\n\n\t * @sa Fmap()\n\n\t * @sa IsFunctor()\n\n\t */\n\n\ttemplate<typename T>\n\n\tstruct InstanceFunctor\n\n\t{\n\n\t\tusing UndefinedTag = void;\n\n\n\n\t\t/** @brief The type of the functor after its elements were\n\n\t\t * mapped by the function \\em F.\n\n\t\t *\n\n\t\t * This type should correspond to the return type of the Apply()\n\n\t\t * function when passed this functor and a function of type\n\n\t\t * \\em F.\n\n\t\t *\n\n\t\t * @tparam F The type of the function to apply to the elements\n\n\t\t * inside this functor.\n\n\t\t */\n\n\t\ttemplate<typename F>\n\n\t\tusing FmapResult_t = detail::ImplementationType;\n\n\n\n\t\t/** @brief Applies the \\em function to the each of the elements\n\n\t\t * inside the \\em functor.\n\n\t\t *\n\n\t\t * @param[in] functor The functor whose values are subject to\n\n\t\t * \\em function.\n\n\t\t * @param[in] function The function that should be applied to the\n\n\t\t * values in the \\em functor.\n\n\t\t * @return A functor of type FmapResult_t<F> where each element\n\n\t\t * the result of applying the \\em function to the corresponding element\n\n\t\t * in the source \\em functor.\n\n\t\t *\n\n\t\t * @tparam F The type of the \\em function to apply to the elements\n\n\t\t * in the function.\n\n\t\t */\n\n\t\ttemplate<typename F>\n\n\t\tstatic FmapResult_t<F> Apply (const T& functor, const F& function);\n\n\t};\n\n\n\n\tnamespace detail\n\n\t{\n\n\t\ttemplate<typename T>\n\n\t\tconstexpr bool IsFunctorImpl (int, typename InstanceFunctor<T>::UndefinedTag* = nullptr)\n\n\t\t{\n\n\t\t\treturn false;\n\n\t\t}\n\n\n\n\t\ttemplate<typename T>\n\n\t\tconstexpr bool IsFunctorImpl (float)\n\n\t\t{\n\n\t\t\treturn true;\n\n\t\t}\n\n\t}\n\n\n\n\t/** @brief Checks whether the given type has a Functor instance for it.\n\n\t *\n\n\t * @return Whether type T implements the Functor class.\n\n\t *\n\n\t * @tparam T The type to check.\n\n\t */\n\n\ttemplate<typename T>\n\n\tconstexpr bool IsFunctor ()\n\n\t{\n\n\t\treturn detail::IsFunctorImpl<T> (0);\n\n\t}\n\n\n\n\t/** @brief The result type of the contents of the functor \\em T mapped\n\n\t * by function \\em F.\n\n\t *\n\n\t * @tparam T The type of the functor.\n\n\t * @tparam F The type of the function to apply to the elements inside the\n\n\t * functor.\n\n\t */\n\n\ttemplate<typename T, typename F>\n\n\tusing FmapResult_t = typename InstanceFunctor<T>::template FmapResult_t<F>;\n\n\n\n\t/** @brief Apply the function \\em f to the elements in \\em functor.\n\n\t *\n\n\t * This function forwards the function \\em f to the instance of the\n\n\t * Functor class (namely, InstanceFunctor<T>) for the type \\em T to do\n\n\t * the actual function application.\n\n\t *\n\n\t * @param[in] functor The functor whose values are subject to\n\n\t * \\em function.\n\n\t * @param[in] function The function that should be applied to the\n\n\t * values in the functor.\n\n\t * @return A functor of type FmapResult_t<T, F> where each element is\n\n\t * the result of applying the \\em function to the corresponding element\n\n\t * in the source \\em functor.\n\n\t *\n\n\t * @tparam T The type of the functor.\n\n\t * @tparam F The type of the function to apply to the elements inside\n\n\t * the functor.\n\n\t *\n\n\t * @sa InstanceFunctor\n\n\t */\n\n\ttemplate<typename T, typename F, typename = std::enable_if_t<IsFunctor<T> ()>>\n\n\tFmapResult_t<T, F> Fmap (const T& functor, const F& function)\n\n\t{\n\n\t\treturn InstanceFunctor<T>::Apply (functor, function);\n\n\t}\n\n\n\n\t/** @brief An operator-style alias for Fmap().\n\n\t *\n\n\t * This operator allows writing Fmap()'s in infix form. Internally, it\n\n\t * just forwards the call to Fmap().\n\n\t *\n\n\t * @param[in] functor The functor whose values are subject to\n\n\t * \\em function.\n\n\t * @param[in] function The function that should be applied to the\n\n\t * values in the functor.\n\n\t * @return A functor of type FmapResult_t<T, F> where each element is\n\n\t * the result of applying the \\em function to the corresponding element\n\n\t * in the source \\em functor.\n\n\t *\n\n\t * @tparam T The type of the functor.\n\n\t * @tparam F The type of the function to apply to the elements inside\n\n\t * the functor.\n\n\t *\n\n\t * @sa InstanceFunctor\n\n\t * @sa Fmap()\n\n\t */\n\n\ttemplate<typename T, typename F>\n\n\tauto operator* (const F& function, const T& functor) -> decltype (Fmap (functor, function))\n\n\t{\n\n\t\treturn Fmap (functor, function);\n\n\t}\n\n\n\n\t/** @brief An operator-style alias for Fmap().\n\n\t *\n\n\t * This operator allows writing Fmap()'s in infix form. Internally, it\n\n\t * just forwards the call to Fmap().\n\n\t *\n\n\t * @param[in] functor The functor whose values are subject to\n\n\t * \\em function.\n\n\t * @param[in] function The function that should be applied to the\n\n\t * values in the functor.\n\n\t * @return A functor of type FmapResult_t<T, F> where each element is\n\n\t * the result of applying the \\em function to the corresponding element\n\n\t * in the source \\em functor.\n\n\t *\n\n\t * @tparam T The type of the functor.\n\n\t * @tparam F The type of the function to apply to the elements inside\n\n\t * the functor.\n\n\t *\n\n\t * @sa InstanceFunctor\n\n\t * @sa Fmap()\n\n\t */\n\n\ttemplate<typename T, typename F>\n\n\tauto operator* (const T& functor, const F& function) -> decltype (Fmap (functor, function))\n\n\t{\n\n\t\treturn Fmap (functor, function);\n\n\t}\n\n\n\n\t/** @brief Implementation of the Functor class for boost.optional.\n\n\t *\n\n\t * The implementation applies the function to the contents of the\n\n\t * boost.optional if it's not empty, otherwise it just leaves an\n\n\t * empty boost.optional.\n\n\t *\n\n\t * This is analogous to the Maybe type.\n\n\t *\n\n\t * @tparam T The element type contained inside the boost.optional.\n\n\t */\n\n\ttemplate<typename T>\n\n\tstruct InstanceFunctor<boost::optional<T>>\n\n\t{\n\n\t\ttemplate<typename F>\n\n\t\tusing FmapResult_t = boost::optional<std::decay_t<std::result_of_t<F (T)>>>;\n\n\n\n\t\ttemplate<typename F>\n\n\t\tstatic FmapResult_t<F> Apply (const boost::optional<T>& t, const F& f)\n\n\t\t{\n\n\t\t\tif (!t)\n\n\t\t\t\treturn {};\n\n\n\n\t\t\treturn { Invoke (f, *t) };\n\n\t\t}\n", "file_path": "src/util/sll/functor.h", "rank": 60, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Blogique\n\n{\n\nnamespace Utils\n\n{\n\n\tenum EntriesViewColumns\n\n\t{\n\n\t\tDate,\n\n\t\tSubject\n\n\t};\n\n\n\n\tenum EntryIdRole\n\n\t{\n\n\t\tDBIdRole = Qt::UserRole + 1\n\n\t};\n\n\n\n\tQList<QStandardItem*> CreateEntriesViewRow (const Entry& entry);\n\n}\n\n}\n", "file_path": "src/plugins/blogique/utils.h", "rank": 61, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Aggregator\n\n{\n\n\t/** Save column width of tree to aggregator`s section of settings */\n\n\tvoid SaveColumnWidth (const QTreeView *tree, const QString& keyName);\n\n\n\n\t/** Try to load column width of tree from aggregator`s section of settings */\n\n\tvoid LoadColumnWidth (QTreeView *tree, const QString& keyName);\n\n}\n", "file_path": "src/plugins/aggregator/uistatepersist.h", "rank": 62, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\t/** @brief Serializes the given \\em var to JSON representation.\n\n\t *\n\n\t * This function abstracts away differences between Qt4 and Qt5. It\n\n\t * uses QJson on Qt4 (don't forget to link to it!) and native JSON\n\n\t * functions on Qt5.\n\n\t *\n\n\t * @param[in] var The recursive variant to be serialized to JSON.\n\n\t * @param[in] compact Whether the output should be compacitified\n\n\t * (this parameter may have no effect).\n\n\t * @return The serialized representation of \\em var.\n\n\t */\n\n\tinline QByteArray SerializeJson (const QVariant& var, bool compact = true)\n\n\t{\n\n\t\treturn QJsonDocument::fromVariant (var)\n\n\t\t\t\t.toJson (compact ? QJsonDocument::Compact : QJsonDocument::Indented);\n\n\t}\n", "file_path": "src/util/sll/serializejson.h", "rank": 63, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\n\t/** @brief Describes the various common partition types.\n\n\t *\n\n\t * This enum is used for USB Mass Storage devices and similar ones\n\n\t * where the concept of a partition makes sense.\n\n\t *\n\n\t * @sa MassStorageRole::PartType\n\n\t */\n\n\tenum PartitionType\n\n\t{\n\n\t\t/** @brief Something other than a partition.\n\n\t\t */\n\n\t\tNonPartition = -1,\n\n\n\n\t\t/** @brief Empty partition without a type.\n\n\t\t */\n\n\t\tEmpty = 0x00,\n\n\n\n\t\t/** @brief FAT32 partition.\n\n\t\t */\n\n\t\tWin95FAT32 = 0x0b,\n\n\n\n\t\t/** @brief FAT32 partition with LBA.\n\n\t\t */\n\n\t\tWin95FAT32LBA = 0x0c\n\n\t};\n\n\n\n\t/** @brief Roles for both USB Mass Storage and generic USB devices.\n\n\t */\n\n\tenum CommonDevRole\n\n\t{\n\n\t\t/** @brief The type of the device.\n\n\t\t *\n\n\t\t * This role is expected to contain a member of the DeviceType enum.\n\n\t\t *\n\n\t\t * @sa DeviceType\n\n\t\t */\n\n\t\tDevType = Qt::UserRole + 1,\n\n\n\n\t\t/** @brief The unique device ID (QString).\n\n\t\t */\n\n\t\tDevID,\n\n\n\n\t\t/** @brief The persistent unique device ID (QString).\n\n\t\t */\n\n\t\tDevPersistentID,\n\n\n\n\t\tCommonDevRoleMax\n\n\t};\n\n\n\n\t/** @brief Roles specific to generic USB devices.\n\n\t *\n\n\t * The corresponding CommonDevRole::DevType is DeviceType::USBDevice.\n\n\t */\n\n\tenum USBDeviceRole\n\n\t{\n\n\t\t/** @brief The general USB ID of the role (QByteArray).\n\n\t\t */\n\n\t\tID = CommonDevRole::CommonDevRoleMax + 1,\n\n\n\n\t\t/** @brief The bus this device is attached to (int).\n\n\t\t */\n\n\t\tBusnum,\n\n\n\n\t\t/** @brief The device number on the given bus (int).\n\n\t\t */\n\n\t\tDevnum,\n\n\n\n\t\t/** @brief The ID of the vendor (QString).\n\n\t\t */\n\n\t\tVendorID,\n\n\n\n\t\t/** @brief The human-readable name of the vendor (QString).\n\n\t\t */\n\n\t\tVendor,\n\n\n\n\t\t/** @brief The ID of the model (QString).\n\n\t\t */\n\n\t\tModelID,\n\n\n\n\t\t/** @brief The human-readable name of the device model (QString).\n\n\t\t */\n\n\t\tModel,\n\n\n\n\t\t/** @brief The system file representing the device (QString).\n\n\t\t *\n\n\t\t * This role should contain the system file path representing the\n\n\t\t * device, if applicable.\n\n\t\t */\n\n\t\tSysFile,\n\n\n\n\t\tUSBDeviceRoleMax\n\n\t};\n\n\n\n\t/** @brief Roles specific to mass storage USB devices.\n\n\t *\n\n\t * The corresponding CommonDevRole::DevType is DeviceType::MassStorage.\n\n\t */\n\n\tenum MassStorageRole\n\n\t{\n\n\t\t/** @brief The device file representing the device (QString).\n\n\t\t *\n\n\t\t * For example, it could be \\em /dev/sdc1 on a Linux system.\n\n\t\t */\n\n\t\tDevFile = USBDeviceRole::USBDeviceRoleMax + 1,\n\n\n\n\t\t/** @brief The type of the partition.\n\n\t\t *\n\n\t\t * This role is expected to contain a member of the\n\n\t\t * PartitionType enum.\n\n\t\t *\n\n\t\t * @sa PartitionType\n\n\t\t */\n\n\t\tPartType,\n\n\n\n\t\t/** @brief Whether this item is removable (bool).\n\n\t\t */\n\n\t\tIsRemovable,\n\n\n\n\t\t/** @brief Whether this item is a partition (bool).\n\n\t\t */\n\n\t\tIsPartition,\n\n\n\n\t\t/** @brief Whether this item could be mounted (bool).\n\n\t\t */\n\n\t\tIsMountable,\n\n\n\n\t\t/** @brief Whether this item is currently mounted (bool).\n\n\t\t */\n\n\t\tIsMounted,\n\n\n\n\t\t/** @brief Whether this item contains media (bool).\n\n\t\t *\n\n\t\t * For example, a CD in a CD-ROM.\n\n\t\t */\n\n\t\tIsMediaAvailable,\n\n\n\n\t\t/** @brief Human-readable name of the device (QString).\n\n\t\t */\n\n\t\tVisibleName,\n\n\n\n\t\t/** @brief Available size in bytes (qint64).\n\n\t\t *\n\n\t\t * If the value is -1, the available size is not known. It is\n\n\t\t * very likely the available size wouldn't be known for unmounted\n\n\t\t * devices.\n\n\t\t */\n\n\t\tAvailableSize,\n\n\n\n\t\t/** @brief Total size in bytes (qint64).\n\n\t\t *\n\n\t\t * If the value is -1, the available size is not known. It is\n\n\t\t * very likely the total size wouldn't be known for unmounted\n\n\t\t * devices.\n\n\t\t */\n\n\t\tTotalSize,\n\n\n\n\t\t/** @brief The list of directories this item is mounted to\n\n\t\t * (QStringList).\n\n\t\t */\n\n\t\tMountPoints,\n\n\n\n\t\tMassStorageRoleMax\n\n\t};\n", "file_path": "src/interfaces/devices/deviceroles.h", "rank": 64, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\n\t/** @brief Describes various USB removable devices.\n\n\t *\n\n\t * The corresponding device model role is CommonDevRole::DevType.\n\n\t *\n\n\t * All device types are expected to return meaningful data for roles\n\n\t * in the CommonDevRole enum.\n\n\t *\n\n\t * @sa CommonDevRole::DevType\n\n\t * @sa CommonDevRole\n\n\t */\n\n\tenum DeviceType\n\n\t{\n\n\t\t/** @brief A general USB device.\n\n\t\t *\n\n\t\t * The device model rows for this USB device are expected to also\n\n\t\t * return data for roles in the USBDeviceRole enum.\n\n\t\t *\n\n\t\t * @sa USBDeviceRole\n\n\t\t */\n\n\t\tUSBDevice,\n\n\n\n\t\t/** @brief A mass storage USB device, like a flash drive.\n\n\t\t *\n\n\t\t * The device model rows for this USB device are expected to also\n\n\t\t * return data for roles in the MassStorageRole enum.\n\n\t\t *\n\n\t\t * @sa MassStorageRole\n\n\t\t */\n\n\t\tMassStorage\n\n\t};\n", "file_path": "src/interfaces/devices/devicetypes.h", "rank": 65, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace TabSessManager\n\n{\n\n\tstruct RecInfo\n\n\t{\n\n\t\tint Order_;\n\n\t\tQByteArray Data_;\n\n\t\tQList<QPair<QByteArray, QVariant>> Props_;\n\n\t\tQString Name_;\n\n\t\tQIcon Icon_;\n\n\t\tint WindowID_;\n\n\t};\n\n\n\n\tbool operator== (const RecInfo&, const RecInfo&);\n\n}\n", "file_path": "src/plugins/tabsessmanager/recinfo.h", "rank": 66, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Scroblibre\n\n{\n\n\tstruct SubmitInfo\n\n\t{\n\n\t\tMedia::AudioInfo Info_;\n\n\t\tQDateTime TS_;\n\n\n\n\t\tSubmitInfo () = default;\n\n\t\tSubmitInfo (const Media::AudioInfo&);\n\n\t\tSubmitInfo (const Media::AudioInfo&, const QDateTime&);\n\n\n\n\t\tSubmitInfo& operator= (const Media::AudioInfo&);\n\n\n\n\t\tvoid Clear ();\n\n\n\n\t\tbool IsValid () const;\n\n\t};\n\n}\n", "file_path": "src/plugins/scroblibre/submitinfo.h", "rank": 67, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\t/** @brief Binds an instance of an object to its member function.\n\n\t *\n\n\t * @param[in] fn The member function of class T.\n\n\t * @param[in] c The instance of class T to bind to the member\n\n\t * function \\em fn.\n\n\t * @return A functor callable with all arguments of \\em fn but the\n\n\t * object itself.\n\n\t * @tparam R The return type of the function.\n\n\t * @tparam T The type of the object.\n\n\t * @tparam Args The arguments to the function, besides the object\n\n\t * itself.\n\n\t */\n\n\ttemplate<typename R, typename B, typename C, typename... Args>\n\n\tauto BindMemFn (R (B::*fn) (Args...), C *c)\n\n\t{\n\n\t\tstatic_assert (std::is_base_of<B, C> {}, \"Base class where the member pointer belongs must be convertible to the binded object's class.\");\n\n\t\treturn [fn, c] (Args... args) { return (c->*fn) (args...); };\n\n\t}\n\n\n\n\ttemplate<typename R, typename B, typename C, typename... Args>\n\n\tauto BindMemFn (R (B::*fn) (Args...) const, const C *c)\n\n\t{\n\n\t\tstatic_assert (std::is_base_of<B, C> {}, \"Base class where the member pointer belongs must be convertible to the binded object's class.\");\n\n\t\treturn [fn, c] (Args... args) { return (c->*fn) (args...); };\n", "file_path": "src/util/sll/functional.h", "rank": 68, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Lastfmscrobble\n\n{\n\n\tenum ErrorCodes\n\n\t{\n\n\t\tAuthError = 4\n\n\t};\n\n}\n", "file_path": "src/plugins/lastfmscrobble/codes.h", "rank": 69, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\t[[noreturn]] inline void Unreachable ()\n\n\t{\n\n\t\t__builtin_unreachable ();\n\n\t}\n\n}\n", "file_path": "src/util/sll/unreachable.h", "rank": 70, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\nnamespace oral\n\n{\n\n\tstruct NoAutogen;\n\n\n\n\ttemplate<typename T, typename... Tags>\n\n\tstruct PKey\n\n\t{\n\n\t\tusing value_type = T;\n\n\n\n\t\tT Val_;\n\n\n\n\t\tPKey () = default;\n\n\n\n\t\tPKey (T val)\n\n\t\t: Val_ { val }\n\n\t\t{\n\n\t\t}\n\n\n\n\t\tPKey& operator= (T val)\n\n\t\t{\n\n\t\t\tVal_ = val;\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\toperator value_type () const\n\n\t\t{\n\n\t\t\treturn Val_;\n\n\t\t}\n\n\n\n\t\tconst value_type& operator* () const\n\n\t\t{\n\n\t\t\treturn Val_;\n\n\t\t}\n\n\t};\n\n\n\n\ttemplate<typename T>\n\n\tstruct Unique\n\n\t{\n\n\t\tusing value_type = T;\n\n\n\n\t\tT Val_;\n\n\n\n\t\tUnique () = default;\n\n\n\n\t\tUnique (T val)\n\n\t\t: Val_ { val }\n\n\t\t{\n\n\t\t}\n\n\n\n\t\tUnique& operator= (T val)\n\n\t\t{\n\n\t\t\tVal_ = val;\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\toperator value_type () const\n\n\t\t{\n\n\t\t\treturn Val_;\n\n\t\t}\n\n\n\n\t\tconst value_type& operator* () const\n\n\t\t{\n\n\t\t\treturn Val_;\n\n\t\t}\n\n\t};\n\n\n\n\tnamespace detail\n\n\t{\n\n\t\ttemplate<typename T>\n\n\t\tstruct IsPKey : std::false_type {};\n\n\n\n\t\ttemplate<typename U, typename... Tags>\n\n\t\tstruct IsPKey<PKey<U, Tags...>> : std::true_type {};\n\n\t}\n\n\n\n\ttemplate<typename Seq, int Idx>\n\n\tstruct References\n\n\t{\n\n\t\tusing member_type = typename std::decay<typename boost::fusion::result_of::at_c<Seq, Idx>::type>::type;\n\n\t\tstatic_assert (detail::IsPKey<member_type>::value, \"References<> element must refer to a PKey<> element\");\n\n\n\n\t\tusing value_type = typename member_type::value_type;\n\n\t\tvalue_type Val_;\n\n\n\n\t\tReferences () = default;\n\n\n\n\t\tReferences (value_type t)\n\n\t\t: Val_ { t }\n\n\t\t{\n\n\t\t}\n\n\n\n\t\ttemplate<typename T, typename... Tags>\n\n\t\tReferences (const PKey<T, Tags...>& key)\n\n\t\t: Val_ (static_cast<T> (key))\n\n\t\t{\n\n\t\t}\n\n\n\n\t\tReferences& operator= (const value_type& val)\n\n\t\t{\n\n\t\t\tVal_ = val;\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\ttemplate<typename T, typename... Tags>\n\n\t\tReferences& operator= (const PKey<T, Tags...>& key)\n\n\t\t{\n\n\t\t\tVal_ = key;\n\n\t\t\treturn *this;\n\n\t\t}\n\n\n\n\t\toperator value_type () const\n\n\t\t{\n\n\t\t\treturn Val_;\n\n\t\t}\n\n\n\n\t\tconst value_type& operator* () const\n\n\t\t{\n\n\t\t\treturn Val_;\n\n\t\t}\n\n\t};\n\n\n\n\ttemplate<int... Fields>\n\n\tstruct PrimaryKey;\n\n\n\n\ttemplate<int... Fields>\n\n\tstruct UniqueSubset;\n\n\n\n\ttemplate<typename... Args>\n\n\tusing Constraints = Typelist<Args...>;\n", "file_path": "src/util/db/oraltypes.h", "rank": 71, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace BitTorrent\n\n{\n\n\tstruct TorrentInfo\n\n\t{\n\n\t\tQString Destination_,\n\n\t\t\t\tState_;\n\n\t\tlibtorrent::torrent_status Status_;\n\n\t\tstd::unique_ptr<libtorrent::torrent_info> Info_;\n\n\t};\n\n}\n", "file_path": "src/plugins/bittorrent/torrentinfo.h", "rank": 72, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\tstruct QStringTrimmed\n\n\t{\n\n\t\tQString operator() (const QString& s) const\n\n\t\t{\n\n\t\t\treturn s.trimmed ();\n\n\t\t}\n\n\n\n\t\tQString operator() (QString&& s) const\n\n\t\t{\n\n\t\t\treturn s.trimmed ();\n\n\t\t}\n\n\n\n\t\tQString operator() (QString& s) const\n\n\t\t{\n\n\t\t\treturn std::move (s).trimmed ();\n\n\t\t}\n\n\t};\n\n\n\n\tstruct QStringToLower\n\n\t{\n\n\t\tQString operator() (const QString& s) const\n\n\t\t{\n\n\t\t\treturn s.toLower ();\n\n\t\t}\n\n\n\n\t\tQString operator() (QString&& s) const\n\n\t\t{\n\n\t\t\treturn s.toLower ();\n\n\t\t}\n\n\n\n\t\tQString operator() (QString& s) const\n\n\t\t{\n\n\t\t\treturn std::move (s).toLower ();\n\n\t\t}\n", "file_path": "src/util/sll/qstringwrappers.h", "rank": 73, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace SB2\n\n{\n\n}\n", "file_path": "src/plugins/sb2/sb2util.h", "rank": 74, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Launchy\n\n{\n\n\tenum ModelRoles\n\n\t{\n\n\t\tCategoryName = Qt::UserRole + 1,\n\n\t\tCategoryIcon,\n\n\t\tCategoryType,\n\n\n\n\t\tItemName,\n\n\t\tItemIcon,\n\n\t\tItemDescription,\n\n\t\tItemID,\n\n\t\tItemCommand,\n\n\n\n\t\tIsItemFavorite,\n\n\t\tIsItemRecent,\n\n\t\tItemRecentPos,\n\n\n\n\t\tItemNativeCategories,\n\n\t\tNativeCategories,\n\n\n\n\t\tExecutorFunctor\n\n\t};\n\n\n\n\ttypedef std::function<void ()> Executor_f;\n\n}\n", "file_path": "src/plugins/launchy/modelroles.h", "rank": 75, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace LMP\n\n{\n\n\tstruct PreviewCharacteristicInfo\n\n\t{\n\n\t\tQString Artist_;\n\n\t\tQString Title_;\n\n\t\tqint32 Length_;\n\n\n\n\t\tPreviewCharacteristicInfo (const Media::AudioInfo&);\n\n\t};\n\n\n\n\tbool operator== (const PreviewCharacteristicInfo&, const PreviewCharacteristicInfo&);\n\n\tuint qHash (const PreviewCharacteristicInfo&);\n\n}\n", "file_path": "src/plugins/lmp/previewcharacteristicinfo.h", "rank": 76, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\tenum WinStateFlag\n\n\t{\n\n\t\tNoState\t\t\t= 0,\n\n\t\tModal\t\t\t= 1 << 0,\n\n\t\tSticky\t\t\t= 1 << 1,\n\n\t\tMaximizedVert\t= 1 << 2,\n\n\t\tMaximizedHorz\t= 1 << 3,\n\n\t\tShaded\t\t\t= 1 << 4,\n\n\t\tSkipTaskbar\t\t= 1 << 5,\n\n\t\tSkipPager\t\t= 1 << 6,\n\n\t\tHidden\t\t\t= 1 << 7,\n\n\t\tFullscreen\t\t= 1 << 8,\n\n\t\tOnTop\t\t\t= 1 << 9,\n\n\t\tOnBottom\t\t= 1 << 10,\n\n\t\tAttention\t\t= 1 << 11\n\n\t};\n\n\n\n\tQ_DECLARE_FLAGS (WinStateFlags, WinStateFlag)\n\n\n\n\tenum AllowedActionFlag\n\n\t{\n\n\t\tNoAction\t\t= 0,\n\n\t\tMove\t\t\t= 1 << 0,\n\n\t\tResize\t\t\t= 1 << 1,\n\n\t\tMinimize\t\t= 1 << 2,\n\n\t\tShade\t\t\t= 1 << 3,\n\n\t\tStick\t\t\t= 1 << 4,\n\n\t\tMaximizeHorz\t= 1 << 5,\n\n\t\tMaximizeVert\t= 1 << 6,\n\n\t\tShowFullscreen\t= 1 << 7,\n\n\t\tChangeDesktop\t= 1 << 8,\n\n\t\tClose\t\t\t= 1 << 9,\n\n\t\tMoveToTop\t\t= 1 << 10,\n\n\t\tMoveToBottom\t= 1 << 11\n\n\t};\n\n\n\n\tQ_DECLARE_FLAGS (AllowedActionFlags, AllowedActionFlag)\n\n}\n", "file_path": "src/util/x11/winflags.h", "rank": 77, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Aggregator\n\n{\n\n\ttypedef quint64 IDType_t;\n\n\n\n\tstatic const IDType_t IDNotFound = static_cast<IDType_t> (-1);\n\n\n\n\ttypedef QList<IDType_t> ids_t;\n\n\n\n\tenum PoolType\n\n\t{\n\n\t\tPTFeed,\n\n\t\tPTChannel,\n\n\t\tPTItem,\n\n\t\tPTFeedSettings,\n\n\t\tPTEnclosure,\n\n\t\tPTMRSSEntry,\n\n\t\tPTMRSSThumbnail,\n\n\t\tPTMRSSCredit,\n\n\t\tPTMRSSComment,\n\n\t\tPTMRSSPeerLink,\n\n\t\tPTMRSSScene,\n\n\t\tPTMAX\n\n\t};\n\n\n\n\tenum ChannelRoles\n\n\t{\n\n\t\tUnreadCount = LeechCraft::RoleMAX + 1,\n\n\t\tChannelID\n\n\t};\n\n}\n", "file_path": "src/plugins/aggregator/common.h", "rank": 78, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\nnamespace IntSeq\n\n{\n\n\ttemplate<typename T, T... Fst, T... Snd>\n\n\tstd::integer_sequence<T, Fst..., Snd...>\n\n\tConcatImpl (std::integer_sequence<T, Fst...>, std::integer_sequence<T, Snd...>);\n\n\n\n\ttemplate<typename... Seqs>\n\n\tstruct ConcatS;\n\n\n\n\ttemplate<typename... Seqs>\n\n\tusing Concat = typename ConcatS<Seqs...>::Type_t;\n\n\n\n\ttemplate<typename Seq>\n\n\tstruct ConcatS<Seq>\n\n\t{\n\n\t\tusing Type_t = Seq;\n\n\t};\n\n\n\n\ttemplate<typename Seq1, typename Seq2, typename... Rest>\n\n\tstruct ConcatS<Seq1, Seq2, Rest...>\n\n\t{\n\n\t\tusing Type_t = Concat<decltype (ConcatImpl (Seq1 {}, Seq2 {})), Rest...>;\n\n\t};\n\n\n\n\ttemplate<typename T, T E, size_t C>\n\n\tstruct RepeatS\n\n\t{\n\n\t\ttemplate<T... Is>\n\n\t\tstatic auto RepeatImpl (std::integer_sequence<T, Is...>)\n\n\t\t{\n\n\t\t\treturn std::integer_sequence<T, (static_cast<void> (Is), E)...> {};\n\n\t\t}\n\n\n\n\t\tusing Type_t = decltype (RepeatImpl (std::make_integer_sequence<T, C> {}));\n\n\t};\n\n\n\n\ttemplate<typename T, T E, size_t C>\n\n\tusing Repeat = typename RepeatS<T, E, C>::Type_t;\n\n}\n", "file_path": "src/util/sll/intseq.h", "rank": 79, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Fenet\n\n{\n\n\tstruct Param\n\n\t{\n\n\t\tQString Name_;\n\n\t\tQString Desc_;\n\n\n\n\t\tdouble Default_;\n\n\n\n\t\tdouble Min_;\n\n\t\tdouble Max_;\n\n\t};\n\n\n\n\tstruct Flag\n\n\t{\n\n\t\tQString Name_;\n\n\t\tQString Desc_;\n\n\t};\n\n\n\n\tstruct CompInfo\n\n\t{\n\n\t\tQList<Param> Params_;\n\n\t\tQList<Flag> Flags_;\n\n\n\n\t\tQString Name_;\n\n\t\tQString Comment_;\n\n\n\n\t\tQStringList ExecNames_;\n\n\t};\n\n\n\n\ttypedef QList<CompInfo> CompInfos_t;\n\n}\n", "file_path": "src/plugins/fenet/compinfo.h", "rank": 80, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace GmailNotifier\n\n{\n\n\tstruct ConvInfo\n\n\t{\n\n\t\tQString Title_;\n\n\t\tQString Summary_;\n\n\t\tQUrl Link_;\n\n\n\n\t\tQDateTime Issued_;\n\n\t\tQDateTime Modified_;\n\n\n\n\t\tQString AuthorName_;\n\n\t\tQString AuthorEmail_;\n\n\t};\n\n\n\n\tbool operator== (const ConvInfo&, const ConvInfo&);\n\n\n\n\ttypedef QList<ConvInfo> ConvInfos_t;\n\n}\n", "file_path": "src/plugins/gmailnotifier/convinfo.h", "rank": 81, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\nnamespace SysInfo\n\n{\n\n\t/** @brief Returns a string of OS name and version joined together.\n\n\t *\n\n\t * @return The name and version of OS running LeechCraft.\n\n\t */\n\n\tUTIL_SYS_API QString GetOSName ();\n\n\n\n\t/** @brief Describes the OS running LeechCraft.\n\n\t */\n\n\tstruct OSInfo\n\n\t{\n\n\t\t/** @brief The name of the OS, including the distribution.\n\n\t\t *\n\n\t\t * Typical values are:\n\n\t\t * - Gentoo/Linux\n\n\t\t * - openSUSE 13.1 (Bottle) (x86_64)\n\n\t\t * - Mac OS X\n\n\t\t * - Windows\n\n\t\t *\n\n\t\t * On non-Linux systems this field typically matches the Flavour_\n\n\t\t * field. On Linux it also includes the distribution name and\n\n\t\t * possibly version.\n\n\t\t *\n\n\t\t * @sa Flavour_\n\n\t\t */\n\n\t\tQString Name_;\n\n\n\n\t\t/** @brief The full version of the OS.\n\n\t\t *\n\n\t\t * This possibly includes the architecture, the OS release and\n\n\t\t * OS-dependent version components like kernel version on Linux.\n\n\t\t */\n\n\t\tQString Version_;\n\n\n\n\t\t/** @brief The OS flavour, or name of the OS without any\n\n\t\t * distribution.\n\n\t\t *\n\n\t\t * Typical values are:\n\n\t\t * - Linux\n\n\t\t * - Mac OS X\n\n\t\t * - Windows\n\n\t\t * - FreeBSD\n\n\t\t *\n\n\t\t * On non-Linux systems this typically matches the Name_ field.\n\n\t\t *\n\n\t\t * @sa Name_\n\n\t\t */\n\n\t\tQString Flavour_;\n\n\n\n\t\t/** @brief Describes the CPU architecture of the OS.\n\n\t\t *\n\n\t\t * This describes the architecture of the OS, not the machine\n\n\t\t * itself. Thus, a 32-bit Linux running on a 64-bit CPU will\n\n\t\t * still be reported as \\em x86 instead of \\em x86_64.\n\n\t\t */\n\n\t\tQString Arch_;\n\n\n\n\t\t/** @brief Constructs the OSInfo object.\n\n\t\t *\n\n\t\t * Sets both the Name_ and the Flavour_ of the OS to \\em name.\n\n\t\t *\n\n\t\t * \\param[in] arch Initializer for the Arch_ field.\n\n\t\t * \\param[in] name Initializer for the Name_ and Flavour_ fields.\n\n\t\t * \\param[in] version Initializer for the Version_ field.\n\n\t\t */\n\n\t\tUTIL_SYS_API OSInfo (const QString& arch, const QString& name, const QString& version);\n\n\n\n\t\t/** @brief Constructs the OSInfo object.\n\n\t\t *\n\n\t\t * \\param[in] arch Initializer for the Arch_ field.\n\n\t\t * \\param[in] flavour Initializer for the Flavour_ field.\n\n\t\t * \\param[in] name Initializer for the Name_ field.\n\n\t\t * \\param[in] version Initializer for the Version_ field.\n\n\t\t */\n\n\t\tUTIL_SYS_API OSInfo (const QString& arch,\n\n\t\t\t\tconst QString& flavour,\n\n\t\t\t\tconst QString& name,\n\n\t\t\t\tconst QString& version);\n\n\t};\n\n\n\n\t/** @brief Returns more precise information about OS name and version.\n\n\t *\n\n\t * @return A structure OSInfo consisting of OS name, version and other\n\n\t * fields.\n\n\t */\n\n\tUTIL_SYS_API OSInfo GetOSInfo ();\n\n}\n\n}\n", "file_path": "src/util/sys/sysinfo.h", "rank": 82, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\t/** @brief Parses JSON content in the given bytearray.\n\n\t *\n\n\t * This functions uses QJson on Qt4 (don't forget to link to it!) and\n\n\t * Qt's native JSON parsers on Qt5.\n\n\t *\n\n\t * @param[in] bytes The byte array to parse JSON from.\n\n\t * @param[in] context The context string to be used in logging\n\n\t * messages.\n\n\t * @return The recursive QVariant with JSON contents.\n\n\t */\n\n\tinline QVariant ParseJson (const QByteArray& bytes, const char *context)\n\n\t{\n\n\t\tQJsonParseError error;\n\n\t\tconst auto& result = QJsonDocument::fromJson (bytes, &error).toVariant ();\n\n\t\tif (error.error != QJsonParseError::NoError)\n\n\t\t{\n\n\t\t\tqWarning () << context\n\n\t\t\t\t\t<< \"cannot parse\"\n\n\t\t\t\t\t<< error.errorString ()\n\n\t\t\t\t\t<< bytes;\n\n\t\t\treturn {};\n\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\n\n\t/** @brief Utility function parsing JSON from the \\em device.\n\n\t *\n\n\t * This function reads all available data from the \\em device and\n\n\t * passes it to the other ParseJson() overload.\n\n\t *\n\n\t * @param[in] device The device from which JSON-encoded data should\n\n\t * be read.\n\n\t * @param[in] context The context string to be used in logging\n\n\t * messages.\n\n\t * @return The recursive QVariant with JSON contents.\n\n\t */\n\n\tinline QVariant ParseJson (QIODevice *device, const char *context)\n\n\t{\n\n\t\treturn ParseJson (device->readAll (), context);\n\n\t}\n\n}\n", "file_path": "src/util/sll/parsejson.h", "rank": 83, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Aggregator\n\n{\n\n\tstruct OPMLItem\n\n\t{\n\n\t\tQString URL_;\n\n\t\tQString HTMLUrl_;\n\n\t\tQString Title_;\n\n\t\tQString Description_;\n\n\t\tQStringList Categories_;\n\n\t\tint MaxArticleAge_;\n\n\t\tint FetchInterval_;\n\n\t\tint MaxArticleNumber_;\n\n\t\tbool CustomFetchInterval_;\n\n\t\t//\t<outline htmlUrl=\"\" title=\"Оформление KDE\"\n\n\t\t//\tuseCustomFetchInterval=\"false\" maxArticleAge=\"0\"\n\n\t\t//\tfetchInterval=\"0\" maxArticleNumber=\"0\"\n\n\t\t//\tarchiveMode=\"globalDefault\" version=\"RSS\" type=\"rss\"\n\n\t\t//\txmlUrl=\"http://www.kde.org/kde-look-content.rdf\"\n\n\t\t//\tid=\"2097705275\" text=\"Оформление KDE\" description=\"\" />\n\n\t};\n\n}\n", "file_path": "src/plugins/aggregator/opmlitem.h", "rank": 84, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\nnamespace detail\n\n{\n\n\tstruct ImplementationType;\n\n}\n\n}\n", "file_path": "src/util/sll/typeclassutil.h", "rank": 85, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<typename T>\n\n\tusing Lazy_t = std::function<T ()>;\n\n\n\n\ttemplate<typename T>\n\n\tLazy_t<T> MakeLazy (const T& t)\n\n\t{\n\n\t\treturn [t] { return t; };\n\n\t}\n\n\n\n\ttemplate<typename R, typename F>\n\n\tLazy_t<R> MakeLazyF (const F& l)\n\n\t{\n\n\t\treturn l;\n\n\t}\n\n\n\n\ttemplate<typename T>\n\n\tstruct InstanceMonadPlus<Lazy_t<T>, std::enable_if_t<IsMonadPlus<T> ()>>\n\n\t{\n\n\t\tstatic Lazy_t<T> Mzero ()\n\n\t\t{\n\n\t\t\treturn [] { return Util::Mzero<T> (); };\n\n\t\t}\n\n\n\n\t\tstatic Lazy_t<T> Mplus (const Lazy_t<T>& t1, const Lazy_t<T>& t2)\n\n\t\t{\n\n\t\t\treturn [=]\n\n\t\t\t{\n\n\t\t\t\tconst auto rt1 = t1 ();\n\n\t\t\t\treturn rt1 != Util::Mzero<T> () ? rt1 : t2 ();\n\n\t\t\t};\n\n\t\t}\n\n\t};\n", "file_path": "src/util/sll/lazy.h", "rank": 86, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Eleeminator\n\n{\n\n\tstruct ProcessInfo\n\n\t{\n\n\t\tint Pid_;\n\n\t\tQString Command_;\n\n\t\tQString CommandLine_;\n\n\t\tQList<ProcessInfo> Children_;\n\n\t};\n\n}\n", "file_path": "src/plugins/eleeminator/processinfo.h", "rank": 87, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Intermutko\n\n{\n\n\tstruct LocaleEntry\n\n\t{\n\n\t\tQLocale::Language Language_;\n\n\t\tQLocale::Country Country_;\n\n\t\tdouble Q_;\n\n\t};\n\n\n\n\tbool operator== (const LocaleEntry&, const LocaleEntry&);\n\n\tbool operator!= (const LocaleEntry&, const LocaleEntry&);\n\n\n\n\tQDataStream& operator<< (QDataStream&, const LocaleEntry&);\n\n\tQDataStream& operator>> (QDataStream&, LocaleEntry&);\n\n}\n", "file_path": "src/plugins/intermutko/localeentry.h", "rank": 88, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Liznoo\n\n{\n\n\tstruct BatteryInfo;\n\n\n\n\tstruct BatteryHistory\n\n\t{\n\n\t\tchar Percentage_;\n\n\n\n\t\tfloat Voltage_;\n\n\t\tfloat Energy_;\n\n\t\tfloat EnergyRate_;\n\n\t\tfloat Temperature_;\n\n\n\n\t\texplicit BatteryHistory (const BatteryInfo&);\n\n\t};\n\n\n\n\tusing BatteryHistoryList = boost::circular_buffer<BatteryHistory>;\n\n}\n", "file_path": "src/plugins/liznoo/batteryhistory.h", "rank": 89, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace BitTorrent\n\n{\n\n\tstruct PeerInfo\n\n\t{\n\n\t\tQString IP_;\n\n\t\tQString Client_;\n\n\t\tint RemoteHas_;\n\n\t\tQString CountryCode_;\n\n\t\tstd::shared_ptr<libtorrent::peer_info> PI_;\n\n\t};\n\n}\n", "file_path": "src/plugins/bittorrent/peerinfo.h", "rank": 90, "score": 116968.39850295629 }, { "content": "namespace LeechCraft\n\n{\n\nnamespace Util\n\n{\n\n\ttemplate<template<typename> class Pred>\n\n\tstruct Not\n\n\t{\n\n\t\ttemplate<typename V>\n\n\t\tstruct Negate;\n\n\n\n\t\ttemplate<bool V>\n\n\t\tstruct Negate<std::integral_constant<bool, V>>\n\n\t\t{\n\n\t\t\tusing Result_t = std::integral_constant<bool, !V>;\n\n\t\t};\n\n\n\n\t\ttemplate<typename T>\n\n\t\tstruct Result_t : Negate<typename Pred<T>::type>::Result_t {};\n\n\t};\n", "file_path": "src/util/sll/typelevel.h", "rank": 91, "score": 116968.39850295629 }, { "content": "\tclass NamedModel : public Util::RoleNamesMixin<T>\n\n\t{\n\n\tpublic:\n\n\t\tNamedModel (QObject *parent)\n\n\t\t: Util::RoleNamesMixin<T> (parent)\n\n\t\t{\n\n\t\t\tQHash<int, QByteArray> result;\n\n\t\t\tresult [CollectionRole::Type] = \"itemType\";\n\n\t\t\tresult [CollectionRole::ID] = \"imageId\";\n\n\t\t\tresult [CollectionRole::Name] = \"name\";\n\n\t\t\tresult [CollectionRole::SmallThumb] = \"smallThumb\";\n\n\t\t\tresult [CollectionRole::SmallThumbSize] = \"smallThumbSize\";\n\n\t\t\tresult [CollectionRole::MediumThumb] = \"mediumThumb\";\n\n\t\t\tresult [CollectionRole::MediumThumbSize] = \"mediumThumbSize\";\n\n\t\t\tresult [CollectionRole::Original] = \"original\";\n\n\t\t\tresult [CollectionRole::OriginalSize] = \"originalSize\";\n\n\t\t\tUtil::RoleNamesMixin<T>::setRoleNames (result);\n\n\t\t}\n\n\t};\n\n\n\n\tenum ItemType\n\n\t{\n\n\t\tCollection,\n\n\t\tAllPhotos,\n\n\t\tImage\n\n\t};\n\n}\n\n}\n", "file_path": "src/plugins/blasq/interfaces/blasq/collection.h", "rank": 92, "score": 116811.9513132328 }, { "content": "\t\tQString Version_;\n", "file_path": "src/util/sys/sysinfo.h", "rank": 93, "score": 116753.61457794931 }, { "content": "\t\tQString Name_;\n", "file_path": "src/util/sys/sysinfo.h", "rank": 94, "score": 116753.01029405628 }, { "content": "\t\tQList<Flag> Flags_;\n", "file_path": "src/plugins/fenet/compinfo.h", "rank": 95, "score": 116739.35900074152 }, { "content": "\t\tdouble Default_;\n", "file_path": "src/plugins/fenet/compinfo.h", "rank": 96, "score": 116738.26064055634 }, { "content": "\t\tquint64 Size_;\n", "file_path": "src/plugins/bittorrent/fileinfo.h", "rank": 97, "score": 116737.71333113663 }, { "content": "\t\tdouble Value_;\n", "file_path": "src/plugins/hotsensors/structures.h", "rank": 98, "score": 116736.80194747495 } ]
C++
pxr/imaging/plugin/hdRpr/rifcpp/rifContext.cpp
MagisterDemens/RadeonProRenderUSD
51d3855b7c1a0cd8dafb5986d5ac4c6eb9df38e2
#include "rifContext.h" #include "rifError.h" #include "RadeonProRender_CL.h" #include "RadeonProRender_GL.h" #include "RadeonImageFilters_cl.h" #include "RadeonImageFilters_gl.h" #include "RadeonImageFilters_metal.h" #include "rprcpp/rprContext.h" #include "rprcpp/rprFramebufferGL.h" #include <vector> #include <cassert> #include <stdexcept> PXR_NAMESPACE_OPEN_SCOPE namespace rif { namespace { class ContextOpenCL final : public Context { public: explicit ContextOpenCL(rpr_context rprContext, std::string const& modelPath); ~ContextOpenCL() override = default; std::unique_ptr<Image> CreateImage(rpr::FrameBuffer* rprFrameBuffer) override; private: const rif_backend_api_type rifBackendApiType = RIF_BACKEND_API_OPENCL; }; class ContextMetal final : public Context { public: explicit ContextMetal(rpr_context rprContext, std::string const& modelPath); ~ContextMetal() override = default; std::unique_ptr<Image> CreateImage(rpr::FrameBuffer* rprFrameBuffer) override; private: const rif_backend_api_type rifBackendApiType = RIF_BACKEND_API_METAL; }; class ContextCPU final : public Context { public: explicit ContextCPU(rpr_context rprContext, std::string const& modelPath); ~ContextCPU() override = default; std::unique_ptr<Image> CreateImage(rpr::FrameBuffer* rprFrameBuffer) override; void UpdateInputImage(rpr::FrameBuffer* rprFrameBuffer, rif_image image) override; private: const rif_backend_api_type rifBackendApiType = RIF_BACKEND_API_OPENCL; }; std::vector<rpr_char> GetRprCachePath(rpr_context rprContext) { size_t length; rpr_status status = rprContextGetInfo(rprContext, RPR_CONTEXT_CACHE_PATH, sizeof(size_t), nullptr, &length); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to get cache path", rprContext)); } std::vector<rpr_char> path(length); status = rprContextGetInfo(rprContext, RPR_CONTEXT_CACHE_PATH, path.size(), &path[0], nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to get cache path", rprContext)); } return path; } rif_image_desc GetRifImageDesc(rpr::FrameBuffer* rprFrameBuffer) { auto rprDesc = rprFrameBuffer->GetDesc(); rif_image_desc imageDesc = {}; imageDesc.image_width = rprDesc.fb_width; imageDesc.image_height = rprDesc.fb_height; imageDesc.image_depth = 1; imageDesc.image_row_pitch = 0; imageDesc.image_slice_pitch = 0; imageDesc.num_components = 4; imageDesc.type = RIF_COMPONENT_TYPE_FLOAT32; return imageDesc; } ContextOpenCL::ContextOpenCL(rpr_context rprContext, std::string const& modelPath) : Context(modelPath) { int deviceCount = 0; RIF_ERROR_CHECK_THROW(rifGetDeviceCount(rifBackendApiType, &deviceCount), "Failed to query device count"); assert(deviceCount != 0); if (0 == deviceCount) throw rif::Error("No compatible devices."); rpr_cl_context clContext; rpr_status status = rprContextGetInfo(rprContext, RPR_CL_CONTEXT, sizeof(rpr_cl_context), &clContext, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query CL context", rprContext)); } rpr_cl_device clDevice; status = rprContextGetInfo(rprContext, RPR_CL_DEVICE, sizeof(rpr_cl_device), &clDevice, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query CL device", rprContext)); } rpr_cl_command_queue clCommandQueue; status = rprContextGetInfo(rprContext, RPR_CL_COMMAND_QUEUE, sizeof(rpr_cl_command_queue), &clCommandQueue, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query CL command queue", rprContext)); } std::vector<rpr_char> path = GetRprCachePath(rprContext); #ifndef __APPLE__ RIF_ERROR_CHECK_THROW(rifCreateContextFromOpenClContext(RIF_API_VERSION, clContext, clDevice, clCommandQueue, path.data(), &m_context), "Failed to create RIF context") #endif } std::unique_ptr<Image> ContextOpenCL::CreateImage(rpr::FrameBuffer* rprFrameBuffer) { if (!rprFrameBuffer) { return nullptr; } rif_image rifImage = nullptr; #ifndef __APPLE__ if (auto rprFrameBufferGL = dynamic_cast<rpr::FrameBufferGL*>(rprFrameBuffer)) { RIF_ERROR_CHECK_THROW(rifContextCreateImageFromOpenGlTexture(m_context, GL_TEXTURE_2D, 0, rprFrameBufferGL->GetGL(), &rifImage), "Failed to create RIF image from OpenGL texture") } else { rpr_cl_mem clMem = rprFrameBuffer->GetCLMem(); assert(clMem); if (!clMem) { RIF_THROW_ERROR_MSG("Failed to get rpr framebuffer cl_mem"); } auto rifImageDesc = GetRifImageDesc(rprFrameBuffer); RIF_ERROR_CHECK_THROW(rifContextCreateImageFromOpenClMemory(m_context, &rifImageDesc, clMem, false, &rifImage), "Failed to create RIF image from OpenCL memory"); } #endif return std::unique_ptr<Image>(new Image(rifImage)); } ContextCPU::ContextCPU(rpr_context rprContext, std::string const& modelPath) : Context(modelPath) { int deviceCount = 0; RIF_ERROR_CHECK_THROW(rifGetDeviceCount(rifBackendApiType, &deviceCount), "Failed to query device count"); assert(deviceCount != 0); if (0 == deviceCount) RIF_THROW_ERROR_MSG("No compatible devices"); std::vector<rpr_char> path = GetRprCachePath(rprContext); RIF_ERROR_CHECK_THROW(rifCreateContext(RIF_API_VERSION, rifBackendApiType, 0, path.data(), &m_context), "Failed to create RIF context") } std::unique_ptr<Image> ContextCPU::CreateImage(rpr::FrameBuffer* rprFrameBuffer) { if (!rprFrameBuffer) { return nullptr; } return Context::CreateImage(GetRifImageDesc(rprFrameBuffer)); } void ContextCPU::UpdateInputImage(rpr::FrameBuffer* rprFrameBuffer, rif_image image) { if (!rprFrameBuffer || !image) { return; } size_t sizeInBytes = 0; size_t retSize = 0; RIF_ERROR_CHECK_THROW(rifImageGetInfo(image, RIF_IMAGE_DATA_SIZEBYTE, sizeof(size_t), (void*)& sizeInBytes, &retSize), "Failed to get RIF image info"); size_t fbSize; rpr_status status = rprFrameBufferGetInfo(rprFrameBuffer->GetHandle(), RPR_FRAMEBUFFER_DATA, 0, NULL, &fbSize); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query RPR_FRAMEBUFFER_DATA")); } assert(sizeInBytes == fbSize); if (sizeInBytes != fbSize) RIF_THROW_ERROR_MSG("Failed to match RIF image and frame buffer sizes"); void* imageData = nullptr; RIF_ERROR_CHECK_THROW(rifImageMap(image, RIF_IMAGE_MAP_WRITE, &imageData), "Failed to map RIF image"); auto rprStatus = rprFrameBufferGetInfo(rprFrameBuffer->GetHandle(), RPR_FRAMEBUFFER_DATA, fbSize, imageData, NULL); assert(RPR_SUCCESS == rprStatus); RIF_ERROR_CHECK_THROW(rifImageUnmap(image, imageData), "Failed to unmap RIF image"); if (RPR_SUCCESS != rprStatus) RIF_THROW_ERROR_MSG("Failed to get data from RPR frame buffer"); } rpr_int GpuDeviceIdUsed(rpr_creation_flags contextFlags) { #define GPU(x) RPR_CREATION_FLAGS_ENABLE_GPU##x std::vector<rpr_int> gpu_ids; gpu_ids.reserve(16); gpu_ids.push_back(GPU(0)); gpu_ids.push_back(GPU(1)); gpu_ids.push_back(GPU(2)); gpu_ids.push_back(GPU(3)); gpu_ids.push_back(GPU(4)); gpu_ids.push_back(GPU(5)); gpu_ids.push_back(GPU(6)); gpu_ids.push_back(GPU(7)); gpu_ids.push_back(GPU(8)); gpu_ids.push_back(GPU(9)); gpu_ids.push_back(GPU(10)); gpu_ids.push_back(GPU(11)); gpu_ids.push_back(GPU(12)); gpu_ids.push_back(GPU(13)); gpu_ids.push_back(GPU(14)); gpu_ids.push_back(GPU(15)); #undef GPU for (rpr_int i = 0; i < gpu_ids.size(); i++ ) { if ((contextFlags & gpu_ids[i]) != 0) return i; } return -1; } ContextMetal::ContextMetal(rpr_context rprContext, std::string const& modelPath) : Context(modelPath) { int deviceCount = 0; RIF_ERROR_CHECK_THROW(rifGetDeviceCount(rifBackendApiType, &deviceCount), "Failed to query device count"); assert(deviceCount != 0); if (0 == deviceCount) RIF_THROW_ERROR_MSG("No compatible devices"); rpr_creation_flags contextFlags = 0; rpr_status status = rprContextGetInfo(rprContext, RPR_CONTEXT_CREATION_FLAGS, sizeof(rpr_creation_flags), &contextFlags, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query RPR context creation flags")); } std::vector<rpr_char> path = GetRprCachePath(rprContext); RIF_ERROR_CHECK_THROW(rifCreateContext(RIF_API_VERSION, rifBackendApiType, GpuDeviceIdUsed(contextFlags), path.data(), &m_context), "Failed to create RIF context"); } std::unique_ptr<Image> ContextMetal::CreateImage(rpr::FrameBuffer* rprFrameBuffer) { if (!rprFrameBuffer) { return nullptr; } rif_image rifImage = nullptr; rpr_cl_mem clMem = rprFrameBuffer->GetCLMem(); assert(clMem); if (!clMem) RIF_THROW_ERROR_MSG("Failed to get frame buffer cl_mem"); rpr_image_format framebufferFormat; rpr_status status = rprFrameBufferGetInfo(rprFrameBuffer->GetHandle(), RPR_FRAMEBUFFER_FORMAT, sizeof(framebufferFormat), &framebufferFormat, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to get framebuffer format")); } int bytesPerComponent = 1; if (framebufferFormat.type == RPR_COMPONENT_TYPE_FLOAT32) { bytesPerComponent = 4; } else if (framebufferFormat.type == RPR_COMPONENT_TYPE_FLOAT16) { bytesPerComponent = 2; } auto desc = GetRifImageDesc(rprFrameBuffer); rif_longlong size = desc.image_width * desc.image_height * framebufferFormat.num_components * bytesPerComponent; RIF_ERROR_CHECK_THROW(rifContextCreateImageFromMetalMemory(m_context, &desc, clMem, size, &rifImage), "Failed to create RIF image from metal memory"); return std::unique_ptr<Image>(new Image(rifImage)); } bool HasGpuContext(rpr_creation_flags contextFlags) { #define GPU(x) RPR_CREATION_FLAGS_ENABLE_GPU##x rpr_creation_flags gpuMask = GPU(0) | GPU(1) | GPU(2) | GPU(3) | GPU(4) | GPU(5) | GPU(6) | GPU(7) | GPU(8) | GPU(9) | GPU(10) | GPU(11) | GPU(12) | GPU(13) | GPU(14) | GPU(15); #undef GPU return (contextFlags & gpuMask) != 0; } } std::unique_ptr<Context> Context::Create(rpr::Context* rprContext, std::string const& modelPath) { if (!rprContext) { return nullptr; } rpr_creation_flags contextFlags = 0; if (RPR_ERROR_CHECK(rprContextGetInfo(rprContext->GetHandle(), RPR_CONTEXT_CREATION_FLAGS, sizeof(rpr_creation_flags), &contextFlags, nullptr), "Failed to query RPR context creation flags")) { return nullptr; } try { std::unique_ptr<Context> rifContext; if (contextFlags & RPR_CREATION_FLAGS_ENABLE_METAL) { rifContext.reset(new ContextMetal(rprContext->GetHandle(), modelPath)); } else if (HasGpuContext(contextFlags) && rprContext->GetActivePluginType() != rpr::PluginType::HYBRID) { rifContext.reset(new ContextOpenCL(rprContext->GetHandle(), modelPath)); } else { rifContext.reset(new ContextCPU(rprContext->GetHandle(), modelPath)); } RIF_ERROR_CHECK_THROW(rifContextCreateCommandQueue(rifContext->m_context, &rifContext->m_commandQueue), "Failed to create RIF command queue"); return rifContext; } catch (rif::Error const& e) { TF_RUNTIME_ERROR("Failed to create RIF context. RIF error: %s", e.what()); } return nullptr; } Context::Context(std::string const& modelPath) : m_modelPath(modelPath) { } Context::~Context() { if (m_commandQueue) { rifObjectDelete(m_commandQueue); } if (m_context) { rifObjectDelete(m_context); } } std::unique_ptr<Image> Context::CreateImage(rif_image_desc const& desc) { rif_image rifImage = nullptr; RIF_ERROR_CHECK_THROW(rifContextCreateImage(m_context, &desc, nullptr, &rifImage), "Failed to create RIF image"); return std::unique_ptr<Image>(new Image(rifImage)); } void Context::UpdateInputImage(rpr::FrameBuffer* rprFrameBuffer, rif_image image) { } void Context::AttachFilter(rif_image_filter filter, rif_image inputImage, rif_image outputImage) { RIF_ERROR_CHECK_THROW(rifCommandQueueAttachImageFilter(m_commandQueue, filter, inputImage, outputImage), "Failed to attach image filter to queue"); ++m_numAttachedFilters; } void Context::DetachFilter(rif_image_filter filter) { auto rifStatus = rifCommandQueueDetachImageFilter(m_commandQueue, filter); if (rifStatus == RIF_ERROR_INVALID_PARAMETER) { return; } RIF_ERROR_CHECK_THROW(rifStatus, "Failed to detach image filter from queue"); --m_numAttachedFilters; } rif_image_filter Context::CreateImageFilter(rif_image_filter_type type) { rif_image_filter outFilter = nullptr; RIF_ERROR_CHECK_THROW(rifContextCreateImageFilter(m_context, type, &outFilter), "Failed to create image filter"); return outFilter; } void Context::ExecuteCommandQueue() { if (!m_numAttachedFilters) { return; } RIF_ERROR_CHECK_THROW(rifContextExecuteCommandQueue(m_context, m_commandQueue, nullptr, nullptr, nullptr), "Failed to execute command queue"); RIF_ERROR_CHECK_THROW(rifSyncronizeQueue(m_commandQueue), "Failed to synchronize command queue"); } } PXR_NAMESPACE_CLOSE_SCOPE
#include "rifContext.h" #include "rifError.h" #include "RadeonProRender_CL.h" #include "RadeonProRender_GL.h" #include "RadeonImageFilters_cl.h" #include "RadeonImageFilters_gl.h" #include "RadeonImageFilters_metal.h" #include "rprcpp/rprContext.h" #include "rprcpp/rprFramebufferGL.h" #include <vector> #include <cassert> #include <stdexcept> PXR_NAMESPACE_OPEN_SCOPE namespace rif { namespace { class ContextOpenCL final : public Context { public: explicit ContextOpenCL(rpr_context rprContext, std::string const& modelPath); ~ContextOpenCL() override = default; std::unique_ptr<Image> CreateImage(rpr::FrameBuffer* rprFrameBuffer) override; private: const rif_backend_api_type rifBackendApiType = RIF_BACKEND_API_OPENCL; }; class ContextMetal final : public Context { public: explicit ContextMetal(rpr_context rprContext, std::string const& modelPath); ~ContextMetal() override = default; std::unique_ptr<Image> CreateImage(rpr::FrameBuffer* rprFrameBuffer) override; private: const rif_backend_api_type rifBackendApiType = RIF_BACKEND_API_METAL; }; class ContextCPU final : public Context { public: explicit ContextCPU(rpr_context rprContext, std::string const& modelPath); ~ContextCPU() override = default; std::unique_ptr<Image> CreateImage(rpr::FrameBuffer* rprFrameBuffer) override; void UpdateInputImage(rpr::FrameBuffer* rprFrameBuffer, rif_image image) override; private: const rif_backend_api_type rifBackendApiType = RIF_BACKEND_API_OPENCL; }; std::vector<rpr_char> GetRprCachePath(rpr_context rprContext) { size_t length; rpr_status status = rprContextGetInfo(rprContext, RPR_CONTEXT_CACHE_PATH, sizeof(size_t), nullptr, &length); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to get cache path", rprContext)); } std::vector<rpr_char> path(length); status = rprContextGetInfo(rprContext, RPR_CONTEXT_CACHE_PATH, path.size(), &path[0], nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to get cache path", rprContext)); } return path; } rif_image_desc GetRifImageDesc(rpr::FrameBuffer* rprFrameBuffer) { auto rprDesc = rprFrameBuffer->GetDesc(); rif_image_desc imageDesc = {}; imageDesc.image_width = rprDesc.fb_width; imageDesc.image_height = rprDesc.fb_height; imageDesc.image_depth = 1; imageDesc.image_row_pitch = 0; imageDesc.image_slice_pitch = 0; imageDesc.num_components = 4; imageDesc.type = RIF_COMPONENT_TYPE_FLOAT32; return imageDesc; } ContextOpenCL::ContextOpenCL(rpr_context rprContext, std::string const& modelPath) : Context(modelPath) { int deviceCount = 0; RIF_ERROR_CHECK_THROW(rifGetDeviceCount(rifBackendApiType, &deviceCount), "Failed to query device count"); assert(deviceCount != 0); if (0 == deviceCount) throw rif::Error("No compatible devices."); rpr_cl_context clContext; rpr_status status = rprContextGetInfo(rprContext, RPR_CL_CONTEXT, sizeof(rpr_cl_context), &clContext, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query CL context", rprContext)); } rpr_cl_device clDevice; status = rprContextGetInfo(rprContext, RPR_CL_DEVICE, sizeof(rpr_cl_device), &clDevice, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query CL device", rprContext)); } rpr_cl_command_queue clCommandQueue; status = rprContextGetInfo(rprContext, RPR_CL_COMMAND_QUEUE, sizeof(rpr_cl_command_queue), &clCommandQueue, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query CL command queue", rprContext)); } std::vector<rpr_char> path = GetRprCachePath(rprContext); #ifndef __APPLE__ RIF_ERROR_CHECK_THROW(rifCreateContextFromOpenClContext(RIF_API_VERSION, clContext, clDevice, clCommandQueue, path.data(), &m_context), "Failed to create RIF context") #endif } std::unique_ptr<Image> ContextOpenCL::CreateImage(rpr::FrameBuffer* rprFrameBuffer) { if (!rprFrameBuffer) { return nullptr; } rif_image rifImage = nullptr; #ifndef __APPLE__ if (auto rprFrameBufferGL = dynamic_cast<rpr::FrameBufferGL*>(rprFrameBuffer)) { RIF_ERROR_CHECK_THROW(rifContextCreateImageFromOpenGlTexture(m_context, GL_TEXTURE_2D, 0, rprFrameBufferGL->GetGL(), &rifImage), "Failed to create RIF image from OpenGL texture") } else { rpr_cl_mem clMem = rprFrameBuffer->GetCLMem(); assert(clMem); if (!clMem) { RIF_THROW_ERROR_MSG("Failed to get rpr framebuffer cl_mem"); } auto rifImageDesc = GetRifImageDesc(rprFrameBuffer); RIF_ERROR_CHECK_THROW(rifContextCreateImageFromOpenClMemory(m_context, &rifImageDesc, clMem, false, &rifImage), "Failed to create RIF image from OpenCL memory"); } #endif return std::unique_ptr<Image>(new Image(rifImage)); } ContextCPU::ContextCPU(rpr_context rprContext, std::string const& modelPath) : Context(modelPath) { int deviceCount = 0; RIF_ERROR_CHECK_THROW(rifGetDeviceCount(rifBackendApiType, &deviceCount), "Failed to query device count"); assert(deviceCount != 0); if (0 == deviceCount) RIF_THROW_ERROR_MSG("No compatible devices"); std::vector<rpr_char> path = GetRprCachePath(rprContext); RIF_ERROR_CHECK_THROW(rifCreateContext(RIF_API_VERSION, rifBackendApiType, 0, path.data(), &m_context), "Failed to create RIF context") } std::unique_ptr<Image> ContextCPU::CreateImage(rpr::FrameBuffer* rprFrameBuffer) { if (!rprFrameBuffer) { return nullptr; } return Context::CreateImage(GetRifImageDesc(rprFrameBuffer)); } void ContextCPU::UpdateInputImage(rpr::FrameBuffer* rprFrameBuffer, rif_image image) { if (!rprFrameBuffer || !image) { return; } size_t sizeInBytes = 0; size_t retSize = 0; RIF_ERROR_CHECK_THROW(rifImageGetInfo(image, RIF_IMAGE_DATA_SIZEBYTE, sizeof(size_t), (void*)& sizeInBytes, &retSize), "Failed to get RIF image info"); size_t fbSize; rpr_status status = rprFrameBufferGetInfo(rprFrameBuffer->GetHandle(), RPR_FRAMEBUFFER_DATA, 0, NULL, &fbSize); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query RPR_FRAMEBUFFER_DATA")); } assert(sizeInBytes == fbSize); if (sizeInBytes != fbSize) RIF_THROW_ERROR_MSG("Failed to match RIF image and frame buffer sizes"); void* imageData = nullptr; RIF_ERROR_CHECK_THROW(rifImageMap(image, RIF_IMAGE_MAP_WRITE, &imageData), "Failed to map RIF image"); auto rprStatus = rprFrameBufferGetInfo(rprFrameBuffer->GetHandle(), RPR_FRAMEBUFFER_DATA, fbSize, imageData, NULL); assert(RPR_SUCCESS == rprStatus); RIF_ERROR_CHECK_THROW(rifImageUnmap(image, imageData), "Failed to unmap RIF image"); if (RPR_SUCCESS != rprStatus) RIF_THROW_ERROR_MSG("Failed to get data from RPR frame buffer"); } rpr_int GpuDeviceIdUsed(rpr_creation_flags contextFlags) { #define GPU(x) RPR_CREATION_FLAGS_ENABLE_GPU##x std::vector<rpr_int> gpu_ids; gpu_ids.reserve(16); gpu_ids.push_back(GPU(0)); gpu_ids.push_back(GPU(1)); gpu_ids.push_back(GPU(2)); gpu_ids.push_back(GPU(3)); gpu_ids.push_back(GPU(4)); gpu_ids.push_back(GPU(5)); gpu_ids.push_back(GPU(6)); gpu_ids.push_back(GPU(7)); gpu_ids.push_back(GPU(8)); gpu_ids.push_back(GPU(9)); gpu_ids.push_back(GPU(10)); gpu_ids.push_back(GPU(11)); gpu_ids.push_back(GPU(12)); gpu_ids.push_back(GPU(13)); gpu_ids.push_back(GPU(14)); gpu_ids.push_back(GPU(15)); #
ContextMetal::ContextMetal(rpr_context rprContext, std::string const& modelPath) : Context(modelPath) { int deviceCount = 0; RIF_ERROR_CHECK_THROW(rifGetDeviceCount(rifBackendApiType, &deviceCount), "Failed to query device count"); assert(deviceCount != 0); if (0 == deviceCount) RIF_THROW_ERROR_MSG("No compatible devices"); rpr_creation_flags contextFlags = 0; rpr_status status = rprContextGetInfo(rprContext, RPR_CONTEXT_CREATION_FLAGS, sizeof(rpr_creation_flags), &contextFlags, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to query RPR context creation flags")); } std::vector<rpr_char> path = GetRprCachePath(rprContext); RIF_ERROR_CHECK_THROW(rifCreateContext(RIF_API_VERSION, rifBackendApiType, GpuDeviceIdUsed(contextFlags), path.data(), &m_context), "Failed to create RIF context"); } std::unique_ptr<Image> ContextMetal::CreateImage(rpr::FrameBuffer* rprFrameBuffer) { if (!rprFrameBuffer) { return nullptr; } rif_image rifImage = nullptr; rpr_cl_mem clMem = rprFrameBuffer->GetCLMem(); assert(clMem); if (!clMem) RIF_THROW_ERROR_MSG("Failed to get frame buffer cl_mem"); rpr_image_format framebufferFormat; rpr_status status = rprFrameBufferGetInfo(rprFrameBuffer->GetHandle(), RPR_FRAMEBUFFER_FORMAT, sizeof(framebufferFormat), &framebufferFormat, nullptr); if (status != RPR_SUCCESS) { throw rif::Error(RPR_GET_ERROR_MESSAGE(status, "Failed to get framebuffer format")); } int bytesPerComponent = 1; if (framebufferFormat.type == RPR_COMPONENT_TYPE_FLOAT32) { bytesPerComponent = 4; } else if (framebufferFormat.type == RPR_COMPONENT_TYPE_FLOAT16) { bytesPerComponent = 2; } auto desc = GetRifImageDesc(rprFrameBuffer); rif_longlong size = desc.image_width * desc.image_height * framebufferFormat.num_components * bytesPerComponent; RIF_ERROR_CHECK_THROW(rifContextCreateImageFromMetalMemory(m_context, &desc, clMem, size, &rifImage), "Failed to create RIF image from metal memory"); return std::unique_ptr<Image>(new Image(rifImage)); } bool HasGpuContext(rpr_creation_flags contextFlags) { #define GPU(x) RPR_CREATION_FLAGS_ENABLE_GPU##x rpr_creation_flags gpuMask = GPU(0) | GPU(1) | GPU(2) | GPU(3) | GPU(4) | GPU(5) | GPU(6) | GPU(7) | GPU(8) | GPU(9) | GPU(10) | GPU(11) | GPU(12) | GPU(13) | GPU(14) | GPU(15); #undef GPU return (contextFlags & gpuMask) != 0; } } std::unique_ptr<Context> Context::Create(rpr::Context* rprContext, std::string const& modelPath) { if (!rprContext) { return nullptr; } rpr_creation_flags contextFlags = 0; if (RPR_ERROR_CHECK(rprContextGetInfo(rprContext->GetHandle(), RPR_CONTEXT_CREATION_FLAGS, sizeof(rpr_creation_flags), &contextFlags, nullptr), "Failed to query RPR context creation flags")) { return nullptr; } try { std::unique_ptr<Context> rifContext; if (contextFlags & RPR_CREATION_FLAGS_ENABLE_METAL) { rifContext.reset(new ContextMetal(rprContext->GetHandle(), modelPath)); } else if (HasGpuContext(contextFlags) && rprContext->GetActivePluginType() != rpr::PluginType::HYBRID) { rifContext.reset(new ContextOpenCL(rprContext->GetHandle(), modelPath)); } else { rifContext.reset(new ContextCPU(rprContext->GetHandle(), modelPath)); } RIF_ERROR_CHECK_THROW(rifContextCreateCommandQueue(rifContext->m_context, &rifContext->m_commandQueue), "Failed to create RIF command queue"); return rifContext; } catch (rif::Error const& e) { TF_RUNTIME_ERROR("Failed to create RIF context. RIF error: %s", e.what()); } return nullptr; } Context::Context(std::string const& modelPath) : m_modelPath(modelPath) { } Context::~Context() { if (m_commandQueue) { rifObjectDelete(m_commandQueue); } if (m_context) { rifObjectDelete(m_context); } } std::unique_ptr<Image> Context::CreateImage(rif_image_desc const& desc) { rif_image rifImage = nullptr; RIF_ERROR_CHECK_THROW(rifContextCreateImage(m_context, &desc, nullptr, &rifImage), "Failed to create RIF image"); return std::unique_ptr<Image>(new Image(rifImage)); } void Context::UpdateInputImage(rpr::FrameBuffer* rprFrameBuffer, rif_image image) { } void Context::AttachFilter(rif_image_filter filter, rif_image inputImage, rif_image outputImage) { RIF_ERROR_CHECK_THROW(rifCommandQueueAttachImageFilter(m_commandQueue, filter, inputImage, outputImage), "Failed to attach image filter to queue"); ++m_numAttachedFilters; } void Context::DetachFilter(rif_image_filter filter) { auto rifStatus = rifCommandQueueDetachImageFilter(m_commandQueue, filter); if (rifStatus == RIF_ERROR_INVALID_PARAMETER) { return; } RIF_ERROR_CHECK_THROW(rifStatus, "Failed to detach image filter from queue"); --m_numAttachedFilters; } rif_image_filter Context::CreateImageFilter(rif_image_filter_type type) { rif_image_filter outFilter = nullptr; RIF_ERROR_CHECK_THROW(rifContextCreateImageFilter(m_context, type, &outFilter), "Failed to create image filter"); return outFilter; } void Context::ExecuteCommandQueue() { if (!m_numAttachedFilters) { return; } RIF_ERROR_CHECK_THROW(rifContextExecuteCommandQueue(m_context, m_commandQueue, nullptr, nullptr, nullptr), "Failed to execute command queue"); RIF_ERROR_CHECK_THROW(rifSyncronizeQueue(m_commandQueue), "Failed to synchronize command queue"); } } PXR_NAMESPACE_CLOSE_SCOPE
undef GPU for (rpr_int i = 0; i < gpu_ids.size(); i++ ) { if ((contextFlags & gpu_ids[i]) != 0) return i; } return -1; }
function_block-function_prefix_line
[ { "content": "class FrameBufferGL : public FrameBuffer {\n\npublic:\n\n FrameBufferGL(rpr_context context, rpr_uint width, rpr_uint height);\n\n FrameBufferGL(FrameBufferGL&& fb) noexcept;\n\n ~FrameBufferGL() override;\n\n\n\n FrameBufferGL const& operator=(FrameBufferGL&& fb) noexcept;\n\n\n\n bool Resize(rpr_uint width, rpr_uint height) override;\n\n\n\n rpr_GLuint GetGL() const;\n\n\n\nprivate:\n\n void CreateGL();\n\n void DeleteGL();\n\n\n\nprivate:\n\n rpr_GLuint m_textureId = 0;\n\n};\n\n\n\n} // namespace rpr\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // RPRCPP_FRAMEBUFFER_GL_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprFramebufferGL.h", "rank": 3, "score": 278291.1940746465 }, { "content": "class FrameBuffer : public Object {\n\npublic:\n\n static constexpr rpr_aov kAovNone = RPR_AOV_MAX;\n\n static constexpr rpr_uint kNumChannels = 4;\n\n\n\n FrameBuffer(rpr_context context, rpr_uint width, rpr_uint height);\n\n FrameBuffer(FrameBuffer&& fb) noexcept;\n\n ~FrameBuffer() override;\n\n\n\n FrameBuffer& operator=(FrameBuffer&& fb) noexcept;\n\n\n\n void AttachAs(rpr_aov aov);\n\n void Clear();\n\n void Resolve(FrameBuffer* dstFrameBuffer);\n\n /// Return true if framebuffer was actually resized\n\n virtual bool Resize(rpr_uint width, rpr_uint height);\n\n\n\n bool GetData(void* dstBuffer, size_t dstBufferSize);\n\n rpr_uint GetSize() const;\n\n rpr_framebuffer_desc GetDesc() const;\n", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprFramebuffer.h", "rank": 4, "score": 269727.6780869844 }, { "content": "class FrameBuffer;\n\n\n\n} // namespace rpr\n\n\n\nnamespace rif {\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifContext.h", "rank": 5, "score": 255222.96346531375 }, { "content": "class HdRprRenderBuffer final : public HdRenderBuffer {\n\npublic:\n\n HdRprRenderBuffer(SdfPath const& id);\n\n ~HdRprRenderBuffer() override = default;\n\n\n\n void Sync(HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits) override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\n bool Allocate(GfVec3i const& dimensions,\n\n HdFormat format,\n\n bool multiSampled) override;\n\n\n\n unsigned int GetWidth() const override { return m_width; }\n\n\n\n unsigned int GetHeight() const override { return m_height; }\n\n\n\n unsigned int GetDepth() const override { return 1u; }\n", "file_path": "pxr/imaging/plugin/hdRpr/renderBuffer.h", "rank": 6, "score": 252849.4750943003 }, { "content": "class FilterResample final : public Filter {\n\npublic:\n\n explicit FilterResample(Context* rifContext, std::uint32_t width, std::uint32_t height);\n\n ~FilterResample() override = default;\n\n\n\n void Resize(std::uint32_t width, std::uint32_t height) override;\n\n};\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifFilter.cpp", "rank": 7, "score": 237909.01064240024 }, { "content": "class FilterCustom final : public Filter {\n\npublic:\n\n explicit FilterCustom(Context* rifContext, rif_image_filter_type type) : Filter(rifContext) {\n\n m_rifFilter = rifContext->CreateImageFilter(type);\n\n }\n\n ~FilterCustom() override = default;\n\n};\n\n\n\nFilterAIDenoise::FilterAIDenoise(Context* rifContext, std::uint32_t width, std::uint32_t height) : Filter(rifContext) {\n\n m_rifFilter = rifContext->CreateImageFilter(RIF_IMAGE_FILTER_AI_DENOISE);\n\n\n\n // setup const parameters\n\n RIF_ERROR_CHECK_THROW(rifImageFilterSetParameter1u(m_rifFilter, \"useHDR\", 1), \"Failed to set filter \\\"usdHDR\\\" parameter\");\n\n RIF_ERROR_CHECK_THROW(rifImageFilterSetParameterString(m_rifFilter, \"modelPath\", rifContext->GetModelPath().c_str()), \"Failed to set filter \\\"modelPath\\\" parameter\");\n\n\n\n // auxillary filters\n\n m_auxFilters.resize(AuxFilterMax, nullptr);\n\n m_auxFilters[RemapDepthFilter] = rifContext->CreateImageFilter(RIF_IMAGE_FILTER_REMAP_RANGE);\n\n\n\n // setup remapping filters\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifFilter.cpp", "rank": 8, "score": 237909.01064240024 }, { "content": "class FilterEaw final : public Filter {\n\n enum {\n\n ColorVar,\n\n Mlaa,\n\n AuxFilterMax\n\n };\n\n\n\n enum {\n\n ColorVarianceImage,\n\n DenoisedOutputImage,\n\n AuxImageMax\n\n };\n\n\n\npublic:\n\n explicit FilterEaw(Context* rifContext, std::uint32_t width, std::uint32_t height);\n\n ~FilterEaw() override = default;\n\n\n\n void AttachFilter(rif_image inputImage) override;\n\n};\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifFilter.cpp", "rank": 9, "score": 237909.01064240024 }, { "content": "class FilterAIDenoise final : public Filter {\n\n enum {\n\n RemapDepthFilter,\n\n AuxFilterMax\n\n };\n\n enum {\n\n RemappedDepthImage,\n\n AuxImageMax\n\n };\n\npublic:\n\n explicit FilterAIDenoise(Context* rifContext, std::uint32_t width, std::uint32_t height);\n\n ~FilterAIDenoise() override = default;\n\n\n\n void AttachFilter(rif_image inputImage) override;\n\n};\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifFilter.cpp", "rank": 10, "score": 234632.35793441988 }, { "content": "class Context : public Object {\n\npublic:\n\n static std::unique_ptr<Context> Create(PluginType plugin, RenderDeviceType renderDevice, bool enableGlInterop, char const* cachePath);\n\n\n\n ~Context() override = default;\n\n\n\n rpr_context GetHandle() const;\n\n bool IsGlInteropEnabled() const;\n\n PluginType GetActivePluginType() const;\n\n RenderDeviceType GetActiveRenderDeviceType() const;\n\n\n\nprivate:\n\n Context() = default;\n\n\n\nprivate:\n\n PluginType m_activePlugin = PluginType::NONE;\n\n RenderDeviceType m_renderDevice = RenderDeviceType::NONE;\n\n bool m_useGlInterop = false;\n\n};\n\n\n\n} // namespace rpr\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // RPRCPP_CONTEXT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprContext.h", "rank": 11, "score": 232406.8154149803 }, { "content": "class Context {\n\npublic:\n\n static std::unique_ptr<Context> Create(rpr::Context* rprContext, std::string const& modelPath);\n\n\n\n virtual ~Context();\n\n\n\n rif_image_filter CreateImageFilter(rif_image_filter_type type);\n\n\n\n std::unique_ptr<Image> CreateImage(rif_image_desc const& desc);\n\n virtual std::unique_ptr<Image> CreateImage(rpr::FrameBuffer* rprFrameBuffer) = 0;\n\n\n\n void AttachFilter(rif_image_filter filter, rif_image inputImage, rif_image outputImage);\n\n void DetachFilter(rif_image_filter filter);\n\n\n\n virtual void UpdateInputImage(rpr::FrameBuffer* rprFrameBuffer, rif_image image);\n\n\n\n void ExecuteCommandQueue();\n\n\n\n std::string const& GetModelPath() const { return m_modelPath; };\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifContext.h", "rank": 12, "score": 221084.6523258242 }, { "content": "class Context;\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifContext.h", "rank": 13, "score": 221084.6523258242 }, { "content": "class Context;\n\n\n\n} // namespace rpr\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/imageCache.h", "rank": 14, "score": 220377.11111986113 }, { "content": "class Context;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifObject.h", "rank": 15, "score": 211697.4034403644 }, { "content": "class HdRprMesh final : public HdMesh {\n\npublic:\n\n HF_MALLOC_TAG_NEW(\"new HdRprMesh\");\n\n\n\n HdRprMesh(SdfPath const& id, SdfPath const& instancerId = SdfPath());\n\n ~HdRprMesh() override = default;\n\n\n\n void Sync(HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits,\n\n TfToken const& reprName) override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\nprotected:\n\n HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;\n\n\n\n void _InitRepr(TfToken const& reprName, HdDirtyBits* dirtyBits) override;\n", "file_path": "pxr/imaging/plugin/hdRpr/mesh.h", "rank": 16, "score": 211122.9638771644 }, { "content": "class HdRprMaterial final : public HdMaterial {\n\npublic:\n\n HdRprMaterial(SdfPath const& id);\n\n\n\n ~HdRprMaterial() override = default;\n\n\n\n void Sync(HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\n void Reload() override;\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\n /// Get pointer to RPR material\n\n /// In case material сreation failure return nullptr\n\n const RprApiObject* GetRprMaterialObject() const;\n\n\n\nprivate:\n\n RprApiObjectPtr m_rprMaterial;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_MATERIAL_H\n", "file_path": "pxr/imaging/plugin/hdRpr/material.h", "rank": 17, "score": 211122.9638771644 }, { "content": "class HdRprPlugin final : public HdRendererPlugin {\n\npublic:\n\n HdRprPlugin() = default;\n\n ~HdRprPlugin() override = default;\n\n\n\n HdRprPlugin(const HdRprPlugin&) = delete;\n\n HdRprPlugin& operator =(const HdRprPlugin&) = delete;\n\n\n\n HdRenderDelegate* CreateRenderDelegate() override;\n\n\n\n void DeleteRenderDelegate(HdRenderDelegate* renderDelegate) override;\n\n\n\n bool IsSupported() const override { return true; }\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_RENDERER_PLUGIN_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rendererPlugin.h", "rank": 18, "score": 205877.57759554608 }, { "content": "class HdRprDelegate final : public HdRenderDelegate {\n\npublic:\n\n\n\n HdRprDelegate();\n\n ~HdRprDelegate() override;\n\n\n\n HdRprDelegate(const HdRprDelegate&) = delete;\n\n HdRprDelegate& operator =(const HdRprDelegate&) = delete;\n\n\n\n const TfTokenVector& GetSupportedRprimTypes() const override;\n\n const TfTokenVector& GetSupportedSprimTypes() const override;\n\n const TfTokenVector& GetSupportedBprimTypes() const override;\n\n\n\n HdRenderParam* GetRenderParam() const override;\n\n HdResourceRegistrySharedPtr GetResourceRegistry() const override;\n\n\n\n HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex* index,\n\n HdRprimCollection const& collection) override;\n\n\n\n HdInstancer* CreateInstancer(HdSceneDelegate* delegate,\n", "file_path": "pxr/imaging/plugin/hdRpr/renderDelegate.h", "rank": 19, "score": 205877.57759554608 }, { "content": "class HdRprRenderParam final : public HdRenderParam {\n\npublic:\n\n HdRprRenderParam(HdRprApi* rprApi, HdRprRenderThread* renderThread)\n\n : m_rprApi(rprApi)\n\n , m_renderThread(renderThread) {\n\n m_numLights.store(0);\n\n }\n\n ~HdRprRenderParam() override = default;\n\n\n\n HdRprApi const* GetRprApi() const { return m_rprApi; }\n\n HdRprApi* AcquireRprApiForEdit() {\n\n m_renderThread->StopRender();\n\n return m_rprApi;\n\n }\n\n\n\n HdRprRenderThread* GetRenderThread() { return m_renderThread; }\n\n\n\n void AddLight() { ++m_numLights; }\n\n void RemoveLight() { --m_numLights; }\n\n bool HasLights() const { return m_numLights != 0; }\n", "file_path": "pxr/imaging/plugin/hdRpr/renderParam.h", "rank": 20, "score": 203392.9360120879 }, { "content": "class HdRprRenderPass final : public HdRenderPass {\n\npublic:\n\n HdRprRenderPass(HdRenderIndex* index,\n\n HdRprimCollection const& collection,\n\n HdRprRenderParam* renderParam);\n\n\n\n ~HdRprRenderPass() override = default;\n\n\n\n bool IsConverged() const override;\n\n\n\n void _Execute(HdRenderPassStateSharedPtr const& renderPassState,\n\n TfTokenVector const& renderTags) override;\n\n\n\nprivate:\n\n HdRprRenderParam* m_renderParam;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_RENDER_PASS_H\n", "file_path": "pxr/imaging/plugin/hdRpr/renderPass.h", "rank": 21, "score": 203392.9360120879 }, { "content": "class Image : public Object {\n\npublic:\n\n static rif_image_desc GetDesc(uint32_t width, uint32_t height, HdFormat format);\n\n\n\n explicit Image(rif_image imageHandle);\n\n\n\n rif_image GetHandle() { return static_cast<rif_image>(m_rifObjectHandle); }\n\n};\n\n\n\n} // namespace rif\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // RIFCPP_IMAGE_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifImage.h", "rank": 22, "score": 201076.17978158867 }, { "content": "enum class PluginType : int\n\n{\n\n NONE = -1,\n\n TAHOE = 0,\n\n HYBRID,\n\n FIRST = TAHOE,\n\n LAST = HYBRID\n\n};\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprContext.h", "rank": 23, "score": 197452.65595704588 }, { "content": "class Error : public std::runtime_error {\n\npublic:\n\n Error(rif_int errorStatus, const char* messageOnFail, char const* file, char const* function, size_t line)\n\n : std::runtime_error(ConstructErrorMessage(errorStatus, messageOnFail, file, function, line)) {\n\n\n\n }\n\n\n\n Error(std::string const& errorMesssage)\n\n : std::runtime_error(errorMesssage) {\n\n\n\n }\n\n};\n\n\n\n} // namespace rif\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // RIFCPP_EXCEPTION_H", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifError.h", "rank": 24, "score": 183880.36934750338 }, { "content": "enum class RenderDeviceType\n\n{\n\n NONE = -1,\n\n CPU = 0,\n\n GPU,\n\n FIRST = CPU,\n\n LAST = GPU\n\n};\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprContext.h", "rank": 25, "score": 175712.63352853624 }, { "content": "class HdRprApi final {\n\npublic:\n\n HdRprApi(HdRenderDelegate* delegate);\n\n ~HdRprApi();\n\n\n\n RprApiObjectPtr CreateEnvironmentLight(const std::string& pathTotexture, float intensity);\n\n RprApiObjectPtr CreateEnvironmentLight(GfVec3f color, float intensity);\n\n RprApiObjectPtr CreateRectLightMesh(float width, float height);\n\n RprApiObjectPtr CreateSphereLightMesh(float radius);\n\n RprApiObjectPtr CreateCylinderLightMesh(float radius, float length);\n\n RprApiObjectPtr CreateDiskLightMesh(float radius);\n\n void SetLightTransform(RprApiObject* light, GfMatrix4f const& transform);\n\n\n\n RprApiObjectPtr CreateDirectionalLight();\n\n void SetDirectionalLightAttributes(RprApiObject* directionalLight, GfVec3f const& color, float shadowSoftness);\n\n\n\n RprApiObjectPtr CreateVolume(const std::vector<uint32_t>& densityGridOnIndices, const std::vector<float>& densityGridOnValueIndices, const std::vector<float>& densityGridValues,\n\n const std::vector<uint32_t>& colorGridOnIndices, const std::vector<float>& colorGridOnValueIndices, const std::vector<float>& colorGridValues,\n\n const std::vector<uint32_t>& emissiveGridOnIndices, const std::vector<float>& emissiveGridOnValueIndices, const std::vector<float>& emissiveGridValues,\n\n const GfVec3i& gridSize, const GfVec3f& voxelSize, const GfVec3f& gridBBLow);\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApi.h", "rank": 26, "score": 170057.82511285515 }, { "content": "class Image : public Object {\n\npublic:\n\n Image(rpr_context context, const char* path);\n\n Image(rpr_context context, void const* encodedData, size_t dataSize);\n\n Image(rpr_context context, rpr_uint width, rpr_uint height, rpr_image_format format, void const* data);\n\n Image(rpr_context context, rpr_image_desc const& imageDesc, rpr_image_format format, void const* data);\n\n Image(Image&& image) noexcept;\n\n ~Image() override = default;\n\n\n\n Image& operator=(Image&& image) noexcept;\n\n\n\n rpr_image_format GetFormat() const;\n\n rpr_image_desc GetDesc() const;\n\n rpr_image GetHandle();\n\n\n\nprivate:\n\n rpr_image GetHandle() const;\n\n};\n\n\n\n} // namespace rpr\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // RPRCPP_IMAGE_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprImage.h", "rank": 27, "score": 169320.33135943732 }, { "content": "struct ParameterSetter : public BOOST_NS::static_visitor<rif_int> {\n\n const char* paramName;\n\n rif_image_filter filter;\n\n\n\n rif_int operator()(int value) {\n\n return rifImageFilterSetParameter1u(filter, paramName, value);\n\n }\n\n\n\n rif_int operator()(float value) {\n\n return rifImageFilterSetParameter1f(filter, paramName, value);\n\n }\n\n\n\n rif_int operator()(std::string const& value) {\n\n return rifImageFilterSetParameterString(filter, paramName, value.c_str());\n\n }\n\n\n\n rif_int operator()(GfVec2i const& value) {\n\n return rifImageFilterSetParameter2u(filter, paramName, value[0], value[1]);\n\n }\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifFilter.cpp", "rank": 28, "score": 161445.08711801755 }, { "content": "class ImageCache {\n\npublic:\n\n ImageCache(rpr::Context* context);\n\n\n\n std::shared_ptr<rpr::Image> GetImage(std::string const& path);\n\n\n\n void RequireGarbageCollection();\n\n void GarbageCollectIfNeeded();\n\n\n\nprivate:\n\n std::shared_ptr<rpr::Image> CreateImage(std::string const& path);\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/imageCache.h", "rank": 29, "score": 160601.68435542504 }, { "content": "class HdRprInstancer : public HdInstancer {\n\npublic:\n\n HdRprInstancer(\n\n HdSceneDelegate* delegate,\n\n SdfPath const& id,\n\n SdfPath const& parentInstancerId) :\n\n HdInstancer(delegate, id, parentInstancerId) {\n\n }\n\n\n\n VtMatrix4dArray ComputeTransforms(SdfPath const& prototypeId);\n\n\n\nprivate:\n\n void Sync();\n\n\n\n VtMatrix4dArray m_transform;\n\n VtVec3fArray m_translate;\n\n VtVec4fArray m_rotate;\n\n VtVec3fArray m_scale;\n\n\n\n std::mutex m_syncMutex;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_INSTANCER_H\n", "file_path": "pxr/imaging/plugin/hdRpr/instancer.h", "rank": 30, "score": 159708.5370451663 }, { "content": "class HdRprField : public HdField {\n\npublic:\n\n HdRprField(SdfPath const& id);\n\n ~HdRprField() override = default;\n\n\n\n void Sync(HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_FIELD_H\n", "file_path": "pxr/imaging/plugin/hdRpr/field.h", "rank": 31, "score": 159708.5370451663 }, { "content": "class HdRprVolume : public HdVolume {\n\npublic:\n\n HdRprVolume(SdfPath const& id);\n\n ~HdRprVolume() override = default;\n\n\n\n void Sync(\n\n HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits,\n\n TfToken const& reprName\n\n ) override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\nprotected:\n\n HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;\n\n\n\n void _InitRepr(TfToken const& reprName,\n", "file_path": "pxr/imaging/plugin/hdRpr/volume.h", "rank": 32, "score": 159708.5370451663 }, { "content": "class HdRprCamera : public HdCamera {\n\n\n\npublic:\n\n HdRprCamera(SdfPath const& id);\n\n ~HdRprCamera() override = default;\n\n\n\n void Sync(HdSceneDelegate *sceneDelegate,\n\n HdRenderParam *renderParam,\n\n HdDirtyBits *dirtyBits) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\n bool GetApertureSize(GfVec2f* value) const;\n\n bool GetApertureOffset(GfVec2f* value) const;\n\n bool GetFocalLength(float* value) const;\n\n bool GetFStop(float* value) const;\n\n bool GetFocusDistance(float* value) const;\n\n bool GetShutterOpen(double* value) const;\n", "file_path": "pxr/imaging/plugin/hdRpr/camera.h", "rank": 33, "score": 159708.5370451663 }, { "content": "class HdRprDistantLight : public HdSprim {\n\n\n\npublic:\n\n HdRprDistantLight(SdfPath const& id)\n\n : HdSprim(id) {\n\n\n\n }\n\n\n\n void Sync(HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\nprotected:\n\n RprApiObjectPtr m_rprLight;\n\n GfMatrix4f m_transform;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_DISTANT_LIGHT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/distantLight.h", "rank": 34, "score": 155653.83652998443 }, { "content": "class HdRprDomeLight : public HdSprim {\n\n\n\npublic:\n\n HdRprDomeLight(SdfPath const& id)\n\n : HdSprim(id) {\n\n\n\n }\n\n\n\n void Sync(HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\nprotected:\n\n RprApiObjectPtr m_rprLight;\n\n GfMatrix4f m_transform;\n\n bool m_created = false;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_DOME_LIGHT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/domeLight.h", "rank": 35, "score": 155653.83652998443 }, { "content": "class HdRprLightBase : public HdLight {\n\npublic:\n\n HdRprLightBase(SdfPath const& id)\n\n : HdLight(id) {\n\n\n\n }\n\n\n\n ~HdRprLightBase() override = default;\n\n\n\n void Sync(HdSceneDelegate* sceneDelegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\nprotected:\n\n virtual bool SyncGeomParams(HdSceneDelegate* sceneDelegate, SdfPath const& id) = 0;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/lightBase.h", "rank": 36, "score": 155653.83652998443 }, { "content": "class HdRprSphereLight : public HdRprLightBase {\n\n\n\npublic:\n\n HdRprSphereLight(SdfPath const& id)\n\n : HdRprLightBase(id) {\n\n }\n\n\n\nprotected:\n\n bool SyncGeomParams(HdSceneDelegate* sceneDelegate, SdfPath const& id) override;\n\n\n\n // Create mesh with emmisive material\n\n RprApiObjectPtr CreateLightMesh(HdRprApi* rprApi) override;\n\n\n\n // Normalize Light Color with surface area\n\n GfVec3f NormalizeLightColor(const GfMatrix4f& transform, const GfVec3f& emmisionColor) override;\n\n\n\nprivate:\n\n float m_radius = std::numeric_limits<float>::quiet_NaN();\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_SPHERE_LIGHT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/sphereLight.h", "rank": 37, "score": 154510.32831510296 }, { "content": "class HdRprDiskLight : public HdRprLightBase {\n\n \n\npublic:\n\n HdRprDiskLight(SdfPath const & id)\n\n : HdRprLightBase(id) {}\n\n\n\nprotected:\n\n\n\n bool SyncGeomParams(HdSceneDelegate* sceneDelegate, SdfPath const& id) override;\n\n\n\n // Create mesh with emmisive material\n\n RprApiObjectPtr CreateLightMesh(HdRprApi* rprApi) override;\n\n\n\n // Normalize Light Color with surface area\n\n GfVec3f NormalizeLightColor(const GfMatrix4f& transform, const GfVec3f& emmisionColor) override;\n\n\n\nprivate:\n\n float m_radius = std::numeric_limits<float>::quiet_NaN();\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_DISK_LIGHT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/diskLight.h", "rank": 38, "score": 154510.32831510296 }, { "content": "class HdRprRectLight : public HdRprLightBase {\n\n\n\npublic:\n\n HdRprRectLight(SdfPath const& id)\n\n : HdRprLightBase(id) {\n\n }\n\n\n\nprotected:\n\n\n\n bool SyncGeomParams(HdSceneDelegate* sceneDelegate, SdfPath const& id) override;\n\n\n\n // Create light mesh which is required to be set emmisive material \n\n RprApiObjectPtr CreateLightMesh(HdRprApi* rprApi) override;\n\n\n\n // Normalize Light Color with surface area\n\n GfVec3f NormalizeLightColor(const GfMatrix4f& transform, const GfVec3f& emmisionColor) override;\n\n\n\nprivate:\n\n float m_width = std::numeric_limits<float>::quiet_NaN();\n\n float m_height = std::numeric_limits<float>::quiet_NaN();\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_RECT_LIGHT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rectLight.h", "rank": 39, "score": 154510.32831510296 }, { "content": "class HdRprCylinderLight : public HdRprLightBase {\n\n\n\npublic:\n\n HdRprCylinderLight(SdfPath const& id)\n\n : HdRprLightBase(id) {\n\n }\n\n\n\nprotected:\n\n\n\n bool SyncGeomParams(HdSceneDelegate* sceneDelegate, SdfPath const& id) override;\n\n\n\n // Create mesh with emmisive material\n\n RprApiObjectPtr CreateLightMesh(HdRprApi* rprApi) override;\n\n\n\n // Normalize Light Color with surface area\n\n GfVec3f NormalizeLightColor(const GfMatrix4f& transform, const GfVec3f& emmisionColor) override;\n\n\n\nprivate:\n\n float m_radius = std::numeric_limits<float>::quiet_NaN();\n\n float m_length = std::numeric_limits<float>::quiet_NaN();\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_CYLINDER_LIGHT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/cylinderLight.h", "rank": 40, "score": 154510.32831510296 }, { "content": "class HdRprBasisCurves : public HdBasisCurves {\n\n\n\npublic:\n\n HdRprBasisCurves(SdfPath const& id,\n\n SdfPath const& instancerId);\n\n\n\n ~HdRprBasisCurves() override = default;\n\n\n\n void Sync(HdSceneDelegate* delegate,\n\n HdRenderParam* renderParam,\n\n HdDirtyBits* dirtyBits,\n\n TfToken const& reprSelector) override;\n\n\n\n void Finalize(HdRenderParam* renderParam) override;\n\n\n\n HdDirtyBits GetInitialDirtyBitsMask() const override;\n\n\n\nprotected:\n\n HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/basisCurves.h", "rank": 41, "score": 153733.70753088486 }, { "content": "class Error : public std::runtime_error {\n\npublic:\n\n Error(rpr_status errorStatus, const char* messageOnFail, char const* file, char const* function, size_t line, rpr_context context = nullptr)\n\n : std::runtime_error(ConstructErrorMessage(errorStatus, messageOnFail, file, function, line, context)) {\n\n\n\n }\n\n\n\n Error(std::string const& errorMesssage)\n\n : std::runtime_error(errorMesssage) {\n\n\n\n }\n\n};\n\n\n\ninline void ThrowErrorMsg(char const* file, char const* function, size_t line, const char* fmt, ...) {\n\n va_list ap;\n\n va_start(ap, fmt);\n\n auto messageOnFail = TfVStringPrintf(fmt, ap);\n\n va_end(ap);\n\n throw Error(ConstructErrorMessage(RPR_SUCCESS, messageOnFail, file, function, line));\n\n}\n\n\n\n} // namespace rpr\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // RPRCPP_EXCEPTION_H", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprError.h", "rank": 42, "score": 153691.19788662548 }, { "content": "class HdRprApiNormalAov : public HdRprApiAov {\n\npublic:\n\n HdRprApiNormalAov(int width, int height, HdFormat format,\n\n rpr::Context* rprContext, rif::Context* rifContext);\n\n ~HdRprApiNormalAov() override = default;\n\nprotected:\n\n void OnFormatChange(rif::Context* rifContext) override;\n\n void OnSizeChange(rif::Context* rifContext) override;\n\n};\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApiAov.h", "rank": 43, "score": 152701.16540793286 }, { "content": "class HdRprApiColorAov : public HdRprApiAov {\n\npublic:\n\n HdRprApiColorAov(int width, int height, HdFormat format, rpr::Context* rprContext);\n\n ~HdRprApiColorAov() override = default;\n\n\n\n void Update(HdRprApi const* rprApi, rif::Context* rifContext) override;\n\n void Resolve() override;\n\n\n\n void SetOpacityAov(std::shared_ptr<HdRprApiAov> opacity);\n\n\n\n void EnableAIDenoise(std::shared_ptr<HdRprApiAov> albedo,\n\n std::shared_ptr<HdRprApiAov> normal,\n\n std::shared_ptr<HdRprApiAov> linearDepth);\n\n void EnableEAWDenoise(std::shared_ptr<HdRprApiAov> albedo,\n\n std::shared_ptr<HdRprApiAov> normal,\n\n std::shared_ptr<HdRprApiAov> linearDepth,\n\n std::shared_ptr<HdRprApiAov> objectId,\n\n std::shared_ptr<HdRprApiAov> worldCoordinate);\n\n void DisableDenoise(rif::Context* rifContext);\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApiAov.h", "rank": 44, "score": 152701.16540793286 }, { "content": "class HdRprApiDepthAov : public HdRprApiAov {\n\npublic:\n\n HdRprApiDepthAov(HdFormat format,\n\n std::shared_ptr<HdRprApiAov> worldCoordinateAov,\n\n rpr::Context* rprContext, rif::Context* rifContext);\n\n ~HdRprApiDepthAov() override = default;\n\n\n\n void Update(HdRprApi const* rprApi, rif::Context* rifContext) override;\n\n void Resize(int width, int height, HdFormat format) override;\n\n\n\nprivate:\n\n std::shared_ptr<HdRprApiAov> m_retainedWorldCoordinateAov;\n\n int m_width;\n\n int m_height;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_RPR_API_AOV_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApiAov.h", "rank": 45, "score": 152701.16540793286 }, { "content": " class ImageMetadata {\n\n public:\n\n ImageMetadata(std::string const& path);\n\n\n\n bool IsMetadataEqual(ImageMetadata const& md);\n\n\n\n public:\n\n std::weak_ptr<rpr::Image> handle;\n\n\n\n private:\n\n size_t m_size = 0u;\n\n double m_modificationTime = 0.0;\n\n };\n\n\n\nprivate:\n\n rpr::Context* m_context;\n\n std::unordered_map<std::string, ImageMetadata> m_cache;\n\n bool m_garbageCollectionRequired = false;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_IMAGE_CACHE_H\n", "file_path": "pxr/imaging/plugin/hdRpr/imageCache.h", "rank": 46, "score": 151125.34958162284 }, { "content": "class HdRprDiagnosticMgrDelegate : public TfDiagnosticMgr::Delegate {\n\npublic:\n\n explicit HdRprDiagnosticMgrDelegate(std::string const& logFile) : m_outputFile(nullptr) {\n\n if (logFile == \"stderr\") {\n\n m_output = stderr;\n\n } else if (logFile == \"stdout\") {\n\n m_output = stdout;\n\n } else {\n\n m_outputFile = fopen(logFile.c_str(), \"wa\");\n\n if (!m_outputFile) {\n\n TF_RUNTIME_ERROR(\"Failed to open error output file: \\\"%s\\\". Defaults to stderr\\n\", logFile.c_str());\n\n m_output = stderr;\n\n } else {\n\n m_output = m_outputFile;\n\n }\n\n }\n\n }\n\n ~HdRprDiagnosticMgrDelegate() override {\n\n if (m_outputFile) {\n\n fclose(m_outputFile);\n", "file_path": "pxr/imaging/plugin/hdRpr/renderDelegate.cpp", "rank": 47, "score": 144405.528412811 }, { "content": "class Filter {\n\npublic:\n\n static std::unique_ptr<Filter> Create(FilterType type, Context* rifContext, std::uint32_t width, std::uint32_t height);\n\n static std::unique_ptr<Filter> CreateCustom(rif_image_filter_type type, Context* rifContext);\n\n\n\n virtual ~Filter();\n\n\n\n void SetInput(FilterInputType inputType, Filter* filter);\n\n void SetInput(FilterInputType inputType, rif_image rifImage, float sigma = 1.0f);\n\n void SetInput(FilterInputType inputType, rpr::FrameBuffer* rprFrameBuffer, float sigma = 1.0f);\n\n void SetInput(const char* name, rpr::FrameBuffer* rprFrameBuffer);\n\n void SetOutput(rif_image rifImage);\n\n void SetOutput(rif_image_desc imageDesc);\n\n void SetOutput(rpr::FrameBuffer* rprFrameBuffer);\n\n void SetParam(const char* name, FilterParam param);\n\n void SetParamFilter(const char* name, Filter* filter);\n\n\n\n rif_image GetInput(FilterInputType inputType) const;\n\n rif_image GetOutput();\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifFilter.h", "rank": 48, "score": 143454.7261447646 }, { "content": "class Object {\n\npublic:\n\n Object(void* objectHandle)\n\n : m_rifObjectHandle(objectHandle) {\n\n\n\n }\n\n\n\n Object() = default;\n\n Object(Object const&) = delete;\n\n Object& operator=(Object const&) = delete;\n\n\n\n void Delete() {\n\n if (m_rifObjectHandle) {\n\n rifObjectDelete(m_rifObjectHandle);\n\n }\n\n m_rifObjectHandle = nullptr;\n\n }\n\n\n\n ~Object() {\n\n Delete();\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifObject.h", "rank": 49, "score": 143454.7261447646 }, { "content": "enum class FilterType\n\n{\n\n None = -1,\n\n AIDenoise,\n\n Resample,\n\n EawDenoise,\n\n FIRST = AIDenoise,\n\n LAST = EawDenoise\n\n};\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifFilter.h", "rank": 50, "score": 135872.52423196216 }, { "content": "protected:\n\n Context(std::string const& modelPath);\n\n\n\nprotected:\n\n rif_context m_context = nullptr;\n\n rif_command_queue m_commandQueue = nullptr;\n\n\n\nprivate:\n\n int m_numAttachedFilters = 0;\n\n std::string m_modelPath;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n} // namespace rif\n\n\n\n#endif // RIFCPP_CONTEXT_H\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifContext.h", "rank": 51, "score": 120048.15488978672 }, { "content": "#ifndef RIFCPP_CONTEXT_H\n\n#define RIFCPP_CONTEXT_H\n\n\n\n#include \"rifImage.h\"\n\n\n\n#include <RadeonProRender.h>\n\n#include <string>\n\n#include <memory>\n\n\n\nPXR_NAMESPACE_OPEN_SCOPE\n\n\n\nnamespace rpr {\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rifcpp/rifContext.h", "rank": 52, "score": 120041.08748488764 }, { "content": "class RprApiObject {\n\npublic:\n\n static std::unique_ptr<RprApiObject> Wrap(void* handle);\n\n\n\n RprApiObject() : m_handle(nullptr) {}\n\n RprApiObject(nullptr_t) : m_handle(nullptr) {}\n\n\n\n explicit RprApiObject(void* handle);\n\n RprApiObject(void* handle, std::function<void (void*)> deleter);\n\n ~RprApiObject();\n\n\n\n void AttachDependency(std::unique_ptr<RprApiObject>&& dependencyObject);\n\n void AttachDependency(std::unique_ptr<rpr::Object>&& dependencyObject);\n\n\n\n void AttachOnReleaseAction(TfToken const& actionName, std::function<void (void*)> action);\n\n void DetachOnReleaseAction(TfToken const& actionName);\n\n bool HasOnReleaseAction(TfToken const& actionName);\n\n\n\n void* GetHandle() const;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApi.h", "rank": 71, "score": 110754.41151835278 }, { "content": "class RprApiObject;\n\nusing RprApiObjectPtr = std::unique_ptr<RprApiObject>;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/material.h", "rank": 72, "score": 109981.92482989674 }, { "content": "class RprApiObject;\n\nusing RprApiObjectPtr = std::unique_ptr<RprApiObject>;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/mesh.h", "rank": 73, "score": 109981.92482989674 }, { "content": "class HdRprParam;\n", "file_path": "pxr/imaging/plugin/hdRpr/mesh.h", "rank": 74, "score": 109981.92482989674 }, { "content": "class HdRprApi;\n", "file_path": "pxr/imaging/plugin/hdRpr/mesh.h", "rank": 75, "score": 109981.92482989674 }, { "content": "class Object {\n\npublic:\n\n Object(Object const&) = delete;\n\n Object& operator=(Object const&) = delete;\n\n Object& operator=(Object&& object) noexcept {\n\n m_rprObjectHandle = object.m_rprObjectHandle;\n\n object.m_rprObjectHandle = nullptr;\n\n return *this;\n\n }\n\n\n\n virtual ~Object() {\n\n Delete();\n\n }\n\n\n\nprotected:\n\n Object() = default;\n\n\n\n void Delete() {\n\n if (m_rprObjectHandle) {\n\n rprObjectDelete(m_rprObjectHandle);\n", "file_path": "pxr/imaging/plugin/hdRpr/rprcpp/rprObject.h", "rank": 76, "score": 109981.92482989674 }, { "content": "class MaterialAdapter;\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApi.h", "rank": 77, "score": 109981.92482989674 }, { "content": "class RprApiObject;\n\nusing RprApiObjectPtr = std::unique_ptr<RprApiObject>;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/volume.h", "rank": 78, "score": 109981.92482989674 }, { "content": "class HdRprApiImpl;\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApi.h", "rank": 79, "score": 109352.89273170586 }, { "content": "class HdRprApi;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApiAov.h", "rank": 80, "score": 109352.89273170586 }, { "content": "class HdRprApi;\n", "file_path": "pxr/imaging/plugin/hdRpr/basisCurves.h", "rank": 81, "score": 108460.4033984023 }, { "content": "class RprApiObject;\n\nusing RprApiObjectPtr = std::unique_ptr<RprApiObject>;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/domeLight.h", "rank": 82, "score": 108460.4033984023 }, { "content": "class RprApiObject;\n\nusing RprApiObjectPtr = std::unique_ptr<RprApiObject>;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/basisCurves.h", "rank": 83, "score": 108460.4033984023 }, { "content": "class HdRprApi;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/renderParam.h", "rank": 84, "score": 108460.4033984023 }, { "content": "class HdRprMaterial;\n", "file_path": "pxr/imaging/plugin/hdRpr/basisCurves.h", "rank": 85, "score": 108460.4033984023 }, { "content": "class HdRprApi;\n", "file_path": "pxr/imaging/plugin/hdRpr/domeLight.h", "rank": 86, "score": 108460.4033984023 }, { "content": "class HdRprApi;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/renderDelegate.h", "rank": 87, "score": 108460.4033984023 }, { "content": "class RprApiObject;\n\nusing RprApiObjectPtr = std::unique_ptr<RprApiObject>;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/lightBase.h", "rank": 88, "score": 108460.4033984023 }, { "content": "class HdRprApi;\n", "file_path": "pxr/imaging/plugin/hdRpr/lightBase.h", "rank": 89, "score": 108460.4033984023 }, { "content": "class RprMaterialFactory {\n\npublic:\n\n RprMaterialFactory(rpr_material_system matSys, ImageCache* imageCache);\n\n\n\n RprApiMaterial* CreateMaterial(EMaterialType type, const MaterialAdapter& materialAdapter);\n\n\n\n void DeleteMaterial(RprApiMaterial* rprmaterial);\n\n\n\n void AttachMaterialToShape(rpr_shape mesh, const RprApiMaterial* material, bool doublesided, bool displacementEnabled);\n\n\n\n void AttachMaterialToCurve(rpr_shape mesh, const RprApiMaterial* material);\n\n\n\nprivate:\n\n rpr_material_system m_matSys;\n\n ImageCache* m_imageCache;\n\n};\n\n\n\nPXR_NAMESPACE_CLOSE_SCOPE\n\n\n\n#endif // HDRPR_MATERIAL_FACTORY_H\n", "file_path": "pxr/imaging/plugin/hdRpr/materialFactory.h", "rank": 90, "score": 108460.4033984023 }, { "content": "def getRprPath(_pathCache=[None]):\n\n if _pathCache[0]:\n\n return _pathCache[0]\n\n\n\n rprPluginType = Registry.FindTypeByName('HdRprPlugin')\n\n plugin = Registry().GetPluginForType(rprPluginType)\n\n if plugin and plugin.path:\n\n _pathCache[0] = plugin.path\n", "file_path": "pxr/imaging/plugin/hdRpr/python/rpr.py", "rank": 91, "score": 108014.1562424906 }, { "content": "class HdRprApiImpl {\n\npublic:\n\n HdRprApiImpl(HdRenderDelegate* delegate)\n\n : m_delegate(delegate) {\n\n // Postpone initialization as further as possible to allow Hydra user to set custom render settings before creating a context\n\n //InitIfNeeded();\n\n }\n\n\n\n void InitIfNeeded() {\n\n RecursiveLockGuard rprLock(g_rprAccessMutex);\n\n\n\n if (m_state != kStateUninitialized) {\n\n return;\n\n }\n\n m_state = kStateRender;\n\n\n\n InitRpr();\n\n InitRif();\n\n InitMaterialSystem();\n\n CreateScene();\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApi.cpp", "rank": 92, "score": 108001.24719291883 }, { "content": "class HdRprApiAov {\n\npublic:\n\n HdRprApiAov(rpr_aov rprAovType, int width, int height, HdFormat format,\n\n rpr::Context* rprContext, std::unique_ptr<rif::Filter> filter);\n\n HdRprApiAov(rpr_aov rprAovType, int width, int height, HdFormat format,\n\n rpr::Context* rprContext, rif::Context* rifContext);\n\n virtual ~HdRprApiAov() = default;\n\n\n\n virtual void Resize(int width, int height, HdFormat format);\n\n virtual void Update(HdRprApi const* rprApi, rif::Context* rifContext);\n\n virtual void Resolve();\n\n\n\n bool GetData(void* dstBuffer, size_t dstBufferSize);\n\n void Clear();\n\n\n\n HdFormat GetFormat() const { return m_format; }\n\n rpr::FrameBuffer* GetAovFb() { return m_aov.get(); };\n\n rpr::FrameBuffer* GetResolvedFb();\n\n\n\nprotected:\n", "file_path": "pxr/imaging/plugin/hdRpr/rprApiAov.h", "rank": 93, "score": 108001.24719291883 }, { "content": "class HdRprRenderParam;\n", "file_path": "pxr/imaging/plugin/hdRpr/renderDelegate.h", "rank": 94, "score": 106995.1781449277 }, { "content": "class HdRprRenderThread {\n\npublic:\n\n HdRprRenderThread();\n\n ~HdRprRenderThread();\n\n\n\n void SetStopCallback(std::function<void()> stopCallback);\n\n void SetRenderCallback(std::function<void()> renderCallback);\n\n void SetShutdownCallback(std::function<void()> shutdownCallback);\n\n\n\n void StartThread();\n\n void StopThread();\n\n bool IsThreadRunning();\n\n\n\n void StartRender();\n\n void StopRender();\n\n bool IsStopRequested();\n\n bool IsRendering();\n\n\n\n void PauseRender();\n\n void ResumeRender();\n", "file_path": "pxr/imaging/plugin/hdRpr/renderThread.h", "rank": 95, "score": 106995.1781449277 }, { "content": "class HdRprRenderParam;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/renderPass.h", "rank": 96, "score": 106995.1781449277 }, { "content": "class HdRprDiagnosticMgrDelegate;\n", "file_path": "pxr/imaging/plugin/hdRpr/renderDelegate.h", "rank": 97, "score": 105583.10182277985 }, { "content": "class HdSceneDelegate;\n\n\n", "file_path": "pxr/imaging/plugin/hdRpr/instancer.h", "rank": 98, "score": 105045.63110550544 }, { "content": "class MaterialAdapter {\n\npublic:\n\n MaterialAdapter(EMaterialType type, const MaterialParams& params);\n\n\n\n MaterialAdapter(EMaterialType type, const HdMaterialNetwork& materialNetwork);\n\n\n\n EMaterialType GetType() const {\n\n return m_type;\n\n }\n\n\n\n const MaterialRprParamsVec4f& GetVec4fRprParams() const {\n\n return m_vec4fRprParams;\n\n }\n\n\n\n const MaterialRprParamsU& GetURprParams() const {\n\n return m_uRprParams;\n\n }\n\n\n\n const MaterialRprParamsTexture& GetTexRprParams() const {\n\n return m_texRpr;\n", "file_path": "pxr/imaging/plugin/hdRpr/materialAdapter.h", "rank": 99, "score": 105045.63110550544 } ]
C++
Code/Framework/AzCore/AzCore/Math/TransformSerializer.cpp
aaarsene/o3de
37e3b0226958974defd14dd6d808e8557dcd7345
#include <AzCore/Math/Transform.h> #include <AzCore/Math/TransformSerializer.h> namespace AZ { AZ_CLASS_ALLOCATOR_IMPL(JsonTransformSerializer, AZ::SystemAllocator, 0); JsonSerializationResult::Result JsonTransformSerializer::Load( void* outputValue, [[maybe_unused]] const Uuid& outputValueTypeId, const rapidjson::Value& inputValue, JsonDeserializerContext& context) { namespace JSR = JsonSerializationResult; if (azrtti_typeid<AZ::Transform>() != outputValueTypeId) { return context.Report( JSR::Tasks::ReadField, JSR::Outcomes::Unsupported, "Unable to deserialize Transform from json because the outputValueTypeId isn't a Transform type."); } AZ::Transform* transformInstance = reinterpret_cast<AZ::Transform*>(outputValue); AZ_Assert(transformInstance, "Output value for JsonTransformSerializer can't be null."); if (IsExplicitDefault(inputValue)) { *transformInstance = AZ::Transform::CreateIdentity(); return context.Report(JSR::Tasks::ReadField, JSR::Outcomes::DefaultsUsed, "Transform value set to identity."); } JSR::ResultCode result(JSR::Tasks::ReadField); { AZ::Vector3 translation = transformInstance->GetTranslation(); JSR::ResultCode loadResult = ContinueLoadingFromJsonObjectField( &translation, azrtti_typeid<decltype(translation)>(), inputValue, TranslationTag, context); result.Combine(loadResult); transformInstance->SetTranslation(translation); } { AZ::Quaternion rotation = transformInstance->GetRotation(); JSR::ResultCode loadResult = ContinueLoadingFromJsonObjectField(&rotation, azrtti_typeid<decltype(rotation)>(), inputValue, RotationTag, context); result.Combine(loadResult); transformInstance->SetRotation(rotation); } { float scale = transformInstance->GetUniformScale(); JSR::ResultCode loadResult = ContinueLoadingFromJsonObjectField(&scale, azrtti_typeid<decltype(scale)>(), inputValue, ScaleTag, context); result.Combine(loadResult); transformInstance->SetUniformScale(scale); } return context.Report( result, result.GetProcessing() != JSR::Processing::Halted ? "Successfully loaded Transform information." : "Failed to load Transform information."); } JsonSerializationResult::Result JsonTransformSerializer::Store( rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue, [[maybe_unused]] const Uuid& valueTypeId, JsonSerializerContext& context) { namespace JSR = AZ::JsonSerializationResult; if (azrtti_typeid<AZ::Transform>() != valueTypeId) { return context.Report( JSR::Tasks::WriteValue, JSR::Outcomes::Unsupported, "Unable to Serialize Transform to json because the valueTypeId isn't a Transform type."); } const AZ::Transform* transformInstance = reinterpret_cast<const AZ::Transform*>(inputValue); AZ_Assert(transformInstance, "Input value for JsonTransformSerializer can't be null."); const AZ::Transform* defaultTransformInstance = reinterpret_cast<const AZ::Transform*>(defaultValue); JSR::ResultCode result(JSR::Tasks::WriteValue); { AZ::ScopedContextPath subPathName(context, TranslationTag); const AZ::Vector3 translation = transformInstance->GetTranslation(); const AZ::Vector3 defaultTranslation = defaultTransformInstance ? defaultTransformInstance->GetTranslation() : AZ::Vector3(); JSR::ResultCode storeResult = ContinueStoringToJsonObjectField( outputValue, TranslationTag, &translation, defaultTransformInstance ? &defaultTranslation : nullptr, azrtti_typeid<decltype(translation)>(), context); result.Combine(storeResult); } { AZ::ScopedContextPath subPathName(context, RotationTag); const AZ::Quaternion rotation = transformInstance->GetRotation(); const AZ::Quaternion defaultRotation = defaultTransformInstance ? defaultTransformInstance->GetRotation() : AZ::Quaternion(); JSR::ResultCode storeResult = ContinueStoringToJsonObjectField( outputValue, RotationTag, &rotation, defaultTransformInstance ? &defaultRotation : nullptr, azrtti_typeid<decltype(rotation)>(), context); result.Combine(storeResult); } { AZ::ScopedContextPath subPathName(context, ScaleTag); float scale = transformInstance->GetUniformScale(); float defaultScale = defaultTransformInstance ? defaultTransformInstance->GetUniformScale() : 0.0f; JSR::ResultCode storeResult = ContinueStoringToJsonObjectField( outputValue, ScaleTag, &scale, defaultTransformInstance ? &defaultScale : nullptr, azrtti_typeid<decltype(scale)>(), context); result.Combine(storeResult); } return context.Report( result, result.GetProcessing() != JSR::Processing::Halted ? "Successfully stored Transform information." : "Failed to store Transform information."); } auto JsonTransformSerializer::GetOperationsFlags() const -> OperationFlags { return OperationFlags::InitializeNewInstance; } }
#include <AzCore/Math/Transform.h> #include <AzCore/Math/TransformSerializer.h> namespace AZ { AZ_CLASS_ALLOCATOR_IMPL(JsonTransformSerializer, AZ::SystemAllocator, 0);
JsonSerializationResult::Result JsonTransformSerializer::Store( rapidjson::Value& outputValue, const void* inputValue, const void* defaultValue, [[maybe_unused]] const Uuid& valueTypeId, JsonSerializerContext& context) { namespace JSR = AZ::JsonSerializationResult; if (azrtti_typeid<AZ::Transform>() != valueTypeId) { return context.Report( JSR::Tasks::WriteValue, JSR::Outcomes::Unsupported, "Unable to Serialize Transform to json because the valueTypeId isn't a Transform type."); } const AZ::Transform* transformInstance = reinterpret_cast<const AZ::Transform*>(inputValue); AZ_Assert(transformInstance, "Input value for JsonTransformSerializer can't be null."); const AZ::Transform* defaultTransformInstance = reinterpret_cast<const AZ::Transform*>(defaultValue); JSR::ResultCode result(JSR::Tasks::WriteValue); { AZ::ScopedContextPath subPathName(context, TranslationTag); const AZ::Vector3 translation = transformInstance->GetTranslation(); const AZ::Vector3 defaultTranslation = defaultTransformInstance ? defaultTransformInstance->GetTranslation() : AZ::Vector3(); JSR::ResultCode storeResult = ContinueStoringToJsonObjectField( outputValue, TranslationTag, &translation, defaultTransformInstance ? &defaultTranslation : nullptr, azrtti_typeid<decltype(translation)>(), context); result.Combine(storeResult); } { AZ::ScopedContextPath subPathName(context, RotationTag); const AZ::Quaternion rotation = transformInstance->GetRotation(); const AZ::Quaternion defaultRotation = defaultTransformInstance ? defaultTransformInstance->GetRotation() : AZ::Quaternion(); JSR::ResultCode storeResult = ContinueStoringToJsonObjectField( outputValue, RotationTag, &rotation, defaultTransformInstance ? &defaultRotation : nullptr, azrtti_typeid<decltype(rotation)>(), context); result.Combine(storeResult); } { AZ::ScopedContextPath subPathName(context, ScaleTag); float scale = transformInstance->GetUniformScale(); float defaultScale = defaultTransformInstance ? defaultTransformInstance->GetUniformScale() : 0.0f; JSR::ResultCode storeResult = ContinueStoringToJsonObjectField( outputValue, ScaleTag, &scale, defaultTransformInstance ? &defaultScale : nullptr, azrtti_typeid<decltype(scale)>(), context); result.Combine(storeResult); } return context.Report( result, result.GetProcessing() != JSR::Processing::Halted ? "Successfully stored Transform information." : "Failed to store Transform information."); } auto JsonTransformSerializer::GetOperationsFlags() const -> OperationFlags { return OperationFlags::InitializeNewInstance; } }
JsonSerializationResult::Result JsonTransformSerializer::Load( void* outputValue, [[maybe_unused]] const Uuid& outputValueTypeId, const rapidjson::Value& inputValue, JsonDeserializerContext& context) { namespace JSR = JsonSerializationResult; if (azrtti_typeid<AZ::Transform>() != outputValueTypeId) { return context.Report( JSR::Tasks::ReadField, JSR::Outcomes::Unsupported, "Unable to deserialize Transform from json because the outputValueTypeId isn't a Transform type."); } AZ::Transform* transformInstance = reinterpret_cast<AZ::Transform*>(outputValue); AZ_Assert(transformInstance, "Output value for JsonTransformSerializer can't be null."); if (IsExplicitDefault(inputValue)) { *transformInstance = AZ::Transform::CreateIdentity(); return context.Report(JSR::Tasks::ReadField, JSR::Outcomes::DefaultsUsed, "Transform value set to identity."); } JSR::ResultCode result(JSR::Tasks::ReadField); { AZ::Vector3 translation = transformInstance->GetTranslation(); JSR::ResultCode loadResult = ContinueLoadingFromJsonObjectField( &translation, azrtti_typeid<decltype(translation)>(), inputValue, TranslationTag, context); result.Combine(loadResult); transformInstance->SetTranslation(translation); } { AZ::Quaternion rotation = transformInstance->GetRotation(); JSR::ResultCode loadResult = ContinueLoadingFromJsonObjectField(&rotation, azrtti_typeid<decltype(rotation)>(), inputValue, RotationTag, context); result.Combine(loadResult); transformInstance->SetRotation(rotation); } { float scale = transformInstance->GetUniformScale(); JSR::ResultCode loadResult = ContinueLoadingFromJsonObjectField(&scale, azrtti_typeid<decltype(scale)>(), inputValue, ScaleTag, context); result.Combine(loadResult); transformInstance->SetUniformScale(scale); } return context.Report( result, result.GetProcessing() != JSR::Processing::Halted ? "Successfully loaded Transform information." : "Failed to load Transform information."); }
function_block-full_function
[]
C++
widgets/mainwindow.cpp
AxelLeLouedec/Fitts
23ff29373f6e8cd3bdbe8eaf1f60c9c0808cf44b
#include "./widgets/mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_settings(new QSettings("options.ini", QSettings::IniFormat)) { ui->setupUi(this); openHome(); } void MainWindow::onHomeEvent(int val, void *obj) { qDebug() << "[MainWindow] onHomeEvent"; switch(val) { case HOME_GAME_END: openResults((FittsModel *) obj); break; case HOME_OPEN_SETTINGS: openSettings(); break; case HOME_OPEN_RAPPEL: openReminder(); break; case HOME_EXIT_PRGM: qApp->exit(); break; default: break; } } void MainWindow::onSettingsEvent(int val, void *obj) { qDebug() << "[MainWindow] onSettingsEvent"; switch(val) { case SETTINGS_CLOSE: model = (FittsModel*) obj; qDebug() << model->nbCible; openHome(); break; default: break; } } void MainWindow::onReminderEvent(int val, void *obj) { qDebug() << "[MainWindow] onRappelEvent"; switch(val) { case REMINDER_CLOSE: openHome(); break; default: break; } } void MainWindow::onResultsEvent(int val) { qDebug() << "[MainWindow] onResultsEvent"; switch(val) { case RESULTS_RESTART: openHome(); break; case RESULTS_EXIT_PRGM: qApp->exit(); default: break; } } void MainWindow::openHome() { qDebug() << "Opening home"; home = new Home(model); connect(home, SIGNAL(onHomeEvent(int,void*)), this, SLOT(onHomeEvent(int,void*))); this->setCentralWidget(home); } void MainWindow::openResults(FittsModel *model) { qDebug() << "Opening results"; results = new Results(model); connect(results, SIGNAL(onResultsEvent(int)), this, SLOT(onResultsEvent(int))); this->setCentralWidget(results); } void MainWindow::openSettings() { qDebug() << "Opening settings"; settings = new Settings(model); connect(settings, SIGNAL(onSettingsEvent(int,void*)), this, SLOT(onSettingsEvent(int,void*))); this->setCentralWidget(settings); } void MainWindow::openReminder() { qDebug() << "Opening Reminder"; reminder = new Reminder(); connect(reminder, SIGNAL(onReminderEvent(int,void*)), this, SLOT(onReminderEvent(int,void*))); this->setCentralWidget(reminder); } MainWindow::~MainWindow() { delete ui; } void MainWindow::changeEvent(QEvent* event) { if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } QMainWindow::changeEvent(event); } void MainWindow::on_actionFran_ais_triggered() { m_settings->setValue("Language",1); updateLanguage(m_settings, &translator); } void MainWindow::on_actionEnglish_triggered() { m_settings->setValue("Language",2); updateLanguage(m_settings, &translator); } void MainWindow::on_actionQuitter_triggered() { qApp->exit(); }
#include "./widgets/mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_settings(new QSettings("options.ini", QSettings::IniFormat)) { ui->setupUi(this); openHome(); } void MainWindow::onHomeEvent(int val, void *obj) { qDebug() << "[MainWindow] onHomeEvent"; switch(val) { case HOME_GAME_END: openResults((FittsModel *) obj); break; case HOME_OPEN_SETTINGS: openSettings(); break; case HOME_OPEN_RAPPEL: openReminder(); break; case HOME_EXIT_PRGM: qApp->exit(); break; default: break; } } void MainWindow::onSettingsEvent(int val, void *obj) { qDebug() << "[MainWindow] onSettingsEvent"; switch(val) { case SETTINGS_CLOSE: model = (FittsModel*) obj; qDebug() << model->nbCible; openHome(); break; default: break; } } void MainWindow::onReminderEvent(int val, void *obj) { qDebug() << "[MainWindow] onRappelEvent"; switch(val) { case REMINDER_CLOSE: openHome(); break; default: break; } } void MainWindow::onResultsEvent(int val) { qDebug() << "[MainWindow] onResultsEv
void MainWindow::openHome() { qDebug() << "Opening home"; home = new Home(model); connect(home, SIGNAL(onHomeEvent(int,void*)), this, SLOT(onHomeEvent(int,void*))); this->setCentralWidget(home); } void MainWindow::openResults(FittsModel *model) { qDebug() << "Opening results"; results = new Results(model); connect(results, SIGNAL(onResultsEvent(int)), this, SLOT(onResultsEvent(int))); this->setCentralWidget(results); } void MainWindow::openSettings() { qDebug() << "Opening settings"; settings = new Settings(model); connect(settings, SIGNAL(onSettingsEvent(int,void*)), this, SLOT(onSettingsEvent(int,void*))); this->setCentralWidget(settings); } void MainWindow::openReminder() { qDebug() << "Opening Reminder"; reminder = new Reminder(); connect(reminder, SIGNAL(onReminderEvent(int,void*)), this, SLOT(onReminderEvent(int,void*))); this->setCentralWidget(reminder); } MainWindow::~MainWindow() { delete ui; } void MainWindow::changeEvent(QEvent* event) { if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } QMainWindow::changeEvent(event); } void MainWindow::on_actionFran_ais_triggered() { m_settings->setValue("Language",1); updateLanguage(m_settings, &translator); } void MainWindow::on_actionEnglish_triggered() { m_settings->setValue("Language",2); updateLanguage(m_settings, &translator); } void MainWindow::on_actionQuitter_triggered() { qApp->exit(); }
ent"; switch(val) { case RESULTS_RESTART: openHome(); break; case RESULTS_EXIT_PRGM: qApp->exit(); default: break; } }
function_block-function_prefixed
[ { "content": "class FittsModel\n\n{\n\npublic:\n\n FittsModel();\n\n\n\n int cibleLeft = 10;\n\n int nbCible = 10;\n\n int minSize = 10;\n\n int maxSize = 150;\n\n\n\n double a = 0.20;\n\n double b = 0.10;\n\n\n\n double ecartType = 0;\n\n double erreurType = 0;\n\n double diffMoy = 0;\n\n double itc95 = 0;\n\n\n\n QList<QPoint> clickPoints;\n\n QList<QPoint> cercleCenter;\n\n QList<int> cercleSize;\n\n QList<qint64> times;\n\n};\n\n\n\n#endif // FITTSMODEL_H\n", "file_path": "models/fittsmodel.h", "rank": 0, "score": 71768.30491137585 }, { "content": "#ifndef FITTSMODEL_H\n\n#define FITTSMODEL_H\n\n\n\n#include <QPoint>\n\n#include <QList>\n\n\n\n\n", "file_path": "models/fittsmodel.h", "rank": 1, "score": 53004.414192398595 }, { "content": "#include \"fittsmodel.h\"\n\n\n\nFittsModel::FittsModel() {}\n\n\n", "file_path": "models/fittsmodel.cpp", "rank": 2, "score": 49897.213618595655 }, { "content": "class MainWindow : public QMainWindow\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n MainWindow(QWidget *parent = nullptr);\n\n ~MainWindow();\n\n\n\nprivate slots:\n\n void on_actionEnglish_triggered();\n\n void on_actionFran_ais_triggered();\n\n void on_actionQuitter_triggered();\n\n void onHomeEvent(int, void *);\n\n void onSettingsEvent(int, void *);\n\n void onReminderEvent(int, void *);\n\n void onResultsEvent(int);\n\n void changeEvent(QEvent* event);\n\n\n\nprivate:\n\n void openSettings();\n", "file_path": "widgets/mainwindow.h", "rank": 3, "score": 32628.227780048706 }, { "content": " void openReminder();\n\n void openHome();\n\n void openResults(FittsModel *model);\n\n Ui::MainWindow *ui;\n\n QSettings* m_settings;\n\n QTranslator translator;\n\n\n\n Home *home = NULL;\n\n Settings *settings = NULL;\n\n Reminder *reminder = NULL;\n\n Results *results = NULL;\n\n\n\n FittsModel *model = NULL;\n\n};\n\n#endif // MAINWINDOW_H\n", "file_path": "widgets/mainwindow.h", "rank": 4, "score": 25828.517788609985 }, { "content": "#ifndef MAINWINDOW_H\n\n#define MAINWINDOW_H\n\n\n\n#include <QMainWindow>\n\n#include <QDebug>\n\n#include <QTranslator>\n\n#include <QSettings>\n\n#include \"./widgets/home.h\"\n\n#include \"./widgets/settings.h\"\n\n#include \"./widgets/results.h\"\n\n#include \"ui_mainwindow.h\"\n\n#include \"utils.h\"\n\n#include \"reminder.h\"\n\n#include \"constants.h\"\n\n\n\nQT_BEGIN_NAMESPACE\n\nnamespace Ui { class MainWindow; }\n\nQT_END_NAMESPACE\n\n\n", "file_path": "widgets/mainwindow.h", "rank": 5, "score": 25827.797352352947 }, { "content": "const static int HOME_EXIT_PRGM = 0x4;\n", "file_path": "constants.h", "rank": 13, "score": 21030.108522504055 }, { "content": "const static int HOME_GAME_END = 0x1;\n", "file_path": "constants.h", "rank": 14, "score": 21030.108522504055 }, { "content": "const static int HOME_OPEN_RAPPEL = 0x3;\n", "file_path": "constants.h", "rank": 15, "score": 21030.108522504055 }, { "content": "#include \"reminder.h\"\n\n#include \"ui_reminder.h\"\n\n\n\nReminder::Reminder(FittsModel *model, QWidget *parent) :\n\n QWidget(parent),\n\n ui(new Ui::Reminder)\n\n{\n\n ui->setupUi(this);\n\n\n\n ui->retranslateUi(this);\n\n}\n\n\n\nReminder::~Reminder()\n\n{\n\n delete ui;\n\n}\n\n\n\n\n\nvoid Reminder::on_RetourButton_clicked()\n\n{\n", "file_path": "widgets/reminder.cpp", "rank": 16, "score": 8.392145004607826 }, { "content": "#include \"settings.h\"\n\n#include \"ui_settings.h\"\n\n\n\nSettings::Settings(FittsModel *model, QWidget *parent) :\n\n QWidget(parent),\n\n ui(new Ui::Settings)\n\n{\n\n ui->setupUi(this);\n\n\n\n if(model == NULL)\n\n fittsModel = new FittsModel();\n\n else\n\n fittsModel = model;\n\n\n\n setupData();\n\n}\n\n\n\nSettings::~Settings()\n\n{\n\n delete ui;\n", "file_path": "widgets/settings.cpp", "rank": 17, "score": 7.303084353531045 }, { "content": "#include \"home.h\"\n\n#include \"ui_home.h\"\n\n\n\nHome::Home(FittsModel *model, QWidget *parent) :\n\n QWidget(parent),\n\n ui(new Ui::Home)\n\n{\n\n // On met en place l'UI avec le fichier généré à partir de mainwindows.ui\n\n ui->setupUi(this);\n\n\n\n // On ajoute nous même le graphique CAR il ne peut pas être ajouter depuis l'éditeur\n\n graphicView = new GraphicWidget(model);\n\n connect(graphicView, SIGNAL(onFinish(FittsModel*)), this, SLOT(onGraphFinish(FittsModel*)));\n\n ui->homeContainer->addWidget(graphicView);\n\n}\n\n\n\nHome::~Home()\n\n{\n\n delete ui;\n\n}\n", "file_path": "widgets/home.cpp", "rank": 18, "score": 7.1272556150714035 }, { "content": "#include \"utils.h\"\n\n\n\n\n\n// Cette fonction retourne le chemin du fichier langage\n\nQString getLangue(int i) {\n\n switch (i) {\n\n case 1: // FR\n\n return \":/translation/Fitts_fr_FR.qm\";\n\n break;\n\n case 2: // EN\n\n return \":/translation/Fitts_en_EN.qm\";\n\n default:\n\n return NULL;\n\n }\n\n}\n\n\n\n// Cette fonction permet d'installer un fichier langage\n\nvoid setupLanguage(QApplication* app, QTranslator *translator)\n\n{\n\n QSettings *m_settings;\n", "file_path": "utils.cpp", "rank": 19, "score": 6.578945374896595 }, { "content": "#include \"results.h\"\n\n#include \"ui_results.h\"\n\n\n\n\n\nResults::Results(FittsModel *model, QWidget *parent) :\n\n QWidget(parent),\n\n ui(new Ui::Results)\n\n{\n\n ui->setupUi(this);\n\n\n\n //container\n\n // TabWidget\n\n QTabWidget *tab = new QTabWidget();\n\n\n\n tab->addTab(createQChartView(buildGraph_1(model)), \"Graphique 1\");\n\n tab->addTab(createQChartView(buildGraph_2(model)), \"Graphique 2\");\n\n\n\n ui->container->addWidget(tab);\n\n}\n\n\n", "file_path": "widgets/results.cpp", "rank": 20, "score": 6.225983275971117 }, { "content": "\n\n// Cette fonction est un callback du widget graphwidget\n\nvoid Home::onGraphFinish(FittsModel* val) {\n\n qDebug() << \"onGraphFinish\";\n\n emit onHomeEvent(HOME_GAME_END, (void *) val);\n\n}\n\n\n\n// Simple listener du bouton\n\nvoid Home::on_home_settings_btn_clicked()\n\n{\n\n emit onHomeEvent(HOME_OPEN_SETTINGS,NULL);\n\n}\n\n\n\nvoid Home::on_home_rappel_btn_clicked()\n\n{\n\n emit onHomeEvent(HOME_OPEN_RAPPEL,NULL);\n\n}\n\n\n\nvoid Home::on_Exit_clicked()\n\n{\n", "file_path": "widgets/home.cpp", "rank": 21, "score": 5.766702187990079 }, { "content": " ui->edit_target_count->setValue(fittsModel->nbCible);\n\n ui->edit_min_target->setValue(fittsModel->minSize);\n\n ui->edit_max_target->setValue(fittsModel->maxSize);\n\n}\n\n\n\nvoid Settings::on_restore_default_clicked()\n\n{\n\n fittsModel = new FittsModel();\n\n setupData();\n\n}\n\n\n\nvoid Settings::changeEvent(QEvent* event)\n\n{\n\n if (event->type() == QEvent::LanguageChange)\n\n // retranslate designer form (single inheritance approach)\n\n ui->retranslateUi(this);\n\n}\n", "file_path": "widgets/settings.cpp", "rank": 22, "score": 5.570786449209038 }, { "content": "#ifndef SETTINGS_H\n\n#define SETTINGS_H\n\n\n\n#include <QWidget>\n\n#include \"constants.h\"\n\n#include \"./models/fittsmodel.h\"\n\n\n\nnamespace Ui {\n", "file_path": "widgets/settings.h", "rank": 23, "score": 4.770937540434264 }, { "content": "#ifndef REMINDER_H\n\n#define REMINDER_H\n\n\n\n#include <QWidget>\n\n#include \"constants.h\"\n\n#include \"./models/fittsmodel.h\"\n\n\n\nnamespace Ui {\n", "file_path": "widgets/reminder.h", "rank": 24, "score": 4.770937540434264 }, { "content": "#ifndef HOME_H\n\n#define HOME_H\n\n\n\n#include <QWidget>\n\n#include <QVBoxLayout>\n\n#include <QStackedLayout>\n\n#include <QLabel>\n\n\n\n#include \"./models/fittsmodel.h\"\n\n#include \"graphicwidget.h\"\n\n#include \"constants.h\"\n\n\n\nnamespace Ui {\n", "file_path": "widgets/home.h", "rank": 25, "score": 4.707932518774388 }, { "content": "#ifndef GRAPHICWIDGET_H\n\n#define GRAPHICWIDGET_H\n\n\n\n#include <QGraphicsView>\n\n#include <QMouseEvent>\n\n#include <QGraphicsView>\n\n#include <QDebug>\n\n#include <QElapsedTimer>\n\n#include <math.h>\n\n#include <QLayout>\n\n#include <QRandomGenerator>\n\n\n\n#include \"./models/fittsmodel.h\"\n\n\n", "file_path": "widgets/graphicwidget.h", "rank": 26, "score": 4.603514284463761 }, { "content": "#include \"./widgets/mainwindow.h\"\n\n#include \"utils.h\"\n\n\n\n#include <QApplication>\n\n#include <QTranslator>\n\n#include <QInputDialog>\n\n\n\nQTranslator translator;\n\n\n\nint main(int argc, char *argv[])\n\n{\n\n QApplication a(argc, argv);\n\n\n\n QCoreApplication::setOrganizationName(\"HM40\");\n\n QCoreApplication::setApplicationName(\"Fitts\");\n\n\n\n // On met en place le langage enregistré.\n\n setupLanguage(&a, &translator);\n\n\n\n MainWindow w;\n\n w.show();\n\n\n\n return a.exec();\n\n}\n\n\n\n\n\n\n", "file_path": "main.cpp", "rank": 27, "score": 4.229859905107379 }, { "content": "}\n\n\n\n\n\nvoid Settings::on_validate_btn_clicked()\n\n{\n\n //TODO: put some constraint ? => limit a to some values etc..\n\n fittsModel->a = ui->edit_a->value();\n\n fittsModel->b = ui->edit_b->value();\n\n\n\n fittsModel->nbCible = ui->edit_target_count->value();\n\n fittsModel->minSize = ui->edit_min_target->value(); // TODO: checking min < max STRICT\n\n fittsModel->maxSize = ui->edit_max_target->value();\n\n\n\n emit onSettingsEvent(SETTINGS_CLOSE, fittsModel);\n\n}\n\n\n\nvoid Settings::setupData() {\n\n ui->edit_a->setValue(fittsModel->a);\n\n ui->edit_b->setValue(fittsModel->b);\n\n\n", "file_path": "widgets/settings.cpp", "rank": 28, "score": 4.143376111902131 }, { "content": "#include \"graphicwidget.h\"\n\n\n\n/*\n\nCette classe contient de nombreuse fonction\n\nqui n'ont pas été créer par les auteurs du programme\n\nelles ont été reprise à partir du programme initial à\n\nmodifier\n\n*/\n\n\n\nGraphicWidget::GraphicWidget(FittsModel *model) {\n\n if(model == NULL)\n\n fittsModel = new FittsModel();\n\n else\n\n fittsModel = model;\n\n\n\n qDebug() << fittsModel->nbCible;\n\n\n\n // On met en place le widget\n\n setup();\n\n\n", "file_path": "widgets/graphicwidget.cpp", "rank": 29, "score": 4.02737842573408 }, { "content": "}\n\n\n\nvoid GraphicWidget::initGame() {\n\n\n\n scene()->clear();\n\n\n\n this->fittsModel->times.clear();\n\n\n\n this->fittsModel->cibleLeft = this->fittsModel->nbCible;\n\n\n\n if(this->fittsModel->maxSize >= this->width() / 2)\n\n this->fittsModel->maxSize = this->width() / 2;\n\n\n\n if(this->fittsModel->maxSize >= this->height() / 2)\n\n this->fittsModel->maxSize = this->height() / 2;\n\n\n\n qreal posX = scene()->width() / 2;\n\n qreal posY = scene()->height() / 2;\n\n int size = 100;\n\n\n", "file_path": "widgets/graphicwidget.cpp", "rank": 30, "score": 3.9335618686045852 }, { "content": " this->fittsModel->times.append(timer->elapsed());\n\n // On restart le chrono\n\n timer->restart();\n\n\n\n // On stock la position du click\n\n this->fittsModel->clickPoints.append(QPoint(x,y));\n\n this->nextCible();\n\n }\n\n }\n\n}\n\n\n\nvoid GraphicWidget::nextCible() {\n\n if(!this->fittsModel->cercleCenter.isEmpty())\n\n this->fittsModel->cibleLeft--;\n\n //this->fittsView->updateTestMsg(); TODO:\n\n\n\n scene()->clear();\n\n\n\n // On stop si c'est finis\n\n if(this->fittsModel->cibleLeft == 0) {\n", "file_path": "widgets/graphicwidget.cpp", "rank": 31, "score": 3.6909998348018265 }, { "content": " QChart *chart = new QChart;\n\n\n\n chart->setTitle(\"Temps d'exécution en fonction de la distance relative\");\n\n chart->setAnimationOptions(QChart::AllAnimations);\n\n chart->createDefaultAxes();\n\n chart->legend()->setVisible(true);\n\n chart->legend()->setAlignment(Qt::AlignBottom);\n\n\n\n QLineSeries *fittsSeries = new QLineSeries;\n\n fittsSeries->setName(\"Courbe théorique\");\n\n QCategoryAxis *axis = new QCategoryAxis;\n\n\n\n QList<double> fittsValues;\n\n\n\n for(int i = 0; i < fittsModel->nbCible; ++i) {\n\n // Calculé la valeur théorique\n\n double D = sqrt(pow(fittsModel->clickPoints[i].x() - fittsModel->cercleCenter[i].x(),2) + pow(fittsModel->clickPoints[i].y() - fittsModel->cercleCenter[i].y(),2));\n\n // On multiplie par 1000 pour être en ms\n\n double value = log2((((2*D) / fittsModel->cercleSize[i]) + 1));\n\n fittsValues.append(value);\n", "file_path": "utils.cpp", "rank": 32, "score": 3.0994383162146217 }, { "content": "#ifndef RESULTS_H\n\n#define RESULTS_H\n\n\n\n#include <QWidget>\n\n#include <QChart>\n\n#include <QChartView>\n\n#include <QVBoxLayout>\n\n\n\n#include \"utils.h\"\n\n#include \"constants.h\"\n\n\n\nQT_CHARTS_USE_NAMESPACE\n\n\n\nnamespace Ui {\n", "file_path": "widgets/results.h", "rank": 33, "score": 3.0415166454211264 }, { "content": " scene()->addEllipse(posX - (size / 2), posY - (size / 2), size, size, QPen(QColor(\"blue\")),QBrush(QColor(\"blue\")));\n\n}\n\n\n\n\n\nvoid GraphicWidget::cibleClicked(int x, int y) {\n\n if(this->fittsModel->cercleCenter.isEmpty()) {\n\n qDebug() << \"premier click\";\n\n // Si vide alors premier click, on demarre le timer TODO: fix that\n\n this->timer = new QElapsedTimer;\n\n timer->start();\n\n\n\n // On démarre avec la première cible\n\n this->fittsModel->clickPoints.append(QPoint(x,y));\n\n this->nextCible();\n\n }\n\n else {\n\n qDebug() << \"click\";\n\n QPointF coords = this->mapToScene(x,y);\n\n if(sqrt(pow(coords.x() - this->fittsModel->cercleCenter.last().x(),2) + pow(coords.y() - this->fittsModel->cercleCenter.last().y(),2)) <= this->fittsModel->cercleSize.last() / 2) {\n\n // On stock le temps de click\n", "file_path": "widgets/graphicwidget.cpp", "rank": 34, "score": 3.018389831173111 }, { "content": " app->installTranslator(translator);\n\n}\n\n\n\n// Cette fonction permet d'actualisé un langage\n\nvoid updateLanguage(QSettings *settings, QTranslator *translator) {\n\n\n\n QString lang = getLangue(settings->value(\"Language\").toInt());\n\n if(lang == NULL)\n\n return;\n\n\n\n QApplication::instance()->removeTranslator(translator);\n\n if (translator->load(lang)) {\n\n qDebug() << \"LOAD FINISHED\";\n\n QApplication::instance()->installTranslator(translator);\n\n } else {\n\n qDebug() << \"COULD NOT INSTALL TRANSLATIONS \";\n\n }\n\n}\n\n\n\nQChart *buildGraph_2(FittsModel *fittsModel) {\n", "file_path": "utils.cpp", "rank": 35, "score": 2.990958979556553 }, { "content": " //qDebug() << posY;\n\n\n\n // On stock les infos sur le cercle\n\n this->fittsModel->cercleCenter.append(QPoint(int(posX),int(posY)));\n\n this->fittsModel->cercleSize.append(size);\n\n\n\n // On place le cercle\n\n scene()->addEllipse(posX - (size / 2), posY - (size / 2), size, size, QPen(QColor(\"red\")),QBrush(QColor(\"red\")));\n\n}\n\n\n\nvoid GraphicWidget::finish() {\n\n\n\n qDebug() << \"Program finish\";\n\n emit onFinish(fittsModel);\n\n //this->fittsView->graphicView->setEnabled(false);\n\n //this->fittsView->resultBtn->setEnabled(true);\n\n}\n\n\n", "file_path": "widgets/graphicwidget.cpp", "rank": 36, "score": 2.9618140299754847 }, { "content": "\n\n\n\nQChart *buildGraph_1(FittsModel *fittsModel) {\n\n\n\n QChart *chart = new QChart;\n\n\n\n chart->setTitle(\"Résultats loi Fitts\");\n\n chart->setAnimationOptions(QChart::AllAnimations);\n\n chart->createDefaultAxes();\n\n chart->legend()->setVisible(true);\n\n chart->legend()->setAlignment(Qt::AlignBottom);\n\n\n\n QLineSeries *expSeries = new QLineSeries;\n\n expSeries->setName(\"Courbe expérimentale\");\n\n QLineSeries *fittsSeries = new QLineSeries;\n\n fittsSeries->setName(\"Courbe théorique\");\n\n QCategoryAxis *axis = new QCategoryAxis;\n\n\n\n QList<double> fittsValues;\n\n\n", "file_path": "utils.cpp", "rank": 37, "score": 2.6860054127676642 }, { "content": " m_settings = new QSettings(\"options.ini\", QSettings::IniFormat);\n\n\n\n QString val = getLangue(m_settings->value(\"Language\").toInt());\n\n if(val == NULL) {\n\n QStringList languages;\n\n languages << \"English\" << \"French\";\n\n QString lang = QInputDialog::getItem(NULL,\"Select language\",\n\n \"Language\", languages);\n\n\n\n if(lang == \"English\") {\n\n m_settings->setValue(\"Language\", 2);\n\n }\n\n else {\n\n m_settings->setValue(\"Language\", 1);\n\n }\n\n setupLanguage(app, translator);\n\n return;\n\n }\n\n\n\n translator->load(val);\n", "file_path": "utils.cpp", "rank": 38, "score": 2.4839182928903702 }, { "content": " for(int i = 0; i < fittsModel->nbCible; ++i) {\n\n double T = fittsModel->times[i];\n\n expSeries->append(i,T);\n\n\n\n\n\n // Calculé la valeur théorique\n\n double D = sqrt(pow(fittsModel->clickPoints[i].x() - fittsModel->cercleCenter[i].x(),2) + pow(fittsModel->clickPoints[i].y() - fittsModel->cercleCenter[i].y(),2));\n\n // On multiplie par 1000 pour être en ms\n\n double value = (fittsModel->a * 1000) + ((fittsModel->b * 1000) * log2((D / fittsModel->cercleSize[i]) + 1));\n\n fittsValues.append(value);\n\n fittsSeries->append(i,value);\n\n\n\n axis->append(QString::number(i + 1) + \"<br />T: \"+QString::number(T)+\"<br />D: \" + QString::number(D),i);\n\n }\n\n\n\n axis->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);\n\n\n\n chart->addSeries(expSeries);\n\n chart->addSeries(fittsSeries);\n\n\n", "file_path": "utils.cpp", "rank": 39, "score": 2.407172623968696 }, { "content": " // On stock la difference de moyenne\n\n fittsModel->diffMoy = fabs(diffMoy);\n\n\n\n\n\n // Ecart type\n\n double variance = 0;\n\n\n\n for (int i = 0; i < fittsValues.size(); ++i) {\n\n variance += pow(diffValues[i] - diffMoy,2);\n\n }\n\n variance /= fittsValues.size();\n\n\n\n double ecartType = sqrt(variance);\n\n\n\n // On stock l'ecart type\n\n fittsModel->ecartType = ecartType;\n\n // On stock l'erreur type\n\n fittsModel->erreurType = fabs(ecartType / sqrt(fittsValues.size()));\n\n\n\n // On stock itc 95%\n\n fittsModel->itc95 = 2 * fittsModel->erreurType;\n\n\n\n return chart;\n\n}\n", "file_path": "utils.cpp", "rank": 40, "score": 2.2983829147897414 }, { "content": "}\n\n\n\nvoid Results::on_exit_clicked()\n\n{\n\n emit onResultsEvent(RESULTS_EXIT_PRGM);\n\n}\n\n\n\nvoid Results::changeEvent(QEvent* event)\n\n{\n\n if (event->type() == QEvent::LanguageChange)\n\n // retranslate designer form (single inheritance approach)\n\n ui->retranslateUi(this);\n\n}\n", "file_path": "widgets/results.cpp", "rank": 41, "score": 2.228797645900633 }, { "content": " emit onReminderEvent(REMINDER_CLOSE, NULL);\n\n}\n\n\n\nvoid Reminder::changeEvent(QEvent* event)\n\n{\n\n if (event->type() == QEvent::LanguageChange)\n\n // retranslate designer form (single inheritance approach)\n\n ui->retranslateUi(this);\n\n}\n", "file_path": "widgets/reminder.cpp", "rank": 42, "score": 1.762478827870673 }, { "content": " emit onHomeEvent(HOME_EXIT_PRGM,NULL);\n\n}\n\n\n\nvoid Home::changeEvent(QEvent* event)\n\n{\n\n if (event->type() == QEvent::LanguageChange)\n\n // retranslate designer form (single inheritance approach)\n\n ui->retranslateUi(this);\n\n}\n", "file_path": "widgets/home.cpp", "rank": 43, "score": 1.7420446936568557 }, { "content": " this->setMinimumSize(this->width(), this->height());\n\n\n\n // On lance le jeu\n\n initGame();\n\n}\n\n\n\n\n\n// Click listener\n\nvoid GraphicWidget::mousePressEvent(QMouseEvent *event) {\n\n cibleClicked(event->x(), event->y());\n\n}\n\n\n\nvoid GraphicWidget::setup() {\n\n this->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff);\n\n this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);\n\n\n\n QGraphicsScene *scene = new QGraphicsScene;\n\n this->fitInView(scene->sceneRect(),Qt::KeepAspectRatio);\n\n this->setScene(scene);\n\n scene->setSceneRect(0,0,this->width(),300);\n", "file_path": "widgets/graphicwidget.cpp", "rank": 44, "score": 1.6994217643206335 }, { "content": " chart->setAxisX(axis,expSeries);\n\n chart->setAxisX(axis,fittsSeries);\n\n\n\n QValueAxis *axisY = new QValueAxis;\n\n axisY->setTitleText(\"temps (en ms)\");\n\n chart->setAxisY(axisY,expSeries);\n\n\n\n\n\n\n\n // Calcul des valeurs\n\n // Moyennes\n\n QList<double> diffValues;\n\n double diffMoy = 0;\n\n\n\n for (int i = 0; i < fittsValues.size(); ++i) {\n\n diffValues.append(fabs(fittsValues[i] - fittsModel->times[i]));\n\n diffMoy += fabs(fittsValues[i] - fittsModel->times[i]);\n\n }\n\n diffMoy /= fittsValues.size();\n\n\n", "file_path": "utils.cpp", "rank": 45, "score": 1.5500262045718087 }, { "content": "\n\n\n\nQChartView *Results::createQChartView(QChart *chart) {\n\n QChartView *plot = new QChartView;\n\n\n\n // Using utils function, building the chart\n\n plot->setChart(chart);\n\n plot->setRenderHint(QPainter::Antialiasing);\n\n\n\n return plot;\n\n}\n\n\n\nResults::~Results()\n\n{\n\n delete ui;\n\n}\n\n\n\nvoid Results::on_restart_clicked()\n\n{\n\n emit onResultsEvent(RESULTS_RESTART);\n", "file_path": "widgets/results.cpp", "rank": 46, "score": 1.3880088399971893 }, { "content": " this->finish();\n\n return;\n\n }\n\n\n\n // On génère la taille du cercle rouge\n\n int size = QRandomGenerator::global()->bounded(this->fittsModel->minSize, this->fittsModel->maxSize);\n\n\n\n //qDebug() << \"size \" + QString::number(size);\n\n // Car on veut le rayon\n\n // On place le cercle dans la scene (Attention faut pas qu'il soit en dehors du cadre)\n\n int sceneW = int(scene()->width());\n\n int sceneH = int(scene()->height());\n\n\n\n //qDebug() << \"sceneW \" + QString::number(sceneW);\n\n //qDebug() << \"sceneW \" + QString::number(sceneH);\n\n\n\n int posX = QRandomGenerator::global()->bounded(sceneW);\n\n int posY = QRandomGenerator::global()->bounded(sceneH);\n\n\n\n //qDebug() << posX;\n", "file_path": "widgets/graphicwidget.cpp", "rank": 47, "score": 1.3827270440877042 } ]
C++
tests/test_address.cc
wavesplatform/wavespp
9505613e01b19e5a73dfb90e9569323be98a3852
#include <cstring> #include <string> #include <iostream> #include <algorithm> #include "../src/address.hpp" #include "../src/utils.hpp" static constexpr auto PUBLIC_KEY_BIN_LEN = wavespp::public_key::PUBLIC_KEY_BIN_LEN; static int test_address_to_base58() { const std::string base58_address = "3MtBqEtkF8cYkNJv85QUS4wteNj48ZMAnt9"; const std::string bin_address = wavespp::utils::from_base58(base58_address); if (wavespp::utils::to_base58(bin_address) != base58_address) { fprintf(stderr, "wavespp::utils::to_base58/from_base58 results do not match\n"); return 1; } if (bin_address.size() != wavespp::address::ADDRESS_BIN_LEN) { fprintf(stderr, "bin_address.size() = %ld != ADDRESS_BIN_LEN\n", bin_address.size()); return 1; } unsigned char bin_uchar_address[wavespp::address::ADDRESS_BIN_LEN] = {0}; std::copy(bin_address.begin(), bin_address.end(), bin_uchar_address); wavespp::address address(bin_uchar_address); if (address.to_base58() != base58_address) { fprintf(stderr, "wavespp::address::to_base58() != %s\n", base58_address.c_str()); return 1; } return 0; } static int test_address_to_binary() { const char* address_base58 = "3Mv9XDntij4ZRE1XiNZed6J74rncBpiYNDV"; const auto expected_address_binary = wavespp::utils::from_base58(address_base58); wavespp::address address(address_base58); const auto address_binary = address.to_binary(); if (address_binary != expected_address_binary) { fprintf(stderr, "%s: binary address %s != expected_address_binary %s \n", __func__, address_binary.c_str(), expected_address_binary.c_str()); return 1; } return 0; } static int test_address_from_binary() { const char* address_base58 = "3Mv9XDntij4ZRE1XiNZed6J74rncBpiYNDV"; const auto expected_address_binary = wavespp::utils::from_base58(address_base58); const auto address = wavespp::address::FromBinary(expected_address_binary); const auto address_binary = address.to_binary(); if (address_binary != expected_address_binary) { fprintf(stderr, "%s: binary address %s != expected_address_binary %s \n", __func__, address_binary.c_str(), expected_address_binary.c_str()); return 1; } return 0; } static int test_address_from_unsigned_char() { printf("%s\n", __func__); const char* address_base58 = "3ND8YwWJ5XHhYNbLcWv9uZEqVboSU8iyMgu"; const auto expected_address_binary = wavespp::utils::from_base58(address_base58); const std::string input_public_key_str = "Do24gp5eC4HrN6XQkYh7FicnbHH3q7nEMnSUfn9Gundu"; const std::string input_public_key = wavespp::utils::from_base58(input_public_key_str); const unsigned char chain_id = 'T'; const unsigned char (&public_key)[PUBLIC_KEY_BIN_LEN] = reinterpret_cast<const unsigned char (&)[PUBLIC_KEY_BIN_LEN]>( *input_public_key.c_str()); wavespp::public_key sender_public_key(public_key); wavespp::address address(sender_public_key, chain_id); const auto address_binary = address.to_binary(); if (address_binary != expected_address_binary) { fprintf(stderr, "%s: binary address %s != expected_address_binary %s \n", __func__, address_binary.c_str(), expected_address_binary.c_str()); return 1; } printf("%s: address_binary: %s\n", __func__, wavespp::utils::to_base58(address_binary).c_str()); return 0; } int main(int argc, char const* argv[]) { int res = 0; do { if ((res = test_address_to_base58())) break; if ((res = test_address_to_binary())) break; if ((res = test_address_from_binary())) break; if ((res = test_address_from_unsigned_char())) break; } while (false); return res; }
#include <cstring> #include <string> #include <iostream> #include <algorithm> #include "../src/address.hpp" #include "../src/utils.hpp" static constexpr auto PUBLIC_KEY_BIN_LEN = wavespp::public_key::PUBLIC_KEY_BIN_LEN; static int test_address_to_base58() { const std::string base58_address = "3MtBqEtkF8cYkNJv85QUS4wteNj48ZMAnt9"; const std::string bin_address = wavespp::utils::from_base58(base58_address); if (wavespp::utils::to_base58(bin_address) != base58_address) { fprintf(stderr, "wavespp::utils::to_base58/from_base58 results do not match\n"); return 1; } if (bin_address.size() != wavespp::address::ADDRESS_BIN_LEN) { fprintf(stderr, "bin_address.size() = %ld != ADDRESS_BIN_LEN\n", bin_address.size()); return 1; } unsigned char bin_uchar_address[wavespp::address::ADDRESS_BIN_LEN] = {0}; std::copy(bin_address.begin(), bin_address.end(), bin_uchar_address); wavespp::address address(bin_uchar_address); if (address.to_base58() != base58_address) { fprintf(stderr, "wavespp::address::to_base58() != %s\n", base58_address.c_str()); return 1; } return 0; } static int test_address_to_binary() { const char* address_base58 = "3Mv9XDntij4ZRE1XiNZed6J74rncBpiYNDV"; const auto expected_address_binary = wavespp::utils::from_base58(address_base58); wavespp::address address(address_base58); const auto address_binary = address.to_binary(); if (address_binary != expected_address_binary) { fprintf(stderr, "%s: binary address %s != expected_address_binary %s \n", __func__, address_binary.c_str(), expected_address_binary.c_str()); return 1; } return 0; } static int test_address_from_binary() { const char* address_base58 = "3Mv9XDntij4ZRE1XiNZed6J74rncBpiYNDV"; const auto expected_address_binary = wavespp::utils::from_base58(address_base58); const auto address = wavespp::address::FromBinary(expected_address_binary); const auto address_binary = address.to_binary();
return 0; } static int test_address_from_unsigned_char() { printf("%s\n", __func__); const char* address_base58 = "3ND8YwWJ5XHhYNbLcWv9uZEqVboSU8iyMgu"; const auto expected_address_binary = wavespp::utils::from_base58(address_base58); const std::string input_public_key_str = "Do24gp5eC4HrN6XQkYh7FicnbHH3q7nEMnSUfn9Gundu"; const std::string input_public_key = wavespp::utils::from_base58(input_public_key_str); const unsigned char chain_id = 'T'; const unsigned char (&public_key)[PUBLIC_KEY_BIN_LEN] = reinterpret_cast<const unsigned char (&)[PUBLIC_KEY_BIN_LEN]>( *input_public_key.c_str()); wavespp::public_key sender_public_key(public_key); wavespp::address address(sender_public_key, chain_id); const auto address_binary = address.to_binary(); if (address_binary != expected_address_binary) { fprintf(stderr, "%s: binary address %s != expected_address_binary %s \n", __func__, address_binary.c_str(), expected_address_binary.c_str()); return 1; } printf("%s: address_binary: %s\n", __func__, wavespp::utils::to_base58(address_binary).c_str()); return 0; } int main(int argc, char const* argv[]) { int res = 0; do { if ((res = test_address_to_base58())) break; if ((res = test_address_to_binary())) break; if ((res = test_address_from_binary())) break; if ((res = test_address_from_unsigned_char())) break; } while (false); return res; }
if (address_binary != expected_address_binary) { fprintf(stderr, "%s: binary address %s != expected_address_binary %s \n", __func__, address_binary.c_str(), expected_address_binary.c_str()); return 1; }
if_condition
[ { "content": "struct address\n\n{\n\n // Length of an address in Base58 format.\n\n static const size_t ADDRESS_B58_LEN = 36;\n\n // Length of an address in binary format.\n\n static constexpr size_t ADDRESS_BIN_LEN = 26;\n\n\n\n address();\n\n address(const char* _str); // from base58\n\n address(const char* str, size_t len); // from base58\n\n address(const public_key& _pub_k, unsigned char net);\n\n // `binary_address` is a raw (binary) representation of an address.\n\n explicit address(const unsigned char (&binary_address)[ADDRESS_BIN_LEN]);\n\n // Constructs address from its raw (binary) representation.\n\n static address FromBinary(const std::string& binary);\n\n\n\n // Returns the address in Base58 format\n\n std::string to_base58() const;\n\n // Returns raw (binary) representation of the address\n\n std::string to_binary() const;\n", "file_path": "src/address.hpp", "rank": 0, "score": 64488.6342308873 }, { "content": "struct hash<wavespp::address>\n\n{\n\n size_t operator() (const wavespp::address& addr) const\n\n {\n\n return wavespp::utils::hash_bytes(addr._data, sizeof(addr._data));\n\n }\n\n};\n\n\n\ntemplate<>\n", "file_path": "src/address.hpp", "rank": 1, "score": 59329.416235377146 }, { "content": " memcpy(_data, binary_address, ADDRESS_BIN_LEN);\n\n}\n\n\n\naddress address::FromBinary(const std::string& binary)\n\n{\n\n if (binary.size() == ADDRESS_BIN_LEN) {\n\n const unsigned char (&binary_uchar)[ADDRESS_BIN_LEN] =\n\n reinterpret_cast<const unsigned char (&)[ADDRESS_BIN_LEN]>\n\n (*binary.c_str());\n\n return address(binary_uchar);\n\n }\n\n\n\n throw coda_error(\"Binary address length must be equal to %lu, got %lu\",\n\n ADDRESS_BIN_LEN, binary.size());\n\n}\n\n\n\n\n\nbool address::satisfy(const public_key& _pub_k, unsigned char net)\n\n{\n\n return *this == address(_pub_k, net);\n", "file_path": "src/address.cpp", "rank": 2, "score": 33665.7938516334 }, { "content": " if (len > address::ADDRESS_B58_LEN)\n\n {\n\n throw coda_error(\"Address base58 string length is %lu, \"\n\n \"should be no more than %lu\", len, ADDRESS_B58_LEN);\n\n }\n\n memset(_data, 0, sizeof(_data));\n\n ssize_t ret = base58_decode_len(_data, str, len);\n\n if (ret < 0)\n\n {\n\n throw base58_decode_exception(str, -ret+1);\n\n }\n\n}\n\n\n\naddress::address(const public_key& _pub_k, unsigned char net)\n\n{\n\n waves_public_key_to_address(_pub_k._data, net, _data);\n\n}\n\n\n\naddress::address(const unsigned char (&binary_address)[ADDRESS_BIN_LEN])\n\n{\n", "file_path": "src/address.cpp", "rank": 3, "score": 33662.8437351778 }, { "content": "}\n\n\n\nstd::string address::to_binary() const\n\n{\n\n return std::string(reinterpret_cast<const char*>(_data), sizeof _data);\n\n}\n\n\n\nstd::string address::to_base58() const\n\n{\n\n char out_buf[address::ADDRESS_B58_LEN+1];\n\n base58_encode(out_buf, _data, sizeof(_data));\n\n return std::string(out_buf);\n\n}\n\n\n\nsignature::signature()\n\n{\n\n memset(_data, 0, sizeof(_data));\n\n}\n\n\n\nsignature::signature(const char* _str)\n", "file_path": "src/address.cpp", "rank": 4, "score": 33662.15890435404 }, { "content": "#ifndef __WAVESPP_ADDRESS_HPP_18906__\n\n#define __WAVESPP_ADDRESS_HPP_18906__\n\n\n\n#include <cstring>\n\n#include <string>\n\n#include \"coda/error.hpp\"\n\n#include \"utils.hpp\"\n\n\n\nnamespace wavespp {\n\n\n", "file_path": "src/address.hpp", "rank": 5, "score": 33662.13659219585 }, { "content": "}\n\n\n\nstd::string public_key::to_base58() const\n\n{\n\n char out_buf[64];\n\n base58_encode(out_buf, _data, sizeof(_data));\n\n return std::string(out_buf);\n\n}\n\n\n\naddress::address()\n\n{\n\n memset(_data, 0, sizeof(_data));\n\n}\n\n\n\naddress::address(const char* str)\n\n : address(str, strlen(str))\n\n{}\n\n\n\naddress::address(const char* str, size_t len)\n\n{\n", "file_path": "src/address.cpp", "rank": 6, "score": 33659.728296450776 }, { "content": "#include \"address.hpp\"\n\n#include \"waves/crypto.h\"\n\n#include \"waves/b58.h\"\n\n#include <coda/error.hpp>\n\n#include <stdio.h>\n\n\n\nnamespace wavespp {\n\n\n\nbase58_decode_exception::base58_decode_exception(const std::string& str, size_t pos) :\n\n _orig_b58(str),\n\n _error_pos(pos)\n\n{\n\n if (_error_pos < 10)\n\n {\n\n snprintf(_what_buf, 128, \"Base58 parse error at %u: %.*s\", (unsigned)_error_pos, (unsigned)_error_pos, _orig_b58.c_str());\n\n } else\n\n {\n\n snprintf(_what_buf, 128, \"Base58 parse error at %u: %.3s...%.3s\", (unsigned)_error_pos, _orig_b58.c_str(), _orig_b58.c_str() + _error_pos - 3);\n\n }\n\n}\n", "file_path": "src/address.cpp", "rank": 7, "score": 33659.456047206826 }, { "content": "}\n\n\n\npublic_key::public_key(const unsigned char (&binary_public_key)[PUBLIC_KEY_BIN_LEN])\n\n{\n\n memcpy(_data, binary_public_key, PUBLIC_KEY_BIN_LEN);\n\n}\n\n\n\nbool public_key::is_set() const\n\n{\n\n size_t data_len = sizeof(_data);\n\n while (data_len--)\n\n {\n\n if (_data[data_len-1]) return true;\n\n }\n\n return false;\n\n}\n\n\n\nbool public_key::verify_signature(const unsigned char* msg, size_t msg_sz, const unsigned char* _signature) const\n\n{\n\n return waves_verify_message(_data, msg, msg_sz, _signature);\n", "file_path": "src/address.cpp", "rank": 8, "score": 33658.52068838663 }, { "content": "\n\n /**\n\n * Returns user group ID.\n\n *\n\n * User group ID determines which shard serves the users associated with the group ID.\n\n *\n\n * By convention, we build an uint16_t from the 2-nd and the 3-rd bytes of the address.\n\n * @link https://wsn.usrsrc.ru/projects/back/wiki/User_Groups\n\n */\n\n inline uint16_t group_id() const\n\n {\n\n return _data[3] | (_data[2] << 8);\n\n }\n\n\n\n bool satisfy(const public_key& _pub_k, unsigned char net);\n\n\n\n inline bool operator <(const address& other) const\n\n {\n\n return memcmp(_data, other._data, sizeof(_data)) < 0;\n\n }\n", "file_path": "src/address.hpp", "rank": 9, "score": 33658.286969103 }, { "content": "\n\n inline bool operator ==(const address& other) const\n\n {\n\n return memcmp(_data, other._data, sizeof(_data)) == 0;\n\n }\n\n\n\n inline bool operator !=(const address& other) const\n\n {\n\n return memcmp(_data, other._data, sizeof(_data)) != 0;\n\n }\n\n\n\n unsigned char _data[26];\n\n};\n\n\n", "file_path": "src/address.hpp", "rank": 10, "score": 33658.13574927236 }, { "content": " return memcmp(_data, other._data, sizeof(_data)) < 0;\n\n }\n\n\n\n inline bool operator ==(const public_key& other) const\n\n {\n\n return memcmp(_data, other._data, sizeof(_data)) == 0;\n\n }\n\n\n\n inline bool operator !=(const public_key& other) const\n\n {\n\n return memcmp(_data, other._data, sizeof(_data)) != 0;\n\n }\n\n\n\n unsigned char _data[PUBLIC_KEY_BIN_LEN];\n\n};\n\n\n", "file_path": "src/address.hpp", "rank": 11, "score": 33653.999076409236 }, { "content": "\n\nconst std::string& base58_decode_exception::get_orig_b58() const throw()\n\n{\n\n return _orig_b58;\n\n}\n\n\n\nsize_t base58_decode_exception::get_error_pos() const throw()\n\n{\n\n return _error_pos;\n\n}\n\n\n\nconst char* base58_decode_exception::what () const throw()\n\n{\n\n return _what_buf;\n\n}\n\n\n\npublic_key::public_key()\n\n{\n\n memset(_data, 0, sizeof(_data));\n\n}\n", "file_path": "src/address.cpp", "rank": 12, "score": 33653.75977917253 }, { "content": "\n\npublic_key::public_key(const char* _str)\n\n{\n\n size_t b58len = strlen(_str);\n\n if (b58len > public_key::PUBLIC_KEY_B58_LEN)\n\n {\n\n throw coda_error(\"Public key base58 string length is %lu, \"\n\n \"should be no more than %lu\", b58len, public_key::PUBLIC_KEY_B58_LEN);\n\n }\n\n memset(_data, 0, sizeof(_data));\n\n ssize_t ret = base58_decode(_data, _str);\n\n if (ret < 0)\n\n {\n\n throw base58_decode_exception(_str, -ret+1);\n\n }\n\n}\n\n\n\npublic_key::public_key(const public_key& _pub_k)\n\n{\n\n memcpy(_data, _pub_k._data, sizeof(_data));\n", "file_path": "src/address.cpp", "rank": 13, "score": 33652.76821032413 }, { "content": "{\n\n size_t b58len = strlen(_str);\n\n if (b58len > signature::SIGNATURE_B58_LEN)\n\n {\n\n throw coda_error(\"Signature base58 string length is %lu, \"\n\n \"should be no more than %lu\", b58len, signature::SIGNATURE_B58_LEN);\n\n }\n\n memset(_data, 0, sizeof(_data));\n\n ssize_t ret = base58_decode(_data, _str);\n\n if (ret < 0)\n\n {\n\n throw base58_decode_exception(_str, -ret+1);\n\n }\n\n}\n\n\n\nsignature::signature(const signature& _sig)\n\n{\n\n memcpy(_data, _sig._data, sizeof(_data));\n\n}\n\n\n\n}\n", "file_path": "src/address.cpp", "rank": 14, "score": 33650.76334949155 }, { "content": "struct signature\n\n{\n\n static const size_t SIGNATURE_B58_LEN = 89;\n\n\n\n signature();\n\n signature(const char* _str); // from base58\n\n signature(const signature& _sig);\n\n\n\n unsigned char _data[64];\n\n};\n\n\n\n}\n\n\n\nnamespace std {\n\n\n\ntemplate<>\n", "file_path": "src/address.hpp", "rank": 21, "score": 32345.1125223815 }, { "content": "struct public_key\n\n{\n\n // Length of a public key in Base58 format.\n\n static const size_t PUBLIC_KEY_B58_LEN = 45;\n\n // Length of a public key in binary format.\n\n static constexpr size_t PUBLIC_KEY_BIN_LEN = 32;\n\n\n\n public_key();\n\n public_key(const char* _str); // from base58\n\n public_key(const public_key& _pub_k);\n\n // `binary_public_key` is a raw (binary) representation of a public key.\n\n explicit public_key(const unsigned char (&binary_public_key)[PUBLIC_KEY_BIN_LEN]);\n\n\n\n bool is_set() const; // true if _data != {0,0,0,0...}\n\n\n\n bool verify_signature(const unsigned char* msg, size_t msg_sz, const unsigned char* _signature) const;\n\n std::string to_base58() const;\n\n\n\n inline bool operator <(const public_key& other) const\n\n {\n", "file_path": "src/address.hpp", "rank": 22, "score": 31138.767999402233 }, { "content": "struct hash<wavespp::public_key>\n\n{\n\n size_t operator() (const wavespp::public_key& pk) const\n\n {\n\n return wavespp::utils::hash_bytes(pk._data, sizeof(pk._data));\n\n }\n\n};\n\n\n\n}\n\n\n\n#endif /* __WAVESPP_ADDRESS_HPP_18906__ */\n", "file_path": "src/address.hpp", "rank": 23, "score": 28977.291695756096 }, { "content": "struct base58_decode_exception : std::exception\n\n{\n\n base58_decode_exception(const std::string& str, size_t pos);\n\n const std::string& get_orig_b58() const throw();\n\n size_t get_error_pos() const throw();\n\n const char* what () const throw();\n\n\n\n std::string _orig_b58;\n\n size_t _error_pos;\n\n char _what_buf[128];\n\n};\n\n\n", "file_path": "src/address.hpp", "rank": 24, "score": 28005.307068644775 }, { "content": "#include <cassert>\n\n#include <cstring>\n\n#include <string>\n\n\n\n#include \"../src/utils.hpp\"\n\n#include \"../src/address.hpp\"\n\n#include \"../src/tx/mass_transfer.hpp\"\n\n\n\nusing wavespp::utils::from_base58;\n\nusing wavespp::utils::to_base58;\n\n\n\nconstexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7',\n\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n\n\n// Converts binary string to hex representation\n\nstatic std::string bin2hex(const unsigned char *data, size_t len)/*{{{*/\n\n{\n\n std::string s(len * 2, ' ');\n\n for (size_t i = 0; i < len; ++i) {\n\n s[2 * i] = hexmap[(data[i] & 0xF0) >> 4];\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 25, "score": 21.41818853434254 }, { "content": " memcpy(&address_data[22], hash2, 4);\n\n return address;\n\n}\n\n\n\nsize_t hash_bytes(const unsigned char* data, size_t len)\n\n{\n\n std::hash<unsigned char> hasher;\n\n size_t result = 0;\n\n for(size_t i = 0; i < len; ++i)\n\n {\n\n result = result * 31 + hasher(data[i]);\n\n }\n\n return result;\n\n}\n\n\n\nconstexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7',\n\n '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};\n\n\n\n// Converts binary string to hex representation\n\nstd::string bin2hex(const unsigned char *data, size_t len)\n", "file_path": "src/utils.cpp", "rank": 26, "score": 19.941427875045456 }, { "content": "#include <cstring>\n\n#include <iostream>\n\n\n\n#include \"../src/utils.hpp\"\n\n\n\nint main(int argc, char const* argv[])\n\n{\n\n const char* expected_base58 = \"oT2YHgTvpkeAHLLtXTHdzAxq9iY4kG953J\";\n\n const char* expected_raw = \"some string one two three\";\n\n\n\n const auto res_base58 = wavespp::utils::to_base58(\n\n reinterpret_cast<const unsigned char*>(expected_raw),\n\n std::strlen(expected_raw));\n\n if (res_base58.compare(expected_base58) != 0) {\n\n fprintf(stderr, \"to_base58() returned incorrect result: %s\\n\", res_base58.c_str());\n\n return 1;\n\n }\n\n\n\n const auto res_raw = wavespp::utils::from_base58(res_base58);\n\n if (std::strncmp(res_raw.c_str(), expected_raw, res_raw.size())) {\n\n fprintf(stderr, \"from_base58() returned value different from expected %s\\n\",\n\n expected_raw);\n\n }\n\n\n\n return 0;\n\n}\n", "file_path": "tests/test_base58.cc", "rank": 27, "score": 19.430879007278953 }, { "content": " fprintf(stderr, \"Argument list is expected to be an array\\n\");\n\n return 1;\n\n }\n\n const Json::Value nullValue;\n\n const auto arg0 = root.get(static_cast<unsigned>(0), nullValue).asString();\n\n const auto arg1 = root.get(static_cast<unsigned int>(1), Json::nullValue).asString();\n\n\n\n if (arg0 != expected_arg0) {\n\n fprintf(stderr, \"Wrong arg0 value: %s != %s\\n\", arg0.c_str(), expected_arg0);\n\n return 1;\n\n }\n\n if (arg1 != expected_arg1) {\n\n fprintf(stderr, \"Wrong arg1 value: %s != %s\\n\", arg1.c_str(), expected_arg1);\n\n return 1;\n\n }\n\n\n\n return 0;\n\n}//}}}\n\n\n\nstatic int test_default_func_call_serialization()//{{{\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 28, "score": 14.589469751586957 }, { "content": "{\n\n unsigned char buf[v.size()];\n\n ssize_t sz = base64_decode(buf, v.c_str());\n\n return std::string((char*)buf, sz);\n\n}\n\n\n\nstd::string secure_hash_to_address(const std::string& hash, uint8_t chain_id)\n\n{\n\n std::string address;\n\n address.resize(26);\n\n uint8_t hash2[32];\n\n uint8_t buf[22];\n\n buf[0] = 1;\n\n buf[1] = chain_id;\n\n memcpy(&buf[2], hash.c_str(), 20);\n\n waves_secure_hash(buf, 22, hash2);\n\n auto address_data = (char*)address.c_str();\n\n address_data[0] = 1;\n\n address_data[1] = chain_id;\n\n memcpy(&address_data[2], hash.c_str(), 20);\n", "file_path": "src/utils.cpp", "rank": 29, "score": 14.581828876881762 }, { "content": "#ifndef __WAVESPP_UTILS_HPP_15740__\n\n#define __WAVESPP_UTILS_HPP_15740__\n\n\n\n#include <string>\n\n\n\nnamespace wavespp {\n\nnamespace utils {\n\n\n\nstd::string to_base58(const unsigned char* v, size_t len);\n\nstd::string to_base58(const std::string& v);\n\nstd::string to_base64(const unsigned char* v, size_t len);\n\nstd::string to_base64(const std::string& v);\n\n\n\nstd::string from_base58(const std::string& v);\n\nstd::string from_base64(const std::string& v);\n\n\n\nstd::string secure_hash_to_address(const std::string& hash, uint8_t chain_id);\n\n\n\nsize_t hash_bytes(const unsigned char *data, size_t len);\n\n\n", "file_path": "src/utils.hpp", "rank": 30, "score": 14.375109426230049 }, { "content": "#include \"utils.hpp\"\n\n#include <waves/b58.h>\n\n#include <waves/b64.h>\n\n#include <waves/crypto.h>\n\n\n\nnamespace wavespp {\n\nnamespace utils {\n\n\n\nstd::string to_base58(const unsigned char* v, size_t len)\n\n{\n\n char buf[len * 2 + 1];\n\n base58_encode(buf, v, len);\n\n return std::string(buf);\n\n}\n\n\n\nstd::string to_base64(const unsigned char* v, size_t len)\n\n{\n\n char buf[len * 2 + 1];\n\n base64_encode(buf, v, len);\n\n return std::string(buf);\n", "file_path": "src/utils.cpp", "rank": 31, "score": 13.948480025636268 }, { "content": " s[2 * i + 1] = hexmap[data[i] & 0x0F];\n\n }\n\n return s;\n\n}/*}}}*/\n\n\n\nstatic unsigned char to_nibble (char c) noexcept/*{{{*/\n\n{\n\n if (c >= '0' && c <= '9') return c - '0';\n\n if (c >= 'a' && c <= 'f') return 10 + c - 'a';\n\n if (c >= 'A' && c <= 'F') return 10 + c - 'A';\n\n return 0xFF;\n\n}/*}}}*/\n\n\n\nstatic std::string hex2bin(const char* hex, size_t len) noexcept /*{{{*/\n\n{\n\n std::string res;\n\n res.reserve(len / 2);\n\n if (len & 1) {\n\n return \"\";\n\n }\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 32, "score": 13.295561911200078 }, { "content": "{\n\n std::string s(len * 2, ' ');\n\n for (size_t i = 0; i < len; ++i) {\n\n s[2 * i] = hexmap[(data[i] & 0xF0) >> 4];\n\n s[2 * i + 1] = hexmap[data[i] & 0x0F];\n\n }\n\n return s;\n\n}\n\n\n\nstatic unsigned char to_nibble (char c) noexcept\n\n{\n\n if (c >= '0' && c <= '9') return c - '0';\n\n if (c >= 'a' && c <= 'f') return 10 + c - 'a';\n\n if (c >= 'A' && c <= 'F') return 10 + c - 'A';\n\n return 0xFF;\n\n}\n\n\n\nstd::string hex2bin(const char* hex, size_t len) noexcept\n\n{\n\n std::string res;\n", "file_path": "src/utils.cpp", "rank": 33, "score": 12.57802293893403 }, { "content": " json_args[i] = true;\n\n break;\n\n case TX_FUNC_ARG_STR:\n\n json_args[i] = std::string(arg_entries[i].types.string.data,\n\n arg_entries[i].types.string.len);\n\n break;\n\n case TX_FUNC_ARG_BIN:\n\n json_args[i] = base64_prefix + utils::to_base64(\n\n (unsigned char*)arg_entries[i].types.binary.decoded_data,\n\n arg_entries[i].types.binary.decoded_len\n\n );\n\n break;\n\n default:\n\n assert(false);\n\n break;\n\n }\n\n }\n\n const auto args_json = Json::writeString(json_builder, json_args);\n\n return FunctionCall(func_name, args_json);\n\n}//}}}\n\n\n\n}\n", "file_path": "src/tx/invoke_script.cpp", "rank": 34, "score": 12.083046605802215 }, { "content": " for (size_t i = 0; i < len; i += 2) {\n\n if (!isxdigit(hex[i]) || !isxdigit(hex[i+1])) {\n\n return \"\";\n\n }\n\n res += to_nibble(hex[i]) * 16 + to_nibble(hex[i+1]);\n\n }\n\n return res;\n\n}/*}}}*/\n\n\n\nstatic inline std::string hex2bin(const char* hex) noexcept /*{{{*/\n\n{\n\n return hex2bin(hex, strlen(hex));\n\n}/*}}}*/\n\n\n\nstatic inline std::string hex2bin(const std::string s) noexcept /*{{{*/\n\n{\n\n return hex2bin(s.c_str(), s.size());\n\n}\n\n\n\nstatic int hex_test()\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 35, "score": 12.017999751883112 }, { "content": "#include <cstdio>\n\n#include <cstring>\n\n#include <memory>\n\n#include <sstream>\n\n\n\n#include <jsoncpp/json/json.h>\n\n\n\n#include \"../src/utils.hpp\"\n\n#include \"../src/tx/invoke_script.hpp\"\n\n\n\nusing wavespp::utils::from_base58;\n\nusing wavespp::utils::to_base58;\n\nusing wavespp::utils::hex2bin;\n\nusing wavespp::utils::bin2hex;\n\n\n\nstatic int test_func_call_serialization()//{{{\n\n{\n\n // https://wavesexplorer.com/testnet/tx/6e1tjxaZGRR7RoYGvqvgANvBDCB9mfEcZZj6zyV5tcZg\n\n const char* expected_tx_id = \"6e1tjxaZGRR7RoYGvqvgANvBDCB9mfEcZZj6zyV5tcZg\";\n\n const char* expected_func_name = \"withdraw\";\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 36, "score": 11.750354011949021 }, { "content": "#include <functional>\n\n\n\n#include \"base.hpp\"\n\n#include \"burn.hpp\"\n\n#include \"transfer.hpp\"\n\n\n\n#include <waves/b58.h>\n\n#include <coda/error.hpp>\n\n\n\nnamespace wavespp {\n\n\n\nBuilderFlagsChecker::BuilderFlagsChecker(std::initializer_list<BuilderFlags> flags_)\n\n{\n\n _flags = 0;\n\n for (auto flag : flags_)\n\n {\n\n _flags |= (uint64_t(1) << static_cast<int>(flag));\n\n }\n\n}\n\n\n", "file_path": "src/tx/base.cpp", "rank": 37, "score": 11.32734722175195 }, { "content": "}\n\n\n\nstd::string to_base58(const std::string& v)\n\n{\n\n return to_base58(reinterpret_cast<const unsigned char*>(v.c_str()), v.size());\n\n}\n\n\n\nstd::string to_base64(const std::string& v)\n\n{\n\n return to_base64(reinterpret_cast<const unsigned char*>(v.c_str()), v.size());\n\n}\n\n\n\nstd::string from_base58(const std::string& v)\n\n{\n\n unsigned char buf[v.size()];\n\n ssize_t sz = base58_decode(buf, v.c_str());\n\n return std::string((char*)buf, sz);\n\n}\n\n\n\nstd::string from_base64(const std::string& v)\n", "file_path": "src/utils.cpp", "rank": 38, "score": 11.21157465694874 }, { "content": " builder.addTransferByAddress(from_base58(\"3NA8WRsMLQ2j6DBx6LCpHPZfNkmEPL45ST6\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N1P7Eqt1eUXkiWPoCRT6KkWMML17L9xBsn\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N3aY1eNdwrcPDupxs9ehEK4X7HZKdwsxWX\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N2kJ1bgjRrq5685cWrmfpehFfdMposdpow\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N5CBzpj42wxhGTxEqEUZrrVzoxjttUjvqb\"), 100000);\n\n#endif\n\n\n\n auto tx_ptr = builder.build();\n\n\n\n const auto id = tx_ptr->id();\n\n const auto id_base58 = to_base58(id);\n\n const auto id_hex = bin2hex(reinterpret_cast<const unsigned char*>(id.c_str()), id.size());\n\n const char* expected_id_base58 = \"CRDtQ3TQ8WvkM9J8Zq7c3ep1J3n1GqvZM7bErL31gCeq\";\n\n\n\n auto&& bytes_vec = tx_ptr->bytes();\n\n const auto bytes = reinterpret_cast<const unsigned char*>(&bytes_vec[0]);\n\n const auto bytes_len = bytes_vec.size();\n\n auto&& tx_bytes_base58 = to_base58(bytes, bytes_len);\n\n\n\n printf(\"%s: TX ID (base58) = %s ID (hex) = %s\\nbytes\\n(base58): %s\\n(hex): %s\\n\",\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 39, "score": 10.851923308494225 }, { "content": "std::string bin2hex(const unsigned char *data, size_t len);\n\n\n\nstd::string hex2bin(const char* hex, size_t len) noexcept;\n\n\n\ninline std::string hex2bin(const char* hex) noexcept\n\n{\n\n return hex2bin(hex, std::char_traits<char>::length(hex));\n\n}\n\n\n\ninline std::string hex2bin(const std::string s) noexcept\n\n{\n\n return hex2bin(s.c_str(), s.size());\n\n}\n\n\n\n}}\n\n\n\n#endif /* __WAVESPP_UTILS_HPP_15740__ */\n", "file_path": "src/utils.hpp", "rank": 40, "score": 9.992739330636184 }, { "content": " auto&& bytes_vec = tx->bytes();\n\n const auto bytes = reinterpret_cast<const unsigned char*>(bytes_vec.data());\n\n const auto bytes_len = bytes_vec.size();\n\n auto&& tx_bytes_base58 = to_base58(bytes, bytes_len);\n\n\n\n const auto itx = std::static_pointer_cast<wavespp::InvokeScriptTransaction>(tx);\n\n const auto fcall = itx->function_call();\n\n const auto func_name = fcall.func_name();\n\n const auto args = fcall.args_json();\n\n\n\n printf(\"Invoke Script TX bytes\\n\"\n\n \"(base58): %s\\n\"\n\n \"(hex): %s\\n\"\n\n \"func_name: %s\\n\"\n\n \"args: %s\\n\",\n\n tx_bytes_base58.c_str(),\n\n bin2hex(bytes, bytes_len).c_str(),\n\n func_name.c_str(),\n\n args.c_str()\n\n );\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 41, "score": 9.592326251716655 }, { "content": " builder.setFunctionCall(hex2bin(\"0109010000000b73746174654368616e676500000000\"));\n\n builder.setDappPublicKeyHash(hex2bin(\"445b674c45823fcf534474a69995565054d7b8ad\"));\n\n builder.addPayment(\"\", 300);\n\n\n\n const auto tx = builder.build();\n\n\n\n auto&& tx_id = to_base58(tx->id());\n\n auto&& bytes_vec = tx->bytes();\n\n const auto bytes = reinterpret_cast<const unsigned char*>(bytes_vec.data());\n\n const auto bytes_len = bytes_vec.size();\n\n auto&& tx_bytes_base58 = to_base58(bytes, bytes_len);\n\n\n\n const auto itx = std::static_pointer_cast<wavespp::InvokeScriptTransaction>(tx);\n\n const auto fcall = itx->function_call();\n\n const auto func_name = fcall.func_name();\n\n const auto args = fcall.args_json();\n\n\n\n printf(\"%s:\\n\"\n\n \"ID: %s\\n\"\n\n \"(base58): %s\\n\"\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 42, "score": 9.396707679188928 }, { "content": "#include \"data.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nDataValue::DataValue(bool v)\n\n{\n\n type = TX_DATA_TYPE_BOOLEAN;\n\n boolean = v;\n\n}\n\n\n\nDataValue::DataValue(int64_t v)\n\n{\n\n type = TX_DATA_TYPE_INTEGER;\n\n integer = v;\n\n}\n\n\n\nDataValue::DataValue(const std::string& v, bool binary)\n\n{\n\n type = binary ? TX_DATA_TYPE_BINARY : TX_DATA_TYPE_STRING;\n\n str = v;\n", "file_path": "src/tx/data.cpp", "rank": 43, "score": 8.930684840673505 }, { "content": "#include \"mass_transfer.hpp\"\n\n#include \"utils.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nTransfer::Transfer(const std::string& alias_, tx_amount_t amount_, bool is_alias) :\n\n _is_alias(is_alias),\n\n _data(alias_),\n\n _amount(amount_)\n\n{}\n\n\n\nbool Transfer::isAlias() const\n\n{\n\n return _is_alias;\n\n}\n\n\n\nconst std::string& Transfer::address() const\n\n{\n\n return _data;\n\n}\n", "file_path": "src/tx/mass_transfer.cpp", "rank": 44, "score": 8.930608308863768 }, { "content": " (Hex): 0b01cff48bcc69c8d78e60a009c1ece9ee48045c765b42def115e6eb516a39f30b740000020154216a1659b3ab3c481a81550b2fa6d2d4242dbdb232b8deca00000000000186a001540535851541d341f55df872dad30ed5e66b7827952293da8c000000000001e24000000169296e82ad00000000004e9530000f54657374206174746163686d656e7401000100409ac7fbe97bfc7732bab9d2dd7d941eaa84941933728bb1a2552f2a5ee702737bbbbbebe4f8fc475dc68572a6bacc17b8fe38e6a2fa5721508a5b84fa69ec898e\n\n#endif\n\n\n\n const char* expected_tx_id { \"64pWj5LfhKWghuaNHKvhV4W1uS3YGR1st8sdHNFDWYRe\" };\n\n\n\n //const std::string seed { \"nasty sound ketchup inflict lecture fetch long tornado elbow scan inside shuffle\" };\n\n const std::string public_key_str { \"Ezmfw3GgJerTZFgSdzEnXydu1LJ52LsAFZXUF5c63UrF\" };\n\n const std::string public_key_bin = from_base58(public_key_str);\n\n\n\n printf(\"public_key_bin = %s\\n\", bin2hex(reinterpret_cast<const unsigned char*>(public_key_bin.c_str()), public_key_bin.size()).c_str());\n\n\n\n const uint8_t chain_id { 'T' };\n\n //const auto nonce { 0 };\n\n const uint64_t fee { 5150000L }; // 0x 4e9530\n\n const std::string asset_id {\"\"};\n\n // 0x 54657374206174746163686d656e74\n\n const std::string attachment_str { \"Test attachment\" };\n\n const uint64_t timestamp = 1551178302125L; // 0x 169296e82ad\n\n\n\n // 0154216a1659b3ab3c481a81550b2fa6d2d4242dbdb232b8deca\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 45, "score": 8.672109933257637 }, { "content": "#include <cstring>\n\n\n\n#include \"../src/utils.hpp\"\n\n#include \"../src/tx/exchange.hpp\"\n\n\n\nusing wavespp::utils::from_base58;\n\nusing wavespp::utils::to_base58;\n\n\n\nint main()\n\n{\n\n // https://wavesexplorer.com/testnet/tx/DjnFyQ78s4baaTS4hbA6n5S9SWsJKqtrivFo2mqRjHCD\n\n // curl -X GET --header 'Accept: application/json' 'https://testnet1.wavesnodes.com/transactions/info/DjnFyQ78s4baaTS4hbA6n5S9SWsJKqtrivFo2mqRjHCD'\n\n const char* expected_tx_id = \"DjnFyQ78s4baaTS4hbA6n5S9SWsJKqtrivFo2mqRjHCD\";\n\n\n\n wavespp::ExchangeTransaction::Builder builder;\n\n wavespp::OrderBuilder order_builder1;\n\n wavespp::OrderBuilder order_builder2;\n\n\n\n const std::vector<std::string> proofs1 = {\n\n from_base58(\"55qCwCYwpuYfoy5nqZhzc8Ww3bbqEvha3TQG2zL6dmQ46FA8ZbhmK8T2hJ5FZUatFYt42geFrtY5oM3Qgg7Vn6qi\")\n", "file_path": "tests/test_exchange_tx.cc", "rank": 46, "score": 7.91443917797157 }, { "content": "\n\n return 0;\n\n}//}}}\n\n\n\n\n\nstatic int test_non_default_func_name_serialization()\n\n{\n\n wavespp::InvokeScriptTransaction::Builder builder;\n\n\n\n const char* expected_tx_id = \"GphqcrFugbzMF9BVEgt1xqwRZirBi6jxKcRbjmbtaUaT\";\n\n const char* expected_func_name = \"stateChange\";\n\n const char* expected_args = \"[]\";\n\n\n\n builder\n\n .setVersion(1)\n\n .setChainId(84)\n\n .setSenderPublicKey(hex2bin(\"3d155a4972d5f000e0d9f904d8fee756ec3b835ba21133f301c7d8489e4a1e4f\"))\n\n .setFee(500000)\n\n .setTimestamp(1563370332624);\n\n\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 47, "score": 7.807839944340891 }, { "content": " auto&& tx = builder.build();\n\n auto&& tx_id = to_base58(tx->id());\n\n auto&& bytes_vec = tx->bytes();\n\n const auto bytes = reinterpret_cast<const unsigned char*>(&bytes_vec[0]);\n\n const auto bytes_len = bytes_vec.size();\n\n auto&& tx_bytes_base58 = to_base58(bytes, bytes_len);\n\n\n\n printf(\"Mass Transfer TX bytes\\n(base58): %s\\n(hex): %s\\n\",\n\n tx_bytes_base58.c_str(),\n\n bin2hex(bytes, bytes_len).c_str()\n\n );\n\n\n\n if (tx_id != expected_tx_id) {\n\n fprintf(stderr, \"Mass Transfer TX ID does not match expected value: %s != %s\\n\",\n\n tx_id.c_str(), expected_tx_id);\n\n return 1;\n\n }\n\n\n\n return 0;\n\n}//}}}\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 48, "score": 7.521033551374269 }, { "content": " auto&& tx_bytes_base58 = to_base58(bytes, bytes_len);\n\n\n\n const auto invoke_script_tx_ptr = reinterpret_cast<wavespp::InvokeScriptTransaction*>(tx.get());\n\n const auto fc = invoke_script_tx_ptr->function_call();\n\n const auto func_name = fc.func_name();\n\n const auto args_json = fc.args_json();\n\n\n\n Json::Value root;\n\n Json::CharReaderBuilder reader;\n\n reader[\"collectComments\"] = false;\n\n JSONCPP_STRING errs;\n\n std::istringstream stream(args_json);\n\n\n\n if (!parseFromStream(reader, stream, &root, &errs)) {\n\n fprintf(stderr, \"Failed to parse function arguments\\n\");\n\n return 1;\n\n }\n\n\n\n printf(\"Invoke Script TX bytes\\n\"\n\n \"(base58): %s\\n\"\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 49, "score": 7.0976396001144915 }, { "content": " const char* expected_arg0 = \"31KuAvrq2PsiQZL1dqZKFZyNYAfgpLchK99XiGmZXUg3\";\n\n const char* expected_arg1 = \"base64:W6LAllyAaOmtHi8ixFXBUvmzact63Xowv5F7kKpCZUCA0OcSzpzNyGiwKCxgJi6KToe83USFV4KAYT33z9iLRpuCy/GL5qIT7H3HqIraa7R/naxV+vjStXFd6akwFcYglpChcTUXYB2TU/SspH5ONlTG6FZmDBQxGwCHznrvDeVkkWfdcfLkyJ5tSrYzP8VlRDBcwuun4oX6b1fotNXJrrFNG7Ht/E14boxfkZ8E2BlWCttKOgE8ZsdrVqOx8uTb4KNAFZJQ2z/3op4zNHu22mcseJMFEA3N80ryDeo/e072iqoWTCmSi68LNE+KaR/sFV4uEPkl0Gp9tQwyWXSweg==\";\n\n\n\n wavespp::InvokeScriptTransaction::Builder builder;\n\n builder\n\n .setVersion(1)\n\n .setChainId(84)\n\n .setSenderPublicKey(hex2bin(\"3657e0319014c536d0f8219b6eea31e189c283889d5d9ca299d8e75a73bbd111\"))\n\n .setFee(500000)\n\n .setTimestamp(1563347126887);\n\n builder\n\n .setFunctionCall(hex2bin(\"01090100000008776974686472617700000002020000002c33314b754176727132507369515a4c3164715a4b465a794e59416667704c63684b39395869476d5a5855673301000001005ba2c0965c8068e9ad1e2f22c455c152f9b369cb7add7a30bf917b90aa42654080d0e712ce9ccdc868b0282c60262e8a4e87bcdd4485578280613df7cfd88b469b82cbf18be6a213ec7dc7a88ada6bb47f9dac55faf8d2b5715de9a93015c6209690a1713517601d9353f4aca47e4e3654c6e856660c14311b0087ce7aef0de5649167dd71f2e4c89e6d4ab6333fc56544305cc2eba7e285fa6f57e8b4d5c9aeb14d1bb1edfc4d786e8c5f919f04d819560adb4a3a013c66c76b56a3b1f2e4dbe0a340159250db3ff7a29e33347bb6da672c789305100dcdf34af20dea3f7b4ef68aaa164c29928baf0b344f8a691fec155e2e10f925d06a7db50c325974b07a\"))\n\n .setDappPublicKeyHash(hex2bin(\"104710bd7c2a27f9b0c64f7ccc712fde2bfc0aae\"));\n\n\n\n const auto tx = builder.build();\n\n\n\n auto&& tx_id = to_base58(tx->id());\n\n auto&& bytes_vec = tx->bytes();\n\n const auto bytes = reinterpret_cast<const unsigned char*>(bytes_vec.data());\n\n const auto bytes_len = bytes_vec.size();\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 50, "score": 7.08409015384818 }, { "content": " {\n\n waves_tx_set_asset_id_bytes(&tx->data.transfer.fee_asset_id, _fee_asset_id.c_str());\n\n }\n\n tx->data.transfer.amount = _amount;\n\n tx->data.transfer.recipient.is_alias = _is_alias;\n\n if (_is_alias)\n\n {\n\n tx->data.transfer.recipient.data.alias.chain_id = _chain_id;\n\n waves_tx_set_string(&tx->data.transfer.recipient.data.alias.alias, _alias.c_str());\n\n }\n\n else\n\n {\n\n auto address = wavespp::utils::secure_hash_to_address(_recipient_public_key_hash, _chain_id);\n\n waves_tx_set_address_bytes(&tx->data.transfer.recipient.data.address, address.c_str());\n\n }\n\n tx->data.transfer.fee = _fee;\n\n tx->data.transfer.timestamp = _timestamp;\n\n tx_set_encoded_string_bytes(&tx->data.transfer.attachment, _attachment.c_str(), _attachment.size());\n\n return std::make_shared<TransferTransaction>(tx);\n\n}\n", "file_path": "src/tx/transfer.cpp", "rank": 51, "score": 7.041083958430983 }, { "content": " _flags.check_and_throw();\n\n auto tx = waves_tx_new(TRANSACTION_TYPE_DATA);\n\n tx->version = TX_VERSION_1;\n\n waves_tx_set_public_key_bytes(&tx->data.data.sender_public_key, _sender_public_key.c_str());\n\n for (const auto& p : _data)\n\n {\n\n const auto& key = p.first;\n\n const auto& data_value = p.second;\n\n switch(data_value.type)\n\n {\n\n case TX_DATA_TYPE_BOOLEAN:\n\n waves_tx_data_add_entry_boolean(tx, key.c_str(), data_value.boolean);\n\n break;\n\n case TX_DATA_TYPE_INTEGER:\n\n waves_tx_data_add_entry_integer(tx, key.c_str(), uint64_t(data_value.integer));\n\n break;\n\n case TX_DATA_TYPE_STRING:\n\n waves_tx_data_add_entry_string(tx, key.c_str(), data_value.str.c_str());\n\n break;\n\n case TX_DATA_TYPE_BINARY:\n", "file_path": "src/tx/data.cpp", "rank": 52, "score": 6.872615693167065 }, { "content": "#include <cassert>\n\n\n\n#include <jsoncpp/json/json.h>\n\n\n\n#include \"invoke_script.hpp\"\n\n#include \"../utils.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nPayment::Payment(const std::string& asset_id_, tx_amount_t amount_) :\n\n asset_id(asset_id_),\n\n amount(amount_)\n\n{}\n\n\n\nFunctionCall::FunctionCall(const std::string& func_name, const std::string& args_json)\n\n : func_name_{ func_name }\n\n , args_json_{ args_json }\n\n{}\n\n\n\nInvokeScriptTransaction::Builder::Builder() :\n", "file_path": "src/tx/invoke_script.cpp", "rank": 53, "score": 6.854747616196333 }, { "content": "#ifndef __WAVESPP_TX_BASE_HPP_8551__\n\n#define __WAVESPP_TX_BASE_HPP_8551__\n\n\n\n#include <cstdint>\n\n#include <memory>\n\n#include <string>\n\n#include <vector>\n\n\n\n#include \"waves/tx.h\"\n\n\n\nnamespace wavespp {\n\n\n", "file_path": "src/tx/base.hpp", "rank": 54, "score": 6.830094934863622 }, { "content": " waves_tx_set_string(&tx->data.invoke_script.d_app.data.alias.alias, _dapp_alias.c_str());\n\n }\n\n else\n\n {\n\n auto address = wavespp::utils::secure_hash_to_address(_dapp_public_key_hash, _chain_id);\n\n waves_tx_set_address_bytes(&tx->data.invoke_script.d_app.data.address, address.c_str());\n\n }\n\n if (!_fee_asset_id.empty())\n\n {\n\n waves_tx_set_asset_id_bytes(&tx->data.invoke_script.fee_asset_id, _fee_asset_id.c_str());\n\n }\n\n tx->data.invoke_script.fee = _fee;\n\n tx->data.invoke_script.timestamp = _timestamp;\n\n return std::make_shared<InvokeScriptTransaction>(tx);\n\n}\n\n\n\nInvokeScriptTransaction::InvokeScriptTransaction(waves_tx_t* tx) :\n\n Transaction(tx)\n\n{}\n\n\n", "file_path": "src/tx/invoke_script.cpp", "rank": 55, "score": 6.652635007670164 }, { "content": "#ifndef __WAVESPP_TX_INVOKE_SCRIPT_HPP_19595__\n\n#define __WAVESPP_TX_INVOKE_SCRIPT_HPP_19595__\n\n\n\n#include <string>\n\n#include <vector>\n\n\n\n#include \"base.hpp\"\n\n\n\nnamespace wavespp {\n\n\n", "file_path": "src/tx/invoke_script.hpp", "rank": 56, "score": 6.6002208077366715 }, { "content": " builder.addTransferByAddress(from_base58(\"3MxY9ebhD9phcf9A4iDo3PrRYwqQdabWNYi\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MqrobfvY4sC38Kbs8nrHuPA1oPVRYfCSUD\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N7T9qyb8pRribqUQB3Hhhgj7cZ7DxiMBCq\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NCyPghhVSe6D6JWghkbf3TxUzzZPaYkrbT\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Myuo3rsiB3gjLPaVV91CxQTSGgkwAFfX8g\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MrfENak5dETJ8TQkwk9D9ST9T3vmSyfZeg\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N1okaa3RbD5Ao3FceNzDuhbJ9VWn9av6Ck\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N8zSyhTotpHqPtmysv82exjqy6Q3BNTib5\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NAWf31Z9QgrDtcMNMTaq3HjWsby669Go69\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NCCfDxdRHy58MTpMSDNvpk8vj5AcgwoV4H\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N6vcRobZoa3RYLT1eQpzYtkxceZ2VNkWqA\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N5YFqAy3NofcYAH1ioWhJFzgMyzhTjw79H\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N3yZxfRH4ARYcP5aQWowP1AEP4ka6Ssgj8\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N5td1UFB3V9RRJw1wrF4VaYBHtxjhjJCS6\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MufCTMQfwi7kgbY7NLzzX6ZbfpuJbqG8f3\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MwTUT6vwQdj9wgY32nWjRYkG54TqnBCSXV\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mw5wKRskMZ4z45LdDUwwhccM7wUuMHbGJa\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N1ndwAQdyQQtNSof9PGsEisvV8cVrVYfP9\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N8pBn8fJeJ75KV71vTYMrcmLDZKbH1GoRV\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N54Vyg3NXhGzbE9TvHM1pQYnZvfj4w3xEK\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 57, "score": 6.472258937106206 }, { "content": " waves_tx_set_asset_id_bytes(&tx->data.lease.lease_asset_id, _lease_asset_id.c_str());\n\n }\n\n tx->data.lease.amount = _amount;\n\n tx->data.lease.recipient.is_alias = _is_alias;\n\n if (_is_alias)\n\n {\n\n tx->data.lease.recipient.data.alias.chain_id = _chain_id;\n\n waves_tx_set_string(&tx->data.lease.recipient.data.alias.alias, _alias.c_str());\n\n }\n\n else\n\n {\n\n auto address = wavespp::utils::secure_hash_to_address(_recipient_public_key_hash, _chain_id);\n\n waves_tx_set_address_bytes(&tx->data.lease.recipient.data.address, address.c_str());\n\n }\n\n tx->data.lease.fee = _fee;\n\n tx->data.lease.timestamp = _timestamp;\n\n return std::make_shared<LeaseTransaction>(tx);\n\n}\n\n\n\nLeaseTransaction::LeaseTransaction(waves_tx_t* tx) :\n", "file_path": "src/tx/lease.cpp", "rank": 58, "score": 6.462025286651844 }, { "content": "{\n\n const std::string hex_str { \"f0a8c3a7f0cb4e8669a4e3c85f36bb9d34fa5f0ee8906cfb2c976a5e96ad2065\" };\n\n const std::string base58_str { \"HCS7115151v5VVgnBmBE5sMyCGy7urFZGwovnK1BMfQQ\" };\n\n const std::string bin_from_base58 = from_base58(base58_str);\n\n const std::string bin_from_hex2bin = hex2bin(hex_str.c_str(), hex_str.size());\n\n\n\n if (bin_from_hex2bin != bin_from_base58) {\n\n fprintf(stderr, \"bin_from_hex2bin(%s) != bin_from_base58(%s)\\n\",\n\n bin_from_hex2bin.c_str(), bin_from_base58.c_str());\n\n return 1;\n\n }\n\n return 0;\n\n}\n\n\n\nstatic int simple_test()//{{{\n\n{\n\n#if 0\n\n Mass Transfer TX ID = 64pWj5LfhKWghuaNHKvhV4W1uS3YGR1st8sdHNFDWYRe\n\n Mass Transfer TX Body Bytes\n\n (Base58): iHnbwbvFoEHfNQhW3TA6s2xQFJNHhGWNebYq9GLW3xhNmLnJfEBTeDvmNGnVB5wvna7wPiM4Cr28Ha8wnu4ZGh7jWbjTfnPVzEkLwpiRw5vz1f7Tq5Nf2RjxARYKtUrtwxedpRjqx4kYRvoe155qxJfW5ySamhptE5M29nzLoNdFMrYKJkAx786tkSaBHTf73pDcVgrJQD6DqLZyEEuobLsyY5ToryEN7vrkX6awEWxebXMfDr4gtKxjSSkJzBX5berEzBR2459HuMKgzsADbQ1yx9\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 59, "score": 6.45241848785572 }, { "content": " order->matcher_fee = _matcher_fee;\n\n if (_verison == 1)\n\n {\n\n const auto& sig = _proofs.at(0);\n\n tx_set_encoded_string_bytes(&order->signature, sig.c_str(), sig.size());\n\n }\n\n else if (_verison == 2)\n\n {\n\n tx_array_t* proofs_array = &order->proofs;\n\n for (const auto proof: _proofs)\n\n {\n\n tx_encoded_string_t* e = (tx_encoded_string_t*)tx_array_new_elem(proofs_array);\n\n tx_set_encoded_string_bytes(e, proof.c_str(), proof.size());\n\n }\n\n }\n\n}\n\n\n\n}\n", "file_path": "src/tx/order.cpp", "rank": 60, "score": 6.4394446709250746 }, { "content": "void BuilderFlagsChecker::set(BuilderFlags flag)\n\n{\n\n _flags &= ~(uint64_t(1) << static_cast<int>(flag));\n\n}\n\n\n\nbool BuilderFlagsChecker::get(BuilderFlags flag)\n\n{\n\n return (_flags >> static_cast<int>(flag)) & 1;\n\n}\n\n\n\nbool BuilderFlagsChecker::check()\n\n{\n\n return _flags == 0;\n\n}\n\n\n\nvoid BuilderFlagsChecker::check_and_throw()\n\n{\n\n if (!check())\n\n {\n\n throw coda_error(\"Can't build transaction\");\n", "file_path": "src/tx/base.cpp", "rank": 61, "score": 6.43036071945071 }, { "content": " builder.addTransferByAddress(from_base58(\"3Mq7oEcrYPXsb6BDHKYgizLVPrcaKdBsm4y\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MzDcSxYei8zTP8bLFHg2UYT8qxrkaD7bvp\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N3GT9vPArK81f5WqkEUbFD3WS4iyQg2X6a\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N7c5cMFWerHXbSLefFrkG2zeFbcwKV4dLU\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NBw1YQi6b2892RirYcucvropWGPGLP2zex\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MtnxBNHCkxQMpqgTaeyzrFpJnVR21xLYvS\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MpbPi31KJ9R5edXjrRiQ8FgQPFG5GeeGbn\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3My89wXWC8xDfPoSNEZQaJAx4rKGZeumSgk\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NCGG162pu2CK22RYhKKBHZBwxpYZhVDw4j\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N1pbqb91u8kRFiizF52NjXabvxetpVU2Tn\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NBEJMHrEyAgtrx1NSuHYyg1EvkpYTWQ199\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N5SPDNGSsCkoNW7mqYQFUQw3THpuZujTd6\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MvuEpcKGUCsTdSbHjP8tyvFNpvukzWgLHs\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MzFKgbi82kVmi8NkuCzjLdGW2svcMMfpiL\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N8KvkWejxP42XQdGFCMf9qAAXvFRfECBJu\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N6KuoMw5otsbBDubjtGweiCnZG2JBcS7Wj\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N3DJwmxGMzdFLgXia4cgBmL42XzokrQkFw\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N3QpJ7JahWLpRmguyZfarZT9DGqB21bDnY\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N3HzWUyhb1Chbv8JVmi76EMqR75owvKr7D\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MwLkvGLFWQqRN915FytssaXxN7wgWLq4Ci\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 62, "score": 5.673847984829852 }, { "content": " } else {\n\n func_name.assign(\"default\");\n\n assert(args_len == 0);\n\n }\n\n\n\n Json::StreamWriterBuilder json_builder;\n\n Json::Value json_args(Json::arrayValue);\n\n#ifndef JSON_HAS_INT64\n\n# error libjsonpp must be built with int64 support\n\n#endif\n\n const std::string base64_prefix {\"base64:\"};\n\n for (tx_size_t i = 0; i < args_len; ++i) {\n\n switch (arg_entries[i].arg_type) {\n\n case TX_FUNC_ARG_INT:\n\n json_args[i] = static_cast<Json::Int64>(arg_entries[i].types.integer);\n\n break;\n\n case TX_FUNC_ARG_FALSE:\n\n json_args[i] = false;\n\n break;\n\n case TX_FUNC_ARG_TRUE:\n", "file_path": "src/tx/invoke_script.cpp", "rank": 63, "score": 5.623283420729356 }, { "content": " builder.addTransferByAddress(from_base58(\"3ND4mbm16SRnXLtVySvqtALdFvYZF7ECJTT\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N8pQ1wh6qy5JCwHY4juYv1SkqorcAcAYAL\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MzaaNoCK4dfscZUGtGjuC4nKHeKD9L1fao\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NAYAX5HyUiVXoomsZoTYEjNXncchXHfsfA\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NCiWeuBZtqEBw7nYkXxErRpRDRAMoN9JXq\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MtgSDUEVZAp2az9Fy4s5FNBc3cEU3pQXeV\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MsTwdFPEL26SGLWuYSYwn7aniNeTv6g3jC\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MzT1U19SGYRLSoxg7rPiT9ramj1Ws6xfoD\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MuSCcwbwn95KoKwCrSWpqBo6UqY9RvJEhs\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MxZdDPWcPu1WWrNH9YuXdQk4s3W6zTjjEg\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mzs3dWgbcdmkkLijiq5QTDLRySRkboK42P\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N5U4PD9XCWvhvLtXVrLhHmmebYSF6UdEZ3\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N4LndHjs1EBH2o7ALmqBPnKJfdJTTqvgAn\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Ms2xja5gTxJG8iC5KJJmJTT2cb6o2or3wx\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mz3WvShcfMQNDiGVKJVVgJZDBshfxQExEE\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MqCpDaA1XYTrzMBxKbh18QTTvWbJrraTbK\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MqNfN68ZsK9gvhByZk3LLuGkeg9cSSseFy\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mt9KCrBaHywmnR2kZJz7azEJQKhTBuyXCn\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N9Y7aKAkV5LtiLk2KsXxzs2xYPpdNocRYv\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N8wUqX79jiegTFdppLrAB9tCiSQ8iXj7rF\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 64, "score": 5.611103397882408 }, { "content": " tx_transfer_t* e = (tx_transfer_t*)tx_array_new_elem(transfers_array);\n\n e->amount = transfer.amount();\n\n e->recipient.is_alias = transfer.isAlias();\n\n if (transfer.isAlias())\n\n {\n\n e->recipient.data.alias.chain_id = _chain_id;\n\n waves_tx_set_string(&e->recipient.data.alias.alias, transfer.address().c_str());\n\n }\n\n else\n\n {\n\n waves_tx_set_address_bytes(&e->recipient.data.address, transfer.address().c_str());\n\n }\n\n }\n\n tx->data.mass_transfer.fee = _fee;\n\n tx->data.mass_transfer.timestamp = _timestamp;\n\n tx_set_encoded_string_bytes(&tx->data.mass_transfer.attachment, _attachment.c_str(), _attachment.size());\n\n return std::make_shared<MassTransferTransaction>(tx);\n\n}\n\n\n\nMassTransferTransaction::MassTransferTransaction(waves_tx_t* tx) :\n", "file_path": "src/tx/mass_transfer.cpp", "rank": 65, "score": 5.590220361787561 }, { "content": " };\n\n const std::vector<std::string> proofs2 = {\n\n from_base58(\"gyH4ieAHMtbU3Mgcw2FpEQnKPeLMezt5j4x8dRdYfN98PfJoDqQyzDZxVjJ4Gs7WrqAhSjMUnkRz9uqSBfPFNdW\")\n\n };\n\n const auto price_asset_id = from_base58(\"FExqRNegdpai5pw2vdEKPtsrUaWqQhpgLiVLopnqUMhZ\");\n\n const auto amount_asset_id = \"\";\n\n const uint64_t amount = 1L;\n\n const uint64_t price = 100000000L;\n\n const uint64_t order_timestamp = 1504019301490L;\n\n const auto sender_public_key = from_base58(\"5M618KzeuoxCrQBUZLLnv6EL2PqcJVbREES8mWLFCaHM\");\n\n const auto matcher_public_key = from_base58(\"4oP8SPd7LiUo8xsokSTiyZjwg4rojdyXqWEq7NTwWsSU\");\n\n const uint8_t chain_id = 'T';\n\n const uint64_t buy_matcher_fee = 300000L;\n\n const uint64_t sell_matcher_fee = 300000L;\n\n const uint64_t buy_order_expiration = 1504105701490L;\n\n const uint64_t sell_order_expiration = 1506611301490L;\n\n const uint64_t buy_order_fee = 488640L;\n\n const uint64_t sell_order_fee = 445092L;\n\n const auto order_version = 1;\n\n const auto tx_version = 1;\n", "file_path": "tests/test_exchange_tx.cc", "rank": 66, "score": 5.550241702733377 }, { "content": " _data.emplace_back(std::make_pair(key, DataValue(value)));\n\n return *this;\n\n}\n\n\n\nDataTransaction::Builder&\n\nDataTransaction::Builder::addStringEntry(const std::string& key, const std::string& value)\n\n{\n\n _data.emplace_back(std::make_pair(key, DataValue(value, false)));\n\n return *this;\n\n}\n\n\n\nDataTransaction::Builder&\n\nDataTransaction::Builder::addBinaryEntry(const std::string& key, const std::string& value)\n\n{\n\n _data.emplace_back(std::make_pair(key, DataValue(value, true)));\n\n return *this;\n\n}\n\n\n\nTransactionPtr DataTransaction::Builder::build()\n\n{\n", "file_path": "src/tx/data.cpp", "rank": 67, "score": 5.48823120653752 }, { "content": "\n\ntx_amount_t Transfer::amount() const\n\n{\n\n return _amount;\n\n}\n\n\n\nMassTransferTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP,\n\n BuilderFlags::HAS_ATTACHMENT,\n\n })\n\n{\n\n}\n\n\n\nMassTransferTransaction::Builder&\n\nMassTransferTransaction::Builder::addTransferByAddress(const std::string& address, tx_amount_t amount)\n\n{\n", "file_path": "src/tx/mass_transfer.cpp", "rank": 68, "score": 5.212394922493925 }, { "content": " builder.addTransferByAddress(from_base58(\"3MxTg1DeGex16zLi6m2h9UatdYGqxavGiur\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N84cFmzZKxocBgfNwWmyXgfpSQnf5KcuNr\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mu2g1GmKzXok5F6wRLZQRmaQ1DcNtskSLH\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MuPFcVQ67hcSaCRVasPFyBmuRxx5yBWvCG\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N5gWaMfun6vMrpQrN55nTSN8d3jND9mMWV\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N67nxWvmhnWEDH5wRv4GZC656iFXiSHMtN\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MwdHcMxESReeeg186fZPZZqqf84Vy5Sj3k\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N7nSum5jGE2aSoYNwF2aPiKJxphMEaAVgv\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N17B5dTCvZ5qnQnBKn8z941vw5i8Pgunoq\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mw6B2Ai7Qd8VbFYWd9Me7Xu3W8y4PhREqa\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N6ejCEVEaPDyF5a2kdAgviMPFP7rMr4CeG\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N7BCQ2N9RBCb3xUUEKpP7R3VRC6aUASGZw\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N8VkmDP4tDqBxoRosY5anExvkjXyHTDgpd\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MvKrV6av1LKeYfCBXovYJd5cuX8i31tH5y\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N6Hij2u2WgQzADLzZLqvz7jRvP9y2CBCFF\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NBSQCkMqWyLRv7E1cVY1UQQZdatckoT3nU\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MvFL7nZkGtSxgdLLwBUBB9H6AREAHaQnp4\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MrAQ8SJARPCFzUtRrff4U3oDrtpX9GTLqy\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MsL64ZaDcKNKZFVb389qtcXcGuSCMSnN7n\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mthqtad5HLK2zPC6J6PfduoA7NmW9SJEmy\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 69, "score": 5.198918619731709 }, { "content": "#include \"lease.hpp\"\n\n#include \"utils.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nLeaseTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_VERSION,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_RECIPIENT,\n\n BuilderFlags::HAS_AMOUNT,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP,\n\n })\n\n{\n\n}\n\n\n\nLeaseTransaction::Builder&\n\nLeaseTransaction::Builder::setLeaseAssetId(const std::string& v)\n", "file_path": "src/tx/lease.cpp", "rank": 70, "score": 5.08805245137022 }, { "content": "tx_fee_t InvokeScriptTransaction::fee() const\n\n{\n\n return _tx->data.invoke_script.fee;\n\n}\n\n\n\ntx_timestamp_t InvokeScriptTransaction::timestamp() const\n\n{\n\n return _tx->data.invoke_script.timestamp;\n\n}\n\n\n\nFunctionCall InvokeScriptTransaction::function_call() const//{{{\n\n{\n\n auto&& call = _tx->data.invoke_script.call;\n\n const auto args_len = call.args.len;\n\n const auto arg_entries = reinterpret_cast<tx_func_arg_t*>(call.args.array);\n\n\n\n std::string func_name;\n\n\n\n if (call.function.data != 0x00) {\n\n func_name.assign(call.function.data, call.function.len);\n", "file_path": "src/tx/invoke_script.cpp", "rank": 71, "score": 4.9885009136827145 }, { "content": " const std::string recipient1 { \"3MrxmAKscY6yupdg46vG22SfEpiWCRKCXoF\" };\n\n // 01540535851541d341f55df872dad30ed5e66b7827952293da8c\n\n const std::string recipient2 { \"3MpPdGWDEZpXauK7AuMSuz1jjzRPRW5sNwm\" };\n\n const uint64_t amount1 = 100000L;\n\n const uint64_t amount2 = 123456L;\n\n\n\n wavespp::MassTransferTransaction::Builder builder;\n\n builder\n\n .setAssetId(asset_id)\n\n .setFee(fee)\n\n .setChainId(chain_id)\n\n .setVersion(1)\n\n .setTimestamp(timestamp)\n\n .setSenderPublicKey(public_key_bin);\n\n\n\n builder\n\n .addTransferByAddress(from_base58(recipient1), amount1)\n\n .addTransferByAddress(from_base58(recipient2), amount2)\n\n .setAttachment(attachment_str);\n\n\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 72, "score": 4.972399756485007 }, { "content": " _transfers.emplace_back(Transfer(address, amount, false));\n\n return *this;\n\n}\n\n\n\nMassTransferTransaction::Builder&\n\nMassTransferTransaction::Builder::addTransferByAlias(const std::string& alias, tx_amount_t amount)\n\n{\n\n _transfers.emplace_back(Transfer(alias, amount, true));\n\n return *this;\n\n}\n\n\n\nMassTransferTransaction::Builder&\n\nMassTransferTransaction::Builder::setAssetId(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_ASSET_ID);\n\n _asset_id = v;\n\n return *this;\n\n}\n\n\n\nMassTransferTransaction::Builder&\n", "file_path": "src/tx/mass_transfer.cpp", "rank": 73, "score": 4.814470115392835 }, { "content": "}\n\n\n\nTransaction::Transaction(waves_tx_t* tx) :\n\n _tx(tx)\n\n{}\n\n\n\nTransaction::~Transaction()\n\n{\n\n waves_tx_destroy(_tx);\n\n}\n\n\n\nconst std::string& Transaction::id() const\n\n{\n\n if (_id.empty())\n\n {\n\n const auto& bs = bytes();\n\n _id.resize(32);\n\n waves_tx_get_id((uint8_t*)_id.c_str(), bs.data(), bs.size());\n\n }\n\n return _id;\n", "file_path": "src/tx/base.cpp", "rank": 74, "score": 4.786331810992015 }, { "content": " builder.addTransferByAddress(hex2bin(\"01547dc5d63ac40de4a35525ad66e27a91b7cac28d8fe32e9961\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015495df57cd29d5bf48206c3ca7f198a6c8aef3759efdc21d9c\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01548cbfb085087f4eb225d6e062b0860996db6692f8e12b917e\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154a795bc84b0233a701278b170ea69c2efdf01cd7de3e7ec56\"), 100000);\n\n#else\n\n builder.addTransferByAddress(from_base58(\"3Mvt6yW9txnvEB75g7rRZBQVAceZjrxXKx2\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N9UKgVHZW4es9ZHjQRDA1YwpzRSMZsyGNW\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N7a7cFFL1VzsjQyc3CPHbSSGKzmxQ7468o\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N4BLF4vjtQgV9oD8NtYvgzfKZBxwvS45ah\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N32q8cR22i3StFBLjHe6r2G1JDGEV8P3wM\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N5eWADzvJXMVz3LnSLJjiML58U4LbtTTmt\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MytKKkdYCnQJ9hXSgwbtekHVq6kro3r3PQ\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N4CEA8rFc9UfLwGivXwDgHNsnVfoCcNevd\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NBfAQzkSmom9N84rkWigkXqjw9LRhumsyC\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MySPGDg7T6NXNXi4bqsDxVjRH5VhRzZvgn\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3N7kktwbj1vaPmMxsmCKAE9SyQA7Ca68d8j\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MuTfFV1Rhq2qFQitJ33CX1fjykxtAS23Cj\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3MzAazqXYwqj8msAuXnSVUBB1SU172sAokm\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3Mr6bR7wQJjZ7SqfnRzkh29BcxGpXj5g48S\"), 100000);\n\n builder.addTransferByAddress(from_base58(\"3NB3j9qCUp9uzZd26pCDv9ezYFGRFKkfzYk\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 75, "score": 4.7350073413584575 }, { "content": "#include \"sponsorship.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nSponsorshipTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_MIN_SPONSORED_ASSET_FEE,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP,\n\n })\n\n{\n\n}\n\n\n\nSponsorshipTransaction::Builder& SponsorshipTransaction::Builder::setAssetId(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_ASSET_ID);\n\n _asset_id = v;\n\n return *this;\n\n}\n", "file_path": "src/tx/sponsorship.cpp", "rank": 76, "score": 4.375644124544966 }, { "content": "#include \"alias.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nAliasTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_VERSION,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_ALIAS,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP\n\n })\n\n{}\n\n\n\nAliasTransaction::Builder&\n\nAliasTransaction::Builder::setAlias(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_ALIAS);\n\n _alias = v;\n", "file_path": "src/tx/alias.cpp", "rank": 77, "score": 4.339096441421322 }, { "content": " builder.addTransferByAddress(hex2bin(\"0154c70f091399fc2f32cbd4bede26b72020e5896fe1ad4c285b\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01543817b2d94fc7923cb2f42f0e96954b809bdadffae387305a\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01543bfc125de4bf9cdafa9da1f004e3b92166fa01d7c3c120a9\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154acf0e43fefe28f560e6fdf0f9436895ed181c720937b529e\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154b1b8f7383df05d2245aaa569b87ec12fb2d6d8c7b5eb73a3\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01545493d07f8a136cc8ea10e39f92ebf47c3bd60594e2c7772f\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154c400944494cdecb4db98c025d0d007439217ea025b1e7693\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01547ac2634aef0216335b4131839f4952f03ea9881177b6a180\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01544eb16b406fd702eadede2c8390730f08c3290c45a7a80f95\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154b792b809c8a616f076f688eba4c3bc0e054aa65d3dfbd345\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154bd55e7ea44fe4f72278839b5ca196e0ea368c61f04c915aa\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154cbd08947331392c726ea3cd0d7ab23dc9c0f13de8040afc6\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154464fa4d04329a1a67c952da1613855403816a823b96db058\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154b399979c7c9810ec1a268d1453fc6cc47906e6771906f8a6\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154ec1680d77d66c711bc190feafe43435094b225c32c92aaa5\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01544574a168cb1892f57af1c78f9437d35702327ba900415365\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015418a5655d5d474df2617f5d64015485cb0ff4f09f89ac13c4\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01542572999659c51b967d10177b227c27b3fab63f9e4c4376d5\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015434880bef338bbd2f624cee2a9c75d16ce35f6f0144aecd7c\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01545e9336ecdceaf334235b1768f3df3a922f4e1f6a31f0e1eb\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 78, "score": 4.323559975045146 }, { "content": " builder.addTransferByAddress(hex2bin(\"01541551800371047e790b3451604252b9ac254a65ffb3f70326\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154c05a6e3845b774ef9979d6ed284de8803e02cfec807dbe26\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154fceb1769a33c1bcc1ff05ffaa710f4d8cd0bef7916674f7a\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01546da34bdeded9bef1d77c954a8e6a3cacb3ddfd79d8910d65\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01541e19509a8013646fb0b10423240615702711befddca32c99\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154826efd68ba2bf86f2a37ec31fcac2e7e0ed0b5255b3c3475\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154d13dc0cfa0337ff5b1c0b70c738c7063994cbbb04eb9e81c\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154e1ec6c2d654ea7b4e22f1b71eb070b333c3b0fa73e809fda\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154f475582b741e9251c5d32f06d3038081d24907b53ae4adde\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154ba93b9eeba9074f08029da767d016248e66887b573b849c5\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154ab614179e5802e52fe3fe6cbd718e5d053b12c8323788088\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01549a3a8964c1b539ecc97724e92fc42f5d5598fbb51110c547\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154af3b40cd28e50774cfdd438f25b3b9bce12b1ba8d8f42383\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01543f001762717f1e48dc05e24c0e81c8b8acf8f5d464880e72\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015452b8b4333a53b61446eaae7ba3814d7d2cb5924bab31cae4\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01544ea5fb14071087ff8683632822ead19ecba132fd7c228e67\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154823906e89e6c47d1d6bc0e4fb97f5aee9a6e323aaa2f2614\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154cf4ce7dd98c1917f1fb19977a4031893126ceb9c166ea9dc\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154a6216af507917375a865f48eba6e37ee23466f03a49592d0\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154fdef76fcf9f6894a3f8d27ec5356165b55ef75245763012a\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 79, "score": 4.323559975045146 }, { "content": " builder.addTransferByAddress(hex2bin(\"01547101ef0bf406c1a04bd73a9284c9366701a4bc0177185089\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01549273cd0d47e40a51d29a43b772fb7afb5a7309477b8e91f3\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154c20aa398eee04707bb5c8471e140cbabdd9ae02d54fe39f1\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154f17fa653ef49cb6f0a0be0dc28ea4bd8fd11f9294ec42bc5\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154357f6067bfa6ed05b97c0a2403acd2ab77d4f61ea2008f1f\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154076f31366a64b1ab6cb8f4d6fa2f4bf73ebe57185c8350f5\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154650199d37ce88df27170ace83401a7fa8c2688332d051d45\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154f5239fa1d86ca891df103cb7bc4bc33f4e9a90f84f9aa990\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015482981bf30875534271bb3e635cba6bdbe06a1207dffc27cd\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154e9cca04b7db92de0006983b88c1412b7f6ae0d25bd0d48c0\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154aa44ec38886ff18270d051f1d913abc0208ffa264e01d225\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01544ca0041bd3fc8b330318fa1fd807158c88be240b74f0a2c6\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01547154c5693ea2f8c6f58a7b2fc2fb63da19726a2b8101c9e9\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154c9f4b6cf187dc18831863422440d2ac5689a1fade51a3cbe\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154b403ab358b40e460fb7752f1ae4d3f84167438494b7ca4ac\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015491dbb34292e09097d5e33d3f4b80ae292bcc279f09d025f6\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01549408c6c50f63720382e1c60830a4348ca176642990e1c471\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015492be63efd74ee35c4ab58b823cbc918a3a83831c46a3cfac\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015451738a0ae6119ad3d9be359d03953a37983a398d27f7cba3\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154ddbc166b5c364cc0f67ddc89d4d0e898f6c1109ab328f91d\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 80, "score": 4.323559975045146 }, { "content": " builder.addTransferByAddress(hex2bin(\"0154cf571f20a70dc0ccb517bc5c1bd914998adafb4404b1eff1\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015474f8f08786a39dc3a9c8e5be21354cb937269ea182accd30\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154e235734f077a917e17a1e997ceaad068cc197a8da11393dd\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154fa1aab5dc402cf904c6d257ae5bbf34b6e06ed6e8537f030\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01543443de4b3c7cc3b65c78403eef20ab14a927bec4c2baf1be\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015426eee2a0440e565cb8b019f625cdbe7b065f7a128c5a7d5f\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154738a8e45a2173b3424c5ad212d49fc5aafff1bf03d551a38\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01543c8ad2655cbc701d847387c4edf541644a5e19233ec2558e\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01545edaa412477239af002bb6a55982263a5a3d5df7d046f391\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01547816585fab5f999da24a343d478ac6039d6e907710a4e06c\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154aa9609321ac3da9ca95cfb3da1b633b26969a0c50c237186\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01549e3dd84c03d38f8004292d71caf8b0cf0d0b6f7f3ab06b3b\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154223569768bec1d82d02dc6de630f945d8073c3b392a80ee3\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01546f192943d1e8997bb200dc8149be0a03c6a0a94f06804313\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01540e2235cf98d786bdced711a2da688389bd4123528c3b3686\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01540ffefac54105ba94c7a00ecc1babd767d559a4e01d556458\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01542e611f0b75f6c4870c85ecdefa64f609b4a3a4b170186fa3\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154d73addf2dfff7dd8f470b3bde30ed9b6c8b3e1f83b172393\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154d0ae0e9d70378063d521cefea6e5f3dbe8e6139a5f1e6750\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01540d2f4f89a603f45878dc2554163c1064ded3ca50ea717c06\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 81, "score": 4.323559975045146 }, { "content": "IssueTransaction::Builder&\n\nIssueTransaction::Builder::setScript(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_SCRIPT);\n\n _script = v;\n\n return *this;\n\n}\n\n\n\nTransactionPtr IssueTransaction::Builder::build()\n\n{\n\n _flags.check_and_throw();\n\n auto tx = waves_tx_new(TRANSACTION_TYPE_ISSUE);\n\n tx->version = _version;\n\n tx->data.issue.chain_id = _chain_id;\n\n waves_tx_set_public_key_bytes(&tx->data.issue.sender_public_key, _sender_public_key.c_str());\n\n waves_tx_set_string(&tx->data.issue.name, _name.c_str());\n\n waves_tx_set_string(&tx->data.issue.description, _description.c_str());\n\n tx->data.issue.quantity = _quantity;\n\n tx->data.issue.decimals = _decimals;\n\n tx->data.issue.reissuable = _reissuable;\n", "file_path": "src/tx/issue.cpp", "rank": 82, "score": 4.312950473443701 }, { "content": "#include \"set_script.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nSetScriptTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_SCRIPT,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP,\n\n })\n\n{\n\n}\n\n\n\nSetScriptTransaction::Builder&\n\nSetScriptTransaction::Builder::setScript(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_SCRIPT);\n\n _script = v;\n", "file_path": "src/tx/set_script.cpp", "rank": 83, "score": 4.303154232039498 }, { "content": " builder.setAssetId(hex2bin(\"b12558c530fb3509a46a2eb165f15eedb6e40391de95eaf530d180f267921138\"))\n\n .setAttachment(\"\");\n\n\n\n#if 1\n\n builder.addTransferByAddress(hex2bin(\"01544c690cce8adea26c6b50ec1804560acd8ee7be7c0d5b193f\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154d6834f213553f627b1a39ce956a01bafef8fc08772a6a55b\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154c1ab79a3c25c32f8d206b0926cbb7ca2c478d2991fec5870\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01549c7413e672c46a3cd6b7a56dcb2d448cb04f26ab58c7905a\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01548fe052c69a507048a9f67b7dbb7a456a38f74bd550df9bb8\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154ac8fb65cf848b30ee3f59635a95e57edf5a267c64bebf093\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01546d5bbc64d0c017b5e453977f5319b997f860b1be9508f8a3\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01549c9f6a066e197b529ff4a9bd7cd817d467e433f4b8755b32\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154ee8066847e7add4b682dd547373e6845fea2e58e00cf8e63\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015468743586450a5b8f6a4b492424cac34cf6555a3952cf6a07\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154c3aec2d80365226108a9a5800c47cc53ef1f03bf51bee798\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01543cd177aa937d87cedd0cdb847c02ec9863c3eb36d1523388\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154706f79a600ba62dcb0b8f4b0af755bf040469b4ac0aa8f0a\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"015417ed27915497c0e2d118cbf257a1b61bdfa9d295b412cfb3\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"0154e7ccc12ced76f63b8a6a93d8fee47a68078f0fe71c546f95\"), 100000);\n\n builder.addTransferByAddress(hex2bin(\"01545dba79687027980bebd73e603dd2e7acfb9263470170e9c5\"), 100000);\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 84, "score": 4.275225562156146 }, { "content": "\n\n// https://wavesexplorer.com/testnet/tx/CRDtQ3TQ8WvkM9J8Zq7c3ep1J3n1GqvZM7bErL31gCeq\n\nint hundred_transfers_test()\n\n{\n\n\n\n wavespp::MassTransferTransaction::Builder builder;\n\n\n\n // https://wavesexplorer.com/testnet/tx/CRDtQ3TQ8WvkM9J8Zq7c3ep1J3n1GqvZM7bErL31gCeq\n\n\n\n const std::string sender_public_key_hex { \"f0a8c3a7f0cb4e8669a4e3c85f36bb9d34fa5f0ee8906cfb2c976a5e96ad2065\" };\n\n const std::string sender_public_key_base58 { \"HCS7115151v5VVgnBmBE5sMyCGy7urFZGwovnK1BMfQQ\" };\n\n //const std::string sender_public_key_bin = from_base58(sender_public_key_base58);\n\n const std::string sender_public_key_bin = hex2bin(sender_public_key_hex);\n\n\n\n builder.setVersion(1)\n\n .setChainId('T')\n\n .setSenderPublicKey(sender_public_key_bin)\n\n .setFee(5150000L)\n\n .setTimestamp(1551178449125L);\n\n\n", "file_path": "tests/test_mass_transfer_tx.cc", "rank": 85, "score": 4.266490789888 }, { "content": "#include \"burn.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nBurnTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_VERSION,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_QUANTITY,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP\n\n })\n\n{}\n\n\n\nBurnTransaction::Builder&\n\nBurnTransaction::Builder::setAssetId(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_ASSET_ID);\n\n _asset_id = v;\n", "file_path": "src/tx/burn.cpp", "rank": 86, "score": 4.2330270311684615 }, { "content": "}\n\n\n\nInvokeScriptTransaction::Builder&\n\nInvokeScriptTransaction::Builder::setDappAlias(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_DAPP);\n\n _is_dapp_alias = true;\n\n _dapp_alias = v;\n\n return *this;\n\n}\n\n\n\nTransactionPtr InvokeScriptTransaction::Builder::build()\n\n{\n\n _flags.check_and_throw();\n\n auto tx = waves_tx_new(TRANSACTION_TYPE_INVOKE_SCRIPT);\n\n tx->version = TX_VERSION_1;\n\n tx->data.invoke_script.chain_id = _chain_id;\n\n waves_tx_set_public_key_bytes(&tx->data.invoke_script.sender_public_key, _sender_public_key.c_str());\n\n tx_array_t* payments_array = &tx->data.invoke_script.payments;\n\n for (const auto& payment : _payments)\n", "file_path": "src/tx/invoke_script.cpp", "rank": 87, "score": 4.160779797692771 }, { "content": "MassTransferTransaction::Builder::setAttachment(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_ATTACHMENT);\n\n _attachment = v;\n\n return *this;\n\n}\n\n\n\nTransactionPtr MassTransferTransaction::Builder::build()\n\n{\n\n _flags.check_and_throw();\n\n auto tx = waves_tx_new(TRANSACTION_TYPE_MASS_TRANSFER);\n\n tx->version = TX_VERSION_1;\n\n waves_tx_set_public_key_bytes(&tx->data.mass_transfer.sender_public_key, _sender_public_key.c_str());\n\n if (!_asset_id.empty())\n\n {\n\n waves_tx_set_asset_id_bytes(&tx->data.mass_transfer.asset_id, _asset_id.c_str());\n\n }\n\n tx_array_t* transfers_array = &tx->data.mass_transfer.transfers;\n\n for (const auto& transfer : _transfers)\n\n {\n", "file_path": "src/tx/mass_transfer.cpp", "rank": 88, "score": 4.138522176388317 }, { "content": "#include \"lease_cancel.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nLeaseCancelTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_VERSION,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_LEASE_ID,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP,\n\n })\n\n{\n\n}\n\n\n\nLeaseCancelTransaction::Builder&\n\nLeaseCancelTransaction::Builder::setLeaseId(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_LEASE_ID);\n", "file_path": "src/tx/lease_cancel.cpp", "rank": 89, "score": 4.132019623174595 }, { "content": "#include \"set_asset_script.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nSetAssetScriptTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_ASSET_ID,\n\n BuilderFlags::HAS_SCRIPT,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP,\n\n })\n\n{\n\n}\n\n\n\nSetAssetScriptTransaction::Builder&\n\nSetAssetScriptTransaction::Builder::setScript(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_SCRIPT);\n", "file_path": "src/tx/set_asset_script.cpp", "rank": 90, "score": 4.067317431229869 }, { "content": "#include \"reissue.hpp\"\n\n\n\nnamespace wavespp {\n\n\n\nReissueTransaction::Builder::Builder() :\n\n Transaction::Builder({\n\n BuilderFlags::HAS_VERSION,\n\n BuilderFlags::HAS_PUBLIC_KEY,\n\n BuilderFlags::HAS_CHAIN_ID,\n\n BuilderFlags::HAS_ASSET_ID,\n\n BuilderFlags::HAS_REISSUABLE,\n\n BuilderFlags::HAS_QUANTITY,\n\n BuilderFlags::HAS_FEE,\n\n BuilderFlags::HAS_TIMESTAMP,\n\n })\n\n{}\n\n\n\nReissueTransaction::Builder& ReissueTransaction::Builder::setAssetId(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_ASSET_ID);\n", "file_path": "src/tx/reissue.cpp", "rank": 91, "score": 4.067317431229869 }, { "content": " {\n\n tx_payment_t* e = (tx_payment_t*)tx_array_new_elem(payments_array);\n\n e->amount = payment.amount;\n\n if (!payment.asset_id.empty())\n\n {\n\n waves_tx_set_asset_id_bytes(&e->asset_id, payment.asset_id.c_str());\n\n }\n\n }\n\n if (_function_call.empty())\n\n {\n\n tx->data.invoke_script.call.valid = false;\n\n }\n\n else\n\n {\n\n tx_load_func_call(&tx->data.invoke_script.call, (const unsigned char*)_function_call.c_str());\n\n }\n\n tx->data.invoke_script.d_app.is_alias = _is_dapp_alias;\n\n if (_is_dapp_alias)\n\n {\n\n tx->data.invoke_script.d_app.data.alias.chain_id = _chain_id;\n", "file_path": "src/tx/invoke_script.cpp", "rank": 92, "score": 3.714259720454487 }, { "content": "#ifndef __WAVESPP_TX_DATA_HPP_17588__\n\n#define __WAVESPP_TX_DATA_HPP_17588__\n\n\n\n#include \"base.hpp\"\n\n#include <vector>\n\n\n\nnamespace wavespp {\n\n\n", "file_path": "src/tx/data.hpp", "rank": 93, "score": 3.702447605088142 }, { "content": "#ifndef __WAVESPP_TX_EXCHANGE_HPP_5214__\n\n#define __WAVESPP_TX_EXCHANGE_HPP_5214__\n\n\n\n#include \"base.hpp\"\n\n#include \"order.hpp\"\n\n\n\nnamespace wavespp {\n\n\n", "file_path": "src/tx/exchange.hpp", "rank": 94, "score": 3.677203527532767 }, { "content": " OrderType _order_type;\n\n std::string _sender_public_key;\n\n std::string _matcher_public_key;\n\n std::string _amount_asset;\n\n std::string _price_asset;\n\n tx_amount_t _price;\n\n tx_amount_t _amount;\n\n tx_timestamp_t _timestamp;\n\n tx_timestamp_t _expiration;\n\n tx_fee_t _matcher_fee;\n\n std::vector<std::string> _proofs;\n\n};\n\n\n\n}\n\n\n\n#endif /* __WAVESPP_TX_ORDER_HPP_6945__ */\n", "file_path": "src/tx/order.hpp", "rank": 95, "score": 3.636697925163694 }, { "content": "\n\nTransferTransaction::Builder&\n\nTransferTransaction::Builder::setAttachment(const std::string& v)\n\n{\n\n _flags.set(BuilderFlags::HAS_ATTACHMENT);\n\n _attachment = v;\n\n return *this;\n\n}\n\n\n\nTransactionPtr TransferTransaction::Builder::build()\n\n{\n\n _flags.check_and_throw();\n\n auto tx = waves_tx_new(TRANSACTION_TYPE_TRANSFER);\n\n tx->version = _version;\n\n waves_tx_set_public_key_bytes(&tx->data.transfer.sender_public_key, _sender_public_key.c_str());\n\n if (!_asset_id.empty())\n\n {\n\n waves_tx_set_asset_id_bytes(&tx->data.transfer.asset_id, _asset_id.c_str());\n\n }\n\n if (!_fee_asset_id.empty())\n", "file_path": "src/tx/transfer.cpp", "rank": 96, "score": 3.571062072130912 }, { "content": " .setOrder1(order_builder1)\n\n .setOrder2(order_builder2)\n\n .setBuyMatcherFee(buy_matcher_fee)\n\n .setSellMatcherFee(sell_matcher_fee);\n\n\n\n auto&& tx = builder.build();\n\n auto&& tx_id = to_base58(tx->id());\n\n auto&& bytes_vec = tx->bytes();\n\n auto&& tx_bytes = to_base58(&bytes_vec[0], bytes_vec.size());\n\n\n\n printf(\"Exchange TX bytes (base58): %s\\n\", tx_bytes.c_str());\n\n\n\n if (tx_id != expected_tx_id) {\n\n fprintf(stderr, \"Exchange TX ID does not match expected value: %s != %s\\n\",\n\n tx_id.c_str(), expected_tx_id);\n\n return 1;\n\n }\n\n\n\n return 0;\n\n}\n", "file_path": "tests/test_exchange_tx.cc", "rank": 97, "score": 3.440547880442086 }, { "content": " return *this;\n\n}\n\n\n\nTransactionPtr AliasTransaction::Builder::build()\n\n{\n\n _flags.check_and_throw();\n\n auto tx = waves_tx_new(TRANSACTION_TYPE_ALIAS);\n\n tx->version = _version;\n\n waves_tx_set_public_key_bytes(&tx->data.alias.sender_public_key, _sender_public_key.c_str());\n\n tx->data.alias.alias.chain_id = _chain_id;\n\n waves_tx_set_string(&tx->data.alias.alias.alias, _alias.c_str());\n\n tx->data.alias.fee = _fee;\n\n tx->data.alias.timestamp = _timestamp;\n\n return std::make_shared<AliasTransaction>(tx);\n\n}\n\n\n\nAliasTransaction::AliasTransaction(waves_tx_t* tx) :\n\n Transaction(tx)\n\n{}\n\n\n", "file_path": "src/tx/alias.cpp", "rank": 98, "score": 3.4298429080022586 }, { "content": "{\n\n // https://wavesexplorer.com/testnet/tx/4n78dua6HRcrPqvX56qz8TVqcmBqvnKLMDndzE7w63DU\n\n const char* expected_tx_id = \"4n78dua6HRcrPqvX56qz8TVqcmBqvnKLMDndzE7w63DU\";\n\n const char* expected_func_name = \"default\";\n\n const char* expected_args = \"[]\";\n\n\n\n#if 0\n\nTx bytes in hex:\n\n1001543d155a4972d5f000e0d9f904d8fee756ec3b835ba21133f301c7d8489e4a1e4f02540009746573742d64617070000000000000000007a120000000016c0022286e\n\n\n\n10 // tx type\n\n01 // version\n\n54 // chain id\n\n3d155a4972d5f000e0d9f904d8fee756ec3b835ba21133f301c7d8489e4a1e4f // sender public key\n\n02 // alias flag\n\n54 // chain id\n\n0009 // alias length\n\n746573742d64617070 // alias\n\n00 // default\n\n0000 // payments number\n", "file_path": "tests/test_invoke_script_tx.cc", "rank": 99, "score": 3.2780352790364904 } ]
C++
xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp
andoma/pdfium
6c0c0ce4b67502b89edf9c47c7e248328a8d8e9c
#include "xfa/src/foxitlib.h" #include "xfa/src/fwl/src/core/include/fwl_targetimp.h" #include "xfa/src/fwl/src/core/include/fwl_noteimp.h" #include "xfa/src/fwl/src/core/include/fwl_widgetimp.h" #include "xfa/src/fwl/src/core/include/fwl_panelimp.h" #include "xfa/src/fwl/src/core/include/fwl_formimp.h" #include "xfa/src/fwl/src/basewidget/include/fwl_tooltipctrlimp.h" IFWL_ToolTip* IFWL_ToolTip::Create(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) { IFWL_ToolTip* pToolTip = new IFWL_ToolTip; CFWL_ToolTipImp* pToolTipImpl = new CFWL_ToolTipImp(properties, pOuter); pToolTip->SetImpl(pToolTipImpl); pToolTipImpl->SetInterface(pToolTip); return pToolTip; } FWL_ERR IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { return static_cast<CFWL_ToolTipImp*>(GetImpl())->SetAnchor(rtAnchor); } FWL_ERR IFWL_ToolTip::Show() { return static_cast<CFWL_ToolTipImp*>(GetImpl())->Show(); } FWL_ERR IFWL_ToolTip::Hide() { return static_cast<CFWL_ToolTipImp*>(GetImpl())->Hide(); } IFWL_ToolTip::IFWL_ToolTip() { } CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : CFWL_FormImp(properties, pOuter), m_bBtnDown(FALSE), m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), m_iTTOAlign(FDE_TTOALIGNMENT_Center), m_hTimerShow(NULL), m_hTimerHide(NULL), m_pTimer(NULL) { m_rtClient.Set(0, 0, 0, 0); m_rtCaption.Set(0, 0, 0, 0); m_rtAnchor.Set(0, 0, 0, 0); m_TimerShow.m_pToolTip = this; m_TimerHide.m_pToolTip = this; } CFWL_ToolTipImp::~CFWL_ToolTipImp() { if (m_pTimer) { delete m_pTimer; m_pTimer = NULL; } } FWL_ERR CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const { wsClass = FWL_CLASS_ToolTip; return FWL_ERR_Succeeded; } FX_DWORD CFWL_ToolTipImp::GetClassID() const { return FWL_CLASSHASH_ToolTip; } FWL_ERR CFWL_ToolTipImp::Initialize() { m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup; m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child; if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) return FWL_ERR_Indefinite; m_pDelegate = new CFWL_ToolTipImpDelegate(this); return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImp::Finalize() { delete m_pDelegate; m_pDelegate = nullptr; return CFWL_WidgetImp::Finalize(); } FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { if (bAutoSize) { rect.Set(0, 0, 0, 0); if (m_pProperties->m_pThemeProvider == NULL) { m_pProperties->m_pThemeProvider = GetAvailableTheme(); } CFX_WideString wsCaption; IFWL_ToolTipDP* pData = static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); if (pData) { pData->GetCaption(m_pInterface, wsCaption); } int32_t iLen = wsCaption.GetLength(); if (iLen > 0) { CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); rect.Set(0, 0, sz.x, sz.y); rect.width += FWL_WGTCAPACITY_CXBorder * 25; rect.height += FWL_WGTCAPACITY_CYBorder * 8; } CFWL_WidgetImp::GetWidgetRect(rect, TRUE); } else { rect = m_pProperties->m_rtWidget; } return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImp::Update() { if (IsLocked()) { return FWL_ERR_Indefinite; } if (!m_pProperties->m_pThemeProvider) { m_pProperties->m_pThemeProvider = GetAvailableTheme(); } UpdateTextOutStyles(); GetClientRect(m_rtClient); m_rtCaption = m_rtClient; return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) { FX_FLOAT x = 0; FX_FLOAT y = 0; FX_FLOAT t = 0; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (pTheme) { CFWL_ThemePart part; part.m_pWidget = m_pInterface; x = *static_cast<FX_FLOAT*>( pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder)); y = *static_cast<FX_FLOAT*>( pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder)); } rect = m_pProperties->m_rtWidget; rect.Offset(-rect.left, -rect.top); rect.Deflate(x, t, x, y); return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { IFWL_ToolTipTarget* toolTipTarget = CFWL_ToolTipContainer::getInstance()->GetCurrentToolTipTarget(); if (toolTipTarget && !toolTipTarget->UseDefaultTheme()) { return toolTipTarget->DrawToolTip(pGraphics, pMatrix, m_pInterface); } if (!pGraphics) return FWL_ERR_Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_ERR_Indefinite; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; DrawBkground(pGraphics, pTheme, pMatrix); DrawText(pGraphics, pTheme, pMatrix); return FWL_ERR_Succeeded; } void CFWL_ToolTipImp::DrawBkground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { CFWL_ThemeBackground param; param.m_pWidget = m_pInterface; param.m_iPart = FWL_PART_TTP_Background; param.m_dwStates = m_pProperties->m_dwStates; param.m_pGraphics = pGraphics; if (pMatrix) { param.m_matrix.Concat(*pMatrix); } param.m_rtPart = m_rtClient; if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { param.m_pData = &m_rtCaption; } pTheme->DrawBackground(&param); } void CFWL_ToolTipImp::DrawText(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { if (!m_pProperties->m_pDataProvider) return; CFX_WideString wsCaption; m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); if (wsCaption.IsEmpty()) { return; } CFWL_ThemeText param; param.m_pWidget = m_pInterface; param.m_iPart = FWL_PART_TTP_Caption; param.m_dwStates = m_pProperties->m_dwStates; param.m_pGraphics = pGraphics; if (pMatrix) { param.m_matrix.Concat(*pMatrix); } param.m_rtPart = m_rtCaption; param.m_wsText = wsCaption; param.m_dwTTOStyles = m_dwTTOStyles; param.m_iTTOAlign = m_iTTOAlign; pTheme->DrawText(&param); } void CFWL_ToolTipImp::UpdateTextOutStyles() { m_iTTOAlign = FDE_TTOALIGNMENT_Center; m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { m_dwTTOStyles |= FDE_TTOSTYLE_RTL; } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) { m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; } } FWL_ERR CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) { m_rtAnchor = rtAnchor; return TRUE; } FWL_ERR CFWL_ToolTipImp::Show() { IFWL_ToolTipDP* pData = static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); int32_t nInitDelay = pData->GetInitialDelay(m_pInterface); if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) { m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE); } return TRUE; } FWL_ERR CFWL_ToolTipImp::Hide() { SetStates(FWL_WGTSTATE_Invisible, TRUE); if (m_hTimerHide) { FWL_StopTimer(m_hTimerHide); m_hTimerHide = NULL; } if (m_hTimerShow) { FWL_StopTimer(m_hTimerShow); m_hTimerShow = NULL; } return TRUE; } FWL_ERR CFWL_ToolTipImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) { IFWL_ToolTipDP* pData = static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface); m_hTimerHide = FWL_StartTimer(&m_TimerHide, nAutoPopDelay, FALSE); } return CFWL_WidgetImp::SetStates(dwStates, bSet); } void CFWL_ToolTipImp::RefreshToolTipPos() { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { CFX_RectF rtPopup; CFX_RectF rtWidget(m_pProperties->m_rtWidget); CFX_RectF rtAnchor(m_rtAnchor); rtPopup.Set(0, 0, 0, 0); FX_FLOAT fx = rtAnchor.Center().x + 20; FX_FLOAT fy = rtAnchor.Center().y + 20; rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); FX_FLOAT fScreenWidth = 0; FX_FLOAT fScreenHeight = 0; GetScreenSize(fScreenWidth, fScreenHeight); if (rtPopup.bottom() > fScreenHeight) { rtPopup.Offset(0, fScreenHeight - rtPopup.bottom()); } if (rtPopup.right() > fScreenWidth) { rtPopup.Offset(fScreenWidth - rtPopup.right(), 0); } if (rtPopup.left < 0) { rtPopup.Offset(0 - rtPopup.left, 0); } if (rtPopup.top < 0) { rtPopup.Offset(0, 0 - rtPopup.top); } SetWidgetRect(rtPopup); Update(); } } CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip) : m_pToolTip(pToolTip) {} int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) { if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) { if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE); m_pToolTip->RefreshToolTipPos(); FWL_StopTimer(m_pToolTip->m_hTimerShow); m_pToolTip->m_hTimerShow = NULL; return TRUE; } } if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) { m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE); FWL_StopTimer(m_pToolTip->m_hTimerHide); m_pToolTip->m_hTimerHide = NULL; return TRUE; } return TRUE; } CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner) : m_pOwner(pOwner) {} int32_t CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); } FWL_ERR CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); }
#include "xfa/src/foxitlib.h" #include "xfa/src/fwl/src/core/include/fwl_targetimp.h" #include "xfa/src/fwl/src/core/include/fwl_noteimp.h" #include "xfa/src/fwl/src/core/include/fwl_widgetimp.h" #include "xfa/src/fwl/src/core/include/fwl_panelimp.h" #include "xfa/src/fwl/src/core/include/fwl_formimp.h" #include "xfa/src/fwl/src/basewidget/include/fwl_tooltipctrlimp.h" IFWL_ToolTip* IFWL_ToolTip::Create(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) { IFWL_ToolTip* pToolTip = new IFWL_ToolTip; CFWL_ToolTipImp* pToolTipImpl = new CFWL_ToolTipImp(properties, pOuter); pToolTip->SetImpl(pToolTipImpl); pToolTipImpl->SetInterface(pToolTip); return pToolTip; } FWL_ERR IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { return static_cast<CFWL_ToolTipImp*>(GetImpl())->SetAnchor(rtAnchor); } FWL_ERR IFWL_ToolTip::Show() { return static_cast<CFWL_ToolTipImp*>(GetImpl())->Show(); } FWL_ERR IFWL_ToolTip::Hide() { return static_cast<CFWL_ToolTipImp*>(GetImpl())->Hide(); } IFWL_ToolTip::IFWL_ToolTip() { } CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : CFWL_FormImp(properties, pOuter), m_bBtnDown(FALSE), m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), m_iTTOAlign(FDE_TTOALIGNMENT_Center), m_hTimerShow(NULL), m_hTimerHide(NULL), m_pTimer(NULL) { m_rtClient.Set(0, 0, 0, 0); m_rtCaption.Set(0, 0, 0, 0); m_rtAnchor.Set(0, 0, 0, 0); m_TimerShow.m_pToolTip = this; m_TimerHide.m_pToolTip = this; } CFWL_ToolTipImp::~CFWL_ToolTipImp() { if (m_pTimer) { delete m_pTimer; m_pTimer = NULL; } } FWL_ERR CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const { wsClass = FWL_CLASS_ToolTip; return FWL_ERR_Succeeded; } FX_DWORD CFWL_ToolTipImp::GetClassID() const { return FWL_CLASSHASH_ToolTip; } FWL_ERR CFWL_ToolTipImp::Initialize() { m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup; m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child; if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) return FWL_ERR_Indefinite; m_pDelegate = new CFWL_ToolTipImpDelegate(this); return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImp::Finalize() { delete m_pDelegate; m_pDelegate = nullptr; return CFWL_WidgetImp::Finalize(); } FWL_ERR CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { if (bAutoSize) { rect.Set(0, 0, 0, 0); if (m_pProperties->m_pThemeProvider == NULL) { m_pProperties->m_pThemeProvider = GetAvailableTheme(); } CFX_WideString wsCaption; IFWL_ToolTipDP* pData = static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); if (pData) { pData->GetCaption(m_pInterface, wsCaption); } int32_t iLen = wsCaption.GetLength(); if (iLen > 0) { CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); rect.Set(0, 0, sz.x, sz.y); rect.width += FWL_WGTCAPACITY_CXBorder * 25; rect.height += FWL_WGTCAPACITY_CYBorder * 8; } CFWL_WidgetImp::GetWidgetRect(rect, TRUE); } else { rect = m_pProperties->m_rtWidget; } return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImp::Update() { if (IsLocked()) {
FWL_ERR CFWL_ToolTipImp::GetClientRect(CFX_RectF& rect) { FX_FLOAT x = 0; FX_FLOAT y = 0; FX_FLOAT t = 0; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (pTheme) { CFWL_ThemePart part; part.m_pWidget = m_pInterface; x = *static_cast<FX_FLOAT*>( pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CXBorder)); y = *static_cast<FX_FLOAT*>( pTheme->GetCapacity(&part, FWL_WGTCAPACITY_CYBorder)); } rect = m_pProperties->m_rtWidget; rect.Offset(-rect.left, -rect.top); rect.Deflate(x, t, x, y); return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { IFWL_ToolTipTarget* toolTipTarget = CFWL_ToolTipContainer::getInstance()->GetCurrentToolTipTarget(); if (toolTipTarget && !toolTipTarget->UseDefaultTheme()) { return toolTipTarget->DrawToolTip(pGraphics, pMatrix, m_pInterface); } if (!pGraphics) return FWL_ERR_Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_ERR_Indefinite; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; DrawBkground(pGraphics, pTheme, pMatrix); DrawText(pGraphics, pTheme, pMatrix); return FWL_ERR_Succeeded; } void CFWL_ToolTipImp::DrawBkground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { CFWL_ThemeBackground param; param.m_pWidget = m_pInterface; param.m_iPart = FWL_PART_TTP_Background; param.m_dwStates = m_pProperties->m_dwStates; param.m_pGraphics = pGraphics; if (pMatrix) { param.m_matrix.Concat(*pMatrix); } param.m_rtPart = m_rtClient; if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { param.m_pData = &m_rtCaption; } pTheme->DrawBackground(&param); } void CFWL_ToolTipImp::DrawText(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { if (!m_pProperties->m_pDataProvider) return; CFX_WideString wsCaption; m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); if (wsCaption.IsEmpty()) { return; } CFWL_ThemeText param; param.m_pWidget = m_pInterface; param.m_iPart = FWL_PART_TTP_Caption; param.m_dwStates = m_pProperties->m_dwStates; param.m_pGraphics = pGraphics; if (pMatrix) { param.m_matrix.Concat(*pMatrix); } param.m_rtPart = m_rtCaption; param.m_wsText = wsCaption; param.m_dwTTOStyles = m_dwTTOStyles; param.m_iTTOAlign = m_iTTOAlign; pTheme->DrawText(&param); } void CFWL_ToolTipImp::UpdateTextOutStyles() { m_iTTOAlign = FDE_TTOALIGNMENT_Center; m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { m_dwTTOStyles |= FDE_TTOSTYLE_RTL; } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) { m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; } } FWL_ERR CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) { m_rtAnchor = rtAnchor; return TRUE; } FWL_ERR CFWL_ToolTipImp::Show() { IFWL_ToolTipDP* pData = static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); int32_t nInitDelay = pData->GetInitialDelay(m_pInterface); if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) { m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE); } return TRUE; } FWL_ERR CFWL_ToolTipImp::Hide() { SetStates(FWL_WGTSTATE_Invisible, TRUE); if (m_hTimerHide) { FWL_StopTimer(m_hTimerHide); m_hTimerHide = NULL; } if (m_hTimerShow) { FWL_StopTimer(m_hTimerShow); m_hTimerShow = NULL; } return TRUE; } FWL_ERR CFWL_ToolTipImp::SetStates(FX_DWORD dwStates, FX_BOOL bSet) { if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) { IFWL_ToolTipDP* pData = static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface); m_hTimerHide = FWL_StartTimer(&m_TimerHide, nAutoPopDelay, FALSE); } return CFWL_WidgetImp::SetStates(dwStates, bSet); } void CFWL_ToolTipImp::RefreshToolTipPos() { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { CFX_RectF rtPopup; CFX_RectF rtWidget(m_pProperties->m_rtWidget); CFX_RectF rtAnchor(m_rtAnchor); rtPopup.Set(0, 0, 0, 0); FX_FLOAT fx = rtAnchor.Center().x + 20; FX_FLOAT fy = rtAnchor.Center().y + 20; rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); FX_FLOAT fScreenWidth = 0; FX_FLOAT fScreenHeight = 0; GetScreenSize(fScreenWidth, fScreenHeight); if (rtPopup.bottom() > fScreenHeight) { rtPopup.Offset(0, fScreenHeight - rtPopup.bottom()); } if (rtPopup.right() > fScreenWidth) { rtPopup.Offset(fScreenWidth - rtPopup.right(), 0); } if (rtPopup.left < 0) { rtPopup.Offset(0 - rtPopup.left, 0); } if (rtPopup.top < 0) { rtPopup.Offset(0, 0 - rtPopup.top); } SetWidgetRect(rtPopup); Update(); } } CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip) : m_pToolTip(pToolTip) {} int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) { if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) { if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE); m_pToolTip->RefreshToolTipPos(); FWL_StopTimer(m_pToolTip->m_hTimerShow); m_pToolTip->m_hTimerShow = NULL; return TRUE; } } if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) { m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE); FWL_StopTimer(m_pToolTip->m_hTimerHide); m_pToolTip->m_hTimerHide = NULL; return TRUE; } return TRUE; } CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner) : m_pOwner(pOwner) {} int32_t CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { return CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); } FWL_ERR CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } FWL_ERR CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { return m_pOwner->DrawWidget(pGraphics, pMatrix); }
return FWL_ERR_Indefinite; } if (!m_pProperties->m_pThemeProvider) { m_pProperties->m_pThemeProvider = GetAvailableTheme(); } UpdateTextOutStyles(); GetClientRect(m_rtClient); m_rtCaption = m_rtClient; return FWL_ERR_Succeeded; }
function_block-function_prefix_line
[ { "content": "class CLST_Rect : public CPDF_Rect {\n\n public:\n\n CLST_Rect() { left = top = right = bottom = 0.0f; }\n\n\n\n CLST_Rect(FX_FLOAT other_left,\n\n FX_FLOAT other_top,\n\n FX_FLOAT other_right,\n\n FX_FLOAT other_bottom) {\n\n left = other_left;\n\n top = other_top;\n\n right = other_right;\n\n bottom = other_bottom;\n\n }\n\n\n\n CLST_Rect(const CPDF_Rect& rect) {\n\n left = rect.left;\n\n top = rect.top;\n\n right = rect.right;\n\n bottom = rect.bottom;\n\n }\n", "file_path": "fpdfsdk/include/fxedit/fxet_list.h", "rank": 0, "score": 136993.78863044854 }, { "content": "struct FX_RECT {\n\n int left;\n\n\n\n int top;\n\n\n\n int right;\n\n\n\n int bottom;\n\n\n\n FX_RECT() : left(0), top(0), right(0), bottom(0) {}\n\n\n\n FX_RECT(int left1, int top1, int right1, int bottom1) {\n\n left = left1;\n\n top = top1;\n\n right = right1;\n\n bottom = bottom1;\n\n }\n\n\n\n int Width() const { return right - left; }\n\n\n", "file_path": "core/include/fxcrt/fx_coordinates.h", "rank": 1, "score": 129507.57992301341 }, { "content": "struct ReleaseDeleter {\n\n inline void operator()(T* ptr) const { ptr->Release(); }\n\n};\n\n\n\n#define FX_DATALIST_LENGTH 1024\n\ntemplate <size_t unit>\n", "file_path": "core/include/fxcrt/fx_basic.h", "rank": 2, "score": 129507.04148544998 }, { "content": "class CPDF_Null;\n", "file_path": "core/include/fpdfapi/fpdf_objects.h", "rank": 3, "score": 129505.96621814875 }, { "content": "class CFX_FloatRect {\n\n public:\n\n CFX_FloatRect() { left = right = bottom = top = 0; }\n\n\n\n CFX_FloatRect(FX_FLOAT left1,\n\n FX_FLOAT bottom1,\n\n FX_FLOAT right1,\n\n FX_FLOAT top1) {\n\n left = left1;\n\n bottom = bottom1;\n\n right = right1;\n\n top = top1;\n\n }\n\n\n\n CFX_FloatRect(const FX_FLOAT* pArray) {\n\n left = pArray[0];\n\n bottom = pArray[1];\n\n right = pArray[2];\n\n top = pArray[3];\n\n }\n", "file_path": "core/include/fxcrt/fx_coordinates.h", "rank": 4, "score": 126508.96893328322 }, { "content": "struct FX_SMALL_RECT {\n\n int16_t Left;\n\n\n\n int16_t Top;\n\n\n\n int16_t Right;\n\n\n\n int16_t Bottom;\n\n};\n", "file_path": "core/include/fxcrt/fx_coordinates.h", "rank": 5, "score": 126508.96893328322 }, { "content": "struct FxFreeDeleter {\n\n inline void operator()(void* ptr) const { FX_Free(ptr); }\n\n};\n\n\n\n// Used with std::unique_ptr to Release() objects that can't be deleted.\n\ntemplate <class T>\n", "file_path": "core/include/fxcrt/fx_basic.h", "rank": 6, "score": 126508.44296267189 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/listbox.h", "rank": 7, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties {\n\n public:\n\n CFWL_WidgetProperties() {\n\n m_ctmOnParent.SetIdentity();\n\n m_rtWidget.Set(0, 0, 0, 0);\n\n m_dwStyles = FWL_WGTSTYLE_Child;\n\n m_dwStyleExes = 0;\n\n m_dwStates = 0;\n\n m_pParent = NULL;\n\n m_pOwner = NULL;\n\n }\n\n CFWL_WidgetImpProperties MakeWidgetImpProperties(\n\n IFWL_DataProvider* pDataProvider) const;\n\n\n\n CFX_WideString m_wsWindowclass;\n\n CFX_Matrix m_ctmOnParent;\n\n CFX_RectF m_rtWidget;\n\n FX_DWORD m_dwStyles;\n\n FX_DWORD m_dwStyleExes;\n\n FX_DWORD m_dwStates;\n\n CFWL_Widget* m_pParent;\n\n CFWL_Widget* m_pOwner;\n\n};\n\n\n", "file_path": "xfa/include/fwl/lightwidget/widget.h", "rank": 8, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/pushbutton.h", "rank": 9, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/scrollbar.h", "rank": 10, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/barcode.h", "rank": 11, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/picturebox.h", "rank": 12, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/tooltipctrl.h", "rank": 13, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/combobox.h", "rank": 14, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/edit.h", "rank": 15, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/datetimepicker.h", "rank": 16, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/caret.h", "rank": 17, "score": 126498.29580351255 }, { "content": "class CFWL_WidgetProperties;\n", "file_path": "xfa/include/fwl/lightwidget/checkbox.h", "rank": 18, "score": 126498.29580351255 }, { "content": "class CFX_Edit_RectArray {\n\n public:\n\n CFX_Edit_RectArray() {}\n\n\n\n virtual ~CFX_Edit_RectArray() { Empty(); }\n\n\n\n void Empty() {\n\n for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++)\n\n delete m_Rects.GetAt(i);\n\n\n\n m_Rects.RemoveAll();\n\n }\n\n\n\n void Add(const CPDF_Rect& rect) {\n\n // check for overlapped area\n\n for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) {\n\n CPDF_Rect* pRect = m_Rects.GetAt(i);\n\n if (pRect && pRect->Contains(rect))\n\n return;\n\n }\n", "file_path": "fpdfsdk/include/fxedit/fxet_edit.h", "rank": 19, "score": 123646.07489090151 }, { "content": "struct CFX_Edit_LineRect {\n\n CFX_Edit_LineRect(const CPVT_WordRange& wrLine, const CPDF_Rect& rcLine)\n\n : m_wrLine(wrLine), m_rcLine(rcLine) {}\n\n\n\n FX_BOOL operator!=(const CFX_Edit_LineRect& linerect) const {\n\n return FXSYS_memcmp(this, &linerect, sizeof(CFX_Edit_LineRect)) != 0;\n\n }\n\n\n\n FX_BOOL IsSameHeight(const CFX_Edit_LineRect& linerect) const {\n\n return FX_EDIT_IsFloatZero(\n\n (m_rcLine.top - m_rcLine.bottom) -\n\n (linerect.m_rcLine.top - linerect.m_rcLine.bottom));\n\n }\n\n\n\n FX_BOOL IsSameTop(const CFX_Edit_LineRect& linerect) const {\n\n return FX_EDIT_IsFloatZero(m_rcLine.top - linerect.m_rcLine.top);\n\n }\n\n\n\n FX_BOOL IsSameLeft(const CFX_Edit_LineRect& linerect) const {\n\n return FX_EDIT_IsFloatZero(m_rcLine.left - linerect.m_rcLine.left);\n\n }\n\n\n\n FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const {\n\n return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right);\n\n }\n\n\n\n CPVT_WordRange m_wrLine;\n\n CPDF_Rect m_rcLine;\n\n};\n\n\n", "file_path": "fpdfsdk/include/fxedit/fxet_edit.h", "rank": 20, "score": 123646.07489090151 }, { "content": "class CPDF_TrueTypeFont;\n", "file_path": "core/include/fpdfapi/fpdf_resource.h", "rank": 21, "score": 123645.04736781519 }, { "content": "class CFX_Edit_LineRectArray {\n\n public:\n\n CFX_Edit_LineRectArray() {}\n\n\n\n virtual ~CFX_Edit_LineRectArray() { Empty(); }\n\n\n\n void Empty() {\n\n for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++)\n\n delete m_LineRects.GetAt(i);\n\n\n\n m_LineRects.RemoveAll();\n\n }\n\n\n\n void RemoveAll() { m_LineRects.RemoveAll(); }\n\n\n\n void operator=(CFX_Edit_LineRectArray& rects) {\n\n Empty();\n\n for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++)\n\n m_LineRects.Add(rects.GetAt(i));\n\n\n", "file_path": "fpdfsdk/include/fxedit/fxet_edit.h", "rank": 22, "score": 120909.88787908097 }, { "content": "class CPDF_Null : public CPDF_Object {\n\n public:\n\n CPDF_Null() {}\n\n\n\n // CPDF_Object.\n\n Type GetType() const override { return NULLOBJ; }\n\n CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override {\n\n return new CPDF_Null;\n\n }\n\n};\n\n\n", "file_path": "core/include/fpdfapi/fpdf_objects.h", "rank": 23, "score": 120908.3813041425 }, { "content": "#ifndef _FWL_BARCODE_H\n\n#define _FWL_BARCODE_H\n\n#include \"fwl_edit.h\"\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_barcode.h", "rank": 24, "score": 120906.66732195593 }, { "content": "#ifndef _FWL_SCROLLBAR_H\n\n#define _FWL_SCROLLBAR_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_scrollbar.h", "rank": 25, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_EDIT_H\n\n#define _FWL_EDIT_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_edit.h", "rank": 26, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_DATETIMEPICKER_H\n\n#define _FWL_DATETIMEPICKER_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_datetimepicker.h", "rank": 27, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_PUSHBUTTON_H\n\n#define _FWL_PUSHBUTTON_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_pushbutton.h", "rank": 28, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_COMBOBOX_H\n\n#define _FWL_COMBOBOX_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_combobox.h", "rank": 29, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_TOOLTIP_H\n\n#define _FWL_TOOLTIP_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_tooltipctrl.h", "rank": 30, "score": 120899.68712466196 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/core/fwl_widget.h", "rank": 31, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_LISTBOX_H\n\n#define _FWL_LISTBOX_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_listbox.h", "rank": 32, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_SPINBUTTON_H\n\n#define _FWL_SPINBUTTON_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_spinbutton.h", "rank": 33, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_PICTUREBOX_H\n\n#define _FWL_PICTUREBOX_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_picturebox.h", "rank": 34, "score": 120899.68712466196 }, { "content": "class CFWL_WidgetImpProperties {\n\n public:\n\n CFWL_WidgetImpProperties() {\n\n m_ctmOnParent.SetIdentity();\n\n m_rtWidget.Set(0, 0, 0, 0);\n\n m_dwStyles = FWL_WGTSTYLE_Child;\n\n m_dwStyleExes = 0;\n\n m_dwStates = 0;\n\n m_pThemeProvider = NULL;\n\n m_pDataProvider = NULL;\n\n m_pParent = NULL;\n\n m_pOwner = NULL;\n\n }\n\n CFX_Matrix m_ctmOnParent;\n\n CFX_RectF m_rtWidget;\n\n FX_DWORD m_dwStyles;\n\n FX_DWORD m_dwStyleExes;\n\n FX_DWORD m_dwStates;\n\n IFWL_ThemeProvider* m_pThemeProvider;\n\n IFWL_DataProvider* m_pDataProvider;\n\n IFWL_Widget* m_pParent;\n\n IFWL_Widget* m_pOwner;\n\n};\n", "file_path": "xfa/include/fwl/core/fwl_widget.h", "rank": 35, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_CARET_H\n\n#define _FWL_CARET_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_caret.h", "rank": 36, "score": 120899.68712466196 }, { "content": "#ifndef _FWL_CHECKBOX_H\n\n#define _FWL_CHECKBOX_H\n\nclass CFWL_WidgetImpProperties;\n", "file_path": "xfa/include/fwl/basewidget/fwl_checkbox.h", "rank": 37, "score": 120899.68712466196 }, { "content": " FT_Raster_NewFunc raster_new;\n", "file_path": "third_party/freetype/include/freetype/ftimage.h", "rank": 38, "score": 118244.60015118921 }, { "content": "struct IntegerForSizeAndSign<8, true> {\n\n typedef int64_t type;\n\n};\n\ntemplate <>\n", "file_path": "third_party/base/numerics/safe_math_impl.h", "rank": 39, "score": 115947.31570928122 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Property_Set( FT_Library library,\n\n const FT_String* module_name,\n\n const FT_String* property_name,\n", "file_path": "third_party/freetype/include/freetype/ftmodapi.h", "rank": 40, "score": 115794.01420079617 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Property_Get( FT_Library library,\n\n const FT_String* module_name,\n\n const FT_String* property_name,\n", "file_path": "third_party/freetype/include/freetype/ftmodapi.h", "rank": 41, "score": 115789.8247888691 }, { "content": "class CFXEU_Delete : public CFX_Edit_UndoItem {\n\n public:\n\n CFXEU_Delete(CFX_Edit* pEdit,\n\n const CPVT_WordPlace& wpOldPlace,\n\n const CPVT_WordPlace& wpNewPlace,\n\n FX_WORD word,\n\n int32_t charset,\n\n const CPVT_SecProps& SecProps,\n\n const CPVT_WordProps& WordProps,\n\n FX_BOOL bSecEnd);\n\n ~CFXEU_Delete() override;\n\n\n\n // CFX_Edit_UndoItem\n\n void Redo() override;\n\n void Undo() override;\n\n\n\n private:\n\n CFX_Edit* m_pEdit;\n\n\n\n CPVT_WordPlace m_wpOld;\n\n CPVT_WordPlace m_wpNew;\n\n FX_WORD m_Word;\n\n int32_t m_nCharset;\n\n CPVT_SecProps m_SecProps;\n\n CPVT_WordProps m_WordProps;\n\n FX_BOOL m_bSecEnd;\n\n};\n\n\n", "file_path": "fpdfsdk/include/fxedit/fxet_edit.h", "rank": 42, "score": 115784.932529265 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h", "rank": 43, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_listboximp.h", "rank": 44, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h", "rank": 45, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_monthcalendarimp.h", "rank": 46, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_pictureboximp.h", "rank": 47, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_tooltipctrlimp.h", "rank": 48, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_scrollbarimp.h", "rank": 49, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_barcodeimp.h", "rank": 50, "score": 115775.64549583771 }, { "content": " typedef enum BDF_PropertyType_\n\n {\n\n BDF_PROPERTY_TYPE_NONE = 0,\n\n BDF_PROPERTY_TYPE_ATOM = 1,\n\n BDF_PROPERTY_TYPE_INTEGER = 2,\n\n BDF_PROPERTY_TYPE_CARDINAL = 3\n\n\n", "file_path": "third_party/freetype/include/freetype/ftbdf.h", "rank": 51, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_spinbuttonimp.h", "rank": 52, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/core/include/fwl_formimp.h", "rank": 53, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/core/include/fwl_panelimp.h", "rank": 54, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_checkboximp.h", "rank": 55, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/core/include/fwl_widgetimp.h", "rank": 56, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_pushbuttonimp.h", "rank": 57, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_editimp.h", "rank": 58, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_caretimp.h", "rank": 59, "score": 115775.64549583771 }, { "content": "class CFWL_WidgetImpProperties;\n", "file_path": "xfa/src/fwl/src/basewidget/include/fwl_formproxyimp.h", "rank": 60, "score": 115775.64549583771 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Stroker_New( FT_Library library,\n", "file_path": "third_party/freetype/include/freetype/ftstroke.h", "rank": 61, "score": 115758.71111671261 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face( FT_Library library,\n\n const char* filepathname,\n\n FT_Long face_index,\n", "file_path": "third_party/freetype/include/freetype/freetype.h", "rank": 62, "score": 115738.84406542852 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_Manager_New( FT_Library library,\n\n FT_UInt max_faces,\n\n FT_UInt max_sizes,\n\n FT_ULong max_bytes,\n\n FTC_Face_Requester requester,\n\n FT_Pointer req_data,\n", "file_path": "third_party/freetype/include/freetype/ftcache.h", "rank": 63, "score": 115738.84406542852 }, { "content": "FT_BEGIN_HEADER\n\n\n\n\n\n /*************************************************************************/\n\n /* */\n\n /* <Section> */\n\n /* sizes_management */\n\n /* */\n\n /* <Title> */\n\n /* Size Management */\n\n /* */\n\n /* <Abstract> */\n\n /* Managing multiple sizes per face. */\n\n /* */\n\n /* <Description> */\n\n /* When creating a new face object (e.g., with @FT_New_Face), an */\n\n /* @FT_Size object is automatically created and used to store all */\n\n /* pixel-size dependent information, available in the `face->size' */\n\n /* field. */\n\n /* */\n\n /* It is however possible to create more sizes for a given face, */\n\n /* mostly in order to manage several character pixel sizes of the */\n\n /* same font family and style. See @FT_New_Size and @FT_Done_Size. */\n\n /* */\n\n /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */\n\n /* modify the contents of the current `active' size; you thus need */\n\n /* to use @FT_Activate_Size to change it. */\n\n /* */\n\n /* 99% of applications won't need the functions provided here, */\n\n /* especially if they use the caching sub-system, so be cautious */\n\n /* when using these. */\n\n /* */\n\n /*************************************************************************/\n\n\n\n\n\n /*************************************************************************/\n\n /* */\n\n /* <Function> */\n\n /* FT_New_Size */\n\n /* */\n\n /* <Description> */\n\n /* Create a new size object from a given face object. */\n\n /* */\n\n /* <Input> */\n\n /* face :: A handle to a parent face object. */\n\n /* */\n\n /* <Output> */\n\n /* asize :: A handle to a new size object. */\n\n /* */\n\n /* <Return> */\n\n /* FreeType error code. 0~means success. */\n\n /* */\n\n /* <Note> */\n\n /* You need to call @FT_Activate_Size in order to select the new size */\n\n /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */\n\n /* @FT_Load_Glyph, @FT_Load_Char, etc. */\n\n /* */\n\n FT_EXPORT( FT_Error )\n\n FT_New_Size( FT_Face face,\n", "file_path": "third_party/freetype/include/freetype/ftsizes.h", "rank": 64, "score": 115738.84406542852 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Outline_New( FT_Library library,\n\n FT_UInt numPoints,\n\n FT_Int numContours,\n", "file_path": "third_party/freetype/include/freetype/ftoutln.h", "rank": 65, "score": 115738.84406542852 }, { "content": " FT_EXPORT( void )\n", "file_path": "third_party/freetype/include/freetype/ftbitmap.h", "rank": 66, "score": 115738.84406542852 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Library( FT_Memory memory,\n", "file_path": "third_party/freetype/include/freetype/ftmodapi.h", "rank": 67, "score": 115738.84406542852 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Get_BDF_Property( FT_Face face,\n\n const char* prop_name,\n", "file_path": "third_party/freetype/include/freetype/ftbdf.h", "rank": 68, "score": 113388.97851653035 }, { "content": "class CFXEU_InsertReturn : public CFX_Edit_UndoItem {\n\n public:\n\n CFXEU_InsertReturn(CFX_Edit* pEdit,\n\n const CPVT_WordPlace& wpOldPlace,\n\n const CPVT_WordPlace& wpNewPlace,\n\n const CPVT_SecProps* pSecProps,\n\n const CPVT_WordProps* pWordProps);\n\n ~CFXEU_InsertReturn() override;\n\n\n\n // CFX_Edit_UndoItem\n\n void Redo() override;\n\n void Undo() override;\n\n\n\n private:\n\n CFX_Edit* m_pEdit;\n\n\n\n CPVT_WordPlace m_wpOld;\n\n CPVT_WordPlace m_wpNew;\n\n CPVT_SecProps m_SecProps;\n\n CPVT_WordProps m_WordProps;\n\n};\n\n\n", "file_path": "fpdfsdk/include/fxedit/fxet_edit.h", "rank": 69, "score": 113384.14174035801 }, { "content": "class CPDF_TrueTypeFont : public CPDF_SimpleFont {\n\n public:\n\n CPDF_TrueTypeFont();\n\n\n\n protected:\n\n // CPDF_SimpleFont:\n\n FX_BOOL _Load() override;\n\n void LoadGlyphMap() override;\n\n};\n\n\n", "file_path": "core/include/fpdfapi/fpdf_resource.h", "rank": 70, "score": 113381.7458067631 }, { "content": " FT_BASE( FT_Error )\n\n FT_Stream_New( FT_Library library,\n\n const FT_Open_Args* args,\n", "file_path": "third_party/freetype/include/freetype/internal/ftstream.h", "rank": 71, "score": 113344.22489851182 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_ImageCache_New( FTC_Manager manager,\n", "file_path": "third_party/freetype/include/freetype/ftcache.h", "rank": 72, "score": 113337.08458484567 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Outline_New_Internal( FT_Memory memory,\n\n FT_UInt numPoints,\n\n FT_Int numContours,\n", "file_path": "third_party/freetype/include/freetype/ftoutln.h", "rank": 73, "score": 113337.08458484567 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face_From_FOND( FT_Library library,\n\n Handle fond,\n\n FT_Long face_index,\n", "file_path": "third_party/freetype/include/freetype/ftmac.h", "rank": 74, "score": 113337.08458484567 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Memory_Face( FT_Library library,\n\n const FT_Byte* file_base,\n\n FT_Long file_size,\n\n FT_Long face_index,\n", "file_path": "third_party/freetype/include/freetype/freetype.h", "rank": 75, "score": 113337.08458484567 }, { "content": " operator FX_DWORD() { return color; }\n", "file_path": "xfa/include/fwl/theme/utils.h", "rank": 76, "score": 112621.63870839862 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_TrueTypeGX_Validate( FT_Face face,\n\n FT_UInt validation_flags,\n\n FT_Bytes tables[FT_VALIDATE_GX_LENGTH],\n", "file_path": "third_party/freetype/include/freetype/ftgxval.h", "rank": 77, "score": 111092.11610645645 }, { "content": " FT_EXPORT( void )\n\n FT_TrueTypeGX_Free( FT_Face face,\n", "file_path": "third_party/freetype/include/freetype/ftgxval.h", "rank": 78, "score": 111085.00032153085 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_CMapCache_New( FTC_Manager manager,\n", "file_path": "third_party/freetype/include/freetype/ftcache.h", "rank": 79, "score": 111051.94584344917 }, { "content": " FT_BASE( FT_Error )\n\n FT_GlyphLoader_New( FT_Memory memory,\n", "file_path": "third_party/freetype/include/freetype/internal/ftgloadr.h", "rank": 80, "score": 111040.32406372156 }, { "content": " FT_BASE( FT_Error )\n\n FT_CMap_New( FT_CMap_Class clazz,\n\n FT_Pointer init_data,\n\n FT_CharMap charmap,\n", "file_path": "third_party/freetype/include/freetype/internal/ftobjs.h", "rank": 81, "score": 111040.25454189871 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_SBitCache_New( FTC_Manager manager,\n", "file_path": "third_party/freetype/include/freetype/ftcache.h", "rank": 82, "score": 111032.9790594556 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face_From_FSRef( FT_Library library,\n\n const FSRef *ref,\n\n FT_Long face_index,\n", "file_path": "third_party/freetype/include/freetype/ftmac.h", "rank": 83, "score": 111032.9790594556 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face_From_FSSpec( FT_Library library,\n\n const FSSpec *spec,\n\n FT_Long face_index,\n", "file_path": "third_party/freetype/include/freetype/ftmac.h", "rank": 84, "score": 111032.9790594556 }, { "content": " FT_BASE( FT_Error )\n\n FT_New_GlyphSlot( FT_Face face,\n", "file_path": "third_party/freetype/include/freetype/internal/ftobjs.h", "rank": 85, "score": 111032.9790594556 }, { "content": " FT_EXPORT( FT_TrueTypeEngineType )\n", "file_path": "third_party/freetype/include/freetype/ftmodapi.h", "rank": 86, "score": 108878.83953440924 }, { "content": " FT_EXPORT( FT_Bool )\n", "file_path": "third_party/freetype/include/freetype/freetype.h", "rank": 87, "score": 108863.57184569092 }, { "content": "FX_LPCJAPCHARPROPERTYEX FX_GetJapCharPropertyEx(FX_WCHAR wch);\n", "file_path": "xfa/src/fgas/include/fx_ucd.h", "rank": 88, "score": 108855.29200661124 }, { "content": "class IFWL_Widget;\n", "file_path": "xfa/include/fwl/theme/widgettp.h", "rank": 89, "score": 105110.859035459 }, { "content": "class IFWL_Widget;\n\n\n", "file_path": "xfa/include/fwl/lightwidget/theme.h", "rank": 90, "score": 105110.859035459 }, { "content": "#ifndef _FWL_PANEL_H\n\n#define _FWL_PANEL_H\n\nclass IFWL_Widget;\n", "file_path": "xfa/include/fwl/core/fwl_panel.h", "rank": 91, "score": 103621.83670822762 }, { "content": "#ifndef _FWL_WIDGETMGR_H\n\n#define _FWL_WIDGETMGR_H\n\nclass IFWL_Widget;\n", "file_path": "xfa/include/fwl/core/fwl_widgetmgr.h", "rank": 92, "score": 103621.83670822762 }, { "content": "class IFWL_Widget;\n", "file_path": "xfa/include/fwl/core/fwl_app.h", "rank": 93, "score": 103621.83670822762 }, { "content": "class IFWL_Widget;\n", "file_path": "xfa/include/fwl/basewidget/fwl_caret.h", "rank": 94, "score": 103621.83670822762 }, { "content": "#ifndef _FWL_ADAPTER_WIDGETMGR_H\n\n#define _FWL_ADAPTER_WIDGETMGR_H\n\nclass IFWL_Widget;\n", "file_path": "xfa/include/fwl/adapter/fwl_adapterwidgetmgr.h", "rank": 95, "score": 103621.83670822762 }, { "content": "class IFWL_Widget;\n", "file_path": "xfa/include/fwl/basewidget/fwl_listbox.h", "rank": 96, "score": 103621.83670822762 }, { "content": "class IFWL_Widget;\n", "file_path": "xfa/include/fwl/basewidget/fwl_checkbox.h", "rank": 97, "score": 103621.83670822762 }, { "content": "#ifndef _FWL_CONTENT_H\n\n#define _FWL_CONTENT_H\n\nclass IFWL_Widget;\n", "file_path": "xfa/include/fwl/core/fwl_content.h", "rank": 98, "score": 103621.83670822762 }, { "content": "class IFWL_Widget;\n", "file_path": "xfa/include/fwl/basewidget/fwl_barcode.h", "rank": 99, "score": 103621.83670822762 } ]
C++
qtmultimedia/tests/auto/unit/qmediaserviceprovider/tst_qmediaserviceprovider.cpp
wgnet/wds_qt
8db722fd367d2d0744decf99ac7bafaba8b8a3d3
#include <QtTest/QtTest> #include <QDebug> #include <QStringList> #include <private/qmediaserviceprovider_p.h> #include <qmediaserviceproviderplugin.h> #include <private/qmediapluginloader_p.h> #include <qmediaobject.h> #include <qmediaservice.h> #include <qmediaplayer.h> #include <qaudiorecorder.h> #include <qcamera.h> #include <qcamerainfo.h> QT_USE_NAMESPACE class MockMediaServiceProvider : public QMediaServiceProvider { QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &) { Q_UNUSED(type); return 0; } void releaseService(QMediaService *service) { Q_UNUSED(service); } }; class tst_QMediaServiceProvider : public QObject { Q_OBJECT public slots: void initTestCase(); private slots: void testDefaultProviderAvailable(); void testObtainService(); void testHasSupport(); void testSupportedMimeTypes(); void testProviderHints(); void testDefaultDevice(); void testAvailableDevices(); void testCameraInfo(); private: QObjectList plugins; }; void tst_QMediaServiceProvider::initTestCase() { QCoreApplication::setLibraryPaths(QStringList() << QCoreApplication::applicationDirPath()); } void tst_QMediaServiceProvider::testDefaultProviderAvailable() { QVERIFY(QMediaServiceProvider::defaultServiceProvider() != 0); } void tst_QMediaServiceProvider::testObtainService() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QMediaService *service = 0; service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); QVERIFY(service != 0); provider->releaseService(service); } void tst_QMediaServiceProvider::testHasSupport() { MockMediaServiceProvider mockProvider; QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), QMultimedia::MaybeSupported); QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), QMultimedia::MaybeSupported); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), QMultimedia::ProbablySupported); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringList()), QMultimedia::ProbablySupported); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", QStringList() << "mpeg4"), QMultimedia::MaybeSupported); QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), QMultimedia::NotSupported); QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QMultimedia::MaybeSupported); QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), QMultimedia::MaybeSupported); QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), QMultimedia::MaybeSupported); QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); QMediaPlayer mediaPlayer; QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2")); QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback); QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4")); } void tst_QMediaServiceProvider::testSupportedMimeTypes() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QVERIFY(provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/ogg")); QVERIFY(!provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/mp3")); } void tst_QMediaServiceProvider::testProviderHints() { { QMediaServiceProviderHint hint; QVERIFY(hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::Null); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), 0); } { QByteArray deviceName(QByteArray("testDevice")); QMediaServiceProviderHint hint(deviceName); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::Device); QCOMPARE(hint.device(), deviceName); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), 0); } { QMediaServiceProviderHint hint(QCamera::FrontFace); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::CameraPosition); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::FrontFace); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), 0); } { QMediaServiceProviderHint hint(QMediaServiceProviderHint::LowLatencyPlayback); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback); } { QMediaServiceProviderHint hint(QMediaServiceProviderHint::RecordingSupport); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), QMediaServiceProviderHint::RecordingSupport); } { QString mimeType(QLatin1String("video/ogg")); QStringList codecs; codecs << "theora" << "vorbis"; QMediaServiceProviderHint hint(mimeType,codecs); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QCOMPARE(hint.mimeType(), mimeType); QCOMPARE(hint.codecs(), codecs); QMediaServiceProviderHint hint2(hint); QVERIFY(!hint2.isNull()); QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType); QVERIFY(hint2.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QCOMPARE(hint2.mimeType(), mimeType); QCOMPARE(hint2.codecs(), codecs); QMediaServiceProviderHint hint3; QVERIFY(hint3.isNull()); hint3 = hint; QVERIFY(!hint3.isNull()); QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType); QVERIFY(hint3.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QCOMPARE(hint3.mimeType(), mimeType); QCOMPARE(hint3.codecs(), codecs); QCOMPARE(hint, hint2); QCOMPARE(hint3, hint2); QMediaServiceProviderHint hint4(mimeType,codecs); QCOMPARE(hint, hint4); QMediaServiceProviderHint hint5(mimeType,QStringList()); QVERIFY(hint != hint5); } } void tst_QMediaServiceProvider::testDefaultDevice() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_AUDIOSOURCE), QByteArray("audiosource1")); QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_CAMERA), QByteArray("frontcamera")); } void tst_QMediaServiceProvider::testAvailableDevices() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QList<QByteArray> devices = provider->devices(Q_MEDIASERVICE_AUDIOSOURCE); QCOMPARE(devices.count(), 2); QCOMPARE(devices.at(0), QByteArray("audiosource1")); QCOMPARE(devices.at(1), QByteArray("audiosource2")); devices = provider->devices(Q_MEDIASERVICE_CAMERA); QCOMPARE(devices.count(), 3); QCOMPARE(devices.at(0), QByteArray("frontcamera")); QCOMPARE(devices.at(1), QByteArray("backcamera")); QCOMPARE(devices.at(2), QByteArray("somecamera")); } void tst_QMediaServiceProvider::testCameraInfo() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QCOMPARE(provider->cameraPosition("backcamera"), QCamera::BackFace); QCOMPARE(provider->cameraOrientation("backcamera"), 90); QCOMPARE(provider->cameraPosition("frontcamera"), QCamera::FrontFace); QCOMPARE(provider->cameraOrientation("frontcamera"), 270); QCOMPARE(provider->cameraPosition("somecamera"), QCamera::UnspecifiedPosition); QCOMPARE(provider->cameraOrientation("somecamera"), 0); { QCamera camera; QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCameraInfo::defaultCamera()); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCameraInfo::availableCameras().at(0)); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCameraInfo::availableCameras().at(1)); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5")); } { QCamera camera(QCameraInfo::availableCameras().at(2)); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5")); } { QCamera camera(QCamera::FrontFace); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCamera::BackFace); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5")); } { QCamera camera(QCamera::UnspecifiedPosition); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } } QTEST_MAIN(tst_QMediaServiceProvider) #include "tst_qmediaserviceprovider.moc"
#include <QtTest/QtTest> #include <QDebug> #include <QStringList> #include <private/qmediaserviceprovider_p.h> #include <qmediaserviceproviderplugin.h> #include <private/qmediapluginloader_p.h> #include <qmediaobject.h> #include <qmediaservice.h> #include <qmediaplayer.h> #include <qaudiorecorder.h> #include <qcamera.h> #include <qcamerainfo.h> QT_USE_NAMESPACE class MockMediaServiceProvider : public QMediaServiceProvider { QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &) { Q_UNUSED(type); return 0; } void releaseService(QMediaService *service) { Q_UNUSED(service); } }; class tst_QMediaServiceProvider : public QObject { Q_OBJECT public slots: void initTestCase(); private slots: void testDefaultProviderAvailable(); void testObtainService(); void testHasSupport(); void testSupportedMimeTypes(); void testProviderHints(); void testDefaultDevice(); void testAvailableDevices(); void testCameraInfo(); private: QObjectList plugins; }; void tst_QMediaServiceProvider::initTestCase() { QCoreApplication::setLibraryPaths(QStringList() << QCoreApplication::applicationDirPath()); } void tst_QMediaServiceProvider::testDefaultProviderAvailable() { QVERIFY(QMediaServiceProvider::defaultServiceProvider() != 0); } void tst_QMediaServiceProvider::testObtainService() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QMediaService *service = 0; service = provider->requestService(Q_MEDIASERVICE_MEDIAPLAYER); QVERIFY(service != 0); provider->releaseService(service); } void tst_QMediaServiceProvider::testHasSupport() { MockMediaServiceProvider mockProvider; QCOMPARE(mockProvider.hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), QMultimedia::MaybeSupported); QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/ogv", QStringList()), QMultimedia::MaybeSupported); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/ogg", QStringList()), QMultimedia::ProbablySupported); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "audio/wav", QStringL
e(), QMediaServiceProviderHint::Device); QCOMPARE(hint.device(), deviceName); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), 0); } { QMediaServiceProviderHint hint(QCamera::FrontFace); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::CameraPosition); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::FrontFace); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), 0); } { QMediaServiceProviderHint hint(QMediaServiceProviderHint::LowLatencyPlayback); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), QMediaServiceProviderHint::LowLatencyPlayback); } { QMediaServiceProviderHint hint(QMediaServiceProviderHint::RecordingSupport); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::SupportedFeatures); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), QMediaServiceProviderHint::RecordingSupport); } { QString mimeType(QLatin1String("video/ogg")); QStringList codecs; codecs << "theora" << "vorbis"; QMediaServiceProviderHint hint(mimeType,codecs); QVERIFY(!hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::ContentType); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QCOMPARE(hint.mimeType(), mimeType); QCOMPARE(hint.codecs(), codecs); QMediaServiceProviderHint hint2(hint); QVERIFY(!hint2.isNull()); QCOMPARE(hint2.type(), QMediaServiceProviderHint::ContentType); QVERIFY(hint2.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QCOMPARE(hint2.mimeType(), mimeType); QCOMPARE(hint2.codecs(), codecs); QMediaServiceProviderHint hint3; QVERIFY(hint3.isNull()); hint3 = hint; QVERIFY(!hint3.isNull()); QCOMPARE(hint3.type(), QMediaServiceProviderHint::ContentType); QVERIFY(hint3.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QCOMPARE(hint3.mimeType(), mimeType); QCOMPARE(hint3.codecs(), codecs); QCOMPARE(hint, hint2); QCOMPARE(hint3, hint2); QMediaServiceProviderHint hint4(mimeType,codecs); QCOMPARE(hint, hint4); QMediaServiceProviderHint hint5(mimeType,QStringList()); QVERIFY(hint != hint5); } } void tst_QMediaServiceProvider::testDefaultDevice() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_AUDIOSOURCE), QByteArray("audiosource1")); QCOMPARE(provider->defaultDevice(Q_MEDIASERVICE_CAMERA), QByteArray("frontcamera")); } void tst_QMediaServiceProvider::testAvailableDevices() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QList<QByteArray> devices = provider->devices(Q_MEDIASERVICE_AUDIOSOURCE); QCOMPARE(devices.count(), 2); QCOMPARE(devices.at(0), QByteArray("audiosource1")); QCOMPARE(devices.at(1), QByteArray("audiosource2")); devices = provider->devices(Q_MEDIASERVICE_CAMERA); QCOMPARE(devices.count(), 3); QCOMPARE(devices.at(0), QByteArray("frontcamera")); QCOMPARE(devices.at(1), QByteArray("backcamera")); QCOMPARE(devices.at(2), QByteArray("somecamera")); } void tst_QMediaServiceProvider::testCameraInfo() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QCOMPARE(provider->cameraPosition("backcamera"), QCamera::BackFace); QCOMPARE(provider->cameraOrientation("backcamera"), 90); QCOMPARE(provider->cameraPosition("frontcamera"), QCamera::FrontFace); QCOMPARE(provider->cameraOrientation("frontcamera"), 270); QCOMPARE(provider->cameraPosition("somecamera"), QCamera::UnspecifiedPosition); QCOMPARE(provider->cameraOrientation("somecamera"), 0); { QCamera camera; QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCameraInfo::defaultCamera()); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCameraInfo::availableCameras().at(0)); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCameraInfo::availableCameras().at(1)); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5")); } { QCamera camera(QCameraInfo::availableCameras().at(2)); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5")); } { QCamera camera(QCamera::FrontFace); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } { QCamera camera(QCamera::BackFace); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin5")); } { QCamera camera(QCamera::UnspecifiedPosition); QVERIFY(camera.service()); QCOMPARE(camera.service()->objectName(), QLatin1String("MockServicePlugin3")); } } QTEST_MAIN(tst_QMediaServiceProvider) #include "tst_qmediaserviceprovider.moc"
ist()), QMultimedia::ProbablySupported); QCOMPARE(provider->hasSupport(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER), "video/avi", QStringList() << "mpeg4"), QMultimedia::MaybeSupported); QCOMPARE(provider->hasSupport(QByteArray("non existing service"), "video/ogv", QStringList()), QMultimedia::NotSupported); QCOMPARE(QMediaPlayer::hasSupport("video/ogv"), QMultimedia::MaybeSupported); QCOMPARE(QMediaPlayer::hasSupport("audio/ogg"), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/wav"), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::LowLatency), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/ogg", QStringList(), QMediaPlayer::LowLatency), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::LowLatency), QMultimedia::MaybeSupported); QCOMPARE(QMediaPlayer::hasSupport("video/quicktime", QStringList(), QMediaPlayer::StreamPlayback), QMultimedia::ProbablySupported); QCOMPARE(QMediaPlayer::hasSupport("audio/wav", QStringList(), QMediaPlayer::StreamPlayback), QMultimedia::MaybeSupported); QMediaPlayer simplePlayer(0, QMediaPlayer::LowLatency); QCOMPARE(simplePlayer.service()->objectName(), QLatin1String("MockServicePlugin2")); QMediaPlayer mediaPlayer; QVERIFY(mediaPlayer.service()->objectName() != QLatin1String("MockServicePlugin2")); QMediaPlayer streamPlayer(0, QMediaPlayer::StreamPlayback); QCOMPARE(streamPlayer.service()->objectName(), QLatin1String("MockServicePlugin4")); } void tst_QMediaServiceProvider::testSupportedMimeTypes() { QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider(); if (provider == 0) QSKIP("No default provider"); QVERIFY(provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/ogg")); QVERIFY(!provider->supportedMimeTypes(QByteArray(Q_MEDIASERVICE_MEDIAPLAYER)).contains("audio/mp3")); } void tst_QMediaServiceProvider::testProviderHints() { { QMediaServiceProviderHint hint; QVERIFY(hint.isNull()); QCOMPARE(hint.type(), QMediaServiceProviderHint::Null); QVERIFY(hint.device().isEmpty()); QCOMPARE(hint.cameraPosition(), QCamera::UnspecifiedPosition); QVERIFY(hint.mimeType().isEmpty()); QVERIFY(hint.codecs().isEmpty()); QCOMPARE(hint.features(), 0); } { QByteArray deviceName(QByteArray("testDevice")); QMediaServiceProviderHint hint(deviceName); QVERIFY(!hint.isNull()); QCOMPARE(hint.typ
random
[]
C++
main/svl/source/misc/sharecontrolfile.cxx
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
#include "precompiled_svl.hxx" #include <stdio.h> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XContent.hpp> #include <com/sun/star/ucb/InsertCommandArgument.hpp> #include <com/sun/star/ucb/InteractiveIOException.hpp> #include <com/sun/star/io/WrongFormatException.hpp> #include <osl/time.h> #include <osl/security.hxx> #include <osl/socket.hxx> #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <comphelper/processfactory.hxx> #include <ucbhelper/content.hxx> #include <tools/urlobj.hxx> #include <tools/stream.hxx> #include <unotools/bootstrap.hxx> #include <unotools/streamwrap.hxx> #include <unotools/useroptions.hxx> #include <svl/sharecontrolfile.hxx> using namespace ::com::sun::star; namespace svt { ShareControlFile::ShareControlFile( const ::rtl::OUString& aOrigURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory ) : LockFileCommon( aOrigURL, xFactory, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".~sharing." ) ) ) { OpenStream(); if ( !IsValid() ) throw io::NotConnectedException(); } ShareControlFile::~ShareControlFile() { try { Close(); } catch( uno::Exception& ) {} } void ShareControlFile::OpenStream() { if ( !m_xStream.is() && m_aURL.getLength() ) { uno::Reference< ucb::XCommandEnvironment > xDummyEnv; ::ucbhelper::Content aContent = ::ucbhelper::Content( m_aURL, xDummyEnv ); uno::Reference< ucb::XContentIdentifier > xContId( aContent.get().is() ? aContent.get()->getIdentifier() : 0 ); if ( !xContId.is() || !xContId->getContentProviderScheme().equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "file" ) ) ) ) throw io::IOException(); uno::Reference< io::XStream > xStream; try { xStream = aContent.openWriteableStreamNoLock(); } catch ( ucb::InteractiveIOException const & e ) { if ( e.Code == ucb::IOErrorCode_NOT_EXISTING ) { SvMemoryStream aStream(0,0); uno::Reference< io::XInputStream > xInput( new ::utl::OInputStreamWrapper( aStream ) ); ucb::InsertCommandArgument aInsertArg; aInsertArg.Data = xInput; aInsertArg.ReplaceExisting = sal_False; aContent.executeCommand( rtl::OUString::createFromAscii( "insert" ), uno::makeAny( aInsertArg ) ); try { aContent.setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ), uno::makeAny( sal_True ) ); } catch( uno::Exception& ) {} xStream = aContent.openWriteableStreamNoLock(); } else throw; } m_xSeekable.set( xStream, uno::UNO_QUERY_THROW ); m_xInputStream.set( xStream->getInputStream(), uno::UNO_QUERY_THROW ); m_xOutputStream.set( xStream->getOutputStream(), uno::UNO_QUERY_THROW ); m_xTruncate.set( m_xOutputStream, uno::UNO_QUERY_THROW ); m_xStream = xStream; } } void ShareControlFile::Close() { if ( m_xStream.is() ) { try { if ( m_xInputStream.is() ) m_xInputStream->closeInput(); if ( m_xOutputStream.is() ) m_xOutputStream->closeOutput(); } catch( uno::Exception& ) {} m_xStream = uno::Reference< io::XStream >(); m_xInputStream = uno::Reference< io::XInputStream >(); m_xOutputStream = uno::Reference< io::XOutputStream >(); m_xSeekable = uno::Reference< io::XSeekable >(); m_xTruncate = uno::Reference< io::XTruncate >(); m_aUsersData.realloc( 0 ); } } uno::Sequence< uno::Sequence< ::rtl::OUString > > ShareControlFile::GetUsersData() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); if ( !m_aUsersData.getLength() ) { sal_Int64 nLength = m_xSeekable->getLength(); if ( nLength > SAL_MAX_INT32 ) throw uno::RuntimeException(); uno::Sequence< sal_Int8 > aBuffer( (sal_Int32)nLength ); m_xSeekable->seek( 0 ); sal_Int32 nRead = m_xInputStream->readBytes( aBuffer, (sal_Int32)nLength ); nLength -= nRead; while ( nLength > 0 ) { uno::Sequence< sal_Int8 > aTmpBuf( (sal_Int32)nLength ); nRead = m_xInputStream->readBytes( aTmpBuf, (sal_Int32)nLength ); if ( nRead > nLength ) throw uno::RuntimeException(); for ( sal_Int32 nInd = 0; nInd < nRead; nInd++ ) aBuffer[aBuffer.getLength() - (sal_Int32)nLength + nInd] = aTmpBuf[nInd]; nLength -= nRead; } m_aUsersData = ParseList( aBuffer ); } return m_aUsersData; } void ShareControlFile::SetUsersDataAndStore( const uno::Sequence< uno::Sequence< ::rtl::OUString > >& aUsersData ) { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); if ( !m_xTruncate.is() || !m_xOutputStream.is() || !m_xSeekable.is() ) throw uno::RuntimeException(); m_xTruncate->truncate(); m_xSeekable->seek( 0 ); ::rtl::OUStringBuffer aBuffer; for ( sal_Int32 nInd = 0; nInd < aUsersData.getLength(); nInd++ ) { if ( aUsersData[nInd].getLength() != SHARED_ENTRYSIZE ) throw lang::IllegalArgumentException(); for ( sal_Int32 nEntryInd = 0; nEntryInd < SHARED_ENTRYSIZE; nEntryInd++ ) { aBuffer.append( EscapeCharacters( aUsersData[nInd][nEntryInd] ) ); if ( nEntryInd < SHARED_ENTRYSIZE - 1 ) aBuffer.append( (sal_Unicode)',' ); else aBuffer.append( (sal_Unicode)';' ); } } ::rtl::OString aStringData( ::rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ) ); uno::Sequence< sal_Int8 > aData( (sal_Int8*)aStringData.getStr(), aStringData.getLength() ); m_xOutputStream->writeBytes( aData ); m_aUsersData = aUsersData; } uno::Sequence< ::rtl::OUString > ShareControlFile::InsertOwnEntry() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); GetUsersData(); uno::Sequence< ::uno::Sequence< ::rtl::OUString > > aNewData( m_aUsersData.getLength() + 1 ); uno::Sequence< ::rtl::OUString > aNewEntry = GenerateOwnEntry(); sal_Bool bExists = sal_False; sal_Int32 nNewInd = 0; for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); nInd++ ) { if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE ) { if ( m_aUsersData[nInd][SHARED_LOCALHOST_ID] == aNewEntry[SHARED_LOCALHOST_ID] && m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] == aNewEntry[SHARED_SYSUSERNAME_ID] && m_aUsersData[nInd][SHARED_USERURL_ID] == aNewEntry[SHARED_USERURL_ID] ) { if ( !bExists ) { aNewData[nNewInd] = aNewEntry; bExists = sal_True; } } else { aNewData[nNewInd] = m_aUsersData[nInd]; } nNewInd++; } } if ( !bExists ) aNewData[nNewInd++] = aNewEntry; aNewData.realloc( nNewInd ); SetUsersDataAndStore( aNewData ); return aNewEntry; } bool ShareControlFile::HasOwnEntry() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) { throw io::NotConnectedException(); } GetUsersData(); uno::Sequence< ::rtl::OUString > aEntry = GenerateOwnEntry(); for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); ++nInd ) { if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE && m_aUsersData[nInd][SHARED_LOCALHOST_ID] == aEntry[SHARED_LOCALHOST_ID] && m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] == aEntry[SHARED_SYSUSERNAME_ID] && m_aUsersData[nInd][SHARED_USERURL_ID] == aEntry[SHARED_USERURL_ID] ) { return true; } } return false; } void ShareControlFile::RemoveEntry( const uno::Sequence< ::rtl::OUString >& aArgEntry ) { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); GetUsersData(); uno::Sequence< ::rtl::OUString > aEntry = aArgEntry; if ( aEntry.getLength() != SHARED_ENTRYSIZE ) aEntry = GenerateOwnEntry(); uno::Sequence< ::uno::Sequence< ::rtl::OUString > > aNewData( m_aUsersData.getLength() + 1 ); sal_Int32 nNewInd = 0; for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); nInd++ ) { if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE ) { if ( m_aUsersData[nInd][SHARED_LOCALHOST_ID] != aEntry[SHARED_LOCALHOST_ID] || m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] != aEntry[SHARED_SYSUSERNAME_ID] || m_aUsersData[nInd][SHARED_USERURL_ID] != aEntry[SHARED_USERURL_ID] ) { aNewData[nNewInd] = m_aUsersData[nInd]; nNewInd++; } } } aNewData.realloc( nNewInd ); SetUsersDataAndStore( aNewData ); if ( !nNewInd ) { RemoveFile(); } } void ShareControlFile::RemoveFile() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); Close(); uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess( xFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess") ), uno::UNO_QUERY_THROW ); xSimpleFileAccess->kill( m_aURL ); } }
#include "precompiled_svl.hxx" #include <stdio.h> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XContent.hpp> #include <com/sun/star/ucb/InsertCommandArgument.hpp> #include <com/sun/star/ucb/InteractiveIOException.hpp> #include <com/sun/star/io/WrongFormatException.hpp> #include <osl/time.h> #include <osl/security.hxx> #include <osl/socket.hxx> #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <comphelper/processfactory.hxx> #include <ucbhelper/content.hxx> #include <tools/urlobj.hxx> #include <tools/stream.hxx> #include <unotools/bootstrap.hxx> #include <unotools/streamwrap.hxx> #include <unotools/useroptions.hxx> #include <svl/sharecontrolfile.hxx> using namespace ::com::sun::star; namespace svt { ShareControlFile::ShareControlFile( const ::rtl::OUString& aOrigURL, const uno::Reference< lang::XMultiServiceFactory >& xFactory ) : LockFileCommon( aOrigURL, xFactory, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".~sharing." ) ) ) { OpenStream(); if ( !IsValid() ) throw io::NotConnectedException(); } ShareControlFile::~ShareControlFile() { try { Close(); } catch( uno::Exception& ) {} } void ShareControlFile::OpenStream() { if ( !m_xStream.is() && m_aURL.getLength() ) { uno::Reference< ucb::XCommandEnvironment > xDummyEnv; ::ucbhelper::Content aContent = ::ucbhelper::Content( m_aURL, xDummyEnv ); uno::Reference< ucb::XContentIdentifier > xContId( aContent.get().is() ? aContent.get()->getIdentifier() : 0 ); if ( !xContId.is() || !xContId->getContentProviderScheme().equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "file" ) ) ) ) throw io::IOException(); uno::Reference< io::XStream > xStream; try { xStream = aContent.openWriteableStreamNoLock(); } catch ( ucb::InteractiveIOException const & e ) { if ( e.Code == ucb::IOErrorCode_NOT_EXISTING ) { SvMemoryStream aStream(0,0); uno::Reference< io::XInputStream > xInput( new ::utl::OInputStreamWrapper( aStream ) ); ucb::InsertCommandArgument aInsertArg; aInsertArg.Data = xInput; aInsertArg.ReplaceExisting = sal_False; aContent.executeCommand( rtl::OUString::createFromAscii( "insert" ), uno::makeAny( aInsertArg ) ); try { aContent.setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ), uno::makeAny( sal_True ) ); } catch( uno::Exception& ) {} xStream = aContent.openWriteableStreamNoLock(); } else throw; } m_xSeekable.set( xStream, uno::UNO_QUERY_THROW ); m_xInputStream.set( xStream->getInputStream(), uno::UNO_QUERY_THROW ); m_xOutputStream.set( xStream->getOutputStream(), uno::UNO_QUERY_THROW ); m_xTruncate.set( m_xOutputStream, uno::UNO_QUERY_THROW ); m_xStream = xStream; } } void ShareControlFile::Close() { if ( m_xStream.is() ) { try { if ( m_xInputStream.is() ) m_xInputStream->closeInput(); if ( m_xOutputStream.is() ) m_xOutputStream->closeOutput(); } catch( uno::Exception& ) {} m_xStream = uno::Reference< io::XStream >(); m_xInputStream = uno::Reference< io::XInputStream >(); m_xOutputStream = uno::Reference< io::XOutputStream >(); m_xSeekable = uno::Reference< io::XSeekable >(); m_xTruncate = uno::Reference< io::XTruncate >(); m_aUsersData.realloc( 0 ); } } uno::Sequence< uno::Sequence< ::rtl::OUString > > ShareControlFile::GetUsersData() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); if ( !m_aUsersData.getLength() ) { sal_Int64 nLength = m_xSeekable->getLength(); if ( nLength > SAL_MAX_INT32 ) throw uno::RuntimeException(); uno::Sequence< sal_Int8 > aBuffer( (sal_Int32)nLength ); m_xSeekable->seek( 0 ); sal_Int32 nRead = m_xInputStream->readBytes( aBuffer, (sal_Int32)nLength ); nLength -= nRead; while ( nLength > 0 ) { uno::Sequence< sal_Int8 > aTmpBuf( (sal_Int32)nLength ); nRead = m_xInputStream->readBytes( aTmpBuf, (sal_Int32)nLength ); if ( nRead > nLength ) throw uno::RuntimeException(); for ( sal_Int32 nInd = 0; nInd < nRead; nInd++ ) aBuffer[aBuffer.getLength() - (sal_Int32)nLength + nInd] = aTmpBuf[nInd]; nLength -= nRead; } m_aUsersData = ParseList( aBuffer ); } return m_aUsersData; } void ShareControlFile::SetUsersDataAndStore( const uno::Sequence< uno::Sequence< ::rtl::OUString > >& aUsersData ) { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); if ( !m_xTruncate.is() || !m_xOutputStream.is() || !m_xSeekable.is() ) throw uno::RuntimeException(); m_xTruncate->truncate(); m_xSeekable->seek( 0 ); ::rtl::OUStringBuffer aBuffer; for ( sal_Int32 nInd = 0; nInd < aUsersData.getLength(); nInd++ ) { if ( aUsersData[nInd].getLength() != SHARED_ENTRYSIZE ) throw lang::IllegalArgumentException(); for ( sal_Int32 nEntryInd = 0; nEntryInd < SHARED_ENTRYSIZE; nEntryInd++ ) { aBuffer.append( EscapeCharacters( aUsersData[nInd][nEntryInd] ) ); if ( nEntryInd < SHARED_ENTRYSIZE - 1 ) aBuffer.append( (sal_Unicode)',' ); else aBuffer.append( (sal_Unicode)';' ); } } ::rtl::OString aStringData( ::rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ) ); uno::Sequence< sal_Int8 > aData( (sal_Int8*)aStringData.getStr(), aStringData.getLength() ); m_xOutputStream->writeBytes( aData ); m_aUsersData = aUsersData; } uno::Sequence< ::rtl::OUString > ShareControlFile::InsertOwnEntry() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); GetUsersData(); uno::Sequence< ::uno::Sequence< ::rtl::OUString > > aNewData( m_aUsersData.getLength() + 1 ); uno::Sequence< ::rtl::OUString > aNewEntry = GenerateOwnEntry(); sal_Bool bExists = sal_False; sal_Int32 nNewInd = 0; for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); nInd++ ) { if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE ) { if ( m_aUsersData[nInd][SHARED_LOCALHOST_ID] == aNewEntry[SHARED_LOCALHOST_ID] && m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] == aNewEntry[SHARED_SYSUSERNAME_ID] && m_aUsersData[nInd][SHARED_USERURL_ID] == aNewEntry[SHARED_USERURL_ID] ) {
} else { aNewData[nNewInd] = m_aUsersData[nInd]; } nNewInd++; } } if ( !bExists ) aNewData[nNewInd++] = aNewEntry; aNewData.realloc( nNewInd ); SetUsersDataAndStore( aNewData ); return aNewEntry; } bool ShareControlFile::HasOwnEntry() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) { throw io::NotConnectedException(); } GetUsersData(); uno::Sequence< ::rtl::OUString > aEntry = GenerateOwnEntry(); for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); ++nInd ) { if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE && m_aUsersData[nInd][SHARED_LOCALHOST_ID] == aEntry[SHARED_LOCALHOST_ID] && m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] == aEntry[SHARED_SYSUSERNAME_ID] && m_aUsersData[nInd][SHARED_USERURL_ID] == aEntry[SHARED_USERURL_ID] ) { return true; } } return false; } void ShareControlFile::RemoveEntry( const uno::Sequence< ::rtl::OUString >& aArgEntry ) { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); GetUsersData(); uno::Sequence< ::rtl::OUString > aEntry = aArgEntry; if ( aEntry.getLength() != SHARED_ENTRYSIZE ) aEntry = GenerateOwnEntry(); uno::Sequence< ::uno::Sequence< ::rtl::OUString > > aNewData( m_aUsersData.getLength() + 1 ); sal_Int32 nNewInd = 0; for ( sal_Int32 nInd = 0; nInd < m_aUsersData.getLength(); nInd++ ) { if ( m_aUsersData[nInd].getLength() == SHARED_ENTRYSIZE ) { if ( m_aUsersData[nInd][SHARED_LOCALHOST_ID] != aEntry[SHARED_LOCALHOST_ID] || m_aUsersData[nInd][SHARED_SYSUSERNAME_ID] != aEntry[SHARED_SYSUSERNAME_ID] || m_aUsersData[nInd][SHARED_USERURL_ID] != aEntry[SHARED_USERURL_ID] ) { aNewData[nNewInd] = m_aUsersData[nInd]; nNewInd++; } } } aNewData.realloc( nNewInd ); SetUsersDataAndStore( aNewData ); if ( !nNewInd ) { RemoveFile(); } } void ShareControlFile::RemoveFile() { ::osl::MutexGuard aGuard( m_aMutex ); if ( !IsValid() ) throw io::NotConnectedException(); Close(); uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess( xFactory->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess") ), uno::UNO_QUERY_THROW ); xSimpleFileAccess->kill( m_aURL ); } }
if ( !bExists ) { aNewData[nNewInd] = aNewEntry; bExists = sal_True; }
if_condition
[]
C++
tools/mesh_import/src/core/binary_exporter.cpp
ValtoForks/Terminus-Engine
0c7381af84736ec7b029977843590453cde64b1d
#include <binary_exporter.h> #include <assimp_importer.h> #include <filesystem.h> #include <timer.h> #include <iostream> namespace binary_exporter { void export_mesh(AssimpImportData* data, std::string output, Options options) { std::string meshOutputName = filesystem::get_filename(data->filename); auto mats = new TSM_Material_Json[data->header.material_count]; for (int i = 0; i < data->header.material_count; i++) { Json doc; String map = std::string(data->materials[i].albedo); if (map != "") { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["diffuse_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map; std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } else { Json diffuse_color; diffuse_color["r"] = 0.0f; diffuse_color["g"] = 0.0f; diffuse_color["b"] = 0.0f; diffuse_color["a"] = 1.0f; doc["diffuse_value"] = diffuse_color; } map = std::string(data->materials[i].normal); if (map != "") { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["normal_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map; std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } map = std::string(data->materials[i].metalness); if (data->materials[i].has_metalness) { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["metalness_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map; std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } else { doc["metalness_value"] = 0.5f; } map = std::string(data->materials[i].roughness); if (data->materials[i].has_roughness) { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["roughness_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map; std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } else { doc["roughness_value"] = 0.5f; } doc["backface_cull"] = true; std::string matPath = output; matPath += "/material/mat_"; matPath += data->materials[i].mesh_name; matPath += ".json"; String output_str = doc.dump(4); if (filesystem::write_begin(matPath)) { filesystem::write((void*)output_str.c_str(), output_str.size(), 1, 0); filesystem::write_end(); } String formattedString = "material/mat_"; formattedString += data->materials[i].mesh_name; formattedString += ".json\0"; strncpy(mats[i].material, formattedString.c_str(),50); } for (int i = 0; i < data->header.mesh_count; i++) { uint32_t idx = data->meshes[i].material_index; if (options.verbose) std::cout << "Mat Idx : " << std::to_string(idx) << std::endl; } std::string meshPath = output; meshPath += "/mesh/"; meshPath += meshOutputName; meshPath += "."; meshPath += ASSET_EXTENSION; if (filesystem::write_begin(meshPath)) { long Offset = 0; filesystem::write(&data->header, sizeof(TSM_FileHeader), 1, Offset); Offset += sizeof(TSM_FileHeader); filesystem::write(data->vertices, sizeof(TSM_Vertex), data->header.vertex_count, Offset); Offset += sizeof(TSM_Vertex) * data->header.vertex_count; filesystem::write(data->indices, sizeof(uint32_t), data->header.index_count, Offset); Offset += sizeof(uint32_t) * data->header.index_count; filesystem::write(data->meshes, sizeof(TSM_MeshHeader), data->header.mesh_count, Offset); Offset += sizeof(TSM_MeshHeader) * data->header.mesh_count; filesystem::write(mats, sizeof(TSM_Material_Json), data->header.material_count, Offset); filesystem::write_end(); } T_SAFE_DELETE_ARRAY(mats); T_SAFE_DELETE_ARRAY(data->vertices); T_SAFE_DELETE_ARRAY(data->indices); T_SAFE_DELETE_ARRAY(data->materials); T_SAFE_DELETE_ARRAY(data->meshes); T_SAFE_DELETE(data); } void export_mesh(std::string file, std::string output, Options options) { Timer timer; timer.start(); filesystem::create_directory(output); filesystem::create_directory(output + "/mesh"); filesystem::create_directory(output + "/material"); filesystem::create_directory(output + "/texture"); AssimpImportData* data = assimp_importer::import_mesh(file, options); export_mesh(data, output, options); timer.stop(); std::cout << "Finished exporting mesh in " << timer.elapsed_time_sec() << " second(s)." << std::endl; } }
#include <binary_exporter.h> #include <assimp_importer.h> #include <filesystem.h> #include <timer.h> #include <iostream> namespace binary_exporter { void export_mesh(AssimpImportData* data, std::string output, Options options) { std::string meshOutputName = filesystem::get_filename(data->filename); auto mats = new TSM_Material_Json[data->header.material_count]; for (int i = 0; i < data->header.material_count; i++) { Json doc; String map = std::string(data->materials[i].albedo); if (map != "") { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["diffuse_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map; std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } else { Json diffuse_color; diffuse_color["r"] = 0.0f; diffuse_color["g"] = 0.0f; diffuse_color["b"] = 0.0f; diffuse_color["a"] = 1.0f; doc["diffuse_value"] = diffuse_color; } map = std::string(data->materials[i].normal); if (map != "") { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["normal_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map; std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } map = std::string(data->materials[i].metalness); if (data->materials[i].has_metalness) { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["metalness_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map; std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } else { doc["metalness_value"] = 0.5f; } map = std::string(data->materials[i].roughness); if (data->materials[i].has_roughness) { String name = filesystem::get_file_name_and_extention(map); String path_in_mat = "texture/"; path_in_mat += name; doc["roughness_map"] = path_in_mat; String sourcePath = data->mesh_path; sourcePath += map;
string file, std::string output, Options options) { Timer timer; timer.start(); filesystem::create_directory(output); filesystem::create_directory(output + "/mesh"); filesystem::create_directory(output + "/material"); filesystem::create_directory(output + "/texture"); AssimpImportData* data = assimp_importer::import_mesh(file, options); export_mesh(data, output, options); timer.stop(); std::cout << "Finished exporting mesh in " << timer.elapsed_time_sec() << " second(s)." << std::endl; } }
std::string dest_path = output; dest_path += "/"; dest_path += path_in_mat; filesystem::copy_file(sourcePath, dest_path); } else { doc["roughness_value"] = 0.5f; } doc["backface_cull"] = true; std::string matPath = output; matPath += "/material/mat_"; matPath += data->materials[i].mesh_name; matPath += ".json"; String output_str = doc.dump(4); if (filesystem::write_begin(matPath)) { filesystem::write((void*)output_str.c_str(), output_str.size(), 1, 0); filesystem::write_end(); } String formattedString = "material/mat_"; formattedString += data->materials[i].mesh_name; formattedString += ".json\0"; strncpy(mats[i].material, formattedString.c_str(),50); } for (int i = 0; i < data->header.mesh_count; i++) { uint32_t idx = data->meshes[i].material_index; if (options.verbose) std::cout << "Mat Idx : " << std::to_string(idx) << std::endl; } std::string meshPath = output; meshPath += "/mesh/"; meshPath += meshOutputName; meshPath += "."; meshPath += ASSET_EXTENSION; if (filesystem::write_begin(meshPath)) { long Offset = 0; filesystem::write(&data->header, sizeof(TSM_FileHeader), 1, Offset); Offset += sizeof(TSM_FileHeader); filesystem::write(data->vertices, sizeof(TSM_Vertex), data->header.vertex_count, Offset); Offset += sizeof(TSM_Vertex) * data->header.vertex_count; filesystem::write(data->indices, sizeof(uint32_t), data->header.index_count, Offset); Offset += sizeof(uint32_t) * data->header.index_count; filesystem::write(data->meshes, sizeof(TSM_MeshHeader), data->header.mesh_count, Offset); Offset += sizeof(TSM_MeshHeader) * data->header.mesh_count; filesystem::write(mats, sizeof(TSM_Material_Json), data->header.material_count, Offset); filesystem::write_end(); } T_SAFE_DELETE_ARRAY(mats); T_SAFE_DELETE_ARRAY(data->vertices); T_SAFE_DELETE_ARRAY(data->indices); T_SAFE_DELETE_ARRAY(data->materials); T_SAFE_DELETE_ARRAY(data->meshes); T_SAFE_DELETE(data); } void export_mesh(std::
random
[ { "content": "using String = std::string;\n", "file_path": "tools/mesh_import/include/types.h", "rank": 0, "score": 120601.69996484136 }, { "content": "using Json = nlohmann::json;\n", "file_path": "tools/mesh_import/include/types.h", "rank": 1, "score": 120591.52757084777 }, { "content": " stbi_uc *data;\n", "file_path": "tools/texture_import/src/stb_image.h", "rank": 2, "score": 120271.16197648991 }, { "content": "\tchar \t name[50];\n", "file_path": "tools/mesh_import/include/tsm_headers.h", "rank": 3, "score": 118461.21176582563 }, { "content": "\tchar name[50];\n", "file_path": "tools/mesh_import/include/tsm_animation.h", "rank": 4, "score": 118461.21176582563 }, { "content": "\tchar name[50];\n", "file_path": "tools/mesh_import/include/tsm_skeleton.h", "rank": 5, "score": 118461.21176582563 }, { "content": " void* output_data;\n", "file_path": "tools/texture_import/src/stb_image_resize.h", "rank": 6, "score": 118356.3548824824 }, { "content": "class StringBuffer\n\n{\n\nprivate:\n\n char _buffer[SIZE];\n\n size_t _length;\n\n \n\npublic:\n\n const static size_t END = SIZE;\n\n \n\npublic:\n\n StringBuffer()\n\n {\n\n _length = 0;\n\n }\n\n \n\n StringBuffer(const char* str)\n\n {\n\n strcpy(&_buffer[0], str);\n\n _length = strlen(str);\n\n }\n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 7, "score": 102409.84838720452 }, { "content": "struct StringHash\n\n{\n\n\n\n uint64_t m_hash;\n\n \n\n StringHash()\n\n {\n\n m_hash = 0;\n\n }\n\n \n\n StringHash(const char* str)\n\n {\n\n m_hash = TE_HASH(str);\n\n }\n\n \n\n StringHash(uint64_t hash)\n\n {\n\n m_hash = hash;\n\n }\n\n \n", "file_path": "engine/include/stl/string_hash.hpp", "rank": 8, "score": 102409.84838720452 }, { "content": "struct AxisMap\n\n{\n\n uint32_t count;\n\n std::array<uint64_t, TE_KEYBOARD_NUM_BUTTONS> keyboard_pos;\n\n std::array<uint64_t, TE_KEYBOARD_NUM_BUTTONS> keyboard_neg;\n\n std::array<uint64_t, 3> mouse;\n\n std::array<uint64_t, TE_GAMEPAD_AXIS_MAX> gamepad;\n\n};\n\n\n", "file_path": "engine/include/io/input_map.hpp", "rank": 9, "score": 102358.41580137242 }, { "content": "struct ActionMap\n\n{\n\n uint32_t count;\n\n std::array<uint64_t, TE_KEYBOARD_NUM_BUTTONS> keyboard;\n\n std::array<uint64_t, TE_MOUSE_NUM_BUTTONS> mouse;\n\n std::array<uint64_t, TE_GAMEPAD_MAX> gamepad;\n\n};\n\n\n", "file_path": "engine/include/io/input_map.hpp", "rank": 10, "score": 102358.41580137242 }, { "content": "class InputMap\n\n{\n\n friend class InputManager;\n\n \n\nprivate:\n\n StringHash m_name;\n\n ActionMap m_action_map;\n\n StateMap m_state_map;\n\n AxisMap m_axis_map;\n\n \n\npublic:\n\n\tInputMap();\n\n ~InputMap();\n\n StringHash name();\n\n uint32_t num_states();\n\n uint32_t num_axis();\n\n uint32_t num_actions();\n\n void set_action(uint64_t hash, int32_t mouse, int32_t keyboard, int32_t gamepad);\n\n void set_state(uint64_t hash, int32_t mouse, int32_t keyboard, int32_t gamepad);\n\n void set_axis(uint64_t hash, int32_t mouse, int32_t keyboard_pos, int32_t keyboard_neg, int32_t gamepad);\n\n void clear_action(StringHash hash);\n\n void clear_state(StringHash hash);\n\n void clear_axis(StringHash hash);\n\n};\n\n\n\nTE_END_TERMINUS_NAMESPACE\n", "file_path": "engine/include/io/input_map.hpp", "rank": 11, "score": 102358.41580137242 }, { "content": "struct StateMap\n\n{\n\n uint32_t count;\n\n std::array<uint64_t, TE_KEYBOARD_NUM_BUTTONS> keyboard;\n\n std::array<uint64_t, TE_MOUSE_NUM_BUTTONS> mouse;\n\n std::array<uint64_t, TE_GAMEPAD_MAX> gamepad;\n\n};\n\n\n", "file_path": "engine/include/io/input_map.hpp", "rank": 12, "score": 102358.41580137242 }, { "content": "class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT\n\n{\n\nprivate:\n\n D3D12_PIPELINE_STATE_SUBOBJECT_TYPE _Type;\n\n InnerStructType _Inner;\n\npublic:\n\n CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() noexcept : _Type(Type), _Inner(DefaultArg()) {}\n\n CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) : _Type(Type), _Inner(i) {}\n\n CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) { _Inner = i; return *this; }\n\n operator InnerStructType() const { return _Inner; }\n\n operator InnerStructType&() { return _Inner; }\n\n};\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS;\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK;\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE;\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INPUT_LAYOUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT> CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT;\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE> CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE;\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PRIMITIVE_TOPOLOGY_TYPE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY> CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY;\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS> CD3DX12_PIPELINE_STATE_STREAM_VS;\n\ntypedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS> CD3DX12_PIPELINE_STATE_STREAM_GS;\n", "file_path": "engine/include/gfx/direct3d12/d3dx12.h", "rank": 13, "score": 99767.64383281939 }, { "content": "class JsonSerializer : public ISerializer\n\n{\n\npublic:\n\n\tJsonSerializer(IStream& stream);\n\n\t~JsonSerializer();\n\n\tvoid serialize(const char* name, bool& value) override;\n\n\tvoid serialize(const char* name, int8_t& value) override;\n\n\tvoid serialize(const char* name, uint8_t& value) override;\n\n\tvoid serialize(const char* name, int16_t& value) override;\n\n\tvoid serialize(const char* name, uint16_t& value) override;\n\n\tvoid serialize(const char* name, int32_t& value) override;\n\n\tvoid serialize(const char* name, uint32_t& value) override;\n\n\tvoid serialize(const char* name, float& value) override;\n\n\tvoid serialize(const char* name, double& value) override;\n\n\tvoid serialize(const char* name, std::string& value) override;\n\n\tvoid serialize(const char* name, const char* value) override;\n\n\n\n\tvoid begin_serialize_struct(const char* name) override;\n\n\tvoid end_serialize_struct(const char* name) override;\n\n\tvoid begin_serialize_array(const char* name, int count) override;\n", "file_path": "engine/include/io/json_serializer.hpp", "rank": 14, "score": 98066.95364733043 }, { "content": "class StaticHashMap\n\n{\n\npublic:\n\n struct FindResult\n\n {\n\n uint32_t hash_index;\n\n uint32_t data_prev_index;\n\n uint32_t data_index;\n\n };\n\n \n\n uint32_t\t\t\t m_hash[SIZE];\n\n Deque<uint32_t, SIZE> m_free_indices;\n\n\tuint64_t\t\t\t m_key[SIZE];\n\n\tuint32_t\t\t\t m_next[SIZE];\n\n\tuint32_t\t\t\t m_prev[SIZE];\n\n\tVALUE\t\t\t\t m_value[SIZE];\n\n\tKEY\t\t\t\t\t m_key_original[SIZE];\n\n uint32_t\t\t\t m_num_objects;\n\n const uint32_t INVALID_INDEX = 0xffffffffu;\n\n \n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 15, "score": 98030.80371550909 }, { "content": "struct Options\n\n{\n\n bool verbose = false;\n", "file_path": "tools/mesh_import/include/options.h", "rank": 16, "score": 96087.49286288972 }, { "content": "#pragma once\n\n\n\n#include <stdio.h>\n\n#include <cstring>\n\n#include <string>\n\n\n\ntemplate<size_t SIZE>\n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 17, "score": 95268.31664102091 }, { "content": "#pragma once\n\n\n\n#include <core/terminus_macros.hpp>\n\n#include <io/io_macros.hpp>\n\n#include <stl/murmur_hash.hpp>\n\n\n\nTE_BEGIN_TERMINUS_NAMESPACE\n\n\n", "file_path": "engine/include/stl/string_hash.hpp", "rank": 18, "score": 95267.37328926928 }, { "content": " }\n\n \n\n StringHash& operator= (uint64_t hash)\n\n {\n\n m_hash = hash;\n\n return *this;\n\n }\n\n};\n\n\n\nTE_END_TERMINUS_NAMESPACE\n", "file_path": "engine/include/stl/string_hash.hpp", "rank": 19, "score": 95266.74446346094 }, { "content": " size_t pos = END;\n\n \n\n for(int i = 0; i < _length; i++)\n\n {\n\n if(_buffer[i] == c)\n\n pos = i;\n\n }\n\n \n\n return pos;\n\n }\n\n \n\n inline size_t size() const\n\n {\n\n return SIZE;\n\n }\n\n \n\n inline StringBuffer substring(size_t start, size_t end) const\n\n {\n\n StringBuffer buf;\n\n \n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 20, "score": 95266.60625650367 }, { "content": " \n\n void operator = (const char* buf)\n\n {\n\n strcpy(&this->_buffer[0], buf);\n\n this->_length = strlen(buf);\n\n }\n\n \n\n StringBuffer& operator+ (const StringBuffer& buf)\n\n {\n\n if(this->_length + buf._length < SIZE)\n\n {\n\n strcpy(&this->_buffer[this->_length], &buf._buffer[0]);\n\n this->_length += buf._length;\n\n }\n\n \n\n return *this;\n\n }\n\n \n\n StringBuffer& operator += (const StringBuffer& buf)\n\n {\n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 21, "score": 95266.48783940218 }, { "content": " \n\n StringBuffer(std::string str)\n\n {\n\n strcpy(&_buffer[0], str.c_str());\n\n _length = strlen(str.c_str());\n\n }\n\n \n\n inline size_t find_first(char c) const\n\n {\n\n for(int i = 0; i < _length; i++)\n\n {\n\n if(_buffer[i] == c)\n\n return i;\n\n }\n\n \n\n return END;\n\n }\n\n \n\n inline size_t find_last(char c) const\n\n {\n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 22, "score": 95266.16998026248 }, { "content": "\tvoid raw_serialize(void* data, const size_t& size) override;\n\n\tvoid raw_deserialize(void* data, const size_t& size) override;\n\n\n\n\tvoid flush_to_stream() override;\n\n\n\n\tvoid print();\n\n\n\nprivate:\n\n\tstd::stack<nlohmann::json> m_object_stack;\n\n};\n\n\n\nTE_END_TERMINUS_NAMESPACE", "file_path": "engine/include/io/json_serializer.hpp", "rank": 23, "score": 95263.8927279181 }, { "content": "\t\treturn (strcmp(this->c_str(), buf.c_str()) == 0);\n\n\t}\n\n \n\n bool operator != (StringBuffer& buf)\n\n {\n\n return (strcmp(this->c_str(), buf.c_str()) != 0);\n\n }\n\n \n\n};\n\n\n\nusing StringBuffer16 = StringBuffer<16>;\n\nusing StringBuffer32 = StringBuffer<32>;\n\nusing StringBuffer64 = StringBuffer<64>;\n\nusing StringBuffer128 = StringBuffer<128>;\n\nusing StringBuffer256 = StringBuffer<256>;\n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 24, "score": 95263.82825159802 }, { "content": " bool operator== (const StringHash& other)\n\n {\n\n return m_hash == other.m_hash;\n\n }\n\n \n\n bool operator!= (const StringHash& other)\n\n {\n\n return m_hash != other.m_hash;\n\n }\n\n \n\n StringHash& operator= (const StringHash& other)\n\n {\n\n m_hash = other.m_hash;\n\n return *this;\n\n }\n\n \n\n StringHash& operator= (const char* str)\n\n {\n\n m_hash = TE_HASH(str);\n\n return *this;\n", "file_path": "engine/include/stl/string_hash.hpp", "rank": 25, "score": 95263.38205747512 }, { "content": " return *this + buf;\n\n }\n\n \n\n bool operator == (const char* str)\n\n {\n\n return (strcmp(this->c_str(), str) == 0);\n\n }\n\n \n\n bool operator != (const char* str)\n\n {\n\n return (strcmp(this->c_str(), str) != 0);\n\n }\n\n \n\n bool operator == (StringBuffer& buf)\n\n {\n\n return (strcmp(this->c_str(), buf.c_str()) == 0);\n\n }\n\n\n\n\tbool operator == (const StringBuffer& buf)\n\n\t{\n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 26, "score": 95262.18264978472 }, { "content": " if(end == END)\n\n end = _length - 1;\n\n \n\n buf._length = end - start + 1;\n\n strncpy(&buf._buffer[0], &_buffer[start], buf._length);\n\n buf._buffer[buf._length] = '\\0';\n\n \n\n return buf;\n\n }\n\n \n\n inline const char* c_str() const { return &_buffer[0]; }\n\n \n\n inline size_t length() const { return _length; }\n\n \n\n StringBuffer& operator = (const StringBuffer& buf)\n\n {\n\n strcpy(&this->_buffer[0], &buf._buffer[0]);\n\n this->_length = buf._length;\n\n return *this;\n\n }\n", "file_path": "engine/include/stl/string_buffer.hpp", "rank": 27, "score": 95261.87002362336 }, { "content": "#pragma once\n\n\n\n#include <io/serializer_macros.hpp>\n\n#include <io/serializer.hpp>\n\n\n\n// Json Includes\n\n#include <json.hpp>\n\n\n\nTE_BEGIN_TERMINUS_NAMESPACE\n\n\n", "file_path": "engine/include/io/json_serializer.hpp", "rank": 28, "score": 95261.56521567122 }, { "content": "\tvoid end_serialize_array(const char* name) override;\n\n\n\n\tvoid deserialize(const char* name, bool& value) override;\n\n\tvoid deserialize(const char* name, int8_t& value) override;\n\n\tvoid deserialize(const char* name, uint8_t& value) override;\n\n\tvoid deserialize(const char* name, int16_t& value) override;\n\n\tvoid deserialize(const char* name, uint16_t& value) override;\n\n\tvoid deserialize(const char* name, int32_t& value) override;\n\n\tvoid deserialize(const char* name, uint32_t& value) override;\n\n\tvoid deserialize(const char* name, float& value) override;\n\n\tvoid deserialize(const char* name, double& value) override;\n\n\tvoid deserialize(const char* name, std::string& value) override;\n\n\tvoid deserialize(const char* name, char** value, bool is_static = true) override;\n\n\n\n\tvoid begin_deserialize_struct(const char* name) override;\n\n\tvoid end_deserialize_struct(const char* name) override;\n\n\tint begin_deserialize_array(const char* name) override;\n\n\tvoid end_deserialize_array(const char* name) override;\n\n\n\n\tbool is_raw_serializable() override;\n", "file_path": "engine/include/io/json_serializer.hpp", "rank": 29, "score": 95261.53494887169 }, { "content": "#pragma once\n\n\n\n#include <core/terminus_macros.hpp>\n\n#include <io/io_macros.hpp>\n\n#include <io/input_device.hpp>\n\n#include <stl/string_hash.hpp>\n\n#include <stdint.h>\n\n#include <array>\n\n\n\nTE_BEGIN_TERMINUS_NAMESPACE\n\n\n", "file_path": "engine/include/io/input_map.hpp", "rank": 30, "score": 95228.29838858174 }, { "content": "struct TextureCube : Texture\n\n{\n\n\tuint16_t width;\n\n\tuint16_t height;\n\n};\n\n\n", "file_path": "engine/include/gfx/opengl/gfx_types_gl.hpp", "rank": 31, "score": 95143.44935599895 }, { "content": "#pragma once\n\n\n\n#include <stl/deque.hpp>\n\n#include <stl/murmur_hash.hpp>\n\n\n\n// @TODO:\n\n// 1. Turn HashEntry array into SOA. [DONE]\n\n// 2. Add new StringBuffer16 (or 32) array for Keys.\n\n// 3. Finish data swap-and-pop upon erase. [DONE]\n\n// 4. Implement iterators.\n\n// 5. Add prev index to HashEntry. [DONE]\n\n\n\n// (48 + sizeof(T)) * N\n\n\n\ntemplate <typename T>\n\nuint64_t create_hash(const T& key)\n\n{\n\n\treturn murmur_hash_64(&key, sizeof(T), 0);\n\n}\n\n\n\n//template <>\n\n//uint64_t create_hash<uint64_t>(const uint64_t& key)\n\n//{\n\n//\treturn key;\n\n//}\n\n\n\ntemplate<typename KEY, typename VALUE, size_t SIZE>\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 32, "score": 92488.71673829178 }, { "content": " object = m_value[data_index];\n\n return true;\n\n }\n\n }\n\n\n\n\tVALUE* get_ptr(const KEY& key)\n\n\t{\n\n\t\tuint32_t data_index = find_or_fail(create_hash(key));\n\n\n\n\t\tif (data_index == INVALID_INDEX)\n\n\t\t\treturn nullptr;\n\n\t\telse\n\n\t\t\treturn &m_value[data_index];\n\n\t}\n\n\n\n void remove(const KEY& key)\n\n {\n\n FindResult result = find(create_hash(key));\n\n \n\n // check if key actually exists\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 33, "score": 92481.25736391934 }, { "content": "public:\n\n\tStaticHashMap()\n\n {\n\n for (uint32_t i = 0; i< SIZE; ++i)\n\n {\n\n m_hash[i] = INVALID_INDEX;\n\n m_next[i] = INVALID_INDEX;\n\n\t\t\tm_prev[i] = INVALID_INDEX;\n\n m_free_indices.push_back(i);\n\n }\n\n \n\n m_num_objects = 0;\n\n }\n\n \n\n ~StaticHashMap()\n\n {\n\n \n\n }\n\n \n\n\tvoid set(const KEY& key, const VALUE& value)\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 34, "score": 92481.03592402737 }, { "content": " }\n\n \n\n return result.data_index;\n\n }\n\n \n\n void erase(FindResult& result)\n\n {\n\n uint32_t last_data_index = m_num_objects - 1;\n\n m_num_objects--;\n\n // push last items' index into freelist\n\n m_free_indices.push_front(last_data_index);\n\n\n\n // Handle the element to be deleted\n\n if (result.data_prev_index == INVALID_INDEX)\n\n m_hash[result.hash_index] = INVALID_INDEX;\n\n else\n\n m_next[result.data_prev_index] = m_next[result.data_index];\n\n\n\n if (m_next[result.data_index] != INVALID_INDEX)\n\n m_prev[m_next[result.data_index]] = result.data_prev_index;\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 35, "score": 92481.01902150662 }, { "content": "\n\n if (result.data_index != last_data_index) // is NOT last element\n\n {\n\n // Handle the last element\n\n if (m_prev[last_data_index] == INVALID_INDEX)\n\n {\n\n uint64_t last_hash_index = m_key[last_data_index] % SIZE;\n\n m_hash[last_hash_index] = result.data_index;\n\n }\n\n else\n\n m_next[m_prev[last_data_index]] = result.data_index;\n\n\n\n if (m_next[last_data_index] != INVALID_INDEX)\n\n m_prev[m_next[last_data_index]] = result.data_index;\n\n\n\n // Swap elements\n\n\t\t\tm_key[result.data_index] = m_key[last_data_index];\n\n\t\t\tm_next[result.data_index] = m_next[last_data_index];\n\n\t\t\tm_prev[result.data_index] = m_prev[last_data_index];\n\n\t\t\tm_value[result.data_index] = m_value[last_data_index];\n\n }\n\n }\n\n};\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 36, "score": 92478.81913885071 }, { "content": " \n\n while (result.data_index != INVALID_INDEX)\n\n {\n\n if (m_key[result.data_index] == key)\n\n return result;\n\n \n\n result.data_prev_index = result.data_index;\n\n result.data_index = m_next[result.data_index];\n\n }\n\n \n\n return result;\n\n }\n\n \n\n // tries to find an object. if not found returns INVALID_INDEX.\n\n uint32_t find_or_fail(const uint64_t& key)\n\n {\n\n FindResult result = find(key);\n\n return result.data_index;\n\n }\n\n \n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 37, "score": 92478.51542114577 }, { "content": " // tries to find an object. if not found creates Hash Entry.\n\n uint32_t find_or_make(const uint64_t& key)\n\n {\n\n FindResult result = find(key);\n\n \n\n if (result.data_index == INVALID_INDEX)\n\n {\n\n result.data_index = m_free_indices.pop_front();\n\n m_next[result.data_index] = INVALID_INDEX;\n\n m_key[result.data_index] = key;\n\n m_num_objects++;\n\n \n\n if (result.data_prev_index != INVALID_INDEX)\n\n {\n\n m_next[result.data_prev_index] = result.data_index;\n\n m_prev[result.data_index] = result.data_prev_index;\n\n }\n\n \n\n if (m_hash[result.hash_index] == INVALID_INDEX)\n\n m_hash[result.hash_index] = result.data_index;\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 38, "score": 92478.43495155062 }, { "content": "\t{\n\n\t\tuint32_t data_index = find_or_make(create_hash(key));\n\n\t\tm_key_original[data_index] = key;\n\n\t\tm_value[data_index] = value;\n\n\t}\n\n \n\n bool has(const KEY& key)\n\n {\n\n uint32_t data_index = find_or_fail(create_hash(key));\n\n return data_index != INVALID_INDEX;\n\n }\n\n \n\n bool get(const KEY& key, VALUE& object)\n\n {\n\n uint32_t data_index = find_or_fail(create_hash(key));\n\n \n\n if (data_index == INVALID_INDEX)\n\n return false;\n\n else\n\n {\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 39, "score": 92478.4197492929 }, { "content": " if (result.data_index != INVALID_INDEX)\n\n erase(result);\n\n }\n\n \n\n uint32_t size()\n\n {\n\n return m_num_objects;\n\n }\n\n \n\nprivate:\n\n FindResult find(const uint64_t& key)\n\n {\n\n FindResult result;\n\n \n\n result.hash_index = INVALID_INDEX;\n\n result.data_prev_index = INVALID_INDEX;\n\n result.data_index = INVALID_INDEX;\n\n \n\n result.hash_index = key % SIZE;\n\n result.data_index = m_hash[result.hash_index];\n", "file_path": "engine/include/stl/static_hash_map.hpp", "rank": 40, "score": 92477.81633490062 }, { "content": "struct Texture;\n", "file_path": "engine/include/gfx/gfx_descs.hpp", "rank": 41, "score": 91734.74133807128 }, { "content": "enum DataType\n\n{\n\n\tGFX_DATA_TYPE_BYTE = 0,\n\n\tGFX_DATA_TYPE_UBYTE = 1,\n\n\tGFX_DATA_TYPE_INT16 = 2,\n\n\tGFX_DATA_TYPE_INT32 = 3,\n\n\tGFX_DATA_TYPE_UINT16 = 4,\n\n\tGFX_DATA_TYPE_UINT32 = 5,\n\n\tGFX_DATA_TYPE_FLOAT = 6\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_enums.hpp", "rank": 42, "score": 89898.67331153675 }, { "content": "enum TextureFormat\n\n{\n\n\t// @TODO: Add compressed formats\n\n\tGFX_FORMAT_UNKNOWN = -1,\n\n\tGFX_FORMAT_R32G32B32_FLOAT = 0,\n\n\tGFX_FORMAT_R32G32B32A32_FLOAT = 1,\n\n\tGFX_FORMAT_R32G32B32_UINT = 2,\n\n\tGFX_FORMAT_R32G32B32A32_UINT = 3,\n\n\tGFX_FORMAT_R32G32B32_INT = 4,\n\n\tGFX_FORMAT_R32G32B32A32_INT = 5,\n\n\tGFX_FORMAT_R16G16_FLOAT = 6,\n\n\tGFX_FORMAT_R16G16B16_FLOAT = 7,\n\n\tGFX_FORMAT_R16G16B16A16_FLOAT = 8,\n\n\tGFX_FORMAT_R16G16B16_UINT = 9,\n\n\tGFX_FORMAT_R16G16B16A16_UINT = 10,\n\n\tGFX_FORMAT_R16G16B16_INT = 11,\n\n\tGFX_FORMAT_R16G16B16A16_INT = 12,\n\n\tGFX_FORMAT_R8G8B8_UNORM = 13,\n\n\tGFX_FORMAT_R8G8B8A8_UNORM = 14,\n\n\tGFX_FORMAT_R8G8B8_UNORM_SRGB = 15,\n", "file_path": "engine/include/gfx/gfx_enums.hpp", "rank": 43, "score": 89166.96968628232 }, { "content": "enum TextureType\n\n{\n\n\tGFX_TEXTURE_1D = 0,\n\n\tGFX_TEXTURE_2D = 1,\n\n\tGFX_TEXTURE_3D = 2,\n\n\tGFX_TEXTURE_CUBE = 3,\n\n\tGFX_TEXTURE_CUBE_POSITIVE_X = GFX_TEXTURE_CUBE + 1,\n\n\tGFX_TEXTURE_CUBE_NEGATIVE_X = GFX_TEXTURE_CUBE + 2,\n\n\tGFX_TEXTURE_CUBE_POSITIVE_Y = GFX_TEXTURE_CUBE + 3,\n\n\tGFX_TEXTURE_CUBE_NEGATIVE_Y = GFX_TEXTURE_CUBE + 4,\n\n\tGFX_TEXTURE_CUBE_POSITIVE_Z = GFX_TEXTURE_CUBE + 5,\n\n\tGFX_TEXTURE_CUBE_NEGATIVE_Z = GFX_TEXTURE_CUBE + 6\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_enums.hpp", "rank": 44, "score": 89166.96968628232 }, { "content": "enum TextureUsage\n\n{\n\n\tGFX_TEXTURE_USAGE_NONE = 1,\n\n\tGFX_TEXTURE_USAGE_READABLE = 2,\n\n\tGFX_TEXTURE_USAGE_WRITABLE = 4,\n\n\tGFX_TEXTURE_USAGE_DRAWABLE = 8\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_enums.hpp", "rank": 45, "score": 89166.96968628232 }, { "content": "enum TextureFilter\n\n{\n\n\tGFX_FILTER_LINEAR = 0,\n\n\tGFX_FILTER_NEAREST = 1,\n\n\tGFX_FILTER_LINEAR_ALL = 2,\n\n\tGFX_FILTER_NEAREST_ALL = 3,\n\n\tGFX_FILTER_ANISOTROPIC_ALL = 4,\n\n\tGFX_FILTER_LINEAR_MIPMAP_NEAREST = 5,\n\n\tGFX_FILTER_NEAREST_MIPMAP_LINEAR = 6,\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_enums.hpp", "rank": 46, "score": 89166.96968628232 }, { "content": "//------------------------------------------------------------------------------------------------\n\nstruct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION\n\n{ \n\n CD3DX12_TEXTURE_COPY_LOCATION() = default;\n\n explicit CD3DX12_TEXTURE_COPY_LOCATION(const D3D12_TEXTURE_COPY_LOCATION &o) :\n\n D3D12_TEXTURE_COPY_LOCATION(o)\n\n {}\n\n CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes) { pResource = pRes; }\n\n CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint)\n\n {\n\n pResource = pRes;\n\n Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;\n\n PlacedFootprint = Footprint;\n\n }\n\n CD3DX12_TEXTURE_COPY_LOCATION(ID3D12Resource* pRes, UINT Sub)\n\n {\n\n pResource = pRes;\n\n Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;\n\n SubresourceIndex = Sub;\n\n }\n\n}; \n\n\n", "file_path": "engine/include/gfx/direct3d12/d3dx12.h", "rank": 47, "score": 87906.54134116776 }, { "content": "class VmaMap\n\n{\n\npublic:\n\n typedef VmaPair<KeyT, ValueT> PairType;\n\n typedef PairType* iterator;\n\n\n\n VmaMap(const VmaStlAllocator<PairType>& allocator) : m_Vector(allocator) { }\n\n\n\n iterator begin() { return m_Vector.begin(); }\n\n iterator end() { return m_Vector.end(); }\n\n\n\n void insert(const PairType& pair);\n\n iterator find(const KeyT& key);\n\n void erase(iterator it);\n\n \n\nprivate:\n\n VmaVector< PairType, VmaStlAllocator<PairType> > m_Vector;\n\n};\n\n\n\n#define VMA_MAP_TYPE(KeyT, ValueT) VmaMap<KeyT, ValueT>\n\n\n\ntemplate<typename FirstT, typename SecondT>\n", "file_path": "engine/include/gfx/vulkan/vk_mem_alloc.h", "rank": 48, "score": 87436.45526183337 }, { "content": "enum BufferMapUsage\n\n{\n\n\tGFX_BUFFER_MAP_READ = 1,\n\n\tGFX_BUFFER_MAP_WRITE = 2,\n\n\tGFX_BUFFER_MAP_READ_WRITE = 4,\n\n\tGFX_BUFFER_MAP_PERSISTANT = 8\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_enums.hpp", "rank": 49, "score": 87436.45526183337 }, { "content": "struct Texture\n\n{\n\n GLuint id;\n\n uint16_t resource_id;\n\n GLenum gl_texture_target;\n\n\tuint32_t mipLevels;\n\n\tuint32_t arraySize;\n\n\tGLenum internalFormat;\n\n\tGLenum format;\n\n\tGLenum type;\n\n};\n\n\n", "file_path": "engine/include/gfx/opengl/gfx_types_gl.hpp", "rank": 50, "score": 86739.03420739449 }, { "content": "struct TextureCreateDesc\n\n{\n\n\tTextureFormat format;\n\n\tTextureUsage texture_usage;\n\n\tResourceUsage resource_usage;\n\n\tTextureType\t type;\n\n uint16_t width;\n\n uint16_t height;\n\n uint16_t depth;\n\n\tSampleCount samples;\n\n void* data;\n\n\tuint16_t array_slices;\n\n uint16_t mipmap_levels;\n\n uint32_t flags;\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_descs.hpp", "rank": 51, "score": 86739.03420739449 }, { "content": "struct Texture\n\n{\n\n\tTextureType type;\n\n\tTextureFormat format;\n\n\tuint32_t\twidth;\n\n\tuint32_t\theight;\n\n\tuint32_t\tdepth;\n\n\tVkImage image;\n\n\tVkFormat vk_format;\n\n\tVkImageType vk_type;\n\n\t// For accessing images in shaders.\n\n\tVkImageView vk_image_view; \n\n\tVkImageAspectFlags aspect_flags;\n\n\tVkSampleCountFlagBits sample_count;\n\n\tstruct VmaAllocation_T* allocation;\n\n\tVkDeviceMemory device_memory;\n\n\tResourceState current_state;\n\n\n\n\tTexture()\n\n\t{\n\n\t\timage = VK_NULL_HANDLE;\n\n\t\tvk_image_view = VK_NULL_HANDLE;\n\n\t\tallocation = VK_NULL_HANDLE;\n\n\t\tdevice_memory = VK_NULL_HANDLE;\n\n\t\tvk_format = VK_FORMAT_UNDEFINED;\n\n\t\tcurrent_state = GFX_RESOURCE_STATE_UNDEFINED;\n\n\t}\n\n};\n\n\n", "file_path": "engine/include/gfx/vulkan/gfx_types_vk.hpp", "rank": 52, "score": 86739.03420739449 }, { "content": "enum TextureAddressMode\n\n{\n\n\tGFX_ADDRESS_REPEAT = 0,\n\n\tGFX_ADDRESS_MIRRORED_REPEAT = 1,\n\n\tGFX_ADDRESS_CLAMP_TO_EDGE = 2,\n\n\tGFX_ADDRESS_CLAMP_TO_BORDER = 3\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_enums.hpp", "rank": 53, "score": 86739.03420739449 }, { "content": "struct Texture\n\n{\n\n\tComPtr<ID3D12Resource> d3d12_texture;\n\n\tCD3DX12_CPU_DESCRIPTOR_HANDLE d3d12_srv;\n\n};\n\n\n", "file_path": "engine/include/gfx/direct3d12/gfx_types_d3d12.hpp", "rank": 54, "score": 86739.03420739449 }, { "content": "struct TextureResourceBarrier\n\n{\n\n\tTexture*\t texture;\n\n\tResourceState target_state;\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_descs.hpp", "rank": 55, "score": 86739.03420739449 }, { "content": "class VmaStringBuilder\n\n{\n\npublic:\n\n VmaStringBuilder(VmaAllocator alloc) : m_Data(VmaStlAllocator<char>(alloc->GetAllocationCallbacks())) { }\n\n size_t GetLength() const { return m_Data.size(); }\n\n const char* GetData() const { return m_Data.data(); }\n\n\n\n void Add(char ch) { m_Data.push_back(ch); }\n\n void Add(const char* pStr);\n\n void AddNewLine() { Add('\\n'); }\n\n void AddNumber(uint32_t num);\n\n void AddNumber(uint64_t num);\n\n void AddPointer(const void* ptr);\n\n\n\nprivate:\n\n VmaVector< char, VmaStlAllocator<char> > m_Data;\n\n};\n\n\n\nvoid VmaStringBuilder::Add(const char* pStr)\n\n{\n", "file_path": "engine/include/gfx/vulkan/vk_mem_alloc.h", "rank": 56, "score": 85157.11588568868 }, { "content": "class VmaJsonWriter\n\n{\n\npublic:\n\n VmaJsonWriter(const VkAllocationCallbacks* pAllocationCallbacks, VmaStringBuilder& sb);\n\n ~VmaJsonWriter();\n\n\n\n void BeginObject(bool singleLine = false);\n\n void EndObject();\n\n \n\n void BeginArray(bool singleLine = false);\n\n void EndArray();\n\n \n\n void WriteString(const char* pStr);\n\n void BeginString(const char* pStr = VMA_NULL);\n\n void ContinueString(const char* pStr);\n\n void ContinueString(uint32_t n);\n\n void ContinueString(uint64_t n);\n\n void ContinueString_Pointer(const void* ptr);\n\n void EndString(const char* pStr = VMA_NULL);\n\n \n", "file_path": "engine/include/gfx/vulkan/vk_mem_alloc.h", "rank": 57, "score": 85146.67384879044 }, { "content": "struct RenderDeviceInitData\n\n{\n\n void* memory;\n\n size_t size;\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_descs.hpp", "rank": 58, "score": 85132.72747547894 }, { "content": "struct DeviceData\n\n{\n\n void* window;\n\n uint16_t width;\n\n uint16_t height;\n\n GLenum\t\t primitive_type;\n\n ShaderProgram* current_program;\n\n GLuint\t\t last_sampler_location;\n\n IndexBuffer* current_index_buffer = nullptr;\n\n};\n\n\n\n#endif\n", "file_path": "engine/include/gfx/opengl/gfx_types_gl.hpp", "rank": 59, "score": 85132.72747547894 }, { "content": "struct BufferTextureCopyRegion\n\n{\n\n\tsize_t src_offset;\n\n\tsize_t row_pitch;\n\n\tsize_t height;\n\n\tint32_t offsets[3];\n\n\tuint32_t extents[3];\n\n\tuint32_t mip_level;\n\n\tuint32_t base_array_layer;\n\n\tuint32_t layer_count;\n\n};\n\n\n", "file_path": "engine/include/gfx/gfx_descs.hpp", "rank": 60, "score": 84439.81485478055 }, { "content": " bool verbose = false;\n", "file_path": "tools/mesh_import/include/options.h", "rank": 61, "score": 82981.9423429682 }, { "content": "class TypeResolver<StringBuffer<N>>\n\n{\n\npublic:\n\n\tstatic TypeDescriptor* get()\n\n\t{\n\n\t\tstatic TypeDescriptor_StringBuffer<N> typeDesc;\n\n\t\treturn &typeDesc;\n\n\t}\n\n};\n\n\n\nTE_END_TERMINUS_NAMESPACE", "file_path": "engine/include/io/type_descriptor.hpp", "rank": 62, "score": 82958.11847694902 }, { "content": "struct Texture2D : Texture\n\n{\n\n uint16_t width;\n\n uint16_t height;\n\n};\n\n\n", "file_path": "engine/include/gfx/opengl/gfx_types_gl.hpp", "rank": 63, "score": 82259.34018594169 }, { "content": "struct Texture3D : Texture\n\n{\n\n \n\n};\n\n\n", "file_path": "engine/include/gfx/opengl/gfx_types_gl.hpp", "rank": 64, "score": 82259.34018594169 }, { "content": "struct Texture1D : Texture\n\n{\n\n \n\n};\n\n\n", "file_path": "engine/include/gfx/opengl/gfx_types_gl.hpp", "rank": 65, "score": 82259.34018594169 }, { "content": "struct TypeDescriptor_StringBuffer : TypeDescriptor\n\n{\n\n\tTypeDescriptor_StringBuffer() : TypeDescriptor{ \"StringBuffer\", sizeof(StringBuffer<N>) }\n\n\t{\n\n\n\n\t}\n\n\n\n\tvoid serialize(void* obj, const char* name, ISerializer* serializer)\n\n\t{\n\n\t\tif (serializer->is_raw_serializable())\n\n\t\t\tserializer->raw_serialize(obj, m_size);\n\n\t\telse\n\n\t\t\tserializer->serialize(name, (const char*)obj);\n\n\t}\n\n\n\n\tvoid deserialize(void* obj, const char* name, ISerializer* serializer)\n\n\t{\n\n\t\tif (serializer->is_raw_serializable())\n\n\t\t\tserializer->raw_deserialize(obj, m_size);\n\n\t\telse\n", "file_path": "engine/include/io/type_descriptor.hpp", "rank": 66, "score": 80869.83088395736 }, { "content": " int output_h;\n", "file_path": "tools/texture_import/src/stb_image_resize.h", "rank": 67, "score": 80642.27959821923 }, { "content": " int output_w;\n", "file_path": "tools/texture_import/src/stb_image_resize.h", "rank": 68, "score": 80642.27959821923 }, { "content": " void *raw_data, *raw_coeff;\n", "file_path": "tools/texture_import/src/stb_image.h", "rank": 69, "score": 80598.68639245721 }, { "content": "\tchar joint_name[50];\n", "file_path": "tools/mesh_import/include/tsm_animation.h", "rank": 70, "score": 78840.44844284334 }, { "content": "\tString mesh_name;\n", "file_path": "tools/mesh_import/include/tsm_material.h", "rank": 71, "score": 78840.44844284334 }, { "content": " const void* input_data;\n", "file_path": "tools/texture_import/src/stb_image_resize.h", "rank": 72, "score": 78667.04206424177 }, { "content": " void *io_user_data;\n", "file_path": "tools/texture_import/src/stb_image.h", "rank": 73, "score": 78667.04206424177 }, { "content": "PFNGLNAMEDBUFFERDATAPROC glad_glNamedBufferData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 74, "score": 77417.57087635256 }, { "content": "PFNGLMAPNAMEDBUFFERPROC glad_glMapNamedBuffer;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 75, "score": 77405.22837947929 }, { "content": "struct TSM_Material_Json\n\n{\n\n\tchar material[50];\n", "file_path": "tools/mesh_import/include/tsm_material.h", "rank": 76, "score": 76984.10460762131 }, { "content": "struct AssimpImportData;\n", "file_path": "tools/mesh_import/include/binary_exporter.h", "rank": 77, "score": 76971.49520066062 }, { "content": "struct AssimpImportData\n\n{\n\n\tTSM_FileHeader header;\n\n\tTSM_MeshHeader* meshes;\n\n\tAssimp_Material* materials;\n\n\tTSM_Vertex*\t\t\tvertices;\n\n\tTSM_SkeletalVertex* skeletal_vertices;\n\n\tuint32_t*\t\t\tindices;\n\n\tbool\t\t\t skeletal;\n\n std::string mesh_path;\n\n std::string filename;\n", "file_path": "tools/mesh_import/include/assimp_importer.h", "rank": 78, "score": 76971.49520066062 }, { "content": "struct TypeDescriptor_StaticHashMap: TypeDescriptor_Container\n\n{\n\n\tTypeDescriptor* m_key_desc;\n\n\tvoid* (*get_key)(void*, size_t);\n\n\tvoid (*deserialize_pair)(void*, TypeDescriptor*, TypeDescriptor*, ISerializer*);\n\n\n\n\tTypeDescriptor_StaticHashMap() : TypeDescriptor_Container{ \"StaticHashMap\", sizeof(StaticHashMap<KEY_TYPE, VALUE_TYPE, N>) }\n\n\t{\n\n\t\tm_object_desc = TypeResolver<StripPointer<VALUE_TYPE>::Type>::get();\n\n\t\tm_key_desc = TypeResolver<StripPointer<KEY_TYPE>::Type>::get();\n\n\n\n\t\tget_size = [](void* obj) -> size_t {\n\n\t\t\tStaticHashMap<KEY_TYPE, VALUE_TYPE, N>* hash_map = (StaticHashMap<KEY_TYPE, VALUE_TYPE, N>*)obj;\n\n\t\t\treturn hash_map->size();\n\n\t\t};\n\n\n\n\t\tget_item = [](void* obj, size_t idx) -> void* {\n\n\t\t\tStaticHashMap<KEY_TYPE, VALUE_TYPE, N>* hash_map = (StaticHashMap<KEY_TYPE, VALUE_TYPE, N>*)obj;\n\n\t\t\treturn &hash_map->m_value[idx];\n\n\t\t};\n", "file_path": "engine/include/io/type_descriptor.hpp", "rank": 79, "score": 76958.85690102493 }, { "content": " int output_stride_bytes;\n", "file_path": "tools/texture_import/src/stb_image_resize.h", "rank": 80, "score": 76867.37161857035 }, { "content": "PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_glNamedFramebufferTexture;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 81, "score": 76805.74727601997 }, { "content": "PFNGLCLEARNAMEDBUFFERDATAPROC glad_glClearNamedBufferData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 82, "score": 75647.03198472747 }, { "content": "PFNGLNAMEDBUFFERSUBDATAPROC glad_glNamedBufferSubData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 83, "score": 75647.03198472747 }, { "content": "PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_glInvalidateNamedFramebufferData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 84, "score": 75647.03198472747 }, { "content": "PFNGLMAPNAMEDBUFFERRANGEPROC glad_glMapNamedBufferRange;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 85, "score": 75634.97176060553 }, { "content": "PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_glNamedFramebufferTextureLayer;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 86, "score": 75049.20078259261 }, { "content": "PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_glInvalidateNamedFramebufferSubData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 87, "score": 73955.66679672891 }, { "content": "PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_glCopyNamedBufferSubData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 88, "score": 73955.66679672891 }, { "content": "PFNGLGETNAMEDBUFFERSUBDATAPROC glad_glGetNamedBufferSubData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 89, "score": 73955.66679672891 }, { "content": "PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_glClearNamedBufferSubData;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 90, "score": 73955.66679672891 }, { "content": "PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_glFlushMappedNamedBufferRange;\n", "file_path": "engine/src/gfx/opengl/glad.c", "rank": 91, "score": 73943.87622288543 }, { "content": "class TypeResolver<StaticHashMap<KEY_TYPE, VALUE_TYPE, N>>\n\n{\n\npublic:\n\n\tstatic TypeDescriptor* get()\n\n\t{\n\n\t\tstatic TypeDescriptor_StaticHashMap<KEY_TYPE, VALUE_TYPE, N> typeDesc;\n\n\t\treturn &typeDesc;\n\n\t}\n\n};\n\n\n\ntemplate <size_t N>\n", "file_path": "engine/include/io/type_descriptor.hpp", "rank": 92, "score": 73438.76068369723 }, { "content": "#include <iostream>\n\n#include <core/application.hpp>\n\n#include <core/engine_core.hpp>\n\n#include <core/terminus_macros.hpp>\n\n#include <io/reflection.hpp>\n\n#include <io/json_serializer.hpp>\n\n#include <io/binary_serializer.hpp>\n\n#include <io/memory_stream.hpp>\n\n#include <io/file_stream.hpp>\n\n#include <io/logger.hpp>\n\n\n\nTE_BEGIN_TERMINUS_NAMESPACE\n\n\n\nvoid on_state_input(Event* e)\n\n{\n\n\tif (e->data.input_state.hash == TE_HASH(\"fire\"))\n\n\t{\n\n\t\tif (e->data.input_state.state == 1)\n\n\t\t\tstd::cout << \"Fire State ON\" << std::endl;\n\n\t\telse\n", "file_path": "samples/2_texture/main.cpp", "rank": 93, "score": 51340.41061869478 }, { "content": "void create_foo(Foo& foo)\n\n{\n\n\tfoo.list.resize(10);\n\n\n\n\tfor (int i = 0; i < 10; i++)\n\n\t\tfoo.list[i] = rand();\n\n\n\n\tfor (int i = 0; i < 10; i++)\n\n\t{\n\n\t\tBar obj;\n\n\t\tobj.a = rand();\n\n\t\tobj.b = rand();\n\n\t\tfoo.test.push_back(obj);\n\n\t}\n\n\n\n\tfoo.map.set(\"Jesse\", 434);\n\n\tfoo.map.set(\"Walter\", 85);\n\n}\n\n\n\nvoid test_bin_serialize_fs(const Foo& foo)\n", "file_path": "samples/2_texture/main.cpp", "rank": 94, "score": 51333.530418559625 }, { "content": "\tserializer.save(foo);\n\n\tserializer.flush_to_stream();\n\n\n\n\tf->write(stream.data(), stream.size(), 1);\n\n\tglobal::filesystem().close_file(f);\n\n}\n\n\n\nvoid test_deserialize_ms()\n\n{\n\n\tFile* f = global::filesystem().open_file(\"test_m.json\", TE_FS_READ | TE_FS_BINARY);\n\n\n\n\tsize_t size = f->size();\n\n\tchar* buf = (char*)TE_HEAP_ALLOC(size + 1);\n\n\tf->read(buf, size, 1);\n\n\tbuf[size] = '\\0';\n\n\n\n\tMemoryStream stream(buf, size);\n\n\tJsonSerializer serializer(stream);\n\n\n\n\tserializer.print();\n", "file_path": "samples/2_texture/main.cpp", "rank": 95, "score": 51329.46705030664 }, { "content": "\t\t\tstd::cout << \"Fire State OFF\" << std::endl;\n\n\t}\n\n}\n\n\n\nvoid on_action_input(Event* e)\n\n{\n\n\tif (e->data.input_action.hash == TE_HASH(\"block\"))\n\n\t\tstd::cout << \"Block action\" << std::endl;\n\n}\n\n\n\nvoid on_axis_input(Event* e)\n\n{\n\n\tif (e->data.input_axis.hash == TE_HASH(\"forward\"))\n\n\t{\n\n\t\tstd::cout << \"Forward axis : \" << e->data.input_axis.value << std::endl;\n\n\t}\n\n}\n\n\n", "file_path": "samples/2_texture/main.cpp", "rank": 96, "score": 51329.32959440261 }, { "content": "\tserializer.load(foo);\n\n\n\n\tglobal::filesystem().close_file(f);\n\n}\n\n\n\nvoid test_serialize_fs(const Foo& foo)\n\n{\n\n\tFile* f = global::filesystem().open_file(\"test_f.json\", TE_FS_WRITE | TE_FS_BINARY);\n\n\n\n\tFileStream stream(f);\n\n\tJsonSerializer serializer(stream);\n\n\n\n\tserializer.save(foo);\n\n\tserializer.flush_to_stream();\n\n\n\n\tglobal::filesystem().close_file(f);\n\n}\n\n\n\nvoid test_deserialize_fs()\n\n{\n", "file_path": "samples/2_texture/main.cpp", "rank": 97, "score": 51328.41320157327 }, { "content": "\tFile* f = global::filesystem().open_file(\"test_f.json\", TE_FS_READ | TE_FS_BINARY);\n\n\n\n\tFileStream stream(f);\n\n\tJsonSerializer serializer(stream);\n\n\n\n\tserializer.print();\n\n\n\n\tFoo foo;\n\n\tserializer.load(foo);\n\n\n\n\tglobal::filesystem().close_file(f);\n\n}\n\n\n\nvoid test_serialize_ms(const Foo& foo)\n\n{\n\n\tFile* f = global::filesystem().open_file(\"test_m.json\", TE_FS_WRITE | TE_FS_BINARY);\n\n\n\n\tMemoryStream stream;\n\n\tJsonSerializer serializer(stream);\n\n\n", "file_path": "samples/2_texture/main.cpp", "rank": 98, "score": 51327.82600898352 }, { "content": "\t\tvbo_desc.usage_flags = GFX_RESOURCE_USAGE_GPU_ONLY;\n\n\t\tvbo_desc.data_type = GFX_DATA_TYPE_FLOAT;\n\n\t\tvbo_desc.offset = 0;\n\n\t\tvbo_desc.size = sizeof(kVertices);\n\n\t\tvbo_desc.data = (void*)&kVertices[0];\n\n\n\n\t\tm_vbo = global::gfx_device().create_buffer(vbo_desc);\n\n\n\n\t\tif (!m_vbo)\n\n\t\t{\n\n\t\t\tTE_LOG_ERROR(\"Failed to create Vertex Buffer!\");\n\n\t\t\treturn false;\n\n\t\t}\n\n\n\n\t\tBufferCreateDesc ibo_desc;\n\n\t\tibo_desc.creation_flags = GFX_BUFFER_CREATION_COMMITTED;\n\n\t\tibo_desc.type = GFX_BUFFER_INDEX;\n\n\t\tibo_desc.usage_flags = GFX_RESOURCE_USAGE_GPU_ONLY;\n\n\t\tibo_desc.data_type = GFX_DATA_TYPE_UINT32;\n\n\t\tibo_desc.offset = 0;\n", "file_path": "samples/2_texture/main.cpp", "rank": 99, "score": 51327.081838216254 } ]
C++
src/EventTraceKit.Etw/EventSession.cpp
ljani/event-trace-kit
59a217fbaecfc87b3915e2494a8d25593d04ae99
#include "Descriptors.h" #include "TraceLog.h" #include "WatchDog.h" #include "InteropHelper.h" #include "etk/ITraceLog.h" #include "etk/ITraceProcessor.h" #include "etk/ITraceSession.h" #include <memory> #include <string> using namespace System; using namespace System::Collections::Generic; using namespace System::ComponentModel; using namespace System::Linq; using namespace System::Runtime::InteropServices; using namespace System::Threading::Tasks; using namespace EventTraceKit::Tracing; using msclr::interop::marshal_as; namespace msclr { namespace interop { static bool IsProviderBinary(String^ filePath) { return filePath->EndsWith(L".exe", StringComparison::OrdinalIgnoreCase) || filePath->EndsWith(L".dll", StringComparison::OrdinalIgnoreCase); } template<> inline etk::TraceProviderDescriptor marshal_as(EventProviderDescriptor^ const& provider) { etk::TraceProviderDescriptor native( marshal_as<GUID>(provider->Id), provider->Level, provider->MatchAnyKeyword, provider->MatchAllKeyword); native.IncludeSecurityId = provider->IncludeSecurityId; native.IncludeTerminalSessionId = provider->IncludeTerminalSessionId; native.IncludeStackTrace = provider->IncludeStackTrace; if (provider->ExecutableName) native.ExecutableName = marshal_as<std::wstring>(provider->ExecutableName); if (provider->ProcessIds) native.ProcessIds = marshal_as_vector(provider->ProcessIds); native.EventIdsFilterIn = provider->EventIdsFilterIn; if (provider->EventIds) native.EventIds = marshal_as_vector(provider->EventIds); native.StackWalkEventIdsFilterIn = provider->StackWalkEventIdsFilterIn; if (provider->StackWalkEventIds) native.StackWalkEventIds = marshal_as_vector(provider->StackWalkEventIds); native.FilterStackWalkLevelKeyword = provider->FilterStackWalkLevelKeyword; native.StackWalkFilterIn = provider->StackWalkFilterIn; native.StackWalkLevel = provider->StackWalkLevel; native.StackWalkMatchAnyKeyword = provider->StackWalkMatchAnyKeyword; native.StackWalkMatchAllKeyword = provider->StackWalkMatchAllKeyword; if (provider->Manifest) { auto manifest = marshal_as<std::wstring>(provider->Manifest); if (IsProviderBinary(provider->Manifest)) native.SetProviderBinary(manifest); else native.SetManifest(manifest); } return native; } } } namespace EventTraceKit::Tracing { public ref struct TraceStatistics { property unsigned NumberOfBuffers; property unsigned FreeBuffers; property unsigned EventsLost; property unsigned BuffersWritten; property unsigned LogBuffersLost; property unsigned RealTimeBuffersLost; property unsigned LoggerThreadId; }; public ref class EventSession : public System::IDisposable { public: EventSession(TraceProfileDescriptor^ profile, TraceLog^ traceLog); ~EventSession() { this->!EventSession(); } !EventSession(); void Start(); Task^ StartAsync(); void Stop(); void Flush(); TraceStatistics^ Query(); private: ref struct StartAsyncHelper { StartAsyncHelper(EventSession^ parent) : parent(parent) {} void Run() { parent->Start(); } EventSession^ parent; }; TraceProfileDescriptor^ profile; TraceLog^ traceLog; std::wstring* loggerName = nullptr; WatchDog^ watchDog; etk::ITraceSession* session = nullptr; etk::ITraceSession* kernelSession = nullptr; etk::ITraceProcessor* processor = nullptr; }; static std::wstring LoggerNameBase = L"EventTraceKit_54644792-9281-48E9-B69D-E82A86F98960"; static std::wstring CreateLoggerName() { int pid = System::Diagnostics::Process::GetCurrentProcess()->Id; return LoggerNameBase + L"_" + std::to_wstring(pid); } static etk::TraceProperties CreateTraceProperties(CollectorDescriptor^ profile) { etk::TraceProperties properties(marshal_as<GUID>(System::Guid::NewGuid())); if (profile->BufferSize.HasValue) properties.BufferSize = profile->BufferSize.Value; if (profile->MinimumBuffers.HasValue) properties.MinimumBuffers = profile->MinimumBuffers.Value; if (profile->MaximumBuffers.HasValue) properties.MaximumBuffers = profile->MaximumBuffers.Value; if (profile->LogFileName) properties.LogFileName = marshal_as<std::wstring>(profile->LogFileName); if (profile->FlushPeriod.HasValue) { properties.FlushPeriod = std::chrono::duration<unsigned, std::milli>( static_cast<unsigned>(profile->FlushPeriod.Value.TotalMilliseconds)); } return properties; } EventSession::EventSession(TraceProfileDescriptor^ profile, TraceLog^ traceLog) : profile(profile) , traceLog(traceLog) , loggerName(new std::wstring(CreateLoggerName())) { if (profile->Collectors->Count == 0) throw gcnew System::ArgumentException(L"profile"); if (!traceLog) throw gcnew System::ArgumentNullException(L"traceLog"); watchDog = gcnew WatchDog(marshal_as<String^>(*loggerName)); traceLog->UpdateTraceData(profile); for each (auto collector in profile->Collectors) { if (auto systemCollector = dynamic_cast<SystemCollectorDescriptor^>(collector)) { auto traceProperties = CreateTraceProperties(systemCollector); auto session = etk::CreateEtwTraceSession(L"NT Kernel Logger", traceProperties); session->SetKernelProviders(systemCollector->KernelFlags, true); this->kernelSession = session.release(); continue; } if (auto eventCollector = dynamic_cast<EventCollectorDescriptor^>(collector)) { auto traceProperties = CreateTraceProperties(eventCollector); auto session = etk::CreateEtwTraceSession(*loggerName, traceProperties); for each (auto provider in eventCollector->Providers) { auto nativeProvider = marshal_as<etk::TraceProviderDescriptor>(provider); session->AddProvider(nativeProvider); session->EnableProvider(nativeProvider.Id); } this->session = session.release(); continue; } } } EventSession::!EventSession() { Stop(); delete session; delete kernelSession; delete watchDog; delete loggerName; } void EventSession::Start() { watchDog->Start(); HRESULT hr; if (kernelSession) { hr = kernelSession->Start(); if (FAILED(hr)) throw gcnew Win32Exception(hr); } if (session) { hr = session->Start(); if (FAILED(hr)) { if (kernelSession) (void)kernelSession->Stop(); throw gcnew Win32Exception(hr); } } std::vector<std::wstring_view> loggerNames; if (session) loggerNames.push_back(*loggerName); if (kernelSession) loggerNames.push_back(L"NT Kernel Logger"); auto processor = etk::CreateEtwTraceProcessor(loggerNames); processor->SetEventSink(traceLog->Native()); this->processor = processor.release(); this->processor->StartProcessing(); auto logFileHeader = this->processor->GetLogFileHeader(); EventSessionInfo sessionInfo; sessionInfo.StartTime = logFileHeader->StartTime.QuadPart; sessionInfo.PerfFreq = logFileHeader->PerfFreq.QuadPart; sessionInfo.PointerSize = logFileHeader->PointerSize; traceLog->SetSessionInfo(sessionInfo); } Task^ EventSession::StartAsync() { return Task::Run(gcnew Action(this, &EventSession::Start)); } void EventSession::Stop() { if (!processor) return; processor->StopProcessing(); if (session) session->Stop(); if (kernelSession) kernelSession->Stop(); watchDog->Stop(); delete processor; processor = nullptr; } void EventSession::Flush() { if (!processor) return; if (session) session->Flush(); if (kernelSession) kernelSession->Flush(); } TraceStatistics^ EventSession::Query() { if (!session) return gcnew TraceStatistics(); etk::TraceStatistics nativeStats; session->Query(nativeStats); auto stats = gcnew TraceStatistics(); stats->NumberOfBuffers = nativeStats.NumberOfBuffers; stats->FreeBuffers = nativeStats.FreeBuffers; stats->EventsLost = nativeStats.EventsLost; stats->BuffersWritten = nativeStats.BuffersWritten; stats->LogBuffersLost = nativeStats.LogBuffersLost; stats->RealTimeBuffersLost = nativeStats.RealTimeBuffersLost; stats->LoggerThreadId = nativeStats.LoggerThreadId; return stats; } }
#include "Descriptors.h" #include "TraceLog.h" #include "WatchDog.h" #include "InteropHelper.h" #include "etk/ITraceLog.h" #include "etk/ITraceProcessor.h" #include "etk/ITraceSession.h" #include <memory> #include <string> using namespace System; using namespace System::Collections::Generic; using namespace System::ComponentModel; using namespace System::Linq; using namespace System::Runtime::InteropServices; using namespace System::Threading::Tasks; using namespace EventTraceKit::Tracing; using msclr::interop::marshal_as; namespace msclr { namespace interop { static bool IsPro
on* kernelSession = nullptr; etk::ITraceProcessor* processor = nullptr; }; static std::wstring LoggerNameBase = L"EventTraceKit_54644792-9281-48E9-B69D-E82A86F98960"; static std::wstring CreateLoggerName() { int pid = System::Diagnostics::Process::GetCurrentProcess()->Id; return LoggerNameBase + L"_" + std::to_wstring(pid); } static etk::TraceProperties CreateTraceProperties(CollectorDescriptor^ profile) { etk::TraceProperties properties(marshal_as<GUID>(System::Guid::NewGuid())); if (profile->BufferSize.HasValue) properties.BufferSize = profile->BufferSize.Value; if (profile->MinimumBuffers.HasValue) properties.MinimumBuffers = profile->MinimumBuffers.Value; if (profile->MaximumBuffers.HasValue) properties.MaximumBuffers = profile->MaximumBuffers.Value; if (profile->LogFileName) properties.LogFileName = marshal_as<std::wstring>(profile->LogFileName); if (profile->FlushPeriod.HasValue) { properties.FlushPeriod = std::chrono::duration<unsigned, std::milli>( static_cast<unsigned>(profile->FlushPeriod.Value.TotalMilliseconds)); } return properties; } EventSession::EventSession(TraceProfileDescriptor^ profile, TraceLog^ traceLog) : profile(profile) , traceLog(traceLog) , loggerName(new std::wstring(CreateLoggerName())) { if (profile->Collectors->Count == 0) throw gcnew System::ArgumentException(L"profile"); if (!traceLog) throw gcnew System::ArgumentNullException(L"traceLog"); watchDog = gcnew WatchDog(marshal_as<String^>(*loggerName)); traceLog->UpdateTraceData(profile); for each (auto collector in profile->Collectors) { if (auto systemCollector = dynamic_cast<SystemCollectorDescriptor^>(collector)) { auto traceProperties = CreateTraceProperties(systemCollector); auto session = etk::CreateEtwTraceSession(L"NT Kernel Logger", traceProperties); session->SetKernelProviders(systemCollector->KernelFlags, true); this->kernelSession = session.release(); continue; } if (auto eventCollector = dynamic_cast<EventCollectorDescriptor^>(collector)) { auto traceProperties = CreateTraceProperties(eventCollector); auto session = etk::CreateEtwTraceSession(*loggerName, traceProperties); for each (auto provider in eventCollector->Providers) { auto nativeProvider = marshal_as<etk::TraceProviderDescriptor>(provider); session->AddProvider(nativeProvider); session->EnableProvider(nativeProvider.Id); } this->session = session.release(); continue; } } } EventSession::!EventSession() { Stop(); delete session; delete kernelSession; delete watchDog; delete loggerName; } void EventSession::Start() { watchDog->Start(); HRESULT hr; if (kernelSession) { hr = kernelSession->Start(); if (FAILED(hr)) throw gcnew Win32Exception(hr); } if (session) { hr = session->Start(); if (FAILED(hr)) { if (kernelSession) (void)kernelSession->Stop(); throw gcnew Win32Exception(hr); } } std::vector<std::wstring_view> loggerNames; if (session) loggerNames.push_back(*loggerName); if (kernelSession) loggerNames.push_back(L"NT Kernel Logger"); auto processor = etk::CreateEtwTraceProcessor(loggerNames); processor->SetEventSink(traceLog->Native()); this->processor = processor.release(); this->processor->StartProcessing(); auto logFileHeader = this->processor->GetLogFileHeader(); EventSessionInfo sessionInfo; sessionInfo.StartTime = logFileHeader->StartTime.QuadPart; sessionInfo.PerfFreq = logFileHeader->PerfFreq.QuadPart; sessionInfo.PointerSize = logFileHeader->PointerSize; traceLog->SetSessionInfo(sessionInfo); } Task^ EventSession::StartAsync() { return Task::Run(gcnew Action(this, &EventSession::Start)); } void EventSession::Stop() { if (!processor) return; processor->StopProcessing(); if (session) session->Stop(); if (kernelSession) kernelSession->Stop(); watchDog->Stop(); delete processor; processor = nullptr; } void EventSession::Flush() { if (!processor) return; if (session) session->Flush(); if (kernelSession) kernelSession->Flush(); } TraceStatistics^ EventSession::Query() { if (!session) return gcnew TraceStatistics(); etk::TraceStatistics nativeStats; session->Query(nativeStats); auto stats = gcnew TraceStatistics(); stats->NumberOfBuffers = nativeStats.NumberOfBuffers; stats->FreeBuffers = nativeStats.FreeBuffers; stats->EventsLost = nativeStats.EventsLost; stats->BuffersWritten = nativeStats.BuffersWritten; stats->LogBuffersLost = nativeStats.LogBuffersLost; stats->RealTimeBuffersLost = nativeStats.RealTimeBuffersLost; stats->LoggerThreadId = nativeStats.LoggerThreadId; return stats; } }
viderBinary(String^ filePath) { return filePath->EndsWith(L".exe", StringComparison::OrdinalIgnoreCase) || filePath->EndsWith(L".dll", StringComparison::OrdinalIgnoreCase); } template<> inline etk::TraceProviderDescriptor marshal_as(EventProviderDescriptor^ const& provider) { etk::TraceProviderDescriptor native( marshal_as<GUID>(provider->Id), provider->Level, provider->MatchAnyKeyword, provider->MatchAllKeyword); native.IncludeSecurityId = provider->IncludeSecurityId; native.IncludeTerminalSessionId = provider->IncludeTerminalSessionId; native.IncludeStackTrace = provider->IncludeStackTrace; if (provider->ExecutableName) native.ExecutableName = marshal_as<std::wstring>(provider->ExecutableName); if (provider->ProcessIds) native.ProcessIds = marshal_as_vector(provider->ProcessIds); native.EventIdsFilterIn = provider->EventIdsFilterIn; if (provider->EventIds) native.EventIds = marshal_as_vector(provider->EventIds); native.StackWalkEventIdsFilterIn = provider->StackWalkEventIdsFilterIn; if (provider->StackWalkEventIds) native.StackWalkEventIds = marshal_as_vector(provider->StackWalkEventIds); native.FilterStackWalkLevelKeyword = provider->FilterStackWalkLevelKeyword; native.StackWalkFilterIn = provider->StackWalkFilterIn; native.StackWalkLevel = provider->StackWalkLevel; native.StackWalkMatchAnyKeyword = provider->StackWalkMatchAnyKeyword; native.StackWalkMatchAllKeyword = provider->StackWalkMatchAllKeyword; if (provider->Manifest) { auto manifest = marshal_as<std::wstring>(provider->Manifest); if (IsProviderBinary(provider->Manifest)) native.SetProviderBinary(manifest); else native.SetManifest(manifest); } return native; } } } namespace EventTraceKit::Tracing { public ref struct TraceStatistics { property unsigned NumberOfBuffers; property unsigned FreeBuffers; property unsigned EventsLost; property unsigned BuffersWritten; property unsigned LogBuffersLost; property unsigned RealTimeBuffersLost; property unsigned LoggerThreadId; }; public ref class EventSession : public System::IDisposable { public: EventSession(TraceProfileDescriptor^ profile, TraceLog^ traceLog); ~EventSession() { this->!EventSession(); } !EventSession(); void Start(); Task^ StartAsync(); void Stop(); void Flush(); TraceStatistics^ Query(); private: ref struct StartAsyncHelper { StartAsyncHelper(EventSession^ parent) : parent(parent) {} void Run() { parent->Start(); } EventSession^ parent; }; TraceProfileDescriptor^ profile; TraceLog^ traceLog; std::wstring* loggerName = nullptr; WatchDog^ watchDog; etk::ITraceSession* session = nullptr; etk::ITraceSessi
random
[ { "content": "namespace EventTraceKit.EventTracing.Schema\n\n{\n\n using System.Xml.Linq;\n\n using EventTraceKit.EventTracing.Schema.Base;\n\n\n\n public static class EventManifestSchema\n\n {\n\n public static readonly XNamespace Namespace =\n\n \"http://schemas.microsoft.com/win/2004/08/events\";\n\n }\n\n\n\n public static class EventSchema\n\n {\n\n public static readonly XNamespace Namespace =\n\n \"http://schemas.microsoft.com/win/2004/08/events/event\";\n\n }\n\n\n\n public static class WinEventSchema\n\n {\n\n public static readonly XNamespace Namespace =\n", "file_path": "src/EventTraceKit.EventTracing/Schema/Namespaces.cs", "rank": 0, "score": 52726.358330813 }, { "content": " \"http://manifests.microsoft.com/win/2004/08/windows/events\";\n\n\n\n public static readonly QName Int8 = new QName(\"Int8\", \"win\", Namespace);\n\n public static readonly QName UInt8 = new QName(\"UInt8\", \"win\", Namespace);\n\n public static readonly QName Int16 = new QName(\"Int16\", \"win\", Namespace);\n\n public static readonly QName UInt16 = new QName(\"UInt16\", \"win\", Namespace);\n\n public static readonly QName Int32 = new QName(\"Int32\", \"win\", Namespace);\n\n public static readonly QName UInt32 = new QName(\"UInt32\", \"win\", Namespace);\n\n public static readonly QName Int64 = new QName(\"Int64\", \"win\", Namespace);\n\n public static readonly QName UInt64 = new QName(\"UInt64\", \"win\", Namespace);\n\n public static readonly QName Float = new QName(\"Float\", \"win\", Namespace);\n\n public static readonly QName Double = new QName(\"Double\", \"win\", Namespace);\n\n public static readonly QName Boolean = new QName(\"Boolean\", \"win\", Namespace);\n\n public static readonly QName UnicodeString = new QName(\"UnicodeString\", \"win\", Namespace);\n\n public static readonly QName AnsiString = new QName(\"AnsiString\", \"win\", Namespace);\n\n public static readonly QName Binary = new QName(\"Binary\", \"win\", Namespace);\n\n public static readonly QName Guid = new QName(\"GUID\", \"win\", Namespace);\n\n public static readonly QName Pointer = new QName(\"Pointer\", \"win\", Namespace);\n\n public static readonly QName FileTime = new QName(\"FILETIME\", \"win\", Namespace);\n\n public static readonly QName SystemTime = new QName(\"SYSTEMTIME\", \"win\", Namespace);\n", "file_path": "src/EventTraceKit.EventTracing/Schema/Namespaces.cs", "rank": 1, "score": 52723.241055772894 }, { "content": " public static readonly QName SecurityId = new QName(\"SID\", \"win\", Namespace);\n\n public static readonly QName HexInt32 = new QName(\"HexInt32\", \"win\", Namespace);\n\n public static readonly QName HexInt64 = new QName(\"HexInt64\", \"win\", Namespace);\n\n public static readonly QName CountedUnicodeString = new QName(\"CountedUnicodeString\", \"win\", Namespace);\n\n public static readonly QName CountedAnsiString = new QName(\"CountedAnsiString\", \"win\", Namespace);\n\n public static readonly QName CountedBinary = new QName(\"CountedBinary\", \"win\", Namespace);\n\n }\n\n\n\n public static class EventTraceKitSchema\n\n {\n\n public static readonly XNamespace Namespace = \"urn:uuid:fb199331-10b4-437d-88b3-adb0561c2e3f\";\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing/Schema/Namespaces.cs", "rank": 2, "score": 52722.678416230076 }, { "content": " // with the /str option, or rebuild your VS project.\n\n [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"16.0.0.0\")]\n\n [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n\n [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n\n internal class Strings {\n\n \n\n private static global::System.Resources.ResourceManager resourceMan;\n\n \n\n private static global::System.Globalization.CultureInfo resourceCulture;\n\n \n\n [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\n internal Strings() {\n\n }\n\n \n\n /// <summary>\n\n /// Returns the cached ResourceManager instance used by this class.\n\n /// </summary>\n\n [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n\n internal static global::System.Resources.ResourceManager ResourceManager {\n\n get {\n", "file_path": "src/EventManifestCompiler.Build.Tasks/Strings.Designer.cs", "rank": 3, "score": 52671.558719639164 }, { "content": " if (object.ReferenceEquals(resourceMan, null)) {\n\n global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(\"EventManifestCompiler.Build.Tasks.Strings\", typeof(Strings).Assembly);\n\n resourceMan = temp;\n\n }\n\n return resourceMan;\n\n }\n\n }\n\n \n\n /// <summary>\n\n /// Overrides the current thread's CurrentUICulture property for all\n\n /// resource lookups using this strongly typed resource class.\n\n /// </summary>\n\n [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n\n internal static global::System.Globalization.CultureInfo Culture {\n\n get {\n\n return resourceCulture;\n\n }\n\n set {\n\n resourceCulture = value;\n\n }\n", "file_path": "src/EventManifestCompiler.Build.Tasks/Strings.Designer.cs", "rank": 4, "score": 52670.51069852171 }, { "content": "//------------------------------------------------------------------------------\n\n// <auto-generated>\n\n// This code was generated by a tool.\n\n// Runtime Version:4.0.30319.42000\n\n//\n\n// Changes to this file may cause incorrect behavior and will be lost if\n\n// the code is regenerated.\n\n// </auto-generated>\n\n//------------------------------------------------------------------------------\n\n\n\nnamespace EventManifestCompiler.Build.Tasks {\n\n using System;\n\n \n\n \n\n /// <summary>\n\n /// A strongly-typed resource class, for looking up localized strings, etc.\n\n /// </summary>\n\n // This class was auto-generated by the StronglyTypedResourceBuilder\n\n // class via a tool like ResGen or Visual Studio.\n\n // To add or remove a member, edit your .ResX file then rerun ResGen\n", "file_path": "src/EventManifestCompiler.Build.Tasks/Strings.Designer.cs", "rank": 5, "score": 52667.7442525992 }, { "content": " }\n\n \n\n /// <summary>\n\n /// Looks up a localized string similar to Required file &quot;{0}&quot; is missing..\n\n /// </summary>\n\n internal static string Error_MissingFile {\n\n get {\n\n return ResourceManager.GetString(\"Error_MissingFile\", resourceCulture);\n\n }\n\n }\n\n \n\n /// <summary>\n\n /// Looks up a localized string similar to &quot;{1}&quot; task received an invalid value for the &quot;{0}&quot; parameter..\n\n /// </summary>\n\n internal static string General_InvalidValue {\n\n get {\n\n return ResourceManager.GetString(\"General_InvalidValue\", resourceCulture);\n\n }\n\n }\n\n \n", "file_path": "src/EventManifestCompiler.Build.Tasks/Strings.Designer.cs", "rank": 6, "score": 52664.821821041485 }, { "content": " /// </summary>\n\n internal static string TrackedToolTask_RebuildingDueToInvalidTLog {\n\n get {\n\n return ResourceManager.GetString(\"TrackedToolTask_RebuildingDueToInvalidTLog\", resourceCulture);\n\n }\n\n }\n\n \n\n /// <summary>\n\n /// Looks up a localized string similar to Forcing a rebuild of all source files due to the contents of &quot;{0}&quot; being invalid..\n\n /// </summary>\n\n internal static string TrackedToolTask_RebuildingDueToInvalidTLogContents {\n\n get {\n\n return ResourceManager.GetString(\"TrackedToolTask_RebuildingDueToInvalidTLogContents\", resourceCulture);\n\n }\n\n }\n\n \n\n /// <summary>\n\n /// Looks up a localized string similar to Forcing rebuild of all source files due to missing command TLog &quot;{0}&quot;..\n\n /// </summary>\n\n internal static string TrackedToolTask_RebuildingNoCommandTLog {\n", "file_path": "src/EventManifestCompiler.Build.Tasks/Strings.Designer.cs", "rank": 7, "score": 52664.50913309738 }, { "content": " /// <summary>\n\n /// Looks up a localized string similar to Tracking command:.\n\n /// </summary>\n\n internal static string Native_TrackingCommandMessage {\n\n get {\n\n return ResourceManager.GetString(\"Native_TrackingCommandMessage\", resourceCulture);\n\n }\n\n }\n\n \n\n /// <summary>\n\n /// Looks up a localized string similar to Forcing rebuild of all source files due to a change in the command line since the last build..\n\n /// </summary>\n\n internal static string TrackedToolTask_RebuildingAllSourcesCommandLineChanged {\n\n get {\n\n return ResourceManager.GetString(\"TrackedToolTask_RebuildingAllSourcesCommandLineChanged\", resourceCulture);\n\n }\n\n }\n\n \n\n /// <summary>\n\n /// Looks up a localized string similar to Forcing a rebuild of all sources due to an error with the tracking logs. {0}.\n", "file_path": "src/EventManifestCompiler.Build.Tasks/Strings.Designer.cs", "rank": 8, "score": 52664.20290265273 }, { "content": " get {\n\n return ResourceManager.GetString(\"TrackedToolTask_RebuildingNoCommandTLog\", resourceCulture);\n\n }\n\n }\n\n \n\n /// <summary>\n\n /// Looks up a localized string similar to Forcing rebuild of source file &quot;{0}&quot; due to a change in the command line since the last build..\n\n /// </summary>\n\n internal static string TrackedToolTask_RebuildingSourceCommandLineChanged {\n\n get {\n\n return ResourceManager.GetString(\"TrackedToolTask_RebuildingSourceCommandLineChanged\", resourceCulture);\n\n }\n\n }\n\n }\n\n}\n", "file_path": "src/EventManifestCompiler.Build.Tasks/Strings.Designer.cs", "rank": 9, "score": 52662.936854528816 }, { "content": "namespace EventTraceKit.VsExtension.Native\n\n{\n\n using System;\n\n using System.Runtime.InteropServices;\n\n\n\n [StructLayout(LayoutKind.Sequential)]\n\n public struct UnmanagedString\n\n : IEquatable<UnmanagedString>\n\n , IComparable<UnmanagedString>\n\n , IComparable<string>\n\n {\n\n private readonly unsafe char* str;\n\n\n\n public unsafe UnmanagedString(char* str)\n\n {\n\n this.str = str;\n\n }\n\n\n\n public static readonly UnmanagedString Empty;\n\n\n", "file_path": "src/EventTraceKit.VsExtension/Native/UnmanagedString.cs", "rank": 10, "score": 51810.678015160636 }, { "content": "namespace EventTraceKit.VsExtension.Extensions\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Text.RegularExpressions;\n\n\n\n public static class StringExtensions\n\n {\n\n public static string TrimToLength(\n\n this string s, int maxLength, TrimPosition position = TrimPosition.End)\n\n {\n\n if (s == null || s.Length <= maxLength)\n\n return s;\n\n if (maxLength <= 0)\n\n return string.Empty;\n\n\n\n var length = maxLength - 1;\n\n switch (position) {\n\n case TrimPosition.End:\n\n return s.Substring(0, length) + \"…\";\n", "file_path": "src/EventTraceKit.VsExtension/Extensions/StringExtensions.cs", "rank": 11, "score": 51807.7719341781 }, { "content": "namespace EventTraceKit.EventTracing.Schema\n\n{\n\n using System;\n\n using System.Diagnostics;\n\n using EventTraceKit.EventTracing.Support;\n\n\n\n [DebuggerDisplay(\"{Name}({Id,h}) = '{Value}'\")]\n\n public sealed class LocalizedString : SourceItem\n\n {\n\n public const uint UnusedId = uint.MaxValue;\n\n\n\n public LocalizedString(LocatedRef<string> name, LocatedRef<string> value)\n\n : this(name, value, UnusedId)\n\n {\n\n }\n\n\n\n public LocalizedString(LocatedRef<string> name, string value, uint id)\n\n {\n\n Name = name ?? throw new ArgumentNullException(nameof(name));\n\n Value = value ?? throw new ArgumentNullException(nameof(value));\n", "file_path": "src/EventTraceKit.EventTracing/Schema/LocalizedString.cs", "rank": 12, "score": 51801.0714109881 }, { "content": " public unsafe bool IsEmpty\n\n {\n\n get\n\n {\n\n if (HasValue)\n\n return str[0] == '\\0';\n\n return true;\n\n }\n\n }\n\n\n\n public unsafe bool HasValue => str != null;\n\n\n\n public override unsafe string ToString()\n\n {\n\n return str != null ? new string(str) : string.Empty;\n\n }\n\n\n\n public static implicit operator string(UnmanagedString value)\n\n {\n\n return value.ToString();\n", "file_path": "src/EventTraceKit.VsExtension/Native/UnmanagedString.cs", "rank": 13, "score": 51798.564162794355 }, { "content": " case TrimPosition.Start:\n\n return \"…\" + s.Substring(s.Length - length, length);\n\n case TrimPosition.Middle:\n\n int suffix = length / 2;\n\n int prefix = length - suffix;\n\n return s.Substring(0, prefix) + \"…\" + s.Substring(s.Length - suffix, suffix);\n\n default:\n\n throw new ArgumentOutOfRangeException(nameof(position), position, null);\n\n }\n\n }\n\n\n\n public static string MakeNumberedCopy(this string fullString, ISet<string> usedStrings = null)\n\n {\n\n if (usedStrings == null || !usedStrings.Contains(fullString))\n\n return fullString;\n\n\n\n var match = Regex.Match(fullString, @\"\\A(?<str>.*) \\(Copy(?: (?<num>\\d+))?\\)\\z\");\n\n\n\n string str;\n\n int num;\n", "file_path": "src/EventTraceKit.VsExtension/Extensions/StringExtensions.cs", "rank": 14, "score": 51797.18286477046 }, { "content": " }\n\n\n\n public static unsafe explicit operator char*(UnmanagedString value)\n\n {\n\n return value.str;\n\n }\n\n\n\n public bool Equals(UnmanagedString other)\n\n {\n\n throw new NotImplementedException();\n\n }\n\n\n\n public int CompareTo(UnmanagedString other)\n\n {\n\n throw new NotImplementedException();\n\n }\n\n\n\n public int CompareTo(string other)\n\n {\n\n throw new NotImplementedException();\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.VsExtension/Native/UnmanagedString.cs", "rank": 15, "score": 51796.998671407324 }, { "content": " Id = id;\n\n }\n\n\n\n public LocatedRef<string> Name { get; }\n\n public LocatedRef<string> Value { get; }\n\n public uint Id { get; set; }\n\n public LocatedRef<string> Symbol { get; set; }\n\n\n\n public bool Imported { get; set; }\n\n\n\n public override string ToString()\n\n {\n\n return Name;\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing/Schema/LocalizedString.cs", "rank": 16, "score": 51792.80226015142 }, { "content": " if (match.Success) {\n\n str = match.Groups[\"str\"].Value;\n\n num = match.Groups[\"num\"].Success ? int.Parse(match.Groups[\"num\"].Value) : 1;\n\n } else {\n\n str = fullString;\n\n num = 0;\n\n }\n\n\n\n while (true) {\n\n ++num;\n\n string copiedStr = str + (num == 1 ? \" (Copy)\" : $\" (Copy {num})\");\n\n if (!usedStrings.Contains(copiedStr))\n\n return copiedStr;\n\n }\n\n }\n\n }\n\n\n\n public enum TrimPosition\n\n {\n\n End,\n\n Start,\n\n Middle\n\n }\n\n}\n", "file_path": "src/EventTraceKit.VsExtension/Extensions/StringExtensions.cs", "rank": 17, "score": 51791.40650379109 }, { "content": "[assembly: System.Windows.Markup.XmlnsDefinition(\n\n \"urn:schemas-eventtracekit:settings\",\n\n \"EventTraceKit.VsExtension.Settings.Persistence\")]\n", "file_path": "src/EventTraceKit.VsExtension/Settings/Persistence/NamespaceMapping.cs", "rank": 18, "score": 50992.616962507505 }, { "content": "namespace EventTraceKit.EventTracing.Internal.Extensions\n\n{\n\n using System;\n\n using System.Globalization;\n\n\n\n internal static class StringExtensions\n\n {\n\n public static string ToStringInvariant(this int value)\n\n {\n\n return value.ToString(CultureInfo.InvariantCulture);\n\n }\n\n\n\n /// <summary>\n\n /// Escapes the string so that it is safe to use as a formatting\n\n /// string with <see cref=\"string.Format(string,object)\"/> and zero\n\n /// args.\n\n /// </summary>\n\n /// <param name=\"str\">The string to escape.</param>\n\n /// <returns>\n\n /// The escaped string with formatting-relevant characters ({, })\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Extensions/StringExtensions.cs", "rank": 19, "score": 50964.41060174091 }, { "content": "namespace EventTraceKit.VsExtension.Extensions\n\n{\n\n using System.Text;\n\n\n\n public static class StringBuilderExtensions\n\n {\n\n private const string HexChars = \"0123456789ABCDEF\";\n\n\n\n public static void AppendHexByte(this StringBuilder builder, byte b)\n\n {\n\n int hi = (b >> 4) & 0xF;\n\n int lo = b & 0xF;\n\n builder.Append(HexChars[hi]);\n\n builder.Append(HexChars[lo]);\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.VsExtension/Extensions/StringBuilderExtensions.cs", "rank": 20, "score": 50961.273277669374 }, { "content": "#include \"etk/Support/StringConversions.h\"\n\n\n\n#include <Windows.h>\n\n#include <type_traits>\n\n\n\nnamespace etk\n\n{\n\n\n\nnamespace\n\n{\n\n\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 21, "score": 50956.72100756398 }, { "content": "\n\n buffer.resize(convertedLength);\n\n return true;\n\n}\n\n\n\n} // namespace\n\n\n\nbool U8To16(std::string_view source, std::wstring& output)\n\n{\n\n return Convert<U8To16Conversion>(source.data(), source.length(), output);\n\n}\n\n\n\nstd::wstring U8To16(std::string_view source)\n\n{\n\n std::wstring buffer;\n\n (void)Convert<U8To16Conversion>(source.data(), source.length(), buffer);\n\n return buffer;\n\n}\n\n\n\nbool U16To8(std::wstring_view source, std::string& output)\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 22, "score": 50952.2288436528 }, { "content": " /// escaped.\n\n /// </returns>\n\n public static string EscapeFormatting(this string str)\n\n {\n\n return str.Replace(\"{\", \"{{\").Replace(\"}\", \"}}\");\n\n }\n\n\n\n /// <summary>\n\n /// Returns the longest common prefix of both specified strings.\n\n /// </summary>\n\n /// <param name=\"a\">The first string.</param>\n\n /// <param name=\"b\">The second string.</param>\n\n /// <returns>\n\n /// The longest common prefix of both strings (which may be empty).\n\n /// Also returns empty if any input string is <see langword=\"null\"/>.\n\n /// </returns>\n\n public static string LongestCommonPrefix(string a, string b)\n\n {\n\n if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b))\n\n return string.Empty;\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Extensions/StringExtensions.cs", "rank": 23, "score": 50950.16563447492 }, { "content": "{\n\n return Convert<U16To8Conversion>(source.data(), source.length(), output);\n\n}\n\n\n\nstd::string U16To8(std::wstring_view source)\n\n{\n\n std::string buffer;\n\n (void)Convert<U16To8Conversion>(source.data(), source.length(), buffer);\n\n return buffer;\n\n}\n\n\n\n} // namespace etk\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 24, "score": 50947.996306245535 }, { "content": " typename OutputStringAllocator = std::allocator<typename Converter::OutputChar>>\n\nbool Convert(typename Converter::InputChar const* source, size_t sourceLength,\n\n std::basic_string<typename Converter::OutputChar, OutputCharTraits,\n\n OutputStringAllocator>& buffer)\n\n{\n\n if (sourceLength == 0)\n\n return true;\n\n\n\n size_t outLength;\n\n if (!Converter::EstimateLength(source, sourceLength, outLength))\n\n return false;\n\n\n\n buffer.resize(outLength);\n\n\n\n size_t const convertedLength =\n\n Converter::Convert(&buffer[0], buffer.length() + 1, source, sourceLength);\n\n if (convertedLength == 0) {\n\n buffer.clear();\n\n return false;\n\n }\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 25, "score": 50946.87197643195 }, { "content": " return true;\n\n}\n\n\n\nsize_t U8To16Conversion::Convert(wchar_t* out, size_t outSize, char const* source,\n\n size_t sourceLength) noexcept\n\n{\n\n if (outSize == 0)\n\n return 0;\n\n\n\n int const length =\n\n MultiByteToWideChar(CP_UTF8, 0, source, static_cast<int>(sourceLength), out,\n\n static_cast<int>(outSize));\n\n if (length <= 0)\n\n return 0;\n\n\n\n return static_cast<size_t>(length);\n\n}\n\n\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 26, "score": 50944.18168820014 }, { "content": " return true;\n\n}\n\n\n\nsize_t U16To8Conversion::Convert(char* out, size_t outSize, wchar_t const* source,\n\n size_t sourceLength) noexcept\n\n{\n\n if (outSize == 0)\n\n return 0;\n\n\n\n int const length =\n\n WideCharToMultiByte(CP_UTF8, 0, source, static_cast<int>(sourceLength), out,\n\n static_cast<int>(outSize), nullptr, nullptr);\n\n if (length <= 0)\n\n return 0;\n\n\n\n return static_cast<size_t>(length);\n\n}\n\n\n\ntemplate<typename Converter,\n\n typename OutputCharTraits = std::char_traits<typename Converter::OutputChar>,\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 27, "score": 50943.8146029162 }, { "content": "\n\n int length = Math.Min(a.Length, b.Length);\n\n int i;\n\n for (i = 0; i < length; ++i) {\n\n if (a[i] != b[i])\n\n break;\n\n }\n\n\n\n return a.Substring(0, i);\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Extensions/StringExtensions.cs", "rank": 28, "score": 50938.176251761935 }, { "content": "namespace EventTraceKit.EventTracing.Internal\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Xml;\n\n using System.Xml.Linq;\n\n\n\n internal sealed class XElementNamespaceResolver : IXmlNamespaceResolver\n\n {\n\n private readonly XElement element;\n\n\n\n public XElementNamespaceResolver(XElement element)\n\n {\n\n this.element = element;\n\n }\n\n\n\n public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)\n\n {\n\n throw new NotSupportedException();\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Internal/XElementNamespaceResolver.cs", "rank": 29, "score": 50194.11345940599 }, { "content": "namespace EventTraceKit.VsExtension.Views\n\n{\n\n using System.Collections.ObjectModel;\n\n using System.Linq;\n\n using EventTraceKit.Tracing;\n\n using EventTraceKit.VsExtension.Extensions;\n\n using EventTraceKit.VsExtension.Serialization;\n\n\n\n [SerializedShape(typeof(Settings.Persistence.SystemCollector))]\n\n public class SystemCollectorViewModel : CollectorViewModel\n\n {\n\n private string name = \"System Collector\";\n\n\n\n public SystemCollectorViewModel()\n\n {\n\n KernelFlags.Add(new KernelFlag(false, \"Process\", \"Process create/delete\", 0x00000001));\n\n KernelFlags.Add(new KernelFlag(false, \"Image Load\", \"Kernel and user mode Image Load/Unload events\", 0x00000004));\n\n }\n\n\n\n public override ITraceSettingsContext Context { get; set; }\n", "file_path": "src/EventTraceKit.VsExtension/Views/SystemCollectorViewModel.cs", "rank": 30, "score": 50191.3271020458 }, { "content": "\n\n public string Name\n\n {\n\n get => name;\n\n set => SetProperty(ref name, value);\n\n }\n\n\n\n public class KernelFlag : ObservableModel\n\n {\n\n private bool isEnabled;\n\n\n\n public KernelFlag(bool isEnabled, string name, string description, uint flagValue)\n\n {\n\n this.isEnabled = isEnabled;\n\n this.name = name;\n\n this.description = description;\n\n FlagValue = flagValue;\n\n }\n\n\n\n public bool IsEnabled\n", "file_path": "src/EventTraceKit.VsExtension/Views/SystemCollectorViewModel.cs", "rank": 31, "score": 50185.54554381572 }, { "content": "\n\n public string LookupNamespace(string prefix)\n\n {\n\n return element.GetNamespaceOfPrefix(prefix)?.NamespaceName;\n\n }\n\n\n\n public string LookupPrefix(string namespaceName)\n\n {\n\n return element.GetPrefixOfNamespace(namespaceName);\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing/Internal/XElementNamespaceResolver.cs", "rank": 32, "score": 50184.034355326374 }, { "content": " {\n\n get => isEnabled;\n\n set => SetProperty(ref isEnabled, value);\n\n }\n\n\n\n private string name;\n\n\n\n public string Name\n\n {\n\n get => name;\n\n set => SetProperty(ref name, value);\n\n }\n\n\n\n private string description;\n\n\n\n public string Description\n\n {\n\n get => description;\n\n set => SetProperty(ref description, value);\n\n }\n", "file_path": "src/EventTraceKit.VsExtension/Views/SystemCollectorViewModel.cs", "rank": 33, "score": 50179.98622008191 }, { "content": "\n\n public uint FlagValue { get; }\n\n }\n\n\n\n public ObservableCollection<KernelFlag> KernelFlags { get; } =\n\n new ObservableCollection<KernelFlag>();\n\n\n\n public override CollectorViewModel DeepClone()\n\n {\n\n var clone = new SystemCollectorViewModel();\n\n clone.KernelFlags.AddRange(KernelFlags.Select(x => new KernelFlag(x.IsEnabled, x.Name, x.Description, x.FlagValue)));\n\n return clone;\n\n }\n\n\n\n public override CollectorDescriptor CreateDescriptor()\n\n {\n\n var descriptor = new SystemCollectorDescriptor();\n\n descriptor.KernelFlags = KernelFlags.Where(x => x.IsEnabled).Aggregate(0u, (a, x) => a | x.FlagValue);\n\n return descriptor;\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.VsExtension/Views/SystemCollectorViewModel.cs", "rank": 34, "score": 50178.35904719005 }, { "content": "namespace EventTraceKit.VsExtension.Tests.Extensions\n\n{\n\n using System.Collections.Generic;\n\n using EventTraceKit.VsExtension.Extensions;\n\n using Xunit;\n\n\n\n public class StringExtensionsTest\n\n {\n\n [Theory]\n\n [InlineData(null, 0, TrimPosition.End, null)]\n\n [InlineData(\"1234567890\", 0, TrimPosition.End, \"\")]\n\n [InlineData(\"1234567890\", 0, TrimPosition.Start, \"\")]\n\n [InlineData(\"1234567890\", 0, TrimPosition.Middle, \"\")]\n\n [InlineData(\"1234567890\", 1, TrimPosition.End, \"…\")]\n\n [InlineData(\"1234567890\", 1, TrimPosition.Start, \"…\")]\n\n [InlineData(\"1234567890\", 1, TrimPosition.Middle, \"…\")]\n\n [InlineData(\"1234567890\", 2, TrimPosition.End, \"1…\")]\n\n [InlineData(\"1234567890\", 2, TrimPosition.Start, \"…0\")]\n\n [InlineData(\"1234567890\", 2, TrimPosition.Middle, \"1…\")]\n\n [InlineData(\"1234567890\", 5, TrimPosition.End, \"1234…\")]\n", "file_path": "src/EventTraceKit.VsExtension.Tests/Extensions/StringExtensionsTest.cs", "rank": 35, "score": 50135.97483106294 }, { "content": " [InlineData(\"foo bar\", \"foo bar (Copy)\", new[] { \"foo bar\" })]\n\n [InlineData(\"foo bar\", \"foo bar (Copy 2)\", new[] { \"foo bar\", \"foo bar (Copy)\" })]\n\n [InlineData(\"foo bar\", \"foo bar (Copy 3)\", new[] { \"foo bar\", \"foo bar (Copy)\", \"foo bar (Copy 2)\" })]\n\n [InlineData(\"foo bar\", \"foo bar (Copy)\", new[] { \"foo bar\", \"foo bar (Copy 2)\" })]\n\n [InlineData(\"foo bar\", \"foo bar (Copy 2)\", new[] { \"foo bar\", \"foo bar (Copy)\", \"foo bar (Copy 3)\" })]\n\n [InlineData(\"foo (Copy)\", \"foo (Copy)\", new[] { \"foo\" })]\n\n [InlineData(\"foo (Copy)\", \"foo (Copy 2)\", new[] { \"foo (Copy)\" })]\n\n [InlineData(\"foo (Copy 2)\", \"foo (Copy 3)\", new[] { \"foo (Copy 2)\" })]\n\n public void MakeNumberedCopy(string input, string expected, string[] used)\n\n {\n\n Assert.Equal(expected, input.MakeNumberedCopy(used != null ? new HashSet<string>(used) : null));\n\n Assert.Equal(expected, StringExtensions.MakeNumberedCopy(input, used != null ? new HashSet<string>(used) : null));\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.VsExtension.Tests/Extensions/StringExtensionsTest.cs", "rank": 36, "score": 50132.51345550208 }, { "content": " [InlineData(\"1234567890\", 5, TrimPosition.Start, \"…7890\")]\n\n [InlineData(\"1234567890\", 5, TrimPosition.Middle, \"12…90\")]\n\n [InlineData(\"1234567890\", 6, TrimPosition.End, \"12345…\")]\n\n [InlineData(\"1234567890\", 6, TrimPosition.Start, \"…67890\")]\n\n [InlineData(\"1234567890\", 6, TrimPosition.Middle, \"123…90\")]\n\n [InlineData(\"1234567890\", 10, TrimPosition.End, \"1234567890\")]\n\n [InlineData(\"1234567890\", 10, TrimPosition.Start, \"1234567890\")]\n\n [InlineData(\"1234567890\", 10, TrimPosition.Middle, \"1234567890\")]\n\n public void TrimToLength(string input, int maxLength, TrimPosition position, string expected)\n\n {\n\n Assert.Equal(expected, input.TrimToLength(maxLength, position));\n\n Assert.Equal(expected, StringExtensions.TrimToLength(input, maxLength, position));\n\n }\n\n\n\n [Theory]\n\n [InlineData(null, null, null)]\n\n [InlineData(\"foo\", \"foo\", null)]\n\n [InlineData(\"foo\", \"foo\", new string[0])]\n\n [InlineData(\"foo\", \"foo\", new[] { \"bar\" })]\n\n [InlineData(\"foo\", \"foo (Copy)\", new[] { \"foo\" })]\n", "file_path": "src/EventTraceKit.VsExtension.Tests/Extensions/StringExtensionsTest.cs", "rank": 37, "score": 50126.93105395291 }, { "content": "namespace EventTraceKit.EventTracing.Compilation.Support\n\n{\n\n using System;\n\n using System.IO;\n\n using System.IO.MemoryMappedFiles;\n\n using System.Runtime.InteropServices;\n\n using System.Text;\n\n\n\n internal sealed class MemoryMappedViewWriter : IDisposable\n\n {\n\n private readonly FileStream output;\n\n\n\n private MemoryMappedFile mappedFile;\n\n private MemoryMappedViewAccessor accessor;\n\n private byte[] stringBuffer = new byte[0x100];\n\n private long position;\n\n\n\n public MemoryMappedViewWriter(FileStream output, long initialCapacity = 0x10000)\n\n {\n\n this.output = output ?? throw new ArgumentNullException(nameof(output));\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 38, "score": 49395.749396682455 }, { "content": " return count;\n\n }\n\n\n\n public void WriteString(ref long offset, string str)\n\n {\n\n int count = EncodeName(str, ref stringBuffer);\n\n WriteArray(ref offset, stringBuffer, 0, count);\n\n }\n\n\n\n public void WriteZString(ref long offset, string str)\n\n {\n\n // Includes NUL wchar_t.\n\n int count = Encoding.Unicode.GetByteCount(str) + 2;\n\n if (stringBuffer.Length < count)\n\n stringBuffer = new byte[count];\n\n\n\n int byteCount = Encoding.Unicode.GetBytes(str, 0, str.Length, stringBuffer, 0);\n\n for (int i = byteCount; i < count; ++i)\n\n stringBuffer[i] = 0;\n\n WriteArray(ref offset, stringBuffer, 0, count);\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 39, "score": 49377.65054421089 }, { "content": " WriteResource(ref position, ref resource);\n\n }\n\n\n\n private int GetByteCount(string name)\n\n {\n\n // Count includes NUL and 4-byte length.\n\n int count = Encoding.Unicode.GetByteCount(name) + 2 + 4;\n\n return (count + 3) & ~3;\n\n }\n\n\n\n private int EncodeName(string name, ref byte[] buf)\n\n {\n\n int count = GetByteCount(name);\n\n if (buf.Length < count)\n\n buf = new byte[count];\n\n byte[] countBytes = BitConverter.GetBytes((uint)count);\n\n Buffer.BlockCopy(countBytes, 0, buf, 0, 4);\n\n int byteCount = Encoding.Unicode.GetBytes(name, 0, name.Length, buf, 4);\n\n for (int i = 4 + byteCount; i < count; ++i)\n\n buf[i] = 0;\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 40, "score": 49375.2362230816 }, { "content": "\n\n private void Allocate(long newCapacity)\n\n {\n\n if (accessor != null) {\n\n accessor.Dispose();\n\n mappedFile.Dispose();\n\n }\n\n\n\n mappedFile = MemoryMappedFile.CreateFromFile(\n\n output,\n\n null,\n\n newCapacity,\n\n MemoryMappedFileAccess.ReadWrite,\n\n null,\n\n HandleInheritability.None,\n\n true);\n\n\n\n accessor = mappedFile.CreateViewAccessor();\n\n Capacity = newCapacity;\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 41, "score": 49373.13984800272 }, { "content": "\n\n private void EnsureSpace(long offset, int byteCount)\n\n {\n\n long requiredCapacity = offset + byteCount;\n\n if (requiredCapacity > Capacity)\n\n GrowTo(requiredCapacity);\n\n }\n\n\n\n private void EnsureSpace(int byteCount)\n\n {\n\n long requiredCapacity = position + byteCount;\n\n if (requiredCapacity > Capacity)\n\n GrowTo(requiredCapacity);\n\n }\n\n\n\n private void GrowTo(long requiredCapacity)\n\n {\n\n long newCapacity = Capacity;\n\n while (newCapacity < requiredCapacity)\n\n newCapacity *= 2;\n\n Allocate(newCapacity);\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 42, "score": 49367.68790352438 }, { "content": "\n\n Allocate(initialCapacity);\n\n }\n\n\n\n public long Capacity { get; private set; }\n\n\n\n public long Position\n\n {\n\n get => position;\n\n set\n\n {\n\n position = value;\n\n if (position > Capacity)\n\n GrowTo(position);\n\n }\n\n }\n\n\n\n public void Dispose()\n\n {\n\n accessor.Dispose();\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 43, "score": 49367.68790352438 }, { "content": "\n\n public void WriteUInt8(byte value)\n\n {\n\n WriteUInt8(ref position, value);\n\n }\n\n\n\n public void WriteUInt16(ushort value)\n\n {\n\n WriteUInt16(ref position, value);\n\n }\n\n\n\n public void WriteUInt32(uint value)\n\n {\n\n WriteUInt32(ref position, value);\n\n }\n\n\n\n public void Align(ref long offset, int alignment)\n\n {\n\n var mod = (int)(offset % alignment);\n\n if (mod == 0)\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 44, "score": 49367.68790352438 }, { "content": " }\n\n\n\n public void WriteArray<T>(T[] values) where T : struct\n\n {\n\n WriteArray(ref position, values);\n\n }\n\n\n\n public void WriteArray<T>(ref long offset, T[] values) where T : struct\n\n {\n\n WriteArray(ref offset, values, 0, values.Length);\n\n }\n\n\n\n public void WriteArray<T>(ref long offset, T[] values, int index, int count) where T : struct\n\n {\n\n int byteCount = count * Marshal.SizeOf<T>();\n\n EnsureSpace(offset, byteCount);\n\n accessor.WriteArray(offset, values, index, count);\n\n offset += byteCount;\n\n }\n\n\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 45, "score": 49367.68790352438 }, { "content": " mappedFile.Dispose();\n\n output.SetLength(Position);\n\n }\n\n\n\n public void Flush()\n\n {\n\n accessor.Flush();\n\n output.Flush();\n\n }\n\n\n\n public void WriteResource<T>(ref long offset, ref T resource) where T : struct\n\n {\n\n var size = Marshal.SizeOf<T>();\n\n EnsureSpace(offset, size);\n\n accessor.Write(offset, ref resource);\n\n offset += size;\n\n }\n\n\n\n public void WriteResource<T>(ref T resource) where T : struct\n\n {\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 46, "score": 49367.68790352438 }, { "content": " return;\n\n int fill = alignment - mod;\n\n for (int i = 0; i < fill; ++i)\n\n WriteUInt8(ref offset, 0);\n\n }\n\n\n\n public void Align(int alignment)\n\n {\n\n Align(ref position, alignment);\n\n }\n\n\n\n public void AlignBlock(long start, ref long offset, int alignment)\n\n {\n\n var mod = (int)((offset - start) % alignment);\n\n if (mod == 0)\n\n return;\n\n int fill = alignment - mod;\n\n for (int i = 0; i < fill; ++i)\n\n WriteUInt8(ref offset, 0);\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 47, "score": 49367.68790352438 }, { "content": " public void WriteUInt8(ref long offset, byte value)\n\n {\n\n EnsureSpace(1);\n\n accessor.Write(offset, value);\n\n offset += 1;\n\n }\n\n\n\n public void WriteUInt16(ref long offset, ushort value)\n\n {\n\n EnsureSpace(2);\n\n accessor.Write(offset, value);\n\n offset += 2;\n\n }\n\n\n\n public void WriteUInt32(ref long offset, uint value)\n\n {\n\n EnsureSpace(offset, 4);\n\n accessor.Write(offset, value);\n\n offset += 4;\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/MemoryMappedViewWriter.cs", "rank": 48, "score": 49367.68790352438 }, { "content": "namespace EventTraceKit.VsExtension.Tests.Extensions\n\n{\n\n using System.Text;\n\n using VsExtension.Extensions;\n\n using Xunit;\n\n\n\n public class StringBuilderExtensionsTest\n\n {\n\n [Theory]\n\n [InlineData(0x00, \"00\")]\n\n [InlineData(0x9A, \"9A\")]\n\n [InlineData(0xAB, \"AB\")]\n\n [InlineData(0xFF, \"FF\")]\n\n public void Name(byte input, string expected)\n\n {\n\n var builder = new StringBuilder();\n\n builder.AppendHexByte(input);\n\n Assert.Equal(expected, builder.ToString());\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.VsExtension.Tests/Extensions/StringBuilderExtensionsTest.cs", "rank": 49, "score": 49349.94733895365 }, { "content": "namespace EventTraceKit.EventTracing.Tests.Internal.Extensions\n\n{\n\n using EventTraceKit.EventTracing.Internal.Extensions;\n\n using Xunit;\n\n\n\n public class StringExtensionsTest\n\n {\n\n [Theory]\n\n [InlineData(\"\", \"\")]\n\n [InlineData(\"abc\", \"abc\")]\n\n [InlineData(\"{\", \"{{\")]\n\n [InlineData(\"abc {0}\", \"abc {{0}}\")]\n\n [InlineData(\"abc {{0}}\", \"abc {{{{0}}}}\")]\n\n [InlineData(\"abc {{{0}}}\", \"abc {{{{{{0}}}}}}\")]\n\n public static void EscapeFormatting(string input, string expected)\n\n {\n\n Assert.Equal(expected, input.EscapeFormatting());\n\n Assert.Equal(input, string.Format(input.EscapeFormatting(), new object[0]));\n\n }\n\n\n", "file_path": "src/EventTraceKit.EventTracing.Tests/Internal/Extensions/StringExtensionsTest.cs", "rank": 50, "score": 49348.27097229085 }, { "content": " [Theory]\n\n [InlineData(null, null, \"\")]\n\n [InlineData(\"abc\", null, \"\")]\n\n [InlineData(null, \"abc\", \"\")]\n\n [InlineData(\"\", \"\", \"\")]\n\n [InlineData(\"abc\", \"\", \"\")]\n\n [InlineData(\"\", \"abc\", \"\")]\n\n [InlineData(\"abc\", \"abc\", \"abc\")]\n\n [InlineData(\"abcX\", \"abc\", \"abc\")]\n\n [InlineData(\"abc\", \"abcX\", \"abc\")]\n\n [InlineData(\"abcX\", \"abcY\", \"abc\")]\n\n public static void LongestCommonPrefix(string input1, string input2, string expected)\n\n {\n\n Assert.Equal(expected, StringExtensions.LongestCommonPrefix(input1, input2));\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing.Tests/Internal/Extensions/StringExtensionsTest.cs", "rank": 51, "score": 49340.15827006624 }, { "content": "struct U8To16Conversion\n\n{\n\n using InputChar = char;\n\n using OutputChar =\n\n std::conditional_t<sizeof(wchar_t) == sizeof(char16_t), wchar_t, char16_t>;\n\n static bool EstimateLength(InputChar const* source, size_t sourceLength,\n\n size_t& outLength) noexcept;\n\n static size_t Convert(OutputChar* out, size_t outLength, InputChar const* source,\n\n size_t sourceLength) noexcept;\n\n};\n\n\n\nbool U8To16Conversion::EstimateLength(char const* source, size_t sourceLength,\n\n size_t& outLength) noexcept\n\n{\n\n int const length = MultiByteToWideChar(CP_UTF8, 0, source,\n\n static_cast<int>(sourceLength), nullptr, 0);\n\n if (length <= 0)\n\n return false;\n\n\n\n outLength = static_cast<size_t>(length);\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 52, "score": 48564.928719895426 }, { "content": "struct U16To8Conversion\n\n{\n\n using InputChar =\n\n std::conditional_t<sizeof(wchar_t) == sizeof(char16_t), wchar_t, char16_t>;\n\n using OutputChar = char;\n\n static bool EstimateLength(InputChar const* source, size_t sourceLength,\n\n size_t& outLength) noexcept;\n\n static size_t Convert(OutputChar* out, size_t outLength, InputChar const* source,\n\n size_t sourceLength) noexcept;\n\n};\n\n\n\nbool U16To8Conversion::EstimateLength(wchar_t const* source, size_t sourceLength,\n\n size_t& outLength) noexcept\n\n{\n\n int const length = WideCharToMultiByte(\n\n CP_UTF8, 0, source, static_cast<int>(sourceLength), nullptr, 0, nullptr, nullptr);\n\n if (length <= 0)\n\n return false;\n\n\n\n outLength = static_cast<size_t>(length);\n", "file_path": "src/EventTraceKit.EtwCore/Source/Support/StringConversions.cpp", "rank": 53, "score": 48564.928719895426 }, { "content": "class string_back_insert_iterator\n\n{\n\npublic:\n\n using iterator_category = std::output_iterator_tag;\n\n using value_type = void;\n\n using difference_type = void;\n\n using pointer = void;\n\n using reference = void;\n\n\n\n using container_type = Container;\n\n\n\n explicit string_back_insert_iterator(Container& container)\n\n : container(std::addressof(container))\n\n {}\n\n\n\n template<typename T>\n\n string_back_insert_iterator& operator=(T const& value)\n\n {\n\n container->push_back(static_cast<typename Container::value_type>(value));\n\n return *this;\n", "file_path": "src/EventTraceKit.EtwCore/Source/EtwTraceProcessor.cpp", "rank": 54, "score": 47822.2375107212 }, { "content": "namespace etk\n\n{\n\n\n\ninline bool vsprintf(std::wstring& sink, size_t expectedLength, wchar_t const* format,\n\n va_list args)\n\n{\n\n size_t currSize = sink.size();\n\n\n\n bool measured = false;\n\nretry:\n\n if (expectedLength == 0) {\n\n va_list a;\n\n va_copy(a, args);\n\n int ret = _scwprintf(format, a);\n\n va_end(a);\n\n if (ret < 0)\n\n return false;\n\n if (ret == 0)\n\n return true;\n\n measured = true;\n\n expectedLength = static_cast<size_t>(ret);\n\n }\n\n\n\n if (expectedLength > 0)\n\n sink.resize(currSize + expectedLength);\n\n\n\n int ret = vswprintf(&sink[currSize], expectedLength + 1, format, args);\n\n if (ret < 0) {\n\n if (measured)\n\n return false;\n\n expectedLength = 0;\n\n goto retry;\n\n }\n\n\n\n size_t written = static_cast<unsigned>(ret);\n\n sink.resize(currSize + written);\n\n\n\n return written <= expectedLength;\n\n}\n\n\n\ninline bool vsprintf(std::wstring& sink, wchar_t const* format, va_list args)\n\n{\n\n return vsprintf(sink, 0, format, args);\n\n}\n\n\n\ninline bool sprintf(std::wstring& sink, wchar_t const* format, ...)\n\n{\n\n va_list args;\n\n va_start(args, format);\n\n bool ret = vsprintf(sink, 0, format, args);\n\n va_end(args);\n\n return ret;\n\n}\n\n\n\ninline bool sprintf(std::wstring& sink, size_t expectedLength, wchar_t const* format, ...)\n\n{\n\n va_list args;\n\n va_start(args, format);\n\n bool ret = vsprintf(sink, expectedLength, format, args);\n\n va_end(args);\n\n return ret;\n\n}\n\n\n", "file_path": "src/EventTraceKit.EtwCore/Public/etk/Support/StringFormat.h", "rank": 55, "score": 46402.97938446688 }, { "content": "namespace etk\n\n{\n\n\n\nbool U8To16(std::string_view source, std::wstring& output);\n\nstd::wstring U8To16(std::string_view source);\n\n\n\nbool U16To8(std::wstring_view source, std::string& output);\n\nstd::string U16To8(std::wstring_view source);\n\n\n", "file_path": "src/EventTraceKit.EtwCore/Public/etk/Support/StringConversions.h", "rank": 56, "score": 46402.97938446688 }, { "content": "struct EmcGenStaticProviderList\n\n{\n\n struct Entry\n\n {\n\n using FunctionType = ULONG();\n\n FunctionType* Register;\n\n FunctionType* Unregister;\n\n };\n\n\n\n /// <summary>\n\n /// Registers all enlisted static providers with ETW.\n\n /// </summary>\n\n static inline ULONG RegisterAll()\n\n {\n\n ULONG result = 0;\n\n for (auto it = &first + 1; it < &last; ++it) {\n\n if (*it) {\n\n ULONG const ec = (*it)->Register();\n\n if (ec != 0 && result == 0)\n\n result = ec;\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/CodeGen/CxxCodeGenerator.cs", "rank": 57, "score": 45776.487244793156 }, { "content": "#define MSG_UnexpectedSWFallback_OutOfVideoMemory 0xD000000EL\n", "file_path": "src/EventTraceKit.EventTracing.Tests/Compilation/ResGen/TestCases/wpf-etw.h", "rank": 58, "score": 41509.7684727525 }, { "content": "#define MSG_UnexpectedSWFallback_OutOfVideoMemory 0xD000000EL\n", "file_path": "src/EventTraceKit.EventTracing.Tests/Compilation/ResGen/TestCases/wpf-etw.wevt.v3-8.1-compat.h", "rank": 59, "score": 39921.191414375666 }, { "content": "#include <sdkddkver.h>\n\n#undef _WIN32_WINNT\n\n#define _WIN32_WINNT _WIN32_WINNT_WINBLUE\n\n\n\n#include \"etk/ADT/VarStructPtr.h\"\n\n#include \"etk/Support/CompilerSupport.h\"\n\n#include \"InteropHelper.h\"\n\n\n\n#include <memory>\n\n#include <windows.h>\n\n#include <tdh.h>\n\n\n\nusing namespace System;\n\nusing namespace System::Collections::Generic;\n\nusing namespace System::ComponentModel;\n\nusing namespace System::Runtime::InteropServices;\n\nusing namespace System::Threading;\n\nusing msclr::interop::marshal_as;\n\n\n\nnamespace\n", "file_path": "src/EventTraceKit.Etw/ManifestInfo.cpp", "rank": 61, "score": 39.49312747538503 }, { "content": "#include \"TraceLog.h\"\n\n#include <msclr/marshal_cppstd.h>\n\n\n\nusing namespace System;\n\nusing namespace System::ComponentModel;\n\nusing namespace System::Runtime::InteropServices;\n\nusing msclr::interop::marshal_as;\n\n\n\nnamespace EventTraceKit::Tracing\n\n{\n\n\n\nnamespace\n\n{\n\n\n\netk::TraceLogFilterEvent* GetNativeFunctionPtr(TraceLogFilterPredicate^ filter)\n\n{\n\n if (!filter) return nullptr;\n\n return static_cast<etk::TraceLogFilterEvent*>(\n\n Marshal::GetFunctionPointerForDelegate(filter).ToPointer());\n\n}\n\n\n", "file_path": "src/EventTraceKit.Etw/TraceLog.cpp", "rank": 62, "score": 36.3403069879213 }, { "content": "namespace EventTraceKit.VsExtension.Tests\n\n{\n\n using System.Collections.Generic;\n\n using System.IO;\n\n using System.Linq;\n\n using System.Xml.Linq;\n\n\n\n public static class TestExtensions\n\n {\n\n public static IEnumerable<XAttribute> NonXmlnsAttributes(this XElement element)\n\n {\n\n return element.Attributes().Where(x => !IsXmlns(x.Name));\n\n }\n\n\n\n public static bool IsXmlns(this XName name)\n\n {\n\n return name.LocalName == \"xmlns\" || name.Namespace == XNamespace.Xmlns;\n\n }\n\n\n\n public static string ReadFullyAsString(this MemoryStream stream)\n", "file_path": "src/EventTraceKit.VsExtension.Tests/TestExtensions.cs", "rank": 63, "score": 35.417189459732825 }, { "content": "#include \"WatchDog.h\"\n\n\n\nusing namespace System;\n\nusing namespace System::Diagnostics;\n\nusing namespace System::IO;\n\nusing namespace System::Reflection;\n\nusing namespace System::Text;\n\nusing namespace System::Threading;\n\nusing namespace Microsoft::Win32::SafeHandles;\n\n\n\nnamespace EventTraceKit\n\n{\n\n\n\nstatic String^ GetAssemblyFilePath(Assembly^ assembly)\n\n{\n\n String^ path = (gcnew Uri(assembly->CodeBase))->AbsolutePath;\n\n path = Uri::UnescapeDataString(path);\n\n return Path::GetFullPath(path);\n\n}\n\n\n", "file_path": "src/EventTraceKit.Etw/WatchDog.cpp", "rank": 64, "score": 32.29979067276252 }, { "content": "namespace EventTraceKit.VsExtension.Windows\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Linq;\n\n using System.Reflection;\n\n using System.Runtime.InteropServices;\n\n using System.Windows;\n\n using System.Windows.Controls.Primitives;\n\n using System.Windows.Data;\n\n using System.Windows.Interop;\n\n using System.Windows.Media;\n\n\n\n public static class FrameworkExtensions\n\n {\n\n private static readonly Func<DependencyObject, DependencyObject, bool> MenuBase_IsDescendant;\n\n\n\n static FrameworkExtensions()\n\n {\n\n MenuBase_IsDescendant = (Func<DependencyObject, DependencyObject, bool>)\n", "file_path": "src/EventTraceKit.VsExtension/Windows/FrameworkExtensions.cs", "rank": 65, "score": 31.986385075150743 }, { "content": "namespace EventTraceKit.VsExtension.Native\n\n{\n\n using System;\n\n using System.Diagnostics;\n\n using System.Runtime.InteropServices;\n\n using System.Text;\n\n using Microsoft.VisualStudio.Shell.Interop;\n\n using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;\n\n\n\n internal static class NativeMethods\n\n {\n\n public const int ERROR_NOT_SAME_DEVICE = 17;\n\n\n\n [DllImport(\"user32.dll\")]\n\n public static extern IntPtr GetCapture();\n\n\n\n [DllImport(\"user32.dll\")]\n\n [return: MarshalAs(UnmanagedType.Bool)]\n\n public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);\n\n\n", "file_path": "src/EventTraceKit.VsExtension/Native/NativeMethods.cs", "rank": 66, "score": 31.22312218599959 }, { "content": "namespace EventTraceKit.VsExtension.Serialization\n\n{\n\n using System.Collections.Generic;\n\n using System.IO;\n\n\n\n public static class XamlSerializerExtensions\n\n {\n\n public static MemoryStream SaveToStream(\n\n this IXamlSerializer serializer, object element)\n\n {\n\n var stream = new MemoryStream();\n\n serializer.Save(element, stream);\n\n stream.Position = 0;\n\n return stream;\n\n }\n\n\n\n public static string SaveToString(\n\n this IXamlSerializer serializer, object element)\n\n {\n\n using var stream = serializer.SaveToStream(element);\n", "file_path": "src/EventTraceKit.VsExtension/Serialization/XamlSerializerExtensions.cs", "rank": 67, "score": 30.449246813457748 }, { "content": "namespace EventTraceKit.EventTracing.Internal.Extensions\n\n{\n\n using System;\n\n using System.IO;\n\n using System.Runtime.InteropServices;\n\n using System.Text;\n\n\n\n internal static class BinaryReaderExtensions\n\n {\n\n public static string ReadPaddedString(this BinaryReader reader, uint byteCount)\n\n {\n\n return reader.ReadPaddedString(Encoding.ASCII, byteCount);\n\n }\n\n\n\n public static string ReadPaddedString(this BinaryReader reader, Encoding encoding, uint byteCount)\n\n {\n\n var bytes = new byte[byteCount];\n\n reader.Read(bytes, 0, bytes.Length);\n\n return encoding.GetString(bytes).TrimEnd('\\0');\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Extensions/BinaryReaderExtensions.cs", "rank": 68, "score": 29.561530428580355 }, { "content": "namespace EventTraceKit.EventTracing.Internal.Native\n\n{\n\n using System;\n\n using System.Runtime.ConstrainedExecution;\n\n using System.Runtime.InteropServices;\n\n\n\n public static class NativeMethods\n\n {\n\n public const int MESSAGE_RESOURCE_UNICODE = 1;\n\n\n\n [DllImport(\"kernel32.dll\")]\n\n [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]\n\n public static extern IntPtr LocalFree(IntPtr hMem);\n\n\n\n [DllImport(\"advapi32.dll\", CharSet = CharSet.Unicode, SetLastError = true)]\n\n private static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(\n\n string StringSecurityDescriptor,\n\n uint StringSDRevision,\n\n out SafeLocalMemHandle pSecurityDescriptor,\n\n out uint SecurityDescriptorSize);\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Native/NativeMethods.cs", "rank": 69, "score": 29.466591133085288 }, { "content": "namespace EventTraceKit.EventTracing.Internal.Native\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Runtime.ConstrainedExecution;\n\n using System.Runtime.InteropServices;\n\n using System.Security;\n\n\n\n [SecurityCritical]\n\n [SuppressUnmanagedCodeSecurity]\n\n internal static class UnsafeNativeMethods\n\n {\n\n public const short RT_RCDATA = 10;\n\n public const short RT_MESSAGETABLE = 11;\n\n public const short RT_HTML = 23;\n\n\n\n public static bool IS_INTRESOURCE(IntPtr ptr)\n\n {\n\n return (ptr.ToInt64() >> 16) == 0;\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Native/UnsafeNativeMethods.cs", "rank": 70, "score": 28.870623469308427 }, { "content": "namespace EventManifestCompiler.Build.Tasks.Tests\n\n{\n\n using System.Collections.Generic;\n\n using System.Text;\n\n\n\n public static class CommandLineUtils\n\n {\n\n public static IEnumerable<string> EnumerateCommandLineArgs(string commandLine)\n\n {\n\n if (string.IsNullOrEmpty(commandLine))\n\n yield break;\n\n\n\n int backslashCount = 0;\n\n bool inQuotes = false;\n\n\n\n var buffer = new StringBuilder();\n\n for (int i = 0; i < commandLine.Length; ++i) {\n\n char c = commandLine[i];\n\n switch (c) {\n\n case '\"':\n", "file_path": "src/EventManifestCompiler.Build.Tasks.Tests/CommandLineUtils.cs", "rank": 71, "score": 28.38219170712814 }, { "content": "namespace EventTraceKit.VsExtension\n\n{\n\n using System;\n\n using System.Diagnostics;\n\n using Microsoft.VisualStudio.Shell;\n\n using Microsoft.VisualStudio.Shell.Interop;\n\n\n\n public static class MessageHelper\n\n {\n\n public static void ShowWarningMessage(string message, string title)\n\n {\n\n VsShellUtilities.ShowMessageBox(\n\n ServiceProvider.GlobalProvider,\n\n message,\n\n title,\n\n OLEMSGICON.OLEMSGICON_WARNING,\n\n OLEMSGBUTTON.OLEMSGBUTTON_OK,\n\n OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);\n\n }\n\n\n", "file_path": "src/EventTraceKit.VsExtension/MessageHelper.cs", "rank": 72, "score": 28.352078940179602 }, { "content": "namespace EventTraceKit.EventTracing.Internal.Native\n\n{\n\n using System;\n\n using System.Globalization;\n\n using System.Runtime.InteropServices;\n\n\n\n internal sealed class ResourceName\n\n {\n\n public ResourceName(short id)\n\n {\n\n Id = id;\n\n }\n\n\n\n public ResourceName(string name)\n\n {\n\n Name = name;\n\n }\n\n\n\n public static ResourceName FromPtr(IntPtr ptr)\n\n {\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Native/ResourceName.cs", "rank": 73, "score": 28.28805060000025 }, { "content": "namespace EventTraceKit.EventTracing.Internal\n\n{\n\n using System.Collections.Generic;\n\n using System.IO;\n\n using System.Linq;\n\n\n\n internal static class WindowsSdkUtils\n\n {\n\n public static string FindSdkPath()\n\n {\n\n return EnumerateSdkIncludePaths().FirstOrDefault(Directory.Exists);\n\n }\n\n\n\n public static IEnumerable<string> EnumerateSdkIncludePaths()\n\n {\n\n var winKits10 = new DirectoryInfo(@\"C:\\Program Files (x86)\\Windows Kits\\10\\Include\");\n\n foreach (var dir in winKits10.EnumerateDirectories().Reverse()) {\n\n var path = Path.Combine(dir.FullName, \"um\");\n\n if (Directory.Exists(path))\n\n yield return path;\n\n }\n\n\n\n yield return @\"C:\\Program Files (x86)\\Windows Kits\\8.1\\Include\\um\";\n\n yield return @\"C:\\Program Files (x86)\\Windows Kits\\8.0\\Include\\um\";\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing/Internal/WindowsSdkUtils.cs", "rank": 74, "score": 28.134526690769842 }, { "content": "namespace EventTraceKit.EventTracing.Internal.Extensions\n\n{\n\n using System.Xml;\n\n using System.Xml.Linq;\n\n using System.Xml.Schema;\n\n\n\n internal static class XmlExtensions\n\n {\n\n public static void Add(\n\n this XmlSchemaSet set, XNamespace targetNamespace, string schemaUri)\n\n {\n\n set.Add(targetNamespace.NamespaceName, schemaUri);\n\n }\n\n\n\n public static void AddNamespace(\n\n this XmlNamespaceManager nsmgr, string prefix, XNamespace ns)\n\n {\n\n nsmgr.AddNamespace(prefix, ns.NamespaceName);\n\n }\n\n }\n\n}\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Extensions/XmlExtensions.cs", "rank": 75, "score": 28.09659831820796 }, { "content": "namespace EventTraceKit.VsExtension\n\n{\n\n using System.Runtime.InteropServices;\n\n using System.Windows;\n\n\n\n public static class ClipboardUtils\n\n {\n\n public static bool TryGet<T>(out T value, out string text)\n\n where T : class\n\n {\n\n value = default;\n\n text = default;\n\n\n\n var dataObj = Clipboard.GetDataObject();\n\n if (dataObj == null)\n\n return false;\n\n\n\n if (dataObj.GetDataPresent(typeof(T)))\n\n value = (T)dataObj.GetData(typeof(T));\n\n if (dataObj.GetDataPresent(DataFormats.UnicodeText, true))\n", "file_path": "src/EventTraceKit.VsExtension/ClipboardUtils.cs", "rank": 76, "score": 27.999257763081683 }, { "content": "#include <cstdio>\n\n#include <string>\n\n#include <string_view>\n\n\n\n#include <fcntl.h>\n\n#include <io.h>\n\n#include <objbase.h>\n\n#include <psapi.h>\n\n#include <windows.h>\n\n\n\nusing namespace std::literals;\n\n\n\nnamespace\n\n{\n\n\n\nbool Consume(wchar_t const*& p, wchar_t chr)\n\n{\n\n if (*p != chr)\n\n return false;\n\n\n", "file_path": "src/TraceLaunch.x86/Main.cpp", "rank": 77, "score": 27.771248923616497 }, { "content": "namespace EventManifestCompiler.Build.Tasks\n\n{\n\n using System;\n\n using System.IO;\n\n using System.Security;\n\n using Microsoft.Build.Framework;\n\n using Microsoft.Build.Utilities;\n\n\n\n internal static class FileUtilities\n\n {\n\n internal static string GetTemporaryFile()\n\n {\n\n return GetTemporaryFile(\".tmp\");\n\n }\n\n\n\n internal static string GetTemporaryFile(string extension)\n\n {\n\n return GetTemporaryFile(null, extension);\n\n }\n\n\n", "file_path": "src/EventManifestCompiler.Build.Tasks/FileUtilities.cs", "rank": 78, "score": 27.66754230879425 }, { "content": "namespace EventManifestCompiler.Build.Tasks\n\n{\n\n using System;\n\n using System.IO;\n\n\n\n internal static class ErrorUtilities\n\n {\n\n internal static void ThrowInternalError(string message, params object[] args)\n\n {\n\n //throw new InternalErrorException(ResourceUtilities.FormatString(message, args));\n\n throw new Exception(string.Format(message, args));\n\n }\n\n\n\n internal static void ThrowInternalError(string message, Exception innerException, params object[] args)\n\n {\n\n //throw new InternalErrorException(ResourceUtilities.FormatString(message, args), innerException);\n\n throw new Exception(string.Format(message, args), innerException);\n\n }\n\n\n\n internal static void VerifyThrow(bool condition, string unformattedMessage)\n", "file_path": "src/EventManifestCompiler.Build.Tasks/ErrorUtilities.cs", "rank": 79, "score": 26.596582588484225 }, { "content": "namespace EventTraceKit.VsExtension.Native\n\n{\n\n using System;\n\n using System.Runtime.InteropServices;\n\n using Microsoft.Win32.SafeHandles;\n\n\n\n internal sealed class SafeBstrHandle : SafeHandleZeroOrMinusOneIsInvalid\n\n {\n\n private SafeBstrHandle(IntPtr handle) : base(true)\n\n {\n\n SetHandle(handle);\n\n }\n\n\n\n public static SafeBstrHandle Create(string str)\n\n {\n\n return new SafeBstrHandle(Marshal.StringToBSTR(str));\n\n }\n\n\n\n public unsafe UnmanagedString Get()\n\n {\n", "file_path": "src/EventTraceKit.VsExtension/Native/SafeBstrHandle.cs", "rank": 80, "score": 26.54624766242958 }, { "content": "namespace Xunit.Sdk\n\n{\n\n using System;\n\n using System.Collections;\n\n using System.Collections.Generic;\n\n using System.Globalization;\n\n using System.Linq;\n\n using System.Reflection;\n\n using System.Text;\n\n using EventTraceKit.EventTracing.Tests.Compilation.TestSupport;\n\n\n\n internal class SequenceEqualException : EqualException\n\n {\n\n private static readonly Dictionary<char, string> Encodings = new Dictionary<char, string> {\n\n { '\\r', \"\\\\r\" },\n\n { '\\n', \"\\\\n\" },\n\n { '\\t', \"\\\\t\" },\n\n { '\\0', \"\\\\0\" }\n\n };\n\n\n", "file_path": "src/EventTraceKit.EventTracing.Tests/Compilation/TestSupport/SequenceEqualException.cs", "rank": 81, "score": 26.41011911829444 }, { "content": "namespace EventTraceKit.VsExtension.Extensions\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Linq;\n\n using System.Runtime.InteropServices;\n\n using EnvDTE;\n\n using EnvDTE80;\n\n using Microsoft.VisualStudio;\n\n using Microsoft.VisualStudio.Shell;\n\n using Microsoft.VisualStudio.Shell.Interop;\n\n\n\n internal static class DteExtensions\n\n {\n\n public static IEnumerable<Project> ProjectsRecursive(this Solution solution)\n\n {\n\n return solution.Projects.Cast<Project>().SelectMany(EnumerateProject);\n\n }\n\n\n\n private static IEnumerable<Project> EnumerateProject(Project project)\n", "file_path": "src/EventTraceKit.VsExtension/Extensions/DteExtensions.cs", "rank": 82, "score": 26.328013542766143 }, { "content": "namespace EventTraceKit.VsExtension.Views.PresetManager\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Linq;\n\n using System.Threading.Tasks;\n\n using System.Windows;\n\n using EventTraceKit.VsExtension.Windows;\n\n\n\n public partial class PresetSaveAsDialog\n\n {\n\n private readonly IEnumerable<string> builtInPresetNames;\n\n private AsyncDelegateCommand saveCommand;\n\n\n\n public static readonly DependencyProperty CanExecuteProperty =\n\n DependencyProperty.Register(\n\n nameof(CanExecute),\n\n typeof(bool),\n\n typeof(PresetSaveAsDialog),\n\n new PropertyMetadata(\n", "file_path": "src/EventTraceKit.VsExtension/Views/PresetManager/PresetSaveAsDialog.xaml.cs", "rank": 83, "score": 26.021238910440236 }, { "content": "namespace EventTraceKit.VsExtension.Views\n\n{\n\n using System;\n\n using System.Runtime.InteropServices;\n\n using System.Windows;\n\n using System.Windows.Interop;\n\n using EventTraceKit.VsExtension.Extensions;\n\n using Microsoft.VisualStudio.Shell;\n\n using Microsoft.VisualStudio.Shell.Interop;\n\n using Microsoft.Win32;\n\n using Microsoft.Windows.TaskDialogs;\n\n\n\n public static class VsModalExtensions\n\n {\n\n public static TaskDialogResult ShowModal(this TaskDialog dialog)\n\n {\n\n dialog.OwnerWindow = new HandleRef(null, GetDialogOwnerHwnd());\n\n return dialog.Show();\n\n }\n\n\n", "file_path": "src/EventTraceKit.VsExtension/Views/VsModalExtensions.cs", "rank": 84, "score": 25.90072408731532 }, { "content": "namespace CoreConsoleApp\n\n{\n\n using System;\n\n using System.Threading;\n\n\n\n public class Program\n\n {\n\n public static void Main(string[] args)\n\n {\n\n for (int i = 0; i < 50; ++i) {\n\n Console.WriteLine(\"CoreConsoleApp {0}\", i);\n\n Thread.Sleep(1000);\n\n }\n\n }\n\n }\n\n}\n", "file_path": "test/CoreConsoleApp/Program.cs", "rank": 85, "score": 25.857268050069848 }, { "content": "namespace EventTraceKit.VsExtension\n\n{\n\n using System;\n\n using System.Globalization;\n\n using System.Linq;\n\n using System.Runtime.InteropServices;\n\n using System.Windows;\n\n using System.Windows.Markup;\n\n using System.Windows.Media;\n\n using Microsoft.VisualStudio;\n\n using Microsoft.VisualStudio.Settings;\n\n using Microsoft.VisualStudio.Shell;\n\n using Microsoft.VisualStudio.Shell.Interop;\n\n using Microsoft.VisualStudio.Shell.Settings;\n\n using Microsoft.VisualStudio.TextManager.Interop;\n\n using Native;\n\n using IServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;\n\n\n\n public static class FontUtils\n\n {\n", "file_path": "src/EventTraceKit.VsExtension/FontAndColorsHelper.cs", "rank": 86, "score": 25.82344818629604 }, { "content": "namespace EventTraceKit.EventTracing.Compilation.Support\n\n{\n\n using System.IO;\n\n using System.Text;\n\n using System.Threading;\n\n\n\n internal static class IO\n\n {\n\n private static UTF8Encoding utf8WithBOM;\n\n private static UTF8Encoding utf8NoBOM;\n\n\n\n private static Encoding UTF8BOM\n\n {\n\n get\n\n {\n\n if (utf8WithBOM == null) {\n\n var encoding = new UTF8Encoding(false, true);\n\n Thread.MemoryBarrier();\n\n utf8WithBOM = encoding;\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/Support/IO.cs", "rank": 87, "score": 25.620577226254124 }, { "content": "namespace EventTraceKit.VsExtension.UITests\n\n{\n\n using System;\n\n using System.Collections;\n\n using System.Collections.Generic;\n\n using System.Linq;\n\n using System.Threading.Tasks;\n\n using System.Windows;\n\n using System.Windows.Controls;\n\n using EventTraceKit.VsExtension.Windows;\n\n using Microsoft.VisualStudio.Threading;\n\n using Xunit;\n\n\n\n public class BindTest\n\n {\n\n private const string SpecialItemValue = \"<special>\";\n\n\n\n private static IEnumerable<string> NextItems(Random rng, int count)\n\n {\n\n var list = Enumerable.Range(0, count).Select(x => rng.Next().ToString()).ToList();\n", "file_path": "src/EventTraceKit.VsExtension.UITests/BindTest.cs", "rank": 88, "score": 25.384785486282603 }, { "content": "namespace EventTraceKit.VsExtension.Extensions\n\n{\n\n using System;\n\n using System.Xml.Linq;\n\n\n\n public static class XElementExtensions\n\n {\n\n public static string AsString(this XAttribute attribute)\n\n {\n\n return attribute?.Value;\n\n }\n\n\n\n public static byte? AsByte(this XAttribute attribute)\n\n {\n\n if (attribute != null && byte.TryParse(attribute.Value, out byte value))\n\n return value;\n\n return null;\n\n }\n\n\n\n public static ushort? AsUShort(this XAttribute attribute)\n", "file_path": "src/EventTraceKit.VsExtension/Extensions/XElementExtensions.cs", "rank": 89, "score": 25.351287370805956 }, { "content": "namespace EventManifestCompiler\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.ComponentModel;\n\n using System.ComponentModel.Composition;\n\n using System.ComponentModel.Composition.Hosting;\n\n using System.Diagnostics;\n\n using System.IO;\n\n using System.Linq;\n\n using System.Reflection;\n\n using EventManifestCompiler.Support;\n\n using EventTraceKit.EventTracing.Compilation.CodeGen;\n\n using EventTraceKit.EventTracing.Support;\n\n using NOption;\n\n\n\n public static class Program\n\n {\n\n public static int Main(string[] args)\n\n {\n", "file_path": "src/EventManifestCompiler/Program.cs", "rank": 90, "score": 25.312860491090685 }, { "content": "namespace EventTraceKit.EventTracing.Compilation.CodeGen\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Linq;\n\n using System.Text;\n\n\n\n internal static class CodeGenUtils\n\n {\n\n public static IEnumerable<int> CodePoints(this string str)\n\n {\n\n for (int i = 0; i < str.Length;) {\n\n int cp;\n\n if (char.IsSurrogate(str, i)) {\n\n cp = char.ConvertToUtf32(str, i);\n\n i += 2;\n\n } else {\n\n cp = str[i];\n\n ++i;\n\n }\n", "file_path": "src/EventTraceKit.EventTracing/Compilation/CodeGen/CodeGenUtils.cs", "rank": 91, "score": 25.289714639596014 }, { "content": "namespace EventManifestCompiler.Build.Tasks\n\n{\n\n using System;\n\n using System.IO;\n\n using System.Security;\n\n\n\n internal static class ExceptionHandling\n\n {\n\n internal static bool NotExpectedException(Exception ex)\n\n {\n\n return\n\n !(ex is UnauthorizedAccessException) &&\n\n !(ex is NotSupportedException) &&\n\n (!(ex is ArgumentException) || ex is ArgumentNullException) &&\n\n !(ex is SecurityException) &&\n\n !(ex is IOException);\n\n }\n\n }\n\n}\n", "file_path": "src/EventManifestCompiler.Build.Tasks/ExceptionHandling.cs", "rank": 92, "score": 24.975498336930613 }, { "content": "namespace EventTraceKit.VsExtension.Formatting\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.Linq;\n\n using System.Reflection;\n\n\n\n public static class FormatProviderExtensions\n\n {\n\n public static string DefaultFormat(\n\n this IFormatProvider formatProvider)\n\n {\n\n return formatProvider?.GetType()\n\n .GetCustomAttribute<DefaultFormatAttribute>(true)?.DefaultFormat;\n\n }\n\n\n\n public static SupportedFormat DefaultSupportedFormat(\n\n this IFormatProvider formatProvider)\n\n {\n\n if (formatProvider == null)\n", "file_path": "src/EventTraceKit.VsExtension/Formatting/FormatProviderExtensions.cs", "rank": 93, "score": 24.923327334296108 }, { "content": "namespace EventTraceKit.EventTracing.Internal.Native\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n using System.ComponentModel;\n\n using System.IO;\n\n using System.Runtime.InteropServices;\n\n\n\n internal static class SafeModuleHandleExtensions\n\n {\n\n public static List<ResourceName> GetResourceTypes(this SafeModuleHandle module)\n\n {\n\n return UnsafeNativeMethods.GetResourceTypesEx(module);\n\n }\n\n\n\n public static List<ResourceName> GetResourceNames(this SafeModuleHandle module, ResourceName type)\n\n {\n\n return UnsafeNativeMethods.GetResourceNamesEx(module, type);\n\n }\n\n\n", "file_path": "src/EventTraceKit.EventTracing/Internal/Native/SafeModuleHandleExtensions.cs", "rank": 95, "score": 24.592216894510592 }, { "content": "namespace EventTraceKit.VsExtension.Windows\n\n{\n\n using System.Windows;\n\n using Extensions;\n\n\n\n public static class ValidateValueCallbacks\n\n {\n\n private static bool IsFiniteDoubleImpl(object value)\n\n {\n\n return value is double d && d.IsFinite();\n\n }\n\n\n\n public static ValidateValueCallback IsFiniteDouble { get; } = IsFiniteDoubleImpl;\n\n }\n\n}\n", "file_path": "src/EventTraceKit.VsExtension/Windows/ValidateValueCallbacks.cs", "rank": 96, "score": 24.51298787185155 }, { "content": "namespace EventTraceKit.VsExtension.Extensions\n\n{\n\n using System;\n\n using System.Collections.Generic;\n\n\n\n internal static class ComparisonUtils\n\n {\n\n public static bool CompareValueT<T>(\n\n out int cmp, T first, T second) where T : struct, IComparable<T>\n\n {\n\n cmp = first.CompareTo(second);\n\n return cmp == 0;\n\n }\n\n\n\n public static bool Compare<T>(out int cmp, T first, T second)\n\n where T : IComparable\n\n {\n\n cmp = first.CompareTo(second);\n\n return cmp == 0;\n\n }\n", "file_path": "src/EventTraceKit.VsExtension/Extensions/ComparisonUtils.cs", "rank": 97, "score": 24.441652349838826 }, { "content": "namespace EventTraceKit.VsExtension\n\n{\n\n using System;\n\n using System.Threading.Tasks;\n\n using System.Windows.Input;\n\n\n\n public class AsyncDelegateCommand : ICommand\n\n {\n\n private static readonly Func<bool> CanAlwaysExecute = () => true;\n\n private readonly Func<Task> execute;\n\n private readonly Func<bool> canExecute;\n\n private bool isExecuting;\n\n\n\n public AsyncDelegateCommand(Func<Task> execute)\n\n : this(execute, CanAlwaysExecute)\n\n {\n\n }\n\n\n\n public AsyncDelegateCommand(\n\n Func<Task> execute, Func<bool> canExecute)\n", "file_path": "src/EventTraceKit.VsExtension/AsyncDelegateCommand.cs", "rank": 98, "score": 24.380954199212148 }, { "content": "namespace PerfRunner\n\n{\n\n using System;\n\n using System.Runtime.InteropServices;\n\n\n\n internal sealed class CoTaskMemHandle : SafeHandle\n\n {\n\n public CoTaskMemHandle(IntPtr handle)\n\n : base(handle, true)\n\n {\n\n }\n\n\n\n public override bool IsInvalid => handle == IntPtr.Zero;\n\n\n\n public static CoTaskMemHandle Allocate(int size)\n\n {\n\n var buffer = Marshal.AllocCoTaskMem(size);\n\n return new CoTaskMemHandle(buffer);\n\n }\n\n\n\n protected override bool ReleaseHandle()\n\n {\n\n Marshal.FreeCoTaskMem(handle);\n\n return true;\n\n }\n\n }\n\n}\n", "file_path": "src/PerfRunner/CoTaskMemHandle.cs", "rank": 99, "score": 24.275686108896927 } ]
C++
export/windows/cpp/obj/src/haxe/Timer.cpp
TinyPlanetStudios/Project-Crash-Land
365f196be4212602d32251566f26b53fb70693f6
#include <hxcpp.h> #ifndef INCLUDED_haxe_Log #include <haxe/Log.h> #endif #ifndef INCLUDED_haxe_Timer #include <haxe/Timer.h> #endif #ifndef INCLUDED_openfl__legacy_Lib #include <openfl/_legacy/Lib.h> #endif namespace haxe{ void Timer_obj::__construct(Float time){ HX_STACK_FRAME("haxe.Timer","new",0x4136b0cf,"haxe.Timer.new","haxe/Timer.hx",210,0x1a690682) HX_STACK_THIS(this) HX_STACK_ARG(time,"time") HXLINE( 212) this->mTime = time; HXLINE( 213) ::haxe::Timer_obj::sRunningTimers->push(hx::ObjectPtr<OBJ_>(this)); HXLINE( 214) Float _hx_tmp = ::haxe::Timer_obj::getMS(); HXDLIN( 214) this->mFireAt = (_hx_tmp + this->mTime); HXLINE( 215) this->mRunning = true; } Dynamic Timer_obj::__CreateEmpty() { return new Timer_obj; } hx::ObjectPtr< Timer_obj > Timer_obj::__new(Float time) { hx::ObjectPtr< Timer_obj > _hx_result = new Timer_obj(); _hx_result->__construct(time); return _hx_result; } Dynamic Timer_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< Timer_obj > _hx_result = new Timer_obj(); _hx_result->__construct(inArgs[0]); return _hx_result; } HX_BEGIN_DEFAULT_FUNC(__default_run,Timer_obj) void _hx_run(){ HX_STACK_FRAME("haxe.Timer","__default_run",0xdc2b9b9c,"haxe.Timer.__default_run","haxe/Timer.hx",257,0x1a690682) HX_STACK_THIS(this) } HX_END_LOCAL_FUNC0((void)) HX_END_DEFAULT_FUNC void Timer_obj::stop(){ HX_STACK_FRAME("haxe.Timer","stop",0xd1fd70b3,"haxe.Timer.stop","haxe/Timer.hx",277,0x1a690682) HX_STACK_THIS(this) HXLINE( 277) Bool _hx_tmp = this->mRunning; HXDLIN( 277) if (_hx_tmp) { HXLINE( 279) this->mRunning = false; HXLINE( 281) { HXLINE( 281) HX_VARI( Int,_g1) = (int)0; HXDLIN( 281) HX_VARI( Int,_g) = ::haxe::Timer_obj::sRunningTimers->length; HXDLIN( 281) while((_g1 < _g)){ HXLINE( 281) HX_VARI( Int,i) = _g1++; HXLINE( 283) Bool _hx_tmp1 = hx::IsEq( ::haxe::Timer_obj::sRunningTimers->__get(i).StaticCast< ::haxe::Timer >(),hx::ObjectPtr<OBJ_>(this) ); HXDLIN( 283) if (_hx_tmp1) { HXLINE( 285) ::haxe::Timer_obj::sRunningTimers[i] = null(); HXLINE( 286) goto _hx_goto_0; } } _hx_goto_0:; } } } HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,stop,(void)) void Timer_obj::_hx___check(Float inTime){ HX_STACK_FRAME("haxe.Timer","__check",0xb5623597,"haxe.Timer.__check","haxe/Timer.hx",299,0x1a690682) HX_STACK_THIS(this) HX_STACK_ARG(inTime,"inTime") HXLINE( 299) Bool _hx_tmp = (inTime >= this->mFireAt); HXDLIN( 299) if (_hx_tmp) { HXLINE( 301) hx::AddEq(this->mFireAt,this->mTime); HXLINE( 302) this->run(); } } HX_DEFINE_DYNAMIC_FUNC1(Timer_obj,_hx___check,(void)) ::Array< ::Dynamic> Timer_obj::sRunningTimers; ::haxe::Timer Timer_obj::delay( ::Dynamic f,Int time){ HX_BEGIN_LOCAL_FUNC_S2(hx::LocalFunc,_hx_Closure_0, ::Dynamic,f, ::haxe::Timer,t) HXARGC(0) void _hx_run(){ HX_STACK_FRAME("haxe.Timer","delay",0x3ed5f1b2,"haxe.Timer.delay","haxe/Timer.hx",224,0x1a690682) HXLINE( 226) t->stop(); HXLINE( 227) f(); } HX_END_LOCAL_FUNC0((void)) HX_STACK_FRAME("haxe.Timer","delay",0x3ed5f1b2,"haxe.Timer.delay","haxe/Timer.hx",220,0x1a690682) HX_STACK_ARG(f,"f") HX_STACK_ARG(time,"time") HXLINE( 222) HX_VARI( ::haxe::Timer,t) = ::haxe::Timer_obj::__new(time); HXLINE( 224) t->run = ::Dynamic(new _hx_Closure_0(f,t)); HXLINE( 231) return t; } STATIC_HX_DEFINE_DYNAMIC_FUNC2(Timer_obj,delay,return ) Float Timer_obj::getMS(){ HX_STACK_FRAME("haxe.Timer","getMS",0xf90fafab,"haxe.Timer.getMS","haxe/Timer.hx",239,0x1a690682) HXLINE( 239) Float _hx_tmp = ( (Float)(::haxe::Timer_obj::lime_time_stamp()) ); HXDLIN( 239) return (_hx_tmp * ((Float)1000.0)); } STATIC_HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,getMS,return ) ::Dynamic Timer_obj::measure( ::Dynamic f, ::Dynamic pos){ HX_STACK_FRAME("haxe.Timer","measure",0x42373f4d,"haxe.Timer.measure","haxe/Timer.hx",247,0x1a690682) HX_STACK_ARG(f,"f") HX_STACK_ARG(pos,"pos") HXLINE( 249) HX_VARI( Float,t0) = ::haxe::Timer_obj::stamp(); HXLINE( 250) HX_VARI( ::Dynamic,r) = f(); HXLINE( 251) Float _hx_tmp = ::haxe::Timer_obj::stamp(); HXDLIN( 251) ::haxe::Log_obj::trace(((_hx_tmp - t0) + HX_("s",73,00,00,00)),pos); HXLINE( 252) return r; } STATIC_HX_DEFINE_DYNAMIC_FUNC2(Timer_obj,measure,return ) Float Timer_obj::stamp(){ HX_STACK_FRAME("haxe.Timer","stamp",0xebba8a32,"haxe.Timer.stamp","haxe/Timer.hx",267,0x1a690682) HXLINE( 267) return ( (Float)(::haxe::Timer_obj::lime_time_stamp()) ); } STATIC_HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,stamp,return ) void Timer_obj::_hx___checkTimers(){ HX_STACK_FRAME("haxe.Timer","__checkTimers",0xb7078205,"haxe.Timer.__checkTimers","haxe/Timer.hx",309,0x1a690682) HXLINE( 311) HX_VARI( Float,now) = ::haxe::Timer_obj::getMS(); HXLINE( 312) HX_VARI( Bool,foundNull) = false; HXLINE( 313) HX_VAR( ::haxe::Timer,timer); HXLINE( 315) { HXLINE( 315) HX_VARI( Int,_g1) = (int)0; HXDLIN( 315) HX_VARI( Int,_g) = ::haxe::Timer_obj::sRunningTimers->length; HXDLIN( 315) while((_g1 < _g)){ HXLINE( 315) HX_VARI( Int,i) = _g1++; HXLINE( 317) timer = ::haxe::Timer_obj::sRunningTimers->__get(i).StaticCast< ::haxe::Timer >(); HXLINE( 319) Bool _hx_tmp = hx::IsNotNull( timer ); HXDLIN( 319) if (_hx_tmp) { HXLINE( 321) timer->_hx___check(now); } HXLINE( 325) Bool _hx_tmp1 = !(foundNull); HXDLIN( 325) if (_hx_tmp1) { HXLINE( 325) foundNull = hx::IsNull( ::haxe::Timer_obj::sRunningTimers->__get(i).StaticCast< ::haxe::Timer >() ); } else { HXLINE( 325) foundNull = true; } } } HXLINE( 329) if (foundNull) { HX_BEGIN_LOCAL_FUNC_S0(hx::LocalFunc,_hx_Closure_0) HXARGC(1) Bool _hx_run( ::haxe::Timer val){ HX_STACK_FRAME("haxe.Timer","__checkTimers",0xb7078205,"haxe.Timer.__checkTimers","haxe/Timer.hx",331,0x1a690682) HX_STACK_ARG(val,"val") HXLINE( 331) return hx::IsNotNull( val ); } HX_END_LOCAL_FUNC1(return) HXLINE( 331) ::haxe::Timer_obj::sRunningTimers = ::haxe::Timer_obj::sRunningTimers->filter( ::Dynamic(new _hx_Closure_0())); } } STATIC_HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,_hx___checkTimers,(void)) Float Timer_obj::_hx___nextWake(Float limit){ HX_STACK_FRAME("haxe.Timer","__nextWake",0x0e101148,"haxe.Timer.__nextWake","haxe/Timer.hx",339,0x1a690682) HX_STACK_ARG(limit,"limit") HXLINE( 341) HX_VARI( Float,now) = ::haxe::Timer_obj::getMS(); HXLINE( 342) HX_VAR( Float,sleep); HXLINE( 344) { HXLINE( 344) HX_VARI( Int,_g) = (int)0; HXDLIN( 344) HX_VARI( ::Array< ::Dynamic>,_g1) = ::haxe::Timer_obj::sRunningTimers; HXDLIN( 344) while((_g < _g1->length)){ HXLINE( 344) HX_VARI( ::haxe::Timer,timer) = _g1->__get(_g).StaticCast< ::haxe::Timer >(); HXDLIN( 344) ++_g; HXLINE( 346) Bool _hx_tmp = hx::IsNull( timer ); HXDLIN( 346) if (_hx_tmp) { HXLINE( 347) continue; } HXLINE( 349) sleep = (timer->mFireAt - now); HXLINE( 351) Bool _hx_tmp1 = (sleep < limit); HXDLIN( 351) if (_hx_tmp1) { HXLINE( 353) limit = sleep; HXLINE( 355) if ((sleep < (int)0)) { HXLINE( 357) return (int)0; } } } } HXLINE( 365) return (limit * ((Float)0.001)); } STATIC_HX_DEFINE_DYNAMIC_FUNC1(Timer_obj,_hx___nextWake,return ) ::Dynamic Timer_obj::lime_time_stamp; Timer_obj::Timer_obj() { run = new __default_run(this); } void Timer_obj::__Mark(HX_MARK_PARAMS) { HX_MARK_BEGIN_CLASS(Timer); HX_MARK_MEMBER_NAME(mTime,"mTime"); HX_MARK_MEMBER_NAME(mFireAt,"mFireAt"); HX_MARK_MEMBER_NAME(mRunning,"mRunning"); HX_MARK_MEMBER_NAME(run,"run"); HX_MARK_END_CLASS(); } void Timer_obj::__Visit(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(mTime,"mTime"); HX_VISIT_MEMBER_NAME(mFireAt,"mFireAt"); HX_VISIT_MEMBER_NAME(mRunning,"mRunning"); HX_VISIT_MEMBER_NAME(run,"run"); } hx::Val Timer_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp) { switch(inName.length) { case 3: if (HX_FIELD_EQ(inName,"run") ) { return hx::Val( run); } break; case 4: if (HX_FIELD_EQ(inName,"stop") ) { return hx::Val( stop_dyn()); } break; case 5: if (HX_FIELD_EQ(inName,"mTime") ) { return hx::Val( mTime); } break; case 7: if (HX_FIELD_EQ(inName,"mFireAt") ) { return hx::Val( mFireAt); } if (HX_FIELD_EQ(inName,"__check") ) { return hx::Val( _hx___check_dyn()); } break; case 8: if (HX_FIELD_EQ(inName,"mRunning") ) { return hx::Val( mRunning); } } return super::__Field(inName,inCallProp); } bool Timer_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp) { switch(inName.length) { case 5: if (HX_FIELD_EQ(inName,"delay") ) { outValue = delay_dyn(); return true; } if (HX_FIELD_EQ(inName,"getMS") ) { outValue = getMS_dyn(); return true; } if (HX_FIELD_EQ(inName,"stamp") ) { outValue = stamp_dyn(); return true; } break; case 7: if (HX_FIELD_EQ(inName,"measure") ) { outValue = measure_dyn(); return true; } break; case 10: if (HX_FIELD_EQ(inName,"__nextWake") ) { outValue = _hx___nextWake_dyn(); return true; } break; case 13: if (HX_FIELD_EQ(inName,"__checkTimers") ) { outValue = _hx___checkTimers_dyn(); return true; } break; case 14: if (HX_FIELD_EQ(inName,"sRunningTimers") ) { outValue = sRunningTimers; return true; } break; case 15: if (HX_FIELD_EQ(inName,"lime_time_stamp") ) { outValue = lime_time_stamp; return true; } } return false; } hx::Val Timer_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 3: if (HX_FIELD_EQ(inName,"run") ) { run=inValue.Cast< ::Dynamic >(); return inValue; } break; case 5: if (HX_FIELD_EQ(inName,"mTime") ) { mTime=inValue.Cast< Float >(); return inValue; } break; case 7: if (HX_FIELD_EQ(inName,"mFireAt") ) { mFireAt=inValue.Cast< Float >(); return inValue; } break; case 8: if (HX_FIELD_EQ(inName,"mRunning") ) { mRunning=inValue.Cast< Bool >(); return inValue; } } return super::__SetField(inName,inValue,inCallProp); } bool Timer_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 14: if (HX_FIELD_EQ(inName,"sRunningTimers") ) { sRunningTimers=ioValue.Cast< ::Array< ::Dynamic> >(); return true; } break; case 15: if (HX_FIELD_EQ(inName,"lime_time_stamp") ) { lime_time_stamp=ioValue.Cast< ::Dynamic >(); return true; } } return false; } void Timer_obj::__GetFields(Array< ::String> &outFields) { outFields->push(HX_HCSTRING("mTime","\x1a","\x33","\x83","\xfa")); outFields->push(HX_HCSTRING("mFireAt","\x96","\xea","\x58","\x72")); outFields->push(HX_HCSTRING("mRunning","\x12","\x2d","\x35","\x13")); super::__GetFields(outFields); }; #if HXCPP_SCRIPTABLE static hx::StorageInfo Timer_obj_sMemberStorageInfo[] = { {hx::fsFloat,(int)offsetof(Timer_obj,mTime),HX_HCSTRING("mTime","\x1a","\x33","\x83","\xfa")}, {hx::fsFloat,(int)offsetof(Timer_obj,mFireAt),HX_HCSTRING("mFireAt","\x96","\xea","\x58","\x72")}, {hx::fsBool,(int)offsetof(Timer_obj,mRunning),HX_HCSTRING("mRunning","\x12","\x2d","\x35","\x13")}, {hx::fsObject ,(int)offsetof(Timer_obj,run),HX_HCSTRING("run","\x4b","\xe7","\x56","\x00")}, { hx::fsUnknown, 0, null()} }; static hx::StaticInfo Timer_obj_sStaticStorageInfo[] = { {hx::fsObject ,(void *) &Timer_obj::sRunningTimers,HX_HCSTRING("sRunningTimers","\xfa","\xbb","\xcd","\xfe")}, {hx::fsObject ,(void *) &Timer_obj::lime_time_stamp,HX_HCSTRING("lime_time_stamp","\x3b","\x9f","\x6b","\x12")}, { hx::fsUnknown, 0, null()} }; #endif static ::String Timer_obj_sMemberFields[] = { HX_HCSTRING("mTime","\x1a","\x33","\x83","\xfa"), HX_HCSTRING("mFireAt","\x96","\xea","\x58","\x72"), HX_HCSTRING("mRunning","\x12","\x2d","\x35","\x13"), HX_HCSTRING("run","\x4b","\xe7","\x56","\x00"), HX_HCSTRING("stop","\x02","\xf0","\x5b","\x4c"), HX_HCSTRING("__check","\xa8","\xf1","\x14","\xb0"), ::String(null()) }; static void Timer_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(Timer_obj::__mClass,"__mClass"); HX_MARK_MEMBER_NAME(Timer_obj::sRunningTimers,"sRunningTimers"); HX_MARK_MEMBER_NAME(Timer_obj::lime_time_stamp,"lime_time_stamp"); }; #ifdef HXCPP_VISIT_ALLOCS static void Timer_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(Timer_obj::__mClass,"__mClass"); HX_VISIT_MEMBER_NAME(Timer_obj::sRunningTimers,"sRunningTimers"); HX_VISIT_MEMBER_NAME(Timer_obj::lime_time_stamp,"lime_time_stamp"); }; #endif hx::Class Timer_obj::__mClass; static ::String Timer_obj_sStaticFields[] = { HX_HCSTRING("sRunningTimers","\xfa","\xbb","\xcd","\xfe"), HX_HCSTRING("delay","\x83","\xd7","\x26","\xd7"), HX_HCSTRING("getMS","\x7c","\x95","\x60","\x91"), HX_HCSTRING("measure","\x5e","\xfb","\xe9","\x3c"), HX_HCSTRING("stamp","\x03","\x70","\x0b","\x84"), HX_HCSTRING("__checkTimers","\xd6","\x20","\x5c","\x49"), HX_HCSTRING("__nextWake","\xd7","\x75","\xf7","\x9d"), HX_HCSTRING("lime_time_stamp","\x3b","\x9f","\x6b","\x12"), ::String(null()) }; void Timer_obj::__register() { hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("haxe.Timer","\x5d","\x9d","\x24","\x4b"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &Timer_obj::__GetStatic; __mClass->mSetStaticField = &Timer_obj::__SetStatic; __mClass->mMarkFunc = Timer_obj_sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(Timer_obj_sStaticFields); __mClass->mMembers = hx::Class_obj::dupFunctions(Timer_obj_sMemberFields); __mClass->mCanCast = hx::TCanCast< Timer_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = Timer_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = Timer_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = Timer_obj_sStaticStorageInfo; #endif hx::_hx_RegisterClass(__mClass->mName, __mClass); } void Timer_obj::__boot() { { HX_STACK_FRAME("haxe.Timer","boot",0xc6bd04e3,"haxe.Timer.boot","haxe/Timer.hx",203,0x1a690682) HXLINE( 203) sRunningTimers = ::Array_obj< ::Dynamic>::__new(0); } { HX_STACK_FRAME("haxe.Timer","boot",0xc6bd04e3,"haxe.Timer.boot","haxe/Timer.hx",379,0x1a690682) HXLINE( 379) lime_time_stamp = ::openfl::_legacy::Lib_obj::load(HX_("lime-legacy",c1,7f,b9,87),HX_("lime_legacy_time_stamp",9d,85,d0,ec),(int)0); } } }
#include <hxcpp.h> #ifndef INCLUDED_haxe_Log #include <haxe/Log.h> #endif #ifndef INCLUDED_haxe_Timer #include <haxe/Timer.h> #endif #ifndef INCLUDED_openfl__legacy_Lib #include <openfl/_legacy/Lib.h> #endif namespace haxe{ void Timer_obj::__construct(Float time){ HX_STACK_FRAME("haxe.Timer","new",0x4136b0cf,"haxe.Timer.new","haxe/Timer.hx",210,0x1a690682) HX_STACK_THIS(this) HX_STACK_ARG(time,"time") HXLINE( 212) this->mTime = time; HXLINE( 213) ::haxe::Timer_obj::sRunningTimers->push(hx::ObjectPtr<OBJ_>(this)); HXLINE( 214) Float _hx_tmp = ::haxe::Timer_obj::getMS(); HXDLIN( 214) this->mFireAt = (_hx_tmp + this->mTime); HXLINE( 215) this->mRunning = true; } Dynamic Timer_obj::__CreateEmpty() { return new Timer_obj; } hx::ObjectPtr< Timer_obj > Timer_obj::__new(Float time) { hx::ObjectPtr< Timer_obj > _hx_result = new Timer_obj(); _hx_result->__construct(time); return _hx_result; } Dynamic Timer_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< Timer_obj > _hx_result = new Timer_obj(); _hx_result->__construct(inArgs[0]); return _hx_result; } HX_BEGIN_DEFAULT_FUNC(__default_run,Timer_obj) void _hx_run(){ HX_STACK_FRAME("haxe.Timer","__default_run",0xdc2b9b9c,"haxe.Timer.__default_run","haxe/Timer.hx",257,0x1a690682) HX_STACK_THIS(this) } HX_END_LOCAL_FUNC0((void)) HX_END_DEFAULT_FUNC void Timer_obj::stop(){ HX_STACK_FRAME("haxe.Timer","stop",0xd1fd70b3,"haxe.Timer.stop","haxe/Timer.hx",277,0x1a690682) HX_STACK_THIS(this) HXLINE( 277) Bool _hx_tmp = this->mRunning; HXDLIN( 277) if (_hx_tmp) { HXLINE( 279) this->mRunning = false; HXLINE( 281) { HXLINE( 281) HX_VARI( Int,_g1) = (int)0; HXDLIN( 281) HX_VARI( Int,_g) = ::haxe::Timer_obj::sRunningTimers->length; HXDLIN( 281) while((_g1 < _g)){ HXLINE( 281) HX_VARI( Int,i) = _g1++; HXLINE( 283) Bool _hx_tmp1 = hx::IsEq( ::haxe::Timer_obj::sRunningTimers->__get(i).StaticCast< ::haxe::Timer >(),hx::ObjectPtr<OBJ_>(this) ); HXDLIN( 283) if (_hx_tmp1) { HXLINE( 285) ::haxe::Timer_obj::sRunningTimers[i] = null(); HXLINE( 286) goto _hx_goto_0; } } _hx_goto_0:; } } } HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,stop,(void)) void Timer_obj::_hx___check(Float inTime){ HX_STACK_FRAME("haxe.Timer","__check",0xb5623597,"haxe.Timer.__check","haxe/Timer.hx",299,0x1a690682) HX_STACK_THIS(this) HX_STACK_ARG(inTime,"inTime") HXLINE( 299) Bool _hx_tmp = (inTime >= this->mFireAt); HXDLIN( 299) if (_hx_tmp) { HXLINE( 301) hx::AddEq(this->mFireAt,this->mTime); HXLINE( 302) this->run(); } } HX_DEFINE_DYNAMIC_FUNC1(Timer_obj,_hx___check,(void)) ::Array< ::Dynamic> Timer_obj::sRunningTimers; ::haxe::Timer Timer_obj::delay( ::Dynamic f,Int time){ HX_BEGIN_LOCAL_FUNC_S2(hx::LocalFunc,_hx_Closure_0, ::Dynamic,f, ::haxe::Timer,t) HXARGC(0) void _hx_run(){ HX_STACK_FRAME("haxe.Timer","delay",0x3ed5f1b2,"haxe.Timer.delay","haxe/Timer.hx",224,0x1a690682) HXLINE( 226) t->stop(); HXLINE( 227) f(); } HX_END_LOCAL_FUNC0((void)) HX_STACK_FRAME("haxe.Timer","delay",0x3ed5f1b2,"haxe.Timer.delay","haxe/Timer.hx",220,0x1a690682) HX_STACK_ARG(f,"f") HX_STACK_ARG(time,"time") HXLINE( 222) HX_VARI( ::haxe::Timer,t) = ::haxe::Timer_obj::__new(time); HXLINE( 224) t->run = ::Dynamic(new _hx_Closure_0(f,t)); HXLINE( 231) return t; } STATIC_HX_DEFINE_DYNAMIC_FUNC2(Timer_obj,delay,return ) Float Timer_obj::getMS(){ HX_STACK_FRAME("haxe.Timer","getMS",0xf90fafab,"haxe.Timer.getMS","haxe/Timer.hx",239,0x1a690682) HXLINE( 239) Float _hx_tmp = ( (Float)(::haxe::Timer_obj::lime_time_stamp()) ); HXDLIN( 239) return (_hx_tmp * ((Float)1000.0)); } STATIC_HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,getMS,return ) ::Dynamic Timer_obj::measure( ::Dynamic f, ::Dynamic pos){ HX_STACK_FRAME("haxe.Timer","measure",0x42373f4d,"haxe.Timer.measure","haxe/Timer.hx",247,0x1a690682) HX_STACK_ARG(f,"f") HX_STACK_ARG(pos,"pos") HXLINE( 249) HX_VARI( Float,t0) = ::haxe::Timer_obj::stamp(); HXLINE( 250) HX_VARI( ::Dynamic,r) = f(); HXLINE( 251) Float _hx_tmp = ::haxe::Timer_obj::stamp(); HXDLIN( 251) ::haxe::Log_obj::trace(((_hx_tmp - t0) + HX_("s",73,00,00,00)),pos); HXLINE( 252) return r; } STATIC_HX_DEFINE_DYNAMIC_FUNC2(Timer_obj,measure,return ) Float Timer_obj::stamp(){ HX_STACK_FRAME("haxe.Timer","stamp",0xebba8a32,"haxe.Timer.stamp","haxe/Timer.hx",267,0x1a690682) HXLINE( 267) return ( (Float)(::haxe::Timer_obj::lime_time_stamp()) ); } STATIC_HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,stamp,return ) void Timer_obj::_hx___checkTimers(){ HX_STACK_FRAME("haxe.Timer","__checkTimers",0xb7078205,"haxe.Timer.__checkTimers","haxe/Timer.hx",309,0x1a690682) HXLINE( 311) HX_VARI( Float,now) = ::haxe::Timer_obj::getMS(); HXLINE( 312) HX_VARI( Bool,foundNull) = false; HXLINE( 313) HX_VAR( ::haxe::Timer,timer); HXLINE( 315) { HXLINE( 315) HX_VARI( Int,_g1) = (int)0; HXDLIN( 315) HX_VARI( Int,_g) = ::haxe::Timer_obj::sRunningTimers->length; HXDLIN( 315) while((_g1 < _g)){ HXLINE( 315) HX_VARI( Int,i) = _g1++; HXLINE( 317) timer = ::haxe::Timer_obj::sRunningTimers->__get(i).StaticCast< ::haxe::Timer >(); HXLINE( 319) Bool _hx_tmp = hx::IsNotNull( timer ); HXDLIN( 319) if (_hx_tmp) { HXLINE( 321) timer->_hx___check(now); } HXLINE( 325) Bool _hx_tmp1 = !(foundNull); HXDLIN( 325) if (_hx_tmp1) { HXLINE( 325) foundNull = hx::IsNull( ::haxe::Timer_obj::sRunningTimers->__get(i).StaticCast< ::haxe::Timer >() ); } else { HXLINE( 325) foundNull = true; } } } HXLINE( 329) if (foundNull) { HX_BEGIN_LOCAL_FUNC_S0(hx::LocalFunc,_hx_Closure_0) HXARGC(1) Bool _hx_run( ::haxe::Timer val){ HX_STACK_FRAME("haxe.Timer","__checkTimers",0xb7078205,"haxe.Timer.__checkTimers","haxe/Timer.hx",331,0x1a690682) HX_STACK_ARG(val,"val") HXLINE( 331) return hx::IsNotNull( val ); } HX_END_LOCAL_FUNC1(return) HXLINE( 331) ::haxe::Timer_obj::sRunningTimers = ::haxe::Timer_obj::sRunningTimers->filter( ::Dynamic(new _hx_Closure_0())); } }
::Dynamic Timer_obj::lime_time_stamp; Timer_obj::Timer_obj() { run = new __default_run(this); } void Timer_obj::__Mark(HX_MARK_PARAMS) { HX_MARK_BEGIN_CLASS(Timer); HX_MARK_MEMBER_NAME(mTime,"mTime"); HX_MARK_MEMBER_NAME(mFireAt,"mFireAt"); HX_MARK_MEMBER_NAME(mRunning,"mRunning"); HX_MARK_MEMBER_NAME(run,"run"); HX_MARK_END_CLASS(); } void Timer_obj::__Visit(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(mTime,"mTime"); HX_VISIT_MEMBER_NAME(mFireAt,"mFireAt"); HX_VISIT_MEMBER_NAME(mRunning,"mRunning"); HX_VISIT_MEMBER_NAME(run,"run"); } hx::Val Timer_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp) { switch(inName.length) { case 3: if (HX_FIELD_EQ(inName,"run") ) { return hx::Val( run); } break; case 4: if (HX_FIELD_EQ(inName,"stop") ) { return hx::Val( stop_dyn()); } break; case 5: if (HX_FIELD_EQ(inName,"mTime") ) { return hx::Val( mTime); } break; case 7: if (HX_FIELD_EQ(inName,"mFireAt") ) { return hx::Val( mFireAt); } if (HX_FIELD_EQ(inName,"__check") ) { return hx::Val( _hx___check_dyn()); } break; case 8: if (HX_FIELD_EQ(inName,"mRunning") ) { return hx::Val( mRunning); } } return super::__Field(inName,inCallProp); } bool Timer_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp) { switch(inName.length) { case 5: if (HX_FIELD_EQ(inName,"delay") ) { outValue = delay_dyn(); return true; } if (HX_FIELD_EQ(inName,"getMS") ) { outValue = getMS_dyn(); return true; } if (HX_FIELD_EQ(inName,"stamp") ) { outValue = stamp_dyn(); return true; } break; case 7: if (HX_FIELD_EQ(inName,"measure") ) { outValue = measure_dyn(); return true; } break; case 10: if (HX_FIELD_EQ(inName,"__nextWake") ) { outValue = _hx___nextWake_dyn(); return true; } break; case 13: if (HX_FIELD_EQ(inName,"__checkTimers") ) { outValue = _hx___checkTimers_dyn(); return true; } break; case 14: if (HX_FIELD_EQ(inName,"sRunningTimers") ) { outValue = sRunningTimers; return true; } break; case 15: if (HX_FIELD_EQ(inName,"lime_time_stamp") ) { outValue = lime_time_stamp; return true; } } return false; } hx::Val Timer_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 3: if (HX_FIELD_EQ(inName,"run") ) { run=inValue.Cast< ::Dynamic >(); return inValue; } break; case 5: if (HX_FIELD_EQ(inName,"mTime") ) { mTime=inValue.Cast< Float >(); return inValue; } break; case 7: if (HX_FIELD_EQ(inName,"mFireAt") ) { mFireAt=inValue.Cast< Float >(); return inValue; } break; case 8: if (HX_FIELD_EQ(inName,"mRunning") ) { mRunning=inValue.Cast< Bool >(); return inValue; } } return super::__SetField(inName,inValue,inCallProp); } bool Timer_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 14: if (HX_FIELD_EQ(inName,"sRunningTimers") ) { sRunningTimers=ioValue.Cast< ::Array< ::Dynamic> >(); return true; } break; case 15: if (HX_FIELD_EQ(inName,"lime_time_stamp") ) { lime_time_stamp=ioValue.Cast< ::Dynamic >(); return true; } } return false; } void Timer_obj::__GetFields(Array< ::String> &outFields) { outFields->push(HX_HCSTRING("mTime","\x1a","\x33","\x83","\xfa")); outFields->push(HX_HCSTRING("mFireAt","\x96","\xea","\x58","\x72")); outFields->push(HX_HCSTRING("mRunning","\x12","\x2d","\x35","\x13")); super::__GetFields(outFields); }; #if HXCPP_SCRIPTABLE static hx::StorageInfo Timer_obj_sMemberStorageInfo[] = { {hx::fsFloat,(int)offsetof(Timer_obj,mTime),HX_HCSTRING("mTime","\x1a","\x33","\x83","\xfa")}, {hx::fsFloat,(int)offsetof(Timer_obj,mFireAt),HX_HCSTRING("mFireAt","\x96","\xea","\x58","\x72")}, {hx::fsBool,(int)offsetof(Timer_obj,mRunning),HX_HCSTRING("mRunning","\x12","\x2d","\x35","\x13")}, {hx::fsObject ,(int)offsetof(Timer_obj,run),HX_HCSTRING("run","\x4b","\xe7","\x56","\x00")}, { hx::fsUnknown, 0, null()} }; static hx::StaticInfo Timer_obj_sStaticStorageInfo[] = { {hx::fsObject ,(void *) &Timer_obj::sRunningTimers,HX_HCSTRING("sRunningTimers","\xfa","\xbb","\xcd","\xfe")}, {hx::fsObject ,(void *) &Timer_obj::lime_time_stamp,HX_HCSTRING("lime_time_stamp","\x3b","\x9f","\x6b","\x12")}, { hx::fsUnknown, 0, null()} }; #endif static ::String Timer_obj_sMemberFields[] = { HX_HCSTRING("mTime","\x1a","\x33","\x83","\xfa"), HX_HCSTRING("mFireAt","\x96","\xea","\x58","\x72"), HX_HCSTRING("mRunning","\x12","\x2d","\x35","\x13"), HX_HCSTRING("run","\x4b","\xe7","\x56","\x00"), HX_HCSTRING("stop","\x02","\xf0","\x5b","\x4c"), HX_HCSTRING("__check","\xa8","\xf1","\x14","\xb0"), ::String(null()) }; static void Timer_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(Timer_obj::__mClass,"__mClass"); HX_MARK_MEMBER_NAME(Timer_obj::sRunningTimers,"sRunningTimers"); HX_MARK_MEMBER_NAME(Timer_obj::lime_time_stamp,"lime_time_stamp"); }; #ifdef HXCPP_VISIT_ALLOCS static void Timer_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(Timer_obj::__mClass,"__mClass"); HX_VISIT_MEMBER_NAME(Timer_obj::sRunningTimers,"sRunningTimers"); HX_VISIT_MEMBER_NAME(Timer_obj::lime_time_stamp,"lime_time_stamp"); }; #endif hx::Class Timer_obj::__mClass; static ::String Timer_obj_sStaticFields[] = { HX_HCSTRING("sRunningTimers","\xfa","\xbb","\xcd","\xfe"), HX_HCSTRING("delay","\x83","\xd7","\x26","\xd7"), HX_HCSTRING("getMS","\x7c","\x95","\x60","\x91"), HX_HCSTRING("measure","\x5e","\xfb","\xe9","\x3c"), HX_HCSTRING("stamp","\x03","\x70","\x0b","\x84"), HX_HCSTRING("__checkTimers","\xd6","\x20","\x5c","\x49"), HX_HCSTRING("__nextWake","\xd7","\x75","\xf7","\x9d"), HX_HCSTRING("lime_time_stamp","\x3b","\x9f","\x6b","\x12"), ::String(null()) }; void Timer_obj::__register() { hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("haxe.Timer","\x5d","\x9d","\x24","\x4b"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &Timer_obj::__GetStatic; __mClass->mSetStaticField = &Timer_obj::__SetStatic; __mClass->mMarkFunc = Timer_obj_sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(Timer_obj_sStaticFields); __mClass->mMembers = hx::Class_obj::dupFunctions(Timer_obj_sMemberFields); __mClass->mCanCast = hx::TCanCast< Timer_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = Timer_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = Timer_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = Timer_obj_sStaticStorageInfo; #endif hx::_hx_RegisterClass(__mClass->mName, __mClass); } void Timer_obj::__boot() { { HX_STACK_FRAME("haxe.Timer","boot",0xc6bd04e3,"haxe.Timer.boot","haxe/Timer.hx",203,0x1a690682) HXLINE( 203) sRunningTimers = ::Array_obj< ::Dynamic>::__new(0); } { HX_STACK_FRAME("haxe.Timer","boot",0xc6bd04e3,"haxe.Timer.boot","haxe/Timer.hx",379,0x1a690682) HXLINE( 379) lime_time_stamp = ::openfl::_legacy::Lib_obj::load(HX_("lime-legacy",c1,7f,b9,87),HX_("lime_legacy_time_stamp",9d,85,d0,ec),(int)0); } } }
STATIC_HX_DEFINE_DYNAMIC_FUNC0(Timer_obj,_hx___checkTimers,(void)) Float Timer_obj::_hx___nextWake(Float limit){ HX_STACK_FRAME("haxe.Timer","__nextWake",0x0e101148,"haxe.Timer.__nextWake","haxe/Timer.hx",339,0x1a690682) HX_STACK_ARG(limit,"limit") HXLINE( 341) HX_VARI( Float,now) = ::haxe::Timer_obj::getMS(); HXLINE( 342) HX_VAR( Float,sleep); HXLINE( 344) { HXLINE( 344) HX_VARI( Int,_g) = (int)0; HXDLIN( 344) HX_VARI( ::Array< ::Dynamic>,_g1) = ::haxe::Timer_obj::sRunningTimers; HXDLIN( 344) while((_g < _g1->length)){ HXLINE( 344) HX_VARI( ::haxe::Timer,timer) = _g1->__get(_g).StaticCast< ::haxe::Timer >(); HXDLIN( 344) ++_g; HXLINE( 346) Bool _hx_tmp = hx::IsNull( timer ); HXDLIN( 346) if (_hx_tmp) { HXLINE( 347) continue; } HXLINE( 349) sleep = (timer->mFireAt - now); HXLINE( 351) Bool _hx_tmp1 = (sleep < limit); HXDLIN( 351) if (_hx_tmp1) { HXLINE( 353) limit = sleep; HXLINE( 355) if ((sleep < (int)0)) { HXLINE( 357) return (int)0; } } } } HXLINE( 365) return (limit * ((Float)0.001)); } STATIC_HX_DEFINE_DYNAMIC_FUNC1(Timer_obj,_hx___nextWake,return )
call_expression
[ { "content": "class HXCPP_CLASS_ATTRIBUTES Timer_obj : public hx::Object\n\n{\n\n\tpublic:\n\n\t\ttypedef hx::Object super;\n\n\t\ttypedef Timer_obj OBJ_;\n\n\t\tTimer_obj();\n\n\n\n\tpublic:\n\n\t\tvoid __construct(Float time);\n\n\t\tinline void *operator new(size_t inSize, bool inContainer=true,const char *inName=\"haxe.Timer\")\n\n\t\t\t{ return hx::Object::operator new(inSize,inContainer,inName); }\n\n\t\tinline void *operator new(size_t inSize, int extra)\n\n\t\t\t{ return hx::Object::operator new(inSize+extra,true,\"haxe.Timer\"); }\n\n\t\tstatic hx::ObjectPtr< Timer_obj > __new(Float time);\n\n\t\tstatic Dynamic __CreateEmpty();\n\n\t\tstatic Dynamic __Create(hx::DynamicArray inArgs);\n\n\t\t//~Timer_obj();\n\n\n\n\t\tHX_DO_RTTI_ALL;\n\n\t\thx::Val __Field(const ::String &inString, hx::PropertyAccess inCallProp);\n", "file_path": "export/windows/cpp/obj/include/haxe/Timer.h", "rank": 0, "score": 195030.109864606 }, { "content": "\t\tstatic Float stamp();\n\n\t\tstatic ::Dynamic stamp_dyn();\n\n\n\n\t\tstatic void _hx___checkTimers();\n\n\t\tstatic ::Dynamic _hx___checkTimers_dyn();\n\n\n\n\t\tstatic Float _hx___nextWake(Float limit);\n\n\t\tstatic ::Dynamic _hx___nextWake_dyn();\n\n\n\n\t\tstatic ::Dynamic lime_time_stamp;\n\n\t\tstatic ::Dynamic &lime_time_stamp_dyn() { return lime_time_stamp;}\n\n\t\tFloat mTime;\n\n\t\tFloat mFireAt;\n\n\t\tBool mRunning;\n\n\t\t::Dynamic run;\n\n\t\tinline ::Dynamic &run_dyn() {return run; }\n\n\n\n\t\tvoid stop();\n\n\t\t::Dynamic stop_dyn();\n\n\n\n\t\tvoid _hx___check(Float inTime);\n\n\t\t::Dynamic _hx___check_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n\n\n#endif /* INCLUDED_haxe_Timer */ \n", "file_path": "export/windows/cpp/obj/include/haxe/Timer.h", "rank": 1, "score": 182495.56334394234 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Timer\",\"\\xa5\",\"\\x2f\",\"\\x63\",\"\\xa3\"); }\n\n\n\n\t\tstatic void __boot();\n\n\t\tstatic ::Array< ::Dynamic> sRunningTimers;\n\n\t\tstatic ::haxe::Timer delay( ::Dynamic f,Int time);\n\n\t\tstatic ::Dynamic delay_dyn();\n\n\n\n\t\tstatic Float getMS();\n\n\t\tstatic ::Dynamic getMS_dyn();\n\n\n\n\t\tstatic ::Dynamic measure( ::Dynamic f, ::Dynamic pos);\n\n\t\tstatic ::Dynamic measure_dyn();\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/Timer.h", "rank": 2, "score": 182488.76642533243 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_Timer\n\n#define INCLUDED_haxe_Timer\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS1(haxe,Timer)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/Timer.h", "rank": 3, "score": 182469.25554587154 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"NullResolver\",\"\\xcd\",\"\\x81\",\"\\x9f\",\"\\xf1\"); }\n\n\n\n\t\tstatic ::haxe::_Unserializer::NullResolver instance;\n\n\t\thx::Class resolveClass(::String name);\n\n\t\t::Dynamic resolveClass_dyn();\n\n\n\n\t\thx::Class resolveEnum(::String name);\n\n\t\t::Dynamic resolveEnum_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace _Unserializer\n\n\n\n#endif /* INCLUDED_haxe__Unserializer_NullResolver */ \n", "file_path": "export/windows/cpp/obj/include/haxe/_Unserializer/NullResolver.h", "rank": 4, "score": 175619.2902763549 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe__Unserializer_NullResolver\n\n#define INCLUDED_haxe__Unserializer_NullResolver\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,_Unserializer,NullResolver)\n\n\n\nnamespace haxe{\n\nnamespace _Unserializer{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/_Unserializer/NullResolver.h", "rank": 5, "score": 175608.17102341115 }, { "content": "class HXCPP_CLASS_ATTRIBUTES NullResolver_obj : public hx::Object\n\n{\n\n\tpublic:\n\n\t\ttypedef hx::Object super;\n\n\t\ttypedef NullResolver_obj OBJ_;\n\n\t\tNullResolver_obj();\n\n\n\n\tpublic:\n\n\t\tvoid __construct();\n\n\t\tinline void *operator new(size_t inSize, bool inContainer=false,const char *inName=\"haxe._Unserializer.NullResolver\")\n\n\t\t\t{ return hx::Object::operator new(inSize,inContainer,inName); }\n\n\t\tinline void *operator new(size_t inSize, int extra)\n\n\t\t\t{ return hx::Object::operator new(inSize+extra,false,\"haxe._Unserializer.NullResolver\"); }\n\n\t\tstatic hx::ObjectPtr< NullResolver_obj > __new();\n\n\t\tstatic Dynamic __CreateEmpty();\n\n\t\tstatic Dynamic __Create(hx::DynamicArray inArgs);\n\n\t\t//~NullResolver_obj();\n\n\n\n\t\tHX_DO_RTTI_ALL;\n\n\t\thx::Val __Field(const ::String &inString, hx::PropertyAccess inCallProp);\n", "file_path": "export/windows/cpp/obj/include/haxe/_Unserializer/NullResolver.h", "rank": 6, "score": 165414.484600914 }, { "content": "class HXCPP_CLASS_ATTRIBUTES ByteArray_obj : public ::haxe::io::Bytes_obj\n\n{\n\n\tpublic:\n\n\t\ttypedef ::haxe::io::Bytes_obj super;\n\n\t\ttypedef ByteArray_obj OBJ_;\n\n\t\tByteArray_obj();\n\n\n\n\tpublic:\n\n\t\tvoid __construct(hx::Null< Int > __o_size);\n\n\t\tinline void *operator new(size_t inSize, bool inContainer=true,const char *inName=\"openfl._legacy.utils.ByteArray\")\n\n\t\t\t{ return hx::Object::operator new(inSize,inContainer,inName); }\n\n\t\tinline void *operator new(size_t inSize, int extra)\n\n\t\t\t{ return hx::Object::operator new(inSize+extra,true,\"openfl._legacy.utils.ByteArray\"); }\n\n\t\tstatic hx::ObjectPtr< ByteArray_obj > __new(hx::Null< Int > __o_size);\n\n\t\tstatic Dynamic __CreateEmpty();\n\n\t\tstatic Dynamic __Create(hx::DynamicArray inArgs);\n\n\t\t//~ByteArray_obj();\n\n\n\n\t\tHX_DO_RTTI_ALL;\n\n\t\thx::Val __Field(const ::String &inString, hx::PropertyAccess inCallProp);\n", "file_path": "export/windows/cpp/obj/include/openfl/_legacy/utils/ByteArray.h", "rank": 7, "score": 158703.65765527412 }, { "content": "\t\tInt pos;\n\n\t\tInt length;\n\n\t\t::cpp::VirtualArray cache;\n\n\t\t::Array< ::String > scache;\n\n\t\t ::Dynamic resolver;\n\n\t\tvoid setResolver( ::Dynamic r);\n\n\t\t::Dynamic setResolver_dyn();\n\n\n\n\t\tInt readDigits();\n\n\t\t::Dynamic readDigits_dyn();\n\n\n\n\t\tFloat readFloat();\n\n\t\t::Dynamic readFloat_dyn();\n\n\n\n\t\tvoid unserializeObject( ::Dynamic o);\n\n\t\t::Dynamic unserializeObject_dyn();\n\n\n\n\t\t ::Dynamic unserializeEnum(hx::Class edecl,::String tag);\n\n\t\t::Dynamic unserializeEnum_dyn();\n\n\n\n\t\t ::Dynamic unserialize();\n\n\t\t::Dynamic unserialize_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n\n\n#endif /* INCLUDED_haxe_Unserializer */ \n", "file_path": "export/windows/cpp/obj/include/haxe/Unserializer.h", "rank": 8, "score": 121219.3596996057 }, { "content": "\t\tInt scount;\n\n\t\tBool useCache;\n\n\t\tBool useEnumIndex;\n\n\t\tvirtual ::String toString();\n\n\t\t::Dynamic toString_dyn();\n\n\n\n\t\tvoid serializeString(::String s);\n\n\t\t::Dynamic serializeString_dyn();\n\n\n\n\t\tBool serializeRef( ::Dynamic v);\n\n\t\t::Dynamic serializeRef_dyn();\n\n\n\n\t\tvoid serializeFields( ::Dynamic v);\n\n\t\t::Dynamic serializeFields_dyn();\n\n\n\n\t\tvoid serialize( ::Dynamic v);\n\n\t\t::Dynamic serialize_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n\n\n#endif /* INCLUDED_haxe_Serializer */ \n", "file_path": "export/windows/cpp/obj/include/haxe/Serializer.h", "rank": 9, "score": 121215.17104553738 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Serializer\",\"\\xb2\",\"\\xca\",\"\\xd0\",\"\\x55\"); }\n\n\n\n\t\tstatic void __boot();\n\n\t\tstatic Bool USE_CACHE;\n\n\t\tstatic Bool USE_ENUM_INDEX;\n\n\t\tstatic ::String BASE64;\n\n\t\tstatic ::Array< ::Dynamic> BASE64_CODES;\n\n\t\tstatic ::String run( ::Dynamic v);\n\n\t\tstatic ::Dynamic run_dyn();\n\n\n\n\t\t ::StringBuf buf;\n\n\t\t::cpp::VirtualArray cache;\n\n\t\t ::haxe::ds::StringMap shash;\n", "file_path": "export/windows/cpp/obj/include/haxe/Serializer.h", "rank": 10, "score": 121212.46275034203 }, { "content": "\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Log\",\"\\x64\",\"\\x0c\",\"\\x3a\",\"\\x00\"); }\n\n\n\n\t\tstatic void __boot();\n\n\t\tstatic ::Dynamic trace;\n\n\t\tstatic inline ::Dynamic &trace_dyn() {return trace; }\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n\n\n#endif /* INCLUDED_haxe_Log */ \n", "file_path": "export/windows/cpp/obj/include/haxe/Log.h", "rank": 11, "score": 121212.45252078192 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Unserializer\",\"\\x4b\",\"\\x42\",\"\\x41\",\"\\x93\"); }\n\n\n\n\t\tstatic void __boot();\n\n\t\tstatic ::Dynamic DEFAULT_RESOLVER;\n\n\t\tstatic ::String BASE64;\n\n\t\tstatic ::Array< Int > CODES;\n\n\t\tstatic ::Array< Int > initCodes();\n\n\t\tstatic ::Dynamic initCodes_dyn();\n\n\n\n\t\tstatic ::Dynamic run(::String v);\n\n\t\tstatic ::Dynamic run_dyn();\n\n\n\n\t\t::String buf;\n", "file_path": "export/windows/cpp/obj/include/haxe/Unserializer.h", "rank": 12, "score": 121207.81174627165 }, { "content": "\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Resource\",\"\\xee\",\"\\x18\",\"\\x52\",\"\\xec\"); }\n\n\n\n\t\tstatic ::haxe::io::Bytes getBytes(::String name);\n\n\t\tstatic ::Dynamic getBytes_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n\n\n#endif /* INCLUDED_haxe_Resource */ \n", "file_path": "export/windows/cpp/obj/include/haxe/Resource.h", "rank": 13, "score": 121206.41226342598 }, { "content": "\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Utf8\",\"\\x51\",\"\\x81\",\"\\x87\",\"\\x38\"); }\n\n\n\n\t\tstatic Int charCodeAt(::String s,Int index);\n\n\t\tstatic ::Dynamic charCodeAt_dyn();\n\n\n\n\t\tstatic Int length(::String s);\n\n\t\tstatic ::Dynamic length_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n\n\n#endif /* INCLUDED_haxe_Utf8 */ \n", "file_path": "export/windows/cpp/obj/include/haxe/Utf8.h", "rank": 14, "score": 121206.04367018919 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_Utf8\n\n#define INCLUDED_haxe_Utf8\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS1(haxe,Utf8)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/Utf8.h", "rank": 15, "score": 121198.24502775673 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_Log\n\n#define INCLUDED_haxe_Log\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS1(haxe,Log)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/Log.h", "rank": 16, "score": 121198.24502775673 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_IMap\n\n#define INCLUDED_haxe_IMap\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS1(haxe,IMap)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/IMap.h", "rank": 17, "score": 121198.24502775673 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_Unserializer\n\n#define INCLUDED_haxe_Unserializer\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS1(haxe,Unserializer)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/Unserializer.h", "rank": 18, "score": 121198.24502775673 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_Resource\n\n#define INCLUDED_haxe_Resource\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS1(haxe,Resource)\n\nHX_DECLARE_CLASS2(haxe,io,Bytes)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/Resource.h", "rank": 19, "score": 121197.9549772077 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_Serializer\n\n#define INCLUDED_haxe_Serializer\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS0(StringBuf)\n\nHX_DECLARE_CLASS1(haxe,IMap)\n\nHX_DECLARE_CLASS1(haxe,Serializer)\n\nHX_DECLARE_CLASS2(haxe,ds,StringMap)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/Serializer.h", "rank": 20, "score": 121197.35680160648 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Uncompress\",\"\\x1b\",\"\\x33\",\"\\x34\",\"\\x00\"); }\n\n\n\n\t\tstatic ::haxe::io::Bytes run( ::haxe::io::Bytes src, ::Dynamic bufsize);\n\n\t\tstatic ::Dynamic run_dyn();\n\n\n\n\t\t ::Dynamic s;\n\n\t\t ::Dynamic execute( ::haxe::io::Bytes src,Int srcPos, ::haxe::io::Bytes dst,Int dstPos);\n\n\t\t::Dynamic execute_dyn();\n\n\n\n\t\tvoid setFlushMode(::hx::EnumBase f);\n\n\t\t::Dynamic setFlushMode_dyn();\n\n\n\n\t\tvoid close();\n\n\t\t::Dynamic close_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace zip\n\n\n\n#endif /* INCLUDED_haxe_zip_Uncompress */ \n", "file_path": "export/windows/cpp/obj/include/haxe/zip/Uncompress.h", "rank": 42, "score": 118888.10303614964 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Compress\",\"\\xc2\",\"\\x03\",\"\\x71\",\"\\x5d\"); }\n\n\n\n\t\tstatic ::haxe::io::Bytes run( ::haxe::io::Bytes s,Int level);\n\n\t\tstatic ::Dynamic run_dyn();\n\n\n\n\t\t ::Dynamic s;\n\n\t\t ::Dynamic execute( ::haxe::io::Bytes src,Int srcPos, ::haxe::io::Bytes dst,Int dstPos);\n\n\t\t::Dynamic execute_dyn();\n\n\n\n\t\tvoid setFlushMode(::hx::EnumBase f);\n\n\t\t::Dynamic setFlushMode_dyn();\n\n\n\n\t\tvoid close();\n\n\t\t::Dynamic close_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace zip\n\n\n\n#endif /* INCLUDED_haxe_zip_Compress */ \n", "file_path": "export/windows/cpp/obj/include/haxe/zip/Compress.h", "rank": 43, "score": 118888.05118335148 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Path\",\"\\xc5\",\"\\x11\",\"\\x2b\",\"\\x35\"); }\n\n\n\n\t\tstatic ::String directory(::String path);\n\n\t\tstatic ::Dynamic directory_dyn();\n\n\n\n\t\tstatic ::String addTrailingSlash(::String path);\n\n\t\tstatic ::Dynamic addTrailingSlash_dyn();\n\n\n\n\t\tstatic ::String removeTrailingSlashes(::String path);\n\n\t\tstatic ::Dynamic removeTrailingSlashes_dyn();\n\n\n\n\t\t::String dir;\n\n\t\t::String file;\n\n\t\t::String ext;\n\n\t\tBool backslash;\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace io\n\n\n\n#endif /* INCLUDED_haxe_io_Path */ \n", "file_path": "export/windows/cpp/obj/include/haxe/io/Path.h", "rank": 44, "score": 118887.06529969852 }, { "content": "\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Parser\",\"\\xff\",\"\\x10\",\"\\x1d\",\"\\x22\"); }\n\n\n\n\t\tstatic void __boot();\n\n\t\tstatic ::haxe::ds::StringMap escapes;\n\n\t\tstatic ::Xml parse(::String str,hx::Null< Bool > strict);\n\n\t\tstatic ::Dynamic parse_dyn();\n\n\n\n\t\tstatic Int doParse(::String str,Bool strict,hx::Null< Int > p, ::Xml parent);\n\n\t\tstatic ::Dynamic doParse_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace xml\n\n\n\n#endif /* INCLUDED_haxe_xml_Parser */ \n", "file_path": "export/windows/cpp/obj/include/haxe/xml/Parser.h", "rank": 45, "score": 118886.74685827289 }, { "content": "\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"CallStack\",\"\\xaa\",\"\\xa1\",\"\\x1d\",\"\\xb2\"); }\n\n\n\n\t\tstatic ::Array< ::Dynamic> callStack();\n\n\t\tstatic ::Dynamic callStack_dyn();\n\n\n\n\t\tstatic ::Array< ::Dynamic> exceptionStack();\n\n\t\tstatic ::Dynamic exceptionStack_dyn();\n\n\n\n\t\tstatic ::String toString(::Array< ::Dynamic> stack);\n\n\t\tstatic ::Dynamic toString_dyn();\n\n\n\n\t\tstatic void itemToString( ::StringBuf b,::hx::EnumBase s);\n\n\t\tstatic ::Dynamic itemToString_dyn();\n\n\n\n\t\tstatic ::Array< ::Dynamic> makeStack(::Array< ::String > s);\n\n\t\tstatic ::Dynamic makeStack_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n\n\n#endif /* INCLUDED_haxe_CallStack */ \n", "file_path": "export/windows/cpp/obj/include/haxe/CallStack.h", "rank": 46, "score": 118880.47657007379 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Bytes\",\"\\x4b\",\"\\x78\",\"\\xc5\",\"\\x50\"); }\n\n\n\n\t\tstatic ::haxe::io::Bytes alloc(Int length);\n\n\t\tstatic ::Dynamic alloc_dyn();\n\n\n\n\t\tstatic ::haxe::io::Bytes ofString(::String s);\n\n\t\tstatic ::Dynamic ofString_dyn();\n\n\n\n\t\tstatic ::haxe::io::Bytes ofData(::Array< unsigned char > b);\n\n\t\tstatic ::Dynamic ofData_dyn();\n\n\n\n\t\tInt length;\n\n\t\t::Array< unsigned char > b;\n\n\t\tvoid blit(Int pos, ::haxe::io::Bytes src,Int srcpos,Int len);\n", "file_path": "export/windows/cpp/obj/include/haxe/io/Bytes.h", "rank": 47, "score": 118880.17219875482 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Fast\",\"\\xbc\",\"\\xee\",\"\\x8e\",\"\\x2e\"); }\n\n\n\n\t\t ::Xml x;\n\n\t\t ::haxe::xml::_Fast::NodeAccess node;\n\n\t\t ::haxe::xml::_Fast::NodeListAccess nodes;\n\n\t\t ::haxe::xml::_Fast::AttribAccess att;\n\n\t\t ::haxe::xml::_Fast::HasAttribAccess has;\n\n\t\t ::haxe::xml::_Fast::HasNodeAccess hasNode;\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace xml\n\n\n\n#endif /* INCLUDED_haxe_xml_Fast */ \n", "file_path": "export/windows/cpp/obj/include/haxe/xml/Fast.h", "rank": 48, "score": 118879.50732610619 }, { "content": "\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Input\",\"\\xea\",\"\\x33\",\"\\x4b\",\"\\x51\"); }\n\n\n\n\t\tvirtual Int readByte();\n\n\t\t::Dynamic readByte_dyn();\n\n\n\n\t\tvoid close();\n\n\t\t::Dynamic close_dyn();\n\n\n\n\t\t::String readLine();\n\n\t\t::Dynamic readLine_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace io\n\n\n\n#endif /* INCLUDED_haxe_io_Input */ \n", "file_path": "export/windows/cpp/obj/include/haxe/io/Input.h", "rank": 49, "score": 118876.61940935934 }, { "content": "\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Output\",\"\\x21\",\"\\x83\",\"\\x15\",\"\\x41\"); }\n\n\n\n\t\tvirtual void writeByte(Int c);\n\n\t\t::Dynamic writeByte_dyn();\n\n\n\n\t\tvirtual Int writeBytes( ::haxe::io::Bytes s,Int pos,Int len);\n\n\t\t::Dynamic writeBytes_dyn();\n\n\n\n\t\tvirtual void close();\n\n\t\t::Dynamic close_dyn();\n\n\n\n\t\tvoid write( ::haxe::io::Bytes s);\n\n\t\t::Dynamic write_dyn();\n\n\n\n\t\tvoid writeFullBytes( ::haxe::io::Bytes s,Int pos,Int len);\n\n\t\t::Dynamic writeFullBytes_dyn();\n\n\n\n\t\tvoid writeString(::String s);\n\n\t\t::Dynamic writeString_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace io\n\n\n\n#endif /* INCLUDED_haxe_io_Output */ \n", "file_path": "export/windows/cpp/obj/include/haxe/io/Output.h", "rank": 50, "score": 118876.56995826628 }, { "content": "\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"Eof\",\"\\x9c\",\"\\xbc\",\"\\x34\",\"\\x00\"); }\n\n\n\n\t\tvirtual ::String toString();\n\n\t\t::Dynamic toString_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace io\n\n\n\n#endif /* INCLUDED_haxe_io_Eof */ \n", "file_path": "export/windows/cpp/obj/include/haxe/io/Eof.h", "rank": 51, "score": 118875.43305605448 }, { "content": "\t\t::Dynamic blit_dyn();\n\n\n\n\t\t ::haxe::io::Bytes sub(Int pos,Int len);\n\n\t\t::Dynamic sub_dyn();\n\n\n\n\t\t::String getString(Int pos,Int len);\n\n\t\t::Dynamic getString_dyn();\n\n\n\n\t\tvirtual ::String toString();\n\n\t\t::Dynamic toString_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace io\n\n\n\n#endif /* INCLUDED_haxe_io_Bytes */ \n", "file_path": "export/windows/cpp/obj/include/haxe/io/Bytes.h", "rank": 52, "score": 118871.04176771177 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_lang_Iterator\n\n#define INCLUDED_haxe_lang_Iterator\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,lang,Iterator)\n\n\n\nnamespace haxe{\n\nnamespace lang{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/lang/Iterator.h", "rank": 53, "score": 118866.8296684023 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_io_Input\n\n#define INCLUDED_haxe_io_Input\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Input)\n\n\n\nnamespace haxe{\n\nnamespace io{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/io/Input.h", "rank": 54, "score": 118866.8296684023 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_io_Eof\n\n#define INCLUDED_haxe_io_Eof\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Eof)\n\n\n\nnamespace haxe{\n\nnamespace io{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/io/Eof.h", "rank": 55, "score": 118866.8296684023 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_io_Bytes\n\n#define INCLUDED_haxe_io_Bytes\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Bytes)\n\n\n\nnamespace haxe{\n\nnamespace io{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/io/Bytes.h", "rank": 56, "score": 118866.8296684023 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_io_Path\n\n#define INCLUDED_haxe_io_Path\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Path)\n\n\n\nnamespace haxe{\n\nnamespace io{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/io/Path.h", "rank": 57, "score": 118866.8296684023 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_io_Error\n\n#define INCLUDED_haxe_io_Error\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Error)\n\nnamespace haxe{\n\nnamespace io{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/io/Error.h", "rank": 58, "score": 118866.8296684023 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_io_Output\n\n#define INCLUDED_haxe_io_Output\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Bytes)\n\nHX_DECLARE_CLASS2(haxe,io,Output)\n\n\n\nnamespace haxe{\n\nnamespace io{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/io/Output.h", "rank": 59, "score": 118866.61881549875 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_lang_Iterable\n\n#define INCLUDED_haxe_lang_Iterable\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,lang,Iterable)\n\nHX_DECLARE_CLASS2(haxe,lang,Iterator)\n\n\n\nnamespace haxe{\n\nnamespace lang{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/lang/Iterable.h", "rank": 60, "score": 118866.61881549875 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_zip_Compress\n\n#define INCLUDED_haxe_zip_Compress\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Bytes)\n\nHX_DECLARE_CLASS2(haxe,zip,Compress)\n\nHX_DECLARE_CLASS2(haxe,zip,FlushMode)\n\n\n\nnamespace haxe{\n\nnamespace zip{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/zip/Compress.h", "rank": 61, "score": 118866.3454995754 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_zip_Uncompress\n\n#define INCLUDED_haxe_zip_Uncompress\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Bytes)\n\nHX_DECLARE_CLASS2(haxe,zip,FlushMode)\n\nHX_DECLARE_CLASS2(haxe,zip,Uncompress)\n\n\n\nnamespace haxe{\n\nnamespace zip{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/zip/Uncompress.h", "rank": 62, "score": 118866.3454995754 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_xml_Parser\n\n#define INCLUDED_haxe_xml_Parser\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS0(Xml)\n\nHX_DECLARE_CLASS1(haxe,IMap)\n\nHX_DECLARE_CLASS2(haxe,ds,StringMap)\n\nHX_DECLARE_CLASS2(haxe,xml,Parser)\n\n\n\nnamespace haxe{\n\nnamespace xml{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/xml/Parser.h", "rank": 63, "score": 118866.1847948758 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_StackItem\n\n#define INCLUDED_haxe_StackItem\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS1(haxe,StackItem)\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/StackItem.h", "rank": 64, "score": 118865.68598994333 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_CallStack\n\n#define INCLUDED_haxe_CallStack\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS0(StringBuf)\n\nHX_DECLARE_CLASS1(haxe,CallStack)\n\nHX_DECLARE_CLASS1(haxe,StackItem)\n\n\n\nnamespace haxe{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/CallStack.h", "rank": 65, "score": 118865.08597227944 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_xml_Fast\n\n#define INCLUDED_haxe_xml_Fast\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS0(Xml)\n\nHX_DECLARE_CLASS2(haxe,xml,Fast)\n\nHX_DECLARE_CLASS3(haxe,xml,_Fast,AttribAccess)\n\nHX_DECLARE_CLASS3(haxe,xml,_Fast,HasAttribAccess)\n\nHX_DECLARE_CLASS3(haxe,xml,_Fast,HasNodeAccess)\n\nHX_DECLARE_CLASS3(haxe,xml,_Fast,NodeAccess)\n\nHX_DECLARE_CLASS3(haxe,xml,_Fast,NodeListAccess)\n\n\n\nnamespace haxe{\n\nnamespace xml{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/xml/Fast.h", "rank": 66, "score": 118865.0659216143 }, { "content": "\t\tvoid destroy();\n\n\t\t::Dynamic destroy_dyn();\n\n\n\n\t\t ::flixel::util::FlxTimer start(hx::Null< Float > Time, ::Dynamic OnComplete,hx::Null< Int > Loops);\n\n\t\t::Dynamic start_dyn();\n\n\n\n\t\t ::flixel::util::FlxTimer reset(hx::Null< Float > NewTime);\n\n\t\t::Dynamic reset_dyn();\n\n\n\n\t\tvoid cancel();\n\n\t\t::Dynamic cancel_dyn();\n\n\n\n\t\tvoid update(Float elapsed);\n\n\t\t::Dynamic update_dyn();\n\n\n\n\t\tFloat get_timeLeft();\n\n\t\t::Dynamic get_timeLeft_dyn();\n\n\n\n\t\tFloat get_elapsedTime();\n\n\t\t::Dynamic get_elapsedTime_dyn();\n", "file_path": "export/windows/cpp/obj/include/flixel/util/FlxTimer.h", "rank": 67, "score": 116935.49961141686 }, { "content": "\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n\n\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\tvoid *_hx_getInterface(int inHash);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"FlxTimer\",\"\\x13\",\"\\xca\",\"\\x0f\",\"\\xcd\"); }\n\n\n\n\t\tstatic ::flixel::util::FlxTimerManager manager;\n\n\t\tFloat time;\n\n\t\tInt loops;\n\n\t\tBool active;\n\n\t\tBool finished;\n\n\t\t ::Dynamic onComplete;\n\n\t\t ::Dynamic &onComplete_dyn() { return onComplete;}\n\n\t\tFloat _timeCounter;\n\n\t\tInt _loopsCounter;\n\n\t\tBool _inManager;\n", "file_path": "export/windows/cpp/obj/include/flixel/util/FlxTimer.h", "rank": 68, "score": 116934.29415259432 }, { "content": "\n\n\t\tInt get_loopsLeft();\n\n\t\t::Dynamic get_loopsLeft_dyn();\n\n\n\n\t\tInt get_elapsedLoops();\n\n\t\t::Dynamic get_elapsedLoops_dyn();\n\n\n\n\t\tFloat get_progress();\n\n\t\t::Dynamic get_progress_dyn();\n\n\n\n};\n\n\n\n} // end namespace flixel\n\n} // end namespace util\n\n\n\n#endif /* INCLUDED_flixel_util_FlxTimer */ \n", "file_path": "export/windows/cpp/obj/include/flixel/util/FlxTimer.h", "rank": 69, "score": 116918.31025401094 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_flixel_util_FlxTimer\n\n#define INCLUDED_flixel_util_FlxTimer\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\n#ifndef INCLUDED_flixel_util_IFlxDestroyable\n\n#include <flixel/util/IFlxDestroyable.h>\n\n#endif\n\nHX_DECLARE_CLASS1(flixel,FlxBasic)\n\nHX_DECLARE_CLASS2(flixel,util,FlxTimer)\n\nHX_DECLARE_CLASS2(flixel,util,FlxTimerManager)\n\nHX_DECLARE_CLASS2(flixel,util,IFlxDestroyable)\n\n\n\nnamespace flixel{\n\nnamespace util{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/flixel/util/FlxTimer.h", "rank": 70, "score": 116913.643860138 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"BytesBuffer\",\"\\xab\",\"\\x73\",\"\\x22\",\"\\xf6\"); }\n\n\n\n\t\t::Array< unsigned char > b;\n\n\t\t ::haxe::io::Bytes getBytes();\n\n\t\t::Dynamic getBytes_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace io\n\n\n\n#endif /* INCLUDED_haxe_io_BytesBuffer */ \n", "file_path": "export/windows/cpp/obj/include/haxe/io/BytesBuffer.h", "rank": 71, "score": 116642.09132108769 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"TreeNode\",\"\\xa0\",\"\\x92\",\"\\x83\",\"\\x06\"); }\n\n\n\n\t\t ::haxe::ds::TreeNode left;\n\n\t\t ::haxe::ds::TreeNode right;\n\n\t\t ::Dynamic key;\n\n\t\t ::Dynamic value;\n\n\t\tInt _height;\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace ds\n\n\n\n#endif /* INCLUDED_haxe_ds_TreeNode */ \n", "file_path": "export/windows/cpp/obj/include/haxe/ds/TreeNode.h", "rank": 72, "score": 116641.92662791381 }, { "content": " template<typename F>\n\n inline void set(int key, const ::cpp::Function<F> &value) {__int_hash_set(h,key,value); }\n\n template<typename V>\n\n inline void set(int key, const ::cpp::Pointer<V> &value) {__int_hash_set(h,key,(Dynamic)value ); }\n\n\n\n template<typename VALUE>\n\n inline Void set(Dynamic &key, const VALUE &value) { set( (int)key, value ); return null(); }\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace ds\n\n\n\n#endif /* INCLUDED_haxe_ds_IntMap */ \n", "file_path": "export/windows/cpp/obj/include/haxe/ds/IntMap.h", "rank": 73, "score": 116641.63226838465 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"JsonParser\",\"\\x47\",\"\\x65\",\"\\x2e\",\"\\x25\"); }\n\n\n\n\t\t::String str;\n\n\t\tInt pos;\n\n\t\t ::Dynamic parseRec();\n\n\t\t::Dynamic parseRec_dyn();\n\n\n\n\t\t::String parseString();\n\n\t\t::Dynamic parseString_dyn();\n\n\n\n\t\tvoid invalidChar();\n\n\t\t::Dynamic invalidChar_dyn();\n\n\n\n\t\tvoid invalidNumber(Int start);\n\n\t\t::Dynamic invalidNumber_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace format\n\n\n\n#endif /* INCLUDED_haxe_format_JsonParser */ \n", "file_path": "export/windows/cpp/obj/include/haxe/format/JsonParser.h", "rank": 74, "score": 116640.46240834262 }, { "content": "\n\n template<typename V, typename H>\n\n inline void set(String key, const ::cpp::Struct<V,H> &value) {__string_hash_set(h,key,value); }\n\n template<typename V>\n\n inline void set(String key, const ::cpp::Function<V> &value) {__string_hash_set(h,key,(Dynamic)value ); }\n\n template<typename V>\n\n inline void set(String key, const ::cpp::Pointer<V> &value) {__string_hash_set(h,key,(Dynamic)value ); }\n\n\n\n template<typename VALUE>\n\n inline Void set(Dynamic &key, const VALUE &value) { set( (String)key, value ); return null(); }\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace ds\n\n\n\n#endif /* INCLUDED_haxe_ds_StringMap */ \n", "file_path": "export/windows/cpp/obj/include/haxe/ds/StringMap.h", "rank": 75, "score": 116633.7650152168 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"BalancedTree\",\"\\x66\",\"\\x71\",\"\\xf8\",\"\\xaa\"); }\n\n\n\n\t\t ::haxe::ds::TreeNode root;\n\n\t\tvoid set( ::Dynamic key, ::Dynamic value);\n\n\t\t::Dynamic set_dyn();\n\n\n\n\t\t ::Dynamic get( ::Dynamic key);\n\n\t\t::Dynamic get_dyn();\n\n\n\n\t\t ::haxe::ds::TreeNode setLoop( ::Dynamic k, ::Dynamic v, ::haxe::ds::TreeNode node);\n\n\t\t::Dynamic setLoop_dyn();\n\n\n\n\t\t ::haxe::ds::TreeNode balance( ::haxe::ds::TreeNode l, ::Dynamic k, ::Dynamic v, ::haxe::ds::TreeNode r);\n\n\t\t::Dynamic balance_dyn();\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/BalancedTree.h", "rank": 76, "score": 116631.87241573833 }, { "content": " inline void set(Dynamic key, const ::cpp::Struct<V,H> &value) {__object_hash_set(h,key,value); }\n\n template<typename V>\n\n inline void set(Dynamic key, const ::cpp::Function<V> &value) {__object_hash_set(h,key,(Dynamic)value ); }\n\n template<typename V>\n\n inline void set(Dynamic key, const ::cpp::Pointer<V> &value) {__object_hash_set(h,key,(Dynamic)value ); }\n\n\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace ds\n\n\n\n#endif /* INCLUDED_haxe_ds_ObjectMap */ \n", "file_path": "export/windows/cpp/obj/include/haxe/ds/ObjectMap.h", "rank": 77, "score": 116631.48238696535 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\tvoid *_hx_getInterface(int inHash);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"ObjectMap\",\"\\xfd\",\"\\xa4\",\"\\x50\",\"\\xe5\"); }\n\n\n\n\t\t ::Dynamic h;\n\n\t\tvoid set( ::Dynamic key, ::Dynamic value);\n\n\t\t::Dynamic set_dyn();\n\n\n\n\t\t ::Dynamic get( ::Dynamic key);\n\n\t\t::Dynamic get_dyn();\n\n\n\n\t\tBool exists( ::Dynamic key);\n\n\t\t::Dynamic exists_dyn();\n\n\n\n\t\tBool remove( ::Dynamic key);\n\n\t\t::Dynamic remove_dyn();\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/ObjectMap.h", "rank": 78, "score": 116631.28750386862 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\tvoid *_hx_getInterface(int inHash);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"StringMap\",\"\\x2b\",\"\\x12\",\"\\x8c\",\"\\x69\"); }\n\n\n\n\t\t ::Dynamic h;\n\n\t\tvoid set(::String key, ::Dynamic value);\n\n\t\t::Dynamic set_dyn();\n\n\n\n\t\t ::Dynamic get(::String key);\n\n\t\t::Dynamic get_dyn();\n\n\n\n\t\tBool exists(::String key);\n\n\t\t::Dynamic exists_dyn();\n\n\n\n\t\tBool remove(::String key);\n\n\t\t::Dynamic remove_dyn();\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/StringMap.h", "rank": 79, "score": 116630.9044816804 }, { "content": "\t\thx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp);\n\n\t\tvoid __GetFields(Array< ::String> &outFields);\n\n\t\tstatic void __register();\n\n\t\tvoid __Mark(HX_MARK_PARAMS);\n\n\t\tvoid __Visit(HX_VISIT_PARAMS);\n\n\t\tvoid *_hx_getInterface(int inHash);\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"IntMap\",\"\\x0d\",\"\\xa9\",\"\\x08\",\"\\xd3\"); }\n\n\n\n\t\t ::Dynamic h;\n\n\t\tvoid set(Int key, ::Dynamic value);\n\n\t\t::Dynamic set_dyn();\n\n\n\n\t\t ::Dynamic get(Int key);\n\n\t\t::Dynamic get_dyn();\n\n\n\n\t\tBool exists(Int key);\n\n\t\t::Dynamic exists_dyn();\n\n\n\n\t\tBool remove(Int key);\n\n\t\t::Dynamic remove_dyn();\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/IntMap.h", "rank": 80, "score": 116630.9044816804 }, { "content": "\t\tstatic void __register();\n\n\t\t::String __ToString() const { return HX_HCSTRING(\"DefaultResolver\",\"\\xc7\",\"\\x41\",\"\\x4a\",\"\\x96\"); }\n\n\n\n\t\thx::Class resolveClass(::String name);\n\n\t\t::Dynamic resolveClass_dyn();\n\n\n\n\t\thx::Class resolveEnum(::String name);\n\n\t\t::Dynamic resolveEnum_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace _Unserializer\n\n\n\n#endif /* INCLUDED_haxe__Unserializer_DefaultResolver */ \n", "file_path": "export/windows/cpp/obj/include/haxe/_Unserializer/DefaultResolver.h", "rank": 81, "score": 116630.15393970073 }, { "content": "\t\tvirtual Int compare( ::Dynamic k1, ::Dynamic k2);\n\n\t\t::Dynamic compare_dyn();\n\n\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace ds\n\n\n\n#endif /* INCLUDED_haxe_ds_BalancedTree */ \n", "file_path": "export/windows/cpp/obj/include/haxe/ds/BalancedTree.h", "rank": 82, "score": 116627.9686884337 }, { "content": "\n\n\t\t ::Dynamic keys();\n\n\t\t::Dynamic keys_dyn();\n\n\n\n\n\n inline void set(Dynamic key, ::null value) { __object_hash_set(h,key,value); }\n\n inline void set(Dynamic key, bool value) { __object_hash_set(h,key,value); }\n\n inline void set(Dynamic key, char value) { __object_hash_set_int(h,key,value); }\n\n inline void set(Dynamic key, unsigned char value) { __object_hash_set_int(h,key,value); }\n\n inline void set(Dynamic key, signed char value) { __object_hash_set_int(h,key,value); }\n\n inline void set(Dynamic key, short value) { __object_hash_set_int(h,key,value); }\n\n inline void set(Dynamic key, unsigned short value) { __object_hash_set_int(h,key,value); }\n\n inline void set(Dynamic key, int value) { __object_hash_set_int(h,key,value); }\n\n inline void set(Dynamic key, unsigned int value) { __object_hash_set_int(h,key,value); }\n\n inline void set(Dynamic key, float value) { __object_hash_set_float(h,key,value); }\n\n inline void set(Dynamic key, double value) { __object_hash_set_float(h,key,value); }\n\n inline void set(Dynamic key, ::String value) { __object_hash_set_string(h,key,value); }\n\n\n\n\n\n template<typename V, typename H>\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/ObjectMap.h", "rank": 83, "score": 116626.61163049004 }, { "content": "\n\n\t\t ::Dynamic keys();\n\n\t\t::Dynamic keys_dyn();\n\n\n\n\t\t ::Dynamic iterator();\n\n\t\t::Dynamic iterator_dyn();\n\n\n\n\n\n inline void set(String key, ::null value) { __string_hash_set(h,key,value); }\n\n inline void set(String key, bool value) { __string_hash_set(h,key,value); }\n\n inline void set(String key, char value) { __string_hash_set_int(h,key,value); }\n\n inline void set(String key, unsigned char value) { __string_hash_set_int(h,key,value); }\n\n inline void set(String key, signed char value) { __string_hash_set_int(h,key,value); }\n\n inline void set(String key, short value) { __string_hash_set_int(h,key,value); }\n\n inline void set(String key, unsigned short value) { __string_hash_set_int(h,key,value); }\n\n inline void set(String key, int value) { __string_hash_set_int(h,key,value); }\n\n inline void set(String key, unsigned int value) { __string_hash_set_int(h,key,value); }\n\n inline void set(String key, float value) { __string_hash_set_float(h,key,value); }\n\n inline void set(String key, double value) { __string_hash_set_float(h,key,value); }\n\n inline void set(String key, ::String value) { __string_hash_set_string(h,key,value); }\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/StringMap.h", "rank": 84, "score": 116624.83494133218 }, { "content": "\n\n\t\t ::Dynamic keys();\n\n\t\t::Dynamic keys_dyn();\n\n\n\n\n\n inline void set(int key, ::null value) { __int_hash_set(h,key,value); }\n\n inline void set(int key, bool value) { __int_hash_set(h,key,value); }\n\n inline void set(int key, char value) { __int_hash_set_int(h,key,value); }\n\n inline void set(int key, unsigned char value) { __int_hash_set_int(h,key,value); }\n\n inline void set(int key, signed char value) { __int_hash_set_int(h,key,value); }\n\n inline void set(int key, short value) { __int_hash_set_int(h,key,value); }\n\n inline void set(int key, unsigned short value) { __int_hash_set_int(h,key,value); }\n\n inline void set(int key, int value) { __int_hash_set_int(h,key,value); }\n\n inline void set(int key, unsigned int value) { __int_hash_set_int(h,key,value); }\n\n inline void set(int key, float value) { __int_hash_set_float(h,key,value); }\n\n inline void set(int key, double value) { __int_hash_set_float(h,key,value); }\n\n inline void set(int key, ::String value) { __int_hash_set_string(h,key,value); }\n\n\n\n template<typename V, typename H>\n\n inline void set(int key, const ::cpp::Struct<V,H> &value) {__int_hash_set(h,key,value); }\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/IntMap.h", "rank": 85, "score": 116622.78233468426 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_ds_StringMap\n\n#define INCLUDED_haxe_ds_StringMap\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\n#ifndef INCLUDED_haxe_IMap\n\n#include <haxe/IMap.h>\n\n#endif\n\nHX_DECLARE_CLASS1(haxe,IMap)\n\nHX_DECLARE_CLASS2(haxe,ds,StringMap)\n\n\n\nnamespace haxe{\n\nnamespace ds{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/StringMap.h", "rank": 86, "score": 116622.69194339824 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_ds_IntMap\n\n#define INCLUDED_haxe_ds_IntMap\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\n#ifndef INCLUDED_haxe_IMap\n\n#include <haxe/IMap.h>\n\n#endif\n\nHX_DECLARE_CLASS1(haxe,IMap)\n\nHX_DECLARE_CLASS2(haxe,ds,IntMap)\n\n\n\nnamespace haxe{\n\nnamespace ds{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/IntMap.h", "rank": 87, "score": 116622.69194339824 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_ds_ObjectMap\n\n#define INCLUDED_haxe_ds_ObjectMap\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\n#ifndef INCLUDED_haxe_IMap\n\n#include <haxe/IMap.h>\n\n#endif\n\nHX_DECLARE_CLASS1(haxe,IMap)\n\nHX_DECLARE_CLASS2(haxe,ds,ObjectMap)\n\n\n\nnamespace haxe{\n\nnamespace ds{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/ObjectMap.h", "rank": 88, "score": 116622.69194339824 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_zip_FlushMode\n\n#define INCLUDED_haxe_zip_FlushMode\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,zip,FlushMode)\n\nnamespace haxe{\n\nnamespace zip{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/zip/FlushMode.h", "rank": 89, "score": 116622.39486138537 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_ds_TreeNode\n\n#define INCLUDED_haxe_ds_TreeNode\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,ds,TreeNode)\n\n\n\nnamespace haxe{\n\nnamespace ds{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/TreeNode.h", "rank": 90, "score": 116622.39486138537 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe__Unserializer_DefaultResolver\n\n#define INCLUDED_haxe__Unserializer_DefaultResolver\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,_Unserializer,DefaultResolver)\n\n\n\nnamespace haxe{\n\nnamespace _Unserializer{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/_Unserializer/DefaultResolver.h", "rank": 91, "score": 116622.39486138537 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_format_JsonParser\n\n#define INCLUDED_haxe_format_JsonParser\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,format,JsonParser)\n\n\n\nnamespace haxe{\n\nnamespace format{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/format/JsonParser.h", "rank": 92, "score": 116622.39486138537 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_io_BytesBuffer\n\n#define INCLUDED_haxe_io_BytesBuffer\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,io,Bytes)\n\nHX_DECLARE_CLASS2(haxe,io,BytesBuffer)\n\n\n\nnamespace haxe{\n\nnamespace io{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/io/BytesBuffer.h", "rank": 93, "score": 116622.19575065663 }, { "content": "// Generated by Haxe 3.3.0\n\n#ifndef INCLUDED_haxe_ds_BalancedTree\n\n#define INCLUDED_haxe_ds_BalancedTree\n\n\n\n#ifndef HXCPP_H\n\n#include <hxcpp.h>\n\n#endif\n\n\n\nHX_DECLARE_CLASS2(haxe,ds,BalancedTree)\n\nHX_DECLARE_CLASS2(haxe,ds,TreeNode)\n\n\n\nnamespace haxe{\n\nnamespace ds{\n\n\n\n\n", "file_path": "export/windows/cpp/obj/include/haxe/ds/BalancedTree.h", "rank": 94, "score": 116622.139276171 }, { "content": "\t\tstatic ::haxe::zip::FlushMode NO;\n\n\t\tstatic inline ::haxe::zip::FlushMode NO_dyn() { return NO; }\n\n\t\tstatic ::haxe::zip::FlushMode SYNC;\n\n\t\tstatic inline ::haxe::zip::FlushMode SYNC_dyn() { return SYNC; }\n\n};\n\n\n\n} // end namespace haxe\n\n} // end namespace zip\n\n\n\n#endif /* INCLUDED_haxe_zip_FlushMode */ \n", "file_path": "export/windows/cpp/obj/include/haxe/zip/FlushMode.h", "rank": 95, "score": 116620.22173494939 }, { "content": "// Generated by Haxe 3.3.0\n\n#include <hxcpp.h>\n\n\n\n#ifndef INCLUDED_haxe__Unserializer_NullResolver\n\n#include <haxe/_Unserializer/NullResolver.h>\n\n#endif\n\n\n\nnamespace haxe{\n\nnamespace _Unserializer{\n\n\n\nvoid NullResolver_obj::__construct(){\n\n \tHX_STACK_FRAME(\"haxe._Unserializer.NullResolver\",\"new\",0x49a2304b,\"haxe._Unserializer.NullResolver.new\",\"C:\\\\Haxe\\\\haxe\\\\std/haxe/Unserializer.hx\",477,0x81c40bdb)\n\n \tHX_STACK_THIS(this)\n\n \t}\n\n\n\nDynamic NullResolver_obj::__CreateEmpty() { return new NullResolver_obj; }\n\n\n\nhx::ObjectPtr< NullResolver_obj > NullResolver_obj::__new()\n\n{\n\n\thx::ObjectPtr< NullResolver_obj > _hx_result = new NullResolver_obj();\n", "file_path": "export/windows/cpp/obj/src/haxe/_Unserializer/NullResolver.cpp", "rank": 96, "score": 115504.95586954909 }, { "content": "\t_hx_result->__construct();\n\n\treturn _hx_result;\n\n}\n\n\n\nDynamic NullResolver_obj::__Create(hx::DynamicArray inArgs)\n\n{\n\n\thx::ObjectPtr< NullResolver_obj > _hx_result = new NullResolver_obj();\n\n\t_hx_result->__construct();\n\n\treturn _hx_result;\n\n}\n\n\n\nhx::Class NullResolver_obj::resolveClass(::String name){\n\n \tHX_STACK_FRAME(\"haxe._Unserializer.NullResolver\",\"resolveClass\",0xc4a78861,\"haxe._Unserializer.NullResolver.resolveClass\",\"C:\\\\Haxe\\\\haxe\\\\std/haxe/Unserializer.hx\",478,0x81c40bdb)\n\n \tHX_STACK_THIS(this)\n\n \tHX_STACK_ARG(name,\"name\")\n\nHXLINE( 478)\t\treturn null();\n\n \t}\n\n\n\n\n\nHX_DEFINE_DYNAMIC_FUNC1(NullResolver_obj,resolveClass,return )\n", "file_path": "export/windows/cpp/obj/src/haxe/_Unserializer/NullResolver.cpp", "rank": 97, "score": 115494.52781958974 }, { "content": "\n\nhx::Class NullResolver_obj::resolveEnum(::String name){\n\n \tHX_STACK_FRAME(\"haxe._Unserializer.NullResolver\",\"resolveEnum\",0x5f3252f8,\"haxe._Unserializer.NullResolver.resolveEnum\",\"C:\\\\Haxe\\\\haxe\\\\std/haxe/Unserializer.hx\",479,0x81c40bdb)\n\n \tHX_STACK_THIS(this)\n\n \tHX_STACK_ARG(name,\"name\")\n\nHXLINE( 479)\t\treturn null();\n\n \t}\n\n\n\n\n\nHX_DEFINE_DYNAMIC_FUNC1(NullResolver_obj,resolveEnum,return )\n\n\n\n ::haxe::_Unserializer::NullResolver NullResolver_obj::instance;\n\n\n\n\n\nNullResolver_obj::NullResolver_obj()\n\n{\n\n}\n\n\n\nhx::Val NullResolver_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp)\n\n{\n", "file_path": "export/windows/cpp/obj/src/haxe/_Unserializer/NullResolver.cpp", "rank": 98, "score": 115488.66823247627 }, { "content": "\tswitch(inName.length) {\n\n\tcase 11:\n\n\t\tif (HX_FIELD_EQ(inName,\"resolveEnum\") ) { return hx::Val( resolveEnum_dyn()); }\n\n\t\tbreak;\n\n\tcase 12:\n\n\t\tif (HX_FIELD_EQ(inName,\"resolveClass\") ) { return hx::Val( resolveClass_dyn()); }\n\n\t}\n\n\treturn super::__Field(inName,inCallProp);\n\n}\n\n\n\nbool NullResolver_obj::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp)\n\n{\n\n\tswitch(inName.length) {\n\n\tcase 8:\n\n\t\tif (HX_FIELD_EQ(inName,\"instance\") ) { outValue = instance; return true; }\n\n\t}\n\n\treturn false;\n\n}\n\n\n\nbool NullResolver_obj::__SetStatic(const ::String &inName,Dynamic &ioValue,hx::PropertyAccess inCallProp)\n", "file_path": "export/windows/cpp/obj/src/haxe/_Unserializer/NullResolver.cpp", "rank": 99, "score": 115487.84878105036 } ]
C++
include/external/urdl/istreambuf.hpp
Ptomaine/nstd
72daa4abab97dc82b407c774b00476459df0730b
#ifndef URDL_ISTREAMBUF_HPP #define URDL_ISTREAMBUF_HPP #include <streambuf> #include "detail/config.hpp" #include "option_set.hpp" #include "url.hpp" #include "detail/abi_prefix.hpp" namespace urdl { class istreambuf : public std::streambuf { public: URDL_DECL istreambuf(); URDL_DECL ~istreambuf(); template <typename Option> void set_option(const Option& option) { option_set options; options.set_option(option); set_options(options); } URDL_DECL void set_options(const option_set& options); template <typename Option> Option get_option() const { option_set options(get_options()); return options.get_option<Option>(); } URDL_DECL option_set get_options() const; URDL_DECL bool is_open() const; URDL_DECL istreambuf* open(const url& u); URDL_DECL istreambuf* close(); URDL_DECL const asio::error_code& puberror() const; URDL_DECL std::size_t open_timeout() const; URDL_DECL void open_timeout(std::size_t milliseconds); URDL_DECL std::size_t read_timeout() const; URDL_DECL void read_timeout(std::size_t milliseconds); URDL_DECL std::string content_type() const; URDL_DECL std::size_t content_length() const; URDL_DECL std::string headers() const; protected: URDL_DECL int_type underflow(); URDL_DECL virtual const asio::error_code& error() const; private: URDL_DECL void init_buffers(); struct body; body* body_; }; } #include "detail/abi_suffix.hpp" #if defined(URDL_HEADER_ONLY) # include "impl/istreambuf.ipp" #endif #endif
#ifndef URDL_ISTREAMBUF_HPP #define URDL_ISTREAMBUF_HPP #include <streambuf> #include "detail/config.hpp" #include "option_set.hpp" #include "url.hpp" #include "detail/abi_prefix.hpp" namespace urdl {
fix.hpp" #if defined(URDL_HEADER_ONLY) # include "impl/istreambuf.ipp" #endif #endif
class istreambuf : public std::streambuf { public: URDL_DECL istreambuf(); URDL_DECL ~istreambuf(); template <typename Option> void set_option(const Option& option) { option_set options; options.set_option(option); set_options(options); } URDL_DECL void set_options(const option_set& options); template <typename Option> Option get_option() const { option_set options(get_options()); return options.get_option<Option>(); } URDL_DECL option_set get_options() const; URDL_DECL bool is_open() const; URDL_DECL istreambuf* open(const url& u); URDL_DECL istreambuf* close(); URDL_DECL const asio::error_code& puberror() const; URDL_DECL std::size_t open_timeout() const; URDL_DECL void open_timeout(std::size_t milliseconds); URDL_DECL std::size_t read_timeout() const; URDL_DECL void read_timeout(std::size_t milliseconds); URDL_DECL std::string content_type() const; URDL_DECL std::size_t content_length() const; URDL_DECL std::string headers() const; protected: URDL_DECL int_type underflow(); URDL_DECL virtual const asio::error_code& error() const; private: URDL_DECL void init_buffers(); struct body; body* body_; }; } #include "detail/abi_suf
random
[ { "content": "*/\n\n\n\n#define URDL_HEADER_ONLY\n\n#define URDL_DISABLE_SSL\n\n#define ASIO_STANDALONE\n\n#define ASIO_HAS_STD_CHRONO\n\n\n\n#include \"external/asio/asio/include/asio.hpp\"\n\n#include \"external/urdl/http.hpp\"\n\n#include \"external/urdl/istream.hpp\"\n\n#include \"external/urdl/istreambuf.hpp\"\n\n#include \"external/urdl/option_set.hpp\"\n\n#include \"external/urdl/read_stream.hpp\"\n\n#include \"external/urdl/url.hpp\"\n\n\n\n#include <string>\n\n#include <vector>\n\n\n\nnamespace nstd\n\n{\n", "file_path": "include/urdl.hpp", "rank": 0, "score": 107560.42862580251 }, { "content": " namespace asio = asio;\n\n namespace urdl = urdl;\n\n\n\n template<typename ContainerType = std::string>\n\n std::pair<std::string, ContainerType> download_url(const urdl::url &url)\n\n {\n\n nstd::asio::io_context io_service;\n\n\n\n nstd::urdl::read_stream stream(io_service);\n\n\n\n stream.open(url);\n\n\n\n std::vector<uint8_t> result;\n\n\n\n while (true)\n\n {\n\n char data[1024];\n\n asio::error_code ec;\n\n std::size_t length { stream.read_some(nstd::asio::buffer(data), ec) };\n\n\n", "file_path": "include/urdl.hpp", "rank": 1, "score": 107552.98411664768 }, { "content": "#pragma once\n\n\n\n/*\n\nMIT License\n\nCopyright (c) 2017 Arlen Keshabyan ([email protected])\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\n\nof this software and associated documentation files (the \"Software\"), to deal\n\nin the Software without restriction, including without limitation the rights\n\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\ncopies of the Software, and to permit persons to whom the Software is\n\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\n\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\nSOFTWARE.\n", "file_path": "include/urdl.hpp", "rank": 2, "score": 107546.70770493812 }, { "content": " if (ec == nstd::asio::error::eof) break;\n\n\n\n if (ec) throw std::system_error(ec);\n\n\n\n std::copy(reinterpret_cast<uint8_t*>(data), reinterpret_cast<uint8_t*>(data) + length, std::back_inserter(result));\n\n }\n\n\n\n return std::make_pair(stream.headers(), ContainerType(std::begin(result), std::end(result)));\n\n }\n\n}\n", "file_path": "include/urdl.hpp", "rank": 3, "score": 107541.85615195702 }, { "content": "inline asio::error_code make_error_code(errc_t e)\n\n{\n\n return asio::error_code(\n\n static_cast<int>(e), http::error_category());\n\n}\n\n\n\n} // namespace errc\n\n} // namespace http\n\n} // namespace urdl\n\n\n\n#include \"detail/abi_suffix.hpp\"\n\n\n\n#if defined(URDL_HEADER_ONLY)\n\n# include \"impl/http.ipp\"\n\n#endif\n\n\n\n#endif // URDL_HTTP_HPP\n", "file_path": "include/external/urdl/http.hpp", "rank": 5, "score": 100128.79786663178 }, { "content": " */\n\n std::string headers() const\n\n {\n\n return rdbuf()->headers();\n\n }\n\n};\n\n\n\n} // namespace urdl\n\n\n\n#include \"detail/abi_suffix.hpp\"\n\n\n\n#endif // URDL_ISTREAM_HPP\n", "file_path": "include/external/urdl/istream.hpp", "rank": 6, "score": 100127.91494015093 }, { "content": "//\n\n// http.hpp\n\n// ~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_HTTP_HPP\n\n#define URDL_HTTP_HPP\n\n\n\n#include <string>\n\n#include \"detail/config.hpp\"\n\n#include \"detail/abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\nnamespace http {\n\n\n", "file_path": "include/external/urdl/http.hpp", "rank": 7, "score": 100127.43410486069 }, { "content": "//\n\n// istream.hpp\n\n// ~~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_ISTREAM_HPP\n\n#define URDL_ISTREAM_HPP\n\n\n\n#include <istream>\n\n#include \"utility/base_from_member.hpp\"\n\n#include \"istreambuf.hpp\"\n\n#include \"detail/abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\n\n", "file_path": "include/external/urdl/istream.hpp", "rank": 8, "score": 100126.22592901268 }, { "content": " std::string protocol_;\n\n std::string user_info_;\n\n std::string host_;\n\n std::string port_;\n\n std::string path_;\n\n std::string query_;\n\n std::string fragment_;\n\n bool ipv6_host_;\n\n};\n\n\n\n} // namespace urdl\n\n\n\n#include \"detail/abi_suffix.hpp\"\n\n\n\n#if defined(URDL_HEADER_ONLY)\n\n# include \"impl/url.ipp\"\n\n#endif\n\n\n\n#endif // URDL_URL_HPP\n", "file_path": "include/external/urdl/url.hpp", "rank": 9, "score": 100125.77488055655 }, { "content": "//\n\n// url.hpp\n\n// ~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// path LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_URL_HPP\n\n#define URDL_URL_HPP\n\n\n\n#include <string>\n\n#include \"detail/config.hpp\"\n\n#include \"detail/abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\n\n\n/// The class @c url enables parsing and accessing the components of URLs.\n", "file_path": "include/external/urdl/url.hpp", "rank": 10, "score": 100125.35941379638 }, { "content": " */\n\n void value(const std::string& v)\n\n {\n\n value_ = v;\n\n }\n\n\n\nprivate:\n\n std::string value_;\n\n};\n\n\n\nnamespace errc {\n\n\n\n/// HTTP error codes.\n\n/**\n\n * The enumerators of type @c errc_t are implicitly convertible to objects of\n\n * type @c asio::error_code.\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n", "file_path": "include/external/urdl/http.hpp", "rank": 12, "score": 100122.24155792604 }, { "content": " * is.open(\"http://www.boost.org\");\n\n * @endcode\n\n *\n\n * To set the user agent for an object of class @c urdl::read_stream:\n\n * @code\n\n * urdl::read_stream stream;\n\n * stream.set_option(urdl::http::user_agent(\"Urdl\"));\n\n * stream.open(\"http://www.boost.org\");\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n", "file_path": "include/external/urdl/http.hpp", "rank": 13, "score": 100121.57918954385 }, { "content": " * is.open(\"http://www.boost.org\");\n\n * @endcode\n\n *\n\n * To set the request method for an object of class @c urdl::read_stream:\n\n * @code\n\n * urdl::read_stream stream;\n\n * stream.set_option(urdl::http::request_method(\"HEAD\"));\n\n * stream.open(\"http://www.boost.org\");\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n", "file_path": "include/external/urdl/http.hpp", "rank": 14, "score": 100121.31297238504 }, { "content": " * is.set_option(urdl::http::max_redirects(1));\n\n * is.open(\"http://www.boost.org\");\n\n * @endcode\n\n *\n\n * To set maximum number of redirects for an object of class\n\n * @c urdl::read_stream:\n\n * @code\n\n * urdl::read_stream stream;\n\n * stream.set_option(urdl::http::max_redirects(1));\n\n * stream.open(\"http://www.boost.org\");\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n", "file_path": "include/external/urdl/http.hpp", "rank": 16, "score": 100121.18574841897 }, { "content": "/// Gets the error category for HTTP errors.\n\n/**\n\n * @returns The @c asio::error_category used for HTTP errors.\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n\nURDL_DECL const asio::error_category& error_category();\n\n\n\n/// Option to specify the HTTP request method.\n\n/**\n\n * @par Remarks\n\n * The default request method is \"GET\".\n\n *\n\n * @par Example\n\n * To set the request method for an object of class @c urdl::istream:\n\n * @code\n\n * urdl::istream is;\n\n * is.set_option(urdl::http::request_method(\"HEAD\"));\n", "file_path": "include/external/urdl/http.hpp", "rank": 17, "score": 100120.71286715995 }, { "content": " * is.set_option(urdl::http::request_content(\"Hello, world!\"));\n\n * is.set_option(urdl::http::request_content_type(\"text/plain\"));\n\n * is.open(\"http://host/path\");\n\n * @endcode\n\n *\n\n * To add content to the HTTP request using an object of class\n\n * @c urdl::read_stream:\n\n * @code\n\n * urdl::read_stream stream;\n\n * stream.set_option(urdl::http::request_method(\"POST\"));\n\n * stream.set_option(urdl::http::request_content(\"Hello, world!\"));\n\n * stream.set_option(urdl::http::request_content_type(\"text/plain\"));\n\n * stream.open(\"http://host/path\");\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n", "file_path": "include/external/urdl/http.hpp", "rank": 18, "score": 100120.31381267445 }, { "content": " * is.set_option(urdl::http::request_content(\"Hello, world!\"));\n\n * is.set_option(urdl::http::request_content_type(\"text/plain\"));\n\n * is.open(\"http://host/path\");\n\n * @endcode\n\n *\n\n * To add content to the HTTP request using an object of class\n\n * @c urdl::read_stream:\n\n * @code\n\n * urdl::read_stream stream;\n\n * stream.set_option(urdl::http::request_method(\"POST\"));\n\n * stream.set_option(urdl::http::request_content(\"Hello, world!\"));\n\n * stream.set_option(urdl::http::request_content_type(\"text/plain\"));\n\n * stream.open(\"http://host/path\");\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n", "file_path": "include/external/urdl/http.hpp", "rank": 19, "score": 100120.31381267445 }, { "content": "/// The class @c istream supports reading content from a specified URL.\n\n/**\n\n * @par Remarks\n\n * The class stores an object of class @c istreambuf.\n\n *\n\n * Currently supported URL protocols are @c http, @c https and @c file.\n\n *\n\n * @par Example\n\n * To read the entire content of a resource located by a URL into a string:\n\n * @code\n\n * urdl::istream is(\"http://www.boost.org/LICENSE_1_0.txt\");\n\n * if (is)\n\n * {\n\n * std::string content;\n\n * if (std::getline(is, content, std::char_traits<char>::eof()))\n\n * {\n\n * ...\n\n * }\n\n * }\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/istream.hpp> @n\n\n * @e Namespace: @c urdl\n\n */\n", "file_path": "include/external/urdl/istream.hpp", "rank": 20, "score": 100119.41231750825 }, { "content": " /// The server-generated status code \"502 Bad Gateway\".\n\n bad_gateway = 502,\n\n\n\n /// The server-generated status code \"503 Service Unavailable\".\n\n service_unavailable = 503,\n\n\n\n /// The server-generated status code \"504 Gateway Timeout\".\n\n gateway_timeout = 504,\n\n\n\n /// The server-generated status code \"505 HTTP Version Not Supported\".\n\n version_not_supported = 505\n\n};\n\n\n\n/// Converts a value of type @c errc_t to a corresponding object of type\n\n/// @c asio::error_code.\n\n/**\n\n * @par Requirements\n\n * @e Header: @c <urdl/http.hpp> @n\n\n * @e Namespace: @c urdl::http\n\n */\n", "file_path": "include/external/urdl/http.hpp", "rank": 21, "score": 100118.92902620125 }, { "content": "/**\n\n * @par Example\n\n * To extract the components of a URL:\n\n * @code\n\n * urdl::url url(\"http://user:pass@host:1234/dir/page?param=0#anchor\");\n\n * std::cout << \"Protocol: \" << url.protocol() << std::endl;\n\n * std::cout << \"User Info: \" << url.user_info() << std::endl;\n\n * std::cout << \"Host: \" << url.host() << std::endl;\n\n * std::cout << \"Port: \" << url.port() << std::endl;\n\n * std::cout << \"Path: \" << url.path() << std::endl;\n\n * std::cout << \"Query: \" << url.query() << std::endl;\n\n * std::cout << \"Fragment: \" << url.fragment() << std::endl;\n\n * @endcode\n\n * The above code will print:\n\n * @code\n\n * Protocol: http\n\n * User Info: user:pass\n\n * Host: host\n\n * Port: 1234\n\n * Path: /dir/page\n\n * Query: param=0\n\n * Fragment: anchor\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/url.hpp> @n\n\n * @e Namespace: @c urdl\n\n */\n", "file_path": "include/external/urdl/url.hpp", "rank": 23, "score": 100117.5894869525 }, { "content": " */\n\n void value(std::size_t v)\n\n {\n\n value_ = v;\n\n }\n\n\n\nprivate:\n\n std::size_t value_;\n\n};\n\n\n\n/// Option to specify the user agent identifier.\n\n/**\n\n * @par Remarks\n\n * The default is to not specify the user agent.\n\n *\n\n * @par Example\n\n * To set the user agent for an object of class @c urdl::istream:\n\n * @code\n\n * urdl::istream is;\n\n * is.set_option(urdl::http::user_agent(\"Urdl\"));\n", "file_path": "include/external/urdl/http.hpp", "rank": 24, "score": 100117.19894709153 }, { "content": " *\n\n * @param ec Error code set to indicate the reason for failure, if any.\n\n *\n\n * @returns A @c url object corresponding to the specified string.\n\n */\n\n URDL_DECL static url from_string(const std::string& s,\n\n asio::error_code& ec);\n\n\n\n /// Compares two @c url objects for equality.\n\n friend URDL_DECL bool operator==(const url& a, const url& b);\n\n\n\n /// Compares two @c url objects for inequality.\n\n friend URDL_DECL bool operator!=(const url& a, const url& b);\n\n\n\n /// Compares two @c url objects for ordering.\n\n friend URDL_DECL bool operator<(const url& a, const url& b);\n\n\n\nprivate:\n\n URDL_DECL static bool unescape_path(const std::string& in, std::string& out);\n\n\n", "file_path": "include/external/urdl/url.hpp", "rank": 25, "score": 100116.73282815052 }, { "content": " * urdl::url::host_component\n\n * | urdl::url::port_component);\n\n * @endcode\n\n */\n\n URDL_DECL std::string to_string(int components = all_components) const;\n\n\n\n /// Converts a string representation of a URL into an object of class @c url.\n\n /**\n\n * @param s URL string to be parsed into its components.\n\n *\n\n * @returns A @c url object corresponding to the specified string.\n\n *\n\n * @throws asio::system_error Thrown when the URL string is invalid.\n\n */\n\n URDL_DECL static url from_string(const char* s);\n\n\n\n /// Converts a string representation of a URL into an object of class @c url.\n\n /**\n\n * @param s URL string to be parsed into its components.\n\n *\n", "file_path": "include/external/urdl/url.hpp", "rank": 26, "score": 100116.62739691888 }, { "content": " */\n\n void value(const std::string& v)\n\n {\n\n value_ = v;\n\n }\n\n\n\nprivate:\n\n std::string value_;\n\n};\n\n\n\n/// Option to specify content to accompany an HTTP request.\n\n/**\n\n * @par Remarks\n\n * The default is for no content to be sent.\n\n *\n\n * @par Example\n\n * To add content to the HTTP request using an object of class @c urdl::istream:\n\n * @code\n\n * urdl::istream is;\n\n * is.set_option(urdl::http::request_method(\"POST\"));\n", "file_path": "include/external/urdl/http.hpp", "rank": 27, "score": 100116.61019140642 }, { "content": " */\n\n void value(const std::string& v)\n\n {\n\n value_ = v;\n\n }\n\n\n\nprivate:\n\n std::string value_;\n\n};\n\n\n\n/// Option to specify the type of the content that accompanies an HTTP request.\n\n/**\n\n * @par Remarks\n\n * The default is for no content type to be specified in the request.\n\n *\n\n * @par Example\n\n * To add content to the HTTP request using an object of class @c urdl::istream:\n\n * @code\n\n * urdl::istream is;\n\n * is.set_option(urdl::http::request_method(\"POST\"));\n", "file_path": "include/external/urdl/http.hpp", "rank": 28, "score": 100116.57171098245 }, { "content": " {\n\n rdbuf()->set_option(option);\n\n }\n\n\n\n /// Sets options to control the behaviour of the stream.\n\n /**\n\n * @param options The options to be set on the stream. The options in the set\n\n * are added on top of any options already set on the stream.\n\n *\n\n * @par Remarks\n\n * Performs @c rdbuf()->set_options(options).\n\n *\n\n * @par Example\n\n * @code\n\n * urdl::istream is;\n\n * urdl::option_set options;\n\n * options.set_option(urdl::http::max_redirects(1));\n\n * options.set_option(urdl::ssl::verify_peer(false));\n\n * stream.set_options(options);\n\n * @endcode\n", "file_path": "include/external/urdl/istream.hpp", "rank": 29, "score": 100116.5127088537 }, { "content": " */\n\n void set_options(const option_set& options)\n\n {\n\n rdbuf()->set_options(options);\n\n }\n\n\n\n /// Gets the current value of an option that controls the behaviour of the\n\n /// stream.\n\n /**\n\n * @returns The current value of the option.\n\n *\n\n * @par Remarks\n\n * Returns @c rdbuf()->get_option<Option>(). Options are uniquely identified\n\n * by type.\n\n *\n\n * @par Example\n\n * @code\n\n * urdl::istream is;\n\n * urdl::http::max_redirects option\n\n * = is.get_option<urdl::http::max_redirects>();\n", "file_path": "include/external/urdl/istream.hpp", "rank": 30, "score": 100116.31462632296 }, { "content": " * ...\n\n * urdl::option_set options(is.get_options());\n\n * urdl::http::max_redirects option\n\n * = options.get_option<urdl::http::max_redirects>();\n\n * std::size_t value = option.value();\n\n * @endcode\n\n */\n\n option_set get_options() const\n\n {\n\n return rdbuf()->get_options();\n\n }\n\n\n\n /// Determines whether the stream is open.\n\n /**\n\n * @returns @c true if the stream is open, @c false otherwise.\n\n *\n\n * @par Remarks\n\n * Returns @c rdbuf()->is_open().\n\n */\n\n bool is_open() const\n", "file_path": "include/external/urdl/istream.hpp", "rank": 31, "score": 100116.27956454825 }, { "content": " */\n\n void value(const std::string& v)\n\n {\n\n value_ = v;\n\n }\n\n\n\nprivate:\n\n std::string value_;\n\n};\n\n\n\n/// Option to specify the maximum number of allowed HTTP redirects.\n\n/**\n\n * @par Remarks\n\n * The default value is for there to be no limit on the number of allowed\n\n * redirects. Set the option to 0 to disable HTTP redirects.\n\n *\n\n * @par Example\n\n * To set maximum number of redirects for an object of class @c urdl::istream:\n\n * @code\n\n * urdl::istream is;\n", "file_path": "include/external/urdl/http.hpp", "rank": 33, "score": 100115.72776826534 }, { "content": " *\n\n * @par Remarks\n\n * Initializes the base class with @c std::basic_istream<char>(sb), where\n\n * @c sb is an object of class @c istreambuf stored within the class. It also\n\n * performs @c rdbuf()->set_options(options), then opens @c sb by performing\n\n * @c sb.open(u) and, if that fails (returns a null pointer), calls\n\n * @c setstate(failbit).\n\n *\n\n * @par Example\n\n * @code\n\n * urdl::option_set options;\n\n * options.set_option(urdl::http::max_redirects(1));\n\n * urdl::istream is(\"http://www.boost.org\", options);\n\n * @endcode\n\n */\n\n explicit istream(const url& u, const option_set& options)\n\n : std::basic_istream<char>(\n\n &this->base_from_member<istreambuf>::member)\n\n {\n\n rdbuf()->set_options(options);\n", "file_path": "include/external/urdl/istream.hpp", "rank": 34, "score": 100115.57015435984 }, { "content": " if (rdbuf()->open(u) == 0)\n\n setstate(std::ios_base::failbit);\n\n }\n\n\n\n /// Sets an option to control the behaviour of the stream.\n\n /**\n\n * @param option The option to be set on the stream.\n\n *\n\n * @par Remarks\n\n * Performs @c rdbuf()->set_option(option). Options are uniquely identified by\n\n * type.\n\n *\n\n * @par Example\n\n * @code\n\n * urdl::istream is;\n\n * is.set_option(urdl::http::max_redirects(1));\n\n * @endcode\n\n */\n\n template <typename Option>\n\n void set_option(const Option& option)\n", "file_path": "include/external/urdl/istream.hpp", "rank": 35, "score": 100115.40128265912 }, { "content": " &this->base_from_member<istreambuf>::member);\n\n }\n\n\n\n /// Gets the last error associated with the stream.\n\n /**\n\n * @returns An @c error_code corresponding to the last error from the stream.\n\n *\n\n * @par Remarks\n\n * Returns a reference to an @c error_code object representing the last\n\n * failure reported by an @c istreambuf function. The set of possible\n\n * @c error_code values and categories depends on the protocol of the URL\n\n * used to open the stream.\n\n *\n\n * @par Example\n\n * To take action given a specific error:\n\n * @code\n\n * urdl::istream is(\"http://somesite/page\");\n\n * if (!is)\n\n * {\n\n * if (is.error() == urdl::http::errc::forbidden)\n", "file_path": "include/external/urdl/istream.hpp", "rank": 37, "score": 100115.04305936325 }, { "content": " * @param ec Error code set to indicate the reason for failure, if any.\n\n *\n\n * @returns A @c url object corresponding to the specified string.\n\n */\n\n URDL_DECL static url from_string(const char* s,\n\n asio::error_code& ec);\n\n\n\n /// Converts a string representation of a URL into an object of class @c url.\n\n /**\n\n * @param s URL string to be parsed into its components.\n\n *\n\n * @returns A @c url object corresponding to the specified string.\n\n *\n\n * @throws asio::system_error Thrown when the URL string is invalid.\n\n */\n\n URDL_DECL static url from_string(const std::string& s);\n\n\n\n /// Converts a string representation of a URL into an object of class @c url.\n\n /**\n\n * @param s URL string to be parsed into its components.\n", "file_path": "include/external/urdl/url.hpp", "rank": 39, "score": 100114.94489000126 }, { "content": " /**\n\n * @returns A string containing the host name of the URL.\n\n */\n\n std::string host() const\n\n {\n\n return host_;\n\n }\n\n\n\n /// Gets the port component of the URL.\n\n /**\n\n * @returns The port number of the URL.\n\n *\n\n * @par Remarks\n\n * If the URL string did not specify a port, and the protocol is one of @c\n\n * http, @c https or @c ftp, an appropriate default port number is returned.\n\n */\n\n URDL_DECL unsigned short port() const;\n\n\n\n /// Gets the path component of the URL.\n\n /**\n", "file_path": "include/external/urdl/url.hpp", "rank": 40, "score": 100114.06055687716 }, { "content": " * std::size_t value = option.value();\n\n * @endcode\n\n */\n\n template <typename Option>\n\n Option get_option() const\n\n {\n\n return rdbuf()->get_option<Option>();\n\n }\n\n\n\n /// Gets the values of all options set on the stream.\n\n /**\n\n * @returns An option set containing all options from the stream.\n\n *\n\n * @par Remarks\n\n * Returns @c rdbuf()->get_options().\n\n *\n\n * @par Example\n\n * To get the options that have been set on the stream:\n\n * @code\n\n * urdl::istream is;\n", "file_path": "include/external/urdl/istream.hpp", "rank": 41, "score": 100114.06055687716 }, { "content": " /**\n\n * @returns A string specifying the protocol of the URL. Examples include\n\n * @c http, @c https or @c file.\n\n */\n\n std::string protocol() const\n\n {\n\n return protocol_;\n\n }\n\n\n\n /// Gets the user info component of the URL.\n\n /**\n\n * @returns A string containing the user info of the URL. Typically in the\n\n * format <tt>user:password</tt>, but depends on the protocol.\n\n */\n\n std::string user_info() const\n\n {\n\n return user_info_;\n\n }\n\n\n\n /// Gets the host component of the URL.\n", "file_path": "include/external/urdl/url.hpp", "rank": 42, "score": 100114.03653521104 }, { "content": " }\n\n\n\n /// Gets the MIME type of the content obtained from the URL.\n\n /**\n\n * @returns A string specifying the MIME type. Examples of possible return\n\n * values include @c text/plain, @c text/html and @c image/png.\n\n *\n\n * @par Remarks\n\n * Returns @c rdbuf()->content_type().\n\n *\n\n * Not all URL protocols support a content type. For these protocols, this\n\n * function returns an empty string.\n\n */\n\n std::string content_type() const\n\n {\n\n return rdbuf()->content_type();\n\n }\n\n\n\n /// Gets the length of the content obtained from the URL.\n\n /**\n", "file_path": "include/external/urdl/istream.hpp", "rank": 43, "score": 100113.9130684231 }, { "content": " * @returns A string containing the path of the URL.\n\n *\n\n * @par Remarks\n\n * The path string is unescaped. To obtain the path in escaped form, use\n\n * @c to_string(url::path_component).\n\n */\n\n URDL_DECL std::string path() const;\n\n\n\n /// Gets the query component of the URL.\n\n /**\n\n * @returns A string containing the query string of the URL.\n\n *\n\n * @par Remarks\n\n * The query string is not unescaped, but is returned in whatever form it\n\n * takes in the original URL string.\n\n */\n\n std::string query() const\n\n {\n\n return query_;\n\n }\n", "file_path": "include/external/urdl/url.hpp", "rank": 44, "score": 100113.85778298254 }, { "content": " all_components = protocol_component | user_info_component | host_component\n\n | port_component | path_component | query_component | fragment_component\n\n };\n\n\n\n /// Converts an object of class @c url to a string representation.\n\n /**\n\n * @param components A bitmask specifying which components of the URL should\n\n * be included in the string. See the @c url::components_type enumeration for\n\n * possible values.\n\n *\n\n * @returns A string representation of the URL.\n\n *\n\n * @par Examples\n\n * To convert the entire URL to a string:\n\n * @code\n\n * std::string s = url.to_string();\n\n * @endcode\n\n * To convert only the host and port number into a string:\n\n * @code\n\n * std::string s = url.to_string(\n", "file_path": "include/external/urdl/url.hpp", "rank": 47, "score": 100113.36727595459 }, { "content": " * @returns The length, in bytes, of the content. If the content associated\n\n * with the URL does not specify a length,\n\n * @c std::numeric_limits<std::size_t>::max().\n\n *\n\n * @par Remarks\n\n * Returns @c rdbuf()->content_length().\n\n */\n\n std::size_t content_length() const\n\n {\n\n return rdbuf()->content_length();\n\n }\n\n\n\n /// Gets the protocol-specific headers obtained from the URL.\n\n /**\n\n * @returns A string containing the headers returned with the content from the\n\n * URL. The format and interpretation of these headers is specific to the\n\n * protocol associated with the URL.\n\n *\n\n * @par Remarks\n\n * Returns @c rdbuf()->headers().\n", "file_path": "include/external/urdl/istream.hpp", "rank": 48, "score": 100110.12604997592 }, { "content": " *\n\n * @par Remarks\n\n * Initializes the base class with @c std::basic_istream<char>(sb),\n\n * where @c sb is an object of class @c istreambuf stored within the class. It\n\n * also opens @c sb by performing @c sb.open(u) and, if that fails (returns a\n\n * null pointer), calls @c setstate(failbit).\n\n */\n\n explicit istream(const url& u)\n\n : std::basic_istream<char>(\n\n &this->base_from_member<istreambuf>::member)\n\n {\n\n if (rdbuf()->open(u) == 0)\n\n setstate(std::ios_base::failbit);\n\n }\n\n\n\n /// Constructs an object of class @c istream.\n\n /**\n\n * @param u The URL to open.\n\n *\n\n * @param options The options to be set on the stream.\n", "file_path": "include/external/urdl/istream.hpp", "rank": 49, "score": 100110.12604997592 }, { "content": "\n\n /// The server-generated status code \"407 Proxy Authentication Required\".\n\n proxy_authentication_required = 407,\n\n\n\n /// The server-generated status code \"408 Request Time-out\".\n\n request_timeout = 408,\n\n\n\n /// The server-generated status code \"409 Conflict\".\n\n conflict = 409,\n\n\n\n /// The server-generated status code \"410 Gone\".\n\n gone = 410,\n\n\n\n /// The server-generated status code \"411 Length Required\".\n\n length_required = 411,\n\n\n\n /// The server-generated status code \"412 Precondition Failed\".\n\n precondition_failed = 412,\n\n\n\n /// The server-generated status code \"413 Request Entity Too Large\".\n", "file_path": "include/external/urdl/http.hpp", "rank": 50, "score": 100110.12604997592 }, { "content": " request_entity_too_large = 413,\n\n\n\n /// The server-generated status code \"414 Request URI Too Large\".\n\n request_uri_too_large = 414,\n\n\n\n /// The server-generated status code \"415 Unsupported Media Type\".\n\n unsupported_media_type = 415,\n\n\n\n /// The server-generated status code \"416 Requested Range Not Satisfiable\".\n\n requested_range_not_satisfiable = 416,\n\n\n\n /// The server-generated status code \"417 Expectation Failed\".\n\n expectation_failed = 417,\n\n\n\n /// The server-generated status code \"500 Internal Server Error\".\n\n internal_server_error = 500,\n\n\n\n /// The server-generated status code \"501 Not Implemented\".\n\n not_implemented = 501,\n\n\n", "file_path": "include/external/urdl/http.hpp", "rank": 51, "score": 100110.12604997592 }, { "content": " */\n\n url(const char* s)\n\n : ipv6_host_(false)\n\n {\n\n *this = from_string(s);\n\n }\n\n\n\n /// Constructs an object of class @c url.\n\n /**\n\n * @param s URL string to be parsed into its components.\n\n *\n\n * @throws asio::system_error Thrown when the URL string is invalid.\n\n */\n\n url(const std::string& s)\n\n : ipv6_host_(false)\n\n {\n\n *this = from_string(s);\n\n }\n\n\n\n /// Gets the protocol component of the URL.\n", "file_path": "include/external/urdl/url.hpp", "rank": 52, "score": 100110.12604997592 }, { "content": " {\n\n return rdbuf()->is_open();\n\n }\n\n\n\n /// Opens the specified URL.\n\n /**\n\n * @param u The URL to open.\n\n *\n\n * @par Remarks\n\n * Calls @c rdbuf()->open(u). If that function does not return a null\n\n * pointer, calls @c clear(). Otherwise calls @c setstate(failbit) (which may\n\n * throw @c ios_base::failure).\n\n */\n\n void open(const url& u)\n\n {\n\n if (rdbuf()->open(u) == 0)\n\n setstate(std::ios_base::failbit);\n\n else\n\n clear();\n\n }\n", "file_path": "include/external/urdl/istream.hpp", "rank": 53, "score": 100110.12604997592 }, { "content": " *\n\n * @par Remarks\n\n * Returns @c rdbuf()->read_timeout().\n\n */\n\n std::size_t read_timeout() const\n\n {\n\n return rdbuf()->read_timeout();\n\n }\n\n\n\n /// Sets the read timeout of the stream.\n\n /**\n\n * @param milliseconds The timeout, in milliseconds, to be used for individual\n\n * read operations on the underlying transport.\n\n *\n\n * @par Remarks\n\n * Performs @c rdbuf()->read_timeout(milliseconds).\n\n */\n\n void read_timeout(std::size_t milliseconds)\n\n {\n\n rdbuf()->read_timeout(milliseconds);\n", "file_path": "include/external/urdl/istream.hpp", "rank": 54, "score": 100110.12604997592 }, { "content": " explicit request_content_type(const std::string& v)\n\n : value_(v)\n\n {\n\n }\n\n\n\n /// Gets the value of the option.\n\n /**\n\n * @returns The value of the option.\n\n */\n\n std::string value() const\n\n {\n\n return value_;\n\n }\n\n\n\n /// Sets the value of the option.\n\n /**\n\n * @param v The desired value for the option.\n\n *\n\n * @par Remarks\n\n * Postcondition: <tt>value() == v</tt>\n", "file_path": "include/external/urdl/http.hpp", "rank": 55, "score": 100110.12604997592 }, { "content": " explicit request_content(const std::string& v)\n\n : value_(v)\n\n {\n\n }\n\n\n\n /// Gets the value of the option.\n\n /**\n\n * @returns The value of the option.\n\n */\n\n std::string value() const\n\n {\n\n return value_;\n\n }\n\n\n\n /// Sets the value of the option.\n\n /**\n\n * @param v The desired value for the option.\n\n *\n\n * @par Remarks\n\n * Postcondition: <tt>value() == v</tt>\n", "file_path": "include/external/urdl/http.hpp", "rank": 56, "score": 100110.12604997592 }, { "content": " return rdbuf()->open_timeout();\n\n }\n\n\n\n /// Sets the open timeout of the stream.\n\n /**\n\n * @param milliseconds The timeout, in milliseconds, to be used when opening\n\n * a URL.\n\n *\n\n * @par Remarks\n\n * Performs @c rdbuf()->open_timeout(milliseconds).\n\n */\n\n void open_timeout(std::size_t milliseconds)\n\n {\n\n rdbuf()->open_timeout(milliseconds);\n\n }\n\n\n\n /// Gets the read timeout of the stream.\n\n /**\n\n * @returns The timeout, in milliseconds, used for individual read operations\n\n * on the underlying transport.\n", "file_path": "include/external/urdl/istream.hpp", "rank": 57, "score": 100110.12604997592 }, { "content": "\n\n /// Gets the fragment component of the URL.\n\n /**\n\n * @returns A string containing the fragment of the URL.\n\n */\n\n std::string fragment() const\n\n {\n\n return fragment_;\n\n }\n\n\n\n /// Components of the URL, used with @c from_string.\n\n enum components_type\n\n {\n\n protocol_component = 1,\n\n user_info_component = 2,\n\n host_component = 4,\n\n port_component = 8,\n\n path_component = 16,\n\n query_component = 32,\n\n fragment_component = 64,\n", "file_path": "include/external/urdl/url.hpp", "rank": 58, "score": 100110.12604997592 }, { "content": " multiple_choices = 300,\n\n\n\n /// The server-generated status code \"301 Moved Permanently\".\n\n moved_permanently = 301,\n\n\n\n /// The server-generated status code \"302 Found\".\n\n found = 302,\n\n\n\n /// The server-generated status code \"303 See Other\".\n\n see_other = 303,\n\n\n\n /// The server-generated status code \"304 Not Modified\".\n\n not_modified = 304,\n\n\n\n /// The server-generated status code \"305 Use Proxy\".\n\n use_proxy = 305,\n\n\n\n /// The server-generated status code \"307 Temporary Redirect\".\n\n temporary_redirect = 307,\n\n\n", "file_path": "include/external/urdl/http.hpp", "rank": 59, "score": 100110.12604997592 }, { "content": " /// The server-generated status code \"400 Bad Request\".\n\n bad_request = 400,\n\n\n\n /// The server-generated status code \"401 Unauthorized\".\n\n unauthorized = 401,\n\n\n\n /// The server-generated status code \"402 Payment Required\".\n\n payment_required = 402,\n\n\n\n /// The server-generated status code \"403 Forbidden\".\n\n forbidden = 403,\n\n\n\n /// The server-generated status code \"404 Not Found\".\n\n not_found = 404,\n\n\n\n /// The server-generated status code \"405 Method Not Allowed\".\n\n method_not_allowed = 405,\n\n\n\n /// The server-generated status code \"406 Not Acceptable\".\n\n not_acceptable = 406,\n", "file_path": "include/external/urdl/http.hpp", "rank": 60, "score": 100110.12604997592 }, { "content": "\n\n /// Closes the stream.\n\n /**\n\n * @par Remarks\n\n * Calls @c rdbuf()->close() and, if that function returns a null\n\n * pointer, calls @c setstate(failbit) (which may throw @c ios_base::failure).\n\n */\n\n void close()\n\n {\n\n if (rdbuf()->close() == 0)\n\n setstate(std::ios_base::failbit);\n\n }\n\n\n\n /// Gets the underlying stream buffer.\n\n /**\n\n * @returns A pointer to the stream buffer contained within the class.\n\n */\n\n istreambuf* rdbuf() const\n\n {\n\n return const_cast<istreambuf*>(\n", "file_path": "include/external/urdl/istream.hpp", "rank": 61, "score": 100110.12604997592 }, { "content": " explicit max_redirects(std::size_t v)\n\n : value_(v)\n\n {\n\n }\n\n\n\n /// Gets the value of the option.\n\n /**\n\n * @returns The value of the option.\n\n */\n\n std::size_t value() const\n\n {\n\n return value_;\n\n }\n\n\n\n /// Sets the value of the option.\n\n /**\n\n * @param v The desired value for the option.\n\n *\n\n * @par Remarks\n\n * Postcondition: <tt>value() == v</tt>\n", "file_path": "include/external/urdl/http.hpp", "rank": 62, "score": 100110.12604997592 }, { "content": "\n\n /// The server-generated status code \"201 Created\".\n\n created = 201,\n\n\n\n /// The server-generated status code \"202 Accepted\".\n\n accepted = 202,\n\n\n\n /// The server-generated status code \"203 Non-Authoritative Information\".\n\n non_authoritative_information = 203,\n\n\n\n /// The server-generated status code \"204 No Content\".\n\n no_content = 204,\n\n\n\n /// The server-generated status code \"205 Reset Content\".\n\n reset_content = 205,\n\n\n\n /// The server-generated status code \"206 Partial Content\".\n\n partial_content = 206,\n\n\n\n /// The server-generated status code \"300 Multiple Choices\".\n", "file_path": "include/external/urdl/http.hpp", "rank": 63, "score": 100110.12604997592 }, { "content": " * {\n\n * std::cout << \"Computer says no\" << std::endl;\n\n * }\n\n * }\n\n * @endcode\n\n */\n\n const asio::error_code& error() const\n\n {\n\n return rdbuf()->puberror();\n\n }\n\n\n\n /// Gets the open timeout of the stream.\n\n /**\n\n * @returns The timeout, in milliseconds, used when opening a URL.\n\n *\n\n * @par Remarks\n\n * Returns @c rdbuf()->open_timeout().\n\n */\n\n std::size_t open_timeout() const\n\n {\n", "file_path": "include/external/urdl/istream.hpp", "rank": 64, "score": 100110.12604997592 }, { "content": " explicit request_method(const std::string& v)\n\n : value_(v)\n\n {\n\n }\n\n\n\n /// Gets the value of the option.\n\n /**\n\n * @returns The value of the option.\n\n */\n\n std::string value() const\n\n {\n\n return value_;\n\n }\n\n\n\n /// Sets the value of the option.\n\n /**\n\n * @param v The desired value for the option.\n\n *\n\n * @par Remarks\n\n * Postcondition: <tt>value() == v</tt>\n", "file_path": "include/external/urdl/http.hpp", "rank": 65, "score": 100110.12604997592 }, { "content": " explicit user_agent(const std::string& v)\n\n : value_(v)\n\n {\n\n }\n\n\n\n /// Gets the value of the option.\n\n /**\n\n * @returns The value of the option.\n\n */\n\n std::string value() const\n\n {\n\n return value_;\n\n }\n\n\n\n /// Sets the value of the option.\n\n /**\n\n * @param v The desired value for the option.\n\n *\n\n * @par Remarks\n\n * Postcondition: <tt>value() == v</tt>\n", "file_path": "include/external/urdl/http.hpp", "rank": 66, "score": 100110.12604997592 }, { "content": " break;\n\n case final_linefeed:\n\n return (c == '\\n');\n\n default:\n\n return false;\n\n }\n\n }\n\n return false;\n\n}\n\n\n\n} // namespace detail\n\n} // namespace urdl\n\n\n\n#include \"abi_suffix.hpp\"\n\n\n\n#endif // URDL_DETAIL_PARSERS_HPP\n", "file_path": "include/external/urdl/detail/parsers.hpp", "rank": 67, "score": 96784.9399272547 }, { "content": "//\n\n// connect.hpp\n\n// ~~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_DETAIL_CONNECT_HPP\n\n#define URDL_DETAIL_CONNECT_HPP\n\n\n\n#include <sstream>\n\n#include \"coroutine.hpp\"\n\n#include \"abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\nnamespace detail {\n\n\n", "file_path": "include/external/urdl/detail/connect.hpp", "rank": 68, "score": 96783.88442024332 }, { "content": " } while (0)\n\n\n\n#if defined(_MSC_VER)\n\n# define URDL_CORO_YIELD(s) URDL_CORO_YIELD_IMPL(s, __COUNTER__ + 1)\n\n#else // defined(_MSC_VER)\n\n# define URDL_CORO_YIELD(s) URDL_CORO_YIELD_IMPL(s, __LINE__)\n\n#endif // defined(_MSC_VER)\n\n\n\n#define URDL_CORO_END \\\n\n }\n\n\n\n} // namespace detail\n\n} // namespace urdl\n\n\n\n#include \"abi_suffix.hpp\"\n\n\n\n#endif // URDL_DETAIL_COROUTINE_HPP\n", "file_path": "include/external/urdl/detail/coroutine.hpp", "rank": 69, "score": 96783.504560291 }, { "content": "//\n\n// parsers.hpp\n\n// ~~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_DETAIL_PARSERS_HPP\n\n#define URDL_DETAIL_PARSERS_HPP\n\n\n\n#include <algorithm>\n\n#include <cctype>\n\n#include <cstdlib>\n\n#include <string>\n\n#include \"abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n", "file_path": "include/external/urdl/detail/parsers.hpp", "rank": 70, "score": 96783.16854402907 }, { "content": "//\n\n// coroutine.hpp\n\n// ~~~~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_DETAIL_COROUTINE_HPP\n\n#define URDL_DETAIL_COROUTINE_HPP\n\n\n\n#include \"abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\nnamespace detail {\n\n\n", "file_path": "include/external/urdl/detail/coroutine.hpp", "rank": 71, "score": 96781.99212186292 }, { "content": " URDL_DECL void set_option_wrapper_base(option_wrapper_base* o);\n\n URDL_DECL option_wrapper_base* get_option_wrapper_base(\n\n const std::type_info& ti) const;\n\n URDL_DECL void clear_option_wrapper_base(const std::type_info& ti);\n\n\n\n std::unique_ptr<option_wrapper_base> head_;\n\n};\n\n\n\n} // namespace urdl\n\n\n\n#include \"detail/abi_suffix.hpp\"\n\n\n\n#if defined(URDL_HEADER_ONLY)\n\n# include \"impl/option_set.ipp\"\n\n#endif\n\n\n\n#endif // URDL_OPTION_SET_HPP\n", "file_path": "include/external/urdl/option_set.hpp", "rank": 72, "score": 96781.85301884999 }, { "content": "//\n\n// option_set.hpp\n\n// ~~~~~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// path LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_OPTION_SET_HPP\n\n#define URDL_OPTION_SET_HPP\n\n\n\n#include <typeinfo>\n\n#include \"detail/config.hpp\"\n\n#include \"detail/abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\n\n\n/// The class @c option_set maintains a collection of options.\n", "file_path": "include/external/urdl/option_set.hpp", "rank": 73, "score": 96781.713394977 }, { "content": " std::string host_;\n\n};\n\n\n\ntemplate <typename Handler>\n\nvoid async_handshake(\n\n asio::ssl::stream<asio::ip::tcp::socket>& socket,\n\n const std::string& host, Handler handler)\n\n{\n\n handshake_coro<Handler>(handler, socket, host)(asio::error_code());\n\n}\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n\n\n} // namespace detail\n\n} // namespace urdl\n\n\n\n#include \"abi_suffix.hpp\"\n\n\n\n#endif // URDL_DETAIL_HANDSHAKE_HPP\n", "file_path": "include/external/urdl/detail/handshake.hpp", "rank": 74, "score": 96781.65247318485 }, { "content": "#endif // !defined(URDL_DISABLE_SSL)\n\n\n\n#include \"abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\nnamespace detail {\n\n\n\ninline asio::error_code handshake(\n\n asio::ip::tcp::socket& /*socket*/,\n\n const std::string& /*host*/, asio::error_code& ec)\n\n{\n\n ec = asio::error_code();\n\n return ec;\n\n}\n\n\n\ntemplate <typename Handler>\n\nvoid async_handshake(asio::ip::tcp::socket& socket,\n\n const std::string& /*host*/, Handler handler)\n\n{\n\n asio::error_code ec;\n", "file_path": "include/external/urdl/detail/handshake.hpp", "rank": 75, "score": 96780.0187009886 }, { "content": "#if !defined(URDL_DISABLE_SSL)\n\n# include \"asio/ssl.hpp\"\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n\n\n#include \"detail/abi_prefix.hpp\"\n\n\n\nnamespace urdl {\n\n\n\n/// The class @c read_stream supports reading content from a specified URL\n\n/// using synchronous or asynchronous operations.\n\n/**\n\n * @par Remarks\n\n * Currently supported URL protocols are @c http, @c https and @c file.\n\n *\n\n * The class @c read_stream meets the type requirements for @c SyncReadStream\n\n * and @c AsyncReadStream, as defined in the Boost.Asio documentation. This\n\n * allows objects of class @c read_stream to be used with the functions\n\n * @c asio::read, @c asio::async_read, @c asio::read_until\n\n * and @c asio::async_read_until.\n\n *\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 76, "score": 96779.65115261203 }, { "content": "//\n\n// handshake.hpp\n\n// ~~~~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_DETAIL_HANDSHAKE_HPP\n\n#define URDL_DETAIL_HANDSHAKE_HPP\n\n\n\n#include <cstring>\n\n#include <cctype>\n\n#include \"coroutine.hpp\"\n\n\n\n#if !defined(URDL_DISABLE_SSL)\n\n# include \"asio/ssl.hpp\"\n\n# include <openssl/x509v3.h>\n", "file_path": "include/external/urdl/detail/handshake.hpp", "rank": 77, "score": 96779.36234986945 }, { "content": "template <typename Handler>\n\nvoid async_connect(asio::ip::tcp::socket::lowest_layer_type& socket,\n\n asio::ip::tcp::resolver& resolver, const url& u, Handler handler)\n\n{\n\n std::ostringstream port_string;\n\n port_string << u.port();\n\n asio::ip::tcp::resolver::query query(u.host(), port_string.str());\n\n connect_coro<Handler>(handler, socket, resolver)(\n\n asio::error_code(), &query);\n\n}\n\n\n\n} // namespace detail\n\n} // namespace urdl\n\n\n\n#include \"abi_suffix.hpp\"\n\n\n\n#endif // URDL_DETAIL_CONNECT_HPP\n", "file_path": "include/external/urdl/detail/connect.hpp", "rank": 78, "score": 96779.34106985916 }, { "content": "\n\n asio::io_context& io_context_;\n\n option_set options_;\n\n detail::file_read_stream file_;\n\n detail::http_read_stream<asio::ip::tcp::socket> http_;\n\n#if !defined(URDL_DISABLE_SSL)\n\n asio::ssl::context ssl_context_;\n\n detail::http_read_stream<\n\n asio::ssl::stream<\n\n asio::ip::tcp::socket> > https_;\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n enum { unknown, file, http, https } protocol_;\n\n};\n\n\n\n} // namespace urdl\n\n\n\n#include \"detail/abi_suffix.hpp\"\n\n\n\n#endif // URDL_READ_STREAM_HPP\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 79, "score": 96779.14220960785 }, { "content": "//\n\n// read_stream.hpp\n\n// ~~~~~~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n#ifndef URDL_READ_STREAM_HPP\n\n#define URDL_READ_STREAM_HPP\n\n\n\n#include \"http.hpp\"\n\n#include \"option_set.hpp\"\n\n#include \"url.hpp\"\n\n#include \"detail/coroutine.hpp\"\n\n#include \"detail/file_read_stream.hpp\"\n\n#include \"detail/http_read_stream.hpp\"\n\n\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 80, "score": 96778.26004621026 }, { "content": "/**\n\n * @par Remarks\n\n * Options are uniquely identified by type, so the @c option_set class is a\n\n * collection of objects of differing types, indexed by type.\n\n *\n\n * The option types stored in the set must meet the type requirements for\n\n * CopyConstructible.\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/option_set.hpp> @n\n\n * @e Namespace: @c urdl\n\n */\n", "file_path": "include/external/urdl/option_set.hpp", "rank": 81, "score": 96777.37099404875 }, { "content": "//\n\n// config.hpp\n\n// ~~~~~~~~~~\n\n//\n\n// Copyright (c) 2009-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)\n\n//\n\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n//\n\n\n\n// No include guard.\n\n\n\n#if defined(URDL_HEADER_ONLY)\n\n# define URDL_DECL inline\n\n#else // defined(URDL_HEADER_ONLY)\n\n# if defined(BOOST_HAS_DECLSPEC)\n\n// We need to import/export our code only if the user has specifically asked\n\n// for it by defining either BOOST_ALL_DYN_LINK if they want all boost\n\n// libraries to be dynamically linked (and if boost is dynamically linked, urdl\n\n// must be dynamically linked too), or URDL_DYN_LINK if they want just urdl to\n", "file_path": "include/external/urdl/detail/config.hpp", "rank": 82, "score": 96776.39717451607 }, { "content": " * read_stream.async_read_some(asio::buffer(data), read_handler);\n\n * }\n\n * }\n\n * ...\n\n * void read_handler(const asio::error_code& ec, std::size_t length)\n\n * {\n\n * if (!ec)\n\n * {\n\n * std::cout.write(data, length);\n\n * read_stream.async_read_some(asio::buffer(data), read_handler);\n\n * }\n\n * }\n\n * @endcode\n\n *\n\n * @par Requirements\n\n * @e Header: @c <urdl/read_stream.hpp> @n\n\n * @e Namespace: @c urdl\n\n */\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 83, "score": 96775.76259854477 }, { "content": " case http:\n\n return http_.close(ec);\n\n#if !defined(URDL_DISABLE_SSL)\n\n case https:\n\n return https_.close(ec);\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n default:\n\n ec = asio::error_code();\n\n break;\n\n }\n\n\n\n return ec;\n\n }\n\n\n\n /// Gets the MIME type of the content obtained from the URL.\n\n /**\n\n * @returns A string specifying the MIME type. Examples of possible return\n\n * values include @c text/plain, @c text/html and @c image/png.\n\n *\n\n * @par Remarks\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 84, "score": 96775.67717618815 }, { "content": "// be dynamically liked.\n\n# if defined(BOOST_ALL_DYN_LINK) || defined(URDL_DYN_LINK)\n\n# if !defined(URDL_DYN_LINK)\n\n# define URDL_DYN_LINK\n\n# endif // !defined(URDL_DYN_LINK)\n\n// Export if this is our own source, otherwise import.\n\n# if defined(URDL_SOURCE)\n\n# define URDL_DECL __declspec(dllexport)\n\n# else // defined(URDL_SOURCE)\n\n# define URDL_DECL __declspec(dllimport)\n\n# endif // defined(URDL_SOURCE)\n\n# endif // defined(BOOST_ALL_DYN_LINK) || defined(URDL_DYN_LINK)\n\n# endif // defined(BOOST_HAS_DECLSPEC)\n\n#endif // defined(URDL_HEADER_ONLY)\n\n\n\n// If URDL_DECL isn't defined yet define it now.\n\n#if !defined(URDL_DECL)\n\n# define URDL_DECL\n\n#endif // !defined(URDL_DECL)\n\n\n", "file_path": "include/external/urdl/detail/config.hpp", "rank": 85, "score": 96774.61659540875 }, { "content": "# else\n\n# define URDL_LIB_PREFIX \"lib\"\n\n# endif\n\n\n\n# if defined(_DEBUG)\n\n# if defined(_DLL)\n\n# define URDL_LIB_SUFFIX \"-gd\"\n\n# else\n\n# define URDL_LIB_SUFFIX \"-sgd\"\n\n# endif\n\n# else\n\n# if defined(_DLL)\n\n# define URDL_LIB_SUFFIX\n\n# else\n\n# define URDL_LIB_SUFFIX \"-s\"\n\n# endif\n\n# endif\n\n\n\n# pragma comment(lib, URDL_LIB_PREFIX \"urdl\" URDL_LIB_SUFFIX \".lib\")\n\n\n\n#endif // !defined(BOOST_ALL_NO_LIB) && !defined(URDL_NO_LIB)\n\n // && !defined(URDL_SOURCE) && !defined(URDL_HEADER_ONLY)\n\n // && defined(_MSC_VER)\n", "file_path": "include/external/urdl/detail/config.hpp", "rank": 86, "score": 96774.56595423556 }, { "content": "#if (BOOST_VERSION >= 105400)\n\n# define URDL_INITFN_RESULT_TYPE(h, sig) BOOST_ASIO_INITFN_RESULT_TYPE(h, sig)\n\n#else // (BOOST_VERSION >= 105400)\n\n# define URDL_INITFN_RESULT_TYPE(h, sig) void\n\n#endif // (BOOST_VERSION >= 105400)\n\n\n\n// Enable library autolinking for MSVC.\n\n\n\n#if !defined(BOOST_ALL_NO_LIB) && !defined(URDL_NO_LIB) \\\n\n && !defined(URDL_SOURCE) && !defined(URDL_HEADER_ONLY) \\\n\n && defined(_MSC_VER)\n\n\n\n# if !defined(_MT)\n\n# error \"You must use the multithreaded runtime.\"\n\n# endif\n\n\n\n# if (defined(_DLL) || defined(_RTLDLL)) && defined(URDL_DYN_LINK)\n\n# define URDL_LIB_PREFIX\n\n# elif defined(URDL_DYN_LINK)\n\n# error \"Mixing a dll library with a static runtime is unsupported.\"\n", "file_path": "include/external/urdl/detail/config.hpp", "rank": 87, "score": 96773.80411141897 }, { "content": " * urdl::read_stream stream(io_context);\n\n * ...\n\n * urdl::option_set options(stream.get_options());\n\n * urdl::http::max_redirects option\n\n * = options.get_option<urdl::http::max_redirects>();\n\n * std::size_t value = option.value();\n\n * @endcode\n\n */\n\n option_set get_options() const\n\n {\n\n return options_;\n\n }\n\n\n\n /// Determines whether the stream is open.\n\n /**\n\n * @returns @c true if the stream is open, @c false otherwise.\n\n */\n\n bool is_open() const\n\n {\n\n switch (protocol_)\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 88, "score": 96773.22699774466 }, { "content": " * urdl::read_stream stream(io_context);\n\n * urdl::option_set options;\n\n * options.set_option(urdl::http::max_redirects(1));\n\n * options.set_option(urdl::ssl::verify_peer(false));\n\n * stream.set_options(options);\n\n * @endcode\n\n */\n\n void set_options(const option_set& options)\n\n {\n\n options_.set_options(options);\n\n }\n\n\n\n /// Gets the current value of an option that controls the behaviour of the\n\n /// stream.\n\n /**\n\n * @returns The current value of the option.\n\n *\n\n * @par Remarks\n\n * Options are uniquely identified by type.\n\n *\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 89, "score": 96773.04865585399 }, { "content": " urdl::http::max_redirects>().value();\n\n if (redirects < max_redirects)\n\n {\n\n ++redirects;\n\n tmp_url = https_.location();\n\n https_.close(ec);\n\n continue;\n\n }\n\n }\n\n return ec;\n\n }\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n else\n\n {\n\n ec = asio::error::operation_not_supported;\n\n return ec;\n\n }\n\n }\n\n }\n\n\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 90, "score": 96772.69912517791 }, { "content": " * @par Example\n\n * @code\n\n * urdl::read_stream stream(io_context);\n\n * urdl::http::max_redirects option\n\n * = stream.get_option<urdl::http::max_redirects>();\n\n * std::size_t value = option.value();\n\n * @endcode\n\n */\n\n template <typename Option>\n\n Option get_option() const\n\n {\n\n return options_.get_option<Option>();\n\n }\n\n\n\n /// Gets the values of all options set on the stream.\n\n /**\n\n * @returns An option set containing all options from the stream.\n\n *\n\n * @par Example\n\n * @code\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 91, "score": 96772.62703850494 }, { "content": " {\n\n case file:\n\n return file_.is_open();\n\n case http:\n\n return http_.is_open();\n\n#if !defined(URDL_DISABLE_SSL)\n\n case https:\n\n return https_.is_open();\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n default:\n\n return false;\n\n }\n\n }\n\n\n\n /// Opens the specified URL.\n\n /**\n\n * @param u The URL to open.\n\n *\n\n * @throws asio::system_error Thrown on failure.\n\n *\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 92, "score": 96772.4507595562 }, { "content": " const asio::ip::tcp::resolver::query* query = 0)\n\n {\n\n URDL_CORO_BEGIN;\n\n\n\n // Open the socket to give the caller something to close to cancel the\n\n // asynchronous operation.\n\n socket_.open(asio::ip::tcp::v4(), ec);\n\n if (ec)\n\n {\n\n URDL_CORO_YIELD(socket_.get_io_context().post(\n\n asio::detail::bind_handler(*this, ec)));\n\n handler_(ec);\n\n return;\n\n }\n\n\n\n // Get a list of endpoints corresponding to the host name.\n\n URDL_CORO_YIELD(resolver_.async_resolve(*query, *this));\n\n if (ec)\n\n {\n\n handler_(ec);\n", "file_path": "include/external/urdl/detail/connect.hpp", "rank": 93, "score": 96772.39994150346 }, { "content": " * Not all URL protocols support a content type. For these protocols, this\n\n * function returns an empty string.\n\n */\n\n std::string content_type() const\n\n {\n\n switch (protocol_)\n\n {\n\n case file:\n\n return std::string();\n\n case http:\n\n return http_.content_type();\n\n#if !defined(URDL_DISABLE_SSL)\n\n case https:\n\n return https_.content_type();\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n default:\n\n return std::string();\n\n }\n\n }\n\n\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 94, "score": 96772.17808364797 }, { "content": " handler_(ec);\n\n return;\n\n }\n\n else if (url_.protocol() == \"http\")\n\n {\n\n this_->protocol_ = http;\n\n URDL_CORO_YIELD(this_->http_.async_open(url_, *this));\n\n if (ec.value() == http::errc::moved_permanently || ec.value() == http::errc::found)\n\n {\n\n url_ = this_->http_.location();\n\n this_->http_.close(ec);\n\n continue;\n\n }\n\n handler_(ec);\n\n return;\n\n }\n\n#if !defined(URDL_DISABLE_SSL)\n\n else if (url_.protocol() == \"https\")\n\n {\n\n this_->protocol_ = https;\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 95, "score": 96772.00994090318 }, { "content": " break;\n\n#if !defined(URDL_DISABLE_SSL)\n\n case https:\n\n https_.async_read_some(buffers, real_handler);\n\n break;\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n default:\n\n asio::error_code ec\n\n = asio::error::operation_not_supported;\n\n io_context_.post(asio::detail::bind_handler(real_handler, ec, 0));\n\n break;\n\n }\n\n\n\n return result.get();\n\n }\n\n\n\nprivate:\n\n template <typename Handler>\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 96, "score": 96772.00994090318 }, { "content": " URDL_CORO_YIELD(this_->https_.async_open(url_, *this));\n\n if (ec.value() == http::errc::moved_permanently || ec.value() == http::errc::found)\n\n {\n\n url_ = this_->https_.location();\n\n this_->https_.close(ec);\n\n continue;\n\n }\n\n handler_(ec);\n\n return;\n\n }\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n else\n\n {\n\n ec = asio::error::operation_not_supported;\n\n this_->io_context_.post(\n\n asio::detail::bind_handler(handler_, ec));\n\n return;\n\n }\n\n }\n\n\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 97, "score": 96771.92959882578 }, { "content": " *\n\n * @par Example\n\n * @code\n\n * urdl::read_stream stream(io_context);\n\n * stream.set_option(urdl::http::max_redirects(1));\n\n * @endcode\n\n */\n\n template <typename Option>\n\n void set_option(const Option& option)\n\n {\n\n options_.set_option(option);\n\n }\n\n\n\n /// Sets options to control the behaviour of the stream.\n\n /**\n\n * @param options The options to be set on the stream. The options in the set\n\n * are added on top of any options already set on the stream.\n\n *\n\n * @par Example\n\n * @code\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 98, "score": 96771.73876770303 }, { "content": " */\n\n template <typename MutableBufferSequence>\n\n std::size_t read_some(const MutableBufferSequence& buffers,\n\n asio::error_code& ec)\n\n {\n\n switch (protocol_)\n\n {\n\n case file:\n\n return file_.read_some(buffers, ec);\n\n case http:\n\n return http_.read_some(buffers, ec);\n\n#if !defined(URDL_DISABLE_SSL)\n\n case https:\n\n return https_.read_some(buffers, ec);\n\n#endif // !defined(URDL_DISABLE_SSL)\n\n default:\n\n ec = asio::error::operation_not_supported;\n\n return 0;\n\n }\n\n }\n", "file_path": "include/external/urdl/read_stream.hpp", "rank": 99, "score": 96771.73876770303 } ]
C++
src/machine_learning/matrix_factorization.cpp
rafaelppires/rex
4d3c10ba4bde86365090b5c7c5e8de037a1fb885
#include "matrix_factorization.h" #include <utils/time_probe.h> #include <iostream> MatrixFactorizationModel::MatrixFactorizationModel(int rank) : rank_(rank) {} double MatrixFactorizationModel::predict(int user, int item) const { return weights_.predict(user, item); } double MatrixFactorizationModel::rmse(const TripletVector<uint8_t> &testset) { size_t count = 0; double sumofsquares = 0; for (auto &t : testset) { double diff = t.value() - predict(t.row(), t.col()); sumofsquares += diff * diff; ++count; } return sqrt(sumofsquares / count); } bool MatrixFactorizationModel::init_item(int item, const Sparse &column) { if (!weights_.has_item(item)) { find_space(0, item); weights_.items.col(item) = column; return true; } return false; } bool MatrixFactorizationModel::init_user(int user, const Sparse &column) { if (!weights_.has_user(user)) { find_space(user, 0); weights_.users.col(user) = column; return true; } return false; } Sparse MatrixFactorizationModel::zero_embedding() { Sparse ret; ret.reserve(rank_); ret.resize(rank_, 1); ret.col(0) = Eigen::MatrixXd::Zero(rank_, 1).sparseView(); return ret; } void MatrixFactorizationModel::make_compressed() { weights_.users.makeCompressed(); weights_.items.makeCompressed(); weights_.user_biases.makeCompressed(); weights_.item_biases.makeCompressed(); } void MatrixFactorizationModel::item_merge_column(Sparse &Y, const Sparse &Other) { sparse_matrix_outer_iterate(Other, [&](Sparse::InnerIterator it, int i) { int item = it.col(); if (!init_item(item, Other.col(item))) { Y.col(item) = (Y.col(item) + Other.col(item)) / 2.; } }); } void MatrixFactorizationModel::user_merge_column(Sparse &X, const Sparse &Other) { sparse_matrix_outer_iterate(Other, [&](Sparse::InnerIterator it, int i) { int user = it.col(); if (!init_user(user, Other.col(user))) { X.col(user) = (X.col(user) + Other.col(user)) / 2.; } }); } void MatrixFactorizationModel::merge_average( const MatrixFactorizationModel &m) { item_merge_column(weights_.items, m.weights_.items); item_merge_column(weights_.item_biases, m.weights_.item_biases); user_merge_column(weights_.users, m.weights_.users); user_merge_column(weights_.user_biases, m.weights_.user_biases); } void MatrixFactorizationModel::prep_toshare() { init_user(rank_, weights_.users.col(0)); weights_.users.col(rank_) = weights_.users.col(0); weights_.users.col(0) = Eigen::MatrixXd::Zero(rank_, 1).sparseView(); weights_.user_biases.coeffRef(0, rank_) = weights_.user_biases.coeff(0, 0); weights_.user_biases.coeffRef(0, 0) = 0; } std::set<int> MatrixFactorizationModel::metropolis_hastings( size_t my_degree, const DegreesAndModels &models, Sparse &factors, Sparse &biases, bool isusers) { std::set<int> ret; sparse_matrix_outer_iterate(factors, [&](Sparse::InnerIterator it, int i) { int index = it.col(); double sum_weights = 0; Sparse embedding(zero_embedding()), bias; bias.resize(1, 1); bias.coeffRef(0, 0) = 0; std::vector<size_t> degrees; for (const auto &model : models) { size_t degree = model.degree; const MatrixFactorizationModel &nmodel = model.model; if (isusers ? nmodel.weights_.has_user(index) : nmodel.weights_.has_item(index)) { double weight = 1. / (1 + std::max(my_degree, degree)); embedding.col(0) += weight * (isusers ? nmodel.weights_.users.col(index) : nmodel.weights_.items.col(index)); bias.coeffRef(0, 0) += weight * (isusers ? nmodel.weights_.user_biases.coeff(0, index) : nmodel.weights_.item_biases.coeff(0, index)); sum_weights += weight; degrees.emplace_back(degree); } } if (sum_weights > 1.0) { std::cerr << "my rank: " << rank_ << " idx: " << index << std::endl; std::cerr << "Sum of weights > 1: " << sum_weights << std::endl; std::cerr << my_degree << " (" << degrees.size() << ") - "; for (auto &d : degrees) std::cerr << d << " "; std::cerr << std::endl; abort(); } double my_weight = 1. - sum_weights; factors.col(index) *= my_weight; biases.coeffRef(0, index) *= my_weight; factors.col(index) += embedding.col(0); biases.coeffRef(0, index) += bias.coeff(0, 0); ret.insert(index); }); return ret; } std::set<int> MatrixFactorizationModel::metropolis_hastings_users( size_t my_degree, const DegreesAndModels &models) { return metropolis_hastings(my_degree, models, weights_.users, weights_.user_biases, true); } std::set<int> MatrixFactorizationModel::metropolis_hastings_items( size_t my_degree, const DegreesAndModels &models) { return metropolis_hastings(my_degree, models, weights_.items, weights_.item_biases, false); } std::pair<double, Sparse> MatrixFactorizationModel::combine_neighbors( bool isuser, int index, const DegreesAndModels &models) { struct Entry { Entry(unsigned d, Sparse c, double b) : degree(d), col(c), bias(b) {} unsigned degree; Sparse col; double bias; }; std::vector<Entry> embs; for (const auto &neigh : models) { const MatrixFactorizationModel &nmodel = neigh.model; if (isuser ? nmodel.weights_.has_user(index) : nmodel.weights_.has_item(index)) { embs.emplace_back( neigh.degree, isuser ? nmodel.weights_.users.col(index) : nmodel.weights_.items.col(index), isuser ? nmodel.weights_.user_biases.coeff(0, index) : nmodel.weights_.item_biases.coeff(0, index)); } } Sparse embedd(zero_embedding()); double sum_of_inverses = 0, bias = 0; for (const auto &e : embs) sum_of_inverses += 1.0 / e.degree; for (const auto &e : embs) { double w = (1.0 / (1 + e.degree * (sum_of_inverses - 1.0 / e.degree))); embedd.col(0) += w * e.col; bias += w * e.bias; } return std::make_pair(bias, embedd); } void MatrixFactorizationModel::combine_neighbors_embeddings( bool isuser, const DegreesAndModels &models, std::set<int> &exclude_list) { for (const auto &neigh : models) { sparse_matrix_outer_iterate( isuser ? neigh.model.weights_.users : neigh.model.weights_.items, [&](Sparse::InnerIterator it, int i) { int index = it.col(); if (exclude_list.insert(index).second) { auto combined = combine_neighbors(isuser, index, models); if (isuser) { init_user(index, combined.second); weights_.user_biases.coeffRef(0, index) = combined.first; } else { init_item(index, combined.second); weights_.item_biases.coeffRef(0, index) = combined.first; } } }); } } void MatrixFactorizationModel::combine_neighbors_users( const DegreesAndModels &models, std::set<int> &exclude_list) { combine_neighbors_embeddings(true, models, exclude_list); } void MatrixFactorizationModel::combine_neighbors_items( const DegreesAndModels &models, std::set<int> &exclude_list) { combine_neighbors_embeddings(false, models, exclude_list); } void MatrixFactorizationModel::merge_weighted(size_t my_degree, const DegreesAndModels &models) { std::set<int> users_done = metropolis_hastings_users(my_degree, models), items_done = metropolis_hastings_items(my_degree, models); combine_neighbors_users(models, users_done); combine_neighbors_items(models, items_done); } void MatrixFactorizationModel::find_space(int user, int item, const Sparse &col, double b) { auto &Y = weights_.items, &B = weights_.item_biases; auto &X = weights_.users, &A = weights_.user_biases; if (item >= Y.cols()) { Y.conservativeResize(rank_, item + 1); B.conservativeResize(1, item + 1); if (col.outerSize() > 0) Y.col(item) = col; if (b > 0) B.coeffRef(0, item) = b; } if (user >= X.cols()) { X.conservativeResize(rank_, user + 1); A.conservativeResize(1, user + 1); if (col.outerSize() > 0) X.col(user) = col; if (b > 0) A.coeffRef(0, user) = b; } } size_t MatrixFactorizationModel::estimate_serial_size() const { return sizeof(rank_) + weights_.estimate_serial_size(); } void MatrixFactorizationModel::serialize_append( std::vector<uint8_t> &out) const { const uint8_t *rptr = reinterpret_cast<const uint8_t *>(&rank_); out.insert(out.end(), rptr, rptr + sizeof(rank_)); weights_.serialize_append(out); } size_t MatrixFactorizationModel::deserialize(const std::vector<uint8_t> &data, size_t offset) { rank_ = *reinterpret_cast<const int *>(&data[offset]); return weights_.deserialize(data, offset + sizeof(rank_)); } HyperMFSGD::HyperMFSGD(int r, double lr, double rp, double ib, double ifact) : rank(r), learning_rate(lr), regularization_param(rp), init_factor(ifact), init_bias(ib) { #if 0 init_column_ = Sparse(Dense::Constant(r, 1, ifact).sparseView()); #else TripletVector<double> column; for (int i = 0; i < r; ++i) { column.emplace_back(i, 0, ifact * double(rand() % 10000) / 10000); } Sparse m(r, 1); m.setFromTriplets(column.begin(), column.end()); init_column_ = m; #endif } MFSGD::MFSGD(HyperMFSGD h) : hyper_(h), model_(h.rank), weights_(model_.weights_) {} double MFSGD::train(int user, int item, double value) { auto &Y = weights_.items, &B = weights_.item_biases; auto &X = weights_.users, &A = weights_.user_biases; double lambda = hyper_.regularization_param, eta = hyper_.learning_rate; #if 1 double err = value - model_.predict(user, item), step = eta * err, mult = 1 - eta * lambda; Y.col(item) = mult * Y.col(item) + step * X.col(user); B.coeffRef(0, item) += step; X.col(user) = mult * X.col(user) + step * Y.col(item); A.coeffRef(0, user) += step; #else double err = value - model_.predict(user, item); B.coeffRef(0, item) += eta * (err - lambda * B.coeffRef(0, item)); A.coeffRef(0, user) += eta * (err - lambda * A.coeffRef(0, user)); X.col(user) += eta * (err * Y.col(item) - lambda * X.col(user)); Y.col(item) += eta * (err * X.col(user) - lambda * Y.col(item)); #endif return err * err; } void MatrixFactorizationModel::get_factors(int user, int item) { }
#include "matrix_factorization.h" #include <utils/time_probe.h> #include <iostream> MatrixFactorizationModel::MatrixFactorizationModel(int rank) : rank_(rank) {} double MatrixFactorizationModel::predict(int user, int item) const { return weights_.predict(user, item); } double MatrixFactorizationModel::rmse(const TripletVector<uint8_t> &testset) { size_t count = 0; double sumofsquares = 0; for (auto &t : testset) { double diff = t.value() - predict(t.row(), t.col()); sumofsquares += diff * diff; ++count; } return sqrt(sumofsquares / count); } bool MatrixFactorizationModel::init_item(int item, const Sparse &column) { if (!weights_.has_item(item)) { find_space(0, item); weights_.items.col(item) = column; return true; } return false; } bool MatrixFactorizationModel::init_user(int user, const Sparse &column) { if (!weights_.has_user(user)) { find_space(user, 0); weights_.users.col(user) = column; return true; } return false; } Sparse MatrixFactorizationModel::zero_embedding() { Sparse ret; ret.reserve(rank_); ret.resize(rank_, 1); ret.col(0) = Eigen::MatrixXd::Zero(rank_, 1).sparseView(); return ret; } void MatrixFactorizationModel::make_compressed() { weights_.users.makeCompressed(); weights_.items.makeCompressed(); weights_.user_biases.makeCompressed(); weights_.item_biases.makeCompressed(); } void MatrixFactorizationModel::item_merge_column(Sparse &Y, const Sparse &Other) { sparse_matrix_outer_iterate(Other, [&](Sparse::InnerIterator it, int i) { int item = it.col(); if (!init_item(item, Other.col(item))) { Y.col(item) = (Y.col(item) + Other.col(item)) / 2.; } }); } void MatrixFactorizationModel::user_merge_column(Sparse &X, const Sparse &Other) { sparse_matrix_outer_iterate(Other, [&](Sparse::InnerIterator it, int i) { int user = it.col(); if (!init_user(user, Other.col(user))) { X.col(user) = (X.col(user) + Other.col(user)) / 2.; } }); } void MatrixFactorizationModel::merge_average( const MatrixFactorizationModel &m) { item_merge_column(weights_.items, m.weights_.items); item_merge_column(weights_.item_biases, m.weights_.item_biases); user_merge_column(weights_.users, m.weights_.users); user_merge_column(weights_.user_biases, m.weights_.user_biases); } void MatrixFactorizationModel::prep_toshare() { init_user(rank_, weights_.users.col(0)); weights_.users.col(rank_) = weights_.users.col(0); weights_.users.col(0) = Eigen::MatrixXd::Zero(rank_, 1).sparseView(); weights_.user_biases.coeffRef(0, rank_) = weights_.user_biases.coeff(0, 0); weights_.user_biases.coeffRef(0, 0) = 0; } std::set<int> MatrixFactorizationModel::metropolis_hastings( size_t my_degree, const DegreesAndModels &models, Sparse &factors, Sparse &biases, bool isusers) { std::set<int> ret; sparse_matrix_outer_iterate(factors, [&](Sparse::InnerIterator it, int i) { int index = it.col(); double sum_weights = 0; Sparse embedding(zero_embedding()), bias; bias.resize(1, 1); bias.coeffRef(0, 0) = 0; std::vector<size_t> degrees; for (const auto &model : models) { size_t degree = model.degree; const MatrixFactorizationModel &nmodel = model.model; if (isusers ? nmodel.weights_.has_user(index) : nmodel.weights_.has_item(index)) { double weight = 1. / (1 + std::max(my_degree, degree)); embedding.col(0) += weight * (isusers ? nmodel.weights_.users.col(index) : nmodel.weights_.items.col(index)); bias.coeffRef(0, 0) += weight * (isusers ? nmodel.weights_.user_biases.coeff(0, index) : nmodel.weights_.item_biases.coeff(0, index)); sum_weights += weight; degrees.emplace_back(degree); } } if (sum_weights > 1.0) { std::cerr << "my rank: " << rank_ << " idx: " << index << std::endl; std::cerr << "Sum of weights > 1: " << sum_weights << std::endl; std::cerr << my_degree << " (" << degrees.size() << ") - "; for (auto &d : degrees) std::cerr << d << " "; std::cerr << std::endl; abort(); } double my_weight = 1. - sum_weights; factors.col(index) *= my_weight; biase
rank_) + weights_.estimate_serial_size(); } void MatrixFactorizationModel::serialize_append( std::vector<uint8_t> &out) const { const uint8_t *rptr = reinterpret_cast<const uint8_t *>(&rank_); out.insert(out.end(), rptr, rptr + sizeof(rank_)); weights_.serialize_append(out); } size_t MatrixFactorizationModel::deserialize(const std::vector<uint8_t> &data, size_t offset) { rank_ = *reinterpret_cast<const int *>(&data[offset]); return weights_.deserialize(data, offset + sizeof(rank_)); } HyperMFSGD::HyperMFSGD(int r, double lr, double rp, double ib, double ifact) : rank(r), learning_rate(lr), regularization_param(rp), init_factor(ifact), init_bias(ib) { #if 0 init_column_ = Sparse(Dense::Constant(r, 1, ifact).sparseView()); #else TripletVector<double> column; for (int i = 0; i < r; ++i) { column.emplace_back(i, 0, ifact * double(rand() % 10000) / 10000); } Sparse m(r, 1); m.setFromTriplets(column.begin(), column.end()); init_column_ = m; #endif } MFSGD::MFSGD(HyperMFSGD h) : hyper_(h), model_(h.rank), weights_(model_.weights_) {} double MFSGD::train(int user, int item, double value) { auto &Y = weights_.items, &B = weights_.item_biases; auto &X = weights_.users, &A = weights_.user_biases; double lambda = hyper_.regularization_param, eta = hyper_.learning_rate; #if 1 double err = value - model_.predict(user, item), step = eta * err, mult = 1 - eta * lambda; Y.col(item) = mult * Y.col(item) + step * X.col(user); B.coeffRef(0, item) += step; X.col(user) = mult * X.col(user) + step * Y.col(item); A.coeffRef(0, user) += step; #else double err = value - model_.predict(user, item); B.coeffRef(0, item) += eta * (err - lambda * B.coeffRef(0, item)); A.coeffRef(0, user) += eta * (err - lambda * A.coeffRef(0, user)); X.col(user) += eta * (err * Y.col(item) - lambda * X.col(user)); Y.col(item) += eta * (err * X.col(user) - lambda * Y.col(item)); #endif return err * err; } void MatrixFactorizationModel::get_factors(int user, int item) { }
s.coeffRef(0, index) *= my_weight; factors.col(index) += embedding.col(0); biases.coeffRef(0, index) += bias.coeff(0, 0); ret.insert(index); }); return ret; } std::set<int> MatrixFactorizationModel::metropolis_hastings_users( size_t my_degree, const DegreesAndModels &models) { return metropolis_hastings(my_degree, models, weights_.users, weights_.user_biases, true); } std::set<int> MatrixFactorizationModel::metropolis_hastings_items( size_t my_degree, const DegreesAndModels &models) { return metropolis_hastings(my_degree, models, weights_.items, weights_.item_biases, false); } std::pair<double, Sparse> MatrixFactorizationModel::combine_neighbors( bool isuser, int index, const DegreesAndModels &models) { struct Entry { Entry(unsigned d, Sparse c, double b) : degree(d), col(c), bias(b) {} unsigned degree; Sparse col; double bias; }; std::vector<Entry> embs; for (const auto &neigh : models) { const MatrixFactorizationModel &nmodel = neigh.model; if (isuser ? nmodel.weights_.has_user(index) : nmodel.weights_.has_item(index)) { embs.emplace_back( neigh.degree, isuser ? nmodel.weights_.users.col(index) : nmodel.weights_.items.col(index), isuser ? nmodel.weights_.user_biases.coeff(0, index) : nmodel.weights_.item_biases.coeff(0, index)); } } Sparse embedd(zero_embedding()); double sum_of_inverses = 0, bias = 0; for (const auto &e : embs) sum_of_inverses += 1.0 / e.degree; for (const auto &e : embs) { double w = (1.0 / (1 + e.degree * (sum_of_inverses - 1.0 / e.degree))); embedd.col(0) += w * e.col; bias += w * e.bias; } return std::make_pair(bias, embedd); } void MatrixFactorizationModel::combine_neighbors_embeddings( bool isuser, const DegreesAndModels &models, std::set<int> &exclude_list) { for (const auto &neigh : models) { sparse_matrix_outer_iterate( isuser ? neigh.model.weights_.users : neigh.model.weights_.items, [&](Sparse::InnerIterator it, int i) { int index = it.col(); if (exclude_list.insert(index).second) { auto combined = combine_neighbors(isuser, index, models); if (isuser) { init_user(index, combined.second); weights_.user_biases.coeffRef(0, index) = combined.first; } else { init_item(index, combined.second); weights_.item_biases.coeffRef(0, index) = combined.first; } } }); } } void MatrixFactorizationModel::combine_neighbors_users( const DegreesAndModels &models, std::set<int> &exclude_list) { combine_neighbors_embeddings(true, models, exclude_list); } void MatrixFactorizationModel::combine_neighbors_items( const DegreesAndModels &models, std::set<int> &exclude_list) { combine_neighbors_embeddings(false, models, exclude_list); } void MatrixFactorizationModel::merge_weighted(size_t my_degree, const DegreesAndModels &models) { std::set<int> users_done = metropolis_hastings_users(my_degree, models), items_done = metropolis_hastings_items(my_degree, models); combine_neighbors_users(models, users_done); combine_neighbors_items(models, items_done); } void MatrixFactorizationModel::find_space(int user, int item, const Sparse &col, double b) { auto &Y = weights_.items, &B = weights_.item_biases; auto &X = weights_.users, &A = weights_.user_biases; if (item >= Y.cols()) { Y.conservativeResize(rank_, item + 1); B.conservativeResize(1, item + 1); if (col.outerSize() > 0) Y.col(item) = col; if (b > 0) B.coeffRef(0, item) = b; } if (user >= X.cols()) { X.conservativeResize(rank_, user + 1); A.conservativeResize(1, user + 1); if (col.outerSize() > 0) X.col(user) = col; if (b > 0) A.coeffRef(0, user) = b; } } size_t MatrixFactorizationModel::estimate_serial_size() const { return sizeof(
random
[ { "content": "class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };\n\n\n\n\n\n/** \\internal Computes the least common multiple of two positive integer A and B\n\n * at compile-time. It implements a naive algorithm testing all multiples of A.\n\n * It thus works better if A>=B.\n\n */\n\ntemplate<int A, int B, int K=1, bool Done = ((A*K)%B)==0>\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 0, "score": 181519.79548809066 }, { "content": "class MatrixFactorizationModel {\n\n public:\n\n typedef std::vector<DPSGDEntry> DegreesAndModels;\n\n\n\n MatrixFactorizationModel() = default;\n\n MatrixFactorizationModel(int rank);\n\n double predict(int user, int item) const;\n\n std::vector<int> recommend_user(int item, int how_many);\n\n std::vector<int> recommend_item(int user, int how_many);\n\n int rank() { return rank_; }\n\n const Sparse& user_features() { return weights_.users; }\n\n const Sparse& item_features() { return weights_.items; }\n\n double rmse(const TripletVector<uint8_t>& testset);\n\n void get_factors(int user, int item);\n\n\n\n void serialize_append(std::vector<uint8_t> &out) const;\n\n size_t deserialize(const std::vector<uint8_t> &data, size_t offset);\n\n void find_space(int user, int item, const Sparse& col = Sparse(),\n\n double b = -1);\n\n\n", "file_path": "src/machine_learning/matrix_factorization.h", "rank": 1, "score": 166525.93255033102 }, { "content": "class MatrixFactorizationModel;\n", "file_path": "src/model_merging/dpsgd_entry.h", "rank": 2, "score": 166520.4204823774 }, { "content": "struct is_convertible<const T,const T&> { enum { value = true }; };\n\n\n\n#endif\n\n\n\n/** \\internal Allows to enable/disable an overload\n\n * according to a compile time condition.\n\n */\n\ntemplate<bool Condition, typename T=void> struct enable_if;\n\n\n\ntemplate<typename T> struct enable_if<true,T>\n\n{ typedef T type; };\n\n\n\n#if defined(EIGEN_GPU_COMPILE_PHASE)\n\n#if !defined(__FLT_EPSILON__)\n\n#define __FLT_EPSILON__ FLT_EPSILON\n\n#define __DBL_EPSILON__ DBL_EPSILON\n\n#endif\n\n\n\nnamespace device {\n\n\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 3, "score": 165563.2227008175 }, { "content": "class BlockImpl<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true,Sparse>\n\n : public internal::sparse_matrix_block_impl<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols>\n\n{\n\npublic:\n\n typedef _StorageIndex StorageIndex;\n\n typedef const SparseMatrix<_Scalar, _Options, _StorageIndex> SparseMatrixType;\n\n typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;\n\n inline BlockImpl(SparseMatrixType& xpr, Index i)\n\n : Base(xpr, i)\n\n {}\n\n\n\n inline BlockImpl(SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n\n : Base(xpr, startRow, startCol, blockRows, blockCols)\n\n {}\n\n\n\n using Base::operator=;\n\nprivate:\n\n template<typename Derived> BlockImpl(const SparseMatrixBase<Derived>& xpr, Index i);\n\n template<typename Derived> BlockImpl(const SparseMatrixBase<Derived>& xpr);\n\n};\n\n\n\n//----------\n\n\n\n/** Generic implementation of sparse Block expression.\n\n * Real-only.\n\n */\n\ntemplate<typename XprType, int BlockRows, int BlockCols, bool InnerPanel>\n", "file_path": "src/Eigen/src/SparseCore/SparseBlock.h", "rank": 4, "score": 161217.16643593376 }, { "content": "struct unary_evaluator<Block<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true>, IteratorBased>\n\n : evaluator<SparseCompressedBase<Block<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true> > >\n\n{\n\n typedef Block<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true> XprType;\n\n typedef evaluator<SparseCompressedBase<XprType> > Base;\n\n explicit unary_evaluator(const XprType &xpr) : Base(xpr) {}\n\n};\n\n\n\n} // end namespace internal\n\n\n\n\n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN_SPARSE_BLOCK_H\n", "file_path": "src/Eigen/src/SparseCore/SparseBlock.h", "rank": 5, "score": 154856.5955950414 }, { "content": "struct bool_constant<true> : true_type {};\n\n\n\ntemplate<>\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 6, "score": 149700.23256709104 }, { "content": "class const_blas_data_mapper : public blas_data_mapper<const Scalar, Index, StorageOrder> {\n\n public:\n\n EIGEN_ALWAYS_INLINE const_blas_data_mapper(const Scalar *data, Index stride) : blas_data_mapper<const Scalar, Index, StorageOrder>(data, stride) {}\n\n\n\n EIGEN_ALWAYS_INLINE const_blas_data_mapper<Scalar, Index, StorageOrder> getSubMapper(Index i, Index j) const {\n\n return const_blas_data_mapper<Scalar, Index, StorageOrder>(&(this->operator()(i, j)), this->m_stride);\n\n }\n\n};\n\n\n\n\n\n/* Helper class to analyze the factors of a Product expression.\n\n * In particular it allows to pop out operator-, scalar multiples,\n\n * and conjugate */\n\ntemplate<typename XprType> struct blas_traits\n\n{\n\n typedef typename traits<XprType>::Scalar Scalar;\n\n typedef const XprType& ExtractType;\n\n typedef XprType _ExtractType;\n\n enum {\n\n IsComplex = NumTraits<Scalar>::IsComplex,\n", "file_path": "src/Eigen/src/Core/util/BlasUtil.h", "rank": 7, "score": 146704.30906553016 }, { "content": "struct is_void : is_same<void, typename remove_const<T>::type> {};\n\n\n\n#if EIGEN_HAS_CXX11\n\ntemplate<> struct is_arithmetic<signed long long> { enum { value = true }; };\n\ntemplate<> struct is_arithmetic<unsigned long long> { enum { value = true }; };\n\nusing std::is_integral;\n\n#else\n\ntemplate<typename T> struct is_integral { enum { value = false }; };\n\ntemplate<> struct is_integral<bool> { enum { value = true }; };\n\ntemplate<> struct is_integral<char> { enum { value = true }; };\n\ntemplate<> struct is_integral<signed char> { enum { value = true }; };\n\ntemplate<> struct is_integral<unsigned char> { enum { value = true }; };\n\ntemplate<> struct is_integral<signed short> { enum { value = true }; };\n\ntemplate<> struct is_integral<unsigned short> { enum { value = true }; };\n\ntemplate<> struct is_integral<signed int> { enum { value = true }; };\n\ntemplate<> struct is_integral<unsigned int> { enum { value = true }; };\n\ntemplate<> struct is_integral<signed long> { enum { value = true }; };\n\ntemplate<> struct is_integral<unsigned long> { enum { value = true }; };\n\n#if EIGEN_COMP_MSVC\n\ntemplate<> struct is_integral<signed __int64> { enum { value = true }; };\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 8, "score": 134841.5823909178 }, { "content": "struct inplace_transpose_selector<MatrixType,true,true> { // PacketSize x PacketSize\n\n static void run(MatrixType& m) {\n\n typedef typename MatrixType::Scalar Scalar;\n\n typedef typename internal::packet_traits<typename MatrixType::Scalar>::type Packet;\n\n const Index PacketSize = internal::packet_traits<Scalar>::size;\n\n const Index Alignment = internal::evaluator<MatrixType>::Alignment;\n\n PacketBlock<Packet> A;\n\n for (Index i=0; i<PacketSize; ++i)\n\n A.packet[i] = m.template packetByOuterInner<Alignment>(i,0);\n\n internal::ptranspose(A);\n\n for (Index i=0; i<PacketSize; ++i)\n\n m.template writePacket<Alignment>(m.rowIndexByOuterInner(i,0), m.colIndexByOuterInner(i,0), A.packet[i]);\n\n }\n\n};\n\n\n\ntemplate<typename MatrixType,bool MatchPacketSize>\n", "file_path": "src/Eigen/src/Core/Transpose.h", "rank": 9, "score": 120145.61848764142 }, { "content": "struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};\n\n\n\nNLOHMANN_JSON_HAS_HELPER(mapped_type);\n\nNLOHMANN_JSON_HAS_HELPER(key_type);\n\nNLOHMANN_JSON_HAS_HELPER(value_type);\n\nNLOHMANN_JSON_HAS_HELPER(iterator);\n\n\n\ntemplate<bool B, class RealType, class CompatibleObjectType>\n", "file_path": "src/json/json.hpp", "rank": 10, "score": 117139.37543565963 }, { "content": "struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleObjectType,\n\n typename = void>\n", "file_path": "src/json/json-17.hpp", "rank": 11, "score": 117139.37543565963 }, { "content": "struct nullary_wrapper<Scalar,NullaryOp,true,true,true>\n\n{\n\n template <typename IndexType>\n\n EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const {\n\n return nullary_wrapper<Scalar,NullaryOp,\n\n has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n\n has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n\n has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().operator()(op,i,j);\n\n }\n\n template <typename IndexType>\n\n EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const {\n\n return nullary_wrapper<Scalar,NullaryOp,\n\n has_nullary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n\n has_unary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value,\n\n has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().operator()(op,i);\n\n }\n\n\n\n template <typename T, typename IndexType>\n\n EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const {\n\n return nullary_wrapper<Scalar,NullaryOp,\n", "file_path": "src/Eigen/src/Core/CoreEvaluators.h", "rank": 12, "score": 116362.23632104407 }, { "content": "struct has_none {int a[1];};\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 13, "score": 115519.14814585852 }, { "content": "struct triangular_solver_unroller<Lhs,Rhs,Mode,LoopIndex,Size,true> {\n\n static void run(const Lhs&, Rhs&) {}\n\n};\n\n\n\ntemplate<typename Lhs, typename Rhs, int Mode>\n", "file_path": "src/Eigen/src/Core/SolveTriangular.h", "rank": 14, "score": 115200.36842311482 }, { "content": "struct has_std_result_type {int a[2];};\n", "file_path": "src/Eigen/src/Core/util/Meta.h", "rank": 15, "score": 113189.59007229327 }, { "content": "extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))\n", "file_path": "src/simd/mmintrin.h", "rank": 16, "score": 108807.23622173438 }, { "content": "struct RangeAccess<AcMd, const T> : RangeAccess<AcMd, T> {\n\n typedef RangeAccess<AcMd, T> Base;\n\n using Base::Base;\n\n};\n\n\n\n} // namespace internal\n\n} // namespace TensorSycl\n\n} // namespace Eigen\n\n\n\n#endif // EIGEN_CXX11_TENSOR_TENSOR_SYCL_STORAGE_MEMORY_H\n", "file_path": "src/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h", "rank": 17, "score": 108704.179495046 }, { "content": "extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))\n", "file_path": "src/simd/mmintrin.h", "rank": 18, "score": 108658.44152511084 }, { "content": "class Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType>\n\n : public internal::SparseRefBase<Ref<const SparseVector<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n\n{\n\n typedef SparseVector<MatScalar,MatOptions,MatIndex> TPlainObjectType;\n\n typedef internal::traits<Ref> Traits;\n\n public:\n\n\n\n typedef internal::SparseRefBase<Ref> Base;\n\n EIGEN_SPARSE_PUBLIC_INTERFACE(Ref)\n\n\n\n template<typename Derived>\n\n inline Ref(const SparseMatrixBase<Derived>& expr) : m_hasCopy(false)\n\n {\n\n construct(expr.derived(), typename Traits::template match<Derived>::type());\n\n }\n\n\n\n inline Ref(const Ref& other) : Base(other), m_hasCopy(false) {\n\n // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy\n\n }\n\n\n", "file_path": "src/Eigen/src/SparseCore/SparseRef.h", "rank": 19, "score": 106922.77734636124 }, { "content": "class Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType>\n\n : public SparseMapBase<Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n\n{\n\n public:\n\n typedef SparseMapBase<Map> Base;\n\n EIGEN_SPARSE_PUBLIC_INTERFACE(Map)\n\n enum { IsRowMajor = Base::IsRowMajor };\n\n\n\n public:\n\n#endif\n\n /** This is the const version of the above constructor.\n\n *\n\n * This constructor is available only if \\c SparseMatrixType is const, e.g.:\n\n * \\code Map<const SparseMatrix<double> > \\endcode\n\n */\n\n inline Map(Index rows, Index cols, Index nnz, const StorageIndex* outerIndexPtr,\n\n const StorageIndex* innerIndexPtr, const Scalar* valuePtr, const StorageIndex* innerNonZerosPtr = 0)\n\n : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr)\n\n {}\n\n\n\n /** Empty destructor */\n\n inline ~Map() {}\n\n};\n\n\n\nnamespace internal {\n\n\n\ntemplate<typename MatScalar, int MatOptions, typename MatIndex, int Options, typename StrideType>\n", "file_path": "src/Eigen/src/SparseCore/SparseMap.h", "rank": 20, "score": 106922.77734636124 }, { "content": "class Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType>\n\n : public internal::SparseRefBase<Ref<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> >\n\n{\n\n typedef SparseMatrix<MatScalar,MatOptions,MatIndex> TPlainObjectType;\n\n typedef internal::traits<Ref> Traits;\n\n public:\n\n\n\n typedef internal::SparseRefBase<Ref> Base;\n\n EIGEN_SPARSE_PUBLIC_INTERFACE(Ref)\n\n\n\n template<typename Derived>\n\n inline Ref(const SparseMatrixBase<Derived>& expr) : m_hasCopy(false)\n\n {\n\n construct(expr.derived(), typename Traits::template match<Derived>::type());\n\n }\n\n\n\n inline Ref(const Ref& other) : Base(other), m_hasCopy(false) {\n\n // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy\n\n }\n\n\n", "file_path": "src/Eigen/src/SparseCore/SparseRef.h", "rank": 21, "score": 106922.77734636124 }, { "content": " static EIGEN_STRONG_INLINE Index blocked(MatrixType& mat)\n", "file_path": "src/Eigen/src/Cholesky/LLT.h", "rank": 22, "score": 106242.98767853303 }, { "content": "EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void MatrixBase<Derived>::stableNormalize()\n", "file_path": "src/Eigen/src/Core/Dot.h", "rank": 23, "score": 106225.2093320402 }, { "content": " static EIGEN_DEVICE_FUNC\n", "file_path": "src/Eigen/src/Eigenvalues/Tridiagonalization.h", "rank": 24, "score": 106225.2093320402 }, { "content": "struct ScalarBinaryOpTraits<void,void,BinaryOp>\n\n{\n\n typedef void ReturnType;\n\n};\n\n\n\n// We require Lhs and Rhs to have \"compatible\" scalar types.\n\n// It is tempting to always allow mixing different types but remember that this is often impossible in the vectorized paths.\n\n// So allowing mixing different types gives very unexpected errors when enabling vectorization, when the user tries to\n\n// add together a float matrix and a double matrix.\n\n#define EIGEN_CHECK_BINARY_COMPATIBILIY(BINOP,LHS,RHS) \\\n\n EIGEN_STATIC_ASSERT((Eigen::internal::has_ReturnType<ScalarBinaryOpTraits<LHS, RHS,BINOP> >::value), \\\n\n YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)\n\n \n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN_XPRHELPER_H\n", "file_path": "src/Eigen/src/Core/util/XprHelper.h", "rank": 25, "score": 106200.68600682903 }, { "content": "inline typename internal::traits<Derived>::Scalar MatrixBase<Derived>::determinant() const\n\n{\n\n eigen_assert(rows() == cols());\n\n typedef typename internal::nested_eval<Derived,Base::RowsAtCompileTime>::type Nested;\n\n return internal::determinant_impl<typename internal::remove_all<Nested>::type>::run(derived());\n", "file_path": "src/Eigen/src/LU/Determinant.h", "rank": 26, "score": 106185.4804657049 }, { "content": " EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}\n", "file_path": "src/Eigen/src/Core/DenseStorage.h", "rank": 27, "score": 105105.70210982021 }, { "content": "EIGEN_DEVICE_FUNC inline Eigen::Index DenseBase<Derived>::count() const\n", "file_path": "src/Eigen/src/Core/BooleanRedux.h", "rank": 28, "score": 105105.70210982021 }, { "content": " static EIGEN_DEVICE_FUNC\n", "file_path": "src/Eigen/src/Core/ProductEvaluators.h", "rank": 29, "score": 105086.8542164767 }, { "content": " EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {\n", "file_path": "src/Eigen/src/Core/DenseStorage.h", "rank": 30, "score": 105086.8542164767 }, { "content": " EIGEN_DEVICE_FUNC\n", "file_path": "src/Eigen/src/Householder/HouseholderSequence.h", "rank": 31, "score": 105053.71322178084 }, { "content": " inline const CompleteOrthogonalDecomposition<PlainObject> completeOrthogonalDecomposition() const;\n", "file_path": "src/Eigen/src/Core/MatrixBase.h", "rank": 32, "score": 105047.49962595612 }, { "content": "EIGEN_DEVICE_FUNC inline bool DenseBase<Derived>::any() const\n\n{\n\n typedef internal::evaluator<Derived> Evaluator;\n\n enum {\n\n unroll = SizeAtCompileTime != Dynamic\n\n && SizeAtCompileTime * (Evaluator::CoeffReadCost + NumTraits<Scalar>::AddCost) <= EIGEN_UNROLLING_LIMIT\n\n };\n\n Evaluator evaluator(derived());\n\n if(unroll)\n\n return internal::any_unroller<Evaluator, unroll ? int(SizeAtCompileTime) : Dynamic, internal::traits<Derived>::RowsAtCompileTime>::run(evaluator);\n\n else\n\n {\n\n for(Index j = 0; j < cols(); ++j)\n\n for(Index i = 0; i < rows(); ++i)\n\n if (evaluator.coeff(i, j)) return true;\n\n return false;\n\n }\n", "file_path": "src/Eigen/src/Core/BooleanRedux.h", "rank": 33, "score": 105047.49962595612 }, { "content": " EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE\n\n const PacketType packet(Index index) const\n\n {\n\n const Index row = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? 0 : index;\n\n const Index col = (RowsAtCompileTime == 1 || MaxRowsAtCompileTime==1) ? index : 0;\n\n return packet<LoadMode,PacketType>(row,col);\n", "file_path": "src/Eigen/src/Core/ProductEvaluators.h", "rank": 34, "score": 105047.49962595612 }, { "content": "inline const Inverse<Derived> MatrixBase<Derived>::inverse() const\n\n{\n\n EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsInteger,THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)\n\n eigen_assert(rows() == cols());\n\n return Inverse<Derived>(derived());\n", "file_path": "src/Eigen/src/LU/InverseImpl.h", "rank": 35, "score": 105047.49962595612 }, { "content": " EIGEN_DEVICE_FUNC Index cols() const {return m_cols;}\n", "file_path": "src/Eigen/src/Core/DenseStorage.h", "rank": 36, "score": 105047.49962595612 }, { "content": " const Index rank = m_cpqr.rank();\n", "file_path": "src/Eigen/src/QR/CompleteOrthogonalDecomposition.h", "rank": 37, "score": 104156.12186127497 }, { "content": "class BlockImpl<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true,Sparse>\n\n : public internal::sparse_matrix_block_impl<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols>\n\n{\n\npublic:\n\n typedef _StorageIndex StorageIndex;\n\n typedef SparseMatrix<_Scalar, _Options, _StorageIndex> SparseMatrixType;\n\n typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;\n\n inline BlockImpl(SparseMatrixType& xpr, Index i)\n\n : Base(xpr, i)\n\n {}\n\n\n\n inline BlockImpl(SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)\n\n : Base(xpr, startRow, startCol, blockRows, blockCols)\n\n {}\n\n\n\n using Base::operator=;\n\n};\n\n\n\ntemplate<typename _Scalar, int _Options, typename _StorageIndex, int BlockRows, int BlockCols>\n", "file_path": "src/Eigen/src/SparseCore/SparseBlock.h", "rank": 38, "score": 104000.21363159583 }, { "content": "EIGEN_DEVICE_FUNC inline void\n", "file_path": "src/Eigen/src/Core/arch/AVX/Complex.h", "rank": 39, "score": 103996.2921142464 }, { "content": "EIGEN_DEVICE_FUNC inline void\n", "file_path": "src/Eigen/src/Core/arch/AVX512/Complex.h", "rank": 40, "score": 103996.2921142464 }, { "content": "EIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet1cd, 2>& kernel) {\n", "file_path": "src/Eigen/src/Core/arch/MSA/Complex.h", "rank": 41, "score": 103996.2921142464 }, { "content": "EIGEN_DEVICE_FUNC inline void\n", "file_path": "src/Eigen/src/Core/arch/SSE/Complex.h", "rank": 42, "score": 103996.2921142464 }, { "content": "EIGEN_DEVICE_FUNC inline void ptranspose(PacketBlock<Packet1cf, 1>& /*kernel*/) {}\n", "file_path": "src/Eigen/src/Core/arch/NEON/Complex.h", "rank": 43, "score": 103996.2921142464 }, { "content": " EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC\n\n PacketType packet(Index idx) const\n\n {\n\n enum { PacketSize = internal::unpacket_traits<PacketType>::size };\n\n typedef Block<const ArgTypeNestedCleaned,\n\n Direction==Vertical ? int(ArgType::RowsAtCompileTime) : int(PacketSize),\n\n Direction==Vertical ? int(PacketSize) : int(ArgType::ColsAtCompileTime),\n\n true /* InnerPanel */> PanelType;\n\n \n\n PanelType panel(m_arg,\n\n Direction==Vertical ? 0 : idx,\n\n Direction==Vertical ? idx : 0,\n\n Direction==Vertical ? m_arg.rows() : Index(PacketSize),\n\n Direction==Vertical ? Index(PacketSize) : m_arg.cols());\n\n\n\n // FIXME\n\n // See bug 1612, currently if PacketSize==1 (i.e. complex<double> with 128bits registers) then the storage-order of panel get reversed\n\n // and methods like packetByOuterInner do not make sense anymore in this context.\n\n // So let's just by pass \"vectorization\" in this case:\n\n if(PacketSize==1)\n\n return internal::pset1<PacketType>(coeff(idx));\n\n \n\n typedef typename internal::redux_evaluator<PanelType> PanelEvaluator;\n\n PanelEvaluator panel_eval(panel);\n\n typedef typename MemberOp::BinaryOp BinaryOp;\n\n PacketType p = internal::packetwise_redux_impl<BinaryOp,PanelEvaluator>::template run<PacketType>(panel_eval,m_functor.binaryFunc(),m_arg.outerSize());\n\n return p;\n", "file_path": "src/Eigen/src/Core/PartialReduxEvaluator.h", "rank": 44, "score": 103957.29608584214 }, { "content": " EIGEN_STRONG_INLINE Packet2cd pmul(const Packet2cd& a, const Packet2cd& b) const\n\n {\n\n return pconj(internal::pmul(a, b));\n", "file_path": "src/Eigen/src/Core/arch/AVX/Complex.h", "rank": 45, "score": 103957.29608584214 }, { "content": " EIGEN_STRONG_INLINE Packet2cf pmul(const Packet2cf& a, const Packet2cf& b) const\n", "file_path": "src/Eigen/src/Core/arch/NEON/Complex.h", "rank": 46, "score": 103957.29608584214 }, { "content": " EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1cd& b) const {\n\n return internal::pmul(pconj(a), b);\n", "file_path": "src/Eigen/src/Core/arch/MSA/Complex.h", "rank": 47, "score": 103957.29608584214 }, { "content": " // Merging models\n\n void merge_average(const MatrixFactorizationModel& w);\n\n void merge_weighted(size_t my_degree, const DegreesAndModels& models);\n\n\n\n void item_merge_column(Sparse& Y, const Sparse& Other);\n\n void user_merge_column(Sparse& X, const Sparse& Other);\n\n\n\n bool init_item(int item, const Sparse& column);\n\n bool init_user(int user, const Sparse& column);\n\n void prep_toshare();\n\n void make_compressed();\n\n size_t estimate_serial_size() const;\n\n\n\n private:\n\n Sparse zero_embedding();\n\n std::set<int> metropolis_hastings(size_t my_degree,\n\n const DegreesAndModels& models,\n\n Sparse& factors, Sparse& biases,\n\n bool isusers);\n\n std::set<int> metropolis_hastings_users(size_t my_degree,\n", "file_path": "src/machine_learning/matrix_factorization.h", "rank": 55, "score": 66.6961087593988 }, { "content": "#include \"mf_weights.h\"\n\n\n\n#include <iostream>\n\n\n\n//------------------------------------------------------------------------------\n\n// MWeights\n\n//------------------------------------------------------------------------------\n\nbool MFWeights::has(int i, const Sparse &m) const {\n\n return i < m.outerSize() && Sparse::InnerIterator(m, i);\n\n // column exists (i.e., not all 0)\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nEmbedding MFWeights::get_factors(int i, const Sparse &factors,\n\n const Sparse &bias) const {\n\n std::vector<double> ret;\n\n const auto &v = factors.col(i);\n\n int n = v.rows();\n\n for (int i = 0; i < n; ++i) ret.emplace_back(v.coeff(i, 0));\n\n return Embedding(bias.coeff(0, i), ret);\n", "file_path": "src/machine_learning/mf_weights.cpp", "rank": 60, "score": 57.92220849350536 }, { "content": " const DegreesAndModels& models);\n\n std::set<int> metropolis_hastings_items(size_t my_degree,\n\n const DegreesAndModels& models);\n\n\n\n std::pair<double, Sparse> combine_neighbors(bool isuser, int index,\n\n const DegreesAndModels& models);\n\n void combine_neighbors_embeddings(bool isuser,\n\n const DegreesAndModels& models,\n\n std::set<int>& exclude_list);\n\n void combine_neighbors_users(const DegreesAndModels& models,\n\n std::set<int>& exclude_list);\n\n void combine_neighbors_items(const DegreesAndModels& models,\n\n std::set<int>& exclude_list);\n\n\n\n int rank_;\n\n MFWeights weights_;\n\n friend class MFSGD;\n\n};\n\n\n", "file_path": "src/machine_learning/matrix_factorization.h", "rank": 62, "score": 54.99399410587737 }, { "content": "}\n\n\n\n//------------------------------------------------------------------------------\n\nbool MFWeights::has_item(int item) const { return has(item, items); }\n\n\n\n//------------------------------------------------------------------------------\n\nbool MFWeights::has_user(int user) const { return has(user, users); }\n\n\n\n//------------------------------------------------------------------------------\n\nEmbedding MFWeights::get_item_factors(int item) const {\n\n return get_factors(item, items, item_biases);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nEmbedding MFWeights::get_user_factors(int user) const {\n\n return get_factors(user, users, user_biases);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\ndouble MFWeights::predict(int user, int item) const {\n", "file_path": "src/machine_learning/mf_weights.cpp", "rank": 64, "score": 48.74051705042084 }, { "content": " for(const auto& x: *node_data_) {\n\n if(train_indices.find(i) != train_indices.end()) {\n\n int user = x.first.first, item = x.first.second;\n\n assert(x.second >= 0 && x.second <= 10);\n\n\n\n model_.find_space(user, item, hyper_.init_column_,\n\n hyper_.init_bias);\n\n total_err += MFSGD::train(user, item, x.second);\n\n ++count;\n\n }\n\n i++;\n\n if(count == num_local_steps)\n\n break;\n\n }\n\n\n\n return std::make_pair(total_err, count);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\ndouble MFSGDDecentralized::test(const TripletVector<uint8_t> &testset) {\n", "file_path": "src/machine_learning/mf_decentralized.cpp", "rank": 67, "score": 46.27923089487722 }, { "content": "#include \"mf_centralized.h\"\n\n\n\n#include <utils/time_probe.h>\n\n\n\n#include <future>\n\n#include <iostream>\n\n#include <mutex>\n\n//------------------------------------------------------------------------------\n\nMatrixFactorizationModel MFSGD::trainX(const Ratings &ratings, uint8_t lowscore,\n\n uint8_t highscore, int matrix_rank,\n\n double learning, double regularization,\n\n int iterations,\n\n const TripletVector<uint8_t> &test) {\n\n double init_bias = lowscore,\n\n init_factor = sqrt(double(highscore - lowscore) / matrix_rank);\n\n HyperMFSGD hyper(matrix_rank, learning, regularization, init_bias,\n\n init_factor);\n\n MFSGDCentralized trainer(ratings, hyper);\n\n trainer.init();\n\n std::cout << \"epoch;trainerr;testerr\\n\";\n", "file_path": "src/machine_learning/mf_centralized.cpp", "rank": 69, "score": 42.34981853768643 }, { "content": " if (user < 0 || item < 0) {\n\n std::cerr << \"Invalid index (\" << user << \",\" << item << \")\"\n\n << std::endl;\n\n abort();\n\n }\n\n assert(users.rows() == items.rows());\n\n return Sparse(users.col(user).transpose() * items.col(item)).coeff(0, 0) +\n\n user_biases.coeff(0, user) + item_biases.coeff(0, item);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nsize_t MFWeights::estimate_serial_size() const {\n\n return serial_size(users) + serial_size(items) + serial_size(user_biases) +\n\n serial_size(item_biases);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nvoid MFWeights::serialize_with_size(const Sparse &matrix,\n\n std::vector<uint8_t> &out) const {\n\n size_t index = out.size();\n", "file_path": "src/machine_learning/mf_weights.cpp", "rank": 70, "score": 41.56572479868186 }, { "content": " for (const auto &t : testset) {\n\n model_.init_user(t.row(), hyper_.init_column_);\n\n model_.init_item(t.col(), hyper_.init_column_); \n\n }\n\n return model_.rmse(testset);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nsize_t MFSGDDecentralized::add_raw_ratings(SharingRatings sr) {\n\n size_t count = 0;\n\n if (sr) {\n\n for(auto it = sr->begin(); it != sr->end(); it++) {\n\n auto res = node_data_->insert(std::make_pair(std::make_pair(it->row(), it->col()), it->value()));\n\n if(res.second)\n\n count++;\n\n }\n\n }\n\n return count;\n\n}\n\n\n", "file_path": "src/machine_learning/mf_decentralized.cpp", "rank": 71, "score": 40.78036660339293 }, { "content": " model_.find_space(user, item, hyper_.init_column_, hyper_.init_bias);\n\n model_.init_item(item, hyper_.init_column_);\n\n model_.init_user(user, hyper_.init_column_);\n\n });\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nstd::pair<double, size_t> MFSGDCentralized::train() {\n\n std::vector<std::future<std::pair<double, size_t>>> results;\n\n sparse_matrix_outer_iterate(ratings_, [&](Ratings::InnerIterator it,\n\n int item) {\n\n auto shared =\n\n std::make_shared<std::packaged_task<std::pair<double, size_t>()>>(\n\n std::bind(&MFSGDCentralized::parallel_train, this, it, item));\n\n results.emplace_back(shared->get_future());\n\n pool_.add_task([shared]() { (*shared)(); });\n\n });\n\n\n\n double total_err = 0;\n\n size_t count = 0;\n", "file_path": "src/machine_learning/mf_centralized.cpp", "rank": 72, "score": 40.17324702762591 }, { "content": " << (sum_train_err / count) << \";\" << (sum_test_err / count) << \";\"\n\n << (sum_items / count) << \";\" << (sum_time / count) << \";\"\n\n << (sumbout / count) << \";\" << (sumbin / count) << \";\" << count\n\n << std::endl;\n\n // std::cout << epoch_stats_.summary() << std::endl;\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nvoid MFCoordinator::run(uint8_t lowscore, uint8_t highscore, int matrix_rank,\n\n double learning, double regularization, int iterations,\n\n bool dpsgd, bool randgraph, unsigned local,\n\n size_t steps_per_iteration, unsigned share_howmany) {\n\n Graph g = randgraph ? random_graph_erdos_renyi(nodes_.size())\n\n : random_graph_small_world(nodes_.size());\n\n make_connected(g);\n\n unsigned edges = establish_relations(g);\n\n //std::cout << (randgraph ? \"Erdos-Renyi\" : \"Small World\")\n\n // << \" Mean degree: \" << double(edges) / nodes_.size() << std::endl;\n\n\n\n double init_bias = lowscore,\n", "file_path": "src/machine_learning/mf_coordinator.cpp", "rank": 73, "score": 38.247336953268125 }, { "content": "\n\n DPSGDModelPtr toshare = std::make_shared<DPSGDShareableModel>(\n\n epoch, modelshare_? trainer_->model(): MatrixFactorizationModel(-2), // -2 for no model sharing\n\n rawdata, neighbours_.size());\n\n\n\n size_t ret = 0;\n\n for (auto &peer : neighbours_) {\n\n ret += communication_->send(userrank_, peer, toshare);\n\n }\n\n return ret;\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nvoid DPSGDMerger::merge(int epoch) {\n\n std::unique_lock<std::mutex> lock(recv_mtx_);\n\n std::vector<DPSGDEntry> models;\n\n size_t count = 0;\n\n for (auto &m : received_models_[epoch]) {\n\n unsigned src = m.first;\n\n ShareableModelPtr shared = m.second;\n", "file_path": "src/model_merging/dpsgd.cpp", "rank": 74, "score": 36.082109268346166 }, { "content": "#include <csv.h>\n\n#include <ratings_parser.h>\n\n#include <stringtools.h>\n\n\n\n#include <Eigen/Sparse>\n\n#include <fstream>\n\n#include <iostream>\n\n#include <set>\n\nusing Eigen::Triplet;\n\nstatic std::set<int> users;\n\n//------------------------------------------------------------------------------\n\nbool csvitem_tovector(TripletVector<uint8_t>& v,\n\n const std::vector<std::string>& item,\n\n std::pair<int, int>& dim, int limit, int filter_divisor,\n\n int filter_modulo) {\n\n try {\n\n Triplet<uint8_t> t(std::stoul(item[0]) - 1, std::stoul(item[1]) - 1,\n\n int(std::stof(item[2]) * 2));\n\n if (limit > 0) {\n\n users.insert(t.row());\n", "file_path": "src/ratings_parser.cpp", "rank": 75, "score": 35.521761237265736 }, { "content": "\n\n return ret;\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nvoid RandomModelWalkMerger::merge(int epoch) {\n\n std::unique_lock<std::mutex> lock(recv_mtx_);\n\n\n\n size_t count = 0;\n\n for (auto &model : received_models_[epoch]) {\n\n unsigned src = model.first;\n\n ShareableModelPtr shared = model.second;\n\n if (shared->model_.rank() != -1) {\n\n if (modelshare_) { // or shared->model_.rank() != -2\n\n trainer_->mutable_model().merge_average(shared->model_);\n\n }\n\n count += trainer_->add_raw_ratings(shared->rawdata);\n\n } // else it's a dummy. Used for synchronization\n\n recvdfrom_.erase(std::make_pair(src, shared->epoch));\n\n }\n\n\n\n received_models_[epoch].clear();\n\n}\n\n\n\n//------------------------------------------------------------------------------\n", "file_path": "src/model_merging/random_model_walk.cpp", "rank": 76, "score": 35.240072342314406 }, { "content": " return MFSGD::trainX(ratings, 2, 10, 20, 0.01, 0.01, 10);\n\n}\n\n*/\n\n\n\n//------------------------------------------------------------------------------\n\nvoid run(Ratings &ratings, TripletVector<uint8_t> &test) {\n\n /*\n\n MatrixFactorizationModel model = train(ratings);\n\n printf(\"RMSE = %lf\\n\", test_model(test, model));\n\n */\n\n ThreadPool tp(std::thread::hardware_concurrency());\n\n std::vector<int> iters = {201};\n\n std::vector<int> ranks = {10};\n\n std::vector<double> lambdas = {0.1};\n\n std::vector<double> etas = {0.005};\n\n std::vector<std::pair<string, std::future<MatrixFactorizationModel>>>\n\n results;\n\n for (int iter : iters) {\n\n for (int rank : ranks) {\n\n for (double eta : etas) {\n", "file_path": "src/local_training.cpp", "rank": 78, "score": 33.70272351225419 }, { "content": " uint8_t *nptr = reinterpret_cast<uint8_t *>(&index);\n\n out.insert(out.end(), nptr, nptr + sizeof(index)); // placeholder\n\n matrix_to_triplets_append(matrix, out);\n\n assert(*reinterpret_cast<size_t *>(&out[index]) == index); // check value\n\n size_t tmp = out.size() - index - sizeof(size_t);\n\n memcpy(&out[index], &tmp, sizeof(tmp)); // fill size in B\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nvoid MFWeights::serialize_append(std::vector<uint8_t> &out) const {\n\n serialize_with_size(users, out);\n\n serialize_with_size(items, out);\n\n serialize_with_size(user_biases, out);\n\n serialize_with_size(item_biases, out);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nsize_t MFWeights::deserialize_matrix(Sparse &matrix,\n\n const std::vector<uint8_t> &data,\n\n size_t offset) {\n", "file_path": "src/machine_learning/mf_weights.cpp", "rank": 79, "score": 32.92676166202218 }, { "content": "#include \"mf_decentralized.h\"\n\n#include <random>\n\n#include <iostream>\n\n//------------------------------------------------------------------------------\n\n// MFSGDDecentralized\n\n//------------------------------------------------------------------------------\n\nMFSGDDecentralized::MFSGDDecentralized(unsigned node_index,\n\n std::shared_ptr<DataStore> node_data,\n\n HyperMFSGD h,\n\n size_t steps_per_iteration)\n\n : MFSGD(h), node_index_(node_index), node_data_(node_data), steps_per_iteration_(steps_per_iteration) {}\n\n//------------------------------------------------------------------------------\n\nMatrixFactorizationModel& MFSGDDecentralized::mutable_model() { return model_; }\n\n\n\n//------------------------------------------------------------------------------\n\nvoid MFSGDDecentralized::make_compressed() {\n\n model_.make_compressed();\n\n}\n\n\n\n//------------------------------------------------------------------------------\n", "file_path": "src/machine_learning/mf_decentralized.cpp", "rank": 80, "score": 32.71588008301312 }, { "content": " for (; it; ++it) {\n\n ulock = get_user_lock(it.row());\n\n if (!ulock) {\n\n std::cerr << \"Error getting user \" << it.row() << \" lock\"\n\n << std::endl;\n\n abort();\n\n } else {\n\n std::lock_guard<std::mutex> lock_user(*ulock);\n\n err += MFSGD::train(it.row(), item, it.value());\n\n ++count;\n\n }\n\n }\n\n }\n\n return std::make_pair(err, count);\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nvoid MFSGDCentralized::init() {\n\n sparse_matrix_iterate(ratings_, [&](Ratings::InnerIterator it) {\n\n int user = it.row(), item = it.col();\n", "file_path": "src/machine_learning/mf_centralized.cpp", "rank": 81, "score": 32.55739474957963 }, { "content": " for (double lambda : lambdas) {\n\n auto shared = std::make_shared<\n\n std::packaged_task<MatrixFactorizationModel()>>(\n\n std::bind(&MFSGD::trainX, ratings, 2, 10, rank, eta,\n\n lambda, iter, test));\n\n std::stringstream ss;\n\n ss << \"r=\" << rank << \" n=\" << eta << \" l=\" << lambda\n\n << \" n=\" << iter;\n\n results.emplace_back(\n\n std::make_pair(ss.str(), shared->get_future()));\n\n tp.add_task([shared]() { (*shared)(); });\n\n }\n\n }\n\n }\n\n }\n\n\n\n bool once = false;\n\n for (auto &r : results) {\n\n r.second.wait();\n\n MatrixFactorizationModel model = r.second.get();\n", "file_path": "src/local_training.cpp", "rank": 82, "score": 32.51357986512679 }, { "content": "#include \"data_splitter.h\"\n\n#include <csv.h>\n\n#include <ratings_parser.h>\n\n#include <set>\n\n\n\nusing std::string;\n\n//------------------------------------------------------------------------------\n\nvoid split_vectors(int from, int to, TripletVector<uint8_t> &src,\n\n TripletVector<uint8_t> &train,\n\n TripletVector<uint8_t> &test) {\n\n float tmult = 0.7;\n\n int count = to - from;\n\n int tcount = tmult * count;\n\n std::set<int> indexes;\n\n while (indexes.size() != tcount) indexes.insert(from + rand() % count);\n\n for (int i = from; i < to; ++i) {\n\n if (indexes.find(i) == indexes.end())\n\n test.push_back(src[i]);\n\n else\n\n train.push_back(src[i]);\n", "file_path": "src/data_splitter.cpp", "rank": 83, "score": 31.49121813181848 }, { "content": " typedef typename ReturnType<internal::member_all>::Type AllReturnType;\n\n typedef typename ReturnType<internal::member_any>::Type AnyReturnType;\n\n typedef PartialReduxExpr<ExpressionType, internal::member_count<Index,Scalar>, Direction> CountReturnType;\n\n typedef typename ReturnType<internal::member_prod>::Type ProdReturnType;\n\n typedef Reverse<const ExpressionType, Direction> ConstReverseReturnType;\n\n typedef Reverse<ExpressionType, Direction> ReverseReturnType;\n\n\n\n template<int p> struct LpNormReturnType {\n\n typedef PartialReduxExpr<ExpressionType, internal::member_lpnorm<p,RealScalar,Scalar>,Direction> Type;\n\n };\n\n\n\n /** \\returns a row (or column) vector expression of the smallest coefficient\n\n * of each column (or row) of the referenced expression.\n\n *\n\n * \\warning the size along the reduction direction must be strictly positive,\n\n * otherwise an assertion is triggered.\n\n * \n\n * \\warning the result is undefined if \\c *this contains NaN.\n\n *\n\n * Example: \\include PartialRedux_minCoeff.cpp\n", "file_path": "src/Eigen/src/Core/VectorwiseOp.h", "rank": 84, "score": 29.99203547866953 }, { "content": "\n\ntemplate<typename MatrixType>\n\ntemplate<typename BDerived,typename XDerived>\n\nbool KLU<MatrixType>::_solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const\n\n{\n\n Index rhsCols = b.cols();\n\n EIGEN_STATIC_ASSERT((XDerived::Flags&RowMajorBit)==0, THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);\n\n eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or analyzePattern()/factorize()\");\n\n\n\n x = b;\n\n int info = klu_solve(m_symbolic, m_numeric, b.rows(), rhsCols, x.const_cast_derived().data(), const_cast<klu_common*>(&m_common), Scalar());\n\n\n\n m_info = info!=0 ? Success : NumericalIssue;\n\n return true;\n\n}\n\n\n\n} // end namespace Eigen\n\n\n\n#endif // EIGEN_KLUSUPPORT_H\n", "file_path": "src/Eigen/src/KLUSupport/KLUSupport.h", "rank": 85, "score": 29.94311282530998 }, { "content": "\n\n if(modelshare_) {\n\n auto &local_model = trainer_->mutable_model();\n\n local_model.merge_weighted(neighbours_.size(), models);\n\n }\n\n\n\n received_models_[epoch].clear();\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\n// DPSGDShareableModel\n\n//------------------------------------------------------------------------------\n\nDPSGDShareableModel::DPSGDShareableModel(int e,\n\n const MatrixFactorizationModel &m,\n\n SharingRatings data, size_t degree)\n\n : ShareableModel(e, DPSGD, m, data), degree_(degree) {\n\n // puts user embedding into its place\n\n //model_.prep_toshare();\n\n // call not needed now, training occurs at original place\n\n}\n", "file_path": "src/model_merging/dpsgd.cpp", "rank": 86, "score": 29.91790691919642 }, { "content": " // If the factorization failed, minor is the column at which it did. On success minor == n.\n\n this->m_info = (m_cholmodFactor->minor == m_cholmodFactor->n ? Success : NumericalIssue);\n\n m_factorizationIsOk = true;\n\n }\n\n\n\n /** Returns a reference to the Cholmod's configuration structure to get a full control over the performed operations.\n\n * See the Cholmod user guide for details. */\n\n cholmod_common& cholmod() { return m_cholmod; }\n\n\n\n #ifndef EIGEN_PARSED_BY_DOXYGEN\n\n /** \\internal */\n\n template<typename Rhs,typename Dest>\n\n void _solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &dest) const\n\n {\n\n eigen_assert(m_factorizationIsOk && \"The decomposition is not in a valid state for solving, you must first call either compute() or symbolic()/numeric()\");\n\n const Index size = m_cholmodFactor->n;\n\n EIGEN_UNUSED_VARIABLE(size);\n\n eigen_assert(size==b.rows());\n\n\n\n // Cholmod needs column-major storage without inner-stride, which corresponds to the default behavior of Ref.\n", "file_path": "src/Eigen/src/CholmodSupport/CholmodSupport.h", "rank": 87, "score": 29.873523821141397 }, { "content": " typedef Replicate<ExpressionType,(isVertical?Dynamic:1),(isHorizontal?Dynamic:1)> ReplicateReturnType;\n\n EIGEN_DEVICE_FUNC\n\n const ReplicateReturnType replicate(Index factor) const;\n\n\n\n /**\n\n * \\return an expression of the replication of each column (or row) of \\c *this\n\n *\n\n * Example: \\include DirectionWise_replicate.cpp\n\n * Output: \\verbinclude DirectionWise_replicate.out\n\n *\n\n * \\sa VectorwiseOp::replicate(Index), DenseBase::replicate(), class Replicate\n\n */\n\n // NOTE implemented here because of sunstudio's compilation errors\n\n // isVertical*Factor+isHorizontal instead of (isVertical?Factor:1) to handle CUDA bug with ternary operator\n\n template<int Factor> const Replicate<ExpressionType,isVertical*Factor+isHorizontal,isHorizontal*Factor+isVertical>\n\n EIGEN_DEVICE_FUNC\n\n replicate(Index factor = Factor) const\n\n {\n\n return Replicate<ExpressionType,(isVertical?Factor:1),(isHorizontal?Factor:1)>\n\n (_expression(),isVertical?factor:1,isHorizontal?factor:1);\n", "file_path": "src/Eigen/src/Core/VectorwiseOp.h", "rank": 88, "score": 29.532755779828108 }, { "content": "//------------------------------------------------------------------------------\n\nvoid MFSGDDecentralized::extract_raw_ratings(unsigned userrank,\n\n unsigned howmany,\n\n TripletVector<uint8_t> &dst) {\n\n std::set<unsigned> sharing_indices;\n\n std::default_random_engine generator;\n\n std::uniform_int_distribution<int> distribution(0, node_data_->size()-1);\n\n \n\n howmany = std::min(howmany, (unsigned) node_data_->size());\n\n\n\n while(sharing_indices.size() < howmany) {\n\n sharing_indices.insert(distribution(generator));\n\n }\n\n\n\n int i = 0, count = 0;\n\n for(const auto& x: *node_data_) {\n\n if(sharing_indices.find(i) != sharing_indices.end()) {\n\n int user = x.first.first, item = x.first.second;\n\n assert(x.second >= 0 && x.second <= 10);\n\n dst.emplace_back(user, item, x.second);\n", "file_path": "src/machine_learning/mf_decentralized.cpp", "rank": 89, "score": 29.21144611463507 }, { "content": " * of each column (or row) of the referenced expression.\n\n *\n\n * Example: \\include PartialRedux_sum.cpp\n\n * Output: \\verbinclude PartialRedux_sum.out\n\n *\n\n * \\sa DenseBase::sum() */\n\n EIGEN_DEVICE_FUNC\n\n const SumReturnType sum() const\n\n { return SumReturnType(_expression()); }\n\n\n\n /** \\returns a row (or column) vector expression of the mean\n\n * of each column (or row) of the referenced expression.\n\n *\n\n * \\sa DenseBase::mean() */\n\n EIGEN_DEVICE_FUNC\n\n const MeanReturnType mean() const\n\n { return sum() / Scalar(Direction==Vertical?m_matrix.rows():m_matrix.cols()); }\n\n\n\n /** \\returns a row (or column) vector expression representing\n\n * whether \\b all coefficients of each respective column (or row) are \\c true.\n", "file_path": "src/Eigen/src/Core/VectorwiseOp.h", "rank": 90, "score": 28.8175308950414 }, { "content": " {\n\n m_factorizationIsOk = true;\n\n m_info = Success;\n\n }\n\n } while(m_info!=Success);\n\n}\n\n\n\ntemplate<typename Scalar, int _UpLo, typename OrderingType>\n\ninline void IncompleteCholesky<Scalar,_UpLo, OrderingType>::updateList(Ref<const VectorIx> colPtr, Ref<VectorIx> rowIdx, Ref<VectorSx> vals, const Index& col, const Index& jk, VectorIx& firstElt, VectorList& listCol)\n\n{\n\n if (jk < colPtr(col+1) )\n\n {\n\n Index p = colPtr(col+1) - jk;\n\n Index minpos; \n\n rowIdx.segment(jk,p).minCoeff(&minpos);\n\n minpos += jk;\n\n if (rowIdx(minpos) != rowIdx(jk))\n\n {\n\n //Swap\n\n std::swap(rowIdx(jk),rowIdx(minpos));\n", "file_path": "src/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h", "rank": 92, "score": 28.332726895576602 }, { "content": " */\n\n Array<StorageIndex,IPARM_SIZE,1>& iparm()\n\n {\n\n return m_iparm; \n\n }\n\n \n\n /** Return a reference to a particular index parameter of the IPARM vector \n\n * \\sa iparm()\n\n */\n\n \n\n int& iparm(int idxparam)\n\n {\n\n return m_iparm(idxparam);\n\n }\n\n \n\n /** Returns a reference to the double vector DPARM of PaStiX parameters \n\n * The statistics related to the different phases of factorization and solve are saved here as well\n\n * \\sa analyzePattern() factorize()\n\n */\n\n Array<double,DPARM_SIZE,1>& dparm()\n", "file_path": "src/Eigen/src/PaStiXSupport/PaStiXSupport.h", "rank": 93, "score": 28.324687013450983 }, { "content": " std::pair<int, int> dim = read_and_split(fname, train, test, cap);\n\n if (dim.first == 0 || dim.second == 0) return false;\n\n\n\n int num_users_per_node = dim.first / num_nodes,\n\n remaining_users = dim.first % num_nodes;\n\n std::vector<int> users_per_node(num_nodes, num_users_per_node);\n\n if (remaining_users > 0) {\n\n do {\n\n users_per_node[remaining_users]++;\n\n } while (--remaining_users);\n\n }\n\n\n\n size_t train_count = 0, test_count = 0; // for later validation\n\n\n\n int i = 0, // counter for train data\n\n j = 0, // counter for test data\n\n node_index = 0;\n\n while (node_index < num_nodes) {\n\n // create training data\n\n auto node_train_data = std::make_shared<DataStore>();\n", "file_path": "src/local_decentralized_training.cpp", "rank": 94, "score": 28.322822374942344 }, { "content": " results.emplace_back(std::make_pair(n.rank(), shared->get_future()));\n\n tp.add_task([shared]() { (*shared)(); });\n\n }\n\n\n\n double sum_train_err = 0, sum_test_err = 0, sum_time = 0, sum_items = 0,\n\n sumbout = 0, sumbin = 0;\n\n unsigned count = 0;\n\n for (auto &kv : results) {\n\n kv.second.wait(); // barrier\n\n auto retval = kv.second.get();\n\n sum_train_err += retval.train_err;\n\n sum_items += retval.train_count;\n\n sum_test_err += retval.test_err;\n\n sum_time += retval.duration;\n\n sumbout += retval.bytes_out;\n\n sumbin += retval.bytes_in;\n\n ++count;\n\n }\n\n epoch_stats_.stop();\n\n std::cout << epoch << \";\" << absolute_timer_.stop() << \";\"\n", "file_path": "src/machine_learning/mf_coordinator.cpp", "rank": 95, "score": 28.26125428387969 }, { "content": " template<bool DoLDLT>\n\n void factorize_preordered(const CholMatrixType& a);\n\n\n\n void analyzePattern(const MatrixType& a, bool doLDLT)\n\n {\n\n eigen_assert(a.rows()==a.cols());\n\n Index size = a.cols();\n\n CholMatrixType tmp(size,size);\n\n ConstCholMatrixPtr pmat;\n\n ordering(a, pmat, tmp);\n\n analyzePattern_preordered(*pmat,doLDLT);\n\n }\n\n void analyzePattern_preordered(const CholMatrixType& a, bool doLDLT);\n\n \n\n void ordering(const MatrixType& a, ConstCholMatrixPtr &pmat, CholMatrixType& ap);\n\n\n\n /** keeps off-diagonal entries; drops diagonal entries */\n\n struct keep_diag {\n\n inline bool operator() (const Index& row, const Index& col, const Scalar&) const\n\n {\n", "file_path": "src/Eigen/src/SparseCholesky/SimplicialCholesky.h", "rank": 96, "score": 28.101176256852927 }, { "content": " * This expression can be assigned to a vector with entries of type \\c bool.\n\n *\n\n * \\sa DenseBase::all() */\n\n EIGEN_DEVICE_FUNC\n\n const AllReturnType all() const\n\n { return AllReturnType(_expression()); }\n\n\n\n /** \\returns a row (or column) vector expression representing\n\n * whether \\b at \\b least one coefficient of each respective column (or row) is \\c true.\n\n * This expression can be assigned to a vector with entries of type \\c bool.\n\n *\n\n * \\sa DenseBase::any() */\n\n EIGEN_DEVICE_FUNC\n\n const AnyReturnType any() const\n\n { return AnyReturnType(_expression()); }\n\n\n\n /** \\returns a row (or column) vector expression representing\n\n * the number of \\c true coefficients of each respective column (or row).\n\n * This expression can be assigned to a vector whose entries have the same type as is used to\n\n * index entries of the original matrix; for dense matrices, this is \\c std::ptrdiff_t .\n", "file_path": "src/Eigen/src/Core/VectorwiseOp.h", "rank": 97, "score": 28.03224608853849 }, { "content": " else dest = y.topRows(cols());\n\n \n\n m_info = Success;\n\n return true;\n\n }\n\n\n\n /** Sets the threshold that is used to determine linearly dependent columns during the factorization.\n\n *\n\n * In practice, if during the factorization the norm of the column that has to be eliminated is below\n\n * this threshold, then the entire column is treated as zero, and it is moved at the end.\n\n */\n\n void setPivotThreshold(const RealScalar& threshold)\n\n {\n\n m_useDefaultThreshold = false;\n\n m_threshold = threshold;\n\n }\n\n \n\n /** \\returns the solution X of \\f$ A X = B \\f$ using the current decomposition of A.\n\n *\n\n * \\sa compute()\n", "file_path": "src/Eigen/src/SparseQR/SparseQR.h", "rank": 98, "score": 27.808195815468125 }, { "content": " if (items[0].revents & ZMQ_POLLIN) {\n\n handle_backend();\n\n }\n\n if (items[1].revents & ZMQ_POLLIN) {\n\n handle_frontend();\n\n }\n\n }\n\n\n\n for (int i = 0; i < thread_count; ++i) {\n\n t[i]->join();\n\n delete t[i];\n\n }\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nvoid AsyncZmq::announce_completion(int rank, char t) {\n\n {\n\n std::unique_lock<std::mutex> lock(oqueue_mtx_);\n\n outqueue_.push(\n\n std::make_pair(rank, pack(t + std::string(\"so long\"), TEXT)));\n", "file_path": "src/communication/async_zmq.cpp", "rank": 99, "score": 27.758600235700627 } ]
C++
vtkMAF/Testing/vtkMAFVolumeResampleTest.cpp
FusionBox2/MAF2
b576955f4f6b954467021f12baedfebcaf79a382
#include <cppunit/config/SourcePrefix.h> #include "vtkMAFVolumeResampleTest.h" #include "vtkMAFSmartPointer.h" #include "vtkMAFVolumeResample.h" #include "vtkDataSet.h" #include "vtkStructuredPoints.h" #include "vtkRectilinearGridReader.h" #include "vtkRectilinearGrid.h" #include "vtkDataArray.h" #include "vtkPointData.h" #include "vtkDataSetWriter.h" using namespace std; void vtkMAFVolumeResampleTest::TestResample() { const char *inFileName = "volumeRG_dim_10_10_10_bounds_1_10_1_10_1_10.vtk"; const char *outVTKFileName= "resampled_volumeRG_dim_10_10_10_bounds_1_10_1_10_1_10.vtk"; TestResampleInternal(inFileName, outVTKFileName ); inFileName = "volumeRG_dim_10_10_10_bounds_m5_5_m5_5_m5_5.vtk"; outVTKFileName= "resampled_volumeRG_dim_10_10_10_bounds_m5_5_m5_5_m5_5.vtk"; TestResampleInternal(inFileName, outVTKFileName ); } void vtkMAFVolumeResampleTest::TestResampleInternal( const char *inFileName , const char *outVTKFileName ) { std::string absPathFilename=MAF_DATA_ROOT; absPathFilename += "/Test_VolumeResample/"; absPathFilename.append(inFileName); vtkRectilinearGridReader *reader = vtkRectilinearGridReader::New(); reader->SetFileName(absPathFilename.c_str()); reader->Update(); double inputDataSpacing[3]; vtkRectilinearGrid *rg = reader->GetOutput(); inputDataSpacing[0] = rg->GetXCoordinates()->GetComponent(1,0)-rg->GetXCoordinates()->GetComponent(0,0); inputDataSpacing[1] = rg->GetYCoordinates()->GetComponent(1,0)-rg->GetYCoordinates()->GetComponent(0,0); inputDataSpacing[2] = rg->GetZCoordinates()->GetComponent(1,0)-rg->GetZCoordinates()->GetComponent(0,0); PrintDouble3(cout, inputDataSpacing, "inputDataSpacing"); double inputDataOrigin[3]; inputDataOrigin[0] = rg->GetXCoordinates()->GetComponent(0,0); inputDataOrigin[1] = rg->GetYCoordinates()->GetComponent(0,0); inputDataOrigin[2] = rg->GetZCoordinates()->GetComponent(0,0); PrintDouble3(cout, inputDataOrigin, "inputDataOrigin"); vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetZeroValue(0); resample->SetInput(reader->GetOutput()); resample->SetVolumeOrigin(inputDataOrigin); PrintDouble3(cout, inputDataOrigin, "inputDataOrigin"); vtkTransform *transform = vtkTransform::New(); transform->Identity(); transform->Update(); double xAxis[3] = {0,0,0}; for (int i = 0; i < 3; i++) { xAxis[i] = transform->GetMatrix()->GetElement(i, 0); } resample->SetVolumeAxisX(xAxis); PrintDouble3(cout, xAxis, "xAxis"); double yAxis[3] = {0,0,0}; for (int i = 0; i < 3; i++) { yAxis[i] = transform->GetMatrix()->GetElement(i, 1); } resample->SetVolumeAxisY(yAxis); PrintDouble3(cout, yAxis, "yAxis"); double sr[2]; rg->GetScalarRange(sr); double w = sr[1] - sr[0]; double l = (sr[1] + sr[0]) * 0.5; resample->SetWindow(w); resample->SetLevel(l); resample->AutoSpacingOff(); vtkStructuredPoints *outputSP = vtkStructuredPoints::New(); outputSP->SetSource(NULL); outputSP->SetOrigin(inputDataOrigin); outputSP->SetSpacing(inputDataSpacing); outputSP->SetScalarType(rg->GetPointData()->GetScalars()->GetDataType()); double resamplingBoxBounds[6]; rg->GetBounds(resamplingBoxBounds); int outputSPExtent[6]; outputSPExtent[0] = 0; outputSPExtent[1] = (resamplingBoxBounds[1] - resamplingBoxBounds[0]) / inputDataSpacing[0]; outputSPExtent[2] = 0; outputSPExtent[3] = (resamplingBoxBounds[3] - resamplingBoxBounds[2]) / inputDataSpacing[1]; outputSPExtent[4] = 0; outputSPExtent[5] = (resamplingBoxBounds[5] - resamplingBoxBounds[4]) / inputDataSpacing[2]; outputSP->SetExtent(outputSPExtent); outputSP->SetUpdateExtent(outputSPExtent); outputSP->Modified(); resample->SetOutput(outputSP); resample->Update(); double inBounds[6] = {0,0,0}; rg->GetBounds(inBounds); double checkBounds[6]; outputSP->GetBounds(checkBounds); CPPUNIT_ASSERT(checkBounds[0]==inBounds[0] && checkBounds[1]==inBounds[1] && checkBounds[2]==inBounds[2]); CPPUNIT_ASSERT(checkBounds[3]==inBounds[3] && checkBounds[4]==inBounds[4] && checkBounds[5]==inBounds[5]); WriteVTKDatasetToFile(outputSP, outVTKFileName); reader->Delete(); resample->Delete(); outputSP->Delete(); transform->Delete(); } void vtkMAFVolumeResampleTest::WriteVTKDatasetToFile( vtkDataSet * outputVolumeVTKData, const char *outputFilename ) { vtkMAFSmartPointer<vtkDataSetWriter> writer; writer->SetInput(outputVolumeVTKData); string fullPathOutputFilename; fullPathOutputFilename.append(MAF_DATA_ROOT); fullPathOutputFilename.append("/Test_VolumeResample/"); fullPathOutputFilename.append(outputFilename); cout << fullPathOutputFilename; writer->SetFileName(fullPathOutputFilename.c_str()); writer->SetFileTypeToASCII(); writer->Write(); } void vtkMAFVolumeResampleTest::PrintDouble6( ostream& os, double array[6], const char *logMessage ) { if (logMessage) os << logMessage << std::endl; os << "xmin, xmax [" << array[0] << " , " << array[1] << "]" << std::endl; os << "ymin, ymax [" << array[2] << " , " << array[3] << "]" << std::endl; os << "zmin, zmax [" << array[4] << " , " << array[5] << "]" << std::endl; os << std::endl; } void vtkMAFVolumeResampleTest::PrintDouble3( ostream& os, double array[3], const char *logMessage ) { if (logMessage) os << logMessage << " [" << array[0] << " , " << array[1] << " , " << array[2] << " ]" << std::endl; os << std::endl; } void vtkMAFVolumeResampleTest::PrintInt3( ostream& os, int array[3], const char *logMessage ) { if (logMessage) os << logMessage << " [" << array[0] << " , " << array[1] << " , " << array[2] << " ]" << std::endl; os << std::endl; } void vtkMAFVolumeResampleTest::TestSetGetVolumeOrigin() { double volumeOrigin[3] = {1,2,3}; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetVolumeOrigin(volumeOrigin); double checkVolumeOrigin[3] = {1,2,3}; resample->GetVolumeOrigin(checkVolumeOrigin); for (int i = 0; i < 3; i++) { CPPUNIT_ASSERT(checkVolumeOrigin[i] == volumeOrigin[i]); } resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetVolumeAxisX() { double volumeAxisX[3] = {0,0,1}; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetVolumeAxisX(volumeAxisX); double checkVolumeAxisX[3] = {0,0,1}; resample->GetVolumeAxisX(checkVolumeAxisX); for (int i = 0; i < 3; i++) { CPPUNIT_ASSERT(checkVolumeAxisX[i] == volumeAxisX[i]); } resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetVolumeAxisY() { double volumeAxisY[3] = {0,0,1}; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetVolumeAxisY(volumeAxisY); double checkVolumeAxisY[3] = {0,0,1}; resample->GetVolumeAxisY(checkVolumeAxisY); for (int i = 0; i < 3; i++) { CPPUNIT_ASSERT(checkVolumeAxisY[i] == volumeAxisY[i]); } resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetWindow() { double window = 10; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetWindow(window); double checkWindow = 10; resample->GetWindow(); CPPUNIT_ASSERT(checkWindow == window); resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetLevel() { double level = 10; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetLevel(level); double checkLevel = 10; resample->GetLevel(); CPPUNIT_ASSERT(checkLevel == level); resample->Delete(); }
#include <cppunit/config/SourcePrefix.h> #include "vtkMAFVolumeResampleTest.h" #include "vtkMAFSmartPointer.h" #include "vtkMAFVolumeResample.h" #include "vtkDataSet.h" #include "vtkStructuredPoints.h" #include "vtkRectilinearGridReader.h" #include "vtkRectilinearGrid.h" #include "vtkDataArray.h" #include "vtkPointData.h" #include "vtkDataSetWriter.h" using namespace std; void vtkMAFVolumeResampleTest::TestResample() { const char *inFileName = "volumeRG_dim_10_10_10_bounds_1_10_1_10_1_10.vtk"; const char *outVTKFileName= "resampled_volumeRG_dim_10_10_10_bounds_1_10_1_10_1_10.vtk"; TestResampleInternal(inFileName, outVTKFileName ); inFileName = "volumeRG_dim_10_10_10_bounds_m5_5_m5_5_m5_5.vtk"; outVTKFileName= "resampled_volumeRG_dim_10_10_10_bounds_m5_5_m5_5_m5_5.vtk"; TestResampleInternal(inFileName, outVTKFileName ); } void vtkMAFVolumeResampleTest::TestResampleInternal( const char *inFileName , const char *outVTKFileName ) { std::string absPathFilename=MAF_DATA_ROOT; absPathFilename += "/Test_VolumeResample/"; absPathFilename.append(inFileName); vtkRectilinearGridReader *reader = vtkRectilinearGridReader::New(); reader->SetFileName(absPathFilename.c_str()); reader->Update(); double inputDataSpacing[3]; vtkRectilinearGrid *rg = reader->GetOutput(); inputDataSpacing[0] = rg->GetXCoordinates()->GetComponent(1,0)-rg->GetXCoordinates()->GetComponent(0,0); inputDataSpacing[1] = rg->GetYCoordinates()->GetComponent(1,0)-rg->GetYCoordinates()->GetComponent(0,0); inputDataSpacing[2] = rg->GetZCoordinates()->GetComponent(1,0)-rg->GetZCoordinates()->GetComponent(0,0); PrintDouble3(cout, inputDataSpacing, "inputDataSpacing"); double inputDataOrigin[3]; inputDataOrigin[0] = rg->GetXCoordinates()->GetComponent(0,0); inputDataOrigin[1] = rg->GetYCoordinates()->GetComponent(0,0); inputDataOrigin[2] = rg->GetZCoordinates()->GetComponent(0,0); PrintDouble3(cout, inputDataOrigin, "inputDataOrigin"); vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetZeroValue(0); resample->SetInput(reader->GetOutput()); resample->SetVolumeOrigin(inputDataOrigin); PrintDouble3(cout, inputDataOrigin, "inputDataOrigin"); vtkTransform *transform = vtkTransform::New(); transform->Identity(); transform->Update(); double xAxis[3] = {0,0,0}; for (int i = 0; i < 3; i++) { xAxis[i] = transform->GetMatrix()->GetElement(i, 0); } resample->SetVolumeAxisX(xAxis); PrintDouble3(cout, xAxis, "xAxis"); double yAxis[3] = {0,0,0}; for (int i = 0; i < 3; i++) { yAxis[i] = transform->GetMatrix()->GetElement(i, 1); } resample->SetVolumeAxisY(yAxis); PrintDouble3(cout, yAxis, "yAxis"); double sr[2]; rg->GetScalarRange(sr); double w = sr[1] - sr[0]; double l = (sr[1] + sr[0]) * 0.5; resample->SetWindow(w); resample->SetLevel(l); resample->AutoSpacingOff(); vtkStructuredPoints *outputSP = vtkStructuredPoints::New(); outputSP->SetSource(NULL); outputSP->SetOrigin(inputDataOrigin); outputSP->SetSpacing(inputDataSpacing); outputSP->SetScalarType(rg->GetPointData()->GetScalars()->GetDataType()); double resamplingBoxBounds[6]; rg->GetBounds(resamplingBoxBounds); int outputSPExtent[6]; outputSPExtent[0] = 0; outputSPExtent[1] = (resamplingBoxBounds[1] - resamplingBoxBounds[0]) / inputDataSpacing[0]; outputSPExtent[2] = 0; outputSPExtent[3] = (resamplingBoxBounds[3] - resamplingBoxBounds[2]) / inputDataSpacing[1]; outputSPExtent[4] = 0; outputSPExtent[5] = (resamplingBoxBounds[5] - resamplingBoxBounds[4]) / inputDataSpacing[2]; outputSP->SetExtent(outputSPExtent); outputSP->SetUpdateExtent(outputSPExtent); outputSP->Modified(); resample->SetOutput(outputSP); resample->Update(); double inBounds[6] = {0,0,0}; rg->GetBounds(inBounds); double checkBounds[6]; outputSP->GetBounds(checkBounds); CPPUNIT_ASSERT(checkBounds[0]==inBounds[0] && checkBounds[1]==inBounds[1] && checkBounds[2]==inBounds[2]); CPPUNIT_ASSERT(checkBounds[3]==inBounds[3] && checkBounds[4]==inBounds[4] && checkBounds[5]==inBounds[5]); WriteVTKDatasetToFile(outputSP, outVTKFileName); reader->Delete(); resample->Delete(); outputSP->Delete(); transform->Delete(); } void vtkMAFVolumeResampleTest::WriteVTKDatasetToFile( vtkDataSet * outputVolumeVTKData, const char *outputFilename ) { vtkMAFSmartPointer<vtkDataSetWriter> writer; writer->SetInput(outputVolumeVTKData); string fullPathOutputFilename; fullPathOutputFilename.append(MAF_DATA_ROOT); fullPathOutputFilename.append("/Test_VolumeResample/"); fullPathOutputFilename.append(outputFilename); cout << fullPathOutputFilename; writer->SetFileName(fullPathOutputFilename.c_str()); writer->SetFileTypeToASCII(); writer->Write(); } void vtkMAFVolumeResampleTest::PrintDouble6( ostream& os, double array[6], const char *logMessage ) { if (logMessage) os << logMessage << std::endl; os << "xmin, xmax [" << array[0] << " , " << array[1] << "]" << std::endl; os << "ymin, ymax [" << array[2] << " , " << array[3] << "]" << std::endl; os << "zmin, zmax [" << array[4] << " , " << array[5] << "]" << std::endl; os << std::endl; } void vtkMAFVolumeResampleTest::PrintDouble3( ostream& os, double array[3], const char *logMessage ) { if (logMessage) os << logMessage << " [" << array[0] << " , " << array[1] << " , " << array[2] << " ]" << std::endl; os << std::endl; } void vtkMAFVolumeResampleTest::PrintInt3( ostream& os, int array[3], const char *logMessage ) { if (logMessage) os << logMessage << " [" << array[0] << " , " << array[1] << " , " << array[2] << " ]" << std::endl; os << std::endl; } void vtkMAFVolumeResampleTest::TestSetGetVolumeOrigin() { double volumeOrigin[3] = {1,2,3}; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetVolumeOrigin(volumeOrigin); double checkVolum
== volumeOrigin[i]); } resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetVolumeAxisX() { double volumeAxisX[3] = {0,0,1}; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetVolumeAxisX(volumeAxisX); double checkVolumeAxisX[3] = {0,0,1}; resample->GetVolumeAxisX(checkVolumeAxisX); for (int i = 0; i < 3; i++) { CPPUNIT_ASSERT(checkVolumeAxisX[i] == volumeAxisX[i]); } resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetVolumeAxisY() { double volumeAxisY[3] = {0,0,1}; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetVolumeAxisY(volumeAxisY); double checkVolumeAxisY[3] = {0,0,1}; resample->GetVolumeAxisY(checkVolumeAxisY); for (int i = 0; i < 3; i++) { CPPUNIT_ASSERT(checkVolumeAxisY[i] == volumeAxisY[i]); } resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetWindow() { double window = 10; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetWindow(window); double checkWindow = 10; resample->GetWindow(); CPPUNIT_ASSERT(checkWindow == window); resample->Delete(); } void vtkMAFVolumeResampleTest::TestSetGetLevel() { double level = 10; vtkMAFVolumeResample *resample = vtkMAFVolumeResample::New(); resample->SetLevel(level); double checkLevel = 10; resample->GetLevel(); CPPUNIT_ASSERT(checkLevel == level); resample->Delete(); }
eOrigin[3] = {1,2,3}; resample->GetVolumeOrigin(checkVolumeOrigin); for (int i = 0; i < 3; i++) { CPPUNIT_ASSERT(checkVolumeOrigin[i]
function_block-random_span
[ { "content": "class vtkTransform;\n", "file_path": "Interaction/mafCameraTransform.h", "rank": 0, "score": 127481.85520661279 }, { "content": "class vtkTransform;\n", "file_path": "Testing/Base/mafTransformFrameTest.h", "rank": 1, "score": 124946.89338589914 }, { "content": "class vtkTransform;\n", "file_path": "Testing/Base/vtkMAFToLinearTransformTest.h", "rank": 2, "score": 123742.2093744945 }, { "content": "class vtkTransform;\n", "file_path": "Interaction/mafGizmoHandle.h", "rank": 3, "score": 113059.86267520633 }, { "content": "class vtkTransform;\n", "file_path": "Interaction/mafAvatar3D.h", "rank": 4, "score": 113059.86267520633 }, { "content": " OVERLAPPED osReader; /* overlapped structure for reading */\n", "file_path": "Interaction/Drivers/serial.h", "rank": 5, "score": 112943.25534293203 }, { "content": "class vtkTransform;\n\n\n\n/** Basic gizmo component used to perform constrained translation on one axis.\n\n \n\n @sa mafGizmoTranslate \n\n*/\n", "file_path": "Interaction/mafGizmoTranslateAxis.h", "rank": 6, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n", "file_path": "Interaction/mafGizmoRotateFan.h", "rank": 7, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n", "file_path": "Interaction/mafGizmoTranslatePlane.h", "rank": 8, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n\n\n\n/** Gizmo component used to perform isotropic scaling.\n\n \n\n @sa mafGizmoScale\n\n*/\n", "file_path": "Interaction/mafGizmoScaleIsotropic.h", "rank": 9, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n", "file_path": "VME/mafVMERefSys.h", "rank": 10, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n", "file_path": "Interaction/mafGizmoBoundingBox.h", "rank": 11, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n", "file_path": "Interaction/mafGizmoAutoscaleHelper.h", "rank": 12, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n\n\n\n/** Basic gizmo component used to perform constrained scaling along one axis.\n\n \n\n @sa mafGizmoScale\n\n*/\n", "file_path": "Interaction/mafGizmoScaleAxis.h", "rank": 13, "score": 111390.35053719708 }, { "content": "class vtkTransform;\n\n\n\ntemplate class MAF_EXPORT mafAutoPointer<mafMatrix>;\n\n\n\n//----------------------------------------------------------------------------\n\n/** Basic gizmo component used to perform constrained rotation around an axis.\n\n \n\n @sa mafGizmoRotate\n\n*/\n", "file_path": "Interaction/mafGizmoRotateCircle.h", "rank": 14, "score": 111390.35053719708 }, { "content": "//class vtkImageData;\n\nclass vtkRectilinearGrid;\n\n\n\n\n", "file_path": "vtkMAF/vtkMAFVolumeResample.h", "rank": 15, "score": 108454.3476626176 }, { "content": "class vtkTransform;\n", "file_path": "vtkMAF/vtkMAFAnnotatedCubeActor.h", "rank": 16, "score": 108311.02057408824 }, { "content": "class vtkTransform;\n", "file_path": "vtkMAF/vtkMAFGlobalAxesHeadActor.h", "rank": 17, "score": 106888.07777783138 }, { "content": "class vtkTransform;\n", "file_path": "vtkMAF/vtkMAFRayCast3DPicker.h", "rank": 18, "score": 106888.07777783138 }, { "content": " function is of type void *, and returns NULL.\n\n Otherwise the type is void which is correct for WIN32\n\n and SPROC\n\n*/ \n\n#ifdef CMAKE_USE_SPROC_INIT\n\ntypedef int mmuThreadProcessIDType;\n\n#endif\n\n\n\n\n\n#ifdef CMAKE_USE_PTHREADS_INIT\n\ntypedef void *(*mmuInternalThreadFunctionType)(void *);\n\ntypedef pthread_t mmuThreadProcessIDType;\n\n#endif\n\n\n\n#ifdef CMAKE_USE_WIN32_THREADS_INIT\n\ntypedef LPTHREAD_START_ROUTINE mmuInternalThreadFunctionType;\n\ntypedef HANDLE mmuThreadProcessIDType;\n\n#endif\n\n\n\n#if !defined(CMAKE_USE_PTHREADS_INIT) && !defined(CMAKE_USE_WIN32_THREADS_INIT)\n\ntypedef void (*mmuInternalThreadFunctionType)(void *);\n\ntypedef int mmuThreadProcessIDType;\n\n#endif\n\n\n\n\n", "file_path": "Base/mafMultiThreader.h", "rank": 19, "score": 89890.90225688777 }, { "content": "class ListOfPolyline2D : public std::vector<Polyline2D*> \n\n{\n\npublic:\n\n /** Clear the list of polylines. */\n\n void clear();\n\n /** check if point is inside the contour */\n\n bool IsInside(int x, int y, int polylineLengthThreshold);\n\n /** retrieve contour polyline */\n\n Polyline2D *FindContour(int x, int y, int polylineLengthThreshold, int distance = 1);\n\n};\n\n\n\n\n\n\n\n\n\n\n\n#endif\n", "file_path": "vtkMAF/vtkMAFContourVolumeMapper.h", "rank": 20, "score": 85503.3082038713 }, { "content": " class ListOfPolyline2DGPU : public std::vector<Polyline2DGPU*> \n\n {\n\n public:\n\n /** Clear the list of polylines. */\n\n void clear();\n\n /** check if point is inside the contour */\n\n bool IsInside(int x, int y, int polylineLengthThreshold);\n\n /** retrieve contour polyline */\n\n Polyline2DGPU *FindContour(int x, int y, int polylineLengthThreshold, int distance = 1);\n\n };\n\n//}//end baoquan space\n\n#endif\n", "file_path": "vtkMAF/vtkMAFContourVolumeMapperGPU.h", "rank": 21, "score": 84430.9551618731 }, { "content": "//----------------------------------------------------------------------------\n\n// constants\n\n//----------------------------------------------------------------------------\n\nenum MAF_TAG_IDS {MAF_MISSING_TAG=0,MAF_NUMERIC_TAG,MAF_STRING_TAG};\n\n\n\n//----------------------------------------------------------------------------\n\n// forward declarations\n\n//----------------------------------------------------------------------------\n\n\n\n/** an utility class for storing <key-type-array of values> information.\n\n an utility class for storing <key-type-array of values> information.\n\n @sa mafTagArray\n\n*/\n", "file_path": "Core/mafTagItem.h", "rank": 22, "score": 84403.6615299609 }, { "content": "class ListOfPolyline2DAdv : public std::vector<Polyline2DAdv*> \n\n{\n\npublic:\n\n /** Clear the list of polylines. */\n\n void clear();\n\n /** check if point is inside the contour */\n\n bool IsInside(int x, int y, int polylineLengthThreshold);\n\n /** retrieve contour polyline */\n\n Polyline2DAdv *FindContour(int x, int y, int polylineLengthThreshold, int distance = 1);\n\n};\n\n\n\n#endif\n", "file_path": "vtkMAF/vtkMAFContourVolumeMapperAdv.h", "rank": 23, "score": 82421.49761411735 }, { "content": "class mafCString : public mafString\n\n{\n\npublic:\n\n /** constructor. */\n\n mafCString(const char *str) {Set(str);}\n\n};\n\n\n\n#endif\n\n\n", "file_path": "Base/mafString.h", "rank": 24, "score": 79131.96552993653 }, { "content": "class MAF_EXPORT mafTransform : public mafTransformBase\n\n{\n\n public:\n\n //------------------------------------------------------------------------------\n\n // Events\n\n //------------------------------------------------------------------------------\n\n //MAF_ID_DEC(UpdateEvent); // Event rised by updates of the internal matrix\n\n\t\n\n mafTransform();\n\n ~mafTransform();\n\n\n\n //----------------------------------------------------------------------------\n\n // Ref Sys Type:\n\n //----------------------------------------------------------------------------\n\n enum \n\n {\n\n CUSTOM = 0, ///< auxiliar ref sys \n\n GLOBAL, \n\n PARENT,\n\n LOCAL, ///< the local ref sys of the VME\n", "file_path": "Base/mafTransform.h", "rank": 25, "score": 77084.77481879703 }, { "content": "class MAF_EXPORT mafCameraTransform:public mafTransformBase\n\n{\n\npublic:\n\n mafCameraTransform();\n\n virtual ~mafCameraTransform();\n\n\n\n mafTypeMacro(mafCameraTransform,mafTransformBase);\n\n \n\n enum AutoPositionModalities\n\n {\n\n ATTACH_TO_FOCAL_POINT, ///< Follow the focal point\n\n ATTACH_TO_CAMERA, ///< Follow the camera position\n\n ATTACH_TO_CLIPPING_PLANE ///< Follow the neat clipping plane\n\n };\n\n\n\n enum AutoFittingModalities\n\n {\n\n MAX_SCALE, ///< Select the maximum scale among X/Y (i.e. fit the minimum size)\n\n MIN_SCALE, ///< Select the minimum scale X/Y (i.e. fit the maximum size)\n\n FIT_X, ///< Always fit the X axis\n", "file_path": "Interaction/mafCameraTransform.h", "rank": 26, "score": 75303.09257940431 }, { "content": "class MAF_EXPORT mafTransformFrame : public mafTransformBase\n\n{\n\n public:\n\n mafTransformFrame();\n\n ~mafTransformFrame();\n\n\t\n\n mafTypeMacro(mafTransformFrame,mafTransformBase);\n\n\n\n //virtual void Print(std::ostream& os, const int tabs=0) const;\n\n\n\n /** set the matrix to be transformed */\n\n void SetInput(mafTransformBase *frame);\n\n void SetInput(mafMatrix *frame);\n\n mafTransformBase *GetInput() {return m_Input;}\n\n\n\n /**\n\n Set/Get the input reference system, i.e. the reference system of the \n\n input matrix.*/\n\n void SetInputFrame(mafMatrix *frame);\n\n void SetInputFrame(mafTransformBase *frame);\n", "file_path": "Base/mafTransformFrame.h", "rank": 27, "score": 75303.09257940431 }, { "content": "class vtkLinearTransform;\n", "file_path": "Base/mafTransformBase.h", "rank": 28, "score": 74191.18662171692 }, { "content": "class MAF_EXPORT vtkMAFToLinearTransform : public vtkLinearTransform\n\n{\n\n public:\n\n static vtkMAFToLinearTransform *New();\n\n vtkTypeRevisionMacro(vtkMAFToLinearTransform,vtkLinearTransform);\n\n void PrintSelf (ostream& os, vtkIndent indent);\n\n \n\n /** \n\n Set the input matrix. Any modifications to the MAF matrix will be\n\n reflected in the VTK transformation. This also set InputTransform to NULL.*/\n\n virtual void SetInputMatrix(mafMatrix *);\n\n\n\n /** return connected matrix if exists. */\n\n mafMatrix *GetInputMatrix() {return m_InputMatrix;}\n\n \n\n /** \n\n Set the input transform. Any modifications to the MAF transform will be\n\n reflected in the VTK transformation. This also set InputMatrix to NULL.*/\n\n virtual void SetInputTransform(mafTransformBase *);\n\n\n", "file_path": "Base/vtkMAFToLinearTransform.h", "rank": 29, "score": 73601.91076365368 }, { "content": "class vtkMAFToLinearTransform;\n\n\n\n#ifdef MAF_EXPORTS\n\ntemplate class MAF_EXPORT mafAutoPointer<mafMatrix>;\n\n#endif\n\n\n\n/** Superclass for Homogeneous transformations.\n\n mafTransformBase is the superclass for MAF geometric, and currently homogeneous\n\n only, transformations. The idea behind a mafTransformBase is the Update() method\n\n should always be called to update the output, which is a mafMatrix internally stored.\n\n @sa mafTransform\n\n @todo\n\n - change SetTimeStamp to apply a Modified(), than change matrix pipes to not call it!!!\n\n - implement issuing of a MATRIX_UPDATED event: add an event source member\n\n */\n", "file_path": "Base/mafTransformBase.h", "rank": 30, "score": 72945.35301645698 }, { "content": "class mafTransformBase;\n", "file_path": "Base/vtkMAFToLinearTransform.h", "rank": 31, "score": 72945.35301645698 }, { "content": "class MAF_EXPORT mafOpMAFTransform : public mafOpTransformInterface\n\n{\n\npublic:\n\n mafOpMAFTransform(const wxString &label = \"Transform \\tCtrl+T\");\n\n ~mafOpMAFTransform(); \n\n virtual void OnEvent(mafEventBase *maf_event);\n\n \n\n mafTypeMacro(mafOpMAFTransform, mafOp);\n\n\n\n mafOp* Copy();\n\n\n\n /** Return true for the acceptable vme type. */\n\n bool Accept(mafNode* vme);\n\n\n\n /** Builds operation's interface. */\n\n void OpRun();\n\n \n\n /** Execute the operation. */\n\n void OpDo();\n\n \n", "file_path": "Operations/mafOpMAFTransform.h", "rank": 32, "score": 72779.82162454759 }, { "content": "//support object\n\nclass mafTransformBaseDerivedClass : public mafTransformBase\n\n{\n\n\tmafTypeMacro(mafTransformBaseDerivedClass,mafTransformBase);\n\n\tmafTransformBaseDerivedClass(){;};\n\n\t\n\n\tvirtual void SetMatrix(const mafMatrix &input) {*m_Matrix=input;SetTimeStamp(input.GetTimeStamp());Modified();}\n\n\n\n\t~mafTransformBaseDerivedClass(){;};\n\n protected:\n\n\t\tvirtual void InternalUpdate(){;};\n\n};\n\n\n\n//----------------------------------------------------------------------------\n\nmafCxxTypeMacro(mafTransformBaseDerivedClass)\n\n//----------------------------------------------------------------------------\n\n\n\n//----------------------------------------------------------------------------\n\nvoid mafTransformBaseTest::TestFixture()\n\n//----------------------------------------------------------------------------\n\n{\n", "file_path": "Testing/Base/mafTransformBaseTest.cpp", "rank": 33, "score": 72779.82162454759 }, { "content": "class MAF_EXPORT mafGUITransformMouse : public mafGUITransformInterface\n\n{\n\npublic:\n\n mafGUITransformMouse(mafVME *input, mafObserver *listener = NULL, bool testMode = false);\n\n\t~mafGUITransformMouse(); \n\n\n\n // constraints enum\n\n enum TRANSFORM_MOUSE_WIDGET_ID\n\n {\n\n X_AXIS = 0,\n\n Y_AXIS, \n\n Z_AXIS,\n\n VIEW_PLANE, \n\n NORMAL_VIEW_PLANE,\n\n XY_PLANE, \n\n XZ_PLANE, \n\n YZ_PLANE,\n\n SURFACE_SNAP,\n\n NORMAL_SURFACE,\n\n };\n", "file_path": "Interaction/mafGUITransformMouse.h", "rank": 34, "score": 72779.82162454759 }, { "content": "class mafXMLString;\n\n\n", "file_path": "Testing/IO/mafXMLStringTest.h", "rank": 35, "score": 71903.45921210258 }, { "content": "class MAF_EXPORT mafXMLString\n\n{\n\npublic:\n\n\tmafXMLString() : m_WStr(0L), m_CStr(NULL) { };\n\n\tmafXMLString(const char *str);\n\n\tmafXMLString(XMLCh *wstr);\n\n\tmafXMLString(const XMLCh *wstr);\n\n\tmafXMLString(const mafXMLString &copy);\n\n\t~mafXMLString();\n\n\tbool Append(const XMLCh *tail);\n\n\tbool Erase(const XMLCh *head, const XMLCh *tail);\n\n\tconst XMLCh* Begin() const;\n\n\tconst XMLCh* End() const;\n\n\tint Size() const;\n\n const char *GetCStr();\n\n\tXMLCh & operator [] (const int i);\n\n\tconst XMLCh operator [] (const int i) const;\n\n\toperator const XMLCh * () const { return m_WStr; };\n\n operator const char * () {return GetCStr();}\n\nprotected:\n\n XMLCh *m_WStr;\n\n char *m_CStr;\n\n};\n\n\n\n#endif\n", "file_path": "IO/mafXMLString.h", "rank": 36, "score": 71903.45921210258 }, { "content": "//----------------------------------------------------------------------------\n\n// widget id's\n\n//----------------------------------------------------------------------------\n\nenum MAF_TRANSFORM_ID\n\n{\n\n\tID_SHOW_GIZMO = MINID,\n\n ID_CHOOSE_GIZMO_COMBO,\n\n ID_ROTATION_STEP,\n\n ID_TRANSLATION_STEP,\n\n ID_ENABLE_STEP,\n\n ID_ROT_SNAP,\n\n ID_RESET,\n\n ID_AUX_REF_SYS,\n\n ID_ENABLE_SCALING,\n\n ID_ROLLOUT_TEXT_ENTRIES,\n\n ID_ROLLOUT_GIZMO_TRANSLATE,\n\n ID_ROLLOUT_GIZMO_ROTATE,\n\n ID_ROLLOUT_GIZMO_SCALE,\n\n ID_ROLLOUT_SAVE_POS\n\n};\n\n\n\n//----------------------------------------------------------------------------\n\nmafCxxTypeMacro(mafOpMAFTransform);\n", "file_path": "Operations/mafOpMAFTransform.cpp", "rank": 37, "score": 71740.66900505233 }, { "content": "class mafGUITransformMouse;\n", "file_path": "Operations/mafOpTransformInterface.h", "rank": 38, "score": 71740.66900505233 }, { "content": "class mafGUITransformMouse;\n", "file_path": "Operations/mafOpMAFTransform.h", "rank": 39, "score": 71740.66900505233 }, { "content": "class mafGUITransformInterfaceDummy : public mafGUITransformInterface\n\n{\n\npublic:\n\n mafGUITransformInterfaceDummy():mafGUITransformInterface(){};\n\n ~mafGUITransformInterfaceDummy(){};\n\n\n\n /*virtual*/ void EnableWidgets(bool enable){};\n\nprotected:\n\nprivate:\n\n};\n\n\n\n//----------------------------------------------------------------------------\n\nvoid mafGUITransformInterfaceTest::TestFixture()\n\n//----------------------------------------------------------------------------\n\n{\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid mafGUITransformInterfaceTest::setUp()\n\n//----------------------------------------------------------------------------\n\n{\n", "file_path": "Testing/Interaction/mafGUITransformInterfaceTest.cpp", "rank": 40, "score": 71189.53296860619 }, { "content": "class MAF_EXPORT mafGUITransformTextEntries : public mafGUITransformInterface\n\n{\n\npublic:\n\n\n\n mafGUITransformTextEntries(mafVME *input, mafObserver *listener = NULL, bool enableScaling = true, bool testMode = false);\n\n\t~mafGUITransformTextEntries(); \n\n\n\n void OnEvent(mafEventBase *maf_event);\n\n\n\n /** Enable-Disable the GUI's widgets */\n\n\tvoid EnableWidgets(bool enable);\n\n\n\n //----------------------------------------------------------------------------\n\n //gui constants: \n\n //----------------------------------------------------------------------------\n\n\n\n // this constants must be visible from the owner object \n\n enum TRANSFORMTEXTENTRIES_WIDGET_ID\n\n {\n\n ID_TRANSLATE_X = MINID,\n", "file_path": "Interaction/mafGUITransformTextEntries.h", "rank": 41, "score": 71189.53296860619 }, { "content": "//----------------------------------------------------------------------------\n\n// Constants :\n\n//----------------------------------------------------------------------------\n\nenum VOLUME_RESAMPLE_WIDGET_ID\n\n{\n\n\tID_FIRST = MINID,\t\n\n\tID_VOLUME_DIR_X,\n\n\tID_VOLUME_DIR_Y,\n\n\tID_VOLUME_DIR_Z,\n\n ID_VOLUME_ORIGIN,\n\n ID_VOLUME_ORIENTATION,\n\n ID_VOLUME_4DBOUNDS,\n\n ID_VOLUME_VMEBOUNDS,\n\n ID_VOLUME_VMELOCALBOUNDS,\n\n ID_VOLUME_SPACING,\n\n ID_VOLUME_CURRENT_SLICE,\n\n ID_VOLUME_AUTOSPACING,\n\n ID_VOLUME_ZERO_VALUE\n\n};\n\n\n", "file_path": "Operations/mafOpVolumeResample.cpp", "rank": 42, "score": 70745.96697888004 }, { "content": "class MAF_EXPORT mafString : public mafBase\n\n{\n\npublic:\n\n \n\n /**\n\n This static method returns the size of c-string. If the string is empty,\n\n it returns 0. It can handle null pointers.*/\n\n static mafID Length(const char* str);\n\n \n\n /** This method returns the size of this string. */\n\n const mafID Length() const;\n\n\n\n /** static method to copy c-string to the another c-string.*/\n\n static void Copy(char* dest, const char* src);\n\n \n\n /** Copy a c-string to this string.*/\n\n void Copy(const char* src);\n\n\n\n /** Copy N characters of another string to this string.*/\n\n void NCopy(const char* src,int n);\n", "file_path": "Base/mafString.h", "rank": 43, "score": 70735.2743918447 }, { "content": "class mafGUITransformTextEntries;\n", "file_path": "Operations/mafOpMAFTransform.h", "rank": 44, "score": 70575.128967825 }, { "content": "class mafStringTest : public CPPUNIT_NS::TestFixture\n\n{\n\n CPPUNIT_TEST_SUITE( mafStringTest );\n\n CPPUNIT_TEST( Test );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n protected:\n\n /** Test multiple string features with a single test */\n\n void Test();\n\n};\n\n\n\n\n\nint\n\nmain( int argc, char* argv[] )\n\n{\n\n // Create the event manager and test controller\n\n CPPUNIT_NS::TestResult controller;\n\n\n\n // Add a listener that colllects test result\n\n CPPUNIT_NS::TestResultCollector result;\n", "file_path": "Testing/Base/mafStringTest.h", "rank": 45, "score": 67447.88344584563 }, { "content": "class mafTransformTest : public CPPUNIT_NS::TestFixture\n\n{\n\n public: \n\n\n\n // CPPUNIT fixture: executed before each test\n\n void setUp();\n\n\n\n // CPPUNIT fixture: executed after each test\n\n void tearDown();\n\n\n\n // CPPUNIT test suite\n\n CPPUNIT_TEST_SUITE( mafTransformTest );\n\n CPPUNIT_TEST( TestFixture ); // just to test that the fixture has no leaks\n\n CPPUNIT_TEST( TestTranslateRotateScale );\n\n CPPUNIT_TEST( TestPolarDecomposition );// leaked! Leak source is mafMatrix\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n private:\n\n \n\n void TestFixture();\n", "file_path": "Testing/Base/mafTransformTest.h", "rank": 46, "score": 67295.18071037832 }, { "content": "class MAF_EXPORT mafTransformBase : public mafReferenceCounted\n\n{\n\npublic:\n\n mafTransformBase();\n\n ~mafTransformBase();\n\n\n\n /** copy constructor */\n\n mafTransformBase(const mafTransformBase&);\n\n\n\n mafAbstractTypeMacro(mafTransformBase,mafReferenceCounted);\n\n virtual void Print(std::ostream& os, const int indent=0) const;\n\n\n\n /** update and return internal transform matrix */\n\n virtual const mafMatrix &GetMatrix() {Update();return *m_Matrix;}\n\n\n\n /** \n\n return pointer to internal matrix (after updating).\n\n BEWARE: do not change the matrix directly. */\n\n mafMatrix *GetMatrixPointer() {Update(); return m_Matrix;}\n\n\n", "file_path": "Base/mafTransformBase.h", "rank": 47, "score": 67295.18071037832 }, { "content": " const bool operator!=(const char *src) const;\n\n const bool operator<(const char *a) const;\n\n const bool operator>(const char *a) const;\n\n const bool operator<=(const char *a) const;\n\n const bool operator>=(const char *a) const;\n\n\n\n //friend MAF_EXPORT std::ostream& operator<<(std::ostream& os, const mafString& s);\n\n //friend MAF_EXPORT std::istream& operator>>(std::istream& is, mafString& s);\n\n\n\n mafString &operator<<(const char *a) {return Append(a);};\n\n\n\n void operator<<(std::ostream &os);\n\n void operator>>(std::istream &os);\n\n\n\n mafString& operator<<( int d);\n\n mafString& operator<<( long d);\n\n mafString& operator<<( float d);\n\n mafString& operator<<( double d);\n\n\t/** Put inside string a mafMatrix in row order \n\n\texample:\n", "file_path": "Base/mafString.h", "rank": 48, "score": 66882.49840642868 }, { "content": " mafString &operator=(const char *src);\n\n mafString &operator=(const double &num);\n\n#ifdef MAF_USE_WX\n\n mafString &operator=(const wxString &str);\n\n#endif\n\n mafString();\n\n ~mafString();\n\nprotected:\n\n\n\n /** Allocate space for the internal c-string. */\n\n int SetSize(mafID size);\n\n\n\n void Initialize() {m_CStr=NULL;m_ConstCStr=\"\";m_Size=0;};\n\n\n\n char *m_CStr;\n\n const char *m_ConstCStr;\n\n mafID m_Size;\n\n};\n\n\n\n/**\n\n Class Name : mafCString.\n\n this string class is thought to simply wrap a c-string: no memory copy.\n\n*/\n", "file_path": "Base/mafString.h", "rank": 49, "score": 66869.94039391281 }, { "content": " 1 0 0 0\n\n\t0 1 0 0\n\n\t0 0 1 0\n\n\t0 0 0 1\n\n\t-> \"1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1\"\n\n\t*/\n\n\tmafString& operator<<( mafMatrix d);\n\n mafString& operator<<( mafString *s);\n\n //void operator<<( std::string s);\n\n\n\n mafString& operator+=(const char *s);\n\n\n\n mafString(const mafString &src);\n\n mafString(const char *src);\n\n mafString(const double &num);\n\n#ifdef MAF_USE_WX\n\n mafString(const wxString &str);\n\n#endif\n\n\n\n mafString &operator=(const mafString &mat);\n", "file_path": "Base/mafString.h", "rank": 50, "score": 66865.0954141186 }, { "content": "\n\n /** Erase characters from start position to end position. If end\n\n is not specified erase to the end of the string.*/\n\n void Erase(int start,int end=-1);\n\n\n\n /**\n\n This method makes a duplicate of a c-string similar to C function\n\n strdup but it uses new to create new string, so you can use\n\n delete to remove it. It returns 0 if the input is empty. This function\n\n automatically release old pointed data (if not specified differently)*/\n\n static char* Duplicate(const char* str);\n\n\n\n /**\n\n This method makes a duplicate of the string similar to C function\n\n strdup but it uses new to create new string, so you can use\n\n delete to remove it. It returns 0 if the input is empty. The new\n\n string pointer is copied in the destination pointer. If this was\n\n already != NULL, the corresponding memory is released. This is useful\n\n to automatically manage garbage collection but beware to not provide \n\n an uninitialized pointer variable. Beware memory releasing\n", "file_path": "Base/mafString.h", "rank": 51, "score": 66865.01348719474 }, { "content": " static char *ParsePathName(char *str);\n\n char *ParsePathName(mafString *str);\n\n\n\n /** Force the string to create an internal duplication in place of reference to const char */\n\n void ForceDuplicate();\n\n \n\n /** Return the pointer to the internal c-string */\n\n const char * GetCStr() const;\n\n \n\n /** \n\n Return the pointer to the internal c-string, but first force string\n\n the internal copy @sa ForceDulicate () */\n\n char *GetNonConstCStr();\n\n\n\n /** return the real memory size allocated for the internal c-string */\n\n int GetSize() const {return m_Size;};\n\n\n\n /**\n\n Pre-Allocate space for the internal c-string. The memory size is\n\n is given in terms of string length, that is one more character\n", "file_path": "Base/mafString.h", "rank": 52, "score": 66863.4581635056 }, { "content": "\n\n /** Format given arguments according to format string. Format string format is\n\n that of vsprintf function */\n\n void Printf(const char *format, ...);\n\n\n\n /** like Printf but faster (you can specify output string size) */ \n\n void NPrintf(unsigned long size, const char *format, ...);\n\n\n\n /** this allows to convert a mafString to const char *. */\n\n operator const char*() const {return GetCStr();}\n\n\n\n /** \n\n Direct access to single string elements for writing. This operator\n\n forces memory copy in case of internal const char reference. */\n\n char & operator [] (const int i);\n\n\n\n /** direct access to string single elements for reading */\n\n const char operator [] (const int i) const;\n\n\n\n const bool operator==(const char *src) const;\n", "file_path": "Base/mafString.h", "rank": 53, "score": 66862.07526536116 }, { "content": " /** Find last occurrence of a substring */\n\n int FindLast(const char *str) const;\n\n\n\n /** Extract the base name of a filename string */\n\n static const char *BaseName(const char *filename);\n\n const char *BaseName() const;\n\n\n\n /** Extract the pathname from a filename string. Result is written inplace. */\n\n void ExtractPathName();\n\n\n\n /**\n\n parse the given string to substitute each (back)slash\n\n character with the right pathname separator.*/\n\n void SetPathName(const char *str);\n\n void SetPathName(mafString *str);\n\n\n\n /**\n\n parse the given string to substitute each (back)slash\n\n character with the right pathname separator.*/\n\n char *ParsePathName();\n", "file_path": "Base/mafString.h", "rank": 54, "score": 66860.74364841188 }, { "content": " for the trailing '\\0' is allocated. Previous data is retained.\n\n Memory is reallocated only if requested size is > of existing one.\n\n All the mafString methods resize this memory when necessary, but to\n\n improve performance it's possible to preallocate an enough large\n\n memory to store the data preventing reallocation of memory.\n\n Return 0 if OK, -1 in case of relocation problems */\n\n int SetMaxLength(mafID len);\n\n\n\n /** return true if empty*/\n\n static bool IsEmpty(const char *str) { return (str?str[0]=='\\0':true);};\n\n /** return true if empty*/\n\n bool IsEmpty() const { return IsEmpty(GetCStr());};\n\n\n\n /** \n\n Set the internal pointer to a give pointer. Second parameter allow \n\n to force the release of the memory */\n\n mafString &Set(const char *a, bool release=false);\n\n \n\n /** this can be used only with non constant c-string */\n\n void SetCStr(char *a, bool release=false);\n", "file_path": "Base/mafString.h", "rank": 55, "score": 66859.43101993775 }, { "content": " must be performed by consumer*/\n\n static void Duplicate(char * &store,const char *src,bool release=true);\n\n \n\n /**\n\n Duplicate the string stored inside this object. Beware memory releasing\n\n must be performed by consumer */\n\n char* Duplicate() const;\n\n \n\n /** \n\n This static method compare two strings. It is similar to strcmp, but it\n\n can handle null pointers. return 0 if str1 == str2, -1 if str1<str2,\n\n 1 if str1>str2*/\n\n static int Compare(const char* str1, const char* str2); \n\n\n\n /** \n\n This method compare the given c-string with the one stored inside this object.\n\n It is similar to strcmp, but it can handle null pointers. Return 0 if str equal this,\n\n -1 if str > this, 1 if str < this*/\n\n int Compare(const char* str) const;\n\n \n", "file_path": "Base/mafString.h", "rank": 56, "score": 66859.19309559627 }, { "content": " /** Check if this string ends with the given one.*/\n\n bool EndsWith(const char* str) const;\n\n\n\n /**\n\n Append two strings and produce a new one. The consumer must delete\n\n the resulting string. The method returns 0 if inputs are empty or\n\n if there was an error.*/\n\n static char* Append(const char* str1, const char* str2);\n\n /** Append a new string to this string. */\n\n mafString &Append(const char* str);\n\n\n\n /** Scan the string for the first occurrence of the character */\n\n int FindChr(const int c) const;\n\n\n\n /** Scan the string for the first occurrence of the character */\n\n int FindLastChr(const int c) const;\n\n\n\n /** Find first occurrence of a substring */\n\n int FindFirst(const char *str) const;\n\n\n", "file_path": "Base/mafString.h", "rank": 57, "score": 66857.71751175958 }, { "content": " /**\n\n This static method compare two strings. It is similar to strcmp, but it\n\n can handle null pointers. Also it only returns C style true or\n\n false versus compare which returns also which one is greater.*/\n\n static bool Equals(const char* str1, const char* str2) { return Compare(str1, str2) == 0;}\n\n \n\n /**\n\n This method compare the given c-string with the one stored inside this object.\n\n It is similar to strcmp, but it can handle null pointers. Also it only\n\n returns C style true or false versus compare which returns also which\n\n one is greater.*/\n\n bool Equals(const char* str) const;\n\n \n\n /** Static method to check if the first string starts with the second one.*/\n\n static bool StartsWith(const char* str1, const char* str2);\n\n /** Check if this string starts with the given one.*/\n\n bool StartsWith(const char* str) const;\n\n\n\n /** Static method to check if the first string ends with the second one.*/\n\n static bool EndsWith(const char* str1, const char* str2); \n", "file_path": "Base/mafString.h", "rank": 58, "score": 66849.03582585334 }, { "content": "/*=========================================================================\n\n\n\n Program: MAF2\n\n Module: mafString\n\n Authors: originally based on vtkString (www.vtk.org), rewritten Marco Petrone\n\n \n\n Copyright (c) B3C\n\n All rights reserved. See Copyright.txt or\n\n http://www.scsitaly.com/Copyright.htm for details.\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef __mafString_h\n\n#define __mafString_h\n\n\n\n#include \"mafDefines.h\"\n\n#include \"mafBase.h\" \n\n#include <string.h>\n\n\n\n//----------------------------------------------------------\n\n// forward references:\n\n//----------------------------------------------------------\n", "file_path": "Base/mafString.h", "rank": 59, "score": 66848.39935359401 }, { "content": " /**\n\n This functions rotate the internal matrix around the specified axis. It can be used in conjuction with\n\n SetMatrix, but if a pipeline is defined (input, input_frame or target_frame) it's overwritten whenever\n\n the Update() is performed.*/\n\n static void RotateX(mafMatrix &matrix,double angle,int premultiply) { mafTransform::RotateWXYZ(matrix,matrix,angle, 1, 0, 0,premultiply); };\n\n static void RotateY(mafMatrix &matrix,double angle,int premultiply) { mafTransform::RotateWXYZ(matrix,matrix,angle, 0, 1, 0,premultiply); };\n\n static void RotateZ(mafMatrix &matrix,double angle,int premultiply) { mafTransform::RotateWXYZ(matrix,matrix,angle, 0, 0, 1,premultiply); };\n\n void RotateX(double angle,int premultiply) { this->RotateX(*m_Matrix,angle,premultiply); };\n\n void RotateY(double angle,int premultiply) { this->RotateY(*m_Matrix,angle,premultiply); };\n\n void RotateZ(double angle,int premultiply) { this->RotateZ(*m_Matrix,angle,premultiply); };\n\n\n\n /** Pre or Post multiply the internal matrix for given matrix and store result in the internal matrix */\n\n void Concatenate(const mafMatrix &matrix, int premultiply);\n\n\n\n /** Pre or Post multiply the internal matrix for given transform and store result in the internal matrix */\n\n void Concatenate(mafTransformBase *trans, int premultiply) {Concatenate(trans->GetMatrix(),premultiply);}\n\n\n\n /**\n\n This function set the orientation (acc. to VTK convention) of the matrix. Notice, the non static functions\n\n work on the internal matrix and can be used in conjuction with SetMatrix, but if a pipeline\n", "file_path": "Base/mafTransform.h", "rank": 60, "score": 66707.94514748175 }, { "content": " as argument. Notice, the non static functions work on the internal matrix and can be used\n\n in conjuction with SetMatrix, but if a pipeline is defined (input, input_frame or \n\n target_frame) it's overwritten whenever the Update() is perfromed.*/\n\n static void Translate(mafMatrix &matrix,double translation[3],int premultiply);\n\n void Translate(double translation[3],int premultiply) {this->Translate(*m_Matrix,translation,premultiply);}\n\n void Translate(double x,double y,double z,int premultiply) {this->Translate(*m_Matrix,x,y,z,premultiply);}\n\n static void Translate(mafMatrix &matrix, double x,double y,double z,int premultiply) {\n\n double temp[3];\n\n temp[0]=x;temp[1]=y;temp[2]=z;\n\n Translate(matrix,temp,premultiply);}\n\n\n\n /**\n\n This function rotate the matrix around the specified axis. Notice, the non static functions\n\n work on the internal matrix and can be used in conjuction with SetMatrix, but if a pipeline\n\n is defined (input, input_frame or target_frame) it's overwritten whenever the Update() is perfromed.*/\n\n static void RotateWXYZ(const mafMatrix &source,mafMatrix &target,double angle,double x, double y, double z,int premultiply);\n\n void RotateWXYZ(double angle,double x, double y, double z,int premultiply) {this->RotateWXYZ(*m_Matrix,*m_Matrix,angle,x,y,z,premultiply);}\n\n void RotateWXYZ(double angle,double rot[3],int premultiply) {this->RotateWXYZ(*m_Matrix,*m_Matrix,angle, rot[0], rot[1], rot[2],premultiply);}\n\n\n\n\n", "file_path": "Base/mafTransform.h", "rank": 61, "score": 66701.47957804076 }, { "content": " scale[2] = static_cast<float>(temp[2]); };\n\n\n\n /** Apply a scale transform. By default the scale matrix is premultiplied */\n\n static void Scale(mafMatrix &matrix,double scalex,double scaley,double scalez,int premultiply);\n\n void Scale(double scalex,double scaley,double scalez,int premultiply) \\\n\n { Scale(*m_Matrix,scalex,scaley,scalez,premultiply);}\n\n\n\n /** Set/Get internal matrix versor*/\n\n static void SetVersor(int axis, double versor[3], mafMatrix &matrix);\n\n \n\n static void GetVersor(int axis, const mafMatrix &matrix, double versor[3]) {mafMatrix::GetVersor(axis,matrix,versor);}\n\n static void GetVersor(int axis, const mafMatrix &matrix, float versor[3]) \\\n\n { \\\n\n double temp[3]; GetVersor(axis, matrix, temp); \\\n\n versor[0] = static_cast<float>(temp[0]); \\\n\n versor[1] = static_cast<float>(temp[1]); \\\n\n versor[2] = static_cast<float>(temp[2]); };\n\n \n\n void GetVersor(int axis, double versor[3]) {GetVersor(axis,GetMatrix(),versor);}\n\n void GetVersor(int axis, float versor[3]) {GetVersor(axis,GetMatrix(),versor);}\n", "file_path": "Base/mafTransform.h", "rank": 62, "score": 66700.44719613994 }, { "content": " VIEW ///< the view ref sys\n\n };\n\n\n\n /** copy constructor */\n\n mafTransform(const mafTransform&);\n\n\n\n /** RTTI stuff */\n\n mafTypeMacro(mafTransform,mafTransformBase);\n\n \n\n /**\n\n Directly set the internal Matrix. It's overwritten by Update if Input or InputFrame !=NULL\n\n This function makes a copy of the input matrix. */\n\n virtual void SetMatrix(const mafMatrix &input) {*m_Matrix=input;SetTimeStamp(input.GetTimeStamp());Modified();}\n\n\n\n /** set the internal matrix pointer to the given matrix. Do not use this if you don't know what you are doing */\n\n void SetMatrixPointer(mafMatrix *matrix);\n\n\n\n\t/**\n\n\t Polar Decomposition of matrix M in Q * S.*/\n\n\tstatic double PolarDecomp(const mafMatrix &M, mafMatrix &Q, mafMatrix &S, double translation[3]);\n", "file_path": "Base/mafTransform.h", "rank": 63, "score": 66699.37915997228 }, { "content": "/*=========================================================================\n\n\n\n Program: MAF2\n\n Module: mafTransform\n\n Authors: Marco Petrone, Stefano Perticoni,Stefania Paperini\n\n \n\n Copyright (c) B3C\n\n All rights reserved. See Copyright.txt or\n\n http://www.scsitaly.com/Copyright.htm for details.\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef __mafTransform_h\n\n#define __mafTransform_h\n\n\n\n#include \"mafTransformBase.h\"\n\n#include \"mafInteractorConstraint.h\"\n\n\n\n#include \"mafUtility.h\"\n\n\n\n//------------------------------------------------------------------------------\n\n// Forward declarations\n\n//------------------------------------------------------------------------------\n", "file_path": "Base/mafTransform.h", "rank": 64, "score": 66696.90085025562 }, { "content": " /**\n\n\t Return the wxyz angle+axis representing the current orientation.\n\n Copied from vtkTransform::GetVTKOrientationWXYZ()*/\n\n static void GetOrientationWXYZ(const mafMatrix &in_matrix, double wxyz[4]);\n\n void GetOrientationWXYZ(double wxyz[4]) \\\n\n { GetOrientationWXYZ(GetMatrix(),wxyz);}\n\n void GetOrientationWXYZ(float wxyz[3]) {\n\n double temp[4]; GetOrientationWXYZ(temp); \n\n wxyz[0]=static_cast<float>(temp[0]); \n\n wxyz[1]=static_cast<float>(temp[1]); \n\n wxyz[2]=static_cast<float>(temp[2]); \n\n wxyz[3]=static_cast<float>(temp[3]);};\n\n\n\n /**\n\n Return the position from the current transformation matrix as an array\n\n of three floating point numbers. This is simply returning the translation \n\n component of the 4x4 matrix. Copied from vtkTransform::GetPosition()*/\n\n static void GetPosition(const mafMatrix &matrix,double position[3]);\n\n static void GetPosition(const mafMatrix &matrix,float position[3]);\n\n void GetPosition(double position[3]) {this->GetPosition(GetMatrix(),position);}\n", "file_path": "Base/mafTransform.h", "rank": 65, "score": 66695.6694238508 }, { "content": " is defined (input, input_frame or target_frame) it's overwritten whenever the Update() is performed.*/\n\n static void SetOrientation(mafMatrix &matrix,double orientation[3]);\n\n void SetOrientation(double orientation[3]) {this->SetOrientation(*m_Matrix,orientation);}\n\n void SetOrientation(double rx,double ry,double rz) {this->SetOrientation(*m_Matrix,rx,ry,rz);}\n\n static void SetOrientation(mafMatrix &matrix,double rx,double ry,double rz) {\n\n double temp[3];\n\n temp[0]=rx;temp[1]=ry;temp[2]=rz;\n\n SetOrientation(matrix,temp);}\n\n\n\n /**\n\n Return the scale factors of the current transformation matrix as \n\n an array of three float numbers. These scale factors are not necessarily\n\n about the x, y, and z axes unless unless the scale transformation was\n\n applied before any rotations. Copied from vtkTransform::GetScale()*/\n\n static void GetScale(const mafMatrix &matrix,double scale[3]);\n\n void GetScale(double scale[3]) {this->GetScale(*m_Matrix,scale);}\n\n void GetScale(float scale[3]) {\n\n double temp[3]; this->GetScale(temp); \n\n scale[0] = static_cast<float>(temp[0]); \n\n scale[1] = static_cast<float>(temp[1]); \n", "file_path": "Base/mafTransform.h", "rank": 66, "score": 66695.56246462 }, { "content": " double PolarDecomp(mafMatrix &Q, mafMatrix &S, double translation[3]) {return PolarDecomp(GetMatrix(),Q,S,translation);}\n\n \n\n /** set internal matrix to Identity */\n\n void Identity();\n\n\n\n /** Invert internal matrix */\n\n void Invert();\n\n\n\n /**\n\n\t Get the x, y, z orientation angles from the transformation matrix as an\n\n array of three floating point values. Copied from vtkTransform::GetOrientation()*/\n\n static void GetOrientation(const mafMatrix &in_matrix,double orientation[3]);\n\n static void GetOrientation(const mafMatrix &in_matrix,float orientation[3]);\n\n void GetOrientation(double orientation[3]) { this->GetOrientation(GetMatrix(),orientation);}\n\n void GetOrientation(float orient[3]) {\n\n double temp[3]; this->GetOrientation(temp); \n\n orient[0] = static_cast<float>(temp[0]); \n\n orient[1] = static_cast<float>(temp[1]); \n\n orient[2] = static_cast<float>(temp[2]); };\n\n\n", "file_path": "Base/mafTransform.h", "rank": 67, "score": 66695.30430883408 }, { "content": "\n\n /**\n\n Copy the 3x3 rotation matrix from another 4x4 matrix into the specified matrix, or in the internal matrix.*/\n\n static void CopyRotation(const mafMatrix &source, mafMatrix &target);\n\n void CopyRotation(const mafMatrix &source) {this->CopyRotation(source,*m_Matrix);}\n\n\n\n /** Copy the translation vector */\n\n static void CopyTranslation(const mafMatrix &source, mafMatrix &target);\n\n void CopyTranslation(const mafMatrix &source) {this->CopyTranslation(source,*m_Matrix);}\n\n \n\n /** Add two vectors */\n\n static void AddVectors( double inV0[3],double inV1[3],double outSum[3] );\n\n\n\n /** Build vector with origin in p1 pointing to p2 */\n\n static void BuildVector(double *p1, double *p2, double *out_vector);\n\n\n\n /** Build vector [coeff * inVector] */\n\n static void BuildVector(double coeff, const double *inVector, double *outVector, int refSysType = LOCAL, int localAxis = mafInteractorConstraint::X);\n\n\n\n /** Project in_vector on in_axis direction; in_axis does not need to be \n", "file_path": "Base/mafTransform.h", "rank": 68, "score": 66694.86665628088 }, { "content": "\t\t\t\t\t\t\t\t\t\t\t\t\tint i,int j,int k,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\tmafMatrix &matrix);\n\n\n\n /** rotation + translation representation conversion */\n\n\tint MatrixToHelicalAxis(const mafMatrix &matrix,\n\n\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t double helical_axis[3],double point[3],\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t double& phi,double& t, int intersect);\n\n\n\n\n\n //----------------------------------------------------------------------------\n\n // declarations for polar_decomp algorithm from Graphics Gems IV,\n\n // by Ken Shoemake <[email protected]>\n\n //----------------------------------------------------------------------------\n\n enum mmuQuatPart {X, Y, Z, W};\n\n\n\n typedef struct {double x, y, z, w;} mmuQuat; ///< mmuQuaternion \n\n typedef mmuQuat HVect; ///< Homogeneous 3D vector \n\n \n\n typedef struct {\n\n\t HVect t;\t///< Translation components\n", "file_path": "Base/mafTransform.h", "rank": 69, "score": 66694.59548634806 }, { "content": " void GetPosition(float position[3]) {\n\n double temp[3]; this->GetPosition(temp); \n\n position[0] = static_cast<float>(temp[0]); \n\n position[1] = static_cast<float>(temp[1]); \n\n position[2] = static_cast<float>(temp[2]); };\n\n\n\n /**\n\n This function set the position column of the matrix. Notice, the non static functions\n\n work on the internal matrix and can be used in conjuction with SetMatrix, but if a pipeline\n\n is defined (input, input_frame or target_frame) it's overwritten whenever the Update() is perfromed.*/\n\n static void SetPosition(mafMatrix &matrix,double position[3]);\n\n void SetPosition(double position[3]) {this->SetPosition(*m_Matrix,position);}\n\n void SetPosition(double x,double y,double z) {this->SetPosition(*m_Matrix,x,y,z);}\n\n static void SetPosition(mafMatrix &matrix, double x,double y,double z) {\n\n double temp[3];\n\n temp[0]=x;temp[1]=y;temp[2]=z;\n\n SetPosition(matrix,temp);}\n\n\n\n /**\n\n This function set the translation column of the matrix by adding the transaltion provided\n", "file_path": "Base/mafTransform.h", "rank": 70, "score": 66693.09937418916 }, { "content": " normalised. The projection signed value is returned */\n\n static double ProjectVectorOnAxis(const double *in_vector, const double *in_axis, double *out_projection = NULL);\n\n\n\n /** Project in_vector on the plane identified by the normal vector in_plane_normal;\n\n in_plane_normal does not need to be normalised. The norm of the projection \n\n is returned and the projection vector is written in out_projection vector if provided. */\n\n static double ProjectVectorOnPlane(const double *in_vector, const double *in_plane_normal, double *out_projection = NULL);\n\n\n\n /** Find perpendicular versors to input versor N */\n\n static void FindPerpendicularVersors(double inVersorN[3], double outVersorP[3], double outVersorQ[3]);\n\n\n\n /** Multiply vector by scalar */\n\n static void MultiplyVectorByScalar(double s, double *vin, double *vout);\n\n\n\n /** rotation representation conversion */\n\n\tint MatrixToAttitudeVector(const mafMatrix &matrix,\n\n\t\t\t\t\t\t\t\t\t\t double attitude_vector[3]);\n\n\n\n /** rotation representation conversion */\n\n\tint MatrixToEulerCardanicAngle(const mafMatrix &matrix,\n", "file_path": "Base/mafTransform.h", "rank": 71, "score": 66692.77902237998 }, { "content": "\t mmuQuat q;\t///< Essential rotation\n\n\t mmuQuat u;\t///< Stretch rotation\n\n\t HVect k;\t///< Stretch factors\n\n\t double f;\t///< Sign of determinant\n\n } mmuAffineParts;\n\n \n\n typedef double HMatrix[4][4]; /* Right-handed, for column vectors */\n\n static double PolarDecomp(HMatrix M, HMatrix Q, HMatrix S);\n\n static void DecompAffine(HMatrix A, mmuAffineParts *parts);\n\n static HVect SpectDecomp(HMatrix S, HMatrix U);\n\n static mmuQuat QuaternionFromMatrix(HMatrix mat);\n\n static void InvertAffine(mmuAffineParts *parts, mmuAffineParts *inverse);\n\n static mmuQuat Snuggle(mmuQuat q, HVect *k);\n\n //----------------------------------------------------------------------------\n\nprotected:\n\n /**\n\n This only sets the timestamp for the output matrix: output matrix is not computed\n\n inside InternalUpdate since this is not a procedural transform. */\n\n virtual void InternalUpdate() {m_Matrix->SetTimeStamp(m_TimeStamp);}\n\nprivate:\n\n};\n\n\n\n#endif\n\n\n", "file_path": "Base/mafTransform.h", "rank": 72, "score": 66692.06989288183 }, { "content": "\t\t\t\t\t\t\t\t\t\t\t\t\tint i,int j,int k,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\tdouble euler_cardan[3],\n\n\t\t\t\t\t\t\t\t\t\t\t\t\tdouble tentative_euler_cardan_first,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\tdouble tentative_euler_cardan_second,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\tdouble tentative_euler_cardan_third);\n\n\n\n /** rotation representation conversion */\n\n\tint MatrixTommuQuaternion(const mafMatrix &matrix, double quaternion[4]);\n\n\n\n /** rotation representation conversion */\n\n\tint QuaternionToMatrix(double quaternion[4],\tmafMatrix &matrix);\n\n\n\n /** rotation + translation representation conversion */\n\n\tint HelicalAxisToMatrix(double helical_axis[3],double angle, mafMatrix &matrix);\n\n\n\n /** rotation representation conversion */\n\n\tint AttitudeVectorToMatrix(double attitude_vector[3], mafMatrix &matrix);\n\n\n\n /** rotation representation conversion */\n\n\tint EulerCardanicAngleToMatrix(double euler_cardan[3],\n", "file_path": "Base/mafTransform.h", "rank": 73, "score": 66690.0908448586 }, { "content": "//----------------------------------------------------------------------------\n\nclass MAF_EXPORT mafOpVolumeResample: public mafOp\n\n{\n\npublic:\n\n \n\n \t mafOpVolumeResample(const wxString &label = \"VolumeResample\");\n\n\tvirtual ~mafOpVolumeResample();\n\n\tvirtual void OnEvent(mafEventBase *maf_event);\n\n\t\n\n mafTypeMacro(mafOpVolumeResample, mafOp);\n\n\n\n mafOp* Copy();\n\n\n\n\tbool Accept(mafNode* vme);\n\n\tvoid OpRun();\t\n\n\tvoid OpDo();\n\n\tvoid OpUndo(); \n\n\n\n\t/**\n\n\tSet spacing for test mode*/\n\n\tvoid SetSpacing(double Spacing[3]);\n", "file_path": "Operations/mafOpVolumeResample.h", "rank": 74, "score": 66428.99296630337 }, { "content": "class MAF_EXPORT mafOpTransformInterface : public mafOp\n\n{\n\npublic:\n\n mafOpTransformInterface(const wxString &label = \"TransformInterface\");\n\n virtual ~mafOpTransformInterface(); \n\n \n\n /** Return true for the acceptable vme type. */\n\n bool Accept(mafNode* vme) {return true;};\n\n\n\n mafTypeMacro(mafOpTransformInterface, mafOp);\n\n\n\n /** Override superclass */\n\n mafOp* Copy();\n\n\n\n /** Override superclass */\n\n void OpDo();\n\n \n\n /** Set/Get the vme used as refsys, the vme is referenced*/\n\n void SetRefSysVME(mafVME *refSysVme);\n\n mafVME *GetRefSysVME() {return m_RefSysVME;};\n", "file_path": "Operations/mafOpTransformInterface.h", "rank": 75, "score": 66268.57962375708 }, { "content": "class MAF_EXPORT mafGUITransformInterface : public mafObserver\n\n{\n\npublic:\n\n\n\n /** Return the gui to be plugged*/\n\n mafGUI *GetGui() {return m_Gui;};\n\n\n\n /** Enable-Disable the GUI's widgets */\n\n virtual void EnableWidgets(bool enable) = 0;\n\n\n\n /** Set the vme to be used as reference system, the vme is referenced; default ref sys is vme abs matrix */\n\n void SetRefSys(mafVME *refSysVme); \n\n mafVME* GetRefSys() {return m_RefSysVME;};\n\n\n\n /** Reset the gui component to initial state */\n\n virtual void Reset() {};\n\n\n\n /** Events handling */ \n\n void OnEvent(mafEventBase *maf_event) {};\n\n \n", "file_path": "Interaction/mafGUITransformInterface.h", "rank": 76, "score": 66268.57962375708 }, { "content": "class mafXMLStringTest : public CPPUNIT_NS::TestFixture\n\n{\n\npublic:\n\n\n\n // CPPUNIT fixture: executed before each test\n\n void setUp();\n\n\n\n // CPPUNIT fixture: executed after each test\n\n void tearDown();\n\n\n\n\tCPPUNIT_TEST_SUITE( mafXMLStringTest );\n\n\tCPPUNIT_TEST( TestStaticAllocation );\n\n\tCPPUNIT_TEST( TestDynamicAllocation );\n\n CPPUNIT_TEST( TestAllConstructors );\n\n CPPUNIT_TEST( TestAppend );\n\n CPPUNIT_TEST( TestErase );\n\n CPPUNIT_TEST( TestBegin );\n\n CPPUNIT_TEST( TestEnd );\n\n CPPUNIT_TEST( TestSize );\n\n CPPUNIT_TEST( TestGetCStr );\n", "file_path": "Testing/IO/mafXMLStringTest.h", "rank": 77, "score": 65420.943614517964 }, { "content": "class mafTransformBaseTest : public CPPUNIT_NS::TestFixture\n\n{\n\npublic: \n\n // CPPUNIT fixture: executed before each test\n\n void setUp();\n\n\n\n // CPPUNIT fixture: executed after each test\n\n void tearDown();\n\n\n\n // CPPUNIT test suite\n\n CPPUNIT_TEST_SUITE( mafTransformBaseTest );\n\n CPPUNIT_TEST(TestFixture); // just to test that the fixture has no leaks\n\n CPPUNIT_TEST(TestStaticAllocation);\n\n CPPUNIT_TEST(TestDynamicAllocation);\n\n CPPUNIT_TEST(TestCopyConstructor);\n\n CPPUNIT_TEST(TestGetMatrix);\n\n\tCPPUNIT_TEST(TestTimeStamp);\n\n\tCPPUNIT_TEST(TestModifiedTime);\n\n\tCPPUNIT_TEST(TestUpdateTime);\n\n\tCPPUNIT_TEST(TestGetEventSource);\n", "file_path": "Testing/Base/mafTransformBaseTest.h", "rank": 78, "score": 65272.82989268693 }, { "content": "class mafTransformFrameTest : public CPPUNIT_NS::TestFixture\n\n{\n\n public: \n\n\n\n // CPPUNIT fixture: executed before each test\n\n void setUp();\n\n\n\n // CPPUNIT fixture: executed after each test\n\n void tearDown();\n\n\n\n // CPPUNIT test suite\n\n CPPUNIT_TEST_SUITE( mafTransformFrameTest );\n\n CPPUNIT_TEST( TestFixture ); // just to test that the fixture has no leaks\n\n CPPUNIT_TEST( TestMafTransformFrameConstructorDestructor );\n\n CPPUNIT_TEST( TestSetInputMafTransformBase );\n\n CPPUNIT_TEST( TestSetInputMafMatrix );\n\n CPPUNIT_TEST( TestGetInput );\n\n CPPUNIT_TEST( TestSetInputFrameMafMatrix );\n\n CPPUNIT_TEST( TestSetInputFrameMafTransformBase );\n\n CPPUNIT_TEST( TestGetInputFrame );\n", "file_path": "Testing/Base/mafTransformFrameTest.h", "rank": 79, "score": 65272.82989268693 }, { "content": "{\n\n Copy(src.c_str());\n\n return *this;\n\n}\n\n#endif\n\n/*\n\n//----------------------------------------------------------------------------\n\nstd::ostream& operator<<(std::ostream& os, const mafString& s)\n\n//----------------------------------------------------------------------------\n\n{\n\n const char *str=s.GetCStr();\n\n os << str;\n\n return os;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid mafString::operator>>(std::istream &is)\n\n//----------------------------------------------------------------------------\n\n{\n\n std::string tmp;\n", "file_path": "Base/mafString.cpp", "rank": 80, "score": 64886.16973650577 }, { "content": "\n\n\n\n#include <xercesc/util/XMLString.hpp>\n\n\n\n#ifdef XERCES_CPP_NAMESPACE_USE\n\n// XERCES_CPP_NAMESPACE_USE\n\n// SIL 12-apr-2006\n\n// removed XERCES_CPP_NAMESPACE_USE and added XERCES_CPP_NAMESPACE_QUALIFIER where required\n\n#endif\n\n\n\n/** string type for converting const char * to and from XMLString types\n\n This is an internal string type to be used only in conjunction with XercecC XML library.\n\n This object is able to convert const char* to and from XMLStrings. This code has been\n\n adapted from example code \"class XercesString\" found in articles \"Make the most of Xerces-C++\"\n\n by Rick Parrish ([email protected]) that can be found at \"www.ibm.com/developerworks/xml\".\n\n*/\n", "file_path": "IO/mafXMLString.h", "rank": 81, "score": 64877.08128100836 }, { "content": " // If the available memory is not sufficient, relocate!\n\n unsigned long len=Length(src);\n\n if (len>=m_Size)\n\n {\n\n SetMaxLength(len);\n\n }\n\n\n\n Copy(m_CStr,src);\n\n }\n\n else\n\n {\n\n SetMaxLength(0);\n\n m_ConstCStr=\"\";\n\n }\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid mafString::NCopy(const char* src,int n)\n\n//----------------------------------------------------------------------------\n\n{\n", "file_path": "Base/mafString.cpp", "rank": 82, "score": 64871.37975445897 }, { "content": "\n\n return strcmp(str1, str2);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nint mafString::Compare(const char* str) const\n\n//----------------------------------------------------------------------------\n\n{\n\n return Compare(m_Size>0?m_CStr:m_ConstCStr, str);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nbool mafString::Equals(const char* str) const\n\n//----------------------------------------------------------------------------\n\n{\n\n return Equals(m_Size>0?m_CStr:m_ConstCStr, str);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\n// Check if the first string starts with the second one.\n", "file_path": "Base/mafString.cpp", "rank": 83, "score": 64870.188776609924 }, { "content": " return *this;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nconst char * mafString::GetCStr() const\n\n//----------------------------------------------------------------------------\n\n{\n\n if (m_Size>0)\n\n {\n\n return m_CStr;\n\n }\n\n else\n\n { \n\n return m_ConstCStr;\n\n }\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nint mafString::SetMaxLength(mafID len)\n\n//----------------------------------------------------------------------------\n", "file_path": "Base/mafString.cpp", "rank": 84, "score": 64868.934865012314 }, { "content": "//----------------------------------------------------------------------------\n\n{\n\n if (a!=GetCStr())\n\n {\n\n SetSize(0); // force memory release\n\n m_ConstCStr = a;\n\n //m_Size = release?Length(a)+1:0;\n\n }\n\n return *this;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid mafString::SetCStr(char *a, bool release)\n\n//----------------------------------------------------------------------------\n\n{\n\n if (a!=GetCStr())\n\n {\n\n SetSize(0); // force memory release\n\n m_CStr = a;\n\n m_Size = release?Length(a)+1:0; // notice: I could have a (char *) that must not be released\n", "file_path": "Base/mafString.cpp", "rank": 85, "score": 64866.16599141951 }, { "content": " \n\n return m_CStr[i];\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nconst char mafString::operator [] (const int i) const\n\n//------------------------------------------------------------------------------\n\n{\n\n return GetCStr()[i];\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nint mafString::FindChr(const int c) const\n\n//----------------------------------------------------------------------------\n\n{\n\n if (IsEmpty())\n\n {\n\n return -1;\n\n }\n\n char *pdest;\n", "file_path": "Base/mafString.cpp", "rank": 86, "score": 64865.83790917253 }, { "content": "#include <stdarg.h>\n\n#include <assert.h>\n\n\n\n#include \"wx/wx.h\"\n\n#include <wx/string.h>\n\n#include <string>\n\n\n\n\n\n//----------------------------------------------------------------------------\n\nmafString::~mafString()\n\n//----------------------------------------------------------------------------\n\n{\n\n if (m_CStr)\n\n {\n\n if (m_Size>0)\n\n delete[] m_CStr;\n\n\n\n m_CStr=NULL;\n\n m_ConstCStr=NULL;\n\n }\n", "file_path": "Base/mafString.cpp", "rank": 87, "score": 64865.26929720919 }, { "content": "//----------------------------------------------------------------------------\n\nconst bool mafString::operator<=(const char *a) const\n\n//----------------------------------------------------------------------------\n\n{\n\n return Compare(a)<=0;\n\n}\n\n//----------------------------------------------------------------------------\n\nconst bool mafString::operator>=(const char *a) const\n\n//----------------------------------------------------------------------------\n\n{\n\n return Compare(a)>=0;\n\n}\n\n\n\n//------------------------------------------------------------------------------\n\nchar & mafString::operator [] (const int i)\n\n//------------------------------------------------------------------------------\n\n{\n\n // check if the string is referencing a \"const char *\"\n\n if (!m_CStr)\n\n ForceDuplicate(); // force memory copying\n", "file_path": "Base/mafString.cpp", "rank": 88, "score": 64865.043425087715 }, { "content": " if (src)\n\n {\n\n SetMaxLength(n);\n\n strncpy(m_CStr,src,n);\n\n m_CStr[n]='\\0';\n\n }\n\n else\n\n {\n\n // release memory\n\n SetSize(0);\n\n }\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\n// Description:\n\n// This method makes a duplicate of the string similar to\n\n// C function strdup but it uses new to create new string, so\n\n// you can use delete to remove it. It returns empty string \n\n// \"\" if the input is empty.\n\nchar* mafString::Duplicate(const char* str)\n", "file_path": "Base/mafString.cpp", "rank": 89, "score": 64864.6358222818 }, { "content": " }\n\n}\n\n//----------------------------------------------------------------------------\n\n// This method returns the size of string. If the string is empty,\n\n// it returns 0. It can handle null pointers.\n\nmafID mafString::Length(const char* str)\n\n//----------------------------------------------------------------------------\n\n{\n\n if ( !str )\n\n {\n\n return 0;\n\n }\n\n return static_cast<mafID>(strlen(str));\n\n}\n\n\n\n \n\n//----------------------------------------------------------------------------\n\n// Description:\n\n// Copy string to the other string.\n\nvoid mafString::Copy(char* dest, const char* src)\n", "file_path": "Base/mafString.cpp", "rank": 90, "score": 64864.46799789997 }, { "content": "}\n\n\n\n//----------------------------------------------------------------------------\n\nmafString::mafString():m_CStr(NULL),m_ConstCStr(\"\"),m_Size(0)\n\n//----------------------------------------------------------------------------\n\n{\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nmafString::mafString(const mafString& src):m_CStr(NULL),m_ConstCStr(\"\"),m_Size(0)\n\n//----------------------------------------------------------------------------\n\n{\n\n Copy(src.GetCStr());\n\n}\n\n//----------------------------------------------------------------------------\n\nmafString::mafString(const char *src):m_CStr(NULL),m_ConstCStr(\"\"),m_Size(0)\n\n//----------------------------------------------------------------------------\n\n{\n\n Copy(src);\n\n}\n", "file_path": "Base/mafString.cpp", "rank": 91, "score": 64864.21892087765 }, { "content": "}\n\n\n\n//----------------------------------------------------------------------------\n\nchar *mafString::ParsePathName(mafString *str)\n\n//----------------------------------------------------------------------------\n\n{\n\n str->ForceDuplicate();\n\n return ParsePathName(str->m_CStr);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nchar *mafString::ParsePathName()\n\n//----------------------------------------------------------------------------\n\n{\n\n return mafString::ParsePathName(this);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid mafString::SetPathName(const char *str)\n\n//----------------------------------------------------------------------------\n", "file_path": "Base/mafString.cpp", "rank": 92, "score": 64864.16060207346 }, { "content": "bool mafString::StartsWith(const char* str1, const char* str2)\n\n//----------------------------------------------------------------------------\n\n{\n\n if ( !str1 || !str2 || strlen(str1) < strlen(str2) )\n\n {\n\n return false;\n\n }\n\n return !strncmp(str1, str2, strlen(str2)); \n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nbool mafString::StartsWith(const char* str) const\n\n//----------------------------------------------------------------------------\n\n{ \n\n return StartsWith(m_Size>0?m_CStr:m_ConstCStr, str);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\n// Check if the first string starts with the second one.\n\nbool mafString::EndsWith(const char* str1, const char* str2)\n", "file_path": "Base/mafString.cpp", "rank": 93, "score": 64864.10001538037 }, { "content": "mafString &mafString::operator<<( std::string s )\n\n//----------------------------------------------------------------------------\n\n{\n\n Append(s);\n\n return *this;\n\n}\n\n*/\n\n//----------------------------------------------------------------------------\n\nmafString &mafString::operator<<( mafString *s )\n\n//----------------------------------------------------------------------------\n\n{\n\n Append( s->m_CStr );\n\n return *this;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nmafString& mafString::operator+=(const char *s)\n\n//----------------------------------------------------------------------------\n\n{\n\n Append(s);\n", "file_path": "Base/mafString.cpp", "rank": 94, "score": 64863.69930792541 }, { "content": "\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nchar *mafString::ParsePathName(char *str)\n\n//----------------------------------------------------------------------------\n\n{\n\n if (mafString::IsEmpty(str))\n\n return str;\n\n\n\n // for Windows platforms parse the string to substitute \"/\" and \"\\\\\" with the right one.\n\n#ifdef _WIN32\n\n for (unsigned int i=0;i<Length(str);i++)\n\n {\n\n if (str[i]=='\\\\')\n\n str[i]='/';\n\n }\n\n#endif\n\n\n\n return str;\n", "file_path": "Base/mafString.cpp", "rank": 95, "score": 64863.6675666407 }, { "content": "\n\n // allocate new memory and copy the second string's content\n\n if (src)\n\n { \n\n store = new char[strlen(src)+1];\n\n strcpy(store,src);\n\n }\n\n else \n\n { \n\n // in case of NULL string reset the output string pointer...\n\n store = NULL;\n\n }\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nchar* mafString::Duplicate() const\n\n//---------------------------------------------------------------------------- \n\n{\n\n return Duplicate(m_Size>0?m_CStr:m_ConstCStr);\n\n}\n", "file_path": "Base/mafString.cpp", "rank": 96, "score": 64863.61395014039 }, { "content": "\n\n\n\n//----------------------------------------------------------------------------\n\n// This method compare two strings. It is similar to strcmp,\n\n// but it can handle null pointers.\n\nint mafString::Compare(const char* str1, const char* str2)\n\n//----------------------------------------------------------------------------\n\n{\n\n if (!str1&&!str2)\n\n return 0;\n\n\n\n if ( !str1&&str2 )\n\n {\n\n return -1;\n\n }\n\n\n\n if ( !str2&&str1 )\n\n {\n\n return 1;\n\n }\n", "file_path": "Base/mafString.cpp", "rank": 97, "score": 64863.551016460224 }, { "content": "{\n\n if (mafString::IsEmpty(str))\n\n return;\n\n\n\n Copy(str);\n\n\n\n ParsePathName(m_CStr);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid mafString::SetPathName(mafString *str)\n\n//----------------------------------------------------------------------------\n\n{\n\n SetPathName(str->GetCStr());\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nconst char *mafString::BaseName(const char *filename)\n\n//----------------------------------------------------------------------------\n\n{\n", "file_path": "Base/mafString.cpp", "rank": 98, "score": 64863.49675713878 }, { "content": " unsigned long len=Length();\n\n SetMaxLength(m_Size>=len?m_Size:len); \n\n }\n\n}\n\n//----------------------------------------------------------------------------\n\nchar *mafString::GetNonConstCStr()\n\n//----------------------------------------------------------------------------\n\n{\n\n ForceDuplicate();\n\n return m_CStr;\n\n}\n\n//----------------------------------------------------------------------------\n\nconst mafID mafString::Length() const\n\n//----------------------------------------------------------------------------\n\n{\n\n return Length(GetCStr());\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nmafString &mafString::Set(const char *a, bool release)\n", "file_path": "Base/mafString.cpp", "rank": 99, "score": 64863.29595387646 } ]
C++
Libraries/VtkVgQtSceneUtil/vtkVgCoordinateTransform.cxx
PinkDiamond1/vivia
70f7fbed4b33b14d34de35c69b2b14df3514d720
#include "vtkVgCoordinateTransform.h" #include <vtkVgAdapt.h> #include <vtkMatrix4x4.h> #include <vtkObjectFactory.h> #include <vgl/vgl_homg_point_2d.h> #include <vgl/algo/vgl_h_matrix_2d.h> #include <vgl/algo/vgl_h_matrix_2d_compute_linear.h> vtkStandardNewMacro(vtkVgCoordinateTransform); vtkVgCoordinateTransform::vtkVgCoordinateTransform() { } vtkVgCoordinateTransform::~vtkVgCoordinateTransform() { } void vtkVgCoordinateTransform::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); } void vtkVgCoordinateTransform::SetFromPoints(double pt1[], double pt2[], double pt3[], double pt4[]) { this->FromPoint[0][0] = pt1[0]; this->FromPoint[0][1] = pt1[1]; this->FromPoint[1][0] = pt2[0]; this->FromPoint[1][1] = pt2[1]; this->FromPoint[2][0] = pt3[0]; this->FromPoint[2][1] = pt3[1]; this->FromPoint[3][0] = pt4[0]; this->FromPoint[3][1] = pt4[1]; } void vtkVgCoordinateTransform::SetFromPoints(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { this->FromPoint[0][0] = x1; this->FromPoint[0][1] = y1; this->FromPoint[1][0] = x2; this->FromPoint[1][1] = y2; this->FromPoint[2][0] = x3; this->FromPoint[2][1] = y3; this->FromPoint[3][0] = x4; this->FromPoint[3][1] = y4; } void vtkVgCoordinateTransform::SetToPoints(double pt1[], double pt2[], double pt3[], double pt4[]) { this->ToPoint[0][0] = pt1[0]; this->ToPoint[0][1] = pt1[1]; this->ToPoint[1][0] = pt2[0]; this->ToPoint[1][1] = pt2[1]; this->ToPoint[2][0] = pt3[0]; this->ToPoint[2][1] = pt3[1]; this->ToPoint[3][0] = pt4[0]; this->ToPoint[3][1] = pt4[1]; } void vtkVgCoordinateTransform::SetToPoints(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { this->ToPoint[0][0] = x1; this->ToPoint[0][1] = y1; this->ToPoint[1][0] = x2; this->ToPoint[1][1] = y2; this->ToPoint[2][0] = x3; this->ToPoint[2][1] = y3; this->ToPoint[3][0] = x4; this->ToPoint[3][1] = y4; } vtkSmartPointer<vtkMatrix4x4> vtkVgCoordinateTransform::GetHomographyMatrix() { std::vector<vgl_homg_point_2d<double> > fromPoints; std::vector<vgl_homg_point_2d<double> > toPoints; for (int i = 0; i < 4; ++i) { vgl_homg_point_2d<double> vglPt2d(this->FromPoint[i][0], this->FromPoint[i][1], 1); fromPoints.push_back(vglPt2d); } for (int i = 0; i < 4; ++i) { vgl_homg_point_2d<double> vglPt2d(this->ToPoint[i][0], this->ToPoint[i][1], 1); toPoints.push_back(vglPt2d); } vgl_h_matrix_2d_compute_linear algo; vgl_h_matrix_2d<double> homography; bool success = algo.compute(fromPoints, toPoints, homography); if (success) { return vtkVgAdapt(homography.get_matrix()); } else { return 0; } }
#include "vtkVgCoordinateTransform.h" #include <vtkVgAdapt.h> #include <vtkMatrix4x4.h> #include <vtkObjectFactory.h> #include <vgl/vgl_homg_point_2d.h> #include <vgl/algo/vgl_h_matrix_2d.h> #include <vgl/algo/vgl_h_matrix_2d_compute_linear.h> vtkStandardNewMacro(vtkVgCoordinateTransform); vtkVgCoordinateTransform::vtkVgCoordinateTransform() { } vtkVgCoordinateTransform::~vtkVgCoordinateTransform() { } void vtkVgCoordinateTransform::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os, indent); } void vtkVgCoordinateTransform::SetFromPoints(double pt1[], double pt2[], double pt3[], double pt4[]) { this->FromPoint[0][0] = pt1[0]; this->FromPoint[0][1] = pt1[1]; this->FromPoint[1][0] = pt2[0]; this->FromPoint[1][1] = pt2[1]; this->FromPoint[2][0] = pt3[0]; this->FromPoint[2][1] = pt3[1]; this->FromPoint[3][0] = pt4[0]; this->FromPoint[3][1] = pt4[1]; } void vtkVgCoordinateTransform::SetFromPoints(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { this->FromPoint[0][0] = x1; this->FromPoint[0][1] = y1; this->FromPoint[1][0] = x2; this->FromPoint[1][1] = y2; this->FromPoint[2][0] = x3; this->FromPoint[2][1] = y3; this->FromPoint[3][0] = x4; this->FromPoint[3][1] = y4; } void vtkVgCoordinateTransform::SetToPoints(double pt1[], double pt2[], double pt3[], double pt4[]) { this->ToPoint[0][0] = pt1[0]; this->ToPoint[0][1] = pt1[1]; this->ToPoint[1][0] = pt2[0]; this->ToPoint[1][1] = pt2[1]; this->ToPoint[2][0] = pt3[0]; this->ToPoint[2][1] = pt3[1]; this->ToPoint[3][0] = pt4[0]; this->ToPoint[3][1] = pt4[1]; } void vtkVgCoordinateTransform::SetToPoints(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
vtkSmartPointer<vtkMatrix4x4> vtkVgCoordinateTransform::GetHomographyMatrix() { std::vector<vgl_homg_point_2d<double> > fromPoints; std::vector<vgl_homg_point_2d<double> > toPoints; for (int i = 0; i < 4; ++i) { vgl_homg_point_2d<double> vglPt2d(this->FromPoint[i][0], this->FromPoint[i][1], 1); fromPoints.push_back(vglPt2d); } for (int i = 0; i < 4; ++i) { vgl_homg_point_2d<double> vglPt2d(this->ToPoint[i][0], this->ToPoint[i][1], 1); toPoints.push_back(vglPt2d); } vgl_h_matrix_2d_compute_linear algo; vgl_h_matrix_2d<double> homography; bool success = algo.compute(fromPoints, toPoints, homography); if (success) { return vtkVgAdapt(homography.get_matrix()); } else { return 0; } }
this->ToPoint[0][0] = x1; this->ToPoint[0][1] = y1; this->ToPoint[1][0] = x2; this->ToPoint[1][1] = y2; this->ToPoint[2][0] = x3; this->ToPoint[2][1] = y3; this->ToPoint[3][0] = x4; this->ToPoint[3][1] = y4; }
function_block-function_prefix_line
[ { "content": "class QT_TESTINGSUPPORT_EXPORT pqQteDoubleSliderEventPlayer :\n\n public pqWidgetEventPlayer\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n pqQteDoubleSliderEventPlayer(QObject* p = 0);\n\n\n\n bool playEvent(QObject* Object, const QString& Command, const QString& Arguments, bool& Error);\n\n\n\nprivate:\n\n Q_DISABLE_COPY(pqQteDoubleSliderEventPlayer)\n\n};\n\n\n\n#endif // !_pqQteDoubleSliderEventPlayer_h", "file_path": "Libraries/QtTestingSupport/pqQteDoubleSliderEventPlayer.h", "rank": 0, "score": 52769.839565178176 }, { "content": "class QT_TESTINGSUPPORT_EXPORT pqQteDoubleSliderEventTranslator :\n\n public pqWidgetEventTranslator\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n pqQteDoubleSliderEventTranslator(QObject* p = 0);\n\n\n\n virtual bool translateEvent(QObject* Object, QEvent* Event, bool& Error);\n\n\n\nprivate:\n\n Q_DISABLE_COPY(pqQteDoubleSliderEventTranslator)\n\n\n\n QObject* CurrentObject;\n\n\n\nprivate slots:\n\n void onValueChanged(double);\n\n};\n\n\n\n#endif // !_pqQteDoubleSliderEventTranslator_h\n", "file_path": "Libraries/QtTestingSupport/pqQteDoubleSliderEventTranslator.h", "rank": 1, "score": 52769.839565178176 }, { "content": "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR\n\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef _pqQteDoubleSliderEventPlayer_h\n\n#define _pqQteDoubleSliderEventPlayer_h\n\n\n\n#include <pqWidgetEventPlayer.h>\n\n\n\n#include <vgExport.h>\n\n\n\n/**\n\nConcrete implementation of pqWidgetEventPlayer that handles playback of recorded qtDoubleSlider user input.\n\n\n\n\\sa pqEventPlayer\n\n*/\n", "file_path": "Libraries/QtTestingSupport/pqQteDoubleSliderEventPlayer.h", "rank": 2, "score": 47031.678339405225 }, { "content": "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR\n\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef _pqQteDoubleSliderEventTranslator_h\n\n#define _pqQteDoubleSliderEventTranslator_h\n\n\n\n#include \"pqWidgetEventTranslator.h\"\n\n\n\n#include <vgExport.h>\n\n\n\n/**\n\nTranslates low-level Qt events into high-level ParaView events that can be recorded as test cases.\n\n\n\n\\sa pqEventTranslator\n\n*/\n\n\n", "file_path": "Libraries/QtTestingSupport/pqQteDoubleSliderEventTranslator.h", "rank": 3, "score": 47030.98081845511 }, { "content": "/*=========================================================================\n\n\n\n Program: ParaView\n\n Module: pqQteDoubleSliderEventTranslator.h\n\n\n\n Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.\n\n All rights reserved.\n\n\n\n ParaView is a free software; you can redistribute it and/or modify it\n\n under the terms of the ParaView license version 1.2.\n\n\n\n See License_v1.2.txt for the full ParaView license.\n\n A copy of this license can be obtained by contacting\n\n Kitware Inc.\n\n 28 Corporate Drive\n\n Clifton Park, NY 12065\n\n USA\n\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n", "file_path": "Libraries/QtTestingSupport/pqQteDoubleSliderEventTranslator.h", "rank": 4, "score": 47028.58388006288 }, { "content": "/*=========================================================================\n\n\n\n Program: ParaView\n\n Module: pqQteDoubleSliderEventPlayer.h\n\n\n\n Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.\n\n All rights reserved.\n\n\n\n ParaView is a free software; you can redistribute it and/or modify it\n\n under the terms of the ParaView license version 1.2.\n\n\n\n See License_v1.2.txt for the full ParaView license.\n\n A copy of this license can be obtained by contacting\n\n Kitware Inc.\n\n 28 Corporate Drive\n\n Clifton Park, NY 12065\n\n USA\n\n\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n", "file_path": "Libraries/QtTestingSupport/pqQteDoubleSliderEventPlayer.h", "rank": 5, "score": 47028.58388006288 }, { "content": "class QDoubleSpinBox;\n", "file_path": "Applications/VpView/vpGraphModelWidget.h", "rank": 6, "score": 45921.49001921082 }, { "content": "// Forward declarations.\n\nclass vtkInformationDoubleKey;\n", "file_path": "Libraries/VtkVgModelView/vtkVgRepresentationBase.h", "rank": 7, "score": 43869.385660511696 }, { "content": " void SetToPoints(double x1, double y1,\n\n double x2, double y2,\n\n double x3, double y3,\n\n double x4, double y4);\n\n\n\n vtkSmartPointer<vtkMatrix4x4> GetHomographyMatrix();\n\n\n\nprotected:\n\n vtkVgCoordinateTransform();\n\n virtual ~vtkVgCoordinateTransform();\n\n\n\n double FromPoint[4][2];\n\n double ToPoint[4][2];\n\n\n\nprivate:\n\n vtkVgCoordinateTransform(const vtkVgCoordinateTransform&); // Not implemented.\n\n void operator=(const vtkVgCoordinateTransform&); // Not implemented.\n\n};\n\n\n\n#endif // __vtkVgCoordinateTransform_h\n", "file_path": "Libraries/VtkVgQtSceneUtil/vtkVgCoordinateTransform.h", "rank": 8, "score": 34.448571112913086 }, { "content": " void SetForegroundColor(double color[3]);\n\n\n\n // Description:\n\n // Compute event time using node's position and timeline view\n\n vtkVgTimeStamp ComputeNodeStartTime(double x, double y, double z);\n\n\n\n // Description:\n\n // Return current layout extents\n\n void GetCurrentLayoutExtents(vgRange<double>& xext, vgRange<double>& yext);\n\n\n\nprotected:\n\n /// Add graph to the representation\n\n void AddGraph(vtkGraph* graph, const std::string& domain);\n\n\n\n vtkIdType PickNodes(double x1, double y1, double x2, double y2,\n\n vtkRenderer* ren);\n\n vtkIdType PickEdges(double x1, double y1, double x2, double y2,\n\n vtkRenderer* ren);\n\n\n\n /// Layout implementations\n", "file_path": "Applications/VpView/vpMultiGraphRepresentation.h", "rank": 9, "score": 22.593757139580898 }, { "content": " void Initialize();\n\n\n\n /// Set the item on the representation.\n\n void SetGraphModel(vpMultiGraphModel* graphModel);\n\n vpMultiGraphModel* GetGraphModel() const;\n\n\n\n /// Update all the event actors. Generally called by the application layer.\n\n virtual void Update();\n\n\n\n /// Pick operation from display (i.e., pixel) coordinates in the current\n\n /// renderer. Return the picked eventId if a successful pick occurs,\n\n /// otherwise return -1. Note that the pick operation takes into account\n\n /// whether the event is currently visible or not.\n\n virtual vtkIdType Pick(double renX, double renY,\n\n vtkRenderer* ren, vtkIdType& pickType);\n\n\n\n // Pick within bounding rectangle\n\n vtkIdType Pick(double x1, double y1, double x2, double y2,\n\n vtkRenderer* ren, vtkIdType& pickType);\n\n\n", "file_path": "Applications/VpView/vpMultiGraphRepresentation.h", "rank": 10, "score": 16.80161777830034 }, { "content": "\n\n//-----------------------------------------------------------------------------\n\ntemplate <typename T>\n\nvoid vtkVgTypeRegistry<T>::PrintSelf(ostream& os, vtkIndent indent)\n\n{\n\n this->Superclass::PrintSelf(os, indent);\n\n\n\n os << indent << \"Types:\\n\";\n\n for (int i = 0, end = this->GetNumberOfTypes(); i < end; ++i)\n\n {\n\n os << indent << this->Types[i].GetName()\n\n << \" (\" << this->Types[i].GetId() << \")\\n\";\n\n }\n\n}\n\n\n\n//-----------------------------------------------------------------------------\n\ntemplate <typename T>\n\nint vtkVgTypeRegistry<T>::GetNumberOfTypes() const\n\n{\n\n return static_cast<int>(this->Types.size());\n", "file_path": "Libraries/VtkVgCore/vtkVgTypeRegistry.h", "rank": 11, "score": 16.001990666367565 }, { "content": " DescriptorStyleGroup,\n\n UserType = 32\n\n };\n\n\n\n enum Column\n\n {\n\n Name = 0x1,\n\n Source = 0x2,\n\n TimeRange = 0x4,\n\n All = 0xf\n\n };\n\n Q_DECLARE_FLAGS(Columns, Column)\n\n\n\n explicit vvDescriptorInfoTree(QWidget* parent = 0);\n\n virtual ~vvDescriptorInfoTree();\n\n\n\n void setItemFactory(vvDescriptorInfoTreeItemFactory*);\n\n\n\n QHash<qint64, vvDescriptor> descriptors() const;\n\n QList<vvDescriptor> descriptors(QList<qint64>) const;\n", "file_path": "Libraries/VvWidgets/vvDescriptorInfoTree.h", "rank": 12, "score": 14.999139121120143 }, { "content": " // Standard VTK functions.\n\n static vtkVgInteractorStyleRubberBand2D* New();\n\n vtkTypeMacro(vtkVgInteractorStyleRubberBand2D, vtkInteractorStyleRubberBand2D);\n\n\n\n virtual void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n // Description:\n\n // Constructor / Destructor.\n\n vtkVgInteractorStyleRubberBand2D();\n\n ~vtkVgInteractorStyleRubberBand2D();\n\n\n\n // Description:\n\n virtual void OnKeyPress();\n\n\n\n virtual void OnChar();\n\n\n\n // Description:\n\n // Overriding these functions to implement custom\n\n // interactions.\n\n virtual void OnLeftButtonDown();\n", "file_path": "Libraries/VtkVgCore/vtkVgInteractorStyleRubberBand2D.h", "rank": 13, "score": 13.635539950820226 }, { "content": " void setTrackUpdateChunkSize(int frames)\n\n {\n\n this->TrackUpdateChunkSize = frames;\n\n }\n\n\n\n double getGeoDistance(double imagePt1[4], double imagePt2[4],\n\n double& latDist, double& lonDist);\n\n\n\n void setRealTimeVideoPlayback(bool enable);\n\n\n\n void setRulerEnabled(bool enable);\n\n\n\n void setColorWindow(double colorWindow);\n\n void setColorLevel(double colorLevel);\n\n\n\n void zoomIn();\n\n void zoomOut();\n\n\n\nprotected slots:\n\n void forceUpdate();\n", "file_path": "Applications/VpView/vpViewCore.h", "rank": 14, "score": 13.380631819952873 }, { "content": " virtual void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n // Description:\n\n // Set/Get layout mode.\n\n void SetLayoutMode(int);\n\n vtkGetMacro(LayoutMode, int);\n\n\n\n // Description:\n\n // Set/Get blast flag that will move the children away from each other.\n\n vtkSetMacro(Blast, int);\n\n vtkGetMacro(Blast, int);\n\n vtkBooleanMacro(Blast, int);\n\n\n\n // Description:\n\n vtkSetMacro(Stack, int);\n\n vtkGetMacro(Stack, int);\n\n vtkBooleanMacro(Stack, int);\n\n\n\n // Description:\n\n vtkSetMacro(ZSort, int);\n", "file_path": "Applications/Viqui/vtkVQBlastLayoutNode.h", "rank": 15, "score": 12.649922627296885 }, { "content": "\n\n static vtkVgNodeBase* New();\n\n\n\n virtual void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n // Description:\n\n // Set/Get name for the node.\n\n vtkSetStringMacro(Name);\n\n const char* GetName() const;\n\n\n\n // Description:\n\n // Set/Get visibility flag.\n\n virtual int SetVisible(int flag);\n\n vtkGetMacro(Visible, int);\n\n vtkBooleanMacro(Visible, int);\n\n\n\n // Description:\n\n // Flag that indicates is state of this node is dirty.\n\n vtkSetMacro(Dirty, int);\n\n vtkGetMacro(Dirty, int);\n", "file_path": "Libraries/VtkVgSceneGraph/vtkVgNodeBase.h", "rank": 16, "score": 11.865292925966534 }, { "content": " // Standard VTK functions.\n\n static vtkVgEventBase* New();\n\n vtkTypeMacro(vtkVgEventBase, vtkObject);\n\n virtual void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n // Description:\n\n // Set/Get the points used for the \"region\" that may or may not be present at\n\n // frames during the event.\n\n vtkGetObjectMacro(RegionPoints, vtkPoints);\n\n void SetRegionPoints(vtkPoints* points);\n\n\n\n void AddRegion(const vtkVgTimeStamp& timeStamp,\n\n vtkIdType numberOfRegionPts, double* regionPts);\n\n void SetRegion(const vtkVgTimeStamp& timeStamp,\n\n vtkIdType numberOfRegionPts, double* regionPts);\n\n void GetRegion(const vtkVgTimeStamp& timeStamp,\n\n vtkIdType& npts, vtkIdType*& pts);\n\n bool GetRegionCenter(const vtkVgTimeStamp& timeStamp, double* center,\n\n bool interpolated);\n\n bool GetRegionAtOrAfter(vtkVgTimeStamp& timeStamp,\n", "file_path": "Libraries/VtkVgCore/vtkVgEventBase.h", "rank": 17, "score": 11.665720840866214 }, { "content": " virtual void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n static vtkVgGraphRepresentation* New();\n\n\n\n static std::string GetGraphEdgeColorModeString(int mode);\n\n static std::string GetGraphEdgeThicknessModeString(int mode);\n\n\n\n // Description:\n\n // Return all the objects that can be rendered.\n\n virtual const vtkPropCollection* GetNewRenderObjects() const;\n\n virtual const vtkPropCollection* GetActiveRenderObjects() const;\n\n virtual const vtkPropCollection* GetExpiredRenderObjects() const;\n\n\n\n virtual vtkPropCollection* GetNewRenderObjects();\n\n virtual vtkPropCollection* GetActiveRenderObjects();\n\n virtual vtkPropCollection* GetExpiredRenderObjects();\n\n\n\n virtual void ResetTemporaryRenderObjects();\n\n\n\n // Description:\n", "file_path": "Libraries/VtkVgModelView/vtkVgGraphRepresentation.h", "rank": 18, "score": 11.488903062739977 }, { "content": " vtkVgClassMacro(vqArchiveVideoSource);\n\n\n\n // Description:\n\n // Usual VTK functions.\n\n vtkTypeMacro(vqArchiveVideoSource, vtkVgVideoProviderBase);\n\n\n\n static vqArchiveVideoSource* New();\n\n\n\n virtual void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n // Description:\n\n // Get and store a clip from a given ::vgKwaArchive.\n\n int AcquireVideoClip(vgKwaArchive* videoArchive);\n\n\n\n // Description:\n\n // Get and store a clip from a given URI.\n\n int AcquireVideoClip(QUrl);\n\n\n\n QUrl GetClipUri() const\n\n {\n", "file_path": "Applications/Viqui/vqArchiveVideoSource.h", "rank": 19, "score": 11.414732227910331 }, { "content": " virtual void GetPickPosition(double pos[3])\n\n {\n\n pos[0] = VTK_DOUBLE_MIN;\n\n pos[1] = VTK_DOUBLE_MIN;\n\n pos[2] = VTK_DOUBLE_MIN;\n\n }\n\n\n\n // Description:\n\n // Color value modifier.\n\n vtkSetClampMacro(ColorMultiplier, double, 0.0, 1.0);\n\n vtkGetMacro(ColorMultiplier, double);\n\n\n\n // Description:\n\n // Force the representation to display all objects in a single color\n\n void SetOverrideColor(const double color[3]);\n\n\n\n // Description:\n\n // Set the display mask that this representation will use.\n\n vtkSetMacro(DisplayMask, unsigned);\n\n vtkGetMacro(DisplayMask, unsigned);\n", "file_path": "Libraries/VtkVgModelView/vtkVgRepresentationBase.h", "rank": 20, "score": 9.985177593376621 }, { "content": "\n\nsignals:\n\n void invalidateHomographyCaching();\n\n\n\nprivate slots:\n\n void updateXMin();\n\n void updateYMin();\n\n void updateBox();\n\n void bundleCropSelect();\n\n void cropSelect();\n\n void disable();\n\n void frameChanged();\n\n void runBundleAdjustment();\n\n void onBundleSelectionComplete();\n\n void onSelectionComplete();\n\n void onRunClicked();\n\n void updateNumImages();\n\n void cacheHomographies(std::string, std::vector<vgl_h_matrix_2d<double> >);\n\n void imageIncludeChanged(bool);\n\n void onImageListSelection();\n", "file_path": "Applications/VpView/vpSuperResWidget.h", "rank": 21, "score": 9.950457021432785 }, { "content": " // Return whether or not this timestamp set to max time\n\n bool IsMaxTime() const\n\n {\n\n return this->Time == VTK_DOUBLE_MAX;\n\n }\n\n\n\n void SetToMinTime()\n\n {\n\n this->Time = VTK_DOUBLE_MIN;\n\n }\n\n bool IsMinTime() const\n\n {\n\n return this->Time == VTK_DOUBLE_MIN;\n\n }\n\n\n\n // Description:\n\n // Returns true if this contains time, otherwise false.\n\n bool HasTime() const\n\n {\n\n return vgTimeStamp::HasTime();\n", "file_path": "Libraries/VtkVgCore/vtkVgTimeStamp.h", "rank": 22, "score": 9.82765847535285 }, { "content": " JSONNode exportToJson();\n\n\n\n void saveState(JSONNode& root);\n\n\n\n void getWorldViewport(double (&viewport)[4], double offX, double offY);\n\n\n\n void setParameterValue(double value, QDoubleSpinBox* widget);\n\n\n\nprotected slots:\n\n void enableCreateNode(bool flag);\n\n void enableCreateEdge(bool flag);\n\n\n\n void createNode(double x, double y);\n\n void createNodeSpatial(double x, double y);\n\n\n\n void createEdge();\n\n void createEdge(int parentId, int childId);\n\n\n\n void removeNodes();\n\n void removeEdges();\n", "file_path": "Applications/VpView/vpGraphModelWidget.h", "rank": 23, "score": 9.77597631571686 }, { "content": " // reimplemented from QWidget\n\n virtual void contextMenuEvent(QContextMenuEvent* event);\n\n virtual void leaveEvent(QEvent* event);\n\n\n\n virtual void mousePressEvent(QMouseEvent* event);\n\n virtual void mouseDoubleClickEvent(QMouseEvent* event);\n\n\n\n virtual QSize sizeHint() const\n\n { return QSize(500, 300); }\n\n\n\n virtual QSize minimumSizeHint() const\n\n { return QSize(300, 200); }\n\n\n\nsignals:\n\n void NodesSelected(QList<vtkVgNodeBase*> nodes);\n\n void NodeActivated(vtkVgNodeBase& node);\n\n void MouseLeft();\n\n void ContextMenuOpened(QMenu& menu);\n\n void ItemsChanged();\n\n\n", "file_path": "Applications/Viqui/vqTreeView.h", "rank": 24, "score": 9.299507612838244 }, { "content": " {\n\n return vgTimeStamp::IsValid();\n\n }\n\n\n\n // Description:\n\n // Reset to initialized state (no time or frame #)\n\n void Reset()\n\n {\n\n this->Time = vgTimeStamp::InvalidTime();\n\n this->FrameNumber = vgTimeStamp::InvalidFrameNumber();\n\n }\n\n\n\n // Description:\n\n // Set time to large value, any comparison (frame or time), will have this\n\n // timestamp grater than other, unless both at max time\n\n void SetToMaxTime()\n\n {\n\n this->Time = VTK_DOUBLE_MAX;\n\n }\n\n\n", "file_path": "Libraries/VtkVgCore/vtkVgTimeStamp.h", "rank": 25, "score": 8.859933844224127 }, { "content": " QList<vvDescriptor> descriptors(QList<QTreeWidgetItem*>,\n\n bool includeChildren = false) const;\n\n QList<qint64> descriptorIds(QList<QTreeWidgetItem*>,\n\n bool includeChildren = false) const;\n\n\n\n QTreeWidgetItem* findItem(int type, qint64 id, QTreeWidgetItem* from = 0);\n\n QList<QTreeWidgetItem*> findItems(int type, qint64 id = -1);\n\n\n\n QList<QTreeWidgetItem*> descriptorItems(qint64 id = -1);\n\n\n\n bool groupByStyle() const;\n\n void setStyleMap(vvDescriptorStyle::Map);\n\n void setColumns(Columns columns, bool setHeaders = true);\n\n\n\n static qint64 itemId(const QTreeWidgetItem*, bool* isValid = 0);\n\n static int itemType(const QTreeWidgetItem*);\n\n static void setItemId(QTreeWidgetItem*, qint64);\n\n static void setItemType(QTreeWidgetItem*, int);\n\n\n\nsignals:\n", "file_path": "Libraries/VvWidgets/vvDescriptorInfoTree.h", "rank": 26, "score": 8.644709528409464 }, { "content": " Unknown = 0x0,\n\n Person = 0x1,\n\n Vehicle = 0x2,\n\n Classifier = 0xf,\n\n Alert = 0x10,\n\n General = 0x20,\n\n User = 0x80,\n\n NonUser = 0x7f,\n\n All = 0xff\n\n };\n\n Q_DECLARE_FLAGS(Groups, Group)\n\n\n\n enum Type\n\n {\n\n Tripwire = -3000,\n\n EnteringRegion = -3001,\n\n ExitingRegion = -3002,\n\n Annotation = -4000,\n\n // NOTE: -5000 - -5??? reserved by vsTrackInfo\n\n QueryAlert = -10000,\n", "file_path": "Libraries/VspData/vsEventInfo.h", "rank": 27, "score": 8.618245977601738 }, { "content": "\n\nprivate:\n\n void completeSelection(bool isBundleCrop);\n\n\n\n void readSuperResParams(super3d::super_res_params::TV_METHOD method,\n\n super3d::super_res_params* srp,\n\n double regularizationScale);\n\n void updateImageInclusion();\n\n QListWidgetItem* buildImageIncludeList(int currentFrame);\n\n\n\n void loadImagery(std::vector<std::string>& filenames);\n\n\n\n void updateHomographyReferenceFrameAndCamera(int newReferenceFrame);\n\n\n\n Ui::vpSuperResWidget* Ui;\n\n\n\n vpViewCore* ViewCoreInstance;\n\n vtkSmartPointer<vtkActor> CropRegionActor;\n\n vtkSmartPointer<vtkPoints> CropRegionPoints;\n\n\n", "file_path": "Applications/VpView/vpSuperResWidget.h", "rank": 28, "score": 8.566315224003235 }, { "content": "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR\n\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef _pqVgMixerEventPlayer_h\n\n#define _pqVgMixerEventPlayer_h\n\n\n\n#include <pqWidgetEventPlayer.h>\n\n\n\n#include <vgExport.h>\n\n\n\n/**\n\nConcrete implementation of pqWidgetEventPlayer that handles playback of recorded qtDoubleSlider user input.\n\n\n\n\\sa pqEventPlayer\n\n*/\n", "file_path": "Libraries/QtTestingSupport/pqVgMixerEventPlayer.h", "rank": 29, "score": 8.492154948953871 }, { "content": "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR\n\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\nEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\nPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef _pqQDialogButtonBoxEventPlayer_h\n\n#define _pqQDialogButtonBoxEventPlayer_h\n\n\n\n#include <pqWidgetEventPlayer.h>\n\n\n\n#include <vgExport.h>\n\n\n\n/**\n\nConcrete implementation of pqWidgetEventPlayer that handles playback of recorded qtDoubleSlider user input.\n\n\n\n\\sa pqEventPlayer\n\n*/\n", "file_path": "Libraries/QtTestingSupport/pqQDialogButtonBoxEventPlayer.h", "rank": 30, "score": 8.383710116096665 }, { "content": " // Main \"execute\" function to check the status of all \"trip wires\" relative\n\n // to the tracks in the track model.\n\n void CheckTripWires();\n\n\n\n // Description:\n\n // Check the specified trip-wire for interesections against all tracks in the\n\n // TrackModel.\n\n void CheckTripWire(vtkIdType tripWireId, std::vector<IntersectionInfo>& intersections);\n\n\n\n // Description:\n\n //int ClassifierType, // Entering, Exiting, or TripWire\n\n //double IntersectionPt[2], // x, y of intersection\n\n //vtkVgTimeStamp &IntersectionTime); // Interpolated \"Time\" at IntersectionPt\n\n void CheckTrackSegment(double pt1[2], double p2[2],\n\n const vtkVgTimeStamp& timeStamp1, const vtkVgTimeStamp& timeStamp2,\n\n std::vector<IntersectionInfo>& intersections);\n\n\n\n // Description:\n\n // Make sure the event model is up to date regarding detected trip wire events\n\n void UpdateEventModel(const vtkVgTimeStamp& timestamp);\n", "file_path": "Libraries/VtkVgModelView/vtkVgTripWireManager.h", "rank": 31, "score": 7.947797523054908 }, { "content": " // Description:\n\n // Set if the label should include the classifier score\n\n vtkSetMacro(ShowProbability, bool);\n\n vtkGetMacro(ShowProbability, bool);\n\n\n\n // Description:\n\n // Set if the label should include the event note\n\n vtkSetMacro(ShowNote, bool);\n\n vtkGetMacro(ShowNote, bool);\n\n\n\n // Description:\n\n // Update all the event actors. Generally called by the application layer.\n\n virtual void Update();\n\n\n\n // Description:\n\n // Set/Get prefix to add to the label\n\n vtkSetStringMacro(LabelPrefix);\n\n vtkGetStringMacro(LabelPrefix);\n\n\n\n enum enumLocationSourceMode\n", "file_path": "Libraries/VtkVgModelView/vtkVgEventLabelRepresentation.h", "rank": 32, "score": 7.911716592730486 }, { "content": " // Get the units of the stored data\n\n // Return false if type is not ASCII\n\n std::string& GetUnits(void);\n\n\n\nprotected:\n\n ~vtkVgNitfEngrdaElement(void);\n\n\n\nprivate:\n\n friend class vtkVgNitfEngrda;\n\n\n\n std::string Label;\n\n size_t MatrixColumnCount;\n\n size_t MatrixRowCount;\n\n char Type;\n\n size_t DataTypeSize;\n\n std::string DataUnits;\n\n size_t DataCount;\n\n\n\n // FIXME: Extend for other data types\n\n union\n\n {\n\n char* Data;\n\n int DataInt;\n\n float DataFloat;\n\n double DataDouble;\n\n };\n\n};\n\ntypedef vtkSmartPointer<vtkVgNitfEngrdaElement> vtkVgNitfEngrdaElementRefPtr;\n\n\n", "file_path": "Libraries/VtkVgIO/vtkVgNitfEngrda.h", "rank": 33, "score": 7.688312535232902 }, { "content": "\n\n /// Location of application user manual.\n\n ///\n\n /// This specifies the file name or location of the application's user\n\n /// manual.\n\n ///\n\n /// \\sa userManualLocation(), setUserManualLocation()\n\n Q_PROPERTY(QString userManualLocation READ userManualLocation\n\n WRITE setUserManualLocation)\n\n\n\npublic:\n\n enum HelpMenuEntry\n\n {\n\n UserManualAction = 0x1,\n\n AboutAction = 0x2,\n\n FullHelpMenu = 0xff\n\n };\n\n Q_DECLARE_FLAGS(HelpMenuEntries, HelpMenuEntry);\n\n\n\npublic:\n", "file_path": "Libraries/QtVgWidgets/vgApplication.h", "rank": 34, "score": 7.587753881368895 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n// The size of this class is kept small (sizeof(void*)) so that it can be\n\n// efficiently passed by value and inserted into \"inline\" data structures\n\n// with minimal overhead.\n\n\n\n#ifndef __vtkVgEventInfo_h\n\n#define __vtkVgEventInfo_h\n\n\n\n#include \"vgPointerInt.h\"\n\n\n", "file_path": "Libraries/VtkVgModelView/vtkVgEventInfo.h", "rank": 35, "score": 7.321421848546459 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n// The size of this class is kept small (sizeof(void*)) so that it can be\n\n// efficiently passed by value and inserted into \"inline\" data structures\n\n// with minimal overhead.\n\n\n\n#ifndef __vtkVgTrackInfo_h\n\n#define __vtkVgTrackInfo_h\n\n\n\n#include \"vgPointerInt.h\"\n\n\n", "file_path": "Libraries/VtkVgModelView/vtkVgTrackInfo.h", "rank": 36, "score": 7.321421848546459 }, { "content": "\n\n /// Set location of application user manual.\n\n ///\n\n /// This method will resolve non-absolute paths so that the stored value is\n\n /// always a complete absolute path. If a name without path is given\n\n /// (recommended), the user manual is assumed to be in a well known relative\n\n /// location with respect to the location of the application executable.\n\n ///\n\n /// The result of specifying a relative path is not specified.\n\n ///\n\n /// \\sa userManualLocation, userManualLocation()\n\n static void setUserManualLocation(const QString&);\n\n\n\n /// Create standard help menu actions.\n\n ///\n\n /// This creates the specified standard actions in the application's Help\n\n /// menu. This includes activation slots for the actions, i.e. the actions\n\n /// will function with no additional setup required.\n\n static void setupHelpMenu(QMenu*, HelpMenuEntries = FullHelpMenu);\n\n\n", "file_path": "Libraries/QtVgWidgets/vgApplication.h", "rank": 37, "score": 7.221286248548754 }, { "content": "// Qt includes\n\n#include <QDebug>\n\n#include <QMouseEvent>\n\n#include <QKeyEvent>\n\n#include <QStyleOptionSlider>\n\n#include <QApplication>\n\n#include <QStylePainter>\n\n#include <QStyle>\n\n\n\n// CTK includes\n\n#include \"ctkRangeSlider.h\"\n\n\n", "file_path": "Libraries/QtVgWidgets/ctkRangeSlider.cpp", "rank": 38, "score": 6.670564795996662 }, { "content": "#include <vtkVgVideoFrameMetaData.h>\n\n\n\n#include <vsDataSource.h>\n\n#include <vsDescriptor.h>\n\n#include <vsDescriptorInput.h>\n\n#include <vsEvent.h>\n\n#include <vsEventInfo.h>\n\n#include <vsSourceFactory.h>\n\n#include <vsTrackClassifier.h>\n\n#include <vsTrackData.h>\n\n#include <vsTrackId.h>\n\n\n\n#include \"vsAlert.h\"\n\n#include \"vsContourWidget.h\"\n\n\n", "file_path": "Libraries/VspUserInterface/vsCore.h", "rank": 39, "score": 6.657661853624339 }, { "content": "#include <qtStatusSource.h>\n\n\n\n// VTK includes\n\n#include <vtkSmartPointer.h>\n\n\n\n// VISGUI includes\n\n#include <vtkVgTimeStamp.h>\n\n#include <vvQueryFormulation.h>\n\n#include <vvQueryInstance.h>\n\n#include <vvQueryResult.h>\n\n\n\n// Viqui includes\n\n#include \"vqResultFilter.h\"\n\n#include \"vtkVQBlastLayoutNode.h\"\n\n\n\n// Forward declarations.\n", "file_path": "Applications/Viqui/vqCore.h", "rank": 40, "score": 6.650212947833601 }, { "content": "\n\n // Description:\n\n virtual void SetVisible(int flag);\n\n virtual int GetVisible() const { return this->Visible; }\n\n\n\n virtual vtkIdType Pick(double renX,\n\n double renY,\n\n vtkRenderer* ren,\n\n vtkIdType& pickType);\n\n\n\n // Description:\n\n // Set if the label should include the event ID\n\n vtkSetMacro(ShowId, bool);\n\n vtkGetMacro(ShowId, bool);\n\n\n\n // Description:\n\n // Set how many classifiers (max) the label should show\n\n vtkSetMacro(ShowClassifiers, unsigned int);\n\n vtkGetMacro(ShowClassifiers, unsigned int);\n\n\n", "file_path": "Libraries/VtkVgModelView/vtkVgEventLabelRepresentation.h", "rank": 41, "score": 6.630969459829236 }, { "content": "#include <vtkVgTrack.h>\n\n#include <vtkVgTrackModel.h>\n\n#include <vtkVgTrackRepresentation.h>\n\n#include <vtkVgVideoMetadata.h>\n\n#include <vtkVgVideoModel0.h>\n\n#include <vtkVgVideoNode.h>\n\n\n\n// VTK includes\n\n#include <vtkIdList.h>\n\n#include <vtkPoints.h>\n\n\n\n#include \"vvVideoPlayerPrivate.h\"\n\n\n", "file_path": "Libraries/VvVtkWidgets/vvQueryVideoPlayerPrivate.h", "rank": 42, "score": 6.605069748001375 }, { "content": "\n\n#include <qtGlobal.h>\n\n\n\n#include <QThread>\n\n\n\n#include <boost/shared_ptr.hpp>\n\n\n\n#include <fstream>\n\n#include <string>\n\n#include <vector>\n\n\n", "file_path": "Applications/VpView/vpSuperResDepthWarper.h", "rank": 43, "score": 6.588558531823017 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n// Qt includes\n\n#include <QFileInfo>\n\n#include <QHash>\n\n#include <QMap>\n\n#include <QMultiHash>\n\n\n\n// QtExtensions includes\n\n#include <qtUtil.h>\n\n\n\n// visgui includes\n\n#include <vtkVgAdapt.h>\n\n#include <vtkVgCompositeEventRepresentation.h>\n\n#include <vtkVgEvent.h>\n\n#include <vtkVgEventModel.h>\n\n#include <vtkVgEventRegionRepresentation.h>\n\n#include <vtkVgTimeStamp.h>\n", "file_path": "Libraries/VvVtkWidgets/vvQueryVideoPlayerPrivate.h", "rank": 44, "score": 6.5660724841074956 }, { "content": "// visgui includes\n\n#include <vgFileDialog.h>\n\n\n\n// VTK Extensions includes\n\n#include <vtkVgEvent.h>\n\n#include <vtkVgEventRegionRepresentation.h>\n\n#include <vtkVgRegionWidget.h>\n\n\n\n#include <vvDescriptorInfoTree.h>\n\n\n\n#include \"vvQueryVideoPlayer.h\"\n\n\n\nnamespace // anonymous\n\n{\n\n\n", "file_path": "Libraries/VvVtkWidgets/vvVideoQueryDialogPrivate.h", "rank": 45, "score": 6.545363834579607 }, { "content": "#include <qtGlobal.h>\n\n\n\n// Qt includes\n\n#include <QDialog>\n\n#include <QCloseEvent>\n\n\n\n// boost includes\n\n#include <boost/shared_ptr.hpp>\n\n\n\n// Forward declarations.\n", "file_path": "Applications/VpView/vpSuperResDepthViewer.h", "rank": 46, "score": 6.541104168067802 }, { "content": "#include <QSharedPointer>\n\n#include <QString>\n\n#include <QStringList>\n\n\n\n#include <map>\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace kwiver\n\n{\n\nnamespace vital\n\n{\n", "file_path": "Applications/VpView/vpViewCore.h", "rank": 47, "score": 6.541104168067802 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vqCore_h\n\n#define __vqCore_h\n\n\n\n// Qt includes\n\n#include <QVTKWidget.h>\n\n#include <QBasicTimer>\n\n#include <QString>\n\n#include <QList>\n\n#include <QHash>\n\n#include <QMultiMap>\n\n#include <QSet>\n\n#include <QSharedPointer>\n\n#include <QUrl>\n\n\n\n// QtExtensions includes\n\n#include <qtGradient.h>\n", "file_path": "Applications/Viqui/vqCore.h", "rank": 48, "score": 6.537841442116962 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#include \"vvVideoQueryDialog.h\"\n\n#include \"ui_videoQuery.h\"\n\n\n\n#include <QDebug>\n\n#include <QLabel>\n\n#include <QMessageBox>\n\n#include <QProgressBar>\n\n#include <QSettings>\n\n\n\n// Qt Extensions includes\n\n#include <qtScopedValueChange.h>\n\n#include <qtStatusManager.h>\n\n#include <qtUtil.h>\n\n\n\n#include <vgExport.h>\n\n\n", "file_path": "Libraries/VvVtkWidgets/vvVideoQueryDialogPrivate.h", "rank": 49, "score": 6.537841442116962 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpSuperResViewer_h\n\n#define __vpSuperResViewer_h\n\n\n\n// super3d includes\n\n#include <super3d/depth/super_res.h>\n\n\n\n// vidtk includes\n\n#include <video_transforms/super_res.h>\n\n\n\n// vxl includes\n\n#include <vil/vil_image_view.h>\n\n#include <vgl/algo/vgl_h_matrix_2d.h>\n\n\n\n// vtk includes\n\n#include <vtkSmartPointer.h>\n\n\n\n// Qt includes\n\n#include <QDialog>\n\n#include <QCloseEvent>\n\n\n\n// boost includes\n\n#include <boost/shared_ptr.hpp>\n\n\n\n// Forward declarations.\n", "file_path": "Applications/VpView/vpSuperResViewer.h", "rank": 50, "score": 6.535695361895864 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsScene_h\n\n#define __vsScene_h\n\n\n\n#include \"vsAlert.h\"\n\n\n\n#include <vsContour.h>\n\n#include <vsEventInfo.h>\n\n#include <vsVideoSource.h>\n\n\n\n#include <vgfItemReference.h>\n\n\n\n#include <vgVideoPlayer.h>\n\n#include <vgVtkVideoFrame.h>\n\n\n\n#include <vtkVgTrackRepresentationBase.h>\n\n\n\n#include <vgMatrix.h>\n\n\n\n#include <vgExport.h>\n\n\n\n#include <qtGlobal.h>\n\n\n\n#include <QColor>\n\n#include <QObject>\n\n\n", "file_path": "Libraries/VspUserInterface/vsScene.h", "rank": 51, "score": 6.525846240936778 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsScenePrivate_h\n\n#define __vsScenePrivate_h\n\n\n\n#include <vsEventInfo.h>\n\n\n\n#include <vgVideoPlayer.h>\n\n\n\n#include <vtkVgInstance.h>\n\n#include <vtkVgTimeStamp.h>\n\n\n\n#include <vgColor.h>\n\n#include <vgMatrix.h>\n\n\n\n#include <vtkSmartPointer.h>\n\n#include <vtkTimeStamp.h>\n\n\n\n#include <QHash>\n\n#include <QMap>\n\n#include <QPoint>\n\n#include <QSet>\n\n#include <QSharedPointer>\n\n\n", "file_path": "Libraries/VspUserInterface/vsScenePrivate.h", "rank": 52, "score": 6.520439988420708 }, { "content": " void ItemsChanged();\n\n\n\npublic slots:\n\n void FocusItemAlone();\n\n void FocusItem();\n\n\n\nprotected slots:\n\n void OnTreeSelectionChanged();\n\n void OnTreeContextMenu(QMenu& menu);\n\n void CreateEvent(int type);\n\n void DeleteEvent();\n\n void EditTrack();\n\n void StopEditingTrack();\n\n void DeleteTrack();\n\n void SplitTrack();\n\n void ImproveTrack();\n\n void AddEventToActivity();\n\n void RemoveEventFromActivity();\n\n\n\n void SetEventStatus(int status);\n", "file_path": "Applications/VpView/vpObjectSelectionPanel.h", "rank": 53, "score": 6.516964981642532 }, { "content": " void update();\n\n void postRender();\n\n\n\n void onLeftClick();\n\n void onRightButtonPress();\n\n void onRightButtonRelease();\n\n void onMouseWheelForward();\n\n void onMouseWheelBackward();\n\n void onPKeyPress();\n\n\n\n void onContextMenuEvent();\n\n\n\n void addRasterLayer(QUrl uri);\n\n\n\n void drawRegion();\n\n void setRegion(vgGeocodedPoly region);\n\n\n\n void updateScene();\n\n void updateSources();\n\n void updateLOD(bool override = false);\n", "file_path": "Applications/Viqui/vqCore.h", "rank": 54, "score": 6.512168617858049 }, { "content": "\n\n void AddEventsToGraphModel();\n\n void AddTrackEventsToGraphModel();\n\n\n\npublic slots:\n\n void ShowAll();\n\n void HideAll();\n\n\n\n void SortBy(int type, Qt::SortOrder direction);\n\n\n\n void ShowAllTracks();\n\n void HideAllTracks();\n\n\n\n void ShowEventType(int type);\n\n void ShowAllEvents();\n\n void HideAllEvents();\n\n\n\n void ShowActivityType(int type);\n\n void ShowAllActivities();\n\n void HideAllActivities();\n", "file_path": "Applications/VpView/vpTreeView.h", "rank": 55, "score": 6.503739956062841 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vqArchiveVideoSource_h\n\n#define __vqArchiveVideoSource_h\n\n\n\n// VG includes.\n\n#include <vtkVgMacros.h>\n\n#include <vtkVgVideoProviderBase.h>\n\n\n\n// VV includes.\n\n#include <vvIqr.h>\n\n\n\n// STL includes.\n\n#include <vector>\n\n\n\n// QT includes.\n\n#include <QObject>\n\n#include <QSharedPointer>\n\n#include <QUrl>\n\n\n", "file_path": "Applications/Viqui/vqArchiveVideoSource.h", "rank": 56, "score": 6.49456964884962 }, { "content": "\n\n void onVideoPlaying();\n\n void onVideoPaused();\n\n void onVideoStopped();\n\n\n\n void onLeftButtonClicked();\n\n\n\n void reset();\n\n\n\n void resetView();\n\n\n\n void seekTo(double value);\n\n\n\n void setEventRegionVisible(bool);\n\n void setEventFollowingEnabled(bool);\n\n void setPlaybackEnabled(bool);\n\n\n\n void doubleThePlaybackSpeed();\n\n void reducePlaybackSpeedByHalf();\n\n\n", "file_path": "Libraries/VvVtkWidgets/vvVideoPlayer.h", "rank": 57, "score": 6.486573204805329 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpProject_h\n\n#define __vpProject_h\n\n\n\n#include \"vpProjectBase.h\"\n\n\n\n#include <vgAttributeSet.h>\n\n\n\n#include <qtGlobal.h>\n\n\n\n#include <vtkSmartPointer.h>\n\n\n\n#include <QHash>\n\n#include <QSharedPointer>\n\n\n\n#include <string>\n\n#include <map>\n\n#include <vector>\n\n#include <algorithm>\n\n\n", "file_path": "Applications/VpView/vpProject.h", "rank": 58, "score": 6.484802051404319 }, { "content": " void onOverviewLoaded();\n\n void onEnterAdjudicationMode();\n\n void onFollowTrackChange(int trackId);\n\n void onExitFollowTrack();\n\n void toggleAdjudicationMode(bool state);\n\n void exitApp();\n\n void onFrameChange();\n\n void onTimeChange(double now);\n\n void onReachedPlayBoundary();\n\n void onFastBackward();\n\n void onReversePause();\n\n void onPause();\n\n void onPlayPause();\n\n void onFastForward();\n\n void onLoopToggle(bool state);\n\n void onFrameUpdate(int minFrameNumber, int frameNumber, bool resize);\n\n void onTimeUpdate(double minTime, double time, bool resize);\n\n void updateMinTime(double time);\n\n void onFrameIntervalEnabled(int state);\n\n void onTreeSelectionChanged(int sessionId);\n", "file_path": "Applications/VpView/vpView.h", "rank": 59, "score": 6.479319355837096 }, { "content": " void forceRender();\n\n\n\n void reactToDataChanged();\n\n\n\n void reactToExternalProcessFileChanged(QString);\n\n\n\nsignals:\n\n\n\n void dataLoaded();\n\n void dataSetChanged();\n\n void iconsLoaded();\n\n void overviewLoaded();\n\n void followTrackChange(int trackId);\n\n\n\n void trackTypesModified();\n\n\n\n void displayZoom();\n\n void frameChanged();\n\n void frameChanged(const QString&);\n\n void timeChanged(double microseconds);\n", "file_path": "Applications/VpView/vpViewCore.h", "rank": 60, "score": 6.476276980871496 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vvQueryVideoPlayer_h\n\n#define __vvQueryVideoPlayer_h\n\n\n\n#include \"vvVideoPlayer.h\"\n\n\n\n#include <QHash>\n\n#include <QList>\n\n#include <QSet>\n\n#include <QSharedPointer>\n\n#include <QUrl>\n\n\n\n#include <vtkType.h>\n\n\n\n#include <vgExport.h>\n\n\n\n#include <vtkVgTrack.h>\n\n\n\n#include <vvQuery.h>\n\n\n\n#include \"vgRegionKeyframe.h\"\n\n\n", "file_path": "Libraries/VvVtkWidgets/vvQueryVideoPlayer.h", "rank": 61, "score": 6.469334652730426 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vtkVgTrack_h\n\n#define __vtkVgTrack_h\n\n\n\n#include <vtkObject.h>\n\n#include <vtkSmartPointer.h>\n\n#include <vtkDenseArray.h>\n\n#include <vtkBoundingBox.h>\n\n\n\n#include \"vtkVgSetGet.h\"\n\n#include \"vtkVgTimeStamp.h\"\n\n\n\n#include <map>\n\n#include <string>\n\n#include <vector>\n\n\n\n#include <vgExport.h>\n\n\n\n#include \"vtkVgGeoCoord.h\"\n\n\n", "file_path": "Libraries/VtkVgCore/vtkVgTrack.h", "rank": 62, "score": 6.469334652730426 }, { "content": " bool UpdateEventAnnotation(vtkVgEvent* event);\n\n bool UpdateActivityAnnotation(vtkVgActivity* event);\n\n\n\n void AddFrameDelta(std::ostream& os,\n\n unsigned int currFrame,\n\n unsigned int firstFrame, unsigned int lastFrame);\n\n\n\nprivate:\n\n bool Visible;\n\n int ObjectType;\n\n vtkIdType ObjectId;\n\n\n\n union\n\n {\n\n vtkVgTrack* Track;\n\n vtkVgEvent* Event;\n\n vtkVgActivity* Activity;\n\n } Object;\n\n\n\n vpViewCore* ViewCoreInstance;\n\n\n\n vtkVgAnnotationActor* Actor;\n\n\n\n vtkSmartPointer<vtkMatrix4x4> RepresentationMatrix;\n\n};\n\n\n\n#endif // __vpAnnotation_h\n", "file_path": "Applications/VpView/vpAnnotation.h", "rank": 63, "score": 6.46909164069398 }, { "content": " void onLeftRelease();\n\n void onLeftClick();\n\n void onRightClick();\n\n void onMouseMove();\n\n void onSelectionComplete();\n\n\n\n void onEditTrackHeadRegion();\n\n\n\n void resetToAOIView();\n\n void resetView();\n\n void resetToViewExtents();\n\n void getAOIExtents(double extents[4]);\n\n\n\n void decreaseTrackHeadSize();\n\n void toggleImageFiltering();\n\n void increaseTrackHeadSize();\n\n\n\n int pickScene();\n\n\n\n void CreateInformaticsDisplay(int x, int y, vtkImageData* normalcy);\n", "file_path": "Applications/VpView/vpViewCore.h", "rank": 64, "score": 6.467477626641269 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpMultiGraphRepresentation_h\n\n#define __vpMultiGraphRepresentation_h\n\n\n\n#include \"vpMultiGraphModel.h\"\n\n#include \"vpPrimitiveConfig.h\"\n\n\n\n// VisGUI includes\n\n#include <vgRange.h>\n\n#include <vtkVgRepresentationBase.h>\n\n#include <vtkVgPickData.h>\n\n\n\n// VTK includes\n\n#include <vtkActor.h>\n\n#include <vtkSmartPointer.h>\n\n\n\n// C++ includes\n\n#include <map>\n\n\n", "file_path": "Applications/VpView/vpMultiGraphRepresentation.h", "rank": 65, "score": 6.463056515190249 }, { "content": "\n\n void FollowTrack();\n\n\n\n void OnShowLinkedEvents();\n\n void OnHideLinkedEvents();\n\n\n\n void OnShowLinkedActivities();\n\n void OnHideLinkedActivities();\n\n\n\n void OnShownItemsChanged();\n\n\n\n void OnHideAll();\n\n void OnShowAll();\n\n\n\n void OnAddEventsToGraphModel();\n\n void OnAddTrackEventsToGraphModel();\n\n\n\nprotected:\n\n virtual void showEvent(QShowEvent* event);\n\n\n", "file_path": "Applications/VpView/vpObjectSelectionPanel.h", "rank": 66, "score": 6.459963974929843 }, { "content": " void onRemoveAllTemporalFilters();\n\n void onRemoveAllFilters();\n\n\n\n void temporalFilterChanged(QTreeWidgetItem* item, int column);\n\n\n\n void bookmarkViewport();\n\n void copyViewportExtentsToClipboard();\n\n void copyExtendedInfoToClipboard();\n\n\n\n void updateInfoWidget(bool trackAttributesOnly = false);\n\n void rebuildObjectViews();\n\n\n\n void onSettingsChanged();\n\n\n\n void onTestingStarted();\n\n void onTestingStopped();\n\n\n\n void createTrack(bool start);\n\n void createEvent(bool start);\n\n void createSceneElement(bool start);\n", "file_path": "Applications/VpView/vpView.h", "rank": 67, "score": 6.447281138969845 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsDescriptorSource_h\n\n#define __vsDescriptorSource_h\n\n\n\n#include <vgExport.h>\n\n\n\n#include <vvDescriptor.h>\n\n#include <vvTrack.h>\n\n\n\n#include \"vsDataSource.h\"\n\n#include \"vsDescriptor.h\"\n\n#include \"vsEvent.h\"\n\n#include \"vsEventInfo.h\"\n\n#include \"vsTrackClassifier.h\"\n\n#include \"vsTrackId.h\"\n\n\n\n#include \"vsDescriptorInput.h\"\n\n\n", "file_path": "Libraries/VspData/vsDescriptorSource.h", "rank": 68, "score": 6.4365435958191055 }, { "content": "#ifndef __ctkRangeSlider_h\n\n#define __ctkRangeSlider_h\n\n\n\n// Qt includes\n\n#include <QSlider>\n\n\n\n#include <vgExport.h>\n\n\n\n// CTK includes\n\n//#include <ctkPimpl.h>\n\n\n", "file_path": "Libraries/QtVgWidgets/ctkRangeSlider.h", "rank": 69, "score": 6.433495270303379 }, { "content": "\n\n virtual void Update();\n\n\n\n // Description:\n\n // Mouse move event.\n\n virtual bool MouseMoveEvent(const vtkContextMouseEvent& mouse);\n\n\n\n // Description:\n\n // Mouse button double click event.\n\n virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent& mouse);\n\n\n\n // Description:\n\n // Mouse button release event.\n\n virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent& mouse);\n\n\n\n // Description:\n\n // Mouse wheel event, positive delta indicates forward movement of the wheel.\n\n virtual bool MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta);\n\n\n\n virtual bool Hit(const vtkContextMouseEvent& mouse);\n", "file_path": "Libraries/VtkVgCore/vtkVgChartTimeline.h", "rank": 70, "score": 6.433067982519232 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpGraphAnimateCallback_h\n\n#define __vpGraphAnimateCallback_h\n\n\n\n// VisGUI includes\n\n#include \"vpMultiGraphModel.h\"\n\n#include \"vpMultiGraphRepresentation.h\"\n\n\n\n// VTK includes\n\n#include <vtkCommand.h>\n\n#include <vtkRenderer.h>\n\n#include <vtkRenderWindow.h>\n\n#include <vtkRenderWindowInteractor.h>\n\n\n\n// C++ includes\n\n#include <vector>\n\n\n", "file_path": "Applications/VpView/vpGraphAnimateCallback.h", "rank": 71, "score": 6.429708101725302 }, { "content": " void exportSceneElements();\n\n void exportFilters();\n\n void exportFilters(QString path, bool startExternalProcess);\n\n\n\n void setTrackTrailLength();\n\n\n\n void changeTrackColors();\n\n void updateTrackColorsFromDialog(vpTrackColorDialog* dlg);\n\n\n\n void setFrameOffset();\n\n\n\n void importProject();\n\n void closeProject(int sessionId);\n\n\n\n void updateTracks();\n\n void finishTrackUpdate();\n\n\n\n void setAutoUpdateEnabled(bool enable);\n\n\n\n void disableTimeBasedIndexing();\n", "file_path": "Applications/VpView/vpView.h", "rank": 72, "score": 6.427423687041007 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsCore_h\n\n#define __vsCore_h\n\n\n\n#include <QObject>\n\n#include <QList>\n\n#include <QHash>\n\n#include <QMap>\n\n#include <QSet>\n\n\n\n#include <qtGlobal.h>\n\n\n\n#include <vgExport.h>\n\n#include <vgNamespace.h>\n\n\n\n#include <vtkVgTimeStamp.h>\n\n\n", "file_path": "Libraries/VspUserInterface/vsCore.h", "rank": 73, "score": 6.427094941921273 }, { "content": "\n\n virtual void chooseQueryVideo() {}\n\n virtual void reprocessQueryVideo() {}\n\n\n\n virtual void setQueryTracksAndDescriptors(\n\n QList<vvDescriptor> descriptors, QList<vvTrack> tracks);\n\n virtual void clearQueryDescriptors();\n\n\n\n void moveToSelected();\n\n void moveToAvailable();\n\n void clearSelected();\n\n\n\n void setStartTimeConstraintToCurrentFrame();\n\n void setEndTimeConstraintToCurrentFrame();\n\n void clearTimeConstraints();\n\n\n\n void addKeyframe();\n\n void removeSelectedKeyframes();\n\n void loadKeyframes();\n\n void unsetKeyframeEditCursor();\n", "file_path": "Libraries/VvVtkWidgets/vvVideoQueryDialog.h", "rank": 74, "score": 6.422212221564201 }, { "content": " void stepVideoForward();\n\n void stepVideoBackward();\n\n void skipVideoForward();\n\n void skipVideoBackward();\n\n\n\n void decreaseVideoPlaybackSpeed();\n\n void increaseVideoPlaybackSpeed();\n\n\n\n void writeRenderedImages(bool);\n\n void saveScreenShot();\n\n\n\n void initializeTesting(const qtCliArgs*);\n\n\n\nprotected slots:\n\n void toggleDrawing(bool);\n\n\n\n void setCursorLocationText(QString);\n\n\n\n void updateTrackLabelActionsEnabled();\n\n\n", "file_path": "Libraries/VspUserInterface/vsMainWindow.h", "rank": 75, "score": 6.421841256525086 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vtkVgPropCollection_h\n\n#define __vtkVgPropCollection_h\n\n\n\n// VTK includes.\n\n#include <vtkObject.h>\n\n#include <vtkSmartPointer.h>\n\n\n\n// STL includes.\n\n#include <map>\n\n#include <vector>\n\n\n\n// VG includes.\n\n#include \"vtkVgMacros.h\"\n\n\n\n#include <vgExport.h>\n\n\n\n// Forward declarations.\n", "file_path": "Libraries/VtkVgSceneGraph/vtkVgPropCollection.h", "rank": 76, "score": 6.419523110909629 }, { "content": "public slots:\n\n void initializeTesting(const qtCliArgs*);\n\n void addLayer(QUrl);\n\n\n\n void resultsPageBack();\n\n void resultsPageForward();\n\n\n\nprotected slots:\n\n void showQueryNewDialog();\n\n void showQueryEditDialog();\n\n void showQueryOpenDialog();\n\n void showGroundTruthOpenDialog();\n\n void showLayerAddFileDialog();\n\n void showConfigureDialog();\n\n void refineResults();\n\n\n\n void setResultFilters();\n\n\n\n void showQueryClip(vvQueryInstance query);\n\n\n", "file_path": "Applications/Viqui/vqApplication.h", "rank": 77, "score": 6.416667324151747 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsContextViewer_h\n\n#define __vsContextViewer_h\n\n\n\n// VisGUI includes.\n\n#include <vsDescriptorInput.h>\n\n\n\n#include <qtGlobal.h>\n\n\n\n// VTK includes.\n\n#include <QVTKWidget.h>\n\n\n\n// QT includes.\n\n#include <QBasicTimer>\n\n#include <QSet>\n\n#include <QUrl>\n\n\n\n// Forward declarations\n", "file_path": "Plugins/VspUiExtensions/ContextViewer/vsContextViewer.h", "rank": 78, "score": 6.411969099818391 }, { "content": " void onEventFilterPresetChanged(int index);\n\n void onEventFilterVisibilityChanged();\n\n void onEventFilterChanged();\n\n void onFrameRendered();\n\n void onReinitialized();\n\n void onShow3dView(bool state);\n\n void onHide3dView();\n\n void onEventExpirationModeChange(QAction* sizeAction, bool render = true);\n\n void onContextLODChanged(int value);\n\n void onWebExport();\n\n void onProjectProcessed();\n\n\n\n void updateFrameTime();\n\n void updateObjectCounts();\n\n void updateUI();\n\n\n\n void handleRenderWindowMouseMove(int x, int y);\n\n void updateFrameFileName(const QString& fileName);\n\n\n\n bool eventFilter(QObject* obj, QEvent* event);\n", "file_path": "Applications/VpView/vpView.h", "rank": 79, "score": 6.409406041427738 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vtkVgRepresentationBase_h\n\n#define __vtkVgRepresentationBase_h\n\n\n\n// VTK includes.\n\n#include <vtkObject.h>\n\n#include <vtkPropCollection.h>\n\n#include <vtkSmartPointer.h>\n\n\n\n// VG includes.\n\n#include \"vtkVgMacros.h\"\n\n\n\n// C++ includes\n\n#include <limits>\n\n\n\n#include <vgExport.h>\n\n\n\n// Forward declarations.\n", "file_path": "Libraries/VtkVgModelView/vtkVgRepresentationBase.h", "rank": 80, "score": 6.404432845814079 }, { "content": " void readyToProcessDatabaseVideoQuery(vvQueryInstance);\n\n\n\npublic slots:\n\n virtual void accept();\n\n\n\nprotected slots:\n\n void updateTimeUpperFromLower();\n\n void updateTimeLowerFromUpper();\n\n\n\n void preSetQueryType();\n\n void setQueryType(int);\n\n\n\n void requestRegion();\n\n void acceptDrawnRegion(vgGeocodedPoly region);\n\n\n\n void editRegionNumeric();\n\n\n\n void editQuery();\n\n\n\n void loadQuery();\n", "file_path": "Applications/Viqui/vqQueryDialog.h", "rank": 81, "score": 6.402596150644024 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsViperArchiveSourcePrivate_h\n\n#define __vsViperArchiveSourcePrivate_h\n\n\n\n#include \"vsViperArchiveSource.h\"\n\n\n\n#include <QMap>\n\n#include <QSet>\n\n#include <QUrl>\n\n\n\n#include <qtThread.h>\n\n\n\n#include <vvDescriptor.h>\n\n\n\n#include <track_oracle/track_oracle.h>\n\n\n\n#include <vsDescriptorInput.h>\n\n#include <vsEvent.h>\n\n#include <vsTrackId.h>\n\n\n", "file_path": "Plugins/VspSourceService/ViperArchiveSource/vsViperArchiveSourcePrivate.h", "rank": 82, "score": 6.402510694677576 }, { "content": " void onTreeHoverItemChanged(int sessionId);\n\n void updateObject(int objectType, int id);\n\n void updateColorofTracksOfType(int typeIndex, double* rgb);\n\n void updateCore();\n\n void updateEverything();\n\n void onCreateEvent(int type, vtkIdList* ids);\n\n void onTimelineSelectionChanged(int type, int id);\n\n void onShowHideTimelineView(bool show);\n\n void onTimelineDialogClosed();\n\n void onDisplayEventLegend(bool state);\n\n void onDisplayEventIcons(bool state);\n\n void onIconSizeChange(QAction* sizeAction, bool render = true);\n\n void onDisplayOverview(bool state);\n\n void onDisplayAOIOutline(bool state);\n\n void onCriticalError(const QString&);\n\n void onWarningError(const QString&);\n\n void onShowConfigureDialog();\n\n void onShowExternalProcessDialog();\n\n void onSaveRenderedImages(bool state);\n\n void onExecuteModeChanged(int index);\n", "file_path": "Applications/VpView/vpView.h", "rank": 83, "score": 6.401968001840416 }, { "content": "\n\n void onIncreaseSceneElementTransparency();\n\n void onDecreaseSceneElementTransparency();\n\n\n\n void onIncreasePolygonNodeSize();\n\n void onDecreasePolygonNodeSize();\n\n\n\n void onPlay();\n\n void onPause();\n\n void setLoop(bool state);\n\n\n\n void nextFrame();\n\n void prevFrame();\n\n void seekToFrame(const vtkVgTimeStamp& position, vg::SeekMode direction);\n\n\n\n void setPlaybackRate(double rate);\n\n double getPlaybackRate();\n\n\n\n void onResize(int width, int height);\n\n\n", "file_path": "Applications/VpView/vpViewCore.h", "rank": 84, "score": 6.398621530881519 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpQtViewer3d_h\n\n#define __vpQtViewer3d_h\n\n\n\n// VisGUI includes\n\n#include <vtkVgPicker.h>\n\n#include <vtkVgTimeStamp.h>\n\n\n\n#include <qtGlobal.h>\n\n\n\n// Qt includes\n\n#include <QList>\n\n#include <QObject>\n\n\n\n// VTK includes\n\n#include <vtkSmartPointer.h>\n\n\n\n// Forward declarations.\n", "file_path": "Applications/VpView/vpQtViewer3d.h", "rank": 85, "score": 6.396914286358268 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsMainWindowPrivate_h\n\n#define __vsMainWindowPrivate_h\n\n\n\n#include <QHash>\n\n#include <QStack>\n\n\n\n#include <qtUiState.h>\n\n\n\n#include <vgRange.h>\n\n\n\n#include <vsContour.h>\n\n#include <vsDescriptorInput.h>\n\n\n\n#include \"vsMainWindow.h\"\n\n\n\n#include \"ui_vsp.h\"\n\n#include \"am_vsp.h\"\n\n\n", "file_path": "Libraries/VspUserInterface/vsMainWindowPrivate.h", "rank": 86, "score": 6.396914286358268 }, { "content": "\n\npublic slots:\n\n void hideAllItems();\n\n void showAllItems();\n\n void setHiddenItemsShown(bool enable);\n\n\n\n void hideSelectedItems();\n\n void showSelectedItems();\n\n\n\n void setSelectedItemsStarred(bool starred);\n\n\n\n void selectTrack(vtkIdType trackId);\n\n\n\n void jumpToSelectedStart();\n\n void jumpToSelectedEnd();\n\n void followSelectedTrack();\n\n\n\nprotected slots:\n\n void itemActivated(const QModelIndex& index);\n\n\n", "file_path": "Libraries/VspUserInterface/vsTrackTreeView.h", "rank": 87, "score": 6.389985843476846 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vtkVgTerrainSource_h\n\n#define __vtkVgTerrainSource_h\n\n\n\n// VG includes.\n\n#include <vgExport.h>\n\n\n\n#include <vtkVgMacros.h>\n\n#include <vtkVgDataSourceBase.h>\n\n\n\n// VTK includes.\n\n#include <vtkMatrix4x4.h>\n\n#include <vtkSmartPointer.h>\n\n\n\n// STL includes.\n\n#include <vector>\n\n\n\n// Forward declarations.\n", "file_path": "Libraries/VtkVgQtSceneUtil/vtkVgTerrainSource.h", "rank": 88, "score": 6.38941335920586 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vdfTrackSource_h\n\n#define __vdfTrackSource_h\n\n\n\n#include \"vdfDataSourceInterface.h\"\n\n#include \"vdfTrackData.h\"\n\n#include \"vdfTrackId.h\"\n\n\n\n#include <vvTrack.h>\n\n\n\n#include <vgTimeMap.h>\n\n\n\n#include <vgExport.h>\n\n\n\n#include <QHash>\n\n#include <QObject>\n\n#include <QSet>\n\n\n", "file_path": "Libraries/VgDataFramework/vdfTrackSource.h", "rank": 89, "score": 6.38941335920586 }, { "content": "\n\nsignals:\n\n void ActivatedNode(vtkVgNodeBase& node);\n\n void SelectedNodes(QList<vtkVgNodeBase*> nodes);\n\n\n\npublic slots:\n\n void SelectNodes(QList<vtkVgNodeBase*> node);\n\n void UpdateColors();\n\n void Update();\n\n void ResetView();\n\n void OnKeyPressed();\n\n\n\nprivate slots:\n\n void OnFrameChanged(int frame);\n\n\n\nprivate:\n\n void UpdateTimelineChart();\n\n void UpdateTimelineTable();\n\n void UpdateSelection();\n\n\n", "file_path": "Applications/Viqui/vqTimeline.h", "rank": 90, "score": 6.383699299149272 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpSuperResDepthViewer_h\n\n#define __vpSuperResDepthViewer_h\n\n\n\n// super3d includes\n\n#include <super3d/depth/super_config.h>\n\n#include <super3d/depth/super_res.h>\n\n\n\n// vxl includes\n\n#include <vil/vil_image_view.h>\n\n#include <vgl/algo/vgl_h_matrix_2d.h>\n\n#include <vpgl/vpgl_perspective_camera.h>\n\n\n\n// vtk includes\n\n#include <vtkSmartPointer.h>\n\n#include <vtkPolyData.h>\n\n\n", "file_path": "Applications/VpView/vpSuperResDepthViewer.h", "rank": 91, "score": 6.382263157049693 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsStreamSourcePrivate_h\n\n#define __vsStreamSourcePrivate_h\n\n\n\n#include <QUrl>\n\n\n\n#include <vgExport.h>\n\n\n\n#include <vvDescriptor.h>\n\n\n\n#include <vsDescriptor.h>\n\n#include <vsDescriptorInput.h>\n\n#include <vsEvent.h>\n\n#include <vsEventInfo.h>\n\n#include <vsVideoSourcePrivate.h>\n\n\n\n#include \"vsStreamSource.h\"\n\n\n", "file_path": "Libraries/VspSourceUtil/vsStreamSourcePrivate.h", "rank": 92, "score": 6.374464154287197 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpSuperResWorker_h\n\n#define __vpSuperResWorker_h\n\n\n\n#include <super3d/depth/super_res.h>\n\n\n\n#include <vgl/algo/vgl_h_matrix_2d.h>\n\n\n\n#include <vtkSmartPointer.h>\n\n\n\n#include <QScopedPointer>\n\n#include <QThread>\n\n\n\n#include <boost/shared_ptr.hpp>\n\n\n\n#include <fstream>\n\n#include <string>\n\n#include <vector>\n\n\n", "file_path": "Applications/VpView/vpSuperResWorker.h", "rank": 93, "score": 6.374464154287197 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vsCorePrivate_h\n\n#define __vsCorePrivate_h\n\n\n\n#include <vgSwatchCache.h>\n\n#include <vgTimeMap.h>\n\n\n\n#include <vtkVgInstance.h>\n\n#include <vtkVgVideoMetadata.h>\n\n\n\n#include <vsContour.h>\n\n#include <vsDescriptorInput.h>\n\n#include <vsEvent.h>\n\n#include <vsTrackId.h>\n\n\n\n#include \"vsCore.h\"\n\n\n", "file_path": "Libraries/VspUserInterface/vsCorePrivate.h", "rank": 94, "score": 6.374464154287197 }, { "content": " void finalizeKeyframeEdit();\n\n void cancelKeyframeEdit();\n\n\n\n void selectDescriptor(vtkIdType id);\n\n void selectKeyframe(vtkIdType id);\n\n void selectTrack(vtkIdType id);\n\n void selectItem(vvDescriptorInfoTree* tree, vtkIdType id, int type);\n\n\n\n void selectItem(QTreeWidgetItem* item, int column);\n\n\n\n void showAll();\n\n void hideAll();\n\n void hideAllDescriptors();\n\n void itemVisibilityChanged(QTreeWidgetItem* item, int column);\n\n void updateItemParentVisibilities();\n\n\n\n void updateSelectionControlsState();\n\n void updateTrackConstraintControlsState();\n\n void updateKeyframeControlsState();\n\n\n", "file_path": "Libraries/VvVtkWidgets/vvVideoQueryDialog.h", "rank": 95, "score": 6.371489716188259 }, { "content": " static const char* GetSortTypeString(int sortType);\n\n\n\nsignals:\n\n void ItemsChanged(const QList<QTreeWidgetItem*>& items,\n\n bool updateStatus = true);\n\n\n\n void MouseLeft();\n\n void ContextMenuOpened(QMenu& menu);\n\n\n\n void FocusItemAlone();\n\n void FocusItem();\n\n void GoToStartFrame();\n\n void GoToEndFrame();\n\n void FollowTrack();\n\n\n\n void ShowLinkedEvents();\n\n void HideLinkedEvents();\n\n\n\n void ShowLinkedActivities();\n\n void HideLinkedActivities();\n", "file_path": "Applications/VpView/vpTreeView.h", "rank": 96, "score": 6.369831939213807 }, { "content": "\n\n void timeIntervalMeasurementRequested();\n\n\n\npublic slots:\n\n void initializeUi();\n\n void loadEventTypes(vtkVgEventTypeRegistry* reg);\n\n void loadPrimitiveTypes(const QString& filename = QString());\n\n void loadAttributeTypes(const QString& filename = QString());\n\n void loadConfig(const QString& filename);\n\n\n\n void updateViews();\n\n void updateVertexDisplaySize();\n\n\n\n void importJson();\n\n void exportJson(QString filename=QString(\"\"));\n\n\n\n void clear();\n\n\n\n void selectEvent(int id);\n\n\n", "file_path": "Applications/VpView/vpGraphModelWidget.h", "rank": 97, "score": 6.369831939213807 }, { "content": "\n\n void mergeTracks(bool start);\n\n\n\n void stopCreatingTrack();\n\n void stopCreatingEvent();\n\n void stopMergingTracks();\n\n\n\n void onEventCreated(int id);\n\n void onTracksMerged(int id);\n\n\n\n void splitTrack(int id, int sessionId);\n\n void improveTrack(int id, int sessionId);\n\n\n\n void addEventsToGraphModel(QList<int> eventIds, int sessionId);\n\n void addTrackEventsToGraphModel(int id, int sessionId);\n\n\n\n void selectEvent(int id);\n\n\n\n void exportTracks();\n\n void exportEvents();\n", "file_path": "Applications/VpView/vpView.h", "rank": 98, "score": 6.368705883103003 }, { "content": "// This file is part of ViViA, and is distributed under the\n\n// OSI-approved BSD 3-Clause License. See top-level LICENSE file or\n\n// https://github.com/Kitware/vivia/blob/master/LICENSE for details.\n\n\n\n#ifndef __vpMultiGraphModel_h\n\n#define __vpMultiGraphModel_h\n\n\n\n#include <vtkVgModelBase.h>\n\n\n\n//\n\n#include <vgTimeStamp.h>\n\n\n\n// VTK includes\n\n#include <vtkGraph.h>\n\n#include <vtkMath.h>\n\n\n\n// C++ include\n\n#include <map>\n\n#include <string>\n\n\n", "file_path": "Applications/VpView/vpMultiGraphModel.h", "rank": 99, "score": 6.364742163729922 } ]
C++
kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/stats_main_cmdline.hpp
transcript/DNAnexus_apps
12c2ba6f57b805a9fcf6e1da4f9d64394ef72256
#ifndef __STATS_ARGS_HPP__ #define __STATS_ARGS_HPP__ #include <jellyfish/yaggo.hpp> class stats_args { public: bool recompute_flag; uint64_t lower_count_arg; bool lower_count_given; uint64_t upper_count_arg; bool upper_count_given; bool verbose_flag; const char * output_arg; bool output_given; const char * db_arg; enum { USAGE_OPT = 1000, FULL_HELP_OPT }; stats_args() : recompute_flag(false), lower_count_arg(), lower_count_given(false), upper_count_arg(), upper_count_given(false), verbose_flag(false), output_arg(""), output_given(false) { } stats_args(int argc, char* argv[]) : recompute_flag(false), lower_count_arg(), lower_count_given(false), upper_count_arg(), upper_count_given(false), verbose_flag(false), output_arg(""), output_given(false) { parse(argc, argv); } void parse(int argc, char* argv[]) { static struct option long_options[] = { {"recompute", 0, 0, 'r'}, {"lower-count", 1, 0, 'L'}, {"upper-count", 1, 0, 'U'}, {"verbose", 0, 0, 'v'}, {"output", 1, 0, 'o'}, {"help", 0, 0, 'h'}, {"full-help", 0, 0, FULL_HELP_OPT}, {"usage", 0, 0, USAGE_OPT}, {"version", 0, 0, 'V'}, {0, 0, 0, 0} }; static const char *short_options = "hVrL:U:vo:"; std::string err; #define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << "Invalid " #type " '" << val << "' for [" which "]: " << err << "\n"; exit(1); } while(true) { int index = -1; int c = getopt_long(argc, argv, short_options, long_options, &index); if(c == -1) break; switch(c) { case ':': std::cerr << "Missing required argument for " << (index == -1 ? std::string(1, (char)optopt) : std::string(long_options[index].name)) << std::endl; exit(1); case 'h': std::cout << usage() << "\n\n" << help() << std::endl; exit(0); case USAGE_OPT: std::cout << usage() << "\nUse --help for more information." << std::endl; exit(0); case 'V': print_version(); exit(0); case '?': std::cerr << "Use --usage or --help for some help\n"; exit(1); case FULL_HELP_OPT: std::cout << usage() << "\n\n" << help() << "\n\n" << hidden() << std::endl; exit(0); case 'r': recompute_flag = true; break; case 'L': lower_count_given = true; lower_count_arg = yaggo::conv_uint<uint64_t>((const char *)optarg, err, false); CHECK_ERR(uint64_t, optarg, "-L, --lower-count=uint64") break; case 'U': upper_count_given = true; upper_count_arg = yaggo::conv_uint<uint64_t>((const char *)optarg, err, false); CHECK_ERR(uint64_t, optarg, "-U, --upper-count=uint64") break; case 'v': verbose_flag = true; break; case 'o': output_given = true; output_arg = optarg; break; } } if(argc - optind != 1) error("Requires exactly 1 argument."); db_arg = argv[optind]; ++optind; } #define stats_args_USAGE "Usage: jellyfish stats [options] db:path" const char * usage() const { return stats_args_USAGE; } void error(const char *msg) { std::cerr << "Error: " << msg << "\n" << usage() << "\nUse --help for more information" << std::endl; exit(1); } #define stats_args_HELP "Statistics\n\nDisplay some statistics about the k-mers in the hash:\n" \ "\n" \ "Unique: Number of k-mers which occur only once.\n" \ "Distinct: Number of k-mers, not counting multiplicity.\n" \ "Total: Number of k-mers, including multiplicity.\n" \ "Max_count: Maximum number of occurrence of a k-mer.\n\n" \ "Options (default value in (), *required):\n" \ " -L, --lower-count=uint64 Don't consider k-mer with count < lower-count\n" \ " -U, --upper-count=uint64 Don't consider k-mer with count > upper-count\n" \ " -v, --verbose Verbose (false)\n" \ " -o, --output=string Output file\n" \ " --usage Usage\n" \ " -h, --help This message\n" \ " --full-help Detailed help\n" \ " -V, --version Version" const char * help() const { return stats_args_HELP; } #define stats_args_HIDDEN "Hidden options:\n" \ " -r, --recompute Recompute (false)" const char * hidden() const { return stats_args_HIDDEN; } void print_version(std::ostream &os = std::cout) const { #ifndef PACKAGE_VERSION #define PACKAGE_VERSION "0.0.0" #endif os << PACKAGE_VERSION << "\n"; } void dump(std::ostream &os = std::cout) { os << "recompute_flag:" << recompute_flag << "\n"; os << "lower_count_given:" << lower_count_given << " lower_count_arg:" << lower_count_arg << "\n"; os << "upper_count_given:" << upper_count_given << " upper_count_arg:" << upper_count_arg << "\n"; os << "verbose_flag:" << verbose_flag << "\n"; os << "output_given:" << output_given << " output_arg:" << output_arg << "\n"; os << "db_arg:" << db_arg << "\n"; } private: }; #endif
#ifndef __STATS_ARGS_HPP__ #define __STATS_ARGS_HPP__ #include <jellyfish/yaggo.hpp> class stats_args { public: bool recompute_flag; uint64_t lower_count_arg; bool lower_count_given; uint64_t upper_count_arg; bool upper_count_given; bool verbose_flag; const char * output_arg; bool output_given; const char * db_arg; enum { USAGE_OPT = 1000, FULL_HELP_OPT }; stats_args() : recompute_flag(false), lower_count_arg(), lower_count_given(false), upper_count_arg(), upper_count_given(false), verbose_flag(false), output_arg(""), output_given(false) { } stats_args(int argc, char* argv[]) : recompute_flag(false), lower_count_arg(), lower_count_given(false), upper_count_arg(), upper_count_given(false), verbose_flag(false), output_arg(""), output_given(false) { parse(argc, argv); } void parse(int argc, char* argv[]) { static struct option long_options[] = { {"recompute", 0, 0, 'r'}, {"lower-count", 1, 0, 'L'}, {"upper-count", 1, 0, 'U'}, {"verbose", 0, 0, 'v'}, {"output", 1, 0, 'o'}, {"help", 0, 0, 'h'}, {"full-help", 0, 0, FULL_HELP_OPT}, {"usage", 0, 0, USAGE_OPT}, {"version", 0, 0, 'V'}, {0, 0, 0, 0} }; static const char *short_options = "hVrL:U:vo:"; std::string err; #define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << "Invalid " #type " '" << val << "' for [" which "]: " << err << "\n"; exit(1); } while(true) { int index = -1; int c = getopt_long(argc, argv, short_options, long_options, &index); if(c == -1) break; switch(c) { case ':': std::cerr << "Missing required argument for " << (index == -1 ? std::string(1, (char)optopt) : std::string(long_options[index].name)) << std::endl; exit(1); case 'h': std::cout << usage() << "\n\n" << help() << std::endl; exit(0); case USAGE_OPT: std::cout << usage() << "\nUse --help for more information." << std::endl; exit(0); case 'V': print_version(); exit(0); case '?': std::cerr << "Use --usage or --help for some help\n"; exit(1); case FULL_HELP_OPT: std::cout << usage() << "\n\n" << help() << "\n\n" << hidden() << std::endl; exit(0); case 'r': recompute_flag = true; break; case 'L': lower_count_given = true; lower_count_arg = yaggo::conv_uint<uint64_t>((const char *)optarg, err, false); CHECK_ERR(uint64_t, optarg, "-L, --lower-count=uint64") break; case 'U': upper_count_given = true; upper_count_arg = yaggo::conv_uint<uint64_t>((const char *)optarg, err, false); CHECK_ERR(uint64_t, optarg, "-U, --upper-count=uint64") break; case 'v': verbose_flag = true; break; case 'o': output_given = true; output_arg = optarg; break; } } if(argc - optind != 1) error("Requires exactly 1 argument."); db_arg = argv[optind]; ++optind; } #define stats_args_USAGE "Usage: jellyfish stats [options] db:path" const char * usage() const { return stats_args_USAGE; } void error(const char *msg) { std::cerr << "Error: " << msg << "\n" << usage() << "\nUse --help for more information" << std::endl; exit(1); } #define stats_args_HELP "Statistics\n\nDisplay some statistics about the k-mers in the hash:\n" \ "\n" \ "Unique: Number of k-mers which occur only once.\n" \ "Distinct: Number of k-mers, not counting multiplicity.\n" \ "Total: Number of k-mers, including multiplicity.\n" \ "Max_count: Maximum number of occurrence of a k-mer.\n\n" \ "Options (default value in (), *required):\n" \ " -L, --lower-count=uint64 Don't consider k-mer with count < lower-count\n" \ " -U, --upper-count=uint64 Don't consider k-mer with count > upper-count\n" \ " -v, --verbose Verbose (false)\n" \ " -o, --output=string Output file\n" \ " --usage Usage\n" \ " -h, --help This message\n" \ " --full-help Detailed help\n" \ " -V, --version Version" const char * help() const { return stats_args_HELP; } #define stats_args_HIDDEN "Hidden options:\n" \ " -r, --recompute Recompute (false)" const char * hidden() const { return stats_args_HIDDEN; } void print_version(std::ostream &os = std::cout) const { #ifndef PACKAGE_VERSION #define PACKAGE_VERSION "0.0.0" #endif os << PACKAGE_VERSION << "\n"; }
private: }; #endif
void dump(std::ostream &os = std::cout) { os << "recompute_flag:" << recompute_flag << "\n"; os << "lower_count_given:" << lower_count_given << " lower_count_arg:" << lower_count_arg << "\n"; os << "upper_count_given:" << upper_count_given << " upper_count_arg:" << upper_count_arg << "\n"; os << "verbose_flag:" << verbose_flag << "\n"; os << "output_given:" << output_given << " output_arg:" << output_arg << "\n"; os << "db_arg:" << db_arg << "\n"; }
function_block-full_function
[ { "content": "struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };\n\n\n\ntemplate <GTEST_2_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 0, "score": 416406.8253525696 }, { "content": "struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };\n\n\n\ntemplate <GTEST_1_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 1, "score": 416402.5838420616 }, { "content": "struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };\n\n\n\ntemplate <GTEST_3_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 2, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };\n\n\n\ntemplate <GTEST_7_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 3, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };\n\n\n\ntemplate <GTEST_4_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 4, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };\n\n\n\ntemplate <int k, class Tuple>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 5, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };\n\n\n\ntemplate <GTEST_6_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 6, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };\n\n\n\ntemplate <GTEST_8_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 7, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };\n\n\n\ntemplate <GTEST_9_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 8, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 9, "score": 391806.44473026635 }, { "content": "struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };\n\n\n\ntemplate <GTEST_5_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 10, "score": 391806.44473026635 }, { "content": "class FooTest : public ::testing::TestWithParam<const char*> {\n\n // You can implement all the usual class fixture members here.\n\n};\n\n\n\n// Then, use the TEST_P macro to define as many parameterized tests\n\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n\n// or \"pattern\", whichever you prefer to think.\n\n\n\nTEST_P(FooTest, DoesBlah) {\n\n // Inside a test, access the test parameter with the GetParam() method\n\n // of the TestWithParam<T> class:\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n ...\n\n}\n\n\n\nTEST_P(FooTest, HasBlahBlah) {\n\n ...\n\n}\n\n\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-param-test.h", "rank": 11, "score": 361592.2892925329 }, { "content": "struct is_pointer<T*> : public true_type {};\n\n\n\ntemplate <typename Iterator>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 12, "score": 327009.92499011045 }, { "content": " class TestName : public CaseName<gtest_TypeParam_> { \\\n\n private: \\\n\n typedef CaseName<gtest_TypeParam_> TestFixture; \\\n\n typedef gtest_TypeParam_ TypeParam; \\\n\n virtual void TestBody(); \\\n\n }; \\\n\n static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\\\n\n __FILE__, __LINE__, #CaseName, #TestName); \\\n\n } \\\n\n template <typename gtest_TypeParam_> \\\n\n void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()\n\n\n\n# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \\\n\n namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n\n typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \\\n\n } \\\n\n static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\\\n\n __FILE__, __LINE__, #__VA_ARGS__)\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-typed-test.h", "rank": 13, "score": 326466.0368386953 }, { "content": "struct RemoveConst<const T[N]> {\n\n typedef typename RemoveConst<T>::type type[N];\n\n};\n\n#endif\n\n\n\n// A handy wrapper around RemoveConst that works when the argument\n\n// T depends on template parameters.\n\n#define GTEST_REMOVE_CONST_(T) \\\n\n typename ::testing::internal::RemoveConst<T>::type\n\n\n\n// Turns const U&, U&, const U, and U all into U.\n\n#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \\\n\n GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))\n\n\n\n// Adds reference to a type if it is not a reference type,\n\n// otherwise leaves it unchanged. This is the same as\n\n// tr1::add_reference, which is not widely available yet.\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 14, "score": 326160.0692892401 }, { "content": "class mer_counting_fasta_direct : public mer_counting<jellyfish::parse_dna, direct_index_t> {\n\npublic:\n\n mer_counting_fasta_direct(const std::vector<const char *> &files,\n\n count_args &_args) :\n\n mer_counting<jellyfish::parse_dna, direct_index_t>(_args)\n\n {\n\n parser = new jellyfish::parse_dna(files.begin(), files.end(),\n\n args->mer_len_arg, args->buffers_arg,\n\n args->buffer_size_arg);\n\n ary = new direct_index_t::storage_t(2 * args->mer_len_arg);\n\n hash = new direct_index_t(ary);\n\n if(args->no_write_flag) {\n\n dumper = new jellyfish::noop_dumper();\n\n } else {\n\n if(args->raw_flag)\n\n std::cerr << \"Switch --raw not (yet) supported with direct indexing. Ignoring.\" << std::endl;\n\n direct_index_dumper_t *_dumper =\n\n new direct_index_dumper_t(args->threads_arg, args->output_arg.c_str(),\n\n args->out_buffer_size_arg,\n\n 8*args->out_counter_len_arg,\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/mer_counter.cc", "rank": 15, "score": 319664.316422704 }, { "content": "class mer_counting_qual_fasta_direct : public mer_counting<jellyfish::parse_qual_dna, direct_index_t> {\n\npublic:\n\n mer_counting_qual_fasta_direct(const std::vector<const char *> &files,\n\n count_args &_args) :\n\n mer_counting<jellyfish::parse_qual_dna, direct_index_t>(_args)\n\n {\n\n parser = new jellyfish::parse_qual_dna(files,\n\n args->mer_len_arg, args->buffers_arg,\n\n args->buffer_size_arg, args->quality_start_arg,\n\n args->min_quality_arg);\n\n ary = new direct_index_t::storage_t(2 * args->mer_len_arg);\n\n hash = new direct_index_t(ary);\n\n if(args->no_write_flag) {\n\n dumper = new jellyfish::noop_dumper();\n\n } else {\n\n if(args->raw_flag)\n\n std::cerr << \"Switch --raw not (yet) supported with direct indexing. Ignoring.\" << std::endl;\n\n direct_index_dumper_t *_dumper =\n\n new direct_index_dumper_t(args->threads_arg, args->output_arg.c_str(),\n\n args->out_buffer_size_arg,\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/mer_counter.cc", "rank": 16, "score": 314897.01594195655 }, { "content": "#define die if(1) err::die_t()\n\n#define eraise(e) if(1) err::raise_t<e>()\n\n#define define_error_class(name) \\\n\n class name : public std::runtime_error { \\\n\n public: explicit name(const std::string &txt) : std::runtime_error(txt) {} \\\n\n }\n\n\n\n#endif\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/err.hpp", "rank": 17, "score": 305628.80483490357 }, { "content": "struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 18, "score": 305087.0739641233 }, { "content": "struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 19, "score": 305082.83245361526 }, { "content": "class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n\n // The usual test fixture members go here too.\n\n};\n\n\n\nTEST_F(BaseTest, HasFoo) {\n\n // This is an ordinary non-parameterized test.\n\n}\n\n\n\nTEST_P(DerivedTest, DoesBlah) {\n\n // GetParam works just the same here as if you inherit from TestWithParam.\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n}\n\n\n\n#endif // 0\n\n\n\n#include \"gtest/internal/gtest-port.h\"\n\n\n\n#if !GTEST_OS_SYMBIAN\n\n# include <utility>\n\n#endif\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-param-test.h", "rank": 20, "score": 303715.3787569794 }, { "content": "struct RemoveConst<const T> { typedef T type; }; // NOLINT\n\n\n\n// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above\n\n// definition to fail to remove the const in 'const int[3]' and 'const\n\n// char[3][4]'. The following specialization works around the bug.\n\n// However, it causes trouble with GCC and thus needs to be\n\n// conditionally compiled.\n\n#if defined(_MSC_VER) || defined(__SUNPRO_CC) || defined(__IBMCPP__)\n\ntemplate <typename T, size_t N>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 21, "score": 300269.94545915036 }, { "content": "struct ByRef { typedef const T& type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 22, "score": 298316.6096498102 }, { "content": "struct is_pointer : public false_type {};\n\n\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 23, "score": 289508.80635476613 }, { "content": " // Holds a value of type T.\n\n class ValueHolder : public ThreadLocalValueHolderBase {\n\n public:\n\n explicit ValueHolder(const T& value) : value_(value) {}\n\n\n\n T* pointer() { return &value_; }\n\n\n\n private:\n\n T value_;\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);\n\n };\n\n\n\n static pthread_key_t CreateKey() {\n\n pthread_key_t key;\n\n // When a thread exits, DeleteThreadLocalValue() will be called on\n\n // the object managed for that thread.\n\n GTEST_CHECK_POSIX_SUCCESS_(\n\n pthread_key_create(&key, &DeleteThreadLocalValue));\n\n return key;\n\n }\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 24, "score": 287550.99943429907 }, { "content": "struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 25, "score": 280486.6933418201 }, { "content": "struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 26, "score": 280486.6933418201 }, { "content": "struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 27, "score": 280486.6933418201 }, { "content": "struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 28, "score": 280486.6933418201 }, { "content": "struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 29, "score": 280486.6933418201 }, { "content": "struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 30, "score": 280486.6933418201 }, { "content": "struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 31, "score": 280486.6933418201 }, { "content": "struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };\n\n\n\n} // namespace gtest_internal\n\n\n\ntemplate <>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 32, "score": 280486.6933418201 }, { "content": "class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {\n\n public:\n\n // ParamType and GeneratorCreationFunc are private types but are required\n\n // for declarations of public methods AddTestPattern() and\n\n // AddTestCaseInstantiation().\n\n typedef typename TestCase::ParamType ParamType;\n\n // A function that returns an instance of appropriate generator type.\n\n typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();\n\n\n\n explicit ParameterizedTestCaseInfo(const char* name)\n\n : test_case_name_(name) {}\n\n\n\n // Test case base name for display purposes.\n\n virtual const string& GetTestCaseName() const { return test_case_name_; }\n\n // Test case id to verify identity.\n\n virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }\n\n // TEST_P macro uses AddTestPattern() to record information\n\n // about a single test in a LocalTestInfo structure.\n\n // test_case_name is the base name of the test case (without invocation\n\n // prefix). test_base_name is the name of an individual test without\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-param-util.h", "rank": 33, "score": 280326.48300916073 }, { "content": "class FooTest : public testing::Test {\n\n ...\n\n};\n\n\n\n// Next, declare that you will define a type-parameterized test case\n\n// (the _P suffix is for \"parameterized\" or \"pattern\", whichever you\n\n// prefer):\n\nTYPED_TEST_CASE_P(FooTest);\n\n\n\n// Then, use TYPED_TEST_P() to define as many type-parameterized tests\n\n// for this type-parameterized test case as you want.\n\nTYPED_TEST_P(FooTest, DoesBlah) {\n\n // Inside a test, refer to TypeParam to get the type parameter.\n\n TypeParam n = 0;\n\n ...\n\n}\n\n\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n\n\n\n// Now the tricky part: you need to register all test patterns before\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-typed-test.h", "rank": 34, "score": 278226.2086145318 }, { "content": "class mer_counting_quake : public mer_counting<jellyfish::parse_quake, fastq_hash_t> {\n\npublic:\n\n mer_counting_quake(std::vector<const char *>,\n\n count_args &_args) :\n\n mer_counting<jellyfish::parse_quake, fastq_hash_t>(_args)\n\n {\n\n parser = new jellyfish::parse_quake(args->file_arg,\n\n args->mer_len_arg, args->buffers_arg, \n\n args->buffer_size_arg, \n\n args->quality_start_arg);\n\n ary = new fastq_hash_t::storage_t(args->size_arg, 2*args->mer_len_arg,\n\n args->reprobes_arg, \n\n jellyfish::quadratic_reprobes);\n\n hash = new fastq_hash_t(ary);\n\n if(args->no_write_flag) {\n\n dumper = new jellyfish::noop_dumper();\n\n } else {\n\n dumper = new raw_fastq_dumper_t(args->threads_arg, args->output_arg.c_str(),\n\n args->out_buffer_size_arg,\n\n ary);\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/mer_counter.cc", "rank": 35, "score": 277631.91260988 }, { "content": "class mer_counting : public mer_counting_base, public thread_exec {\n\nprotected:\n\n count_args *args;\n\n locks::pthread::barrier sync_barrier;\n\n parser_t *parser;\n\n typename hash_t::storage_t *ary;\n\n hash_t *hash;\n\n jellyfish::dumper_t *dumper;\n\n uint64_t distinct, total;\n\n\n\npublic:\n\n explicit mer_counting(count_args &_args) :\n\n args(&_args), sync_barrier(args->threads_arg),\n\n distinct(0), total(0) {}\n\n\n\n ~mer_counting() { \n\n if(dumper)\n\n delete dumper;\n\n if(hash)\n\n delete hash;\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/mer_counter.cc", "rank": 36, "score": 276426.75657765043 }, { "content": "class mer_counting_fasta_hash : public mer_counting<jellyfish::parse_dna, inv_hash_t> {\n\npublic:\n\n mer_counting_fasta_hash(const std::vector<const char *> &files,\n\n count_args &_args) :\n\n mer_counting<jellyfish::parse_dna, inv_hash_t>(_args)\n\n {\n\n parser = new jellyfish::parse_dna(files.begin(), files.end(),\n\n args->mer_len_arg, args->buffers_arg,\n\n args->buffer_size_arg);\n\n ary = new inv_hash_t::storage_t(args->size_arg, 2*args->mer_len_arg,\n\n args->counter_len_arg, \n\n args->reprobes_arg, \n\n jellyfish::quadratic_reprobes);\n\n if(args->matrix_given) {\n\n std::ifstream fd;\n\n fd.exceptions(std::ifstream::eofbit|std::ifstream::failbit|std::ifstream::badbit);\n\n fd.open(args->matrix_arg.c_str());\n\n SquareBinaryMatrix m(&fd);\n\n fd.close();\n\n ary->set_matrix(m);\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/mer_counter.cc", "rank": 37, "score": 275734.441437414 }, { "content": "#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\\\n\nclass GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\\\n\n public:\\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\\\n\n private:\\\n\n virtual void TestBody();\\\n\n static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\\\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\\\n\n};\\\n\n\\\n\n::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\\\n\n ::test_info_ =\\\n\n ::testing::internal::MakeAndRegisterTestInfo(\\\n\n #test_case_name, #test_name, NULL, NULL, \\\n\n (parent_id), \\\n\n parent_class::SetUpTestCase, \\\n\n parent_class::TearDownTestCase, \\\n\n new ::testing::internal::TestFactoryImpl<\\\n\n GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\\\n\nvoid GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n\n\n#ifdef __ICC\n\n// Disable explicit warning on Intel compiler\n\n#pragma warning enable 2304\n\n#endif\n\n\n\n#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 38, "score": 274514.8057984098 }, { "content": "struct RemoveConst { typedef T type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 39, "score": 274446.60236797674 }, { "content": "class fstream_default : public Base {\n\n typedef Base super;\n\n static std::streambuf* open_file(const char* str, std::ios_base::openmode mode) {\n\n std::filebuf* fb = new std::filebuf;\n\n return fb->open(str, mode);\n\n }\n\n\n\n static std::streambuf* get_streambuf(const char* str, Base& def, \n\n std::ios_base::openmode mode) {\n\n return (str != 0) ? open_file(str, mode) : def.rdbuf();\n\n }\n\n static std::streambuf* get_streambuf(const char* str, std::streambuf* buf, \n\n std::ios_base::openmode mode) {\n\n return (str != 0) ? open_file(str, mode) : buf;\n\n }\n\n\n\n bool do_close;\n\npublic:\n\n fstream_default(const char* str, Base& def, std::ios_base::openmode mode = def_mode) :\n\n Base(get_streambuf(str, def, mode)), do_close(str != 0) { \n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/fstream_default.hpp", "rank": 40, "score": 273369.3888964084 }, { "content": "class mer_counting_qual_fasta_hash : public mer_counting<jellyfish::parse_qual_dna, inv_hash_t> {\n\npublic:\n\n mer_counting_qual_fasta_hash(const std::vector<const char *> &files,\n\n count_args &_args) :\n\n mer_counting<jellyfish::parse_qual_dna, inv_hash_t>(_args)\n\n {\n\n parser = new jellyfish::parse_qual_dna(files,\n\n args->mer_len_arg, args->buffers_arg,\n\n args->buffer_size_arg, args->quality_start_arg,\n\n args->min_quality_arg);\n\n ary = new inv_hash_t::storage_t(args->size_arg, 2*args->mer_len_arg,\n\n args->counter_len_arg, \n\n args->reprobes_arg, \n\n jellyfish::quadratic_reprobes);\n\n if(args->matrix_given) {\n\n std::ifstream fd;\n\n fd.exceptions(std::ifstream::eofbit|std::ifstream::failbit|std::ifstream::badbit);\n\n fd.open(args->matrix_arg.c_str());\n\n SquareBinaryMatrix m(&fd);\n\n fd.close();\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/mer_counter.cc", "rank": 41, "score": 272056.43702638487 }, { "content": "// A concrete DeathTestFactory implementation for normal use.\n\nclass DefaultDeathTestFactory : public DeathTestFactory {\n\n public:\n\n virtual bool Create(const char* statement, const RE* regex,\n\n const char* file, int line, DeathTest** test);\n\n};\n\n\n\n// Returns true if exit_status describes a process that was terminated\n\n// by a signal, or exited normally with a nonzero exit code.\n\nGTEST_API_ bool ExitedUnsuccessfully(int exit_status);\n\n\n\n// Traps C++ exceptions escaping statement and reports them as test\n\n// failures. Note that trapping SEH exceptions is not implemented here.\n\n# if GTEST_HAS_EXCEPTIONS\n\n# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n\n try { \\\n\n GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n\n } catch (const ::std::exception& gtest_exception) { \\\n\n fprintf(\\\n\n stderr, \\\n\n \"\\n%s: Caught std::exception-derived exception escaping the \" \\\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-death-test-internal.h", "rank": 42, "score": 269971.9165508655 }, { "content": " class Iterator : public ParamIteratorInterface<ParamType> {\n\n public:\n\n Iterator(const ParamGeneratorInterface<ParamType>* base,\n\n const ParamGenerator<T1>& g1,\n\n const typename ParamGenerator<T1>::iterator& current1,\n\n const ParamGenerator<T2>& g2,\n\n const typename ParamGenerator<T2>::iterator& current2,\n\n const ParamGenerator<T3>& g3,\n\n const typename ParamGenerator<T3>::iterator& current3,\n\n const ParamGenerator<T4>& g4,\n\n const typename ParamGenerator<T4>::iterator& current4,\n\n const ParamGenerator<T5>& g5,\n\n const typename ParamGenerator<T5>::iterator& current5,\n\n const ParamGenerator<T6>& g6,\n\n const typename ParamGenerator<T6>::iterator& current6,\n\n const ParamGenerator<T7>& g7,\n\n const typename ParamGenerator<T7>::iterator& current7,\n\n const ParamGenerator<T8>& g8,\n\n const typename ParamGenerator<T8>::iterator& current8,\n\n const ParamGenerator<T9>& g9,\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-param-util-generated.h", "rank": 43, "score": 267324.6985924891 }, { "content": "class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {\n\n public:\n\n template <typename ForwardIterator>\n\n ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)\n\n : container_(begin, end) {}\n\n virtual ~ValuesInIteratorRangeGenerator() {}\n\n\n\n virtual ParamIteratorInterface<T>* Begin() const {\n\n return new Iterator(this, container_.begin());\n\n }\n\n virtual ParamIteratorInterface<T>* End() const {\n\n return new Iterator(this, container_.end());\n\n }\n\n\n\n private:\n\n typedef typename ::std::vector<T> ContainerType;\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-param-util.h", "rank": 44, "score": 264726.4635216782 }, { "content": " class array : public storage_t {\n\n public:\n\n typedef _key_t key_t;\n\n typedef _val_t val_t;\n\n\n\n private:\n\n typedef typename ::jellyfish::invertible_hash::array<key_t, atomic, mem_block_t> key_ary_t;\n\n typedef typename ::jellyfish::direct_indexing::array<size_t, val_t, atomic, mem_block_t> val_ary_t;\n\n \n\n key_ary_t keys;\n\n val_ary_t vals;\n\n\n\n public:\n\n array(size_t _size, uint_t _key_len, uint_t _reprobe_limit,\n\n size_t *_reprobes) :\n\n keys(_size, _key_len, 0, _reprobe_limit, _reprobes),\n\n vals(keys.get_lsize())\n\n { }\n\n\n\n array(char *keys_map, char *vals_map,\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/aligned_values_array.hpp", "rank": 45, "score": 261580.8212873121 }, { "content": "struct StaticAssertTypeEqHelper;\n\n\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 46, "score": 259293.83566585646 }, { "content": "class TypeParameterizedTestCase {\n\n public:\n\n static bool Register(const char* prefix, const char* case_name,\n\n const char* test_names) {\n\n typedef typename Tests::Head Head;\n\n\n\n // First, register the first test in 'Test' for each type in 'Types'.\n\n TypeParameterizedTest<Fixture, Head, Types>::Register(\n\n prefix, case_name, test_names, 0);\n\n\n\n // Next, recurses (at compile time) with the tail of the test list.\n\n return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>\n\n ::Register(prefix, case_name, SkipComma(test_names));\n\n }\n\n};\n\n\n\n// The base case for the compile time recursion.\n\ntemplate <GTEST_TEMPLATE_ Fixture, typename Types>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 47, "score": 258397.7464239542 }, { "content": "// Helper for suppressing false warning from Clang on a const char*\n\n// variable declared in a conditional expression always being NULL in\n\n// the else branch.\n\nstruct GTEST_API_ ConstCharPtr {\n\n ConstCharPtr(const char* str) : value(str) {}\n\n operator bool() const { return true; }\n\n const char* value;\n\n};\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 48, "score": 255696.429730216 }, { "content": "class ErrorWriting : public std::exception {\n\n std::string msg;\n\npublic:\n\n explicit ErrorWriting(const std::string &_msg) : msg(_msg) {}\n\n virtual ~ErrorWriting() throw() {}\n\n virtual const char* what() const throw() {\n\n return msg.c_str();\n\n }\n\n};\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/hash_merge.cc", "rank": 49, "score": 254215.3576770229 }, { "content": " class string : public ::std::string {\n\n public:\n\n string() : ::std::string() {}\n\n explicit string(const ::std::string &s) : std::string(s) {}\n\n explicit string(const char *s) : ::std::string(s) {}\n\n int as_enum(const char* const strs[]) {\n\n ::std::string err;\n\n int res = conv_enum((const char*)this->c_str(), err, strs);\n\n if(!err.empty())\n\n throw ::std::runtime_error(err);\n\n return res;\n\n }\n\n\n\n\n\n uint32_t as_uint32_suffix() const { return as_uint32(true); }\n\n uint32_t as_uint32(bool si_suffix = false) const {\n\n ::std::string err;\n\n uint32_t res = conv_uint<uint32_t>((const char*)this->c_str(), err, si_suffix);\n\n if(!err.empty()) {\n\n ::std::string msg(\"Invalid conversion of '\");\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/count_main_cmdline.hpp", "rank": 50, "score": 254096.04286682548 }, { "content": "class EqHelper<true> {\n\n public:\n\n // We define two overloaded versions of Compare(). The first\n\n // version will be picked when the second argument to ASSERT_EQ() is\n\n // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or\n\n // EXPECT_EQ(false, a_bool).\n\n template <typename T1, typename T2>\n\n static AssertionResult Compare(\n\n const char* expected_expression,\n\n const char* actual_expression,\n\n const T1& expected,\n\n const T2& actual,\n\n // The following line prevents this overload from being considered if T2\n\n // is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr)\n\n // expands to Compare(\"\", \"\", NULL, my_ptr), which requires a conversion\n\n // to match the Secret* in the other overload, which would otherwise make\n\n // this template match better.\n\n typename EnableIf<!is_pointer<T2>::value>::type* = 0) {\n\n return CmpHelperEQ(expected_expression, actual_expression, expected,\n\n actual);\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest.h", "rank": 51, "score": 253957.3941003691 }, { "content": "class TypeParameterizedTestCase<Fixture, Templates0, Types> {\n\n public:\n\n static bool Register(const char* /*prefix*/, const char* /*case_name*/,\n\n const char* /*test_names*/) {\n\n return true;\n\n }\n\n};\n\n\n\n#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n\n\n// Returns the current OS stack trace as a String.\n\n//\n\n// The maximum number of stack frames to be included is specified by\n\n// the gtest_stack_trace_depth flag. The skip_count parameter\n\n// specifies the number of top frames to be skipped, which doesn't\n\n// count against the number of frames to be included.\n\n//\n\n// For example, if Foo() calls Bar(), which in turn calls\n\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 52, "score": 253578.85434808198 }, { "content": " class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \\\n\n : public CaseName<gtest_TypeParam_> { \\\n\n private: \\\n\n typedef CaseName<gtest_TypeParam_> TestFixture; \\\n\n typedef gtest_TypeParam_ TypeParam; \\\n\n virtual void TestBody(); \\\n\n }; \\\n\n bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \\\n\n ::testing::internal::TypeParameterizedTest< \\\n\n CaseName, \\\n\n ::testing::internal::TemplateSel< \\\n\n GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \\\n\n GTEST_TYPE_PARAMS_(CaseName)>::Register(\\\n\n \"\", #CaseName, #TestName, 0); \\\n\n template <typename gtest_TypeParam_> \\\n\n void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()\n\n\n\n#endif // GTEST_HAS_TYPED_TEST\n\n\n\n// Implements type-parameterized tests.\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-typed-test.h", "rank": 53, "score": 253238.52919145327 }, { "content": "class CRandomMother { // Encapsulate random number generator\n\npublic:\n\n void RandomInit(int seed); // Initialization\n\n int IRandom(int min, int max); // Get integer random number in desired interval\n\n double Random(); // Get floating point random number\n\n uint32_t BRandom(); // Output random bits\n\n explicit CRandomMother(int seed) { // Constructor\n\n RandomInit(seed);}\n\nprotected:\n\n uint32_t x[5]; // History buffer\n\n};\n\n\n\n#endif // __cplusplus\n\n#endif // RANDOMC_H\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/randomc.h", "rank": 54, "score": 250516.96644426516 }, { "content": "class CRandomMersenne { // Encapsulate random number generator\n\n// Choose which version of Mersenne Twister you want:\n\n#if 0 \n\n// Define constants for type MT11213A:\n\n#define MERS_N 351\n\n#define MERS_M 175\n\n#define MERS_R 19\n\n#define MERS_U 11\n\n#define MERS_S 7\n\n#define MERS_T 15\n\n#define MERS_L 17\n\n#define MERS_A 0xE4BD75F5\n\n#define MERS_B 0x655E5280\n\n#define MERS_C 0xFFD58000\n\n#else \n\n// or constants for type MT19937:\n\n#define MERS_N 624\n\n#define MERS_M 397\n\n#define MERS_R 31\n\n#define MERS_U 11\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/randomc.h", "rank": 55, "score": 250516.96644426516 }, { "content": "struct StaticAssertTypeEqHelper<T, T> {};\n\n\n\n#if GTEST_HAS_GLOBAL_STRING\n\ntypedef ::string string;\n\n#else\n\ntypedef ::std::string string;\n\n#endif // GTEST_HAS_GLOBAL_STRING\n\n\n\n#if GTEST_HAS_GLOBAL_WSTRING\n\ntypedef ::wstring wstring;\n\n#elif GTEST_HAS_STD_WSTRING\n\ntypedef ::std::wstring wstring;\n\n#endif // GTEST_HAS_GLOBAL_WSTRING\n\n\n\n// A helper for suppressing warnings on constant condition. It just\n\n// returns 'condition'.\n\nGTEST_API_ bool IsTrue(bool condition);\n\n\n\n// Defines scoped_ptr.\n\n\n\n// This implementation of scoped_ptr is PARTIAL - it only contains\n\n// enough stuff to satisfy Google Test's need.\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 56, "score": 246821.68418338487 }, { "content": "// State of the definition of a type-parameterized test case.\n\nclass GTEST_API_ TypedTestCasePState {\n\n public:\n\n TypedTestCasePState() : registered_(false) {}\n\n\n\n // Adds the given test name to defined_test_names_ and return true\n\n // if the test case hasn't been registered; otherwise aborts the\n\n // program.\n\n bool AddTestName(const char* file, int line, const char* case_name,\n\n const char* test_name) {\n\n if (registered_) {\n\n fprintf(stderr, \"%s Test %s must be defined before \"\n\n \"REGISTER_TYPED_TEST_CASE_P(%s, ...).\\n\",\n\n FormatFileLocation(file, line).c_str(), test_name, case_name);\n\n fflush(stderr);\n\n posix::Abort();\n\n }\n\n defined_test_names_.insert(test_name);\n\n return true;\n\n }\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 57, "score": 246443.33577027763 }, { "content": "class TestWithParam : public Test, public WithParamInterface<T> {\n\n};\n\n\n\n#endif // GTEST_HAS_PARAM_TEST\n\n\n\n// Macros for indicating success/failure in test code.\n\n\n\n// ADD_FAILURE unconditionally adds a failure to the current test.\n\n// SUCCEED generates a success - it doesn't automatically make the\n\n// current test successful, as a test is only successful when it has\n\n// no failure.\n\n//\n\n// EXPECT_* verifies that a certain condition is satisfied. If not,\n\n// it behaves like ADD_FAILURE. In particular:\n\n//\n\n// EXPECT_TRUE verifies that a Boolean condition is true.\n\n// EXPECT_FALSE verifies that a Boolean condition is false.\n\n//\n\n// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except\n\n// that they will also abort the current function on failure. People\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest.h", "rank": 58, "score": 246114.6251949954 }, { "content": "// A working implementation of the OsStackTraceGetterInterface interface.\n\nclass OsStackTraceGetter : public OsStackTraceGetterInterface {\n\n public:\n\n OsStackTraceGetter() : caller_frame_(NULL) {}\n\n virtual String CurrentStackTrace(int max_depth, int skip_count);\n\n virtual void UponLeavingGTest();\n\n\n\n // This string is inserted in place of stack frames that are part of\n\n // Google Test's implementation.\n\n static const char* const kElidedFramesMarker;\n\n\n\n private:\n\n Mutex mutex_; // protects all internal state\n\n\n\n // We save the stack frame below the frame that calls user code.\n\n // We do this because the address of the frame immediately below\n\n // the user code changes between the call to UponLeavingGTest()\n\n // and any calls to CurrentStackTrace() from within the user code.\n\n void* caller_frame_;\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);\n\n};\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/src/gtest-internal-inl.h", "rank": 59, "score": 243931.47780125585 }, { "content": "struct IteratorTraits<const T*> {\n\n typedef T value_type;\n\n};\n\n\n\n#if GTEST_OS_WINDOWS\n\n# define GTEST_PATH_SEP_ \"\\\\\"\n\n# define GTEST_HAS_ALT_PATH_SEP_ 1\n\n// The biggest signed integer type the compiler supports.\n\ntypedef __int64 BiggestInt;\n\n#else\n\n# define GTEST_PATH_SEP_ \"/\"\n\n# define GTEST_HAS_ALT_PATH_SEP_ 0\n\ntypedef long long BiggestInt; // NOLINT\n\n#endif // GTEST_OS_WINDOWS\n\n\n\n// Utilities for char.\n\n\n\n// isspace(int ch) and friends accept an unsigned char or EOF. char\n\n// may be signed, depending on the compiler (or compiler flags).\n\n// Therefore we need to cast a char to unsigned char before calling\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 60, "score": 243902.89101124124 }, { "content": "class UniversalPrinter<T[N]> {\n\n public:\n\n // Prints the given array, omitting some elements when there are too\n\n // many.\n\n static void Print(const T (&a)[N], ::std::ostream* os) {\n\n UniversalPrintArray(a, N, os);\n\n }\n\n};\n\n\n\n// Implements printing a reference type T&.\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-printers.h", "rank": 61, "score": 242791.93522003427 }, { "content": "// The Mutex class can only be used for mutexes created at runtime. It\n\n// shares its API with MutexBase otherwise.\n\nclass Mutex : public MutexBase {\n\n public:\n\n Mutex() {\n\n GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));\n\n owner_ = 0;\n\n }\n\n ~Mutex() {\n\n GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));\n\n }\n\n\n\n private:\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);\n\n};\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 62, "score": 240039.95126593817 }, { "content": "// The convenience class for users who need to override just one or two\n\n// methods and are not concerned that a possible change to a signature of\n\n// the methods they override will not be caught during the build. For\n\n// comments about each method please see the definition of TestEventListener\n\n// above.\n\nclass EmptyTestEventListener : public TestEventListener {\n\n public:\n\n virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}\n\n virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n\n int /*iteration*/) {}\n\n virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}\n\n virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}\n\n virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}\n\n virtual void OnTestStart(const TestInfo& /*test_info*/) {}\n\n virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}\n\n virtual void OnTestEnd(const TestInfo& /*test_info*/) {}\n\n virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}\n\n virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}\n\n virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}\n\n virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n\n int /*iteration*/) {}\n\n virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}\n\n};\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest.h", "rank": 63, "score": 235499.09584645365 }, { "content": "class ThreadWithParam : public ThreadWithParamBase {\n\n public:\n\n typedef void (*UserThreadFunc)(T);\n\n\n\n ThreadWithParam(\n\n UserThreadFunc func, T param, Notification* thread_can_start)\n\n : func_(func),\n\n param_(param),\n\n thread_can_start_(thread_can_start),\n\n finished_(false) {\n\n ThreadWithParamBase* const base = this;\n\n // The thread can be created only after all fields except thread_\n\n // have been initialized.\n\n GTEST_CHECK_POSIX_SUCCESS_(\n\n pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));\n\n }\n\n ~ThreadWithParam() { Join(); }\n\n\n\n void Join() {\n\n if (!finished_) {\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 64, "score": 235494.29727300708 }, { "content": "class TestFactoryImpl : public TestFactoryBase {\n\n public:\n\n virtual Test* CreateTest() { return new TestClass; }\n\n};\n\n\n\n#if GTEST_OS_WINDOWS\n\n\n\n// Predicate-formatters for implementing the HRESULT checking macros\n\n// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}\n\n// We pass a long instead of HRESULT to avoid causing an\n\n// include dependency for the HRESULT type.\n\nGTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,\n\n long hr); // NOLINT\n\nGTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,\n\n long hr); // NOLINT\n\n\n\n#endif // GTEST_OS_WINDOWS\n\n\n\n// Types of SetUpTestCase() and TearDownTestCase() functions.\n\ntypedef void (*SetUpTestCaseFunc)();\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 65, "score": 233314.31408302265 }, { "content": "class BaseTest : public ::testing::Test {\n\n // You can inherit all the usual members for a non-parameterized test\n\n // fixture here.\n\n};\n\n\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-param-test.h", "rank": 66, "score": 232659.1795088345 }, { "content": "// A failed Google Test assertion will throw an exception of this type when\n\n// GTEST_FLAG(throw_on_failure) is true (if exceptions are enabled). We\n\n// derive it from std::runtime_error, which is for errors presumably\n\n// detectable only at run time. Since std::runtime_error inherits from\n\n// std::exception, many testing frameworks know how to extract and print the\n\n// message inside it.\n\nclass GoogleTestFailureException : public ::std::runtime_error {\n\n public:\n\n explicit GoogleTestFailureException(const TestPartResult& failure)\n\n : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}\n\n};\n\n#endif // GTEST_HAS_EXCEPTIONS\n\n\n\nnamespace internal {\n\n// We put these helper functions in the internal namespace as IBM's xlC\n\n// compiler rejects the code if they were declared static.\n\n\n\n// Runs the given method and handles SEH exceptions it throws, when\n\n// SEH is supported; returns the 0-value for type Result in case of an\n\n// SEH exception. (Microsoft compilers cannot handle SEH and C++\n\n// exceptions in the same function. Therefore, we provide a separate\n\n// wrapper function for handling SEH exceptions.)\n\ntemplate <class T, typename Result>\n\nResult HandleSehExceptionsInMethodIfSupported(\n\n T* object, Result (T::*method)(), const char* location) {\n\n#if GTEST_HAS_SEH\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/src/gtest.cc", "rank": 67, "score": 232590.3438832387 }, { "content": "class ParameterizedTestFactory : public TestFactoryBase {\n\n public:\n\n typedef typename TestClass::ParamType ParamType;\n\n explicit ParameterizedTestFactory(ParamType parameter) :\n\n parameter_(parameter) {}\n\n virtual Test* CreateTest() {\n\n TestClass::SetParam(&parameter_);\n\n return new TestClass();\n\n }\n\n\n\n private:\n\n const ParamType parameter_;\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);\n\n};\n\n\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n\n//\n\n// TestMetaFactoryBase is a base class for meta-factories that create\n\n// test factories for passing into MakeAndRegisterTestInfo function.\n\ntemplate <class ParamType>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-param-util.h", "rank": 68, "score": 231189.76074905344 }, { "content": "class ClassUniqueToAlwaysTrue {};\n\n}\n\n\n\nbool IsTrue(bool condition) { return condition; }\n\n\n\nbool AlwaysTrue() {\n\n#if GTEST_HAS_EXCEPTIONS\n\n // This condition is always false so AlwaysTrue() never actually throws,\n\n // but it makes the compiler think that it may throw.\n\n if (IsTrue(false))\n\n throw ClassUniqueToAlwaysTrue();\n\n#endif // GTEST_HAS_EXCEPTIONS\n\n return true;\n\n}\n\n\n\n// If *pstr starts with the given prefix, modifies *pstr to be right\n\n// past the prefix and returns true; otherwise leaves *pstr unchanged\n\n// and returns false. None of pstr, *pstr, and prefix can be NULL.\n\nbool SkipPrefix(const char* prefix, const char** pstr) {\n\n const size_t prefix_len = strlen(prefix);\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/src/gtest.cc", "rank": 69, "score": 231001.19950436073 }, { "content": "struct AddRef { typedef T& type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 70, "score": 229364.44087975562 }, { "content": "struct RemoveReference { typedef T type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 71, "score": 229364.44087975565 }, { "content": "struct AddReference { typedef T& type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 72, "score": 229364.44087975565 }, { "content": " class Iterator : public ParamIteratorInterface<T> {\n\n public:\n\n Iterator(const ParamGeneratorInterface<T>* base,\n\n typename ContainerType::const_iterator iterator)\n\n : base_(base), iterator_(iterator) {}\n\n virtual ~Iterator() {}\n\n\n\n virtual const ParamGeneratorInterface<T>* BaseGenerator() const {\n\n return base_;\n\n }\n\n virtual void Advance() {\n\n ++iterator_;\n\n value_.reset();\n\n }\n\n virtual ParamIteratorInterface<T>* Clone() const {\n\n return new Iterator(*this);\n\n }\n\n // We need to use cached value referenced by iterator_ because *iterator_\n\n // can return a temporary object (and of type other then T), so just\n\n // having \"return &*iterator_;\" doesn't work.\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-param-util.h", "rank": 73, "score": 228241.58534315112 }, { "content": "class RangeGenerator : public ParamGeneratorInterface<T> {\n\n public:\n\n RangeGenerator(T begin, T end, IncrementT step)\n\n : begin_(begin), end_(end),\n\n step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}\n\n virtual ~RangeGenerator() {}\n\n\n\n virtual ParamIteratorInterface<T>* Begin() const {\n\n return new Iterator(this, begin_, 0, step_);\n\n }\n\n virtual ParamIteratorInterface<T>* End() const {\n\n return new Iterator(this, end_, end_index_, step_);\n\n }\n\n\n\n private:\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-param-util.h", "rank": 74, "score": 226117.03200918192 }, { "content": "struct ByRef<T&> { typedef T& type; }; // NOLINT\n\n\n\n// A handy wrapper for ByRef.\n\n#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type\n\n\n\n// AddRef<T>::type is T if T is a reference; otherwise it's T&. This\n\n// is the same as tr1::add_reference<T>::type.\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 75, "score": 225422.3250972037 }, { "content": "// For selecting which printer to use when a given type has neither <<\n\n// nor PrintTo().\n\nenum TypeKind {\n\n kProtobuf, // a protobuf type\n\n kConvertibleToInteger, // a type implicitly convertible to BiggestInt\n\n // (e.g. a named or unnamed enum type)\n\n kOtherType // anything else\n\n};\n\n\n\n// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called\n\n// by the universal printer to print a value of type T when neither\n\n// operator<< nor PrintTo() is defined for T, where kTypeKind is the\n\n// \"kind\" of T as defined by enum TypeKind.\n\ntemplate <typename T, TypeKind kTypeKind>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-printers.h", "rank": 76, "score": 223746.60419191042 }, { "content": "struct RemoveReference<T&> { typedef T type; }; // NOLINT\n\n\n\n// A handy wrapper around RemoveReference that works when the argument\n\n// T depends on template parameters.\n\n#define GTEST_REMOVE_REFERENCE_(T) \\\n\n typename ::testing::internal::RemoveReference<T>::type\n\n\n\n// Removes const from a type if it is a const type, otherwise leaves\n\n// it unchanged. This is the same as tr1::remove_const, which is not\n\n// widely available yet.\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 77, "score": 223232.79770637926 }, { "content": "struct AddRef<T&> { typedef T& type; }; // NOLINT\n\n\n\n// A handy wrapper for AddRef.\n\n#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type\n\n\n\n// A helper for implementing get<k>().\n\ntemplate <int k> class Get;\n\n\n\n// A helper for implementing tuple_element<k, T>. kIndexValid is true\n\n// iff k < the number of fields in tuple type T.\n\ntemplate <bool kIndexValid, int kIndex, class Tuple>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-tuple.h", "rank": 78, "score": 223232.79770637926 }, { "content": "struct AddReference<T&> { typedef T& type; }; // NOLINT\n\n\n\n// A handy wrapper around AddReference that works when the argument T\n\n// depends on template parameters.\n\n#define GTEST_ADD_REFERENCE_(T) \\\n\n typename ::testing::internal::AddReference<T>::type\n\n\n\n// Adds a reference to const on top of T as necessary. For example,\n\n// it transforms\n\n//\n\n// char ==> const char&\n\n// const char ==> const char&\n\n// char& ==> const char&\n\n// const char& ==> const char&\n\n//\n\n// The argument T must depend on some template parameters.\n\n#define GTEST_REFERENCE_TO_CONST_(T) \\\n\n GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))\n\n\n\n// ImplicitlyConvertible<From, To>::value is a compile-time bool\n\n// constant that's true iff type From can be implicitly converted to\n\n// type To.\n\ntemplate <typename From, typename To>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 79, "score": 223232.79770637926 }, { "content": " class dumper : public dumper_t, public thread_exec {\n\n typedef token_ring<locks::pthread::cond> token_ring_t;\n\n struct thread_info_t {\n\n token_ring_t::token *token;\n\n };\n\n const uint_t threads;\n\n const std::string file_prefix;\n\n storage_t *const ary;\n\n int file_index;\n\n token_ring_t tr;\n\n \n\n struct thread_info_t *thread_info;\n\n size_t nb_records, nb_blocks;\n\n std::ofstream *out;\n\n\n\n public:\n\n dumper(uint_t _threads, const char *_file_prefix, size_t chunk_size, storage_t *_ary) :\n\n threads(_threads), file_prefix(_file_prefix),\n\n ary(_ary), file_index(0), tr()\n\n {\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/raw_dumper.hpp", "rank": 80, "score": 223173.28413626686 }, { "content": "class TestCase;\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest.h", "rank": 81, "score": 222069.47032379985 }, { "content": " class sorted_dumper : public dumper_t, public thread_exec {\n\n typedef typename storage_t::overlap_iterator iterator;\n\n typedef compacted_hash::writer<storage_t> writer_t;\n\n typedef heap_t<iterator> oheap_t;\n\n typedef token_ring<locks::pthread::cond> token_ring_t;\n\n\n\n struct thread_info_t {\n\n writer_t writer;\n\n oheap_t heap;\n\n token_ring_t::token *token;\n\n };\n\n\n\n uint_t threads;\n\n std::string file_prefix;\n\n size_t buffer_size;\n\n uint_t klen, vlen;\n\n uint_t key_len, val_len;\n\n size_t record_len, nb_records, nb_blocks;\n\n storage_t *ary;\n\n int file_index;\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/sorted_dumper.hpp", "rank": 82, "score": 221615.64368409564 }, { "content": " class ComputeOffsetsTest : public ::testing::TestWithParam<offset_test_param>\n\n {\n\n public:\n\n Offsets<uint64_t> offsets;\n\n\n\n ComputeOffsetsTest() :\n\n offsets(GetParam().key_len, GetParam().val_len, 15)\n\n { }\n\n\n\n ~ComputeOffsetsTest() { }\n\n };\n\n\n\n TEST_P(ComputeOffsetsTest, CheckCoherency) {\n\n const Offsets<uint64_t>::offset_t *it = NULL, *pit = NULL;\n\n const Offsets<uint64_t>::offset_t *lit = NULL, *lpit = NULL;\n\n uint_t k_len = GetParam().key_len;\n\n uint_t v_len = GetParam().val_len;\n\n uint_t kv_len = k_len + v_len;\n\n uint_t lk_len = 4;\n\n uint_t lv_len = kv_len - lk_len;\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/test_offsets_key_value.cc", "rank": 83, "score": 221614.34458526858 }, { "content": "struct bool_constant {\n\n typedef bool_constant<bool_value> type;\n\n static const bool value = bool_value;\n\n};\n\ntemplate <bool bool_value> const bool bool_constant<bool_value>::value;\n\n\n\ntypedef bool_constant<false> false_type;\n\ntypedef bool_constant<true> true_type;\n\n\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 84, "score": 220871.66418502445 }, { "content": " class direct_sorted_dumper : public dumper_t, public thread_exec {\n\n typedef typename storage_t::iterator iterator;\n\n typedef typename compacted_hash::writer<storage_t> writer_t;\n\n typedef token_ring<locks::pthread::cond> token_ring_t;\n\n\n\n struct thread_info_t {\n\n writer_t writer;\n\n token_ring_t::token *token;\n\n };\n\n\n\n uint_t threads;\n\n const char *file_prefix;\n\n size_t buffer_size;\n\n uint_t klen, vlen;\n\n uint_t key_len, val_len;\n\n size_t record_len, nb_records;\n\n storage_t *ary;\n\n int file_index;\n\n token_ring_t tr;\n\n uint64_t lower_count, upper_count;\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/direct_sorted_dumper.hpp", "rank": 85, "score": 218597.12745035865 }, { "content": "class TypeWithSize {\n\n public:\n\n // This prevents the user from using TypeWithSize<N> with incorrect\n\n // values of N.\n\n typedef void UInt;\n\n};\n\n\n\n// The specialization for size 4.\n\ntemplate <>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-port.h", "rank": 86, "score": 216885.12875478246 }, { "content": "class TypeWithoutFormatter {\n\n public:\n\n // This default version is called when kTypeKind is kOtherType.\n\n static void PrintValue(const T& value, ::std::ostream* os) {\n\n PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),\n\n sizeof(value), os);\n\n }\n\n};\n\n\n\n// We print a protobuf using its ShortDebugString() when the string\n\n// doesn't exceed this many characters; otherwise we print it using\n\n// DebugString() for better readability.\n\nconst size_t kProtobufOneLinerMaxLength = 50;\n\n\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/gtest-printers.h", "rank": 87, "score": 216885.12875478246 }, { "content": " class hash : public hash_t {\n\n public:\n\n define_error_class(TableFull);\n\n // typedef typename std::pair<key_t,val_t> kv_t;\n\n typedef ary_t storage_t;\n\n typedef typename ary_t::iterator iterator;\n\n\n\n hash() : ary(NULL), dumper(NULL), dumping_initiated(false) {}\n\n explicit hash(ary_t *_ary) : ary(_ary), dumper(NULL), dumping_initiated(false) {}\n\n\n\n virtual ~hash() {}\n\n\n\n size_t get_size() const { return ary->get_size(); }\n\n uint_t get_key_len() const { return ary->get_key_len(); }\n\n uint_t get_val_len() const { return ary->get_val_len(); }\n\n uint_t get_max_reprobe() const { return ary->get_max_reprobe(); }\n\n size_t get_max_reprobe_offset() const { return ary->get_max_reprobe_offset(); }\n\n \n\n void set_dumper(dumper_t *new_dumper) { dumper = new_dumper; }\n\n Time get_writing_time() const { \n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/hash.hpp", "rank": 88, "score": 216544.84863546852 }, { "content": "struct CompileAssertTypesEqual;\n\n\n\ntemplate <typename T>\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/unit_tests/gtest/include/gtest/internal/gtest-internal.h", "rank": 89, "score": 215913.0354147811 }, { "content": " {\"upper-count\", 1, 0, 'U'},\n\n {\"verbose\", 0, 0, 'v'},\n\n {\"output\", 1, 0, 'o'},\n\n {\"help\", 0, 0, 'h'},\n\n {\"usage\", 0, 0, USAGE_OPT},\n\n {\"version\", 0, 0, 'V'},\n\n {0, 0, 0, 0}\n\n };\n\n static const char *short_options = \"hVctL:U:vo:\";\n\n\n\n std::string err;\n\n#define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << \"Invalid \" #type \" '\" << val << \"' for [\" which \"]: \" << err << \"\\n\"; exit(1); }\n\n while(true) { \n\n int index = -1;\n\n int c = getopt_long(argc, argv, short_options, long_options, &index);\n\n if(c == -1) break;\n\n switch(c) {\n\n case ':': \n\n std::cerr << \"Missing required argument for \"\n\n << (index == -1 ? std::string(1, (char)optopt) : std::string(long_options[index].name))\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/dump_fastq_main_cmdline.hpp", "rank": 91, "score": 102.21565083810376 }, { "content": " void parse(int argc, char* argv[]) {\n\n static struct option long_options[] = {\n\n {\"bibtex\", 0, 0, 'b'},\n\n {\"output\", 1, 0, 'o'},\n\n {\"help\", 0, 0, 'h'},\n\n {\"usage\", 0, 0, USAGE_OPT},\n\n {\"version\", 0, 0, 'V'},\n\n {0, 0, 0, 0}\n\n };\n\n static const char *short_options = \"hVbo:\";\n\n\n\n#define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << \"Invalid \" #type \" '\" << val << \"' for [\" which \"]: \" << err << \"\\n\"; exit(1); }\n\n while(true) { \n\n int index = -1;\n\n int c = getopt_long(argc, argv, short_options, long_options, &index);\n\n if(c == -1) break;\n\n switch(c) {\n\n case ':': \n\n std::cerr << \"Missing required argument for \"\n\n << (index == -1 ? std::string(1, (char)optopt) : std::string(long_options[index].name))\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/cite_cmdline.hpp", "rank": 92, "score": 98.19930595393116 }, { "content": " {\"usage\", 0, 0, USAGE_OPT},\n\n {\"version\", 0, 0, 'V'},\n\n {0, 0, 0, 0}\n\n };\n\n static const char *short_options = \"hVctL:U:o:\";\n\n\n\n std::string err;\n\n#define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << \"Invalid \" #type \" '\" << val << \"' for [\" which \"]: \" << err << \"\\n\"; exit(1); }\n\n while(true) { \n\n int index = -1;\n\n int c = getopt_long(argc, argv, short_options, long_options, &index);\n\n if(c == -1) break;\n\n switch(c) {\n\n case ':': \n\n std::cerr << \"Missing required argument for \"\n\n << (index == -1 ? std::string(1, (char)optopt) : std::string(long_options[index].name))\n\n << std::endl;\n\n exit(1);\n\n case 'h':\n\n std::cout << usage() << \"\\n\\n\" << help() << std::endl;\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/dump_main_cmdline.hpp", "rank": 93, "score": 95.05075436714039 }, { "content": " CHECK_ERR(double_t, optarg, \"-i, --increment=double\")\n\n break;\n\n case 'f':\n\n full_flag = true;\n\n break;\n\n }\n\n }\n\n\n\n // Parse arguments\n\n if(argc - optind != 1)\n\n error(\"Requires exactly 1 argument.\");\n\n db_arg = argv[optind];\n\n ++optind;\n\n }\n\n\n\n#define histo_fastq_main_args_USAGE \"Usage: jellyfish qhisto [options] db:string\"\n\n const char * usage() const { return histo_fastq_main_args_USAGE; }\n\n void error(const char *msg) { \n\n std::cerr << \"Error: \" << msg << \"\\n\" << usage()\n\n << \"\\nUse --help for more information\"\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/histo_fastq_main_cmdline.hpp", "rank": 95, "score": 93.55025964726212 }, { "content": "\n\n#define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << \"Invalid \" #type \" '\" << val << \"' for [\" which \"]: \" << err << \"\\n\"; exit(1); }\n\n while(true) { \n\n int index = -1;\n\n int c = getopt_long(argc, argv, short_options, long_options, &index);\n\n if(c == -1) break;\n\n switch(c) {\n\n case ':': \n\n std::cerr << \"Missing required argument for \"\n\n << (index == -1 ? std::string(1, (char)optopt) : std::string(long_options[index].name))\n\n << std::endl;\n\n exit(1);\n\n case 'h':\n\n std::cout << usage() << \"\\n\\n\" << help() << std::endl;\n\n exit(0);\n\n case USAGE_OPT:\n\n std::cout << usage() << \"\\nUse --help for more information.\" << std::endl;\n\n exit(0);\n\n case 'V':\n\n print_version();\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/query_cmdline.hpp", "rank": 96, "score": 91.12339205019302 }, { "content": " ::std::string err;\n\n#define CHECK_ERR(type,val,which) if(!err.empty()) { ::std::cerr << \"Invalid \" #type \" '\" << val << \"' for [\" which \"]: \" << err << \"\\n\"; exit(1); }\n\n while(true) {\n\n int index = -1;\n\n int c = getopt_long(argc, argv, short_options, long_options, &index);\n\n if(c == -1) break;\n\n switch(c) {\n\n case ':':\n\n ::std::cerr << \"Missing required argument for \"\n\n << (index == -1 ? ::std::string(1, (char)optopt) : std::string(long_options[index].name))\n\n << ::std::endl;\n\n exit(1);\n\n case 'h':\n\n ::std::cout << usage() << \"\\n\\n\" << help() << std::endl;\n\n exit(0);\n\n case USAGE_OPT:\n\n ::std::cout << usage() << \"\\nUse --help for more information.\" << std::endl;\n\n exit(0);\n\n case 'V':\n\n print_version();\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/count_main_cmdline.hpp", "rank": 97, "score": 90.3642265943503 }, { "content": " {\"output\", 1, 0, 'o'},\n\n {\"out-counter-len\", 1, 0, OUT_COUNTER_LEN_OPT},\n\n {\"out-buffer-size\", 1, 0, OUT_BUFFER_SIZE_OPT},\n\n {\"verbose\", 0, 0, 'v'},\n\n {\"help\", 0, 0, 'h'},\n\n {\"usage\", 0, 0, USAGE_OPT},\n\n {\"version\", 0, 0, 'V'},\n\n {0, 0, 0, 0}\n\n };\n\n static const char *short_options = \"hVs:o:v\";\n\n\n\n std::string err;\n\n#define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << \"Invalid \" #type \" '\" << val << \"' for [\" which \"]: \" << err << \"\\n\"; exit(1); }\n\n while(true) { \n\n int index = -1;\n\n int c = getopt_long(argc, argv, short_options, long_options, &index);\n\n if(c == -1) break;\n\n switch(c) {\n\n case ':': \n\n std::cerr << \"Missing required argument for \"\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/hash_merge_cmdline.hpp", "rank": 98, "score": 90.1042499324664 }, { "content": " };\n\n static const char *short_options = \"Vl:h:i:f\";\n\n\n\n std::string err;\n\n#define CHECK_ERR(type,val,which) if(!err.empty()) { std::cerr << \"Invalid \" #type \" '\" << val << \"' for [\" which \"]: \" << err << \"\\n\"; exit(1); }\n\n while(true) { \n\n int index = -1;\n\n int c = getopt_long(argc, argv, short_options, long_options, &index);\n\n if(c == -1) break;\n\n switch(c) {\n\n case ':': \n\n std::cerr << \"Missing required argument for \"\n\n << (index == -1 ? std::string(1, (char)optopt) : std::string(long_options[index].name))\n\n << std::endl;\n\n exit(1);\n\n case HELP_OPT:\n\n std::cout << usage() << \"\\n\\n\" << help() << std::endl;\n\n exit(0);\n\n case USAGE_OPT:\n\n std::cout << usage() << \"\\nUse --help for more information.\" << std::endl;\n", "file_path": "kraken/resources/home/dnanexus/jellyfish-1.1.11/jellyfish/histo_fastq_main_cmdline.hpp", "rank": 99, "score": 87.95662058162483 } ]
C++
sources/dansandu/ballotin/logging.cpp
dansandu/ballotin
e92aac53153ca85759bc412a86937b28c5dbfc4c
#include "dansandu/ballotin/logging.hpp" #include "dansandu/ballotin/date_time.hpp" #include "dansandu/ballotin/exception.hpp" #include "dansandu/ballotin/file_system.hpp" #include "dansandu/ballotin/string.hpp" #include <algorithm> #include <fstream> using dansandu::ballotin::date_time::getDateTime; using dansandu::ballotin::file_system::writeToStandardError; using dansandu::ballotin::file_system::writeToStandardOutput; namespace dansandu::ballotin::logging { Logger& Logger::globalInstance() { static auto logger = Logger{}; return logger; } Logger::Logger() : level_{Level::debug} { } void Logger::addHandler(std::string name, const Level level, std::function<void(const LogEntry&)> handler) { const auto lock = std::lock_guard<std::mutex>{mutex_}; if (std::find_if(handlers_.cbegin(), handlers_.cend(), [&name](const auto& handler) { return handler.name == name; }) == handlers_.cend()) { handlers_.push_back({std::move(name), level, std::move(handler)}); } else { THROW(std::logic_error, "the handler named '", name, "' is already registered"); } } void Logger::removeHandler(const std::string_view name) { const auto lock = std::lock_guard<std::mutex>{mutex_}; if (const auto position = std::find_if(handlers_.cbegin(), handlers_.cend(), [name](const auto& handler) { return handler.name == name; }); position != handlers_.cend()) { handlers_.erase(position); } } void Logger::setLevel(const Level level) { level_.store(level); } Level Logger::getLevel() const { return level_.load(); } void Logger::log(const Level level, const char* const function, const char* const file, const int line, const std::string_view message) const { if (level <= getLevel()) { const auto timestamp = getDateTime(); const auto logEntry = LogEntry{timestamp, level, std::this_thread::get_id(), function, file, line, message}; const auto lock = std::lock_guard<std::mutex>{mutex_}; for (const auto& handler : handlers_) { if (logEntry.level <= handler.level) { handler.callback(logEntry); } } } } void Logger::log(const Level level, const char* const function, const char* const file, const int line, const std::function<std::string()>& messageSupplier) const { if (level <= getLevel()) { const auto timestamp = getDateTime(); const auto message = messageSupplier(); const auto logEntry = LogEntry{timestamp, level, std::this_thread::get_id(), function, file, line, message}; const auto lock = std::lock_guard<std::mutex>{mutex_}; for (const auto& handler : handlers_) { if (logEntry.level <= handler.level) { handler.callback(logEntry); } } } } void standardOutputHandler(const LogEntry& logEntry) { auto stream = std::stringstream{}; stream << logEntry.timestamp << " " << levelToString(logEntry.level) << " " << logEntry.threadId << " " << logEntry.file << ":" << logEntry.line << " " << logEntry.message << std::endl; const auto string = stream.str(); if (logEntry.level <= Level::warn) { writeToStandardOutput(string); } else { writeToStandardError(string); } } struct UnitTestsHandlerImplementation { static void deleter(void* pointer) { delete static_cast<UnitTestsHandlerImplementation*>(pointer); } UnitTestsHandlerImplementation(const char* const filePath) : logFile{filePath, std::ios_base::out | std::ios_base::app} { } std::ofstream logFile; std::mutex mutex; }; UnitTestsHandler::UnitTestsHandler(const char* const filePath) : implementation_{new UnitTestsHandlerImplementation{filePath}, UnitTestsHandlerImplementation::deleter} { } void UnitTestsHandler::operator()(const LogEntry& logEntry) { auto stream = std::stringstream{}; stream << logEntry.timestamp << " " << levelToString(logEntry.level) << " " << logEntry.threadId << " " << logEntry.file << ":" << logEntry.line << " " << logEntry.message << std::endl; const auto casted = static_cast<UnitTestsHandlerImplementation*>(implementation_.get()); const auto lock = std::lock_guard<std::mutex>{casted->mutex}; casted->logFile << stream.rdbuf(); } }
#include "dansandu/ballotin/logging.hpp" #include "dansandu/ballotin/date_time.hpp" #include "dansandu/ballotin/exception.hpp" #include "dansandu/ballotin/file_system.hpp" #include "dansandu/ballotin/string.hpp" #include <algorithm> #include <fstream> using dansandu::ballotin::date_time::getDateTime; using dansandu::ballotin::file_system::writeToStandardError; using dansandu::ballotin::file_system::writeToStandardOutput; namespace dansandu::ballotin::logging { Logger& Logger::globalInstance() { static auto logger = Logger{}; return logger; } Logger::Logger() : level_{Level::debug} { } void Logger::addHandler(std::string name, const Level level, std::function<void(const LogEntry&)> handler) { const auto lock = std::lock_guard<std::mutex>{mutex_}; if (std::find_if(handlers_.cbegin(), handlers_.cend(), [&name](const auto& handler) { return handler.name == name; }) == handlers_.cend()) { handlers_.push_back({std::move(name), level, std::move(handler)}); } else { THROW(std::logic_error, "the handler named '", name, "' is already registered"); } } void Logger::removeHandler(const std::string_view name) { const auto lock = std::lock_guard<std::mutex>{mutex_}; if (const auto position = std::find_if(handlers_.cbegin(), handlers_.cend(), [name](const auto& handler) { return handler.name == name; }); position != handlers_.cend()) { handlers_.erase(position); } } void Logger::setLevel(const Level level) { level_.store(level); } Level Logger::getLevel() const { return level_.load(); } void Logger::log(const Level level, const char* const function, const char* const file, const int line, const std::string_view message) const { if (level <= getLevel()) { const auto timestamp = getDateTime(); const auto logEntry = LogEntry{timestamp, level, std::this_thread::get_id(), function, file, line, message}; const auto lock = std::lock_guard<std::mutex>{mutex_}; for (const auto& handler : handlers_) { if (logEntry.level <= handler.level) { handler.callback(logEntry); } } } }
void standardOutputHandler(const LogEntry& logEntry) { auto stream = std::stringstream{}; stream << logEntry.timestamp << " " << levelToString(logEntry.level) << " " << logEntry.threadId << " " << logEntry.file << ":" << logEntry.line << " " << logEntry.message << std::endl; const auto string = stream.str(); if (logEntry.level <= Level::warn) { writeToStandardOutput(string); } else { writeToStandardError(string); } } struct UnitTestsHandlerImplementation { static void deleter(void* pointer) { delete static_cast<UnitTestsHandlerImplementation*>(pointer); } UnitTestsHandlerImplementation(const char* const filePath) : logFile{filePath, std::ios_base::out | std::ios_base::app} { } std::ofstream logFile; std::mutex mutex; }; UnitTestsHandler::UnitTestsHandler(const char* const filePath) : implementation_{new UnitTestsHandlerImplementation{filePath}, UnitTestsHandlerImplementation::deleter} { } void UnitTestsHandler::operator()(const LogEntry& logEntry) { auto stream = std::stringstream{}; stream << logEntry.timestamp << " " << levelToString(logEntry.level) << " " << logEntry.threadId << " " << logEntry.file << ":" << logEntry.line << " " << logEntry.message << std::endl; const auto casted = static_cast<UnitTestsHandlerImplementation*>(implementation_.get()); const auto lock = std::lock_guard<std::mutex>{casted->mutex}; casted->logFile << stream.rdbuf(); } }
void Logger::log(const Level level, const char* const function, const char* const file, const int line, const std::function<std::string()>& messageSupplier) const { if (level <= getLevel()) { const auto timestamp = getDateTime(); const auto message = messageSupplier(); const auto logEntry = LogEntry{timestamp, level, std::this_thread::get_id(), function, file, line, message}; const auto lock = std::lock_guard<std::mutex>{mutex_}; for (const auto& handler : handlers_) { if (logEntry.level <= handler.level) { handler.callback(logEntry); } } } }
function_block-full_function
[ { "content": "enum class Level\n\n{\n\n none,\n\n error,\n\n warn,\n\n info,\n\n debug\n\n};\n\n\n\nconstexpr bool operator<(const Level left, const Level right)\n\n{\n\n return static_cast<int>(left) < static_cast<int>(right);\n\n}\n\n\n\nconstexpr bool operator>(const Level left, const Level right)\n\n{\n\n return right < left;\n\n}\n\n\n\nconstexpr bool operator<=(const Level left, const Level right)\n", "file_path": "sources/dansandu/ballotin/logging.hpp", "rank": 0, "score": 37964.187076900904 }, { "content": "class PRALINE_EXPORT Logger\n\n{\n\npublic:\n\n static Logger& globalInstance();\n\n\n\n Logger();\n\n\n\n void addHandler(std::string name, const Level level, std::function<void(const LogEntry&)> handler);\n\n\n\n void removeHandler(const std::string_view name);\n\n\n\n void setLevel(const Level level);\n\n\n\n Level getLevel() const;\n\n\n\n void log(const Level level, const char* const function, const char* const file, const int line,\n\n const std::string_view message) const;\n\n\n\n void log(const Level level, const char* const function, const char* const file, const int line,\n\n const std::function<std::string()>& messageSupplier) const;\n", "file_path": "sources/dansandu/ballotin/logging.hpp", "rank": 1, "score": 37004.50375433012 }, { "content": "#include \"dansandu/ballotin/file_system.hpp\"\n\n#include \"dansandu/ballotin/exception.hpp\"\n\n\n\n#include <fstream>\n\n#include <iostream>\n\n#include <mutex>\n\n#include <string>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::file_system\n\n{\n\n\n\nvoid writeBinaryFile(const std::string& path, const std::vector<uint8_t>& bytes)\n\n{\n\n auto file = std::ofstream{path, std::ios_base::binary};\n\n file << std::noskipws;\n\n for (auto byte : bytes)\n\n {\n\n if (!(file << byte))\n\n {\n", "file_path": "sources/dansandu/ballotin/file_system.cpp", "rank": 2, "score": 24546.439535208512 }, { "content": " }\n\n\n\n return bytes;\n\n}\n\n\n\nvoid writeToStandardOutput(const std::string_view string)\n\n{\n\n static auto mutex = std::mutex{};\n\n auto lock = std::lock_guard<std::mutex>{mutex};\n\n std::cout << string;\n\n}\n\n\n\nvoid writeToStandardError(const std::string_view string)\n\n{\n\n static auto mutex = std::mutex{};\n\n auto lock = std::lock_guard<std::mutex>{mutex};\n\n std::cerr << string;\n\n}\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/file_system.cpp", "rank": 3, "score": 24545.773598053685 }, { "content": "#pragma once\n\n\n\n#include <cstdint>\n\n#include <string>\n\n#include <string_view>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::file_system\n\n{\n\n\n\nPRALINE_EXPORT void writeBinaryFile(const std::string& path, const std::vector<uint8_t>& bytes);\n\n\n\nPRALINE_EXPORT std::vector<uint8_t> readBinaryFile(const std::string& path);\n\n\n\nPRALINE_EXPORT void writeToStandardOutput(const std::string_view string);\n\n\n\nPRALINE_EXPORT void writeToStandardError(const std::string_view string);\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/file_system.hpp", "rank": 4, "score": 24544.495660802197 }, { "content": " THROW(std::runtime_error, \"could not write bytes to file '\", path, \"'\");\n\n }\n\n }\n\n file.close();\n\n}\n\n\n\nstd::vector<uint8_t> readBinaryFile(const std::string& path)\n\n{\n\n auto bytes = std::vector<uint8_t>{};\n\n\n\n auto file = std::ifstream{path, std::ios_base::binary};\n\n if (!(file >> std::noskipws))\n\n {\n\n THROW(std::runtime_error, \"file '\", path, \"' does not exist\");\n\n }\n\n\n\n auto byte = uint8_t{};\n\n while (file >> byte)\n\n {\n\n bytes.push_back(byte);\n", "file_path": "sources/dansandu/ballotin/file_system.cpp", "rank": 5, "score": 24539.849632900863 }, { "content": "class PRALINE_EXPORT UnitTestsHandler\n\n{\n\npublic:\n\n UnitTestsHandler(const char* const filePath);\n\n\n\n void operator()(const LogEntry& logEntry);\n\n\n\nprivate:\n\n std::shared_ptr<void> implementation_;\n\n};\n\n\n\n}\n\n\n\n#if (PRALINE_LOGGING_LEVEL >= 1)\n\n#define LOG_ERROR(...) \\\n\n dansandu::ballotin::logging::Logger::globalInstance().log( \\\n\n dansandu::ballotin::logging::Level::error, __func__, __FILE__, __LINE__, \\\n\n [&]() { return dansandu::ballotin::string::format(__VA_ARGS__); });\n\n#else\n\n#define LOG_ERROR(...) ;\n", "file_path": "sources/dansandu/ballotin/logging.hpp", "rank": 7, "score": 20946.509790293385 }, { "content": "\n\n logger.log(expectedLevel, expectedFunction, expectedFile, expectedLine, expectedMessage);\n\n\n\n REQUIRE(logged);\n\n }\n\n\n\n SECTION(\"level not matching\")\n\n {\n\n auto logged = false;\n\n\n\n logger.addHandler(\"test\", Level::info, [&](const LogEntry&) { logged = true; });\n\n\n\n logger.log(Level::debug, \"function\", \"file\", 3, \"message\");\n\n\n\n REQUIRE(!logged);\n\n }\n\n\n\n SECTION(\"duplicate handler\")\n\n {\n\n const auto name = \"default\";\n", "file_path": "sources/dansandu/ballotin/logging.test.cpp", "rank": 12, "score": 17.44756364670914 }, { "content": "#include \"dansandu/ballotin/logging.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\n#include <stdexcept>\n\n#include <string>\n\n#include <string_view>\n\n\n\nusing dansandu::ballotin::logging::Level;\n\nusing dansandu::ballotin::logging::LogEntry;\n\nusing dansandu::ballotin::logging::Logger;\n\n\n\nTEST_CASE(\"logging\")\n\n{\n\n auto logger = Logger{};\n\n\n\n SECTION(\"level matching\")\n\n {\n\n const auto expectedFunction = \"function\";\n\n const auto expectedFile = \"file\";\n\n const auto expectedLine = 17;\n", "file_path": "sources/dansandu/ballotin/logging.test.cpp", "rank": 13, "score": 16.201727605812955 }, { "content": "#define CATCH_CONFIG_RUNNER\n\n#include \"catchorg/catch/catch.hpp\"\n\n#include \"dansandu/ballotin/logging.hpp\"\n\n\n\nusing dansandu::ballotin::logging::Level;\n\nusing dansandu::ballotin::logging::Logger;\n\nusing dansandu::ballotin::logging::UnitTestsHandler;\n\n\n\nint main(const int argumentsCount, const char* const* const arguments)\n\n{\n\n auto& logger = Logger::globalInstance();\n\n logger.setLevel(Level::debug);\n\n logger.addHandler(\"UnitTests\", Level::debug, UnitTestsHandler{\"unit_tests.log\"});\n\n\n\n const auto catchResult = Catch::Session().run(argumentsCount, arguments);\n\n\n\n return catchResult;\n\n}\n", "file_path": "sources/dansandu/ballotin/executable.test.cpp", "rank": 14, "score": 15.739934268121328 }, { "content": " const auto expectedLevel = Level::debug;\n\n const auto expectedMessage = \"message\";\n\n\n\n auto logged = false;\n\n\n\n logger.addHandler(\"test\", Level::debug,\n\n [&](const LogEntry& logEntry)\n\n {\n\n REQUIRE(logEntry.function == expectedFunction);\n\n\n\n REQUIRE(logEntry.file == expectedFile);\n\n\n\n REQUIRE(logEntry.line == expectedLine);\n\n\n\n REQUIRE(logEntry.level == expectedLevel);\n\n\n\n REQUIRE(logEntry.message == expectedMessage);\n\n\n\n logged = true;\n\n });\n", "file_path": "sources/dansandu/ballotin/logging.test.cpp", "rank": 16, "score": 14.945977943292384 }, { "content": " const auto level = Level::debug;\n\n const auto handler = [&](const LogEntry&) {};\n\n\n\n logger.addHandler(name, level, handler);\n\n\n\n REQUIRE_THROWS_AS(logger.addHandler(name, level, handler), std::logic_error);\n\n }\n\n\n\n SECTION(\"remove handler\")\n\n {\n\n auto logged = false;\n\n\n\n logger.addHandler(\"test\", Level::error, [&](const LogEntry&) { logged = true; });\n\n\n\n logger.removeHandler(\"test\");\n\n\n\n logger.log(Level::error, \"function\", \"file\", 3, \"message\");\n\n\n\n REQUIRE(!logged);\n\n }\n\n}\n", "file_path": "sources/dansandu/ballotin/logging.test.cpp", "rank": 17, "score": 14.64119949356617 }, { "content": "#pragma once\n\n\n\n#include <algorithm>\n\n#include <map>\n\n#include <optional>\n\n#include <ostream>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::container\n\n{\n\n\n\ntemplate<typename T>\n\nauto pop(std::vector<T>& stack)\n\n{\n\n auto value = std::move(stack.back());\n\n stack.pop_back();\n\n return value;\n\n}\n\n\n\ntemplate<typename T, typename E>\n", "file_path": "sources/dansandu/ballotin/container.hpp", "rank": 20, "score": 10.722046983428807 }, { "content": "\n\nprivate:\n\n struct Handler\n\n {\n\n std::string name;\n\n Level level;\n\n std::function<void(const LogEntry&)> callback;\n\n };\n\n\n\n std::atomic<Level> level_;\n\n std::vector<Handler> handlers_;\n\n mutable std::mutex mutex_;\n\n};\n\n\n\nPRALINE_EXPORT void standardOutputHandler(const LogEntry& logEntry);\n\n\n", "file_path": "sources/dansandu/ballotin/logging.hpp", "rank": 21, "score": 10.192521224568342 }, { "content": "{\n\n return !(right < left);\n\n}\n\n\n\nconstexpr bool operator>=(const Level left, const Level right)\n\n{\n\n return !(left < right);\n\n}\n\n\n\nconstexpr const char* levelToString(const Level level)\n\n{\n\n const char* const levels[] = {\"NONE\", \"ERROR\", \"WARN\", \"INFO\", \"DEBUG\"};\n\n return levels[static_cast<int>(level)];\n\n}\n\n\n", "file_path": "sources/dansandu/ballotin/logging.hpp", "rank": 22, "score": 9.81178658241992 }, { "content": "#include \"dansandu/ballotin/type_traits.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\nusing dansandu::ballotin::type_traits::TypeDictionary;\n\nusing dansandu::ballotin::type_traits::TypeEntry;\n\nusing dansandu::ballotin::type_traits::TypePack;\n\n\n\nTEST_CASE(\"type_traits\")\n\n{\n\n REQUIRE(TypePack<int, float, double>::contains<int>);\n\n\n\n REQUIRE(!TypePack<int, float, double>::contains<char>);\n\n\n\n using Dictionary = TypeDictionary<TypeEntry<int, unsigned>, TypeEntry<char, unsigned char>>;\n\n\n\n REQUIRE(Dictionary::containsKey<int>);\n\n\n\n REQUIRE(!Dictionary::containsKey<double>);\n\n\n\n REQUIRE(std::is_same_v<Dictionary::Get<double>, void>);\n\n\n\n REQUIRE(std::is_same_v<Dictionary::Get<int>, unsigned>);\n\n}\n", "file_path": "sources/dansandu/ballotin/type_traits.test.cpp", "rank": 23, "score": 9.739394036981015 }, { "content": "#include \"dansandu/ballotin/binary.hpp\"\n\n#include \"dansandu/ballotin/exception.hpp\"\n\n\n\n#include <cstdint>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::binary\n\n{\n\n\n\nvoid pushBits(std::vector<uint8_t>& bytes, int& bitsCount, const unsigned bitsToAppend, const int bitsToAppendCount)\n\n{\n\n constexpr auto bitsPerByte = 8;\n\n\n\n const auto bytesCount = bitsCount / bitsPerByte + (0 < bitsCount % bitsPerByte);\n\n\n\n if (static_cast<int>(bytes.size()) < bytesCount)\n\n {\n\n THROW(std::invalid_argument, \"invalid bit count \", bitsCount,\n\n \" -- bit count cannot be larger than current bytes size\", bytes.size());\n\n }\n", "file_path": "sources/dansandu/ballotin/binary.cpp", "rank": 24, "score": 8.784973699006745 }, { "content": "#pragma once\n\n\n\n#include <cstdint>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::binary\n\n{\n\n\n\nPRALINE_EXPORT void pushBits(std::vector<uint8_t>& bytes, int& bitsCount, const unsigned bitsToAppend,\n\n const int bitsToAppendCount);\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/binary.hpp", "rank": 25, "score": 8.575316755047561 }, { "content": "#endif\n\n\n\n#if (PRALINE_LOGGING_LEVEL >= 2)\n\n#define LOG_WARN(...) \\\n\n dansandu::ballotin::logging::Logger::globalInstance().log( \\\n\n dansandu::ballotin::logging::Level::warn, __func__, __FILE__, __LINE__, \\\n\n [&]() { return dansandu::ballotin::string::format(__VA_ARGS__); });\n\n#else\n\n#define LOG_WARN(...) ;\n\n#endif\n\n\n\n#if (PRALINE_LOGGING_LEVEL >= 3)\n\n#define LOG_INFO(...) \\\n\n dansandu::ballotin::logging::Logger::globalInstance().log( \\\n\n dansandu::ballotin::logging::Level::info, __func__, __FILE__, __LINE__, \\\n\n [&]() { return dansandu::ballotin::string::format(__VA_ARGS__); });\n\n#else\n\n#define LOG_INFO(...) ;\n\n#endif\n\n\n\n#if (PRALINE_LOGGING_LEVEL >= 4)\n\n#define LOG_DEBUG(...) \\\n\n dansandu::ballotin::logging::Logger::globalInstance().log( \\\n\n dansandu::ballotin::logging::Level::debug, __func__, __FILE__, __LINE__, \\\n\n [&]() { return dansandu::ballotin::string::format(__VA_ARGS__); });\n\n#else\n\n#define LOG_DEBUG(...) ;\n\n#endif\n", "file_path": "sources/dansandu/ballotin/logging.hpp", "rank": 26, "score": 8.533284570238202 }, { "content": "{\n\n const auto casted = static_cast<Implementation*>(implementation_.get());\n\n if (casted->process_)\n\n {\n\n {\n\n const auto lock = std::lock_guard{casted->mutex_};\n\n casted->events_.push_back(Event::resume);\n\n }\n\n casted->conditionVariable_.notify_one();\n\n }\n\n}\n\n\n\nvoid Processor::pause()\n\n{\n\n const auto casted = static_cast<Implementation*>(implementation_.get());\n\n if (casted->process_)\n\n {\n\n {\n\n const auto lock = std::lock_guard{casted->mutex_};\n\n casted->events_.push_back(Event::pause);\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 27, "score": 8.361582407829935 }, { "content": "#pragma once\n\n\n\n#include <functional>\n\n\n\nnamespace dansandu::ballotin::hash\n\n{\n\n\n\ntemplate<typename ValueType>\n\nauto hashCombine(std::size_t seed, const ValueType& value)\n\n{\n\n using std::hash;\n\n return seed ^ (hash<ValueType>{}(value) + (seed << 6) + (seed >> 2) + 0x9e3779b9);\n\n}\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/hash.hpp", "rank": 28, "score": 8.324089680729909 }, { "content": "#include \"dansandu/ballotin/hash.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\nusing dansandu::ballotin::hash::hashCombine;\n\n\n\nTEST_CASE(\"hash\")\n\n{\n\n SECTION(\"hash combine\")\n\n {\n\n auto i = 13;\n\n auto j = 29;\n\n auto iHash = std::hash<int>{}(i);\n\n auto jHash = std::hash<int>{}(j);\n\n auto hash = hashCombine(iHash, j);\n\n\n\n REQUIRE(iHash != hash);\n\n\n\n REQUIRE(jHash != hash);\n\n }\n\n}\n", "file_path": "sources/dansandu/ballotin/hash.test.cpp", "rank": 29, "score": 8.273410419739868 }, { "content": "#include \"dansandu/ballotin/container.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\n#include <map>\n\n#include <sstream>\n\n#include <string>\n\n#include <vector>\n\n\n\nusing dansandu::ballotin::container::contains;\n\nusing dansandu::ballotin::container::pop;\n\nusing dansandu::ballotin::container::uniquePushBack;\n\nusing dansandu::ballotin::container::operator<<;\n\n\n\nTEST_CASE(\"container\")\n\n{\n\n SECTION(\"pop\")\n\n {\n\n auto stack = std::vector<int>{{7, 11, 13}};\n\n\n\n REQUIRE(pop(stack) == 13);\n", "file_path": "sources/dansandu/ballotin/container.test.cpp", "rank": 30, "score": 8.170698598813185 }, { "content": "#pragma once\n\n\n\n#include <sstream>\n\n#include <string>\n\n#include <string_view>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::string\n\n{\n\n\n\ntemplate<typename Iterable>\n\nauto join(const Iterable& iterable, const std::string_view separator)\n\n{\n\n auto stream = std::stringstream{};\n\n for (const auto& element : iterable)\n\n {\n\n stream << element << separator;\n\n }\n\n auto result = stream.str();\n\n result.erase(result.end() - std::min(separator.size(), result.size()), result.end());\n", "file_path": "sources/dansandu/ballotin/string.hpp", "rank": 31, "score": 7.6750462094875225 }, { "content": "#include \"dansandu/ballotin/string.hpp\"\n\n#include \"dansandu/ballotin/exception.hpp\"\n\n\n\n#include <algorithm>\n\n#include <sstream>\n\n#include <string>\n\n#include <string_view>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::string\n\n{\n\n\n\nstd::vector<std::string> split(const std::string_view string, const std::string_view delimiter)\n\n{\n\n if (delimiter.empty())\n\n {\n\n THROW(std::invalid_argument, \"delimiter cannot be empty\");\n\n }\n\n auto tokens = std::vector<std::string>{};\n\n auto tokenBegin = string.cbegin();\n", "file_path": "sources/dansandu/ballotin/string.cpp", "rank": 32, "score": 7.141171046312068 }, { "content": "#include \"dansandu/ballotin/exception.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\n#include <stdexcept>\n\n\n\nusing Catch::Matches;\n\n\n\nTEST_CASE(\"exception\")\n\n{\n\n SECTION(\"pretty throw\")\n\n {\n\n std::string message;\n\n try\n\n {\n\n THROW(std::invalid_argument, \"ouch -- \", 1, \" exception has been thrown\");\n\n }\n\n catch (const std::exception& ex)\n\n {\n\n message = ex.what();\n\n }\n\n\n\n REQUIRE(!message.empty());\n\n }\n\n}\n", "file_path": "sources/dansandu/ballotin/exception.test.cpp", "rank": 33, "score": 7.141132953702044 }, { "content": " }\n\n casted->conditionVariable_.notify_one();\n\n }\n\n}\n\n\n\nvoid Processor::reset()\n\n{\n\n const auto casted = static_cast<Implementation*>(implementation_.get());\n\n if (casted->process_)\n\n {\n\n {\n\n const auto lock = std::lock_guard{casted->mutex_};\n\n casted->events_.push_back(Event::reset);\n\n }\n\n casted->conditionVariable_.notify_one();\n\n }\n\n}\n\n\n\nstd::unique_ptr<IProcess> Processor::wait()\n\n{\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 34, "score": 7.121676900867499 }, { "content": "#include \"dansandu/ballotin/date_time.hpp\"\n\n\n\n#include <chrono>\n\n#include <ctime>\n\n\n\nnamespace dansandu::ballotin::date_time\n\n{\n\n\n\nstd::string getDateTime()\n\n{\n\n auto t = time_t{};\n\n time(&t);\n\n\n\n auto tt = tm{};\n\n\n\n#ifdef _WIN32\n\n gmtime_s(&tt, &t);\n\n#else\n\n gmtime_r(&t, &tt);\n\n#endif\n\n\n\n char buffer[64];\n\n strftime(buffer, sizeof(buffer) / sizeof(*buffer), \"%Y-%m-%d %H:%M:%S%z\", &tt);\n\n\n\n return buffer;\n\n}\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/date_time.cpp", "rank": 35, "score": 7.052971571705927 }, { "content": " const auto casted = static_cast<Implementation*>(implementation_.get());\n\n if (casted->process_)\n\n {\n\n {\n\n const auto lock = std::lock_guard{casted->mutex_};\n\n casted->events_.push_back(Event::wait);\n\n }\n\n casted->conditionVariable_.notify_one();\n\n casted->thread_.join();\n\n }\n\n return std::move(casted->process_);\n\n}\n\n\n\nstd::unique_ptr<IProcess> Processor::yield()\n\n{\n\n const auto casted = static_cast<Implementation*>(implementation_.get());\n\n if (casted->process_)\n\n {\n\n {\n\n const auto lock = std::lock_guard{casted->mutex_};\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 36, "score": 6.865452302204998 }, { "content": "#include \"dansandu/ballotin/random.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\n#include <algorithm>\n\n\n\nusing dansandu::ballotin::random::PredictableBitGenerator;\n\n\n\nTEST_CASE(\"random\")\n\n{\n\n SECTION(\"PredictableBitGenerator\")\n\n {\n\n SECTION(\"seedless\")\n\n {\n\n SECTION(\"samples\")\n\n {\n\n auto generator = PredictableBitGenerator{};\n\n\n\n REQUIRE(generator.min() == 0U);\n\n\n\n REQUIRE(generator.max() == 255U);\n", "file_path": "sources/dansandu/ballotin/random.test.cpp", "rank": 37, "score": 6.86516764722126 }, { "content": "bool contains(const std::vector<T>& container, const E& element)\n\n{\n\n return std::find(container.cbegin(), container.cend(), element) != container.cend();\n\n}\n\n\n\ntemplate<typename T, typename E>\n\nvoid uniquePushBack(std::vector<T>& container, E&& element)\n\n{\n\n if (auto position = std::find(container.cbegin(), container.cend(), element); position == container.cend())\n\n {\n\n container.push_back(std::forward<E>(element));\n\n }\n\n}\n\n\n\ntemplate<typename T>\n\nstd::ostream& operator<<(std::ostream& stream, const std::vector<T>& container)\n\n{\n\n auto addComma = false;\n\n stream << \"[\";\n\n for (const auto& element : container)\n", "file_path": "sources/dansandu/ballotin/container.hpp", "rank": 38, "score": 6.765770928275906 }, { "content": "#include \"dansandu/ballotin/string.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n#include \"dansandu/ballotin/exception.hpp\"\n\n\n\n#include <vector>\n\n\n\nusing dansandu::ballotin::string::format;\n\nusing dansandu::ballotin::string::join;\n\nusing dansandu::ballotin::string::split;\n\nusing dansandu::ballotin::string::trim;\n\n\n\nTEST_CASE(\"string\")\n\n{\n\n SECTION(\"join\")\n\n {\n\n SECTION(\"nonempty separator and list\")\n\n {\n\n std::vector<int> integers = {1, 2, 3, 4};\n\n REQUIRE(join(integers, \", \") == \"1, 2, 3, 4\");\n\n }\n", "file_path": "sources/dansandu/ballotin/string.test.cpp", "rank": 39, "score": 6.725182501826636 }, { "content": "#include \"dansandu/ballotin/binary.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\n#include <cstdint>\n\n#include <vector>\n\n\n\nusing dansandu::ballotin::binary::pushBits;\n\n\n\nusing bytes_type = std::vector<uint8_t>;\n\n\n\nTEST_CASE(\"binary\")\n\n{\n\n SECTION(\"push bits\")\n\n {\n\n SECTION(\"new byte partial write\")\n\n {\n\n bytes_type output = {};\n\n\n\n auto bitsCount = 0;\n\n\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 40, "score": 6.282337066906995 }, { "content": "#pragma once\n\n\n\n#include \"dansandu/ballotin/string.hpp\"\n\n\n\n#include <stdexcept>\n\n#include <thread>\n\n\n\n#define THROW(exception, ...) \\\n\n throw exception{dansandu::ballotin::string::format(\"'\", #exception, \"' exception in thread '\", \\\n\n std::this_thread::get_id(), \\\n\n \"': \", dansandu::ballotin::string::format(__VA_ARGS__), \\\n\n \"\\n at \", __func__, \"(\", __FILE__, \":\", __LINE__, \")\")};\n", "file_path": "sources/dansandu/ballotin/exception.hpp", "rank": 41, "score": 6.066664982677775 }, { "content": "#pragma once\n\n\n\n#include <type_traits>\n\n#include <variant>\n\n\n\nnamespace dansandu::ballotin::type_traits\n\n{\n\n\n", "file_path": "sources/dansandu/ballotin/type_traits.hpp", "rank": 42, "score": 5.6522548257993 }, { "content": "#pragma once\n\n\n\n#include \"dansandu/ballotin/type_traits.hpp\"\n\n\n\n#include <chrono>\n\n#include <memory>\n\n\n\nnamespace dansandu::ballotin::processor\n\n{\n\n\n", "file_path": "sources/dansandu/ballotin/processor.hpp", "rank": 43, "score": 5.499857423342395 }, { "content": "#include \"dansandu/ballotin/processor.hpp\"\n\n\n\n#include <chrono>\n\n#include <condition_variable>\n\n#include <memory>\n\n#include <mutex>\n\n#include <thread>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::processor\n\n{\n\n\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 44, "score": 5.488743430064611 }, { "content": "#pragma once\n\n\n\n#include \"dansandu/ballotin/string.hpp\"\n\n\n\n#include <atomic>\n\n#include <functional>\n\n#include <memory>\n\n#include <mutex>\n\n#include <string>\n\n#include <string_view>\n\n#include <thread>\n\n#include <vector>\n\n\n\nnamespace dansandu::ballotin::logging\n\n{\n\n\n", "file_path": "sources/dansandu/ballotin/logging.hpp", "rank": 45, "score": 5.3747592612285136 }, { "content": "#pragma once\n\n\n\nnamespace dansandu::ballotin::relation\n\n{\n\n\n\ntemplate<typename T>\n", "file_path": "sources/dansandu/ballotin/relation.hpp", "rank": 46, "score": 5.3038671848018115 }, { "content": "#include \"dansandu/ballotin/relation.hpp\"\n\n#include \"catchorg/catch/catch.hpp\"\n\n\n\nusing dansandu::ballotin::relation::TotalOrder;\n\n\n", "file_path": "sources/dansandu/ballotin/relation.test.cpp", "rank": 47, "score": 5.234473767629856 }, { "content": "\n\n auto lock = std::unique_lock{mutex_};\n\n\n\n if (handleEvents())\n\n {\n\n return;\n\n }\n\n\n\n while (paused)\n\n {\n\n conditionVariable_.wait(lock);\n\n\n\n if (handleEvents())\n\n {\n\n return;\n\n }\n\n }\n\n\n\n if (remaining > std::chrono::milliseconds::zero())\n\n {\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 48, "score": 4.895054463724028 }, { "content": "#pragma once\n\n\n\n#include <string>\n\n\n\nnamespace dansandu::ballotin::date_time\n\n{\n\n\n\nstd::string getDateTime();\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/date_time.hpp", "rank": 49, "score": 4.643605514744116 }, { "content": "\n\n REQUIRE(pop(stack) == 11);\n\n\n\n REQUIRE(pop(stack) == 7);\n\n }\n\n\n\n SECTION(\"contains\")\n\n {\n\n auto container = std::vector<int>{{3, 5, 7, 10}};\n\n\n\n REQUIRE(contains(container, 5));\n\n\n\n REQUIRE(!contains(container, 8));\n\n }\n\n\n\n SECTION(\"unique push back\")\n\n {\n\n auto container = std::vector<int>{{1, 3, 5, 7}};\n\n\n\n SECTION(\"unique\")\n", "file_path": "sources/dansandu/ballotin/container.test.cpp", "rank": 50, "score": 4.514603732773809 }, { "content": "\n\n while (static_cast<int>(bytes.size()) > bytesCount)\n\n {\n\n bytes.pop_back();\n\n }\n\n\n\n const auto bitsCapacity = bytesCount * bitsPerByte;\n\n\n\n auto remainingBits = bitsToAppend;\n\n auto remainingBitsCount = bitsToAppendCount;\n\n\n\n while (remainingBitsCount > 0)\n\n {\n\n const auto freeBitsCount = bitsCapacity - bitsCount;\n\n\n\n if (const auto implaceBitsCount = std::min(freeBitsCount, remainingBitsCount); implaceBitsCount > 0)\n\n {\n\n const auto implaceMask = (1U << implaceBitsCount) - 1U;\n\n bytes.back() |= (remainingBits & implaceMask) << (bitsPerByte - freeBitsCount);\n\n\n", "file_path": "sources/dansandu/ballotin/binary.cpp", "rank": 51, "score": 4.3799986047786446 }, { "content": "\n\n const auto expected = std::vector<unsigned>{{0, 1, 2, 3, 4, 5, 6, 7}};\n\n\n\n auto actual = std::vector<unsigned>{};\n\n for (auto i = 0U; i < expected.size(); ++i)\n\n {\n\n actual.push_back(generator());\n\n }\n\n\n\n REQUIRE(expected == actual);\n\n }\n\n\n\n SECTION(\"shuffle\")\n\n {\n\n const auto samples = 50000;\n\n\n\n auto ordered = std::vector<int>{};\n\n for (auto index = 0; index < samples; ++index)\n\n {\n\n ordered.push_back(index);\n", "file_path": "sources/dansandu/ballotin/random.test.cpp", "rank": 52, "score": 4.234990475103344 }, { "content": " {\n\n if (addComma)\n\n stream << \", \";\n\n stream << element;\n\n addComma = true;\n\n }\n\n return stream << \"]\";\n\n}\n\n\n\ntemplate<typename K, typename V>\n\nstd::ostream& operator<<(std::ostream& stream, const std::map<K, V>& container)\n\n{\n\n auto addComma = false;\n\n stream << \"{\";\n\n for (const auto& pair : container)\n\n {\n\n if (addComma)\n\n stream << \", \";\n\n stream << pair.first << \": \" << pair.second;\n\n addComma = true;\n", "file_path": "sources/dansandu/ballotin/container.hpp", "rank": 53, "score": 3.955242603721711 }, { "content": " {\n\n uniquePushBack(container, 0);\n\n\n\n REQUIRE(container == std::vector<int>{{1, 3, 5, 7, 0}});\n\n }\n\n\n\n SECTION(\"duplicate\")\n\n {\n\n uniquePushBack(container, 3);\n\n\n\n REQUIRE(container == std::vector<int>{{1, 3, 5, 7}});\n\n }\n\n }\n\n\n\n SECTION(\"pretty print\")\n\n {\n\n auto stream = std::stringstream{};\n\n\n\n SECTION(\"empty vector\")\n\n {\n", "file_path": "sources/dansandu/ballotin/container.test.cpp", "rank": 54, "score": 3.9199625164313625 }, { "content": " return result;\n\n}\n\n\n\ntemplate<typename... Arguments>\n\nauto format(Arguments&&... arguments)\n\n{\n\n auto stream = std::stringstream{};\n\n (stream << ... << arguments);\n\n return stream.str();\n\n}\n\n\n\nPRALINE_EXPORT std::vector<std::string> split(const std::string_view string, const std::string_view delimiter);\n\n\n\nPRALINE_EXPORT std::string trim(const std::string_view string);\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/string.hpp", "rank": 55, "score": 3.38773520798557 }, { "content": " const auto timepoint = std::chrono::system_clock::now() + remaining;\n\n\n\n auto status = std::cv_status::no_timeout;\n\n\n\n while ((status != std::cv_status::timeout) & !paused)\n\n {\n\n status = conditionVariable_.wait_until(lock, timepoint);\n\n if (handleEvents())\n\n {\n\n return;\n\n }\n\n }\n\n\n\n if (status == std::cv_status::timeout)\n\n {\n\n remaining = interval_;\n\n }\n\n else\n\n {\n\n remaining = std::chrono::duration_cast<std::chrono::milliseconds>(timepoint -\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 56, "score": 3.2512358143521807 }, { "content": "\n\n constexpr static result_type min()\n\n {\n\n return 0U;\n\n }\n\n\n\n constexpr static result_type max()\n\n {\n\n return 255U;\n\n }\n\n\n\nprivate:\n\n result_type index_;\n\n};\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/random.hpp", "rank": 57, "score": 3.0156891609125216 }, { "content": " stream << std::vector<int>{};\n\n REQUIRE(stream.str() == \"[]\");\n\n }\n\n\n\n SECTION(\"singleton vector\")\n\n {\n\n stream << std::vector<int>{1};\n\n REQUIRE(stream.str() == \"[1]\");\n\n }\n\n\n\n SECTION(\"many elements vector\")\n\n {\n\n stream << std::vector<int>{{1, 2, 3, 4}};\n\n REQUIRE(stream.str() == \"[1, 2, 3, 4]\");\n\n }\n\n\n\n SECTION(\"empty map\")\n\n {\n\n stream << std::map<std::string, int>{};\n\n REQUIRE(stream.str() == \"{}\");\n", "file_path": "sources/dansandu/ballotin/container.test.cpp", "rank": 58, "score": 2.9119966926890486 }, { "content": "#pragma once\n\n\n\nnamespace dansandu::ballotin::random\n\n{\n\n\n", "file_path": "sources/dansandu/ballotin/random.hpp", "rank": 59, "score": 2.8274098452571748 }, { "content": "\n\n SECTION(\"empty separator and nonempty list\")\n\n {\n\n std::vector<int> integers = {1, 2, 3, 4};\n\n REQUIRE(join(integers, \"\") == \"1234\");\n\n }\n\n\n\n SECTION(\"nonempty separator and empty list\")\n\n {\n\n std::vector<int> integers;\n\n REQUIRE(join(integers, \"#\") == \"\");\n\n }\n\n\n\n SECTION(\"empty separator and empty list\")\n\n {\n\n std::vector<int> integers;\n\n REQUIRE(join(integers, \"\") == \"\");\n\n }\n\n }\n\n\n", "file_path": "sources/dansandu/ballotin/string.test.cpp", "rank": 60, "score": 2.7267031025978414 }, { "content": " {\n\n const auto sequence = {32, 0, 34, 1, 4, 5, 6, 35, 33};\n\n const auto codeSize = 6;\n\n auto output = bytes_type{};\n\n auto bitsCount = 0;\n\n\n\n for (const auto code : sequence)\n\n {\n\n pushBits(output, bitsCount, code, codeSize);\n\n }\n\n\n\n const bytes_type expectedOutput = {0b00100000U, 0b00100000U, 0b00000110U, 0b01000100U,\n\n 0b01100001U, 0b10001100U, 0b00100001U};\n\n\n\n REQUIRE(output == expectedOutput);\n\n\n\n const auto expectedBitsCount = 54;\n\n\n\n REQUIRE(bitsCount == expectedBitsCount);\n\n }\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 61, "score": 2.5051240631596885 }, { "content": " auto done = false;\n\n auto wait = false;\n\n auto remaining = interval_;\n\n\n\n const auto handleEvents = [&]()\n\n {\n\n for (decltype(events_.size()) index = 0; index < events_.size(); ++index)\n\n {\n\n switch (events_[index])\n\n {\n\n case Event::resume:\n\n // +--------+--------+-------------------------+\n\n // | wait | done | paused = wait & !done |\n\n // +--------+--------+-------------------------+\n\n // | 0 | 0 | 0 |\n\n // | 0 | 1 | 0 |\n\n // | 1 | 0 | 1 |\n\n // | 1 | 1 | 0 |\n\n // +--------+--------+-------------------------+\n\n paused = wait & !done;\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 62, "score": 2.5037855698581497 }, { "content": " }\n\n }\n\n\n\n SECTION(\"with seed\")\n\n {\n\n auto generator = PredictableBitGenerator{252U};\n\n\n\n REQUIRE(generator.min() == 0U);\n\n\n\n REQUIRE(generator.max() == 255U);\n\n\n\n const auto expected = std::vector<unsigned>{{252, 253, 254, 255, 0, 1, 2}};\n\n\n\n auto actual = std::vector<unsigned>{};\n\n for (auto i = 0U; i < expected.size(); ++i)\n\n {\n\n actual.push_back(generator());\n\n }\n\n\n\n REQUIRE(expected == actual);\n\n }\n\n }\n\n}\n", "file_path": "sources/dansandu/ballotin/random.test.cpp", "rank": 63, "score": 2.4553759877110366 }, { "content": " }\n\n\n\n SECTION(\"singleton map\")\n\n {\n\n stream << std::map<std::string, int>{{{\"key\", 17}}};\n\n REQUIRE(stream.str() == \"{key: 17}\");\n\n }\n\n\n\n SECTION(\"many elements map\")\n\n {\n\n stream << std::map<std::string, int>{{{\"key\", 17}, {\"other\", 20}, {\"another\", 23}}};\n\n REQUIRE(stream.str() == \"{another: 23, key: 17, other: 20}\");\n\n }\n\n }\n\n}\n", "file_path": "sources/dansandu/ballotin/container.test.cpp", "rank": 64, "score": 2.444549221522946 }, { "content": " }\n\n\n\n const auto seed = 0U;\n\n\n\n auto generator = PredictableBitGenerator{seed};\n\n auto shuffled = ordered;\n\n std::shuffle(shuffled.begin(), shuffled.end(), generator);\n\n\n\n REQUIRE(shuffled.size() == ordered.size());\n\n\n\n REQUIRE(std::is_permutation(shuffled.cbegin(), shuffled.cend(), ordered.cbegin(), ordered.cend()));\n\n\n\n const auto expected = shuffled;\n\n\n\n generator.seed(seed);\n\n\n\n shuffled = ordered;\n\n std::shuffle(shuffled.begin(), shuffled.end(), generator);\n\n\n\n REQUIRE(expected == shuffled);\n", "file_path": "sources/dansandu/ballotin/random.test.cpp", "rank": 65, "score": 2.252167574636667 }, { "content": " ++begin;\n\n\n\n auto end = string.end() - 1;\n\n while (end > begin && std::isspace(*end))\n\n --end;\n\n\n\n return {begin, end + 1};\n\n}\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/string.cpp", "rank": 66, "score": 2.22934589559777 }, { "content": "\n\n auto bitsCount = 12;\n\n\n\n pushBits(output, bitsCount, 0b0110, 4);\n\n\n\n const bytes_type expectedOutput = {0b11100101U, 0b01101111U};\n\n\n\n REQUIRE(output == expectedOutput);\n\n\n\n const auto expectedByteCount = 2;\n\n\n\n REQUIRE(output.size() == expectedByteCount);\n\n\n\n const auto expectedBitsCount = 16;\n\n\n\n REQUIRE(bitsCount == expectedBitsCount);\n\n }\n\n\n\n SECTION(\"new byte fill\")\n\n {\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 67, "score": 2.105916354730592 }, { "content": " }\n\n return stream << \"}\";\n\n}\n\n\n\ntemplate<typename T>\n\nstd::ostream& operator<<(std::ostream& stream, const std::optional<T>& optional)\n\n{\n\n stream << \"Optional(\";\n\n if (optional)\n\n stream << *optional;\n\n return stream << \")\";\n\n}\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/container.hpp", "rank": 68, "score": 2.09537522687058 }, { "content": " pushBits(output, bitsCount, 0b101U, 3);\n\n\n\n const bytes_type expectedOutput = {0b00000101U};\n\n\n\n REQUIRE(output == expectedOutput);\n\n\n\n const auto expectedByteCount = 1;\n\n\n\n REQUIRE(output.size() == expectedByteCount);\n\n\n\n const auto expectedBitsCount = 3;\n\n\n\n REQUIRE(bitsCount == expectedBitsCount);\n\n }\n\n\n\n SECTION(\"previous byte parital write\")\n\n {\n\n bytes_type output = {0b00000101U};\n\n\n\n auto bitsCount = 3;\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 69, "score": 2.031070159737566 }, { "content": " auto bitsCount = 7;\n\n\n\n pushBits(output, bitsCount, 0b10011U, 5);\n\n\n\n const bytes_type expectedOutput = {0b11100101U, 0b00001001U};\n\n\n\n REQUIRE(output == expectedOutput);\n\n\n\n const auto expectedByteCount = 2;\n\n\n\n REQUIRE(output.size() == expectedByteCount);\n\n\n\n const auto expectedBitsCount = 12;\n\n\n\n REQUIRE(bitsCount == expectedBitsCount);\n\n }\n\n\n\n SECTION(\"previous byte fill\")\n\n {\n\n bytes_type output = {0b11100101U, 0b00001111U};\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 70, "score": 1.9886628214846853 }, { "content": " bytes_type output = {0b11100101U, 0b01111111U, 0b00101011U};\n\n\n\n auto bitsCount = 24;\n\n\n\n pushBits(output, bitsCount, 0b00001100U, 8);\n\n\n\n const bytes_type expectedOutput = {0b11100101U, 0b01111111U, 0b00101011U, 0b00001100U};\n\n\n\n REQUIRE(output == expectedOutput);\n\n\n\n const auto expectedByteCount = 4;\n\n\n\n REQUIRE(output.size() == expectedByteCount);\n\n\n\n const auto expectedBitsCount = 32;\n\n\n\n REQUIRE(bitsCount == expectedBitsCount);\n\n }\n\n\n\n SECTION(\"sequence\")\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 71, "score": 1.9347997822239937 }, { "content": "\n\n const bytes_type expectedOutput = {0b11110100};\n\n\n\n REQUIRE(output == expectedOutput);\n\n\n\n const auto expectedBitsCount = 8;\n\n\n\n REQUIRE(bitsCount == expectedBitsCount);\n\n }\n\n\n\n SECTION(\"byte underflow\")\n\n {\n\n bytes_type output = {0b10101010};\n\n auto bitsCount = 9;\n\n\n\n REQUIRE_THROWS_AS(pushBits(output, bitsCount, 0b00110011, 6), std::invalid_argument);\n\n }\n\n }\n\n}\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 72, "score": 1.8457874084396222 }, { "content": "\n\n SECTION(\"large append\")\n\n {\n\n bytes_type output = {0b00000111};\n\n\n\n auto bitsCount = 3;\n\n\n\n pushBits(output, bitsCount, 0b11111011110111011010, 20);\n\n\n\n const bytes_type expectedOutput = {0b11010111, 0b11101110, 0b01111101};\n\n\n\n REQUIRE(output == expectedOutput);\n\n }\n\n\n\n SECTION(\"byte overflow\")\n\n {\n\n bytes_type output = {0b00110100, 0b00000000, 0b00000000};\n\n auto bitsCount = 6;\n\n\n\n pushBits(output, bitsCount, 0b00000011, 2);\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 73, "score": 1.7604948052244769 }, { "content": "\n\n pushBits(output, bitsCount, 0b1100U, 4);\n\n\n\n const bytes_type expectedOutput = {0b01100101U};\n\n\n\n REQUIRE(output == expectedOutput);\n\n\n\n const auto expectedByteCount = 1;\n\n\n\n REQUIRE(output.size() == expectedByteCount);\n\n\n\n const auto expectedBitsCount = 7;\n\n\n\n REQUIRE(bitsCount == expectedBitsCount);\n\n }\n\n\n\n SECTION(\"previous byte write extending to new byte\")\n\n {\n\n bytes_type output = {0b01100101U};\n\n\n", "file_path": "sources/dansandu/ballotin/binary.test.cpp", "rank": 74, "score": 1.6977338861482911 }, { "content": " remainingBits >>= implaceBitsCount;\n\n remainingBitsCount -= implaceBitsCount;\n\n bitsCount += implaceBitsCount;\n\n }\n\n\n\n if (const auto extendedBitsCount = std::min(bitsPerByte, remainingBitsCount); extendedBitsCount > 0)\n\n {\n\n const auto extendedMask = (1U << extendedBitsCount) - 1U;\n\n bytes.push_back(remainingBits & extendedMask);\n\n\n\n remainingBits >>= extendedBitsCount;\n\n remainingBitsCount -= extendedBitsCount;\n\n bitsCount += extendedBitsCount;\n\n }\n\n }\n\n}\n\n\n\n}\n", "file_path": "sources/dansandu/ballotin/binary.cpp", "rank": 75, "score": 1.5214561923852314 }, { "content": " auto tokenEnd = tokenBegin;\n\n while ((tokenEnd = std::search(tokenBegin, string.cend(), delimiter.cbegin(), delimiter.cend())) != string.cend())\n\n {\n\n if (tokenBegin != tokenEnd)\n\n {\n\n tokens.emplace_back(tokenBegin, tokenEnd);\n\n }\n\n tokenBegin = tokenEnd + delimiter.size();\n\n }\n\n if (tokenBegin != tokenEnd)\n\n {\n\n tokens.emplace_back(tokenBegin, tokenEnd);\n\n }\n\n return tokens;\n\n}\n\n\n\nstd::string trim(const std::string_view string)\n\n{\n\n auto begin = string.begin();\n\n while (begin < string.end() && std::isspace(*begin))\n", "file_path": "sources/dansandu/ballotin/string.cpp", "rank": 76, "score": 1.4975345367974282 }, { "content": " std::chrono::system_clock::now());\n\n }\n\n }\n\n }\n\n }\n\n\n\n std::thread thread_;\n\n std::condition_variable conditionVariable_;\n\n std::vector<Event> events_;\n\n std::unique_ptr<IProcess> process_;\n\n std::chrono::milliseconds interval_;\n\n std::mutex mutex_;\n\n};\n\n\n\nProcessor::Processor(std::unique_ptr<IProcess> process, const std::chrono::milliseconds interval)\n\n : implementation_{new Implementation{std::move(process), interval}, &Implementation::deleter}\n\n{\n\n}\n\n\n\nvoid Processor::resume()\n", "file_path": "sources/dansandu/ballotin/processor.cpp", "rank": 77, "score": 1.31255754540252 } ]
C++
external/opengl/libagl2/src/texture.cpp
gordonjohnpatrick/XobotOS
888ed3b8cc8d8e0a54b1858bfa5a3572545f4d2f
#include "gles2context.h" #define API_ENTRY #define CALL_GL_API(NAME,...) LOGD("?"#NAME); assert(0); #define CALL_GL_API_RETURN(NAME,...) LOGD("?"#NAME); assert(0); return 0; static inline GGLTexture * AllocTexture() { GGLTexture * tex = (GGLTexture *)calloc(1, sizeof(GGLTexture)); tex->minFilter = GGLTexture::GGL_LINEAR; tex->magFilter = GGLTexture::GGL_LINEAR; return tex; } void GLES2Context::InitializeTextures() { tex.textures = std::map<GLuint, GGLTexture *>(); tex.tex2D = AllocTexture(); tex.textures[GL_TEXTURE_2D] = tex.tex2D; tex.texCube = AllocTexture(); tex.textures[GL_TEXTURE_CUBE_MAP] = tex.texCube; for (unsigned i = 0; i < GGL_MAXCOMBINEDTEXTUREIMAGEUNITS; i++) { tex.tmus[i] = NULL; tex.sampler2tmu[i] = NULL; } tex.active = 0; tex.free = max(GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP) + 1; tex.tex2D->format = GGL_PIXEL_FORMAT_RGBA_8888; tex.tex2D->type = GL_TEXTURE_2D; tex.tex2D->levelCount = 1; tex.tex2D->wrapS = tex.tex2D->wrapT = GGLTexture::GGL_REPEAT; tex.tex2D->minFilter = tex.tex2D->magFilter = GGLTexture::GGL_NEAREST; tex.tex2D->width = tex.tex2D->height = 1; tex.tex2D->levels = malloc(4); *(unsigned *)tex.tex2D->levels = 0xff000000; tex.texCube->format = GGL_PIXEL_FORMAT_RGBA_8888; tex.texCube->type = GL_TEXTURE_CUBE_MAP; tex.texCube->levelCount = 1; tex.texCube->wrapS = tex.texCube->wrapT = GGLTexture::GGL_REPEAT; tex.texCube->minFilter = tex.texCube->magFilter = GGLTexture::GGL_NEAREST; tex.texCube->width = tex.texCube->height = 1; tex.texCube->levels = malloc(4 * 6); static unsigned texels [6] = {0xff0000ff, 0xff00ff00, 0xffff0000, 0xff00ffff, 0xffffff00, 0xffff00ff }; memcpy(tex.texCube->levels, texels, sizeof texels); tex.unpack = 4; } void GLES2Context::TextureState::UpdateSampler(GGLInterface * iface, unsigned tmu) { for (unsigned i = 0; i < GGL_MAXCOMBINEDTEXTUREIMAGEUNITS; i++) if (tmu == sampler2tmu[i]) iface->SetSampler(iface, i, tmus[tmu]); } void GLES2Context::UninitializeTextures() { for (std::map<GLuint, GGLTexture *>::iterator it = tex.textures.begin(); it != tex.textures.end(); it++) { if (!it->second) continue; free(it->second->levels); free(it->second); } } static inline void GetFormatAndBytesPerPixel(const GLenum format, unsigned * bytesPerPixel, GGLPixelFormat * texFormat) { switch (format) { case GL_ALPHA: *texFormat = GGL_PIXEL_FORMAT_A_8; *bytesPerPixel = 1; break; case GL_LUMINANCE: *texFormat = GGL_PIXEL_FORMAT_L_8; *bytesPerPixel = 1; break; case GL_LUMINANCE_ALPHA: *texFormat = GGL_PIXEL_FORMAT_LA_88; *bytesPerPixel = 2; break; case GL_RGB: *texFormat = GGL_PIXEL_FORMAT_RGB_888; *bytesPerPixel = 3; break; case GL_RGBA: *texFormat = GGL_PIXEL_FORMAT_RGBA_8888; *bytesPerPixel = 4; break; case GL_UNSIGNED_SHORT_5_6_5: *texFormat = GGL_PIXEL_FORMAT_RGB_565; *bytesPerPixel = 2; break; default: assert(0); return; } } static inline void CopyTexture(char * dst, const char * src, const unsigned bytesPerPixel, const unsigned sx, const unsigned sy, const unsigned sw, const unsigned dx, const unsigned dy, const unsigned dw, const unsigned w, const unsigned h) { const unsigned bpp = bytesPerPixel; if (dw == sw && dw == w && sx == 0 && dx == 0) memcpy(dst + dy * dw * bpp, src + sy * sw * bpp, w * h * bpp); else for (unsigned y = 0; y < h; y++) memcpy(dst + ((dy + y) * dw + dx) * bpp, src + ((sy + y) * sw + sx) * bpp, w * bpp); } void glActiveTexture(GLenum texture) { GLES2_GET_CONST_CONTEXT(ctx); unsigned index = texture - GL_TEXTURE0; assert(NELEM(ctx->tex.tmus) > index); ctx->tex.active = index; } void glBindTexture(GLenum target, GLuint texture) { GLES2_GET_CONST_CONTEXT(ctx); std::map<GLuint, GGLTexture *>::iterator it = ctx->tex.textures.find(texture); GGLTexture * tex = NULL; if (it != ctx->tex.textures.end()) { tex = it->second; if (!tex) { tex = AllocTexture(); tex->type = target; it->second = tex; } assert(target == tex->type); } else if (0 == texture) { if (GL_TEXTURE_2D == target) { tex = ctx->tex.tex2D; } else if (GL_TEXTURE_CUBE_MAP == target) { tex = ctx->tex.texCube; } else assert(0); } else { if (texture <= ctx->tex.free) ctx->tex.free = texture + 1; tex = AllocTexture(); tex->type = target; ctx->tex.textures[texture] = tex; } ctx->tex.tmus[ctx->tex.active] = tex; ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void API_ENTRY(glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) { CALL_GL_API(glCompressedTexImage2D, target, level, internalformat, width, height, border, imageSize, data); } void API_ENTRY(glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) { CALL_GL_API(glCompressedTexSubImage2D, target, level, xoffset, yoffset, width, height, format, imageSize, data); } void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { GLES2_GET_CONST_CONTEXT(ctx); assert(0 == border); assert(0 == level); unsigned bytesPerPixel = 0; GGLPixelFormat texFormat = GGL_PIXEL_FORMAT_UNKNOWN; GetFormatAndBytesPerPixel(internalformat, &bytesPerPixel, &texFormat); assert(texFormat == ctx->rasterizer.frameSurface.format); unsigned offset = 0, size = width * height * bytesPerPixel, totalSize = size; assert(ctx->tex.tmus[ctx->tex.active]); assert(y + height <= ctx->rasterizer.frameSurface.height); assert(x + width <= ctx->rasterizer.frameSurface.width); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; tex.width = width; tex.height = height; tex.levelCount = 1; tex.format = texFormat; switch (target) { case GL_TEXTURE_2D: tex.levels = realloc(tex.levels, totalSize); CopyTexture((char *)tex.levels, (const char *)ctx->rasterizer.frameSurface.data, bytesPerPixel, x, y, ctx->rasterizer.frameSurface.width, 0, 0, width, width, height); break; default: assert(0); return; } ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { GLES2_GET_CONST_CONTEXT(ctx); assert(0 == level); unsigned bytesPerPixel = 4; unsigned offset = 0, size = width * height * bytesPerPixel, totalSize = size; assert(ctx->tex.tmus[ctx->tex.active]); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; assert(tex.format == ctx->rasterizer.frameSurface.format); assert(GGL_PIXEL_FORMAT_RGBA_8888 == tex.format); const unsigned srcWidth = ctx->rasterizer.frameSurface.width; const unsigned srcHeight = ctx->rasterizer.frameSurface.height; assert(x >= 0 && y >= 0); assert(xoffset >= 0 && yoffset >= 0); assert(x + width <= srcWidth); assert(y + height <= srcHeight); assert(xoffset + width <= tex.width); assert(yoffset + height <= tex.height); switch (target) { case GL_TEXTURE_2D: CopyTexture((char *)tex.levels, (const char *)ctx->rasterizer.frameSurface.data, bytesPerPixel, x, y, srcWidth, xoffset, yoffset, tex.width, width, height); break; default: assert(0); return; } ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void glDeleteTextures(GLsizei n, const GLuint* textures) { GLES2_GET_CONST_CONTEXT(ctx); for (unsigned i = 0; i < n; i++) { std::map<GLuint, GGLTexture *>::iterator it = ctx->tex.textures.find(textures[i]); if (it == ctx->tex.textures.end()) continue; ctx->tex.free = min(ctx->tex.free, textures[i]); for (unsigned i = 0; i < GGL_MAXCOMBINEDTEXTUREIMAGEUNITS; i++) if (ctx->tex.tmus[i] == it->second) { if (GL_TEXTURE_2D == it->second->type) ctx->tex.tmus[i] = ctx->tex.tex2D; else if (GL_TEXTURE_CUBE_MAP == it->second->type) ctx->tex.tmus[i] = ctx->tex.texCube; else assert(0); ctx->tex.UpdateSampler(ctx->iface, i); } if (it->second) { free(it->second->levels); free(it->second); } ctx->tex.textures.erase(it); } } void glGenTextures(GLsizei n, GLuint* textures) { GLES2_GET_CONST_CONTEXT(ctx); for (unsigned i = 0; i < n; i++) { textures[i] = 0; for (ctx->tex.free; ctx->tex.free < 0xffffffffu; ctx->tex.free++) if (ctx->tex.textures.find(ctx->tex.free) == ctx->tex.textures.end()) { ctx->tex.textures[ctx->tex.free] = NULL; textures[i] = ctx->tex.free; ctx->tex.free++; break; } assert(textures[i]); } } void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params) { CALL_GL_API(glGetTexParameterfv, target, pname, params); } void API_ENTRY(glGetTexParameteriv)(GLenum target, GLenum pname, GLint* params) { CALL_GL_API(glGetTexParameteriv, target, pname, params); } GLboolean glIsTexture(GLuint texture) { GLES2_GET_CONST_CONTEXT(ctx); if (ctx->tex.textures.find(texture) == ctx->tex.textures.end()) return GL_FALSE; else return GL_TRUE; } void glPixelStorei(GLenum pname, GLint param) { GLES2_GET_CONST_CONTEXT(ctx); assert(GL_UNPACK_ALIGNMENT == pname); assert(1 == param || 2 == param || 4 == param || 8 == param); ctx->tex.unpack = param; } void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) { GLES2_GET_CONST_CONTEXT(ctx); switch (type) { case GL_UNSIGNED_BYTE: break; case GL_UNSIGNED_SHORT_5_6_5: internalformat = format = GL_UNSIGNED_SHORT_5_6_5; assert(4 == ctx->tex.unpack); break; default: assert(0); } assert(internalformat == format); assert(0 == border); if (0 != level) { LOGD("agl2: glTexImage2D level=%d", level); return; } unsigned bytesPerPixel = 0; GGLPixelFormat texFormat = GGL_PIXEL_FORMAT_UNKNOWN; GetFormatAndBytesPerPixel(format, &bytesPerPixel, &texFormat); assert(texFormat && bytesPerPixel); unsigned offset = 0, size = width * height * bytesPerPixel, totalSize = size; assert(ctx->tex.tmus[ctx->tex.active]); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; tex.width = width; tex.height = height; tex.levelCount = 1; tex.format = texFormat; switch (target) { case GL_TEXTURE_2D: assert(GL_TEXTURE_2D == ctx->tex.tmus[ctx->tex.active]->type); offset = 0; break; break; case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: assert(GL_TEXTURE_CUBE_MAP == ctx->tex.tmus[ctx->tex.active]->type); assert(width == height); offset = (target - GL_TEXTURE_CUBE_MAP_POSITIVE_X) * size; totalSize = 6 * size; break; default: assert(0); return; } tex.levels = realloc(tex.levels, totalSize); if (pixels) CopyTexture((char *)tex.levels, (const char *)pixels, bytesPerPixel, 0, 0, width, 0, 0, width, width, height); ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void glTexParameterf(GLenum target, GLenum pname, GLfloat param) { glTexParameteri(target, pname, param); } void API_ENTRY(glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* params) { CALL_GL_API(glTexParameterfv, target, pname, params); } void glTexParameteri(GLenum target, GLenum pname, GLint param) { GLES2_GET_CONST_CONTEXT(ctx); assert(ctx->tex.tmus[ctx->tex.active]); assert(target == ctx->tex.tmus[ctx->tex.active]->type); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; switch (pname) { case GL_TEXTURE_WRAP_S: case GL_TEXTURE_WRAP_T: GGLTexture::GGLTextureWrap wrap; switch (param) { case GL_REPEAT: wrap = GGLTexture::GGL_REPEAT; break; case GL_CLAMP_TO_EDGE: wrap = GGLTexture::GGL_CLAMP_TO_EDGE; break; case GL_MIRRORED_REPEAT: wrap = GGLTexture::GGL_MIRRORED_REPEAT; break; default: assert(0); return; } if (GL_TEXTURE_WRAP_S == pname) tex.wrapS = wrap; else tex.wrapT = wrap; break; case GL_TEXTURE_MIN_FILTER: switch (param) { case GL_NEAREST: tex.minFilter = GGLTexture::GGL_NEAREST; break; case GL_LINEAR: tex.minFilter = GGLTexture::GGL_LINEAR; break; case GL_NEAREST_MIPMAP_NEAREST: break; case GL_NEAREST_MIPMAP_LINEAR: break; case GL_LINEAR_MIPMAP_NEAREST: break; case GL_LINEAR_MIPMAP_LINEAR: break; default: assert(0); return; } break; case GL_TEXTURE_MAG_FILTER: switch (param) { case GL_NEAREST: tex.minFilter = GGLTexture::GGL_NEAREST; break; case GL_LINEAR: tex.minFilter = GGLTexture::GGL_LINEAR; break; default: assert(0); return; } break; default: assert(0); return; } if (tex.magFilter != tex.minFilter) tex.magFilter = tex.minFilter = GGLTexture::GGL_LINEAR; ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void API_ENTRY(glTexParameteriv)(GLenum target, GLenum pname, const GLint* params) { CALL_GL_API(glTexParameteriv, target, pname, params); } void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) { GLES2_GET_CONST_CONTEXT(ctx); assert(0 == level); assert(target == ctx->tex.tmus[ctx->tex.active]->type); switch (type) { case GL_UNSIGNED_BYTE: break; case GL_UNSIGNED_SHORT_5_6_5: format = GL_UNSIGNED_SHORT_5_6_5; assert(4 == ctx->tex.unpack); break; default: assert(0); } GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; GGLPixelFormat texFormat = GGL_PIXEL_FORMAT_UNKNOWN; unsigned bytesPerPixel = 0; GetFormatAndBytesPerPixel(format, &bytesPerPixel, &texFormat); assert(texFormat == tex.format); assert(GL_UNSIGNED_BYTE == type); switch (target) { case GL_TEXTURE_2D: CopyTexture((char *)tex.levels, (const char *)pixels, bytesPerPixel, 0, 0, width, xoffset, yoffset, tex.width, width, height); break; default: assert(0); } ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); }
#include "gles2context.h" #define API_ENTRY #define CALL_GL_API(NAME,...) LOGD("?"#NAME); assert(0); #define CALL_GL_API_RETURN(NAME,...) LOGD("?"#NAME); assert(0); return 0;
void GLES2Context::InitializeTextures() { tex.textures = std::map<GLuint, GGLTexture *>(); tex.tex2D = AllocTexture(); tex.textures[GL_TEXTURE_2D] = tex.tex2D; tex.texCube = AllocTexture(); tex.textures[GL_TEXTURE_CUBE_MAP] = tex.texCube; for (unsigned i = 0; i < GGL_MAXCOMBINEDTEXTUREIMAGEUNITS; i++) { tex.tmus[i] = NULL; tex.sampler2tmu[i] = NULL; } tex.active = 0; tex.free = max(GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP) + 1; tex.tex2D->format = GGL_PIXEL_FORMAT_RGBA_8888; tex.tex2D->type = GL_TEXTURE_2D; tex.tex2D->levelCount = 1; tex.tex2D->wrapS = tex.tex2D->wrapT = GGLTexture::GGL_REPEAT; tex.tex2D->minFilter = tex.tex2D->magFilter = GGLTexture::GGL_NEAREST; tex.tex2D->width = tex.tex2D->height = 1; tex.tex2D->levels = malloc(4); *(unsigned *)tex.tex2D->levels = 0xff000000; tex.texCube->format = GGL_PIXEL_FORMAT_RGBA_8888; tex.texCube->type = GL_TEXTURE_CUBE_MAP; tex.texCube->levelCount = 1; tex.texCube->wrapS = tex.texCube->wrapT = GGLTexture::GGL_REPEAT; tex.texCube->minFilter = tex.texCube->magFilter = GGLTexture::GGL_NEAREST; tex.texCube->width = tex.texCube->height = 1; tex.texCube->levels = malloc(4 * 6); static unsigned texels [6] = {0xff0000ff, 0xff00ff00, 0xffff0000, 0xff00ffff, 0xffffff00, 0xffff00ff }; memcpy(tex.texCube->levels, texels, sizeof texels); tex.unpack = 4; } void GLES2Context::TextureState::UpdateSampler(GGLInterface * iface, unsigned tmu) { for (unsigned i = 0; i < GGL_MAXCOMBINEDTEXTUREIMAGEUNITS; i++) if (tmu == sampler2tmu[i]) iface->SetSampler(iface, i, tmus[tmu]); } void GLES2Context::UninitializeTextures() { for (std::map<GLuint, GGLTexture *>::iterator it = tex.textures.begin(); it != tex.textures.end(); it++) { if (!it->second) continue; free(it->second->levels); free(it->second); } } static inline void GetFormatAndBytesPerPixel(const GLenum format, unsigned * bytesPerPixel, GGLPixelFormat * texFormat) { switch (format) { case GL_ALPHA: *texFormat = GGL_PIXEL_FORMAT_A_8; *bytesPerPixel = 1; break; case GL_LUMINANCE: *texFormat = GGL_PIXEL_FORMAT_L_8; *bytesPerPixel = 1; break; case GL_LUMINANCE_ALPHA: *texFormat = GGL_PIXEL_FORMAT_LA_88; *bytesPerPixel = 2; break; case GL_RGB: *texFormat = GGL_PIXEL_FORMAT_RGB_888; *bytesPerPixel = 3; break; case GL_RGBA: *texFormat = GGL_PIXEL_FORMAT_RGBA_8888; *bytesPerPixel = 4; break; case GL_UNSIGNED_SHORT_5_6_5: *texFormat = GGL_PIXEL_FORMAT_RGB_565; *bytesPerPixel = 2; break; default: assert(0); return; } } static inline void CopyTexture(char * dst, const char * src, const unsigned bytesPerPixel, const unsigned sx, const unsigned sy, const unsigned sw, const unsigned dx, const unsigned dy, const unsigned dw, const unsigned w, const unsigned h) { const unsigned bpp = bytesPerPixel; if (dw == sw && dw == w && sx == 0 && dx == 0) memcpy(dst + dy * dw * bpp, src + sy * sw * bpp, w * h * bpp); else for (unsigned y = 0; y < h; y++) memcpy(dst + ((dy + y) * dw + dx) * bpp, src + ((sy + y) * sw + sx) * bpp, w * bpp); } void glActiveTexture(GLenum texture) { GLES2_GET_CONST_CONTEXT(ctx); unsigned index = texture - GL_TEXTURE0; assert(NELEM(ctx->tex.tmus) > index); ctx->tex.active = index; } void glBindTexture(GLenum target, GLuint texture) { GLES2_GET_CONST_CONTEXT(ctx); std::map<GLuint, GGLTexture *>::iterator it = ctx->tex.textures.find(texture); GGLTexture * tex = NULL; if (it != ctx->tex.textures.end()) { tex = it->second; if (!tex) { tex = AllocTexture(); tex->type = target; it->second = tex; } assert(target == tex->type); } else if (0 == texture) { if (GL_TEXTURE_2D == target) { tex = ctx->tex.tex2D; } else if (GL_TEXTURE_CUBE_MAP == target) { tex = ctx->tex.texCube; } else assert(0); } else { if (texture <= ctx->tex.free) ctx->tex.free = texture + 1; tex = AllocTexture(); tex->type = target; ctx->tex.textures[texture] = tex; } ctx->tex.tmus[ctx->tex.active] = tex; ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void API_ENTRY(glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) { CALL_GL_API(glCompressedTexImage2D, target, level, internalformat, width, height, border, imageSize, data); } void API_ENTRY(glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) { CALL_GL_API(glCompressedTexSubImage2D, target, level, xoffset, yoffset, width, height, format, imageSize, data); } void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { GLES2_GET_CONST_CONTEXT(ctx); assert(0 == border); assert(0 == level); unsigned bytesPerPixel = 0; GGLPixelFormat texFormat = GGL_PIXEL_FORMAT_UNKNOWN; GetFormatAndBytesPerPixel(internalformat, &bytesPerPixel, &texFormat); assert(texFormat == ctx->rasterizer.frameSurface.format); unsigned offset = 0, size = width * height * bytesPerPixel, totalSize = size; assert(ctx->tex.tmus[ctx->tex.active]); assert(y + height <= ctx->rasterizer.frameSurface.height); assert(x + width <= ctx->rasterizer.frameSurface.width); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; tex.width = width; tex.height = height; tex.levelCount = 1; tex.format = texFormat; switch (target) { case GL_TEXTURE_2D: tex.levels = realloc(tex.levels, totalSize); CopyTexture((char *)tex.levels, (const char *)ctx->rasterizer.frameSurface.data, bytesPerPixel, x, y, ctx->rasterizer.frameSurface.width, 0, 0, width, width, height); break; default: assert(0); return; } ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { GLES2_GET_CONST_CONTEXT(ctx); assert(0 == level); unsigned bytesPerPixel = 4; unsigned offset = 0, size = width * height * bytesPerPixel, totalSize = size; assert(ctx->tex.tmus[ctx->tex.active]); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; assert(tex.format == ctx->rasterizer.frameSurface.format); assert(GGL_PIXEL_FORMAT_RGBA_8888 == tex.format); const unsigned srcWidth = ctx->rasterizer.frameSurface.width; const unsigned srcHeight = ctx->rasterizer.frameSurface.height; assert(x >= 0 && y >= 0); assert(xoffset >= 0 && yoffset >= 0); assert(x + width <= srcWidth); assert(y + height <= srcHeight); assert(xoffset + width <= tex.width); assert(yoffset + height <= tex.height); switch (target) { case GL_TEXTURE_2D: CopyTexture((char *)tex.levels, (const char *)ctx->rasterizer.frameSurface.data, bytesPerPixel, x, y, srcWidth, xoffset, yoffset, tex.width, width, height); break; default: assert(0); return; } ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void glDeleteTextures(GLsizei n, const GLuint* textures) { GLES2_GET_CONST_CONTEXT(ctx); for (unsigned i = 0; i < n; i++) { std::map<GLuint, GGLTexture *>::iterator it = ctx->tex.textures.find(textures[i]); if (it == ctx->tex.textures.end()) continue; ctx->tex.free = min(ctx->tex.free, textures[i]); for (unsigned i = 0; i < GGL_MAXCOMBINEDTEXTUREIMAGEUNITS; i++) if (ctx->tex.tmus[i] == it->second) { if (GL_TEXTURE_2D == it->second->type) ctx->tex.tmus[i] = ctx->tex.tex2D; else if (GL_TEXTURE_CUBE_MAP == it->second->type) ctx->tex.tmus[i] = ctx->tex.texCube; else assert(0); ctx->tex.UpdateSampler(ctx->iface, i); } if (it->second) { free(it->second->levels); free(it->second); } ctx->tex.textures.erase(it); } } void glGenTextures(GLsizei n, GLuint* textures) { GLES2_GET_CONST_CONTEXT(ctx); for (unsigned i = 0; i < n; i++) { textures[i] = 0; for (ctx->tex.free; ctx->tex.free < 0xffffffffu; ctx->tex.free++) if (ctx->tex.textures.find(ctx->tex.free) == ctx->tex.textures.end()) { ctx->tex.textures[ctx->tex.free] = NULL; textures[i] = ctx->tex.free; ctx->tex.free++; break; } assert(textures[i]); } } void API_ENTRY(glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params) { CALL_GL_API(glGetTexParameterfv, target, pname, params); } void API_ENTRY(glGetTexParameteriv)(GLenum target, GLenum pname, GLint* params) { CALL_GL_API(glGetTexParameteriv, target, pname, params); } GLboolean glIsTexture(GLuint texture) { GLES2_GET_CONST_CONTEXT(ctx); if (ctx->tex.textures.find(texture) == ctx->tex.textures.end()) return GL_FALSE; else return GL_TRUE; } void glPixelStorei(GLenum pname, GLint param) { GLES2_GET_CONST_CONTEXT(ctx); assert(GL_UNPACK_ALIGNMENT == pname); assert(1 == param || 2 == param || 4 == param || 8 == param); ctx->tex.unpack = param; } void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) { GLES2_GET_CONST_CONTEXT(ctx); switch (type) { case GL_UNSIGNED_BYTE: break; case GL_UNSIGNED_SHORT_5_6_5: internalformat = format = GL_UNSIGNED_SHORT_5_6_5; assert(4 == ctx->tex.unpack); break; default: assert(0); } assert(internalformat == format); assert(0 == border); if (0 != level) { LOGD("agl2: glTexImage2D level=%d", level); return; } unsigned bytesPerPixel = 0; GGLPixelFormat texFormat = GGL_PIXEL_FORMAT_UNKNOWN; GetFormatAndBytesPerPixel(format, &bytesPerPixel, &texFormat); assert(texFormat && bytesPerPixel); unsigned offset = 0, size = width * height * bytesPerPixel, totalSize = size; assert(ctx->tex.tmus[ctx->tex.active]); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; tex.width = width; tex.height = height; tex.levelCount = 1; tex.format = texFormat; switch (target) { case GL_TEXTURE_2D: assert(GL_TEXTURE_2D == ctx->tex.tmus[ctx->tex.active]->type); offset = 0; break; break; case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: assert(GL_TEXTURE_CUBE_MAP == ctx->tex.tmus[ctx->tex.active]->type); assert(width == height); offset = (target - GL_TEXTURE_CUBE_MAP_POSITIVE_X) * size; totalSize = 6 * size; break; default: assert(0); return; } tex.levels = realloc(tex.levels, totalSize); if (pixels) CopyTexture((char *)tex.levels, (const char *)pixels, bytesPerPixel, 0, 0, width, 0, 0, width, width, height); ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void glTexParameterf(GLenum target, GLenum pname, GLfloat param) { glTexParameteri(target, pname, param); } void API_ENTRY(glTexParameterfv)(GLenum target, GLenum pname, const GLfloat* params) { CALL_GL_API(glTexParameterfv, target, pname, params); } void glTexParameteri(GLenum target, GLenum pname, GLint param) { GLES2_GET_CONST_CONTEXT(ctx); assert(ctx->tex.tmus[ctx->tex.active]); assert(target == ctx->tex.tmus[ctx->tex.active]->type); GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; switch (pname) { case GL_TEXTURE_WRAP_S: case GL_TEXTURE_WRAP_T: GGLTexture::GGLTextureWrap wrap; switch (param) { case GL_REPEAT: wrap = GGLTexture::GGL_REPEAT; break; case GL_CLAMP_TO_EDGE: wrap = GGLTexture::GGL_CLAMP_TO_EDGE; break; case GL_MIRRORED_REPEAT: wrap = GGLTexture::GGL_MIRRORED_REPEAT; break; default: assert(0); return; } if (GL_TEXTURE_WRAP_S == pname) tex.wrapS = wrap; else tex.wrapT = wrap; break; case GL_TEXTURE_MIN_FILTER: switch (param) { case GL_NEAREST: tex.minFilter = GGLTexture::GGL_NEAREST; break; case GL_LINEAR: tex.minFilter = GGLTexture::GGL_LINEAR; break; case GL_NEAREST_MIPMAP_NEAREST: break; case GL_NEAREST_MIPMAP_LINEAR: break; case GL_LINEAR_MIPMAP_NEAREST: break; case GL_LINEAR_MIPMAP_LINEAR: break; default: assert(0); return; } break; case GL_TEXTURE_MAG_FILTER: switch (param) { case GL_NEAREST: tex.minFilter = GGLTexture::GGL_NEAREST; break; case GL_LINEAR: tex.minFilter = GGLTexture::GGL_LINEAR; break; default: assert(0); return; } break; default: assert(0); return; } if (tex.magFilter != tex.minFilter) tex.magFilter = tex.minFilter = GGLTexture::GGL_LINEAR; ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); } void API_ENTRY(glTexParameteriv)(GLenum target, GLenum pname, const GLint* params) { CALL_GL_API(glTexParameteriv, target, pname, params); } void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) { GLES2_GET_CONST_CONTEXT(ctx); assert(0 == level); assert(target == ctx->tex.tmus[ctx->tex.active]->type); switch (type) { case GL_UNSIGNED_BYTE: break; case GL_UNSIGNED_SHORT_5_6_5: format = GL_UNSIGNED_SHORT_5_6_5; assert(4 == ctx->tex.unpack); break; default: assert(0); } GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active]; GGLPixelFormat texFormat = GGL_PIXEL_FORMAT_UNKNOWN; unsigned bytesPerPixel = 0; GetFormatAndBytesPerPixel(format, &bytesPerPixel, &texFormat); assert(texFormat == tex.format); assert(GL_UNSIGNED_BYTE == type); switch (target) { case GL_TEXTURE_2D: CopyTexture((char *)tex.levels, (const char *)pixels, bytesPerPixel, 0, 0, width, xoffset, yoffset, tex.width, width, height); break; default: assert(0); } ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active); }
static inline GGLTexture * AllocTexture() { GGLTexture * tex = (GGLTexture *)calloc(1, sizeof(GGLTexture)); tex->minFilter = GGLTexture::GGL_LINEAR; tex->magFilter = GGLTexture::GGL_LINEAR; return tex; }
function_block-full_function
[]
C++
activemq-cpp/src/test/activemq/core/ConnectionAuditTest.cpp
novomatic-tech/activemq-cpp
d6f76ede90d21b7ee2f0b5d4648e440e66d63003
#include "ConnectionAuditTest.h" #include <activemq/core/ConnectionAudit.h> #include <activemq/core/Dispatcher.h> #include <activemq/core/ActiveMQMessageAudit.h> #include <activemq/util/IdGenerator.h> #include <activemq/commands/Message.h> #include <activemq/commands/ActiveMQDestination.h> #include <activemq/commands/ActiveMQQueue.h> #include <decaf/util/ArrayList.h> using namespace std; using namespace activemq; using namespace activemq::core; using namespace activemq::commands; using namespace activemq::util; using namespace decaf; using namespace decaf::lang; using namespace decaf::util; namespace { class MyDispatcher : public Dispatcher { public: virtual ~MyDispatcher() {} virtual void dispatch(const Pointer<commands::MessageDispatch>& message) { } virtual int getHashCode() const { return 1; } }; } ConnectionAuditTest::ConnectionAuditTest() { } ConnectionAuditTest::~ConnectionAuditTest() { } void ConnectionAuditTest::testConstructor1() { ConnectionAudit audit; CPPUNIT_ASSERT(audit.isCheckForDuplicates()); CPPUNIT_ASSERT(audit.getAuditDepth() == ActiveMQMessageAudit::DEFAULT_WINDOW_SIZE); CPPUNIT_ASSERT(audit.getAuditMaximumProducerNumber() == ActiveMQMessageAudit::MAXIMUM_PRODUCER_COUNT); } void ConnectionAuditTest::testConstructor2() { ConnectionAudit audit(100, 200); CPPUNIT_ASSERT(audit.isCheckForDuplicates()); CPPUNIT_ASSERT(audit.getAuditDepth() == 100); CPPUNIT_ASSERT(audit.getAuditMaximumProducerNumber() == 200); } void ConnectionAuditTest::testIsDuplicate() { int count = 10000; ConnectionAudit audit; ArrayList<Pointer<MessageId> > list; Pointer<MyDispatcher> dispatcher(new MyDispatcher); Pointer<ProducerId> pid(new ProducerId); pid->setConnectionId("test"); pid->setSessionId(0); pid->setValue(1); Pointer<Message> message(new Message()); for (int i = 0; i < count; i++) { Pointer<ActiveMQDestination> destination(new ActiveMQQueue("TEST.QUEUE")); message->setDestination(destination); Pointer<MessageId> id(new MessageId); id->setProducerId(pid); id->setProducerSequenceId(i); list.add(id); message->setMessageId(id); CPPUNIT_ASSERT(!audit.isDuplicate(dispatcher.get(), message)); } int index = list.size() -1 -audit.getAuditDepth(); for (; index < list.size(); index++) { Pointer<MessageId> id = list.get(index); message->setMessageId(id); CPPUNIT_ASSERT_MESSAGE(std::string() + "duplicate msg:" + id->toString(), audit.isDuplicate(dispatcher.get(), message)); } } void ConnectionAuditTest::testRollbackDuplicate() { int count = 10000; ConnectionAudit audit; ArrayList<Pointer<MessageId> > list; Pointer<MyDispatcher> dispatcher(new MyDispatcher); Pointer<ProducerId> pid(new ProducerId); pid->setConnectionId("test"); pid->setSessionId(0); pid->setValue(1); Pointer<ActiveMQDestination> destination(new ActiveMQQueue("TEST.QUEUE")); Pointer<Message> message(new Message()); message->setDestination(destination); for (int i = 0; i < count; i++) { Pointer<MessageId> id(new MessageId); id->setProducerId(pid); id->setProducerSequenceId(i); list.add(id); message->setMessageId(id); CPPUNIT_ASSERT(!audit.isDuplicate(dispatcher.get(), message)); } int index = list.size() -1 -audit.getAuditDepth(); for (; index < list.size(); index++) { Pointer<MessageId> id = list.get(index); message->setMessageId(id); CPPUNIT_ASSERT_MESSAGE(std::string() + "duplicate msg:" + id->toString(), audit.isDuplicate(dispatcher.get(), message)); audit.rollbackDuplicate(dispatcher.get(), message); CPPUNIT_ASSERT_MESSAGE(std::string() + "duplicate msg:" + id->toString(), !audit.isDuplicate(dispatcher.get(), message)); } }
#include "ConnectionAuditTest.h" #include <activemq/core/ConnectionAudit.h> #include <activemq/core/Dispatcher.h> #include <activemq/core/ActiveMQMessageAudit.h> #include <activemq/util/IdGenerator.h> #include <activemq/commands/Message.h> #include <activemq/commands/ActiveMQDestination.h> #include <activemq/commands/ActiveMQQueue.h> #include <decaf/util/ArrayList.h> using namespace std; using namespace activemq; using namespace activemq::core; using namespace activemq::commands; using namespace activemq::util; using namespace decaf; using namespace decaf::lang; using namespace decaf::util; namespace { class MyDispatcher : public Dispatcher { public: virtual ~MyDispatcher() {} virtual void dispatch(const Pointer<commands::MessageDispatch>& message) { } virtual int getHashCode() const { return 1; } }; } ConnectionAuditTest::ConnectionAuditTest() { } ConnectionAuditTest::~ConnectionAuditTest() { } void ConnectionAuditTest::testConstructor1() { ConnectionAudit audit; CPPUNIT_ASSERT(audit.isCheckForDuplicates()); CPPUNIT_ASSERT(audit.getAuditDepth() == ActiveMQMessageAudit::DEFAULT_WINDOW_SIZE); CPPUNIT_ASSERT(audit.getAuditMaximumProd
eId> id(new MessageId); id->setProducerId(pid); id->setProducerSequenceId(i); list.add(id); message->setMessageId(id); CPPUNIT_ASSERT(!audit.isDuplicate(dispatcher.get(), message)); } int index = list.size() -1 -audit.getAuditDepth(); for (; index < list.size(); index++) { Pointer<MessageId> id = list.get(index); message->setMessageId(id); CPPUNIT_ASSERT_MESSAGE(std::string() + "duplicate msg:" + id->toString(), audit.isDuplicate(dispatcher.get(), message)); } } void ConnectionAuditTest::testRollbackDuplicate() { int count = 10000; ConnectionAudit audit; ArrayList<Pointer<MessageId> > list; Pointer<MyDispatcher> dispatcher(new MyDispatcher); Pointer<ProducerId> pid(new ProducerId); pid->setConnectionId("test"); pid->setSessionId(0); pid->setValue(1); Pointer<ActiveMQDestination> destination(new ActiveMQQueue("TEST.QUEUE")); Pointer<Message> message(new Message()); message->setDestination(destination); for (int i = 0; i < count; i++) { Pointer<MessageId> id(new MessageId); id->setProducerId(pid); id->setProducerSequenceId(i); list.add(id); message->setMessageId(id); CPPUNIT_ASSERT(!audit.isDuplicate(dispatcher.get(), message)); } int index = list.size() -1 -audit.getAuditDepth(); for (; index < list.size(); index++) { Pointer<MessageId> id = list.get(index); message->setMessageId(id); CPPUNIT_ASSERT_MESSAGE(std::string() + "duplicate msg:" + id->toString(), audit.isDuplicate(dispatcher.get(), message)); audit.rollbackDuplicate(dispatcher.get(), message); CPPUNIT_ASSERT_MESSAGE(std::string() + "duplicate msg:" + id->toString(), !audit.isDuplicate(dispatcher.get(), message)); } }
ucerNumber() == ActiveMQMessageAudit::MAXIMUM_PRODUCER_COUNT); } void ConnectionAuditTest::testConstructor2() { ConnectionAudit audit(100, 200); CPPUNIT_ASSERT(audit.isCheckForDuplicates()); CPPUNIT_ASSERT(audit.getAuditDepth() == 100); CPPUNIT_ASSERT(audit.getAuditMaximumProducerNumber() == 200); } void ConnectionAuditTest::testIsDuplicate() { int count = 10000; ConnectionAudit audit; ArrayList<Pointer<MessageId> > list; Pointer<MyDispatcher> dispatcher(new MyDispatcher); Pointer<ProducerId> pid(new ProducerId); pid->setConnectionId("test"); pid->setSessionId(0); pid->setValue(1); Pointer<Message> message(new Message()); for (int i = 0; i < count; i++) { Pointer<ActiveMQDestination> destination(new ActiveMQQueue("TEST.QUEUE")); message->setDestination(destination); Pointer<Messag
random
[ { "content": " class DECAF_API Reader: public virtual decaf::io::Closeable, public virtual decaf::lang::Readable {\n\n private:\n\n\n\n Reader(const Reader&);\n\n Reader& operator=(const Reader&);\n\n\n\n protected:\n\n\n\n Reader();\n\n\n\n public:\n\n\n\n virtual ~Reader();\n\n\n\n /**\n\n * Marks the present position in the stream. Subsequent calls to reset() will attempt\n\n * to reposition the stream to this point. Not all character-input streams support\n\n * the mark() operation.\n\n *\n\n * @param readAheadLimit\n", "file_path": "activemq-cpp/src/main/decaf/io/Reader.h", "rank": 0, "score": 401708.00318746694 }, { "content": " class AMQCPP_API MessageDispatchChannel: public decaf::util::concurrent::Synchronizable {\n\n public:\n\n\n\n virtual ~MessageDispatchChannel();\n\n\n\n /**\n\n * Add a Message to the Channel behind all pending message.\n\n *\n\n * @param message - The message to add to the Channel.\n\n */\n\n virtual void enqueue(const Pointer<MessageDispatch>& message) = 0;\n\n\n\n /**\n\n * Add a message to the front of the Channel.\n\n *\n\n * @param message - The Message to add to the front of the Channel.\n\n */\n\n virtual void enqueueFirst(const Pointer<MessageDispatch>& message) = 0;\n\n\n\n /**\n", "file_path": "activemq-cpp/src/main/activemq/core/MessageDispatchChannel.h", "rank": 1, "score": 386964.97447386186 }, { "content": " class Queue : public virtual decaf::util::Collection<E> {\n\n public:\n\n\n\n virtual ~Queue() {}\n\n\n\n /**\n\n * Inserts the specified element into the queue provided that the condition\n\n * allows such an operation. The method is generally preferable to the\n\n * collection.add(E), since the latter might throw an exception if the\n\n * operation fails.\n\n *\n\n * @param value\n\n * the specified element to insert into the queue.\n\n *\n\n * @return true if the operation succeeds and false if it fails.\n\n *\n\n * @throws NullPointerException if the Queue implementation does not allow Null values to\n\n * be inserted into the Queue.\n\n * @throws IllegalArgumentException if some property of the specified\n\n * element prevents it from being added to this queue\n", "file_path": "activemq-cpp/src/main/decaf/util/Queue.h", "rank": 2, "score": 367434.3860060965 }, { "content": " class Set : public virtual decaf::util::Collection<E> {\n\n public:\n\n\n\n virtual ~Set() {}\n\n\n\n };\n\n\n\n}}\n\n\n\n#endif /*_DECAF_UTIL_SET_H_*/\n", "file_path": "activemq-cpp/src/main/decaf/util/Set.h", "rank": 3, "score": 367434.3860060965 }, { "content": " class AbstractCollection : public virtual decaf::util::Collection<E> {\n\n protected:\n\n\n\n mutable util::concurrent::Mutex mutex;\n\n\n\n public:\n\n\n\n AbstractCollection() : Collection<E>(), mutex() {}\n\n\n\n /**\n\n * Copy Constructor, copy element from the source collection to this\n\n * collection after clearing any element stored in this collection.\n\n *\n\n * @param collection - the collection to copy\n\n */\n\n AbstractCollection(const AbstractCollection& other) : Collection<E>(), mutex() {\n\n if (other.isEmpty()) {\n\n return;\n\n }\n\n std::auto_ptr<Iterator<E> > iter(other.iterator());\n", "file_path": "activemq-cpp/src/main/decaf/util/AbstractCollection.h", "rank": 4, "score": 360459.1533890603 }, { "content": " class AbstractSet : public virtual decaf::util::Set<E>,\n\n public virtual decaf::util::AbstractCollection<E> {\n\n public:\n\n\n\n AbstractSet() : AbstractCollection<E>() {}\n\n\n\n virtual ~AbstractSet() {}\n\n\n\n /**\n\n * {@inheritDoc}\n\n *\n\n * This implementation determines which is the smaller of this set and the specified\n\n * collection, by invoking the size method on each. If this set has fewer elements,\n\n * then the implementation iterates over this set, checking each element returned by\n\n * the iterator in turn to see if it is contained in the specified collection. If it\n\n * is so contained, it is removed from this set with the iterator's remove method. If\n\n * the specified collection has fewer elements, then the implementation iterates over\n\n * the specified collection, removing from this set each element returned by the\n\n * iterator, using this set's remove method.\n\n *\n", "file_path": "activemq-cpp/src/main/decaf/util/AbstractSet.h", "rank": 5, "score": 360459.1533890603 }, { "content": " class DECAF_API List : public virtual decaf::util::Collection<E> {\n\n public:\n\n\n\n // Un-hide any methods from Collection that the declarations in this interface hid.\n\n using decaf::util::Collection<E>::add;\n\n using decaf::util::Collection<E>::addAll;\n\n using decaf::util::Collection<E>::remove;\n\n\n\n public:\n\n\n\n List() {}\n\n\n\n virtual ~List() {}\n\n\n\n /**\n\n * @return a list iterator over the elements in this list (in proper sequence).\n\n */\n\n virtual ListIterator<E>* listIterator() = 0;\n\n virtual ListIterator<E>* listIterator() const = 0;\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/List.h", "rank": 6, "score": 360160.5376354226 }, { "content": " class DECAF_API IntArrayBuffer : public decaf::nio::IntBuffer {\n\n private:\n\n\n\n // The reference array object that backs this buffer.\n\n decaf::lang::Pointer<ByteArrayAdapter> _array;\n\n\n\n // Offset into the array that we are to start from\n\n int offset;\n\n\n\n // The length of the sub-array, or limit\n\n int length;\n\n\n\n // Read / Write flag\n\n bool readOnly;\n\n\n\n public:\n\n\n\n /**\n\n * Creates a IntArrayBuffer object that has its backing array allocated internally\n\n * and is then owned and deleted when this object is deleted. The array is\n", "file_path": "activemq-cpp/src/main/decaf/internal/nio/IntArrayBuffer.h", "rank": 7, "score": 351041.91839714267 }, { "content": " class DECAF_API Throwable : public std::exception {\n\n public:\n\n\n\n Throwable();\n\n\n\n virtual ~Throwable() throw();\n\n\n\n /**\n\n * Gets the cause of the error, if no message was provided to the instance\n\n * of this interface but a cause was then the value cause.getMessage is\n\n * then returned.\n\n * @return string errors message\n\n */\n\n virtual std::string getMessage() const = 0;\n\n\n\n /**\n\n * Gets the exception that caused this one to be thrown, this allows\n\n * for chaining of exceptions in the case of a method that throws only\n\n * a particular exception but wishes to allow for the real causal\n\n * exception to be passed only in case the caller knows about that\n", "file_path": "activemq-cpp/src/main/decaf/lang/Throwable.h", "rank": 8, "score": 350153.8989948907 }, { "content": " class MockComparatorStringByLength : public decaf::util::Comparator<std::string> {\n\n\n\n virtual bool operator() ( const std::string& left, const std::string& right ) const {\n\n return left.size() == right.size();\n\n }\n\n\n\n virtual int compare( const std::string& o1, const std::string& o2 ) const {\n\n return o1.size() < o2.size() ? -1 : o1.size() > o2.size() ? 1 : 0;\n\n }\n\n\n\n };\n\n\n\n}}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n\nvoid PriorityQueueTest::testConstructor_1() {\n\n\n\n PriorityQueue<int> pqueue;\n\n\n\n CPPUNIT_ASSERT( pqueue.isEmpty() );\n", "file_path": "activemq-cpp/src/test/decaf/util/PriorityQueueTest.cpp", "rank": 9, "score": 347711.3501310664 }, { "content": " class MessagingTask : public decaf::lang::Runnable {\n\n private:\n\n\n\n Receiver* receiver;\n\n std::string message;\n\n\n\n private:\n\n\n\n MessagingTask(const MessagingTask&);\n\n MessagingTask& operator= (const MessagingTask&);\n\n\n\n public:\n\n\n\n MessagingTask(Receiver* receiver, const std::string& message);\n\n\n\n virtual ~MessagingTask();\n\n\n\n virtual void run();\n\n\n\n };\n\n}\n\n\n\n#endif /** _CMSTEMPLATE_MESSAGINGTASK_H_ */\n", "file_path": "activemq-cpp/src/examples/cmstemplate-stress/MessagingTask.h", "rank": 10, "score": 346881.05999272387 }, { "content": " class CacheMap : public LinkedHashMap<int, int> {\n\n public:\n\n\n\n int removals;\n\n\n\n CacheMap() : LinkedHashMap<int, int>(), removals(0) {\n\n }\n\n\n\n virtual ~CacheMap() {}\n\n\n\n protected:\n\n\n\n virtual bool removeEldestEntry(const MapEntry<int, int>& eldest) {\n\n return size() > 5;\n\n }\n\n\n\n virtual void onEviction(const MapEntry<int, int>& eldest) {\n\n removals++;\n\n }\n\n\n", "file_path": "activemq-cpp/src/test/decaf/util/LinkedHashMapTest.cpp", "rank": 11, "score": 344854.4892614318 }, { "content": " class StringTask : public decaf::util::concurrent::Callable<std::string> {\n\n public:\n\n\n\n StringTask() : decaf::util::concurrent::Callable<std::string>() {\n\n }\n\n\n\n virtual ~StringTask() {}\n\n\n\n std::string call() {\n\n return TEST_STRING;\n\n }\n\n };\n\n\n\n };\n\n\n\n}}}\n\n\n\n#endif /* _DECAF_UTIL_CONCURRENT_EXECUTORSTESTSUPPORT_H_ */\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h", "rank": 12, "score": 343705.2422850198 }, { "content": " class DECAF_API SHA1MessageDigestSpi : public decaf::security::MessageDigestSpi {\n\n private:\n\n\n\n SHA1MessageDigestSpi(const SHA1MessageDigestSpi&);\n\n SHA1MessageDigestSpi& operator= (const SHA1MessageDigestSpi&);\n\n\n\n SHA1MessageDigestSpiImpl* impl;\n\n\n\n public:\n\n\n\n SHA1MessageDigestSpi();\n\n\n\n virtual ~SHA1MessageDigestSpi();\n\n\n\n public:\n\n\n\n virtual bool isCloneable() const {\n\n return true;\n\n }\n\n\n", "file_path": "activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h", "rank": 13, "score": 337775.90640608995 }, { "content": " class DECAF_API MD5MessageDigestSpi : public decaf::security::MessageDigestSpi {\n\n private:\n\n\n\n MD5MessageDigestSpi(const MD5MessageDigestSpi&);\n\n MD5MessageDigestSpi& operator= (const MD5MessageDigestSpi&);\n\n\n\n MD5MessageDigestSpiImpl* impl;\n\n\n\n public:\n\n\n\n MD5MessageDigestSpi();\n\n\n\n virtual ~MD5MessageDigestSpi();\n\n\n\n public:\n\n\n\n virtual bool isCloneable() const {\n\n return true;\n\n }\n\n\n", "file_path": "activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h", "rank": 14, "score": 337775.90640608995 }, { "content": " class DECAF_API MD4MessageDigestSpi : public decaf::security::MessageDigestSpi {\n\n private:\n\n\n\n MD4MessageDigestSpi(const MD4MessageDigestSpi&);\n\n MD4MessageDigestSpi& operator= (const MD4MessageDigestSpi&);\n\n\n\n MD4MessageDigestSpiImpl* impl;\n\n\n\n public:\n\n\n\n MD4MessageDigestSpi();\n\n\n\n virtual ~MD4MessageDigestSpi();\n\n\n\n public:\n\n\n\n virtual bool isCloneable() const {\n\n return true;\n\n }\n\n\n", "file_path": "activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD4MessageDigestSpi.h", "rank": 15, "score": 337775.90640608995 }, { "content": " class AMQCPP_API MessageId : public BaseDataStructure, public decaf::lang::Comparable<MessageId> {\n\n protected:\n\n\n\n std::string textView;\n\n Pointer<ProducerId> producerId;\n\n long long producerSequenceId;\n\n long long brokerSequenceId;\n\n\n\n public:\n\n\n\n const static unsigned char ID_MESSAGEID = 110;\n\n\n\n typedef decaf::lang::PointerComparator<MessageId> COMPARATOR;\n\n\n\n private:\n\n\n\n mutable std::string key;\n\n\n\n public:\n\n\n", "file_path": "activemq-cpp/src/main/activemq/commands/MessageId.h", "rank": 16, "score": 337417.82874138793 }, { "content": " class DECAF_API InputStream: public Closeable, virtual public util::concurrent::Synchronizable {\n\n private:\n\n\n\n // Synchronization object.\n\n util::concurrent::Mutex mutex;\n\n\n\n private:\n\n\n\n InputStream(const InputStream&);\n\n InputStream& operator=(const InputStream&);\n\n\n\n public:\n\n\n\n InputStream();\n\n\n\n virtual ~InputStream();\n\n\n\n /**\n\n * Closes the InputStream freeing any resources that might have been acquired\n\n * during the lifetime of this stream.\n", "file_path": "activemq-cpp/src/main/decaf/io/InputStream.h", "rank": 17, "score": 336287.18010013824 }, { "content": " class BrokerMonitor: public decaf::lang::Runnable, activemq::cmsutil::MessageCreator {\n\n private:\n\n\n\n bool closing;\n\n bool brokerOk;\n\n std::string url;\n\n int interval;\n\n decaf::lang::Thread* brokerMonitorThread;\n\n decaf::util::concurrent::CountDownLatch* quit;\n\n\n\n private:\n\n\n\n activemq::cmsutil::CmsTemplate* createCmsTemplate(cms::ConnectionFactory* connectionFactory);\n\n\n\n public:\n\n\n\n BrokerMonitor(const std::string& url, int interval,\n\n decaf::util::concurrent::CountDownLatch* quit);\n\n\n\n virtual ~BrokerMonitor();\n", "file_path": "activemq-cpp/src/examples/stress-test/BrokerMonitor.h", "rank": 18, "score": 332922.4514917914 }, { "content": " class AMQCPP_API MessageDispatch : public BaseCommand {\n\n protected:\n\n\n\n Pointer<ConsumerId> consumerId;\n\n Pointer<ActiveMQDestination> destination;\n\n Pointer<Message> message;\n\n int redeliveryCounter;\n\n\n\n public:\n\n\n\n const static unsigned char ID_MESSAGEDISPATCH = 21;\n\n\n\n private:\n\n\n\n decaf::lang::Exception rollbackCause;\n\n\n\n private:\n\n\n\n MessageDispatch(const MessageDispatch&);\n\n MessageDispatch& operator= (const MessageDispatch&);\n", "file_path": "activemq-cpp/src/main/activemq/commands/MessageDispatch.h", "rank": 19, "score": 331405.99918630504 }, { "content": " class AMQCPP_API FifoMessageDispatchChannel : public MessageDispatchChannel {\n\n private:\n\n\n\n bool closed;\n\n bool running;\n\n\n\n mutable decaf::util::LinkedList< Pointer<MessageDispatch> > channel;\n\n\n\n private:\n\n\n\n FifoMessageDispatchChannel(const FifoMessageDispatchChannel&);\n\n FifoMessageDispatchChannel& operator=(const FifoMessageDispatchChannel&);\n\n\n\n public:\n\n\n\n FifoMessageDispatchChannel();\n\n\n\n virtual ~FifoMessageDispatchChannel();\n\n\n\n virtual void enqueue(const Pointer<MessageDispatch>& message);\n", "file_path": "activemq-cpp/src/main/activemq/core/FifoMessageDispatchChannel.h", "rank": 20, "score": 331332.36017740273 }, { "content": " class PublicFutureTask : public FutureTask<std::string> {\n\n public:\n\n\n\n PublicFutureTask(Callable<std::string>* r) : FutureTask<std::string>(r) {}\n\n\n\n virtual ~PublicFutureTask() {}\n\n\n\n virtual bool runAndReset() {\n\n return FutureTask<std::string>::runAndReset();\n\n }\n\n\n\n virtual void set(const std::string& x) {\n\n FutureTask<std::string>::set(x);\n\n }\n\n\n\n virtual void setException(const Exception& ex) {\n\n FutureTask<std::string>::setException(ex);\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/FutureTaskTest.cpp", "rank": 21, "score": 331007.6304638015 }, { "content": " class Collection : public virtual lang::Iterable<E>,\n\n public virtual util::concurrent::Synchronizable {\n\n public:\n\n\n\n virtual ~Collection() {}\n\n\n\n /**\n\n * Renders this Collection as a Copy of the given Collection\n\n *\n\n * @param collection\n\n * The collection to mirror.\n\n *\n\n * @throws UnsupportedOperationExceptio if this is an unmodifiable collection.\n\n * @throws IllegalStateException if the elements cannot be added at this time due\n\n * to insertion restrictions.\n\n */\n\n virtual void copy(const Collection<E>& collection) = 0;\n\n\n\n /**\n\n * Returns true if this collection changed as a result of the call.\n", "file_path": "activemq-cpp/src/main/decaf/util/Collection.h", "rank": 22, "score": 329701.4392738956 }, { "content": " class DECAF_API DefaultMessageDigestProviderService : public decaf::security::ProviderService {\n\n private:\n\n\n\n DefaultMessageDigestProviderService(const DefaultMessageDigestProviderService&);\n\n DefaultMessageDigestProviderService& operator= (const DefaultMessageDigestProviderService&);\n\n\n\n public:\n\n\n\n DefaultMessageDigestProviderService(const decaf::security::Provider* provider,\n\n const std::string& algorithmName);\n\n\n\n virtual ~DefaultMessageDigestProviderService();\n\n\n\n virtual decaf::security::SecuritySpi* newInstance();\n\n\n\n };\n\n\n\n}}}}\n\n\n\n#endif /* _DECAF_INTERNAL_SECURITY_PROVIDER_DEFAULTMESSAGEDIGESTPROVIDERSERVICE_H_ */\n", "file_path": "activemq-cpp/src/main/decaf/internal/security/provider/DefaultMessageDigestProviderService.h", "rank": 24, "score": 329481.08025801694 }, { "content": " class DECAF_API IntBuffer : public Buffer,\n\n public lang::Comparable<IntBuffer> {\n\n protected:\n\n\n\n /**\n\n * Creates a IntBuffer object that has its backing array allocated internally\n\n * and is then owned and deleted when this object is deleted. The array is\n\n * initially created with all elements initialized to zero.\n\n *\n\n * @param capacity\n\n * The size and limit of the Buffer in integers.\n\n *\n\n * @throws IllegalArguementException if capacity is negative.\n\n */\n\n IntBuffer( int capacity );\n\n\n\n public:\n\n\n\n virtual ~IntBuffer() {}\n\n\n", "file_path": "activemq-cpp/src/main/decaf/nio/IntBuffer.h", "rank": 25, "score": 328541.99899933394 }, { "content": " class Consumer: public cms::MessageListener, public decaf::lang::Runnable {\n\n private:\n\n\n\n auto_ptr<CMSProvider> cmsProvider;\n\n long initialDelay;\n\n long waitMillis;\n\n int numReceived;\n\n\n\n public:\n\n\n\n Consumer(const std::string& brokerURL, const std::string& destination, long waitMillis) :\n\n Runnable(), cmsProvider(), initialDelay(0), waitMillis(waitMillis), numReceived(0) {\n\n\n\n this->cmsProvider.reset(new CMSProvider(brokerURL));\n\n this->cmsProvider->setTopic(false);\n\n this->cmsProvider->setDestinationName(destination);\n\n }\n\n\n\n virtual ~Consumer() {\n\n }\n", "file_path": "activemq-cpp/src/test-integration/activemq/test/ExpirationTest.cpp", "rank": 26, "score": 326876.109226265 }, { "content": " class ConstStlListIterator : public decaf::util::ListIterator<E> {\n\n private:\n\n\n\n typename std::list<E>::const_iterator current;\n\n typename std::list<E>::const_iterator prev;\n\n const typename std::list<E>* list;\n\n\n\n private:\n\n\n\n ConstStlListIterator(const ConstStlListIterator&);\n\n ConstStlListIterator operator= (const ConstStlListIterator&);\n\n\n\n public:\n\n\n\n ConstStlListIterator(const typename std::list<E>* list, int index) :\n\n ListIterator<E>(), current(list->begin()), prev(list->end()), list( list) {\n\n\n\n if (index < (int) list->size()) {\n\n std::advance(this->current, index);\n\n } else {\n", "file_path": "activemq-cpp/src/main/decaf/util/StlList.h", "rank": 27, "score": 326113.9140867044 }, { "content": " class AMQCPP_API SimplePriorityMessageDispatchChannel : public MessageDispatchChannel {\n\n private:\n\n\n\n static const int MAX_PRIORITIES;\n\n\n\n bool closed;\n\n bool running;\n\n\n\n mutable decaf::util::concurrent::Mutex mutex;\n\n\n\n mutable ArrayPointer< decaf::util::LinkedList< Pointer<MessageDispatch> > > channels;\n\n\n\n int enqueued;\n\n\n\n private:\n\n\n\n SimplePriorityMessageDispatchChannel(const SimplePriorityMessageDispatchChannel&);\n\n SimplePriorityMessageDispatchChannel& operator=(const SimplePriorityMessageDispatchChannel&);\n\n\n\n public:\n", "file_path": "activemq-cpp/src/main/activemq/core/SimplePriorityMessageDispatchChannel.h", "rank": 28, "score": 326027.9881067106 }, { "content": " class AMQCPP_API MessageDispatchNotification : public BaseCommand {\n\n protected:\n\n\n\n Pointer<ConsumerId> consumerId;\n\n Pointer<ActiveMQDestination> destination;\n\n long long deliverySequenceId;\n\n Pointer<MessageId> messageId;\n\n\n\n public:\n\n\n\n const static unsigned char ID_MESSAGEDISPATCHNOTIFICATION = 90;\n\n\n\n private:\n\n\n\n MessageDispatchNotification(const MessageDispatchNotification&);\n\n MessageDispatchNotification& operator= (const MessageDispatchNotification&);\n\n\n\n public:\n\n\n\n MessageDispatchNotification();\n", "file_path": "activemq-cpp/src/main/activemq/commands/MessageDispatchNotification.h", "rank": 29, "score": 324867.14274572884 }, { "content": " class testSubmitEECallable : public Callable<int> {\n\n public:\n\n\n\n virtual ~testSubmitEECallable() {}\n\n\n\n virtual int call() {\n\n throw NumberFormatException(__FILE__, __LINE__, \"Throwing a common exception\");\n\n return 1;\n\n }\n\n };\n\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n\nvoid AbstractExecutorServiceTest::testSubmitEE() {\n\n ThreadPoolExecutor p(1, 1, 60, TimeUnit::SECONDS, new LinkedBlockingQueue<Runnable*>(10));\n\n\n\n testSubmitEECallable c;\n\n\n\n try {\n\n\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/AbstractExecutorServiceTest.cpp", "rank": 30, "score": 322666.52403640456 }, { "content": " class AMQCPP_API ActiveMQSessionKernel : public virtual cms::Session, public Dispatcher {\n\n private:\n\n\n\n friend class activemq::core::ActiveMQSessionExecutor;\n\n\n\n protected:\n\n\n\n SessionConfig* config;\n\n\n\n /**\n\n * SessionInfo for this Session\n\n */\n\n Pointer<commands::SessionInfo> sessionInfo;\n\n\n\n /**\n\n * Transaction Management object\n\n */\n\n Pointer<ActiveMQTransactionContext> transaction;\n\n\n\n /**\n", "file_path": "activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.h", "rank": 31, "score": 319834.52370512113 }, { "content": " class StringThreadLocal : public ThreadLocal<std::string> {\n\n public:\n\n\n\n StringThreadLocal() : ThreadLocal<std::string>() {}\n\n virtual ~StringThreadLocal() {}\n\n\n\n protected:\n\n\n\n virtual std::string initialValue() const {\n\n return \"initial\";\n\n }\n\n };\n\n\n\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n\nvoid ThreadLocalTest::testRemove() {\n\n\n\n StringThreadLocal tl;\n\n\n\n CPPUNIT_ASSERT_EQUAL(std::string(\"initial\"), tl.get());\n\n tl.set(\"fixture\");\n\n CPPUNIT_ASSERT_EQUAL(std::string(\"fixture\"), tl.get());\n\n tl.remove();\n\n CPPUNIT_ASSERT_EQUAL(std::string(\"initial\"), tl.get());\n\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace {\n\n\n", "file_path": "activemq-cpp/src/test/decaf/lang/ThreadLocalTest.cpp", "rank": 32, "score": 318409.8925882912 }, { "content": " class DECAF_API MessageDigestSpi : public SecuritySpi {\n\n public:\n\n\n\n MessageDigestSpi();\n\n\n\n virtual ~MessageDigestSpi();\n\n\n\n /**\n\n * Queries the SPI implementation and returns true if the SPI can be\n\n * cloned.\n\n *\n\n * @return true if the SPI is clonable.\n\n */\n\n virtual bool isCloneable() const;\n\n\n\n /**\n\n * Returns a clone if the implementation supports being cloned.\n\n *\n\n * @return a new pointer that is a copy of this object.\n\n *\n", "file_path": "activemq-cpp/src/main/decaf/security/MessageDigestSpi.h", "rank": 33, "score": 318132.9580087902 }, { "content": " class ConstKeyIterator : public Iterator<K>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstKeyIterator(const ConstKeyIterator&);\n\n ConstKeyIterator& operator= (const ConstKeyIterator&);\n\n\n\n public:\n\n\n\n ConstKeyIterator(const HashMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstKeyIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual K next() {\n\n this->makeNext();\n\n return this->currentEntry->getKey();\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\");\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/HashMap.h", "rank": 34, "score": 317752.2299740074 }, { "content": " class ConstKeyIterator : public Iterator<K>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstKeyIterator(const ConstKeyIterator&);\n\n ConstKeyIterator& operator= (const ConstKeyIterator&);\n\n\n\n public:\n\n\n\n ConstKeyIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstKeyIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual K next() {\n\n this->makeNext();\n\n return this->currentEntry->first;\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\" );\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/StlMap.h", "rank": 35, "score": 317752.2299740074 }, { "content": " class ConstValueIterator : public Iterator<V>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstValueIterator(const ConstValueIterator&);\n\n ConstValueIterator& operator= (const ConstValueIterator&);\n\n\n\n public:\n\n\n\n ConstValueIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {}\n\n\n\n virtual ~ConstValueIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual V next() {\n\n this->makeNext();\n\n return this->currentEntry->second;\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\" );\n\n }\n\n };\n\n\n\n private:\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/StlMap.h", "rank": 36, "score": 317752.22997400735 }, { "content": " class ConstValueIterator : public Iterator<V>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstValueIterator(const ConstValueIterator&);\n\n ConstValueIterator& operator= (const ConstValueIterator&);\n\n\n\n public:\n\n\n\n ConstValueIterator(const HashMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstValueIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual V next() {\n\n this->makeNext();\n\n return this->currentEntry->getValue();\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\");\n\n }\n\n };\n\n\n\n protected:\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/HashMap.h", "rank": 37, "score": 317752.2299740074 }, { "content": " class MessagingTask:public decaf::lang::Runnable {\n\n private:\n\n\n\n Receiver* receiver;\n\n std::string message;\n\n\n\n static decaf::util::concurrent::ThreadPoolExecutor* threadPoolExecutor;\n\n\n\n public:\n\n\n\n MessagingTask(Receiver* receiver, const std::string& message);\n\n\n\n virtual ~MessagingTask();\n\n\n\n virtual void run();\n\n\n\n static void initializeThreads(int min, int max);\n\n static void terminateThreads();\n\n\n\n virtual void queue();\n\n\n\n };\n\n\n\n}}\n\n\n\n#endif /** _CMS_STRESS_MESSAGINGTASK_H_ */\n", "file_path": "activemq-cpp/src/examples/stress-test/MessagingTask.h", "rank": 38, "score": 316052.0157265151 }, { "content": " class ConstKeyIterator : public Iterator<K>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstKeyIterator(const ConstKeyIterator&);\n\n ConstKeyIterator& operator= (const ConstKeyIterator&);\n\n\n\n public:\n\n\n\n ConstKeyIterator(const LinkedHashMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstKeyIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual K next() {\n\n this->makeNext();\n\n return this->currentEntry->getKey();\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\" );\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/LinkedHashMap.h", "rank": 39, "score": 314821.45311548834 }, { "content": " class ConstValueIterator : public Iterator<V>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstValueIterator(const ConstValueIterator&);\n\n ConstValueIterator& operator= (const ConstValueIterator&);\n\n\n\n public:\n\n\n\n ConstValueIterator(const LinkedHashMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstValueIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual V next() {\n\n this->makeNext();\n\n return this->currentEntry->getValue();\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\" );\n\n }\n\n };\n\n\n\n private:\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/LinkedHashMap.h", "rank": 40, "score": 314821.45311548834 }, { "content": " class AMQCPP_API PrimitiveMap : public decaf::util::StlMap<std::string, PrimitiveValueNode> {\n\n private:\n\n\n\n PrimitiveValueConverter converter;\n\n\n\n public:\n\n\n\n /**\n\n * Default Constructor, creates an empty map.\n\n */\n\n PrimitiveMap();\n\n\n\n virtual ~PrimitiveMap();\n\n\n\n /**\n\n * Copy Constructor\n\n *\n\n * @param source\n\n * The Decaf Library Map instance whose elements will be copied into this Map.\n\n */\n", "file_path": "activemq-cpp/src/main/activemq/util/PrimitiveMap.h", "rank": 41, "score": 314677.2490113568 }, { "content": " class ActiveMQMessageAuditTest : public CppUnit::TestFixture {\n\n\n\n CPPUNIT_TEST_SUITE( ActiveMQMessageAuditTest );\n\n CPPUNIT_TEST( testIsDuplicateString );\n\n CPPUNIT_TEST( testIsDuplicateMessageId );\n\n CPPUNIT_TEST( testIsInOrderString );\n\n CPPUNIT_TEST( testIsInOrderMessageId );\n\n CPPUNIT_TEST( testRollbackString );\n\n CPPUNIT_TEST( testRollbackMessageId );\n\n CPPUNIT_TEST( testGetLastSeqId );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n public:\n\n\n\n ActiveMQMessageAuditTest();\n\n virtual ~ActiveMQMessageAuditTest();\n\n\n\n void testIsDuplicateString();\n\n void testIsDuplicateMessageId();\n\n void testIsInOrderString();\n", "file_path": "activemq-cpp/src/test/activemq/core/ActiveMQMessageAuditTest.h", "rank": 42, "score": 312825.98034826474 }, { "content": " class AMQCPP_API MessageDispatchMarshaller : public BaseCommandMarshaller {\n\n public:\n\n\n\n MessageDispatchMarshaller() {}\n\n virtual ~MessageDispatchMarshaller() {}\n\n\n\n virtual commands::DataStructure* createObject() const;\n\n\n\n virtual unsigned char getDataStructureType() const;\n\n\n\n virtual void tightUnmarshal(OpenWireFormat* wireFormat,\n\n commands::DataStructure* dataStructure,\n\n decaf::io::DataInputStream* dataIn,\n\n utils::BooleanStream* bs);\n\n\n\n virtual int tightMarshal1(OpenWireFormat* wireFormat,\n\n commands::DataStructure* dataStructure,\n\n utils::BooleanStream* bs);\n\n\n\n virtual void tightMarshal2(OpenWireFormat* wireFormat,\n", "file_path": "activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshaller.h", "rank": 43, "score": 312783.1097120461 }, { "content": " class FifoMessageDispatchChannelTest : public CppUnit::TestFixture {\n\n\n\n CPPUNIT_TEST_SUITE( FifoMessageDispatchChannelTest );\n\n CPPUNIT_TEST( testCtor );\n\n CPPUNIT_TEST( testStart );\n\n CPPUNIT_TEST( testStop );\n\n CPPUNIT_TEST( testClose );\n\n CPPUNIT_TEST( testEnqueue );\n\n CPPUNIT_TEST( testEnqueueFront );\n\n CPPUNIT_TEST( testPeek );\n\n CPPUNIT_TEST( testDequeueNoWait );\n\n CPPUNIT_TEST( testDequeue );\n\n CPPUNIT_TEST( testRemoveAll );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n public:\n\n\n\n FifoMessageDispatchChannelTest() {}\n\n virtual ~FifoMessageDispatchChannelTest() {}\n\n\n", "file_path": "activemq-cpp/src/test/activemq/core/FifoMessageDispatchChannelTest.h", "rank": 44, "score": 312783.1097120461 }, { "content": " class ConstValueIterator : public Iterator<V>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstValueIterator(const ConstValueIterator&);\n\n ConstValueIterator& operator= (const ConstValueIterator&);\n\n\n\n public:\n\n\n\n ConstValueIterator(const ConcurrentStlMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstValueIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual V next() {\n\n synchronized(&this->associatedMap->mutex) {\n\n this->makeNext();\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h", "rank": 45, "score": 311964.85043618234 }, { "content": " class ConstKeyIterator : public Iterator<K>, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstKeyIterator(const ConstKeyIterator&);\n\n ConstKeyIterator& operator= (const ConstKeyIterator&);\n\n\n\n public:\n\n\n\n ConstKeyIterator(const ConcurrentStlMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstKeyIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual K next() {\n\n synchronized(&this->associatedMap->mutex) {\n\n this->makeNext();\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h", "rank": 46, "score": 311964.85043618234 }, { "content": " class DECAF_API Writer: public decaf::io::Closeable, public decaf::io::Flushable, public decaf::lang::Appendable {\n\n private:\n\n\n\n Writer(const Writer&);\n\n Writer& operator=(const Writer&);\n\n\n\n public:\n\n\n\n Writer();\n\n\n\n virtual ~Writer();\n\n\n\n /**\n\n * Writes an single byte char value.\n\n *\n\n * @param v\n\n * The value to be written.\n\n *\n\n * @throws IOException thrown if an error occurs.\n\n */\n", "file_path": "activemq-cpp/src/main/decaf/io/Writer.h", "rank": 47, "score": 311087.47385014803 }, { "content": " class MessageDispatchMarshallerTest : public CppUnit::TestFixture {\n\n\n\n CPPUNIT_TEST_SUITE( MessageDispatchMarshallerTest );\n\n CPPUNIT_TEST( test );\n\n CPPUNIT_TEST( testLooseMarshal );\n\n CPPUNIT_TEST( testTightMarshal );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n public:\n\n\n\n MessageDispatchMarshallerTest() {}\n\n virtual ~MessageDispatchMarshallerTest() {}\n\n\n\n /**\n\n * Test the marshaller and its marshalled type.\n\n */\n\n virtual void test();\n\n virtual void testLooseMarshal();\n\n virtual void testTightMarshal();\n\n\n\n };\n\n\n\n}}}}}\n\n\n\n#endif /*_ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSAHAL_GENERATED_MESSAGEDISPATCHMARSHALLERTEST_H_*/\n", "file_path": "activemq-cpp/src/test/activemq/wireformat/openwire/marshal/generated/MessageDispatchMarshallerTest.h", "rank": 48, "score": 309950.28183336294 }, { "content": " class AMQCPP_API MessageDispatchNotificationMarshaller : public BaseCommandMarshaller {\n\n public:\n\n\n\n MessageDispatchNotificationMarshaller() {}\n\n virtual ~MessageDispatchNotificationMarshaller() {}\n\n\n\n virtual commands::DataStructure* createObject() const;\n\n\n\n virtual unsigned char getDataStructureType() const;\n\n\n\n virtual void tightUnmarshal(OpenWireFormat* wireFormat,\n\n commands::DataStructure* dataStructure,\n\n decaf::io::DataInputStream* dataIn,\n\n utils::BooleanStream* bs);\n\n\n\n virtual int tightMarshal1(OpenWireFormat* wireFormat,\n\n commands::DataStructure* dataStructure,\n\n utils::BooleanStream* bs);\n\n\n\n virtual void tightMarshal2(OpenWireFormat* wireFormat,\n", "file_path": "activemq-cpp/src/main/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshaller.h", "rank": 49, "score": 307186.95284556714 }, { "content": " class SimplePriorityMessageDispatchChannelTest : public CppUnit::TestFixture {\n\n\n\n CPPUNIT_TEST_SUITE( SimplePriorityMessageDispatchChannelTest );\n\n CPPUNIT_TEST( testCtor );\n\n CPPUNIT_TEST( testStart );\n\n CPPUNIT_TEST( testStop );\n\n CPPUNIT_TEST( testClose );\n\n CPPUNIT_TEST( testEnqueue );\n\n CPPUNIT_TEST( testEnqueueFront );\n\n CPPUNIT_TEST( testPeek );\n\n CPPUNIT_TEST( testDequeueNoWait );\n\n CPPUNIT_TEST( testDequeue );\n\n CPPUNIT_TEST( testRemoveAll );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n public:\n\n\n\n SimplePriorityMessageDispatchChannelTest() {}\n\n virtual ~SimplePriorityMessageDispatchChannelTest() {}\n\n\n", "file_path": "activemq-cpp/src/test/activemq/core/SimplePriorityMessageDispatchChannelTest.h", "rank": 50, "score": 307186.95284556714 }, { "content": " class MessageDispatchNotificationMarshallerTest : public CppUnit::TestFixture {\n\n\n\n CPPUNIT_TEST_SUITE( MessageDispatchNotificationMarshallerTest );\n\n CPPUNIT_TEST( test );\n\n CPPUNIT_TEST( testLooseMarshal );\n\n CPPUNIT_TEST( testTightMarshal );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n public:\n\n\n\n MessageDispatchNotificationMarshallerTest() {}\n\n virtual ~MessageDispatchNotificationMarshallerTest() {}\n\n\n\n /**\n\n * Test the marshaller and its marshalled type.\n\n */\n\n virtual void test();\n\n virtual void testLooseMarshal();\n\n virtual void testTightMarshal();\n\n\n\n };\n\n\n\n}}}}}\n\n\n\n#endif /*_ACTIVEMQ_WIREFORMAT_OPENWIRE_MARSAHAL_GENERATED_MESSAGEDISPATCHNOTIFICATIONMARSHALLERTEST_H_*/\n", "file_path": "activemq-cpp/src/test/activemq/wireformat/openwire/marshal/generated/MessageDispatchNotificationMarshallerTest.h", "rank": 51, "score": 304490.4995546286 }, { "content": " class MessageDigestTest : public CppUnit::TestFixture {\n\n\n\n CPPUNIT_TEST_SUITE( MessageDigestTest );\n\n CPPUNIT_TEST( testGetInstance1 );\n\n CPPUNIT_TEST( testGetInstance2 );\n\n CPPUNIT_TEST( testGetInstance3 );\n\n CPPUNIT_TEST( testGetInstance4 );\n\n CPPUNIT_TEST( testResults1 );\n\n CPPUNIT_TEST( testResults2 );\n\n CPPUNIT_TEST( testResults3 );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\n public:\n\n\n\n MessageDigestTest();\n\n virtual ~MessageDigestTest();\n\n\n\n void testGetInstance1();\n\n void testGetInstance2();\n\n void testGetInstance3();\n", "file_path": "activemq-cpp/src/test/decaf/security/MessageDigestTest.h", "rank": 52, "score": 303709.3233578373 }, { "content": " class ConstEntryIterator : public Iterator< MapEntry<K,V> >, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstEntryIterator(const ConstEntryIterator&);\n\n ConstEntryIterator& operator= (const ConstEntryIterator&);\n\n\n\n public:\n\n\n\n ConstEntryIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {}\n\n\n\n virtual ~ConstEntryIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual MapEntry<K, V> next() {\n\n this->makeNext();\n\n return MapEntry<K, V>(this->currentEntry->first, this->currentEntry->second);\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\" );\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/StlMap.h", "rank": 53, "score": 301982.9478697166 }, { "content": " class ConstEntryIterator : public Iterator< MapEntry<K,V> >, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstEntryIterator(const ConstEntryIterator&);\n\n ConstEntryIterator& operator= (const ConstEntryIterator&);\n\n\n\n public:\n\n\n\n ConstEntryIterator(const HashMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstEntryIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual MapEntry<K, V> next() {\n\n this->makeNext();\n\n return *(this->currentEntry);\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\");\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/HashMap.h", "rank": 54, "score": 301982.9478697166 }, { "content": " class MessagePullCache : public LinkedHashMap<std::string, Pointer<Command> > {\n\n protected:\n\n\n\n ConnectionStateTracker* parent;\n\n\n\n public:\n\n\n\n MessagePullCache(ConnectionStateTracker* parent) :\n\n LinkedHashMap<std::string, Pointer<Command> >(), parent(parent) {\n\n }\n\n\n\n virtual ~MessagePullCache() {}\n\n\n\n virtual bool removeEldestEntry(const MapEntry<std::string, Pointer<Command> >& eldest AMQCPP_UNUSED) {\n\n return size() > parent->getMaxMessagePullCacheSize();\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/main/activemq/state/ConnectionStateTracker.cpp", "rank": 55, "score": 301246.5132193222 }, { "content": " class ConstReverseIterator : public Iterator<E> {\n\n private:\n\n\n\n const LinkedList<E>* list;\n\n const ListNode<E>* current;\n\n\n\n private:\n\n\n\n ConstReverseIterator(const ConstReverseIterator&);\n\n ConstReverseIterator operator=(const ConstReverseIterator&);\n\n\n\n public:\n\n\n\n ConstReverseIterator(const LinkedList<E>* list) : Iterator<E>(), list(list), current(NULL) {\n\n\n\n if (list == NULL) {\n\n throw decaf::lang::exceptions::NullPointerException(\n\n __FILE__, __LINE__, \"Parent LinkedList pointer was Null.\" );\n\n }\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/LinkedList.h", "rank": 56, "score": 299381.5881249159 }, { "content": " class ConstSetIterator : public Iterator<E> {\n\n private:\n\n\n\n typename std::set<E>::const_iterator current;\n\n typename std::set<E>::const_iterator previous;\n\n const typename std::set<E>* set;\n\n\n\n private:\n\n\n\n ConstSetIterator(const ConstSetIterator&);\n\n ConstSetIterator operator=(const ConstSetIterator&);\n\n\n\n public:\n\n\n\n ConstSetIterator(const typename std::set<E>* set) :\n\n Iterator<E>(), current(set->begin()), previous(set->begin()), set(set) {\n\n }\n\n\n\n virtual ~ConstSetIterator() {}\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/StlSet.h", "rank": 57, "score": 299381.5881249159 }, { "content": " class ConstEntryIterator : public Iterator< MapEntry<K,V> >, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstEntryIterator(const ConstEntryIterator&);\n\n ConstEntryIterator& operator= (const ConstEntryIterator&);\n\n\n\n public:\n\n\n\n ConstEntryIterator(const LinkedHashMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstEntryIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual MapEntry<K, V> next() {\n\n this->makeNext();\n\n return *(this->currentEntry);\n\n }\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__, \"Cannot write to a const Iterator.\" );\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/LinkedHashMap.h", "rank": 58, "score": 299266.175104431 }, { "content": " class TimerImpl: public decaf::lang::Thread, public SynchronizableImpl {\n\n public:\n\n\n\n TimerTaskHeap heap;\n\n bool cancelled;\n\n\n\n public:\n\n\n\n TimerImpl() : Thread(), heap(), cancelled(false) {}\n\n\n\n TimerImpl(const std::string& name) : Thread(name), heap(), cancelled(false) {}\n\n\n\n virtual ~TimerImpl() {\n\n try {\n\n this->cancel();\n\n this->join();\n\n }\n\n DECAF_CATCHALL_NOTHROW()\n\n }\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/Timer.cpp", "rank": 59, "score": 298461.86373176664 }, { "content": " class ConstPriorityQueueIterator : public PriorityQueueIterator {\n\n private:\n\n\n\n ConstPriorityQueueIterator( const ConstPriorityQueueIterator& );\n\n ConstPriorityQueueIterator& operator= ( const ConstPriorityQueueIterator& );\n\n\n\n public:\n\n\n\n ConstPriorityQueueIterator(const PriorityQueue* queue) :\n\n PriorityQueueIterator(const_cast<PriorityQueue*>(queue)) {}\n\n\n\n virtual void remove() {\n\n throw lang::exceptions::UnsupportedOperationException(\n\n __FILE__, __LINE__,\n\n \"PriorityQueue::Iterator::remove - Not Valid on a Const Iterator\");\n\n }\n\n };\n\n\n\n friend class PriorityQueueIterator;\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/PriorityQueue.h", "rank": 60, "score": 297740.91988958255 }, { "content": "////////////////////////////////////////////////////////////////////////////////\n\nclass MyIntRunnable: public Runnable {\n\nprivate:\n\n\n\n AtomicInteger* aip;\n\n\n\nprivate:\n\n\n\n MyIntRunnable(const MyIntRunnable&);\n\n MyIntRunnable operator= (const MyIntRunnable&);\n\n\n\npublic:\n\n\n\n MyIntRunnable( AtomicInteger* ai ) :\n\n aip( ai ) {\n\n }\n\n\n\n virtual void run() {\n\n while( !aip->compareAndSet( 2, 3 ) ) {\n\n Thread::yield();\n\n }\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/atomic/AtomicIntegerTest.cpp", "rank": 61, "score": 297713.5014424042 }, { "content": " class AMQCPP_API Transport : public activemq::util::Service, public decaf::io::Closeable {\n\n public:\n\n\n\n virtual ~Transport();\n\n\n\n /**\n\n * Starts the Transport, the send methods of a Transport will throw an exception\n\n * if used before the Transport is started.\n\n *\n\n * @throw IOException if and error occurs while starting the Transport.\n\n */\n\n virtual void start() = 0;\n\n\n\n /**\n\n * Stops the Transport.\n\n *\n\n * @throw IOException if an error occurs while stopping the transport.\n\n */\n\n virtual void stop() = 0;\n\n\n", "file_path": "activemq-cpp/src/main/activemq/transport/Transport.h", "rank": 62, "score": 297645.46304079914 }, { "content": " class ConstEntryIterator : public Iterator< MapEntry<K,V> >, public ConstAbstractMapIterator {\n\n private:\n\n\n\n ConstEntryIterator(const ConstEntryIterator&);\n\n ConstEntryIterator& operator= (const ConstEntryIterator&);\n\n\n\n public:\n\n\n\n ConstEntryIterator(const ConcurrentStlMap* parent) : ConstAbstractMapIterator(parent) {\n\n }\n\n\n\n virtual ~ConstEntryIterator() {}\n\n\n\n virtual bool hasNext() const {\n\n return this->checkHasNext();\n\n }\n\n\n\n virtual MapEntry<K, V> next() {\n\n synchronized(&this->associatedMap->mutex) {\n\n this->makeNext();\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h", "rank": 63, "score": 296615.3541715774 }, { "content": " class CmsMessageCreator : public activemq::cmsutil::MessageCreator {\n\n private:\n\n\n\n std::string text;\n\n\n\n public:\n\n\n\n CmsMessageCreator(const std::string& text);\n\n\n\n virtual ~CmsMessageCreator();\n\n virtual cms::Message* createMessage(cms::Session* session);\n\n\n\n };\n\n}\n\n\n\n#endif /** _CMSTEMPLATE_CMSMESSAGECREATOR_H_ */\n", "file_path": "activemq-cpp/src/examples/cmstemplate-stress/CmsMessageCreator.h", "rank": 64, "score": 295978.92297144467 }, { "content": " class CmsMessageCreator: public activemq::cmsutil::MessageCreator {\n\n private:\n\n\n\n std::string text;\n\n std::string headerName;\n\n std::string headerValue;\n\n\n\n public:\n\n\n\n CmsMessageCreator(const std::string& txt,\n\n const std::string& name = \"\",\n\n const std::string& value = \"\");\n\n\n\n virtual ~CmsMessageCreator();\n\n\n\n virtual cms::Message* createMessage(cms::Session* session);\n\n };\n\n\n\n}}\n\n\n\n#endif /** _CMS_STRESS_CMSMESSAGECREATOR_H_ */\n", "file_path": "activemq-cpp/src/examples/stress-test/CmsMessageCreator.h", "rank": 65, "score": 295978.92297144467 }, { "content": " class IntArrayBufferTest : public CppUnit::TestFixture {\n\n\n\n CPPUNIT_TEST_SUITE( IntArrayBufferTest );\n\n CPPUNIT_TEST( test );\n\n CPPUNIT_TEST( testArray );\n\n CPPUNIT_TEST( testArrayOffset );\n\n CPPUNIT_TEST( testReadOnlyArray );\n\n CPPUNIT_TEST( testAsReadOnlyBuffer );\n\n CPPUNIT_TEST( testCompact );\n\n CPPUNIT_TEST( testCompareTo );\n\n CPPUNIT_TEST( testDuplicate );\n\n CPPUNIT_TEST( testEquals );\n\n CPPUNIT_TEST( testHasArray );\n\n CPPUNIT_TEST( testGet );\n\n CPPUNIT_TEST( testGet2 );\n\n CPPUNIT_TEST( testGetIntArray );\n\n CPPUNIT_TEST( testGetIntArray2 );\n\n CPPUNIT_TEST( testGetWithIndex );\n\n CPPUNIT_TEST( testPutInt );\n\n CPPUNIT_TEST( testPutIntArray );\n", "file_path": "activemq-cpp/src/test/decaf/internal/nio/IntArrayBufferTest.h", "rank": 66, "score": 294903.19044752506 }, { "content": " class ConstLinkedIterator : public Iterator<E> {\n\n private:\n\n\n\n Pointer< QueueNode<E> > current;\n\n Pointer< QueueNode<E> > last;\n\n E currentElement;\n\n const LinkedBlockingQueue<E>* parent;\n\n\n\n private:\n\n\n\n ConstLinkedIterator(const ConstLinkedIterator&);\n\n ConstLinkedIterator& operator= (const ConstLinkedIterator&);\n\n\n\n public:\n\n\n\n ConstLinkedIterator(const LinkedBlockingQueue<E>* parent) : current(), last(),\n\n currentElement(),\n\n parent(parent) {\n\n TotalLock lock(parent);\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/LinkedBlockingQueue.h", "rank": 67, "score": 292095.3373270766 }, { "content": " class ConstSimpleListIterator : public ListIterator<E> {\n\n protected:\n\n\n\n const AbstractList<E>* parent;\n\n int numLeft;\n\n int expectedModCount;\n\n int lastPosition;\n\n\n\n private:\n\n\n\n ConstSimpleListIterator(const ConstSimpleListIterator&);\n\n ConstSimpleListIterator operator=(const ConstSimpleListIterator&);\n\n\n\n public:\n\n\n\n ConstSimpleListIterator(const AbstractList<E>* parent, int start) :\n\n ListIterator<E>(), parent(parent), numLeft(0), expectedModCount(0), lastPosition(-1) {\n\n\n\n if (parent == NULL) {\n\n throw decaf::lang::exceptions::NullPointerException(\n", "file_path": "activemq-cpp/src/main/decaf/util/AbstractList.h", "rank": 68, "score": 292095.3373270766 }, { "content": " class ConstLinkedListIterator : public ListIterator<E> {\n\n private:\n\n\n\n const LinkedList<E>* list;\n\n const ListNode<E>* current;\n\n const ListNode<E>* lastReturned;\n\n int index;\n\n\n\n private:\n\n\n\n ConstLinkedListIterator(const ConstLinkedListIterator&);\n\n ConstLinkedListIterator operator=(const ConstLinkedListIterator&);\n\n\n\n public:\n\n\n\n ConstLinkedListIterator(const LinkedList<E>* list, int index) :\n\n ListIterator<E>(), list(list), current(NULL), lastReturned(NULL), index(-1) {\n\n\n\n if (list == NULL) {\n\n throw decaf::lang::exceptions::NullPointerException(\n", "file_path": "activemq-cpp/src/main/decaf/util/LinkedList.h", "rank": 69, "score": 292095.3373270766 }, { "content": " class DECAF_API DecafRuntime: public decaf::lang::Runtime {\n\n private:\n\n\n\n DecafRuntime(const DecafRuntime&);\n\n DecafRuntime& operator=(const DecafRuntime&);\n\n\n\n public:\n\n\n\n /**\n\n * Initializes the APR Runtime for a library.\n\n */\n\n DecafRuntime();\n\n\n\n /**\n\n * Terminates the APR Runtime for a library.\n\n */\n\n virtual ~DecafRuntime();\n\n\n\n /**\n\n * Grants access to the Global APR Pool instance that should be\n", "file_path": "activemq-cpp/src/main/decaf/internal/DecafRuntime.h", "rank": 70, "score": 291302.08694993856 }, { "content": " class AMQCPP_API ActiveMQConsumerKernel : public cms::MessageConsumer, public Dispatcher {\n\n private:\n\n\n\n /**\n\n * Internal Class that holds Members of this class, allows for changes without API breakage.\n\n */\n\n ActiveMQConsumerKernelConfig* internal;\n\n\n\n /**\n\n * The ActiveMQSession that owns this class instance.\n\n */\n\n ActiveMQSessionKernel* session;\n\n\n\n /**\n\n * The ConsumerInfo object for this class instance.\n\n */\n\n Pointer<commands::ConsumerInfo> consumerInfo;\n\n\n\n private:\n\n\n", "file_path": "activemq-cpp/src/main/activemq/core/kernels/ActiveMQConsumerKernel.h", "rank": 71, "score": 291013.71159581514 }, { "content": " class RunnableFuture : public Future<T>, public decaf::lang::Runnable {\n\n public:\n\n\n\n virtual ~RunnableFuture() {}\n\n\n\n };\n\n\n\n}}}\n\n\n\n#endif /* _DECAF_UTIL_CONCURRENT_RUNNABLEFUTURE_H_ */\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/RunnableFuture.h", "rank": 72, "score": 290958.5628967306 }, { "content": " class DECAF_API Socket : public decaf::io::Closeable {\n\n protected:\n\n\n\n // The actual Socket that this Socket represents.\n\n mutable SocketImpl* impl;\n\n\n\n private:\n\n\n\n // Factory for creating sockets, if not set a Plan TCP Socket is created\n\n static SocketImplFactory* factory;\n\n\n\n mutable volatile bool created;\n\n\n\n bool connected;\n\n bool closed;\n\n bool bound;\n\n bool inputShutdown;\n\n bool outputShutdown;\n\n\n\n friend class ServerSocket;\n", "file_path": "activemq-cpp/src/main/decaf/net/Socket.h", "rank": 73, "score": 289658.59809460206 }, { "content": " class ConstStlMapValueCollection : public AbstractCollection<V> {\n\n private:\n\n\n\n const StlMap* associatedMap;\n\n\n\n private:\n\n\n\n ConstStlMapValueCollection(const ConstStlMapValueCollection&);\n\n ConstStlMapValueCollection& operator= (const ConstStlMapValueCollection&);\n\n\n\n public:\n\n\n\n ConstStlMapValueCollection(const StlMap* parent) : AbstractCollection<V>(), associatedMap(parent) {}\n\n\n\n virtual ~ConstStlMapValueCollection() {}\n\n\n\n virtual bool contains(const V& value) const {\n\n return this->associatedMap->containsValue(value);\n\n }\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/StlMap.h", "rank": 74, "score": 288626.8894152502 }, { "content": " class ConstHashMapKeySet : public AbstractSet<K> {\n\n private:\n\n\n\n const HashMap* associatedMap;\n\n\n\n private:\n\n\n\n ConstHashMapKeySet(const ConstHashMapKeySet&);\n\n ConstHashMapKeySet& operator= (const ConstHashMapKeySet&);\n\n\n\n public:\n\n\n\n ConstHashMapKeySet(const HashMap* parent) : AbstractSet<K>(), associatedMap(parent) {\n\n }\n\n\n\n virtual ~ConstHashMapKeySet() {}\n\n\n\n virtual bool contains(const K& key) const {\n\n return this->associatedMap->containsKey(key);\n\n }\n", "file_path": "activemq-cpp/src/main/decaf/util/HashMap.h", "rank": 75, "score": 288626.8894152502 }, { "content": " class ConstHashMapValueCollection : public AbstractCollection<V> {\n\n private:\n\n\n\n const HashMap* associatedMap;\n\n\n\n private:\n\n\n\n ConstHashMapValueCollection(const ConstHashMapValueCollection&);\n\n ConstHashMapValueCollection& operator= (const ConstHashMapValueCollection&);\n\n\n\n public:\n\n\n\n ConstHashMapValueCollection(const HashMap* parent) : AbstractCollection<V>(), associatedMap(parent) {\n\n }\n\n\n\n virtual ~ConstHashMapValueCollection() {}\n\n\n\n virtual bool contains(const V& value) const {\n\n return this->associatedMap->containsValue(value);\n\n }\n", "file_path": "activemq-cpp/src/main/decaf/util/HashMap.h", "rank": 76, "score": 288626.8894152502 }, { "content": " class ConstStlMapKeySet : public AbstractSet<K> {\n\n private:\n\n\n\n const StlMap* associatedMap;\n\n\n\n private:\n\n\n\n ConstStlMapKeySet(const ConstStlMapKeySet&);\n\n ConstStlMapKeySet& operator= (const ConstStlMapKeySet&);\n\n\n\n public:\n\n\n\n ConstStlMapKeySet(const StlMap* parent) : AbstractSet<K>(), associatedMap(parent) {}\n\n\n\n virtual ~ConstStlMapKeySet() {}\n\n\n\n virtual bool contains(const K& key) const {\n\n return this->associatedMap->containsKey(key);\n\n }\n\n\n", "file_path": "activemq-cpp/src/main/decaf/util/StlMap.h", "rank": 77, "score": 288626.8894152502 }, { "content": " class TextMessageCreator: public activemq::cmsutil::MessageCreator {\n\n public:\n\n\n\n TextMessageCreator() : MessageCreator() {}\n\n\n\n virtual ~TextMessageCreator() {}\n\n\n\n virtual cms::Message* createMessage( cms::Session* session ) {\n\n\n\n cms::Message* message = NULL;\n\n\n\n if( session != NULL ) {\n\n message = session->createTextMessage(\"test text message\");\n\n }\n\n\n\n return message;\n\n }\n\n };\n\n}\n\n\n", "file_path": "activemq-cpp/src/examples/cmstemplate/CMSTemplateSender.cpp", "rank": 78, "score": 288551.7731555651 }, { "content": " class MockReader : public decaf::io::Reader {\n\n private:\n\n\n\n std::vector<char> contents;\n\n\n\n int current_offset;\n\n int length;\n\n\n\n public:\n\n\n\n MockReader() : Reader(), contents(), current_offset(0), length(0) {\n\n }\n\n\n\n MockReader( std::vector<char>& data ) : Reader(), contents(data), current_offset(0), length((int)contents.size()) {\n\n }\n\n\n\n virtual void close() {\n\n contents.clear();\n\n }\n\n\n", "file_path": "activemq-cpp/src/test/decaf/io/ReaderTest.cpp", "rank": 79, "score": 287179.48452026525 }, { "content": " class ShutdownTask : public decaf::lang::Runnable {\n\n private:\n\n\n\n SocketFactory** defaultRef;\n\n\n\n private:\n\n\n\n ShutdownTask( const ShutdownTask& );\n\n ShutdownTask& operator= ( const ShutdownTask& );\n\n\n\n public:\n\n\n\n ShutdownTask( SocketFactory** defaultRef ) : defaultRef( defaultRef ) {}\n\n virtual ~ShutdownTask() {}\n\n\n\n virtual void run() {\n\n *defaultRef = NULL;\n\n }\n\n };\n\n}\n", "file_path": "activemq-cpp/src/main/decaf/net/SocketFactory.cpp", "rank": 80, "score": 287179.4845202652 }, { "content": " class DECAF_API SecureRandom : public decaf::util::Random {\n\n private:\n\n\n\n std::auto_ptr<SecureRandomSpi> secureRandom;\n\n\n\n public:\n\n\n\n /**\n\n * Creates a new instance of a secure random number generator that implements the\n\n * default random number algorithm.\n\n *\n\n * The SecureRandom instance that is created with this constructor is unseeded and\n\n * can be seeded by calling the setSeed method. Calls to nextBytes on an unseeded\n\n * SecureRandom result in the object seeding itself.\n\n */\n\n SecureRandom();\n\n\n\n /**\n\n * Creates a new instance of a secure random number generator that implements the\n\n * default random number algorithm.\n", "file_path": "activemq-cpp/src/main/decaf/security/SecureRandom.h", "rank": 81, "score": 284780.7412498363 }, { "content": " class NoOpRunnable : public decaf::lang::Runnable {\n\n public:\n\n\n\n NoOpRunnable() : decaf::lang::Runnable() {\n\n }\n\n\n\n virtual ~NoOpRunnable() {}\n\n\n\n virtual void run() {\n\n }\n\n };\n\n\n\n template<typename E>\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h", "rank": 82, "score": 284647.8236890537 }, { "content": " class ShortRunnable : public decaf::lang::Runnable {\n\n private:\n\n\n\n ExecutorsTestSupport* parent;\n\n\n\n private:\n\n\n\n ShortRunnable(const ShortRunnable&);\n\n ShortRunnable operator= (const ShortRunnable&);\n\n\n\n public:\n\n\n\n ShortRunnable(ExecutorsTestSupport* parent) : decaf::lang::Runnable(), parent(parent) {\n\n }\n\n\n\n virtual ~ShortRunnable() {}\n\n\n\n virtual void run() {\n\n try {\n\n Thread::sleep(SHORT_DELAY_MS);\n\n } catch(decaf::lang::Exception& e) {\n\n parent->threadUnexpectedException(e);\n\n }\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h", "rank": 83, "score": 284647.8236890537 }, { "content": " class BenchmarkRunnable : public decaf::lang::Runnable {\n\n public:\n\n\n\n virtual void run() {\n\n Thread::sleep( 10 );\n\n }\n\n\n\n };\n\n\n\n}}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n\nThreadBenchmark::ThreadBenchmark() {\n\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n\nThreadBenchmark::~ThreadBenchmark() {\n\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n", "file_path": "activemq-cpp/src/test-benchmarks/decaf/lang/ThreadBenchmark.cpp", "rank": 84, "score": 284647.8236890537 }, { "content": " class ShutdownTask : public decaf::lang::Runnable {\n\n private:\n\n\n\n ServerSocketFactory** defaultRef;\n\n\n\n private:\n\n\n\n ShutdownTask( const ShutdownTask& );\n\n ShutdownTask& operator= ( const ShutdownTask& );\n\n\n\n public:\n\n\n\n ShutdownTask( ServerSocketFactory** defaultRef ) : defaultRef( defaultRef ) {}\n\n virtual ~ShutdownTask() {}\n\n\n\n virtual void run() {\n\n *defaultRef = NULL;\n\n }\n\n };\n\n}\n", "file_path": "activemq-cpp/src/main/decaf/net/ServerSocketFactory.cpp", "rank": 85, "score": 284647.8236890537 }, { "content": " class SmallRunnable : public decaf::lang::Runnable {\n\n private:\n\n\n\n ExecutorsTestSupport* parent;\n\n\n\n private:\n\n\n\n SmallRunnable(const SmallRunnable&);\n\n SmallRunnable operator= (const SmallRunnable&);\n\n\n\n public:\n\n\n\n SmallRunnable(ExecutorsTestSupport* parent) : decaf::lang::Runnable(), parent(parent) {\n\n }\n\n\n\n virtual ~SmallRunnable() {}\n\n\n\n virtual void run() {\n\n try {\n\n Thread::sleep(SMALL_DELAY_MS);\n\n } catch(decaf::lang::Exception& e) {\n\n parent->threadUnexpectedException(e);\n\n }\n\n }\n\n };\n\n\n\n template<typename E>\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h", "rank": 86, "score": 284647.8236890537 }, { "content": "////////////////////////////////////////////////////////////////////////////////\n\nclass PointerTestRunnable : public decaf::lang::Runnable {\n\nprivate:\n\n\n\n Pointer<TestClassA> mine;\n\n\n\npublic:\n\n\n\n PointerTestRunnable( const Pointer<TestClassA>& value ) : mine( value ) {}\n\n\n\n void run() {\n\n\n\n for( int i = 0; i < 999; ++i ) {\n\n Pointer<TestClassBase> copy = this->mine;\n\n CPPUNIT_ASSERT( copy->returnHello() == \"Hello\" );\n\n copy.reset( new TestClassB() );\n\n CPPUNIT_ASSERT( copy->returnHello() == \"GoodBye\" );\n\n }\n\n }\n\n};\n\n\n", "file_path": "activemq-cpp/src/test/decaf/lang/PointerTest.cpp", "rank": 87, "score": 284647.8236890537 }, { "content": " class LongRunnable : public decaf::lang::Runnable {\n\n private:\n\n\n\n ExecutorsTestSupport* parent;\n\n\n\n private:\n\n\n\n LongRunnable(const LongRunnable&);\n\n LongRunnable operator= (const LongRunnable&);\n\n\n\n public:\n\n\n\n LongRunnable(ExecutorsTestSupport* parent) : decaf::lang::Runnable(), parent(parent) {\n\n }\n\n\n\n virtual ~LongRunnable() {}\n\n\n\n virtual void run() {\n\n try {\n\n Thread::sleep(LONG_DELAY_MS);\n\n } catch(decaf::lang::Exception& e) {\n\n parent->threadUnexpectedException(e);\n\n }\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h", "rank": 88, "score": 284647.8236890537 }, { "content": " class MediumRunnable : public decaf::lang::Runnable {\n\n private:\n\n\n\n ExecutorsTestSupport* parent;\n\n\n\n private:\n\n\n\n MediumRunnable(const MediumRunnable&);\n\n MediumRunnable operator= (const MediumRunnable&);\n\n\n\n public:\n\n\n\n MediumRunnable(ExecutorsTestSupport* parent) : decaf::lang::Runnable(), parent(parent) {\n\n }\n\n\n\n virtual ~MediumRunnable() {}\n\n\n\n virtual void run() {\n\n try {\n\n Thread::sleep(MEDIUM_DELAY_MS);\n\n } catch(decaf::lang::Exception& e) {\n\n parent->threadUnexpectedException(e);\n\n }\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h", "rank": 89, "score": 284647.8236890537 }, { "content": " class TextMessageCreator : public activemq::cmsutil::MessageCreator {\n\n private:\n\n\n\n std::string text;\n\n\n\n public:\n\n\n\n TextMessageCreator(const std::string& text) :\n\n activemq::cmsutil::MessageCreator(), text(text) {\n\n }\n\n\n\n virtual ~TextMessageCreator() {\n\n }\n\n\n\n std::string getText() const {\n\n return text;\n\n }\n\n\n\n virtual cms::Message* createMessage(cms::Session* session) throw (cms::CMSException) {\n\n\n\n return session->createTextMessage(text);\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/test-integration/activemq/test/CmsTemplateTest.cpp", "rank": 90, "score": 284304.8306418946 }, { "content": " class Less : public decaf::util::Comparator<E> {\n\n public:\n\n\n\n Less() {}\n\n virtual ~Less() {}\n\n\n\n virtual bool operator()(const E& left, const E& right) const {\n\n return left < right;\n\n }\n\n\n\n virtual int compare(const E& o1, const E& o2) const {\n\n\n\n if (o1 > o2) {\n\n return 1;\n\n } else if (o1 < o2) {\n\n return -1;\n\n }\n\n\n\n return 0;\n\n }\n\n\n\n };\n\n\n\n}}}\n\n\n\n#endif /* _DECAF_UTIL_COMPARATORS_LESS_H_ */\n", "file_path": "activemq-cpp/src/main/decaf/util/comparators/Less.h", "rank": 91, "score": 283161.30317390535 }, { "content": " class Equals : public decaf::util::Comparator<E> {\n\n public:\n\n\n\n Equals() {}\n\n virtual ~Equals() {}\n\n\n\n virtual bool operator()(const E& left, const E& right) const {\n\n return left == right;\n\n }\n\n\n\n virtual int compare(const E& o1, const E& o2) const {\n\n\n\n if (o1 == o2) {\n\n return 0;\n\n }\n\n\n\n if (o1 < o2) {\n\n return -1;\n\n }\n\n\n\n return 1;\n\n }\n\n\n\n };\n\n\n\n template< typename E >\n", "file_path": "activemq-cpp/src/main/decaf/util/comparators/Equals.h", "rank": 92, "score": 283161.30317390535 }, { "content": " class MyTransport : public Transport, public decaf::lang::Runnable {\n\n public:\n\n\n\n TransportListener* listener;\n\n decaf::lang::Thread* thread;\n\n decaf::util::concurrent::Mutex mutex;\n\n decaf::util::concurrent::Mutex startedMutex;\n\n bool done;\n\n std::queue< Pointer<commands::Command> > requests;\n\n\n\n private:\n\n\n\n MyTransport(const MyTransport&);\n\n MyTransport& operator= (const MyTransport&);\n\n\n\n public:\n\n\n\n MyTransport() : listener(NULL), thread(NULL), mutex(), startedMutex(), done(false), requests() {\n\n }\n\n\n", "file_path": "activemq-cpp/src/test/activemq/transport/correlator/ResponseCorrelatorTest.cpp", "rank": 93, "score": 282778.7446210568 }, { "content": " class DECAF_API CancellationException : public decaf::lang::Exception {\n\n public:\n\n\n\n /**\n\n * Default Constructor\n\n */\n\n CancellationException();\n\n\n\n /**\n\n * Conversion Constructor from some other Exception\n\n *\n\n * @param ex An exception that should become this type of Exception\n\n */\n\n CancellationException(const decaf::lang::Exception& ex);\n\n\n\n /**\n\n * Copy Constructor\n\n *\n\n * @param ex - The Exception to copy in this new instance.\n\n */\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/CancellationException.h", "rank": 94, "score": 282444.81469470053 }, { "content": " class DECAF_API TimeoutException : public decaf::lang::Exception {\n\n public:\n\n\n\n /**\n\n * Default Constructor\n\n */\n\n TimeoutException();\n\n\n\n /**\n\n * Conversion Constructor from some other Exception\n\n *\n\n * @param ex An exception that should become this type of Exception\n\n */\n\n TimeoutException(const decaf::lang::Exception& ex);\n\n\n\n /**\n\n * Copy Constructor\n\n *\n\n * @param ex\n\n * The exception to copy from.\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/TimeoutException.h", "rank": 95, "score": 282444.81469470053 }, { "content": " class DECAF_API ExecutionException : public decaf::lang::Exception {\n\n public:\n\n\n\n /**\n\n * Default Constructor\n\n */\n\n ExecutionException();\n\n\n\n /**\n\n * Conversion Constructor from some other Exception\n\n *\n\n * @param ex - An exception that should become this type of Exception\n\n */\n\n ExecutionException(const decaf::lang::Exception& ex);\n\n\n\n /**\n\n * Copy Constructor\n\n *\n\n * @param ex - The Exception to copy in this new instance.\n\n */\n", "file_path": "activemq-cpp/src/main/decaf/util/concurrent/ExecutionException.h", "rank": 96, "score": 282444.81469470053 }, { "content": " class MediumInterruptedRunnable : public decaf::lang::Runnable {\n\n private:\n\n\n\n ExecutorsTestSupport* parent;\n\n\n\n private:\n\n\n\n MediumInterruptedRunnable(const MediumInterruptedRunnable&);\n\n MediumInterruptedRunnable operator= (const MediumInterruptedRunnable&);\n\n\n\n public:\n\n\n\n MediumInterruptedRunnable(ExecutorsTestSupport* parent) : decaf::lang::Runnable(), parent(parent) {\n\n }\n\n\n\n virtual ~MediumInterruptedRunnable() {}\n\n\n\n virtual void run() {\n\n try {\n\n Thread::sleep(MEDIUM_DELAY_MS);\n\n parent->threadShouldThrow();\n\n } catch(decaf::lang::Exception& e) {\n\n }\n\n }\n\n };\n\n\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/ExecutorsTestSupport.h", "rank": 97, "score": 282189.39530217357 }, { "content": " class FutureRunnable : public decaf::lang::Runnable {\n\n public:\n\n\n\n FutureRunnable() {\n\n }\n\n\n\n virtual ~FutureRunnable() {\n\n }\n\n\n\n virtual void run() {\n\n }\n\n };\n\n\n\n template<typename E>\n", "file_path": "activemq-cpp/src/test/decaf/util/concurrent/FutureTaskTest.cpp", "rank": 98, "score": 282189.3953021735 }, { "content": " class ShutdownTask : public decaf::lang::Runnable {\n\n private:\n\n\n\n SocketFactory** defaultRef;\n\n\n\n private:\n\n\n\n ShutdownTask( const ShutdownTask& );\n\n ShutdownTask& operator= ( const ShutdownTask& );\n\n\n\n public:\n\n\n\n ShutdownTask( SocketFactory** defaultRef ) : defaultRef( defaultRef ) {}\n\n virtual ~ShutdownTask() {}\n\n\n\n virtual void run() {\n\n *defaultRef = NULL;\n\n }\n\n };\n\n}\n", "file_path": "activemq-cpp/src/main/decaf/net/ssl/SSLSocketFactory.cpp", "rank": 99, "score": 282189.3953021735 } ]
C++
PlayTools/mainwindow.cpp
memorywalker/playtools
39441f3df16484a0784a5cc3b62c57af049fdc52
#include "mainwindow.h" #include "firewallrules.h" #include "ui_mainwindow.h" #include <Windows.h> #include "AutoMate.h" #include <QDebug> #include <QHotkey> #include <QSound> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_nLuckwheelInteval(4000) { ui->setupUi(this); m_AutoMate = new AutoMate(); m_AutoMate->SetWindow(this); m_GtaProcessPath = "I:\\SteamLibrary\\steamapps\\common\\Grand Theft Auto V\\GTA5.exe"; m_firewallRules.SetActionListener(this); InitUI(); } MainWindow::~MainWindow() { for (size_t i = 0; i < FunctionType_Max; i++) { delete m_FuncHotkeys[i]; m_FuncHotkeys[i] = nullptr; } delete ui; } void MainWindow::InitUI() { QString strluckyWheelInteval = ui->lineEditLuckyWheelInteval->text(); m_nLuckwheelInteval = strluckyWheelInteval.toInt(); BindHotKeys(); } void MainWindow::PlaySoundPrompt() { QSound::play("c:/Windows/media/tada.wav"); } void MainWindow::BindHotKeys() { for (size_t i = 0; i < FunctionType_Max; i++) { m_FuncHotkeys[i] = new QHotkey(this); } QString strKey = ui->lineEditSolo->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Solo]->setShortcut(QKeySequence(strKey), true); QMetaObject::Connection conn = QObject::connect(m_FuncHotkeys[FunctionType_Solo], &QHotkey::activated, this, &MainWindow::on_soloButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditDisconnectProcess->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Disconnect]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Disconnect], &QHotkey::activated, this, &MainWindow::on_disconnectProcessButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditFingerPrint->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Finger]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Finger], &QHotkey::activated, this, &MainWindow::on_fingerPrintButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditLuckyWheel->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Lucky]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Lucky], &QHotkey::activated, this, &MainWindow::on_luckyWheelButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditDoomsDayII->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_DoomsDayII]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_DoomsDayII], &QHotkey::activated, this, &MainWindow::on_doomsDay2Button_clicked); Q_ASSERT(conn); strKey = ui->lineEditDoomsDayIII->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_DoomsDayIII]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_DoomsDayIII], &QHotkey::activated, this, &MainWindow::on_doomsDay3Button_clicked); Q_ASSERT(conn); strKey = ui->lineEditSnack->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Snack]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Snack], &QHotkey::activated, this, &MainWindow::on_snackButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditArmor->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Armor]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Armor], &QHotkey::activated, this, &MainWindow::on_amorButton_clicked); Q_ASSERT(conn); } void MainWindow::UnBindHotKeys() { bool bRet = QObject::disconnect(m_FuncHotkeys[FunctionType_Solo], &QHotkey::activated, this, &MainWindow::on_soloButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Disconnect], &QHotkey::activated, this, &MainWindow::on_disconnectProcessButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Finger], &QHotkey::activated, this, &MainWindow::on_fingerPrintButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Lucky], &QHotkey::activated, this, &MainWindow::on_luckyWheelButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_DoomsDayII], &QHotkey::activated, this, &MainWindow::on_doomsDay2Button_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_DoomsDayIII], &QHotkey::activated, this, &MainWindow::on_doomsDay3Button_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Snack], &QHotkey::activated, this, &MainWindow::on_snackButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Armor], &QHotkey::activated, this, &MainWindow::on_amorButton_clicked); for (size_t i = 0; i < FunctionType_Max; i++) { delete m_FuncHotkeys[i]; m_FuncHotkeys[i] = nullptr; } } void MainWindow::OnActionDone(QString& strOut) { ui->labelPrompt->setText(strOut); PlaySoundPrompt(); } void MainWindow::closeEvent(QCloseEvent* e) { m_firewallRules.StopProcessOffine(); m_firewallRules.StopSinglePublicSession(); } void MainWindow::on_snackButton_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendSnackCmd(); } } void MainWindow::on_amorButton_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendArmorCmd(); } } void MainWindow::on_soloButton_clicked() { PlaySoundPrompt(); static bool switchOn = false; if (!switchOn) { m_firewallRules.StartSinglePublicSession(); } else { m_firewallRules.StopSinglePublicSession(); } switchOn = !switchOn; if (switchOn) { ui->soloButton->setStyleSheet("background-color: rgb(255, 0, 0)"); } else { ui->soloButton->setStyleSheet("background-color: rgb(23, 135, 6)"); } } void MainWindow::on_disconnectProcessButton_clicked() { PlaySoundPrompt(); static bool switchOn = false; if (!switchOn) { m_firewallRules.StartProcessOffline(m_GtaProcessPath); } else { m_firewallRules.StopProcessOffine(); } switchOn = !switchOn; if (switchOn) { ui->disconnectProcessButton->setStyleSheet("background-color: rgb(255, 0, 0)"); } else { ui->disconnectProcessButton->setStyleSheet("background-color: rgb(23, 135, 6)"); } } void MainWindow::on_fingerPrintButton_clicked() { PlaySoundPrompt(); } void MainWindow::on_luckyWheelButton_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendLuckyWheelCmd(m_nLuckwheelInteval); } } void MainWindow::on_doomsDay2Button_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendDoomsDayIICmd(); } } void MainWindow::on_doomsDay3Button_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendDoomsDayIIICmd(); } } void MainWindow::on_lineEditLuckyWheelInteval_textChanged(const QString &arg1) { QString strluckyWheelInteval = ui->lineEditLuckyWheelInteval->text(); m_nLuckwheelInteval = strluckyWheelInteval.toInt(); } void MainWindow::on_pushButtonSave_clicked() { UnBindHotKeys(); BindHotKeys(); }
#include "mainwindow.h" #include "firewallrules.h" #include "ui_mainwindow.h" #include <Windows.h> #include "AutoMate.h" #include <QDebug> #include <QHotkey> #include <QSound> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , m_nLuckwheelInteval(4000) { ui->setupUi(this); m_AutoMate = new AutoMate(); m_AutoMate->SetWindow(this); m_GtaProcessPath = "I:\\SteamLibrary\\steamapps\\common\\Grand Theft Auto V\\GTA5.exe"; m_firewallRules.SetActionListener(this); InitUI(); } MainWindow::~MainWindow() { for (size_t i = 0; i < FunctionType_Max; i++) { delete m_FuncHotkeys[i]; m_FuncHotkeys[i] = nullptr; } delete ui; } void MainWindow::InitUI() { QString strluckyWheelInteval = ui->lineEditLuckyWheelInteval->text(); m_nLuckwheelInteval = strluckyWheelInteval.toInt(); BindHotKeys(); } void MainWindow::PlaySoundPrompt() { QSound::play("c:/Windows/media/tada.wav"); } void MainWindow::BindHotKeys() { for (size_t i = 0; i < FunctionType_Max; i++) { m_FuncHotkeys[i] = new QHotkey(this); } QString strKey = ui->lineEditSolo->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Solo]->setShortcut(QKeySequence(strKey), true); QMetaObject::Connection conn = QObject::connect(m_FuncHotkeys[FunctionType_Solo], &QHotkey::activated, this, &MainWindow::on_soloButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditDisconnectProcess->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Disconnect]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Disconnect], &QHotkey::activated, this, &MainWindow::on_disconnectProcessButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditFingerPrint->text().trimmed().toLower(); m
m_firewallRules.StartProcessOffline(m_GtaProcessPath); } else { m_firewallRules.StopProcessOffine(); } switchOn = !switchOn; if (switchOn) { ui->disconnectProcessButton->setStyleSheet("background-color: rgb(255, 0, 0)"); } else { ui->disconnectProcessButton->setStyleSheet("background-color: rgb(23, 135, 6)"); } } void MainWindow::on_fingerPrintButton_clicked() { PlaySoundPrompt(); } void MainWindow::on_luckyWheelButton_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendLuckyWheelCmd(m_nLuckwheelInteval); } } void MainWindow::on_doomsDay2Button_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendDoomsDayIICmd(); } } void MainWindow::on_doomsDay3Button_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendDoomsDayIIICmd(); } } void MainWindow::on_lineEditLuckyWheelInteval_textChanged(const QString &arg1) { QString strluckyWheelInteval = ui->lineEditLuckyWheelInteval->text(); m_nLuckwheelInteval = strluckyWheelInteval.toInt(); } void MainWindow::on_pushButtonSave_clicked() { UnBindHotKeys(); BindHotKeys(); }
_FuncHotkeys[FunctionType_Finger]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Finger], &QHotkey::activated, this, &MainWindow::on_fingerPrintButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditLuckyWheel->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Lucky]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Lucky], &QHotkey::activated, this, &MainWindow::on_luckyWheelButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditDoomsDayII->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_DoomsDayII]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_DoomsDayII], &QHotkey::activated, this, &MainWindow::on_doomsDay2Button_clicked); Q_ASSERT(conn); strKey = ui->lineEditDoomsDayIII->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_DoomsDayIII]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_DoomsDayIII], &QHotkey::activated, this, &MainWindow::on_doomsDay3Button_clicked); Q_ASSERT(conn); strKey = ui->lineEditSnack->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Snack]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Snack], &QHotkey::activated, this, &MainWindow::on_snackButton_clicked); Q_ASSERT(conn); strKey = ui->lineEditArmor->text().trimmed().toLower(); m_FuncHotkeys[FunctionType_Armor]->setShortcut(QKeySequence(strKey), true); conn = QObject::connect(m_FuncHotkeys[FunctionType_Armor], &QHotkey::activated, this, &MainWindow::on_amorButton_clicked); Q_ASSERT(conn); } void MainWindow::UnBindHotKeys() { bool bRet = QObject::disconnect(m_FuncHotkeys[FunctionType_Solo], &QHotkey::activated, this, &MainWindow::on_soloButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Disconnect], &QHotkey::activated, this, &MainWindow::on_disconnectProcessButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Finger], &QHotkey::activated, this, &MainWindow::on_fingerPrintButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Lucky], &QHotkey::activated, this, &MainWindow::on_luckyWheelButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_DoomsDayII], &QHotkey::activated, this, &MainWindow::on_doomsDay2Button_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_DoomsDayIII], &QHotkey::activated, this, &MainWindow::on_doomsDay3Button_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Snack], &QHotkey::activated, this, &MainWindow::on_snackButton_clicked); bRet &= QObject::disconnect(m_FuncHotkeys[FunctionType_Armor], &QHotkey::activated, this, &MainWindow::on_amorButton_clicked); for (size_t i = 0; i < FunctionType_Max; i++) { delete m_FuncHotkeys[i]; m_FuncHotkeys[i] = nullptr; } } void MainWindow::OnActionDone(QString& strOut) { ui->labelPrompt->setText(strOut); PlaySoundPrompt(); } void MainWindow::closeEvent(QCloseEvent* e) { m_firewallRules.StopProcessOffine(); m_firewallRules.StopSinglePublicSession(); } void MainWindow::on_snackButton_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendSnackCmd(); } } void MainWindow::on_amorButton_clicked() { PlaySoundPrompt(); if (m_AutoMate) { m_AutoMate->SendArmorCmd(); } } void MainWindow::on_soloButton_clicked() { PlaySoundPrompt(); static bool switchOn = false; if (!switchOn) { m_firewallRules.StartSinglePublicSession(); } else { m_firewallRules.StopSinglePublicSession(); } switchOn = !switchOn; if (switchOn) { ui->soloButton->setStyleSheet("background-color: rgb(255, 0, 0)"); } else { ui->soloButton->setStyleSheet("background-color: rgb(23, 135, 6)"); } } void MainWindow::on_disconnectProcessButton_clicked() { PlaySoundPrompt(); static bool switchOn = false; if (!switchOn) {
random
[ { "content": "class AutoMate\n\n{\n\npublic:\n\n\tAutoMate();\n\n\t~AutoMate();\n\n\n\n\tvoid SetWindow(QObject* qObj);\n\n\n\n\tvoid SendTestCommand();\n\n\n\n\tvoid SendSnackCmd();\n\n\tvoid SendArmorCmd();\n\n\tvoid SendDoomsDayIICmd();\n\n\tvoid SendDoomsDayIIICmd();\n\n\tvoid SendLuckyWheelCmd(int millisec);\n\n\tvoid SendFingerPrintCmd();\n\n\n\nprivate:\n\n\tconst static char MAX_KEY_COUNT = 3;\n\n\t// Press down and up with interval; 3 key for most\n", "file_path": "PlayTools/AutoMate.h", "rank": 0, "score": 31311.14421347797 }, { "content": "//! A class to define global, systemwide Hotkeys\n\nclass QHOTKEY_SHARED_EXPORT QHotkey : public QObject\n\n{\n\n\tQ_OBJECT\n\n\tfriend class QHotkeyPrivate;\n\n\n\n\t//! Specifies whether this hotkey is currently registered or not\n\n\tQ_PROPERTY(bool registered READ isRegistered WRITE setRegistered NOTIFY registeredChanged)\n\n\t//! Holds the shortcut this hotkey will be triggered on\n\n\tQ_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut RESET resetShortcut)\n\n\n\npublic:\n", "file_path": "PlayTools/QHotkey/qhotkey.h", "rank": 1, "score": 30433.28993149334 }, { "content": "class Ui_MainWindow\n\n{\n\npublic:\n\n QWidget *centralwidget;\n\n QVBoxLayout *verticalLayout;\n\n QVBoxLayout *rootlayout;\n\n QHBoxLayout *toplayout;\n\n QVBoxLayout *mainlayout;\n\n QHBoxLayout *horizontalLayout_2;\n\n QPushButton *soloButton;\n\n QLineEdit *lineEditSolo;\n\n QHBoxLayout *horizontalLayout_4;\n\n QPushButton *disconnectProcessButton;\n\n QLineEdit *lineEditDisconnectProcess;\n\n QHBoxLayout *horizontalLayout_5;\n\n QPushButton *fingerPrintButton;\n\n QLineEdit *lineEditFingerPrint;\n\n QHBoxLayout *horizontalLayout_6;\n\n QPushButton *luckyWheelButton;\n\n QLineEdit *lineEditLuckyWheel;\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 2, "score": 29785.557245892072 }, { "content": " class MainWindow: public Ui_MainWindow {};\n\n} // namespace Ui\n\n\n\nQT_END_NAMESPACE\n\n\n\n#endif // UI_MAINWINDOW_H\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 3, "score": 26806.856360440997 }, { "content": "\t//! Defines shortcut with native keycodes\n\n\tclass QHOTKEY_SHARED_EXPORT NativeShortcut {\n\n\tpublic:\n\n\t\t//! The native keycode\n\n\t\tquint32 key;\n\n\t\t//! The native modifiers\n\n\t\tquint32 modifier;\n\n\n\n\t\t//! Creates an invalid native shortcut\n\n\t\tNativeShortcut();\n\n\t\t//! Creates a valid native shortcut, with the given key and modifiers\n\n\t\tNativeShortcut(quint32 key, quint32 modifier = 0);\n\n\n\n\t\t//! Checks, whether this shortcut is valid or not\n\n\t\tbool isValid() const;\n\n\n\n\t\t//! Equality operator\n\n\t\tbool operator ==(const NativeShortcut &other) const;\n\n\t\t//! Inequality operator\n\n\t\tbool operator !=(const NativeShortcut &other) const;\n\n\n", "file_path": "PlayTools/QHotkey/qhotkey.h", "rank": 4, "score": 26034.75649491446 }, { "content": "\tvoid SendKeyInput(WORD* keylist, char num);\n\n\tvoid KeyPress(WORD keyCode, bool bUp = false);\n\n\tvoid KeyDown(WORD keyCode);\n\n\tvoid KeyUp(WORD keyCode);\n\n\tvoid KeyClick(WORD keyCode);\n\n\n\n\n\n\tQObject* m_MainWindow;\n\n};\n\n\n", "file_path": "PlayTools/AutoMate.h", "rank": 5, "score": 25865.679453435187 }, { "content": "#pragma once\n\n\n", "file_path": "PlayTools/AutoMate.h", "rank": 6, "score": 25861.870763970215 }, { "content": "/********************************************************************************\n\n** Form generated from reading UI file 'mainwindow.ui'\n\n**\n\n** Created by: Qt User Interface Compiler version 5.15.0\n\n**\n\n** WARNING! All changes made in this file will be lost when recompiling UI file!\n\n********************************************************************************/\n\n\n\n#ifndef UI_MAINWINDOW_H\n\n#define UI_MAINWINDOW_H\n\n\n\n#include <QtCore/QVariant>\n\n#include <QtWidgets/QApplication>\n\n#include <QtWidgets/QHBoxLayout>\n\n#include <QtWidgets/QLabel>\n\n#include <QtWidgets/QLineEdit>\n\n#include <QtWidgets/QMainWindow>\n\n#include <QtWidgets/QMenuBar>\n\n#include <QtWidgets/QPushButton>\n\n#include <QtWidgets/QSpacerItem>\n\n#include <QtWidgets/QStatusBar>\n\n#include <QtWidgets/QVBoxLayout>\n\n#include <QtWidgets/QWidget>\n\n\n\nQT_BEGIN_NAMESPACE\n\n\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 7, "score": 25555.152935189013 }, { "content": " lineEditSnack->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+Alt+E\", nullptr));\n\n amorButton->setText(QCoreApplication::translate(\"MainWindow\", \"Armor\", nullptr));\n\n lineEditArmor->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+Alt+C\", nullptr));\n\n pushButtonSave->setText(QCoreApplication::translate(\"MainWindow\", \"Save\", nullptr));\n\n pushButton_2->setText(QCoreApplication::translate(\"MainWindow\", \"PushButton\", nullptr));\n\n labelPrompt->setText(QCoreApplication::translate(\"MainWindow\", \"Prompt\", nullptr));\n\n labelInfo->setText(QCoreApplication::translate(\"MainWindow\", \"Ver 0.1\", nullptr));\n\n } // retranslateUi\n\n\n\n};\n\n\n\nnamespace Ui {\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 8, "score": 25553.739088693394 }, { "content": " QHBoxLayout *bottomlayout;\n\n QMenuBar *menubar;\n\n QStatusBar *statusbar;\n\n\n\n void setupUi(QMainWindow *MainWindow)\n\n {\n\n if (MainWindow->objectName().isEmpty())\n\n MainWindow->setObjectName(QString::fromUtf8(\"MainWindow\"));\n\n MainWindow->resize(441, 666);\n\n centralwidget = new QWidget(MainWindow);\n\n centralwidget->setObjectName(QString::fromUtf8(\"centralwidget\"));\n\n verticalLayout = new QVBoxLayout(centralwidget);\n\n verticalLayout->setObjectName(QString::fromUtf8(\"verticalLayout\"));\n\n rootlayout = new QVBoxLayout();\n\n rootlayout->setObjectName(QString::fromUtf8(\"rootlayout\"));\n\n toplayout = new QHBoxLayout();\n\n toplayout->setObjectName(QString::fromUtf8(\"toplayout\"));\n\n\n\n rootlayout->addLayout(toplayout);\n\n\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 9, "score": 25553.569340463375 }, { "content": " } // setupUi\n\n\n\n void retranslateUi(QMainWindow *MainWindow)\n\n {\n\n MainWindow->setWindowTitle(QCoreApplication::translate(\"MainWindow\", \"Play Tools\", nullptr));\n\n soloButton->setText(QCoreApplication::translate(\"MainWindow\", \"Solo\", nullptr));\n\n lineEditSolo->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+Alt+S\", nullptr));\n\n disconnectProcessButton->setText(QCoreApplication::translate(\"MainWindow\", \"Disconnect Process\", nullptr));\n\n lineEditDisconnectProcess->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+Alt+O\", nullptr));\n\n fingerPrintButton->setText(QCoreApplication::translate(\"MainWindow\", \"FingerPrint\", nullptr));\n\n lineEditFingerPrint->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+P\", nullptr));\n\n luckyWheelButton->setText(QCoreApplication::translate(\"MainWindow\", \"Lucky Wheel\", nullptr));\n\n lineEditLuckyWheel->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+E\", nullptr));\n\n labelLuckWheel->setText(QCoreApplication::translate(\"MainWindow\", \"Inteval(ms)\", nullptr));\n\n lineEditLuckyWheelInteval->setText(QCoreApplication::translate(\"MainWindow\", \"4125\", nullptr));\n\n doomsDay2Button->setText(QCoreApplication::translate(\"MainWindow\", \"DoomsDay II\", nullptr));\n\n lineEditDoomsDayII->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+F2\", nullptr));\n\n doomsDay3Button->setText(QCoreApplication::translate(\"MainWindow\", \"DoomsDay III\", nullptr));\n\n lineEditDoomsDayIII->setText(QCoreApplication::translate(\"MainWindow\", \"Ctrl+F3\", nullptr));\n\n snackButton->setText(QCoreApplication::translate(\"MainWindow\", \"Sancks\", nullptr));\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 10, "score": 25553.482563925896 }, { "content": "\n\n mainlayout->addItem(verticalSpacer);\n\n\n\n labelPrompt = new QLabel(centralwidget);\n\n labelPrompt->setObjectName(QString::fromUtf8(\"labelPrompt\"));\n\n QFont font2;\n\n font2.setFamily(QString::fromUtf8(\"\\345\\276\\256\\350\\275\\257\\351\\233\\205\\351\\273\\221\"));\n\n labelPrompt->setFont(font2);\n\n\n\n mainlayout->addWidget(labelPrompt);\n\n\n\n labelInfo = new QLabel(centralwidget);\n\n labelInfo->setObjectName(QString::fromUtf8(\"labelInfo\"));\n\n QFont font3;\n\n font3.setFamily(QString::fromUtf8(\"Arial\"));\n\n font3.setPointSize(12);\n\n font3.setBold(true);\n\n font3.setWeight(75);\n\n labelInfo->setFont(font3);\n\n\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 11, "score": 25551.783101603975 }, { "content": " rootlayout->addLayout(bottomlayout);\n\n\n\n rootlayout->setStretch(0, 1);\n\n rootlayout->setStretch(1, 16);\n\n rootlayout->setStretch(2, 1);\n\n\n\n verticalLayout->addLayout(rootlayout);\n\n\n\n MainWindow->setCentralWidget(centralwidget);\n\n menubar = new QMenuBar(MainWindow);\n\n menubar->setObjectName(QString::fromUtf8(\"menubar\"));\n\n menubar->setGeometry(QRect(0, 0, 441, 21));\n\n MainWindow->setMenuBar(menubar);\n\n statusbar = new QStatusBar(MainWindow);\n\n statusbar->setObjectName(QString::fromUtf8(\"statusbar\"));\n\n MainWindow->setStatusBar(statusbar);\n\n\n\n retranslateUi(MainWindow);\n\n\n\n QMetaObject::connectSlotsByName(MainWindow);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 12, "score": 25551.77516264384 }, { "content": " mainlayout = new QVBoxLayout();\n\n mainlayout->setObjectName(QString::fromUtf8(\"mainlayout\"));\n\n horizontalLayout_2 = new QHBoxLayout();\n\n horizontalLayout_2->setObjectName(QString::fromUtf8(\"horizontalLayout_2\"));\n\n horizontalLayout_2->setSizeConstraint(QLayout::SetFixedSize);\n\n soloButton = new QPushButton(centralwidget);\n\n soloButton->setObjectName(QString::fromUtf8(\"soloButton\"));\n\n QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);\n\n sizePolicy.setHorizontalStretch(0);\n\n sizePolicy.setVerticalStretch(0);\n\n sizePolicy.setHeightForWidth(soloButton->sizePolicy().hasHeightForWidth());\n\n soloButton->setSizePolicy(sizePolicy);\n\n QFont font;\n\n font.setFamily(QString::fromUtf8(\"Arial\"));\n\n font.setPointSize(10);\n\n font.setBold(true);\n\n font.setWeight(75);\n\n soloButton->setFont(font);\n\n soloButton->setFocusPolicy(Qt::StrongFocus);\n\n soloButton->setStyleSheet(QString::fromUtf8(\"background-color: rgb(23, 135, 6);\"));\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 13, "score": 25551.234320690757 }, { "content": "\n\n horizontalLayout_2->addWidget(soloButton);\n\n\n\n lineEditSolo = new QLineEdit(centralwidget);\n\n lineEditSolo->setObjectName(QString::fromUtf8(\"lineEditSolo\"));\n\n QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Preferred);\n\n sizePolicy1.setHorizontalStretch(0);\n\n sizePolicy1.setVerticalStretch(0);\n\n sizePolicy1.setHeightForWidth(lineEditSolo->sizePolicy().hasHeightForWidth());\n\n lineEditSolo->setSizePolicy(sizePolicy1);\n\n QFont font1;\n\n font1.setFamily(QString::fromUtf8(\"Arial\"));\n\n font1.setPointSize(11);\n\n font1.setBold(true);\n\n font1.setWeight(75);\n\n lineEditSolo->setFont(font1);\n\n\n\n horizontalLayout_2->addWidget(lineEditSolo);\n\n\n\n horizontalLayout_2->setStretch(0, 1);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 14, "score": 25550.547946993058 }, { "content": "\n\n lineEditArmor = new QLineEdit(centralwidget);\n\n lineEditArmor->setObjectName(QString::fromUtf8(\"lineEditArmor\"));\n\n sizePolicy1.setHeightForWidth(lineEditArmor->sizePolicy().hasHeightForWidth());\n\n lineEditArmor->setSizePolicy(sizePolicy1);\n\n lineEditArmor->setFont(font1);\n\n\n\n horizontalLayout_3->addWidget(lineEditArmor);\n\n\n\n horizontalLayout_3->setStretch(0, 1);\n\n horizontalLayout_3->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_3);\n\n\n\n horizontalLayout_11 = new QHBoxLayout();\n\n horizontalLayout_11->setObjectName(QString::fromUtf8(\"horizontalLayout_11\"));\n\n pushButtonSave = new QPushButton(centralwidget);\n\n pushButtonSave->setObjectName(QString::fromUtf8(\"pushButtonSave\"));\n\n QSizePolicy sizePolicy2(QSizePolicy::Minimum, QSizePolicy::Preferred);\n\n sizePolicy2.setHorizontalStretch(0);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 15, "score": 25550.401684122702 }, { "content": " horizontalLayout_5->addWidget(fingerPrintButton);\n\n\n\n lineEditFingerPrint = new QLineEdit(centralwidget);\n\n lineEditFingerPrint->setObjectName(QString::fromUtf8(\"lineEditFingerPrint\"));\n\n sizePolicy1.setHeightForWidth(lineEditFingerPrint->sizePolicy().hasHeightForWidth());\n\n lineEditFingerPrint->setSizePolicy(sizePolicy1);\n\n lineEditFingerPrint->setFont(font1);\n\n\n\n horizontalLayout_5->addWidget(lineEditFingerPrint);\n\n\n\n horizontalLayout_5->setStretch(0, 1);\n\n horizontalLayout_5->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_5);\n\n\n\n horizontalLayout_6 = new QHBoxLayout();\n\n horizontalLayout_6->setObjectName(QString::fromUtf8(\"horizontalLayout_6\"));\n\n horizontalLayout_6->setSizeConstraint(QLayout::SetDefaultConstraint);\n\n luckyWheelButton = new QPushButton(centralwidget);\n\n luckyWheelButton->setObjectName(QString::fromUtf8(\"luckyWheelButton\"));\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 16, "score": 25550.348689056384 }, { "content": " horizontalLayout_7->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_7);\n\n\n\n horizontalLayout = new QHBoxLayout();\n\n horizontalLayout->setObjectName(QString::fromUtf8(\"horizontalLayout\"));\n\n horizontalLayout->setSizeConstraint(QLayout::SetDefaultConstraint);\n\n snackButton = new QPushButton(centralwidget);\n\n snackButton->setObjectName(QString::fromUtf8(\"snackButton\"));\n\n sizePolicy.setHeightForWidth(snackButton->sizePolicy().hasHeightForWidth());\n\n snackButton->setSizePolicy(sizePolicy);\n\n snackButton->setFont(font);\n\n snackButton->setFocusPolicy(Qt::StrongFocus);\n\n\n\n horizontalLayout->addWidget(snackButton);\n\n\n\n lineEditSnack = new QLineEdit(centralwidget);\n\n lineEditSnack->setObjectName(QString::fromUtf8(\"lineEditSnack\"));\n\n sizePolicy1.setHeightForWidth(lineEditSnack->sizePolicy().hasHeightForWidth());\n\n lineEditSnack->setSizePolicy(sizePolicy1);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 17, "score": 25550.323083656323 }, { "content": "\n\n lineEditLuckyWheelInteval = new QLineEdit(centralwidget);\n\n lineEditLuckyWheelInteval->setObjectName(QString::fromUtf8(\"lineEditLuckyWheelInteval\"));\n\n sizePolicy1.setHeightForWidth(lineEditLuckyWheelInteval->sizePolicy().hasHeightForWidth());\n\n lineEditLuckyWheelInteval->setSizePolicy(sizePolicy1);\n\n lineEditLuckyWheelInteval->setFont(font);\n\n lineEditLuckyWheelInteval->setAlignment(Qt::AlignCenter);\n\n\n\n horizontalLayout_6->addWidget(lineEditLuckyWheelInteval);\n\n\n\n horizontalLayout_6->setStretch(0, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_6);\n\n\n\n horizontalLayout_8 = new QHBoxLayout();\n\n horizontalLayout_8->setObjectName(QString::fromUtf8(\"horizontalLayout_8\"));\n\n horizontalLayout_8->setSizeConstraint(QLayout::SetDefaultConstraint);\n\n doomsDay2Button = new QPushButton(centralwidget);\n\n doomsDay2Button->setObjectName(QString::fromUtf8(\"doomsDay2Button\"));\n\n sizePolicy.setHeightForWidth(doomsDay2Button->sizePolicy().hasHeightForWidth());\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 18, "score": 25550.203219563668 }, { "content": " horizontalLayout_2->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_2);\n\n\n\n horizontalLayout_4 = new QHBoxLayout();\n\n horizontalLayout_4->setObjectName(QString::fromUtf8(\"horizontalLayout_4\"));\n\n horizontalLayout_4->setSizeConstraint(QLayout::SetDefaultConstraint);\n\n disconnectProcessButton = new QPushButton(centralwidget);\n\n disconnectProcessButton->setObjectName(QString::fromUtf8(\"disconnectProcessButton\"));\n\n sizePolicy.setHeightForWidth(disconnectProcessButton->sizePolicy().hasHeightForWidth());\n\n disconnectProcessButton->setSizePolicy(sizePolicy);\n\n disconnectProcessButton->setFont(font);\n\n disconnectProcessButton->setFocusPolicy(Qt::StrongFocus);\n\n disconnectProcessButton->setStyleSheet(QString::fromUtf8(\"background-color: rgb(23, 135, 6);\"));\n\n\n\n horizontalLayout_4->addWidget(disconnectProcessButton);\n\n\n\n lineEditDisconnectProcess = new QLineEdit(centralwidget);\n\n lineEditDisconnectProcess->setObjectName(QString::fromUtf8(\"lineEditDisconnectProcess\"));\n\n sizePolicy1.setHeightForWidth(lineEditDisconnectProcess->sizePolicy().hasHeightForWidth());\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 19, "score": 25550.195679911343 }, { "content": " lineEditSnack->setFont(font1);\n\n\n\n horizontalLayout->addWidget(lineEditSnack);\n\n\n\n horizontalLayout->setStretch(0, 1);\n\n horizontalLayout->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout);\n\n\n\n horizontalLayout_3 = new QHBoxLayout();\n\n horizontalLayout_3->setObjectName(QString::fromUtf8(\"horizontalLayout_3\"));\n\n horizontalLayout_3->setSizeConstraint(QLayout::SetDefaultConstraint);\n\n amorButton = new QPushButton(centralwidget);\n\n amorButton->setObjectName(QString::fromUtf8(\"amorButton\"));\n\n sizePolicy.setHeightForWidth(amorButton->sizePolicy().hasHeightForWidth());\n\n amorButton->setSizePolicy(sizePolicy);\n\n amorButton->setFont(font);\n\n amorButton->setFocusPolicy(Qt::StrongFocus);\n\n\n\n horizontalLayout_3->addWidget(amorButton);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 20, "score": 25550.05344826466 }, { "content": " sizePolicy2.setVerticalStretch(0);\n\n sizePolicy2.setHeightForWidth(pushButtonSave->sizePolicy().hasHeightForWidth());\n\n pushButtonSave->setSizePolicy(sizePolicy2);\n\n pushButtonSave->setFont(font);\n\n\n\n horizontalLayout_11->addWidget(pushButtonSave);\n\n\n\n pushButton_2 = new QPushButton(centralwidget);\n\n pushButton_2->setObjectName(QString::fromUtf8(\"pushButton_2\"));\n\n sizePolicy2.setHeightForWidth(pushButton_2->sizePolicy().hasHeightForWidth());\n\n pushButton_2->setSizePolicy(sizePolicy2);\n\n\n\n horizontalLayout_11->addWidget(pushButton_2);\n\n\n\n horizontalLayout_11->setStretch(0, 1);\n\n horizontalLayout_11->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_11);\n\n\n\n verticalSpacer = new QSpacerItem(20, 36, QSizePolicy::Minimum, QSizePolicy::Expanding);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 21, "score": 25550.05344826466 }, { "content": " doomsDay2Button->setSizePolicy(sizePolicy);\n\n doomsDay2Button->setFont(font);\n\n doomsDay2Button->setFocusPolicy(Qt::StrongFocus);\n\n\n\n horizontalLayout_8->addWidget(doomsDay2Button);\n\n\n\n lineEditDoomsDayII = new QLineEdit(centralwidget);\n\n lineEditDoomsDayII->setObjectName(QString::fromUtf8(\"lineEditDoomsDayII\"));\n\n sizePolicy1.setHeightForWidth(lineEditDoomsDayII->sizePolicy().hasHeightForWidth());\n\n lineEditDoomsDayII->setSizePolicy(sizePolicy1);\n\n lineEditDoomsDayII->setFont(font1);\n\n\n\n horizontalLayout_8->addWidget(lineEditDoomsDayII);\n\n\n\n horizontalLayout_8->setStretch(0, 1);\n\n horizontalLayout_8->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_8);\n\n\n\n horizontalLayout_7 = new QHBoxLayout();\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 22, "score": 25549.959930873683 }, { "content": " lineEditDisconnectProcess->setSizePolicy(sizePolicy1);\n\n lineEditDisconnectProcess->setFont(font1);\n\n\n\n horizontalLayout_4->addWidget(lineEditDisconnectProcess);\n\n\n\n horizontalLayout_4->setStretch(0, 1);\n\n horizontalLayout_4->setStretch(1, 1);\n\n\n\n mainlayout->addLayout(horizontalLayout_4);\n\n\n\n horizontalLayout_5 = new QHBoxLayout();\n\n horizontalLayout_5->setObjectName(QString::fromUtf8(\"horizontalLayout_5\"));\n\n horizontalLayout_5->setSizeConstraint(QLayout::SetDefaultConstraint);\n\n fingerPrintButton = new QPushButton(centralwidget);\n\n fingerPrintButton->setObjectName(QString::fromUtf8(\"fingerPrintButton\"));\n\n sizePolicy.setHeightForWidth(fingerPrintButton->sizePolicy().hasHeightForWidth());\n\n fingerPrintButton->setSizePolicy(sizePolicy);\n\n fingerPrintButton->setFont(font);\n\n fingerPrintButton->setFocusPolicy(Qt::StrongFocus);\n\n\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 23, "score": 25549.94227423583 }, { "content": " mainlayout->addWidget(labelInfo);\n\n\n\n mainlayout->setStretch(0, 1);\n\n mainlayout->setStretch(1, 1);\n\n mainlayout->setStretch(2, 1);\n\n mainlayout->setStretch(3, 1);\n\n mainlayout->setStretch(4, 1);\n\n mainlayout->setStretch(5, 1);\n\n mainlayout->setStretch(6, 1);\n\n mainlayout->setStretch(7, 1);\n\n mainlayout->setStretch(8, 1);\n\n mainlayout->setStretch(9, 1);\n\n mainlayout->setStretch(10, 1);\n\n mainlayout->setStretch(11, 1);\n\n\n\n rootlayout->addLayout(mainlayout);\n\n\n\n bottomlayout = new QHBoxLayout();\n\n bottomlayout->setObjectName(QString::fromUtf8(\"bottomlayout\"));\n\n\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 24, "score": 25549.854142574684 }, { "content": " sizePolicy.setHeightForWidth(luckyWheelButton->sizePolicy().hasHeightForWidth());\n\n luckyWheelButton->setSizePolicy(sizePolicy);\n\n luckyWheelButton->setFont(font);\n\n luckyWheelButton->setFocusPolicy(Qt::StrongFocus);\n\n\n\n horizontalLayout_6->addWidget(luckyWheelButton);\n\n\n\n lineEditLuckyWheel = new QLineEdit(centralwidget);\n\n lineEditLuckyWheel->setObjectName(QString::fromUtf8(\"lineEditLuckyWheel\"));\n\n sizePolicy1.setHeightForWidth(lineEditLuckyWheel->sizePolicy().hasHeightForWidth());\n\n lineEditLuckyWheel->setSizePolicy(sizePolicy1);\n\n lineEditLuckyWheel->setFont(font1);\n\n\n\n horizontalLayout_6->addWidget(lineEditLuckyWheel);\n\n\n\n labelLuckWheel = new QLabel(centralwidget);\n\n labelLuckWheel->setObjectName(QString::fromUtf8(\"labelLuckWheel\"));\n\n labelLuckWheel->setFont(font);\n\n\n\n horizontalLayout_6->addWidget(labelLuckWheel);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 25, "score": 25549.81205656967 }, { "content": " horizontalLayout_7->setObjectName(QString::fromUtf8(\"horizontalLayout_7\"));\n\n horizontalLayout_7->setSizeConstraint(QLayout::SetDefaultConstraint);\n\n doomsDay3Button = new QPushButton(centralwidget);\n\n doomsDay3Button->setObjectName(QString::fromUtf8(\"doomsDay3Button\"));\n\n sizePolicy.setHeightForWidth(doomsDay3Button->sizePolicy().hasHeightForWidth());\n\n doomsDay3Button->setSizePolicy(sizePolicy);\n\n doomsDay3Button->setFont(font);\n\n doomsDay3Button->setFocusPolicy(Qt::StrongFocus);\n\n\n\n horizontalLayout_7->addWidget(doomsDay3Button);\n\n\n\n lineEditDoomsDayIII = new QLineEdit(centralwidget);\n\n lineEditDoomsDayIII->setObjectName(QString::fromUtf8(\"lineEditDoomsDayIII\"));\n\n sizePolicy1.setHeightForWidth(lineEditDoomsDayIII->sizePolicy().hasHeightForWidth());\n\n lineEditDoomsDayIII->setSizePolicy(sizePolicy1);\n\n lineEditDoomsDayIII->setFont(font1);\n\n\n\n horizontalLayout_7->addWidget(lineEditDoomsDayIII);\n\n\n\n horizontalLayout_7->setStretch(0, 1);\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 26, "score": 25549.679123929003 }, { "content": " QLabel *labelLuckWheel;\n\n QLineEdit *lineEditLuckyWheelInteval;\n\n QHBoxLayout *horizontalLayout_8;\n\n QPushButton *doomsDay2Button;\n\n QLineEdit *lineEditDoomsDayII;\n\n QHBoxLayout *horizontalLayout_7;\n\n QPushButton *doomsDay3Button;\n\n QLineEdit *lineEditDoomsDayIII;\n\n QHBoxLayout *horizontalLayout;\n\n QPushButton *snackButton;\n\n QLineEdit *lineEditSnack;\n\n QHBoxLayout *horizontalLayout_3;\n\n QPushButton *amorButton;\n\n QLineEdit *lineEditArmor;\n\n QHBoxLayout *horizontalLayout_11;\n\n QPushButton *pushButtonSave;\n\n QPushButton *pushButton_2;\n\n QSpacerItem *verticalSpacer;\n\n QLabel *labelPrompt;\n\n QLabel *labelInfo;\n", "file_path": "PlayTools/ui_mainwindow.h", "rank": 27, "score": 25548.067146302317 }, { "content": "#include <Windows.h>\n\n#include \"AutoMate.h\"\n\n#include <QKeyEvent>\n\n#include <QCoreApplication>\n\n\n\n#include \"mainwindow.h\"\n\n\n\n// \n\nstatic const int KEY_PRESS_INTERVAL = 300;\n\n\n\nAutoMate::AutoMate():m_MainWindow(nullptr)\n\n{\n\n\n\n}\n\n\n\n\n\nAutoMate::~AutoMate()\n\n{\n\n}\n\n\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 28, "score": 24327.17434815405 }, { "content": "}\n\n\n\nvoid AutoMate::KeyUp(WORD keyCode)\n\n{\n\n\tKeyPress(keyCode, true);\n\n}\n\n\n\nvoid AutoMate::KeyClick(WORD keyCode)\n\n{\n\n\tKeyPress(keyCode);\n\n\tSleep(100);\n\n\tKeyPress(keyCode, true);\n\n}\n\n\n\nvoid AutoMate::SendTestCommand()\n\n{\n\n\tSleep(KEY_PRESS_INTERVAL);\n\n\n\n\tint sleepTime = 100;\n\n\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 29, "score": 24326.22542566198 }, { "content": "\n\nvoid AutoMate::SendDoomsDayIIICmd()\n\n{\n\n\tSleep(KEY_PRESS_INTERVAL);\n\n\n\n\tKeyDown(VK_SPACE);\n\n\tSleep(60);\n\n\tKeyDown('D');\n\n\tSleep(20);\n\n\tKeyDown('S');\n\n\tSleep(20);\n\n\tKeyUp(VK_SPACE);\n\n\tSleep(40);\n\n\tKeyUp('D');\n\n\tSleep(20);\n\n\tKeyUp('S');\n\n}\n\n\n\nvoid AutoMate::SendLuckyWheelCmd(int millisec)\n\n{\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 30, "score": 24322.614790764186 }, { "content": "void AutoMate::SetWindow(QObject* qObj)\n\n{\n\n\tm_MainWindow = qObj;\n\n}\n\n\n\n\n\n\n\nvoid AutoMate::SendSnackCmd()\n\n{\n\n\t//keybd_event(VK_TAB, 0, 0, 0);\n\n\t//keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);\n\n\n\n\t//keybd_event(VK_LSHIFT, 0, 0, 0);\n\n\t//keybd_event('M', 0, 0, 0);\n\n\n\n\t//keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);\n\n\t//keybd_event('M', 0, KEYEVENTF_KEYUP, 0);\n\n\n\n\t//// press down ctrl+A at the same time\n\n\t//keybd_event(VK_CONTROL, 0, 0, 0);\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 31, "score": 24322.108782016112 }, { "content": "\tSleep(KEY_PRESS_INTERVAL);\n\n\n\n\tKeyClick('E');\n\n\tSleep(millisec);\n\n\tKeyClick('S');\n\n}\n\n\n\nvoid AutoMate::SendFingerPrintCmd()\n\n{\n\n}\n\n\n\nvoid AutoMate::KeyPress(WORD keyCode, bool bUp /*= false*/)\n\n{\n\n\tINPUT input;\n\n\tmemset(&input, 0, sizeof(input));\n\n\n\n\tinput.type = INPUT_KEYBOARD;\n\n\tinput.ki.dwExtraInfo = GetMessageExtraInfo();\n\n\t// for DirectInput App, use scan code instead of Virtual code\n\n\tinput.ki.wScan = static_cast<WORD>(MapVirtualKeyEx(keyCode, MAPVK_VK_TO_VSC, GetKeyboardLayout(0)));\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 32, "score": 24321.45448002296 }, { "content": "\n\n\tfor (size_t i = 0; i < ARRAYSIZE(keySeq); i++)\n\n\t{\n\n\t\tKeyClick(keySeq[i]);\n\n\t\tSleep(50);\n\n\t}\n\n}\n\n\n\nvoid AutoMate::SendDoomsDayIICmd()\n\n{\n\n\tSleep(KEY_PRESS_INTERVAL);\n\n\n\n\tKeyDown(VK_SPACE);\n\n\tSleep(500);\n\n\tKeyDown('D');\n\n\tSleep(30);\n\n\tKeyUp(VK_SPACE);\n\n\tSleep(10);\n\n\tKeyUp('D');\n\n}\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 33, "score": 24321.281571140767 }, { "content": "\t//keybd_event('A', 0, 0, 0);\n\n\n\n\t//Sleep(KEY_PRESS_INTERVAL);\n\n\n\n\t//// press up ctrl+A at the same time\n\n\t//keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);\n\n\t//keybd_event('A', 0, KEYEVENTF_KEYUP, 0);\n\n\n\n\tSleep(KEY_PRESS_INTERVAL);\n\n\n\n\tWORD keySeq[] = { 'M', VK_DOWN, VK_DOWN, VK_RETURN, VK_DOWN, VK_DOWN, VK_RETURN, VK_RETURN, VK_ESCAPE, VK_ESCAPE, VK_ESCAPE };\n\n\n\n\tfor (size_t i = 0; i < ARRAYSIZE(keySeq); i++)\n\n\t{\n\n\t\tKeyClick(keySeq[i]);\n\n\t\tSleep(50);\n\n\t}\t\n\n}\n\n\n\nvoid AutoMate::SendArmorCmd()\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 34, "score": 24320.325305477665 }, { "content": "\t// Specifies various aspects of a keystroke.This member can be certain combinations of the following values.\n\n\tDWORD dwFlags = KEYEVENTF_SCANCODE;\n\n\tif (bUp)\n\n\t{\n\n\t\tdwFlags |= KEYEVENTF_KEYUP;\n\n\t}\n\n\tif (VK_LEFT<=keyCode&&keyCode<=VK_DOWN)\n\n\t{\n\n\t\tdwFlags |= KEYEVENTF_EXTENDEDKEY;\n\n\t}\n\n\tinput.ki.dwFlags = dwFlags;\n\n\t// The time stamp for the event, in milliseconds. If this parameter is zero, the system will provide its own time stamp.\n\n\tinput.ki.time = 0;\n\n\n\n\tSendInput(1, &input, sizeof(INPUT));\n\n}\n\n\n\nvoid AutoMate::KeyDown(WORD keyCode)\n\n{\n\n\tKeyPress(keyCode);\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 35, "score": 24320.091208424983 }, { "content": "\tWORD key = 'W';\n\n\tfor (int i = 0; i < 5; i++)\n\n\t{\n\n\t\tKeyPress(key);\n\n\t\tSleep(sleepTime);\n\n\t\tKeyPress(key, true);\n\n\t\tSleep(sleepTime);\n\n\t}\n\n\t\n\n\tkey = 'A';\n\n\tKeyPress(key);\n\n\tSleep(sleepTime);\n\n\tKeyPress(key, true);\n\n\t\n\n}\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 36, "score": 24320.008683259388 }, { "content": "{\n\n\t//QKeyEvent keyTab(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);\n\n\t//QKeyEvent keyM(QEvent::KeyPress, Qt::Key_M, Qt::ShiftModifier);\n\n\n\n\t//QCoreApplication::sendEvent(m_MainWindow, &keyTab);\n\n\t//QCoreApplication::sendEvent(m_MainWindow, &keyM);\n\n\n\n\t//WORD tab = VK_TAB;\n\n\t//SendKeyInput(&tab, 1);\n\n\n\n\t//WORD combine[2] = { VK_LSHIFT, 'K' };\n\n\t//SendKeyInput(combine, 2);\n\n\n\n\t//WORD combine2[2] = { VK_CONTROL, 'A' };\n\n\t//SendKeyInput(combine2, 2);\n\n\n\n\tSleep(KEY_PRESS_INTERVAL);\n\n\n\n\tWORD keySeq[] = { 'M', VK_DOWN, VK_DOWN, VK_RETURN, VK_DOWN, VK_RETURN, \n\n\t\tVK_DOWN, VK_DOWN, VK_DOWN, VK_DOWN, VK_RETURN, VK_ESCAPE, VK_ESCAPE, VK_ESCAPE };\n", "file_path": "PlayTools/AutoMate.cpp", "rank": 37, "score": 24316.799613428193 }, { "content": "class AutoMate;\n", "file_path": "PlayTools/mainwindow.h", "rank": 38, "score": 24316.799613428193 }, { "content": "\tprivate:\n\n\t\tbool valid;\n\n\t};\n\n\n\n\t//! Constructor\n\n\texplicit QHotkey(QObject *parent = Q_NULLPTR);\n\n\t//! Constructs a hotkey with a shortcut and optionally registers it\n\n\texplicit QHotkey(const QKeySequence &shortcut, bool autoRegister = false, QObject *parent = Q_NULLPTR);\n\n\t//! Constructs a hotkey with a key and modifiers and optionally registers it\n\n\texplicit QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false, QObject *parent = Q_NULLPTR);\n\n\t//! Constructs a hotkey from a native shortcut and optionally registers it\n\n\texplicit QHotkey(const NativeShortcut &shortcut, bool autoRegister = false, QObject *parent = Q_NULLPTR);\n\n\t//! Destructor\n\n\t~QHotkey();\n\n\n\n\t//! READ-Accessor for QHotkey::registered\n\n\tbool isRegistered() const;\n\n\t//! READ-Accessor for QHotkey::shortcut - the key and modifiers as a QKeySequence\n\n\tQKeySequence shortcut() const;\n\n\t//! READ-Accessor for QHotkey::shortcut - the key only\n", "file_path": "PlayTools/QHotkey/qhotkey.h", "rank": 39, "score": 23337.978811635025 }, { "content": "#ifndef QHOTKEY_P_H\n\n#define QHOTKEY_P_H\n\n\n\n#include \"qhotkey.h\"\n\n#include <QAbstractNativeEventFilter>\n\n#include <QMultiHash>\n\n#include <QMutex>\n\n#include <QGlobalStatic>\n\n\n", "file_path": "PlayTools/QHotkey/qhotkey_p.h", "rank": 40, "score": 23337.681059954724 }, { "content": "#ifndef QHOTKEY_H\n\n#define QHOTKEY_H\n\n\n\n#include <QObject>\n\n#include <QKeySequence>\n\n#include <QPair>\n\n#include <QLoggingCategory>\n\n\n\n#ifdef QHOTKEY_LIB\n\n\t#ifdef QHOTKEY_LIB_BUILD\n\n\t\t#define QHOTKEY_SHARED_EXPORT Q_DECL_EXPORT\n\n\t#else\n\n\t\t#define QHOTKEY_SHARED_EXPORT Q_DECL_IMPORT\n\n\t#endif\n\n#else\n\n\t#define QHOTKEY_SHARED_EXPORT\n\n#endif\n\n\n\n//! A class to define global, systemwide Hotkeys\n", "file_path": "PlayTools/QHotkey/qhotkey.h", "rank": 41, "score": 23337.47095158966 }, { "content": "\n\nsignals:\n\n\t//! Will be emitted if the shortcut is pressed\n\n\tvoid activated(QPrivateSignal);\n\n\n\n\t//! NOTIFY-Accessor for QHotkey::registered\n\n\tvoid registeredChanged(bool registered);\n\n\n\nprivate:\n\n\tQt::Key _keyCode;\n\n\tQt::KeyboardModifiers _modifiers;\n\n\n\n\tNativeShortcut _nativeShortcut;\n\n\tbool _registered;\n\n};\n\n\n\nuint QHOTKEY_SHARED_EXPORT qHash(const QHotkey::NativeShortcut &key);\n\nuint QHOTKEY_SHARED_EXPORT qHash(const QHotkey::NativeShortcut &key, uint seed);\n\n\n\nQHOTKEY_SHARED_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey)\n\n\n\n#endif // QHOTKEY_H\n", "file_path": "PlayTools/QHotkey/qhotkey.h", "rank": 42, "score": 23335.56704063341 }, { "content": "\tQt::Key keyCode() const;\n\n\t//! READ-Accessor for QHotkey::shortcut - the modifiers only\n\n\tQt::KeyboardModifiers modifiers() const;\n\n\n\n\t//! Get the current native shortcut\n\n\tNativeShortcut currentNativeShortcut() const;\n\n\n\npublic slots:\n\n\t//! WRITE-Accessor for QHotkey::registered\n\n\tbool setRegistered(bool registered);\n\n\n\n\t//! WRITE-Accessor for QHotkey::shortcut\n\n\tbool setShortcut(const QKeySequence &shortcut, bool autoRegister = false);\n\n\t//! WRITE-Accessor for QHotkey::shortcut\n\n\tbool setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false);\n\n\t//! RESET-Accessor for QHotkey::shortcut\n\n\tbool resetShortcut();\n\n\n\n\t//! Set this hotkey to a native shortcut\n\n\tbool setNativeShortcut(NativeShortcut nativeShortcut, bool autoRegister = false);\n", "file_path": "PlayTools/QHotkey/qhotkey.h", "rank": 43, "score": 23332.443711074768 }, { "content": "\n\n\tvirtual bool registerShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement\n\n\tvirtual bool unregisterShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement\n\n\n\nprivate:\n\n\tQMultiHash<QHotkey::NativeShortcut, QHotkey*> shortcuts;\n\n\n\n\tQ_INVOKABLE bool addShortcutInvoked(QHotkey *hotkey);\n\n\tQ_INVOKABLE bool removeShortcutInvoked(QHotkey *hotkey);\n\n\tQ_INVOKABLE QHotkey::NativeShortcut nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers);\n\n};\n\n\n\n#define NATIVE_INSTANCE(ClassName) \\\n\n\tQ_GLOBAL_STATIC(ClassName, hotkeyPrivate) \\\n\n\t\\\n\n\tQHotkeyPrivate *QHotkeyPrivate::instance()\\\n\n\t{\\\n\n\t\treturn hotkeyPrivate;\\\n\n\t}\n\n\n\n#endif // QHOTKEY_P_H\n", "file_path": "PlayTools/QHotkey/qhotkey_p.h", "rank": 44, "score": 23331.28458441044 }, { "content": "class QObject;\n\n\n", "file_path": "PlayTools/AutoMate.h", "rank": 45, "score": 22945.935776324022 }, { "content": "#include \"qhotkey.h\"\n\n#include \"qhotkey_p.h\"\n\n#include <QCoreApplication>\n\n#include <QAbstractEventDispatcher>\n\n#include <QMetaMethod>\n\n#include <QThread>\n\n#include <QDebug>\n\n\n\nQ_LOGGING_CATEGORY(logQHotkey, \"QHotkey\")\n\n\n\nQHotkey::QHotkey(QObject *parent) :\n\n\tQObject(parent),\n\n\t_keyCode(Qt::Key_unknown),\n\n\t_modifiers(Qt::NoModifier),\n\n\t_nativeShortcut(),\n\n\t_registered(false)\n\n{}\n\n\n\nQHotkey::QHotkey(const QKeySequence &sequence, bool autoRegister, QObject *parent) :\n\n\tQHotkey(parent)\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 46, "score": 22025.80373232384 }, { "content": "{\n\n\tsetShortcut(sequence, autoRegister);\n\n}\n\n\n\nQHotkey::QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister, QObject *parent) :\n\n\tQHotkey(parent)\n\n{\n\n\tsetShortcut(keyCode, modifiers, autoRegister);\n\n}\n\n\n\nQHotkey::QHotkey(const QHotkey::NativeShortcut &shortcut, bool autoRegister, QObject *parent) :\n\n\tQHotkey(parent)\n\n{\n\n\tsetNativeShortcut(shortcut, autoRegister);\n\n}\n\n\n\nQHotkey::~QHotkey()\n\n{\n\n\tif(_registered)\n\n\t\tQHotkeyPrivate::instance()->removeShortcut(this);\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 47, "score": 22021.40591971448 }, { "content": "\t\t\tQt::KeyboardModifiers(shortcut[0] & Qt::KeyboardModifierMask),\n\n\t\t\tautoRegister);\n\n}\n\n\n\nbool QHotkey::setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister)\n\n{\n\n\tif(_registered) {\n\n\t\tif(autoRegister) {\n\n\t\t\tif(!QHotkeyPrivate::instance()->removeShortcut(this))\n\n\t\t\t\treturn false;\n\n\t\t} else\n\n\t\t\treturn false;\n\n\t}\n\n\n\n\tif(keyCode == Qt::Key_unknown) {\n\n\t\t_keyCode = Qt::Key_unknown;\n\n\t\t_modifiers = Qt::NoModifier;\n\n\t\t_nativeShortcut = NativeShortcut();\n\n\t\treturn true;\n\n\t}\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 48, "score": 22019.562718121564 }, { "content": "\n\n\tif(nativeShortcut.isValid()) {\n\n\t\t_keyCode = Qt::Key_unknown;\n\n\t\t_modifiers = Qt::NoModifier;\n\n\t\t_nativeShortcut = nativeShortcut;\n\n\t\tif(autoRegister)\n\n\t\t\treturn QHotkeyPrivate::instance()->addShortcut(this);\n\n\t\telse\n\n\t\t\treturn true;\n\n\t} else {\n\n\t\t_keyCode = Qt::Key_unknown;\n\n\t\t_modifiers = Qt::NoModifier;\n\n\t\t_nativeShortcut = NativeShortcut();\n\n\t\treturn true;\n\n\t}\n\n}\n\n\n\nbool QHotkey::setRegistered(bool registered)\n\n{\n\n\tif(_registered && !registered)\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 49, "score": 22019.429811291455 }, { "content": "\tif(_registered &&\n\n\t !QHotkeyPrivate::instance()->removeShortcut(this)) {\n\n\t\treturn false;\n\n\t}\n\n\n\n\t_keyCode = Qt::Key_unknown;\n\n\t_modifiers = Qt::NoModifier;\n\n\t_nativeShortcut = NativeShortcut();\n\n\treturn true;\n\n}\n\n\n\nbool QHotkey::setNativeShortcut(QHotkey::NativeShortcut nativeShortcut, bool autoRegister)\n\n{\n\n\tif(_registered) {\n\n\t\tif(autoRegister) {\n\n\t\t\tif(!QHotkeyPrivate::instance()->removeShortcut(this))\n\n\t\t\t\treturn false;\n\n\t\t} else\n\n\t\t\treturn false;\n\n\t}\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 50, "score": 22019.392114987248 }, { "content": "\n\n\t_keyCode = keyCode;\n\n\t_modifiers = modifiers;\n\n\t_nativeShortcut = QHotkeyPrivate::instance()->nativeShortcut(keyCode, modifiers);\n\n\tif(_nativeShortcut.isValid()) {\n\n\t\tif(autoRegister)\n\n\t\t\treturn QHotkeyPrivate::instance()->addShortcut(this);\n\n\t\telse\n\n\t\t\treturn true;\n\n\t} else {\n\n\t\tqCWarning(logQHotkey) << \"Unable to map shortcut to native keys. Key:\" << keyCode << \"Modifiers:\" << modifiers;\n\n\t\t_keyCode = Qt::Key_unknown;\n\n\t\t_modifiers = Qt::NoModifier;\n\n\t\t_nativeShortcut = NativeShortcut();\n\n\t\treturn false;\n\n\t}\n\n}\n\n\n\nbool QHotkey::resetShortcut()\n\n{\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 51, "score": 22018.066587381203 }, { "content": "\tshortcuts.insert(shortcut, hotkey);\n\n\thotkey->_registered = true;\n\n\treturn true;\n\n}\n\n\n\nbool QHotkeyPrivate::removeShortcutInvoked(QHotkey *hotkey)\n\n{\n\n\tQHotkey::NativeShortcut shortcut = hotkey->_nativeShortcut;\n\n\n\n\tif(shortcuts.remove(shortcut, hotkey) == 0)\n\n\t\treturn false;\n\n\thotkey->_registered = false;\n\n\temit hotkey->registeredChanged(true);\n\n\tif(shortcuts.count(shortcut) == 0)\n\n\t\treturn unregisterShortcut(shortcut);\n\n\telse\n\n\t\treturn true;\n\n}\n\n\n\nQHotkey::NativeShortcut QHotkeyPrivate::nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers)\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 52, "score": 22017.919077308954 }, { "content": "{\n\n\tbool ok1, ok2 = false;\n\n\tauto k = nativeKeycode(keycode, ok1);\n\n\tauto m = nativeModifiers(modifiers, ok2);\n\n\tif(ok1 && ok2)\n\n\t\treturn {k, m};\n\n\telse\n\n\t\treturn {};\n\n}\n\n\n\n\n\n\n\nQHotkey::NativeShortcut::NativeShortcut() :\n\n\tkey(),\n\n\tmodifier(),\n\n\tvalid(false)\n\n{}\n\n\n\nQHotkey::NativeShortcut::NativeShortcut(quint32 key, quint32 modifier) :\n\n\tkey(key),\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 53, "score": 22017.612077618312 }, { "content": "\tmodifier(modifier),\n\n\tvalid(true)\n\n{}\n\n\n\nbool QHotkey::NativeShortcut::isValid() const\n\n{\n\n\treturn valid;\n\n}\n\n\n\nbool QHotkey::NativeShortcut::operator ==(const QHotkey::NativeShortcut &other) const\n\n{\n\n\treturn (key == other.key) &&\n\n\t\t (modifier == other.modifier) &&\n\n\t\t valid == other.valid;\n\n}\n\n\n\nbool QHotkey::NativeShortcut::operator !=(const QHotkey::NativeShortcut &other) const\n\n{\n\n\treturn (key != other.key) ||\n\n\t\t (modifier != other.modifier) ||\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 54, "score": 22016.726845184043 }, { "content": "\t\treturn QHotkeyPrivate::instance()->removeShortcut(this);\n\n\telse if(!_registered && registered) {\n\n\t\tif(!_nativeShortcut.isValid())\n\n\t\t\treturn false;\n\n\t\telse\n\n\t\t\treturn QHotkeyPrivate::instance()->addShortcut(this);\n\n\t} else\n\n\t\treturn true;\n\n}\n\n\n\n\n\n\n\n// ---------- QHotkeyPrivate implementation ----------\n\n\n\nQHotkeyPrivate::QHotkeyPrivate() :\n\n\tshortcuts()\n\n{\n\n\tQ_ASSERT_X(qApp, Q_FUNC_INFO, \"QHotkey requires QCoreApplication to be instantiated\");\n\n\tqApp->eventDispatcher()->installNativeEventFilter(this);\n\n}\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 55, "score": 22016.528679771745 }, { "content": "QHotkey::NativeShortcut QHotkey::currentNativeShortcut() const\n\n{\n\n\treturn _nativeShortcut;\n\n}\n\n\n\nbool QHotkey::isRegistered() const\n\n{\n\n\treturn _registered;\n\n}\n\n\n\nbool QHotkey::setShortcut(const QKeySequence &shortcut, bool autoRegister)\n\n{\n\n\tif(shortcut.isEmpty()) {\n\n\t\treturn resetShortcut();\n\n\t} else if(shortcut.count() > 1) {\n\n\t\tqCWarning(logQHotkey, \"Keysequences with multiple shortcuts are not allowed! \"\n\n\t\t\t\t\t\t\t \"Only the first shortcut will be used!\");\n\n\t}\n\n\n\n\treturn setShortcut(Qt::Key(shortcut[0] & ~Qt::KeyboardModifierMask),\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 56, "score": 22016.446279582375 }, { "content": "\t} else\n\n\t\treturn res;\n\n}\n\n\n\nbool QHotkeyPrivate::addShortcut(QHotkey *hotkey)\n\n{\n\n\tif(hotkey->_registered)\n\n\t\treturn false;\n\n\n\n\tQt::ConnectionType conType = (QThread::currentThread() == thread() ?\n\n\t\t\t\t\t\t\t\t\t Qt::DirectConnection :\n\n\t\t\t\t\t\t\t\t\t Qt::BlockingQueuedConnection);\n\n\tbool res = false;\n\n\tif(!QMetaObject::invokeMethod(this, \"addShortcutInvoked\", conType,\n\n\t\t\t\t\t\t\t\t Q_RETURN_ARG(bool, res),\n\n\t\t\t\t\t\t\t\t Q_ARG(QHotkey*, hotkey))) {\n\n\t\treturn false;\n\n\t} else {\n\n\t\tif(res)\n\n\t\t\temit hotkey->registeredChanged(true);\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 57, "score": 22016.379929397575 }, { "content": "\t\treturn res;\n\n\t}\n\n}\n\n\n\nvoid QHotkeyPrivate::activateShortcut(QHotkey::NativeShortcut shortcut)\n\n{\n\n\tQMetaMethod signal = QMetaMethod::fromSignal(&QHotkey::activated);\n\n\tfor(QHotkey *hkey : shortcuts.values(shortcut))\n\n\t\tsignal.invoke(hkey, Qt::QueuedConnection);\n\n}\n\n\n\nbool QHotkeyPrivate::addShortcutInvoked(QHotkey *hotkey)\n\n{\n\n\tQHotkey::NativeShortcut shortcut = hotkey->_nativeShortcut;\n\n\n\n\tif(!shortcuts.contains(shortcut)) {\n\n\t\tif(!registerShortcut(shortcut))\n\n\t\t\treturn false;\n\n\t}\n\n\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 58, "score": 22016.3539882985 }, { "content": "\t\t valid != other.valid;\n\n}\n\n\n\nuint qHash(const QHotkey::NativeShortcut &key)\n\n{\n\n\treturn qHash(key.key) ^ qHash(key.modifier);\n\n}\n\n\n\nuint qHash(const QHotkey::NativeShortcut &key, uint seed)\n\n{\n\n\treturn qHash(key.key, seed) ^ qHash(key.modifier, seed);\n\n}\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 59, "score": 22014.636467450335 }, { "content": "}\n\n\n\nQKeySequence QHotkey::shortcut() const\n\n{\n\n\tif(_keyCode == Qt::Key_unknown)\n\n\t\treturn QKeySequence();\n\n\telse\n\n\t\treturn QKeySequence(_keyCode | _modifiers);\n\n}\n\n\n\nQt::Key QHotkey::keyCode() const\n\n{\n\n\treturn _keyCode;\n\n}\n\n\n\nQt::KeyboardModifiers QHotkey::modifiers() const\n\n{\n\n\treturn _modifiers;\n\n}\n\n\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 60, "score": 22014.636467450335 }, { "content": "\t\treturn res;\n\n\t}\n\n}\n\n\n\nbool QHotkeyPrivate::removeShortcut(QHotkey *hotkey)\n\n{\n\n\tif(!hotkey->_registered)\n\n\t\treturn false;\n\n\n\n\tQt::ConnectionType conType = (QThread::currentThread() == thread() ?\n\n\t\t\t\t\t\t\t\t\t Qt::DirectConnection :\n\n\t\t\t\t\t\t\t\t\t Qt::BlockingQueuedConnection);\n\n\tbool res = false;\n\n\tif(!QMetaObject::invokeMethod(this, \"removeShortcutInvoked\", conType,\n\n\t\t\t\t\t\t\t\t Q_RETURN_ARG(bool, res),\n\n\t\t\t\t\t\t\t\t Q_ARG(QHotkey*, hotkey))) {\n\n\t\treturn false;\n\n\t} else {\n\n\t\tif(res)\n\n\t\t\temit hotkey->registeredChanged(false);\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 61, "score": 22014.636467450335 }, { "content": "\n\nQHotkeyPrivate::~QHotkeyPrivate()\n\n{\n\n\tif(!shortcuts.isEmpty())\n\n\t\tqCWarning(logQHotkey) << \"QHotkeyPrivate destroyed with registered shortcuts!\";\n\n\tif(qApp && qApp->eventDispatcher())\n\n\t\tqApp->eventDispatcher()->removeNativeEventFilter(this);\n\n}\n\n\n\nQHotkey::NativeShortcut QHotkeyPrivate::nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers)\n\n{\n\n\tQt::ConnectionType conType = (QThread::currentThread() == thread() ?\n\n\t\t\t\t\t\t\t\t\t Qt::DirectConnection :\n\n\t\t\t\t\t\t\t\t\t Qt::BlockingQueuedConnection);\n\n\tQHotkey::NativeShortcut res;\n\n\tif(!QMetaObject::invokeMethod(this, \"nativeShortcutInvoked\", conType,\n\n\t\t\t\t\t\t\t\t Q_RETURN_ARG(QHotkey::NativeShortcut, res),\n\n\t\t\t\t\t\t\t\t Q_ARG(Qt::Key, keycode),\n\n\t\t\t\t\t\t\t\t Q_ARG(Qt::KeyboardModifiers, modifiers))) {\n\n\t\treturn QHotkey::NativeShortcut();\n", "file_path": "PlayTools/QHotkey/qhotkey.cpp", "rank": 62, "score": 22014.636467450335 }, { "content": "#include \"qhotkey.h\"\n\n#include \"qhotkey_p.h\"\n\n#include <qt_windows.h>\n\n#include <QDebug>\n\n\n\n#define HKEY_ID(nativeShortcut) (((nativeShortcut.key ^ (nativeShortcut.modifier << 8)) & 0x0FFF) | 0x7000)\n\n\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 63, "score": 20847.195006407463 }, { "content": "\tswitch (keycode)\n\n\t{\n\n\tcase Qt::Key_Escape:\n\n\t\treturn VK_ESCAPE;\n\n\tcase Qt::Key_Tab:\n\n\tcase Qt::Key_Backtab:\n\n\t\treturn VK_TAB;\n\n\tcase Qt::Key_Backspace:\n\n\t\treturn VK_BACK;\n\n\tcase Qt::Key_Return:\n\n\tcase Qt::Key_Enter:\n\n\t\treturn VK_RETURN;\n\n\tcase Qt::Key_Insert:\n\n\t\treturn VK_INSERT;\n\n\tcase Qt::Key_Delete:\n\n\t\treturn VK_DELETE;\n\n\tcase Qt::Key_Pause:\n\n\t\treturn VK_PAUSE;\n\n\tcase Qt::Key_Print:\n\n\t\treturn VK_PRINT;\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 64, "score": 20842.453123250096 }, { "content": "\t\t\t\t\t\t\t HKEY_ID(shortcut),\n\n\t\t\t\t\t\t\t shortcut.modifier,\n\n\t\t\t\t\t\t\t shortcut.key);\n\n\tif(ok)\n\n\t\treturn true;\n\n\telse {\n\n\t\tqCWarning(logQHotkey) << \"Failed to register hotkey. Error:\"\n\n\t\t\t\t\t\t\t << qPrintable(QHotkeyPrivateWin::formatWinError(::GetLastError()));\n\n\t\treturn false;\n\n\t}\n\n}\n\n\n\nbool QHotkeyPrivateWin::unregisterShortcut(QHotkey::NativeShortcut shortcut)\n\n{\n\n\tBOOL ok = UnregisterHotKey(NULL, HKEY_ID(shortcut));\n\n\tif(ok)\n\n\t\treturn true;\n\n\telse {\n\n\t\tqCWarning(logQHotkey) << \"Failed to unregister hotkey. Error:\"\n\n\t\t\t\t\t\t\t << qPrintable(QHotkeyPrivateWin::formatWinError(::GetLastError()));\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 65, "score": 20842.14627208188 }, { "content": "}\n\n\n\nquint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)\n\n{\n\n\tquint32 nMods = 0;\n\n\tif (modifiers & Qt::ShiftModifier)\n\n\t\tnMods |= MOD_SHIFT;\n\n\tif (modifiers & Qt::ControlModifier)\n\n\t\tnMods |= MOD_CONTROL;\n\n\tif (modifiers & Qt::AltModifier)\n\n\t\tnMods |= MOD_ALT;\n\n\tif (modifiers & Qt::MetaModifier)\n\n\t\tnMods |= MOD_WIN;\n\n\tok = true;\n\n\treturn nMods;\n\n}\n\n\n\nbool QHotkeyPrivateWin::registerShortcut(QHotkey::NativeShortcut shortcut)\n\n{\n\n\tBOOL ok = RegisterHotKey(NULL,\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 66, "score": 20841.47427882736 }, { "content": "\tQ_UNUSED(eventType);\n\n\tQ_UNUSED(result);\n\n\n\n\tMSG* msg = static_cast<MSG*>(message);\n\n\tif(msg->message == WM_HOTKEY)\n\n\t\tthis->activateShortcut({HIWORD(msg->lParam), LOWORD(msg->lParam)});\n\n\n\n\treturn false;\n\n}\n\n\n\nquint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode, bool &ok)\n\n{\n\n\tok = true;\n\n\tif(keycode <= 0xFFFF) {//Try to obtain the key from it's \"character\"\n\n\t\tconst SHORT vKey = VkKeyScanW(keycode);\n\n\t\tif(vKey > -1)\n\n\t\t\treturn LOBYTE(vKey);\n\n\t}\n\n\n\n\t//find key from switch/case --> Only finds a very small subset of keys\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 67, "score": 20841.47427882736 }, { "content": "\tcase Qt::Key_Clear:\n\n\t\treturn VK_CLEAR;\n\n\tcase Qt::Key_Home:\n\n\t\treturn VK_HOME;\n\n\tcase Qt::Key_End:\n\n\t\treturn VK_END;\n\n\tcase Qt::Key_Left:\n\n\t\treturn VK_LEFT;\n\n\tcase Qt::Key_Up:\n\n\t\treturn VK_UP;\n\n\tcase Qt::Key_Right:\n\n\t\treturn VK_RIGHT;\n\n\tcase Qt::Key_Down:\n\n\t\treturn VK_DOWN;\n\n\tcase Qt::Key_PageUp:\n\n\t\treturn VK_PRIOR;\n\n\tcase Qt::Key_PageDown:\n\n\t\treturn VK_NEXT;\n\n\tcase Qt::Key_CapsLock:\n\n\t\treturn VK_CAPITAL;\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 68, "score": 20839.789674617685 }, { "content": "\tcase Qt::Key_MediaPrevious:\n\n\t\treturn VK_MEDIA_PREV_TRACK;\n\n\tcase Qt::Key_MediaPlay:\n\n\t\treturn VK_MEDIA_PLAY_PAUSE;\n\n\tcase Qt::Key_MediaStop:\n\n\t\treturn VK_MEDIA_STOP;\n\n\tcase Qt::Key_VolumeDown:\n\n\t\treturn VK_VOLUME_DOWN;\n\n\tcase Qt::Key_VolumeUp:\n\n\t\treturn VK_VOLUME_UP;\n\n\tcase Qt::Key_VolumeMute:\n\n\t\treturn VK_VOLUME_MUTE;\n\n\tcase Qt::Key_Mode_switch:\n\n\t\treturn VK_MODECHANGE;\n\n\tcase Qt::Key_Select:\n\n\t\treturn VK_SELECT;\n\n\tcase Qt::Key_Printer:\n\n\t\treturn VK_PRINT;\n\n\tcase Qt::Key_Execute:\n\n\t\treturn VK_EXECUTE;\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 69, "score": 20839.789674617685 }, { "content": "\tcase Qt::Key_NumLock:\n\n\t\treturn VK_NUMLOCK;\n\n\tcase Qt::Key_ScrollLock:\n\n\t\treturn VK_SCROLL;\n\n\n\n\tcase Qt::Key_F1:\n\n\t\treturn VK_F1;\n\n\tcase Qt::Key_F2:\n\n\t\treturn VK_F2;\n\n\tcase Qt::Key_F3:\n\n\t\treturn VK_F3;\n\n\tcase Qt::Key_F4:\n\n\t\treturn VK_F4;\n\n\tcase Qt::Key_F5:\n\n\t\treturn VK_F5;\n\n\tcase Qt::Key_F6:\n\n\t\treturn VK_F6;\n\n\tcase Qt::Key_F7:\n\n\t\treturn VK_F7;\n\n\tcase Qt::Key_F8:\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 70, "score": 20839.789674617685 }, { "content": "\t\treturn VK_F8;\n\n\tcase Qt::Key_F9:\n\n\t\treturn VK_F9;\n\n\tcase Qt::Key_F10:\n\n\t\treturn VK_F10;\n\n\tcase Qt::Key_F11:\n\n\t\treturn VK_F11;\n\n\tcase Qt::Key_F12:\n\n\t\treturn VK_F12;\n\n\tcase Qt::Key_F13:\n\n\t\treturn VK_F13;\n\n\tcase Qt::Key_F14:\n\n\t\treturn VK_F14;\n\n\tcase Qt::Key_F15:\n\n\t\treturn VK_F15;\n\n\tcase Qt::Key_F16:\n\n\t\treturn VK_F16;\n\n\tcase Qt::Key_F17:\n\n\t\treturn VK_F17;\n\n\tcase Qt::Key_F18:\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 71, "score": 20839.789674617685 }, { "content": "\t\treturn false;\n\n\t}\n\n}\n\n\n\nQString QHotkeyPrivateWin::formatWinError(DWORD winError)\n\n{\n\n\twchar_t *buffer = NULL;\n\n\tDWORD num = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,\n\n\t\t\t\t\t\t\t NULL,\n\n\t\t\t\t\t\t\t winError,\n\n\t\t\t\t\t\t\t 0,\n\n\t\t\t\t\t\t\t (LPWSTR)&buffer,\n\n\t\t\t\t\t\t\t 0,\n\n\t\t\t\t\t\t\t NULL);\n\n\tif(buffer) {\n\n\t\tQString res = QString::fromWCharArray(buffer, num);\n\n\t\tLocalFree(buffer);\n\n\t\treturn res;\n\n\t} else\n\n\t\treturn QString();\n\n}\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 72, "score": 20839.789674617685 }, { "content": "\t\treturn VK_BROWSER_HOME;\n\n\n\n\tcase Qt::Key_LaunchMail:\n\n\t\treturn VK_LAUNCH_MAIL;\n\n\tcase Qt::Key_LaunchMedia:\n\n\t\treturn VK_LAUNCH_MEDIA_SELECT;\n\n\tcase Qt::Key_Launch0:\n\n\t\treturn VK_LAUNCH_APP1;\n\n\tcase Qt::Key_Launch1:\n\n\t\treturn VK_LAUNCH_APP2;\n\n\n\n\tcase Qt::Key_Massyo:\n\n\t\treturn VK_OEM_FJ_MASSHOU;\n\n\tcase Qt::Key_Touroku:\n\n\t\treturn VK_OEM_FJ_TOUROKU;\n\n\n\n\tdefault:\n\n\t\tok = false;\n\n\t\treturn 0;\n\n\t}\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 73, "score": 20839.789674617685 }, { "content": "\tcase Qt::Key_Sleep:\n\n\t\treturn VK_SLEEP;\n\n\tcase Qt::Key_Period:\n\n\t\treturn VK_DECIMAL;\n\n\tcase Qt::Key_Play:\n\n\t\treturn VK_PLAY;\n\n\tcase Qt::Key_Cancel:\n\n\t\treturn VK_CANCEL;\n\n\n\n\tcase Qt::Key_Forward:\n\n\t\treturn VK_BROWSER_FORWARD;\n\n\tcase Qt::Key_Refresh:\n\n\t\treturn VK_BROWSER_REFRESH;\n\n\tcase Qt::Key_Stop:\n\n\t\treturn VK_BROWSER_STOP;\n\n\tcase Qt::Key_Search:\n\n\t\treturn VK_BROWSER_SEARCH;\n\n\tcase Qt::Key_Favorites:\n\n\t\treturn VK_BROWSER_FAVORITES;\n\n\tcase Qt::Key_HomePage:\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 74, "score": 20839.789674617685 }, { "content": "\t\treturn VK_F18;\n\n\tcase Qt::Key_F19:\n\n\t\treturn VK_F19;\n\n\tcase Qt::Key_F20:\n\n\t\treturn VK_F20;\n\n\tcase Qt::Key_F21:\n\n\t\treturn VK_F21;\n\n\tcase Qt::Key_F22:\n\n\t\treturn VK_F22;\n\n\tcase Qt::Key_F23:\n\n\t\treturn VK_F23;\n\n\tcase Qt::Key_F24:\n\n\t\treturn VK_F24;\n\n\n\n\tcase Qt::Key_Menu:\n\n\t\treturn VK_APPS;\n\n\tcase Qt::Key_Help:\n\n\t\treturn VK_HELP;\n\n\tcase Qt::Key_MediaNext:\n\n\t\treturn VK_MEDIA_NEXT_TRACK;\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 75, "score": 20839.789674617685 }, { "content": "class QHOTKEY_SHARED_EXPORT QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter\n\n{\n\n\tQ_OBJECT\n\n\n\npublic:\n\n\tQHotkeyPrivate();//singleton!!!\n\n\t~QHotkeyPrivate();\n\n\n\n\tstatic QHotkeyPrivate *instance();\n\n\n\n\tQHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);\n\n\n\n\tbool addShortcut(QHotkey *hotkey);\n\n\tbool removeShortcut(QHotkey *hotkey);\n\n\n\nprotected:\n\n\tvoid activateShortcut(QHotkey::NativeShortcut shortcut);\n\n\n\n\tvirtual quint32 nativeKeycode(Qt::Key keycode, bool &ok) = 0;//platform implement\n\n\tvirtual quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) = 0;//platform implement\n", "file_path": "PlayTools/QHotkey/qhotkey_p.h", "rank": 76, "score": 19525.829471806344 }, { "content": "class QHotkeyPrivateWin : public QHotkeyPrivate\n\n{\n\npublic:\n\n\t// QAbstractNativeEventFilter interface\n\n\tbool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;\n\n\n\nprotected:\n\n\t// QHotkeyPrivate interface\n\n\tquint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;\n\n\tquint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;\n\n\tbool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;\n\n\tbool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;\n\n\n\nprivate:\n\n\tstatic QString formatWinError(DWORD winError);\n\n};\n\nNATIVE_INSTANCE(QHotkeyPrivateWin)\n\n\n\nbool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, long *result)\n\n{\n", "file_path": "PlayTools/QHotkey/qhotkey_win.cpp", "rank": 77, "score": 14604.602999594015 }, { "content": "class QHotkey;\n\n\n", "file_path": "PlayTools/mainwindow.h", "rank": 78, "score": 12819.092319040657 }, { "content": "#ifndef MAINWINDOW_H\n\n#define MAINWINDOW_H\n\n\n\n#include <QMainWindow>\n\n#include \"firewallrules.h\"\n\n\n\nQT_BEGIN_NAMESPACE\n\nnamespace Ui { class MainWindow; }\n\nQT_END_NAMESPACE\n\n\n", "file_path": "PlayTools/mainwindow.h", "rank": 87, "score": 6.077993113161154 }, { "content": " void on_disconnectProcessButton_clicked();\n\n\n\n void on_fingerPrintButton_clicked();\n\n\n\n void on_luckyWheelButton_clicked();\n\n\n\n void on_doomsDay2Button_clicked();\n\n\n\n void on_doomsDay3Button_clicked();\n\n\n\n void on_lineEditLuckyWheelInteval_textChanged(const QString &arg1);\n\n\n\n void on_pushButtonSave_clicked();\n\n\n\nprivate:\n\n void InitUI();\n\n void PlaySoundPrompt();\n\n void BindHotKeys();\n\n void UnBindHotKeys();\n\n\n", "file_path": "PlayTools/mainwindow.h", "rank": 89, "score": 5.885538089636221 }, { "content": " enum FunctionType\n\n {\n\n FunctionType_Solo,\n\n FunctionType_Disconnect,\n\n\t\tFunctionType_Finger,\n\n\t\tFunctionType_Lucky,\n\n\t\tFunctionType_DoomsDayII,\n\n\t\tFunctionType_DoomsDayIII,\n\n\t\tFunctionType_Snack,\n\n\t\tFunctionType_Armor,\n\n\t\tFunctionType_Max,\n\n\n\n };\n\n\n\nprivate:\n\n Ui::MainWindow *ui;\n\n AutoMate* m_AutoMate;\n\n FirewallRules m_firewallRules;\n\n QString m_GtaProcessPath;\n\n QHotkey* m_FuncHotkeys[FunctionType_Max];\n\n int m_nLuckwheelInteval;\n\n};\n\n#endif // MAINWINDOW_H\n", "file_path": "PlayTools/mainwindow.h", "rank": 90, "score": 5.071498423346587 }, { "content": " RunFirewallCmd(outCmd);\n\n}\n\n\n\nvoid FirewallRules::StopSinglePublicSession()\n\n{\n\n QString cmd = QString(\"netsh advfirewall firewall delete rule name=\\\"%1\\\" \").arg(SINGLE_PUBLIC_SESSION_NAME);\n\n RunFirewallCmd(cmd);\n\n}\n\n\n\nvoid FirewallRules::StartProcessOffline(QString& processName)\n\n{\n\n\tQString outCmd = QString(\"netsh advfirewall firewall add rule name=\\\"%1\\\" dir=out program=\\\"%2\\\" action=block enable=yes\").arg(PROCESS_OFFLINE_NAME, processName);\n\n\tRunFirewallCmd(outCmd);\n\n}\n\n\n\nvoid FirewallRules::StopProcessOffine()\n\n{\n\n\tQString cmd = QString(\"netsh advfirewall firewall delete rule name=\\\"%1\\\" \").arg(PROCESS_OFFLINE_NAME);\n\n\tRunFirewallCmd(cmd);\n\n}\n", "file_path": "PlayTools/firewallrules.cpp", "rank": 91, "score": 4.721488455666886 }, { "content": "#include \"firewallrules.h\"\n\n#include <qprocess.h>\n\n#include <QDebug>\n\n#include <windows.h>\n\n#include <stdio.h>\n\n#include <netfw.h>\n\n#include <crtdbg.h>\n\n\n\n\n\n#pragma comment( lib, \"ole32.lib\" )\n\n#pragma comment( lib, \"oleaut32.lib\" )\n\n\n\n// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ics/c-adding-an-outbound-rule?redirectedfrom=MSDN\n\n\n\n\n\n// Instantiate INetFwPolicy2\n\nHRESULT WFCOMInitialize(INetFwPolicy2** ppNetFwPolicy2)\n\n{\n\n HRESULT hr = S_OK;\n\n\n", "file_path": "PlayTools/firewallrules.cpp", "rank": 94, "score": 3.906990842963106 }, { "content": "#ifndef FIREWALLRULES_H\n\n#define FIREWALLRULES_H\n\n\n\n#include <QString>\n\n#include <QProcess>\n\n\n", "file_path": "PlayTools/firewallrules.h", "rank": 95, "score": 3.758345705246968 }, { "content": "#include \"mainwindow.h\"\n\n\n\n#include <QApplication>\n\n\n\nint main(int argc, char *argv[])\n\n{\n\n QApplication a(argc, argv);\n\n MainWindow w;\n\n w.show();\n\n return a.exec();\n\n}\n", "file_path": "PlayTools/main.cpp", "rank": 96, "score": 3.530368228026565 }, { "content": " CurrentProfilesBitMask ^= NET_FW_PROFILE2_PUBLIC;\n\n }\n\n\n\n // Create a new Firewall Rule object.\n\n INetFwRule* pFwRule = NULL;\n\n hr = CoCreateInstance(\n\n __uuidof(NetFwRule),\n\n NULL,\n\n CLSCTX_INPROC_SERVER,\n\n __uuidof(INetFwRule),\n\n (void**)&pFwRule);\n\n if (FAILED(hr))\n\n {\n\n printf(\"CoCreateInstance for Firewall Rule failed: 0x%08lx\\n\", hr);\n\n goto Cleanup;\n\n }\n\n\n\n BSTR bstrRuleName = SysAllocString(L\"OUTBOUND_RULE\");\n\n BSTR bstrRuleDescription = SysAllocString(L\"Allow outbound network traffic from my Application over TCP port 4000\");\n\n BSTR bstrRuleGroup = SysAllocString(L\"Sample Rule Group\");\n", "file_path": "PlayTools/firewallrules.cpp", "rank": 98, "score": 2.8304919841006475 }, { "content": "{\n\n\n\n}\n\n\n\nFirewallRules::~FirewallRules()\n\n{\n\n}\n\n\n\nvoid FirewallRules::SetActionListener(IFirewallActionListener* listener)\n\n{\n\n m_pListener = listener;\n\n}\n\n\n\nvoid FirewallRules::SetFireWallRules()\n\n{\n\n QProcess cmd;\n\n //cmd.start(QString(\"netsh interface ip set address \\\"%1\\\" dhcp\").arg(\"WLAN\"));\n\n cmd.start(QString(\"netsh advfirewall firewall add rule name=\\\"%1\\\" dir=in program=\\\"%2\\\" action=allow\")\n\n .arg(\"fwtest\", \"C:\\\\Users\\\\happycastpc.exe\"));\n\n \n", "file_path": "PlayTools/firewallrules.cpp", "rank": 99, "score": 2.563676421724908 } ]
C++
fltl/include/mpl/Static.hpp
iambrosie/Grail-Plus
e102de735e86df241e4311394190ad39181f073b
#ifndef FLTL_STATIC_HPP_ #define FLTL_STATIC_HPP_ #include <new> namespace fltl { namespace mpl { namespace detail { template <typename T> class StaticValue { public: inline static T &default_value(void) throw() { static T val; static bool is_initialized(false); if(!is_initialized) { is_initialized = true; new (&val) T; } return val; } }; template <typename T> class StaticValue<T *> { public: inline static T *&default_value(void) throw() { static T *val(0); return val; } }; template <> class StaticValue<char> { public: inline static char &default_value(void) throw() { static char val('\0'); return val; } }; template <> class StaticValue<unsigned char> { public: inline static unsigned char &default_value(void) throw() { static unsigned char val(0U); return val; } }; template <> class StaticValue<short> { public: inline static short &default_value(void) throw() { static short val(0); return val; } }; template <> class StaticValue<unsigned short> { public: inline static unsigned short &default_value(void) throw() { static unsigned short val(0U); return val; } }; template <> class StaticValue<int> { public: inline static int &default_value(void) throw() { static int val(0); return val; } }; template <> class StaticValue<unsigned> { public: inline static unsigned &default_value(void) throw() { static unsigned val(0U); return val; } }; template <> class StaticValue<long> { public: inline static long &default_value(void) throw() { static long val(0L); return val; } }; template <> class StaticValue<unsigned long> { public: inline static unsigned long &default_value(void) throw() { static unsigned long val(0UL); return val; } }; template <> class StaticValue<float> { public: inline static float &default_value(void) throw() { static float val(0.0); return val; } }; template <> class StaticValue<double> { public: inline static double &default_value(void) throw() { static double val(0.0); return val; } }; } template <typename T> class Static { public: static const T &VALUE; }; template <typename T> const T &Static<T>::VALUE(detail::StaticValue<T>::default_value()); }} #endif
#ifndef FLTL_STATIC_HPP_ #define FLTL_STATIC_HPP_ #include <new> namespace fltl { namespace mpl { namespace detail { template <typename T> class StaticValue { public: inline static T &default_value(void) throw() { static T val; static bool is_initialized(false); if(!is_initialized) { is_initialized = true; new (&val) T; } return val; } }; template <typename T> class StaticValue<T *> {
taticValue<unsigned short> { public: inline static unsigned short &default_value(void) throw() { static unsigned short val(0U); return val; } }; template <> class StaticValue<int> { public: inline static int &default_value(void) throw() { static int val(0); return val; } }; template <> class StaticValue<unsigned> { public: inline static unsigned &default_value(void) throw() { static unsigned val(0U); return val; } }; template <> class StaticValue<long> { public: inline static long &default_value(void) throw() { static long val(0L); return val; } }; template <> class StaticValue<unsigned long> { public: inline static unsigned long &default_value(void) throw() { static unsigned long val(0UL); return val; } }; template <> class StaticValue<float> { public: inline static float &default_value(void) throw() { static float val(0.0); return val; } }; template <> class StaticValue<double> { public: inline static double &default_value(void) throw() { static double val(0.0); return val; } }; } template <typename T> class Static { public: static const T &VALUE; }; template <typename T> const T &Static<T>::VALUE(detail::StaticValue<T>::default_value()); }} #endif
public: inline static T *&default_value(void) throw() { static T *val(0); return val; } }; template <> class StaticValue<char> { public: inline static char &default_value(void) throw() { static char val('\0'); return val; } }; template <> class StaticValue<unsigned char> { public: inline static unsigned char &default_value(void) throw() { static unsigned char val(0U); return val; } }; template <> class StaticValue<short> { public: inline static short &default_value(void) throw() { static short val(0); return val; } }; template <> class S
random
[ { "content": " class IfTrue<true,ThenT,ElseT> {\n\n public:\n\n typedef ThenT type;\n\n };\n\n\n\n template <typename T0, typename T2, typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 1, "score": 226457.0076507059 }, { "content": " class Alphabet<unsigned> : public detail::AlphabetBase<unsigned> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 2, "score": 223286.52019498567 }, { "content": " class Alphabet<short> : public detail::AlphabetBase<short> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 3, "score": 223286.52019498567 }, { "content": " class Alphabet<long> : public detail::AlphabetBase<long> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 4, "score": 223286.52019498567 }, { "content": " class Alphabet<char> : public detail::AlphabetBase<char> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 5, "score": 223286.52019498567 }, { "content": " class Alphabet<int> : public detail::AlphabetBase<int> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 6, "score": 223286.52019498567 }, { "content": " class TestCase : public detail::TestBase {\n\n public:\n\n\n\n static TestCase<TEST_FUNC> self;\n\n\n\n static const char *func_name;\n\n static const char *message;\n\n static bool added_already;\n\n\n\n TestCase<TEST_FUNC> *get_this(void) throw() {\n\n return this;\n\n }\n\n\n\n /// constructor that gets called at runtime when the tests are\n\n /// run\n\n TestCase(const char *_func_name, const char *_message) throw()\n\n : TestBase(get_this())\n\n {\n\n if(!added_already) {\n\n\n", "file_path": "fltl/test/Test.hpp", "rank": 7, "score": 213423.31858625574 }, { "content": " class Alphabet<unsigned short> : public detail::AlphabetBase<unsigned short> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 8, "score": 209035.89650685448 }, { "content": " class Alphabet<unsigned char> : public detail::AlphabetBase<unsigned char> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 9, "score": 209035.89650685445 }, { "content": " class Alphabet<unsigned long> : public detail::AlphabetBase<unsigned long> { };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 10, "score": 209035.89650685448 }, { "content": " class IfTrue {\n\n public:\n\n typedef ElseT type;\n\n };\n\n\n\n template <typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 11, "score": 208571.16920689394 }, { "content": " class SizeOf<IfEqual<void,Unit,detail::sizeof_centinel,Unit>::type> {\n\n public:\n\n enum {\n\n VALUE = 0\n\n };\n\n };\n\n}}\n\n\n\n#endif /* FLTL_MPL_SIZEOF_HPP_ */\n", "file_path": "fltl/include/mpl/SizeOf.hpp", "rank": 24, "score": 184801.85542147892 }, { "content": " class Max : private trait::StaticOnly {\n\n public:\n\n enum {\n\n VALUE = FLTL_FOLD_LEFT(\n\n FLTL_MAX_TEMPLATE_VARIABLE_LIMIT,\n\n FLTL_MAX_OF_2,\n\n FLTL_PACK_0,\n\n v0\n\n )\n\n };\n\n };\n\n}}\n\n\n\n#endif /* FLTL_MPL_MAX_HPP_ */\n", "file_path": "fltl/include/mpl/Max.hpp", "rank": 25, "score": 184151.60562454193 }, { "content": " class Alphabet : public T {\n\n public:\n\n using typename T::alphabet_type;\n\n using typename T::less_type;\n\n using typename T::scope_type;\n\n };\n\n\n\n template<>\n", "file_path": "fltl/include/trait/Alphabet.hpp", "rank": 26, "score": 181161.7752890143 }, { "content": " class AlphaMap : public std::map<\n\n K,\n\n V,\n\n typename trait::Alphabet<K>::less_type\n\n > { };\n\n }\n\n\n\n /// represents a TDOP \"grammar\" of parser categories and their rules.\n\n template <typename AlphaT>\n", "file_path": "fltl/include/TDOP.hpp", "rank": 27, "score": 174630.50285953653 }, { "content": " class Symbol : public Term<AlphaT> {\n\n private:\n\n\n\n friend class TDOP<AlphaT>;\n\n friend class Term<AlphaT>;\n\n friend class Operator<AlphaT>;\n\n friend class detail::SymbolGenerator<AlphaT>;\n\n\n\n FLTL_TDOP_USE_TYPES(TDOP<AlphaT>);\n\n\n\n Symbol(unsigned id) throw()\n\n : Term<AlphaT>(static_cast<int32_t>(id) * -1)\n\n { }\n\n\n\n public:\n\n\n\n typedef symbol_tag tag_type;\n\n\n\n /// constructors\n\n\n", "file_path": "fltl/include/tdop/Symbol.hpp", "rank": 28, "score": 170696.76267529235 }, { "content": " class StaticOnly {\n\n private:\n\n StaticOnly(void) throw() { }\n\n StaticOnly(const StaticOnly &) throw() { }\n\n ~StaticOnly(void) throw() { }\n\n };\n\n\n\n}}\n\n\n\n#endif /* FLTL_TRAIT_STATICONLY_HPP_ */\n", "file_path": "fltl/include/trait/StaticOnly.hpp", "rank": 29, "score": 169421.22519320832 }, { "content": " class Or;\n\n\n\n template <typename T0>\n", "file_path": "fltl/include/mpl/Or.hpp", "rank": 30, "score": 168571.751247329 }, { "content": " class Or {\n\n public:\n\n enum {\n\n RESULT = (T0::RESULT || T1::RESULT || T2::RESULT)\n\n };\n\n };\n\n}}\n\n\n\n#endif /* FLTL_OR_HPP_ */\n", "file_path": "fltl/include/mpl/Or.hpp", "rank": 31, "score": 168571.751247329 }, { "content": " class ProductionBuilder : public trait::Uncopyable {\n\n private:\n\n\n\n friend class CFG<AlphaT>;\n\n\n\n typedef Symbol<AlphaT> symbol_type;\n\n typedef SymbolString<AlphaT> symbol_string_type;\n\n typedef ProductionBuilder<AlphaT> self_type;\n\n\n\n helper::Array<symbol_type> buffer;\n\n\n\n public:\n\n\n\n ProductionBuilder(void) throw()\n\n : buffer()\n\n {\n\n buffer.reserve(32U);\n\n }\n\n\n\n inline self_type &clear(void) throw() {\n", "file_path": "fltl/include/cfg/ProductionBuilder.hpp", "rank": 32, "score": 166976.979492891 }, { "content": " class OpaqueCategory : public Term<AlphaT> {\n\n private:\n\n\n\n friend class TDOP<AlphaT>;\n\n friend class Term<AlphaT>;\n\n friend class Operator<AlphaT>;\n\n friend class OpaqueRule<AlphaT>;\n\n\n\n friend class detail::CategoryGenerator<AlphaT>;\n\n\n\n FLTL_TDOP_USE_TYPES(TDOP<AlphaT>);\n\n\n\n /// construction from other places, e.g. OpaqueRule.\n\n OpaqueCategory(unsigned num) throw()\n\n : Term<AlphaT>(static_cast<int32_t>(num))\n\n { }\n\n\n\n OpaqueCategory(Category<AlphaT> *cat) throw()\n\n : Term<AlphaT>(static_cast<int32_t>(cat->number))\n\n { }\n", "file_path": "fltl/include/tdop/OpaqueCategory.hpp", "rank": 33, "score": 163454.15970220845 }, { "content": " class VariableSymbol : public Symbol<AlphaT> {\n\n private:\n\n\n\n friend class CFG<AlphaT>;\n\n friend class OpaqueProduction<AlphaT>;\n\n friend class detail::PatternData<AlphaT>;\n\n\n\n typedef VariableSymbol<AlphaT> self_type;\n\n\n\n explicit VariableSymbol(const internal_sym_type _value) throw()\n\n : Symbol<AlphaT>(_value)\n\n { }\n\n\n\n public:\n\n\n\n VariableSymbol(void) throw()\n\n : Symbol<AlphaT>(1)\n\n { }\n\n\n\n VariableSymbol(const self_type &that) throw()\n", "file_path": "fltl/include/cfg/VariableSymbol.hpp", "rank": 34, "score": 163454.15970220845 }, { "content": " class TerminalSymbol : public Symbol<AlphaT> {\n\n private:\n\n\n\n friend class CFG<AlphaT>;\n\n friend class detail::PatternData<AlphaT>;\n\n\n\n typedef TerminalSymbol<AlphaT> self_type;\n\n\n\n explicit TerminalSymbol(const internal_sym_type _value) throw()\n\n : cfg::Symbol<AlphaT>(_value)\n\n { }\n\n\n\n public:\n\n\n\n TerminalSymbol(void) throw()\n\n : Symbol<AlphaT>(-1)\n\n { }\n\n\n\n TerminalSymbol(const self_type &that) throw()\n\n : Symbol<AlphaT>(that)\n", "file_path": "fltl/include/cfg/TerminalSymbol.hpp", "rank": 35, "score": 163454.15970220845 }, { "content": " class IfEqual {\n\n public:\n\n typedef ElseT type;\n\n };\n\n\n\n template <typename T0, typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 36, "score": 163238.88449801865 }, { "content": " class IfZero {\n\n public:\n\n typedef ElseT type;\n\n };\n\n\n\n template <typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 37, "score": 163238.88449801865 }, { "content": " class IfUZero {\n\n public:\n\n typedef ElseT type;\n\n };\n\n\n\n template <typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 40, "score": 158241.72098946996 }, { "content": " class IfTypesEqual {\n\n public:\n\n enum {\n\n RESULT = 0\n\n };\n\n };\n\n\n\n template <typename T0, typename T1>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 41, "score": 158241.72098946996 }, { "content": " class Max2 {\n\n public:\n\n enum {\n\n VALUE = (v0 > v1 ? v0 : v1)\n\n };\n\n };\n\n }\n\n\n\n /// Compute the maximum of 1 to FLTL_MAX_TEMPLATE_VARIABLE_LIMIT values at\n\n /// compile time.\n\n template <\n\n const std::size_t v0\n\n FLTL_ENUMERATE_VALUE_PARAMS(\n\n FLTL_MAX_TEMPLATE_VARIABLE_LIMIT,\n\n v,\n\n const std::size_t,\n\n = 0\n\n )\n\n >\n", "file_path": "fltl/include/mpl/Max.hpp", "rank": 42, "score": 158241.72098946996 }, { "content": " class SizeOf {\n\n public:\n\n enum {\n\n VALUE = sizeof(T)\n\n };\n\n };\n\n\n\n template <typename T>\n", "file_path": "fltl/include/mpl/SizeOf.hpp", "rank": 43, "score": 158241.72098946993 }, { "content": " class PatternBuilder<AlphaT,CatTagT,void,true> {\n\n private:\n\n\n\n friend class AnyOperator<AlphaT>;\n\n friend class AnyOperatorString<AlphaT>;\n\n friend class OpaqueCategory<AlphaT>;\n\n friend class Unbound<AlphaT,category_tag>;\n\n friend class Unbound<AlphaT,category_lb_tag>;\n\n friend class Bound<AlphaT,category_lb_tag>;\n\n friend class OpaquePattern<AlphaT>;\n\n\n\n FLTL_TDOP_USE_TYPES(TDOP<AlphaT>);\n\n typedef PatternBuilder<AlphaT,CatTagT,void,true> self_type;\n\n\n\n PatternData<AlphaT> *pattern;\n\n\n\n PatternBuilder(PatternData<AlphaT> *_pattern) throw()\n\n : pattern(_pattern)\n\n {\n\n PatternData<AlphaT>::incref(pattern);\n", "file_path": "fltl/include/tdop/Pattern.hpp", "rank": 44, "score": 155101.9107038744 }, { "content": " class sizeof_centinel { };\n\n }\n\n\n\n /// Get the byte size for a particular type. this allows us to say that\n\n /// specific types have zero size, which happens to be useful for other\n\n /// mpl classes.\n\n template <typename T>\n", "file_path": "fltl/include/mpl/SizeOf.hpp", "rank": 45, "score": 153549.5292812735 }, { "content": " class SizeOf<void> {\n\n public:\n\n enum {\n\n VALUE = 0\n\n };\n\n };\n\n\n\n // set the size of the Unit type, assuming it's distinct from void.\n\n template <>\n", "file_path": "fltl/include/mpl/SizeOf.hpp", "rank": 46, "score": 153214.34483649515 }, { "content": " class Or<T0,T1,void> {\n\n public:\n\n enum {\n\n RESULT = (T0::RESULT || T1::RESULT)\n\n };\n\n };\n\n\n\n template <typename T0, typename T1, typename T2>\n", "file_path": "fltl/include/mpl/Or.hpp", "rank": 47, "score": 152675.05088307703 }, { "content": " class Or<T0,void,void> {\n\n public:\n\n enum {\n\n RESULT = T0::RESULT\n\n };\n\n };\n\n\n\n template <typename T0, typename T1>\n", "file_path": "fltl/include/mpl/Or.hpp", "rank": 48, "score": 152675.05088307703 }, { "content": " class RemoveReference {\n\n public:\n\n typedef T type;\n\n typedef const T const_type;\n\n };\n\n\n\n template <typename T>\n", "file_path": "fltl/include/mpl/RemoveReference.hpp", "rank": 49, "score": 149135.21787895236 }, { "content": " class AddReference {\n\n public:\n\n typedef T &type;\n\n typedef const T &const_type;\n\n };\n\n\n\n template <typename T>\n", "file_path": "fltl/include/mpl/AddReference.hpp", "rank": 50, "score": 149135.21787895236 }, { "content": " class unusable_type {\n\n private:\n\n explicit unusable_type(void) throw() { }\n\n unusable_type &operator=(const unusable_type &) throw() {\n\n return *this;\n\n }\n\n public:\n\n unusable_type(const unusable_type &) throw() { }\n\n };\n\n }\n\n\n", "file_path": "fltl/include/mpl/UserOperators.hpp", "rank": 51, "score": 149135.21787895236 }, { "content": " class RemoveConst {\n\n public:\n\n typedef T type;\n\n };\n\n\n\n template <typename T>\n", "file_path": "fltl/include/mpl/RemoveConst.hpp", "rank": 52, "score": 149135.21787895236 }, { "content": " class Op ## name { \\\n\n public: \\\n\n typedef void return_type; \\\n\n typedef const OpParamT param_type; \\\n\n FLTL_FORCE_INLINE static void run( \\\n\n const void *, \\\n\n const OpParamT \\\n\n ) throw() { } \\\n\n }\n\n\n\n#define FLTL_USER_OPERATOR0(trait,tag,name,func) \\\n\n FLTL_USER_OPERATOR0_TYPE_SUFFIX(trait,tag,name,func,void,const throw())\n\n\n\n#define FLTL_USER_OPERATOR0_MUT(trait,tag,name,func) \\\n\n FLTL_USER_OPERATOR0_TYPE_SUFFIX(trait,tag,name,func,void,throw())\n\n\n\n#define FLTL_USER_OPERATOR0_TYPE(trait,tag,name,func,tt) \\\n\n FLTL_USER_OPERATOR0_TYPE_SUFFIX(trait,tag,name,func,tt,const throw())\n\n\n\n#define FLTL_USER_OPERATOR0_MUT_TYPE(trait,tag,name,func,tt) \\\n", "file_path": "fltl/include/mpl/UserOperators.hpp", "rank": 53, "score": 148800.033434174 }, { "content": " class IfTypesEqual<T0,T0> {\n\n public:\n\n enum {\n\n RESULT = 1\n\n };\n\n };\n\n}}\n\n\n\n#endif /* FLTL_IF_HPP_ */\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 54, "score": 148511.58679592703 }, { "content": " class SizeOf<const T> {\n\n public:\n\n enum {\n\n VALUE = SizeOf<T>::VALUE\n\n };\n\n };\n\n\n\n template <>\n", "file_path": "fltl/include/mpl/SizeOf.hpp", "rank": 55, "score": 148511.58679592703 }, { "content": " class IfZero<0,ThenT,ElseT> {\n\n public:\n\n typedef ThenT type;\n\n };\n\n\n\n template <const unsigned val, typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 56, "score": 148260.7394807559 }, { "content": " // tag for the \"global\" scope\n\n class global_scope_type { };\n\n\n\n FLTL_MAKE_USER_OP0(UnaryPlus);\n\n FLTL_MAKE_USER_OP0(UnaryMinus);\n\n FLTL_MAKE_USER_OP0(UnaryPreIncrement);\n\n FLTL_MAKE_USER_OP0(UnaryPostIncrement);\n\n FLTL_MAKE_USER_OP0(UnaryPreDecrement);\n\n FLTL_MAKE_USER_OP0(UnaryPostDecrement);\n\n FLTL_MAKE_USER_OP0(UnaryLogicalNot);\n\n FLTL_MAKE_USER_OP0(UnaryBitwiseNot);\n\n FLTL_MAKE_USER_OP0(UnaryIndirection);\n\n FLTL_MAKE_USER_OP0(UnaryReference);\n\n\n\n FLTL_MAKE_USER_OP0(BinaryIndirection); // a->b\n\n\n\n FLTL_MAKE_USER_OP1(BinaryPlus);\n\n FLTL_MAKE_USER_OP1(BinaryMinus);\n\n FLTL_MAKE_USER_OP1(BinaryMult);\n\n FLTL_MAKE_USER_OP1(BinaryDiv);\n\n FLTL_MAKE_USER_OP1(BinaryMod);\n", "file_path": "fltl/include/mpl/UserOperators.hpp", "rank": 57, "score": 144974.8118217894 }, { "content": " class AddReference<T &> {\n\n public:\n\n typedef T &type;\n\n typedef const T &const_type;\n\n };\n\n}}\n\n\n\n#endif /* FLTL_ADDREFERENCE_HPP_ */\n", "file_path": "fltl/include/mpl/AddReference.hpp", "rank": 58, "score": 144639.62737701103 }, { "content": " class RemoveReference<T &> {\n\n public:\n\n typedef T type;\n\n typedef const T const_type;\n\n };\n\n}}\n\n\n\n\n\n#endif /* Grail_Plus_REMOVEREFERENCE_HPP_ */\n", "file_path": "fltl/include/mpl/RemoveReference.hpp", "rank": 59, "score": 144639.627377011 }, { "content": " class IfTypesEqual<T0, const T1> {\n\n public:\n\n enum {\n\n RESULT = IfTypesEqual<T0,T1>::RESULT\n\n };\n\n };\n\n\n\n template <typename T0>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 60, "score": 144100.3334235929 }, { "content": " class IfTypesEqual<const T0, T1> {\n\n public:\n\n enum {\n\n RESULT = IfTypesEqual<T0,T1>::RESULT\n\n };\n\n };\n\n\n\n template <typename T0, typename T1>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 61, "score": 144100.3334235929 }, { "content": " class RemoveConst<const T> {\n\n public:\n\n typedef T type;\n\n };\n\n\n\n}}\n\n\n\n#endif /* FLTL_REMOVECONST_HPP_ */\n", "file_path": "fltl/include/mpl/RemoveConst.hpp", "rank": 62, "score": 140423.3859806841 }, { "content": " class IfUZero<0U,ThenT,ElseT> {\n\n public:\n\n typedef ThenT type;\n\n };\n\n\n\n template <typename T0, typename T1>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 63, "score": 140172.53866551293 }, { "content": " class IfEqual<T0,T0,ThenT,ElseT> {\n\n public:\n\n typedef ThenT type;\n\n };\n\n\n\n template <const int val, typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 64, "score": 139952.3888371868 }, { "content": " class IfTypesEqual<const T0, const T1> {\n\n public:\n\n enum {\n\n RESULT = IfTypesEqual<T0,T1>::RESULT\n\n };\n\n };\n\n\n\n template <typename T0, typename T1>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 65, "score": 139952.3888371868 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_IF_HPP_\n\n#define FLTL_IF_HPP_\n\n\n\nnamespace fltl { namespace mpl {\n\n\n\n template <const bool cond, typename ThenT, typename ElseT>\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 66, "score": 118993.70568769235 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_OR_HPP_\n\n#define FLTL_OR_HPP_\n\n\n\nnamespace fltl { namespace mpl {\n\n\n\n template <typename T0, typename T1=void, typename T2=void>\n", "file_path": "fltl/include/mpl/Or.hpp", "rank": 67, "score": 118990.10513004947 }, { "content": "/*\n\n * Or.hpp\n\n *\n\n * Created on: Mar 3, 2011\n\n * Author: Peter Goodman\n\n * Version: $Id$\n\n *\n\n * Copyright 2011 Peter Goodman, all rights reserved.\n\n *\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n\n * of this software and associated documentation files (the \"Software\"), to deal\n\n * in the Software without restriction, including without limitation the rights\n\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\n * copies of the Software, and to permit persons to whom the Software is\n\n * furnished to do so, subject to the following conditions:\n\n *\n\n * The above copyright notice and this permission notice shall be included in\n\n * all copies or substantial portions of the Software.\n\n *\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "file_path": "fltl/include/mpl/Or.hpp", "rank": 68, "score": 118974.26359574408 }, { "content": "/*\n\n * If.hpp\n\n *\n\n * Created on: Jan 17, 2011\n\n * Author: Peter Goodman\n\n * Version: $Id$\n\n *\n\n * Copyright 2011 Peter Goodman, all rights reserved.\n\n *\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n\n * of this software and associated documentation files (the \"Software\"), to deal\n\n * in the Software without restriction, including without limitation the rights\n\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\n * copies of the Software, and to permit persons to whom the Software is\n\n * furnished to do so, subject to the following conditions:\n\n *\n\n * The above copyright notice and this permission notice shall be included in\n\n * all copies or substantial portions of the Software.\n\n *\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "file_path": "fltl/include/mpl/If.hpp", "rank": 69, "score": 118974.26359574408 }, { "content": " class AnyOperator {\n\n public:\n\n\n\n typedef AnyOperator<AlphaT> self_type;\n\n typedef any_operator_tag tag_type;\n\n\n\n // any initial rule, regardless of category\n\n FLTL_TDOP_RULE_PATTERN(any_operator_tag)\n\n };\n\n\n\n template <typename AlphaT>\n", "file_path": "fltl/include/tdop/Any.hpp", "rank": 70, "score": 118200.88899917314 }, { "content": " /// offsets into CFG symbol strings\n\n class str {\n\n public:\n\n enum {\n\n REF_COUNT = 0,\n\n HASH = 1,\n\n LENGTH = 2,\n\n FIRST_SYMBOL = 3\n\n };\n\n };\n\n }\n\n\n\n}\n\n\n\n#include \"fltl/include/helper/Pattern.hpp\"\n\n\n\n#include \"fltl/include/cfg/Symbol.hpp\"\n\n#include \"fltl/include/cfg/TerminalSymbol.hpp\"\n\n#include \"fltl/include/cfg/VariableSymbol.hpp\"\n\n#include \"fltl/include/cfg/Production.hpp\"\n\n#include \"fltl/include/cfg/Variable.hpp\"\n\n\n\nnamespace fltl {\n\n\n\n /// context-free grammar type.\n\n ///\n\n /// Assumptions:\n\n /// - AlphaT has a strict weak ordering.\n\n /// - AlphaT is default constructible\n\n /// - AlphaT is copy constructible\n\n template <typename AlphaT>\n", "file_path": "fltl/include/CFG.hpp", "rank": 71, "score": 118200.88899917314 }, { "content": " class AnySymbol {\n\n public:\n\n typedef AnySymbol self_type;\n\n FLTL_CFG_PRODUCTION_PATTERN(any_symbol_tag)\n\n };\n\n\n\n template <typename AlphaT>\n", "file_path": "fltl/include/cfg/Any.hpp", "rank": 72, "score": 118200.88899917314 }, { "content": " class Match;\n\n\n\n template <typename, typename, typename, const unsigned>\n", "file_path": "fltl/include/CFG.hpp", "rank": 73, "score": 118200.88899917314 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_NO_INLINE_HPP_\n\n#define FLTL_NO_INLINE_HPP_\n\n\n\n#if defined(__INTEL_COMPILER)\n\n#define FLTL_NO_INLINE\n\n#elif defined(_WIN32)\n\n#define FLTL_NO_INLINE __declspec(noinline)\n\n#elif defined(__GNUC__) || defined(__GNUG__)\n\n#define FLTL_NO_INLINE __attribute__((noinline))\n\n#elif defined(__clang__)\n\n#define FLTL_NO_INLINE __attribute__((noinline))\n\n#else\n\n#define FLTL_NO_INLINE\n\n#endif\n\n\n\n#endif /* FLTL_NO_INLINE_HPP_ */\n", "file_path": "fltl/include/preprocessor/NO_INLINE.hpp", "rank": 74, "score": 115408.36549629862 }, { "content": "/*\n\n * NO_INLINE.hpp\n\n *\n\n * Created on: Jan 21, 2011\n\n * Author: Peter Goodman\n\n * Version: $Id$\n\n *\n\n * Copyright 2011 Peter Goodman, all rights reserved.\n\n *\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n\n * of this software and associated documentation files (the \"Software\"), to deal\n\n * in the Software without restriction, including without limitation the rights\n\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\n * copies of the Software, and to permit persons to whom the Software is\n\n * furnished to do so, subject to the following conditions:\n\n *\n\n * The above copyright notice and this permission notice shall be included in\n\n * all copies or substantial portions of the Software.\n\n *\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "file_path": "fltl/include/preprocessor/NO_INLINE.hpp", "rank": 75, "score": 115401.08564956243 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_TRAIT_STATICONLY_HPP_\n\n#define FLTL_TRAIT_STATICONLY_HPP_\n\n\n\nnamespace fltl { namespace trait {\n\n\n", "file_path": "fltl/include/trait/StaticOnly.hpp", "rank": 76, "score": 115336.80363407079 }, { "content": "/*\n\n * StaticOnly.hpp\n\n *\n\n * Created on: Sep 17, 2010\n\n * Author: Peter Goodman\n\n * Version: $Id$\n\n *\n\n * Copyright 2011 Peter Goodman, all rights reserved.\n\n *\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n\n * of this software and associated documentation files (the \"Software\"), to deal\n\n * in the Software without restriction, including without limitation the rights\n\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\n * copies of the Software, and to permit persons to whom the Software is\n\n * furnished to do so, subject to the following conditions:\n\n *\n\n * The above copyright notice and this permission notice shall be included in\n\n * all copies or substantial portions of the Software.\n\n *\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "file_path": "fltl/include/trait/StaticOnly.hpp", "rank": 77, "score": 115330.56320809183 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_MPL_SIZEOF_HPP_\n\n#define FLTL_MPL_SIZEOF_HPP_\n\n\n\n#include \"fltl/include/mpl/If.hpp\"\n\n#include \"fltl/include/mpl/Unit.hpp\"\n\n\n\nnamespace fltl { namespace mpl {\n\n\n\n namespace detail {\n", "file_path": "fltl/include/mpl/SizeOf.hpp", "rank": 78, "score": 115128.95823503606 }, { "content": "#define FLTL_MAX_TEMPLATE_VARIABLE_LIMIT 10\n\n\n\n#if FLTL_TEMPLATE_VARIABLE_LIMIT > (FLTL_MAX_TEMPLATE_VARIABLE_LIMIT - 3)\n\n#error \"The Max template must accept more template arguments.\"\n\n#endif\n\n\n\n/// the fold function for computing the max value of N numbers by computing\n\n/// the value one pair at a time.\n\n#define FLTL_MAX_OF_2(n, _, rest) (detail::Max2<v ## n, rest>::VALUE)\n\n\n\nnamespace fltl { namespace mpl {\n\n\n\n namespace detail {\n\n\n\n /// compute the maximum of two values at compile time.\n\n template <const std::size_t v0, const std::size_t v1>\n", "file_path": "fltl/include/mpl/Max.hpp", "rank": 79, "score": 115127.51015726865 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_MPL_MAX_HPP_\n\n#define FLTL_MPL_MAX_HPP_\n\n\n\n#include <cstddef>\n\n\n\n#include \"fltl/include/preprocessor/TEMPLATE_VARIABLE_LIMIT.hpp\"\n\n#include \"fltl/include/preprocessor/ENUMERATE_VALUE_PARAMS.hpp\"\n\n#include \"fltl/include/preprocessor/FOLD_LEFT.hpp\"\n\n#include \"fltl/include/preprocessor/PACK.hpp\"\n\n\n\n#include \"fltl/include/trait/StaticOnly.hpp\"\n\n\n", "file_path": "fltl/include/mpl/Max.hpp", "rank": 80, "score": 115125.32653526832 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_MPL_UNIT_HPP_\n\n#define FLTL_MPL_UNIT_HPP_\n\n\n\nnamespace fltl { namespace mpl {\n\n\n\n typedef void Unit;\n\n}}\n\n\n\n#endif /* FLTL_MPL_UNIT_HPP_ */\n", "file_path": "fltl/include/mpl/Unit.hpp", "rank": 81, "score": 115122.68432343363 }, { "content": "/*\n\n * Max.hpp\n\n *\n\n * Created on: Sep 14, 2010\n\n * Author: Peter Goodman\n\n * Version: $Id$\n\n *\n\n * Copyright 2011 Peter Goodman, all rights reserved.\n\n *\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n\n * of this software and associated documentation files (the \"Software\"), to deal\n\n * in the Software without restriction, including without limitation the rights\n\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\n * copies of the Software, and to permit persons to whom the Software is\n\n * furnished to do so, subject to the following conditions:\n\n *\n\n * The above copyright notice and this permission notice shall be included in\n\n * all copies or substantial portions of the Software.\n\n *\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "file_path": "fltl/include/mpl/Max.hpp", "rank": 82, "score": 115107.97881819172 }, { "content": "/*\n\n * SizeOf.hpp\n\n *\n\n * Created on: Sep 15, 2010\n\n * Author: Peter Goodman\n\n * Version: $Id$\n\n *\n\n * Copyright 2011 Peter Goodman, all rights reserved.\n\n *\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n\n * of this software and associated documentation files (the \"Software\"), to deal\n\n * in the Software without restriction, including without limitation the rights\n\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\n * copies of the Software, and to permit persons to whom the Software is\n\n * furnished to do so, subject to the following conditions:\n\n *\n\n * The above copyright notice and this permission notice shall be included in\n\n * all copies or substantial portions of the Software.\n\n *\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "file_path": "fltl/include/mpl/SizeOf.hpp", "rank": 83, "score": 115107.97881819172 }, { "content": "/*\n\n * Unit.hpp\n\n *\n\n * Created on: Sep 14, 2010\n\n * Author: Peter Goodman\n\n * Version: $Id$\n\n *\n\n * Copyright 2011 Peter Goodman, all rights reserved.\n\n *\n\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n\n * of this software and associated documentation files (the \"Software\"), to deal\n\n * in the Software without restriction, including without limitation the rights\n\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\n * copies of the Software, and to permit persons to whom the Software is\n\n * furnished to do so, subject to the following conditions:\n\n *\n\n * The above copyright notice and this permission notice shall be included in\n\n * all copies or substantial portions of the Software.\n\n *\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n", "file_path": "fltl/include/mpl/Unit.hpp", "rank": 84, "score": 115107.97881819172 }, { "content": " class category_tag { };\n", "file_path": "fltl/include/TDOP.hpp", "rank": 85, "score": 114621.2933539436 }, { "content": " /// Don't allow for subtypes of this type to be copied\n\n class Uncopyable {\n\n protected:\n\n\n\n Uncopyable(void) throw() { }\n\n\n\n ~Uncopyable(void) throw() { }\n\n\n\n private:\n\n\n\n Uncopyable(const Uncopyable &) throw() { }\n\n\n\n Uncopyable &operator=(const Uncopyable &) throw() {\n\n return *this;\n\n }\n\n };\n\n\n\n}}\n\n\n\n#endif /* FLTL_TRAIT_UNCOPYABLE_HPP_ */\n", "file_path": "fltl/include/trait/Uncopyable.hpp", "rank": 86, "score": 114621.2933539436 }, { "content": " class rule_tag { };\n\n\n", "file_path": "fltl/include/TDOP.hpp", "rank": 87, "score": 114621.2933539436 }, { "content": " class term_tag { };\n", "file_path": "fltl/include/TDOP.hpp", "rank": 88, "score": 114621.2933539436 }, { "content": " class operator_tag { };\n", "file_path": "fltl/include/TDOP.hpp", "rank": 89, "score": 114621.2933539436 }, { "content": " class symbol_tag { };\n", "file_path": "fltl/include/CFG.hpp", "rank": 90, "score": 114621.2933539436 }, { "content": " class any_operator_tag { };\n", "file_path": "fltl/include/TDOP.hpp", "rank": 91, "score": 114621.2933539436 }, { "content": " class terminal_tag { };\n", "file_path": "fltl/include/CFG.hpp", "rank": 92, "score": 114621.2933539436 }, { "content": " class PatternBuilder;\n\n\n\n template <typename> class PatternData;\n\n\n\n template <typename> class CategoryGenerator;\n\n template <typename> class SymbolGenerator;\n\n template <typename> class RuleGenerator;\n\n template <typename,const bool> class PatternGenerator;\n\n }\n\n\n\n // forward eclaractions\n\n template <typename> class Category;\n\n template <typename> class OpaqueCategory;\n\n template <typename> class Symbol;\n\n template <typename> class Rule;\n\n template <typename> class OpaqueRule;\n\n template <typename> class Term;\n\n\n\n template <typename> class Operator;\n\n template <typename> class OperatorString;\n", "file_path": "fltl/include/TDOP.hpp", "rank": 93, "score": 114621.2933539436 }, { "content": " class Symbol {\n\n protected:\n\n\n\n mutable internal_sym_type value;\n\n\n\n friend class CFG<AlphaT>;\n\n friend class Variable<AlphaT>;\n\n friend class Production<AlphaT>;\n\n friend class OpaqueProduction<AlphaT>;\n\n friend class ProductionBuilder<AlphaT>;\n\n friend class SymbolString<AlphaT>;\n\n friend class VariableSymbol<AlphaT>;\n\n friend class TerminalSymbol<AlphaT>;\n\n friend class detail::SimpleGenerator<AlphaT>;\n\n friend class detail::PatternData<AlphaT>;\n\n\n\n template <typename, typename>\n\n friend class detail::PatternGenerator;\n\n\n\n template <typename, typename, typename, typename>\n", "file_path": "fltl/include/cfg/Symbol.hpp", "rank": 94, "score": 114621.2933539436 }, { "content": " class Generator {\n\n private:\n\n\n\n typedef Generator<AlphaT> self_type;\n\n\n\n friend class detail::CategoryGenerator<AlphaT>;\n\n friend class detail::SymbolGenerator<AlphaT>;\n\n friend class detail::RuleGenerator<AlphaT>;\n\n friend class detail::PatternGenerator<AlphaT,true>;\n\n friend class detail::PatternGenerator<AlphaT,false>;\n\n friend class TDOP<AlphaT>;\n\n\n\n FLTL_TDOP_USE_TYPES(TDOP<AlphaT>);\n\n\n\n // location/navigation information\n\n TDOP<AlphaT> *machine;\n\n tdop::Category<AlphaT> *category;\n\n\n\n union {\n\n tdop::Rule<AlphaT> *rule;\n", "file_path": "fltl/include/tdop/Generator.hpp", "rank": 95, "score": 114621.2933539436 }, { "content": " class symbol_tag { };\n", "file_path": "fltl/include/TDOP.hpp", "rank": 96, "score": 114621.2933539436 }, { "content": " class Category {\n\n private:\n\n\n\n friend class TDOP<AlphaT>;\n\n friend class Term<AlphaT>;\n\n friend class OpaqueCategory<AlphaT>;\n\n friend class OpaqueRule<AlphaT>;\n\n friend class Rule<AlphaT>;\n\n\n\n friend class detail::CategoryGenerator<AlphaT>;\n\n friend class detail::SymbolGenerator<AlphaT>;\n\n friend class detail::RuleGenerator<AlphaT>;\n\n friend class detail::PatternGenerator<AlphaT,true>;\n\n friend class detail::PatternGenerator<AlphaT,false>;\n\n\n\n typedef Category<AlphaT> self_type;\n\n\n\n unsigned ref_count;\n\n\n\n /// the \"number\"/id of this parsercategory\n", "file_path": "fltl/include/tdop/Category.hpp", "rank": 97, "score": 114621.2933539436 }, { "content": " class AnyOperatorString {\n\n public:\n\n\n\n typedef AnyOperatorString<AlphaT> self_type;\n\n typedef any_operator_string_tag tag_type;\n\n\n\n const AnyOperatorStringOfLength<AlphaT>\n\n operator()(unsigned &len) const throw() {\n\n return AnyOperatorStringOfLength<AlphaT>(&len);\n\n }\n\n\n\n // any extension rule, regardless of category\n\n FLTL_TDOP_RULE_PATTERN(any_operator_string_tag)\n\n };\n\n\n\n template <typename AlphaT>\n", "file_path": "fltl/include/tdop/Any.hpp", "rank": 98, "score": 114621.2933539436 }, { "content": " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\n * THE SOFTWARE.\n\n */\n\n\n\n#ifndef FLTL_FIND_BALANCED_HPP_\n\n#define FLTL_FIND_BALANCED_HPP_\n\n\n\n#include \"grail/include/io/UTF8FileBuffer.hpp\"\n\n\n\nnamespace grail { namespace io { namespace detail {\n\n\n\n /// try to find something that needs to be balanced; assumes non-null\n\n /// ascii\n\n template <const unsigned BUFFER_SIZE, const bool LOOK_FOR_ERRORS>\n\n static bool find_balanced(\n\n UTF8FileBuffer<BUFFER_SIZE> &buffer,\n", "file_path": "grail/include/io/detail/find_balanced.hpp", "rank": 99, "score": 25.71117500511673 } ]
C++
src/chwSurfaceTweak.cpp
bradleyhenke/chwtools
733e346b4dc6452954b6ba19899d2ccf0a0cd79f
#include "chwSurfaceTweak.h" const MTypeId chwSurfaceTweak::typeId( 0x89007 ); const MString chwSurfaceTweak::typeName( "chwSurfaceTweak" ); MObject chwSurfaceTweak::aInVert; MObject chwSurfaceTweak::aFalloffMode; MObject chwSurfaceTweak::aFalloffCurve; MObject chwSurfaceTweak::aFalloffRadius; MObject chwSurfaceTweak::aRelativeMatrix; MObject chwSurfaceTweak::aDeformMatrix; MObject chwSurfaceTweak::aOutTranslate; MObject chwSurfaceTweak::aOutTranslateX; MObject chwSurfaceTweak::aOutTranslateY; MObject chwSurfaceTweak::aOutTranslateZ; MObject chwSurfaceTweak::aOutRotate; MObject chwSurfaceTweak::aOutRotateX; MObject chwSurfaceTweak::aOutRotateY; MObject chwSurfaceTweak::aOutRotateZ; chwSurfaceTweak::chwSurfaceTweak() { m_data = new chwSurfaceTweakData; } chwSurfaceTweak::~chwSurfaceTweak() { delete m_data; } void* chwSurfaceTweak::creator(){ return new chwSurfaceTweak(); } MStatus chwSurfaceTweak::initialize() { MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MFnMatrixAttribute mAttr; MRampAttribute rAttr; MFnUnitAttribute uAttr; aInVert = nAttr.create( "vertex", "v", MFnNumericData::kLong ); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setMin(0); nAttr.setDefault(0); nAttr.setReadable(true); nAttr.setWritable(true); addAttribute(aInVert); aFalloffMode = eAttr.create( "falloffMode", "fom" ); eAttr.addField( "Volume", 0); eAttr.setKeyable(true); eAttr.setStorable(true); eAttr.setReadable(true); eAttr.setWritable(true); eAttr.setDefault(0); addAttribute(aFalloffMode); aFalloffRadius = nAttr.create( "falloffRadius", "for", MFnNumericData::kFloat, 1.0 ); nAttr.setWritable(true); nAttr.setStorable(true); nAttr.setKeyable (true); nAttr.setConnectable(true); nAttr.setMin(0.0); nAttr.setDefault(1.0); addAttribute(aFalloffRadius); aFalloffCurve = rAttr.createCurveRamp("falloffCurve", "foc"); addAttribute(aFalloffCurve); aRelativeMatrix = mAttr.create( "relativeMatrix", "rm" ); mAttr.setConnectable(true); addAttribute(aRelativeMatrix); aDeformMatrix = mAttr.create( "deformMatrix", "dm" ); mAttr.setConnectable(true); addAttribute(aDeformMatrix); aOutTranslateX = nAttr.create( "outTranslateX", "ostx", MFnNumericData::kDouble, 0.0 ); aOutTranslateY = nAttr.create( "outTranslateY", "osty", MFnNumericData::kDouble, 0.0 ); aOutTranslateZ = nAttr.create( "outTranslateZ", "ostz", MFnNumericData::kDouble, 0.0 ); aOutTranslate = nAttr.create( "outTranslate", "os", aOutTranslateX, aOutTranslateY, aOutTranslateZ ); addAttribute(aOutTranslate); aOutRotateX = uAttr.create( "outRotateX", "osrx", MFnUnitAttribute::kAngle, 0.0 ); aOutRotateY = uAttr.create( "outRotateY", "osry", MFnUnitAttribute::kAngle, 0.0 ); aOutRotateZ = uAttr.create( "outRotateZ", "osrz", MFnUnitAttribute::kAngle, 0.0 ); aOutRotate = nAttr.create( "outRotate", "osr", aOutRotateX, aOutRotateY, aOutRotateZ ); addAttribute(aOutRotate); attributeAffects( chwSurfaceTweak::aInVert, chwSurfaceTweak::aOutTranslate ); attributeAffects( chwSurfaceTweak::aInVert, chwSurfaceTweak::aOutRotate ); attributeAffects( chwSurfaceTweak::inputGeom, chwSurfaceTweak::aOutTranslate ); attributeAffects( chwSurfaceTweak::inputGeom, chwSurfaceTweak::aOutRotate ); attributeAffects( chwSurfaceTweak::aRelativeMatrix, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aDeformMatrix, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aFalloffMode, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aFalloffCurve, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aFalloffRadius, chwSurfaceTweak::outputGeom ); MGlobal::executeCommand( "makePaintable -attrType \"multiFloat\" -sm \"deformer\" \"chwSurfaceTweak\" \"weights\";" ); return MStatus::kSuccess; } MStatus chwSurfaceTweak::compute(const MPlug& plug, MDataBlock& data) { MStatus status; MObject thisNode = this->thisMObject(); m_data->m_env = data.inputValue(envelope).asFloat(); m_data->m_vert = data.inputValue( aInVert ).asInt(); if (plug == aOutTranslate || plug == aOutRotate || plug.parent() == aOutTranslate || plug.parent() == aOutRotate ) { MDataHandle outTranslateHnd = data.outputValue( aOutTranslate ); MDataHandle outRotateHnd = data.outputValue( aOutRotate ); MPlug inPlug(thisNode,input); inPlug.selectAncestorLogicalIndex(0,input); MDataHandle hInput = data.inputValue(inPlug, &status); CHECK_MSTATUS_AND_RETURN_IT(status); MDataHandle hGeom = hInput.child(inputGeom); MObject mesh = hGeom.asMesh(); if (!mesh.isNull()) { MFnMesh meshFn(mesh, &status); CHECK_MSTATUS_AND_RETURN_IT(status); m_data->m_numverts = meshFn.numVertices(); status = meshFn.getPoints(m_data->m_points, MSpace::kWorld); CHECK_MSTATUS_AND_RETURN_IT(status); status = meshFn.getVertexNormals(false, m_data->m_normals, MSpace::kWorld); CHECK_MSTATUS_AND_RETURN_IT(status); int prev; MItMeshVertex iter(mesh); iter.setIndex(m_data->m_vert, prev); iter.getConnectedVertices(m_data->m_conids); if (m_data->m_conids.length() > 1) { m_data->m_aimvert = m_data->m_conids[0]; m_data->m_upvert = m_data->m_conids[1]; } else { return MStatus::kFailure; } if (m_data->m_vert < m_data->m_numverts) { MMatrix m; MVector vx, vy, vz; MPoint outTranslate; double outRotate[3]; vx = m_data->m_normals[m_data->m_vert]; vy = (m_data->m_points[m_data->m_upvert] - m_data->m_points[m_data->m_vert]).normal(); vz = (vx ^ vy).normal(); vy = (vx ^ vz).normal(); m[0][0] = vx[0]; m[0][1] = vx[1]; m[0][2] = vx[2]; m[0][3] = 0.f; m[1][0] = vy[0]; m[1][1] = vy[1]; m[1][2] = vy[2]; m[1][3] = 0.f; m[2][0] = vz[0]; m[2][1] = vz[1]; m[2][2] = vz[2]; m[2][3] = 0.f; m[3][0] = m_data->m_points[m_data->m_vert][0]; m[3][1] = m_data->m_points[m_data->m_vert][1]; m[3][2] = m_data->m_points[m_data->m_vert][2]; m[3][3] = 1.f; MTransformationMatrix outMatrix(m); MTransformationMatrix::RotationOrder order; outMatrix.getRotation(outRotate, order, MSpace::kWorld); outTranslate = outMatrix.getTranslation(MSpace::kWorld); outRotateHnd.set3Double(outRotate[0], outRotate[1], outRotate[2]); outTranslateHnd.set3Double(outTranslate[0],outTranslate[1],outTranslate[2]); } else { outTranslateHnd.set(0.0, 0.0, 0.0); outRotateHnd.set(0.0, 0.0, 0.0); } } outTranslateHnd.setClean(); outRotateHnd.setClean(); } else if (plug.attribute() == outputGeom) { unsigned int index = plug.logicalIndex(); MPlug inPlug(thisNode,input); inPlug.selectAncestorLogicalIndex(index,input); MDataHandle hInput = data.inputValue(inPlug); MDataHandle hGeom = hInput.child(inputGeom); m_data->m_localToWorldMatrix = hGeom.geometryTransformMatrix(); MDataHandle hOutput = data.outputValue(plug); hOutput.copy(hGeom); MObject mesh = hGeom.asMesh(); if (!mesh.isNull()) { if (m_data->m_env > 0.0) { m_data->m_falloffMode = data.inputValue( aFalloffMode ).asShort(); m_data->m_falloffRadius = data.inputValue( aFalloffRadius ).asFloat(); m_data->m_falloffCurve = MRampAttribute(thisNode, aFalloffCurve, &status); m_data->m_relativeMatrix = data.inputValue( aRelativeMatrix ).asMatrix(); m_data->m_deformMatrix = data.inputValue( aDeformMatrix ).asMatrix(); m_data->m_relativeInverseMatrix = m_data->m_relativeMatrix.inverse(); m_data->m_localToWorldMatrixInverse = m_data->m_localToWorldMatrix.inverse(); MTransformationMatrix defMat(m_data->m_relativeMatrix); m_data->m_relativeMatrixTranslate = defMat.translation(MSpace::kWorld); MFnMesh meshFn(mesh, &status); CHECK_MSTATUS_AND_RETURN_IT(status); m_data->m_numverts = meshFn.numVertices(); status = meshFn.getPoints(m_data->m_points, MSpace::kWorld); CHECK_MSTATUS_AND_RETURN_IT(status); m_data->m_weights.setLength(m_data->m_numverts); for (unsigned int idx=0; idx < m_data->m_numverts; idx++) { m_data->m_weights[idx]= weightValue(data,index,idx); } ThreadedDeform td; td.data = m_data; parallel_for( blocked_range<int>( 0, m_data->m_numverts ), td ); status = meshFn.setPoints(m_data->m_points, MSpace::kWorld); } } } data.setClean(plug); return status; } MStatus chwSurfaceTweak::postConstructor_initialise_ramp_curve( MObject &rampObj, int index, float position, float value, int interpolation) { MStatus status; MObject thisNode = this->thisMObject(); MPlug rampPlug( thisNode, rampObj ); MPlug elementPlug = rampPlug.elementByLogicalIndex( index, &status ); MPlug positionPlug = elementPlug.child(0, &status); status = positionPlug.setFloat(position); MPlug valuePlug = elementPlug.child(1); status = valuePlug.setFloat(value); MPlug interpPlug = elementPlug.child(2); interpPlug.setInt(interpolation); return MS::kSuccess; } void chwSurfaceTweak::postConstructor() { MStatus status; status = postConstructor_initialise_ramp_curve( aFalloffCurve, 0, 0.0f, 1.0f, 2 ); CHECK_MSTATUS(status); status = postConstructor_initialise_ramp_curve( aFalloffCurve, 1, 1.0f, 0.0f, 2 ); CHECK_MSTATUS(status); }
#include "chwSurfaceTweak.h" const MTypeId chwSurfaceTweak::typeId( 0x89007 ); const MString chwSurfaceTweak::typeName( "chwSurfaceTweak" ); MObject chwSurfaceTweak::aInVert; MObject chwSurfaceTweak::aFalloffMode; MObject chwSurfaceTweak::aFalloffCurve; MObject chwSurfaceTweak::aFalloffRadius; MObject chwSurfaceTweak::aRelativeMatrix; MObject chwSurfaceTweak::aDeformMatrix; MObject chwSurfaceTweak::aOutTranslate; MObject chwSurfaceTweak::aOutTranslateX; MObject chwSurfaceTweak::aOutTranslateY; MObject chwSurfaceTweak::aOutTranslateZ; MObject chwSurfaceTweak::aOutRotate; MObject chwSurfaceTweak::aOutRotateX; MObject chwSurfaceTweak::aOutRotateY; MObject chwSurfaceTweak::aOutRotateZ; chwSurfaceTweak::chwSurfaceTweak() { m_data = new chwSurfaceTweakData; } chwSurfaceTweak::~chwSurfaceTweak() { delete m_data; } void* chwSurfaceTweak::creator(){ return new chwSurfaceTweak(); } MStatus chwSurfaceTweak::initialize() { MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MFnMatrixAttribute mAttr; MRampAttribute rAttr; MFnUnitAttribute uAttr; aInVert = nAttr.create( "vertex", "v", MFnNumericData::kLong ); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setMin(0); nAttr.setDefault(0); nAttr.setReadable(true); nAttr.setWritable(true); addAttribute(aInVert); aFalloffMode = eAttr.create( "falloffMode", "fom" ); eAttr.addField( "Volume", 0); eAttr.setKeyable(true); eAttr.setStorable(true); eAttr.setReadable(true); eAttr.setWritable(true); eAttr.setDefault(0); addAttribute(aFalloffMode); aFalloffRadius = nAttr.create( "falloffRadius", "for", MFnNumericData::kFloat, 1.0 ); nAttr.setWritable(true); nAttr.setStorable(true); nAttr.setKeyable (true); nAttr.setConnectable(true); nAttr.setMin(0.0); nAttr.setDefault(1.0); addAttribute(aFalloffRadius); aFalloffCurve = rAttr.createCurveRamp("falloffCurve", "foc"); addAttribute(aFalloffCurve); aRelativeMatrix = mAttr.create( "relativeMatrix", "rm" ); mAttr.setConnectable(true); addAttribute(aRelativeMatrix); aDeformMatrix = mAttr.create( "deformMatrix", "dm" ); mAttr.setConnectable(true); addAttribute(aDeformMatrix); aOutTranslateX = nAttr.create( "outTranslateX", "ostx", MFnNumericData::kDouble, 0.0 ); aOutTranslateY = nAttr.create( "outTranslateY", "osty", MFnNumericData::kDouble, 0.0 ); aOutTranslateZ = nAttr.create( "outTranslateZ", "ostz", MFnNumericData::kDouble, 0.0 ); aOutTranslate = nAttr.create( "outTranslate", "os", aOutTranslateX, aOutTranslateY, aOutTranslateZ ); addAttribute(aOutTranslate); aOutRotateX = uAttr.create( "outRotateX", "osrx", MFnUnitAttribute::kAngle, 0.0 ); aOutRotateY = uAttr.create( "outRotateY", "osry", MFnUnitAttribute::kAngle, 0.0 ); aOutRotateZ = uAttr.create( "outRotateZ", "osrz", MFnUnitAttribute::kAngle, 0.0 ); aOutRotate = nAttr.create( "outRotate", "osr", aOutRotateX, aOutRotateY, aOutRotateZ ); addAttribute(aOutRotate); attributeAffects( chwSurfaceTweak::aInVert, chwSurfaceTweak::aOutTranslate ); attributeAffects( chwSurfaceTweak::aInVert, chwSurfaceTweak::aOutRotate ); attributeAffects( chwSurfaceTweak::inputGeom, chwSurfaceTweak::aOutTranslate ); attributeAffects( chwSurfaceTweak::inputGeom, chwSurfaceTweak::aOutRotate ); attributeAffects( chwSurfaceTweak::aRelativeMatrix, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aDeformMatrix, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aFalloffMode, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aFalloffCurve, chwSurfaceTweak::outputGeom ); attributeAffects( chwSurfaceTweak::aFalloffRadius, chwSurfaceTweak::outputGeom ); MGlobal::executeCommand( "makePaintable -attrType \"multiFloat\" -sm \"deformer\" \"chwSurfaceTweak\" \"weights\";" ); return MStatus::kSuccess; } MStatus chwSurfaceTweak::compute(const MPlug& plug, MDataBlock& data) { MStatus status; MObject thisNode = this->thisMObject(); m_data->m_env = data.inputValue(envelope).asFloat(); m_data->m_vert = data.inputValue( aInVert ).asInt(); if (plug == aOutTranslate || plug == aOutRotate || plug.parent() == aOutTranslate || plug.parent() == aOutRotate ) { MDataHandle outTranslateHnd = data.outputValue( aOutTranslate ); MDataHandle outRotateHnd = data.outputValue( aOutRotate ); MPlug inPlug(thisNode,input); inPlug.selectAncestorLogicalIndex(0,input); MDataHandle hInput = data.inputValue(inPlug, &status); CHECK_MSTATUS_AND_RETURN_IT(status); MDataHandle hGeom = hInput.child(inputGeom); MObject mesh = hGeom.asMesh(); if (!mesh.isNull()) { MFnMesh meshFn(mesh, &status); CHECK_MSTATUS_AND_RETURN_IT(status); m_data->m_numverts = meshFn.numVertices(); status = meshFn.getPoints(m_data->m_points, MSpace::kWorld); CHECK_MSTATUS_AND_RETURN_IT(status); status = meshFn.getVertexNormals(false, m_data->m_normals, MSpace::kWorld); CHECK_MSTATUS_AND_RETURN_IT(status); int prev; MItMeshVertex iter(mesh); iter.setIndex(m_data->m_vert, prev); iter.getConnectedVertices(m_data->m_conids); if (m_data->m_conids.length() > 1) { m_data->m_aimvert = m_data->m_conids[0]; m_data->m_upvert = m_data->m_conids[1]; } else { return MStatus::kFailure; } if (m_data->m_vert < m_data->m_numverts) { MMatrix m; MVector vx, vy, vz; MPoint outTranslate; double outRotate[3]; vx = m_data->m_normals[m_data->m_vert]; vy = (m_data->m_points[m_data->m_upvert] - m_data->m_points[m_data->m_vert]).normal(); vz = (vx ^ vy).normal(); vy = (vx ^ vz).normal(); m[0][0] = vx[0]; m[0][1] = vx[1]; m[0][2] = vx[2]; m[0][3] = 0.f; m[1][0] = vy[0]; m[1][1] = vy[1]; m[1][2] = vy[2]; m[1][3] = 0.f; m[2][0] = vz[0]; m[2][1] = vz[1]; m[2][2] = vz[2]; m[2][3] = 0.f; m[3][0] = m_data->m_points[m_data->m_vert][0]; m[3][1] = m_data->m_points[m_data->m_vert][1]; m[3][2] = m_data->m_points[m_data->m_vert][2]; m[3][3] = 1.f; MTransformationMatrix outMatrix(m); MTransformationMatrix::RotationOrder order; outMatrix.getRotation(outRotate, order, MSpace::kWorld); outTranslate = outMatrix.getTranslation(MSpace::kWorld); outRotateHnd.set3Double(outRotate[0], outRotate[1], outRotate[2]); outTranslateHnd.set3Double(outTranslate[0],outTranslate[1],outTranslate[2]); } else { outTranslateHnd.set(0.0, 0.0, 0.0); outRotateHnd.set(0.0, 0.0, 0.0); } } outTranslateHnd.setClean(); outRotateHnd.setClean(); } else if (plug.attribute() == outputGeom) { unsigned int index = plug.logicalIndex(); MPlug inPlug(thisNode,input); inPlug.selectAncestorLogicalIndex(index,input); MDataHandle hInput = data.inputValue(inPlug); MDataHandle hGeom = hInput.child(inputGeom); m_data->m_localToWorldMatrix = hGeom.geometryTransformMatrix(); MDataHandle hOutput = data.outputValue(plug); hOutput.copy(hGeom); MObject mesh = hGeom.asMesh(); if (!mesh.isNull()) { if (m_data->m_env > 0.0) { m_data->m_falloffMode = data.inputValue( aFalloffMode ).asShort(); m_data->m_falloffRadius = data.inputValue( aFalloffRadius ).asFloat(); m_data->m_falloffCurve = MRampAttribute(thisNode, aFalloffCurve, &status); m_data->m_relativeMatrix = data.inputValue( aRelativeMatrix ).asMatrix(); m_data->m_deformMatrix = data.inputValue( aDeformMatrix ).asMatrix(); m_data->m_relativeInverseMatrix = m_data->m_relativeMatrix.inverse(); m_data->m_localToWorldMatrixInverse = m_data->m_localToWorldMatrix.inverse(); MTransformationMatrix defMat(m_data->m_relativeMatrix); m_data->m_relativeMatrixTranslate = defMat.translation(MSpace::kWorld); MFnMesh meshFn(mesh, &status); CHECK_MSTATUS_AND_RETURN_IT(status); m_data->m_numverts = meshFn.numVertices(); status = meshFn.getPoints(m_data->m_points, MSpace::kWorld); CHECK_MSTATUS_AND_RETURN_IT(status); m_data->m_weights.setLength(m_data->m_numverts); for (unsigned int idx=0; idx < m_data->m_numverts; idx++) { m_data->m_weights[idx]= weightValue(data,index,idx); } ThreadedDeform td; td.data = m_data; parallel_for( blocked_range<int>( 0, m_data->m_numverts ), td ); status = meshFn.setPoints(m_data->m_points, MSpace::kWorld); } } } data.setClean(plug); return status; }
void chwSurfaceTweak::postConstructor() { MStatus status; status = postConstructor_initialise_ramp_curve( aFalloffCurve, 0, 0.0f, 1.0f, 2 ); CHECK_MSTATUS(status); status = postConstructor_initialise_ramp_curve( aFalloffCurve, 1, 1.0f, 0.0f, 2 ); CHECK_MSTATUS(status); }
MStatus chwSurfaceTweak::postConstructor_initialise_ramp_curve( MObject &rampObj, int index, float position, float value, int interpolation) { MStatus status; MObject thisNode = this->thisMObject(); MPlug rampPlug( thisNode, rampObj ); MPlug elementPlug = rampPlug.elementByLogicalIndex( index, &status ); MPlug positionPlug = elementPlug.child(0, &status); status = positionPlug.setFloat(position); MPlug valuePlug = elementPlug.child(1); status = valuePlug.setFloat(value); MPlug interpPlug = elementPlug.child(2); interpPlug.setInt(interpolation); return MS::kSuccess; }
function_block-full_function
[ { "content": "class chwVertexBindData\n\n{\n\n\tpublic:\n\n\t\tMPointArray\t\tm_drvpoints;\n\n\t\tMPointArray\t\tm_defpoints;\n\n\t\tMFloatArray\t\tm_weights;\n\n\t\tMIntArray\t\tm_mapping;\n\n\t\tMMatrix\t\t\tm_localToWorldMatrix;\n\n\t\tfloat\t\t\tm_cutoffDistance;\n\n\t\tfloat\t\t\tm_searchDistance;\n\n};\n\n\n", "file_path": "include/chwVertexBind.h", "rank": 0, "score": 71214.335526944 }, { "content": "class chwMeshRelax : public MPxDeformerNode\n\n{\n\n\tpublic:\n\n\t\t\t\t\tchwMeshRelax();\n\n\t\t\tvirtual ~chwMeshRelax();\n\n\n\n\t\t\tvirtual MStatus \tcompute(const MPlug& plug, MDataBlock& data);\n\n\t\t\tstatic void* \t\tcreator();\n\n\t\t\tstatic MStatus \tinitialize();\n\n\n\n\tpublic:\n\n\t\tstatic MObject \t\taIterations;\n\n\t\tstatic const MTypeId \ttypeId;\n\n\t\tstatic const MString \ttypeName;\n\n\tprivate:\n\n\t\tchwEdgeRelax m_relax;\n\n};\n\n\n\n#endif // CHWMESHRELAX_H\n", "file_path": "include/chwMeshRelax.h", "rank": 1, "score": 61325.964982955564 }, { "content": "class chwVertexBind : public MPxDeformerNode\n\n{\n\n\tpublic:\n\n\t\t\t\t\t\t\t\tchwVertexBind();\n\n\t\tvirtual\t\t\t\t\t~chwVertexBind();\n\n\t\tstatic void*\t\t\tcreator();\n\n\t\tstatic MStatus\t\t\tinitialize();\n\n\n\n\t\tvirtual MStatus\t\t\tdeform(MDataBlock& data,\n\n\t\t\t\t\t\t\t\t\tMItGeometry& iter,\n\n\t\t\t\t\t\t\t\t\tconst MMatrix& mat,\n\n\t\t\t\t\t\t\t\t\tunsigned int mIndex);\n\n\n\n\t\tvirtual MStatus\t\t\tinitializeMapping( MDataBlock& data, MItGeometry& iter, const MMatrix &localToWorldMatrix);\n\n\n\n\t\tstatic int\t\t\t\tgetClosestPoint( MPoint &pt, MPointArray &points ) ;\n\n\n\n\t\tvirtual MObject&\t\taccessoryAttribute() const;\n\n\n\n\t\t// Attributes\n", "file_path": "include/chwVertexBind.h", "rank": 2, "score": 60907.16995348032 }, { "content": "class chwSurfaceTweakData\n\n{\n\n\tpublic:\n\n\t\tunsigned int\t\t\tm_vert;\n\n\t\tunsigned int\t\t\tm_upvert;\n\n\t\tunsigned int\t\t\tm_aimvert;\n\n\n\n\t\tunsigned int\t\t\tm_numverts;\n\n\n\n\t\tfloat\t\t\t\t\tm_env;\n\n\t\tshort\t\t\t\t\tm_falloffMode;\n\n\t\tfloat\t\t\t\t\tm_falloffRadius;\n\n\t\tMRampAttribute\t\t\tm_falloffCurve;\n\n\n\n\t\tMMatrix\t\t\t\t\tm_deformMatrix;\n\n\t\tMMatrix\t\t\t\t\tm_relativeMatrix;\n\n\t\tMMatrix\t\t\t\t\tm_relativeInverseMatrix;\n\n\t\tMMatrix\t\t\t\t\tm_localToWorldMatrix;\n\n\t\tMMatrix\t\t\t\t\tm_localToWorldMatrixInverse;\n\n\n\n\t\tMVector\t\t\t\t\tm_relativeMatrixTranslate;\n\n\n\n\t\tMPointArray\t\t\t\tm_points;\n\n\t\tMFloatVectorArray\t\tm_normals;\n\n\t\tMFloatArray\t\t\t\tm_weights;\n\n\n\n\t\tMIntArray\t\t\t\tm_conids;\n\n};\n\n\n", "file_path": "include/chwSurfaceTweak.h", "rank": 3, "score": 58972.80964150416 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWMESHRELAX_H\n\n#define CHWMESHRELAX_H\n\n\n\n#include <maya/MPxDeformerNode.h>\n\n#include <maya/MItGeometry.h>\n\n#include <maya/MTypeId.h>\n\n#include <maya/MPlug.h>\n\n#include <maya/MDataBlock.h>\n\n#include <maya/MDataHandle.h>\n\n#include <maya/MPoint.h>\n\n#include <maya/MPointArray.h>\n\n#include <maya/MFnMesh.h>\n\n#include <maya/MVector.h>\n\n#include <maya/MFloatVectorArray.h>\n\n#include <maya/MGlobal.h>\n\n#include <maya/MMatrix.h>\n\n#include <maya/MFnNumericAttribute.h>\n\n#include <maya/MIOStream.h>\n\n#include <chwEdgeRelax.h>\n\n\n\n\n", "file_path": "include/chwMeshRelax.h", "rank": 4, "score": 51510.89715532284 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwMeshRelax.h", "rank": 5, "score": 51503.246659614466 }, { "content": "\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tdata->m_mapping[idx] = -1;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\tstruct ThreadedDeform\n\n\t\t{\n\n\t\t\tchwVertexBindData *data;\n\n\t\t\tvoid operator()( const blocked_range<int>& range ) const {\n\n\t\t\t\tfor ( int idx = range.begin(); idx!=range.end(); ++idx )\n\n\t\t\t\t{\n\n\t\t\t\t\tif (data->m_weights[idx] != 0.f)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tif (data->m_mapping[idx] >= 0)\n\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tdata->m_defpoints[idx] *= data->m_localToWorldMatrix;\n\n\t\t\t\t\t\t\tdata->m_defpoints[idx] += ((data->m_drvpoints[data->m_mapping[idx]] - data->m_defpoints[idx]) * data->m_weights[idx]);\n\n\t\t\t\t\t\t\tdata->m_defpoints[idx] *= data->m_localToWorldMatrix.inverse();\n", "file_path": "include/chwVertexBind.h", "rank": 6, "score": 51097.1070476012 }, { "content": "\t\tstatic MObject \t\taDriverMesh;\n\n\t\tstatic MObject \t\taCutoffDistance;\n\n\t\tstatic MObject \t\taSearchDistance;\n\n\t\tstatic MObject \t\taInitialize;\n\n\t\tstatic MObject \t\taVertexMap;\n\n\n\n\t\t// PLUGIN\n\n\t\tstatic MTypeId \t\ttypeId;\n\n\t\tstatic const MString \ttypeName;\n\n\tprivate:\n\n\t\tchwVertexBindData *m_data;\n\n\n\n\t\tstruct ThreadedInitialize\n\n\t\t{\n\n\t\t\tchwVertexBindData *data;\n\n\t\t\tvoid operator()( const blocked_range<int>& range ) const {\n\n\t\t\t\tfloat maxdistance;\n\n\t\t\t\tfloat curdistance;\n\n\t\t\t\tfor ( int idx = range.begin(); idx!=range.end(); ++idx )\n\n\t\t\t\t{\n", "file_path": "include/chwVertexBind.h", "rank": 7, "score": 51093.46988950799 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWVERTEXBIND_H\n\n#define CHWVERTEXBIND_H\n\n\n\n#include <maya/MStatus.h>\n\n#include <maya/MObject.h>\n\n#include <maya/MPoint.h>\n\n#include <maya/MTypeId.h>\n\n#include <maya/MString.h>\n\n#include <maya/MPointArray.h>\n\n#include <maya/MDataBlock.h>\n\n#include <maya/MItGeometry.h>\n\n#include <maya/MFnTypedAttribute.h>\n\n#include <maya/MFnEnumAttribute.h>\n\n#include <maya/MFnNumericAttribute.h>\n\n#include <maya/MPxDeformerNode.h>\n\n#include <maya/MGlobal.h>\n\n#include <maya/MItMeshVertex.h>\n\n#include <maya/MMatrix.h>\n\n#include <maya/MArrayDataBuilder.h>\n\n\n\n#include \"float.h\"\n\n\n\n// THREADING\n\n#include \"tbb/tbb.h\"\n\nusing namespace tbb;\n\n\n", "file_path": "include/chwVertexBind.h", "rank": 8, "score": 51088.71918057718 }, { "content": "\t\t\t\t\tmaxdistance = FLT_MAX;\n\n\t\t\t\t\tcurdistance = FLT_MIN;\n\n\n\n\t\t\t\t\tdata->m_mapping[idx] = -1;\n\n\t\t\t\t\tMPoint defpoint = data->m_defpoints[idx] * data->m_localToWorldMatrix;\n\n\n\n\t\t\t\t\tfor ( int idy = 0; idy < data->m_drvpoints.length(); idy++ )\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tcurdistance = defpoint.distanceTo( data->m_drvpoints[idy] );\n\n\t\t\t\t\t\tif (curdistance <= data->m_cutoffDistance)\n\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tdata->m_mapping[idx] = idy;\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (curdistance < maxdistance)\n\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tmaxdistance = curdistance;\n\n\t\t\t\t\t\t\tdata->m_mapping[idx] = idy;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif(maxdistance > data->m_searchDistance)\n", "file_path": "include/chwVertexBind.h", "rank": 9, "score": 51087.37520128013 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwVertexBind.h", "rank": 10, "score": 51081.49583903719 }, { "content": "\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\n\n};\n\n\n\n#endif // CHWVERTEXBIND_H\n", "file_path": "include/chwVertexBind.h", "rank": 11, "score": 51078.921846586 }, { "content": "class chwSurfaceTweak : public MPxDeformerNode\n\n{\n\n\tpublic:\n\n\t\t\t\t\t\t\tchwSurfaceTweak();\n\n\t\tvirtual\t\t\t\t~chwSurfaceTweak();\n\n\t\tstatic void*\t\tcreator();\n\n\t\tstatic MStatus\t\tinitialize();\n\n\n\n\t\tvirtual MStatus\t\tcompute( const MPlug& plug, MDataBlock& data );\n\n\t\tvirtual\tvoid\t\tpostConstructor();\n\n\n\n\t\tstatic MObject aInVert;\n\n\n\n\t\tstatic MObject aFalloffMode;\n\n\t\tstatic MObject aFalloffCurve;\n\n\t\tstatic MObject aFalloffRadius;\n\n\t\tstatic MObject aRelativeMatrix;\n\n\t\tstatic MObject aDeformMatrix;\n\n\n\n\t\tstatic MObject aOutTranslate;\n", "file_path": "include/chwSurfaceTweak.h", "rank": 12, "score": 47502.733300620705 }, { "content": "class chwCollisionData\n\n{\n\n\tpublic:\n\n\t\tMFloatPointArray\t\t\tm_points;\n\n\t\tMFloatVectorArray\t\t\tm_normals;\n\n\t\tMFloatArray\t\t\t\t\tm_weights;\n\n\t\tMMeshIntersector\t\t\tm_intersector;\n\n\t\tMMeshIsectAccelParams\t\tm_mmAccelParams;\n\n\t\tMIntArray\t\t\t\t\tm_collided;\n\n\t\tMRampAttribute\t\t\t\tm_bulgeRampAttribute;\n\n\n\n\t\tunsigned int\t\t\t\tm_numpoints;\n\n\n\n\t\t// USER SETTINGS\n\n\t\tfloat\t\t\t\t\t\tm_collisionStrength;\n\n\t\tfloat\t\t\t\t\t\tm_bulgeStrength;\n\n\t\tfloat\t\t\t\t\t\tm_bulgeDistance;\n\n\n\n\t\tMBoundingBox\t\t\t\tm_boxin;\n\n\t\tMBoundingBox\t\t\t\tm_boxcol;\n\n\n\n\t\tfloat\t\t\t\t\t\tm_defmax;\n\n};\n\n\n", "file_path": "include/chwCollision.h", "rank": 13, "score": 46212.838111551115 }, { "content": "class chwNormalOffsetData\n\n{\n\n\tpublic:\n\n\t\tunsigned int\t\tm_numverts;\n\n\t\tunsigned int\t\tm_smooth;\n\n\t\tfloat\t\t\t\tm_env;\n\n\t\tfloat\t\t\t\tm_strength;\n\n\t\tMPointArray\t\t\tm_points;\n\n\t\tMFloatVectorArray\tm_normals;\n\n\t\tMFloatArray\t\t\tm_weights;\n\n};\n\n\n", "file_path": "include/chwNormalOffset.h", "rank": 14, "score": 41803.72970493951 }, { "content": "class chwEdgeRelaxData\n\n{\n\n\tpublic:\n\n\t\tunsigned int\t\t\t\t\tm_vertcount;\n\n\t\tunsigned int\t\t\t\t\tm_cachedcount;\n\n\t\tunsigned int\t\t\t\t\tm_iterations;\n\n\t\tMPointArray\t\t\t\t\t\tm_points;\n\n\t\tMPointArray\t\t\t\t\t\tm_relaxpoints;\n\n\t\tstd::vector<std::vector<int>>\tm_conids;\n\n\t\tMFloatArray\t\t\t\t\t\tm_weights;\n\n};\n\n\n", "file_path": "include/chwEdgeRelax.h", "rank": 15, "score": 41803.72970493951 }, { "content": "class chwCollision : public MPxDeformerNode\n\n{\n\npublic:\n\n\t\t\t\t\tchwCollision();\n\n\t\tvirtual\t\t~chwCollision();\n\n\n\n\t\tvirtual MStatus\t\tcompute(const MPlug& plug, MDataBlock& data);\n\n\t\tstatic void*\t\tcreator();\n\n\t\tstatic MStatus\t\tinitialize();\n\n\n\n\t\tvirtual\tvoid\t\tpostConstructor();\n\n\n\npublic:\n\n\t\tstatic MObject\t\taCollisionStrength;\n\n\t\tstatic MObject\t\taCollisionMesh;\n\n\t\tstatic MObject\t\taCollisionMeshName;\n\n\t\tstatic MObject\t\taCollisionMeshList;\n\n\t\tstatic MObject\t\taCollisionBulgeStrength;\n\n\t\tstatic MObject\t\taCollisionBulgeDistance;\n\n\t\tstatic MObject\t\taCollisionBulgeRamp;\n", "file_path": "include/chwCollision.h", "rank": 16, "score": 37983.22345352918 }, { "content": "def chwSurfaceTweak():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 1:\n\n\t\tselection = selection[0]\n\n\t\tif selection.count('vtx'):\n\n\t\t\tsplits = selection.split('.')\n\n\t\t\tmesh = splits[0]\n\n\t\t\tvtx = re.sub(\"[^0-9]\", \"\", splits[1])\n\n\t\t\tname = util.nextName('chwSurfaceTweak_'+mesh)\n\n\t\t\tss = cmds.deformer(mesh, type='chwSurfaceTweak')[0]\n\n\t\t\tcmds.setAttr(ss+'.vertex', int(vtx))\n\n\t\t\tpivot_ctrl = cmds.group(em=True, name=name)\n\n\t\t\toffset_ctrl = util.makeControlSphere(name+'_Offset', 0.25)\n\n\t\t\tsticky_ctrl = util.makeControlSphere(name+'_Deform')\n\n\t\t\tcmds.parent(sticky_ctrl, offset_ctrl)\n\n\t\t\tcmds.parent(offset_ctrl, pivot_ctrl)\n\n\t\t\tcmds.addAttr(sticky_ctrl, at='double', ln='envelope', k=1, dv=1, min=0, max=1)\n\n\t\t\tcmds.addAttr(sticky_ctrl, at='enum', ln='falloffMode', k=1, en='Volume')\n\n\t\t\tcmds.addAttr(sticky_ctrl, at='double', ln='falloffRadius', k=1, dv=1, min=0)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.falloffMode', ss+'.falloffMode', f=True)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.falloffRadius', ss+'.falloffRadius', f=True)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.envelope', ss+'.envelope', f=True)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.worldMatrix[0]', ss+'.deformMatrix')\n\n\t\t\tcmds.connectAttr(offset_ctrl+'.worldMatrix[0]', ss+'.relativeMatrix')\n\n\t\t\tcmds.connectAttr(ss+'.outRotate', pivot_ctrl+'.rotate')\n\n\t\t\tcmds.connectAttr(ss+'.outTranslate', pivot_ctrl+'.translate')\n\n\t\t\tcmds.select(sticky_ctrl, r=True)\n\n\t\t\treturn [pivot_ctrl, offset_ctrl, sticky_ctrl, ss]\n\n\t\telse:\n\n\t\t\tprint \"chwSurfaceTweak: You need to select a mesh vertex!\\n\"\n\n\telse:\n", "file_path": "chwTools/scripts/chwTools/deformers.py", "rank": 17, "score": 37921.35208660156 }, { "content": "class chwNormalOffset : public MPxDeformerNode\n\n{\n\n\tpublic:\n\n\t\t\t\t\t\t\t\tchwNormalOffset();\n\n\t\tvirtual\t\t\t\t\t~chwNormalOffset();\n\n\n\n\t\tvirtual MStatus\t\t\tcompute(const MPlug& plug, MDataBlock& data);\n\n\t\tstatic void*\t\t\tcreator();\n\n\t\tstatic MStatus\t\t\tinitialize();\n\n\n\n\tpublic:\n\n\t\tstatic MObject\t\t\taStrength;\n\n\t\tstatic MObject\t\t\taNormalSmooth;\n\n\n\n\t\tstatic const MTypeId\ttypeId;\n\n\t\tstatic const MString\ttypeName;\n\n\n\n\tprivate:\n\n\t\t\tchwEdgeRelax m_relax;\n\n\t\t\tchwNormalOffsetData *m_data;\n", "file_path": "include/chwNormalOffset.h", "rank": 18, "score": 34939.99358871753 }, { "content": "def chwMeshRelax():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 1:\n\n\t\tcmds.deformer(selection, type='chwMeshRelax')\n\n\telse:\n", "file_path": "chwTools/scripts/chwTools/deformers.py", "rank": 19, "score": 34668.12466557332 }, { "content": "def chwVertexBind():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 2:\n\n\t\tvs = cmds.deformer(selection[-1], type='chwVertexBind')\n\n\t\tcmds.connectAttr(selection[0]+'.worldMesh[0]', vs[0]+'.driverMesh')\n\n\t\tcmds.setAttr(vs[0]+'.initialize', 1)\n\n\telse:\n", "file_path": "chwTools/scripts/chwTools/deformers.py", "rank": 20, "score": 34392.57571173141 }, { "content": "\t\t\t\tfor ( int idx = range.begin(); idx!=range.end(); ++idx )\n\n\t\t\t\t{\n\n\t\t\t\t\tdata->m_collided[idx] = 0;\n\n\t\t\t\t\tif (data->m_boxcol.contains(data->m_points[idx]))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tbool bAllIntersections = colFn->allIntersections(data->m_points[idx], data->m_normals[idx], NULL, NULL, false, MSpace::kWorld, 9999.f, false,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&data->m_mmAccelParams, false, m_hitPoints, &m_faHitRayParams, &m_iaHitFaces,\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t&m_iaHitTriangles, &m_faHitBary1, &m_faHitBary2, 0.000001f, &m_status);\n\n\t\t\t\t\t\tCHECK_MSTATUS(m_status);\n\n\t\t\t\t\t\tif (bAllIntersections)\n\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tunsigned int numHits = m_hitPoints.length();\n\n\t\t\t\t\t\t\tif ((numHits % 2) != 0)\n\n\t\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\t\tdata->m_intersector.getClosestPoint(data->m_points[idx], m_pointOnMesh);\n\n\t\t\t\t\t\t\t\tMFloatPoint colpoint = m_pointOnMesh.getPoint();\n\n\t\t\t\t\t\t\t\tMFloatVector offset = colpoint - data->m_points[idx];\n\n\t\t\t\t\t\t\t\tdata->m_points[idx] += offset * data->m_weights[idx] * data->m_collisionStrength;\n\n\t\t\t\t\t\t\t\tfloat l = offset.length();\n\n\t\t\t\t\t\t\t\ttbb::mutex::scoped_lock lock;\n", "file_path": "include/chwCollision.h", "rank": 21, "score": 26503.166183592464 }, { "content": "\t\t\t\t\t\t\t\tlock.acquire(m_mutex);\n\n\t\t\t\t\t\t\t\tif (l > data->m_defmax)\n\n\t\t\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\t\t\tdata->m_defmax = l;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tlock.release();\n\n\t\t\t\t\t\t\t\tdata->m_collided[idx] = 1;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\n\n\t\tstruct ThreadedBulge\n\n\t\t{\n\n\t\t\tchwCollisionData *data;\n\n\t\t\tvoid operator()( const blocked_range<int>& range ) const {\n\n\t\t\t\tMStatus\t\t\t\t\t\tm_status;\n\n\t\t\t\tMPointOnMesh\t\t\t\tm_pointOnMesh;\n", "file_path": "include/chwCollision.h", "rank": 22, "score": 26503.119155387176 }, { "content": "\t\t\t\tfor ( int idx = range.begin(); idx!=range.end(); ++idx )\n\n\t\t\t\t{\n\n\t\t\t\t\tif (!data->m_collided[idx])\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tfloat rampval;\n\n\t\t\t\t\t\tdata->m_intersector.getClosestPoint(data->m_points[idx], m_pointOnMesh);\n\n\t\t\t\t\t\tMFloatPoint colpoint = m_pointOnMesh.getPoint();\n\n\t\t\t\t\t\tMFloatVector offset = colpoint - data->m_points[idx];\n\n\t\t\t\t\t\tfloat ramppos = offset.length() / data->m_bulgeDistance;\n\n\t\t\t\t\t\tdata->m_bulgeRampAttribute.getValueAtPosition(ramppos, rampval, &m_status);\n\n\t\t\t\t\t\tCHECK_MSTATUS(m_status);\n\n\t\t\t\t\t\tfloat bulgestr = rampval * data->m_defmax * data->m_bulgeStrength;\n\n\t\t\t\t\t\tdata->m_points[idx] += data->m_normals[idx] * data->m_weights[idx] * data->m_collisionStrength * bulgestr;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n};\n\n\n\n#endif // CHWCOLLISION_H\n", "file_path": "include/chwCollision.h", "rank": 23, "score": 26502.34334556681 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWCOLLISION_H\n\n#define CHWCOLLISION_H\n\n\n\n#include <string>\n\n#include <iostream>\n\n#include <sstream>\n\n\n\n#include <maya/MPxDeformerNode.h>\n\n#include <maya/MItGeometry.h>\n\n#include <maya/MTypeId.h>\n\n#include <maya/MPlug.h>\n\n#include <maya/MDataBlock.h>\n\n#include <maya/MDataHandle.h>\n\n#include <maya/MPoint.h>\n\n#include <maya/MPointArray.h>\n\n#include <maya/MFloatArray.h>\n\n#include <maya/MFnMesh.h>\n", "file_path": "include/chwCollision.h", "rank": 24, "score": 26501.349918099313 }, { "content": "\n\n\t\tstatic const MTypeId typeId;\n\n\t\tstatic const MString typeName;\n\nprivate:\n\n\t\tchwCollisionData *m_data;\n\n\t\tMStatus postConstructor_initialise_ramp_curve(MObject &rampObj, int index, float position, float value, int interpolation);\n\n\n\n\t\tstruct ThreadedCollide\n\n\t\t{\n\n\t\t\tchwCollisionData *data;\n\n\t\t\tMFnMesh *colFn;\n\n\t\t\tvoid operator()( const blocked_range<int>& range ) const {\n\n\t\t\t\tMFloatPointArray\t\t\tm_hitPoints;\n\n\t\t\t\tMFloatArray\t\t\t\t\tm_faHitRayParams;\n\n\t\t\t\tMIntArray\t\t\t\t\tm_iaHitFaces;\n\n\t\t\t\tMIntArray\t\t\t\t\tm_iaHitTriangles;\n\n\t\t\t\tMFloatArray\t\t\t\t\tm_faHitBary1;\n\n\t\t\t\tMFloatArray\t\t\t\t\tm_faHitBary2;\n\n\t\t\t\tMStatus\t\t\t\t\t\tm_status;\n\n\t\t\t\tMPointOnMesh\t\t\t\tm_pointOnMesh;\n", "file_path": "include/chwCollision.h", "rank": 25, "score": 26500.88406020844 }, { "content": "#include <maya/MVector.h>\n\n#include <maya/MFloatVectorArray.h>\n\n#include <maya/MFloatPointArray.h>\n\n#include <maya/MGlobal.h>\n\n#include <maya/MMatrix.h>\n\n#include <maya/MFnNumericAttribute.h>\n\n#include <maya/MFnTypedAttribute.h>\n\n#include <maya/MFnCompoundAttribute.h>\n\n#include <maya/MMeshIntersector.h>\n\n#include <maya/MBoundingBox.h>\n\n#include <maya/MDagPath.h>\n\n#include <maya/MRampAttribute.h>\n\n#include <maya/MFnStringData.h>\n\n\n\n// THREADING\n\n#include \"tbb/tbb.h\"\n\nusing namespace tbb;\n\n\n\ntypedef mutex mMutex;\n\nstatic mMutex m_mutex;\n\n\n", "file_path": "include/chwCollision.h", "rank": 26, "score": 26496.762395767484 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwCollision.h", "rank": 27, "score": 26492.742647899955 }, { "content": "\n\n\t\tMFloatArray w(vertCount);\n\n\t\tif(env != 0.00 && iterations != 0)\n\n\t\t{\n\n\t\t\tfor (unsigned int idx=0; idx < vertCount; idx++)\n\n\t\t\t{\n\n\t\t\t\tw[idx] = weightValue(data,index,idx) * env;\n\n\t\t\t}\n\n\t\t\tMObject relaxMesh(outMesh);\n\n\t\t\tm_relax.relax(relaxMesh, iterations, rpts, w);\n\n\t\t\tmeshFn.setPoints(rpts, MSpace::kObject);\n\n\t\t}\n\n\t}\n\n\tdata.setClean(plug);\n\n\treturn MS::kSuccess;\n\n}\n", "file_path": "src/chwMeshRelax.cpp", "rank": 28, "score": 25112.26954649401 }, { "content": "\tunsigned int vertCount;\n\n\n\n\tif (plug.attribute() == outputGeom)\n\n\t{\n\n\t\tunsigned int index = plug.logicalIndex();\n\n\t\tMObject thisNode = this->thisMObject();\n\n\t\tMPlug inPlug(thisNode,input);\n\n\t\tinPlug.selectAncestorLogicalIndex(index,input);\n\n\t\tMDataHandle hInput = data.inputValue(inPlug, &stat );\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(stat)\n\n\n\n\t\tMDataHandle hGeom = hInput.child(inputGeom);\n\n\t\tMMatrix m = hGeom.geometryTransformMatrix();\n\n\t\tMDataHandle hOutput = data.outputValue(plug);\n\n\t\thOutput.copy(hGeom);\n\n\t\tMObject outMesh = hGeom.asMesh();\n\n\t\tMFnMesh meshFn(outMesh);\n\n\t\tvertCount = meshFn.numVertices();\n\n\t\tmeshFn.getPoints(pts, MSpace::kObject);\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(stat)\n", "file_path": "src/chwMeshRelax.cpp", "rank": 29, "score": 25111.315088238123 }, { "content": "\tnAttr.setStorable(true);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setConnectable(true);\n\n\tnAttr.setMin(0);\n\n\taddAttribute( aIterations );\n\n\n\n\tattributeAffects( chwMeshRelax::aIterations, chwMeshRelax::outputGeom );\n\n\n\n\tMGlobal::executeCommand(\"makePaintable -attrType multiFloat -sm deformer chwMeshRelax weights\");\n\n\n\n\treturn MStatus::kSuccess;\n\n}\n\n\n\nMStatus chwMeshRelax::compute(const MPlug& plug, MDataBlock& data)\n\n{\n\n\tMStatus stat;\n\n\tMPointArray pts;\n\n\tMPointArray rpts;\n\n\tfloat env = data.inputValue(envelope).asFloat();\n\n\tunsigned int iterations = data.inputValue(aIterations).asInt();\n", "file_path": "src/chwMeshRelax.cpp", "rank": 30, "score": 25109.89172127793 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#include <chwMeshRelax.h>\n\n\n\nconst MTypeId\tchwMeshRelax::typeId( 0x89002 );\n\nconst MString\tchwMeshRelax::typeName( \"chwMeshRelax\" );\n\n\n\nMObject \t\tchwMeshRelax::aIterations;\n\n\n\nchwMeshRelax::chwMeshRelax(){}\n\nchwMeshRelax::~chwMeshRelax(){}\n\nvoid* chwMeshRelax::creator(){ return new chwMeshRelax(); }\n\n\n\nMStatus chwMeshRelax::initialize()\n\n{\n\n\tMFnNumericAttribute nAttr;\n\n\n\n\taIterations = nAttr.create( \"iterations\", \"it\", MFnNumericData::kInt );\n\n\tnAttr.setKeyable(true);\n", "file_path": "src/chwMeshRelax.cpp", "rank": 31, "score": 25105.874567652736 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "src/chwMeshRelax.cpp", "rank": 32, "score": 25095.45347962712 }, { "content": "\t\t\tstruct ThreadedDeform\n\n\t\t\t{\n\n\t\t\t\tchwNormalOffsetData *data;\n\n\t\t\t\tvoid operator()( const blocked_range<int>& range ) const {\n\n\t\t\t\t\tfor ( int idx = range.begin(); idx!=range.end(); ++idx )\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tdata->m_points[idx] += data->m_normals[idx] * data->m_weights[idx];\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n};\n\n\n\n#endif // CHWNORMALOFFSET_H\n", "file_path": "include/chwNormalOffset.h", "rank": 33, "score": 24945.721613029953 }, { "content": "\t\t\t\tvoid operator()( const blocked_range<int>& range ) const {\n\n\t\t\t\t\tMStatus status;\n\n\t\t\t\t\tMPoint point;\n\n\t\t\t\t\tfloat dist,ramppos, rampval;\n\n\t\t\t\t\tfloat w;\n\n\t\t\t\t\tfor ( int idx = range.begin(); idx!=range.end(); ++idx )\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tw = data->m_weights[idx] * data->m_env;\n\n\t\t\t\t\t\tif ((w > 0.f) && (data->m_falloffRadius > 0.f))\n\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tdist = (data->m_relativeMatrixTranslate - data->m_points[idx]).length();\n\n\t\t\t\t\t\t\tramppos = dist / data->m_falloffRadius;\n\n\t\t\t\t\t\t\tdata->m_falloffCurve.getValueAtPosition(ramppos, rampval, &status);\n\n\n\n\t\t\t\t\t\t\tpoint = data->m_points[idx] * data->m_relativeInverseMatrix * data->m_deformMatrix;\n\n\t\t\t\t\t\t\tdata->m_points[idx] += ((point - data->m_points[idx]) * w * rampval);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n};\n\n\n\n#endif // CHWSURFACETWEAK_H\n", "file_path": "include/chwSurfaceTweak.h", "rank": 34, "score": 24944.252573776626 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWSURFACETWEAK_H\n\n#define CHWSURFACETWEAK_H\n\n\n\n#include <string.h>\n\n#include <math.h>\n\n#include <maya/MPxNode.h>\n\n#include <maya/MArrayDataBuilder.h>\n\n#include <maya/MPxDeformerNode.h>\n\n#include <maya/MMeshIntersector.h>\n\n#include <maya/MFnSingleIndexedComponent.h>\n\n#include <maya/MItGeometry.h>\n\n#include <maya/MItMeshVertex.h>\n\n#include <maya/MItMeshPolygon.h>\n\n#include <maya/MFnNumericAttribute.h>\n\n#include <maya/MFnEnumAttribute.h>\n\n#include <maya/MFnTypedAttribute.h>\n\n#include <maya/MTypeId.h>\n", "file_path": "include/chwSurfaceTweak.h", "rank": 35, "score": 24943.39292940774 }, { "content": "\t\t\t\t{\n\n\t\t\t\t\tnumcons = data->m_conids[idx].size();\n\n\t\t\t\t\tdata->m_relaxpoints[idx] = MPoint();\n\n\t\t\t\t\tfor (unsigned int idy=0; idy < numcons; idy++)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tidz = data->m_conids[idx][idy];\n\n\t\t\t\t\t\tdata->m_relaxpoints[idx] += data->m_points[idz];\n\n\t\t\t\t\t}\n\n\t\t\t\t\tdata->m_relaxpoints[idx] = data->m_points[idx] + ((data->m_relaxpoints[idx] / float(numcons)) - data->m_points[idx]) * data->m_weights[idx];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n};\n\n\n\n#endif // CHWEDGERELAX_H\n", "file_path": "include/chwEdgeRelax.h", "rank": 36, "score": 24941.870087191888 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWEDGERELAX_H\n\n#define CHWEDGERELAX_H\n\n\n\n#include <string.h>\n\n#include <math.h>\n\n#include <float.h>\n\n#include <vector>\n\n#include <iostream>\n\n#include <algorithm>\n\n\n\n#include <maya/MFnMesh.h>\n\n#include <maya/MVector.h>\n\n#include <maya/MIntArray.h>\n\n#include <maya/MFloatArray.h>\n\n#include <maya/MPointArray.h>\n\n#include <maya/MItMeshVertex.h>\n\n\n\n// THREADING\n\n#include \"tbb/tbb.h\"\n\nusing namespace tbb;\n\n\n", "file_path": "include/chwEdgeRelax.h", "rank": 37, "score": 24938.500676218486 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWNORMALOFFSET_H\n\n#define CHWNORMALOFFSET_H\n\n\n\n#include <maya/MPxDeformerNode.h>\n\n#include <maya/MItGeometry.h>\n\n#include <maya/MTypeId.h>\n\n#include <maya/MPlug.h>\n\n#include <maya/MDataBlock.h>\n\n#include <maya/MDataHandle.h>\n\n#include <maya/MPoint.h>\n\n#include <maya/MPointArray.h>\n\n#include <maya/MFnMesh.h>\n\n#include <maya/MVector.h>\n\n#include <maya/MFloatVectorArray.h>\n\n#include <maya/MGlobal.h>\n\n#include <maya/MMatrix.h>\n\n#include <maya/MFnNumericAttribute.h>\n\n#include <maya/MFloatArray.h>\n\n#include \"chwEdgeRelax.h\"\n\n\n\n// THREADING\n\n#include \"tbb/tbb.h\"\n\nusing namespace tbb;\n\n\n", "file_path": "include/chwNormalOffset.h", "rank": 38, "score": 24938.393131305573 }, { "content": "#include <maya/MDataBlock.h>\n\n#include <maya/MDataHandle.h>\n\n#include <maya/MDagPath.h>\n\n#include <maya/MGlobal.h>\n\n#include <maya/MArrayDataHandle.h>\n\n#include <maya/MPointArray.h>\n\n#include <maya/MPoint.h>\n\n#include <maya/MVector.h>\n\n#include <maya/MMatrix.h>\n\n#include <maya/MObject.h>\n\n#include <maya/MRampAttribute.h>\n\n#include <maya/MFnUnitAttribute.h>\n\n#include <maya/MFnMesh.h>\n\n#include <maya/MItMeshVertex.h>\n\n#include <maya/MFnMatrixAttribute.h>\n\n#include <maya/MAngle.h>\n\n\n\n// THREADING\n\n#include \"tbb/tbb.h\"\n\nusing namespace tbb;\n\n\n", "file_path": "include/chwSurfaceTweak.h", "rank": 39, "score": 24938.307543054045 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWMATRIXSELECTOR_H\n\n#define CHWMATRIXSELECTOR_H\n\n\n\n#include <math.h>\n\n#include <maya/MPxNode.h>\n\n#include <maya/MItGeometry.h>\n\n#include <maya/MTypeId.h>\n\n#include <maya/MPlug.h>\n\n#include <maya/MPlugArray.h>\n\n#include <maya/MDataBlock.h>\n\n#include <maya/MDataHandle.h>\n\n#include <maya/MPoint.h>\n\n#include <maya/MPointArray.h>\n\n#include <maya/MFnMesh.h>\n\n#include <maya/MVector.h>\n\n#include <maya/MFloatVectorArray.h>\n\n#include <maya/MGlobal.h>\n", "file_path": "include/chwMatrixSelector.h", "rank": 40, "score": 24938.306447232524 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#ifndef CHWCURVESAMPLER_H\n\n#define CHWCURVESAMPLER_H\n\n\n\n#include <math.h>\n\n#include <maya/MPxNode.h>\n\n#include <maya/MTypeId.h>\n\n#include <maya/MPlug.h>\n\n#include <maya/MPlugArray.h>\n\n#include <maya/MDataBlock.h>\n\n#include <maya/MDataHandle.h>\n\n#include <maya/MGlobal.h>\n\n#include <maya/MMatrix.h>\n\n#include <maya/MFnNumericAttribute.h>\n\n#include <maya/MFnUnitAttribute.h>\n\n#include <maya/MFnTypedAttribute.h>\n\n#include <maya/MQuaternion.h>\n\n#include <maya/MIOStream.h>\n\n#include <maya/MEulerRotation.h>\n\n#include <maya/MFnNurbsCurve.h>\n\n#include <maya/MArrayDataBuilder.h>\n\n#include <maya/MArrayDataHandle.h>\n\n#include <maya/MVector.h>\n\n\n", "file_path": "include/chwCurveSampler.h", "rank": 41, "score": 24936.82182656532 }, { "content": "\t\tstatic MObject aOutTranslateX;\n\n\t\tstatic MObject aOutTranslateY;\n\n\t\tstatic MObject aOutTranslateZ;\n\n\n\n\t\tstatic MObject aOutRotate;\n\n\t\tstatic MObject aOutRotateX;\n\n\t\tstatic MObject aOutRotateY;\n\n\t\tstatic MObject aOutRotateZ;\n\n\n\n\t\tstatic const MTypeId typeId;\n\n\t\tstatic const MString typeName;\n\n\n\n\t\tprivate:\n\n\t\t\tchwSurfaceTweakData\t*m_data;\n\n\n\n\t\t\tMStatus\t\tpostConstructor_initialise_ramp_curve(MObject &rampObj, int index, float position, float value, int interpolation);\n\n\n\n\t\t\tstruct ThreadedDeform\n\n\t\t\t{\n\n\t\t\t\tchwSurfaceTweakData *data;\n", "file_path": "include/chwSurfaceTweak.h", "rank": 42, "score": 24936.5903580128 }, { "content": "#include <maya/MMatrix.h>\n\n#include <maya/MFnNumericAttribute.h>\n\n#include <maya/MFnMatrixAttribute.h>\n\n#include <maya/MFnEnumAttribute.h>\n\n#include <maya/MFnCompoundAttribute.h>\n\n#include <maya/MFnUnitAttribute.h>\n\n#include <maya/MQuaternion.h>\n\n#include <maya/MIOStream.h>\n\n#include <maya/MEulerRotation.h>\n\n\n", "file_path": "include/chwMatrixSelector.h", "rank": 43, "score": 24932.35501295421 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwCurveSampler.h", "rank": 44, "score": 24931.047125173533 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwNormalOffset.h", "rank": 45, "score": 24931.047125173533 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwMatrixSelector.h", "rank": 46, "score": 24931.047125173533 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwSurfaceTweak.h", "rank": 47, "score": 24931.047125173533 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "include/chwEdgeRelax.h", "rank": 48, "score": 24931.047125173533 }, { "content": "\t\tdrvIter.allPositions(m_data->m_drvpoints, MSpace::kWorld);\n\n\t\titer.allPositions(m_data->m_defpoints);\n\n\t\tm_data->m_mapping.setLength(m_data->m_defpoints.length());\n\n\t\tm_data->m_weights.setLength(m_data->m_defpoints.length());\n\n\t\tm_data->m_localToWorldMatrix = localToWorldMatrix;\n\n\n\n\t\tfor ( unsigned int idx = 0; idx < m_data->m_defpoints.length(); idx++ )\n\n\t\t{\n\n\t\t\tvertMapArrayData.jumpToElement(idx);\n\n\t\t\tm_data->m_mapping[idx] = vertMapArrayData.inputValue().asInt();\n\n\t\t\tm_data->m_weights[idx] = weightValue( data, mIndex, idx ) * env;\n\n\t\t}\n\n\n\n\t\tThreadedDeform td;\n\n\t\ttd.data = m_data;\n\n\t\tparallel_for( blocked_range<int>( 0, m_data->m_defpoints.length() ), td );\n\n\n\n\t\titer.setAllPositions(m_data->m_defpoints);\n\n\t}\n\n\treturn status;\n", "file_path": "src/chwVertexBind.cpp", "rank": 49, "score": 24714.089628848742 }, { "content": "\tdelete m_data;\n\n}\n\nvoid* chwVertexBind::creator(){ return new chwVertexBind(); }\n\n\n\nMStatus chwVertexBind::initialize()\n\n{\n\n\tMFnTypedAttribute \t\ttAttr;\n\n\tMFnEnumAttribute \t\teAttr;\n\n\tMFnNumericAttribute \tnAttr;\n\n\n\n\taDriverMesh = tAttr.create( \"driverMesh\", \"drv\", MFnData::kMesh );\n\n\ttAttr.setStorable(false);\n\n\ttAttr.setConnectable(true);\n\n\taddAttribute( aDriverMesh );\n\n\n\n\taSearchDistance = nAttr.create( \"SearchDistance\", \"sd\", MFnNumericData::kFloat, 0.01);\n\n\tnAttr.setStorable(true);\n\n\tnAttr.setReadable(true);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setKeyable(true);\n", "file_path": "src/chwVertexBind.cpp", "rank": 50, "score": 24710.480721599015 }, { "content": "\tm_data->m_localToWorldMatrix = localToWorldMatrix;\n\n\n\n\tThreadedInitialize ti;\n\n\tti.data = m_data;\n\n\tparallel_for( blocked_range<int>( 0, m_data->m_defpoints.length() ), ti );\n\n\n\n\tMArrayDataHandle vertMapOutArrayHandle = data.outputArrayValue( aVertexMap, &status );\n\n\tCHECK_MSTATUS(status);\n\n\tMArrayDataBuilder vertMapOutArrayBuilder = vertMapOutArrayHandle.builder(&status);\n\n\tCHECK_MSTATUS(status);\n\n\n\n\tfor ( unsigned int idx = 0; idx < m_data->m_defpoints.length(); idx++ )\n\n\t{\n\n\t\tMDataHandle initIndexData = vertMapOutArrayBuilder.addElement( idx, &status );\n\n\t\tCHECK_MSTATUS(status);\n\n\t\tinitIndexData.setInt(m_data->m_mapping[idx]);\n\n\t\tinitIndexData.setClean();\n\n\t}\n\n\n\n\tvertMapOutArrayHandle.set( vertMapOutArrayBuilder );\n", "file_path": "src/chwVertexBind.cpp", "rank": 51, "score": 24708.510571151768 }, { "content": "\taddAttribute( aInitialize );\n\n\n\n\taVertexMap = nAttr.create( \"vtxIndexMap\", \"vtximp\", MFnNumericData::kLong, -9999 );\n\n\tnAttr.setKeyable(false);\n\n\tnAttr.setArray(true);\n\n\tnAttr.setStorable(true);\n\n\tnAttr.setReadable(true);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setUsesArrayDataBuilder(true);\n\n\taddAttribute( aVertexMap );\n\n\n\n\tattributeAffects(chwVertexBind::aDriverMesh, \tchwVertexBind::outputGeom);\n\n\tattributeAffects(chwVertexBind::aSearchDistance,\tchwVertexBind::outputGeom);\n\n\tattributeAffects(chwVertexBind::aCutoffDistance,\tchwVertexBind::outputGeom);\n\n\tattributeAffects(chwVertexBind::aInitialize, \tchwVertexBind::outputGeom);\n\n\tattributeAffects(chwVertexBind::aVertexMap,\t\tchwVertexBind::outputGeom);\n\n\n\n\tMGlobal::executeCommand( \"makePaintable -attrType \\\"multiFloat\\\" -sm \\\"deformer\\\" \\\"chwVertexBind\\\" \\\"weights\\\";\" );\n\n\n\n\treturn MStatus::kSuccess;\n", "file_path": "src/chwVertexBind.cpp", "rank": 52, "score": 24707.703119478007 }, { "content": "}\n\n\n\nMStatus chwVertexBind::deform( MDataBlock& data, MItGeometry& iter, const MMatrix& localToWorldMatrix, unsigned int mIndex)\n\n{\n\n\tMStatus status;\n\n\tshort initialized_mapping = data.inputValue( aInitialize ).asShort();\n\n\n\n\tif( initialized_mapping == 1 )\n\n\t{\n\n\t\tstatus = initializeMapping(data, iter, localToWorldMatrix);\n\n\t\tinitialized_mapping = data.inputValue( aInitialize ).asShort();\n\n\t}\n\n\tif( initialized_mapping == 2 )\n\n\t{\n\n\t\tfloat env = data.inputValue(envelope).asFloat();\n\n\t\tMArrayDataHandle vertMapArrayData = data.inputArrayValue( aVertexMap );\n\n\n\n\t\tMDataHandle meshAttrHandle = data.inputValue( aDriverMesh, &status );\n\n\t\tMItGeometry drvIter( meshAttrHandle );\n\n\n", "file_path": "src/chwVertexBind.cpp", "rank": 53, "score": 24706.690965313304 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#include <chwVertexBind.h>\n\n\n\nMTypeId \t\tchwVertexBind::typeId ( 0x89001 );\n\nconst MString \tchwVertexBind::typeName( \"chwVertexBind\" );\n\n\n\nMObject \t\tchwVertexBind::aDriverMesh;\n\nMObject \t\tchwVertexBind::aSearchDistance;\n\nMObject \t\tchwVertexBind::aCutoffDistance;\n\nMObject \t\tchwVertexBind::aInitialize;\n\nMObject \t\tchwVertexBind::aVertexMap;\n\n\n\nchwVertexBind::chwVertexBind()\n\n{\n\n\tm_data = new chwVertexBindData;\n\n}\n\nchwVertexBind::~chwVertexBind()\n\n{\n", "file_path": "src/chwVertexBind.cpp", "rank": 54, "score": 24705.284695790295 }, { "content": "\n\n\tMObject tObj = thisMObject();\n\n\tMPlug setInitMode( tObj, aInitialize );\n\n\tsetInitMode.setValue( 2 );\n\n\n\n\tdata.setClean(aVertexMap);\n\n\treturn status;\n\n}\n\n\n\nMObject& chwVertexBind::accessoryAttribute() const\n\n{\n\n\treturn chwVertexBind::aDriverMesh ;\n\n}\n", "file_path": "src/chwVertexBind.cpp", "rank": 55, "score": 24704.269664053714 }, { "content": "}\n\n\n\n\n\n\n\nMStatus chwVertexBind::initializeMapping( MDataBlock& data, MItGeometry& iter, const MMatrix& localToWorldMatrix)\n\n{\n\n\tMStatus status;\n\n\n\n\tMDataHandle cutoffDistanceHnd = data.inputValue(aCutoffDistance, &status);\n\n\tm_data->m_cutoffDistance = cutoffDistanceHnd.asFloat();\n\n\n\n\tMDataHandle searchDistanceHnd = data.inputValue(aSearchDistance, &status);\n\n\tm_data->m_searchDistance = searchDistanceHnd.asFloat();\n\n\n\n\tMDataHandle meshAttrHandle = data.inputValue( aDriverMesh, &status );\n\n\tMItGeometry drvIter( meshAttrHandle );\n\n\n\n\tdrvIter.allPositions(m_data->m_drvpoints, MSpace::kWorld);\n\n\titer.allPositions(m_data->m_defpoints);\n\n\tm_data->m_mapping.setLength(m_data->m_defpoints.length());\n", "file_path": "src/chwVertexBind.cpp", "rank": 56, "score": 24701.599111190706 }, { "content": "\tnAttr.setMin(0.0);\n\n\taddAttribute(aSearchDistance);\n\n\n\n\taCutoffDistance = nAttr.create( \"Cutoff\", \"cof\", MFnNumericData::kFloat, 0.0);\n\n\tnAttr.setStorable(true);\n\n\tnAttr.setReadable(true);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setKeyable(true);\n\n\tnAttr.setMin(0.0);\n\n\taddAttribute(aCutoffDistance);\n\n\n\n\taInitialize = eAttr.create( \"initialize\", \"inl\" );\n\n\teAttr.addField(\t\"Off\", 0);\n\n\teAttr.addField(\t\"Re-Set Bind\", 1);\n\n\teAttr.addField(\t\"Bound\", 2);\n\n\teAttr.setKeyable(true);\n\n\teAttr.setStorable(true);\n\n\teAttr.setReadable(true);\n\n\teAttr.setWritable(true);\n\n\teAttr.setDefault(0);\n", "file_path": "src/chwVertexBind.cpp", "rank": 57, "score": 24699.62749734655 }, { "content": "/***********************************************************************************\n\n* Copyright (c) 2018 Cristian Hinz Welkens.\n\n*\n\n* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n*\n\n* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n* this software and associated documentation files (the \"Software\"), to deal in\n\n* the Software without restriction, including without limitation the rights to \n\n* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n* of the Software, and to permit persons to whom the Software is furnished to do\n\n* so, subject to the following conditions:\n\n*\n\n* The above copyright notice and this permission notice shall be included in all\n\n* copies or substantial portions of the Software.\n\n*\n\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n", "file_path": "src/chwVertexBind.cpp", "rank": 58, "score": 24697.182252563416 }, { "content": "class chwEdgeRelax\n\n{\n\n\tpublic:\n\n\t\t\t\tchwEdgeRelax();\n\n\t\tvirtual\t~chwEdgeRelax();\n\n\t\tvoid relax(MObject&, unsigned int);\n\n\t\tvoid relax(MObject&, unsigned int, MFloatArray &weights);\n\n\t\tvoid relax(MObject&, unsigned int, MPointArray&);\n\n\t\tvoid relax(MObject&, unsigned int, MPointArray&, MFloatArray &weights);\n\n\tprivate:\n\n\t\tchwEdgeRelaxData *m_relaxData;\n\n\t\tvoid\tbuildTopology(MObject &mesh);\n\n\t\tvoid\tdoRelax();\n\n\t\tstruct ThreadedDeform\n\n\t\t{\n\n\t\t\tchwEdgeRelaxData *data;\n\n\t\t\tvoid operator()( const blocked_range<int>& range ) const {\n\n\t\t\t\tunsigned int idz;\n\n\t\t\t\tunsigned int numcons;\n\n\t\t\t\tfor ( int idx = range.begin(); idx!=range.end(); ++idx )\n", "file_path": "include/chwEdgeRelax.h", "rank": 59, "score": 21182.16684584333 }, { "content": "#/***********************************************************************************\n\n#* Copyright (c) 2018 Cristian Hinz Welkens.\n\n#*\n\n#* This file is part of chwTools (https://github.com/chinzw/chwtools).\n\n#*\n\n#* Permission is hereby granted, free of charge, to any person obtaining a copy of\n\n#* this software and associated documentation files (the \"Software\"), to deal in\n\n#* the Software without restriction, including without limitation the rights to \n\n#* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\n\n#* of the Software, and to permit persons to whom the Software is furnished to do\n\n#* so, subject to the following conditions:\n\n#*\n\n#* The above copyright notice and this permission notice shall be included in all\n\n#* copies or substantial portions of the Software.\n\n#*\n\n#* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n\n#* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n\n#* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n\n#* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n\n#* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n\n#* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n#***********************************************************************************/\n\n\n\n\n\nimport re\n\nimport util\n\nfrom maya import cmds\n\n\n\nutil.loadPlugin()\n\n\n\ndef chwMeshRelax():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 1:\n\n\t\tcmds.deformer(selection, type='chwMeshRelax')\n\n\telse:\n\n\t\tprint \"chwMeshRelax: You need to select one mesh!\\n\"\n\n\n\ndef chwNormalOffset():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 1:\n\n\t\tcmds.deformer(selection, type='chwNormalOffset')\n\n\telse:\n\n\t\tprint \"chwNormalOffset: You need to select one mesh!\\n\"\n\n\n\ndef chwVertexBind():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 2:\n\n\t\tvs = cmds.deformer(selection[-1], type='chwVertexBind')\n\n\t\tcmds.connectAttr(selection[0]+'.worldMesh[0]', vs[0]+'.driverMesh')\n\n\t\tcmds.setAttr(vs[0]+'.initialize', 1)\n\n\telse:\n\n\t\tprint \"chwVertexBind: You need to select a driver and a target!\\n\"\n\n\n\ndef chwSurfaceTweak():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 1:\n\n\t\tselection = selection[0]\n\n\t\tif selection.count('vtx'):\n\n\t\t\tsplits = selection.split('.')\n\n\t\t\tmesh = splits[0]\n\n\t\t\tvtx = re.sub(\"[^0-9]\", \"\", splits[1])\n\n\t\t\tname = util.nextName('chwSurfaceTweak_'+mesh)\n\n\t\t\tss = cmds.deformer(mesh, type='chwSurfaceTweak')[0]\n\n\t\t\tcmds.setAttr(ss+'.vertex', int(vtx))\n\n\t\t\tpivot_ctrl = cmds.group(em=True, name=name)\n\n\t\t\toffset_ctrl = util.makeControlSphere(name+'_Offset', 0.25)\n\n\t\t\tsticky_ctrl = util.makeControlSphere(name+'_Deform')\n\n\t\t\tcmds.parent(sticky_ctrl, offset_ctrl)\n\n\t\t\tcmds.parent(offset_ctrl, pivot_ctrl)\n\n\t\t\tcmds.addAttr(sticky_ctrl, at='double', ln='envelope', k=1, dv=1, min=0, max=1)\n\n\t\t\tcmds.addAttr(sticky_ctrl, at='enum', ln='falloffMode', k=1, en='Volume')\n\n\t\t\tcmds.addAttr(sticky_ctrl, at='double', ln='falloffRadius', k=1, dv=1, min=0)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.falloffMode', ss+'.falloffMode', f=True)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.falloffRadius', ss+'.falloffRadius', f=True)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.envelope', ss+'.envelope', f=True)\n\n\t\t\tcmds.connectAttr(sticky_ctrl+'.worldMatrix[0]', ss+'.deformMatrix')\n\n\t\t\tcmds.connectAttr(offset_ctrl+'.worldMatrix[0]', ss+'.relativeMatrix')\n\n\t\t\tcmds.connectAttr(ss+'.outRotate', pivot_ctrl+'.rotate')\n\n\t\t\tcmds.connectAttr(ss+'.outTranslate', pivot_ctrl+'.translate')\n\n\t\t\tcmds.select(sticky_ctrl, r=True)\n\n\t\t\treturn [pivot_ctrl, offset_ctrl, sticky_ctrl, ss]\n\n\t\telse:\n\n\t\t\tprint \"chwSurfaceTweak: You need to select a mesh vertex!\\n\"\n\n\telse:\n\n\t\tprint \"chwSurfaceTweak: You need to select a mesh vertex!\\n\"\n\n\n\n\n\ndef chwCollision():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) > 1:\n\n\t\tdefmesh = selection[0]\n\n\t\tselection.pop(0)\n\n\t\tcolDefs = [x for x in cmds.listHistory(defmesh) if cmds.nodeType(x) == 'chwCollision']\n\n\t\tif colDefs:\n\n\t\t\tnextIdx = 0\n\n\t\t\tcoldef = colDefs[0]\n\n\t\t\tindices = cmds.getAttr(coldef+'.collisionMeshList', mi=True)\n\n\t\t\tif indices:\n\n\t\t\t\tnextIdx = indices[-1]+1\n\n\t\t\tfor idx in xrange(0, len(selection)):\n\n\t\t\t\tmidx = idx + nextIdx\n\n\t\t\t\tcmds.getAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName')\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName', l=False)\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName', selection[idx], type='string')\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName', l=True)\n\n\t\t\t\tcmds.connectAttr(selection[idx]+'.worldMesh[0]', coldef+'.collisionMeshList['+str(midx)+'].collisionMesh', f=True)\n\n\t\telse:\n\n\t\t\tcoldef = cmds.deformer(defmesh, type='chwCollision')[0]\n\n\t\t\tfor idx in xrange(0, len(selection)):\n\n\t\t\t\tcmds.connectAttr(selection[idx]+'.worldMesh[0]', coldef+'.collisionMeshList['+str(idx)+'].collisionMesh', f=True)\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(idx)+'].collisionMeshName', selection[idx], type='string')\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(idx)+'].collisionMeshName', l=True)\n\n\n", "file_path": "chwTools/scripts/chwTools/deformers.py", "rank": 60, "score": 19568.467078856134 }, { "content": "def chwCollision():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) > 1:\n\n\t\tdefmesh = selection[0]\n\n\t\tselection.pop(0)\n\n\t\tcolDefs = [x for x in cmds.listHistory(defmesh) if cmds.nodeType(x) == 'chwCollision']\n\n\t\tif colDefs:\n\n\t\t\tnextIdx = 0\n\n\t\t\tcoldef = colDefs[0]\n\n\t\t\tindices = cmds.getAttr(coldef+'.collisionMeshList', mi=True)\n\n\t\t\tif indices:\n\n\t\t\t\tnextIdx = indices[-1]+1\n\n\t\t\tfor idx in xrange(0, len(selection)):\n\n\t\t\t\tmidx = idx + nextIdx\n\n\t\t\t\tcmds.getAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName')\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName', l=False)\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName', selection[idx], type='string')\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(midx)+'].collisionMeshName', l=True)\n\n\t\t\t\tcmds.connectAttr(selection[idx]+'.worldMesh[0]', coldef+'.collisionMeshList['+str(midx)+'].collisionMesh', f=True)\n\n\t\telse:\n\n\t\t\tcoldef = cmds.deformer(defmesh, type='chwCollision')[0]\n\n\t\t\tfor idx in xrange(0, len(selection)):\n\n\t\t\t\tcmds.connectAttr(selection[idx]+'.worldMesh[0]', coldef+'.collisionMeshList['+str(idx)+'].collisionMesh', f=True)\n\n\t\t\t\tcmds.setAttr(coldef+'.collisionMeshList['+str(idx)+'].collisionMeshName', selection[idx], type='string')\n", "file_path": "chwTools/scripts/chwTools/deformers.py", "rank": 61, "score": 18000.634282995168 }, { "content": "class chwCurveSampler : public MPxNode\n\n{\n\n\tpublic:\n\n\t\t\t\tchwCurveSampler();\n\n\t\tvirtual ~chwCurveSampler();\n\n\n\n\t\tvirtual MStatus \tcompute(const MPlug& plug, MDataBlock& data);\n\n\t\tstatic void* \t\tcreator();\n\n\t\tstatic MStatus \tinitialize();\n\n\n\n\tpublic:\n\n\t\tstatic\tMObject\t\t\taInCurve;\n\n\t\tstatic\tMObject\t\t\taInUpCurve;\n\n\t\tstatic\tMObject\t\t\taInNumSamples;\n\n\t\tstatic\tMObject\t\t\taOutRotate;\n\n\t\tstatic\tMObject\t\t\taOutRotateX;\n\n\t\tstatic\tMObject\t\t\taOutRotateY;\n\n\t\tstatic\tMObject\t\t\taOutRotateZ;\n\n\t\tstatic\tMObject\t\t\taOutTranslate;\n\n\t\tstatic\tMObject\t\t\taOutTranslateX;\n\n\t\tstatic\tMObject\t\t\taOutTranslateY;\n\n\t\tstatic\tMObject\t\t\taOutTranslateZ;\n\n\n\n\t\tstatic const MTypeId \ttypeId;\n\n\t\tstatic const MString \ttypeName;\n\n};\n\n\n\n#endif // CHWCURVESAMPLER_H\n", "file_path": "include/chwCurveSampler.h", "rank": 62, "score": 17646.27222345726 }, { "content": "class chwMatrixSelector : public MPxNode\n\n{\n\n\tpublic:\n\n\t\t\t\tchwMatrixSelector();\n\n\t\tvirtual ~chwMatrixSelector();\n\n\n\n\t\tvirtual MStatus \tcompute(const MPlug& plug, MDataBlock& data);\n\n\t\tstatic void* \t\tcreator();\n\n\t\tstatic MStatus \tinitialize();\n\n\n\n\tpublic:\n\n\t\tstatic\tMObject\t\t\taInMatrix;\n\n\t\tstatic\tMObject\t\t\taInMatrixList;\n\n\t\tstatic\tMObject\t\t\taOutRotate;\n\n\t\tstatic\tMObject\t\t\taOutRotateX;\n\n\t\tstatic\tMObject\t\t\taOutRotateY;\n\n\t\tstatic\tMObject\t\t\taOutRotateZ;\n\n\t\tstatic\tMObject\t\t\taOutTranslate;\n\n\t\tstatic\tMObject\t\t\taOutTranslateX;\n\n\t\tstatic\tMObject\t\t\taOutTranslateY;\n\n\t\tstatic\tMObject\t\t\taOutTranslateZ;\n\n\t\tstatic\tMObject\t\t\taInMatrixIndex;\n\n\n\n\n\n\t\tstatic const MTypeId \ttypeId;\n\n\t\tstatic const MString \ttypeName;\n\n};\n\n\n\n#endif // CHWMATRIXSELECTOR_H\n", "file_path": "include/chwMatrixSelector.h", "rank": 63, "score": 17646.27222345726 }, { "content": "def chwNormalOffset():\n\n\tselection = cmds.ls(sl=True)\n\n\tif len(selection) == 1:\n\n\t\tcmds.deformer(selection, type='chwNormalOffset')\n\n\telse:\n", "file_path": "chwTools/scripts/chwTools/deformers.py", "rank": 64, "score": 17307.300629780348 }, { "content": "\toutput.setLength(m_relaxData->m_vertcount);\n\n\toutput = m_relaxData->m_relaxpoints;\n\n}\n\n\n\nvoid chwEdgeRelax::doRelax()\n\n{\n\n\tfor (unsigned int idx=0; idx < m_relaxData->m_iterations; ++idx)\n\n\t{\n\n\t\tThreadedDeform td;\n\n\t\ttd.data = m_relaxData;\n\n\t\tparallel_for( blocked_range<int>( 0, m_relaxData->m_vertcount ), td );\n\n\t\tm_relaxData->m_points = m_relaxData->m_relaxpoints;\n\n\t}\n\n}\n\n\n\nvoid chwEdgeRelax::buildTopology(MObject &mesh)\n\n{\n\n\tMItMeshVertex \titer(mesh);\n\n\tMFnMesh\t\t\tmeshfn(mesh);\n\n\tMIntArray \t\tconVerts;\n", "file_path": "src/chwEdgeRelax.cpp", "rank": 65, "score": 22.69602579917136 }, { "content": "\n\n\t\tstatus = meshFn.getVertexNormals(false, m_data->m_normals, MSpace::kWorld);\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\t// RESIZE ALL ARRAYS\n\n\t\tm_data->m_numpoints = m_data->m_points.length();\n\n\t\tm_data->m_weights.setLength(m_data->m_numpoints);\n\n\t\tm_data->m_collided.setLength(m_data->m_numpoints);\n\n\n\n\t\tif(env > 0)\n\n\t\t{\n\n\t\t\tfor (unsigned int idx=0; idx<m_data->m_numpoints; idx++)\n\n\t\t\t{\n\n\t\t\t\tm_data->m_boxin.expand(m_data->m_points[idx]);\n\n\t\t\t\tm_data->m_weights[idx] = weightValue(data,index,idx) * env;\n\n\t\t\t}\n\n\n\n\t\t\tMArrayDataHandle arrayHandle = data.inputArrayValue(aCollisionMeshList, &status);\n\n\t\t\tunsigned int count = arrayHandle.elementCount();\n\n\t\t\tfor (unsigned int midx=0; midx < count; midx++)\n", "file_path": "src/chwCollision.cpp", "rank": 66, "score": 21.456760560591995 }, { "content": "\t\tm_data->m_numverts = meshFn.numVertices();\n\n\n\n\t\tif(m_data->m_env != 0.00 && m_data->m_strength != 0.00)\n\n\t\t{\n\n\t\t\tm_data->m_weights.setLength(m_data->m_numverts);\n\n\t\t\tfor (unsigned int idx=0; idx < m_data->m_numverts; idx++)\n\n\t\t\t{\n\n\t\t\t\tm_data->m_weights[idx] = weightValue(data,index,idx) * m_data->m_env * m_data->m_strength;\n\n\t\t\t}\n\n\t\t\tif (m_data->m_smooth > 0)\n\n\t\t\t{\n\n\t\t\t\tMObject relaxMesh(inMesh);\n\n\t\t\t\tm_relax.relax(relaxMesh, m_data->m_smooth);\n\n\t\t\t\tMFnMesh relaxFn(relaxMesh, &status);\n\n\t\t\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\t\t\trelaxFn.getVertexNormals(false, m_data->m_normals, MSpace::kObject);\n\n\t\t\t}\n\n\t\t\telse\n\n\t\t\t{\n", "file_path": "src/chwNormalOffset.cpp", "rank": 67, "score": 21.213864473710814 }, { "content": "\t\t\t\tmeshFn.getVertexNormals(false, m_data->m_normals, MSpace::kObject);\n\n\t\t\t}\n\n\n\n\t\t\t// THREADED DEFORMATION\n\n\t\t\tThreadedDeform td;\n\n\t\t\ttd.data = m_data;\n\n\t\t\tparallel_for( blocked_range<int>( 0, m_data->m_numverts ), td );\n\n\t\t}\n\n\t\tmeshFn.setPoints(m_data->m_points, MSpace::kObject);\n\n\t}\n\n\tdata.setClean(plug);\n\n\treturn MS::kSuccess;\n\n}\n", "file_path": "src/chwNormalOffset.cpp", "rank": 69, "score": 18.567517505983094 }, { "content": "\tm_data->m_smooth = data.inputValue(aNormalSmooth).asInt();\n\n\n\n\tif (plug.attribute() == outputGeom)\n\n\t{\n\n\t\tunsigned int index = plug.logicalIndex();\n\n\t\tMObject thisNode = this->thisMObject();\n\n\t\tMPlug inPlug(thisNode,input);\n\n\t\tinPlug.selectAncestorLogicalIndex(index,input);\n\n\t\tMDataHandle hInput = data.inputValue(inPlug, &status );\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\tMDataHandle hGeom = hInput.child(inputGeom);\n\n\t\tMMatrix m = hGeom.geometryTransformMatrix();\n\n\t\tMDataHandle hOutput = data.outputValue(plug);\n\n\t\thOutput.copy(hGeom);\n\n\t\tMObject inMesh = hGeom.asMesh();\n\n\t\tMFnMesh meshFn(inMesh, &status);\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\tmeshFn.getPoints(m_data->m_points, MSpace::kObject);\n", "file_path": "src/chwNormalOffset.cpp", "rank": 70, "score": 17.904318846198596 }, { "content": "\tif (plug.attribute() == outputGeom)\n\n\t{\n\n\t\tfloat env = data.inputValue(envelope).asFloat();\n\n\n\n\t\tm_data->m_bulgeRampAttribute = MRampAttribute(thisNode, aCollisionBulgeRamp, &status);\n\n\n\n\t\tunsigned int index = plug.logicalIndex();\n\n\t\tMPlug inPlug(thisNode,input);\n\n\t\tinPlug.selectAncestorLogicalIndex(index,input);\n\n\t\tMDataHandle hInput = data.inputValue(inPlug, &status );\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\tMDataHandle hGeom = hInput.child(inputGeom);\n\n\t\tMDataHandle hOutput = data.outputValue(plug);\n\n\t\thOutput.copy(hGeom);\n\n\t\tMObject outMesh = hGeom.asMesh();\n\n\t\tMFnMesh meshFn(outMesh);\n\n\n\n\t\tstatus = meshFn.getPoints(m_data->m_points, MSpace::kWorld);\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n", "file_path": "src/chwCollision.cpp", "rank": 74, "score": 17.202457895892735 }, { "content": "\tMFnMesh meshfn(mesh);\n\n\tmeshfn.setPoints(m_relaxData->m_relaxpoints);\n\n}\n\n\n\nvoid chwEdgeRelax::relax(MObject& mesh, unsigned int iterations, MFloatArray &weights)\n\n{\n\n\tm_relaxData->m_iterations = iterations;\n\n\n\n\tbuildTopology(mesh);\n\n\n\n\tm_relaxData->m_weights = weights;\n\n\n\n\tdoRelax();\n\n\n\n\tMFnMesh meshfn(mesh);\n\n\tmeshfn.setPoints(m_relaxData->m_relaxpoints);\n\n}\n\n\n\nvoid chwEdgeRelax::relax(MObject& mesh, unsigned int iterations, MPointArray &output)\n\n{\n", "file_path": "src/chwEdgeRelax.cpp", "rank": 76, "score": 16.648200688453837 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#include \"chwEdgeRelax.h\"\n\n\n\nchwEdgeRelax::chwEdgeRelax()\n\n{\n\n\tm_relaxData = new chwEdgeRelaxData;\n\n\tm_relaxData->m_cachedcount = 0;\n\n}\n\nchwEdgeRelax::~chwEdgeRelax() { }\n\n\n\nvoid chwEdgeRelax::relax(MObject& mesh, unsigned int iterations)\n\n{\n\n\tm_relaxData->m_iterations = iterations;\n\n\n\n\tbuildTopology(mesh);\n\n\n\n\tdoRelax();\n\n\n", "file_path": "src/chwEdgeRelax.cpp", "rank": 77, "score": 15.266012504650387 }, { "content": "\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\tdouble min, max = 0.f;\n\n\t\tdouble param = 0.f;\n\n\t\tMVector\t\tinCurveTangent(0.f,0.f,0.f);\n\n\t\tMPoint\t\tinCurvePoint(0.f,0.f,0.f);\n\n\t\tMPoint\t\tinUpCurvePoint(0.f,0.f,0.f);\n\n\n\n\t\tMVector\t\tvx, vy, vz;\n\n\n\n\t\tMPoint outTranslate;\n\n\t\tdouble outRotate[3];\n\n\n\n\t\tinCurveFn.getKnotDomain(min, max);\n\n\n\n\t\tfloat step = max / (inNumSamples-1);\n\n\n\n\t\tfor (unsigned int idx=0; idx < inNumSamples; idx++)\n\n\t\t{\n\n\t\t\tparam = min + (idx * step);\n", "file_path": "src/chwCurveSampler.cpp", "rank": 78, "score": 15.067917224489126 }, { "content": "\tm_relaxData->m_iterations = iterations;\n\n\n\n\tbuildTopology(mesh);\n\n\n\n\tdoRelax();\n\n\n\n\toutput.setLength(m_relaxData->m_vertcount);\n\n\toutput = m_relaxData->m_relaxpoints;\n\n}\n\n\n\nvoid chwEdgeRelax::relax(MObject& mesh, unsigned int iterations, MPointArray &output, MFloatArray &weights)\n\n{\n\n\tm_relaxData->m_iterations = iterations;\n\n\n\n\tbuildTopology(mesh);\n\n\n\n\tm_relaxData->m_weights = weights;\n\n\n\n\tdoRelax();\n\n\n", "file_path": "src/chwEdgeRelax.cpp", "rank": 79, "score": 15.045322833624525 }, { "content": "MObject \t\tchwMatrixSelector::aInMatrixIndex;\n\n\n\nchwMatrixSelector::chwMatrixSelector(){}\n\nchwMatrixSelector::~chwMatrixSelector(){}\n\nvoid* chwMatrixSelector::creator(){ return new chwMatrixSelector(); }\n\n\n\nMStatus chwMatrixSelector::compute(const MPlug& plug, MDataBlock& data)\n\n{\n\n\tMStatus status;\n\n\n\n\tif(plug == aOutRotate || plug == aOutTranslate || plug.parent() == aOutRotate || plug.parent() == aOutTranslate) {\n\n\t\tunsigned int matrixIndex = data.inputValue( aInMatrixIndex ).asShort();\n\n\t\tMArrayDataHandle arrayHandle = data.inputArrayValue(aInMatrixList, &status);\n\n\t\tif (status == MS::kSuccess) {\n\n\t\t\tunsigned int count = arrayHandle.elementCount();\n\n\t\t\tif (matrixIndex<count) {\n\n\t\t\t\tarrayHandle.jumpToArrayElement(matrixIndex);\n\n\t\t\t\tMDataHandle inputHandle = arrayHandle.inputValue(&status).child(aInMatrix);\n\n\t\t\t\tif (status == MS::kSuccess) {\n\n\t\t\t\t\tMTransformationMatrix matrix = inputHandle.asMatrix();\n", "file_path": "src/chwMatrixSelector.cpp", "rank": 80, "score": 14.951340062788235 }, { "content": "\t\t\t\tm_data->m_collisionStrength = collisionStrengthHnd.asFloat();\n\n\t\t\t\tm_data->m_bulgeStrength = collisionBulgeStrengthHnd.asFloat();\n\n\t\t\t\tm_data->m_bulgeDistance = collisionBulgeDistanceHnd.asFloat();\n\n\t\t\t\tm_data->m_defmax = 0.f;\n\n\n\n\t\t\t\tif ((m_data->m_collisionStrength > 0.f) && !collisionMeshHnd.data().isNull())\n\n\t\t\t\t{\n\n\t\t\t\t\tMFloatPointArray pointsCol;\n\n\t\t\t\t\tMObject\tcolMesh = collisionMeshHnd.asMeshTransformed();\n\n\t\t\t\t\ttc.colFn = new MFnMesh(colMesh);\n\n\n\n\t\t\t\t\tstatus = tc.colFn->getPoints(pointsCol, MSpace::kWorld);\n\n\t\t\t\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\t\t\t\tfor (unsigned int idx=0; idx<pointsCol.length(); idx++)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tm_data->m_boxcol.expand(pointsCol[idx]);\n\n\t\t\t\t\t}\n\n\n\n\t\t\t\t\tm_data->m_mmAccelParams = tc.colFn->autoUniformGridParams();\n", "file_path": "src/chwCollision.cpp", "rank": 83, "score": 14.519192903052751 }, { "content": "MObject \t\tchwCurveSampler::aOutTranslateZ;\n\n\n\nchwCurveSampler::chwCurveSampler(){}\n\nchwCurveSampler::~chwCurveSampler(){}\n\nvoid* chwCurveSampler::creator(){ return new chwCurveSampler(); }\n\n\n\nMStatus chwCurveSampler::compute(const MPlug& plug, MDataBlock& data)\n\n{\n\n\tMStatus status;\n\n\n\n\tif(plug == aOutRotate || plug == aOutTranslate || plug.parent() == aOutRotate || plug.parent() == aOutTranslate) {\n\n\t\t// GET NUM SAMPLES\n\n\t\tunsigned int inNumSamples = data.inputValue(aInNumSamples).asInt();\n\n\n\n\t\t// SETUP ARRAY DATA HANDLE\n\n\t\tMArrayDataHandle outRotateArray = data.outputArrayValue(aOutRotate, &status);\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n\n\n\n\t\tMArrayDataHandle outTranslateArray = data.outputArrayValue(aOutTranslate, &status);\n\n\t\tCHECK_MSTATUS_AND_RETURN_IT(status);\n", "file_path": "src/chwCurveSampler.cpp", "rank": 84, "score": 14.334236951924755 }, { "content": "\t\t\t\t\tm_data->m_intersector.create(colMesh);\n\n\n\n\t\t\t\t\tif (m_data->m_boxin.intersects(m_data->m_boxcol))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tparallel_for( blocked_range<int>( 0, m_data->m_numpoints ), tc );\n\n\t\t\t\t\t\tparallel_for( blocked_range<int>( 0, m_data->m_numpoints ), tb );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tmeshFn.setPoints(m_data->m_points, MSpace::kWorld);\n\n\t}\n\n\tdata.setClean(plug);\n\n\treturn MS::kSuccess;\n\n}\n\n\n\nvoid chwCollision::postConstructor()\n\n{\n\n\tMStatus status;\n\n\n", "file_path": "src/chwCollision.cpp", "rank": 86, "score": 12.494921731601483 }, { "content": "chwCollision::~chwCollision()\n\n{\n\n\tdelete m_data;\n\n}\n\nvoid* chwCollision::creator(){ return new chwCollision(); }\n\n\n\nMStatus chwCollision::initialize()\n\n{\n\n\tMFnTypedAttribute\t\ttAttr;\n\n\tMFnNumericAttribute\t\tnAttr;\n\n\tMFnCompoundAttribute\tcAttr;\n\n\tMRampAttribute\t\t\trAttr;\n\n\tMFnStringData\t\t\tstringdata;\n\n\n\n\taCollisionMesh = tAttr.create( \"collisionMesh\", \"cm\", MFnData::kMesh );\n\n\ttAttr.setStorable(false);\n\n\ttAttr.setConnectable(true);\n\n\taddAttribute( aCollisionMesh );\n\n\n\n\taCollisionMeshName = tAttr.create( \"collisionMeshName\", \"cmn\", MFnData::kString, stringdata.create() );\n", "file_path": "src/chwCollision.cpp", "rank": 87, "score": 12.134161223076516 }, { "content": "\n\n\t\t\tm[2][0] = vz[0];\n\n\t\t\tm[2][1] = vz[1];\n\n\t\t\tm[2][2] = vz[2];\n\n\t\t\tm[2][3] = 0.f;\n\n\n\n\t\t\tm[3][0] = inCurvePoint[0];\n\n\t\t\tm[3][1] = inCurvePoint[1];\n\n\t\t\tm[3][2] = inCurvePoint[2];\n\n\t\t\tm[3][3] = 1.f;\n\n\n\n\t\t\tMDataHandle outRotateHnd = outRotateBuilder.addElement(idx);\n\n\t\t\tMDataHandle outTranslateHnd = outTranslateBuilder.addElement(idx);\n\n\n\n\t\t\tMTransformationMatrix outMatrix(m);\n\n\t\t\tMTransformationMatrix::RotationOrder order;\n\n\n\n\t\t\toutMatrix.getRotation(outRotate, order, MSpace::kWorld);\n\n\t\t\toutTranslate = outMatrix.getTranslation(MSpace::kWorld);\n\n\n", "file_path": "src/chwCurveSampler.cpp", "rank": 88, "score": 11.403400283474532 }, { "content": "\n\n\tmeshfn.getPoints(m_relaxData->m_points, MSpace::kObject);\n\n\n\n\tm_relaxData->m_vertcount = iter.count();\n\n\tm_relaxData->m_points.clear();\n\n\tm_relaxData->m_relaxpoints.clear();\n\n\tm_relaxData->m_weights.clear();\n\n\tm_relaxData->m_points.setLength(m_relaxData->m_vertcount);\n\n\tm_relaxData->m_relaxpoints.setLength(m_relaxData->m_vertcount);\n\n\tm_relaxData->m_weights.setLength(m_relaxData->m_vertcount);\n\n\n\n\tm_relaxData->m_weights = MFloatArray(m_relaxData->m_vertcount, 1.f);\n\n\n\n\tif (m_relaxData->m_vertcount != m_relaxData->m_cachedcount)\n\n\t{\n\n\t\tm_relaxData->m_conids.clear();\n\n\t\tm_relaxData->m_conids.resize(m_relaxData->m_vertcount);\n\n\t\tfor (unsigned int idx=0; !iter.isDone(); iter.next(),++idx)\n\n\t\t{\n\n\t\t\t\titer.getConnectedVertices(conVerts);\n", "file_path": "src/chwEdgeRelax.cpp", "rank": 89, "score": 11.103473489102276 }, { "content": "\n\nvoid* chwNormalOffset::creator()\n\n{\n\n\treturn new chwNormalOffset();\n\n}\n\n\n\n\n\nMStatus chwNormalOffset::initialize()\n\n{\n\n\tMFnNumericAttribute nAttr;\n\n\n\n\taStrength = nAttr.create( \"strength\", \"str\", MFnNumericData::kFloat );\n\n\tnAttr.setKeyable(true);\n\n\tnAttr.setStorable(true);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setConnectable(true);\n\n\taddAttribute( aStrength );\n\n\n\n\taNormalSmooth = nAttr.create( \"normalSmooth\", \"ns\", MFnNumericData::kInt );\n\n\tnAttr.setKeyable(true);\n", "file_path": "src/chwNormalOffset.cpp", "rank": 90, "score": 10.752410281520898 }, { "content": "* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n***********************************************************************************/\n\n\n\n#include <maya/MFnPlugin.h>\n\n#include <chwVertexBind.h>\n\n#include <chwMeshRelax.h>\n\n#include <chwNormalOffset.h>\n\n#include <chwMatrixSelector.h>\n\n#include <chwCurveSampler.h>\n\n#include <chwCollision.h>\n\n#include <chwSurfaceTweak.h>\n\n\n\nMStatus initializePlugin( MObject obj )\n\n{\n\n\tMFnPlugin plugin( obj, \"Cristian Hinz Welkens\", \"1.0\", \"Any\");\n\n\n\n\tCHECK_MSTATUS ( plugin.registerNode( chwVertexBind::typeName, chwVertexBind::typeId,\n\n\t\t\t\t\tchwVertexBind::creator, chwVertexBind::initialize, MPxNode::kDeformerNode ) );\n\n\n\n\tCHECK_MSTATUS ( plugin.registerNode( chwMeshRelax::typeName, chwMeshRelax::typeId,\n", "file_path": "src/chwTools.cpp", "rank": 91, "score": 10.692089496458017 }, { "content": "\tnAttr.setStorable(true);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setConnectable(true);\n\n\tnAttr.setMin(0);\n\n\taddAttribute( aNormalSmooth );\n\n\n\n\tattributeAffects( chwNormalOffset::aStrength, chwNormalOffset::outputGeom );\n\n\tattributeAffects( chwNormalOffset::aNormalSmooth, chwNormalOffset::outputGeom );\n\n\n\n\tMGlobal::executeCommand(\"makePaintable -attrType multiFloat -sm deformer chwNormalOffset weights\");\n\n\n\n\treturn MStatus::kSuccess;\n\n}\n\n\n\nMStatus chwNormalOffset::compute(const MPlug& plug, MDataBlock& data)\n\n{\n\n\n\n\tMStatus status;\n\n\tm_data->m_env = data.inputValue(envelope).asFloat();\n\n\tm_data->m_strength = data.inputValue(aStrength).asFloat();\n", "file_path": "src/chwNormalOffset.cpp", "rank": 92, "score": 10.658778140880191 }, { "content": "\t\t\t\tfor (unsigned int idz=0;idz<conVerts.length();++idz)\n\n\t\t\t\t{\n\n\t\t\t\t\tm_relaxData->m_conids[idx].push_back(conVerts[idz]);\n\n\t\t\t\t}\n\n\t\t}\n\n\t\titer.reset();\n\n\t}\n\n\tm_relaxData->m_cachedcount = m_relaxData->m_vertcount;\n\n}\n", "file_path": "src/chwEdgeRelax.cpp", "rank": 93, "score": 10.386067077330875 }, { "content": "\t\t\tinCurveTangent = inCurveFn.tangent(param, MSpace::kWorld);\n\n\t\t\tinCurveFn.getPointAtParam(param, inCurvePoint, MSpace::kWorld);\n\n\t\t\tinUpCurveFn.getPointAtParam(param, inUpCurvePoint, MSpace::kWorld);\n\n\n\n\n\n\t\t\tMMatrix m;\n\n\n\n\t\t\tvx = inCurveTangent.normal();\n\n\t\t\tvy = (inUpCurvePoint - inCurvePoint).normal();\n\n\t\t\tvz = (vx ^ vy).normal();\n\n\n\n\t\t\tm[0][0] = vx[0];\n\n\t\t\tm[0][1] = vx[1];\n\n\t\t\tm[0][2] = vx[2];\n\n\t\t\tm[0][3] = 0.f;\n\n\n\n\t\t\tm[1][0] = vy[0];\n\n\t\t\tm[1][1] = vy[1];\n\n\t\t\tm[1][2] = vy[2];\n\n\t\t\tm[1][3] = 0.f;\n", "file_path": "src/chwCurveSampler.cpp", "rank": 95, "score": 9.474514580096084 }, { "content": "\tuAttr.setConnectable(true);\n\n\taOutRotate = nAttr.create( \"outRotate\", \"or\", aOutRotateX, aOutRotateY, aOutRotateZ);\n\n\tnAttr.setArray(true);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setStorable(true);\n\n\tnAttr.setConnectable(true);\n\n\tnAttr.setUsesArrayDataBuilder(true);\n\n\taddAttribute( aOutRotate );\n\n\n\n\n\n\taOutTranslateX = nAttr.create( \"outTranslateX\", \"otx\", MFnNumericData::kDouble, 0.0);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setStorable(true);\n\n\tnAttr.setConnectable(true);\n\n\taOutTranslateY = nAttr.create( \"outTranslateY\", \"oty\", MFnNumericData::kDouble, 0.0);\n\n\tnAttr.setWritable(true);\n\n\tnAttr.setStorable(true);\n\n\tnAttr.setConnectable(true);\n\n\taOutTranslateZ = nAttr.create( \"outTranslateZ\", \"otz\", MFnNumericData::kDouble, 0.0);\n\n\tnAttr.setWritable(true);\n", "file_path": "src/chwCurveSampler.cpp", "rank": 97, "score": 8.829101889861452 }, { "content": "\tstatus = postConstructor_initialise_ramp_curve( aCollisionBulgeRamp, 0, 0.0f, 0.0f, 2 );\n\n\tCHECK_MSTATUS(status);\n\n\tstatus = postConstructor_initialise_ramp_curve( aCollisionBulgeRamp, 1, 0.3f, 0.8f, 2 );\n\n\tCHECK_MSTATUS(status);\n\n\tstatus = postConstructor_initialise_ramp_curve( aCollisionBulgeRamp, 2, 1.0f, 0.0f, 2 );\n\n\tCHECK_MSTATUS(status);\n\n}\n\n\n\nMStatus chwCollision::postConstructor_initialise_ramp_curve( MObject &rampObj, int index, float position, float value, int interpolation)\n\n{\n\n\tMStatus status;\n\n\n\n\tMObject thisNode = this->thisMObject();\n\n\n\n\tMPlug rampPlug( thisNode, rampObj );\n\n\tMPlug elementPlug = rampPlug.elementByLogicalIndex( index, &status );\n\n\n\n\tMPlug positionPlug = elementPlug.child(0, &status);\n\n\tstatus = positionPlug.setFloat(position);\n\n\n\n\tMPlug valuePlug = elementPlug.child(1);\n\n\tstatus = valuePlug.setFloat(value);\n\n\n\n\tMPlug interpPlug = elementPlug.child(2);\n\n\tinterpPlug.setInt(interpolation);\n\n\n\n\treturn MS::kSuccess;\n\n}\n", "file_path": "src/chwCollision.cpp", "rank": 99, "score": 8.504856191374927 } ]
C++
src/transpiler/transpiler.cpp
GeminiLab/afbd
6855eedd6e3b1309adea2071074d0ce0003e6079
#include <transpiler/transpiler.h> #include <llvm/IR/TypeBuilder.h> #include <queue> #include <set> #include <sstream> #include <iostream> using namespace std; using namespace afbd; void print_common_header(fstream &fs) { } shared_ptr<set<shared_ptr<Instruction>>> get_all_instrs(shared_ptr<Instruction> root) { auto _instrs = make_shared<set<shared_ptr<Instruction>>>(); queue<shared_ptr<Instruction>> _instr_to_visit; _instrs->insert(root); _instr_to_visit.push(root); while (!_instr_to_visit.empty()) { auto u = _instr_to_visit.front(); _instr_to_visit.pop(); for (auto& e: *u->succs()) { auto nx = e.first; if (_instrs->find(nx) == _instrs->end()) { _instrs->insert(nx); _instr_to_visit.push(nx); } } } return _instrs; } llvm::Function *Transpiler::transpile_process(shared_ptr<Process> proc) { std::ostringstream ss; ss << "process_" << rand() << "_" << time(nullptr); auto process = llvm::Function::Create( process_type, llvm::GlobalValue::LinkageTypes::ExternalLinkage, ss.str(), m ); llvm::IRBuilder<> builder(context); auto bbEntry = llvm::BasicBlock::Create(context, "", process); auto bbLoop = llvm::BasicBlock::Create(context, "", process); llvm::BasicBlock* bbEnd; if (proc->type() == ProcessType::Always) { bbEnd = bbLoop; } else { bbEnd = llvm::BasicBlock::Create(context, "", process); } builder.SetInsertPoint(bbEntry); auto sim = process->arg_begin(); map<shared_ptr<Var>, llvm::Value*> varAddr; for (auto &v: *var_id) { varAddr[v.first] = builder.CreateInBoundsGEP(sim, llvm::ArrayRef<llvm::Value*> { builder.getInt32(0), builder.getInt32(v.second) }); } function<llvm::Value*(shared_ptr<Expr>)> eval = [&](shared_ptr<Expr> expr) -> llvm::Value* { auto type = expr->type(); if (type == ExprType::VAR) { return builder.CreateLoad(varAddr[expr->as_var()]); } else if (type == ExprType::CONSTANT) { return builder.getInt32(expr->as_constant()->value()); } else { if (type == ExprType::NOT) { return builder.CreateNot(eval(expr->get_operand(0))); } else if (type == ExprType::REDUCE_BOOL) { return builder.CreateIntCast(eval(expr->get_operand(0)), builder.getInt32Ty(), false); } else if (type == ExprType::COND) { return builder.CreateSelect(eval(expr->get_operand(0)), eval(expr->get_operand(1)), eval(expr->get_operand(2))); } else { auto opl = eval(expr->get_operand(0)); auto opr = eval(expr->get_operand(1)); switch (type) { case ExprType::ADD: return builder.CreateAdd(opl, opr); case ExprType::SUB: return builder.CreateSub(opl, opr); case ExprType::MUL: return builder.CreateMul(opl, opr); case ExprType::DIV: return builder.CreateUDiv(opl, opr); case ExprType::MOD: return builder.CreateURem(opl, opr); case ExprType::EQ: return builder.CreateICmpEQ(opl, opr); case ExprType::NE: return builder.CreateICmpNE(opl, opr); case ExprType::GT: return builder.CreateICmpUGT(opl, opr); case ExprType::GE: return builder.CreateICmpUGE(opl, opr); case ExprType::LT: return builder.CreateICmpULT(opl, opr); case ExprType::LE: return builder.CreateICmpULE(opl, opr); case ExprType::AND: return builder.CreateAnd(opl, opr); case ExprType::OR: return builder.CreateOr(opl, opr); case ExprType::XOR: return builder.CreateXor(opl, opr); case ExprType::SHL: return builder.CreateShl(opl, opr); case ExprType::LSHR: return builder.CreateLShr(opl, opr); case ExprType::ASHR: return builder.CreateAShr(opl, opr); } } } }; function<llvm::Value*(llvm::Value*, int32_t)> shrink_to_width = [&](llvm::Value *v, int32_t width) -> llvm::Value* { return builder.CreateAnd(v, builder.getInt32((uint32_t)((1ull << width) - 1))); }; auto instrs = get_all_instrs(proc->begin()); map<shared_ptr<Instruction>, llvm::BasicBlock*> instr_bb; for (auto &x: *instrs) { instr_bb[x] = llvm::BasicBlock::Create(context, "", process); } builder.CreateBr(bbLoop); builder.SetInsertPoint(bbLoop); builder.CreateBr(instr_bb[proc->begin()]); for (auto &x: *instrs) { builder.SetInsertPoint(instr_bb[x]); auto type = x->type(); auto instr_delay = x->delay(); auto has_delay = instr_delay >= 0; instr_delay = has_delay ? instr_delay : 0; if (type == InstructionType::Delay) { if (instr_delay > 0) { builder.CreateCall(delay, llvm::ArrayRef<llvm::Value*> { builder.getInt32(instr_delay) }); } } else if (type == InstructionType::Trigger) { if (x->triggers()->size() > 0) { builder.CreateCall(prepare_wait); for (auto &w: *x->triggers()) { builder.CreateCall( add_wait, llvm::ArrayRef<llvm::Value*> { builder.getInt32(var_id->at(w.first)), builder.getInt32((int32_t)w.second), } ); } builder.CreateCall(do_wait); } } else { auto assign_type = x->assign_type(); auto dst = x->dst()->as_var(); if (assign_type == AssignType::Blocking) { if (has_delay) { auto temp = builder.CreateAlloca(builder.getInt32Ty()); builder.CreateStore(shrink_to_width(eval(x->expr()), dst->bit()), temp); if (instr_delay == 0) { builder.CreateCall(delay_for_explicit_zero_delay); } else { builder.CreateCall(delay, llvm::ArrayRef<llvm::Value*> { builder.getInt32(instr_delay) }); } builder.CreateCall( update, llvm::ArrayRef<llvm::Value*> { varAddr[x->dst()->as_var()], builder.CreateLoad(temp), builder.getInt32(var_id->at(dst)), } ); } else { builder.CreateCall( update, llvm::ArrayRef<llvm::Value*> { varAddr[x->dst()->as_var()], shrink_to_width(eval(x->expr()), dst->bit()), builder.getInt32(var_id->at(dst)), } ); } } else { builder.CreateCall( delayed_nonblocking_assign_update, llvm::ArrayRef<llvm::Value*> { varAddr[x->dst()->as_var()], shrink_to_width(eval(x->expr()), dst->bit()), builder.getInt32(var_id->at(dst)), builder.getInt32(instr_delay), } ); } } auto bbcd = llvm::BasicBlock::Create(context, "", process); builder.CreateBr(bbcd); builder.SetInsertPoint(bbcd); bool end = false; for (auto &s: *x->succs()) { auto instr = s.first; auto cond = s.second; if (cond == nullptr) { builder.CreateBr(instr_bb[instr]); end = true; break; } else { bbcd = llvm::BasicBlock::Create(context, "", process); builder.CreateCondBr(eval(cond), instr_bb[instr], bbcd); builder.SetInsertPoint(bbcd); } } if (!end) builder.CreateBr(bbEnd); } if (bbEnd != bbLoop) { builder.SetInsertPoint(bbEnd); builder.CreateCall(process_end); builder.CreateRetVoid(); } return process; } void Transpiler::load_static_functions() { auto voidTy = llvm::TypeBuilder<void, false>::get(context); auto tickTy = llvm::TypeBuilder<int32_t, false>::get(context); auto valTy = llvm::TypeBuilder<int32_t, false>::get(context); auto valPtrTy = valTy->getPointerTo(); auto varIdTy = llvm::TypeBuilder<int32_t, false>::get(context); auto edgeTy = llvm::TypeBuilder<int32_t, false>::get(context); process_type = llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{sim_type->getPointerTo()}, false ); set_var_count = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{varIdTy}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "set_var_count", m ); push_process = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{process_type->getPointerTo(), sim_type->getPointerTo()}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "push_process", m ); process_end = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "process_end", m ); reset = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "reset", m ); delay = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { tickTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delay", m ); delay_for_explicit_zero_delay = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delay_for_explicit_zero_delay", m ); delay_for_nonblocking_assign_update = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { tickTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delay_for_nonblocking_assign_update", m ); delayed_nonblocking_assign_update = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { valPtrTy, valTy, varIdTy, tickTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delayed_nonblocking_assign_update", m ); prepare_wait = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "prepare_wait", m ); add_wait = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{ varIdTy, edgeTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "add_wait", m ); do_wait = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "do_wait", m ); update = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { valPtrTy, valTy, varIdTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "update", m ); } llvm::Module *Transpiler::transpile(shared_ptr<Module> module, shared_ptr<fstream> fs) { auto simName = "sim_" + module->name(); m = new llvm::Module("sim_" + simName, context); llvm::IRBuilder<> builder(context); print_common_header(*fs); var_id = make_shared<map<shared_ptr<Var>, int>>(); *fs << "struct " << simName << " {" << endl; vector<llvm::Type *> member; for (auto &var: *module->vars()) { (*var_id)[var] = member.size(); member.push_back(builder.getInt32Ty()); *fs << "int " << *var->name() << ";" << endl; } *fs << "};" << endl; sim_type = llvm::StructType::create(context, llvm::ArrayRef<llvm::Type *>(member), simName); auto initializer = llvm::Function::Create( llvm::FunctionType::get(builder.getVoidTy(), llvm::ArrayRef<llvm::Type *>{sim_type->getPointerTo()}, false), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "initialize_sim", m ); *fs << "extern \"C\" void initialize_sim(" << simName << "*);" << endl; load_static_functions(); auto bb = llvm::BasicBlock::Create(context, "", initializer); builder.SetInsertPoint(bb); initializer->arg_begin()->setName("s"); builder.CreateCall(set_var_count, llvm::ArrayRef<llvm::Value*> { builder.getInt32(module->vars()->size()) }); for (auto &proc: *module->procs()) { builder.CreateCall(push_process, llvm::ArrayRef<llvm::Value*> { transpile_process(proc), initializer->arg_begin() }); } builder.CreateRetVoid(); fs->close(); return m; }
#include <transpiler/transpiler.h> #include <llvm/IR/TypeBuilder.h> #include <queue> #include <set> #include <sstream> #include <iostream> using namespace std; using namespace afbd; void print_common_header(fstream &fs) { } shared_ptr<set<shared_ptr<Instruction>>> get_all_instrs(shared_ptr<Instruction> root) { auto _instrs = make_shared<set<shared_ptr<Instruction>>>(); queue<shared_ptr<Instruction>> _instr_to_visit; _instrs->insert(root); _instr_to_visit.push(root); while (!_instr_to_visit.empty()) { auto u = _instr_to_visit.front(); _instr_to_visit.pop(); for (auto& e: *u->succs()) { auto nx = e.first; if (_instrs->find(nx) == _instrs->end()) { _instrs->insert(nx); _instr_to_visit.push(nx); } } } return _instrs; } llvm::Function *Transpiler::transpile_process(shared_ptr<Process> proc) { std::ostringstream ss; ss << "process_" << rand() << "_" << time(nullptr); auto process = llvm::Function::Create( process_type, llvm::GlobalValue::LinkageTypes::ExternalLinkage, ss.str(), m ); llvm::IRBuilder<> builder(context); auto bbEntry = llvm::BasicBlock::Create(context, "", process); auto bbLoop = llvm::BasicBlock::Create(context, "", process); llvm::BasicBlock* bbEnd; if (proc->type() == ProcessType::Always) { bbEnd = bbLoop; } else { bbEnd = llvm::BasicBlock::Create(context, "", process); } builder.SetInsertPoint(bbEntry); auto sim = process->arg_begin(); map<shared_ptr<Var>, llvm::Value*> varAddr; for (auto &v: *var_id) { varAddr[v.first] = builder.CreateInBoundsGEP(sim, llvm::ArrayRef<llvm::Value*> { builder.getInt32(0), builder.getInt32(v.second) }); } function<llvm::Value*(shared_ptr<Expr>)> eval = [&](shared_ptr<Expr> expr) -> llvm::Value* { auto type = expr->type(); if (type == ExprType::VAR) { return builder.CreateLoad(varAddr[expr->as_var()]); } else if (type == ExprType::CONSTANT) { return builder.getInt32(expr->as_constant()->value()); } else { if (type == ExprType::NOT) { return builder.CreateNot(eval(expr->get_operand(0))); } else if (type == ExprType::REDUCE_BOOL) { return builder.CreateIntCast(eval(expr->get_operand(0)), builder.getInt32Ty(), false); } else if (type == ExprType::COND) { return builder.CreateSelect(eval(expr->get_operand(0)), eval(expr->get_operand(1)), eval(expr->get_operand(2))); } else { auto opl = eval(expr->get_operand(0)); auto opr = eval(expr->get_operand(1)); switch (type) { case ExprType::ADD: return builder.CreateAdd(opl, opr); case ExprType::SUB: return builder.CreateSub(opl, opr); case ExprType::MUL: return builder.CreateMul(opl, opr); case ExprType::DIV: return builder.CreateUDiv(opl, opr); case ExprType::MOD: return builder.CreateURem(opl, opr); case ExprType::EQ: return builder.CreateICmpEQ(opl, opr); case ExprType::NE: return builder.CreateICmpNE(opl, opr); case ExprType::GT: return builder.CreateICmpUGT(opl, opr); case ExprType::GE: return builder.CreateICmpUGE(opl, opr); case ExprType::LT: return builder.CreateICmpULT(opl, opr); case ExprType::LE: return builder.CreateICmpULE(opl, opr); case ExprType::AND: return builder.CreateAnd(opl, opr); case ExprType::OR: return builder.CreateOr(opl, opr); case ExprType::XOR: return builder.CreateXor(opl, opr); case ExprType::SHL: return builder.CreateShl(opl, opr); case ExprType::LSHR: return builder.CreateLShr(opl, opr); case ExprType::ASHR: return builder.CreateAShr(opl, opr); } } } }; function<llvm::Value*(llvm::Value*, int32_t)> shrink_to_width = [&](llvm::Value *v, int32_t width) -> llvm::Value* { return builder.CreateAnd(v, builder.getInt32((uint32_t)((1ull << width) - 1))); }; auto instrs = get_all_instrs(proc->begin()); map<shared_ptr<Instruction>, llvm::BasicBlock*> instr_bb; for (auto &x: *instrs) { instr_bb[x] = llvm::BasicBlock::Create(context, "", process); } builder.CreateBr(bbLoop); builder.SetInsertPoint(bbLoop); builder.CreateBr(instr_bb[proc->begin()]); for (auto &x: *instrs) { builder.SetInsertPoint(instr_bb[x]); auto type = x->type(); auto instr_delay = x->delay(); auto has_delay = instr_delay >= 0; instr_delay = has_delay ? instr_delay : 0; if (type == InstructionType::Delay) { if (instr_delay > 0) { builder.CreateCall(delay, llvm::ArrayRef<llvm::Value*> { builder.getInt32(instr_delay) }); } } else if (type == InstructionType::Trigger) { if
process_type = llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{sim_type->getPointerTo()}, false ); set_var_count = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{varIdTy}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "set_var_count", m ); push_process = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{process_type->getPointerTo(), sim_type->getPointerTo()}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "push_process", m ); process_end = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "process_end", m ); reset = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "reset", m ); delay = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { tickTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delay", m ); delay_for_explicit_zero_delay = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delay_for_explicit_zero_delay", m ); delay_for_nonblocking_assign_update = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { tickTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delay_for_nonblocking_assign_update", m ); delayed_nonblocking_assign_update = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { valPtrTy, valTy, varIdTy, tickTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "delayed_nonblocking_assign_update", m ); prepare_wait = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "prepare_wait", m ); add_wait = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{ varIdTy, edgeTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "add_wait", m ); do_wait = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type *>{}, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "do_wait", m ); update = llvm::Function::Create( llvm::FunctionType::get( voidTy, llvm::ArrayRef<llvm::Type*> { valPtrTy, valTy, varIdTy }, false ), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "update", m ); } llvm::Module *Transpiler::transpile(shared_ptr<Module> module, shared_ptr<fstream> fs) { auto simName = "sim_" + module->name(); m = new llvm::Module("sim_" + simName, context); llvm::IRBuilder<> builder(context); print_common_header(*fs); var_id = make_shared<map<shared_ptr<Var>, int>>(); *fs << "struct " << simName << " {" << endl; vector<llvm::Type *> member; for (auto &var: *module->vars()) { (*var_id)[var] = member.size(); member.push_back(builder.getInt32Ty()); *fs << "int " << *var->name() << ";" << endl; } *fs << "};" << endl; sim_type = llvm::StructType::create(context, llvm::ArrayRef<llvm::Type *>(member), simName); auto initializer = llvm::Function::Create( llvm::FunctionType::get(builder.getVoidTy(), llvm::ArrayRef<llvm::Type *>{sim_type->getPointerTo()}, false), llvm::GlobalValue::LinkageTypes::ExternalLinkage, "initialize_sim", m ); *fs << "extern \"C\" void initialize_sim(" << simName << "*);" << endl; load_static_functions(); auto bb = llvm::BasicBlock::Create(context, "", initializer); builder.SetInsertPoint(bb); initializer->arg_begin()->setName("s"); builder.CreateCall(set_var_count, llvm::ArrayRef<llvm::Value*> { builder.getInt32(module->vars()->size()) }); for (auto &proc: *module->procs()) { builder.CreateCall(push_process, llvm::ArrayRef<llvm::Value*> { transpile_process(proc), initializer->arg_begin() }); } builder.CreateRetVoid(); fs->close(); return m; }
(x->triggers()->size() > 0) { builder.CreateCall(prepare_wait); for (auto &w: *x->triggers()) { builder.CreateCall( add_wait, llvm::ArrayRef<llvm::Value*> { builder.getInt32(var_id->at(w.first)), builder.getInt32((int32_t)w.second), } ); } builder.CreateCall(do_wait); } } else { auto assign_type = x->assign_type(); auto dst = x->dst()->as_var(); if (assign_type == AssignType::Blocking) { if (has_delay) { auto temp = builder.CreateAlloca(builder.getInt32Ty()); builder.CreateStore(shrink_to_width(eval(x->expr()), dst->bit()), temp); if (instr_delay == 0) { builder.CreateCall(delay_for_explicit_zero_delay); } else { builder.CreateCall(delay, llvm::ArrayRef<llvm::Value*> { builder.getInt32(instr_delay) }); } builder.CreateCall( update, llvm::ArrayRef<llvm::Value*> { varAddr[x->dst()->as_var()], builder.CreateLoad(temp), builder.getInt32(var_id->at(dst)), } ); } else { builder.CreateCall( update, llvm::ArrayRef<llvm::Value*> { varAddr[x->dst()->as_var()], shrink_to_width(eval(x->expr()), dst->bit()), builder.getInt32(var_id->at(dst)), } ); } } else { builder.CreateCall( delayed_nonblocking_assign_update, llvm::ArrayRef<llvm::Value*> { varAddr[x->dst()->as_var()], shrink_to_width(eval(x->expr()), dst->bit()), builder.getInt32(var_id->at(dst)), builder.getInt32(instr_delay), } ); } } auto bbcd = llvm::BasicBlock::Create(context, "", process); builder.CreateBr(bbcd); builder.SetInsertPoint(bbcd); bool end = false; for (auto &s: *x->succs()) { auto instr = s.first; auto cond = s.second; if (cond == nullptr) { builder.CreateBr(instr_bb[instr]); end = true; break; } else { bbcd = llvm::BasicBlock::Create(context, "", process); builder.CreateCondBr(eval(cond), instr_bb[instr], bbcd); builder.SetInsertPoint(bbcd); } } if (!end) builder.CreateBr(bbEnd); } if (bbEnd != bbLoop) { builder.SetInsertPoint(bbEnd); builder.CreateCall(process_end); builder.CreateRetVoid(); } return process; } void Transpiler::load_static_functions() { auto voidTy = llvm::TypeBuilder<void, false>::get(context); auto tickTy = llvm::TypeBuilder<int32_t, false>::get(context); auto valTy = llvm::TypeBuilder<int32_t, false>::get(context); auto valPtrTy = valTy->getPointerTo(); auto varIdTy = llvm::TypeBuilder<int32_t, false>::get(context); auto edgeTy = llvm::TypeBuilder<int32_t, false>::get(context);
random
[ { "content": "class SigSet<T, typename std::enable_if<!std::is_pointer<T>::value>::type> : public SigSet<T, std::less<T>> {};\n\ntemplate<typename T>\n\nusing sort_by_name_id_guard = typename std::enable_if<std::is_same<T,RTLIL::Cell*>::value>::type;\n\ntemplate<typename T>\n", "file_path": "3rd/yosys/include/sigtools.h", "rank": 0, "score": 180007.15396701597 }, { "content": "struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleObjectType,\n\n typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 1, "score": 179867.43734223006 }, { "content": "\t\tAstNodeType type;\n", "file_path": "3rd/yosys/include/ast.h", "rank": 2, "score": 163788.14090654557 }, { "content": "using std::max;\n", "file_path": "3rd/yosys/include/yosys.h", "rank": 3, "score": 163632.2245210259 }, { "content": "struct is_complete_type : std::false_type {};\n\n\n\ntemplate <typename T>\n", "file_path": "3rd/include/json/json.hpp", "rank": 4, "score": 156990.97360035335 }, { "content": "enum ProcessType {\n\n Initial,\n\n Always,\n\n};\n\n\n\n//std::string proc_type_to_str(ProcessType type);\n\n\n\nProcessType str_to_proc_type(std::string str);\n\n\n\n#define MAX_INST_NUM 10000\n\n\n", "file_path": "include/afbdil/process.h", "rank": 5, "score": 156754.22649043097 }, { "content": "struct is_compatible_type_impl: std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 6, "score": 153349.00334085766 }, { "content": "enum class ExprType {\n\n //terminal\n\n CONSTANT,\n\n VAR,\n\n\n\n //non-terminal\n\n ADD,\n\n SUB,\n\n MUL,\n\n DIV,\n\n MOD,\n\n SHL,\n\n LSHR,\n\n ASHR,\n\n\n\n AND,\n\n OR,\n\n XOR,\n\n NOT,\n\n\n", "file_path": "include/afbdil/expr.h", "rank": 7, "score": 151765.98218634046 }, { "content": "struct is_constructible_object_type_impl : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename ConstructibleObjectType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 8, "score": 149904.79958923694 }, { "content": "struct is_compatible_string_type_impl : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleStringType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 9, "score": 149904.79958923694 }, { "content": "struct is_compatible_object_type_impl : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleObjectType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 10, "score": 149904.79958923694 }, { "content": "struct is_constructible_array_type_impl : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename ConstructibleArrayType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 11, "score": 149904.79958923694 }, { "content": "struct is_compatible_integer_type_impl : std::false_type {};\n\n\n\ntemplate <typename RealIntegerType, typename CompatibleNumberIntegerType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 12, "score": 149904.79958923694 }, { "content": "struct is_compatible_array_type_impl : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleArrayType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 13, "score": 149904.79958923694 }, { "content": "struct is_constructible_string_type_impl : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename ConstructibleStringType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 14, "score": 149904.79958923694 }, { "content": "struct has_to_json : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename T>\n", "file_path": "3rd/include/json/json.hpp", "rank": 15, "score": 147192.7048842536 }, { "content": "struct has_from_json : std::false_type {};\n\n\n\ntemplate <typename BasicJsonType, typename T>\n", "file_path": "3rd/include/json/json.hpp", "rank": 16, "score": 147192.7048842536 }, { "content": " class NumberIntegerType = std::int64_t,\n", "file_path": "3rd/include/json/json.hpp", "rank": 17, "score": 143174.19757787322 }, { "content": "struct is_constructible_tuple : std::false_type {};\n\n\n\ntemplate <typename T1, typename... Args>\n", "file_path": "3rd/include/json/json.hpp", "rank": 18, "score": 143174.19757787322 }, { "content": "struct is_iterator_traits : std::false_type {};\n\n\n\ntemplate <typename T>\n", "file_path": "3rd/include/json/json.hpp", "rank": 19, "score": 143174.19757787322 }, { "content": " class NumberUnsignedType = std::uint64_t,\n", "file_path": "3rd/include/json/json.hpp", "rank": 20, "score": 143174.19757787322 }, { "content": "class Process {\n\n std::shared_ptr<Instruction> _begin;\n\n ProcessType _type;\n\npublic:\n\n Process();\n\n\n\n int inst_num;\n\n\n\n [[nodiscard]]\n\n ProcessType type() const;\n\n\n\n void type(ProcessType type);\n\n\n\n [[nodiscard]]\n\n std::shared_ptr<Instruction> begin() const;\n\n void begin(const std::shared_ptr<Instruction> &begin);\n\n\n\n std::shared_ptr<Process> substitute_clone(std::map<std::shared_ptr<Var>, std::shared_ptr<Expr>>& substitute_map);\n\n\n\n\tjson11::Json to_json();\n\n\n\n std::vector<std::shared_ptr<Instruction>> all_instructions();\n\n\n\n void to_smv(std::vector<std::shared_ptr<Expr>>& expressions, std::map<std::shared_ptr<Var>, int>& vars_next, std::map<std::shared_ptr<Var>, int>& vars_init, std::set<std::shared_ptr<Var>>& edge_vars, std::vector<std::pair<int, std::shared_ptr<Expr>>>& countdowns, std::vector<std::shared_ptr<Var>>& vars, int& temp_var_num, std::set<std::string>& conditions);\n\n};\n\n\n\n}\n", "file_path": "include/afbdil/process.h", "rank": 21, "score": 142358.58824152095 }, { "content": "class Expr {\n\n ExprType _type;\n\n std::shared_ptr<std::vector<std::shared_ptr<Expr>>> _operands;\n\n std::shared_ptr<Var> _var;\n\n std::shared_ptr<Constant> _constant;\n\n\n\npublic:\n\n Expr(std::shared_ptr<Var> var);\n\n Expr(std::shared_ptr<Constant> constant);\n\n Expr(ExprType type, std::initializer_list<std::shared_ptr<Expr>> operands);\n\n Expr(ExprType type, std::vector<std::shared_ptr<Expr>> operands);\n\n\n\n ExprType type() const;\n\n std::shared_ptr<Var> as_var() const;\n\n std::shared_ptr<Constant> as_constant() const;\n\n int operand_num() const;\n\n std::shared_ptr<Expr>& get_operand(int i) const;\n\n inline void add_operand(std::shared_ptr<Expr> operand) { _operands->push_back(operand); }\n\n\n\n bool is_true() const;\n", "file_path": "include/afbdil/expr.h", "rank": 22, "score": 142324.04959020176 }, { "content": " class StringType = std::string, class BooleanType = bool,\n", "file_path": "3rd/include/json/json.hpp", "rank": 23, "score": 139968.33736120502 }, { "content": "struct has_non_default_from_json : std::false_type {};\n\n\n\ntemplate<typename BasicJsonType, typename T>\n", "file_path": "3rd/include/json/json.hpp", "rank": 24, "score": 139405.9794356057 }, { "content": "class SigSet<T, sort_by_name_id_guard<T>> : public SigSet<T, RTLIL::sort_by_name_id<typename std::remove_pointer<T>::type>> {};\n\n\n", "file_path": "3rd/yosys/include/sigtools.h", "rank": 25, "score": 138162.99222854446 }, { "content": "class Process;\n", "file_path": "include/afbdil/def.h", "rank": 26, "score": 130225.17623551063 }, { "content": "class Expr;\n", "file_path": "include/afbdil/def.h", "rank": 27, "score": 130197.26789711507 }, { "content": "using namespace afbd;\n", "file_path": "include/afbdil/patternmatching.h", "rank": 28, "score": 129017.14243532556 }, { "content": "USING_YOSYS_NAMESPACE\n\n\n\nnamespace afbd\n\n{\n\n\ttypedef std::pair<std::shared_ptr<Expr>, std::shared_ptr<Expr>> ExprPair;\n\n\n\n\tstruct afbdilPass : public Pass\n\n\t{\n\n\t\tafbdilPass() : Pass(\"afbdilPass\") { }\n\n\n\n\t\tstd::map<std::string, std::shared_ptr<Module>> str2module;\n\n\t\tstd::vector<std::shared_ptr<Module>> unfolded_modules;\n\n\t\tstd::map<std::shared_ptr<Module>, int> module_occurence;\n\n\n\n\t\tstd::shared_ptr<Expr> parse_identifier(AST::AstNode* astnode, std::map<std::string, std::shared_ptr<Expr>>& str2expr);\n\n\t\tstd::shared_ptr<Expr> parse_constant(AST::AstNode* astnode);\n\n\t\tExprPair parse_range(AST::AstNode* astnode, std::map<std::string, std::shared_ptr<Expr>>& str2expr);\n\n\t\tstd::shared_ptr<Expr> parse_expr(AST::AstNode* astnode, std::map<std::string, std::shared_ptr<Expr>>& str2expr);\n\n\t\tstd::shared_ptr<Instruction> parse_block(std::shared_ptr<Instruction> begin, AST::AstNode* astnode, std::map<std::string, std::shared_ptr<Expr>>& str2expr, std::shared_ptr<Expr> cond);\n\n\t\tstd::shared_ptr<Instruction> parse_assign(std::shared_ptr<Instruction> begin, AST::AstNode* astnode, std::map<std::string, std::shared_ptr<Expr>>& str2expr, std::shared_ptr<Expr> cond, bool is_blocking);\n\n\t\tstd::shared_ptr<Instruction> parse_case(std::shared_ptr<Instruction> begin, AST::AstNode* astnode, std::map<std::string, std::shared_ptr<Expr>>& str2expr, std::shared_ptr<Expr> cond);\n\n\t\tstd::shared_ptr<Instruction> parse_statement(std::shared_ptr<Instruction> begin, AST::AstNode* astnode, std::map<std::string, std::shared_ptr<Expr>>& str2expr, std::shared_ptr<Expr> cond);\n\n\n\n void execute(vector<string> args, RTLIL::Design* design) override;\n\n\n\n\t\tvoid execute_cell(std::shared_ptr<Module>& curr, std::shared_ptr<std::vector<std::shared_ptr<Expr>>>& cell_vector);\n\n\n\n std::shared_ptr<Module> res;\n\n\t};\n", "file_path": "include/transpiler/afbdilpass.h", "rank": 29, "score": 129017.14243532556 }, { "content": "struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};\n\n\n\n//////////////////////////\n\n// aliases for detected //\n\n//////////////////////////\n\n\n\ntemplate <typename T>\n\nusing mapped_type_t = typename T::mapped_type;\n\n\n\ntemplate <typename T>\n\nusing key_type_t = typename T::key_type;\n\n\n\ntemplate <typename T>\n\nusing value_type_t = typename T::value_type;\n\n\n\ntemplate <typename T>\n\nusing difference_type_t = typename T::difference_type;\n\n\n\ntemplate <typename T>\n\nusing pointer_t = typename T::pointer;\n", "file_path": "3rd/include/json/json.hpp", "rank": 30, "score": 126606.10024646524 }, { "content": "YOSYS_NAMESPACE_BEGIN\n\n\n", "file_path": "3rd/yosys/include/yosys.h", "rank": 31, "score": 124736.54234612796 }, { "content": "YOSYS_NAMESPACE_BEGIN\n\n\n\nnamespace AST\n\n{\n\n\t// all node types, type2str() must be extended\n\n\t// whenever a new node type is added here\n\n\tenum AstNodeType\n\n\t{\n\n\t\tAST_NONE,\n\n\t\tAST_DESIGN,\n\n\t\tAST_MODULE,\n\n\t\tAST_TASK,\n\n\t\tAST_FUNCTION,\n\n\t\tAST_DPI_FUNCTION,\n\n\n\n\t\tAST_WIRE,\n\n\t\tAST_MEMORY,\n\n\t\tAST_AUTOWIRE,\n\n\t\tAST_PARAMETER,\n\n\t\tAST_LOCALPARAM,\n\n\t\tAST_DEFPARAM,\n\n\t\tAST_PARASET,\n\n\t\tAST_ARGUMENT,\n\n\t\tAST_RANGE,\n\n\t\tAST_MULTIRANGE,\n\n\t\tAST_CONSTANT,\n\n\t\tAST_REALVALUE,\n\n\t\tAST_CELLTYPE,\n\n\t\tAST_IDENTIFIER,\n\n\t\tAST_PREFIX,\n\n\t\tAST_ASSERT,\n\n\t\tAST_ASSUME,\n\n\t\tAST_LIVE,\n\n\t\tAST_FAIR,\n\n\t\tAST_COVER,\n\n\t\tAST_ENUM,\n\n\t\tAST_ENUM_ITEM,\n\n\n\n\t\tAST_FCALL,\n\n\t\tAST_TO_BITS,\n\n\t\tAST_TO_SIGNED,\n\n\t\tAST_TO_UNSIGNED,\n\n\t\tAST_CONCAT,\n\n\t\tAST_REPLICATE,\n\n\t\tAST_BIT_NOT,\n\n\t\tAST_BIT_AND,\n\n\t\tAST_BIT_OR,\n\n\t\tAST_BIT_XOR,\n\n\t\tAST_BIT_XNOR,\n\n\t\tAST_REDUCE_AND,\n\n\t\tAST_REDUCE_OR,\n\n\t\tAST_REDUCE_XOR,\n\n\t\tAST_REDUCE_XNOR,\n\n\t\tAST_REDUCE_BOOL,\n\n\t\tAST_SHIFT_LEFT,\n\n\t\tAST_SHIFT_RIGHT,\n\n\t\tAST_SHIFT_SLEFT,\n\n\t\tAST_SHIFT_SRIGHT,\n\n\t\tAST_LT,\n\n\t\tAST_LE,\n\n\t\tAST_EQ,\n\n\t\tAST_NE,\n\n\t\tAST_EQX,\n\n\t\tAST_NEX,\n\n\t\tAST_GE,\n\n\t\tAST_GT,\n\n\t\tAST_ADD,\n\n\t\tAST_SUB,\n\n\t\tAST_MUL,\n\n\t\tAST_DIV,\n\n\t\tAST_MOD,\n\n\t\tAST_POW,\n\n\t\tAST_POS,\n\n\t\tAST_NEG,\n\n\t\tAST_LOGIC_AND,\n\n\t\tAST_LOGIC_OR,\n\n\t\tAST_LOGIC_NOT,\n\n\t\tAST_TERNARY,\n\n\t\tAST_MEMRD,\n\n\t\tAST_MEMWR,\n\n\t\tAST_MEMINIT,\n\n\n\n\t\tAST_TCALL,\n\n\t\tAST_ASSIGN,\n\n\t\tAST_CELL,\n\n\t\tAST_PRIMITIVE,\n\n\t\tAST_CELLARRAY,\n\n\t\tAST_ALWAYS,\n\n\t\tAST_INITIAL,\n\n\t\tAST_BLOCK,\n\n\t\tAST_ASSIGN_EQ,\n\n\t\tAST_ASSIGN_LE,\n\n\t\tAST_CASE,\n\n\t\tAST_COND,\n\n\t\tAST_CONDX,\n\n\t\tAST_CONDZ,\n\n\t\tAST_DEFAULT,\n\n\t\tAST_FOR,\n\n\t\tAST_WHILE,\n\n\t\tAST_REPEAT,\n\n\n\n\t\tAST_GENVAR,\n\n\t\tAST_GENFOR,\n\n\t\tAST_GENIF,\n\n\t\tAST_GENCASE,\n\n\t\tAST_GENBLOCK,\n\n\t\tAST_TECALL,\n\n\t\t\n\n\t\tAST_POSEDGE,\n\n\t\tAST_NEGEDGE,\n\n\t\tAST_EDGE,\n\n\n\n\t\tAST_INTERFACE,\n\n\t\tAST_INTERFACEPORT,\n\n\t\tAST_INTERFACEPORTTYPE,\n\n\t\tAST_MODPORT,\n\n\t\tAST_MODPORTMEMBER,\n\n\t\tAST_PACKAGE,\n\n\n\n\t\tAST_WIRETYPE,\n\n\t\tAST_TYPEDEF\n\n\t};\n\n\n\n\tstruct AstSrcLocType {\n\n\t\tunsigned int first_line, last_line;\n\n\t\tunsigned int first_column, last_column;\n\n\t\tAstSrcLocType() : first_line(0), last_line(0), first_column(0), last_column(0) {}\n\n\t\tAstSrcLocType(int _first_line, int _first_column, int _last_line, int _last_column) : first_line(_first_line), last_line(_last_line), first_column(_first_column), last_column(_last_column) {}\n\n\t};\n\n\n\n\t// convert an node type to a string (e.g. for debug output)\n\n\tstd::string type2str(AstNodeType type);\n\n\n\n\t// The AST is built using instances of this struct\n\n\tstruct AstNode\n\n\t{\n\n\t\t// for dict<> and pool<>\n\n\t\tunsigned int hashidx_;\n\n\t\tunsigned int hash() const { return hashidx_; }\n\n\n\n\t\tint during_delay;\n\n\t\tint after_delay;\n\n\n\n\t\t// this nodes type\n\n\t\tAstNodeType type;\n\n\n\n\t\t// the list of child nodes for this node\n\n\t\tstd::vector<AstNode*> children;\n\n\n\n\t\t// the list of attributes assigned to this node\n\n\t\tstd::map<RTLIL::IdString, AstNode*> attributes;\n\n\t\tbool get_bool_attribute(RTLIL::IdString id);\n\n\n\n\t\t// node content - most of it is unused in most node types\n\n\t\tstd::string str;\n\n\t\tstd::vector<RTLIL::State> bits;\n\n\t\tbool is_input, is_output, is_reg, is_logic, is_signed, is_string, is_wand, is_wor, range_valid, range_swapped, was_checked, is_unsized, is_custom_type;\n\n\t\tint port_id, range_left, range_right;\n\n\t\tuint32_t integer;\n\n\t\tdouble realvalue;\n\n\t\t// set for IDs typed to an enumeration, not used\n\n\t\tbool is_enum;\n\n\n\n\t\t// if this is a multirange memory then this vector contains offset and length of each dimension\n\n\t\tstd::vector<int> multirange_dimensions;\n\n\n\n\t\t// this is set by simplify and used during RTLIL generation\n\n\t\tAstNode *id2ast;\n\n\n\n\t\t// this is used by simplify to detect if basic analysis has been performed already on the node\n\n\t\tbool basic_prep;\n\n\n\n\t\t// this is the original sourcecode location that resulted in this AST node\n\n\t\t// it is automatically set by the constructor using AST::current_filename and\n\n\t\t// the AST::get_line_num() callback function.\n\n\t\tstd::string filename;\n\n\t\tAstSrcLocType location;\n\n\n\n\t\t// creating and deleting nodes\n\n\t\tAstNode(AstNodeType type = AST_NONE, AstNode *child1 = NULL, AstNode *child2 = NULL, AstNode *child3 = NULL);\n\n\t\tAstNode *clone() const;\n\n\t\tvoid cloneInto(AstNode *other) const;\n\n\t\tvoid delete_children();\n\n\t\t~AstNode();\n\n\n\n\t\tenum mem2reg_flags\n\n\t\t{\n\n\t\t\t/* status flags */\n\n\t\t\tMEM2REG_FL_ALL = 0x00000001,\n\n\t\t\tMEM2REG_FL_ASYNC = 0x00000002,\n\n\t\t\tMEM2REG_FL_INIT = 0x00000004,\n\n\n\n\t\t\t/* candidate flags */\n\n\t\t\tMEM2REG_FL_FORCED = 0x00000100,\n\n\t\t\tMEM2REG_FL_SET_INIT = 0x00000200,\n\n\t\t\tMEM2REG_FL_SET_ELSE = 0x00000400,\n\n\t\t\tMEM2REG_FL_SET_ASYNC = 0x00000800,\n\n\t\t\tMEM2REG_FL_EQ2 = 0x00001000,\n\n\t\t\tMEM2REG_FL_CMPLX_LHS = 0x00002000,\n\n\t\t\tMEM2REG_FL_CONST_LHS = 0x00004000,\n\n\t\t\tMEM2REG_FL_VAR_LHS = 0x00008000,\n\n\n\n\t\t\t/* proc flags */\n\n\t\t\tMEM2REG_FL_EQ1 = 0x01000000,\n\n\t\t};\n\n\n\n\t\t// simplify() creates a simpler AST by unrolling for-loops, expanding generate blocks, etc.\n\n\t\t// it also sets the id2ast pointers so that identifier lookups are fast in genRTLIL()\n\n\t\tbool simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, int width_hint, bool sign_hint, bool in_param);\n\n\t\tAstNode *readmem(bool is_readmemh, std::string mem_filename, AstNode *memory, int start_addr, int finish_addr, bool unconditional_init);\n\n\t\tvoid expand_genblock(std::string index_var, std::string prefix, std::map<std::string, std::string> &name_map);\n\n\t\tvoid replace_ids(const std::string &prefix, const std::map<std::string, std::string> &rules);\n\n\t\tvoid mem2reg_as_needed_pass1(dict<AstNode*, pool<std::string>> &mem2reg_places,\n\n\t\t\t\tdict<AstNode*, uint32_t> &mem2reg_flags, dict<AstNode*, uint32_t> &proc_flags, uint32_t &status_flags);\n\n\t\tbool mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod, AstNode *block, AstNode *&async_block);\n\n\t\tbool mem2reg_check(pool<AstNode*> &mem2reg_set);\n\n\t\tvoid mem2reg_remove(pool<AstNode*> &mem2reg_set, vector<AstNode*> &delnodes);\n\n\t\tvoid meminfo(int &mem_width, int &mem_size, int &addr_bits);\n\n\n\n\t\t// additional functionality for evaluating constant functions\n\n\t\tstruct varinfo_t { RTLIL::Const val; int offset; bool is_signed; };\n\n\t\tbool has_const_only_constructs(bool &recommend_const_eval);\n\n\t\tvoid replace_variables(std::map<std::string, varinfo_t> &variables, AstNode *fcall);\n\n\t\tAstNode *eval_const_function(AstNode *fcall);\n\n\t\tbool is_simple_const_expr();\n\n\t\tstd::string process_format_str(const std::string &sformat, int next_arg, int stage, int width_hint, bool sign_hint);\n\n\n\n\t\t// create a human-readable text representation of the AST (for debugging)\n\n\t\tvoid dumpAst(FILE *f, std::string indent) const;\n\n\t\tvoid dumpVlog(FILE *f, std::string indent) const;\n\n\n\n\t\t// used by genRTLIL() for detecting expression width and sign\n\n\t\tvoid detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *found_real = NULL);\n\n\t\tvoid detectSignWidth(int &width_hint, bool &sign_hint, bool *found_real = NULL);\n\n\n\n\t\t// create RTLIL code for this AST node\n\n\t\t// for expressions the resulting signal vector is returned\n\n\t\t// all generated cell instances, etc. are written to the RTLIL::Module pointed to by AST_INTERNAL::current_module\n\n\t\tRTLIL::SigSpec genRTLIL(int width_hint = -1, bool sign_hint = false);\n\n\t\tRTLIL::SigSpec genWidthRTLIL(int width, const dict<RTLIL::SigBit, RTLIL::SigBit> *new_subst_ptr = NULL);\n\n\n\n\t\t// compare AST nodes\n\n\t\tbool operator==(const AstNode &other) const;\n\n\t\tbool operator!=(const AstNode &other) const;\n\n\t\tbool contains(const AstNode *other) const;\n\n\n\n\t\t// helper functions for creating AST nodes for constants\n\n\t\tstatic AstNode *mkconst_int(uint32_t v, bool is_signed, int width = 32);\n\n\t\tstatic AstNode *mkconst_bits(const std::vector<RTLIL::State> &v, bool is_signed, bool is_unsized);\n\n\t\tstatic AstNode *mkconst_bits(const std::vector<RTLIL::State> &v, bool is_signed);\n\n\t\tstatic AstNode *mkconst_str(const std::vector<RTLIL::State> &v);\n\n\t\tstatic AstNode *mkconst_str(const std::string &str);\n\n\n\n\t\t// helper function for creating sign-extended const objects\n\n\t\tRTLIL::Const bitsAsConst(int width, bool is_signed);\n\n\t\tRTLIL::Const bitsAsConst(int width = -1);\n\n\t\tRTLIL::Const bitsAsUnsizedConst(int width);\n\n\t\tRTLIL::Const asAttrConst();\n\n\t\tRTLIL::Const asParaConst();\n\n\t\tuint64_t asInt(bool is_signed);\n\n\t\tbool bits_only_01() const;\n\n\t\tbool asBool() const;\n\n\n\n\t\t// helper functions for real valued const eval\n\n\t\tint isConst() const; // return '1' for AST_CONSTANT and '2' for AST_REALVALUE\n\n\t\tdouble asReal(bool is_signed);\n\n\t\tRTLIL::Const realAsConst(int width);\n\n\n\n\t\t// helpers for enum\n\n\t\tvoid allocateDefaultEnumValues();\n\n\t};\n\n\n\n\t// process an AST tree (ast must point to an AST_DESIGN node) and generate RTLIL code\n\n\tvoid process(RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump_ast2, bool no_dump_ptr, bool dump_vlog1, bool dump_vlog2, bool dump_rtlil, bool nolatches, bool nomeminit,\n\n\t\t\tbool nomem2reg, bool mem2reg, bool noblackbox, bool lib, bool nowb, bool noopt, bool icells, bool pwires, bool nooverwrite, bool overwrite, bool defer, bool autowire);\n\n\n\n\t// parametric modules are supported directly by the AST library\n\n\t// therefore we need our own derivate of RTLIL::Module with overloaded virtual functions\n\n\tstruct AstModule : RTLIL::Module {\n\n\t\tAstNode *ast;\n\n\t\tbool nolatches, nomeminit, nomem2reg, mem2reg, noblackbox, lib, nowb, noopt, icells, pwires, autowire;\n\n\t\t~AstModule() YS_OVERRIDE;\n\n\t\tRTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, bool mayfail) YS_OVERRIDE;\n\n\t\tRTLIL::IdString derive(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, dict<RTLIL::IdString, RTLIL::Module*> interfaces, dict<RTLIL::IdString, RTLIL::IdString> modports, bool mayfail) YS_OVERRIDE;\n\n\t\tstd::string derive_common(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Const> parameters, AstNode **new_ast_out, bool quiet = false);\n\n\t\tvoid reprocess_module(RTLIL::Design *design, dict<RTLIL::IdString, RTLIL::Module *> local_interfaces) YS_OVERRIDE;\n\n\t\tRTLIL::Module *clone() const YS_OVERRIDE;\n\n\t\tvoid loadconfig() const;\n\n\t};\n\n\n\n\t// this must be set by the language frontend before parsing the sources\n\n\t// the AstNode constructor then uses current_filename and get_line_num()\n\n\t// to initialize the filename and linenum properties of new nodes\n\n\textern std::string current_filename;\n\n\textern void (*set_line_num)(int);\n\n\textern int (*get_line_num)();\n\n\n\n\t// set set_line_num and get_line_num to internal dummy functions (done by simplify() and AstModule::derive\n\n\t// to control the filename and linenum properties of new nodes not generated by a frontend parser)\n\n\tvoid use_internal_line_num();\n\n\n\n\t// call a DPI function\n\n\tAstNode *dpi_call(const std::string &rtype, const std::string &fname, const std::vector<std::string> &argtypes, const std::vector<AstNode*> &args);\n\n\n\n\t// Helper functions related to handling SystemVerilog interfaces\n\n\tstd::pair<std::string,std::string> split_modport_from_type(std::string name_type);\n\n\tAstNode * find_modport(AstNode *intf, std::string name);\n\n\tvoid explode_interface_port(AstNode *module_ast, RTLIL::Module * intfmodule, std::string intfname, AstNode *modport);\n", "file_path": "3rd/yosys/include/ast.h", "rank": 32, "score": 124732.41268810771 }, { "content": "void typeCheck(std::shared_ptr<afbd::Module> module);\n", "file_path": "include/afbdil/patternmatching.h", "rank": 33, "score": 124626.04926715035 }, { "content": "YOSYS_NAMESPACE_BEGIN\n\n\n\nnamespace RTLIL\n\n{\n\n\tenum State : unsigned char {\n\n\t\tS0 = 0,\n\n\t\tS1 = 1,\n\n\t\tSx = 2, // undefined value or conflict\n\n\t\tSz = 3, // high-impedance / not-connected\n\n\t\tSa = 4, // don't care (used only in cases)\n\n\t\tSm = 5 // marker (used internally by some passes)\n\n\t};\n\n\n\n\tenum SyncType : unsigned char {\n\n\t\tST0 = 0, // level sensitive: 0\n\n\t\tST1 = 1, // level sensitive: 1\n\n\t\tSTp = 2, // edge sensitive: posedge\n\n\t\tSTn = 3, // edge sensitive: negedge\n\n\t\tSTe = 4, // edge sensitive: both edges\n\n\t\tSTa = 5, // always active\n\n\t\tSTg = 6, // global clock\n\n\t\tSTi = 7 // init\n\n\t};\n\n\n\n\tenum ConstFlags : unsigned char {\n\n\t\tCONST_FLAG_NONE = 0,\n\n\t\tCONST_FLAG_STRING = 1,\n\n\t\tCONST_FLAG_SIGNED = 2, // only used for parameters\n\n\t\tCONST_FLAG_REAL = 4 // only used for parameters\n\n\t};\n\n\n\n\tstruct Const;\n\n\tstruct AttrObject;\n\n\tstruct Selection;\n\n\tstruct Monitor;\n\n\tstruct Design;\n\n\tstruct Module;\n\n\tstruct Wire;\n\n\tstruct Memory;\n\n\tstruct Cell;\n\n\tstruct SigChunk;\n\n\tstruct SigBit;\n\n\tstruct SigSpecIterator;\n\n\tstruct SigSpecConstIterator;\n\n\tstruct SigSpec;\n\n\tstruct CaseRule;\n\n\tstruct SwitchRule;\n\n\tstruct SyncRule;\n\n\tstruct Process;\n\n\n\n\ttypedef std::pair<SigSpec, SigSpec> SigSig;\n\n\n\n\tstruct IdString\n\n\t{\n\n\t\t#undef YOSYS_XTRACE_GET_PUT\n\n\t\t#undef YOSYS_SORT_ID_FREE_LIST\n\n\t\t#undef YOSYS_USE_STICKY_IDS\n\n\t\t#undef YOSYS_NO_IDS_REFCNT\n\n\n\n\t\t// the global id string cache\n\n\n\n\t\tstatic struct destruct_guard_t {\n\n\t\t\tbool ok; // POD, will be initialized to zero\n\n\t\t\tdestruct_guard_t() { ok = true; }\n\n\t\t\t~destruct_guard_t() { ok = false; }\n\n\t\t} destruct_guard;\n\n\n\n\t\tstatic std::vector<char*> global_id_storage_;\n\n\t\tstatic dict<char*, int, hash_cstr_ops> global_id_index_;\n\n\t#ifndef YOSYS_NO_IDS_REFCNT\n\n\t\tstatic std::vector<int> global_refcount_storage_;\n\n\t\tstatic std::vector<int> global_free_idx_list_;\n\n\t#endif\n\n\n\n\t#ifdef YOSYS_USE_STICKY_IDS\n\n\t\tstatic int last_created_idx_ptr_;\n\n\t\tstatic int last_created_idx_[8];\n\n\t#endif\n\n\n\n\t\tstatic inline void xtrace_db_dump()\n\n\t\t{\n\n\t\t#ifdef YOSYS_XTRACE_GET_PUT\n\n\t\t\tfor (int idx = 0; idx < GetSize(global_id_storage_); idx++)\n\n\t\t\t{\n\n\t\t\t\tif (global_id_storage_.at(idx) == nullptr)\n\n\t\t\t\t\tlog(\"#X# DB-DUMP index %d: FREE\\n\", idx);\n\n\t\t\t\telse\n\n\t\t\t\t\tlog(\"#X# DB-DUMP index %d: '%s' (ref %d)\\n\", idx, global_id_storage_.at(idx), global_refcount_storage_.at(idx));\n\n\t\t\t}\n\n\t\t#endif\n\n\t\t}\n\n\n\n\t\tstatic inline void checkpoint()\n\n\t\t{\n\n\t\t#ifdef YOSYS_USE_STICKY_IDS\n\n\t\t\tlast_created_idx_ptr_ = 0;\n\n\t\t\tfor (int i = 0; i < 8; i++) {\n\n\t\t\t\tif (last_created_idx_[i])\n\n\t\t\t\t\tput_reference(last_created_idx_[i]);\n\n\t\t\t\tlast_created_idx_[i] = 0;\n\n\t\t\t}\n\n\t\t#endif\n\n\t\t#ifdef YOSYS_SORT_ID_FREE_LIST\n\n\t\t\tstd::sort(global_free_idx_list_.begin(), global_free_idx_list_.end(), std::greater<int>());\n\n\t\t#endif\n\n\t\t}\n\n\n\n\t\tstatic inline int get_reference(int idx)\n\n\t\t{\n\n\t\t\tif (idx) {\n\n\t\t#ifndef YOSYS_NO_IDS_REFCNT\n\n\t\t\t\tglobal_refcount_storage_[idx]++;\n\n\t\t#endif\n\n\t\t#ifdef YOSYS_XTRACE_GET_PUT\n\n\t\t\t\tif (yosys_xtrace)\n\n\t\t\t\t\tlog(\"#X# GET-BY-INDEX '%s' (index %d, refcount %d)\\n\", global_id_storage_.at(idx), idx, global_refcount_storage_.at(idx));\n\n\t\t#endif\n\n\t\t\t}\n\n\t\t\treturn idx;\n\n\t\t}\n\n\n\n\t\tstatic int get_reference(const char *p)\n\n\t\t{\n\n\t\t\tlog_assert(destruct_guard.ok);\n\n\n\n\t\t\tif (!p[0])\n\n\t\t\t\treturn 0;\n\n\n\n\t\t\tlog_assert(p[0] == '$' || p[0] == '\\\\');\n\n\t\t\tlog_assert(p[1] != 0);\n\n\n\n\t\t\tauto it = global_id_index_.find((char*)p);\n\n\t\t\tif (it != global_id_index_.end()) {\n\n\t\t#ifndef YOSYS_NO_IDS_REFCNT\n\n\t\t\t\tglobal_refcount_storage_.at(it->second)++;\n\n\t\t#endif\n\n\t\t#ifdef YOSYS_XTRACE_GET_PUT\n\n\t\t\t\tif (yosys_xtrace)\n\n\t\t\t\t\tlog(\"#X# GET-BY-NAME '%s' (index %d, refcount %d)\\n\", global_id_storage_.at(it->second), it->second, global_refcount_storage_.at(it->second));\n\n\t\t#endif\n\n\t\t\t\treturn it->second;\n\n\t\t\t}\n\n\n\n\t\t#ifndef YOSYS_NO_IDS_REFCNT\n\n\t\t\tif (global_free_idx_list_.empty()) {\n\n\t\t\t\tif (global_id_storage_.empty()) {\n\n\t\t\t\t\tglobal_refcount_storage_.push_back(0);\n\n\t\t\t\t\tglobal_id_storage_.push_back((char*)\"\");\n\n\t\t\t\t\tglobal_id_index_[global_id_storage_.back()] = 0;\n\n\t\t\t\t}\n\n\t\t\t\tlog_assert(global_id_storage_.size() < 0x40000000);\n\n\t\t\t\tglobal_free_idx_list_.push_back(global_id_storage_.size());\n\n\t\t\t\tglobal_id_storage_.push_back(nullptr);\n\n\t\t\t\tglobal_refcount_storage_.push_back(0);\n\n\t\t\t}\n\n\n\n\t\t\tint idx = global_free_idx_list_.back();\n\n\t\t\tglobal_free_idx_list_.pop_back();\n\n\t\t\tglobal_id_storage_.at(idx) = strdup(p);\n\n\t\t\tglobal_id_index_[global_id_storage_.at(idx)] = idx;\n\n\t\t\tglobal_refcount_storage_.at(idx)++;\n\n\t\t#else\n\n\t\t\tif (global_id_storage_.empty()) {\n\n\t\t\t\tglobal_id_storage_.push_back((char*)\"\");\n\n\t\t\t\tglobal_id_index_[global_id_storage_.back()] = 0;\n\n\t\t\t}\n\n\t\t\tint idx = global_id_storage_.size();\n\n\t\t\tglobal_id_storage_.push_back(strdup(p));\n\n\t\t\tglobal_id_index_[global_id_storage_.back()] = idx;\n\n\t\t#endif\n\n\n\n\t\t\tif (yosys_xtrace) {\n\n\t\t\t\tlog(\"#X# New IdString '%s' with index %d.\\n\", p, idx);\n\n\t\t\t\tlog_backtrace(\"-X- \", yosys_xtrace-1);\n\n\t\t\t}\n\n\n\n\t\t#ifdef YOSYS_XTRACE_GET_PUT\n\n\t\t\tif (yosys_xtrace)\n\n\t\t\t\tlog(\"#X# GET-BY-NAME '%s' (index %d, refcount %d)\\n\", global_id_storage_.at(idx), idx, global_refcount_storage_.at(idx));\n\n\t\t#endif\n\n\n\n\t\t#ifdef YOSYS_USE_STICKY_IDS\n\n\t\t\t// Avoid Create->Delete->Create pattern\n\n\t\t\tif (last_created_idx_[last_created_idx_ptr_])\n\n\t\t\t\tput_reference(last_created_idx_[last_created_idx_ptr_]);\n\n\t\t\tlast_created_idx_[last_created_idx_ptr_] = idx;\n\n\t\t\tget_reference(last_created_idx_[last_created_idx_ptr_]);\n\n\t\t\tlast_created_idx_ptr_ = (last_created_idx_ptr_ + 1) & 7;\n\n\t\t#endif\n\n\n\n\t\t\treturn idx;\n\n\t\t}\n\n\n\n\t#ifndef YOSYS_NO_IDS_REFCNT\n\n\t\tstatic inline void put_reference(int idx)\n\n\t\t{\n\n\t\t\t// put_reference() may be called from destructors after the destructor of\n\n\t\t\t// global_refcount_storage_ has been run. in this case we simply do nothing.\n\n\t\t\tif (!destruct_guard.ok || !idx)\n\n\t\t\t\treturn;\n\n\n\n\t\t#ifdef YOSYS_XTRACE_GET_PUT\n\n\t\t\tif (yosys_xtrace) {\n\n\t\t\t\tlog(\"#X# PUT '%s' (index %d, refcount %d)\\n\", global_id_storage_.at(idx), idx, global_refcount_storage_.at(idx));\n\n\t\t\t}\n\n\t\t#endif\n\n\n\n\t\t\tint &refcount = global_refcount_storage_[idx];\n\n\n\n\t\t\tif (--refcount > 0)\n\n\t\t\t\treturn;\n\n\n\n\t\t\tlog_assert(refcount == 0);\n\n\n\n\t\t\tif (yosys_xtrace) {\n\n\t\t\t\tlog(\"#X# Removed IdString '%s' with index %d.\\n\", global_id_storage_.at(idx), idx);\n\n\t\t\t\tlog_backtrace(\"-X- \", yosys_xtrace-1);\n\n\t\t\t}\n\n\n\n\t\t\tglobal_id_index_.erase(global_id_storage_.at(idx));\n\n\t\t\tfree(global_id_storage_.at(idx));\n\n\t\t\tglobal_id_storage_.at(idx) = nullptr;\n\n\t\t\tglobal_free_idx_list_.push_back(idx);\n\n\t\t}\n\n\t#else\n\n\t\tstatic inline void put_reference(int) { }\n\n\t#endif\n\n\n\n\t\t// the actual IdString object is just is a single int\n\n\n\n\t\tint index_;\n\n\n\n\t\tinline IdString() : index_(0) { }\n\n\t\tinline IdString(const char *str) : index_(get_reference(str)) { }\n\n\t\tinline IdString(const IdString &str) : index_(get_reference(str.index_)) { }\n", "file_path": "3rd/yosys/include/yosys_rtlil.h", "rank": 34, "score": 120723.13157047177 }, { "content": "\t\tvoid detectSignWidth(int &width_hint, bool &sign_hint, bool *found_real = NULL);\n", "file_path": "3rd/yosys/include/ast.h", "rank": 35, "score": 116966.07574002919 }, { "content": "extern void eval_select_op(vector<RTLIL::Selection> &work, const string &op, RTLIL::Design *design);\n", "file_path": "3rd/yosys/include/register.h", "rank": 36, "score": 116964.80525650896 }, { "content": "\t\tAstNode *eval_const_function(AstNode *fcall);\n", "file_path": "3rd/yosys/include/ast.h", "rank": 37, "score": 116964.80525650896 }, { "content": "extern RTLIL::Selection eval_select_args(const vector<string> &args, RTLIL::Design *design);\n", "file_path": "3rd/yosys/include/register.h", "rank": 38, "score": 116964.80525650896 }, { "content": "\t\tbool is_simple_const_expr();\n", "file_path": "3rd/yosys/include/ast.h", "rank": 39, "score": 116913.89609344055 }, { "content": "\tclass iterator : public std::iterator<std::forward_iterator_tag, std::pair<K, T>>\n\n\t{\n\n\t\tfriend class dict;\n\n\tprotected:\n\n\t\tdict *ptr;\n\n\t\tint index;\n\n\t\titerator(dict *ptr, int index) : ptr(ptr), index(index) { }\n\n\tpublic:\n\n\t\titerator() { }\n\n\t\titerator operator++() { index--; return *this; }\n\n\t\tbool operator<(const iterator &other) const { return index > other.index; }\n\n\t\tbool operator==(const iterator &other) const { return index == other.index; }\n\n\t\tbool operator!=(const iterator &other) const { return index != other.index; }\n\n\t\tstd::pair<K, T> &operator*() { return ptr->entries[index].udata; }\n\n\t\tstd::pair<K, T> *operator->() { return &ptr->entries[index].udata; }\n\n\t\tconst std::pair<K, T> &operator*() const { return ptr->entries[index].udata; }\n\n\t\tconst std::pair<K, T> *operator->() const { return &ptr->entries[index].udata; }\n\n\t\toperator const_iterator() const { return const_iterator(ptr, index); }\n\n\t};\n\n\n", "file_path": "3rd/yosys/include/hashlib.h", "rank": 40, "score": 113924.15528256545 }, { "content": "\t\tvoid detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *found_real = NULL);\n", "file_path": "3rd/yosys/include/ast.h", "rank": 41, "score": 113444.95392681987 }, { "content": "\tclass const_iterator : public std::iterator<std::forward_iterator_tag, std::pair<K, T>>\n\n\t{\n\n\t\tfriend class dict;\n\n\tprotected:\n\n\t\tconst dict *ptr;\n\n\t\tint index;\n\n\t\tconst_iterator(const dict *ptr, int index) : ptr(ptr), index(index) { }\n\n\tpublic:\n\n\t\tconst_iterator() { }\n\n\t\tconst_iterator operator++() { index--; return *this; }\n\n\t\tbool operator<(const const_iterator &other) const { return index > other.index; }\n\n\t\tbool operator==(const const_iterator &other) const { return index == other.index; }\n\n\t\tbool operator!=(const const_iterator &other) const { return index != other.index; }\n\n\t\tconst std::pair<K, T> &operator*() const { return ptr->entries[index].udata; }\n\n\t\tconst std::pair<K, T> *operator->() const { return &ptr->entries[index].udata; }\n\n\t};\n\n\n", "file_path": "3rd/yosys/include/hashlib.h", "rank": 42, "score": 112255.60473917167 }, { "content": "\tclass iterator : public std::iterator<std::forward_iterator_tag, K>\n\n\t{\n\n\t\tfriend class pool;\n\n\tprotected:\n\n\t\tpool *ptr;\n\n\t\tint index;\n\n\t\titerator(pool *ptr, int index) : ptr(ptr), index(index) { }\n\n\tpublic:\n\n\t\titerator() { }\n\n\t\titerator operator++() { index--; return *this; }\n\n\t\tbool operator==(const iterator &other) const { return index == other.index; }\n\n\t\tbool operator!=(const iterator &other) const { return index != other.index; }\n\n\t\tK &operator*() { return ptr->entries[index].udata; }\n\n\t\tK *operator->() { return &ptr->entries[index].udata; }\n\n\t\tconst K &operator*() const { return ptr->entries[index].udata; }\n\n\t\tconst K *operator->() const { return &ptr->entries[index].udata; }\n\n\t\toperator const_iterator() const { return const_iterator(ptr, index); }\n\n\t};\n\n\n\n\tpool()\n", "file_path": "3rd/yosys/include/hashlib.h", "rank": 43, "score": 110280.51974004788 }, { "content": "\tclass const_iterator : public std::iterator<std::forward_iterator_tag, K>\n\n\t{\n\n\t\tfriend class pool;\n\n\tprotected:\n\n\t\tconst pool *ptr;\n\n\t\tint index;\n\n\t\tconst_iterator(const pool *ptr, int index) : ptr(ptr), index(index) { }\n\n\tpublic:\n\n\t\tconst_iterator() { }\n\n\t\tconst_iterator operator++() { index--; return *this; }\n\n\t\tbool operator==(const const_iterator &other) const { return index == other.index; }\n\n\t\tbool operator!=(const const_iterator &other) const { return index != other.index; }\n\n\t\tconst K &operator*() const { return ptr->entries[index].udata; }\n\n\t\tconst K *operator->() const { return &ptr->entries[index].udata; }\n\n\t};\n\n\n", "file_path": "3rd/yosys/include/hashlib.h", "rank": 44, "score": 108254.26653221584 }, { "content": "#pragma once\n\n\n\n#include <afbdil/def.h>\n\n#include <afbdil/instruction.h>\n\n#include <afbdil/var.h>\n\n#include <afbdil/module.h>\n\n\n\n#include <memory>\n\n#include <set>\n\n\n\nnamespace afbd {\n\n\n", "file_path": "include/afbdil/process.h", "rank": 45, "score": 103073.8349775987 }, { "content": "\n\n\tstd::shared_ptr<Expr> substitute_clone(std::map<std::shared_ptr<Var>, std::shared_ptr<Expr>>& substitute_map);\n\n\n\n void simplify();\n\n\n\n int bit() const;\n\n\n\n json11::Json to_json();\n\n\n\n void all_as_sens(std::shared_ptr<Module>& module, std::shared_ptr<Process>& proc);\n\n\n\n\tstd::string children_to_smv(std::string delim);\n\n\n\n std::string binary_to_smv(std::string delim);\n\n\n\n\tstd::string to_smv(bool as_bool = false);\n\n\n\n\tbool operator==(const Expr& right) const;\n\n};\n\n\n", "file_path": "include/afbdil/expr.h", "rank": 46, "score": 103046.80434779671 }, { "content": "#pragma once\n\n\n\n#include <afbdil/def.h>\n\n\n\n#include <memory>\n\n\n\nnamespace afbd {\n\n\n", "file_path": "include/afbdil/expr.h", "rank": 47, "score": 103039.80444901537 }, { "content": " EQ,\n\n NE,\n\n GT,\n\n GE,\n\n LT,\n\n LE,\n\n\n\n COND,\n\n SUBVEC,\n\n CONCAT,\n\n REDUCE_BOOL,\n\n\n\n UNKNOWN\n\n};\n\n\n", "file_path": "include/afbdil/expr.h", "rank": 48, "score": 103021.51458000821 }, { "content": "class exception : public std::exception\n\n{\n\n public:\n\n /// returns the explanatory string\n\n JSON_HEDLEY_RETURNS_NON_NULL\n\n const char* what() const noexcept override\n\n {\n\n return m.what();\n\n }\n\n\n\n /// the id of the exception\n\n const int id;\n\n\n\n protected:\n\n JSON_HEDLEY_NON_NULL(3)\n\n exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}\n\n\n\n static std::string name(const std::string& ename, int id_)\n\n {\n\n return \"[json.exception.\" + ename + \".\" + std::to_string(id_) + \"] \";\n", "file_path": "3rd/include/json/json.hpp", "rank": 49, "score": 101894.91224593663 }, { "content": "enum class value_t : std::uint8_t\n\n{\n\n null, ///< null value\n\n object, ///< object (unordered set of name/value pairs)\n\n array, ///< array (ordered collection of values)\n\n string, ///< string value\n\n boolean, ///< boolean value\n\n number_integer, ///< number value (signed integer)\n\n number_unsigned, ///< number value (unsigned integer)\n\n number_float, ///< number value (floating-point)\n\n discarded ///< discarded by the the parser callback function\n\n};\n\n\n\n/*!\n\n@brief comparison operator for JSON types\n\n\n\nReturns an ordering that is similar to Python:\n\n- order: null < boolean < number < object < array < string\n\n- furthermore, each type is not smaller than itself\n\n- discarded values are not comparable\n", "file_path": "3rd/include/json/json.hpp", "rank": 50, "score": 101894.91224593663 }, { "content": "struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<std::is_constructible<T1, Args>...> {};\n\n} // namespace detail\n\n} // namespace nlohmann\n\n\n\n// #include <nlohmann/detail/value_t.hpp>\n\n\n\n\n\n#include <array> // array\n\n#include <ciso646> // and\n\n#include <cstddef> // size_t\n\n#include <cstdint> // uint8_t\n\n#include <string> // string\n\n\n\nnamespace nlohmann\n\n{\n\nnamespace detail\n\n{\n\n///////////////////////////\n\n// JSON type enumeration //\n\n///////////////////////////\n", "file_path": "3rd/include/json/json.hpp", "rank": 51, "score": 100175.5123634206 }, { "content": "class Constant {\n\n int _bit;\n\n int _value;\n\npublic:\n\n Constant(int bit, int value);\n\n\n\n int bit() const;\n\n inline void bit(int v) { _bit = v; }\n\n int value() const;\n\n};\n\n\n\ntypedef std::initializer_list<std::shared_ptr<Expr>> exl;\n\n\n\nstd::shared_ptr<Expr> double_fold(ExprType type, std::vector<std::shared_ptr<Expr>>& operands);\n\n\n\nstd::string to_string(ExprType type);\n\n}\n", "file_path": "include/afbdil/expr.h", "rank": 52, "score": 98918.8562040442 }, { "content": "class Queue {\n\n vec<T> buf;\n\n int first;\n\n int end;\n\n\n\npublic:\n\n typedef T Key;\n\n\n\n Queue() : buf(1), first(0), end(0) {}\n\n\n\n void clear (bool dealloc = false) { buf.clear(dealloc); buf.growTo(1); first = end = 0; }\n\n int size () const { return (end >= first) ? end - first : end - first + buf.size(); }\n\n\n\n const T& operator [] (int index) const { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }\n\n T& operator [] (int index) { assert(index >= 0); assert(index < size()); return buf[(first + index) % buf.size()]; }\n\n\n\n T peek () const { assert(first != end); return buf[first]; }\n\n void pop () { assert(first != end); first++; if (first == buf.size()) first = 0; }\n\n void insert(T elem) { // INVARIANT: buf[end] is always unused\n\n buf[end++] = elem;\n", "file_path": "3rd/libs/minisat/Queue.h", "rank": 53, "score": 93012.52875437865 }, { "content": " class StringType, class BooleanType, class NumberIntegerType, \\\n", "file_path": "3rd/include/json/json.hpp", "rank": 54, "score": 92383.64567070475 }, { "content": "struct SigSet\n\n{\n\n\tstatic_assert(!std::is_same<Compare,void>::value, \"Default value for `Compare' class not found for SigSet<T>. Please specify.\");\n\n\n\n\tstruct bitDef_t : public std::pair<RTLIL::Wire*, int> {\n\n\t\tbitDef_t() : std::pair<RTLIL::Wire*, int>(NULL, 0) { }\n\n\t\tbitDef_t(const RTLIL::SigBit &bit) : std::pair<RTLIL::Wire*, int>(bit.wire, bit.offset) { }\n\n\t\tunsigned int hash() const { return first->name.hash() + second; }\n\n\t};\n\n\n\n\tdict<bitDef_t, std::set<T, Compare>> bits;\n\n\n\n\tvoid clear()\n\n\t{\n\n\t\tbits.clear();\n\n\t}\n\n\n\n\tvoid insert(RTLIL::SigSpec sig, T data)\n\n\t{\n\n\t\tfor (auto &bit : sig)\n", "file_path": "3rd/yosys/include/sigtools.h", "rank": 55, "score": 91678.88755182407 }, { "content": "enum class AssignType {\n\n\tBlocking,\n\n\tNonBlocking\n\n};\n\n\n\nstd::string instruction_type_to_str(InstructionType type);\n\nInstructionType str_to_instruction_type(std::string str);\n\n\n", "file_path": "include/afbdil/instruction.h", "rank": 56, "score": 91562.20728633343 }, { "content": "enum class InstructionType {\n\n Assign,\n\n Delay,\n\n Trigger,\n\n};\n\n\n", "file_path": "include/afbdil/instruction.h", "rank": 57, "score": 91562.20728633343 }, { "content": "class json_reverse_iterator : public std::reverse_iterator<Base>\n\n{\n\n public:\n\n using difference_type = std::ptrdiff_t;\n\n /// shortcut to the reverse iterator adapter\n\n using base_iterator = std::reverse_iterator<Base>;\n\n /// the reference type for the pointed-to element\n\n using reference = typename Base::reference;\n\n\n\n /// create reverse iterator from iterator\n\n explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept\n\n : base_iterator(it) {}\n\n\n\n /// create reverse iterator from base class\n\n explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {}\n\n\n\n /// post-increment (it++)\n\n json_reverse_iterator const operator++(int)\n\n {\n\n return static_cast<json_reverse_iterator>(base_iterator::operator++(1));\n", "file_path": "3rd/include/json/json.hpp", "rank": 58, "score": 90057.66507841679 }, { "content": " class NumberUnsignedType, class NumberFloatType, \\\n\n template<typename> class AllocatorType, \\\n\n template<typename, typename = void> class JSONSerializer>\n\n\n\n#define NLOHMANN_BASIC_JSON_TPL \\\n\n basic_json<ObjectType, ArrayType, StringType, BooleanType, \\\n\n NumberIntegerType, NumberUnsignedType, NumberFloatType, \\\n\n AllocatorType, JSONSerializer>\n\n\n\n\n\nnamespace nlohmann\n\n{\n\nnamespace detail\n\n{\n\n////////////////\n\n// exceptions //\n\n////////////////\n\n\n\n/*!\n\n@brief general exception of the @ref basic_json class\n", "file_path": "3rd/include/json/json.hpp", "rank": 59, "score": 89009.72719035934 }, { "content": " class AlwaysVoid,\n\n template <class...> class Op,\n\n class... Args>\n", "file_path": "3rd/include/json/json.hpp", "rank": 60, "score": 88420.37879388429 }, { "content": "struct is_compatible_type\n\n : is_compatible_type_impl<BasicJsonType, CompatibleType> {};\n\n\n\n// https://en.cppreference.com/w/cpp/types/conjunction\n\ntemplate<class...> struct conjunction : std::true_type { };\n\ntemplate<class B1> struct conjunction<B1> : B1 { };\n\ntemplate<class B1, class... Bn>\n", "file_path": "3rd/include/json/json.hpp", "rank": 61, "score": 88305.03119376206 }, { "content": "struct iterator_types <\n\n It,\n\n void_t<typename It::difference_type, typename It::value_type, typename It::pointer,\n\n typename It::reference, typename It::iterator_category >>\n\n{\n\n using difference_type = typename It::difference_type;\n\n using value_type = typename It::value_type;\n\n using pointer = typename It::pointer;\n\n using reference = typename It::reference;\n\n using iterator_category = typename It::iterator_category;\n\n};\n\n\n\n// This is required as some compilers implement std::iterator_traits in a way that\n\n// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.\n\ntemplate <typename T, typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 62, "score": 88305.03119376206 }, { "content": "struct iterator_types {};\n\n\n\ntemplate <typename It>\n", "file_path": "3rd/include/json/json.hpp", "rank": 63, "score": 88305.03119376206 }, { "content": "class LSet : public IntSet<Lit, MkIndexLit>{};\n\n\n\n//=================================================================================================\n\n// Lifted booleans:\n\n//\n\n// NOTE: this implementation is optimized for the case when comparisons between values are mostly\n\n// between one variable and one constant. Some care had to be taken to make sure that gcc \n\n// does enough constant propagation to produce sensible code, and this appears to be somewhat\n\n// fragile unfortunately.\n\n\n", "file_path": "3rd/libs/minisat/SolverTypes.h", "rank": 64, "score": 87203.6431966791 }, { "content": "struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>\n\n : iterator_types<T>\n\n{\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "3rd/include/json/json.hpp", "rank": 65, "score": 86915.94268814361 }, { "content": "struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>\n\n{\n\n using iterator_category = std::random_access_iterator_tag;\n\n using value_type = T;\n\n using difference_type = ptrdiff_t;\n\n using pointer = T*;\n\n using reference = T&;\n\n};\n\n} // namespace detail\n\n} // namespace nlohmann\n\n\n\n// #include <nlohmann/detail/macro_scope.hpp>\n\n\n\n// #include <nlohmann/detail/meta/cpp_future.hpp>\n\n\n\n// #include <nlohmann/detail/meta/detected.hpp>\n\n\n\n\n\n#include <type_traits>\n\n\n\n// #include <nlohmann/detail/meta/void_t.hpp>\n\n\n\n\n\n// http://en.cppreference.com/w/cpp/experimental/is_detected\n\nnamespace nlohmann\n\n{\n\nnamespace detail\n\n{\n", "file_path": "3rd/include/json/json.hpp", "rank": 66, "score": 86915.94268814361 }, { "content": " /// token types for the parser\n\n enum class token_type\n\n {\n\n uninitialized, ///< indicating the scanner is uninitialized\n\n literal_true, ///< the `true` literal\n\n literal_false, ///< the `false` literal\n\n literal_null, ///< the `null` literal\n\n value_string, ///< a string -- use get_string() for actual value\n\n value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value\n\n value_integer, ///< a signed integer -- use get_number_integer() for actual value\n\n value_float, ///< an floating point number -- use get_number_float() for actual value\n\n begin_array, ///< the character for array begin `[`\n\n begin_object, ///< the character for object begin `{`\n\n end_array, ///< the character for array end `]`\n\n end_object, ///< the character for object end `}`\n\n name_separator, ///< the name separator `:`\n\n value_separator, ///< the value separator `,`\n\n parse_error, ///< indicating a parse error\n\n end_of_input, ///< indicating the end of the input buffer\n\n literal_or_value ///< a literal or the begin of a value (only for diagnostics)\n\n };\n", "file_path": "3rd/include/json/json.hpp", "rank": 67, "score": 85277.51902910654 }, { "content": "struct is_compatible_integer_type\n\n : is_compatible_integer_type_impl<RealIntegerType,\n\n CompatibleNumberIntegerType> {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleType, typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 68, "score": 85271.63204889819 }, { "content": "struct is_constructible_object_type\n\n : is_constructible_object_type_impl<BasicJsonType,\n\n ConstructibleObjectType> {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleStringType,\n\n typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 69, "score": 85271.63204889819 }, { "content": "struct is_compatible_array_type\n\n : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};\n\n\n\ntemplate <typename BasicJsonType, typename ConstructibleArrayType, typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 70, "score": 85271.63204889819 }, { "content": "struct is_compatible_type_impl <\n\n BasicJsonType, CompatibleType,\n\n enable_if_t<is_complete_type<CompatibleType>::value >>\n\n{\n\n static constexpr bool value =\n\n has_to_json<BasicJsonType, CompatibleType>::value;\n\n};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleType>\n", "file_path": "3rd/include/json/json.hpp", "rank": 71, "score": 85271.63204889819 }, { "content": "struct is_compatible_string_type\n\n : is_compatible_string_type_impl<BasicJsonType, ConstructibleStringType> {};\n\n\n\ntemplate <typename BasicJsonType, typename ConstructibleStringType,\n\n typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 72, "score": 85271.63204889819 }, { "content": "struct is_compatible_object_type\n\n : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};\n\n\n\ntemplate <typename BasicJsonType, typename ConstructibleObjectType,\n\n typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 73, "score": 85271.63204889819 }, { "content": "struct is_constructible_array_type\n\n : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};\n\n\n\ntemplate <typename RealIntegerType, typename CompatibleNumberIntegerType,\n\n typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 74, "score": 85271.63204889819 }, { "content": "struct is_constructible_string_type\n\n : is_constructible_string_type_impl<BasicJsonType, ConstructibleStringType> {};\n\n\n\ntemplate <typename BasicJsonType, typename CompatibleArrayType, typename = void>\n", "file_path": "3rd/include/json/json.hpp", "rank": 75, "score": 85271.63204889819 }, { "content": "\t\tstd::string str;\n", "file_path": "3rd/yosys/include/ast.h", "rank": 76, "score": 84937.76237081223 }, { "content": "\t\tRTLIL::SigSpec in_a, in_b;\n", "file_path": "3rd/yosys/include/macc.h", "rank": 77, "score": 84931.99857690121 }, { "content": "\tCellTypes()\n\n\t{\n\n\t}\n\n\n\n\tCellTypes(RTLIL::Design *design)\n\n\t{\n", "file_path": "3rd/yosys/include/celltypes.h", "rank": 78, "score": 84931.99857690121 }, { "content": "#include <afbdil/expr.h>\n\n#include <afbdil/var.h>\n\n#include <iostream>\n\n#include <sstream>\n\n#include <algorithm>\n\n\n\nusing namespace std;\n\nusing namespace afbd;\n\n\n\n\n\nExpr::Expr(shared_ptr<Var> var): _type(ExprType::VAR), _var(var) {\n\n _constant = nullptr;\n\n _operands = nullptr;\n\n}\n\n\n\nExpr::Expr(shared_ptr<Constant> constant): _type(ExprType::CONSTANT), _constant(constant) {\n\n _var = nullptr;\n\n _operands = nullptr;\n\n}\n\n\n", "file_path": "src/afbdil/expr.cpp", "rank": 80, "score": 47.21986580153234 }, { "content": "#include <afbdil/process.h>\n\n\n\n#include <cstdlib>\n\n#include <cstring>\n\n#include <iostream>\n\n#include <list>\n\n#include <set>\n\n\n\nusing namespace std;\n\nusing namespace afbd;\n\n\n\nnamespace afbd {\n\n\textern std::shared_ptr<Expr> expr_true;\n\n extern std::shared_ptr<Expr> expr_int_zero;\n\n extern std::shared_ptr<Expr> expr_int_one;\n\n extern std::shared_ptr<Expr> expr_int_minus_one;\n\n extern std::shared_ptr<Expr> expr_nobit_zero;\n\n extern std::shared_ptr<Expr> expr_nobit_one;\n\n extern std::shared_ptr<Expr> expr_nobit_minus_one;\n\n}\n", "file_path": "src/afbdil/process.cpp", "rank": 81, "score": 45.300674191601274 }, { "content": " ret_map[\"operands\"] = json11::Json(operands_vec);\n\n return json11::Json(ret_map);\n\n }\n\n}\n\n\n\nvoid Expr::all_as_sens(std::shared_ptr<Module>& module, std::shared_ptr<Process>& proc)\n\n{\n\n auto begin = proc->begin();\n\n if(begin->type() != InstructionType::Trigger)\n\n {\n\n std::cout << \"shit! begin of a process is not a trigger, during all_as_sens\\n\";\n\n return;\n\n }\n\n\n\n switch(_type)\n\n {\n\n case ExprType::VAR:\n\n begin->triggers()->push_back(std::make_pair(as_var(), Edge::EDGE));\n\n return;\n\n case ExprType::CONSTANT:\n", "file_path": "src/afbdil/expr.cpp", "rank": 82, "score": 44.816696764079225 }, { "content": "#include <afbdil/instruction.h>\n\n\n\nusing namespace std;\n\nusing namespace afbd;\n\n\n\nstd::string instruction_type_to_str(InstructionType type)\n\n{\n\n\tswitch(type)\n\n\t{\n\n\tcase InstructionType::Assign:\n\n\t\treturn \"assign\";\n\n\tcase InstructionType::Delay:\n\n\t\treturn \"delay\";\n\n\tcase InstructionType::Trigger:\n\n\t\treturn \"trigger\";\n\n\t}\n\n}\n\n\n\nInstructionType str_to_instruction_type(std::string str)\n\n{\n", "file_path": "src/afbdil/instruction.cpp", "rank": 83, "score": 43.21114781406223 }, { "content": "#include <afbdil/module.h>\n\n#include <iostream>\n\n#include <sstream>\n\n#include <sys/time.h>\n\n\n\nusing namespace std;\n\nusing namespace afbd;\n\n\n\nextern std::string no_slash(std::string& str);\n\n\n\nModule::Module(std::string name) {\n\n _vars = make_shared<VarContainer>();\n\n _procs = make_shared<ProcContainer>();\n\n\n\n _name = no_slash(name);\n\n _has_error = false;\n\n}\n\n\n\nshared_ptr<VarContainer> Module::vars() const {\n\n return _vars;\n", "file_path": "src/afbdil/module.cpp", "rank": 85, "score": 41.470189549295625 }, { "content": " for(auto& child : *_operands)\n\n {\n\n int child_bit = child->bit();\n\n if(child_bit > ret)\n\n ret = child_bit;\n\n }\n\n return ret;\n\n}\n\n\n\nnamespace afbd {\n\n std::string to_string(ExprType type) {\n\n switch (type) {\n\n case ExprType::VAR:\n\n return \"var\";\n\n case ExprType::CONSTANT:\n\n return \"constant\";\n\n\n\n case ExprType::ADD:\n\n return \"add\";\n\n case ExprType::SUB:\n", "file_path": "src/afbdil/expr.cpp", "rank": 86, "score": 41.14330836663208 }, { "content": "}\n\n\n\nvoid typeCheck(std::shared_ptr<afbd::Module> module)\n\n{\n\n\tfor(auto process: *(module->procs()))\n\n\t{\n\n\t\tauto instructions = process->all_instructions();\n\n\t\tfor(auto instruction: instructions)\n\n\t\t{\n\n\t\t\tauto expr = instruction->expr();\n\n\t\t\tauto dst = instruction->dst();\n\n\t\t\tif(expr)\n\n\t\t\t{\n\n\t\t\t\tint expr_len = exprCheck(module, expr, instruction->line());\n\n\t\t\t\tif(expr_len != -1 && dst && dst->type() == ExprType::VAR)\n\n\t\t\t\t{\n\n\t\t\t\t\tint dst_len = dst->as_var()->bit();\n\n\t\t\t\t\tif(dst_len != expr_len)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tstd::string str = \"type mismatch in assign \";\n", "file_path": "src/afbdil/patternmatching.cpp", "rank": 87, "score": 39.09170072217145 }, { "content": "#include <memory>\n\n\n\n#include \"../../include/afbdil/patternmatching.h\"\n\n#include \"../../include/afbdil/expr.h\"\n\n#include \"../../include/afbdil/instruction.h\"\n\n\n\nusing namespace afbd;\n\n\n\nvoid reportDefect(std::shared_ptr<Module> module, std::string str, bool is_error, int line)\n\n{\n\n if(is_error)\n\n {\n\n std::cout << \"Error: \";\n\n module->set_error();\n\n }\n\n else\n\n std::cout << \"Warning: \";\n\n\tstd::cout << str << \" in line \" << line << \".\\n\";\n\n}\n\n\n", "file_path": "src/afbdil/patternmatching.cpp", "rank": 89, "score": 38.34594776393211 }, { "content": "\n\nstd::string Expr::binary_to_smv(std::string delim)\n\n{\n\n auto opl = get_operand(0);\n\n auto opr = get_operand(1);\n\n\n\n //std::cout << \"binary_to_smv called opl is \" << to_string(opl->type()) << \" opr is \" << to_string(opr->type()) << \"\\n\";\n\n //std::cout << to_json().dump() << \"\\n\";\n\n\n\n if(opr->type() == ExprType::CONSTANT)\n\n {\n\n while(opl->type() == ExprType::REDUCE_BOOL)\n\n opl = opl->get_operand(0);\n\n\n\n if(opl->type() >= ExprType::EQ && opr->type() <= ExprType::LE)\n\n return std::string(\"(\") + opl->to_smv() + \" \" + delim + \" \" + opr->to_smv(true) + \")\";\n\n }\n\n if(opl->type() == ExprType::CONSTANT)\n\n {\n\n while(opr->type() == ExprType::REDUCE_BOOL)\n", "file_path": "src/afbdil/expr.cpp", "rank": 90, "score": 38.22569587292211 }, { "content": " return;\n\n default:\n\n for(auto& child : *_operands)\n\n child->all_as_sens(module, proc);\n\n return;\n\n }\n\n}\n\n\n\nstd::shared_ptr<Expr> Expr::substitute_clone(std::map<std::shared_ptr<Var>, std::shared_ptr<Expr>>& substitute_map)\n\n{\n\n switch(_type)\n\n {\n\n case ExprType::CONSTANT:\n\n {\n\n auto constant = as_constant();\n\n return std::make_shared<Expr>(std::make_shared<Constant>(constant->bit(), constant->value()));\n\n }\n\n case ExprType::VAR:\n\n return substitute_map[_var];\n\n default:\n", "file_path": "src/afbdil/expr.cpp", "rank": 93, "score": 37.41974106773634 }, { "content": " llvm::Function *delayed_nonblocking_assign_update;\n\n llvm::Function *prepare_wait;\n\n llvm::Function *add_wait;\n\n llvm::Function *do_wait;\n\n\n\n llvm::Function *update;\n\n llvm::Function *mark_updated;\n\n\n\n void load_static_functions();\n\n\n\n\n\n llvm::Value *eval_expr(llvm::IRBuilder<> &builder, std::shared_ptr<afbd::Expr> expr);\n\n llvm::Function *transpile_process(std::shared_ptr<afbd::Process> proc);\n\npublic:\n\n llvm::Module* transpile(std::shared_ptr<afbd::Module> module, std::shared_ptr<std::fstream> fs);\n\n};\n", "file_path": "include/transpiler/transpiler.h", "rank": 94, "score": 36.94466638023935 }, { "content": "void clkCheck(std::shared_ptr<afbd::Module> module)\n\n{\n\n\tstd::set<std::shared_ptr<Var>> clk_vars;\n\n\n\n\tfor(auto process : (*module->procs()))\n\n\t{\n\n\t\tauto begin = process->begin();\n\n\t\tauto triggers = begin->triggers();\n\n\t\tif(triggers)\n\n\t\t{\n\n\t\t\tfor(auto trigger: *triggers)\n\n\t\t\t{\n\n\t\t\t\tif(trigger.second != Edge::EDGE)\n\n\t\t\t\t\tclk_vars.insert(trigger.first);\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\n\n\tfor(auto process : (*module->procs()))\n\n\t{\n", "file_path": "src/afbdil/patternmatching.cpp", "rank": 95, "score": 36.91181171505654 }, { "content": "\t//For trigger\n\n std::shared_ptr<TriggerContainer> _triggers;\n\n\n\npublic:\n\n\texplicit Instruction(std::shared_ptr<Process> proc);\n\n\texplicit Instruction(Process* proc);\n\n\n\n [[nodiscard]]\n\n std::shared_ptr<Expr> dst() const;\n\n void dst(const std::shared_ptr<Expr> &dst);\n\n\n\n [[nodiscard]]\n\n std::shared_ptr<Expr> expr() const;\n\n void expr(const std::shared_ptr<Expr> &expr);\n\n\n\n\t[[nodiscard]]\n\n\tAssignType assign_type() const;\n\n\tvoid assign_type(AssignType assign_type);\n\n\n\n [[nodiscard]]\n", "file_path": "include/afbdil/instruction.h", "rank": 97, "score": 36.07117724841817 }, { "content": "#include <fstream>\n\n#include <memory>\n\nusing namespace std;\n\nusing namespace afbd;\n\n\n\nUSING_YOSYS_NAMESPACE\n\n\n\ntypedef initializer_list<shared_ptr<Expr>> exl;\n\n#define lexpr(...) initializer_list<shared_ptr<Expr>> { __VA_ARGS__ }\n\n#define nexpr(...) make_shared<Expr>(__VA_ARGS__)\n\n#define nconst(...) make_shared<Constant>(__VA_ARGS__)\n\n\n\nint main(int argc, char** argv) {\n\n /*\n\n auto m2 = make_shared<afbd::Module>(\"counter\");\n\n auto a = m2->add_var(1, \"clk\");\n\n auto b = m2->add_var(1, \"rst\");\n\n auto t = m2->add_var(32, \"cnt\");\n\n auto t2 = m2->add_var(32, \"cn2\");\n\n\n", "file_path": "main.cpp", "rank": 98, "score": 35.69949226852871 }, { "content": "\n\nstd::string proc_type_to_str(ProcessType type)\n\n{\n\n\tswitch(type)\n\n\t{\n\n\tcase ProcessType::Initial:\n\n\t\treturn \"initial\";\n\n\tcase ProcessType::Always:\n\n\t\treturn \"always\";\n\n\t}\n\n}\n\n\n\nProcessType str_to_proc_type(std::string str)\n\n{\n\n\tif(str == \"initial\")\n\n\t\treturn ProcessType::Initial;\n\n\telse if(str == \"always\")\n\n\t\treturn ProcessType::Always;\n\n}\n\n\n", "file_path": "src/afbdil/process.cpp", "rank": 99, "score": 35.565097749114884 } ]
C++
Editor/HairParticleWindow.cpp
mewbak/WickedEngine
572bc7836fa14793b1c3b3b4733ddc61f1da5887
#include "stdafx.h" #include "HairParticleWindow.h" using namespace std; using namespace wiECS; using namespace wiScene; HairParticleWindow::HairParticleWindow(wiGUI* gui) : GUI(gui) { assert(GUI && "Invalid GUI!"); float screenW = (float)wiRenderer::GetDevice()->GetScreenWidth(); float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight(); hairWindow = new wiWindow(GUI, "Hair Particle System Window"); hairWindow->SetSize(XMFLOAT2(800, 600)); GUI->AddWidget(hairWindow); float x = 150; float y = 20; float step = 35; addButton = new wiButton("Add Hair Particle System"); addButton->SetPos(XMFLOAT2(x, y += step)); addButton->SetSize(XMFLOAT2(200, 30)); addButton->OnClick([&](wiEventArgs args) { Scene& scene = wiScene::GetScene(); scene.Entity_CreateHair("editorHair"); }); addButton->SetTooltip("Add new hair particle system."); hairWindow->AddWidget(addButton); meshComboBox = new wiComboBox("Mesh: "); meshComboBox->SetSize(XMFLOAT2(300, 25)); meshComboBox->SetPos(XMFLOAT2(x, y += step)); meshComboBox->SetEnabled(false); meshComboBox->OnSelect([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { if (args.iValue == 0) { hair->meshID = INVALID_ENTITY; } else { Scene& scene = wiScene::GetScene(); hair->meshID = scene.meshes.GetEntity(args.iValue - 1); } } }); meshComboBox->SetTooltip("Choose a mesh where hair will grow from..."); hairWindow->AddWidget(meshComboBox); countSlider = new wiSlider(0, 100000, 1000, 100000, "Strand Count: "); countSlider->SetSize(XMFLOAT2(360, 30)); countSlider->SetPos(XMFLOAT2(x, y += step * 2)); countSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->strandCount = (uint32_t)args.iValue; } }); countSlider->SetEnabled(false); countSlider->SetTooltip("Set hair strand count"); hairWindow->AddWidget(countSlider); lengthSlider = new wiSlider(0, 4, 1, 100000, "Particle Length: "); lengthSlider->SetSize(XMFLOAT2(360, 30)); lengthSlider->SetPos(XMFLOAT2(x, y += step)); lengthSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->length = args.fValue; } }); lengthSlider->SetEnabled(false); lengthSlider->SetTooltip("Set hair strand length"); hairWindow->AddWidget(lengthSlider); stiffnessSlider = new wiSlider(0, 20, 5, 100000, "Particle Stiffness: "); stiffnessSlider->SetSize(XMFLOAT2(360, 30)); stiffnessSlider->SetPos(XMFLOAT2(x, y += step * 2)); stiffnessSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->stiffness = args.fValue; } }); stiffnessSlider->SetEnabled(false); stiffnessSlider->SetTooltip("Set hair strand stiffness, how much it tries to get back to rest position."); hairWindow->AddWidget(stiffnessSlider); randomnessSlider = new wiSlider(0, 1, 0.2f, 100000, "Particle Randomness: "); randomnessSlider->SetSize(XMFLOAT2(360, 30)); randomnessSlider->SetPos(XMFLOAT2(x, y += step)); randomnessSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->randomness = args.fValue; } }); randomnessSlider->SetEnabled(false); randomnessSlider->SetTooltip("Set hair length randomization factor. This will affect randomness of hair lengths."); hairWindow->AddWidget(randomnessSlider); segmentcountSlider = new wiSlider(1, 10, 1, 9, "Segment Count: "); segmentcountSlider->SetSize(XMFLOAT2(360, 30)); segmentcountSlider->SetPos(XMFLOAT2(x, y += step)); segmentcountSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->segmentCount = (uint32_t)args.iValue; } }); segmentcountSlider->SetEnabled(false); segmentcountSlider->SetTooltip("Set hair strand segment count. This will affect simulation quality and performance."); hairWindow->AddWidget(segmentcountSlider); randomSeedSlider = new wiSlider(1, 12345, 1, 12344, "Random seed: "); randomSeedSlider->SetSize(XMFLOAT2(360, 30)); randomSeedSlider->SetPos(XMFLOAT2(x, y += step)); randomSeedSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->randomSeed = (uint32_t)args.iValue; } }); randomSeedSlider->SetEnabled(false); randomSeedSlider->SetTooltip("Set hair system-wide random seed value. This will affect hair patch placement randomization."); hairWindow->AddWidget(randomSeedSlider); viewDistanceSlider = new wiSlider(0, 1000, 100, 10000, "View distance: "); viewDistanceSlider->SetSize(XMFLOAT2(360, 30)); viewDistanceSlider->SetPos(XMFLOAT2(x, y += step)); viewDistanceSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->viewDistance = args.fValue; } }); viewDistanceSlider->SetEnabled(false); viewDistanceSlider->SetTooltip("Set view distance. After this, particles will be faded out."); hairWindow->AddWidget(viewDistanceSlider); hairWindow->Translate(XMFLOAT3(200, 50, 0)); hairWindow->SetVisible(false); SetEntity(entity); } HairParticleWindow::~HairParticleWindow() { hairWindow->RemoveWidgets(true); GUI->RemoveWidget(hairWindow); SAFE_DELETE(hairWindow); } void HairParticleWindow::SetEntity(Entity entity) { this->entity = entity; auto hair = GetHair(); if (hair != nullptr) { lengthSlider->SetValue(hair->length); stiffnessSlider->SetValue(hair->stiffness); randomnessSlider->SetValue(hair->randomness); countSlider->SetValue((float)hair->strandCount); segmentcountSlider->SetValue((float)hair->segmentCount); randomSeedSlider->SetValue((float)hair->randomSeed); viewDistanceSlider->SetValue(hair->viewDistance); } else { } } wiHairParticle* HairParticleWindow::GetHair() { if (entity == INVALID_ENTITY) { return nullptr; } Scene& scene = wiScene::GetScene(); wiHairParticle* hair = scene.hairs.GetComponent(entity); return hair; } void HairParticleWindow::UpdateData() { auto emitter = GetHair(); if (emitter == nullptr) { return; } Scene& scene = wiScene::GetScene(); meshComboBox->ClearItems(); meshComboBox->AddItem("NO MESH"); for (size_t i = 0; i < scene.meshes.GetCount(); ++i) { Entity entity = scene.meshes.GetEntity(i); const NameComponent& name = *scene.names.GetComponent(entity); meshComboBox->AddItem(name.name); if (emitter->meshID == entity) { meshComboBox->SetSelected((int)i + 1); } } }
#include "stdafx.h" #include "HairParticleWindow.h" using namespace std; using namespace wiECS; using namespace wiScene; HairParticleWindow::HairParticleWindow(wiGUI* gui) : GUI(gui) { assert(GUI && "Invalid GUI!"); float screenW = (float)wiRenderer::GetDevice()->GetScreenWidth(); float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight(); hairWindow = new wiWindow(GUI, "Hair Particle System Window"); hairWindow->SetSize(XMFLOAT2(800, 600)); GUI->AddWidget(hairWindow); float x = 150; float y = 20; float step = 35; addButton = new wiButton("Add Hair Particle System"); addButton->SetPos(XMFLOAT2(x, y += step)); addButton->SetSize(XMFLOAT2(200, 30));
; addButton->SetTooltip("Add new hair particle system."); hairWindow->AddWidget(addButton); meshComboBox = new wiComboBox("Mesh: "); meshComboBox->SetSize(XMFLOAT2(300, 25)); meshComboBox->SetPos(XMFLOAT2(x, y += step)); meshComboBox->SetEnabled(false); meshComboBox->OnSelect([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { if (args.iValue == 0) { hair->meshID = INVALID_ENTITY; } else { Scene& scene = wiScene::GetScene(); hair->meshID = scene.meshes.GetEntity(args.iValue - 1); } } }); meshComboBox->SetTooltip("Choose a mesh where hair will grow from..."); hairWindow->AddWidget(meshComboBox); countSlider = new wiSlider(0, 100000, 1000, 100000, "Strand Count: "); countSlider->SetSize(XMFLOAT2(360, 30)); countSlider->SetPos(XMFLOAT2(x, y += step * 2)); countSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->strandCount = (uint32_t)args.iValue; } }); countSlider->SetEnabled(false); countSlider->SetTooltip("Set hair strand count"); hairWindow->AddWidget(countSlider); lengthSlider = new wiSlider(0, 4, 1, 100000, "Particle Length: "); lengthSlider->SetSize(XMFLOAT2(360, 30)); lengthSlider->SetPos(XMFLOAT2(x, y += step)); lengthSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->length = args.fValue; } }); lengthSlider->SetEnabled(false); lengthSlider->SetTooltip("Set hair strand length"); hairWindow->AddWidget(lengthSlider); stiffnessSlider = new wiSlider(0, 20, 5, 100000, "Particle Stiffness: "); stiffnessSlider->SetSize(XMFLOAT2(360, 30)); stiffnessSlider->SetPos(XMFLOAT2(x, y += step * 2)); stiffnessSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->stiffness = args.fValue; } }); stiffnessSlider->SetEnabled(false); stiffnessSlider->SetTooltip("Set hair strand stiffness, how much it tries to get back to rest position."); hairWindow->AddWidget(stiffnessSlider); randomnessSlider = new wiSlider(0, 1, 0.2f, 100000, "Particle Randomness: "); randomnessSlider->SetSize(XMFLOAT2(360, 30)); randomnessSlider->SetPos(XMFLOAT2(x, y += step)); randomnessSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->randomness = args.fValue; } }); randomnessSlider->SetEnabled(false); randomnessSlider->SetTooltip("Set hair length randomization factor. This will affect randomness of hair lengths."); hairWindow->AddWidget(randomnessSlider); segmentcountSlider = new wiSlider(1, 10, 1, 9, "Segment Count: "); segmentcountSlider->SetSize(XMFLOAT2(360, 30)); segmentcountSlider->SetPos(XMFLOAT2(x, y += step)); segmentcountSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->segmentCount = (uint32_t)args.iValue; } }); segmentcountSlider->SetEnabled(false); segmentcountSlider->SetTooltip("Set hair strand segment count. This will affect simulation quality and performance."); hairWindow->AddWidget(segmentcountSlider); randomSeedSlider = new wiSlider(1, 12345, 1, 12344, "Random seed: "); randomSeedSlider->SetSize(XMFLOAT2(360, 30)); randomSeedSlider->SetPos(XMFLOAT2(x, y += step)); randomSeedSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->randomSeed = (uint32_t)args.iValue; } }); randomSeedSlider->SetEnabled(false); randomSeedSlider->SetTooltip("Set hair system-wide random seed value. This will affect hair patch placement randomization."); hairWindow->AddWidget(randomSeedSlider); viewDistanceSlider = new wiSlider(0, 1000, 100, 10000, "View distance: "); viewDistanceSlider->SetSize(XMFLOAT2(360, 30)); viewDistanceSlider->SetPos(XMFLOAT2(x, y += step)); viewDistanceSlider->OnSlide([&](wiEventArgs args) { auto hair = GetHair(); if (hair != nullptr) { hair->viewDistance = args.fValue; } }); viewDistanceSlider->SetEnabled(false); viewDistanceSlider->SetTooltip("Set view distance. After this, particles will be faded out."); hairWindow->AddWidget(viewDistanceSlider); hairWindow->Translate(XMFLOAT3(200, 50, 0)); hairWindow->SetVisible(false); SetEntity(entity); } HairParticleWindow::~HairParticleWindow() { hairWindow->RemoveWidgets(true); GUI->RemoveWidget(hairWindow); SAFE_DELETE(hairWindow); } void HairParticleWindow::SetEntity(Entity entity) { this->entity = entity; auto hair = GetHair(); if (hair != nullptr) { lengthSlider->SetValue(hair->length); stiffnessSlider->SetValue(hair->stiffness); randomnessSlider->SetValue(hair->randomness); countSlider->SetValue((float)hair->strandCount); segmentcountSlider->SetValue((float)hair->segmentCount); randomSeedSlider->SetValue((float)hair->randomSeed); viewDistanceSlider->SetValue(hair->viewDistance); } else { } } wiHairParticle* HairParticleWindow::GetHair() { if (entity == INVALID_ENTITY) { return nullptr; } Scene& scene = wiScene::GetScene(); wiHairParticle* hair = scene.hairs.GetComponent(entity); return hair; } void HairParticleWindow::UpdateData() { auto emitter = GetHair(); if (emitter == nullptr) { return; } Scene& scene = wiScene::GetScene(); meshComboBox->ClearItems(); meshComboBox->AddItem("NO MESH"); for (size_t i = 0; i < scene.meshes.GetCount(); ++i) { Entity entity = scene.meshes.GetEntity(i); const NameComponent& name = *scene.names.GetComponent(entity); meshComboBox->AddItem(name.name); if (emitter->meshID == entity) { meshComboBox->SetSelected((int)i + 1); } } }
addButton->OnClick([&](wiEventArgs args) { Scene& scene = wiScene::GetScene(); scene.Entity_CreateHair("editorHair"); })
call_expression
[ { "content": "class wiGUI;\n", "file_path": "Editor/HairParticleWindow.h", "rank": 0, "score": 231629.97973045165 }, { "content": "class HairParticleWindow\n\n{\n\npublic:\n\n\tHairParticleWindow(wiGUI* gui);\n\n\t~HairParticleWindow();\n\n\n\n\twiECS::Entity entity;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\tvoid UpdateData();\n\n\n\n\twiScene::wiHairParticle* GetHair();\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiWindow*\thairWindow;\n\n\n\n\twiButton* addButton;\n\n\twiComboBox*\tmeshComboBox;\n\n\twiSlider* lengthSlider;\n\n\twiSlider* stiffnessSlider;\n\n\twiSlider* randomnessSlider;\n\n\twiSlider* countSlider;\n\n\twiSlider* segmentcountSlider;\n\n\twiSlider* randomSeedSlider;\n\n\twiSlider* viewDistanceSlider;\n\n\n\n};\n\n\n", "file_path": "Editor/HairParticleWindow.h", "rank": 1, "score": 212444.14969631986 }, { "content": "class MaterialWindow;\n\n\n", "file_path": "Editor/HairParticleWindow.h", "rank": 2, "score": 187915.48251923 }, { "content": "class wiWindow;\n", "file_path": "Editor/HairParticleWindow.h", "rank": 3, "score": 187915.48251923 }, { "content": "#pragma once\n\n\n", "file_path": "Editor/HairParticleWindow.h", "rank": 4, "score": 184998.02468382282 }, { "content": "class HairParticleWindow;\n", "file_path": "Editor/Editor.h", "rank": 16, "score": 179151.22972069826 }, { "content": "class wiLabel;\n", "file_path": "Editor/HairParticleWindow.h", "rank": 17, "score": 173662.68405565852 }, { "content": "class wiSlider;\n", "file_path": "Editor/HairParticleWindow.h", "rank": 18, "score": 173662.68405565852 }, { "content": "class wiButton;\n\n\n", "file_path": "Editor/HairParticleWindow.h", "rank": 19, "score": 173662.68405565852 }, { "content": "class wiColorPicker;\n", "file_path": "Editor/HairParticleWindow.h", "rank": 20, "score": 168500.4400604978 }, { "content": "class wiCheckBox;\n", "file_path": "Editor/HairParticleWindow.h", "rank": 21, "score": 168500.4400604978 }, { "content": "class wiComboBox;\n", "file_path": "Editor/HairParticleWindow.h", "rank": 22, "score": 168500.4400604978 }, { "content": "class wiHairParticle\n\n{\n\nprivate:\n\n\tstd::unique_ptr<wiGraphics::GPUBuffer> cb;\n\n\tstd::unique_ptr<wiGraphics::GPUBuffer> particleBuffer;\n\n\tstd::unique_ptr<wiGraphics::GPUBuffer> simulationBuffer;\n\npublic:\n\n\n\n\tvoid UpdateCPU(const TransformComponent& transform, const MeshComponent& mesh, float dt);\n\n\tvoid UpdateGPU(const MeshComponent& mesh, const MaterialComponent& material, wiGraphics::CommandList cmd) const;\n\n\tvoid Draw(const CameraComponent& camera, const MaterialComponent& material, RENDERPASS renderPass, bool transparent, wiGraphics::CommandList cmd) const;\n\n\n\n\tenum FLAGS\n\n\t{\n\n\t\tEMPTY = 0,\n\n\t\tREGENERATE_FRAME = 1 << 0,\n\n\t};\n\n\tuint32_t _flags = EMPTY;\n\n\n\n\twiECS::Entity meshID = wiECS::INVALID_ENTITY;\n", "file_path": "WickedEngine/wiHairParticle.h", "rank": 23, "score": 139154.2027310102 }, { "content": "#pragma once\n\n#include \"CommonInclude.h\"\n\n#include \"wiGraphicsDevice.h\"\n\n#include \"wiEnums.h\"\n\n#include \"wiECS.h\"\n\n#include \"wiScene_Decl.h\"\n\n#include \"wiIntersect.h\"\n\n\n\n#include <memory>\n\n\n", "file_path": "WickedEngine/wiHairParticle.h", "rank": 24, "score": 119554.29850783893 }, { "content": "\n\n\tuint32_t strandCount = 0;\n\n\tuint32_t segmentCount = 1;\n\n\tuint32_t randomSeed = 1;\n\n\tfloat length = 1.0f;\n\n\tfloat stiffness = 10.0f;\n\n\tfloat randomness = 0.2f;\n\n\tfloat viewDistance = 200;\n\n\n\n\t// Non-serialized attributes:\n\n\tXMFLOAT4X4 world;\n\n\tXMFLOAT4X4 worldPrev;\n\n\tAABB aabb;\n\n\n\n\tvoid Serialize(wiArchive& archive, uint32_t seed = 0);\n\n\n\n\tstatic void LoadShaders();\n\n\tstatic void Initialize();\n\n};\n\n\n\n}\n", "file_path": "WickedEngine/wiHairParticle.h", "rank": 25, "score": 119553.06701506878 }, { "content": "class wiGUI;\n", "file_path": "Editor/LightWindow.h", "rank": 26, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/CameraWindow.h", "rank": 27, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/EmitterWindow.h", "rank": 28, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/RendererWindow.h", "rank": 29, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/OceanWindow.h", "rank": 30, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/DecalWindow.h", "rank": 31, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/ObjectWindow.h", "rank": 32, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/WeatherWindow.h", "rank": 33, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/PostprocessWindow.h", "rank": 34, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/SoundWindow.h", "rank": 35, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/MeshWindow.h", "rank": 36, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/MaterialWindow.h", "rank": 37, "score": 119404.77633694654 }, { "content": "class wiGUI;\n", "file_path": "Editor/AnimationWindow.h", "rank": 38, "score": 119404.77633694654 }, { "content": "#include \"wiHairParticle.h\"\n\n#include \"wiRenderer.h\"\n\n#include \"wiResourceManager.h\"\n\n#include \"wiMath.h\"\n\n#include \"wiIntersect.h\"\n\n#include \"wiRandom.h\"\n\n#include \"ResourceMapping.h\"\n\n#include \"wiArchive.h\"\n\n#include \"ShaderInterop.h\"\n\n#include \"wiTextureHelper.h\"\n\n#include \"wiScene.h\"\n\n#include \"ShaderInterop_HairParticle.h\"\n\n#include \"wiBackLog.h\"\n\n\n\nusing namespace std;\n\nusing namespace wiGraphics;\n\n\n\nnamespace wiScene\n\n{\n\n\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 39, "score": 115918.96405765248 }, { "content": "\n\n\tdevice->BindComputeShader(&cs_simulate, cmd);\n\n\n\n\tHairParticleCB hcb;\n\n\thcb.xWorld = world;\n\n\thcb.xColor = material.baseColor;\n\n\thcb.xHairRegenerate = (_flags & REGENERATE_FRAME) ? 1 : 0;\n\n\thcb.xLength = length;\n\n\thcb.xStiffness = stiffness;\n\n\thcb.xHairRandomness = randomness;\n\n\thcb.xHairStrandCount = strandCount;\n\n\thcb.xHairSegmentCount = std::max(segmentCount, 1u);\n\n\thcb.xHairParticleCount = hcb.xHairStrandCount * hcb.xHairSegmentCount;\n\n\thcb.xHairRandomSeed = randomSeed;\n\n\thcb.xHairViewDistance = viewDistance;\n\n\thcb.xHairBaseMeshIndexCount = (uint)mesh.indices.size();\n\n\thcb.xHairBaseMeshVertexPositionStride = sizeof(MeshComponent::Vertex_POS);\n\n\t// segmentCount will be loop in the shader, not a threadgroup so we don't need it here:\n\n\thcb.xHairNumDispatchGroups = (uint)ceilf((float)strandCount / (float)THREADCOUNT_SIMULATEHAIR);\n\n\tdevice->UpdateBuffer(cb.get(), &hcb, cmd);\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 40, "score": 115901.83683463967 }, { "content": "\n\n\t\t\tbd.Usage = USAGE_DEFAULT;\n\n\t\t\tbd.ByteWidth = sizeof(HairParticleCB);\n\n\t\t\tbd.BindFlags = BIND_CONSTANT_BUFFER;\n\n\t\t\tbd.CPUAccessFlags = 0;\n\n\t\t\tbd.MiscFlags = 0;\n\n\t\t\twiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, cb.get());\n\n\t\t}\n\n\t}\n\n\n\n}\n\nvoid wiHairParticle::UpdateGPU(const MeshComponent& mesh, const MaterialComponent& material, CommandList cmd) const\n\n{\n\n\tif (strandCount == 0 || particleBuffer == nullptr)\n\n\t{\n\n\t\treturn;\n\n\t}\n\n\n\n\tGraphicsDevice* device = wiRenderer::GetDevice();\n\n\tdevice->EventBegin(\"HairParticle - UpdateRenderData\", cmd);\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 41, "score": 115896.08290720379 }, { "content": "\t{\n\n\t\tarchive << _flags;\n\n\t\twiECS::SerializeEntity(archive, meshID, seed);\n\n\t\tarchive << strandCount;\n\n\t\tarchive << segmentCount;\n\n\t\tarchive << randomSeed;\n\n\t\tarchive << length;\n\n\t\tarchive << stiffness;\n\n\t\tarchive << randomness;\n\n\t\tarchive << viewDistance;\n\n\t}\n\n}\n\n\n\n\n\nvoid wiHairParticle::LoadShaders()\n\n{\n\n\tstd::string path = wiRenderer::GetShaderPath();\n\n\n\n\twiRenderer::LoadVertexShader(vs, \"hairparticleVS.cso\");\n\n\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 42, "score": 115895.73615551925 }, { "content": "\t\t}\n\n\t\tdevice->BindPipelineState(&PSO_wire, cmd);\n\n\t\tdevice->BindResource(VS, wiTextureHelper::getWhite(), TEXSLOT_ONDEMAND0, cmd);\n\n\t}\n\n\telse\n\n\t{\n\n\t\tdevice->BindPipelineState(&PSO[renderPass][transparent], cmd);\n\n\n\n\t\tconst GPUResource* res[] = {\n\n\t\t\tmaterial.GetBaseColorMap()\n\n\t\t};\n\n\t\tdevice->BindResources(PS, res, TEXSLOT_ONDEMAND0, arraysize(res), cmd);\n\n\t\tdevice->BindResources(VS, res, TEXSLOT_ONDEMAND0, arraysize(res), cmd);\n\n\t}\n\n\n\n\tdevice->BindConstantBuffer(VS, cb.get(), CB_GETBINDSLOT(HairParticleCB), cmd);\n\n\n\n\tdevice->BindResource(VS, particleBuffer.get(), 0, cmd);\n\n\n\n\tdevice->Draw(strandCount * 12 * std::max(segmentCount, 1u), 0, cmd);\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 43, "score": 115894.5111853809 }, { "content": "\tdevice->EventEnd(cmd);\n\n}\n\n\n\nvoid wiHairParticle::Draw(const CameraComponent& camera, const MaterialComponent& material, RENDERPASS renderPass, bool transparent, CommandList cmd) const\n\n{\n\n\tif (strandCount == 0 || cb == nullptr)\n\n\t{\n\n\t\treturn;\n\n\t}\n\n\n\n\tGraphicsDevice* device = wiRenderer::GetDevice();\n\n\tdevice->EventBegin(\"HairParticle - Draw\", cmd);\n\n\n\n\tdevice->BindStencilRef(STENCILREF_DEFAULT, cmd);\n\n\n\n\tif (wiRenderer::IsWireRender())\n\n\t{\n\n\t\tif (transparent || renderPass == RENDERPASS_DEPTHONLY)\n\n\t\t{\n\n\t\t\treturn;\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 44, "score": 115894.43957590112 }, { "content": "\tbld.IndependentBlendEnable = false;\n\n\twiRenderer::GetDevice()->CreateBlendState(&bld, &bs[1]);\n\n\n\n\tLoadShaders();\n\n\n\n\twiBackLog::post(\"wiHairParticle Initialized\");\n\n}\n\n\n\n}\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 45, "score": 115894.02306004026 }, { "content": "\t\t\tcb.reset(new GPUBuffer);\n\n\t\t\tparticleBuffer.reset(new GPUBuffer);\n\n\t\t\tsimulationBuffer.reset(new GPUBuffer);\n\n\n\n\t\t\tGPUBufferDesc bd;\n\n\t\t\tbd.Usage = USAGE_DEFAULT;\n\n\t\t\tbd.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS;\n\n\t\t\tbd.CPUAccessFlags = 0;\n\n\t\t\tbd.MiscFlags = RESOURCE_MISC_BUFFER_STRUCTURED;\n\n\n\n\t\t\tif (strandCount*segmentCount > 0)\n\n\t\t\t{\n\n\t\t\t\tbd.StructureByteStride = sizeof(Patch);\n\n\t\t\t\tbd.ByteWidth = bd.StructureByteStride * strandCount * segmentCount;\n\n\t\t\t\twiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, particleBuffer.get());\n\n\n\n\t\t\t\tbd.StructureByteStride = sizeof(PatchSimulationData);\n\n\t\t\t\tbd.ByteWidth = bd.StructureByteStride * strandCount * segmentCount;\n\n\t\t\t\twiRenderer::GetDevice()->CreateBuffer(&bd, nullptr, simulationBuffer.get());\n\n\t\t\t}\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 46, "score": 115892.91929072587 }, { "content": "\n\n\tdevice->BindConstantBuffer(CS, cb.get(), CB_GETBINDSLOT(HairParticleCB), cmd);\n\n\n\n\tGPUResource* uavs[] = {\n\n\t\tparticleBuffer.get(),\n\n\t\tsimulationBuffer.get()\n\n\t};\n\n\tdevice->BindUAVs(CS, uavs, 0, arraysize(uavs), cmd);\n\n\n\n\tGPUResource* res[] = {\n\n\t\tmesh.indexBuffer.get(),\n\n\t\tmesh.streamoutBuffer_POS != nullptr ? mesh.streamoutBuffer_POS.get() : mesh.vertexBuffer_POS.get(),\n\n\t};\n\n\tdevice->BindResources(CS, res, TEXSLOT_ONDEMAND0, arraysize(res), cmd);\n\n\n\n\tdevice->Dispatch(hcb.xHairNumDispatchGroups, 1, 1, cmd);\n\n\n\n\tdevice->UnbindUAVs(0, arraysize(uavs), cmd);\n\n\tdevice->UnbindResources(TEXSLOT_ONDEMAND0, arraysize(res), cmd);\n\n\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 47, "score": 115892.89619821782 }, { "content": "static VertexShader vs;\n\nstatic PixelShader ps_alphatestonly;\n\nstatic PixelShader ps_deferred;\n\nstatic PixelShader ps_forward;\n\nstatic PixelShader ps_forward_transparent;\n\nstatic PixelShader ps_tiledforward;\n\nstatic PixelShader ps_tiledforward_transparent;\n\nstatic PixelShader ps_simplest;\n\nstatic ComputeShader cs_simulate;\n\nstatic DepthStencilState dss_default, dss_equal, dss_rejectopaque_keeptransparent;\n\nstatic RasterizerState rs, ncrs, wirers;\n\nstatic BlendState bs[2]; \n\nstatic PipelineState PSO[RENDERPASS_COUNT][2];\n\nstatic PipelineState PSO_wire;\n\n\n\nvoid wiHairParticle::UpdateCPU(const TransformComponent& transform, const MeshComponent& mesh, float dt)\n\n{\n\n\tworld = transform.world;\n\n\n\n\tXMFLOAT3 _min = mesh.aabb.getMin();\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 48, "score": 115892.09147867565 }, { "content": "\n\n\tdevice->EventEnd(cmd);\n\n}\n\n\n\n\n\nvoid wiHairParticle::Serialize(wiArchive& archive, uint32_t seed)\n\n{\n\n\tif (archive.IsReadMode())\n\n\t{\n\n\t\tarchive >> _flags;\n\n\t\twiECS::SerializeEntity(archive, meshID, seed);\n\n\t\tarchive >> strandCount;\n\n\t\tarchive >> segmentCount;\n\n\t\tarchive >> randomSeed;\n\n\t\tarchive >> length;\n\n\t\tarchive >> stiffness;\n\n\t\tarchive >> randomness;\n\n\t\tarchive >> viewDistance;\n\n\t}\n\n\telse\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 49, "score": 115892.05982738202 }, { "content": "\n\n\n\n}\n\nvoid wiHairParticle::Initialize()\n\n{\n\n\n\n\tRasterizerStateDesc rsd;\n\n\trsd.FillMode = FILL_SOLID;\n\n\trsd.CullMode = CULL_BACK;\n\n\trsd.FrontCounterClockwise = true;\n\n\trsd.DepthBias = 0;\n\n\trsd.DepthBiasClamp = 0;\n\n\trsd.SlopeScaledDepthBias = 0;\n\n\trsd.DepthClipEnable = true;\n\n\trsd.MultisampleEnable = false;\n\n\trsd.AntialiasedLineEnable = false;\n\n\twiRenderer::GetDevice()->CreateRasterizerState(&rsd, &rs);\n\n\n\n\trsd.FillMode = FILL_SOLID;\n\n\trsd.CullMode = CULL_NONE;\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 50, "score": 115890.54598057654 }, { "content": "\tXMFLOAT3 _max = mesh.aabb.getMax();\n\n\n\n\t_max.x += length;\n\n\t_max.y += length;\n\n\t_max.z += length;\n\n\n\n\t_min.x -= length;\n\n\t_min.y -= length;\n\n\t_min.z -= length;\n\n\n\n\taabb = AABB(_min, _max);\n\n\taabb = aabb.transform(world);\n\n\n\n\tif (dt > 0)\n\n\t{\n\n\t\t_flags &= ~REGENERATE_FRAME;\n\n\t\tif (cb == nullptr || (strandCount * segmentCount) != particleBuffer->GetDesc().ByteWidth / sizeof(Patch))\n\n\t\t{\n\n\t\t\t_flags |= REGENERATE_FRAME;\n\n\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 51, "score": 115887.6209926083 }, { "content": "\n\n\t\t\t\tif (j == 1)\n\n\t\t\t\t{\n\n\t\t\t\t\tdesc.dss = &dss_rejectopaque_keeptransparent; // transparent\n\n\t\t\t\t}\n\n\n\n\t\t\t\tdevice->CreatePipelineState(&desc, &PSO[i][j]);\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\n\n\t{\n\n\t\tPipelineStateDesc desc;\n\n\t\tdesc.vs = &vs;\n\n\t\tdesc.ps = &ps_simplest;\n\n\t\tdesc.bs = &bs[0];\n\n\t\tdesc.rs = &wirers;\n\n\t\tdesc.dss = &dss_default;\n\n\t\tdevice->CreatePipelineState(&desc, &PSO_wire);\n\n\t}\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 52, "score": 115883.33383766063 }, { "content": "\trsd.FrontCounterClockwise = true;\n\n\trsd.DepthBias = 0;\n\n\trsd.DepthBiasClamp = 0;\n\n\trsd.SlopeScaledDepthBias = 0;\n\n\trsd.DepthClipEnable = true;\n\n\trsd.MultisampleEnable = false;\n\n\trsd.AntialiasedLineEnable = false;\n\n\twiRenderer::GetDevice()->CreateRasterizerState(&rsd, &ncrs);\n\n\n\n\trsd.FillMode = FILL_WIREFRAME;\n\n\trsd.CullMode = CULL_NONE;\n\n\trsd.FrontCounterClockwise = true;\n\n\trsd.DepthBias = 0;\n\n\trsd.DepthBiasClamp = 0;\n\n\trsd.SlopeScaledDepthBias = 0;\n\n\trsd.DepthClipEnable = true;\n\n\trsd.MultisampleEnable = false;\n\n\trsd.AntialiasedLineEnable = false;\n\n\twiRenderer::GetDevice()->CreateRasterizerState(&rsd, &wirers);\n\n\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 53, "score": 115883.33383766063 }, { "content": "\n\n\tDepthStencilStateDesc dsd;\n\n\tdsd.DepthEnable = true;\n\n\tdsd.DepthWriteMask = DEPTH_WRITE_MASK_ALL;\n\n\tdsd.DepthFunc = COMPARISON_GREATER;\n\n\n\n\tdsd.StencilEnable = true;\n\n\tdsd.StencilReadMask = 0xFF;\n\n\tdsd.StencilWriteMask = 0xFF;\n\n\tdsd.FrontFace.StencilFunc = COMPARISON_ALWAYS;\n\n\tdsd.FrontFace.StencilPassOp = STENCIL_OP_REPLACE;\n\n\tdsd.FrontFace.StencilFailOp = STENCIL_OP_KEEP;\n\n\tdsd.FrontFace.StencilDepthFailOp = STENCIL_OP_KEEP;\n\n\tdsd.BackFace.StencilFunc = COMPARISON_ALWAYS;\n\n\tdsd.BackFace.StencilPassOp = STENCIL_OP_REPLACE;\n\n\tdsd.BackFace.StencilFailOp = STENCIL_OP_KEEP;\n\n\tdsd.BackFace.StencilDepthFailOp = STENCIL_OP_KEEP;\n\n\twiRenderer::GetDevice()->CreateDepthStencilState(&dsd, &dss_default);\n\n\n\n\tdsd.DepthWriteMask = DEPTH_WRITE_MASK_ZERO;\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 54, "score": 115883.33383766063 }, { "content": "\twiRenderer::LoadPixelShader(ps_simplest, \"hairparticlePS_simplest.cso\");\n\n\twiRenderer::LoadPixelShader(ps_alphatestonly, \"hairparticlePS_alphatestonly.cso\");\n\n\twiRenderer::LoadPixelShader(ps_deferred, \"hairparticlePS_deferred.cso\");\n\n\twiRenderer::LoadPixelShader(ps_forward, \"hairparticlePS_forward.cso\");\n\n\twiRenderer::LoadPixelShader(ps_forward_transparent, \"hairparticlePS_forward_transparent.cso\");\n\n\twiRenderer::LoadPixelShader(ps_tiledforward, \"hairparticlePS_tiledforward.cso\");\n\n\twiRenderer::LoadPixelShader(ps_tiledforward_transparent, \"hairparticlePS_tiledforward_transparent.cso\");\n\n\n\n\twiRenderer::LoadComputeShader(cs_simulate, \"hairparticle_simulateCS.cso\");\n\n\n\n\tGraphicsDevice* device = wiRenderer::GetDevice();\n\n\n\n\tfor (int i = 0; i < RENDERPASS_COUNT; ++i)\n\n\t{\n\n\t\tif (i == RENDERPASS_DEPTHONLY || i == RENDERPASS_DEFERRED || i == RENDERPASS_FORWARD || i == RENDERPASS_TILEDFORWARD)\n\n\t\t{\n\n\t\t\tfor (int j = 0; j < 2; ++j)\n\n\t\t\t{\n\n\t\t\t\tif ((i == RENDERPASS_DEPTHONLY || i == RENDERPASS_DEFERRED) && j == 1)\n\n\t\t\t\t{\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 55, "score": 115883.33383766063 }, { "content": "\tdsd.DepthFunc = COMPARISON_EQUAL;\n\n\twiRenderer::GetDevice()->CreateDepthStencilState(&dsd, &dss_equal);\n\n\tdsd.DepthFunc = COMPARISON_GREATER;\n\n\twiRenderer::GetDevice()->CreateDepthStencilState(&dsd, &dss_rejectopaque_keeptransparent);\n\n\n\n\n\n\tBlendStateDesc bld;\n\n\tbld.RenderTarget[0].BlendEnable = false;\n\n\tbld.AlphaToCoverageEnable = false; // maybe for msaa\n\n\twiRenderer::GetDevice()->CreateBlendState(&bld, &bs[0]);\n\n\n\n\tbld.RenderTarget[0].SrcBlend = BLEND_SRC_ALPHA;\n\n\tbld.RenderTarget[0].DestBlend = BLEND_INV_SRC_ALPHA;\n\n\tbld.RenderTarget[0].BlendOp = BLEND_OP_ADD;\n\n\tbld.RenderTarget[0].SrcBlendAlpha = BLEND_ONE;\n\n\tbld.RenderTarget[0].DestBlendAlpha = BLEND_ONE;\n\n\tbld.RenderTarget[0].BlendOpAlpha = BLEND_OP_ADD;\n\n\tbld.RenderTarget[0].BlendEnable = true;\n\n\tbld.RenderTarget[0].RenderTargetWriteMask = COLOR_WRITE_ENABLE_ALL;\n\n\tbld.AlphaToCoverageEnable = false;\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 56, "score": 115883.33383766063 }, { "content": "\t\t\t\t\t\tdesc.ps = &ps_forward;\n\n\t\t\t\t\t\tdesc.dss = &dss_equal;\n\n\t\t\t\t\t}\n\n\t\t\t\t\telse\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tdesc.ps = &ps_forward_transparent;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase RENDERPASS_TILEDFORWARD:\n\n\t\t\t\t\tif (j == 0)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tdesc.ps = &ps_tiledforward;\n\n\t\t\t\t\t\tdesc.dss = &dss_equal;\n\n\t\t\t\t\t}\n\n\t\t\t\t\telse\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tdesc.ps = &ps_tiledforward_transparent;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 57, "score": 115883.33383766063 }, { "content": "\t\t\t\t\tcontinue;\n\n\t\t\t\t}\n\n\n\n\t\t\t\tPipelineStateDesc desc;\n\n\t\t\t\tdesc.vs = &vs;\n\n\t\t\t\tdesc.bs = &bs[j];\n\n\t\t\t\tdesc.rs = &ncrs;\n\n\t\t\t\tdesc.dss = &dss_default;\n\n\n\n\t\t\t\tswitch (i)\n\n\t\t\t\t{\n\n\t\t\t\tcase RENDERPASS_DEPTHONLY:\n\n\t\t\t\t\tdesc.ps = &ps_alphatestonly;\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase RENDERPASS_DEFERRED:\n\n\t\t\t\t\tdesc.ps = &ps_deferred;\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase RENDERPASS_FORWARD:\n\n\t\t\t\t\tif (j == 0)\n\n\t\t\t\t\t{\n", "file_path": "WickedEngine/wiHairParticle.cpp", "rank": 58, "score": 115883.33383766063 }, { "content": "class wiGUI;\n", "file_path": "Editor/ForceFieldWindow.h", "rank": 59, "score": 115746.64589279103 }, { "content": "class wiGUI;\n", "file_path": "Editor/EnvProbeWindow.h", "rank": 60, "score": 115746.64589279103 }, { "content": "class wiArchive;\n\n\n\nnamespace wiScene\n\n{\n\n\n", "file_path": "WickedEngine/wiHairParticle.h", "rank": 61, "score": 112438.62118971524 }, { "content": "using namespace DirectX;\n", "file_path": "WickedEngine/CommonInclude.h", "rank": 62, "score": 106196.93651265175 }, { "content": "\tclass wiHairParticle; // todo: rename\n\n}\n", "file_path": "WickedEngine/wiScene_Decl.h", "rank": 63, "score": 103232.63563804142 }, { "content": "#ifndef WI_SHADERINTEROP_HAIRPARTICLE_H\n\n#define WI_SHADERINTEROP_HAIRPARTICLE_H\n\n\n\n#include \"ShaderInterop.h\"\n\n\n\n#define THREADCOUNT_SIMULATEHAIR 256\n\n\n\nstruct Patch\n\n{\n\n\tfloat3 position;\n\n\tuint tangent_random;\n\n\tfloat3 normal; // need high precision for the simulation!\n\n\tuint binormal_length;\n\n};\n\n\n\nstruct PatchSimulationData\n\n{\n\n\tfloat3 velocity;\n\n\tuint padding;\n\n};\n\n\n\nCBUFFER(HairParticleCB, CBSLOT_OTHER_HAIRPARTICLE)\n\n{\n\n\tfloat4x4 xWorld;\n\n\tfloat4 xColor;\n\n\n\n\tuint xHairRegenerate;\n\n\tfloat xLength;\n\n\tfloat xStiffness;\n\n\tfloat xHairRandomness;\n\n\n\n\tuint xHairParticleCount;\n\n\tuint xHairStrandCount;\n\n\tuint xHairSegmentCount;\n\n\tuint xHairRandomSeed;\n\n\n\n\tfloat xHairViewDistance;\n\n\tuint xHairBaseMeshIndexCount;\n\n\tuint xHairBaseMeshVertexPositionStride;\n\n\tuint xHairNumDispatchGroups;\n\n};\n\n\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 64, "score": 100490.07220501051 }, { "content": "\tfloat3 normal; // need high precision for the simulation!\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 65, "score": 100490.07220501051 }, { "content": "\tfloat3 position;\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 66, "score": 100490.07220501051 }, { "content": "\tuint padding;\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 67, "score": 100490.07220501051 }, { "content": "\tfloat3 velocity;\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 68, "score": 100490.07220501051 }, { "content": "\tuint binormal_length;\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 69, "score": 97889.45998792688 }, { "content": "\tuint tangent_random;\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 70, "score": 97889.45998792688 }, { "content": "#ifndef WI_SHADERINTEROP_HAIRPARTICLE_H\n\n#define WI_SHADERINTEROP_HAIRPARTICLE_H\n\n\n\n#include \"ShaderInterop.h\"\n\n\n\n#define THREADCOUNT_SIMULATEHAIR 256\n\n\n\nstruct Patch\n\n{\n\n\tfloat3 position;\n\n\tuint tangent_random;\n\n\tfloat3 normal; // need high precision for the simulation!\n\n\tuint binormal_length;\n\n};\n\n\n\nstruct PatchSimulationData\n\n{\n\n\tfloat3 velocity;\n\n\tuint padding;\n\n};\n\n\n\nCBUFFER(HairParticleCB, CBSLOT_OTHER_HAIRPARTICLE)\n\n{\n\n\tfloat4x4 xWorld;\n\n\tfloat4 xColor;\n\n\n\n\tuint xHairRegenerate;\n\n\tfloat xLength;\n\n\tfloat xStiffness;\n\n\tfloat xHairRandomness;\n\n\n\n\tuint xHairParticleCount;\n\n\tuint xHairStrandCount;\n\n\tuint xHairSegmentCount;\n\n\tuint xHairRandomSeed;\n\n\n\n\tfloat xHairViewDistance;\n\n\tuint xHairBaseMeshIndexCount;\n\n\tuint xHairBaseMeshVertexPositionStride;\n\n\tuint xHairNumDispatchGroups;\n\n};\n\n\n", "file_path": "WickedEngine/ShaderInterop_HairParticle.h", "rank": 71, "score": 95420.05621012289 }, { "content": "class iter_impl : public std::iterator<std::bidirectional_iterator_tag, BasicJsonType>\n\n{\n\n /// allow basic_json to access private members\n\n friend iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;\n\n friend BasicJsonType;\n\n friend iteration_proxy<iter_impl>;\n\n\n\n using object_t = typename BasicJsonType::object_t;\n\n using array_t = typename BasicJsonType::array_t;\n\n // make sure BasicJsonType is basic_json or const basic_json\n\n static_assert(is_basic_json<typename std::remove_const<BasicJsonType>::type>::value,\n\n \"iter_impl only accepts (const) basic_json\");\n\n\n\n public:\n\n /// the type of the values when the iterator is dereferenced\n\n using value_type = typename BasicJsonType::value_type;\n\n /// a type to represent differences between iterators\n\n using difference_type = typename BasicJsonType::difference_type;\n\n /// defines a pointer to the type iterated over (value_type)\n\n using pointer = typename std::conditional<std::is_const<BasicJsonType>::value,\n", "file_path": "Editor/json.hpp", "rank": 72, "score": 87462.61827541719 }, { "content": " class NumberIntegerType = std::int64_t,\n", "file_path": "Editor/json.hpp", "rank": 73, "score": 79296.03776719881 }, { "content": " class NumberUnsignedType = std::uint64_t,\n", "file_path": "Editor/json.hpp", "rank": 74, "score": 79296.03776719881 }, { "content": "class exception : public std::exception\n\n{\n\n public:\n\n /// returns the explanatory string\n\n const char* what() const noexcept override\n\n {\n\n return m.what();\n\n }\n\n\n\n /// the id of the exception\n\n const int id;\n\n\n\n protected:\n\n exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}\n\n\n\n static std::string name(const std::string& ename, int id_)\n\n {\n\n return \"[json.exception.\" + ename + \".\" + std::to_string(id_) + \"] \";\n\n }\n\n\n", "file_path": "Editor/json.hpp", "rank": 75, "score": 77590.76226523776 }, { "content": "struct is_compatible_integer_type_impl : std::false_type {};\n\n\n\ntemplate<typename RealIntegerType, typename CompatibleNumberIntegerType>\n", "file_path": "Editor/json.hpp", "rank": 76, "score": 76314.23957686411 }, { "content": "struct is_compatible_object_type_impl : std::false_type {};\n\n\n\ntemplate<class RealType, class CompatibleObjectType>\n", "file_path": "Editor/json.hpp", "rank": 77, "score": 76314.23957686411 }, { "content": "class wiWindow;\n", "file_path": "Editor/SoundWindow.h", "rank": 78, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/DecalWindow.h", "rank": 79, "score": 73434.51489258007 }, { "content": "class DecalWindow\n\n{\n\npublic:\n\n\tDecalWindow(wiGUI* gui);\n\n\t~DecalWindow();\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiECS::Entity entity;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\twiTextInputField*\tdecalNameField;\n\n\n\n\twiWindow*\tdecalWindow;\n\n};\n\n\n", "file_path": "Editor/DecalWindow.h", "rank": 80, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/MeshWindow.h", "rank": 81, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/PostprocessWindow.h", "rank": 82, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/OceanWindow.h", "rank": 83, "score": 73434.51489258007 }, { "content": "class CameraWindow\n\n{\n\npublic:\n\n\tCameraWindow(wiGUI* gui);\n\n\t~CameraWindow();\n\n\n\n\tvoid ResetCam();\n\n\n\n\twiECS::Entity proxy = wiECS::INVALID_ENTITY;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\n\n\twiScene::TransformComponent camera_transform;\n\n\twiScene::TransformComponent camera_target;\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiWindow* cameraWindow;\n\n\twiSlider* farPlaneSlider;\n\n\twiSlider* nearPlaneSlider;\n", "file_path": "Editor/CameraWindow.h", "rank": 84, "score": 73434.51489258007 }, { "content": "class LightWindow\n\n{\n\npublic:\n\n\tLightWindow(wiGUI* gui);\n\n\t~LightWindow();\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiECS::Entity entity;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\tvoid SetLightType(wiScene::LightComponent::LightType type);\n\n\n\n\twiWindow*\tlightWindow;\n\n\twiSlider*\tenergySlider;\n\n\twiSlider*\trangeSlider;\n\n\twiSlider*\tradiusSlider;\n\n\twiSlider*\twidthSlider;\n\n\twiSlider*\theightSlider;\n\n\twiSlider*\tfovSlider;\n", "file_path": "Editor/LightWindow.h", "rank": 85, "score": 73434.51489258007 }, { "content": "class OceanWindow\n\n{\n\npublic:\n\n\tOceanWindow(wiGUI* gui);\n\n\t~OceanWindow();\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiWindow* oceanWindow;\n\n\twiCheckBox* enabledCheckBox;\n\n\twiSlider*\tpatchSizeSlider;\n\n\twiSlider*\twaveAmplitudeSlider;\n\n\twiSlider*\tchoppyScaleSlider;\n\n\twiSlider*\twindDependencySlider;\n\n\twiSlider*\ttimeScaleSlider;\n\n\twiSlider*\theightSlider;\n\n\twiSlider*\tdetailSlider;\n\n\twiSlider*\ttoleranceSlider;\n\n\twiColorPicker* colorPicker;\n\n};\n\n\n", "file_path": "Editor/OceanWindow.h", "rank": 86, "score": 73434.51489258007 }, { "content": "class SoundWindow\n\n{\n\npublic:\n\n\tSoundWindow(wiGUI* gui);\n\n\t~SoundWindow();\n\n\n\n\twiECS::Entity entity = wiECS::INVALID_ENTITY;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiWindow* soundWindow;\n\n\twiComboBox* reverbComboBox;\n\n\twiButton* addButton;\n\n\twiLabel* filenameLabel;\n\n\twiTextInputField* nameField;\n\n\twiButton* playstopButton;\n\n\twiCheckBox* loopedCheckbox;\n\n\twiSlider* volumeSlider;\n\n};\n", "file_path": "Editor/SoundWindow.h", "rank": 87, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/ObjectWindow.h", "rank": 88, "score": 73434.51489258007 }, { "content": "class MaterialWindow\n\n{\n\npublic:\n\n\tMaterialWindow(wiGUI* gui);\n\n\t~MaterialWindow();\n\n\n\n\twiECS::Entity entity;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiWindow*\tmaterialWindow;\n\n\twiTextInputField*\tmaterialNameField;\n\n\twiCheckBox* waterCheckBox;\n\n\twiCheckBox* planarReflCheckBox;\n\n\twiCheckBox* shadowCasterCheckBox;\n\n\twiCheckBox* flipNormalMapCheckBox;\n\n\twiCheckBox* useVertexColorsCheckBox;\n\n\twiCheckBox* specularGlossinessCheckBox;\n\n\twiCheckBox* occlusionPrimaryCheckBox;\n", "file_path": "Editor/MaterialWindow.h", "rank": 89, "score": 73434.51489258007 }, { "content": "class MaterialWindow;\n\n\n", "file_path": "Editor/EmitterWindow.h", "rank": 90, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/MaterialWindow.h", "rank": 91, "score": 73434.51489258007 }, { "content": "class AnimationWindow\n\n{\n\npublic:\n\n\tAnimationWindow(wiGUI* gui);\n\n\t~AnimationWindow();\n\n\n\n\twiGUI* GUI;\n\n\t\n\n\twiECS::Entity entity = wiECS::INVALID_ENTITY;\n\n\n\n\twiWindow*\tanimWindow;\n\n\twiComboBox*\tanimationsComboBox;\n\n\twiCheckBox* loopedCheckBox;\n\n\twiButton*\tplayButton;\n\n\twiButton*\tstopButton;\n\n\twiSlider*\ttimerSlider;\n\n\n\n\tvoid Update();\n\n};\n\n\n", "file_path": "Editor/AnimationWindow.h", "rank": 92, "score": 73434.51489258007 }, { "content": "class ObjectWindow\n\n{\n\npublic:\n\n\tObjectWindow(EditorComponent* editor);\n\n\t~ObjectWindow();\n\n\n\n\tEditorComponent* editor;\n\n\twiECS::Entity entity;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiWindow*\tobjectWindow;\n\n\n\n\twiLabel*\tnameLabel;\n\n\twiCheckBox* renderableCheckBox;\n\n\twiSlider*\tditherSlider;\n\n\twiSlider*\tcascadeMaskSlider;\n\n\twiColorPicker* colorPicker;\n\n\n", "file_path": "Editor/ObjectWindow.h", "rank": 93, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/EmitterWindow.h", "rank": 94, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/AnimationWindow.h", "rank": 95, "score": 73434.51489258007 }, { "content": "class MeshWindow\n\n{\n\npublic:\n\n\tMeshWindow(wiGUI* gui);\n\n\t~MeshWindow();\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiECS::Entity entity;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\twiWindow*\tmeshWindow;\n\n\twiLabel*\tmeshInfoLabel;\n\n\twiCheckBox* doubleSidedCheckBox;\n\n\twiCheckBox* softbodyCheckBox;\n\n\twiSlider*\tmassSlider;\n\n\twiSlider*\tfrictionSlider;\n\n\twiButton*\timpostorCreateButton;\n\n\twiSlider*\timpostorDistanceSlider;\n\n\twiSlider*\ttessellationFactorSlider;\n\n\twiButton*\tflipCullingButton;\n\n\twiButton*\tflipNormalsButton;\n\n\twiButton*\tcomputeNormalsSmoothButton;\n\n\twiButton*\tcomputeNormalsHardButton;\n\n\twiButton*\trecenterButton;\n\n\twiButton*\trecenterToBottomButton;\n\n};\n\n\n", "file_path": "Editor/MeshWindow.h", "rank": 96, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/CameraWindow.h", "rank": 97, "score": 73434.51489258007 }, { "content": "class EmitterWindow\n\n{\n\npublic:\n\n\tEmitterWindow(wiGUI* gui);\n\n\t~EmitterWindow();\n\n\n\n\twiECS::Entity entity;\n\n\tvoid SetEntity(wiECS::Entity entity);\n\n\n\n\tvoid UpdateData();\n\n\n\n\twiScene::wiEmittedParticle* GetEmitter();\n\n\n\n\twiGUI* GUI;\n\n\n\n\twiWindow*\temitterWindow;\n\n\n\n\twiTextInputField*\temitterNameField;\n\n\twiButton* addButton;\n\n\twiButton* restartButton;\n", "file_path": "Editor/EmitterWindow.h", "rank": 98, "score": 73434.51489258007 }, { "content": "class wiWindow;\n", "file_path": "Editor/LightWindow.h", "rank": 99, "score": 73434.51489258007 } ]
C++
libmarch/include/march/python/wrapper_core.hpp
j8xixo12/solvcon
a8bf3a54d4b1ed91d292e0cdbcb6f2710d33d99a
#pragma once #include <pybind11/pybind11.h> #include <pybind11/stl.h> #include <utility> #include <memory> #include <vector> #include <algorithm> #include <cstring> #include "march.hpp" #include "march/python/WrapBase.hpp" namespace march { namespace python { class MARCH_PYTHON_WRAPPER_VISIBILITY WrapBuffer : public WrapBase< WrapBuffer, Buffer, std::shared_ptr<Buffer> > { friend base_type; WrapBuffer(pybind11::module & mod, const char * pyname, const char * clsdoc) : base_type(mod, pyname, clsdoc) { } }; class MARCH_PYTHON_WRAPPER_VISIBILITY WrapLookupTableCore : public WrapBase< WrapLookupTableCore, LookupTableCore > { friend base_type; WrapLookupTableCore(pybind11::module & mod, const char * pyname, const char * clsdoc) : base_type(mod, pyname, clsdoc) { namespace py = pybind11; (*this) .init() .def_property_readonly("nghost", &LookupTableCore::nghost) .def_property_readonly("nbody", &LookupTableCore::nbody) .def_property_readonly("ncolumn", &LookupTableCore::ncolumn) .array_readwrite() .array_readonly() .pickle() .address() .def("__getattr__", [](LookupTableCore & tbl, py::object key) { return py::object(Table(tbl).full().attr(key)); }) .def_property_readonly("_nda", [](LookupTableCore & tbl) { return Table(tbl).full(); }) ; } wrapper_type & init() { namespace py = pybind11; return def(py::init([](py::args args, py::kwargs kwargs) { std::vector<index_type> dims(args.size()-1); index_type nghost = args[0].cast<index_type>(); index_type nbody = args[1].cast<index_type>(); dims[0] = nghost + nbody; for (size_t it=1; it<dims.size(); ++it) { dims[it] = args[it+1].cast<index_type>(); } PyArray_Descr * descr = nullptr; if (kwargs && kwargs.contains("dtype")) { PyArray_DescrConverter(py::object(kwargs["dtype"]).ptr(), &descr); } if (nullptr == descr) { descr = PyArray_DescrFromType(NPY_INT); } DataTypeId dtid = static_cast<DataTypeId>(descr->type_num); Py_DECREF(descr); LookupTableCore table(nghost, nbody, dims, dtid); std::string creation("empty"); if (kwargs && kwargs.contains("creation")) { creation = kwargs["creation"].cast<std::string>(); } if ("zeros" == creation) { memset(table.buffer()->template data<char>(), 0, table.buffer()->nbyte()); } else if ("empty" == creation) { } else { throw py::value_error("invalid creation type"); } return table; })); } wrapper_type & array_readwrite() { namespace py = pybind11; return def_property( "F", [](LookupTableCore & tbl) { return Table(tbl).full(); }, [](LookupTableCore & tbl, py::array src) { Table::CopyInto(Table(tbl).full(), src); }, "Full array.") .def_property( "G", [](LookupTableCore & tbl) { return Table(tbl).ghost(); }, [](LookupTableCore & tbl, py::array src) { if (tbl.nghost()) { Table::CopyInto(Table(tbl).ghost(), src); } else { throw py::index_error("ghost is zero"); } }, "Ghost-part array.") .def_property( "B", [](LookupTableCore & tbl) { return Table(tbl).body(); }, [](LookupTableCore & tbl, py::array src) { Table::CopyInto(Table(tbl).body(), src); }, "Body-part array.") ; } wrapper_type & array_readonly() { return def_property_readonly( "_ghostpart", [](LookupTableCore & tbl) { return Table(tbl).ghost(); }, "Ghost-part array without setter.") .def_property_readonly( "_bodypart", [](LookupTableCore & tbl) { return Table(tbl).body(); }, "Body-part array without setter.") ; } wrapper_type & pickle() { namespace py = pybind11; return def(py::pickle( [](LookupTableCore & tbl){ return py::make_tuple(tbl.nghost(), tbl.nbody(), tbl.dims(), (long)tbl.datatypeid(), Table(tbl).full()); }, [](py::tuple tpl){ if (tpl.size() != 5) { throw std::runtime_error("Invalid state for Table (LookupTableCore)!"); } index_type nghost = tpl[0].cast<index_type>(); index_type nbody = tpl[1].cast<index_type>(); std::vector<index_type> dims = tpl[2].cast<std::vector<index_type>>(); DataTypeId datatypeid = static_cast<DataTypeId>(tpl[3].cast<long>()); py::array src = tpl[4].cast<py::array>(); LookupTableCore tbl(nghost, nbody, dims, datatypeid); Table::CopyInto(Table(tbl).full(), src); return tbl; } )); } wrapper_type & address() { return def_property_readonly( "offset", [](LookupTableCore & tbl) { return tbl.nghost() * tbl.ncolumn(); }, "Element offset from the head of the ndarray to where the body starts.") .def_property_readonly( "_ghostaddr", [](LookupTableCore & tbl) { return (Py_intptr_t) Table::BYTES(Table(tbl).full()); }) .def_property_readonly( "_bodyaddr", [](LookupTableCore & tbl) { return (Py_intptr_t) Table::BYTES(Table(tbl).body()); }) ; } }; template< size_t NDIM > class MARCH_PYTHON_WRAPPER_VISIBILITY WrapVector : public WrapBase< WrapVector<NDIM>, Vector<NDIM> > { using base_type = WrapBase< WrapVector<NDIM>, Vector<NDIM> >; using wrapper_type = typename base_type::wrapper_type; using wrapped_type = typename base_type::wrapped_type; friend base_type; WrapVector(pybind11::module & mod, const char * pyname, const char * clsdoc) : base_type(mod, pyname, clsdoc) { namespace py = pybind11; wrapped_type dummy; #define MARCH_PYBIND_VECTOR_SCALAR_OP(PYNAME, CXXOP) \ .def("__i" #PYNAME "__", [](wrapped_type & self, real_type v) { self CXXOP v; return self; }) \ .def("__" #PYNAME "__", [](wrapped_type & self, real_type v) { auto ret(self); ret CXXOP v; return ret; }) #define MARCH_PYBIND_VECTOR_VECTOR_OP(PYNAME, CXXOP) \ .def("__i" #PYNAME "__", [](wrapped_type & self, wrapped_type const & v) { self CXXOP v; return self; }) \ .def("__" #PYNAME "__", [](wrapped_type & self, wrapped_type const & v) { auto ret(self); ret CXXOP v; return ret; }) (*this) .def(py::init([]() { return wrapped_type(); })) .def(py::init([](wrapped_type & other) { return wrapped_type(other); })) .add_element_init(dummy) .def("repr", &wrapped_type::repr, py::arg("indent")=0, py::arg("precision")=0) .def("__repr__", [](wrapped_type & self){ return self.repr(); }) .def("__eq__", &wrapped_type::operator==) .def( "__hash__", [](wrapped_type const & self) { py::list tmp; for (size_t it=0; it<self.size(); ++it) { tmp.append(self[it]); } return py::hash(tmp); } ) .def("is_close_to", &wrapped_type::is_close_to) .def("__len__", &wrapped_type::size) .def( "__getitem__", [](wrapped_type & self, index_type i) { return self.at(i); }, py::return_value_policy::copy ) .def( "__setitem__", [](wrapped_type & self, index_type i, real_type v) { self.at(i) = v; } ) MARCH_PYBIND_VECTOR_VECTOR_OP(add, +=) MARCH_PYBIND_VECTOR_VECTOR_OP(sub, -=) MARCH_PYBIND_VECTOR_SCALAR_OP(add, +=) MARCH_PYBIND_VECTOR_SCALAR_OP(sub, -=) MARCH_PYBIND_VECTOR_SCALAR_OP(mul, *=) MARCH_PYBIND_VECTOR_SCALAR_OP(div, /=) MARCH_PYBIND_VECTOR_SCALAR_OP(truediv, /=) ; #undef MARCH_PYBIND_VECTOR_SCALAR_OP #undef MARCH_PYBIND_VECTOR_VECTOR_OP } wrapper_type & add_element_init(Vector<3> const &) { namespace py = pybind11; (*this) .def(py::init([](real_type v0, real_type v1, real_type v2) { return wrapped_type(v0, v1, v2); })) ; return *this; } wrapper_type & add_element_init(Vector<2> const &) { namespace py = pybind11; (*this) .def(py::init([](real_type v0, real_type v1) { return wrapped_type(v0, v1); })) ; return *this; } }; } }
#pragma once #include <pybind11/pybind11.h> #include <pybind11/stl.h> #include <utility> #include <memory> #include <vector> #include <algorithm> #include <cstring> #include "march.hpp" #include "march/python/WrapBase.hpp" namespace march { namespace python { class MARCH_PYTHON_WRAPPER_VISIBILITY WrapBuffer : public WrapBase< WrapBuffer, Buffer, std::shared_ptr<Buffer> > { friend base_type; WrapBuffer(pybind11::module & mod, const char * pyname, const char * clsdoc) : base_type(mod, pyname, clsdoc) { } }; class MARCH_PYTHON_WRAPPER_VISIBILITY WrapLookupTableCore : public WrapBase< WrapLookupTableCore, LookupTableCore > { friend base_type; WrapLookupTableCore(pybind11::module & mod, const char * pyname, const char * clsdoc) : base_type(mod, pyname, clsdoc) { namespace py = pybind11; (*this) .init() .def_property_readonly("nghost", &LookupTableCore::nghost) .def_property_readonly("nbody", &LookupTableCore::nbody) .def_property_readonly("ncolumn", &LookupTableCore::ncolumn) .array_readwrite() .array_readonly() .pickle() .address() .def("__getattr__", [](LookupTableCore & tbl, py::object key) { return py::object(Table(tbl).full().attr(key)); }) .def_property_readonly("_nda", [](LookupTableCore & tbl) { return Table(tbl).full(); }) ; } wrapper_type & init() { namespace py = pybind11; return def(py::init([](py::args args, py::kwargs kwargs) { std::vector<index_type> dims(args.size()-1); index_type nghost = args[0].cast<index_type>(); index_type nbody = args[1].cast<index_type>(); dims[0] = nghost + nbody; for (size_t it=1; it<dims.size(); ++it) { dims[it] = args[it+1].cast<index_type>(); } PyArray_Descr * descr = nullptr; if (kwargs && kwargs.contains("dtype")) { PyArray_DescrConverter(py::object(kwargs["dtype"]).ptr(), &descr); } if (nullptr == descr) { descr = PyArray_DescrFromType(NPY_INT); } DataTypeId dtid = static_cast<DataTypeId>(descr->type_num); Py_DECREF(descr); LookupTableCore table(nghost, nbody, dims, dtid); std::string creation("empty"); if (kwargs && kwargs.contains("creation")) { creation = kwargs["creation"].cast<std::string>(); } if ("zeros" == creation) { memset(table.buffer()->template data<char>(), 0, table.buffer()->nbyte()); } else if ("empty" == creation) { } else { throw py::value_error("invalid creation type"); } return table; })); } wrapper_type & array_readwrite() { namespace py = pybind11; return def_property( "F", [](LookupTableCore & tbl) { return Table(tbl).full(); }, [](LookupTableCore & tbl, py::array src) { Table::CopyInto(Table(tbl).full(), src); }, "Full array.") .def_property( "G", [](LookupTableCore & tbl) { return Table(tbl).ghost(); }, [](LookupTableCore & tbl, py::array src) {
}, "Ghost-part array.") .def_property( "B", [](LookupTableCore & tbl) { return Table(tbl).body(); }, [](LookupTableCore & tbl, py::array src) { Table::CopyInto(Table(tbl).body(), src); }, "Body-part array.") ; } wrapper_type & array_readonly() { return def_property_readonly( "_ghostpart", [](LookupTableCore & tbl) { return Table(tbl).ghost(); }, "Ghost-part array without setter.") .def_property_readonly( "_bodypart", [](LookupTableCore & tbl) { return Table(tbl).body(); }, "Body-part array without setter.") ; } wrapper_type & pickle() { namespace py = pybind11; return def(py::pickle( [](LookupTableCore & tbl){ return py::make_tuple(tbl.nghost(), tbl.nbody(), tbl.dims(), (long)tbl.datatypeid(), Table(tbl).full()); }, [](py::tuple tpl){ if (tpl.size() != 5) { throw std::runtime_error("Invalid state for Table (LookupTableCore)!"); } index_type nghost = tpl[0].cast<index_type>(); index_type nbody = tpl[1].cast<index_type>(); std::vector<index_type> dims = tpl[2].cast<std::vector<index_type>>(); DataTypeId datatypeid = static_cast<DataTypeId>(tpl[3].cast<long>()); py::array src = tpl[4].cast<py::array>(); LookupTableCore tbl(nghost, nbody, dims, datatypeid); Table::CopyInto(Table(tbl).full(), src); return tbl; } )); } wrapper_type & address() { return def_property_readonly( "offset", [](LookupTableCore & tbl) { return tbl.nghost() * tbl.ncolumn(); }, "Element offset from the head of the ndarray to where the body starts.") .def_property_readonly( "_ghostaddr", [](LookupTableCore & tbl) { return (Py_intptr_t) Table::BYTES(Table(tbl).full()); }) .def_property_readonly( "_bodyaddr", [](LookupTableCore & tbl) { return (Py_intptr_t) Table::BYTES(Table(tbl).body()); }) ; } }; template< size_t NDIM > class MARCH_PYTHON_WRAPPER_VISIBILITY WrapVector : public WrapBase< WrapVector<NDIM>, Vector<NDIM> > { using base_type = WrapBase< WrapVector<NDIM>, Vector<NDIM> >; using wrapper_type = typename base_type::wrapper_type; using wrapped_type = typename base_type::wrapped_type; friend base_type; WrapVector(pybind11::module & mod, const char * pyname, const char * clsdoc) : base_type(mod, pyname, clsdoc) { namespace py = pybind11; wrapped_type dummy; #define MARCH_PYBIND_VECTOR_SCALAR_OP(PYNAME, CXXOP) \ .def("__i" #PYNAME "__", [](wrapped_type & self, real_type v) { self CXXOP v; return self; }) \ .def("__" #PYNAME "__", [](wrapped_type & self, real_type v) { auto ret(self); ret CXXOP v; return ret; }) #define MARCH_PYBIND_VECTOR_VECTOR_OP(PYNAME, CXXOP) \ .def("__i" #PYNAME "__", [](wrapped_type & self, wrapped_type const & v) { self CXXOP v; return self; }) \ .def("__" #PYNAME "__", [](wrapped_type & self, wrapped_type const & v) { auto ret(self); ret CXXOP v; return ret; }) (*this) .def(py::init([]() { return wrapped_type(); })) .def(py::init([](wrapped_type & other) { return wrapped_type(other); })) .add_element_init(dummy) .def("repr", &wrapped_type::repr, py::arg("indent")=0, py::arg("precision")=0) .def("__repr__", [](wrapped_type & self){ return self.repr(); }) .def("__eq__", &wrapped_type::operator==) .def( "__hash__", [](wrapped_type const & self) { py::list tmp; for (size_t it=0; it<self.size(); ++it) { tmp.append(self[it]); } return py::hash(tmp); } ) .def("is_close_to", &wrapped_type::is_close_to) .def("__len__", &wrapped_type::size) .def( "__getitem__", [](wrapped_type & self, index_type i) { return self.at(i); }, py::return_value_policy::copy ) .def( "__setitem__", [](wrapped_type & self, index_type i, real_type v) { self.at(i) = v; } ) MARCH_PYBIND_VECTOR_VECTOR_OP(add, +=) MARCH_PYBIND_VECTOR_VECTOR_OP(sub, -=) MARCH_PYBIND_VECTOR_SCALAR_OP(add, +=) MARCH_PYBIND_VECTOR_SCALAR_OP(sub, -=) MARCH_PYBIND_VECTOR_SCALAR_OP(mul, *=) MARCH_PYBIND_VECTOR_SCALAR_OP(div, /=) MARCH_PYBIND_VECTOR_SCALAR_OP(truediv, /=) ; #undef MARCH_PYBIND_VECTOR_SCALAR_OP #undef MARCH_PYBIND_VECTOR_VECTOR_OP } wrapper_type & add_element_init(Vector<3> const &) { namespace py = pybind11; (*this) .def(py::init([](real_type v0, real_type v1, real_type v2) { return wrapped_type(v0, v1, v2); })) ; return *this; } wrapper_type & add_element_init(Vector<2> const &) { namespace py = pybind11; (*this) .def(py::init([](real_type v0, real_type v1) { return wrapped_type(v0, v1); })) ; return *this; } }; } }
if (tbl.nghost()) { Table::CopyInto(Table(tbl).ghost(), src); } else { throw py::index_error("ghost is zero"); }
if_condition
[ { "content": "class LookupTable<ElemType, 0>: public LookupTableCore\n\n{\n\n\n\npublic:\n\n\n\n using elem_type = ElemType;\n\n\n\n typedef elem_type (&row_type);\n\n typedef const elem_type (&const_row_type);\n\n\n\n LookupTable() {}\n\n\n\n LookupTable(index_type nghost, index_type nbody)\n\n : LookupTableCore(nghost, nbody, std::vector<index_type>({nghost+nbody}), type_to<ElemType>::id)\n\n {}\n\n\n\n row_type operator[](index_type loc) {\n\n return *reinterpret_cast<elem_type *>(row(loc));\n\n }\n\n\n", "file_path": "libmarch/include/march/core/LookupTable.hpp", "rank": 0, "score": 350371.82836060657 }, { "content": "class Buffer: public std::enable_shared_from_this<Buffer> {\n\n\n\nprivate:\n\n\n\n size_t m_length = 0;\n\n char * m_data = nullptr;\n\n\n\n struct ctor_passkey {};\n\n\n\npublic:\n\n\n\n Buffer(const ctor_passkey &) { }\n\n\n\n static std::shared_ptr<Buffer> construct() {\n\n return std::make_shared<Buffer>(ctor_passkey());\n\n }\n\n\n\n /**\n\n * \\param[in] length Memory buffer length.\n\n */\n", "file_path": "libmarch/include/march/core/Buffer.hpp", "rank": 1, "score": 335039.3033220356 }, { "content": "class LookupTable: public LookupTableCore\n\n{\n\n\n\npublic:\n\n\n\n using elem_type = ElemType;\n\n\n\n typedef elem_type (&row_type)[NCOLUMN];\n\n typedef const elem_type (&const_row_type)[NCOLUMN];\n\n\n\n LookupTable() {}\n\n\n\n LookupTable(index_type nghost, index_type nbody)\n\n : LookupTableCore(nghost, nbody, std::vector<index_type>({nghost+nbody, NCOLUMN}), type_to<ElemType>::id)\n\n {}\n\n\n\n row_type operator[](index_type loc) {\n\n return *reinterpret_cast<elem_type(*)[NCOLUMN]>(row(loc));\n\n }\n\n\n", "file_path": "libmarch/include/march/core/LookupTable.hpp", "rank": 2, "score": 304842.5503635246 }, { "content": "class Order1Hand : public HandCRTP< Order1Hand<NDIM>, HandTraits<SolutionOrder1Table<real_type, NDIM>, Vector<NDIM>> >\n\n{\n\npublic:\n\n using base_type = HandCRTP< Order1Hand<NDIM>, HandTraits<SolutionOrder1Table<real_type, NDIM>, Vector<NDIM>> >;\n\n using base_type::base_type;\n\n using trait_type = HandTraits<SolutionOrder1Table<real_type, NDIM>, Vector<NDIM>>;\n\n using vector_type = Vector<NDIM>;\n\n using matrix_type = Matrix<NDIM>;\n\n Order1Hand & operator=(vector_type const & value) {\n\n for (index_type it=0; it<trait_type::neq; ++it) { (**this)[it] = value; }\n\n return *this;\n\n }\n\n Order1Hand & operator=(real_type value) {\n\n for (index_type it=0; it<trait_type::neq; ++it) { (**this)[it] = value; }\n\n return *this;\n\n }\n\n vector_type & density() { return (**this)[0]; }\n\n vector_type const & density() const { return (**this)[0]; }\n\n matrix_type & momentum() { return *reinterpret_cast<matrix_type *>(&(**this)[1]); }\n\n matrix_type const & momentum() const { return *reinterpret_cast<matrix_type const *>(&(**this)[1]); }\n\n vector_type & energy() { return (**this)[NDIM+1]; }\n\n vector_type const & energy() const { return (**this)[NDIM+1]; }\n\n}; /* end class Order1Hand */\n\n\n\n/**\n\n * Solution arrays.\n\n */\n\ntemplate< size_t NDIM >\n", "file_path": "libmarch/include/march/gas/Solution.hpp", "rank": 3, "score": 295000.73254999385 }, { "content": "class Table {\n\n\n\nprivate:\n\n\n\n enum array_flavor { FULL = 0, GHOST = 1, BODY = 2 };\n\n\n\npublic:\n\n\n\n Table(LookupTableCore & table) : m_table(table) {}\n\n\n\n Table(Table const & ) = delete;\n\n Table(Table &&) = delete;\n\n Table & operator=(Table const & ) = delete;\n\n Table & operator=(Table &&) = delete;\n\n\n\n pybind11::array full () { return from(FULL ); }\n\n pybind11::array ghost() { return from(GHOST); }\n\n pybind11::array body () { return from(BODY ); }\n\n\n\n static int NDIM (pybind11::array arr) { return PyArray_NDIM ((PyArrayObject *) arr.ptr()); }\n", "file_path": "libmarch/include/march/python/WrapBase.hpp", "rank": 4, "score": 292538.4033486382 }, { "content": "class PythonAnchor : public gas::CommonAnchor\n\n{\n\n\n\npublic:\n\n\n\n virtual ~PythonAnchor() {}\n\n\n\n template <size_t NDIM> PythonAnchor(ctor_passkey const & pk, gas::Solver<NDIM> & svr)\n\n : CommonAnchor(pk, svr) {}\n\n\n\n template <size_t NDIM>\n\n static std::shared_ptr<PythonAnchor> construct(gas::Solver<NDIM> & svr) {\n\n return std::make_shared<PythonAnchor>(ctor_passkey(), svr);\n\n }\n\n\n\n#define DECL_MARCH_GAS_PYTHON_ANCHOR_METHOD(NAME) \\\n\n void NAME() override { PYBIND11_OVERLOAD(void, CommonAnchor, NAME); }\n\n\n\n DECL_MARCH_GAS_PYTHON_ANCHOR_METHOD(provide)\n\n DECL_MARCH_GAS_PYTHON_ANCHOR_METHOD(preloop)\n", "file_path": "libmarch/include/march/python/wrapper_gas.hpp", "rank": 5, "score": 290983.1737255276 }, { "content": "class FooTest : public ::testing::TestWithParam<const char*> {\n\n // You can implement all the usual class fixture members here.\n\n};\n\n\n\n// Then, use the TEST_P macro to define as many parameterized tests\n\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n\n// or \"pattern\", whichever you prefer to think.\n\n\n\nTEST_P(FooTest, DoesBlah) {\n\n // Inside a test, access the test parameter with the GetParam() method\n\n // of the TestWithParam<T> class:\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n ...\n\n}\n\n\n\nTEST_P(FooTest, HasBlahBlah) {\n\n ...\n\n}\n\n\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 6, "score": 271620.3838763124 }, { "content": "class PythonAnchorManager : public gas::AnchorChain<NDIM>::LifeManager {\n\n\n\npublic:\n\n\n\n void append(pybind11::object const & pyobj) { m_list.push_back(pyobj); }\n\n\n\nprivate:\n\n\n\n std::list<pybind11::object> m_list;\n\n\n\n}; /* class PythonAnchorManager */\n\n\n\ntemplate< size_t NDIM >\n\nclass\n\nMARCH_PYTHON_WRAPPER_VISIBILITY\n\nWrapGasAnchorChain\n\n : public WrapBase< WrapGasAnchorChain<NDIM>, gas::AnchorChain<NDIM> >\n\n{\n\n\n\n /* aliases for dependent type name lookup */\n", "file_path": "libmarch/include/march/python/wrapper_gas.hpp", "rank": 7, "score": 262708.0908330167 }, { "content": "class Order0Hand : public HandCRTP< Order0Hand<NDIM>, HandTraits<SolutionOrder0Table<real_type, NDIM>, real_type> >\n\n{\n\npublic:\n\n using base_type = HandCRTP< Order0Hand<NDIM>, HandTraits<SolutionOrder0Table<real_type, NDIM>, real_type> >;\n\n using base_type::base_type;\n\n using trait_type = HandTraits<SolutionOrder0Table<real_type, NDIM>, real_type>;\n\n using vector_type = Vector<NDIM>;\n\n Order0Hand & operator=(real_type value) {\n\n for (index_type it=0; it<trait_type::neq; ++it) { (**this)[it] = value; }\n\n return *this;\n\n }\n\n // accessors to solution quantities.\n\n real_type & density() { return (**this)[0]; }\n\n real_type const & density() const { return (**this)[0]; }\n\n vector_type & momentum() { return *reinterpret_cast<vector_type *>(&(**this)[1]); }\n\n vector_type const & momentum() const { return *reinterpret_cast<vector_type const *>(&(**this)[1]); }\n\n real_type & energy() { return (**this)[NDIM+1]; }\n\n real_type const & energy() const { return (**this)[NDIM+1]; }\n\n // accessors physics values.\n\n real_type pressure(real_type gamma /* ratio of specific heat */) const {\n", "file_path": "libmarch/include/march/gas/Solution.hpp", "rank": 8, "score": 260702.7733387092 }, { "content": "struct array_assign_< ElemType, NCOLUMN, 0 > {\n\n typedef ElemType (&array_type)[NCOLUMN];\n\n typedef const ElemType (&const_array_type)[NCOLUMN];\n\n static void act(array_type row_out, const_array_type row_in) {\n\n row_out[0] = row_in[0];\n\n }\n\n}; /* end struct array_assign_ specialization */\n\n\n\ntemplate < typename ElemType, size_t NCOLUMN >\n\nvoid array_assign(ElemType (&row_out)[NCOLUMN], const ElemType (&row_in)[NCOLUMN]) {\n\n array_assign_<ElemType, NCOLUMN, NCOLUMN-1>::act(row_out, row_in);\n\n}\n\n\n\n} /* end namespace aux */\n\n\n\n/**\n\n * Typed unresizeable lookup table.\n\n */\n\ntemplate< typename ElemType, size_t NCOLUMN >\n", "file_path": "libmarch/include/march/core/LookupTable.hpp", "rank": 9, "score": 255680.31241844862 }, { "content": "class HandCRTP : public HandBase {\n\n\n\npublic:\n\n\n\n using derived_type = Derived;\n\n using trait_type = Traits;\n\n using table_type = typename trait_type::table_type;\n\n using item_reference = typename trait_type::item_reference;\n\n using item_const_reference = typename trait_type::item_const_reference;\n\n using row_type = typename trait_type::row_type;\n\n using row_pointer = typename trait_type::row_pointer;\n\n using row_reference = typename trait_type::row_reference;\n\n using row_const_reference = typename trait_type::row_const_reference;\n\n\n\n HandCRTP(table_type & table, index_type irow) : HandCRTP(&table[irow]) {}\n\n HandCRTP(table_type const & table, index_type irow) : HandCRTP(&table[irow]) {}\n\n\n\n derived_type & assign(derived_type && other) { this->m_ptr = other.m_ptr; }\n\n\n\n HandCRTP(HandCRTP && other) : HandCRTP(other.ptr()) {}\n", "file_path": "libmarch/include/march/gas/Solution.hpp", "rank": 10, "score": 247669.4657521054 }, { "content": "class LookupTableCore {\n\n\n\nprivate:\n\n\n\n std::shared_ptr<Buffer> m_buffer;\n\n std::vector<index_type> m_dims;\n\n index_type m_nghost = 0;\n\n index_type m_nbody = 0;\n\n index_type m_ncolumn = 0;\n\n index_type m_elsize = 1; ///< Element size in bytes.\n\n DataTypeId m_datatypeid = MH_INT8;\n\n\n\npublic:\n\n\n\n LookupTableCore() : m_buffer(Buffer::construct()), m_dims() { }\n\n\n\n /**\n\n * \\param[in] nghost Number of ghost (negative index) rows.\n\n * \\param[in] nbody Number of body (non-negative index) rows.\n\n * \\param[in] dims The shape of the table, including the combined row\n", "file_path": "libmarch/include/march/core/LookupTable.hpp", "rank": 11, "score": 245626.06455222395 }, { "content": "class CellTypeGroup {\n\n\n\npublic:\n\n\n\n CellTypeGroup(CellTypeGroup const & ) = delete;\n\n CellTypeGroup(CellTypeGroup &&) = delete;\n\n CellTypeGroup const & operator=(CellTypeGroup const & ) = delete;\n\n CellTypeGroup && operator=(CellTypeGroup &&) = delete;\n\n\n\n CellType const & point () const { return m_cell_types[CellType::POINT ]; }\n\n CellType const & line () const { return m_cell_types[CellType::LINE ]; }\n\n CellType const & quadrilateral() const { return m_cell_types[CellType::QUADRILATERAL]; }\n\n CellType const & triangle () const { return m_cell_types[CellType::TRIANGLE ]; }\n\n CellType const & hexahedron () const { return m_cell_types[CellType::HEXAHEDRON ]; }\n\n CellType const & tetrahedron () const { return m_cell_types[CellType::TETRAHEDRON ]; }\n\n CellType const & prism () const { return m_cell_types[CellType::PRISM ]; }\n\n CellType const & pyramid () const { return m_cell_types[CellType::PYRAMID ]; }\n\n\n\n CellType const & operator[](size_t id) const { return m_cell_types[id]; }\n\n size_t size() const { return sizeof(m_cell_types) / sizeof(CellType); }\n", "file_path": "libmarch/include/march/mesh/CellType.hpp", "rank": 12, "score": 245516.99247212458 }, { "content": "class InstanceCounter {\n\n\n\npublic:\n\n\n\n InstanceCounter() { ++m_active_instance_count; }\n\n InstanceCounter(InstanceCounter const &) { ++m_active_instance_count; }\n\n ~InstanceCounter() { --m_active_instance_count; }\n\n\n\n static size_t active_instance_count() { return m_active_instance_count; }\n\n\n\nprivate:\n\n\n\n static size_t m_active_instance_count;\n\n\n\n}; /* end class InstanceCounter */\n\n\n\ntemplate< class T > size_t InstanceCounter<T>::m_active_instance_count = 0;\n\n\n\n} /* end namespace march */\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/include/march/core/memory.hpp", "rank": 13, "score": 242051.1529434481 }, { "content": " class Resizer {\n\n public:\n\n Resizer(LookupTableCore & table) : m_table(table) {}\n\n LookupTableCore operator()(index_type nghost, index_type nbody) {\n\n LookupTableCore newtable = new_table(m_table, nghost, nbody);\n\n copy(newtable, m_table);\n\n return newtable;\n\n }\n\n template< class ValueType >\n\n LookupTableCore operator()(index_type nghost, index_type nbody, ValueType initial) {\n\n LookupTableCore newtable = new_table(m_table, nghost, nbody);\n\n fill(newtable, initial);\n\n copy(newtable, m_table);\n\n return newtable;\n\n }\n\n private:\n\n static LookupTableCore new_table(LookupTableCore const & src, index_type nghost, index_type nbody) {\n\n std::vector<index_type> dims(src.m_dims);\n\n dims[0] = nghost + nbody;\n\n return LookupTableCore(nghost, nbody, dims, src.m_datatypeid);\n", "file_path": "libmarch/include/march/core/LookupTable.hpp", "rank": 14, "score": 241987.21942185902 }, { "content": "class UniversalTersePrinter<const char*> {\n\n public:\n\n static void Print(const char* str, ::std::ostream* os) {\n\n if (str == NULL) {\n\n *os << \"NULL\";\n\n } else {\n\n UniversalPrint(string(str), os);\n\n }\n\n }\n\n};\n\ntemplate <>\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 15, "score": 239571.6495064805 }, { "content": "struct SolutionOrder0Table : public LookupTable< ElemType, SolutionTableTraits<NDIM>::neq >\n\n{\n\n using table_traits = SolutionTableTraits<NDIM>;\n\n constexpr static size_t ndim = table_traits::ndim;\n\n constexpr static size_t neq = table_traits::neq;\n\n using base_type = LookupTable<ElemType, neq>;\n\n using hand_type = Order0Hand<ndim>;\n\n SolutionOrder0Table(index_type nghost, index_type nbody) : base_type(nghost, nbody) {}\n\n hand_type hat(index_type irow) { return hand_type(*this, irow); }\n\n hand_type const hat(index_type irow) const { return hand_type(*this, irow); }\n\n}; /* end struct SolutionOrder0Table */\n\n\n\ntemplate< size_t NDIM > class Order1Hand;\n\n\n\ntemplate< typename ElemType, size_t NDIM >\n", "file_path": "libmarch/include/march/gas/Solution.hpp", "rank": 16, "score": 238671.83435348305 }, { "content": "class ModuleInitializer {\n\n\n\npublic:\n\n\n\n static ModuleInitializer & get_instance() {\n\n static ModuleInitializer inst;\n\n return inst;\n\n }\n\n\n\n void initialize(pybind11::module & topmod) {\n\n if (!m_initialized) {\n\n initialize_march(topmod);\n\n initialize_march_gas(topmod);\n\n }\n\n }\n\n\n\n bool is_initialized() const { return m_initialized; }\n\n\n\nprivate:\n\n\n", "file_path": "libmarch/include/march/python/WrapBase.hpp", "rank": 17, "score": 236886.61123442376 }, { "content": "class TrimInterface : public TrimBase<NDIM> {\n\n\n\npublic:\n\n\n\n using base_type = TrimBase<NDIM>;\n\n using solver_type = typename base_type::solver_type;\n\n using block_type = typename base_type::block_type;\n\n using pointer = typename base_type::pointer;\n\n\n\n TrimInterface(solver_type & solver, BoundaryData & boundary): base_type(solver, boundary) {\n\n static_assert(sizeof(TrimInterface<NDIM>) == sizeof(base_type), \"TrimInterface size mismatch\");\n\n }\n\n ~TrimInterface() override {}\n\n std::string type_name() override { return string::get_type_name(*this); }\n\n void apply_do0() override { /* FIXME: add code */ }\n\n void apply_do1() override { /* FIXME: add code */ }\n\n\n\n}; /* end class TrimInterface */\n\n\n\n\n\ntemplate< size_t NDIM >\n", "file_path": "libmarch/include/march/gas/Trim.hpp", "rank": 18, "score": 236354.4027404365 }, { "content": "class TrimInlet : public TrimBase<NDIM> {\n\n\n\npublic:\n\n\n\n constexpr static size_t NVALUE = 6;\n\n\n\n using base_type = TrimBase<NDIM>;\n\n using solver_type = typename base_type::solver_type;\n\n using block_type = typename base_type::block_type;\n\n using pointer = typename base_type::pointer;\n\n\n\n TrimInlet(solver_type & solver, BoundaryData & boundary): base_type(solver, boundary) {\n\n static_assert(sizeof(TrimInlet<NDIM>) == sizeof(base_type), \"TrimInlet size mismatch\");\n\n }\n\n\n\n ~TrimInlet() override {}\n\n std::string type_name() override { return string::get_type_name(*this); }\n\n void apply_do0() override;\n\n void apply_do1() override;\n\n\n", "file_path": "libmarch/include/march/gas/Trim.hpp", "rank": 19, "score": 236354.4027404365 }, { "content": "class TrimNoOp : public TrimBase<NDIM> {\n\n\n\npublic:\n\n\n\n using base_type = TrimBase<NDIM>;\n\n using solver_type = typename base_type::solver_type;\n\n using block_type = typename base_type::block_type;\n\n using pointer = typename base_type::pointer;\n\n\n\n TrimNoOp(solver_type & solver, BoundaryData & boundary): base_type(solver, boundary) {\n\n static_assert(sizeof(TrimNoOp<NDIM>) == sizeof(base_type), \"TrimNoOp size mismatch\");\n\n }\n\n ~TrimNoOp() override {}\n\n std::string type_name() override { return string::get_type_name(*this); }\n\n void apply_do0() override {}\n\n void apply_do1() override {}\n\n\n\n}; /* end class TrimNoOp */\n\n\n\n\n\ntemplate< size_t NDIM >\n", "file_path": "libmarch/include/march/gas/Trim.hpp", "rank": 20, "score": 236354.4027404365 }, { "content": "struct SolutionOrder1Table : public LookupTable< ElemType, NDIM*SolutionTableTraits<NDIM>::neq >\n\n{\n\n using table_traits = SolutionTableTraits<NDIM>;\n\n constexpr static size_t ndim = table_traits::ndim;\n\n constexpr static size_t neq = table_traits::neq;\n\n using base_type = LookupTable<ElemType, ndim*neq>;\n\n using hand_type = Order1Hand<ndim>;\n\n SolutionOrder1Table(index_type nghost, index_type nbody) : base_type(nghost, nbody) {}\n\n hand_type hat(index_type irow) { return hand_type(*this, irow); }\n\n hand_type const hat(index_type irow) const { return hand_type(*this, irow); }\n\n}; /* end struct SolutionOrder0Table */\n\n\n", "file_path": "libmarch/include/march/gas/Solution.hpp", "rank": 21, "score": 233360.5811058531 }, { "content": "class TrimSlipWall : public TrimBase<NDIM> {\n\n\n\npublic:\n\n\n\n using base_type = TrimBase<NDIM>;\n\n using solver_type = typename base_type::solver_type;\n\n using block_type = typename base_type::block_type;\n\n using pointer = typename base_type::pointer;\n\n\n\n TrimSlipWall(solver_type & solver, BoundaryData & boundary): base_type(solver, boundary) {\n\n static_assert(sizeof(TrimSlipWall<NDIM>) == sizeof(base_type), \"TrimSlipWall size mismatch\");\n\n }\n\n\n\n ~TrimSlipWall() override {}\n\n std::string type_name() override { return string::get_type_name(*this); }\n\n void apply_do0() override;\n\n void apply_do1() override;\n\n\n\n}; /* end class TrimSlipWall */\n\n\n", "file_path": "libmarch/include/march/gas/Trim.hpp", "rank": 22, "score": 232190.06122849713 }, { "content": "class TrimNonRefl : public TrimBase<NDIM> {\n\n\n\npublic:\n\n\n\n using base_type = TrimBase<NDIM>;\n\n using pointer = typename base_type::pointer;\n\n using solver_type = typename base_type::solver_type;\n\n using block_type = typename base_type::block_type;\n\n\n\n TrimNonRefl(solver_type & solver, BoundaryData & boundary): base_type(solver, boundary) {\n\n static_assert(sizeof(TrimNonRefl<NDIM>) == sizeof(base_type), \"TrimNonRefl size mismatch\");\n\n }\n\n\n\n ~TrimNonRefl() override {}\n\n std::string type_name() override { return string::get_type_name(*this); }\n\n void apply_do0() override;\n\n void apply_do1() override;\n\n\n\n}; /* end class TrimNonRefl */\n\n\n", "file_path": "libmarch/include/march/gas/Trim.hpp", "rank": 23, "score": 232190.06122849713 }, { "content": "#define MH_DECL_CELL_TYPE(NAME, TYPE, DIM, NNODE, NEDGE, NSURFACE) \\\n\nstruct NAME##CellType : public CellType { \\\n\n NAME##CellType() : CellType(TYPE, DIM, NNODE, NEDGE, NSURFACE) {} \\\n\n};\n\n// id, ndim, nnode, nedge, nsurface\n\nMH_DECL_CELL_TYPE(Point , 0, 0, 1, 0, 0 ) // point/node/vertex\n\nMH_DECL_CELL_TYPE(Line , 1, 1, 2, 0, 0 ) // line/edge\n\nMH_DECL_CELL_TYPE(Quadrilateral, 2, 2, 4, 4, 0 )\n\nMH_DECL_CELL_TYPE(Triangle , 3, 2, 3, 3, 0 )\n\nMH_DECL_CELL_TYPE(Hexahedron , 4, 3, 8, 12, 6 ) // hexahedron/brick\n\nMH_DECL_CELL_TYPE(Tetrahedron , 5, 3, 4, 6, 4 )\n\nMH_DECL_CELL_TYPE(Prism , 6, 3, 6, 9, 5 )\n\nMH_DECL_CELL_TYPE(Pyramid , 7, 3, 5, 8, 5 )\n\n#undef MH_DECL_CELL_TYPE\n\n\n\nnamespace detail {\n\n\n", "file_path": "libmarch/include/march/mesh/CellType.hpp", "rank": 24, "score": 226373.0651716724 }, { "content": "class GETypeGroup {\n\n\n\npublic:\n\n\n\n GEType const & operator[](size_t id) const { return m_ge_types[id]; }\n\n size_t size() const { return sizeof(m_ge_types) / sizeof(GEType); }\n\n \n\n static const GETypeGroup & get_instance() {\n\n static GETypeGroup inst;\n\n return inst;\n\n }\n\n\n\nprivate:\n\n\n\n GETypeGroup()\n\n : m_ge_types{\n\n GEType(0, 0, 0 ) // point\n\n , GEType(1, 1, 1 ) // line\n\n , GEType(2, 4, 1.0/4) // quadrilateral\n\n , GEType(3, 3, 1.0/3) // triangle\n", "file_path": "libmarch/include/march/mesh/ConservationElement/GradientElement.hpp", "rank": 25, "score": 223098.4735375644 }, { "content": "class FaceHand : public BlockHandBase< NDIM, FaceHand<NDIM> > {\n\n\n\npublic:\n\n\n\n using base_type = BlockHandBase<NDIM, FaceHand<NDIM>>;\n\n using base_type::base_type;\n\n\n\n using block_type = UnstructuredBlock<NDIM>;\n\n using vector_type = Vector<NDIM>;\n\n\n\n std::string repr(size_t indent=0, size_t precision=0) const;\n\n\n\n index_type tpn() const { return this->block().fctpn()[this->index()]; }\n\n\n\n CellType const & type() const { return celltype(tpn()); }\n\n\n\n vector_type const & cnd() const { return this->row_as_vector(this->block().fccnd()[this->index()]); }\n\n vector_type const & nml() const { return this->row_as_vector(this->block().fcnml()[this->index()]); }\n\n real_type ara() const { return this->block().fcara()[this->index()]; }\n\n\n", "file_path": "libmarch/include/march/mesh/UnstructuredBlock/hand.hpp", "rank": 26, "score": 203896.44827277877 }, { "content": "class CellHand : public BlockHandBase< NDIM, CellHand<NDIM> > {\n\n\n\npublic:\n\n\n\n using base_type = BlockHandBase<NDIM, CellHand<NDIM>>;\n\n using base_type::base_type;\n\n\n\n using block_type = UnstructuredBlock<NDIM>;\n\n using vector_type = Vector<NDIM>;\n\n\n\n std::string repr(size_t indent=0, size_t precision=0) const;\n\n\n\n index_type tpn() const { return this->block().cltpn()[this->index()]; }\n\n\n\n CellType const & type() const { return celltype(tpn()); }\n\n\n\n vector_type const & cnd() const {\n\n return *reinterpret_cast<vector_type const *>(&(this->block().clcnd()[this->index()][0]));\n\n }\n\n\n", "file_path": "libmarch/include/march/mesh/UnstructuredBlock/hand.hpp", "rank": 27, "score": 203896.44827277877 }, { "content": "class NodeHand : public BlockHandBase< NDIM, NodeHand<NDIM> > {\n\n\n\npublic:\n\n\n\n using base_type = BlockHandBase<NDIM, NodeHand<NDIM>>;\n\n using base_type::base_type;\n\n\n\n using block_type = UnstructuredBlock<NDIM>;\n\n using vector_type = Vector<NDIM>;\n\n\n\n std::string repr(size_t indent=0, size_t precision=0) const;\n\n\n\n vector_type const & crd() const { return this->row_as_vector(this->block().ndcrd()[this->index()]); }\n\n\n\n}; /* end class NodeHand */\n\n\n\ntemplate< size_t NDIM >\n\nstd::string NodeHand<NDIM>::repr(size_t indent, size_t precision) const {\n\n std::string ret(string::format(\"NodeHand%ldD(index=%d\", NDIM, this->index()));\n\n ret += \", crd=\" + crd().repr(indent, precision) + \")\";\n\n return ret;\n\n}\n\n\n\ntemplate< size_t NDIM > class CellHand;\n\n\n\ntemplate< size_t NDIM >\n", "file_path": "libmarch/include/march/mesh/UnstructuredBlock/hand.hpp", "rank": 28, "score": 203896.44827277877 }, { "content": "enum DataTypeId {\n\n MH_BOOL=0,\n\n MH_INT8, MH_UINT8,\n\n MH_INT16, MH_UINT16,\n\n MH_INT32, MH_UINT32,\n\n MH_LONG, MH_ULONG,\n\n MH_INT64, MH_UINT64,\n\n MH_FLOAT, MH_DOUBLE, MH_LONGDOUBLE,\n\n MH_CFLOAT, MH_CDOUBLE, MH_CLONGDOUBLE\n\n};\n\n\n\ninline size_t data_type_size(const DataTypeId dtid) {\n\n size_t ret = 0;\n\n switch (dtid) {\n\n case MH_BOOL:\n\n case MH_INT8:\n\n case MH_UINT8:\n\n ret = 1;\n\n break;\n\n case MH_INT16:\n", "file_path": "libmarch/include/march/core/types.hpp", "rank": 29, "score": 201609.49496733624 }, { "content": "// The convenience class for users who need to override just one or two\n\n// methods and are not concerned that a possible change to a signature of\n\n// the methods they override will not be caught during the build. For\n\n// comments about each method please see the definition of TestEventListener\n\n// above.\n\nclass EmptyTestEventListener : public TestEventListener {\n\n public:\n\n virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}\n\n virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n\n int /*iteration*/) {}\n\n virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}\n\n virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}\n\n virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}\n\n virtual void OnTestStart(const TestInfo& /*test_info*/) {}\n\n virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}\n\n virtual void OnTestEnd(const TestInfo& /*test_info*/) {}\n\n virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}\n\n virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}\n\n virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}\n\n virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n\n int /*iteration*/) {}\n\n virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}\n\n};\n\n\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 30, "score": 198338.2324460745 }, { "content": "class UnstructuredBlock\n\n : public std::enable_shared_from_this<UnstructuredBlock<NDIM>>\n\n{\n\n\n\npublic:\n\n\n\n static_assert(2 == NDIM || 3 == NDIM, \"not 2 or 3 dimensional\");\n\n\n\n static constexpr index_type FCMND = CellType::FCNND_MAX;\n\n static constexpr index_type CLMND = CellType::CLNND_MAX;\n\n static constexpr index_type CLMFC = CellType::CLNFC_MAX;\n\n static constexpr index_type FCNCL = 4;\n\n static constexpr index_type FCREL = 4;\n\n static constexpr index_type BFREL = BoundaryData::BFREL;\n\n\n\n // TODO: move to UnstructuredBlock.\n\n // @[\n\n void locate_point(const real_type (& crd)[NDIM]) const;\n\n\n\n // moved to mesh: void prepare_ce();\n", "file_path": "libmarch/include/march/mesh/UnstructuredBlock/class.hpp", "rank": 31, "score": 197416.0682546721 }, { "content": " class ctor_passkey {\n\n private:\n\n ctor_passkey() = default;\n\n friend UnstructuredBlock<NDIM>;\n\n };\n\n\n\n UnstructuredBlock(\n\n const ctor_passkey &\n\n , index_type nnode, index_type nface, index_type ncell, index_type nbound\n\n , index_type ngstnode, index_type ngstface, index_type ngstcell\n\n , bool use_incenter\n\n ) : std::enable_shared_from_this<UnstructuredBlock<NDIM>>()\n\n , m_nnode(nnode), m_nface(nface), m_ncell(ncell), m_nbound(nbound)\n\n , m_ngstnode(ngstnode), m_ngstface(ngstface), m_ngstcell(ngstcell)\n\n , m_use_incenter(use_incenter)\n\n {\n\n build_tables();\n\n }\n\n\n\n UnstructuredBlock() = delete;\n", "file_path": "libmarch/include/march/mesh/UnstructuredBlock/class.hpp", "rank": 32, "score": 197416.0682546721 }, { "content": "struct array_assign_ {\n\n typedef ElemType (&array_type)[NCOLUMN];\n\n typedef const ElemType (&const_array_type)[NCOLUMN];\n\n static void act(array_type row_out, const_array_type row_in) {\n\n array_assign_<ElemType, NCOLUMN, INDEX-1>::act(row_out, row_in);\n\n row_out[INDEX] = row_in[INDEX];\n\n }\n\n}; /* end struct array_assign_ */\n\n\n\ntemplate < typename ElemType, size_t NCOLUMN >\n", "file_path": "libmarch/include/march/core/LookupTable.hpp", "rank": 33, "score": 196446.04053268413 }, { "content": "class Anchor\n\n : public std::enable_shared_from_this<Anchor<NDIM>>\n\n{\n\n\n\npublic:\n\n\n\n using solver_type = Solver<NDIM>;\n\n\n\n Anchor() = delete;\n\n Anchor(Anchor const & ) = delete;\n\n Anchor(Anchor &&) = delete;\n\n Anchor & operator=(Anchor const & ) = delete;\n\n Anchor & operator=(Anchor &&) = delete;\n\n\n\nprotected:\n\n\n", "file_path": "libmarch/include/march/gas/Anchor.hpp", "rank": 34, "score": 195375.60519170674 }, { "content": "class Solution {\n\n\n\npublic:\n\n\n\n using table_traits = SolutionTableTraits<NDIM>;\n\n static constexpr size_t ndim=table_traits::ndim;\n\n static constexpr size_t neq=table_traits::neq;\n\n\n\n using o0table_type = SolutionOrder0Table<real_type, ndim>;\n\n using o1table_type = SolutionOrder1Table<real_type, ndim>;\n\n using o0hand_type = typename o0table_type::hand_type;\n\n using o1hand_type = typename o1table_type::hand_type;\n\n\n\n Solution(index_type ngstcell, index_type ncell)\n\n : m_so0c(ngstcell, ncell), m_so0n(ngstcell, ncell), m_so0t(ngstcell, ncell)\n\n , m_so1c(ngstcell, ncell), m_so1n(ngstcell, ncell)\n\n , m_stm(ngstcell, ncell), m_cflo(ngstcell, ncell), m_cflc(ngstcell, ncell)\n\n , m_gamma(ngstcell, ncell)\n\n {}\n\n\n", "file_path": "libmarch/include/march/gas/Solution.hpp", "rank": 35, "score": 195375.60519170674 }, { "content": "class Quantity\n\n : public InstanceCounter<Quantity<NDIM>>\n\n , public std::enable_shared_from_this<Quantity<NDIM>>\n\n{\n\n\n\npublic:\n\n\n\n using solver_type = Solver<NDIM>;\n\n using solution_type = typename solver_type::solution_type;\n\n using block_type = UnstructuredBlock<NDIM>;\n\n using vector_type = Vector<NDIM>;\n\n\n\n using o0hand_type = typename solution_type::o0hand_type;\n\n using o1hand_type = typename solution_type::o1hand_type;\n\n\n\n static constexpr real_type ALMOST_ZERO = solver_type::ALMOST_ZERO;\n\n\n", "file_path": "libmarch/include/march/gas/Quantity.hpp", "rank": 36, "score": 195375.60519170674 }, { "content": " class Iterator : public ParamIteratorInterface<ParamType> {\n\n public:\n\n Iterator(const ParamGeneratorInterface<ParamType>* base,\n\n const ParamGenerator<T1>& g1,\n\n const typename ParamGenerator<T1>::iterator& current1,\n\n const ParamGenerator<T2>& g2,\n\n const typename ParamGenerator<T2>::iterator& current2,\n\n const ParamGenerator<T3>& g3,\n\n const typename ParamGenerator<T3>::iterator& current3,\n\n const ParamGenerator<T4>& g4,\n\n const typename ParamGenerator<T4>::iterator& current4,\n\n const ParamGenerator<T5>& g5,\n\n const typename ParamGenerator<T5>::iterator& current5,\n\n const ParamGenerator<T6>& g6,\n\n const typename ParamGenerator<T6>::iterator& current6,\n\n const ParamGenerator<T7>& g7,\n\n const typename ParamGenerator<T7>::iterator& current7,\n\n const ParamGenerator<T8>& g8,\n\n const typename ParamGenerator<T8>::iterator& current8,\n\n const ParamGenerator<T9>& g9,\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 37, "score": 194530.23771151976 }, { "content": "class Solver\n\n : public InstanceCounter<Solver<NDIM>>\n\n , public std::enable_shared_from_this<Solver<NDIM>>\n\n{\n\n\n\npublic:\n\n\n\n using int_type = State::int_type;\n\n using block_type = UnstructuredBlock<NDIM>;\n\n using anchor_chain_type = AnchorChain<NDIM>;\n\n using vector_type = Vector<NDIM>;\n\n using solution_type = Solution<NDIM>;\n\n\n\n static constexpr size_t ndim = solution_type::ndim;\n\n static constexpr size_t neq = solution_type::neq;\n\n static constexpr real_type TINY = 1.e-60;\n\n static constexpr real_type ALMOST_ZERO = 1.e-200;\n\n\n\n static constexpr index_type FCMND = block_type::FCMND;\n\n static constexpr index_type CLMND = block_type::CLMND;\n\n static constexpr index_type CLMFC = block_type::CLMFC;\n\n static constexpr index_type FCNCL = block_type::FCNCL;\n\n static constexpr index_type FCREL = block_type::FCREL;\n\n static constexpr index_type BFREL = block_type::BFREL;\n\n\n", "file_path": "libmarch/include/march/gas/Solver_decl.hpp", "rank": 38, "score": 191390.8563949837 }, { "content": " class ctor_passkey {\n\n ctor_passkey() = default;\n\n friend Quantity<NDIM>;\n\n };\n\n\n\n Quantity(ctor_passkey const &, solver_type const & solver)\n\n : m_solver(solver)\n\n , m_density (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_velocity (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_vorticity (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_vorticity_magnitude (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_ke (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_pressure (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_temperature (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_soundspeed (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_mach (solver.block()->ngstcell(), solver.block()->ncell())\n\n , m_schlieren (solver.block()->ngstcell(), solver.block()->ncell())\n\n {}\n\n\n\n Quantity() = delete;\n", "file_path": "libmarch/include/march/gas/Quantity.hpp", "rank": 39, "score": 191390.8563949837 }, { "content": "class AnchorChain\n\n{\n\n\n\npublic:\n\n\n\n using anchor_type = Anchor<NDIM>;\n\n using anchor_ptr = std::shared_ptr<anchor_type>;\n\n\n\n struct LifeManager { virtual ~LifeManager() {} };\n\n\n\n std::unique_ptr<LifeManager> & life_manager() { return m_life_manager; }\n\n std::unique_ptr<LifeManager> const & life_manager() const { return m_life_manager; }\n\n\n\n void push_back(anchor_ptr const & ptr) { m_anchors.push_back(ptr); }\n\n void append(anchor_ptr const & ptr, std::string const & name) {\n\n m_anchors.push_back(ptr);\n\n m_names.emplace(name, ptr);\n\n }\n\n\n\n#define DECL_MARCH_GAS_ANCHOR_CALL_FORWARD(NAME) \\\n", "file_path": "libmarch/include/march/gas/Anchor.hpp", "rank": 40, "score": 191390.8563949837 }, { "content": "class CommonAnchor\n\n : public std::enable_shared_from_this<CommonAnchor>\n\n{\n\n\n\npublic:\n\n\n\n CommonAnchor() = delete;\n\n CommonAnchor(CommonAnchor const & ) = delete;\n\n CommonAnchor(CommonAnchor &&) = delete;\n\n CommonAnchor & operator=(CommonAnchor const & ) = delete;\n\n CommonAnchor & operator=(CommonAnchor &&) = delete;\n\n\n\n virtual ~CommonAnchor() {}\n\n\n\nprotected:\n\n\n", "file_path": "libmarch/include/march/gas/Anchor.hpp", "rank": 41, "score": 191390.8563949837 }, { "content": "class HandBase {\n\npublic:\n\n HandBase() : m_ptr(nullptr) {}\n\n operator bool() const { return m_ptr; }\n\nprotected:\n\n template<class T> HandBase(T * ptr) : m_ptr((void *)ptr) {}\n\n template<class T> T * ptr() { return reinterpret_cast<T *>(m_ptr); }\n\n template<class T> T * ptr() const { return reinterpret_cast<T *>(m_ptr); }\n\nprivate:\n\n void * m_ptr;\n\n}; /* end class HandBase */\n\n\n\n/**\n\n * Hand is a handle to solution arrays. The copy and move constructors copy\n\n * the pointer inside the other object, but assignment operators deep copy the\n\n * contents of the array.\n\n */\n\ntemplate< class Derived, class Traits >\n", "file_path": "libmarch/include/march/gas/Solution.hpp", "rank": 42, "score": 191390.8563949837 }, { "content": "class TrimInternal {\n\n\n\npublic:\n\n\n\n using solver_type = Solver<NDIM>;\n\n using block_type = typename solver_type::block_type;\n\n using o0hand_type = typename Solution<NDIM>::o0hand_type;\n\n using o1hand_type = typename Solution<NDIM>::o1hand_type;\n\n\n\n constexpr static index_type FCNCL = block_type::FCNCL;\n\n\n\n using fccls_row_const_reference = index_type const (&)[FCNCL];\n\n template< size_t NVALUE > using boundary_value_type = real_type[NVALUE];\n\n\n\n TrimInternal(solver_type & solver, BoundaryData & boundary)\n\n : m_solver(solver)\n\n , m_block(*solver.block())\n\n , m_boundary(boundary)\n\n {}\n\n\n", "file_path": "libmarch/include/march/gas/Trim.hpp", "rank": 43, "score": 191390.8563949837 }, { "content": "class TrimBase {\n\n\n\npublic:\n\n\n\n using pointer = std::unique_ptr<TrimBase<NDIM>>;\n\n\n\n using internal_type = TrimInternal<NDIM>;\n\n using solver_type = typename internal_type::solver_type;\n\n using block_type = typename internal_type::block_type;\n\n\n\n TrimBase(solver_type & solver, BoundaryData & boundary): m_internal(solver, boundary) {}\n\n\n\n TrimBase() = delete;\n\n TrimBase(TrimBase const & other) : m_internal(other.m_internal) {}\n\n TrimBase(TrimBase && other) : m_internal(other.m_internal) {}\n\n TrimBase & operator=(TrimBase const & ) = delete;\n\n TrimBase & operator=(TrimBase &&) = delete;\n\n\n\n virtual ~TrimBase() {}\n\n\n", "file_path": "libmarch/include/march/gas/Trim.hpp", "rank": 44, "score": 191390.8563949837 }, { "content": "class Parameter\n\n{\n\n\n\npublic:\n\n\n\n using int_type = int32_t;\n\n\n\n Parameter() = default;\n\n Parameter(Parameter const & ) = default;\n\n Parameter(Parameter &&) = delete;\n\n Parameter & operator=(Parameter const & ) = default;\n\n Parameter & operator=(Parameter &&) = delete;\n\n\n\n real_type sigma0() const { return m_sigma0; }\n\n real_type & sigma0() { return m_sigma0; }\n\n real_type taumin() const { return m_taumin; }\n\n real_type & taumin() { return m_taumin; }\n\n real_type tauscale() const { return m_tauscale; }\n\n real_type & tauscale() { return m_tauscale; }\n\n\n", "file_path": "libmarch/include/march/gas/Solver_decl.hpp", "rank": 45, "score": 191390.8563949837 }, { "content": " class ctor_passkey {};\n\n\n\npublic:\n\n\n\n Anchor(ctor_passkey const &, solver_type & svr, std::shared_ptr<CommonAnchor> const & common)\n\n : m_solver(svr), m_common(common) {}\n\n\n\n static std::shared_ptr<Anchor<NDIM>> construct(\n\n solver_type & svr\n\n , std::shared_ptr<CommonAnchor> const & common = std::shared_ptr<CommonAnchor>()\n\n ) {\n\n return std::make_shared<Anchor<NDIM>>(ctor_passkey(), svr, common);\n\n }\n\n\n\n virtual ~Anchor() = default;\n\n\n\n solver_type const & solver() const { return m_solver; }\n\n solver_type & solver() { return m_solver; }\n\n\n\n#define DECL_MARCH_GAS_ANCHOR_METHOD(NAME) \\\n", "file_path": "libmarch/include/march/gas/Anchor.hpp", "rank": 46, "score": 191390.8563949837 }, { "content": " class TestName : public CaseName<gtest_TypeParam_> { \\\n\n private: \\\n\n typedef CaseName<gtest_TypeParam_> TestFixture; \\\n\n typedef gtest_TypeParam_ TypeParam; \\\n\n virtual void TestBody(); \\\n\n }; \\\n\n static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\\\n\n __FILE__, __LINE__, #CaseName, #TestName); \\\n\n } \\\n\n template <typename gtest_TypeParam_> \\\n\n void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()\n\n\n\n# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \\\n\n namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n\n typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \\\n\n } \\\n\n static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\\\n\n __FILE__, __LINE__, #__VA_ARGS__)\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 47, "score": 191246.4017458324 }, { "content": "// This class generates an XML output file.\n\nclass XmlUnitTestResultPrinter : public EmptyTestEventListener {\n\n public:\n\n explicit XmlUnitTestResultPrinter(const char* output_file);\n\n\n\n virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);\n\n\n\n private:\n\n // Is c a whitespace character that is normalized to a space character\n\n // when it appears in an XML attribute value?\n\n static bool IsNormalizableWhitespace(char c) {\n\n return c == 0x9 || c == 0xA || c == 0xD;\n\n }\n\n\n\n // May c appear in a well-formed XML document?\n\n static bool IsValidXmlCharacter(char c) {\n\n return IsNormalizableWhitespace(c) || c >= 0x20;\n\n }\n\n\n\n // Returns an XML-escaped copy of the input string str. If\n\n // is_attribute is true, the text is meant to appear as an attribute\n", "file_path": "libmarch/tests/gtest/gtest-all.cc", "rank": 48, "score": 189339.9243148903 }, { "content": " class FormatForComparison<CharType*, OtherStringType> { \\\n\n public: \\\n\n static ::std::string Format(CharType* value) { \\\n\n return ::testing::PrintToString(value); \\\n\n } \\\n\n }\n\n\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);\n\n\n\n#if GTEST_HAS_GLOBAL_STRING\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);\n\n#endif\n\n\n\n#if GTEST_HAS_GLOBAL_WSTRING\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);\n\n#endif\n\n\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 49, "score": 187827.21713612135 }, { "content": " class ctor_passkey {\n\n ctor_passkey() = default;\n\n friend Solver<NDIM>;\n\n };\n\n\n\n Solver(const ctor_passkey &, const std::shared_ptr<block_type> & block);\n\n\n\n Solver() = delete;\n\n Solver(Solver const & ) = delete;\n\n Solver(Solver &&) = delete;\n\n Solver & operator=(Solver const & ) = delete;\n\n Solver & operator=(Solver &&) = delete;\n\n\n\n static std::shared_ptr<Solver<NDIM>> construct(const std::shared_ptr<block_type> & block) {\n\n return std::make_shared<Solver<NDIM>>(ctor_passkey(), block);\n\n }\n\n\n\n std::shared_ptr<block_type> const & block() const { return m_block; }\n\n std::vector<std::unique_ptr<TrimBase<NDIM>>> const & trims() const { return m_trims; }\n\n std::vector<std::unique_ptr<TrimBase<NDIM>>> & trims() { return m_trims; }\n", "file_path": "libmarch/include/march/gas/Solver_decl.hpp", "rank": 50, "score": 187606.49383784318 }, { "content": "class BoundaryData {\n\n\n\npublic:\n\n\n\n static constexpr index_type BFREL = 3;\n\n\n\nprivate:\n\n\n\n /**\n\n * First column is the face index in block. The second column is the face\n\n * index in bndfcs. The third column is the face index of the related\n\n * block (if exists).\n\n */\n\n LookupTable<index_type, BFREL> m_facn;\n\n\n\n /**\n\n * Values attached (specified) for each boundary face. Each row is a\n\n * boundary face, and each column is a value.\n\n */\n\n LookupTableCore m_values;\n", "file_path": "libmarch/include/march/mesh/BoundaryData.hpp", "rank": 51, "score": 187606.49383784318 }, { "content": "// Streams test results to the given port on the given host machine.\n\nclass GTEST_API_ StreamingListener : public EmptyTestEventListener {\n\n public:\n", "file_path": "libmarch/tests/gtest/gtest-all.cc", "rank": 52, "score": 185248.78596570904 }, { "content": "class BlockHandBase {\n\n\n\npublic:\n\n\n\n using block_type = UnstructuredBlock<NDIM>;\n\n using vector_type = Vector<NDIM>;\n\n\n\n BlockHandBase(block_type const & block, index_type index)\n\n : m_block(&const_cast<block_type &>(block))\n\n , m_index(index)\n\n {}\n\n\n\n block_type & block() { return *m_block; }\n\n block_type const & block() const { return *m_block; }\n\n\n\n index_type index() const { return m_index; }\n\n void set_index(index_type index) { m_index = index; }\n\n\n\n bool operator==(HandType const & other) { return (m_block == other.m_block) && (m_index == other.m_index); }\n\n bool operator!=(HandType const & other) { return (m_block != other.m_block) || (m_index == other.m_index); }\n", "file_path": "libmarch/include/march/mesh/UnstructuredBlock/hand.hpp", "rank": 53, "score": 180581.35991629318 }, { "content": " class FormatForComparison<CharType*, OtherOperand> { \\\n\n public: \\\n\n static ::std::string Format(CharType* value) { \\\n\n return ::testing::PrintToString(static_cast<const void*>(value)); \\\n\n } \\\n\n }\n\n\n\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);\n\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);\n\n\n\n#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_\n\n\n\n// If a C string is compared with an STL string object, we know it's meant\n\n// to point to a NUL-terminated string, and thus can print it as a string.\n\n\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \\\n\n template <> \\\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 54, "score": 177967.2902887777 }, { "content": "class UniversalTersePrinter<char*> {\n\n public:\n\n static void Print(char* str, ::std::ostream* os) {\n\n UniversalTersePrinter<const char*>::Print(str, os);\n\n }\n\n};\n\n\n\n#if GTEST_HAS_STD_WSTRING\n\ntemplate <>\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 55, "score": 171013.96285844286 }, { "content": "#pragma once\n\n\n\n/*\n\n * Copyright (c) 2017, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n#include <pybind11/pybind11.h>\n\n\n\n#include \"march/python/WrapBase.hpp\"\n\n#include \"march/python/wrapper_core.hpp\"\n\n#include \"march/python/wrapper_mesh.hpp\"\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/include/march/python/wrapper_march.hpp", "rank": 56, "score": 167447.89759325483 }, { "content": "/*\n\n * Copyright (c) 2017, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n#include <pybind11/pybind11.h>\n\n#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\n\n#include <numpy/arrayobject.h>\n\n\n\n#include <utility>\n\n#include <memory>\n\n#include <vector>\n\n#include <algorithm>\n\n#include <cstring>\n\n\n\n#include \"march.hpp\"\n\n#include \"march/python/wrapper_march.hpp\"\n\n\n\nnamespace march {\n\n\n", "file_path": "libmarch/src/python/march.cpp", "rank": 57, "score": 163821.0366078412 }, { "content": "namespace python {\n\n\n\nPyObject * ModuleInitializer::initialize_march(pybind11::module & mod) {\n\n#if defined(Py_DEBUG)\n\n ::march::setup_debug();\n\n#endif // Py_DEBUG\n\n\n\n import_array1(nullptr); // or numpy c api segfault.\n\n\n\n mod.doc() = \"libmarch wrapper\";\n\n\n\n // section: core\n\n WrapBuffer::commit(mod, \"Buffer\", \"Internal data buffer\");\n\n WrapLookupTableCore::commit(mod, \"Table\", \"Lookup table that allows ghost entity.\");\n\n WrapVector<2>::commit(mod, \"Vector2D\", \"Cartesian vector (2D).\");\n\n WrapVector<3>::commit(mod, \"Vector3D\", \"Cartesian vector (3D).\");\n\n\n\n // section: mesh\n\n WrapBoundaryData::commit(mod, \"BoundaryData\", \"Data of a boundary condition.\");\n\n WrapUnstructuredBlock<2>::commit(mod, \"UnstructuredBlock2D\", \"Unstructured mesh block (2D).\");\n", "file_path": "libmarch/src/python/march.cpp", "rank": 58, "score": 163817.76959659482 }, { "content": " WrapUnstructuredBlock<3>::commit(mod, \"UnstructuredBlock3D\", \"Unstructured mesh block (3D).\");\n\n WrapNodeHand<2>::commit(mod, \"NodeHand2D\", \"Hand to a node (2D).\");\n\n WrapNodeHand<3>::commit(mod, \"NodeHand3D\", \"Hand to a node (3D).\");\n\n WrapFaceHand<2>::commit(mod, \"FaceHand2D\", \"Hand to a face (2D).\");\n\n WrapFaceHand<3>::commit(mod, \"FaceHand3D\", \"Hand to a face (3D).\");\n\n WrapCellHand<2>::commit(mod, \"CellHand2D\", \"Hand to a cell (2D).\");\n\n WrapCellHand<3>::commit(mod, \"CellHand3D\", \"Hand to a cell (3D).\");\n\n WrapBasicCE<2>::commit(mod, \"BasicCE2D\", \"Basic conservation element (2D).\");\n\n WrapBasicCE<3>::commit(mod, \"BasicCE3D\", \"Basic conservation element (3D).\");\n\n WrapConservationElement<2>::commit(mod, \"ConservationElement2D\", \"Conservation element (2D).\");\n\n WrapConservationElement<3>::commit(mod, \"ConservationElement3D\", \"Conservation element (3D).\");\n\n\n\n return mod.ptr();\n\n}\n\n\n\n} /* end namespace python */\n\n\n\n} /* end namespace march */\n\n\n\nPYBIND11_MODULE(libmarch, mod) {\n\n ::march::python::ModuleInitializer::get_instance().initialize(mod);\n\n}\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/src/python/march.cpp", "rank": 59, "score": 163794.78222399004 }, { "content": "class TestWithParam : public Test, public WithParamInterface<T> {\n\n};\n\n\n\n#endif // GTEST_HAS_PARAM_TEST\n\n\n\n// Macros for indicating success/failure in test code.\n\n\n\n// ADD_FAILURE unconditionally adds a failure to the current test.\n\n// SUCCEED generates a success - it doesn't automatically make the\n\n// current test successful, as a test is only successful when it has\n\n// no failure.\n\n//\n\n// EXPECT_* verifies that a certain condition is satisfied. If not,\n\n// it behaves like ADD_FAILURE. In particular:\n\n//\n\n// EXPECT_TRUE verifies that a Boolean condition is true.\n\n// EXPECT_FALSE verifies that a Boolean condition is false.\n\n//\n\n// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except\n\n// that they will also abort the current function on failure. People\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 60, "score": 162026.0995064851 }, { "content": "// The Mutex class can only be used for mutexes created at runtime. It\n\n// shares its API with MutexBase otherwise.\n\nclass Mutex : public MutexBase {\n\n public:\n\n Mutex() {\n\n GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));\n\n has_owner_ = false;\n\n }\n\n ~Mutex() {\n\n GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));\n\n }\n\n\n\n private:\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);\n\n};\n\n\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 61, "score": 161847.83467165002 }, { "content": " class RunnableImpl : public Runnable {\n\n public:\n\n RunnableImpl(UserThreadFunc* func, T param)\n\n : func_(func),\n\n param_(param) {\n\n }\n\n virtual ~RunnableImpl() {}\n\n virtual void Run() {\n\n func_(param_);\n\n }\n\n\n\n private:\n\n UserThreadFunc* const func_;\n\n const T param_;\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);\n\n };\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);\n\n};\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 62, "score": 161842.6626818435 }, { "content": "struct CellType {\n\n\n\n static constexpr size_t NVALUE = 5;\n\n\n\n CellType(\n\n index_type const id_in\n\n , index_type const dim_in\n\n , index_type const nnode_in\n\n , index_type const nedge_in\n\n , index_type const nsurface_in\n\n ) : m_data{id_in, dim_in, nnode_in, nedge_in, nsurface_in} {}\n\n\n\n CellType() = default;\n\n\n\n index_type id () const { return m_data[0]; }\n\n index_type ndim () const { return m_data[1]; }\n\n index_type nnode () const { return m_data[2]; }\n\n index_type nedge () const { return m_data[3]; }\n\n index_type nsurface() const { return m_data[4]; }\n\n\n", "file_path": "libmarch/include/march/mesh/CellType.hpp", "rank": 63, "score": 160238.13734868704 }, { "content": "class UniversalTersePrinter<const wchar_t*> {\n\n public:\n\n static void Print(const wchar_t* str, ::std::ostream* os) {\n\n if (str == NULL) {\n\n *os << \"NULL\";\n\n } else {\n\n UniversalPrint(::std::wstring(str), os);\n\n }\n\n }\n\n};\n\n#endif\n\n\n\ntemplate <>\n", "file_path": "libmarch/tests/gtest/gtest.h", "rank": 64, "score": 159456.32983645902 }, { "content": "/*\n\n * Copyright (c) 2017, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n#include <pybind11/pybind11.h>\n\n\n\n#include \"march.hpp\"\n\n#include \"march/gas.hpp\"\n\n#include \"march/python/wrapper_gas.hpp\"\n\n\n\nnamespace march {\n\n\n\nnamespace python {\n\n\n\nPyObject * ModuleInitializer::initialize_march_gas(pybind11::module & marchmod) {\n\n auto gasmod = marchmod.def_submodule(\"gas\", \"Gas dynamic solver\");\n\n\n\n // section: solver and associated data\n\n WrapGasSolver<2>::commit(gasmod, \"Solver2D\", \"Gas-dynamics solver (2D).\");\n", "file_path": "libmarch/src/python/march_gas.cpp", "rank": 65, "score": 159352.30676443953 }, { "content": " WrapGasTrimNonRefl<2>::commit(gasmod, \"TrimNonRefl2D\", \"Gas-dynamics non-reflective trim (2D).\");\n\n WrapGasTrimNonRefl<3>::commit(gasmod, \"TrimNonRefl3D\", \"Gas-dynamics non-reflective trim (3D).\");\n\n WrapGasTrimSlipWall<2>::commit(gasmod, \"TrimSlipWall2D\", \"Gas-dynamics slip wall trim (2D).\");\n\n WrapGasTrimSlipWall<3>::commit(gasmod, \"TrimSlipWall3D\", \"Gas-dynamics slip wall trim (3D).\");\n\n WrapGasTrimInlet<2>::commit(gasmod, \"TrimInlet2D\", \"Gas-dynamics inlet trim (2D).\");\n\n WrapGasTrimInlet<3>::commit(gasmod, \"TrimInlet3D\", \"Gas-dynamics inlet trim (3D).\");\n\n\n\n return gasmod.ptr();\n\n}\n\n\n\n} /* end namespace python */\n\n\n\n} /* end namespace march */\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/src/python/march_gas.cpp", "rank": 66, "score": 159331.1763804525 }, { "content": " WrapGasSolver<3>::commit(gasmod, \"Solver3D\", \"Gas-dynamics solver (3D).\");\n\n WrapGasCommonAnchor::commit(gasmod, \"CommonAnchor\", \"Gas-dynamics multi-dimensional anchor.\");\n\n WrapGasAnchor<2>::commit(gasmod, \"Anchor2D\", \"Gas-dynamics anchor (2D).\");\n\n WrapGasAnchor<3>::commit(gasmod, \"Anchor3D\", \"Gas-dynamics anchor (3D).\");\n\n WrapGasAnchorChain<2>::commit(gasmod, \"AnchorChain2D\", \"Gas-dynamics sequential container for anchors (2D).\");\n\n WrapGasAnchorChain<3>::commit(gasmod, \"AnchorChain3D\", \"Gas-dynamics sequential container for anchors (3D).\");\n\n WrapGasParameter::commit(gasmod, \"Parameter\", \"Gas-dynamics solver parameters.\");\n\n WrapGasState::commit(gasmod, \"State\", \"Gas-dynamics solver states.\");\n\n WrapGasSolution<2>::commit(gasmod, \"Solution2D\", \"Gas-dynamics solution data (2D).\");\n\n WrapGasSolution<3>::commit(gasmod, \"Solution3D\", \"Gas-dynamics solution data (3D).\");\n\n WrapGasQuantity<2>::commit(gasmod, \"Quantity2D\", \"Gas-dynamics quantities (2D).\");\n\n WrapGasQuantity<3>::commit(gasmod, \"Quantity3D\", \"Gas-dynamics quantities (3D).\");\n\n\n\n // section: boundary-condition treatments\n\n WrapGasTrimBase<gas::TrimBase<2>, 2>::commit(gasmod, \"TrimBase2D\", \"Gas-dynamics trim base type (2D).\");\n\n WrapGasTrimBase<gas::TrimBase<3>, 3>::commit(gasmod, \"TrimBase3D\", \"Gas-dynamics trim base type (3D).\");\n\n WrapGasTrimInterface<2>::commit(gasmod, \"TrimInterface2D\", \"Gas-dynamics interface trim (2D).\");\n\n WrapGasTrimInterface<3>::commit(gasmod, \"TrimInterface3D\", \"Gas-dynamics interface trim (3D).\");\n\n WrapGasTrimNoOp<2>::commit(gasmod, \"TrimNoOp2D\", \"Gas-dynamics no-op trim (2D).\");\n\n WrapGasTrimNoOp<3>::commit(gasmod, \"TrimNoOp3D\", \"Gas-dynamics no-op trim (3D).\");\n", "file_path": "libmarch/src/python/march_gas.cpp", "rank": 67, "score": 159322.67505550434 }, { "content": "#pragma once\n\n\n\n/*\n\n * Copyright (c) 2016, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see LICENSE.txt\n\n */\n\n\n\n#include <stdexcept>\n\n#include <memory>\n\n\n\nnamespace march\n\n{\n\n\n\n/**\n\n * Untyped and unresizeable memory buffer for data storage.\n\n */\n", "file_path": "libmarch/include/march/core/Buffer.hpp", "rank": 68, "score": 159162.63136559582 }, { "content": "#pragma once\n\n\n\n/*\n\n * Copyright (c) 2016, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n/**\n\n * \\file\n\n * Utilities.\n\n */\n\n\n\n#include <utility>\n\n#include <memory>\n\n\n\n#include <cstdio>\n\n#include <sstream>\n\n#include <iostream>\n\n#include <iomanip>\n\n\n", "file_path": "libmarch/include/march/core/utility.hpp", "rank": 69, "score": 159158.41472418632 }, { "content": "#pragma once\n\n\n\n/*\n\n * Copyright (c) 2018, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n/**\n\n * \\file\n\n * Memory facilities.\n\n */\n\n\n\nnamespace march {\n\n\n\n/**\n\n * Mixin to help track the active instance count.\n\n */\n\ntemplate< class T >\n", "file_path": "libmarch/include/march/core/memory.hpp", "rank": 70, "score": 159156.02285743385 }, { "content": "\n\nnamespace detail {\n\n\n\ninline static constexpr size_t log2(size_t n, int k = 0) { return (n <= 1) ? k : log2(n >> 1, k + 1); }\n\n\n\n} /* end namespace detail */\n\n\n\ntemplate<typename ElementType>\n\nvoid fill_sentinel(ElementType *arr, size_t nelem, ElementType sentinel) {\n\n std::fill(arr, arr + nelem, sentinel);\n\n}\n\n\n\ntemplate<typename ElementType>\n\nvoid fill_sentinel(ElementType *arr, size_t nelem) {\n\n if (true == std::is_floating_point<ElementType>::value) {\n\n fill_sentinel(arr, nelem, std::numeric_limits<ElementType>::quiet_NaN());\n\n } else if (true == std::is_arithmetic<ElementType>::value) {\n\n char * carr = reinterpret_cast<char *>(arr);\n\n fill_sentinel(carr, nelem*sizeof(ElementType), static_cast<char>(-1));\n\n } else {\n\n throw std::runtime_error(\"cannot fill sentinel for unsupported type\");\n\n }\n\n}\n\n\n\n} /* end namespace march */\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/include/march/core/utility.hpp", "rank": 71, "score": 159154.70384380504 }, { "content": "#pragma once\n\n\n\n/*\n\n * Copyright (c) 2016, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n#include <array>\n\n#include <string>\n\n\n\n#include \"march/core/types.hpp\"\n\n#include \"march/core/utility.hpp\"\n\n#include \"march/core/string.hpp\"\n\n\n\nnamespace march {\n\n\n\n#pragma GCC diagnostic push\n\n#ifndef __clang__\n\n#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n\n#endif // __clang__\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 72, "score": 159152.18332767588 }, { "content": "#if !defined(_MSC_VER) && !defined(__INTEL_COMPILER)\n\n# if __cplusplus >= 201402L\n\n# define MH_CPP14\n\n# endif\n\n#elif defined(_MSC_VER)\n\n# if _MSVC_LANG >= 201402L\n\n# define MH_CPP14\n\n# endif\n\n#endif\n\n\n\nnamespace march {\n\n\n\n#ifdef MH_CPP14\n\nusing std::make_unique;\n\n#else // MH_CPP14\n\ntemplate<typename T, typename... Args>\n\nstd::unique_ptr<T> make_unique(Args&&... args) {\n\n return std::unique_ptr<T>(new T(std::forward<Args>(args)...));\n\n}\n\n#endif // MH_CPP14\n", "file_path": "libmarch/include/march/core/utility.hpp", "rank": 73, "score": 159150.12373941034 }, { "content": " Buffer(size_t length, const ctor_passkey &) : m_length(length) { m_data = new char[length](); }\n\n\n\n static std::shared_ptr<Buffer> construct(size_t length) {\n\n return std::make_shared<Buffer>(length, ctor_passkey());\n\n }\n\n\n\n ~Buffer() {\n\n if (nullptr != m_data) {\n\n delete[] m_data;\n\n m_data = nullptr;\n\n }\n\n }\n\n\n\n Buffer() = delete;\n\n\n\n Buffer(Buffer const & ) = delete;\n\n\n\n Buffer(Buffer &&) = delete;\n\n\n\n Buffer & operator=(Buffer const & ) = delete;\n", "file_path": "libmarch/include/march/core/Buffer.hpp", "rank": 74, "score": 159149.42237675545 }, { "content": "\n\n Buffer & operator=(Buffer &&) = delete;\n\n\n\n explicit operator bool() const { return nullptr == m_data; }\n\n\n\n size_t nbyte() const { return m_length; }\n\n\n\n template< typename T >\n\n size_t length() const {\n\n size_t result = m_length / sizeof(T);\n\n if (result * sizeof(T) != m_length) {\n\n throw std::length_error(\"length not divisible\");\n\n }\n\n return result;\n\n }\n\n\n\n template< typename T, size_t LENGTH >\n\n T (& array() const) [LENGTH] {\n\n if (LENGTH * sizeof(T) != m_length) {\n\n throw std::length_error(\"array byte count mismatches buffer\");\n", "file_path": "libmarch/include/march/core/Buffer.hpp", "rank": 75, "score": 159147.40391029505 }, { "content": " }\n\n return *reinterpret_cast<T(*)[LENGTH]>(data<T>());\n\n }\n\n\n\n /** Backdoor */\n\n template< typename T >\n\n T * data() const { return reinterpret_cast<T*>(m_data); }\n\n\n\n}; /* end class Buffer */\n\n\n\n} /* end namespace march */\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/include/march/core/Buffer.hpp", "rank": 76, "score": 159146.3538672961 }, { "content": "\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator/(Vector<NDIM> lhs, real_type rhs) { lhs /= rhs; return lhs; }\n\n\n\ninline real_type cross(Vector<2> const & lhs, Vector<2> const & rhs) {\n\n return lhs[0]*rhs[1] - lhs[1]*rhs[0];\n\n}\n\n\n\ninline Vector<3> cross(Vector<3> const & lhs, Vector<3> const & rhs) {\n\n return Vector<3>(lhs[1]*rhs[2] - lhs[2]*rhs[1], lhs[2]*rhs[0] - lhs[0]*rhs[2], lhs[0]*rhs[1] - lhs[1]*rhs[0]);\n\n}\n\n\n\n#pragma GCC diagnostic pop\n\n\n\n} /* end namespace march */\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 77, "score": 159143.64574366156 }, { "content": " }\n\n Vector(real_type v0, real_type v1, real_type v2) : data{v0, v1, v2} {\n\n static_assert(3 == NDIM, \"only valid for 3 dimensional\");\n\n }\n\n Vector(const Vector & other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] = other.data[it]; }\n\n }\n\n Vector(const real_type (&other)[NDIM]) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] = other[it]; }\n\n }\n\n Vector(const real_type * other) { // I don't like this danger.\n\n for (size_t it=0; it<NDIM; ++it) { data[it] = other[it]; }\n\n }\n\n\n\n /* assignment operators */\n\n Vector & operator=(Vector const & other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] = other.data[it]; }\n\n return *this;\n\n }\n\n Vector & operator=(real_type const (&other)[NDIM]) {\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 78, "score": 159135.7699067491 }, { "content": " }\n\n Vector & operator+=(real_type other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] += other; }\n\n return *this;\n\n }\n\n Vector & operator-=(Vector const & other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] -= other.data[it]; }\n\n return *this;\n\n }\n\n Vector & operator-=(real_type other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] -= other; }\n\n return *this;\n\n }\n\n Vector & operator*=(real_type other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] *= other; }\n\n return *this;\n\n }\n\n Vector & operator/=(real_type other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] /= other; }\n\n return *this;\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 79, "score": 159135.68443256494 }, { "content": "\n\n/**\n\n * Cartesian vector in two or three dimensional space.\n\n */\n\ntemplate< size_t NDIM > struct Vector {\n\n\n\n static_assert(2 == NDIM || 3 == NDIM, \"not 2 or 3 dimensional\");\n\n\n\n typedef real_type value_type;\n\n typedef value_type & reference;\n\n typedef const value_type & const_reference;\n\n typedef size_t size_type;\n\n\n\n value_type data[NDIM];\n\n\n\n /* constructors */\n\n Vector() = default;\n\n Vector(real_type v) { for (size_t it=0; it<NDIM; ++it) { data[it] = v; } }\n\n Vector(real_type v0, real_type v1) : data{v0, v1} {\n\n static_assert(2 == NDIM, \"only valid for 2 dimensional\");\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 80, "score": 159135.4749128757 }, { "content": " }\n\n return ret;\n\n}\n\n\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator+(Vector<NDIM> lhs, Vector<NDIM> const & rhs) { lhs += rhs; return lhs; }\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator+(Vector<NDIM> lhs, real_type rhs) { lhs += rhs; return lhs; }\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator+(real_type lhs, Vector<NDIM> rhs) { rhs += lhs; return rhs; }\n\n\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator-(Vector<NDIM> lhs, Vector<NDIM> const & rhs) { lhs -= rhs; return lhs; }\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator-(Vector<NDIM> lhs, real_type rhs) { lhs -= rhs; return lhs; }\n\n\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator*(Vector<NDIM> lhs, real_type rhs) { lhs *= rhs; return lhs; }\n\ntemplate< size_t NDIM >\n\nVector<NDIM> operator*(real_type lhs, Vector<NDIM> rhs) { rhs *= lhs; return rhs; }\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 81, "score": 159134.9192346858 }, { "content": " return true;\n\n }\n\n\n\n /* accessors */\n\n constexpr size_type size() const { return NDIM; }\n\n reference operator[](size_type n) { return data[n]; }\n\n constexpr const_reference operator[](size_type n) const { return data[n]; }\n\n reference at(size_type n) {\n\n if (n < NDIM) { return data[n]; }\n\n else { throw std::out_of_range(string::format(\"Vector%ldD doesn't have %d-th element\", NDIM, n)); }\n\n }\n\n const_reference at(size_type n) const {\n\n if (n < NDIM) { return data[n]; }\n\n else { throw std::out_of_range(string::format(\"Vector%ldD doesn't have %d-th element\", NDIM, n)); }\n\n }\n\n\n\n /* arithmetic operators */\n\n Vector & operator+=(Vector const & other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] += other.data[it]; }\n\n return *this;\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 82, "score": 159134.58035694083 }, { "content": " for (size_t it=0; it<NDIM; ++it) { data[it] = other[it]; }\n\n return *this;\n\n }\n\n Vector & operator=(real_type other) {\n\n for (size_t it=0; it<NDIM; ++it) { data[it] = other; }\n\n return *this;\n\n }\n\n\n\n bool operator==(Vector const & other) {\n\n for (size_t it=0; it<NDIM; ++it) { if (data[it] != other.data[it]) { return false; } }\n\n return true;\n\n }\n\n\n\n bool operator!=(Vector const & other) {\n\n for (size_t it=0; it<NDIM; ++it) { if (data[it] != other.data[it]) { return true; } }\n\n return false;\n\n }\n\n\n\n bool is_close_to(Vector const & other, real_type epsilon) {\n\n for (size_t it=0; it<NDIM; ++it) { if (std::abs(data[it] - other.data[it]) > epsilon) { return false; } }\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 83, "score": 159133.93817301097 }, { "content": " }\n\n real_type dot(Vector const & rhs) const {\n\n if (3 == NDIM) { return this->data[0]*rhs.data[0] + this->data[1]*rhs.data[1] + this->data[2]*rhs.data[2]; }\n\n else { return this->data[0]*rhs.data[0] + this->data[1]*rhs.data[1]; }\n\n }\n\n real_type square() const {\n\n if (3 == NDIM) { return data[0]*data[0] + data[1]*data[1] + data[2]*data[2]; }\n\n else { return data[0]*data[0] + data[1]*data[1]; }\n\n }\n\n real_type length() const { return sqrt(square()); }\n\n\n\n std::string repr(size_t indent=0, size_t precision=0) const;\n\n\n\n}; /* end struct Vector */\n\n\n\ntemplate< size_t NDIM > std::string Vector<NDIM>::repr(size_t, size_t precision) const {\n\n std::string ret(NDIM == 3 ? \"Vector3D(\" : \"Vector2D(\");\n\n for (size_t it=0; it<NDIM; ++it) {\n\n ret += string::from_double(data[it], precision);\n\n ret += NDIM-1 == it ? \")\" : \",\";\n", "file_path": "libmarch/include/march/core/Vector.hpp", "rank": 84, "score": 159132.7513062051 }, { "content": "#pragma once\n\n\n\n/*\n\n * Copyright (c) 2017, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n#include <pybind11/pybind11.h>\n\n\n\nPYBIND11_DECLARE_HOLDER_TYPE(T, std::unique_ptr<T>);\n\nPYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);\n\n\n\n#ifdef __GNUG__\n\n# define MARCH_PYTHON_WRAPPER_VISIBILITY __attribute__((visibility(\"hidden\")))\n\n#else\n\n# define MARCH_PYTHON_WRAPPER_VISIBILITY\n\n#endif\n\n\n\nnamespace march {\n\n\n", "file_path": "libmarch/include/march/python/common.hpp", "rank": 85, "score": 159055.17309650008 }, { "content": "namespace python {\n\n\n\nnamespace py = pybind11;\n\n\n\n} /* end namespace python */\n\n\n\n} /* end namespace march */\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/include/march/python/common.hpp", "rank": 86, "score": 159050.20559797416 }, { "content": "#pragma once\n\n\n\n/*\n\n * Copyright (c) 2016, Yung-Yu Chen <[email protected]>\n\n * BSD 3-Clause License, see COPYING\n\n */\n\n\n\n/**\n\n * \\file\n\n * Basic typedefs and constants for libmarch.\n\n */\n\n\n\n#include <cstdint>\n\n#include <complex>\n\n#include <limits>\n\n\n\n#include \"march/core/utility.hpp\"\n\n\n\nnamespace march\n\n{\n\n\n\n/**\n\n * The enum is compatible to numpy NPY_TYPES.\n\n *\n\n * MH_LONG, MH_ULONG, MH_LONGDOUBLE, MH_CLONGDOUBLE aren't used.\n\n */\n", "file_path": "libmarch/include/march/core/types.hpp", "rank": 87, "score": 159002.43461430227 }, { "content": "template <> struct id_to<MH_FLOAT> { typedef float type; };\n\ntemplate <> struct id_to<MH_DOUBLE> { typedef double type; };\n\ntemplate <> struct id_to<MH_CFLOAT> { typedef std::complex<float> type; };\n\ntemplate <> struct id_to<MH_CDOUBLE> { typedef std::complex<double> type; };\n\n\n\n/**\n\n * The primitive data type for lookup-table indices.\n\n */\n\ntypedef int32_t index_type;\n\nstatic constexpr index_type MH_INDEX_SENTINEL = INT32_MAX;\n\nstatic constexpr index_type INVALID_INDEX = MH_INDEX_SENTINEL;\n\n\n\n/**\n\n * The primitive data type for element shape type. May use only a single byte\n\n * but now take 4 bytes for legacy compatibility.\n\n */\n\ntypedef int32_t shape_type;\n\n\n\ntypedef double real_type;\n\n\n\nconstexpr static real_type MH_REAL_SENTINEL = -std::numeric_limits<real_type>::infinity();\n\n\n\n} /* end namespace march */\n\n\n\n// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4:\n", "file_path": "libmarch/include/march/core/types.hpp", "rank": 88, "score": 158989.81174682803 }, { "content": " return ret;\n\n}\n\n\n\n/**\n\n * Convert type to ID.\n\n */\n\ntemplate <typename type, typename SFINAE = void> struct type_to { };\n\n\n\ntemplate <typename T> struct type_to<T, typename std::enable_if<std::is_integral<T>::value>::type> {\n\nprivate:\n\n constexpr static DataTypeId ids[8] = {\n\n MH_INT8, MH_UINT8, MH_INT16, MH_UINT16,\n\n MH_INT32, MH_UINT32, MH_INT64, MH_UINT64\n\n };\n\npublic:\n\n constexpr static DataTypeId id = ids[detail::log2(sizeof(T)) * 2 + (std::is_unsigned<T>::value ? 1 : 0)];\n\n};\n\n\n\n#define MARCH_DECL_TYPEID(Type, ID) \\\n\n template <> struct type_to<Type> { constexpr static DataTypeId id = ID; };\n", "file_path": "libmarch/include/march/core/types.hpp", "rank": 89, "score": 158985.15979943852 }, { "content": "MARCH_DECL_TYPEID(bool, MH_BOOL)\n\nMARCH_DECL_TYPEID(float, MH_FLOAT)\n\nMARCH_DECL_TYPEID(double, MH_DOUBLE)\n\nMARCH_DECL_TYPEID(std::complex<float>, MH_CFLOAT)\n\nMARCH_DECL_TYPEID(std::complex<double>, MH_CDOUBLE)\n\n#undef MARCH_DECL_TYPEID\n\n\n\n/**\n\n * Convert ID to type.\n\n */\n\ntemplate <int ID> struct id_to { };\n\ntemplate <> struct id_to<MH_BOOL> { typedef bool type; };\n\ntemplate <> struct id_to<MH_INT8> { typedef int8_t type; };\n\ntemplate <> struct id_to<MH_UINT8> { typedef uint8_t type; };\n\ntemplate <> struct id_to<MH_INT16> { typedef int16_t type; };\n\ntemplate <> struct id_to<MH_UINT16> { typedef uint16_t type; };\n\ntemplate <> struct id_to<MH_INT32> { typedef int32_t type; };\n\ntemplate <> struct id_to<MH_UINT32> { typedef uint32_t type; };\n\ntemplate <> struct id_to<MH_INT64> { typedef int64_t type; };\n\ntemplate <> struct id_to<MH_UINT64> { typedef uint64_t type; };\n", "file_path": "libmarch/include/march/core/types.hpp", "rank": 90, "score": 158982.1406521851 }, { "content": "class\n\nMARCH_PYTHON_WRAPPER_VISIBILITY\n\nWrapBoundaryData\n\n : public WrapBase< WrapBoundaryData, BoundaryData >\n\n{\n\n\n\n friend base_type;\n\n\n\n WrapBoundaryData(pybind11::module & mod, const char * pyname, const char * clsdoc)\n\n : base_type(mod, pyname, clsdoc)\n\n {\n\n namespace py = pybind11;\n\n (*this)\n\n .def(\n\n py::init([] (index_type nvalue, const std::string & name) {\n\n return make_unique<BoundaryData>(nvalue, name);\n\n }),\n\n py::arg(\"nvalue\"), py::arg(\"name\")=\"None\"\n\n )\n\n .def_property_readonly_static(\"BFREL\", [](py::object const & /* self */) { return BoundaryData::BFREL; })\n", "file_path": "libmarch/include/march/python/wrapper_mesh.hpp", "rank": 97, "score": 55.72222230413941 }, { "content": "\n\n WrapGasQuantity(pybind11::module & mod, const char * pyname, const char * clsdoc)\n\n : base_type(mod, pyname, clsdoc)\n\n {\n\n namespace py = pybind11;\n\n\n\n#define DECL_MARCH_PYBIND_GAS_QUANTITY_REAL(NAME) \\\n\n .def_property( \\\n\n #NAME, \\\n\n [](wrapped_type const & self ) { return self.NAME(); }, \\\n\n [](wrapped_type & self, real_type val) { return self.NAME() = val; } \\\n\n )\n\n// FIXME: change the properties to be like those of Solution\n\n#define DECL_MARCH_PYBIND_GAS_QUANTITY_ARRAY(NAME, ARR) \\\n\n .def_property( \\\n\n #NAME, \\\n\n [](wrapped_type & qty) { return Table(qty.NAME()).ARR(); }, \\\n\n [](wrapped_type & qty, py::array src) { Table::CopyInto(Table(qty.NAME()).ARR(), src); }, \\\n\n #NAME \" \" #ARR \" array\")\n\n\n", "file_path": "libmarch/include/march/python/wrapper_gas.hpp", "rank": 98, "score": 53.77865210371527 }, { "content": "\n\n friend base_type;\n\n\n\n WrapBlockHand(pybind11::module & mod, const char * pyname, const char * clsdoc)\n\n : base_type(mod, pyname, clsdoc)\n\n {\n\n namespace py = pybind11;\n\n (*this)\n\n .def(\n\n py::init([](block_type & block, index_type index) {\n\n return wrapped_type(block, index);\n\n }),\n\n py::arg(\"block\"), py::arg(\"index\")\n\n )\n\n .def(\"repr\", &wrapped_type::repr, py::arg(\"indent\")=0, py::arg(\"precision\")=0)\n\n .def(\"__repr__\", [](wrapped_type & self){ return self.repr(); })\n\n .def(\"__eq__\", &wrapped_type::operator==)\n\n .def(\n\n \"__hash__\",\n\n [](wrapped_type const & self) {\n", "file_path": "libmarch/include/march/python/wrapper_mesh.hpp", "rank": 99, "score": 52.646649145389404 } ]
C++
cpp/mindalpha/dense_tensor.cpp
mindalpha/MindAlpha
5b6fe017a37238884a6e963fd6b0a1492938e186
#include <string.h> #include <json11.hpp> #include <mindalpha/dense_tensor.h> #include <mindalpha/file_utils.h> #include <mindalpha/tensor_utils.h> namespace mindalpha { void DenseTensor::Init(std::function<void()> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DenseInit" }, { "meta", GetMeta() }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [cb](PSMessage req, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::Dispose(std::function<void()> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DenseDispose" }, { "name", GetMeta().GetName() }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [cb](PSMessage req, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::Push(SmartArray<uint8_t> in, std::function<void()> cb, bool is_value, bool is_state) { const size_t name_hash = GetMeta().GetNameHash(); const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t slice_items = SliceElements(is_state ? GetMeta().GetStateShape() : GetMeta().GetDataShape()); const size_t slice_length = item_size * slice_items; const int num_parts = GetMeta().GetPartitionCount(); json11::Json json = json11::Json::object { { "command", "DensePush" }, { "name", GetMeta().GetName() }, { "is_value", is_value }, { "is_state", is_state }, }; std::string command = json.dump(); std::vector<PSMessage> reqs; reqs.reserve(num_parts); for (int k = 0; k < num_parts; k++) { PSMessage req = std::make_shared<Message>(); req->GetMessageMeta().SetReceiver(ServerRankToNodeId(k)); req->GetMessageMeta().SetBody(command); size_t begin = 0; size_t end = 0; GetMeta().ComputePartitionShapesWithHash(name_hash, k, begin, end, nullptr, nullptr); begin *= slice_length; end *= slice_length; SmartArray<uint8_t> k_in = in.Slice(begin, end); req->AddTypedSlice(k_in, GetMeta().GetDataType()); reqs.push_back(req); } agent_->SendAllRequests(std::move(reqs), [cb](std::vector<PSMessage> reqs, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::Pull(std::function<void(SmartArray<uint8_t> out)> cb, bool is_state) { json11::Json json = json11::Json::object { { "command", "DensePull" }, { "name", GetMeta().GetName() }, { "is_state", is_state }, }; PSMessage req = std::make_shared<Message>(); req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [this, cb, is_state](PSMessage req, std::vector<PSMessage> ress) { const size_t name_hash = GetMeta().GetNameHash(); const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t slice_items = SliceElements(is_state ? GetMeta().GetStateShape() : GetMeta().GetDataShape()); const size_t slice_length = item_size * slice_items; const size_t total_items = TotalElements(is_state ? GetMeta().GetStateShape() : GetMeta().GetDataShape()); const size_t total_length = item_size * total_items; const int num_parts = GetMeta().GetPartitionCount(); SmartArray<uint8_t> out(total_length); for (int k = 0; k < num_parts; k++) { PSMessage res = ress.at(k); SmartArray<uint8_t> k_out = res->GetTypedSlice(0, GetMeta().GetDataType()); const int sender = res->GetMessageMeta().GetSender(); const int rank = NodeIdToRank(sender); size_t begin = 0; size_t end = 0; GetMeta().ComputePartitionShapesWithHash(name_hash, rank, begin, end, nullptr, nullptr); begin *= slice_length; end *= slice_length; memcpy(out.data() + begin, k_out.data(), end - begin); } cb(out); }); } void DenseTensor::PushMeta(const DenseTensorMeta& meta, std::function<void()> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DensePushMeta" }, { "name", GetMeta().GetName() }, { "meta", meta }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [cb](PSMessage req, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::PullMeta(std::function<void (DenseTensorMeta meta)> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DensePullMeta" }, { "name", GetMeta().GetName() }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [this, cb](PSMessage req, std::vector<PSMessage> ress) { for (size_t k = 0; k < ress.size(); k++) { const std::string& body1 = ress.at(0)->GetMessageMeta().GetBody(); const std::string& body2 = ress.at(k)->GetMessageMeta().GetBody(); if (body1 != body2) { const int nodeId1 = ress.at(0)->GetMessageMeta().GetSender(); const int nodeId2 = ress.at(k)->GetMessageMeta().GetSender(); std::string serr; serr.append("Meta of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' on node "); serr.append(NodeIdToString(nodeId1)); serr.append(" and "); serr.append(NodeIdToString(nodeId2)); serr.append(" mismatch.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } } const std::string& body = ress.at(0)->GetMessageMeta().GetBody(); DenseTensorMeta meta = DenseTensorMeta::FromJsonString(body); cb(std::move(meta)); }); } void DenseTensor::Load(const std::string& dir_path, std::function<void()> cb, bool keep_meta) { std::string meta_path = GetDenseMetaPath(dir_path); std::string str = StreamReadAll(meta_path); DenseTensorMeta meta = DenseTensorMeta::FromJsonString(str); if (!meta.IsCompatible(meta_)) { std::string serr; serr.append("Incompatible meta detected in '"); serr.append(meta_path); serr.append("', can not load dense tensor '"); serr.append(GetMeta().GetName()); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } auto push_data_and_state = [this, dir_path, cb] { if (agent_->GetAgentRank() != 0) { cb(); return; } const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t total_items = TotalElements(GetMeta().GetDataShape()); const size_t total_length = item_size * total_items; SmartArray<uint8_t> data(total_length); std::string data_path = GetDenseDataPath(dir_path); if (!data.empty() && LoadAsSArray(data_path, &data) < 0) { std::string serr; serr.append("Fail to load data file of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' from '"); serr.append(data_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } Push(data, [this, dir_path, cb] { if (GetMeta().GetStateShape().empty()) { cb(); return; } const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t total_items = TotalElements(GetMeta().GetStateShape()); const size_t total_length = item_size * total_items; SmartArray<uint8_t> state(total_length); std::string state_path = GetDenseStatePath(dir_path); if (!state.empty() && LoadAsSArray(state_path, &state) < 0) { std::string serr; serr.append("Fail to load state file of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' from '"); serr.append(state_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } Push(state, [cb] { cb(); }, false, true); }, true, false); }; if (!keep_meta) { GetMeta().SetInitializerByData(meta.GetInitializerAsData()); GetMeta().SetUpdaterByData(meta.GetUpdaterAsData()); } if (keep_meta || agent_->GetAgentRank() != 0) push_data_and_state(); else { meta.SetName(GetMeta().GetName()); meta.SetPartitionCount(agent_->GetServerCount()); PushMeta(meta, push_data_and_state); } } void DenseTensor::Save(const std::string& dir_path, std::function<void()> cb) { PullMeta([this, dir_path, cb](DenseTensorMeta meta) { std::string meta_path = GetDenseMetaPath(dir_path); std::string str = meta.ToJsonString(); EnsureLocalDirectory(dir_path); StreamWriteAll(meta_path, str); Pull([this, dir_path, cb](SmartArray<uint8_t> data) { std::string data_path = GetDenseDataPath(dir_path); if (!data.empty() && SaveAsSArray(data_path, data) < 0) { std::string serr; serr.append("Fail to save data file of dense tensor "); serr.append(GetMeta().GetName()); serr.append("' to '"); serr.append(data_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } Pull([this, dir_path, cb](SmartArray<uint8_t> state) { std::string state_path = GetDenseStatePath(dir_path); if (!state.empty() && SaveAsSArray(state_path, state) < 0) { std::string serr; serr.append("Fail to save state file of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' to '"); serr.append(state_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } cb(); }, true); }, false); }); } std::string DenseTensor::GetDenseMetaPath(const std::string& dir_path) const { std::string file_name = fmt::format("{}__dense_meta.json", GetMeta().GetName()); std::string file_path = JoinPath(dir_path, file_name); return file_path; } std::string DenseTensor::GetDenseDataPath(const std::string& dir_path) const { std::string file_name = fmt::format("{}__dense_data.dat", GetMeta().GetName()); std::string file_path = JoinPath(dir_path, file_name); return file_path; } std::string DenseTensor::GetDenseStatePath(const std::string& dir_path) const { std::string file_name = fmt::format("{}__dense_state.dat", GetMeta().GetName()); std::string file_path = JoinPath(dir_path, file_name); return file_path; } }
#include <string.h> #include <json11.hpp> #include <mindalpha/dense_tensor.h> #include <mindalpha/file_utils.h> #include <mindalpha/tensor_utils.h> namespace mindalpha { void DenseTensor::Init(std::function<void()> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DenseInit" }, { "meta", GetMeta() }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [cb](PSMessage req, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::Dispose(std::function<void()> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DenseDispose" }, { "name", GetMeta().GetName() }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [cb](PSMessage req, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::Push(SmartArray<uint8_t> in, std::function<void()> cb, bool is_value, bool is_state) { const size_t name_hash = GetMeta().GetNameHash(); const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t slice_items = SliceElements(is_state ? GetMeta().GetStateShape() : GetMeta().GetDataShape()); const size_t slice_length = item_size * slice_items; const int num_parts = GetMeta().GetPartitionCount(); json11::Json json = json11::Json::object { { "command", "DensePush" }, { "name", GetMeta().GetName() }, { "is_value", is_value }, { "is_state", is_state }, }; std::string command = json.dump(); std::vector<PSMessage> reqs; reqs.reserve(num_parts); for (int k = 0; k < num_parts; k++) { PSMessage req = std::make_shared<Message>(); req->GetMessageMeta().SetReceiver(ServerRankToNodeId(k)); req->GetMessageMeta().SetBody(command); size_t begin = 0; size_t end = 0; GetMeta().ComputePartitionShapesWithHash(name_hash, k, begin, end, nullptr, nullptr); begin *= slice_length; end *= slice_length; SmartArray<uint8_t> k_in = in.Slice(begin, end); req->AddTypedSlice(k_in, GetMeta().GetDataType()); reqs.push_back(req); } agent_->SendAllRequests(std::move(reqs), [cb](std::vector<PSMessage> reqs, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::Pull(std::function<void(SmartArray<uint8_t> out)> cb, bool is_state) { json11::Json json = json11::Json::object { { "command", "DensePull" }, { "name", GetMeta().GetName() }, { "is_state", is_state }, }; PSMessage req = std::make_shared<Message>(); req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [this, cb, is_state](PSMessage req, std::vector<PSMessage> ress) { const size_t name_hash = GetMeta().GetNameHash(); const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t slice_items = SliceElements(is_state ? GetMeta().GetStateShape() : GetMeta().GetDataShape()); const size_t slice_length = item_size * slice_items; const size_t total_items = TotalElements(is_state ? GetMeta().GetStateShape() : GetMeta().GetDataShape()); const size_t total_length = item_size * total_items; const int num_parts = GetMeta().GetPartitionCount(); SmartArray<uint8_t> out(total_length); for (int k = 0; k < num_parts; k++) { PSMessage res = ress.at(k); SmartArray<uint8_t> k_out = res->GetTypedSlice(0, GetMeta().GetDataType()); const int sender = res->GetMessageMeta().GetSender(); const int rank = NodeIdToRank(sender); size_t begin = 0; size_t end = 0; GetMeta().ComputePartitionShapesWithHash(name_hash, rank, begin, end, nullptr, nullptr); begin *= slice_length; end *= slice_length; memcpy(out.data() + begin, k_out.data(), end - begin); } cb(out); }); } void DenseTensor::PushMeta(const DenseTensorMeta& meta, std::function<void()> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DensePushMeta" }, { "name", GetMeta().GetName() }, { "meta", meta }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [cb](PSMessage req, std::vector<PSMessage> ress) { cb(); }); } void DenseTensor::PullMeta(std::function<void (DenseTensorMeta meta)> cb) { PSMessage req = std::make_shared<Message>(); json11::Json json = json11::Json::object { { "command", "DensePullMeta" }, { "name", GetMeta().GetName() }, }; req->GetMessageMeta().SetReceiver(ServerGroup); req->GetMessageMeta().SetBody(json.dump()); agent_->BroadcastRequest(req, [this, cb](PSMessage req, std::vector<PSMessage> ress) { for (size_t k = 0; k < ress.size(); k++) { const std::string& body1 = ress.at(0)->GetMessageMeta().GetBody(); const std::string& body2 = ress.at(k)->GetMessageMeta().GetBody(); if (body1 != body2) { const int nodeId1 = ress.at(0)->GetMessageMeta().GetSender(); const int nodeId2 = ress.at(k)->GetMessageMeta().GetSender(); std::string serr; serr.append("Meta of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' on node "); serr.append(NodeIdToString(nodeId1)); serr.append(" and "); serr.append(NodeIdToString(nodeId2)); serr.append(" mismatch.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } } const std::string& body = ress.at(0)->GetMessageMeta().GetBody(); DenseTensorMeta meta = DenseTensorMeta::FromJsonString(body); cb(std::move(meta)); }); } void DenseTensor::Load(const std::string& dir_path, std::function<void()> cb, bool keep_meta) { std::string meta_path = GetDenseMetaPath(dir_path); std::string str = StreamReadAll(meta_path); DenseTensorMeta meta = DenseTensorMeta::FromJsonString(str); if (!meta.IsCompatible(meta_)) { std::string serr; serr.append("Incompatible meta detected in '"); serr.append(meta_path); serr.append("', can not load dense tensor '"); serr.append(GetMeta().GetName()); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } auto push_data_and_state = [this, dir_path, cb] { if (agent_->GetAgentRank() != 0) { cb(); return; } const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t total_items = TotalElements(GetMeta().GetDataShape()); const size_t total_length = item_size * total_items; SmartArray<uint8_t> data(total_length); std::string data_path = GetDenseDataPath(dir_path); if (!data.empty() && LoadAsSArray(data_path, &data) < 0) { std::string serr; serr.append("Fail to load data file of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' from '"); serr.append(data_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } Push(data, [this, dir_path, cb] { if (GetMeta().GetStateShape().empty()) { cb(); return; } const size_t item_size = DataTypeToSize(GetMeta().GetDataType()); const size_t total_items = TotalElements(GetMeta().GetStateShape()); const size_t total_length = item_size * total_items; SmartArray<uint8_t> state(total_length); std::string state_path = GetDenseStatePath(dir_path); if (!state.empty() && LoadAsSArray(state_path, &state) < 0) { std::string serr; serr.append("Fail to load state file of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' from '"); serr.append(state_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } Push(state, [cb] { cb(); }, false, true); }, true, false); }; if (!keep_meta) { GetMeta().SetInitializerByData(meta.GetInitializerAsData()); GetMeta().SetUpdaterByData(meta.GetUpdaterAsData()); }
} void DenseTensor::Save(const std::string& dir_path, std::function<void()> cb) { PullMeta([this, dir_path, cb](DenseTensorMeta meta) { std::string meta_path = GetDenseMetaPath(dir_path); std::string str = meta.ToJsonString(); EnsureLocalDirectory(dir_path); StreamWriteAll(meta_path, str); Pull([this, dir_path, cb](SmartArray<uint8_t> data) { std::string data_path = GetDenseDataPath(dir_path); if (!data.empty() && SaveAsSArray(data_path, data) < 0) { std::string serr; serr.append("Fail to save data file of dense tensor "); serr.append(GetMeta().GetName()); serr.append("' to '"); serr.append(data_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } Pull([this, dir_path, cb](SmartArray<uint8_t> state) { std::string state_path = GetDenseStatePath(dir_path); if (!state.empty() && SaveAsSArray(state_path, state) < 0) { std::string serr; serr.append("Fail to save state file of dense tensor '"); serr.append(GetMeta().GetName()); serr.append("' to '"); serr.append(state_path); serr.append("'.\n\n"); serr.append(GetStackTrace()); spdlog::error(serr); throw std::runtime_error(serr); } cb(); }, true); }, false); }); } std::string DenseTensor::GetDenseMetaPath(const std::string& dir_path) const { std::string file_name = fmt::format("{}__dense_meta.json", GetMeta().GetName()); std::string file_path = JoinPath(dir_path, file_name); return file_path; } std::string DenseTensor::GetDenseDataPath(const std::string& dir_path) const { std::string file_name = fmt::format("{}__dense_data.dat", GetMeta().GetName()); std::string file_path = JoinPath(dir_path, file_name); return file_path; } std::string DenseTensor::GetDenseStatePath(const std::string& dir_path) const { std::string file_name = fmt::format("{}__dense_state.dat", GetMeta().GetName()); std::string file_path = JoinPath(dir_path, file_name); return file_path; } }
if (keep_meta || agent_->GetAgentRank() != 0) push_data_and_state(); else { meta.SetName(GetMeta().GetName()); meta.SetPartitionCount(agent_->GetServerCount()); PushMeta(meta, push_data_and_state); }
if_condition
[ { "content": "class DenseTensorMeta\n\n{\n\npublic:\n\n const std::string& GetName() const { return name_; }\n\n void SetName(std::string value) { name_ = std::move(value); }\n\n\n\n DataType GetDataType() const { return data_type_; }\n\n void SetDataType(DataType value) { data_type_ = value; }\n\n\n\n const std::vector<size_t>& GetDataShape() const { return data_shape_; }\n\n void SetDataShape(std::vector<size_t> value) { data_shape_ = std::move(value); }\n\n\n\n const std::vector<size_t>& GetStateShape() const { return state_shape_; }\n\n void SetStateShape(std::vector<size_t> value) { state_shape_ = std::move(value); }\n\n\n\n DenseInitializer GetInitializer() const { return initializer_; }\n\n void SetInitializer(DenseInitializer value) { initializer_ = std::move(value); }\n\n\n\n DenseUpdater GetUpdater() const { return updater_; }\n\n void SetUpdater(DenseUpdater value) { updater_ = std::move(value); }\n", "file_path": "cpp/mindalpha/dense_tensor_meta.h", "rank": 0, "score": 137043.0683102511 }, { "content": "namespace mindalpha\n\n{\n\n\n\n//\n\n// Use the X Macro technique to simplify code. See the following page\n\n// for more information about X Macros:\n\n//\n\n// https://en.wikipedia.org/wiki/X_Macro\n\n//\n\n\n\n#define MINDALPHA_NODE_CONTROL_COMMANDS(X) \\\n\n X(Terminate) \\\n\n X(AddNode) \\\n\n X(Barrier) \\\n\n /**/\n\n\n\nenum class NodeControlCommand\n\n{\n\n#undef MINDALPHA_NODE_CONTROL_COMMAND_DEF\n\n#define MINDALPHA_NODE_CONTROL_COMMAND_DEF(n) n,\n\n MINDALPHA_NODE_CONTROL_COMMANDS(MINDALPHA_NODE_CONTROL_COMMAND_DEF)\n\n};\n\n\n\n// A missing ``NodeControlCommand`` is represented by ``NodeControlCommand(-1)``.\n\nconstexpr NodeControlCommand NullNodeControlCommand = static_cast<NodeControlCommand>(-1);\n\nconstexpr const char* NullNodeControlCommandString = \"null\";\n\n\n\n// Functions to convert ``NodeControlCommand`` to and from strings.\n\nstd::string NodeControlCommandToString(NodeControlCommand command);\n\nNodeControlCommand NodeControlCommandFromString(const std::string& str);\n\n\n\nstd::string NullableNodeControlCommandToString(NodeControlCommand command);\n\nNodeControlCommand NullableNodeControlCommandFromString(const std::string& str);\n\n\n", "file_path": "cpp/mindalpha/node_control_command.h", "rank": 1, "score": 120981.43064771511 }, { "content": " def name(self):\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 2, "score": 119853.9328093584 }, { "content": "class SparseTensorMeta\n\n{\n\npublic:\n\n const std::string& GetName() const { return name_; }\n\n void SetName(std::string value) { name_ = std::move(value); }\n\n\n\n DataType GetDataType() const { return data_type_; }\n\n void SetDataType(DataType value) { data_type_ = value; }\n\n\n\n const std::vector<size_t>& GetSliceDataShape() const { return slice_data_shape_; }\n\n void SetSliceDataShape(std::vector<size_t> value) { slice_data_shape_ = std::move(value); }\n\n\n\n const std::vector<size_t>& GetSliceStateShape() const { return slice_state_shape_; }\n\n void SetSliceStateShape(std::vector<size_t> value) { slice_state_shape_ = std::move(value); }\n\n\n\n SparseInitializer GetInitializer() const { return initializer_; }\n\n void SetInitializer(SparseInitializer value) { initializer_ = std::move(value); }\n\n\n\n SparseUpdater GetUpdater() const { return updater_; }\n\n void SetUpdater(SparseUpdater value) { updater_ = std::move(value); }\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.h", "rank": 3, "score": 108505.23685784862 }, { "content": "#include <vector>\n\n#include <functional>\n\n#include <any>\n\n#include <json11.hpp>\n\n#include <mindalpha/data_type.h>\n\n#include <mindalpha/smart_array.h>\n\n#include <mindalpha/string_utils.h>\n\n\n\nnamespace mindalpha\n\n{\n\n\n\nusing DenseInitializer = std::function<void(const std::string& name,\n\n SmartArray<uint8_t> data,\n\n const class DenseTensorMeta& meta)>;\n\n\n\nusing DenseUpdater = std::function<void(const std::string& name,\n\n SmartArray<uint8_t> param,\n\n SmartArray<uint8_t> grad,\n\n SmartArray<uint8_t> state,\n\n const class DenseTensorMeta& meta)>;\n\n\n", "file_path": "cpp/mindalpha/dense_tensor_meta.h", "rank": 4, "score": 94261.35003564467 }, { "content": " std::string GetUpdaterAsData() const;\n\n\n\n std::string ToString() const;\n\n std::string ToJsonString() const;\n\n json11::Json to_json() const;\n\n\n\n static DenseTensorMeta FromJsonString(const std::string& str);\n\n static DenseTensorMeta FromJson(json11::Json json);\n\n\n\n bool IsCompatible(const DenseTensorMeta& rhs) const;\n\n\n\n bool operator==(const DenseTensorMeta& rhs) const;\n\n bool operator!=(const DenseTensorMeta& rhs) const { return !(*this == rhs); }\n\n\n\nprivate:\n\n std::string name_;\n\n DataType data_type_ = NullDataType;\n\n std::vector<size_t> data_shape_;\n\n std::vector<size_t> state_shape_;\n\n DenseInitializer initializer_;\n\n DenseUpdater updater_;\n\n std::any initializer_object_;\n\n std::any updater_object_;\n\n int partition_count_ = -1;\n\n};\n\n\n\n}\n", "file_path": "cpp/mindalpha/dense_tensor_meta.h", "rank": 5, "score": 94258.89443701657 }, { "content": " std::string ToJsonString() const;\n\n json11::Json to_json() const;\n\n\n\n static SparseTensorMeta FromJsonString(const std::string& str);\n\n static SparseTensorMeta FromJson(json11::Json json);\n\n\n\n bool IsCompatible(const SparseTensorMeta& rhs) const;\n\n bool IsCompatibleRelaxed(const SparseTensorMeta& rhs, bool data_only) const;\n\n\n\n bool operator==(const SparseTensorMeta& rhs) const;\n\n bool operator!=(const SparseTensorMeta& rhs) const { return !(*this == rhs); }\n\n\n\nprivate:\n\n std::string name_;\n\n DataType data_type_ = NullDataType;\n\n std::vector<size_t> slice_data_shape_;\n\n std::vector<size_t> slice_state_shape_;\n\n SparseInitializer initializer_;\n\n SparseUpdater updater_;\n\n std::any initializer_object_;\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.h", "rank": 6, "score": 94257.99943043414 }, { "content": "#include <vector>\n\n#include <functional>\n\n#include <any>\n\n#include <json11.hpp>\n\n#include <mindalpha/data_type.h>\n\n#include <mindalpha/smart_array.h>\n\n\n\nnamespace mindalpha\n\n{\n\n\n\nusing SparseInitializer = std::function<void(const std::string& name,\n\n SmartArray<uint8_t> data,\n\n SmartArray<uint8_t> keys,\n\n const class SparseTensorMeta& meta)>;\n\n\n\nusing SparseUpdater = std::function<void(const std::string& name,\n\n SmartArray<uint8_t> param,\n\n SmartArray<uint8_t> grad,\n\n SmartArray<uint8_t> indices,\n\n SmartArray<uint8_t> keys,\n\n const class SparseTensorMeta& meta)>;\n\n\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.h", "rank": 7, "score": 94257.5904482217 }, { "content": "\n\n int GetPartitionCount() const { return partition_count_; }\n\n void SetPartitionCount(int value) { partition_count_ = value; }\n\n\n\n void CheckDenseTensorMeta(int index) const;\n\n\n\n void ComputePartitionShapesWithHash(size_t hash, int index, size_t& begin, size_t& end,\n\n std::vector<size_t>* partition_data_shape,\n\n std::vector<size_t>* partition_state_shape) const;\n\n\n\n void ComputePartitionShapes(int index, size_t& begin, size_t& end,\n\n std::vector<size_t>* partition_data_shape,\n\n std::vector<size_t>* partition_state_shape) const;\n\n\n\n size_t GetNameHash() const { return BKDRHash(name_); }\n\n\n\n void SetInitializerByData(std::string data);\n\n void SetUpdaterByData(std::string data);\n\n\n\n std::string GetInitializerAsData() const;\n", "file_path": "cpp/mindalpha/dense_tensor_meta.h", "rank": 8, "score": 94255.1447154551 }, { "content": "\n\n int GetPartitionCount() const { return partition_count_; }\n\n void SetPartitionCount(int value) { partition_count_ = value; }\n\n\n\n void CheckSparseTensorMeta(int index) const;\n\n void ComputeSliceInfo();\n\n\n\n size_t GetSliceDataLength() const { return slice_data_length_; }\n\n size_t GetSliceStateLength() const { return slice_state_length_; }\n\n size_t GetSliceAgeOffset() const { return slice_age_offset_; }\n\n size_t GetSliceTotalBytes() const { return slice_total_bytes_; }\n\n size_t GetSliceDataStateBytes() const { return GetSliceAgeOffset(); }\n\n\n\n void SetInitializerByData(std::string data);\n\n void SetUpdaterByData(std::string data);\n\n\n\n std::string GetInitializerAsData() const;\n\n std::string GetUpdaterAsData() const;\n\n\n\n std::string ToString() const;\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.h", "rank": 9, "score": 94248.36119122537 }, { "content": " std::any updater_object_;\n\n int partition_count_ = -1;\n\n size_t slice_data_length_ = size_t(-1);\n\n size_t slice_state_length_ = size_t(-1);\n\n size_t slice_age_offset_ = size_t(-1);\n\n size_t slice_total_bytes_ = size_t(-1);\n\n};\n\n\n\n}\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.h", "rank": 10, "score": 94237.51614977562 }, { "content": "//\n\n// Copyright 2021 Mobvista\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n\n\n#pragma once\n\n\n\n#include <stdint.h>\n\n#include <string>\n", "file_path": "cpp/mindalpha/dense_tensor_meta.h", "rank": 11, "score": 94230.50846983212 }, { "content": "//\n\n// Copyright 2021 Mobvista\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n\n\n#pragma once\n\n\n\n#include <stdint.h>\n\n#include <string>\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.h", "rank": 12, "score": 94230.50846983212 }, { "content": "\n\nnamespace mindalpha\n\n{\n\n\n\nstd::string NodeControlCommandToString(NodeControlCommand command)\n\n{\n\n switch (command)\n\n {\n\n#undef MINDALPHA_NODE_CONTROL_COMMAND_DEF\n\n#define MINDALPHA_NODE_CONTROL_COMMAND_DEF(n) case NodeControlCommand::n: return #n;\n\n MINDALPHA_NODE_CONTROL_COMMANDS(MINDALPHA_NODE_CONTROL_COMMAND_DEF)\n\n default:\n\n std::string serr;\n\n serr.append(\"Invalid NodeControlCommand enum value: \");\n\n serr.append(std::to_string(static_cast<int>(command)));\n\n serr.append(\".\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n", "file_path": "cpp/mindalpha/node_control_command.cpp", "rank": 13, "score": 92677.97463280222 }, { "content": "}\n\n\n\nNodeControlCommand NodeControlCommandFromString(const std::string& str)\n\n{\n\n#undef MINDALPHA_NODE_CONTROL_COMMAND_DEF\n\n#define MINDALPHA_NODE_CONTROL_COMMAND_DEF(n) if (str == #n) return NodeControlCommand::n;\n\n MINDALPHA_NODE_CONTROL_COMMANDS(MINDALPHA_NODE_CONTROL_COMMAND_DEF)\n\n std::string serr;\n\n serr.append(\"Invalid NodeControlCommand enum value: \");\n\n serr.append(str);\n\n serr.append(\".\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n}\n\n\n\nstd::string NullableNodeControlCommandToString(NodeControlCommand command)\n\n{\n\n if (command == NullNodeControlCommand)\n\n return NullNodeControlCommandString;\n", "file_path": "cpp/mindalpha/node_control_command.cpp", "rank": 14, "score": 92676.7876888065 }, { "content": " return NodeControlCommandToString(command);\n\n}\n\n\n\nNodeControlCommand NullableNodeControlCommandFromString(const std::string& str)\n\n{\n\n if (str == NullNodeControlCommandString)\n\n return NullNodeControlCommand;\n\n return NodeControlCommandFromString(str);\n\n}\n\n\n\n}\n", "file_path": "cpp/mindalpha/node_control_command.cpp", "rank": 15, "score": 92668.34049937388 }, { "content": "//\n\n// Copyright 2021 Mobvista\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n\n\n#include <stdexcept>\n\n#include <spdlog/spdlog.h>\n\n#include <mindalpha/node_control_command.h>\n\n#include <mindalpha/stack_trace_utils.h>\n", "file_path": "cpp/mindalpha/node_control_command.cpp", "rank": 16, "score": 92665.72327975839 }, { "content": " def _load_tensor(self, dir_path, *, keep_meta=False):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def load_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n self._handle.load(dir_path, load_tensor_done, keep_meta)\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 17, "score": 92428.73178062242 }, { "content": "#include <mindalpha/dense_tensor_meta.h>\n\n#include <mindalpha/stack_trace_utils.h>\n\n\n\nnamespace mindalpha\n\n{\n\n\n\nvoid DenseTensorMeta::CheckDenseTensorMeta(int index) const\n\n{\n\n if (GetName().empty())\n\n {\n\n std::string serr;\n\n serr.append(\"Can not compute dense tensor partition shapes, \");\n\n serr.append(\"as the name is empty.\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n const int n = GetPartitionCount();\n\n if (n <= 0)\n\n {\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 18, "score": 91462.87682499735 }, { "content": "#include <mindalpha/sparse_tensor_meta.h>\n\n#include <mindalpha/stack_trace_utils.h>\n\n\n\nnamespace mindalpha\n\n{\n\n\n\nvoid SparseTensorMeta::CheckSparseTensorMeta(int index) const\n\n{\n\n if (GetName().empty())\n\n {\n\n std::string serr;\n\n serr.append(\"Can not compute sparse tensor slice support info, \");\n\n serr.append(\"as the name is empty.\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n const int n = GetPartitionCount();\n\n if (n <= 0)\n\n {\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 19, "score": 91462.71136761784 }, { "content": " {\n\n { \"name\", name_ },\n\n { \"data_type\", NullableDataTypeToString(data_type_) },\n\n { \"data_shape\", ShapeToString(data_shape_) },\n\n { \"state_shape\", ShapeToString(state_shape_) },\n\n { \"initializer_data\", GetInitializerAsData() },\n\n { \"updater_data\", GetUpdaterAsData() },\n\n { \"partition_count\", partition_count_ },\n\n };\n\n}\n\n\n\nDenseTensorMeta DenseTensorMeta::FromJsonString(const std::string& str)\n\n{\n\n std::string err;\n\n json11::Json json = json11::Json::parse(str, err);\n\n if (!err.empty())\n\n {\n\n std::string serr;\n\n serr.append(\"Unable to create DenseTensorMeta from JSON string; str: \");\n\n serr.append(str);\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 20, "score": 91460.94176224488 }, { "content": " serr.append(\", err: \");\n\n serr.append(err);\n\n serr.append(\".\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n return FromJson(std::move(json));\n\n}\n\n\n\nDenseTensorMeta DenseTensorMeta::FromJson(json11::Json json)\n\n{\n\n DenseTensorMeta meta;\n\n meta.SetName(json[\"name\"].string_value());\n\n meta.SetDataType(DataTypeFromString(json[\"data_type\"].string_value()));\n\n meta.SetDataShape(ShapeFromString(json[\"data_shape\"].string_value()));\n\n meta.SetStateShape(ShapeFromString(json[\"state_shape\"].string_value()));\n\n meta.SetInitializerByData(json[\"initializer_data\"].string_value());\n\n meta.SetUpdaterByData(json[\"updater_data\"].string_value());\n\n meta.SetPartitionCount(json[\"partition_count\"].int_value());\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 21, "score": 91459.15178321234 }, { "content": " meta.SetName(json[\"name\"].string_value());\n\n meta.SetDataType(DataTypeFromString(json[\"data_type\"].string_value()));\n\n meta.SetSliceDataShape(ShapeFromString(json[\"slice_data_shape\"].string_value()));\n\n meta.SetSliceStateShape(ShapeFromString(json[\"slice_state_shape\"].string_value()));\n\n meta.SetInitializerByData(json[\"initializer_data\"].string_value());\n\n meta.SetUpdaterByData(json[\"updater_data\"].string_value());\n\n meta.SetPartitionCount(json[\"partition_count\"].int_value());\n\n meta.ComputeSliceInfo();\n\n return meta;\n\n}\n\n\n\nbool SparseTensorMeta::IsCompatible(const SparseTensorMeta& rhs) const\n\n{\n\n return data_type_ == rhs.data_type_\n\n && slice_data_shape_ == rhs.slice_data_shape_\n\n && slice_state_shape_ == rhs.slice_state_shape_;\n\n}\n\n\n\nbool SparseTensorMeta::IsCompatibleRelaxed(const SparseTensorMeta& rhs, bool data_only) const\n\n{\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 22, "score": 91458.90764054922 }, { "content": "{\n\n return to_json().dump();\n\n}\n\n\n\njson11::Json SparseTensorMeta::to_json() const\n\n{\n\n return json11::Json::object\n\n {\n\n { \"name\", name_ },\n\n { \"data_type\", NullableDataTypeToString(data_type_) },\n\n { \"slice_data_shape\", ShapeToString(slice_data_shape_) },\n\n { \"slice_state_shape\", ShapeToString(slice_state_shape_) },\n\n { \"initializer_data\", GetInitializerAsData() },\n\n { \"updater_data\", GetUpdaterAsData() },\n\n { \"partition_count\", partition_count_ },\n\n };\n\n}\n\n\n\nSparseTensorMeta SparseTensorMeta::FromJsonString(const std::string& str)\n\n{\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 23, "score": 91456.34642857032 }, { "content": " const size_t hash = GetNameHash();\n\n ComputePartitionShapesWithHash(hash, index, begin, end,\n\n partition_data_shape, partition_state_shape);\n\n}\n\n\n\nvoid DenseTensorMeta::SetInitializerByData(std::string data)\n\n{\n\n namespace py = pybind11;\n\n using namespace py::literals;\n\n if (data.empty())\n\n {\n\n initializer_ = {};\n\n initializer_object_ = {};\n\n }\n\n else\n\n {\n\n py::gil_scoped_acquire gil;\n\n py::object obj = mindalpha::deserialize_pyobject(data);\n\n MakeInitializerReady(obj);\n\n std::shared_ptr<py::object> func = mindalpha::make_shared_pyobject(obj);\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 24, "score": 91455.24518572514 }, { "content": " return meta;\n\n}\n\n\n\nbool DenseTensorMeta::IsCompatible(const DenseTensorMeta& rhs) const\n\n{\n\n return data_type_ == rhs.data_type_\n\n && data_shape_ == rhs.data_shape_\n\n && state_shape_ == rhs.state_shape_;\n\n}\n\n\n\nbool DenseTensorMeta::operator==(const DenseTensorMeta& rhs) const\n\n{\n\n return name_ == rhs.name_\n\n && data_type_ == rhs.data_type_\n\n && data_shape_ == rhs.data_shape_\n\n && state_shape_ == rhs.state_shape_\n\n && GetInitializerAsData() == rhs.GetInitializerAsData()\n\n && GetUpdaterAsData() == rhs.GetUpdaterAsData()\n\n && partition_count_ == rhs.partition_count_;\n\n}\n\n\n\n}\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 25, "score": 91453.59342159057 }, { "content": " initializer_ = [func](const std::string& name,\n\n mindalpha::SmartArray<uint8_t> data,\n\n const DenseTensorMeta& meta)\n\n {\n\n py::gil_scoped_acquire gil;\n\n py::array data_arr = mindalpha::make_numpy_array(data, meta.data_type_);\n\n py::tuple data_shape(meta.data_shape_.size());\n\n for (size_t i = 0; i < meta.data_shape_.size(); i++)\n\n data_shape[i] = (i == 0) ? -1 : static_cast<int64_t>(meta.data_shape_.at(i));\n\n data_arr = data_arr.attr(\"reshape\")(data_shape);\n\n (*func)(\"name\"_a=name, \"data\"_a=data_arr, \"keys\"_a=py::none());\n\n };\n\n initializer_object_ = std::move(func);\n\n }\n\n}\n\n\n\nvoid DenseTensorMeta::SetUpdaterByData(std::string data)\n\n{\n\n namespace py = pybind11;\n\n using namespace py::literals;\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 26, "score": 91453.57559213898 }, { "content": " begin = avg_items * i + std::min(i, remainder);\n\n end = begin + my_items;\n\n if (partition_data_shape)\n\n {\n\n *partition_data_shape = GetDataShape();\n\n partition_data_shape->at(0) = end - begin;\n\n }\n\n if (partition_state_shape)\n\n {\n\n *partition_state_shape = GetStateShape();\n\n if (!GetStateShape().empty())\n\n partition_state_shape->at(0) = end - begin;\n\n }\n\n}\n\n\n\nvoid DenseTensorMeta::ComputePartitionShapes(\n\n int index, size_t& begin, size_t& end,\n\n std::vector<size_t>* partition_data_shape,\n\n std::vector<size_t>* partition_state_shape) const\n\n{\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 27, "score": 91452.77641736313 }, { "content": " state_arr = state_arr.attr(\"reshape\")(state_shape);\n\n (*func)(\"name\"_a=name, \"param\"_a=param_arr, \"grad\"_a=grad_arr,\n\n \"state\"_a=state_arr, \"indices\"_a=py::none(), \"keys\"_a=py::none());\n\n }\n\n };\n\n updater_object_ = std::move(func);\n\n }\n\n}\n\n\n\nstd::string DenseTensorMeta::GetInitializerAsData() const\n\n{\n\n pybind11::gil_scoped_acquire gil;\n\n if (!initializer_object_.has_value())\n\n return {};\n\n auto func = std::any_cast<std::shared_ptr<pybind11::object>>(initializer_object_);\n\n return mindalpha::serialize_pyobject(*func);\n\n}\n\n\n\nstd::string DenseTensorMeta::GetUpdaterAsData() const\n\n{\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 28, "score": 91451.79531416223 }, { "content": " serr.append(\"].\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n}\n\n\n\nvoid DenseTensorMeta::ComputePartitionShapesWithHash(\n\n size_t hash, int index, size_t& begin, size_t& end,\n\n std::vector<size_t>* partition_data_shape,\n\n std::vector<size_t>* partition_state_shape) const\n\n{\n\n size_t m = GetDataShape().at(0);\n\n size_t n = GetPartitionCount();\n\n size_t i = index;\n\n size_t h = hash;\n\n i = (i + h) % n;\n\n size_t my_items = (m + n - 1 - i) / n;\n\n size_t avg_items = m / n;\n\n size_t remainder = m % n;\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 29, "score": 91451.67751319871 }, { "content": " std::string err;\n\n json11::Json json = json11::Json::parse(str, err);\n\n if (!err.empty())\n\n {\n\n std::string serr;\n\n serr.append(\"Unable to create SparseTensorMeta from JSON string; str: \");\n\n serr.append(str);\n\n serr.append(\", err: \");\n\n serr.append(err);\n\n serr.append(\".\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n return FromJson(std::move(json));\n\n}\n\n\n\nSparseTensorMeta SparseTensorMeta::FromJson(json11::Json json)\n\n{\n\n SparseTensorMeta meta;\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 30, "score": 91451.53731241683 }, { "content": " serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n}\n\n\n\nvoid SparseTensorMeta::ComputeSliceInfo()\n\n{\n\n const size_t item_size = DataTypeToSize(data_type_);\n\n slice_data_length_ = item_size * TotalElements(slice_data_shape_);\n\n slice_state_length_ = item_size * TotalElements(slice_state_shape_);\n\n const size_t age_offset = slice_data_length_ + slice_state_length_;\n\n const size_t age_size = std::max(item_size, sizeof(int));\n\n const size_t age_mask = age_size - 1;\n\n slice_age_offset_ = (age_offset + age_mask) & ~age_mask;\n\n slice_total_bytes_ = slice_age_offset_ + age_size;\n\n}\n\n\n\nvoid SparseTensorMeta::SetInitializerByData(std::string data)\n\n{\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 31, "score": 91451.0353985987 }, { "content": " return {};\n\n auto func = std::any_cast<std::shared_ptr<pybind11::object>>(initializer_object_);\n\n return mindalpha::serialize_pyobject(*func);\n\n}\n\n\n\nstd::string SparseTensorMeta::GetUpdaterAsData() const\n\n{\n\n pybind11::gil_scoped_acquire gil;\n\n if (!updater_object_.has_value())\n\n return {};\n\n auto func = std::any_cast<std::shared_ptr<pybind11::object>>(updater_object_);\n\n return mindalpha::serialize_pyobject(*func);\n\n}\n\n\n\nstd::string SparseTensorMeta::ToString() const\n\n{\n\n return ToJsonString();\n\n}\n\n\n\nstd::string SparseTensorMeta::ToJsonString() const\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 32, "score": 91450.26490529186 }, { "content": " if (!data_only)\n\n return IsCompatible(rhs);\n\n return data_type_ == rhs.data_type_\n\n && slice_data_shape_ == rhs.slice_data_shape_;\n\n}\n\n\n\nbool SparseTensorMeta::operator==(const SparseTensorMeta& rhs) const\n\n{\n\n return name_ == rhs.name_\n\n && data_type_ == rhs.data_type_\n\n && slice_data_shape_ == rhs.slice_data_shape_\n\n && slice_state_shape_ == rhs.slice_state_shape_\n\n && GetInitializerAsData() == rhs.GetInitializerAsData()\n\n && GetUpdaterAsData() == rhs.GetUpdaterAsData()\n\n && partition_count_ == rhs.partition_count_;\n\n}\n\n\n\n}\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 33, "score": 91449.89845983424 }, { "content": " namespace py = pybind11;\n\n using namespace py::literals;\n\n if (data.empty())\n\n {\n\n initializer_ = {};\n\n initializer_object_ = {};\n\n }\n\n else\n\n {\n\n py::gil_scoped_acquire gil;\n\n py::object obj = mindalpha::deserialize_pyobject(data);\n\n MakeInitializerReady(obj);\n\n std::shared_ptr<py::object> func = mindalpha::make_shared_pyobject(obj);\n\n initializer_ = [func](const std::string& name,\n\n mindalpha::SmartArray<uint8_t> data,\n\n mindalpha::SmartArray<uint8_t> keys,\n\n const SparseTensorMeta& meta)\n\n {\n\n {\n\n py::gil_scoped_acquire gil;\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 34, "score": 91449.07627067118 }, { "content": " mindalpha::SmartArray<uint8_t> grad_clone = grad.Copy();\n\n py::gil_scoped_acquire gil;\n\n py::array param_arr = mindalpha::make_numpy_array(param, meta.data_type_);\n\n py::array grad_arr = mindalpha::make_numpy_array(grad_clone, meta.data_type_);\n\n py::tuple data_shape(meta.data_shape_.size());\n\n for (size_t i = 0; i < meta.data_shape_.size(); i++)\n\n data_shape[i] = (i == 0) ? -1 : static_cast<int64_t>(meta.data_shape_.at(i));\n\n param_arr = param_arr.attr(\"reshape\")(data_shape);\n\n grad_arr = grad_arr.attr(\"reshape\")(data_shape);\n\n if (meta.state_shape_.empty())\n\n {\n\n (*func)(\"name\"_a=name, \"param\"_a=param_arr, \"grad\"_a=grad_arr,\n\n \"state\"_a=py::none(), \"indices\"_a=py::none(), \"keys\"_a=py::none());\n\n }\n\n else\n\n {\n\n py::array state_arr = mindalpha::make_numpy_array(state, meta.data_type_);\n\n py::tuple state_shape(meta.state_shape_.size());\n\n for (size_t i = 0; i < meta.state_shape_.size(); i++)\n\n state_shape[i] = (i == 0) ? -1 : static_cast<int64_t>(meta.state_shape_.at(i));\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 35, "score": 91448.58609957375 }, { "content": " pybind11::gil_scoped_acquire gil;\n\n if (!updater_object_.has_value())\n\n return {};\n\n auto func = std::any_cast<std::shared_ptr<pybind11::object>>(updater_object_);\n\n return mindalpha::serialize_pyobject(*func);\n\n}\n\n\n\nstd::string DenseTensorMeta::ToString() const\n\n{\n\n return ToJsonString();\n\n}\n\n\n\nstd::string DenseTensorMeta::ToJsonString() const\n\n{\n\n return to_json().dump();\n\n}\n\n\n\njson11::Json DenseTensorMeta::to_json() const\n\n{\n\n return json11::Json::object\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 36, "score": 91447.62549574758 }, { "content": " py::slice data_slice(0, data_cols, 1);\n\n py::tuple data_subscript = py::make_tuple(py::ellipsis(), data_slice);\n\n py::array data_arr = blob_arr[data_subscript];\n\n py::tuple data_shape(1 + meta.slice_data_shape_.size());\n\n data_shape[0] = -1;\n\n for (size_t i = 0; i < meta.slice_data_shape_.size(); i++)\n\n data_shape[1 + i] = static_cast<int64_t>(meta.slice_data_shape_.at(i));\n\n data_arr = data_arr.attr(\"reshape\")(data_shape);\n\n py::array grad_arr = mindalpha::make_numpy_array(grad_clone, meta.data_type_);\n\n grad_arr = grad_arr.attr(\"reshape\")(data_shape);\n\n py::array indices_arr = mindalpha::make_numpy_array(indices, mindalpha::DataType::UInt64);\n\n py::array keys_arr = mindalpha::make_numpy_array(keys, mindalpha::DataType::UInt64);\n\n if (meta.slice_state_shape_.empty())\n\n {\n\n (*func)(\"name\"_a=name, \"param\"_a=data_arr, \"grad\"_a=grad_arr,\n\n \"state\"_a=py::none(), \"indices\"_a=indices_arr, \"keys\"_a=keys_arr);\n\n }\n\n else\n\n {\n\n const size_t state_cols = meta.slice_state_length_ / item_size;\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 37, "score": 91447.41545511539 }, { "content": " memset(slice_ptr + meta.slice_data_length_, 0, meta.slice_total_bytes_ - meta.slice_data_length_);\n\n slice_ptr += meta.slice_total_bytes_;\n\n }\n\n };\n\n initializer_object_ = std::move(func);\n\n }\n\n}\n\n\n\nvoid SparseTensorMeta::SetUpdaterByData(std::string data)\n\n{\n\n namespace py = pybind11;\n\n using namespace py::literals;\n\n if (data.empty())\n\n {\n\n updater_ = {};\n\n updater_object_ = {};\n\n }\n\n else\n\n {\n\n py::gil_scoped_acquire gil;\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 38, "score": 91446.60909096469 }, { "content": " if (data.empty())\n\n {\n\n updater_ = {};\n\n updater_object_ = {};\n\n }\n\n else\n\n {\n\n py::gil_scoped_acquire gil;\n\n py::object obj = mindalpha::deserialize_pyobject(data);\n\n MakeUpdaterReady(obj);\n\n std::shared_ptr<py::object> func = mindalpha::make_shared_pyobject(obj);\n\n updater_ = [func](const std::string& name,\n\n mindalpha::SmartArray<uint8_t> param,\n\n mindalpha::SmartArray<uint8_t> grad,\n\n mindalpha::SmartArray<uint8_t> state,\n\n const DenseTensorMeta& meta)\n\n {\n\n // Some PyTorch operations such as ``grad.clone()`` and ``XXX + grad``\n\n // require memory alignment, we use ``SmartArray::Copy`` to use GLIBC allocated\n\n // memory which is 16 bytes aligned.\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 39, "score": 91446.2924018183 }, { "content": " {\n\n std::string serr;\n\n serr.append(\"Can not compute partition shapes for dense tensor '\");\n\n serr.append(GetName());\n\n serr.append(\"', as the tensor state shape [\");\n\n for (size_t i = 0; i < GetStateShape().size(); i++)\n\n {\n\n serr.append(i ? \", \" : \"\");\n\n serr.append(std::to_string(GetStateShape().at(i)));\n\n }\n\n serr.append(\"] is invalid; partition_count = \");\n\n serr.append(std::to_string(GetPartitionCount()));\n\n serr.append(\", partition_index = \");\n\n serr.append(std::to_string(index));\n\n serr.append(\", shape = [\");\n\n for (size_t i = 0; i < GetDataShape().size(); i++)\n\n {\n\n serr.append(i ? \", \" : \"\");\n\n serr.append(std::to_string(GetDataShape().at(i)));\n\n }\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 40, "score": 91446.26150067018 }, { "content": " py::slice state_slice(data_cols, data_cols + state_cols, 1);\n\n py::tuple state_subscript = py::make_tuple(py::ellipsis(), state_slice);\n\n py::array state_arr = blob_arr[state_subscript];\n\n py::tuple state_shape(1 + meta.slice_state_shape_.size());\n\n state_shape[0] = -1;\n\n for (size_t i = 0; i < meta.slice_state_shape_.size(); i++)\n\n state_shape[1 + i] = static_cast<int64_t>(meta.slice_state_shape_.at(i));\n\n state_arr = state_arr.attr(\"reshape\")(state_shape);\n\n (*func)(\"name\"_a=name, \"param\"_a=data_arr, \"grad\"_a=grad_arr,\n\n \"state\"_a=state_arr, \"indices\"_a=indices_arr, \"keys\"_a=keys_arr);\n\n }\n\n };\n\n updater_object_ = std::move(func);\n\n }\n\n}\n\n\n\nstd::string SparseTensorMeta::GetInitializerAsData() const\n\n{\n\n pybind11::gil_scoped_acquire gil;\n\n if (!initializer_object_.has_value())\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 41, "score": 91446.14403030487 }, { "content": " {\n\n std::string serr;\n\n serr.append(\"Can not compute partition shapes for dense tensor '\");\n\n serr.append(GetName());\n\n serr.append(\"', as the tensor data shape [\");\n\n for (size_t i = 0; i < GetDataShape().size(); i++)\n\n {\n\n serr.append(i ? \", \" : \"\");\n\n serr.append(std::to_string(GetDataShape().at(i)));\n\n }\n\n serr.append(\"] is invalid; partition_count = \");\n\n serr.append(std::to_string(GetPartitionCount()));\n\n serr.append(\", partition_index = \");\n\n serr.append(std::to_string(index));\n\n serr.append(\".\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n if (!GetStateShape().empty() && GetStateShape().at(0) != m)\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 42, "score": 91445.99452441961 }, { "content": " py::object obj = mindalpha::deserialize_pyobject(data);\n\n MakeUpdaterReady(obj);\n\n std::shared_ptr<py::object> func = mindalpha::make_shared_pyobject(obj);\n\n updater_ = [func](const std::string& name,\n\n mindalpha::SmartArray<uint8_t> param,\n\n mindalpha::SmartArray<uint8_t> grad,\n\n mindalpha::SmartArray<uint8_t> indices,\n\n mindalpha::SmartArray<uint8_t> keys,\n\n const SparseTensorMeta& meta)\n\n {\n\n // Some PyTorch operations such as ``grad.clone()`` and ``XXX + grad``\n\n // require memory alignment, we use ``SmartArray::Copy`` to use GLIBC allocated\n\n // memory which is 16 bytes aligned.\n\n mindalpha::SmartArray<uint8_t> grad_clone = grad.Copy();\n\n py::gil_scoped_acquire gil;\n\n const size_t item_size = mindalpha::DataTypeToSize(meta.data_type_);\n\n const size_t cols = meta.slice_total_bytes_ / item_size;\n\n const size_t data_cols = meta.slice_data_length_ / item_size;\n\n py::array blob_arr = mindalpha::make_numpy_array(param, meta.data_type_);\n\n blob_arr = blob_arr.attr(\"reshape\")(-1, cols);\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 43, "score": 91444.29731075646 }, { "content": " const size_t item_size = mindalpha::DataTypeToSize(meta.data_type_);\n\n const size_t cols = meta.slice_total_bytes_ / item_size;\n\n const size_t data_cols = meta.slice_data_length_ / item_size;\n\n py::array blob_arr = mindalpha::make_numpy_array(data, meta.data_type_);\n\n blob_arr = blob_arr.attr(\"reshape\")(-1, cols);\n\n py::slice data_slice(0, data_cols, 1);\n\n py::tuple data_subscript = py::make_tuple(py::ellipsis(), data_slice);\n\n py::array data_arr = blob_arr[data_subscript];\n\n py::tuple data_shape(1 + meta.slice_data_shape_.size());\n\n data_shape[0] = -1;\n\n for (size_t i = 0; i < meta.slice_data_shape_.size(); i++)\n\n data_shape[1 + i] = static_cast<int64_t>(meta.slice_data_shape_.at(i));\n\n data_arr = data_arr.attr(\"reshape\")(data_shape);\n\n py::array keys_arr = mindalpha::make_numpy_array(keys, mindalpha::DataType::UInt64);\n\n (*func)(\"name\"_a=name, \"data\"_a=data_arr, \"keys\"_a=keys_arr);\n\n }\n\n const size_t slice_count = data.size() / meta.slice_total_bytes_;\n\n uint8_t* slice_ptr = data.data();\n\n for (size_t i = 0; i < slice_count; i++)\n\n {\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 44, "score": 91443.50327305484 }, { "content": " serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n if (GetDataShape().empty())\n\n {\n\n std::string serr;\n\n serr.append(\"Can not compute partition shapes for dense tensor '\");\n\n serr.append(GetName());\n\n serr.append(\"', as the tensor data shape is empty; partition_count = \");\n\n serr.append(std::to_string(GetPartitionCount()));\n\n serr.append(\", partition_index = \");\n\n serr.append(std::to_string(index));\n\n serr.append(\".\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n const size_t m = GetDataShape().at(0);\n\n if (m == 0)\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 45, "score": 91442.55107093079 }, { "content": " std::string serr;\n\n serr.append(\"Can not compute partition shapes for dense tensor '\");\n\n serr.append(GetName());\n\n serr.append(\"', as the partition count \");\n\n serr.append(std::to_string(n));\n\n serr.append(\" is invalid.\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n if (index < 0 || index >= n)\n\n {\n\n std::string serr;\n\n serr.append(\"Can not compute partition shapes for dense tensor '\");\n\n serr.append(GetName());\n\n serr.append(\"', as the partition index \");\n\n serr.append(std::to_string(index));\n\n serr.append(\" is invalid; partition_count = \");\n\n serr.append(std::to_string(GetPartitionCount()));\n\n serr.append(\".\\n\\n\");\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 46, "score": 91439.39790939364 }, { "content": " std::string serr;\n\n serr.append(\"Can not compute slice support info for sparse tensor '\");\n\n serr.append(GetName());\n\n serr.append(\"', as the partition count \");\n\n serr.append(std::to_string(n));\n\n serr.append(\" is invalid.\\n\\n\");\n\n serr.append(GetStackTrace());\n\n spdlog::error(serr);\n\n throw std::runtime_error(serr);\n\n }\n\n if (index < 0 || index >= n)\n\n {\n\n std::string serr;\n\n serr.append(\"Can not compute slice support info for sparse tensor '\");\n\n serr.append(GetName());\n\n serr.append(\"', as the partition index \");\n\n serr.append(std::to_string(index));\n\n serr.append(\" is invalid; partition_count = \");\n\n serr.append(std::to_string(GetPartitionCount()));\n\n serr.append(\".\\n\\n\");\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 47, "score": 91439.32316933275 }, { "content": "//\n\n// Copyright 2021 Mobvista\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n\n\n#include <stdexcept>\n\n#include <spdlog/spdlog.h>\n\n#include <mindalpha/pybind_utils.h>\n\n#include <mindalpha/tensor_utils.h>\n", "file_path": "cpp/mindalpha/dense_tensor_meta.cpp", "rank": 48, "score": 91437.94147361857 }, { "content": "//\n\n// Copyright 2021 Mobvista\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n\n\n#include <stdexcept>\n\n#include <spdlog/spdlog.h>\n\n#include <mindalpha/tensor_utils.h>\n\n#include <mindalpha/pybind_utils.h>\n", "file_path": "cpp/mindalpha/sparse_tensor_meta.cpp", "rank": 49, "score": 91437.94147361857 }, { "content": " def load_tensor_done():\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 50, "score": 90561.01444281661 }, { "content": " async def _load_tensors(self, dir_path, *, keep_meta=False):\n\n futures = []\n\n for tensor in self._tensors:\n\n if not tensor.is_backing:\n\n future = tensor._load_tensor(dir_path, keep_meta=keep_meta)\n\n futures.append(future)\n", "file_path": "python/mindalpha/model.py", "rank": 51, "score": 83009.7846229963 }, { "content": "namespace mindalpha\n\n{\n\n\n\n//\n\n// Use the X Macro technique to simplify code. See the following page\n\n// for more information about X Macros:\n\n//\n\n// https://en.wikipedia.org/wiki/X_Macro\n\n//\n\n\n\n#define MINDALPHA_INTEGRAL_DATA_TYPES(X) \\\n\n X(int8_t, int8, Int8) \\\n\n X(int16_t, int16, Int16) \\\n\n X(int32_t, int32, Int32) \\\n\n X(int64_t, int64, Int64) \\\n\n X(uint8_t, uint8, UInt8) \\\n\n X(uint16_t, uint16, UInt16) \\\n\n X(uint32_t, uint32, UInt32) \\\n\n X(uint64_t, uint64, UInt64) \\\n\n /**/\n\n\n\n#define MINDALPHA_FLOATING_DATA_TYPES(X) \\\n\n X(float, float32, Float32) \\\n\n X(double, float64, Float64) \\\n\n /**/\n\n\n\n#define MINDALPHA_DATA_TYPES(X) \\\n\n MINDALPHA_INTEGRAL_DATA_TYPES(X) \\\n\n MINDALPHA_FLOATING_DATA_TYPES(X) \\\n\n /**/\n\n\n\nenum class DataType\n\n{\n\n#undef MINDALPHA_DATA_TYPE_DEF\n\n#define MINDALPHA_DATA_TYPE_DEF(t, l, u) u,\n\n MINDALPHA_DATA_TYPES(MINDALPHA_DATA_TYPE_DEF)\n\n};\n\n\n\n// A missing ``DataType`` is represented by ``DataType(-1)``.\n\nconstexpr DataType NullDataType = static_cast<DataType>(-1);\n\nconstexpr const char* NullDataTypeString = \"null\";\n\n\n\n// Functions to convert ``DataType`` to and from strings.\n\nstd::string DataTypeToString(DataType type);\n\nDataType DataTypeFromString(const std::string& str);\n\n\n\nstd::string NullableDataTypeToString(DataType type);\n\nDataType NullableDataTypeFromString(const std::string& str);\n\n\n\n// This class template computes the ``DataType`` code of a numeric type.\n\ntemplate<typename T>\n\nstruct DataTypeToCode;\n\n\n\n#undef MINDALPHA_DATA_TYPE_DEF\n\n#define MINDALPHA_DATA_TYPE_DEF(t, l, u) \\\n\n template<> \\\n\n struct DataTypeToCode<t> \\\n\n { \\\n\n static constexpr DataType value = DataType::u; \\\n\n }; \\\n\n /**/\n\n MINDALPHA_DATA_TYPES(MINDALPHA_DATA_TYPE_DEF)\n\n\n\n// Compute the size in bytes of a value of ``type``.\n\nsize_t DataTypeToSize(DataType type);\n\n\n\n// This function template and two function overloads ensure ``value``\n\n// can be output as numbers. Output ``int8_t``/``uint8_t`` directly to\n\n// ``std::ostream`` will cause problems as they are character types\n\n// actually.\n\ntemplate<typename T>\n\ninline T AsNumber(T value) { return value; }\n\n\n\ninline int32_t AsNumber(int8_t value) { return static_cast<int32_t>(value); }\n\ninline uint32_t AsNumber(uint8_t value) { return static_cast<uint32_t>(value); }\n\n\n", "file_path": "cpp/mindalpha/data_type.h", "rank": 52, "score": 82665.60836220431 }, { "content": "namespace mindalpha\n\n{\n\n\n\n// Integer encodings of node group of the same role.\n\n#undef MINDALPHA_NODE_ROLE_DEF\n\n#define MINDALPHA_NODE_ROLE_DEF(n) constexpr int n##Group = 1 << static_cast<int>(NodeRole::n);\n\nMINDALPHA_NODE_ROLES(MINDALPHA_NODE_ROLE_DEF)\n\n\n\n// Tag value specify that this integer encoding identify a single node.\n\nconstexpr int SingleNodeIdTag = 1 << (static_cast<int>(NodeRole::Worker) + 1);\n\n\n\n// Tag value specify that this integer encoding identify a node of the specific role.\n\n#undef MINDALPHA_NODE_ROLE_DEF\n\n#define MINDALPHA_NODE_ROLE_DEF(n) constexpr int n##NodeIdTag = 1 << static_cast<int>(NodeRole::n) | SingleNodeIdTag;\n\nMINDALPHA_NODE_ROLES(MINDALPHA_NODE_ROLE_DEF)\n\n\n\n// Encode node numbered ``rank`` as a node id, which is an integer. ``rank`` is zero-based.\n\n#undef MINDALPHA_NODE_ROLE_DEF\n\n#define MINDALPHA_NODE_ROLE_DEF(n) constexpr int n##RankToNodeId(int rank) { return rank << 4 | n##NodeIdTag; }\n\nMINDALPHA_NODE_ROLES(MINDALPHA_NODE_ROLE_DEF)\n\n\n\n// Get the zero-based ``rank`` from node id ``id``.\n\nconstexpr int NodeIdToRank(int id) { return id >> 4; }\n\n\n\n// Node id of the coordinator node. Since there is a single coordinator node\n\n// in the Parameter Server system, its node id can be pre-computed.\n\nconstexpr int CoordinatorNodeId = CoordinatorRankToNodeId(0);\n\n\n\n// Convert integer node id to a descriptive string.\n\nstd::string NodeIdToString(int node_id);\n\n\n", "file_path": "cpp/mindalpha/node_encoding.h", "rank": 53, "score": 82539.09941880858 }, { "content": "namespace mindalpha\n\n{\n\n\n\n//\n\n// Use the X Macro technique to simplify code. See the following page\n\n// for more information about X Macros:\n\n//\n\n// https://en.wikipedia.org/wiki/X_Macro\n\n//\n\n\n\n#define MINDALPHA_NODE_ROLES(X) \\\n\n X(Coordinator) \\\n\n X(Server) \\\n\n X(Worker) \\\n\n /**/\n\n\n\nenum class NodeRole\n\n{\n\n#undef MINDALPHA_NODE_ROLE_DEF\n\n#define MINDALPHA_NODE_ROLE_DEF(n) n,\n\n MINDALPHA_NODE_ROLES(MINDALPHA_NODE_ROLE_DEF)\n\n};\n\n\n\n// A missing ``NodeRole`` is represented by ``NodeRole(-1)``.\n\nconstexpr NodeRole NullNodeRole = static_cast<NodeRole>(-1);\n\nconstexpr const char* NullNodeRoleString = \"null\";\n\n\n\n// Functions to convert ``NodeRole`` to and from strings.\n\nstd::string NodeRoleToString(NodeRole role);\n\nNodeRole NodeRoleFromString(const std::string& str);\n\n\n\nstd::string NullableNodeRoleToString(NodeRole role);\n\nNodeRole NullableNodeRoleFromString(const std::string& str);\n\n\n", "file_path": "cpp/mindalpha/node_role.h", "rank": 54, "score": 82539.09941880858 }, { "content": " def data(self):\n\n self._check_clean()\n", "file_path": "python/mindalpha/embedding.py", "rank": 55, "score": 82509.05630239297 }, { "content": "namespace mindalpha\n\n{\n\n\n\nstruct FileHeader {\n\n uint32_t magic;\n\n uint32_t patch;\n\n uint64_t size;\n\n static const uint32_t kMagicNum = 0xffffeeee;\n\n bool Check() {\n\n return magic == kMagicNum &&\n\n size > 0;\n\n }\n\n inline uint64_t Size() {\n\n return size;\n\n }\n", "file_path": "cpp/mindalpha/file_utils.h", "rank": 56, "score": 82486.9059677107 }, { "content": " def rank(self):\n", "file_path": "python/mindalpha/agent.py", "rank": 57, "score": 82362.52998376961 }, { "content": " def load_pickle_file(pickler_path):\n\n job_instance = None\n\n with open(pickler_path, 'rb') as f:\n\n try:\n\n job_instance = pickle.load(f)\n\n except Exception as err:\n\n raise Exception(f\"load {pickler_path} err: {err}\")\n", "file_path": "python/mindalpha/experiment.py", "rank": 58, "score": 81727.66145860594 }, { "content": " def pickle_file_name(self):\n", "file_path": "python/mindalpha/experiment.py", "rank": 59, "score": 81686.70427350655 }, { "content": "namespace mindalpha\n\n{\n\n\n\nsize_t SliceElements(const std::vector<size_t>& shape);\n\nsize_t TotalElements(const std::vector<size_t>& shape);\n\nstd::string ShapeToString(const std::vector<size_t>& shape);\n\nstd::vector<size_t> ShapeFromString(const std::string& str);\n\nvoid FillNaN(uint8_t* buffer, size_t size, DataType type);\n\nvoid MakeInitializerReady(pybind11::object initializer);\n\nvoid MakeUpdaterReady(pybind11::object udpater);\n\n\n", "file_path": "cpp/mindalpha/tensor_utils.h", "rank": 60, "score": 81620.57049188393 }, { "content": " def load(self, dir_path, *, keep_meta=False):\n\n # When spare tensors are repartitioned, we need to make\n\n # sure sparse tensors are cleared, as ``import_from``\n\n # won't clear or override existing keys. Make sure this\n\n # in C++ is a bit complicated, so we do it here.\n\n self.agent.barrier()\n\n if self.agent.rank == 0:\n\n asyncio.run(self.model._clear_tensors())\n\n # When spare tensors are repartitioned, they must be loaded\n\n # and pushed to servers later by all workers, so we do not\n\n # use ``if self.agent.rank == 0:`` here, instead this will\n\n # be checked in C++ code when necessary.\n\n self.agent.barrier()\n\n asyncio.run(self.model._load_tensors(dir_path, keep_meta=keep_meta))\n\n self.agent.barrier()\n\n asyncio.run(self.model._pull_tensors(force_mode=True))\n", "file_path": "python/mindalpha/distributed_trainer.py", "rank": 61, "score": 81344.01730649409 }, { "content": "namespace mindalpha\n\n{\n\n\n\nconst uint64_t map_file_signature_size = 32;\n\n\n\nstruct MapFileHeader\n\n{\n\n char signature[map_file_signature_size];\n\n uint64_t version;\n\n uint64_t reserved_; // for backward compatibility\n\n uint64_t key_type;\n\n uint64_t value_type;\n\n uint64_t key_count;\n\n uint64_t bucket_count;\n\n uint64_t value_count;\n\n uint64_t value_count_per_key;\n\n\n\n void FillBasicFields();\n\n bool IsSignatureValid() const;\n\n void Validate(const std::string& hint) const;\n\n};\n\n\n\nconst uint64_t map_file_header_size = sizeof(MapFileHeader);\n\n\n\nextern const char map_file_signature[map_file_signature_size];\n\nextern const uint64_t map_file_version;\n\n\n", "file_path": "cpp/mindalpha/map_file_header.h", "rank": 62, "score": 81342.3305264719 }, { "content": " def get_state_tensor(self, state, index):\n\n num = self.states_per_param\n\n dim = state.shape[-1]\n\n subscript = list(slice(None) for d in state.shape)\n\n subscript[-1] = slice(dim // num * index, dim // num * (index + 1))\n\n subscript = tuple(subscript)\n\n tensor = operator.getitem(state, subscript)\n", "file_path": "python/mindalpha/updater.py", "rank": 63, "score": 80906.15025491941 }, { "content": " def _load_column_name_map(self):\n\n if self._column_name_map is not None:\n\n raise RuntimeError(\"column map has been loaded\")\n\n column_name_file_path = self._checked_get_column_name_file_path()\n\n combine_schema = CombineSchema()\n\n combine_schema.load_column_name_from_file(use_s3(column_name_file_path))\n\n self._column_name_map = combine_schema.get_column_name_map()\n\n string = f\"\\033[32mloaded column name map from \\033[m{column_name_file_path!r}\"\n\n print(string)\n\n keys = tuple(item for item in self._selected_columns if item not in self._column_name_map)\n\n if keys:\n\n raise ValueError(f\"the following columns are not defined in {self._column_name_file_path!r}: \"\n", "file_path": "python/mindalpha/cast.py", "rank": 64, "score": 79833.24617827602 }, { "content": " def column_name_file_path(self, value):\n\n if value is not None:\n\n if not isinstance(value, str) or not file_exists(value):\n\n raise RuntimeError(f\"column name file {value!r} not found\")\n\n if self._column_name_file_path is not None:\n\n raise RuntimeError(f\"can not reset column_name_file_path {self._column_name_file_path!r} to {value!r}\")\n", "file_path": "python/mindalpha/embedding.py", "rank": 65, "score": 79668.0631530426 }, { "content": " def get_sparse_state_tensor(self, state, index):\n", "file_path": "python/mindalpha/updater.py", "rank": 66, "score": 78907.19288115755 }, { "content": " def get_dense_state_tensor(self, state, index):\n", "file_path": "python/mindalpha/updater.py", "rank": 67, "score": 78907.19288115755 }, { "content": " def _ensure_column_name_map_loaded(self):\n\n if self._column_name_map is None:\n", "file_path": "python/mindalpha/cast.py", "rank": 68, "score": 77908.53094834955 }, { "content": " def has_alternative_column_name_file_path(self):\n", "file_path": "python/mindalpha/embedding.py", "rank": 69, "score": 77747.41099158055 }, { "content": " def alternative_column_name_file_path(self, value):\n\n if value is not None:\n\n if not isinstance(value, str) or not file_exists(value):\n\n raise RuntimeError(f\"alternative column name file {value!r} not found\")\n\n if self._alternative_column_name_file_path is not None:\n\n raise RuntimeError(f\"can not reset alternative_column_name_file_path {self._alternative_column_name_file_path!r} to {value!r}\")\n", "file_path": "python/mindalpha/embedding.py", "rank": 70, "score": 77747.41099158055 }, { "content": "#\n\n# Copyright 2021 Mobvista\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n#\n\n\n\nimport re\n\n\n\ndef is_valid_qualified_name(name):\n\n pattern = r'^[A-Za-z_.\\-][A-Za-z0-9_.\\-]*$'\n\n match = re.match(pattern, name)\n\n return match is not None\n", "file_path": "python/mindalpha/name_utils.py", "rank": 71, "score": 76436.84878000808 }, { "content": "#\n\n# Copyright 2021 Mobvista\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n#\n\n\n\ndef file_exists(url):\n\n import os\n\n from .s3_utils import s3_file_exists\n\n if url.startswith('s3://') or url.startswith('s3a://'):\n\n return s3_file_exists(url)\n\n else:\n\n return os.path.isfile(url)\n\n\n\ndef dir_exists(url):\n\n import os\n\n from .s3_utils import get_s3_dir_size\n\n if url.startswith('s3://') or url.startswith('s3a://'):\n\n return get_s3_dir_size(url) > 0\n\n else:\n\n return os.path.isdir(url)\n\n\n\ndef delete_dir(url):\n\n import os\n\n import shutil\n\n from .s3_utils import delete_s3_dir\n\n if url.startswith('s3://') or url.startswith('s3a://'):\n\n delete_s3_dir(url)\n\n else:\n\n if os.path.isdir(url):\n\n shutil.rmtree(url)\n\n\n\ndef delete_file(url):\n\n import os\n\n from .s3_utils import delete_s3_file\n\n if url.startswith('s3://') or url.startswith('s3a://'):\n\n delete_s3_file(url)\n\n else:\n\n if os.path.isfile(url):\n\n os.remove(url)\n\n\n\ndef copy_dir(src_url, dst_url):\n\n import shutil\n\n from .s3_utils import copy_s3_dir\n\n from .s3_utils import download_s3_dir\n\n from .s3_utils import upload_s3_dir\n\n if src_url.startswith('s3://') or src_url.startswith('s3a://'):\n\n if dst_url.startswith('s3://') or dst_url.startswith('s3a://'):\n\n copy_s3_dir(src_url, dst_url)\n\n else:\n\n download_s3_dir(src_url, dst_url)\n\n else:\n\n if dst_url.startswith('s3://') or dst_url.startswith('s3a://'):\n\n upload_s3_dir(src_url, dst_url)\n\n else:\n\n shutil.copytree(src_url, dst_url)\n", "file_path": "python/mindalpha/file_utils.py", "rank": 72, "score": 76301.33832529862 }, { "content": " def _checked_get_column_name_file_path(self):\n\n if self._column_name_file_path is None:\n\n raise RuntimeError(\"column_name_file_path is not set\")\n", "file_path": "python/mindalpha/cast.py", "rank": 73, "score": 75917.75263006195 }, { "content": " def _checked_get_column_name_file_path(self):\n\n if self._column_name_file_path is None:\n\n raise RuntimeError(\"column_name_file_path is not set\")\n", "file_path": "python/mindalpha/embedding.py", "rank": 74, "score": 75917.75263006195 }, { "content": "#\n\n# Copyright 2021 Mobvista\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n#\n\n\n\nimport asyncio\n\nimport torch\n\nfrom ._mindalpha import DenseTensor\n\nfrom ._mindalpha import SparseTensor\n\nfrom .embedding import EmbeddingOperator\n\nfrom .url_utils import use_s3\n\n\n\nclass DistributedTensor(object):\n\n def __init__(self, name, item, name_prefix):\n\n self.__name = name if name_prefix is None else name_prefix + name\n\n self.__item = item\n\n self.__handle = None\n\n\n\n @property\n\n def name(self):\n\n return self.__name\n\n\n\n @property\n\n def item(self):\n\n return self.__item\n\n\n\n @property\n\n def _handle(self):\n\n return self.__handle\n\n\n\n @property\n\n def is_dense(self):\n\n return isinstance(self.item, torch.Tensor)\n\n\n\n @property\n\n def is_dense_parameter(self):\n\n return isinstance(self.item, torch.nn.Parameter)\n\n\n\n @property\n\n def is_dense_buffer(self):\n\n return self.is_dense and not self.is_dense_parameter\n\n\n\n @property\n\n def is_sparse(self):\n\n return isinstance(self.item, EmbeddingOperator)\n\n\n\n @property\n\n def is_backing(self):\n\n return self.is_sparse and self.item.is_backing\n\n\n\n @property\n\n def is_exported(self):\n\n return self.is_sparse and self.item.is_exported\n\n\n\n def _zero_grad(self):\n\n if self.is_dense_parameter or self.is_sparse:\n\n if self.item.grad is not None:\n\n self.item.grad.detach_()\n\n self.item.grad.zero_()\n\n\n\n def _init_tensor(self, trainer):\n\n if self.is_dense:\n\n return self._init_dense_tensor(trainer)\n\n else:\n\n return self._init_sparse_tensor(trainer)\n\n\n\n def _init_tensor_log(self, x):\n\n if self.is_dense_parameter:\n\n string = \"\\033[38;5;046m\"\n\n elif self.is_dense_buffer:\n\n string = \"\\033[38;5;051m\"\n\n else:\n\n string = \"\\033[38;5;196m\"\n\n if self.is_dense:\n\n string += f\"init dense tensor {x.name} with shape {x.data_shape}, \"\n\n else:\n\n string += f\"init sparse tensor {x.name} with slice shape {x.slice_data_shape}, \"\n\n string += f\"updater {x.updater} and \"\n\n string += f\"initializer {x.initializer}\"\n\n string += \"\\033[m\"\n\n print(string)\n\n\n\n def _init_dense_tensor(self, trainer):\n\n x = DenseTensor()\n\n x.name = self.name\n\n x.data_type = trainer._get_dtype_name(self)\n\n x.data_shape = trainer._get_dense_data_shape(self)\n\n x.state_shape = trainer._get_dense_state_shape(self)\n\n x.initializer = trainer._get_dense_initializer(self)\n\n x.updater = trainer._get_dense_updater(self)\n\n x.partition_count = trainer.agent.server_count\n\n x.agent = trainer.agent._cxx_agent\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def init_dense_tensor_done():\n\n self.__handle = x\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._init_tensor_log(x)\n\n x.init(init_dense_tensor_done)\n\n return future\n\n\n\n def _init_sparse_tensor(self, trainer):\n\n x = SparseTensor()\n\n x.name = self.name\n\n x.data_type = trainer._get_dtype_name(self)\n\n x.slice_data_shape = trainer._get_sparse_slice_data_shape(self)\n\n x.slice_state_shape = trainer._get_sparse_slice_state_shape(self)\n\n x.initializer = trainer._get_sparse_initializer(self)\n\n x.updater = trainer._get_sparse_updater(self)\n\n x.partition_count = trainer.agent.server_count\n\n x.agent = trainer.agent._cxx_agent\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def init_sparse_tensor_done():\n\n self.__handle = x\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._init_tensor_log(x)\n\n x.init(init_sparse_tensor_done)\n\n return future\n\n\n\n def _pull_tensor(self):\n\n if self.is_dense:\n\n return self._pull_dense_tensor()\n\n else:\n\n return self._pull_sparse_tensor()\n\n\n\n def _pull_dense_tensor(self):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def pull_dense_tensor_done(data):\n\n data = torch.from_numpy(data)\n\n data = data.view(self.item.shape)\n\n self.item.data.copy_(data)\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.pull(pull_dense_tensor_done, False)\n\n return future\n\n\n\n async def _pull_sparse_tensor(self):\n\n op = self.item\n\n keys = op.keys\n\n if keys is None:\n\n return\n\n read_only = not op.training or not op.requires_grad\n\n nan_fill = read_only and op.use_nan_fill\n\n def pull_sparse_tensor():\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def pull_sparse_tensor_done(data):\n\n op._check_dtype_and_shape(keys, data)\n\n op._update_data(data)\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.pull(keys, pull_sparse_tensor_done, read_only, nan_fill)\n\n return future\n\n await pull_sparse_tensor()\n\n\n\n def _push_tensor(self, *, is_value=False, skip_no_grad=True):\n\n if self.is_dense:\n\n return self._push_dense_tensor(is_value=is_value, skip_no_grad=skip_no_grad)\n\n else:\n\n return self._push_sparse_tensor(is_value=is_value, skip_no_grad=skip_no_grad)\n\n\n\n async def _push_dense_tensor(self, *, is_value=False, skip_no_grad=True):\n\n data = self.item\n\n if self.is_dense_parameter:\n\n if not is_value and data.grad is None:\n\n if skip_no_grad:\n\n return\n\n raise RuntimeError(f\"the gradient of parameter {self.name!r} is not available\")\n\n # For dense buffers, use .data to fake gradients.\n\n # But we still need to pass is_value=False, otherwise updaters on server won't be called.\n\n data = data.data.numpy() if self.is_dense_buffer or is_value else data.grad.data.numpy()\n\n def push_dense_tensor():\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def push_dense_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.push(data, push_dense_tensor_done, is_value, False)\n\n return future\n\n await push_dense_tensor()\n\n\n\n async def _push_sparse_tensor(self, *, is_value=False, skip_no_grad=True):\n\n op = self.item\n\n keys, data = op.keys_and_data\n\n if keys is None:\n\n return\n\n if not is_value and data.grad is None:\n\n if skip_no_grad:\n\n return\n\n raise RuntimeError(f\"the gradient of operator {op!r} is not available\")\n\n data = data.data.numpy() if is_value else data.grad.data.numpy()\n\n op._check_dtype_and_shape(keys, data)\n\n def push_sparse_tensor():\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def push_sparse_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.push(keys, data, push_sparse_tensor_done, is_value)\n\n return future\n\n await push_sparse_tensor()\n\n\n\n def _load_tensor(self, dir_path, *, keep_meta=False):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def load_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n self._handle.load(dir_path, load_tensor_done, keep_meta)\n\n return future\n\n\n\n def _save_tensor(self, dir_path):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def save_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n if self.is_sparse:\n\n text_mode = self.item.save_as_text\n\n self._handle.save(dir_path, save_tensor_done, text_mode)\n\n else:\n\n self._handle.save(dir_path, save_tensor_done)\n\n return future\n\n\n\n def _sparse_tensor_clear(self):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_clear_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.clear(sparse_tensor_clear_done)\n\n return future\n\n\n\n def _sparse_tensor_export(self, dir_path):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_export_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n self._handle.export(dir_path, sparse_tensor_export_done)\n\n return future\n\n\n\n def _sparse_tensor_import_from(self, meta_file_path, *,\n\n data_only=False, skip_existing=False,\n\n transform_key=False, feature_name=''):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_import_from_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n meta_file_path = use_s3(meta_file_path)\n\n self._handle.import_from(meta_file_path, sparse_tensor_import_from_done,\n\n data_only, skip_existing,\n\n transform_key, feature_name)\n\n return future\n\n\n\n def _sparse_tensor_prune_small(self, epsilon):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_prune_small_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.prune_small(epsilon, sparse_tensor_prune_small_done)\n\n return future\n\n\n\n def _sparse_tensor_prune_old(self, max_age):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_prune_old_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.prune_old(max_age, sparse_tensor_prune_old_done)\n\n return future\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 75, "score": 75435.00284947186 }, { "content": "#\n\n# Copyright 2021 Mobvista\n\n#\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n\n# you may not use this file except in compliance with the License.\n\n# You may obtain a copy of the License at\n\n#\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n#\n\n# Unless required by applicable law or agreed to in writing, software\n\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n# See the License for the specific language governing permissions and\n\n# limitations under the License.\n\n#\n\n\n\nimport asyncio\n\nimport torch\n\nimport pyspark\n\nfrom .embedding import EmbeddingOperator\n\nfrom .estimator import PyTorchAgent\n\nfrom .estimator import PyTorchLauncher\n\nfrom .estimator import PyTorchModel\n\nfrom .estimator import PyTorchEstimator\n\n\n\nclass TwoTowerRankingModule(torch.nn.Module):\n\n def __init__(self, user_module, item_module, item_embedding_module, similarity_module):\n\n super().__init__()\n\n if not isinstance(user_module, torch.nn.Module):\n\n raise TypeError(f\"user_module must be torch.nn.Module; {user_module!r} is invalid\")\n\n if not isinstance(item_module, torch.nn.Module):\n\n raise TypeError(f\"item_module must be torch.nn.Module; {item_module!r} is invalid\")\n\n if not isinstance(item_embedding_module, torch.nn.Module):\n\n raise TypeError(f\"item_embedding_module must be torch.nn.Module; {item_embedding_module!r} is invalid\")\n\n if not isinstance(similarity_module, torch.nn.Module):\n\n raise TypeError(f\"similarity_module must be torch.nn.Module; {similarity_module!r} is invalid\")\n\n self._user_module = user_module\n\n self._item_module = item_module\n\n self._item_embedding_module = item_embedding_module\n\n self._similarity_module = similarity_module\n\n\n\n @property\n\n def user_module(self):\n\n return self._user_module\n\n\n\n @property\n\n def item_module(self):\n\n return self._item_module\n\n\n\n @property\n\n def item_embedding_module(self):\n\n return self._item_embedding_module\n\n\n\n @property\n\n def similarity_module(self):\n\n return self._similarity_module\n\n\n\n def _get_item_embedding(self, x):\n\n if self.training or self._item_embedding_module is None:\n\n if self._item_module is None:\n\n raise RuntimeError(\"item_module is None\")\n\n item_emb = self._item_module(x)\n\n else:\n\n if self._item_embedding_module is None:\n\n raise RuntimeError(\"item_embedding_module is None\")\n\n item_emb = self._item_embedding_module(x)\n\n return item_emb\n\n\n\n def forward(self, x):\n\n user_emb = self._user_module(x)\n\n item_emb = self._get_item_embedding(x)\n\n sim = self._similarity_module(user_emb, item_emb)\n\n return sim\n\n\n\nclass TwoTowerRankingAgent(PyTorchAgent):\n\n def _mark_unexported_operators(self, module):\n\n for name, mod in module.named_modules():\n\n if isinstance(mod, EmbeddingOperator):\n\n mod.is_exported = False\n\n\n\n def _unmark_unexported_operators(self, module):\n\n for name, mod in module.named_modules():\n\n if isinstance(mod, EmbeddingOperator):\n\n mod.is_exported = True\n\n\n\n def _mark_backing_operators(self, module):\n\n for name, mod in module.named_modules():\n\n if isinstance(mod, EmbeddingOperator):\n\n mod.is_backing = True\n\n\n\n def _unmark_backing_operators(self, module):\n\n for name, mod in module.named_modules():\n\n if isinstance(mod, EmbeddingOperator):\n\n mod.is_backing = False\n\n\n\n def _reload_combine_schemas(self, module, use_alternative_column_name_file):\n\n for name, mod in module.named_modules():\n\n if isinstance(mod, EmbeddingOperator):\n\n if mod.has_alternative_column_name_file_path:\n\n mod.reload_combine_schema(use_alternative_column_name_file)\n\n\n\n ## train\n\n\n\n @classmethod\n\n def _handle_item_embedding_module_for_train(cls, _):\n\n self = __class__.get_instance()\n\n self._mark_backing_operators(self.module.item_embedding_module)\n\n return _\n\n\n\n @classmethod\n\n def _restore_handle_item_embedding_module_for_train(cls, _):\n\n self = __class__.get_instance()\n\n self._unmark_backing_operators(self.module.item_embedding_module)\n\n return _\n\n\n\n def feed_training_dataset(self):\n\n rdd = self.spark_context.parallelize(range(self.worker_count), self.worker_count)\n\n rdd.barrier().mapPartitions(self._handle_item_embedding_module_for_train).collect()\n\n super().feed_training_dataset()\n\n rdd = self.spark_context.parallelize(range(self.worker_count), self.worker_count)\n\n rdd.barrier().mapPartitions(self._restore_handle_item_embedding_module_for_train).collect()\n\n self.feed_item_dataset()\n\n\n\n ## item_predict\n\n\n\n @classmethod\n\n def _pull_model_for_item_predict(cls, _):\n\n self = __class__.get_instance()\n\n asyncio.run(self.model._pull_tensors(force_mode=True))\n\n return _\n\n\n\n @classmethod\n\n def _handle_submodel_for_item_predict(cls, _):\n\n self = __class__.get_instance()\n\n self._reload_combine_schemas(self.module.item_module, True)\n\n self._reload_combine_schemas(self.module.item_embedding_module, True)\n\n self._item_predict_submodel = self.model.get_submodel(self.module.item_module, '_item_module.')\n\n return _\n\n\n\n @classmethod\n\n def _restore_handle_submodel_for_item_predict(cls, _):\n\n self = __class__.get_instance()\n\n self._reload_combine_schemas(self.module.item_module, False)\n\n self._reload_combine_schemas(self.module.item_embedding_module, False)\n\n del self._item_predict_submodel\n\n return _\n\n\n\n def feed_item_dataset(self):\n\n if self.item_dataset is not None:\n\n rdd = self.spark_context.parallelize(range(self.worker_count), self.worker_count)\n\n rdd.barrier().mapPartitions(self._pull_model_for_item_predict).collect()\n\n rdd = self.spark_context.parallelize(range(self.worker_count), self.worker_count)\n\n rdd.barrier().mapPartitions(self._handle_submodel_for_item_predict).collect()\n\n df = self.item_dataset.select(self.feed_item_minibatch()(*self.item_dataset.columns).alias('item_predict'))\n\n df.write.format('noop').mode('overwrite').save()\n\n rdd = self.spark_context.parallelize(range(self.worker_count), self.worker_count)\n\n rdd.barrier().mapPartitions(self._restore_handle_submodel_for_item_predict).collect()\n\n\n\n ## online_predict\n\n\n\n def _handle_item_module_for_online_predict(self):\n\n self._mark_unexported_operators(self.module.item_module)\n\n self._saved_item_module = self.module._item_module\n\n self.module._item_module = None\n\n\n\n def _restore_handle_item_module_for_online_predict(self):\n\n self.module._item_module = self._saved_item_module\n\n del self._saved_item_module\n\n self._unmark_unexported_operators(self.module.item_module)\n\n\n\n def export_model(self):\n\n if self.model_export_path is not None:\n\n self._handle_item_module_for_online_predict()\n\n super().export_model()\n\n self._restore_handle_item_module_for_online_predict()\n\n\n\n ## offline_predict\n\n\n\n def _handle_module_for_offline_predict(self):\n\n if self.use_amended_module_for_offline_predict:\n\n self._saved_item_module = self.module._item_module\n\n self.module._item_module = None\n\n else:\n\n self._saved_item_embedding_module = self.module._item_embedding_module\n\n self.module._item_embedding_module = None\n\n\n\n def _restore_handle_module_for_offline_predict(self):\n\n if self.use_amended_module_for_offline_predict:\n\n self.module._item_module = self._saved_item_module\n\n del self._saved_item_module\n\n else:\n\n self.module._item_embedding_module = self._saved_item_embedding_module\n\n del self._saved_item_embedding_module\n\n\n\n def setup_trainer(self):\n\n if not self.is_training_mode:\n\n self._handle_module_for_offline_predict()\n\n super().setup_trainer()\n\n\n\n def worker_stop(self):\n\n if not self.is_training_mode:\n\n self._restore_handle_module_for_offline_predict()\n\n super().worker_stop()\n\n\n\n ## helper methods for item_predict\n\n\n\n def feed_item_minibatch(self):\n\n from pyspark.sql.types import FloatType\n\n from pyspark.sql.functions import pandas_udf\n\n @pandas_udf(returnType=FloatType())\n\n def _feed_item_minibatch(*minibatch):\n\n self = __class__.get_instance()\n\n result = self.predict_item_minibatch(minibatch)\n\n result = self.process_minibatch_result(minibatch, result)\n\n return result\n\n return _feed_item_minibatch\n\n\n\n def _execute_combine(self, module, ndarrays):\n\n for name, mod in module.named_modules():\n\n if isinstance(mod, EmbeddingOperator):\n\n indices, offsets = mod._do_combine(ndarrays)\n\n return indices\n\n\n\n def _execute_push(self, module, keys, embeddings):\n\n for name, mod in module.named_modules():\n\n if isinstance(mod, EmbeddingOperator):\n\n mod.keys_and_data = keys, embeddings\n\n tensor = mod._distributed_tensor\n\n asyncio.run(tensor._push_tensor(is_value=True))\n\n mod._clean()\n\n return\n\n\n\n def _execute_item_embedding_combine(self, ndarrays):\n\n keys = self._execute_combine(self.module.item_embedding_module, ndarrays)\n\n return keys\n\n\n\n def _execute_item_embedding_push(self, keys, embeddings):\n\n self._execute_push(self.module.item_embedding_module, keys, embeddings)\n\n\n\n def predict_item_minibatch(self, minibatch):\n\n self._item_predict_submodel.eval()\n\n ndarrays = [col.values for col in minibatch]\n\n predictions = self._item_predict_submodel(ndarrays)\n\n embeddings = predictions.detach().numpy()\n\n keys = self._execute_item_embedding_combine(ndarrays)\n\n self._execute_item_embedding_push(keys, embeddings)\n\n\n\nclass TwoTowerRankingLauncher(PyTorchLauncher):\n\n def __init__(self):\n\n super().__init__()\n\n self.item_dataset = None\n\n\n\n def _initialize_agent(self, agent):\n\n agent.item_dataset = self.item_dataset\n\n super()._initialize_agent(agent)\n\n\n\nclass TwoTowerRankingHelperMixin(object):\n\n def __init__(self, item_dataset=None, use_amended_module_for_offline_predict=False, **kwargs):\n\n super().__init__(**kwargs)\n\n self.item_dataset = item_dataset\n\n self.use_amended_module_for_offline_predict = use_amended_module_for_offline_predict\n\n self.extra_agent_attributes['use_amended_module_for_offline_predict'] = self.use_amended_module_for_offline_predict\n\n\n\n def _check_properties(self):\n\n super()._check_properties()\n\n if not isinstance(self.module, TwoTowerRankingModule):\n\n raise TypeError(f\"module must be TwoTowerRankingModule; {self.module!r} is invalid\")\n\n if self.item_dataset is not None and not isinstance(self.item_dataset, pyspark.sql.DataFrame):\n\n raise TypeError(f\"item_dataset must be pyspark.sql.DataFrame; {self.item_dataset!r} is invalid\")\n\n\n\n def _get_launcher_class(self):\n\n return TwoTowerRankingLauncher\n\n\n\n def _get_model_class(self):\n\n return TwoTowerRankingModel\n\n\n\n def _get_agent_class(self):\n\n return self.agent_class or TwoTowerRankingAgent\n\n\n\n def _get_model_arguments(self, module):\n\n args = super()._get_model_arguments(module)\n\n args['item_dataset'] = self.item_dataset\n\n args['use_amended_module_for_offline_predict'] = self.use_amended_module_for_offline_predict\n\n return args\n\n\n\n def _create_launcher(self, dataset, is_training_mode):\n\n launcher = super()._create_launcher(dataset, is_training_mode)\n\n if is_training_mode:\n\n launcher.item_dataset = self.item_dataset\n\n return launcher\n\n\n\nclass TwoTowerRankingModel(TwoTowerRankingHelperMixin, PyTorchModel):\n\n pass\n\n\n\nclass TwoTowerRankingEstimator(TwoTowerRankingHelperMixin, PyTorchEstimator):\n\n def _check_properties(self):\n\n super()._check_properties()\n\n if self.model_export_path is not None and self.item_dataset is None:\n\n raise RuntimeError(\"item_dataset must be specified to export model\")\n\n if self.use_amended_module_for_offline_predict and self.item_dataset is None:\n\n raise RuntimeError(\"item_dataset must be specified to use amended module for offline predict\")\n", "file_path": "python/mindalpha/two_tower_ranking.py", "rank": 76, "score": 75172.36671581458 }, { "content": " def _checked_get_alternative_column_name_file_path(self):\n\n if self._alternative_column_name_file_path is None:\n\n raise RuntimeError(\"alternative_column_name_file_path is not set\")\n", "file_path": "python/mindalpha/embedding.py", "rank": 77, "score": 74172.74505025278 }, { "content": " class ActorProcess* actor_process_ = nullptr;\n\n\n\n struct TrackerEntry\n\n {\n\n int total = 0;\n\n std::vector<PSMessage> responses;\n\n\n\n void Clear()\n\n {\n\n responses.clear();\n\n }\n\n };\n\n\n\n std::mutex tracker_mutex_;\n\n std::condition_variable tracker_cv_;\n\n std::unordered_map<int64_t, TrackerEntry> tracker_;\n\n\n\n bool is_coordinator_ = false;\n\n bool is_server_ = false;\n\n bool is_worker_ = false;\n\n\n\n int server_count_ = 0;\n\n int worker_count_ = 0;\n\n};\n\n\n\n}\n", "file_path": "cpp/mindalpha/ps_agent.h", "rank": 78, "score": 64223.99688488009 }, { "content": "class NodeInfo\n\n{\n\npublic:\n\n NodeRole GetRole() const { return role_; }\n\n void SetRole(NodeRole value) { role_ = value; }\n\n\n\n int GetNodeId() const { return node_id_; }\n\n void SetNodeId(int value) { node_id_ = value; }\n\n\n\n const std::string& GetHostName() const { return host_name_; }\n\n void SetHostName(std::string value) { host_name_ = std::move(value); }\n\n\n\n int GetPort() const { return port_; }\n\n void SetPort(int value) { port_ = value; }\n\n\n\n std::string GetAddress() const { return host_name_ + \":\" + std::to_string(port_); }\n\n\n\n std::string ToString() const;\n\n std::string ToShortString() const;\n\n std::string ToJsonString() const;\n", "file_path": "cpp/mindalpha/node_info.h", "rank": 79, "score": 59075.37796274977 }, { "content": "class NodeControl\n\n{\n\npublic:\n\n bool IsEmpty() const { return command_ == NullNodeControlCommand; }\n\n\n\n NodeControlCommand GetCommand() const { return command_; }\n\n void SetCommand(NodeControlCommand value) { command_ = value; }\n\n\n\n //\n\n // Methods related to node info.\n\n //\n\n std::vector<NodeInfo>& GetNodes() { return nodes_; }\n\n const std::vector<NodeInfo>& GetNodes() const { return nodes_; }\n\n void SetNodes(std::vector<NodeInfo> value) { nodes_ = std::move(value); }\n\n\n\n void ClearNodes() { nodes_.clear(); }\n\n void AddNode(NodeInfo value) { nodes_.push_back(std::move(value)); }\n\n\n\n //\n\n // Methods related to barrier group.\n", "file_path": "cpp/mindalpha/node_control.h", "rank": 80, "score": 59075.37796274977 }, { "content": "class NodeManager\n\n{\n\npublic:\n\n explicit NodeManager(std::shared_ptr<ActorConfig> config);\n\n\n\n std::shared_ptr<ActorConfig> GetConfig() const { return config_; }\n\n void SetConfig(std::shared_ptr<ActorConfig> value) { config_ = std::move(value); }\n\n\n\n const std::vector<int>& GetNodeIds(int group) const;\n\n void Barrier(int group, ActorProcess& process);\n\n void NotifyBarrierDone(const Message& msg);\n\n void UpdateHeartbeat(int nodeId, time_t t);\n\n std::vector<int> GetDeadNodes(int timeout);\n\n\n\nprivate:\n\n void InitNodeIds();\n\n\n\n std::shared_ptr<ActorConfig> config_;\n\n std::mutex start_mutex_;\n\n time_t start_time_ = 0;\n\n std::unordered_map<int, std::vector<int>> node_ids_;\n\n std::mutex barrier_mutex_;\n\n std::condition_variable barrier_cv_;\n\n bool barrier_done_;\n\n std::mutex heartbeat_mutex_;\n\n std::unordered_map<int, time_t> heartbeats_;\n\n};\n\n\n\n}\n", "file_path": "cpp/mindalpha/node_manager.h", "rank": 81, "score": 59075.37796274977 }, { "content": "class MessageMeta\n\n{\n\npublic:\n\n int GetMessageId() const { return message_id_; }\n\n void SetMessageId(int value) { message_id_ = value; }\n\n\n\n int GetSender() const { return sender_; }\n\n void SetSender(int value) { sender_ = value; }\n\n\n\n int GetReceiver() const { return receiver_; }\n\n void SetReceiver(int value) { receiver_ = value; }\n\n\n\n bool IsRequest() const { return is_request_; }\n\n void SetIsRequest(bool value) { is_request_ = value; }\n\n\n\n bool IsException() const { return is_exception_; }\n\n void SetIsException(bool value) { is_exception_ = value; }\n\n\n\n const std::string& GetBody() const { return body_; }\n\n void SetBody(std::string value) { body_ = std::move(value); }\n", "file_path": "cpp/mindalpha/message_meta.h", "rank": 82, "score": 58993.800792978516 }, { "content": "class DenseTensor\n\n{\n\npublic:\n\n DenseTensorMeta& GetMeta() { return meta_; }\n\n const DenseTensorMeta& GetMeta() const { return meta_; }\n\n void SetMeta(DenseTensorMeta value) { meta_ = std::move(value); }\n\n\n\n std::shared_ptr<PSAgent> GetAgent() const { return agent_; }\n\n void SetAgent(std::shared_ptr<PSAgent> value) { agent_ = std::move(value); }\n\n\n\n void Init(std::function<void()> cb);\n\n void Dispose(std::function<void()> cb);\n\n void Push(SmartArray<uint8_t> in, std::function<void()> cb, bool is_value = false, bool is_state = false);\n\n void Pull(std::function<void(SmartArray<uint8_t> out)> cb, bool is_state = false);\n\n void PushMeta(const DenseTensorMeta& meta, std::function<void()> cb);\n\n void PullMeta(std::function<void(DenseTensorMeta meta)> cb);\n\n void Load(const std::string& dir_path, std::function<void()> cb, bool keep_meta = false);\n\n void Save(const std::string& dir_path, std::function<void()> cb);\n\n\n\nprivate:\n\n std::string GetDenseMetaPath(const std::string& dir_path) const;\n\n std::string GetDenseDataPath(const std::string& dir_path) const;\n\n std::string GetDenseStatePath(const std::string& dir_path) const;\n\n\n\n DenseTensorMeta meta_;\n\n std::shared_ptr<PSAgent> agent_;\n\n};\n\n\n\n}\n", "file_path": "cpp/mindalpha/dense_tensor.h", "rank": 83, "score": 57832.04558497133 }, { "content": "class SparseTensor\n\n{\n\npublic:\n\n SparseTensorMeta& GetMeta() { return meta_; }\n\n const SparseTensorMeta& GetMeta() const { return meta_; }\n\n void SetMeta(SparseTensorMeta value) { meta_ = std::move(value); }\n\n\n\n std::shared_ptr<PSAgent> GetAgent() const { return agent_; }\n\n void SetAgent(std::shared_ptr<PSAgent> value) { agent_ = std::move(value); }\n\n\n\n void Init(std::function<void()> cb);\n\n void Dispose(std::function<void()> cb);\n\n void Clear(std::function<void()> cb);\n\n void Push(SmartArray<uint8_t> keys, SmartArray<uint8_t> in, std::function<void()> cb,\n\n bool is_value = false);\n\n void Pull(SmartArray<uint8_t> keys, std::function<void(SmartArray<uint8_t> out)> cb,\n\n bool read_only = false, bool nan_fill = false);\n\n void PushPartition(ArrayHashMap<uint64_t, uint8_t>& data, std::function<void()> cb,\n\n bool data_only = false, bool skip_existing = false);\n\n void PullPartition(ArrayHashMap<uint64_t, uint8_t>& data, std::function<void()> cb,\n", "file_path": "cpp/mindalpha/sparse_tensor.h", "rank": 84, "score": 57832.04558497133 }, { "content": "class TensorPartitionStore\n\n{\n\npublic:\n\n int GetPartitionCount() const { return partition_count_; }\n\n void SetPartitionCount(int value) { partition_count_ = value; }\n\n\n\n int GetPartitionIndex() const { return partition_index_; }\n\n void SetPartitionIndex(int value) { partition_index_ = value; }\n\n\n\n void DenseInit(const DenseTensorMeta& meta);\n\n void DenseDispose(const std::string& name);\n\n void DensePush(const std::string& name, PSMessage req, bool is_value, bool is_state);\n\n PSMessage DensePull(const std::string& name, bool is_state);\n\n void DensePushMeta(const std::string& name, const DenseTensorMeta& meta);\n\n PSMessage DensePullMeta(const std::string& name);\n\n\n\n void SparseInit(const SparseTensorMeta& meta);\n\n void SparseDispose(const std::string& name);\n\n void SparseClear(const std::string& name);\n\n void SparsePush(const std::string& name, PSMessage req, bool is_value);\n", "file_path": "cpp/mindalpha/tensor_partition_store.h", "rank": 85, "score": 55685.93481683781 }, { "content": "class SparseTensorPartition\n\n{\n\npublic:\n\n SparseTensorMeta& GetMeta() { return meta_; }\n\n const SparseTensorMeta& GetMeta() const { return meta_; }\n\n void SetMeta(SparseTensorMeta value) { meta_ = std::move(value); }\n\n\n\n int GetPartitionIndex() const { return partition_index_; }\n\n void SetPartitionIndex(int value) { partition_index_ = value; }\n\n\n\n void AllocateHashMap();\n\n void Clear();\n\n void HandlePush(SmartArray<uint8_t> keys, SmartArray<uint8_t> in, bool is_value);\n\n SmartArray<uint8_t> HandlePull(SmartArray<uint8_t> keys, bool read_only, bool nan_fill);\n\n void HandlePushPartition(SmartArray<uint8_t> keys, SmartArray<uint8_t> in, bool data_only, bool skip_existing);\n\n SmartArray<uint8_t> HandlePullPartition(bool data_only, int index, int count, SmartArray<uint8_t>& keys);\n\n void HandlePushMeta(const SparseTensorMeta& meta);\n\n const SparseTensorMeta& HandlePullMeta();\n\n void Load(const std::string& dir_path);\n\n void Save(const std::string& dir_path, bool text_mode);\n", "file_path": "cpp/mindalpha/sparse_tensor_partition.h", "rank": 86, "score": 55685.93481683781 }, { "content": "class DenseTensorPartition\n\n{\n\npublic:\n\n DenseTensorMeta& GetMeta() { return meta_; }\n\n const DenseTensorMeta& GetMeta() const { return meta_; }\n\n void SetMeta(DenseTensorMeta value) { meta_ = std::move(value); }\n\n\n\n std::vector<size_t>& GetPartitionDataShape() { return partition_data_shape_; }\n\n const std::vector<size_t>& GetPartitionDataShape() const { return partition_data_shape_; }\n\n void SetPartitionDataShape(std::vector<size_t> value) { partition_data_shape_ = std::move(value); }\n\n\n\n std::vector<size_t>& GetPartitionStateShape() { return partition_state_shape_; }\n\n const std::vector<size_t>& GetPartitionStateShape() const { return partition_state_shape_; }\n\n void SetPartitionStateShape(std::vector<size_t> value) { partition_state_shape_ = std::move(value); }\n\n\n\n int GetPartitionIndex() const { return partition_index_; }\n\n void SetPartitionIndex(int value) { partition_index_ = value; }\n\n\n\n size_t GetOffset() const { return offset_; }\n\n void SetOffset(size_t value) { offset_ = value; }\n", "file_path": "cpp/mindalpha/dense_tensor_partition.h", "rank": 87, "score": 55685.93481683781 }, { "content": "def file_exists(url):\n\n import os\n\n from .s3_utils import s3_file_exists\n\n if url.startswith('s3://') or url.startswith('s3a://'):\n\n return s3_file_exists(url)\n\n else:\n", "file_path": "python/mindalpha/file_utils.py", "rank": 88, "score": 54956.713616043155 }, { "content": "def delete_file(url):\n\n import os\n\n from .s3_utils import delete_s3_file\n\n if url.startswith('s3://') or url.startswith('s3a://'):\n\n delete_s3_file(url)\n\n else:\n\n if os.path.isfile(url):\n", "file_path": "python/mindalpha/file_utils.py", "rank": 89, "score": 54956.713616043155 }, { "content": "class LocalFileSystem : public FileSystem {\n\npublic:\n\n /*! \\brief destructor */\n\n virtual ~LocalFileSystem() {\n\n }\n\n /*!\n\n * \\brief get information about a path\n\n * \\param path the path to the file\n\n * \\return the information about the file\n\n */\n\n virtual FileInfo GetPathInfo(const URI &path);\n\n /*!\n\n * \\brief list files in a directory\n\n * \\param path to the file\n\n * \\param out_list the output information about the files\n\n */\n\n virtual void ListDirectory(const URI &path, std::vector<FileInfo> *out_list);\n\n /*!\n\n * \\brief open a stream, will report error and exit if bad thing happens\n\n * NOTE: the IStream can continue to work even when filesystem was destructed\n", "file_path": "cpp/mindalpha/local_filesys.h", "rank": 90, "score": 54788.33024675009 }, { "content": "def is_valid_qualified_name(name):\n\n pattern = r'^[A-Za-z_.\\-][A-Za-z0-9_.\\-]*$'\n\n match = re.match(pattern, name)\n", "file_path": "python/mindalpha/name_utils.py", "rank": 91, "score": 54208.31422425268 }, { "content": " def _push_tensor(self, *, is_value=False, skip_no_grad=True):\n\n if self.is_dense:\n\n return self._push_dense_tensor(is_value=is_value, skip_no_grad=skip_no_grad)\n\n else:\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 92, "score": 53883.14474432791 }, { "content": "class DistributedTensor(object):\n\n def __init__(self, name, item, name_prefix):\n\n self.__name = name if name_prefix is None else name_prefix + name\n\n self.__item = item\n\n self.__handle = None\n\n\n\n @property\n\n def name(self):\n\n return self.__name\n\n\n\n @property\n\n def item(self):\n\n return self.__item\n\n\n\n @property\n\n def _handle(self):\n\n return self.__handle\n\n\n\n @property\n\n def is_dense(self):\n\n return isinstance(self.item, torch.Tensor)\n\n\n\n @property\n\n def is_dense_parameter(self):\n\n return isinstance(self.item, torch.nn.Parameter)\n\n\n\n @property\n\n def is_dense_buffer(self):\n\n return self.is_dense and not self.is_dense_parameter\n\n\n\n @property\n\n def is_sparse(self):\n\n return isinstance(self.item, EmbeddingOperator)\n\n\n\n @property\n\n def is_backing(self):\n\n return self.is_sparse and self.item.is_backing\n\n\n\n @property\n\n def is_exported(self):\n\n return self.is_sparse and self.item.is_exported\n\n\n\n def _zero_grad(self):\n\n if self.is_dense_parameter or self.is_sparse:\n\n if self.item.grad is not None:\n\n self.item.grad.detach_()\n\n self.item.grad.zero_()\n\n\n\n def _init_tensor(self, trainer):\n\n if self.is_dense:\n\n return self._init_dense_tensor(trainer)\n\n else:\n\n return self._init_sparse_tensor(trainer)\n\n\n\n def _init_tensor_log(self, x):\n\n if self.is_dense_parameter:\n\n string = \"\\033[38;5;046m\"\n\n elif self.is_dense_buffer:\n\n string = \"\\033[38;5;051m\"\n\n else:\n\n string = \"\\033[38;5;196m\"\n\n if self.is_dense:\n\n string += f\"init dense tensor {x.name} with shape {x.data_shape}, \"\n\n else:\n\n string += f\"init sparse tensor {x.name} with slice shape {x.slice_data_shape}, \"\n\n string += f\"updater {x.updater} and \"\n\n string += f\"initializer {x.initializer}\"\n\n string += \"\\033[m\"\n\n print(string)\n\n\n\n def _init_dense_tensor(self, trainer):\n\n x = DenseTensor()\n\n x.name = self.name\n\n x.data_type = trainer._get_dtype_name(self)\n\n x.data_shape = trainer._get_dense_data_shape(self)\n\n x.state_shape = trainer._get_dense_state_shape(self)\n\n x.initializer = trainer._get_dense_initializer(self)\n\n x.updater = trainer._get_dense_updater(self)\n\n x.partition_count = trainer.agent.server_count\n\n x.agent = trainer.agent._cxx_agent\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def init_dense_tensor_done():\n\n self.__handle = x\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._init_tensor_log(x)\n\n x.init(init_dense_tensor_done)\n\n return future\n\n\n\n def _init_sparse_tensor(self, trainer):\n\n x = SparseTensor()\n\n x.name = self.name\n\n x.data_type = trainer._get_dtype_name(self)\n\n x.slice_data_shape = trainer._get_sparse_slice_data_shape(self)\n\n x.slice_state_shape = trainer._get_sparse_slice_state_shape(self)\n\n x.initializer = trainer._get_sparse_initializer(self)\n\n x.updater = trainer._get_sparse_updater(self)\n\n x.partition_count = trainer.agent.server_count\n\n x.agent = trainer.agent._cxx_agent\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def init_sparse_tensor_done():\n\n self.__handle = x\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._init_tensor_log(x)\n\n x.init(init_sparse_tensor_done)\n\n return future\n\n\n\n def _pull_tensor(self):\n\n if self.is_dense:\n\n return self._pull_dense_tensor()\n\n else:\n\n return self._pull_sparse_tensor()\n\n\n\n def _pull_dense_tensor(self):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def pull_dense_tensor_done(data):\n\n data = torch.from_numpy(data)\n\n data = data.view(self.item.shape)\n\n self.item.data.copy_(data)\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.pull(pull_dense_tensor_done, False)\n\n return future\n\n\n\n async def _pull_sparse_tensor(self):\n\n op = self.item\n\n keys = op.keys\n\n if keys is None:\n\n return\n\n read_only = not op.training or not op.requires_grad\n\n nan_fill = read_only and op.use_nan_fill\n\n def pull_sparse_tensor():\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def pull_sparse_tensor_done(data):\n\n op._check_dtype_and_shape(keys, data)\n\n op._update_data(data)\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.pull(keys, pull_sparse_tensor_done, read_only, nan_fill)\n\n return future\n\n await pull_sparse_tensor()\n\n\n\n def _push_tensor(self, *, is_value=False, skip_no_grad=True):\n\n if self.is_dense:\n\n return self._push_dense_tensor(is_value=is_value, skip_no_grad=skip_no_grad)\n\n else:\n\n return self._push_sparse_tensor(is_value=is_value, skip_no_grad=skip_no_grad)\n\n\n\n async def _push_dense_tensor(self, *, is_value=False, skip_no_grad=True):\n\n data = self.item\n\n if self.is_dense_parameter:\n\n if not is_value and data.grad is None:\n\n if skip_no_grad:\n\n return\n\n raise RuntimeError(f\"the gradient of parameter {self.name!r} is not available\")\n\n # For dense buffers, use .data to fake gradients.\n\n # But we still need to pass is_value=False, otherwise updaters on server won't be called.\n\n data = data.data.numpy() if self.is_dense_buffer or is_value else data.grad.data.numpy()\n\n def push_dense_tensor():\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def push_dense_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.push(data, push_dense_tensor_done, is_value, False)\n\n return future\n\n await push_dense_tensor()\n\n\n\n async def _push_sparse_tensor(self, *, is_value=False, skip_no_grad=True):\n\n op = self.item\n\n keys, data = op.keys_and_data\n\n if keys is None:\n\n return\n\n if not is_value and data.grad is None:\n\n if skip_no_grad:\n\n return\n\n raise RuntimeError(f\"the gradient of operator {op!r} is not available\")\n\n data = data.data.numpy() if is_value else data.grad.data.numpy()\n\n op._check_dtype_and_shape(keys, data)\n\n def push_sparse_tensor():\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def push_sparse_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.push(keys, data, push_sparse_tensor_done, is_value)\n\n return future\n\n await push_sparse_tensor()\n\n\n\n def _load_tensor(self, dir_path, *, keep_meta=False):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def load_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n self._handle.load(dir_path, load_tensor_done, keep_meta)\n\n return future\n\n\n\n def _save_tensor(self, dir_path):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def save_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n if self.is_sparse:\n\n text_mode = self.item.save_as_text\n\n self._handle.save(dir_path, save_tensor_done, text_mode)\n\n else:\n\n self._handle.save(dir_path, save_tensor_done)\n\n return future\n\n\n\n def _sparse_tensor_clear(self):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_clear_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.clear(sparse_tensor_clear_done)\n\n return future\n\n\n\n def _sparse_tensor_export(self, dir_path):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_export_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n self._handle.export(dir_path, sparse_tensor_export_done)\n\n return future\n\n\n\n def _sparse_tensor_import_from(self, meta_file_path, *,\n\n data_only=False, skip_existing=False,\n\n transform_key=False, feature_name=''):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_import_from_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n meta_file_path = use_s3(meta_file_path)\n\n self._handle.import_from(meta_file_path, sparse_tensor_import_from_done,\n\n data_only, skip_existing,\n\n transform_key, feature_name)\n\n return future\n\n\n\n def _sparse_tensor_prune_small(self, epsilon):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_prune_small_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.prune_small(epsilon, sparse_tensor_prune_small_done)\n\n return future\n\n\n\n def _sparse_tensor_prune_old(self, max_age):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def sparse_tensor_prune_old_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n self._handle.prune_old(max_age, sparse_tensor_prune_old_done)\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 93, "score": 53883.14474432791 }, { "content": " def _init_tensor(self, trainer):\n\n if self.is_dense:\n\n return self._init_dense_tensor(trainer)\n\n else:\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 94, "score": 53883.14474432791 }, { "content": " def _pull_tensor(self):\n\n if self.is_dense:\n\n return self._pull_dense_tensor()\n\n else:\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 95, "score": 53883.14474432791 }, { "content": " def _save_tensor(self, dir_path):\n\n loop = asyncio.get_running_loop()\n\n future = loop.create_future()\n\n def save_tensor_done():\n\n loop.call_soon_threadsafe(future.set_result, None)\n\n dir_path = use_s3(dir_path)\n\n if self.is_sparse:\n\n text_mode = self.item.save_as_text\n\n self._handle.save(dir_path, save_tensor_done, text_mode)\n\n else:\n\n self._handle.save(dir_path, save_tensor_done)\n", "file_path": "python/mindalpha/distributed_tensor.py", "rank": 96, "score": 53883.14474432791 }, { "content": "class S3FileSystem : public FileSystem {\n\n public:\n\n /*! \\brief destructor */\n\n virtual ~S3FileSystem() {}\n\n /*!\n\n * \\brief get information about a path\n\n * \\param path the path to the file\n\n * \\return the information about the file\n\n */\n\n virtual FileInfo GetPathInfo(const URI &path) override;\n\n /*!\n\n * \\brief list files in a directory\n\n * \\param path to the file\n\n * \\param out_list the output information about the files\n\n */\n\n virtual void ListDirectory(const URI &path, std::vector<FileInfo> *out_list) override;\n\n /*!\n\n * \\brief open a stream, will report error and exit if bad thing happens\n\n * NOTE: the Stream can continue to work even when filesystem was destructed\n\n * \\param path path to file\n", "file_path": "cpp/mindalpha/s3_sdk_filesys.h", "rank": 97, "score": 53828.35101683957 }, { "content": " { \"name\", GetMeta().GetName() },\n\n };\n\n req->GetMessageMeta().SetReceiver(ServerGroup);\n\n req->GetMessageMeta().SetBody(json.dump());\n\n agent_->BroadcastRequest(req, [this, cb](PSMessage req, std::vector<PSMessage> ress) {\n\n for (size_t k = 0; k < ress.size(); k++)\n\n {\n\n const std::string& body1 = ress.at(0)->GetMessageMeta().GetBody();\n\n const std::string& body2 = ress.at(k)->GetMessageMeta().GetBody();\n\n if (body1 != body2)\n\n {\n\n const int nodeId1 = ress.at(0)->GetMessageMeta().GetSender();\n\n const int nodeId2 = ress.at(k)->GetMessageMeta().GetSender();\n\n std::string serr;\n\n serr.append(\"Meta of sparse tensor '\");\n\n serr.append(GetMeta().GetName());\n\n serr.append(\"' on node \");\n\n serr.append(NodeIdToString(nodeId1));\n\n serr.append(\" and \");\n\n serr.append(NodeIdToString(nodeId2));\n", "file_path": "cpp/mindalpha/sparse_tensor.cpp", "rank": 98, "score": 49.91848310427618 } ]
C++
chrome/browser/ui/views/tabs/color_picker_view.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
#include "chrome/browser/ui/views/tabs/color_picker_view.h" #include <memory> #include <vector> #include "base/bind.h" #include "base/callback.h" #include "base/containers/span.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/tabs/tab_group_theme.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "components/tab_groups/tab_group_color.h" #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/pointer/touch_ui_controller.h" #include "ui/base/theme_provider.h" #include "ui/gfx/animation/tween.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/favicon_size.h" #include "ui/views/border.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/flex_layout.h" #include "ui/views/layout/flex_layout_types.h" #include "ui/views/view_class_properties.h" namespace { class ColorPickerHighlightPathGenerator : public views::HighlightPathGenerator { public: ColorPickerHighlightPathGenerator() = default; SkPath GetHighlightPath(const views::View* view) override { gfx::RectF bounds(view->GetContentsBounds()); bounds.Inset(gfx::Insets(-2.0f)); const gfx::PointF center = bounds.CenterPoint(); return SkPath().addCircle(center.x(), center.y(), bounds.width() / 2.0f); } private: DISALLOW_COPY_AND_ASSIGN(ColorPickerHighlightPathGenerator); }; } class ColorPickerElementView : public views::Button, public views::ButtonListener { public: ColorPickerElementView( base::RepeatingCallback<void(ColorPickerElementView*)> selected_callback, const views::BubbleDialogDelegateView* bubble_view, tab_groups::TabGroupColorId color_id, base::string16 color_name) : Button(this), selected_callback_(std::move(selected_callback)), bubble_view_(bubble_view), color_id_(color_id), color_name_(color_name) { DCHECK(selected_callback_); SetAccessibleName(color_name); SetFocusForPlatform(); SetInstallFocusRingOnFocus(true); views::HighlightPathGenerator::Install( this, std::make_unique<ColorPickerHighlightPathGenerator>()); const int padding = ChromeLayoutProvider::Get()->GetDistanceMetric( views::DISTANCE_RELATED_BUTTON_HORIZONTAL) / 2; gfx::Insets insets = ui::TouchUiController::Get()->touch_ui() ? gfx::Insets(padding * 2) : gfx::Insets(padding); SetBorder(views::CreateEmptyBorder(insets)); SetInkDropMode(InkDropMode::OFF); set_animate_on_state_change(true); } void SetSelected(bool selected) { if (selected_ == selected) return; selected_ = selected; SchedulePaint(); } bool selected() const { return selected_; } bool IsGroupFocusTraversable() const override { return false; } views::View* GetSelectedViewForGroup(int group) override { DCHECK(parent()); return parent()->GetSelectedViewForGroup(group); } void GetAccessibleNodeData(ui::AXNodeData* node_data) override { views::Button::GetAccessibleNodeData(node_data); node_data->role = ax::mojom::Role::kRadioButton; node_data->SetCheckedState(selected() ? ax::mojom::CheckedState::kTrue : ax::mojom::CheckedState::kFalse); } base::string16 GetTooltipText(const gfx::Point& p) const override { return color_name_; } gfx::Size CalculatePreferredSize() const override { const gfx::Insets insets = GetInsets(); const int circle_size = ui::TouchUiController::Get()->touch_ui() ? 3 * gfx::kFaviconSize / 2 : gfx::kFaviconSize; gfx::Size size(circle_size, circle_size); size.Enlarge(insets.width(), insets.height()); return size; } int GetHeightForWidth(int width) const override { return width; } void PaintButtonContents(gfx::Canvas* canvas) override { gfx::RectF bounds(GetContentsBounds()); DCHECK_EQ(bounds.width(), bounds.height()); const SkColor color = GetThemeProvider()->GetColor(GetTabGroupDialogColorId(color_id_)); cc::PaintFlags flags; flags.setStyle(cc::PaintFlags::kFill_Style); flags.setColor(color); flags.setAntiAlias(true); canvas->DrawCircle(bounds.CenterPoint(), bounds.width() / 2.0f, flags); PaintSelectionIndicator(canvas); } void ButtonPressed(Button* sender, const ui::Event& event) override { DCHECK_EQ(this, sender); if (!selected_) { selected_ = true; SchedulePaint(); selected_callback_.Run(this); } } private: void PaintSelectionIndicator(gfx::Canvas* canvas) { if (!selected_) { return; } constexpr float kInset = 3.0f; constexpr float kThickness = 2.0f; cc::PaintFlags flags; flags.setStyle(cc::PaintFlags::kStroke_Style); flags.setStrokeWidth(kThickness); flags.setAntiAlias(true); flags.setColor(bubble_view_->color()); gfx::RectF indicator_bounds(GetContentsBounds()); indicator_bounds.Inset(gfx::InsetsF(kInset)); DCHECK(!indicator_bounds.size().IsEmpty()); canvas->DrawCircle(indicator_bounds.CenterPoint(), indicator_bounds.width() / 2.0f, flags); } const base::RepeatingCallback<void(ColorPickerElementView*)> selected_callback_; const views::BubbleDialogDelegateView* bubble_view_; const tab_groups::TabGroupColorId color_id_; const base::string16 color_name_; bool selected_ = false; }; ColorPickerView::ColorPickerView( const views::BubbleDialogDelegateView* bubble_view, const TabGroupEditorBubbleView::Colors& colors, tab_groups::TabGroupColorId initial_color_id, ColorSelectedCallback callback) : callback_(std::move(callback)) { DCHECK(!colors.empty()); elements_.reserve(colors.size()); for (const auto& color : colors) { elements_.push_back(AddChildView(std::make_unique<ColorPickerElementView>( base::Bind(&ColorPickerView::OnColorSelected, base::Unretained(this)), bubble_view, color.first, color.second))); if (initial_color_id == color.first) elements_.back()->SetSelected(true); } gfx::Insets child_insets = elements_[0]->GetInsets(); SetProperty(views::kInternalPaddingKey, gfx::Insets(0, child_insets.left(), 0, child_insets.right())); SetFocusBehavior(views::View::FocusBehavior::NEVER); for (View* view : elements_) { view->SetGroup(0); } auto* layout = SetLayoutManager(std::make_unique<views::FlexLayout>()); layout->SetOrientation(views::LayoutOrientation::kHorizontal) .SetDefault( views::kFlexBehaviorKey, views::FlexSpecification(views::MinimumFlexSizeRule::kPreferred, views::MaximumFlexSizeRule::kUnbounded) .WithAlignment(views::LayoutAlignment::kCenter) .WithWeight(1)); } ColorPickerView::~ColorPickerView() { RemoveAllChildViews(true); } base::Optional<int> ColorPickerView::GetSelectedElement() const { for (size_t i = 0; i < elements_.size(); ++i) { if (elements_[i]->selected()) return static_cast<int>(i); } return base::nullopt; } views::View* ColorPickerView::GetSelectedViewForGroup(int group) { for (ColorPickerElementView* element : elements_) { if (element->selected()) return element; } return nullptr; } views::Button* ColorPickerView::GetElementAtIndexForTesting(int index) { DCHECK_GE(index, 0); DCHECK_LT(index, static_cast<int>(elements_.size())); return elements_[index]; } void ColorPickerView::OnColorSelected(ColorPickerElementView* element) { for (ColorPickerElementView* other_element : elements_) { if (other_element != element) other_element->SetSelected(false); } if (callback_) callback_.Run(); }
#include "chrome/browser/ui/views/tabs/color_picker_view.h" #include <memory> #include <vector> #include "base/bind.h" #include "base/callback.h" #include "base/containers/span.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/tabs/tab_group_theme.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "components/tab_groups/tab_group_color.h" #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/pointer/touch_ui_controller.h" #include "ui/base/theme_provider.h" #include "ui/gfx/animation/tween.h" #include "ui/gfx/canvas.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/favicon_size.h" #include "ui/views/border.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/highlight_path_generator.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/flex_layout.h" #include "ui/views/layout/flex_layout_types.h" #include "ui/views/view_class_properties.h" namespace { class ColorPickerHighlightPathGenerator : public views::HighlightPathGenerator { public: ColorPickerHighlightPathGenerator() = default; SkPath GetHighlightPath(const views::View* view) override { gfx::RectF bounds(view->GetContentsBounds()); bounds.Inset(gfx::Insets(-2.0f)); const gfx::PointF center = bounds.CenterPoint(); return SkPath().addCircle(center.x(), center.y(), bounds.width() / 2.0f); } private: DISALLOW_COPY_AND_ASSIGN(ColorPickerHighlightPathGenerator); }; } class ColorPickerElementView : public views::Button, public views::ButtonListener { public: ColorPickerElementView( base::RepeatingCallback<void(ColorPickerElementView*)> selected_callback, const views::BubbleDialogDelegateView* bubble_view, tab_groups::TabGroupColorId color_id, base::string16 color_name) : Button(this), selected_callback_(std::move(selected_callback)), bubble_view_(bubble_view), color_id_(color_id), color_name_(color_name) { DCHECK(selected_callback_); SetAccessibleName(color_name); SetFocusForPlatform(); SetInstallFocusRingOnFocus(true); views::HighlightPathGenerator::Install( this, std::make_unique<ColorPickerHighlightPathGenerator>()); const int padding = ChromeLayoutProvider::Get()->GetDistanceMetric( views::DISTANCE_RELATED_BUTTON_HORIZONTAL) / 2; gfx::Insets insets = ui::TouchUiController::Get()->touch_ui() ? gfx::Insets(padding * 2) : gfx::Insets(padding); SetBorder(views::CreateEmptyBorder(insets)); SetInkDropMode(InkDropMode::OFF); set_animate_on_state_change(true); } void SetSelected(bool selected) { if (selected_ == selected) return; selected_ = selected; SchedulePaint(); } bool selected() const { return selected_; } bool IsGroupFocusTraversable() const override { return false; } views::View* GetSelectedViewForGroup(int group) override { DCHECK(parent()); return parent()->GetSelectedViewForGroup(group); } void GetAccessibleNodeData(ui::AXNodeData* node_data) override { views::Button::GetAccessibleNodeData(node_data); node_data->role = ax::mojom::Role::kRadioButton; node_data->SetCheckedState(selected() ? ax::mojom::CheckedState::kTrue : ax::mojom::CheckedState::kFalse); } base::string16 GetTooltipText(const gfx::Point& p) const override { return color_name_; } gfx::Size CalculatePreferredSize() const override { const gfx::Insets insets = GetInsets(); const int circle_size = ui::TouchUiController::Get()->touch_ui() ? 3 * gfx::kFaviconSize / 2 : gfx::kFaviconSize; gfx::Size size(circle_size, circle_size); size.Enlarge(insets.width(), insets.height()); return size; } int GetHeightForWidth(int width) const override { return width; } void PaintButtonContents(gfx::Canvas* canvas) override { gfx::RectF bounds(GetContentsBounds()); DCHECK_EQ(bounds.width(), bounds.height()); const SkColor color = GetThemeProvider()->GetColor(GetTabGroupDialogColorId(color_id_)); cc::PaintFlags flags; flags.setStyle(cc::PaintFlags::kFil
void ButtonPressed(Button* sender, const ui::Event& event) override { DCHECK_EQ(this, sender); if (!selected_) { selected_ = true; SchedulePaint(); selected_callback_.Run(this); } } private: void PaintSelectionIndicator(gfx::Canvas* canvas) { if (!selected_) { return; } constexpr float kInset = 3.0f; constexpr float kThickness = 2.0f; cc::PaintFlags flags; flags.setStyle(cc::PaintFlags::kStroke_Style); flags.setStrokeWidth(kThickness); flags.setAntiAlias(true); flags.setColor(bubble_view_->color()); gfx::RectF indicator_bounds(GetContentsBounds()); indicator_bounds.Inset(gfx::InsetsF(kInset)); DCHECK(!indicator_bounds.size().IsEmpty()); canvas->DrawCircle(indicator_bounds.CenterPoint(), indicator_bounds.width() / 2.0f, flags); } const base::RepeatingCallback<void(ColorPickerElementView*)> selected_callback_; const views::BubbleDialogDelegateView* bubble_view_; const tab_groups::TabGroupColorId color_id_; const base::string16 color_name_; bool selected_ = false; }; ColorPickerView::ColorPickerView( const views::BubbleDialogDelegateView* bubble_view, const TabGroupEditorBubbleView::Colors& colors, tab_groups::TabGroupColorId initial_color_id, ColorSelectedCallback callback) : callback_(std::move(callback)) { DCHECK(!colors.empty()); elements_.reserve(colors.size()); for (const auto& color : colors) { elements_.push_back(AddChildView(std::make_unique<ColorPickerElementView>( base::Bind(&ColorPickerView::OnColorSelected, base::Unretained(this)), bubble_view, color.first, color.second))); if (initial_color_id == color.first) elements_.back()->SetSelected(true); } gfx::Insets child_insets = elements_[0]->GetInsets(); SetProperty(views::kInternalPaddingKey, gfx::Insets(0, child_insets.left(), 0, child_insets.right())); SetFocusBehavior(views::View::FocusBehavior::NEVER); for (View* view : elements_) { view->SetGroup(0); } auto* layout = SetLayoutManager(std::make_unique<views::FlexLayout>()); layout->SetOrientation(views::LayoutOrientation::kHorizontal) .SetDefault( views::kFlexBehaviorKey, views::FlexSpecification(views::MinimumFlexSizeRule::kPreferred, views::MaximumFlexSizeRule::kUnbounded) .WithAlignment(views::LayoutAlignment::kCenter) .WithWeight(1)); } ColorPickerView::~ColorPickerView() { RemoveAllChildViews(true); } base::Optional<int> ColorPickerView::GetSelectedElement() const { for (size_t i = 0; i < elements_.size(); ++i) { if (elements_[i]->selected()) return static_cast<int>(i); } return base::nullopt; } views::View* ColorPickerView::GetSelectedViewForGroup(int group) { for (ColorPickerElementView* element : elements_) { if (element->selected()) return element; } return nullptr; } views::Button* ColorPickerView::GetElementAtIndexForTesting(int index) { DCHECK_GE(index, 0); DCHECK_LT(index, static_cast<int>(elements_.size())); return elements_[index]; } void ColorPickerView::OnColorSelected(ColorPickerElementView* element) { for (ColorPickerElementView* other_element : elements_) { if (other_element != element) other_element->SetSelected(false); } if (callback_) callback_.Run(); }
l_Style); flags.setColor(color); flags.setAntiAlias(true); canvas->DrawCircle(bounds.CenterPoint(), bounds.width() / 2.0f, flags); PaintSelectionIndicator(canvas); }
function_block-function_prefixed
[]
C++
src/libmv/simple_pipeline/camera_intrinsics.cc
Matthias-Fauconneau/libmv
531c79bf95fddaaa70707d1abcd4fdafda16bbf0
#include "libmv/simple_pipeline/camera_intrinsics.h" #include "libmv/numeric/levenberg_marquardt.h" namespace libmv { struct Offset { signed char ix,iy; unsigned char fx,fy; }; CameraIntrinsics::CameraIntrinsics() : K_(Mat3::Identity()), image_width_(0), image_height_(0), k1_(0), k2_(0), k3_(0), p1_(0), p2_(0), distort_(0), undistort_(0) {} CameraIntrinsics::~CameraIntrinsics() { if(distort_) delete[] distort_; if(undistort_) delete[] undistort_; } void CameraIntrinsics::SetK(const Mat3 new_k) { K_ = new_k; FreeLookupGrid(); } void CameraIntrinsics::SetFocalLength(double focal_x, double focal_y) { K_(0, 0) = focal_x; K_(1, 1) = focal_y; FreeLookupGrid(); } void CameraIntrinsics::SetPrincipalPoint(double cx, double cy) { K_(0, 2) = cx; K_(1, 2) = cy; FreeLookupGrid(); } void CameraIntrinsics::SetImageSize(int width, int height) { image_width_ = width; image_height_ = height; FreeLookupGrid(); } void CameraIntrinsics::SetRadialDistortion(double k1, double k2, double k3) { k1_ = k1; k2_ = k2; k3_ = k3; FreeLookupGrid(); } void CameraIntrinsics::SetTangentialDistortion(double p1, double p2) { p1_ = p1; p2_ = p2; FreeLookupGrid(); } void CameraIntrinsics::ApplyIntrinsics(double normalized_x, double normalized_y, double *image_x, double *image_y) const { double x = normalized_x; double y = normalized_y; double r2 = x*x + y*y; double r4 = r2 * r2; double r6 = r4 * r2; double r_coeff = (1 + k1_*r2 + k2_*r4 + k3_*r6); double xd = x * r_coeff + 2*p1_*x*y + p2_*(r2 + 2*x*x); double yd = y * r_coeff + 2*p2_*x*y + p1_*(r2 + 2*y*y); *image_x = focal_length_x() * xd + principal_point_x(); *image_y = focal_length_y() * yd + principal_point_y(); } struct InvertIntrinsicsCostFunction { public: typedef Vec2 FMatrixType; typedef Vec2 XMatrixType; InvertIntrinsicsCostFunction(const CameraIntrinsics &intrinsics, double image_x, double image_y) : intrinsics(intrinsics), x(image_x), y(image_y) {} Vec2 operator()(const Vec2 &u) const { double xx, yy; intrinsics.ApplyIntrinsics(u(0), u(1), &xx, &yy); Vec2 fx; fx << (xx - x), (yy - y); return fx; } const CameraIntrinsics &intrinsics; double x, y; }; void CameraIntrinsics::InvertIntrinsics(double image_x, double image_y, double *normalized_x, double *normalized_y) const { Vec2 normalized; normalized(0) = (image_x - principal_point_x()) / focal_length_x(); normalized(1) = (image_y - principal_point_y()) / focal_length_y(); typedef LevenbergMarquardt<InvertIntrinsicsCostFunction> Solver; InvertIntrinsicsCostFunction intrinsics_cost(*this, image_x, image_y); Solver::SolverParameters params; Solver solver(intrinsics_cost); solver.minimize(params, &normalized); *normalized_x = normalized(0); *normalized_y = normalized(1); } template<typename WarpFunction> void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { double warp_x, warp_y; WarpFunction(this,x,y,&warp_x,&warp_y); int ix = int(warp_x), iy = int(warp_y); int fx = round((warp_x-ix)*256), fy = round((warp_y-iy)*256); if(fx == 256) { fx=0; ix++; } if(fy == 256) { fy=0; iy++; } if( ix < 0 ) { ix = 0, fx = 0; } if( iy < 0 ) { iy = 0, fy = 0; } if( ix >= width-2 ) ix = width-2; if( iy >= height-2 ) iy = height-2; Offset offset = { ix-x, iy-y, fx, fy }; grid[y*width+x] = offset; } } } template<typename T,int N> static void Warp(const Offset* grid, const T* src, T* dst, int width, int height) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Offset offset = grid[y*width+x]; const T* s = &src[((y+offset.iy)*width+(x+offset.ix))*N]; for (int i = 0; i < N; i++) { dst[(y*width+x)*N+i] = ((s[ i] * (256-offset.fx) + s[ N+i] * offset.fx) * (256-offset.fy) +(s[width*N+i] * (256-offset.fx) + s[width*N+N+i] * offset.fx) * offset.fy) / (256*256); } } } } void CameraIntrinsics::FreeLookupGrid() { if(distort_) delete distort_, distort_=0; if(undistort_) delete undistort_, undistort_=0; } struct ApplyIntrinsicsFunction { ApplyIntrinsicsFunction(CameraIntrinsics* intrinsics, double x, double y, double *warp_x, double *warp_y) { intrinsics->ApplyIntrinsics( (x-intrinsics->principal_point_x())/intrinsics->focal_length_x(), (y-intrinsics->principal_point_y())/intrinsics->focal_length_y(), warp_x, warp_y); } }; struct InvertIntrinsicsFunction { InvertIntrinsicsFunction(CameraIntrinsics* intrinsics, double x, double y, double *warp_x, double *warp_y) { intrinsics->InvertIntrinsics(x,y,warp_x,warp_y); *warp_x = *warp_x*intrinsics->focal_length_x()+intrinsics->principal_point_x(); *warp_y = *warp_y*intrinsics->focal_length_y()+intrinsics->principal_point_y(); } }; void CameraIntrinsics::Distort(const float* src, float* dst, int width, int height, int channels) { if(!distort_) { distort_ = new Offset[width*height]; ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); } if(channels==1) Warp<float,1>(distort_,src,dst,width,height); else if(channels==2) Warp<float,2>(distort_,src,dst,width,height); else if(channels==3) Warp<float,3>(distort_,src,dst,width,height); else if(channels==4) Warp<float,4>(distort_,src,dst,width,height); } void CameraIntrinsics::Distort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { if(!distort_) { distort_ = new Offset[width*height]; ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); } if(channels==1) Warp<unsigned char,1>(distort_,src,dst,width,height); else if(channels==2) Warp<unsigned char,2>(distort_,src,dst,width,height); else if(channels==3) Warp<unsigned char,3>(distort_,src,dst,width,height); else if(channels==4) Warp<unsigned char,4>(distort_,src,dst,width,height); } void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int height, int channels) { if(!undistort_) { undistort_ = new Offset[width*height]; ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); } if(channels==1) Warp<float,1>(undistort_,src,dst,width,height); else if(channels==2) Warp<float,2>(undistort_,src,dst,width,height); else if(channels==3) Warp<float,3>(undistort_,src,dst,width,height); else if(channels==4) Warp<float,4>(undistort_,src,dst,width,height); } void CameraIntrinsics::Undistort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { if(!undistort_) { undistort_ = new Offset[width*height]; ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); } if(channels==1) Warp<unsigned char,1>(undistort_,src,dst,width,height); else if(channels==2) Warp<unsigned char,2>(undistort_,src,dst,width,height); else if(channels==3) Warp<unsigned char,3>(undistort_,src,dst,width,height); else if(channels==4) Warp<unsigned char,4>(undistort_,src,dst,width,height); } }
#include "libmv/simple_pipeline/camera_intrinsics.h" #include "libmv/numeric/levenberg_marquardt.h" namespace libmv { struct Offset { signed char ix,iy; unsigned char fx,fy; }; CameraIntrinsics::CameraIntrinsics() : K_(Mat3::Identity()), image_width_(0), image_height_(0), k1_(0), k2_(0), k3_(0), p1_(0), p2_(0), distort_(0), undistort_(0) {} CameraIntrinsics::~CameraIntrinsics() { if(distort_) delete[] distort_; if(undistort_) delete[] undistort_; } void CameraIntrinsics::SetK(const Mat3 new_k) { K_ = new_k; FreeLookupGrid(); } void CameraIntrinsics::SetFocalLength(double focal_x, double focal_y) { K_(0, 0) = focal_x; K_(1, 1) = focal_y; FreeLookupGrid(); } void CameraIntrinsics::SetPrincipalPoint(double cx, double cy) { K_(0, 2) = cx; K_(1, 2) = cy; FreeLookupGrid(); } void CameraIntrinsics::SetImageSize(int width, int height) { image_width_ = width; image_height_ = height; FreeLookupGrid(); } void CameraIntrinsics::SetRadialDistortion(double k1, double k2, double k3) { k1_ = k1; k2_ = k2; k3_ = k3; FreeLookupGrid(); } void CameraIntrinsics::SetTangentialDistortion(double p1, double p2) { p1_ = p1; p2_ = p2; FreeLookupGrid(); } void CameraIntrinsics::ApplyIntrinsics(double normalized_x, double normalized_y, double *image_x, double *image_y) const { double x = normalized_x; double y = normalized_y; double r2 = x*x + y*y; double r4 = r2 * r2; double r6 = r4 * r2; double r_coeff = (1 + k1_*r2 + k2_*r4 + k3_*r6); double xd = x * r_coeff + 2*p1_*x*y + p2_*(r2 + 2*x*x); double yd = y * r_coeff + 2*p2_*x*y + p1_*(r2 + 2*y*y); *image_x = focal_length_x() * xd + principal_point_x(); *image_y = focal_length_y() * yd + principal_point_y(); } struct InvertIntrinsicsCostFunction { public: typedef Vec2 FMatrixType; typedef Vec2 XMatrixType; InvertIntrinsicsCostFunction(const CameraIntrinsics &intrinsics, double image_x, double image_y) : intrinsics(intrinsics), x(image_x), y(image_y) {} Vec2 operator()(const Vec2 &u) const { double xx, yy; intrinsics.ApplyIntrinsics(u(0), u(1), &xx, &yy); Vec2 fx; fx << (xx - x), (yy - y); return fx; } const CameraIntrinsics &intrinsics; double x, y; }; void CameraIntrinsics::InvertIntrinsics(double image_x, double image_y, double *normalized_x, double *normalized_y) const { Vec2 normalized; normalized(0) = (image_x - principal_point_x()) / focal_length_x(); normalized(1) = (image_y - principal_point_y()) / focal_length_y(); typedef LevenbergMarquardt<InvertIntrinsicsCostFunction> Solver; InvertIntrinsicsCostFunction intrinsics_cost(*this, image_x, image_y); Solver::SolverParameters params; Solver solver(intrinsics_cost); solver.minimize(params, &normalized); *normalized_x = normalized(0); *normalized_y = normalized(1); } template<typename WarpFunction> void CameraIntrinsics::ComputeLookupGrid(Offset* grid, int width, int height) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { double warp_x, warp_y; WarpFunction(this,x,y,&warp_x,&warp_y); int ix = int(warp_x), iy = int(warp_y); int fx = round((warp_x-ix)*256), fy = round((warp_y-iy)*256); if(fx == 256) { fx=0; ix++; } if(fy == 256) { fy=0; iy++; } if( ix < 0 ) { ix = 0, fx = 0; } if( iy < 0 ) { iy = 0, fy = 0; } if( ix >= width-2 ) ix = width-2; if( iy >= height-2 ) iy = height-2; Offset offset = { ix-x, iy-y, fx, fy }; grid[y*width+x] = offset; } } } template<typename T,int N> static void Warp(const Offset* grid, const T* src, T* dst, int width, int height) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Offset offset = grid[y*width+x]; const T* s = &src[((y+offset.iy)*width+(x+offset.ix))*N]; for (in
(undistort_,src,dst,width,height); } }
t i = 0; i < N; i++) { dst[(y*width+x)*N+i] = ((s[ i] * (256-offset.fx) + s[ N+i] * offset.fx) * (256-offset.fy) +(s[width*N+i] * (256-offset.fx) + s[width*N+N+i] * offset.fx) * offset.fy) / (256*256); } } } } void CameraIntrinsics::FreeLookupGrid() { if(distort_) delete distort_, distort_=0; if(undistort_) delete undistort_, undistort_=0; } struct ApplyIntrinsicsFunction { ApplyIntrinsicsFunction(CameraIntrinsics* intrinsics, double x, double y, double *warp_x, double *warp_y) { intrinsics->ApplyIntrinsics( (x-intrinsics->principal_point_x())/intrinsics->focal_length_x(), (y-intrinsics->principal_point_y())/intrinsics->focal_length_y(), warp_x, warp_y); } }; struct InvertIntrinsicsFunction { InvertIntrinsicsFunction(CameraIntrinsics* intrinsics, double x, double y, double *warp_x, double *warp_y) { intrinsics->InvertIntrinsics(x,y,warp_x,warp_y); *warp_x = *warp_x*intrinsics->focal_length_x()+intrinsics->principal_point_x(); *warp_y = *warp_y*intrinsics->focal_length_y()+intrinsics->principal_point_y(); } }; void CameraIntrinsics::Distort(const float* src, float* dst, int width, int height, int channels) { if(!distort_) { distort_ = new Offset[width*height]; ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); } if(channels==1) Warp<float,1>(distort_,src,dst,width,height); else if(channels==2) Warp<float,2>(distort_,src,dst,width,height); else if(channels==3) Warp<float,3>(distort_,src,dst,width,height); else if(channels==4) Warp<float,4>(distort_,src,dst,width,height); } void CameraIntrinsics::Distort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { if(!distort_) { distort_ = new Offset[width*height]; ComputeLookupGrid<InvertIntrinsicsFunction>(distort_,width,height); } if(channels==1) Warp<unsigned char,1>(distort_,src,dst,width,height); else if(channels==2) Warp<unsigned char,2>(distort_,src,dst,width,height); else if(channels==3) Warp<unsigned char,3>(distort_,src,dst,width,height); else if(channels==4) Warp<unsigned char,4>(distort_,src,dst,width,height); } void CameraIntrinsics::Undistort(const float* src, float* dst, int width, int height, int channels) { if(!undistort_) { undistort_ = new Offset[width*height]; ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); } if(channels==1) Warp<float,1>(undistort_,src,dst,width,height); else if(channels==2) Warp<float,2>(undistort_,src,dst,width,height); else if(channels==3) Warp<float,3>(undistort_,src,dst,width,height); else if(channels==4) Warp<float,4>(undistort_,src,dst,width,height); } void CameraIntrinsics::Undistort(const unsigned char* src, unsigned char* dst, int width, int height, int channels) { if(!undistort_) { undistort_ = new Offset[width*height]; ComputeLookupGrid<ApplyIntrinsicsFunction>(undistort_,width,height); } if(channels==1) Warp<unsigned char,1>(undistort_,src,dst,width,height); else if(channels==2) Warp<unsigned char,2>(undistort_,src,dst,width,height); else if(channels==3) Warp<unsigned char,3>(undistort_,src,dst,width,height); else if(channels==4) Warp<unsigned char,4>
random
[ { "content": "struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };\n\n\n\ntemplate <GTEST_3_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 1, "score": 343036.2119991771 }, { "content": "struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };\n\n\n\ntemplate <GTEST_1_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 2, "score": 343033.30679670157 }, { "content": "struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };\n\n\n\ntemplate <GTEST_2_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 3, "score": 343032.98447604134 }, { "content": "class FooTest : public ::testing::TestWithParam<const char*> {\n\n // You can implement all the usual class fixture members here.\n\n};\n\n\n\n// Then, use the TEST_P macro to define as many parameterized tests\n\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n\n// or \"pattern\", whichever you prefer to think.\n\n\n\nTEST_P(FooTest, DoesBlah) {\n\n // Inside a test, access the test parameter with the GetParam() method\n\n // of the TestWithParam<T> class:\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n ...\n\n}\n\n\n\nTEST_P(FooTest, HasBlahBlah) {\n\n ...\n\n}\n\n\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n", "file_path": "src/third_party/gtest/include/gtest/gtest-param-test.h", "rank": 4, "score": 339193.0221307178 }, { "content": "struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };\n\n\n\ntemplate <GTEST_6_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 5, "score": 325761.37279787177 }, { "content": "struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };\n\n\n\ntemplate <GTEST_4_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 6, "score": 325761.37279787177 }, { "content": "struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };\n\n\n\ntemplate <GTEST_5_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 7, "score": 325761.3727978718 }, { "content": "struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };\n\n\n\ntemplate <GTEST_9_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 8, "score": 325761.37279787177 }, { "content": "struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };\n\n\n\ntemplate <GTEST_7_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 9, "score": 325761.37279787177 }, { "content": "struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };\n\n\n\ntemplate <GTEST_8_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 10, "score": 325761.37279787177 }, { "content": "struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };\n\n\n\ntemplate <int k, class Tuple>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 11, "score": 325761.37279787177 }, { "content": "struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 12, "score": 325761.3727978718 }, { "content": "struct RemoveConst<const T[N]> {\n\n typedef typename RemoveConst<T>::type type[N];\n\n};\n\n#endif\n\n\n\n// A handy wrapper around RemoveConst that works when the argument\n\n// T depends on template parameters.\n\n#define GTEST_REMOVE_CONST_(T) \\\n\n typename ::testing::internal::RemoveConst<T>::type\n\n\n\n// Turns const U&, U&, const U, and U all into U.\n\n#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \\\n\n GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))\n\n\n\n// Adds reference to a type if it is not a reference type,\n\n// otherwise leaves it unchanged. This is the same as\n\n// tr1::add_reference, which is not widely available yet.\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 13, "score": 317694.731590732 }, { "content": "struct NormalizedSolver {\n\n enum { MINIMUM_SAMPLES = Solver::MINIMUM_SAMPLES };\n\n static void Solve(const Mat &x1, const Mat &x2, vector<Mat3> *models) {\n\n assert(2 == x1.rows());\n\n assert(MINIMUM_SAMPLES <= x1.cols());\n\n assert(x1.rows() == x2.rows());\n\n assert(x1.cols() == x2.cols());\n\n\n\n // Normalize the data.\n\n Mat3 T1, T2;\n\n Mat x1_normalized, x2_normalized;\n\n NormalizePoints(x1, &x1_normalized, &T1);\n\n NormalizePoints(x2, &x2_normalized, &T2);\n\n\n\n Solver::Solve(x1_normalized, x2_normalized, models);\n\n\n\n for (int i = 0; i < models->size(); ++i) {\n\n Unnormalizer::Unnormalize(T1, T2, &(*models)[i]);\n\n }\n\n }\n\n};\n\n\n\ntemplate<typename Solver, typename Unnormalizer>\n", "file_path": "src/libmv/multiview/two_view_kernel.h", "rank": 14, "score": 292259.34240833856 }, { "content": "struct IsotropicNormalizedSolver {\n\n enum { MINIMUM_SAMPLES = Solver::MINIMUM_SAMPLES };\n\n static void Solve(const Mat &x1, const Mat &x2, vector<Mat3> *models) {\n\n assert(2 == x1.rows());\n\n assert(MINIMUM_SAMPLES <= x1.cols());\n\n assert(x1.rows() == x2.rows());\n\n assert(x1.cols() == x2.cols());\n\n\n\n // Normalize the data.\n\n Mat3 T1, T2;\n\n Mat x1_normalized, x2_normalized;\n\n NormalizeIsotropicPoints(x1, &x1_normalized, &T1);\n\n NormalizeIsotropicPoints(x2, &x2_normalized, &T2);\n\n\n\n Solver::Solve(x1_normalized, x2_normalized, models);\n\n\n\n for (int i = 0; i < models->size(); ++i) {\n\n Unnormalizer::Unnormalize(T1, T2, &(*models)[i]);\n\n }\n\n }\n", "file_path": "src/libmv/multiview/two_view_kernel.h", "rank": 15, "score": 286783.9462379181 }, { "content": "class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n\n // The usual test fixture members go here too.\n\n};\n\n\n\nTEST_F(BaseTest, HasFoo) {\n\n // This is an ordinary non-parameterized test.\n\n}\n\n\n\nTEST_P(DerivedTest, DoesBlah) {\n\n // GetParam works just the same here as if you inherit from TestWithParam.\n\n EXPECT_TRUE(foo.Blah(GetParam()));\n\n}\n\n\n\n#endif // 0\n\n\n\n#include \"gtest/internal/gtest-port.h\"\n\n\n\n#if !GTEST_OS_SYMBIAN\n\n# include <utility>\n\n#endif\n", "file_path": "src/third_party/gtest/include/gtest/gtest-param-test.h", "rank": 16, "score": 286610.0542397736 }, { "content": "struct RemoveConst<const T> { typedef T type; }; // NOLINT\n\n\n\n// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above\n\n// definition to fail to remove the const in 'const int[3]' and 'const\n\n// char[3][4]'. The following specialization works around the bug.\n\n// However, it causes trouble with GCC and thus needs to be\n\n// conditionally compiled.\n\n#if defined(_MSC_VER) || defined(__SUNPRO_CC) || defined(__IBMCPP__)\n\ntemplate <typename T, size_t N>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 17, "score": 284762.96454498696 }, { "content": "struct vec2 {\n\n float x,y;\n\n inline vec2(float x, float y):x(x),y(y){}\n\n};\n\ninline vec2 operator*(mat32 m, vec2 v) {\n\n return vec2(v.x*m(0,0)+v.y*m(0,1)+m(0,2),v.x*m(1,0)+v.y*m(1,1)+m(1,2));\n\n}\n\n\n\n//! fixed point bilinear sample with precision k\n\ntemplate <int k> inline int sample(const ubyte* image,int stride, int x, int y, int u, int v) {\n\n const ubyte* s = &image[y*stride+x];\n\n return ((s[ 0] * (k-u) + s[ 1] * u) * (k-v)\n\n + (s[stride] * (k-u) + s[stride+1] * u) * ( v) ) / (k*k);\n\n}\n\n\n\n#ifdef __SSE__\n\n#include <xmmintrin.h>\n\nint lround(float x) { return _mm_cvtss_si32(_mm_set_ss(x)); }\n\n#elif defined(_MSC_VER)\n\nint lround(float x) { return x+0.5; }\n", "file_path": "src/libmv/tracking/sad.cc", "rank": 18, "score": 283572.3485166205 }, { "content": "struct ByRef { typedef const T& type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 19, "score": 282784.30618238845 }, { "content": "struct Offset;\n\n\n", "file_path": "src/libmv/simple_pipeline/camera_intrinsics.h", "rank": 20, "score": 278967.47144128813 }, { "content": "struct RemoveConst { typedef T type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 21, "score": 266655.4776928237 }, { "content": "// Helper for suppressing false warning from Clang on a const char*\n\n// variable declared in a conditional expression always being NULL in\n\n// the else branch.\n\nstruct GTEST_API_ ConstCharPtr {\n\n ConstCharPtr(const char* str) : value(str) {}\n\n operator bool() const { return true; }\n\n const char* value;\n\n};\n\n\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 22, "score": 259234.63678365923 }, { "content": "// A derived feature with a tag, so that it is possible to check that the right\n\n// features are produced by the iterators.\n\nstruct MyPoint : public Feature {\n\n virtual ~MyPoint() {}\n\n MyPoint(int the_tag) : tag(the_tag) {}\n\n int tag;\n\n};\n\n\n", "file_path": "src/libmv/correspondence/matches_test.cc", "rank": 23, "score": 247280.1636746919 }, { "content": "// A derived feature with a tag, so that it is possible to check that the right\n\n// features are produced by the iterators.\n\nstruct MyPoint : public Feature {\n\n virtual ~MyPoint() {}\n\n MyPoint() {}\n\n MyPoint(int the_tag) : tag(the_tag) {}\n\n int tag;\n\n};\n\n\n", "file_path": "src/libmv/correspondence/feature_set_test.cc", "rank": 24, "score": 243260.07501348708 }, { "content": "struct SiblingTestFeature : public Feature {\n\n virtual ~SiblingTestFeature() {}\n\n};\n\n\n\nTEST(Matches, Views) {\n\n Matches matches;\n\n matches.Insert(1, 1, new SiblingTestFeature);\n\n matches.Insert(1, 2, new MyPoint(30));\n\n matches.Insert(1, 4, new SiblingTestFeature);\n\n Matches::Features<Feature> r1 = matches.All<Feature>();\n\n ++r1; // Ordering means the test feature will be 2nd.\n\n ASSERT_TRUE(r1);\n\n EXPECT_TRUE(r1.feature() != NULL);\n\n EXPECT_EQ(1, r1.image());\n\n EXPECT_EQ(2, r1.track());\n\n\n\n Matches::Features<MyPoint> r = matches.All<MyPoint>();\n\n ASSERT_TRUE(r);\n\n ASSERT_TRUE(r.feature() != NULL);\n\n EXPECT_EQ(30, r.feature()->tag);\n", "file_path": "src/libmv/correspondence/matches_test.cc", "rank": 25, "score": 239407.62100615233 }, { "content": "struct SiblingTestFeature : public Feature {\n\n virtual ~SiblingTestFeature() {}\n\n};\n\n\n\n\n\nTEST(FeatureSet, New) {\n\n FeatureSet features;\n\n\n\n // Create a feature.\n\n FeatureSet::Iterator<MyPoint> it = features.New<MyPoint>();\n\n // Use it.\n\n it.feature().tag = 3;\n\n}\n\n\n\nTEST(FeatureSet, Insert) {\n\n FeatureSet features;\n\n // Insert a feature by copying its contents.\n\n FeatureSet::Iterator<MyPoint> it = features.Insert<MyPoint>(MyPoint(1));\n\n EXPECT_EQ(1, it.feature().tag);\n\n it = features.Insert<MyPoint>(MyPoint(2));\n", "file_path": "src/libmv/correspondence/feature_set_test.cc", "rank": 26, "score": 235712.53044621047 }, { "content": "struct IteratorTraits<const T*> {\n\n typedef T value_type;\n\n};\n\n\n\n#if GTEST_OS_WINDOWS\n\n# define GTEST_PATH_SEP_ \"\\\\\"\n\n# define GTEST_HAS_ALT_PATH_SEP_ 1\n\n// The biggest signed integer type the compiler supports.\n\ntypedef __int64 BiggestInt;\n\n#else\n\n# define GTEST_PATH_SEP_ \"/\"\n\n# define GTEST_HAS_ALT_PATH_SEP_ 0\n\ntypedef long long BiggestInt; // NOLINT\n\n#endif // GTEST_OS_WINDOWS\n\n\n\n// Utilities for char.\n\n\n\n// isspace(int ch) and friends accept an unsigned char or EOF. char\n\n// may be signed, depending on the compiler (or compiler flags).\n\n// Therefore we need to cast a char to unsigned char before calling\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-port.h", "rank": 27, "score": 235534.03955138955 }, { "content": "struct is_pointer : public false_type {};\n\n\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-port.h", "rank": 28, "score": 235442.537816223 }, { "content": "class TestWithParam : public Test, public WithParamInterface<T> {\n\n};\n\n\n\n#endif // GTEST_HAS_PARAM_TEST\n\n\n\n// Macros for indicating success/failure in test code.\n\n\n\n// ADD_FAILURE unconditionally adds a failure to the current test.\n\n// SUCCEED generates a success - it doesn't automatically make the\n\n// current test successful, as a test is only successful when it has\n\n// no failure.\n\n//\n\n// EXPECT_* verifies that a certain condition is satisfied. If not,\n\n// it behaves like ADD_FAILURE. In particular:\n\n//\n\n// EXPECT_TRUE verifies that a Boolean condition is true.\n\n// EXPECT_FALSE verifies that a Boolean condition is false.\n\n//\n\n// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except\n\n// that they will also abort the current function on failure. People\n", "file_path": "src/third_party/gtest/include/gtest/gtest.h", "rank": 29, "score": 234386.31551681436 }, { "content": "struct VectorTest : public testing::Test {\n\n VectorTest() {\n\n foo_construct_calls = 0;\n\n foo_destruct_calls = 0;\n\n }\n\n};\n\n\n\nTEST_F(VectorTest, EmptyVectorDoesNotConstruct) {\n\n {\n\n vector<Foo> v;\n\n EXPECT_EQ(0, v.size());\n\n EXPECT_EQ(0, v.capacity());\n\n }\n\n EXPECT_EQ(0, foo_construct_calls);\n\n EXPECT_EQ(0, foo_destruct_calls);\n\n}\n\n\n\nTEST_F(VectorTest, DestructorGetsCalled) {\n\n {\n\n vector<Foo> v;\n", "file_path": "src/libmv/base/vector_test.cc", "rank": 30, "score": 232203.80611773022 }, { "content": "struct vec2 {\n\n float x, y;\n\n inline vec2() : x(0), y(0) {}\n\n inline vec2(float x, float y) : x(x), y(y) {}\n\n inline vec2(float v[2]) : x(v[0]), y(v[1]) {}\n\n#ifdef QSTRING_H\n\n inline QString toString() const {\n\n return QString(\"%1 %2\").arg(x, 0, 'f', 2).arg(y, 0, 'f', 2);\n\n }\n\n#endif\n\n};\n\ninline vec2 operator -( vec2 a ) { return vec2( -a.x, -a.y ); }\n\ninline vec2 operator +( vec2 a, vec2 b ) { return vec2( a.x+b.x, a.y+b.y ); }\n\ninline vec2 operator +( vec2 a, float b ) { return vec2( a.x+b, a.y+b ); }\n\ninline vec2 operator -( vec2 a, vec2 b ) { return vec2( a.x-b.x, a.y-b.y ); }\n\ninline vec2 operator -( vec2 a, float b ) { return vec2( a.x-b, a.y-b ); }\n\ninline vec2 operator *( float b, vec2 a ) { return vec2( a.x*b, a.y*b ); }\n\ninline vec2 operator /( vec2 a, float b ) { return vec2( a.x/b, a.y/b ); }\n\ninline vec2 operator /( float a, vec2 b ) { return vec2( a/b.x, a/b.y ); }\n\ninline vec2 operator /( vec2 a, vec2 b ) { return vec2( a.x/b.x, a.y/b.y ); }\n\ninline bool operator <( vec2 a, vec2 b ) { return a.x < b.x && a.y < b.y; }\n\ninline bool operator >( vec2 a, vec2 b ) { return a.x > b.x && a.y > b.y; }\n\n\n", "file_path": "src/ui/tracker/gl.h", "rank": 31, "score": 230041.56244879367 }, { "content": " struct sched_param param;\n", "file_path": "src/third_party/pthreads-w32/include/implement.h", "rank": 32, "score": 227651.59242372168 }, { "content": " const MatrixType& pseudoEigenvectors() const\n\n {\n\n eigen_assert(m_isInitialized && \"EigenSolver is not initialized.\");\n\n eigen_assert(m_eigenvectorsOk && \"The eigenvectors have not been computed together with the eigenvalues.\");\n\n return m_eivec;\n", "file_path": "src/third_party/eigen/Eigen/src/Eigenvalues/EigenSolver.h", "rank": 33, "score": 226779.45656848067 }, { "content": "struct EightPointRelativePoseSolver {\n\n enum { MINIMUM_SAMPLES = 8 };\n\n static void Solve(const Mat &x1, const Mat &x2, vector<Mat3> *E);\n\n};\n\n\n\n//-- Generic Solver for the 5pt Essential Matrix Estimation.\n\n//-- Need a new Class that inherit of two_view::kernel::kernel.\n\n// Error must be overwrite in order to compute F from E and K's.\n\n//-- Fitting must normalize image values to camera values.\n\ntemplate<typename SolverArg,\n\n typename ErrorArg,\n\n typename ModelArg = Mat3>\n", "file_path": "src/libmv/multiview/essential_kernel.h", "rank": 34, "score": 225391.3955036822 }, { "content": "struct SevenPointTest : public testing::Test {\n\n void ExpectKernelProperties(const Mat &x1,\n\n const Mat &x2,\n\n Mat3 *F_expected = NULL) {\n\n Kernel kernel(x1, x2);\n\n vector<int> samples;\n\n for (int i = 0; i < x1.cols(); ++i) {\n\n samples.push_back(i);\n\n }\n\n vector<Mat3> Fs;\n\n kernel.Fit(samples, &Fs);\n\n bool found = false; // Need to search for expected answer.\n\n EXPECT_TRUE(Fs.size() != 0);\n\n for (int i = 0; i < Fs.size(); ++i) {\n\n ExpectFundamentalProperties(Fs[i], x1, x2, 1e-8);\n\n if (F_expected) {\n\n found |= Colinear(Fs[i], *F_expected, 1e-6);\n\n }\n\n }\n\n if (F_expected) {\n", "file_path": "src/libmv/multiview/fundamental_kernel_test.cc", "rank": 35, "score": 224961.5395519921 }, { "content": "struct MatchingKernelTest : public testing::Test {\n\n};\n\n\n\n// Test :\n\n// - Libmv Kdtree,\n\n// - Linear matching FLANN,\n\n// - FLANN Kdtree.\n\ntypedef Types< ArrayMatcher_Kdtree<float>,\n\n ArrayMatcher_BruteForce<float>,\n\n ArrayMatcher_Kdtree_Flann<float>\n\n > MatchingKernelImpl;\n\n\n\nTYPED_TEST_CASE(MatchingKernelTest, MatchingKernelImpl);\n\n\n\nTYPED_TEST(MatchingKernelTest, MatcherInterfaceSymmetry)\n\n{\n\n int descriptorSize = 2;\n\n // Build one feature set.\n\n FeatureSet featureSet;\n\n for (int i=0; i < 4; ++i)\n", "file_path": "src/libmv/correspondence/Array_Matcher_test.cc", "rank": 36, "score": 224961.5395519921 }, { "content": "struct EuclideanKernelTest : public testing::Test {\n\n};\n\n\n\ntypedef Types<Kernel>\n\n EuclideanKernelImplementations;\n\n\n\nTYPED_TEST_CASE(EuclideanKernelTest, EuclideanKernelImplementations);\n\n\n\nTYPED_TEST(EuclideanKernelTest, Fitting) {\n\n // Define a few euclidean transformations.\n\n vector<Mat3> H_gt(3);\n\n\n\n H_gt[0] = Mat3::Identity();\n\n \n\n H_gt[1] << 1, 0, -4,\n\n 0, 1, 5,\n\n 0, 0, 1;\n\n double angle = 0.3;\n\n H_gt[2] << cos(angle),-sin(angle), 3,\n\n sin(angle), cos(angle), -6,\n", "file_path": "src/libmv/multiview/euclidean_kernel_test.cc", "rank": 37, "score": 224961.5395519921 }, { "content": "struct SimilarityKernelTest : public testing::Test {\n\n};\n\n\n\ntypedef Types<Kernel,\n\n UnnormalizedKernel>\n\n SimilarityKernelImplementations;\n\n\n\nTYPED_TEST_CASE(SimilarityKernelTest, SimilarityKernelImplementations);\n\n\n\nTYPED_TEST(SimilarityKernelTest, Fitting) {\n\n // Define a few similarities.\n\n vector<Mat3> H_gt(3);\n\n\n\n H_gt[0] = Mat3::Identity();\n\n \n\n double angle = 0.3;\n\n double scale = 1;\n\n H_gt[1] << scale*cos(angle),-scale*sin(angle), -4,\n\n scale*sin(angle), scale*cos(angle), 5,\n\n 0, 0, 1;\n", "file_path": "src/libmv/multiview/similarity_kernel_test.cc", "rank": 38, "score": 224961.5395519921 }, { "content": "struct AffineKernelTest : public testing::Test {\n\n};\n\n\n\ntypedef Types<Kernel,\n\n UnnormalizedKernel>\n\n AffineKernelImplementations;\n\n\n\nTYPED_TEST_CASE(AffineKernelTest, AffineKernelImplementations);\n\n\n\nTYPED_TEST(AffineKernelTest, Fitting) {\n\n // Define a few affinities.\n\n vector<Mat3> H_gt(3);\n\n\n\n H_gt[0] = Mat3::Identity();\n\n H_gt[1] << 1, 0, -4,\n\n 0, 1, 5,\n\n 0, 0, 1;\n\n H_gt[2] << 1, -2, 3,\n\n 4, 5, -6,\n\n 0, 0, 1;\n", "file_path": "src/libmv/multiview/affine_kernel_test.cc", "rank": 39, "score": 224961.5395519921 }, { "content": "struct HomographyKernelTest : public testing::Test {\n\n};\n\n\n\ntypedef Types<Kernel,\n\n UnnormalizedKernel>\n\n HomographyKernelImplementations;\n\n\n\nTYPED_TEST_CASE(HomographyKernelTest, HomographyKernelImplementations);\n\n\n\nTYPED_TEST(HomographyKernelTest, Fitting) {\n\n // Define a few homographies.\n\n vector<Mat3> H_gt(3);\n\n\n\n H_gt[0] = Mat3::Identity();\n\n H_gt[1] << 1, 0, -4,\n\n 0, 1, 5,\n\n 0, 0, 1;\n\n H_gt[2] << 1, -2, 3,\n\n 4, 5, -6,\n\n -7, 8, 1;\n", "file_path": "src/libmv/multiview/homography_kernel_test.cc", "rank": 40, "score": 224961.5395519921 }, { "content": "struct FundamentalErrorTest : public testing::Test {\n\n};\n\n\n\ntypedef Types<SampsonError,\n\n SymmetricEpipolarDistanceError>\n\n FundamentalErrorImplementations;\n\n\n\nTYPED_TEST_CASE(FundamentalErrorTest, FundamentalErrorImplementations);\n\nTYPED_TEST(FundamentalErrorTest, FundamentalErrorTest2) {\n\n Vec3 t(1, 0, 0);\n\n Mat3 F = CrossProductMatrix(t); // Fundamental matrix corresponding to pure\n\n // translation.\n\n\n\n Vec2 x0(0, 0), y0( 0, 0); // Good match (at infinity).\n\n Vec2 x1(0, 0), y1(100, 0); // Good match (no vertical disparity).\n\n Vec2 x2(0, 0), y2(0.0, 0.1); // Small error (a bit of vertical disparity).\n\n Vec2 x3(0, 0), y3( 0, 1); // Bigger error.\n\n Vec2 x4(0, 0), y4( 0, 10); // Biggest error.\n\n Vec2 x5(0, 0), y5(100, 10); // Biggest error with horizontal disparity.\n\n\n", "file_path": "src/libmv/multiview/fundamental_kernel_test.cc", "rank": 41, "score": 224961.5395519921 }, { "content": "struct is_pointer<T*> : public true_type {};\n\n\n\ntemplate <typename Iterator>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-port.h", "rank": 42, "score": 224766.44843841885 }, { "content": " long height;\n", "file_path": "src/third_party/daisy/include/kutility/image_io_png.h", "rank": 43, "score": 220840.26162789448 }, { "content": " long width;\n", "file_path": "src/third_party/daisy/include/kutility/image_io_png.h", "rank": 44, "score": 220838.50891298958 }, { "content": "struct EightPointTest : public SevenPointTest<Kernel> {\n\n};\n\n\n\ntypedef Types<EightPointKernel,\n\n NormalizedEightPointKernel>\n\n EightPointImplementations;\n\n\n\nTYPED_TEST_CASE(EightPointTest, EightPointImplementations);\n\nTYPED_TEST(EightPointTest, EasyCase) {\n\n Mat x1(2, 8);\n\n Mat x2(2, 8);\n\n x1 << 0, 0, 0, 1, 1, 1, 2, 2,\n\n 0, 1, 2, 0, 1, 2, 0, 1;\n\n x2 << 0, 0, 0, 1, 1, 1, 2, 2,\n\n 1, 2, 3, 1, 2, 3, 1, 2;\n\n this->ExpectKernelProperties(x1, x2);\n\n}\n\n\n\n\n\nTYPED_TEST(EightPointTest, RealistCaseWith30Points) {\n\n TwoViewDataSet d = TwoRealisticCameras();\n\n this->ExpectKernelProperties(d.x1, d.x2, &d.F);\n\n}\n\n\n\ntemplate <class Kernel>\n", "file_path": "src/libmv/multiview/fundamental_kernel_test.cc", "rank": 45, "score": 218276.7724421604 }, { "content": "struct AddReference { typedef T& type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 46, "score": 215952.30973640824 }, { "content": "struct AddRef { typedef T& type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 47, "score": 215952.30973640824 }, { "content": "struct RemoveReference { typedef T type; }; // NOLINT\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 48, "score": 215952.30973640824 }, { "content": "class ThreadWithParam : public ThreadWithParamBase {\n\n public:\n\n typedef void (*UserThreadFunc)(T);\n\n\n\n ThreadWithParam(\n\n UserThreadFunc func, T param, Notification* thread_can_start)\n\n : func_(func),\n\n param_(param),\n\n thread_can_start_(thread_can_start),\n\n finished_(false) {\n\n ThreadWithParamBase* const base = this;\n\n // The thread can be created only after all fields except thread_\n\n // have been initialized.\n\n GTEST_CHECK_POSIX_SUCCESS_(\n\n pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));\n\n }\n\n ~ThreadWithParam() { Join(); }\n\n\n\n void Join() {\n\n if (!finished_) {\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-port.h", "rank": 49, "score": 214899.54350370832 }, { "content": "struct StaticAssertTypeEqHelper;\n\n\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-port.h", "rank": 50, "score": 214152.1554432972 }, { "content": "struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 51, "score": 212614.16172251722 }, { "content": "struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 52, "score": 212611.25652004164 }, { "content": "struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 53, "score": 212610.93419938145 }, { "content": "struct has_none {int a[1];};\n", "file_path": "src/third_party/eigen/Eigen/src/Core/util/Meta.h", "rank": 54, "score": 212517.55153563494 }, { "content": "struct ByRef<T&> { typedef T& type; }; // NOLINT\n\n\n\n// A handy wrapper for ByRef.\n\n#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type\n\n\n\n// AddRef<T>::type is T if T is a reference; otherwise it's T&. This\n\n// is the same as tr1::add_reference<T>::type.\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 55, "score": 211432.29491379164 }, { "content": "struct LazyProductReturnType : public ProductReturnType<Lhs,Rhs,LazyCoeffBasedProductMode>\n\n{};\n\n\n\n/***********************************************************************\n\n* Implementation of Inner Vector Vector Product\n\n***********************************************************************/\n\n\n\n// FIXME : maybe the \"inner product\" could return a Scalar\n\n// instead of a 1x1 matrix ??\n\n// Pro: more natural for the user\n\n// Cons: this could be a problem if in a meta unrolled algorithm a matrix-matrix\n\n// product ends up to a row-vector times col-vector product... To tackle this use\n\n// case, we could have a specialization for Block<MatrixType,1,1> with: operator=(Scalar x);\n\n\n\nnamespace internal {\n\n\n\ntemplate<typename Lhs, typename Rhs>\n", "file_path": "src/third_party/eigen/Eigen/src/Core/Product.h", "rank": 56, "score": 211153.28704641882 }, { "content": " class Iterator : public ParamIteratorInterface<ParamType> {\n\n public:\n\n Iterator(const ParamGeneratorInterface<ParamType>* base,\n\n const ParamGenerator<T1>& g1,\n\n const typename ParamGenerator<T1>::iterator& current1,\n\n const ParamGenerator<T2>& g2,\n\n const typename ParamGenerator<T2>::iterator& current2,\n\n const ParamGenerator<T3>& g3,\n\n const typename ParamGenerator<T3>::iterator& current3,\n\n const ParamGenerator<T4>& g4,\n\n const typename ParamGenerator<T4>::iterator& current4,\n\n const ParamGenerator<T5>& g5,\n\n const typename ParamGenerator<T5>::iterator& current5,\n\n const ParamGenerator<T6>& g6,\n\n const typename ParamGenerator<T6>::iterator& current6,\n\n const ParamGenerator<T7>& g7,\n\n const typename ParamGenerator<T7>::iterator& current7,\n\n const ParamGenerator<T8>& g8,\n\n const typename ParamGenerator<T8>::iterator& current8,\n\n const ParamGenerator<T9>& g9,\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-param-util-generated.h", "rank": 57, "score": 210245.4281016344 }, { "content": "struct AddReference<T&> { typedef T& type; }; // NOLINT\n\n\n\n// A handy wrapper around AddReference that works when the argument T\n\n// depends on template parameters.\n\n#define GTEST_ADD_REFERENCE_(T) \\\n\n typename ::testing::internal::AddReference<T>::type\n\n\n\n// Adds a reference to const on top of T as necessary. For example,\n\n// it transforms\n\n//\n\n// char ==> const char&\n\n// const char ==> const char&\n\n// char& ==> const char&\n\n// const char& ==> const char&\n\n//\n\n// The argument T must depend on some template parameters.\n\n#define GTEST_REFERENCE_TO_CONST_(T) \\\n\n GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))\n\n\n\n// ImplicitlyConvertible<From, To>::value is a compile-time bool\n\n// constant that's true iff type From can be implicitly converted to\n\n// type To.\n\ntemplate <typename From, typename To>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 58, "score": 208218.41866646786 }, { "content": "struct AddRef<T&> { typedef T& type; }; // NOLINT\n\n\n\n// A handy wrapper for AddRef.\n\n#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type\n\n\n\n// A helper for implementing get<k>().\n\ntemplate <int k> class Get;\n\n\n\n// A helper for implementing tuple_element<k, T>. kIndexValid is true\n\n// iff k < the number of fields in tuple type T.\n\ntemplate <bool kIndexValid, int kIndex, class Tuple>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 59, "score": 208218.41866646786 }, { "content": "struct RemoveReference<T&> { typedef T type; }; // NOLINT\n\n\n\n// A handy wrapper around RemoveReference that works when the argument\n\n// T depends on template parameters.\n\n#define GTEST_REMOVE_REFERENCE_(T) \\\n\n typename ::testing::internal::RemoveReference<T>::type\n\n\n\n// Removes const from a type if it is a const type, otherwise leaves\n\n// it unchanged. This is the same as tr1::remove_const, which is not\n\n// widely available yet.\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-internal.h", "rank": 60, "score": 208218.41866646786 }, { "content": " class Iterator : public ParamIteratorInterface<T> {\n\n public:\n\n Iterator(const ParamGeneratorInterface<T>* base,\n\n typename ContainerType::const_iterator iterator)\n\n : base_(base), iterator_(iterator) {}\n\n virtual ~Iterator() {}\n\n\n\n virtual const ParamGeneratorInterface<T>* BaseGenerator() const {\n\n return base_;\n\n }\n\n virtual void Advance() {\n\n ++iterator_;\n\n value_.reset();\n\n }\n\n virtual ParamIteratorInterface<T>* Clone() const {\n\n return new Iterator(*this);\n\n }\n\n // We need to use cached value referenced by iterator_ because *iterator_\n\n // can return a temporary object (and of type other then T), so just\n\n // having \"return &*iterator_;\" doesn't work.\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-param-util.h", "rank": 61, "score": 208214.66940753855 }, { "content": "struct has_std_result_type {int a[2];};\n", "file_path": "src/third_party/eigen/Eigen/src/Core/util/Meta.h", "rank": 62, "score": 207468.68356254126 }, { "content": "class RangeGenerator : public ParamGeneratorInterface<T> {\n\n public:\n\n RangeGenerator(T begin, T end, IncrementT step)\n\n : begin_(begin), end_(end),\n\n step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}\n\n virtual ~RangeGenerator() {}\n\n\n\n virtual ParamIteratorInterface<T>* Begin() const {\n\n return new Iterator(this, begin_, 0, step_);\n\n }\n\n virtual ParamIteratorInterface<T>* End() const {\n\n return new Iterator(this, end_, end_index_, step_);\n\n }\n\n\n\n private:\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-param-util.h", "rank": 63, "score": 205241.87380426304 }, { "content": "class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {\n\n public:\n\n template <typename ForwardIterator>\n\n ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)\n\n : container_(begin, end) {}\n\n virtual ~ValuesInIteratorRangeGenerator() {}\n\n\n\n virtual ParamIteratorInterface<T>* Begin() const {\n\n return new Iterator(this, container_.begin());\n\n }\n\n virtual ParamIteratorInterface<T>* End() const {\n\n return new Iterator(this, container_.end());\n\n }\n\n\n\n private:\n\n typedef typename ::std::vector<T> ContainerType;\n\n\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-param-util.h", "rank": 64, "score": 199586.66588546993 }, { "content": "class BaseTest : public ::testing::Test {\n\n // You can inherit all the usual members for a non-parameterized test\n\n // fixture here.\n\n};\n\n\n", "file_path": "src/third_party/gtest/include/gtest/gtest-param-test.h", "rank": 65, "score": 199186.17146323342 }, { "content": "struct TuplePrefixPrinter<0> {\n\n template <typename Tuple>\n\n static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}\n\n\n\n template <typename Tuple>\n\n static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}\n\n};\n\n// We have to specialize the entire TuplePrefixPrinter<> class\n\n// template here, even though the definition of\n\n// TersePrintPrefixToStrings() is the same as the generic version, as\n\n// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't\n\n// support specializing a method template of a class template.\n\ntemplate <>\n", "file_path": "src/third_party/gtest/include/gtest/gtest-printers.h", "rank": 66, "score": 197611.20092292287 }, { "content": "struct TuplePrefixPrinter<1> {\n\n template <typename Tuple>\n\n static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {\n\n UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::\n\n Print(::std::tr1::get<0>(t), os);\n\n }\n\n\n\n template <typename Tuple>\n\n static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {\n\n ::std::stringstream ss;\n\n UniversalTersePrint(::std::tr1::get<0>(t), &ss);\n\n strings->push_back(ss.str());\n\n }\n\n};\n\n\n\n// Helper function for printing a tuple. T must be instantiated with\n\n// a tuple type.\n\ntemplate <typename T>\n\nvoid PrintTupleTo(const T& t, ::std::ostream* os) {\n\n *os << \"(\";\n", "file_path": "src/third_party/gtest/include/gtest/gtest-printers.h", "rank": 67, "score": 197610.56254259608 }, { "content": "struct SameSizeTuplePrefixComparator<0, 0> {\n\n template <class Tuple1, class Tuple2>\n\n static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {\n\n return true;\n\n }\n\n};\n\n\n\ntemplate <int k>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 68, "score": 197433.93964030355 }, { "content": "struct StaticAssertTypeEqHelper<T, T> {};\n\n\n\n#if GTEST_HAS_GLOBAL_STRING\n\ntypedef ::string string;\n\n#else\n\ntypedef ::std::string string;\n\n#endif // GTEST_HAS_GLOBAL_STRING\n\n\n\n#if GTEST_HAS_GLOBAL_WSTRING\n\ntypedef ::wstring wstring;\n\n#elif GTEST_HAS_STD_WSTRING\n\ntypedef ::std::wstring wstring;\n\n#endif // GTEST_HAS_GLOBAL_WSTRING\n\n\n\n// A helper for suppressing warnings on constant condition. It just\n\n// returns 'condition'.\n\nGTEST_API_ bool IsTrue(bool condition);\n\n\n\n// Defines scoped_ptr.\n\n\n\n// This implementation of scoped_ptr is PARTIAL - it only contains\n\n// enough stuff to satisfy Google Test's need.\n\ntemplate <typename T>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-port.h", "rank": 69, "score": 196192.9215452183 }, { "content": " Mat46 X;\n", "file_path": "src/libmv/multiview/sixpointnview.h", "rank": 70, "score": 195738.85546696547 }, { "content": "struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 71, "score": 195339.32252121187 }, { "content": "struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 72, "score": 195339.32252121187 }, { "content": "struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 73, "score": 195339.32252121187 }, { "content": "struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 74, "score": 195339.32252121187 }, { "content": "struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 75, "score": 195339.32252121187 }, { "content": "struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };\n\n\n\n} // namespace gtest_internal\n\n\n\ntemplate <>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 76, "score": 195339.32252121187 }, { "content": "struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };\n\n\n\ntemplate <GTEST_10_TYPENAMES_(T)>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-tuple.h", "rank": 77, "score": 195339.32252121187 }, { "content": "class ParameterizedTestFactory : public TestFactoryBase {\n\n public:\n\n typedef typename TestClass::ParamType ParamType;\n\n explicit ParameterizedTestFactory(ParamType parameter) :\n\n parameter_(parameter) {}\n\n virtual Test* CreateTest() {\n\n TestClass::SetParam(&parameter_);\n\n return new TestClass();\n\n }\n\n\n\n private:\n\n const ParamType parameter_;\n\n\n\n GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);\n\n};\n\n\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n\n//\n\n// TestMetaFactoryBase is a base class for meta-factories that create\n\n// test factories for passing into MakeAndRegisterTestInfo function.\n\ntemplate <class ParamType>\n", "file_path": "src/third_party/gtest/include/gtest/internal/gtest-param-util.h", "rank": 78, "score": 193148.9906074502 }, { "content": "class PolynomialSolver<_Scalar,1> : public PolynomialSolverBase<_Scalar,1>\n\n{\n\n public:\n\n typedef PolynomialSolverBase<_Scalar,1> PS_Base;\n\n EIGEN_POLYNOMIAL_SOLVER_BASE_INHERITED_TYPES( PS_Base )\n\n\n\n public:\n\n /** Computes the complex roots of a new polynomial. */\n\n template< typename OtherPolynomial >\n\n void compute( const OtherPolynomial& poly )\n\n {\n\n assert( Scalar(0) != poly[poly.size()-1] );\n\n m_roots[0] = -poly[0]/poly[poly.size()-1];\n\n }\n\n\n\n protected:\n\n using PS_Base::m_roots;\n\n};\n\n\n\n#endif // EIGEN_POLYNOMIAL_SOLVER_H\n", "file_path": "src/third_party/eigen/unsupported/Eigen/src/Polynomials/PolynomialSolver.h", "rank": 79, "score": 192683.69739125262 }, { "content": "class Calibration : public QWidget, public libmv::CameraIntrinsics {\n\n Q_OBJECT\n\n public:\n\n Calibration(QString path, QSize size);\n\n double Value(int i);\n\n\n\n public slots:\n\n void updateSettings();\n\n\n\n signals:\n\n void settingsChanged();\n\n\n\n private:\n\n QString path_;\n\n QDoubleSpinBox* spinbox_[11];\n\n\n\n};\n\n\n\n#endif\n", "file_path": "src/ui/tracker/calibration.h", "rank": 80, "score": 192463.38856202114 }, { "content": "/// an image in the match graph\n\nstruct Node : public QGraphicsPixmapItem {\n\n//Springs\n\n QMap<Node*,Edge*> edges;\n\n\n\n//RK4 integration\n\n QVector2D position[4];\n\n QVector2D velocity[4];\n\n QVector2D acceleration[4];\n\n};\n\n\n", "file_path": "src/ui/nvr/nview.h", "rank": 81, "score": 191125.72178236695 }, { "content": "// TODO(julien) put this (Edge, node, graph, GraphView) in a widget (.h/.cc)\n\n/// a line linking two nodes\n\nstruct Edge : public QGraphicsLineItem {\n\n Edge(Node* a, Node* b) : a(a), b(b) { setZValue(-1); }\n\n Node* a;\n\n Node* b;\n\n};\n\n\n", "file_path": "src/ui/nvr/nview.h", "rank": 82, "score": 191125.72178236695 }, { "content": " Mat34 P1, P2; // Projection matrix, P = K(R|t)\n", "file_path": "src/libmv/multiview/test_data_sets.h", "rank": 83, "score": 190730.9296564619 }, { "content": " Mat3 K1, K2; // Internal parameters.\n", "file_path": "src/libmv/multiview/test_data_sets.h", "rank": 84, "score": 190729.38573998408 }, { "content": " Mat3X X; // 3D points.\n", "file_path": "src/libmv/multiview/test_data_sets.h", "rank": 85, "score": 190710.15470986185 }, { "content": " class TestName : public CaseName<gtest_TypeParam_> { \\\n\n private: \\\n\n typedef CaseName<gtest_TypeParam_> TestFixture; \\\n\n typedef gtest_TypeParam_ TypeParam; \\\n\n virtual void TestBody(); \\\n\n }; \\\n\n static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\\\n\n __FILE__, __LINE__, #CaseName, #TestName); \\\n\n } \\\n\n template <typename gtest_TypeParam_> \\\n\n void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()\n\n\n\n# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \\\n\n namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n\n typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \\\n\n } \\\n\n static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \\\n\n GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\\\n\n __FILE__, __LINE__, #__VA_ARGS__)\n", "file_path": "src/third_party/gtest/include/gtest/gtest-typed-test.h", "rank": 86, "score": 189540.64648862006 }, { "content": "struct nested<ReturnByValue<Derived>, n, PlainObject>\n\n{\n\n typedef typename traits<Derived>::ReturnType type;\n\n};\n\n\n\n} // end namespace internal\n\n\n\ntemplate<typename Derived> class ReturnByValue\n\n : public internal::dense_xpr_base< ReturnByValue<Derived> >::type\n\n{\n\n public:\n\n typedef typename internal::traits<Derived>::ReturnType ReturnType;\n\n\n\n typedef typename internal::dense_xpr_base<ReturnByValue>::type Base;\n\n EIGEN_DENSE_PUBLIC_INTERFACE(ReturnByValue)\n\n\n\n template<typename Dest>\n\n inline void evalTo(Dest& dst) const\n\n { static_cast<const Derived*>(this)->evalTo(dst); }\n\n inline Index rows() const { return static_cast<const Derived*>(this)->rows(); }\n\n inline Index cols() const { return static_cast<const Derived*>(this)->cols(); }\n\n\n", "file_path": "src/third_party/eigen/Eigen/src/Core/ReturnByValue.h", "rank": 87, "score": 186855.92595096395 }, { "content": "struct blas_traits<const T>\n\n : blas_traits<T>\n\n{};\n\n\n\ntemplate<typename T, bool HasUsableDirectAccess=blas_traits<T>::HasUsableDirectAccess>\n", "file_path": "src/third_party/eigen/Eigen/src/Core/util/BlasUtil.h", "rank": 88, "score": 186430.01658238308 }, { "content": " */\n\n void Undistort(const float* src, float* dst,\n\n int width, int height, int channels);\n\n /*!\n\n Undistort an image using the current camera instrinsics\n\n\n\n The undistorted image is computed in \\a dst using samples from \\a src.\n\n both buffers should be \\a width x \\a height x \\a channels sized.\n\n\n\n \\note This version is much faster.\n\n */\n\n void Undistort(const unsigned char* src, unsigned char* dst,\n\n int width, int height, int channels);\n\n\n\n private:\n\n template<typename WarpFunction> void ComputeLookupGrid(Offset* grid, int width, int height);\n\n void FreeLookupGrid();\n\n\n\n // The traditional intrinsics matrix from x = K[R|t]X.\n\n Mat3 K_;\n", "file_path": "src/libmv/simple_pipeline/camera_intrinsics.h", "rank": 91, "score": 72.20606147585795 }, { "content": " /// Set the entire calibration matrix at once.\n\n void SetK(const Mat3 new_k);\n\n\n\n /// Set both x and y focal length in pixels.\n\n void SetFocalLength(double focal_x, double focal_y);\n\n\n\n void SetPrincipalPoint(double cx, double cy);\n\n\n\n void SetImageSize(int width, int height);\n\n\n\n void SetRadialDistortion(double k1, double k2, double k3 = 0);\n\n\n\n void SetTangentialDistortion(double p1, double p2);\n\n\n\n /*!\n\n Apply camera intrinsics to the normalized point to get image coordinates.\n\n\n\n This applies the lens distortion to a point which is in normalized\n\n camera coordinates (i.e. the principal point is at (0, 0)) to get image\n\n coordinates in pixels.\n", "file_path": "src/libmv/simple_pipeline/camera_intrinsics.h", "rank": 96, "score": 59.67982473890387 }, { "content": "\n\n // This is the size of the image. This is necessary to, for example, handle\n\n // the case of processing a scaled image.\n\n int image_width_;\n\n int image_height_;\n\n\n\n // OpenCV's distortion model with third order polynomial radial distortion\n\n // terms and second order tangential distortion. The distortion is applied to\n\n // the normalized coordinates before the focal length, which makes them\n\n // independent of image size.\n\n double k1_, k2_, k3_, p1_, p2_;\n\n\n\n Offset* distort_;\n\n Offset* undistort_;\n\n};\n\n\n\n} // namespace libmv\n\n\n\n#endif // LIBMV_SIMPLE_PIPELINE_CAMERA_INTRINSICS_H_\n", "file_path": "src/libmv/simple_pipeline/camera_intrinsics.h", "rank": 97, "score": 59.67786224844623 }, { "content": "** IN THE SOFTWARE.\n\n**\n\n****************************************************************************/\n\n\n\n#include \"libmv/tracking/sad.h\"\n\n#include <stdlib.h>\n\n#include <math.h>\n\n\n\nnamespace libmv {\n\n\n\nvoid LaplaceFilter(ubyte* src, ubyte* dst, int width, int height, int strength) {\n\n for(int y=1; y<height-1; y++) for(int x=1; x<width-1; x++) {\n\n const ubyte* s = &src[y*width+x];\n\n int l = 128 +\n\n s[-width-1] + s[-width] + s[-width+1] +\n\n s[1] - 8*s[0] + s[1] +\n\n s[ width-1] + s[ width] + s[ width+1] ;\n\n int d = ((256-strength)*s[0] + strength*l) / 256;\n\n if(d < 0) d=0;\n\n if(d > 255) d=255;\n\n dst[y*width+x] = d;\n\n }\n\n}\n\n\n", "file_path": "src/libmv/tracking/sad.cc", "rank": 98, "score": 59.38872621136846 }, { "content": "#include \"libmv/numeric/numeric.h\"\n\n#include \"libmv/multiview/projection.h\"\n\n#include \"libmv/multiview/triangulation.h\"\n\n\n\nnamespace libmv {\n\n\n\n// HZ 12.2 pag.312\n\nvoid TriangulateDLT(const Mat34 &P1, const Vec2 &x1,\n\n const Mat34 &P2, const Vec2 &x2,\n\n Vec4 *X_homogeneous) {\n\n Mat4 design;\n\n for (int i = 0; i < 4; ++i) {\n\n design(0,i) = x1(0) * P1(2,i) - P1(0,i);\n\n design(1,i) = x1(1) * P1(2,i) - P1(1,i);\n\n design(2,i) = x2(0) * P2(2,i) - P2(0,i);\n\n design(3,i) = x2(1) * P2(2,i) - P2(1,i);\n\n }\n\n Nullspace(&design, X_homogeneous);\n\n}\n\n\n", "file_path": "src/libmv/multiview/triangulation.cc", "rank": 99, "score": 55.98353866653488 } ]
C++
tests/experimental/strong_type/strong_type.t.cpp
tobanteAudio/taetl
0aa6365aa156b297745f395882ff366a8626e5e0
#include "etl/experimental/strong_type/strong_type.hpp" #include "etl/cstdint.hpp" #include "etl/type_traits.hpp" #include "testing/testing.hpp" using namespace etl::experimental; template <typename T> constexpr auto test() -> bool { { using Kilogram = strong_type<T, struct Kilogram_tag>; auto kilo = Kilogram {}; kilo = Kilogram { 0 }; assert((kilo.raw_value() == T { 0 })); } { using Kilo = strong_type<T, struct Kilo_tag>; assert((sizeof(Kilo) == sizeof(typename Kilo::value_type))); assert((etl::is_constructible_v<Kilo>)); assert((etl::is_trivially_constructible_v<Kilo>)); assert((etl::is_nothrow_constructible_v<Kilo>)); assert((etl::is_destructible_v<Kilo>)); assert((etl::is_trivially_destructible_v<Kilo>)); assert((etl::is_nothrow_destructible_v<Kilo>)); assert((etl::is_assignable_v<Kilo, Kilo>)); assert((etl::is_trivially_assignable_v<Kilo, Kilo>)); assert((etl::is_nothrow_assignable_v<Kilo, Kilo>)); assert((etl::is_copy_constructible_v<Kilo>)); assert((etl::is_trivially_copy_constructible_v<Kilo>)); assert((etl::is_nothrow_copy_constructible_v<Kilo>)); assert((etl::is_copy_assignable_v<Kilo>)); assert((etl::is_trivially_copy_assignable_v<Kilo>)); assert((etl::is_nothrow_copy_assignable_v<Kilo>)); assert((etl::is_move_constructible_v<Kilo>)); assert((etl::is_trivially_move_constructible_v<Kilo>)); assert((etl::is_nothrow_move_constructible_v<Kilo>)); assert((etl::is_move_assignable_v<Kilo>)); assert((etl::is_trivially_move_assignable_v<Kilo>)); assert((etl::is_nothrow_move_assignable_v<Kilo>)); assert((etl::is_swappable_v<Kilo>)); assert((etl::is_nothrow_swappable_v<Kilo>)); assert((!etl::has_virtual_destructor_v<Kilo>)); } { using Kilo = strong_type<T, struct Kilo_tag, skill::addable>; auto const lhs = Kilo(1); auto const rhs = Kilo(2); auto const sum = lhs + rhs; assert((sum.raw_value() == T(3))); } { using Kilo = strong_type<T, struct Kilo_tag, skill::subtractable>; auto const lhs = Kilo(2); auto const rhs = Kilo(1); auto const sum = lhs - rhs; assert((sum.raw_value() == T(1))); } { using Kilo = strong_type<T, struct Kilo_tag, skill::multipliable>; auto const lhs = Kilo(2); auto const rhs = Kilo(2); auto const sum = lhs * rhs; assert((sum.raw_value() == T(4))); } { using Kilo = strong_type<T, struct Kilo_tag, skill::divisible>; auto const lhs = Kilo(2); auto const rhs = Kilo(2); auto const sum = lhs / rhs; assert((sum.raw_value() == T(1))); } { using Hertz = strong_type<T, struct Hertz_tag, skill::comparable>; auto const lhs = Hertz { typename Hertz::value_type(44) }; auto const rhs = Hertz { typename Hertz::value_type(48) }; assert((lhs.raw_value() == typename Hertz::value_type(44))); assert((rhs.raw_value() == typename Hertz::value_type(48))); assert((lhs < rhs)); assert((!(lhs > rhs))); assert((lhs <= rhs)); assert((!(lhs >= rhs))); assert((lhs != rhs)); assert((!(lhs == rhs))); } return true; } constexpr auto test_all() -> bool { assert(test<etl::uint8_t>()); assert(test<etl::int8_t>()); assert(test<etl::uint16_t>()); assert(test<etl::int16_t>()); assert(test<etl::uint32_t>()); assert(test<etl::int32_t>()); assert(test<etl::uint64_t>()); assert(test<etl::int64_t>()); assert(test<float>()); assert(test<double>()); assert(test<long double>()); return true; } auto main() -> int { assert(test_all()); static_assert(test_all()); return 0; }
#include "etl/experimental/strong_type/strong_type.hpp" #include "etl/cstdint.hpp" #include "etl/type_traits.hpp" #include "testing/testing.hpp" using namespace etl::experimental; template <typename T> constexpr auto test() -> bool { { using Kilogram = strong_type<T, struct Kilogram_tag>; auto kilo = Kilogram {}; kilo = Kilogram { 0 }; assert((kilo.raw_value() == T { 0 })); } { using Kilo = strong_type<T, struct Kilo_tag>; assert((sizeof(Kilo) == sizeof(typename Kilo::value_type))); assert((etl:
to const sum = lhs / rhs; assert((sum.raw_value() == T(1))); } { using Hertz = strong_type<T, struct Hertz_tag, skill::comparable>; auto const lhs = Hertz { typename Hertz::value_type(44) }; auto const rhs = Hertz { typename Hertz::value_type(48) }; assert((lhs.raw_value() == typename Hertz::value_type(44))); assert((rhs.raw_value() == typename Hertz::value_type(48))); assert((lhs < rhs)); assert((!(lhs > rhs))); assert((lhs <= rhs)); assert((!(lhs >= rhs))); assert((lhs != rhs)); assert((!(lhs == rhs))); } return true; } constexpr auto test_all() -> bool { assert(test<etl::uint8_t>()); assert(test<etl::int8_t>()); assert(test<etl::uint16_t>()); assert(test<etl::int16_t>()); assert(test<etl::uint32_t>()); assert(test<etl::int32_t>()); assert(test<etl::uint64_t>()); assert(test<etl::int64_t>()); assert(test<float>()); assert(test<double>()); assert(test<long double>()); return true; } auto main() -> int { assert(test_all()); static_assert(test_all()); return 0; }
:is_constructible_v<Kilo>)); assert((etl::is_trivially_constructible_v<Kilo>)); assert((etl::is_nothrow_constructible_v<Kilo>)); assert((etl::is_destructible_v<Kilo>)); assert((etl::is_trivially_destructible_v<Kilo>)); assert((etl::is_nothrow_destructible_v<Kilo>)); assert((etl::is_assignable_v<Kilo, Kilo>)); assert((etl::is_trivially_assignable_v<Kilo, Kilo>)); assert((etl::is_nothrow_assignable_v<Kilo, Kilo>)); assert((etl::is_copy_constructible_v<Kilo>)); assert((etl::is_trivially_copy_constructible_v<Kilo>)); assert((etl::is_nothrow_copy_constructible_v<Kilo>)); assert((etl::is_copy_assignable_v<Kilo>)); assert((etl::is_trivially_copy_assignable_v<Kilo>)); assert((etl::is_nothrow_copy_assignable_v<Kilo>)); assert((etl::is_move_constructible_v<Kilo>)); assert((etl::is_trivially_move_constructible_v<Kilo>)); assert((etl::is_nothrow_move_constructible_v<Kilo>)); assert((etl::is_move_assignable_v<Kilo>)); assert((etl::is_trivially_move_assignable_v<Kilo>)); assert((etl::is_nothrow_move_assignable_v<Kilo>)); assert((etl::is_swappable_v<Kilo>)); assert((etl::is_nothrow_swappable_v<Kilo>)); assert((!etl::has_virtual_destructor_v<Kilo>)); } { using Kilo = strong_type<T, struct Kilo_tag, skill::addable>; auto const lhs = Kilo(1); auto const rhs = Kilo(2); auto const sum = lhs + rhs; assert((sum.raw_value() == T(3))); } { using Kilo = strong_type<T, struct Kilo_tag, skill::subtractable>; auto const lhs = Kilo(2); auto const rhs = Kilo(1); auto const sum = lhs - rhs; assert((sum.raw_value() == T(1))); } { using Kilo = strong_type<T, struct Kilo_tag, skill::multipliable>; auto const lhs = Kilo(2); auto const rhs = Kilo(2); auto const sum = lhs * rhs; assert((sum.raw_value() == T(4))); } { using Kilo = strong_type<T, struct Kilo_tag, skill::divisible>; auto const lhs = Kilo(2); auto const rhs = Kilo(2); au
function_block-random_span
[ { "content": "struct auto_reg {\n\n explicit auto_reg(name_and_tags const& sp, test_func_t func)\n\n {\n\n current_session().add_test(sp, func);\n\n }\n\n};\n\n\n\n} // namespace etl::test\n\n\n\n#endif // ETL_EXPERIMENTAL_TESTING_SESSION_HPP\n", "file_path": "etl/experimental/testing/session.hpp", "rank": 0, "score": 165426.4412585607 }, { "content": "struct hash<bool> {\n\n [[nodiscard]] constexpr auto operator()(bool val) const noexcept\n\n -> etl::size_t\n\n {\n\n return static_cast<etl::size_t>(val);\n\n }\n\n};\n\n/// \\group hash\n\n/// \\module Utility\n\ntemplate <>\n", "file_path": "etl/_functional/hash.hpp", "rank": 1, "score": 161952.26258103538 }, { "content": "struct numeric_limits<bool> {\n\n static constexpr bool is_specialized = true;\n\n\n\n static constexpr auto min() noexcept -> bool { return false; }\n\n static constexpr auto max() noexcept -> bool { return true; }\n\n static constexpr auto lowest() noexcept -> bool { return false; }\n\n\n\n static constexpr int digits = 1;\n\n static constexpr int digits10 = 0;\n\n static constexpr int max_digits10 = 0;\n\n\n\n static constexpr bool is_signed = false;\n\n static constexpr bool is_integer = true;\n\n static constexpr bool is_exact = true;\n\n static constexpr int radix = 2;\n\n static constexpr auto epsilon() noexcept -> bool { return false; }\n\n static constexpr auto round_error() noexcept -> bool { return false; }\n\n\n\n static constexpr int min_exponent = 0;\n\n static constexpr int min_exponent10 = 0;\n", "file_path": "etl/_limits/numeric_limits.hpp", "rank": 2, "score": 155808.3166183316 }, { "content": "struct TestStruct {\n\n};\n\n} // namespace\n\n\n\nTEMPLATE_TEST_CASE(\"template test\", \"\", int, char, float, TestStruct)\n\n{\n\n using T = TestType;\n\n if constexpr (etl::is_arithmetic_v<T>) { CHECK(T(1) > T(0)); }\n\n}\n\n#endif", "file_path": "tests/experimental/testing/test_test_case.cpp", "rank": 3, "score": 152388.2156559367 }, { "content": "struct negation : etl::bool_constant<!bool(B::value)> {\n\n};\n\n\n\n/// \\group negation\n\ntemplate <typename B>\n\ninline constexpr bool negation_v = !bool(B::value);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_NEGATION_HPP", "file_path": "etl/_type_traits/negation.hpp", "rank": 4, "score": 143484.7557115692 }, { "content": "struct uses_allocator_impl<Type, Alloc, void_t<typename Type::allocator_type>>\n\n : is_convertible<Alloc, typename Type::allocator_type>::type {\n\n};\n\n} // namespace detail\n\n\n\n/// \\brief If T has a member typedef allocator_type which is convertible from\n\n/// Alloc, the member constant value is true. Otherwise value is false.\n\ntemplate <typename Type, typename Alloc>\n", "file_path": "etl/_memory/uses_allocator.hpp", "rank": 5, "score": 141735.49435757985 }, { "content": "struct is_empty_helper : etl::bool_constant<sizeof(is_empty_test_struct_1<T>)\n\n == sizeof(is_empty_test_struct_2)> {\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "etl/_type_traits/is_empty.hpp", "rank": 6, "score": 141230.06601029157 }, { "content": "struct test_mutex {\n\n constexpr test_mutex(bool failOnTryLock = false) noexcept\n\n : failOnTryLock_ { failOnTryLock }\n\n {\n\n }\n\n\n\n ~test_mutex() noexcept = default;\n\n\n\n auto operator=(test_mutex const&) -> test_mutex& = delete;\n\n test_mutex(test_mutex const&) = delete;\n\n\n\n auto operator=(test_mutex&&) -> test_mutex& = default;\n\n test_mutex(test_mutex&&) = default;\n\n\n\n constexpr auto lock() noexcept\n\n {\n\n if (not isLocked_) { isLocked_ = true; }\n\n }\n\n\n\n constexpr auto try_lock() noexcept -> bool\n", "file_path": "tests/mutex/test_mutex.hpp", "rank": 7, "score": 137962.20826800514 }, { "content": "struct MovableOnly {\n\n MovableOnly();\n\n\n\n MovableOnly(MovableOnly const&) = delete;\n\n auto operator=(MovableOnly const&) -> MovableOnly& = delete;\n\n\n\n MovableOnly(MovableOnly&&); // NOLINT\n\n auto operator=(MovableOnly&&) -> MovableOnly&; // NOLINT\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 8, "score": 137922.5861796286 }, { "content": "struct Throws {\n\n Throws() noexcept(false); // NOLINT\n\n Throws(Throws const&) noexcept(false); // NOLINT\n\n auto operator=(Throws const&) noexcept(false) -> Throws&; // NOLINT\n\n ~Throws() noexcept(false); // NOLINT\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 9, "score": 137922.5861796286 }, { "content": "struct Abstract {\n\n virtual auto foo() -> void = 0;\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 10, "score": 137922.5861796286 }, { "content": "struct test_case {\n\n name_and_tags info;\n\n test_func_t func;\n\n etl::string_view type_name {};\n\n};\n\n\n\n} // namespace etl::test\n\n\n\n#endif // ETL_EXPERIMENTAL_TESTING_TEST_CASE_HPP\n", "file_path": "etl/experimental/testing/test_case.hpp", "rank": 11, "score": 135513.24556136367 }, { "content": "struct DummyClass {\n\n int i; // NOLINT\n\n float f; // NOLINT\n\n};\n\n\n\nunion EmptyUnion {\n\n};\n\n\n\nunion DummyUnion {\n\n int i; // NOLINT\n\n float f; // NOLINT\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 12, "score": 134924.2939336276 }, { "content": "struct InIter {\n\n using iterator_category = etl::input_iterator_tag;\n\n using value_type = typename etl::iterator_traits<It>::value_type;\n\n using difference_type = typename etl::iterator_traits<It>::difference_type;\n\n using pointer = It;\n\n using reference = typename etl::iterator_traits<It>::reference;\n\n\n\n [[nodiscard]] constexpr auto base() const -> It { return iter_; }\n\n\n\n constexpr InIter() : iter_() { }\n\n explicit constexpr InIter(It it) : iter_(it) { }\n\n\n\n template <typename U>\n\n constexpr InIter(const InIter<U>& u) : iter_(u.iter_)\n\n {\n\n }\n\n\n\n constexpr auto operator*() const -> reference { return *iter_; }\n\n constexpr auto operator->() const -> pointer { return iter_; }\n\n\n", "file_path": "tests/testing/iterator_types.hpp", "rank": 13, "score": 134924.2939336276 }, { "content": "struct EmptyClass {\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 14, "score": 134924.2939336276 }, { "content": "struct CopyAndMovable {\n\n CopyAndMovable();\n\n\n\n CopyAndMovable(CopyAndMovable const&);\n\n auto operator=(CopyAndMovable const&) -> CopyAndMovable&;\n\n\n\n CopyAndMovable(CopyAndMovable&&); // NOLINT\n\n auto operator=(CopyAndMovable&&) -> CopyAndMovable&; // NOLINT\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 15, "score": 134924.2939336276 }, { "content": "struct VirtualDtor {\n\n virtual ~VirtualDtor() noexcept { } // NOLINT\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 16, "score": 134924.2939336276 }, { "content": "struct TrivialDtor {\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 17, "score": 134924.2939336276 }, { "content": "struct TriviallyConstructable {\n\n TriviallyConstructable() = default; // trivial and non-throwing\n\n int n;\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 18, "score": 134924.2939336276 }, { "content": "struct NonTrivialDtor {\n\n ~NonTrivialDtor() { } // NOLINT\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 19, "score": 132097.73278736387 }, { "content": "struct TrivialDtorDefaulted {\n\n ~TrivialDtorDefaulted() = default;\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 20, "score": 132097.73278736387 }, { "content": "struct FwdIter {\n\n using iterator_category = etl::forward_iterator_tag;\n\n using value_type = typename etl::iterator_traits<Iter>::value_type;\n\n using difference_type =\n\n typename etl::iterator_traits<Iter>::difference_type;\n\n using pointer = Iter;\n\n using reference = typename etl::iterator_traits<Iter>::reference;\n\n\n\n [[nodiscard]] constexpr auto base() const -> Iter { return iter_; }\n\n\n\n constexpr FwdIter() = default;\n\n\n\n explicit constexpr FwdIter(Iter it) : iter_ { it } { }\n\n\n\n template <typename U>\n\n constexpr FwdIter(FwdIter<U> const& u) : iter_(u.iter_)\n\n {\n\n }\n\n\n\n [[nodiscard]] constexpr auto operator*() const -> reference\n", "file_path": "tests/testing/iterator_types.hpp", "rank": 21, "score": 132097.73278736387 }, { "content": "struct NonTriviallyConstructable {\n\n NonTriviallyConstructable(int& n) : ref { n } { }\n\n\n\n int& ref;\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 22, "score": 132097.73278736387 }, { "content": "struct is_empty_test_struct_2 {\n\n char dummy_data;\n\n};\n\n\n\ntemplate <typename T, bool = etl::is_class<T>::value>\n", "file_path": "etl/_type_traits/is_empty.hpp", "rank": 23, "score": 129559.40647085034 }, { "content": "struct NonTrivialDtorMember {\n\n NonTrivialDtor member;\n\n};\n\n\n\nusing PointerToMemberObj = int VirtualDtor::*;\n\nusing PointerToConstMemberObj = int const VirtualDtor::*;\n\nusing PointerToVolatileMemberObj = int volatile VirtualDtor::*;\n\nusing PointerToCVMemberObj = int const volatile VirtualDtor::*;\n\n\n\nusing PointerToMemberFunc = void (VirtualDtor::*)();\n\nusing PointerToConstMemberFunc = void (VirtualDtor::*)() const;\n\nusing PointerToVolatileMemberFunc = void (VirtualDtor::*)() volatile;\n\nusing PointerToCVMemberFunc = void (VirtualDtor::*)() const volatile;\n\n\n\n#define TEST_IS_TRAIT(trait, type) \\\n\n do { \\\n\n assert(etl::is_base_of_v<etl::true_type, etl::trait<type>>); \\\n\n assert((etl::trait<type>::value)); \\\n\n assert((etl::TETL_PP_CONCAT(trait, _v) < type >)); \\\n\n } while (false)\n", "file_path": "tests/testing/types.hpp", "rank": 24, "score": 129427.95211605355 }, { "content": "struct test_is_specialized;\n\n\n\ntemplate <>\n", "file_path": "tests/type_traits/type_traits.t.cpp", "rank": 25, "score": 129427.95211605355 }, { "content": "struct is_signed : etl::bool_constant<T(-1) < T(0)> {\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "etl/_type_traits/is_signed.hpp", "rank": 26, "score": 129082.01944952781 }, { "content": "struct is_unsigned : etl::bool_constant<T(0) < T(-1)> {\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "etl/_type_traits/is_unsigned.hpp", "rank": 27, "score": 129082.01944952781 }, { "content": "struct Foo {\n\n constexpr Foo(T first, float second, bool third)\n\n : f { first }, s { second }, t { third }\n\n {\n\n }\n\n\n\n T f;\n\n float s;\n\n bool t;\n\n};\n\n} // namespace\n\n\n\ntemplate <typename T>\n\nconstexpr auto test() -> bool\n\n{\n\n\n\n {\n\n etl::tuple<T, float> t1 { T { 1 }, 2.0F };\n\n etl::ignore_unused(t1);\n\n }\n", "file_path": "tests/tuple/tuple.t.cpp", "rank": 28, "score": 126130.17441645998 }, { "content": "struct Counter {\n\n int& value;\n\n Counter(int& v) : value(v) { }\n\n ~Counter() { value++; }\n\n};\n\nauto some_function() -> void { }\n\n} // namespace\n\n\n\ntemplate <typename T>\n\nauto test() -> bool\n\n{\n\n // \"scalar\"\n\n {\n\n auto deleter = etl::default_delete<T>();\n\n auto* ptr = ::new T {};\n\n deleter(ptr);\n\n }\n\n\n\n // \"array\"\n\n {\n", "file_path": "tests/memory/memory.t.cpp", "rank": 29, "score": 126130.17441645998 }, { "content": "struct S {\n\n S(T d = T(0)) : data { d } { }\n\n\n\n S(S const& s)\n\n {\n\n data = s.data;\n\n copy = true;\n\n }\n\n\n\n S(S&& s) noexcept\n\n {\n\n data = s.data;\n\n move = true;\n\n }\n\n\n\n auto operator=(S const& s) noexcept -> S&\n\n {\n\n data = s.data;\n\n copy = true;\n\n return *this;\n", "file_path": "tests/algorithm/move.t.cpp", "rank": 30, "score": 126130.17441645998 }, { "content": "struct Class {\n\n constexpr Class(T n) : num(n) { }\n\n [[nodiscard]] constexpr auto get_num(T i) const -> T { return num + i; }\n\n T num;\n\n};\n\n\n\ntemplate <typename T>\n\n[[nodiscard]] constexpr auto get_num(T i) -> T\n\n{\n\n return i;\n\n}\n\n\n\n} // namespace\n\n\n\ntemplate <typename T>\n\nconstexpr auto test() -> bool\n\n{\n\n auto lambda = [](T x) -> T { return x; };\n\n assert(etl::invoke(lambda, T(1)) == T(1));\n\n assert(etl::invoke([]() { return T(42); }) == T(42));\n", "file_path": "tests/functional/invoke.t.cpp", "rank": 31, "score": 126130.17441645998 }, { "content": "struct is_empty_test_struct_1 : T {\n\n char dummy_data;\n\n};\n\n\n", "file_path": "etl/_type_traits/is_empty.hpp", "rank": 32, "score": 124679.78890463302 }, { "content": "struct DerivedFromVirtualDtor : VirtualDtor {\n\n};\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 33, "score": 124546.23871814477 }, { "content": "struct is_typename;\n\ntemplate <typename T>\n", "file_path": "etl/_type_traits/decl.hpp", "rank": 34, "score": 124512.65465680821 }, { "content": "struct uses_allocator_impl : false_type {\n\n};\n\n\n\ntemplate <typename Type, typename Alloc>\n", "file_path": "etl/_memory/uses_allocator.hpp", "rank": 35, "score": 124165.57125017996 }, { "content": "struct DummyString {\n\n constexpr DummyString() = default;\n\n constexpr explicit DummyString(DummyStringView /*ignore*/) { }\n\n constexpr operator DummyStringView() const noexcept { return { *this }; }\n\n};\n\nconstexpr DummyStringView::DummyStringView(DummyString const& /*ignore*/) { }\n\n\n\n} // namespace\n\n\n\ntemplate <typename T>\n\nconstexpr auto test() -> bool\n\n{\n\n // explicit ctors\n\n etl::ignore_unused(etl::pair<T, DummyString>(T(0), DummyStringView()));\n\n etl::ignore_unused(etl::pair<T, DummyString>(T(0), DummyString()));\n\n etl::ignore_unused(etl::pair<T, DummyStringView>(T(0), DummyStringView()));\n\n etl::ignore_unused(etl::pair<T, DummyStringView>(T(0), DummyStringView()));\n\n\n\n using etl::is_same_v;\n\n\n", "file_path": "tests/utility/pair.t.cpp", "rank": 36, "score": 122783.71640629112 }, { "content": "struct totals {\n\n constexpr auto operator-(totals const& other) const -> totals;\n\n constexpr auto operator+=(totals const& other) -> totals&;\n\n\n\n [[nodiscard]] constexpr auto delta(totals const& prevtotals) const\n\n -> totals;\n\n\n\n int error { 0 };\n\n counts assertions {};\n\n counts test_cases {};\n\n};\n\n\n\nconstexpr auto counts::operator-(counts const& other) const -> counts\n\n{\n\n auto diff = counts {};\n\n diff.passed = passed - other.passed;\n\n diff.failed = failed - other.failed;\n\n diff.failed_but_ok = failed_but_ok - other.failed_but_ok;\n\n return diff;\n\n}\n", "file_path": "etl/experimental/testing/totals.hpp", "rank": 37, "score": 122783.71640629112 }, { "content": "struct DummyString;\n", "file_path": "tests/utility/pair.t.cpp", "rank": 38, "score": 122783.71640629112 }, { "content": "struct A {\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 39, "score": 122783.71640629112 }, { "content": "struct Vertex {\n\n constexpr Vertex() = default;\n\n constexpr Vertex(T xInit, T yInit, T zInit)\n\n : x { xInit }, y { yInit }, z { zInit }\n\n {\n\n }\n\n\n\n T x {};\n\n T y {};\n\n T z {};\n\n};\n\n\n\ntemplate <typename T>\n\n[[nodiscard]] constexpr auto operator==(\n\n Vertex<T> const& lhs, Vertex<T> const& rhs) -> bool\n\n{\n\n return (lhs.x == rhs.x) && (lhs.y == rhs.y) && (lhs.z == rhs.z);\n\n}\n\n\n\ntemplate <typename T>\n", "file_path": "tests/vector/static_vector.t.cpp", "rank": 40, "score": 122783.71640629112 }, { "content": "struct section {\n\n explicit section(section_info const& info, bool shouldExecute)\n\n : info_ { info }, shouldExecute_ { shouldExecute }\n\n {\n\n }\n\n\n\n [[nodiscard]] constexpr auto info() const noexcept -> section_info const&\n\n {\n\n return info_;\n\n }\n\n\n\n explicit operator bool() const noexcept { return shouldExecute_; }\n\n\n\nprivate:\n\n section_info info_;\n\n counts assertions_ {};\n\n bool shouldExecute_;\n\n};\n\n\n\n} // namespace etl::test\n\n\n\n#endif // ETL_EXPERIMENTAL_TESTING_SECTION_HPP\n", "file_path": "etl/experimental/testing/section.hpp", "rank": 41, "score": 122783.71640629112 }, { "content": "struct session {\n\n template <etl::size_t Capacity>\n\n explicit constexpr session(\n\n session_buffer<Capacity>& buffer, etl::string_view name);\n\n\n\n [[nodiscard]] constexpr auto name() const noexcept -> etl::string_view;\n\n\n\n [[nodiscard]] constexpr auto begin() -> test_case*;\n\n [[nodiscard]] constexpr auto end() -> test_case*;\n\n\n\n [[nodiscard]] auto run_all() -> int;\n\n\n\n constexpr auto add_test(name_and_tags const& spec, test_func_t func,\n\n etl::string_view typeName = {}) -> void;\n\n\n\n auto current_test(test_case* tc) -> void;\n\n\n\n auto pass_assertion(source_line_info const& src, char const* expr) -> void;\n\n auto fail_assertion(\n\n source_line_info const& src, char const* expr, bool terminate) -> void;\n", "file_path": "etl/experimental/testing/session.hpp", "rank": 42, "score": 122783.71640629112 }, { "content": "struct counts {\n\n constexpr auto operator-(counts const& other) const -> counts;\n\n constexpr auto operator+=(counts const& other) -> counts&;\n\n\n\n [[nodiscard]] constexpr auto total() const -> etl::uint16_t;\n\n [[nodiscard]] constexpr auto all_passed() const -> bool;\n\n [[nodiscard]] constexpr auto all_ok() const -> bool;\n\n\n\n etl::uint16_t passed { 0 };\n\n etl::uint16_t failed { 0 };\n\n etl::uint16_t failed_but_ok { 0 };\n\n};\n\n\n", "file_path": "etl/experimental/testing/totals.hpp", "rank": 43, "score": 122783.71640629112 }, { "content": "struct test_is_specialized<Foo<float>> {\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits.t.cpp", "rank": 44, "score": 120128.65133969224 }, { "content": "struct D {\n\n virtual ~D() = default;\n\n};\n\n\n\nunion E {\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 45, "score": 119664.7943170293 }, { "content": "struct C {\n\n [[maybe_unused]] static int m;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 46, "score": 119664.7943170293 }, { "content": "struct IsFinal_A {\n\n int m;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 47, "score": 119664.7943170293 }, { "content": "struct null_clock {\n\n using rep = T;\n\n using period = etl::ratio<1>;\n\n using duration = etl::chrono::duration<rep, period>;\n\n using time_point = etl::chrono::time_point<null_clock>;\n\n bool const is_steady = false;\n\n\n\n [[nodiscard]] constexpr auto now() noexcept -> time_point\n\n {\n\n return time_point {};\n\n }\n\n};\n\n\n\ntemplate <typename T>\n\nconstexpr auto test() -> bool\n\n{\n\n auto null = etl::chrono::time_point<null_clock<T>> {};\n\n assert(null.time_since_epoch().count() == T { 0 });\n\n return true;\n\n}\n", "file_path": "tests/chrono/time_point.t.cpp", "rank": 48, "score": 119664.7943170293 }, { "content": "struct IsPolymorphic_A {\n\n int m;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 49, "score": 119664.7943170293 }, { "content": "struct IsAbstract_A {\n\n int m;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 50, "score": 119664.7943170293 }, { "content": "struct Foo {\n\n T i {};\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits.t.cpp", "rank": 51, "score": 119664.7943170293 }, { "content": "struct section_info {\n\n constexpr section_info(source_line_info const& sli, etl::string_view n)\n\n : name(n), line_info(sli)\n\n {\n\n }\n\n\n\n etl::string_view name;\n\n source_line_info line_info;\n\n};\n\n\n", "file_path": "etl/experimental/testing/section.hpp", "rank": 52, "score": 119664.7943170293 }, { "content": "struct not_specialized {\n\n};\n\n\n\ntemplate <typename T>\n\nconstexpr auto test_identity() -> bool\n\n{\n\n using etl::is_same_v;\n\n using etl::type_identity;\n\n using etl::type_identity_t;\n\n\n\n assert((is_same_v<T, typename type_identity<T>::type>));\n\n assert((is_same_v<T, type_identity_t<T>>));\n\n\n\n // clang-format off\n\n if constexpr (!etl::is_function_v<T>) {\n\n assert((is_same_v<T const, typename type_identity<T const>::type>));\n\n assert((is_same_v<T volatile, typename type_identity<T volatile>::type>));\n\n assert((is_same_v<T const volatile, typename type_identity<T const volatile>::type>));\n\n\n\n assert((is_same_v<T const, type_identity_t<T const>>));\n", "file_path": "tests/type_traits/type_traits.t.cpp", "rank": 53, "score": 119664.7943170293 }, { "content": "struct session_stats {\n\n etl::uint16_t num_test_cases { 0 };\n\n etl::uint16_t num_test_cases_failed { 0 };\n\n\n\n etl::uint16_t num_assertions { 0 };\n\n etl::uint16_t num_assertions_failed { 0 };\n\n};\n\n\n\ntemplate <etl::size_t Capacity>\n\nusing session_buffer = etl::array<test_case, Capacity>;\n\n\n", "file_path": "etl/experimental/testing/session.hpp", "rank": 54, "score": 119664.7943170293 }, { "content": "struct example_task {\n\n auto run() -> void\n\n {\n\n auto loopControl = LoopType {};\n\n while (loopControl()) { rtos::this_task::yield(); }\n\n\n\n rtos::delete_task(nullptr);\n\n }\n\n};\n\n\n\nauto test_all() -> bool\n\n{\n\n\n\n auto task = example_task<rtos::once> {};\n\n\n\n rtos::create_task(task, \"test\", 255);\n\n rtos::start_scheduler();\n\n\n\n // Run would normally be called by rtos::start_scheduler(). Only used\n\n // for stubs.\n\n rtos::rtos_task<example_task<rtos::once>>(static_cast<void*>(&task));\n\n\n\n return true;\n\n}\n\n\n\nauto main() -> int\n\n{\n\n assert(test_all());\n\n return 0;\n\n}", "file_path": "tests/experimental/freertos/task.t.cpp", "rank": 55, "score": 119664.7943170293 }, { "content": "struct B {\n\n int m;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 56, "score": 119664.7943170293 }, { "content": "struct IDS {\n\n};\n\ntemplate <typename T>\n", "file_path": "tests/type_traits/type_traits.t.cpp", "rank": 57, "score": 119664.7943170293 }, { "content": "struct DummyStringView {\n\n constexpr DummyStringView() = default;\n\n constexpr DummyStringView(DummyString const& /*ignore*/);\n\n};\n", "file_path": "tests/utility/pair.t.cpp", "rank": 58, "score": 119664.7943170293 }, { "content": "enum struct ScopedEnum { foo, bar, baz };\n", "file_path": "tests/testing/types.hpp", "rank": 59, "score": 116832.53796450992 }, { "content": "struct result_disposition {\n\n enum flags : unsigned char {\n\n normal = 0x01,\n\n continue_on_failure = 0x02, // Failures test, but execution continues\n\n false_test = 0x04, // Prefix expression with !\n\n suppress_fail = 0x08 // Failures do not fail the test\n\n };\n\n};\n\n\n\n} // namespace etl::test\n\n\n\n#endif // ETL_EXPERIMENTAL_TESTING_RESULT_DUSPOSITION_HPP\n", "file_path": "etl/experimental/testing/result_disposition.hpp", "rank": 60, "score": 116750.96484768388 }, { "content": "struct name_and_tags {\n\n name_and_tags(etl::string_view const& n = etl::string_view(),\n\n etl::string_view const& t = etl::string_view()) noexcept\n\n : name(n), tags(t)\n\n {\n\n }\n\n etl::string_view name;\n\n etl::string_view tags;\n\n};\n\n\n\n} // namespace etl::test\n\n\n\n#endif // ETL_EXPERIMENTAL_TESTING_NAME_AND_TAGS_HPP\n", "file_path": "etl/experimental/testing/name_and_tags.hpp", "rank": 61, "score": 116750.96484768388 }, { "content": "struct IsFinal_D {\n\n virtual ~IsFinal_D() = default;\n\n};\n\n\n\nunion IsFinal_E final {\n\n char data1;\n\n float data2;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 62, "score": 116750.96484768388 }, { "content": "struct IsAbstract_B {\n\n virtual void foo() { }\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 63, "score": 116750.96484768388 }, { "content": "struct assertion_handler {\n\n assertion_handler(source_line_info const& src,\n\n result_disposition::flags flags, char const* expr, bool result)\n\n : src_ { src }\n\n , flags_ { flags }\n\n , expr_ { expr }\n\n , res_ { has_flag(result_disposition::false_test) ? !result : result }\n\n {\n\n if (res_ || has_flag(result_disposition::suppress_fail)) {\n\n current_session().pass_assertion(src_, expr_);\n\n }\n\n if (!res_ && has_flag(result_disposition::normal)) {\n\n current_session().fail_assertion(src_, expr_, true);\n\n }\n\n if (!res_ && has_flag(result_disposition::continue_on_failure)) {\n\n current_session().fail_assertion(src_, expr_, false);\n\n }\n\n }\n\n\n\nprivate:\n", "file_path": "etl/experimental/testing/assertion_handler.hpp", "rank": 64, "score": 116750.96484768388 }, { "content": "struct IsPolymorphic_B {\n\n virtual void foo();\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 65, "score": 116750.96484768388 }, { "content": "struct IsFinal_B {\n\n virtual void foo(); // NOLINT\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 66, "score": 116750.96484768388 }, { "content": "struct IsAbstract_C {\n\n virtual void foo() = 0;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 67, "score": 116750.96484768388 }, { "content": "struct IsPolymorphic_D {\n\n virtual ~IsPolymorphic_D() = default;\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 68, "score": 116750.96484768388 }, { "content": "struct uses_allocator : detail::uses_allocator_impl<Type, Alloc>::type {\n\n};\n\n\n\n/// \\brief If T has a member typedef allocator_type which is convertible from\n\n/// Alloc, the member constant value is true. Otherwise value is false.\n\ntemplate <typename Type, typename Alloc>\n\ninline constexpr auto uses_allocator_v = uses_allocator<Type, Alloc>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_MEMORY_USES_ALLOCATOR_HPP", "file_path": "etl/_memory/uses_allocator.hpp", "rank": 69, "score": 116198.55319805813 }, { "content": "enum struct ScopedEnumWithType : long { v1, v2 };\n\n\n", "file_path": "tests/testing/types.hpp", "rank": 70, "score": 114559.60252783047 }, { "content": "struct source_line_info {\n\n source_line_info() = delete;\n\n\n\n constexpr source_line_info(char const* f, etl::size_t l) noexcept\n\n : file { f }, line { l }\n\n {\n\n }\n\n\n\n char const* file;\n\n etl::size_t line;\n\n};\n\n\n\n} // namespace etl::test\n\n\n\n#define TEST_DETAIL_SOURCE_LINE_INFO \\\n\n etl::test::source_line_info(__FILE__, static_cast<etl::size_t>(__LINE__))\n\n\n\n#endif // ETL_EXPERIMENTAL_TESTING_SOURCE_LINE_INFO_HPP\n", "file_path": "etl/experimental/testing/source_line_info.hpp", "rank": 71, "score": 111462.65814309189 }, { "content": "struct IsAbstract_D : IsAbstract_C {\n\n};\n\n\n\n} // namespace\n\n\n\nconstexpr auto test_all() -> bool\n\n{\n\n using etl::make_signed_t;\n\n TEST_TRAIT_TYPE(make_signed, etl::int8_t, etl::int8_t);\n\n TEST_TRAIT_TYPE(make_signed, etl::int16_t, etl::int16_t);\n\n TEST_TRAIT_TYPE(make_signed, etl::int32_t, etl::int32_t);\n\n TEST_TRAIT_TYPE(make_signed, etl::int64_t, etl::int64_t);\n\n\n\n TEST_TRAIT_TYPE(make_signed, etl::uint8_t, etl::int8_t);\n\n TEST_TRAIT_TYPE(make_signed, etl::uint16_t, etl::int16_t);\n\n TEST_TRAIT_TYPE(make_signed, etl::uint32_t, etl::int32_t);\n\n TEST_TRAIT_TYPE(make_signed, etl::uint64_t, etl::int64_t);\n\n\n\n TEST_TRAIT_TYPE(make_signed, signed char, signed char);\n\n TEST_TRAIT_TYPE(make_signed, short, short);\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 72, "score": 109107.15271663794 }, { "content": "struct IsPolymorphic_C : IsPolymorphic_B {\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 73, "score": 109107.15271663794 }, { "content": "struct is_specialized<Template, T, etl::void_t<decltype(Template<T> {})>>\n\n : etl::true_type {\n\n};\n\n\n\ntemplate <template <typename...> typename Template, typename T,\n\n typename Tag = void>\n\ninline constexpr bool is_specialized_v\n\n = etl::is_specialized<Template, T, Tag>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_SPECIALIZED_HPP", "file_path": "etl/_type_traits/is_specialized.hpp", "rank": 74, "score": 108589.50230525926 }, { "content": "struct IsFinal_C final : IsFinal_B {\n\n};\n\n\n", "file_path": "tests/type_traits/type_traits2.t.cpp", "rank": 75, "score": 104677.15892939796 }, { "content": "struct disjunction : etl::bool_constant<(B::value || ...)> {\n\n};\n\n\n\n/// \\group disjunction\n\ntemplate <typename... B>\n\ninline constexpr bool disjunction_v = (B::value || ...);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_DISJUNCTION_HPP", "file_path": "etl/_type_traits/disjunction.hpp", "rank": 76, "score": 102818.99324033948 }, { "content": "struct conjunction : etl::bool_constant<(B::value && ...)> {\n\n};\n\n\n\n/// \\group conjunction\n\ntemplate <typename... B>\n\ninline constexpr bool conjunction_v = (B::value && ...);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_CONJUNCTION_HPP", "file_path": "etl/_type_traits/conjunction.hpp", "rank": 77, "score": 102818.99324033948 }, { "content": "struct is_placeholder : integral_constant<int, 0> {\n\n};\n\n\n\nnamespace detail {\n\ntemplate <int N>\n", "file_path": "etl/_functional/placeholder.hpp", "rank": 78, "score": 102514.73842119373 }, { "content": "struct is_final : bool_constant<TETL_BUILTIN_IS_FINAL(T)> {\n\n};\n\n\n\n/// \\group is_final\n\ntemplate <typename T>\n\ninline constexpr bool is_final_v = is_final<T>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_FINAL_HPP", "file_path": "etl/_type_traits/is_final.hpp", "rank": 79, "score": 102049.79497284269 }, { "content": "struct is_union : bool_constant<TETL_BUILTIN_IS_UNION(T)> {\n\n};\n\n\n\n/// \\group is_union\n\ntemplate <typename T>\n\ninline constexpr bool is_union_v = TETL_BUILTIN_IS_UNION(T);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_UNION_HPP", "file_path": "etl/_type_traits/is_union.hpp", "rank": 80, "score": 102049.79497284269 }, { "content": "struct is_polymorphic : bool_constant<TETL_BUILTIN_IS_POLYMORPHIC(T)> {\n\n};\n\n\n\n/// \\group is_polymorphic\n\ntemplate <typename T>\n\ninline constexpr bool is_polymorphic_v = is_polymorphic<T>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_POLYMORPHIC_HPP", "file_path": "etl/_type_traits/is_polymorphic.hpp", "rank": 81, "score": 102049.79497284269 }, { "content": "struct is_abstract : bool_constant<TETL_BUILTIN_IS_ABSTRACT(T)> {\n\n};\n\n\n\n/// \\group is_abstract\n\ntemplate <typename T>\n\ninline constexpr bool is_abstract_v = TETL_BUILTIN_IS_ABSTRACT(T);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_ABSTRACT_HPP", "file_path": "etl/_type_traits/is_abstract.hpp", "rank": 82, "score": 102049.79497284269 }, { "content": "struct is_enum : bool_constant<TETL_BUILTIN_IS_ENUM(T)> {\n\n};\n\n\n\n/// \\group is_enum\n\ntemplate <typename T>\n\ninline constexpr bool is_enum_v = is_enum<T>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_ENUM_HPP", "file_path": "etl/_type_traits/is_enum.hpp", "rank": 83, "score": 102049.79497284269 }, { "content": "struct rank : integral_constant<size_t, 0> {\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "etl/_type_traits/rank.hpp", "rank": 84, "score": 101143.54081255346 }, { "content": "/// \\copyright Tobias Hienzsch 2019-2021\n\n/// Distributed under the Boost Software License, Version 1.0.\n\n/// See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt\n\n\n\n#include \"etl/algorithm.hpp\"\n\n\n\n#include \"etl/array.hpp\"\n\n#include \"etl/cctype.hpp\"\n\n#include \"etl/cstdint.hpp\"\n\n\n\n#include \"testing/testing.hpp\"\n\n\n\ntemplate <typename T>\n\nconstexpr auto test() -> bool\n\n{\n\n\n\n {\n\n auto const v1 = etl::array { 'a', 'b', 'c', 'f', 'h', 'x' };\n\n auto const v2 = etl::array { 'a', 'b', 'c' };\n\n auto const v3 = etl::array { 'a', 'c' };\n", "file_path": "tests/algorithm/includes.t.cpp", "rank": 85, "score": 100065.1599754299 }, { "content": " auto const v3 = etl::array { T(1), T(3) };\n\n auto const v4 = etl::array { T(1), T(1), T(2) };\n\n auto const v5 = etl::array { T(7) };\n\n auto const v6 = etl::array { T(1), T(3), T(7) };\n\n\n\n assert(etl::includes(begin(v1), end(v1), v2.begin(), v2.end()));\n\n assert(etl::includes(begin(v1), end(v1), v3.begin(), v3.end()));\n\n\n\n assert(!(etl::includes(begin(v1), end(v1), v4.begin(), v4.end())));\n\n assert(!(etl::includes(begin(v1), end(v1), v5.begin(), v5.end())));\n\n assert(!(etl::includes(begin(v1), end(v1), v6.begin(), v6.end())));\n\n }\n\n\n\n return true;\n\n}\n\n\n\nconstexpr auto test_all() -> bool\n\n{\n\n assert(test<etl::uint8_t>());\n\n assert(test<etl::int8_t>());\n", "file_path": "tests/algorithm/includes.t.cpp", "rank": 86, "score": 100060.03858368316 }, { "content": " auto const v4 = etl::array { 'a', 'a', 'b' };\n\n auto const v5 = etl::array { 'g' };\n\n auto const v6 = etl::array { 'a', 'c', 'g' };\n\n auto const v7 = etl::array { 'A', 'B', 'C' };\n\n\n\n auto noCase\n\n = [](char a, char b) { return etl::tolower(a) < etl::tolower(b); };\n\n\n\n assert(etl::includes(begin(v1), end(v1), v2.begin(), v2.end()));\n\n assert(etl::includes(begin(v1), end(v1), v3.begin(), v3.end()));\n\n assert(etl::includes(begin(v1), end(v1), v7.begin(), v7.end(), noCase));\n\n\n\n assert(!(etl::includes(begin(v1), end(v1), v4.begin(), v4.end())));\n\n assert(!(etl::includes(begin(v1), end(v1), v5.begin(), v5.end())));\n\n assert(!(etl::includes(begin(v1), end(v1), v6.begin(), v6.end())));\n\n }\n\n\n\n {\n\n auto const v1 = etl::array { T(1), T(2), T(3), T(6), T(8), T(24) };\n\n auto const v2 = etl::array { T(1), T(2), T(3) };\n", "file_path": "tests/algorithm/includes.t.cpp", "rank": 87, "score": 100051.38070098759 }, { "content": " assert(test<etl::uint16_t>());\n\n assert(test<etl::int16_t>());\n\n assert(test<etl::uint32_t>());\n\n assert(test<etl::int32_t>());\n\n assert(test<etl::uint64_t>());\n\n assert(test<etl::int64_t>());\n\n assert(test<float>());\n\n assert(test<double>());\n\n\n\n return true;\n\n}\n\n\n\nauto main() -> int\n\n{\n\n assert(test_all());\n\n static_assert(test_all());\n\n return 0;\n\n}", "file_path": "tests/algorithm/includes.t.cpp", "rank": 88, "score": 100050.62886903934 }, { "content": "struct is_compound : etl::bool_constant<!etl::is_fundamental_v<T>> {\n\n};\n\n\n\ntemplate <typename T>\n\ninline constexpr bool is_compound_v = !etl::is_fundamental_v<T>;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_COMPOUND_HPP", "file_path": "etl/_type_traits/is_compound.hpp", "rank": 89, "score": 99150.07834813758 }, { "content": "struct ratio_not_equal : bool_constant<!ratio_equal_v<R1, R2>> {\n\n};\n\n\n\ntemplate <typename R1, typename R2>\n\ninline constexpr bool ratio_not_equal_v = ratio_not_equal<R1, R2>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_RATIO_NOT_EQUAL_HPP", "file_path": "etl/_ratio/ratio_not_equal.hpp", "rank": 90, "score": 98332.0233744253 }, { "content": "struct is_class : etl::bool_constant<TETL_BUILTIN_IS_CLASS(T)> {\n\n};\n\n\n\n/// \\group is_class\n\ntemplate <typename T>\n\ninline constexpr bool is_class_v = TETL_BUILTIN_IS_CLASS(T);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_CLASS_HPP", "file_path": "etl/_type_traits/is_class.hpp", "rank": 91, "score": 98332.0233744253 }, { "content": "struct extent<T[], 0> : etl::integral_constant<etl::size_t, 0> {\n\n};\n\n\n\n/// \\exclude\n\ntemplate <typename T, unsigned N>\n", "file_path": "etl/_type_traits/extent.hpp", "rank": 92, "score": 96595.34940397457 }, { "content": "struct type_pack_element_impl<0, T, Ts...> {\n\n using type = T;\n\n};\n\n} // namespace detail\n\n\n\ntemplate <etl::size_t I, typename... Ts>\n", "file_path": "etl/_type_traits/type_pack_element.hpp", "rank": 93, "score": 96433.11527599636 }, { "content": "struct is_trivially_copyable : etl::bool_constant<__is_trivially_copyable(T)> {\n\n};\n\n\n\ntemplate <typename T>\n\ninline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(T);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_HPP", "file_path": "etl/_type_traits/is_trivially_copyable.hpp", "rank": 94, "score": 96273.36606542752 }, { "content": "struct is_standard_layout : bool_constant<TETL_BUILTIN_IS_STANDARD_LAYOUT(T)> {\n\n};\n\n\n\ntemplate <typename T>\n\ninline constexpr bool is_standard_layout_v = is_standard_layout<T>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_STANDARD_LAYOUT_HPP", "file_path": "etl/_type_traits/is_standard_layout.hpp", "rank": 95, "score": 95864.23020059968 }, { "content": "struct is_function : bool_constant<!is_const_v<T const> && !is_reference_v<T>> {\n\n};\n\n\n\n#if defined(TETL_MSVC)\n\n // Qualifier applied to function has no meaning\n\n #pragma warning(default : 4180)\n\n#endif\n\n\n\n/// \\brief Checks whether T is a function type. Types like etl::function,\n\n/// lambdas, classes with overloaded operator() and pointers to functions don't\n\n/// count as function types. Provides the member constant value which is equal\n\n/// to true, if T is a function type. Otherwise, value is equal to false.\n\n///\n\n/// \\details The behavior of a program that adds specializations for is_function\n\n/// or is_function_v is undefined.\n\n/// \\group is_function\n\ntemplate <typename T>\n\ninline constexpr bool is_function_v = is_function<T>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_FUNCTION_HPP", "file_path": "etl/_type_traits/is_function.hpp", "rank": 96, "score": 95761.19877791686 }, { "content": "struct is_assignable : etl::bool_constant<TETL_BUILTIN_IS_ASSIGNABLE(T, U)> {\n\n};\n\n\n\ntemplate <typename T, typename U>\n\ninline constexpr bool is_assignable_v = TETL_BUILTIN_IS_ASSIGNABLE(T, U);\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_ASSIGNABLE_HPP", "file_path": "etl/_type_traits/is_assignable.hpp", "rank": 97, "score": 94913.12570793407 }, { "content": "struct is_pointer : detail::is_pointer_helper<typename remove_cv<T>::type> {\n\n};\n\n\n\n/// \\group is_pointer\n\ntemplate <typename T>\n\ninline constexpr bool is_pointer_v = is_pointer<T>::value;\n\n\n\n} // namespace etl\n\n\n\n#endif // TETL_TYPE_TRAITS_IS_POINTER_HPP", "file_path": "etl/_type_traits/is_pointer.hpp", "rank": 98, "score": 93732.16380776443 }, { "content": "struct nothrow_constructible_impl<true, T> : bool_constant<noexcept(T())> {\n\n};\n\n\n\ntemplate <typename T, size_t Size>\n", "file_path": "etl/_type_traits/is_nothrow_constructible.hpp", "rank": 99, "score": 92964.51357589457 } ]
C++
tests/benchmark/src/UAutomizerFileReader-test.cpp
typesAreSpaces/AXDInterpolator
e0759c806480ff54b7a4f878e007b534a71dad44
#include "UAutomizerFileReader.h" void UAutomizerFileReader::testAXDInterpolator() const { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << tseitin_solver.to_smt2(); axdinterpolator_file.close();, sprintf(exec_command, "./../../bin/axd_interpolator QF_LIA %s %u 1000000;", file_for_implementation.c_str(), curr_solver);, #if REPORT_BAD_CASES if(ret != 0 && ret != 152){ char complain_command[1000]; sprintf( complain_command, "echo File: \"%s\" Solver Code: \"%u\" Sample Id: %d Exit Code: %d >> /home/jose/bad_cases.txt", file_for_implementation.c_str(), curr_solver, 500 - num_samples, ret); system(complain_command); system(("mv " + file_for_implementation + " ~/" + file_for_implementation + std::to_string(500 - num_samples)).c_str()); } #endif sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), curr_solver, ret, file_statistics); ); system(("rm -rf " + temp_file).c_str()); } void UAutomizerFileReader::testOtherSolvers() { switch(curr_solver){ case Z3: { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << "(set-option :produce-interpolants true)" << std::endl; axdinterpolator_file << "(set-logic QF_AUFLIA)" << std::endl; axdinterpolator_file << nameAssertionsZ3(tseitin_solver.to_smt2()); axdinterpolator_file << "(get-interpolant part_a part_b)" << std::endl; axdinterpolator_file.close();, std::string temp_file_name = "z3_inter_temp_" + current_file; sprintf(exec_command, "./../../bin/z3 %s > %s;", file_for_implementation.c_str(), temp_file_name.c_str());, std::ifstream result(temp_file_name.c_str()); std::string line(""); std::string interpolant_from_file(""); std::getline(result, line); if(line == "unsat"){ std::getline(result, line); interpolant_from_file += tseitin_solver.to_smt2_decls_only(); interpolant_from_file += "(assert (and true\n"; while(std::getline(result, line)) interpolant_from_file += line + "\n"; interpolant_from_file += ")\n"; interpolant_from_file += "(check-sat)\n"; system(("rm -rf " + temp_file_name).c_str()); z3::solver z3_interpolant_parser(ctx, "QF_AUFLIA"); z3_interpolant_parser.from_string(interpolant_from_file.c_str()); auto const & interpolant_result = z3_interpolant_parser.assertions(); std::cout << interpolant_result << std::endl; sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 3, ret, file_statistics); } else{ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 3, 1, file_statistics); } ); system(("rm -rf " + temp_file).c_str()); } return; case MATHSAT: { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << "(set-option :produce-interpolants true)" << std::endl; axdinterpolator_file << nameAssertionsMathsat(tseitin_solver.to_smt2()); axdinterpolator_file << "(get-interpolant (part_a))" << std::endl; axdinterpolator_file.close();, std::string temp_file_name = "mathsat_inter_temp_" + current_file; sprintf(exec_command, "./../../bin/mathsat %s > %s;", file_for_implementation.c_str(), temp_file_name.c_str());, std::ifstream result(temp_file_name.c_str()); std::string line(""); std::string interpolant_from_file(""); std::getline(result, line); if(line == "unsat"){ interpolant_from_file += tseitin_solver.to_smt2_decls_only(); interpolant_from_file += "(assert (and true\n"; std::string _interpolant_result = ""; while(std::getline(result, line)) _interpolant_result += line + "\n"; if(_interpolant_result.find("build ie-local interpolant") != std::string::npos){ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 4, 1, file_statistics); } else { interpolant_from_file += _interpolant_result; interpolant_from_file += "))\n"; interpolant_from_file += "(check-sat)\n"; system(("rm -rf " + temp_file_name).c_str()); z3::solver mathsat_interpolant_parser(ctx, "QF_AUFLIA"); mathsat_interpolant_parser.from_string(interpolant_from_file.c_str()); auto const & interpolant_result = mathsat_interpolant_parser.assertions(); std::cout << interpolant_result << std::endl; sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 4, ret, file_statistics); } } else{ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 4, 1, file_statistics); } ); system(("rm -rf " + temp_file).c_str()); } return; case SMTINTERPOL: { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << "(set-option :print-success false)\n" << "(set-option :produce-interpolants true)" << std::endl; axdinterpolator_file << "(set-logic QF_AUFLIA)" << std::endl; axdinterpolator_file << nameAssertionsZ3(tseitin_solver.to_smt2()); axdinterpolator_file << "(get-interpolants part_a part_b)" << std::endl; axdinterpolator_file.close();, std::string temp_file_name = "smtinterpol_inter_temp_" + current_file; sprintf(exec_command, "java -jar ./../../bin/smtinterpol-2.5-663-gf15aa217.jar -w %s > %s", file_for_implementation.c_str(), temp_file_name.c_str());, std::ifstream result(temp_file_name.c_str()); std::string line(""); std::string interpolant_from_file(""); std::getline(result, line); if(line == "unsat"){ interpolant_from_file += tseitin_solver.to_smt2_decls_only(); interpolant_from_file += "(assert \n"; std::getline(result, line); interpolant_from_file += line.erase(0, 1) + "\n"; interpolant_from_file.erase(interpolant_from_file.size() - 2, 2); interpolant_from_file += ")\n"; interpolant_from_file += "(check-sat)\n"; system(("rm -rf " + temp_file_name).c_str()); z3::solver smtinterpol_interpolant_parser(ctx, "QF_AUFLIA"); smtinterpol_interpolant_parser.from_string(interpolant_from_file.c_str()); auto const & interpolant_result = smtinterpol_interpolant_parser.assertions(); std::cerr << interpolant_result << std::endl; sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 5, ret, file_statistics); } else{ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 5, 1, file_statistics); } ); system(("rm -rf " + temp_file).c_str()); } return; } }
#include "UAutomizerFileReader.h" void UAutomizerFileReader::testAXDInterpolator() const { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << tseitin_solver.to_smt2(); axdinterpolator_file.close();, sprintf(exec_command, "./../../bin/axd_interpolator QF_LIA %s %u 1000000;", file_for_implementation.c_str(), curr_solver);, #if REPORT_BAD_CASES if(ret != 0 && ret != 152){ char complain_command[1000]; sprintf( complain_command, "echo File: \"%s\" Solver Code: \"%u\" Sample Id: %d Exit Code: %d >> /home/jose/bad_cases.txt", file_for_implementation.c_str(), curr_solver, 500 - num_samples, ret); system(complain_command); system(("mv " + file_for_implementation + " ~/" + file_for_implementation + std::to_string(500 - num_samples)).c_str()); } #endif sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), curr_solver, ret, file_statistics); ); system(("rm -rf " + temp_file).c_str()); } void UAutomizerFileReader::testOtherSolvers() { switch(curr_solver){ case Z3: { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << "(set-option :produce-interpolants true)" << std::endl; axdinterpolator_file << "(set-logic QF_AUFLIA)" << std::endl; axdinterpolator_file << nameAssertionsZ3(tseitin_solver.to_smt2()); axdinterpolator_file << "(get-interpolant part_a part_b)" << std::endl; axdinterpolator_file.close();, std::string temp_file_name = "z3_inter_temp_" + current_file; sprintf(exec_command, "./../../bin/z3 %s > %s;", file_for_implementation.c_str(), temp_file_name.c_str());, std::ifstream result(temp_file_name.c_str()); std::string line(""); std::string interpolant_from_file(""); std::getline(result, line); if(line == "unsat"){ std::getline(result, line); interpolant_from_file += tseitin_solver.to_smt2_decls_only(); interpolant_from_file += "(assert (and true\n"; while(std::getline(result, line)) interpolant_from_file += line + "\n"; interpolant_from_file += ")\n"; interpolant_from_file += "(check-sat)\n"; system(("rm -rf " + temp_file_name).c_str()); z3::solver z3_interpolant_parser(ctx, "QF_AUFLIA"); z3_interpolant_parser.from_string(interpolant_from_file.c_str()); auto const & interpolant_result = z3_interpolant_parser.assertions(); std::cout << interpolant_result << std::endl; sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 3, ret, file_statistics); } else{ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 3, 1, file_statistics); } ); system(("rm -rf " + temp_file).c_str()); } return; case MATHSAT: { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << "(set-option :produce-interpolants true)" << std::endl; axdinterpolator_file << nameAssertionsMathsat(tseitin_solver.to_smt2()); axdinterpolator_file << "(get-interpolant (part_a))" << std::endl; axdinterpolator_file.close();, std::string temp_file_name = "mathsat_inter_temp_" + current_file; sprintf(exec_command, "./../../bin/mathsat %s > %s;", file_for_implementation.c_str(), temp_file_name.c_str());, std::ifstream result(temp_file_name.c_str()); std::string line(""); std::string interpolant_from_file(""); std::getline(result, line); if(line == "unsat"){ interpolant_from_file += tseitin_solver.to_smt2_decls_only(); interpolant_from_file += "(assert (and true\n"; std::string _interpolant_result = ""; while(std::getline(result, line)) _interpolant_result += line + "\n"; if(_interpolant_result.find("build ie-local interpolant") != std::string::npos){ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 4, 1, file_statistics); } else { interpolant_from_file += _interpolant_result; interpolant_from_file += "))\n"; interpolant_from_file += "(check-sat)\n"; system(("rm -rf " + temp_file_name).c_str()); z3::solver mathsat_interpolant_parser(ctx, "QF_AUFLIA"); mathsat_interpolant_parser.from_string(interpolant_from_file.c_str()); auto const & interpolant_result = mathsat_interpolant_parser.assertions(); std::cout << interpolant_result << std::endl; sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 4, ret, file_statistics); } } else{ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 4, 1, file_statistics); } ); system(("rm -rf " + temp_file).c_str()); } return; case SMTINTERPOL: { TEMP_FILE_SETUP; BENCHMARK_COMMAND( z3::solver tseitin_solver(ctx, "QF_AUFLIA"); tseitin_solver.add(z3::mk_and(part_a)); tseitin_solver.add(z3::mk_and(part_b)); axdinterpolator_file << "(set-option :print-success false)\n" << "(set-option :produce-interpolants true)" << std::endl; axdinterpolator_file << "(set-logic QF_AUFLIA)" << std::endl; axdinterpolator_file << nameAssertionsZ3(tseitin_solver.to_smt2()); axdinterpolator_file << "(get-interpolants part_a part_b)" << std::endl; axdinterpolator_file.close();, std::string temp_file_name = "smtinterpol_inter_temp_" + current_file; sprintf(exec_command, "java -jar ./../../bin/smtinterpol-2.5-663-gf15aa217.jar -w %s > %s", file_for_implementation.c_str(), temp_file_name.c_str());, std::ifstream result(temp_file_name.c_str()); std::string line(""); std::string interpolant_from_file(""); std::getline(result, line); if(line == "unsat"){ interpolant_from_file += tseitin_solver.to_smt2_decls_only(); interpolant_from_file += "(assert \n"; std::getline(result, line); interpolant_from_file += line.erase(0, 1) + "\n"; interpolant_from_file.erase(interpolant_from_file.size() - 2, 2);
interpolant_from_file += ")\n"; interpolant_from_file += "(check-sat)\n"; system(("rm -rf " + temp_file_name).c_str()); z3::solver smtinterpol_interpolant_parser(ctx, "QF_AUFLIA"); smtinterpol_interpolant_parser.from_string(interpolant_from_file.c_str()); auto const & interpolant_result = smtinterpol_interpolant_parser.assertions(); std::cerr << interpolant_result << std::endl; sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 5, ret, file_statistics); } else{ system(("rm -rf " + temp_file_name).c_str()); sprintf(log_command, "echo File: \"%s\" Solver Code: \"%u\" Exit Code: %d >> \"%s\"", file_for_implementation.c_str(), 5, 1, file_statistics); } ); system(("rm -rf " + temp_file).c_str()); } return; } }
function_block-function_prefix_line
[ { "content": "enum SMT_SOLVER { Z3, MATHSAT, SMTINTERPOL };\n\n\n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 0, "score": 219527.99814903465 }, { "content": "enum BENCHMARK_EXIT_CODE { SUCCESS, FAILED, TIMEOUT };\n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 1, "score": 118119.87622310914 }, { "content": " class solver;\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 2, "score": 115627.8942689355 }, { "content": " class solver : public object {\n\n Z3_solver m_solver;\n\n void init(Z3_solver s) {\n\n m_solver = s;\n\n Z3_solver_inc_ref(ctx(), s);\n\n }\n\n public:\n\n struct simple {};\n\n struct translate {};\n\n solver(context & c):object(c) { init(Z3_mk_solver(c)); }\n\n solver(context & c, simple):object(c) { init(Z3_mk_simple_solver(c)); }\n\n solver(context & c, Z3_solver s):object(c) { init(s); }\n\n solver(context & c, char const * logic):object(c) { init(Z3_mk_solver_for_logic(c, c.str_symbol(logic))); }\n\n solver(context & c, solver const& src, translate): object(c) { init(Z3_solver_translate(src.ctx(), src, c)); }\n\n solver(solver const & s):object(s) { init(s.m_solver); }\n\n ~solver() { Z3_solver_dec_ref(ctx(), m_solver); }\n\n operator Z3_solver() const { return m_solver; }\n\n solver & operator=(solver const & s) {\n\n Z3_solver_inc_ref(s.ctx(), s.m_solver);\n\n Z3_solver_dec_ref(ctx(), m_solver);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 3, "score": 102673.08763681822 }, { "content": "class UAutomizerFileReader {\n\n\n\n std::string line, current_frame, current_file;\n\n int nesting_level, max_nesting_level;\n\n unsigned num;\n\n bool is_mem_safety_track;\n\n std::vector<std::string> stack_of_frames;\n\n SMT_SOLVER curr_solver;\n\n std::string const name_solver;\n\n unsigned num_samples;\n\n char * const file_statistics;\n\n bool test_our_implementation;\n\n\n\n bool hasNonSupportedSymbols(z3::expr const &) const;\n\n std::string nameAssertionsZ3(std::string const &) const;\n\n std::string nameAssertionsMathsat(std::string const &) const;\n\n\n\n bool isPushCmd() const;\n\n bool isPopCmd() const;\n\n bool isEchoCmd() const; \n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 4, "score": 93856.91520494904 }, { "content": "\n\n void testAXDInterpolator() const; \n\n void testOtherSolvers(); \n\n void reset(); \n\n\n\n public:\n\n UAutomizerFileReader(SMT_SOLVER, unsigned, char * const, bool, bool);\n\n \n\n void process(char const *);\n\n void processSingleFile(char const *);\n\n};\n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 5, "score": 86272.75079068461 }, { "content": " std::ofstream smt_file (temp_file.c_str());\\\n\n \\\n\n for(auto const & x : stack_of_frames)\\\n\n smt_file << x << std::endl;\\\n\n smt_file << current_frame << std::endl;\\\n\n smt_file.close();\\\n\n\n\n#define BENCHMARK_COMMAND(WRITER, EXEC_COMMAND, LOG_COMMAND)\\\n\n z3::context ctx;\\\n\n z3::solver input_parser(ctx, \"QF_AUFLIA\");\\\n\n input_parser.from_file(temp_file.c_str());\\\n\n \\\n\n for(auto const & x : input_parser.assertions()){\\\n\n if(hasNonSupportedSymbols(x)){\\\n\n system((\"rm -rf \" + temp_file).c_str());\\\n\n return;\\\n\n }\\\n\n }\\\n\n \\\n\n if(input_parser.check() == z3::unsat){\\\n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 6, "score": 86268.95768892833 }, { "content": "#include <iostream>\n\n#include <cassert>\n\n#include <regex>\n\n#include <fstream>\n\n#include <string>\n\n#include <type_traits>\n\n#include <vector>\n\n#include <cstring>\n\n#include <stdio.h>\n\n#include <string>\n\n#include <cstdlib>\n\n#include <regex>\n\n#include \"z3++.h\"\n\n\n\n#define SINGLE_FORMULA 0\n\n#define REPORT_BAD_CASES 0\n\n\n\n#define TEMP_FILE_SETUP\\\n\n std::string temp_file =\\\n\n \"temp_\" + name_solver + \"_\" + current_file;\\\n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 7, "score": 86265.84348226433 }, { "content": " std::string file_for_implementation =\\\n\n \"axdinterpolator_\" + name_solver + \"_\" + current_file;\\\n\n std::ofstream axdinterpolator_file(file_for_implementation.c_str());\\\n\n \\\n\n z3::expr_vector curr_assertions = input_parser.assertions();\\\n\n z3::expr_vector part_a(ctx), part_b(ctx);\\\n\n \\\n\n auto const & to_cnf_tactic = \\\n\n z3::tactic(ctx, \"tseitin-cnf\");\\\n\n \\\n\n z3::goal goal_assertions(ctx);\\\n\n goal_assertions.add(z3::mk_and(curr_assertions));\\\n\n auto const & cnf_assertions = to_cnf_tactic(goal_assertions);\\\n\n \\\n\n assert(cnf_assertions.size() == 1);\\\n\n z3::expr const & curr_conjunction = cnf_assertions[0].as_expr();\\\n\n \\\n\n unsigned total_size_cnf = curr_conjunction.num_args();\\\n\n unsigned half_size_cnf = total_size_cnf/2;\\\n\n if(curr_conjunction.decl().decl_kind() != Z3_OP_AND\\\n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 8, "score": 86264.71120661046 }, { "content": " || half_size_cnf == 0\\\n\n || (total_size_cnf - half_size_cnf) == 0 \\\n\n ){\\\n\n axdinterpolator_file.close();\\\n\n system((\"rm -rf \" + file_for_implementation).c_str());\\\n\n system((\"rm -rf \" + temp_file).c_str());\\\n\n return;\\\n\n }\\\n\n \\\n\n part_a.push_back(ctx.bool_val(true));\\\n\n part_b.push_back(ctx.bool_val(true));\\\n\n for(unsigned i = 0; i < half_size_cnf; i++)\\\n\n part_a.push_back(curr_conjunction.arg(i));\\\n\n for(unsigned i = half_size_cnf; i < total_size_cnf; i++)\\\n\n part_b.push_back(curr_conjunction.arg(i));\\\n\n \\\n\n WRITER;\\\n\n \\\n\n char exec_command[1000];\\\n\n EXEC_COMMAND;\\\n\n int ret = system(exec_command);\\\n\n char log_command[1000];\\\n\n LOG_COMMAND;\\\n\n system(log_command);\\\n\n \\\n\n system((\"rm -rf \" + file_for_implementation).c_str());\\\n\n }\n\n\n", "file_path": "tests/benchmark/include/UAutomizerFileReader.h", "rank": 9, "score": 86263.44279618328 }, { "content": "#include \"UAutomizerFileReader.h\"\n\n\n\nstd::string UAutomizerFileReader::nameAssertionsZ3(std::string const & s) const {\n\n std::stringstream decl_strm(s);\n\n std::string curr_line, collected_assertion = \"\", ret = \"\";\n\n bool matching_assert = false, matching_part_a = true;\n\n unsigned num_balanced_paren = 0;\n\n\n\n while(std::getline(decl_strm, curr_line)){\n\n\n\n if(curr_line.find(\"(assert\") != std::string::npos)\n\n matching_assert = true;\n\n\n\n if(matching_assert){\n\n for(auto const & c : curr_line){\n\n if(c == '(')\n\n num_balanced_paren++;\n\n if(c == ')')\n\n num_balanced_paren--;\n\n }\n", "file_path": "tests/benchmark/src/UAutomizerFileReader-nameAssertions.cpp", "rank": 10, "score": 80341.74349391981 }, { "content": " return ret;\n\n}\n\n\n\nstd::string UAutomizerFileReader::nameAssertionsMathsat(std::string const & s) const {\n\n std::stringstream decl_strm(s);\n\n std::string curr_line, collected_assertion = \"\", ret = \"\";\n\n bool matching_assert = false, matching_part_a = true;\n\n unsigned num_balanced_paren = 0;\n\n\n\n while(std::getline(decl_strm, curr_line)){\n\n\n\n if(curr_line.find(\"(assert\") != std::string::npos)\n\n matching_assert = true;\n\n\n\n if(matching_assert){\n\n for(auto const & c : curr_line){\n\n if(c == '(')\n\n num_balanced_paren++;\n\n if(c == ')')\n\n num_balanced_paren--;\n", "file_path": "tests/benchmark/src/UAutomizerFileReader-nameAssertions.cpp", "rank": 11, "score": 80339.80502556675 }, { "content": " }\n\n\n\n collected_assertion += curr_line;\n\n if(num_balanced_paren == 0){\n\n matching_assert = false;\n\n collected_assertion = collected_assertion.substr(8);\n\n collected_assertion.pop_back();\n\n if(matching_part_a){\n\n collected_assertion = \"(assert (! \" + collected_assertion +\" :interpolation-group part_a))\";\n\n matching_part_a = false;\n\n }\n\n else\n\n collected_assertion = \"(assert (! \" + collected_assertion +\" :interpolation-group part_b))\";\n\n\n\n ret += collected_assertion + \"\\n\";\n\n collected_assertion = \"\";\n\n }\n\n }\n\n else\n\n ret += curr_line + \"\\n\";\n\n }\n\n return ret;\n\n}\n", "file_path": "tests/benchmark/src/UAutomizerFileReader-nameAssertions.cpp", "rank": 12, "score": 80332.0679691368 }, { "content": "\n\n collected_assertion += curr_line;\n\n if(num_balanced_paren == 0){\n\n matching_assert = false;\n\n collected_assertion = collected_assertion.substr(8);\n\n collected_assertion.pop_back();\n\n if(matching_part_a){\n\n collected_assertion = \"(assert (! \" + collected_assertion +\" :named part_a))\";\n\n matching_part_a = false;\n\n }\n\n else\n\n collected_assertion = \"(assert (! \" + collected_assertion +\" :named part_b))\";\n\n\n\n ret += collected_assertion + \"\\n\";\n\n collected_assertion = \"\";\n\n }\n\n }\n\n else\n\n ret += curr_line + \"\\n\";\n\n }\n", "file_path": "tests/benchmark/src/UAutomizerFileReader-nameAssertions.cpp", "rank": 13, "score": 80328.43899097358 }, { "content": " class z3_expr_vector_unique : public z3::expr_vector {\n\n std::set<unsigned> expr_ids;\n\n\n\n public:\n\n z3_expr_vector_unique(z3::context &);\n\n void push(z3::expr const &);\n\n };\n\n\n", "file_path": "include/AXDSignature.h", "rank": 14, "score": 71695.18812625401 }, { "content": " class z3_sort_vector_unique : public z3::sort_vector {\n\n std::set<unsigned> sort_ids;\n\n\n\n public:\n\n z3_sort_vector_unique(z3::context &);\n\n void push(z3::sort const &);\n\n };\n\n\n\n static bool isSpaceOrParen(char);\n\n void extractNameFromSort(std::string &) const;\n\n void processArrayDecls(std::string &);\n\n void indexElementSorts();\n\n\n\n bool is_QF_TO() const;\n\n bool is_QF_IDL() const;\n\n bool isArraySort(z3::sort const &) const;\n\n\n\n void setTheory(TheoryName);\n\n\n\n TheoryName const & getTheoryName() const;\n", "file_path": "include/AXDSignature.h", "rank": 15, "score": 71695.18812625401 }, { "content": " AXDInterpolant(\n\n AXDSignature &, \n\n z3::expr const &,\n\n z3::expr const &,\n\n char const *, \n\n unsigned);\n\n\n\n void z3OutputFile();\n\n void mathsatOutputFile();\n\n void smtInterpolOutputFile();\n\n\n\n friend std::ostream & operator << (\n\n std::ostream &, AXDInterpolant const &);\n\n};\n\n\n\n#endif\n", "file_path": "include/AXDInterpolant.h", "rank": 16, "score": 67185.31580865938 }, { "content": " enum StateOutput { undefined, fine, notfine };\n\n\n\n StandardInput part_a, part_b;\n\n std::string m_file_name;\n\n unsigned num_attempts, remaining_fuel;\n\n bool is_interpolant_computed,\n\n is_unsat,\n\n is_valid_result;\n\n StateOutput state_output;\n\n z3::expr current_interpolant;\n\n z3::solver solver;\n\n\n\n void loop();\n\n\n\n bool testOutput(\n\n z3::expr_vector const &, \n\n z3::expr_vector &, \n\n z3::expr_vector &);\n\n void testOutputArrayAxiomatization(z3::solver &);\n\n void testOutputDiffLifting(\n", "file_path": "include/AXDInterpolant.h", "rank": 17, "score": 67181.80398773948 }, { "content": " z3::solver & s, \n\n StandardInput const &);\n\n\n\n void SmtSolverSetup(\n\n z3::solver &, \n\n StandardInput const &);\n\n void SmtSolverOutStreamSetup(\n\n std::ostream &, \n\n StandardInput const &);\n\n void AB_VectorsSetup(\n\n z3::expr_vector &, \n\n StandardInput const &);\n\n\n\n z3::expr liftInterpolant(z3::expr_vector const &); \n\n void liftInterpolantDiffSubs(\n\n z3::expr_vector &, \n\n z3::expr_vector &, \n\n StandardInput const &); \n\n\n\n public: \n", "file_path": "include/AXDInterpolant.h", "rank": 18, "score": 67178.90766004712 }, { "content": "#ifndef _AXD_INTERPOLANT_\n\n#define _AXD_INTERPOLANT_\n\n\n\n#include \"z3++.h\"\n\n#include <iostream>\n\n#include <utility>\n\n#include <set>\n\n#include <cstring>\n\n#include <fstream>\n\n#include \"Preprocess.h\"\n\n#include \"StandardInput.h\"\n\n\n\n#define _DEBUG_AXD_LOOP_ 0\n\n#define _DEBUG_AXD_CONSTRUCTOR_ 0\n\n#define _TEST_OUTPUT_ 0\n\n#define _TEST_OUTPUT_ORIGINAL_THY_ 0\n\n#define _INCLUDE_OUTPUT_ 1\n\n\n\n#define CURRENT_DIR std::string(\"replace_once\")\n\n#define OUTPUT_DIR CURRENT_DIR + std::string(\"/output\")\n\n\n\n// Notes:\n\n// The input file is a smt2 file\n\n// with two assertions.\n\n// Each assertion is \n\n// of the form (and <pred_1> \\dots <pred_n>).\n\n\n", "file_path": "include/AXDInterpolant.h", "rank": 19, "score": 67176.05096247296 }, { "content": "class AXDInterpolant : public Preprocessor {\n\n\n", "file_path": "include/AXDInterpolant.h", "rank": 20, "score": 65546.3856023725 }, { "content": " system((\"rm -rf \" \n\n + OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\").c_str());\n\n\n\n if(is_valid_result){\n\n // Lift interpolant to MaxDiff(Index Theory)\n\n z3::solver mathsat_interpolant_parser(sig.ctx);\n\n mathsat_interpolant_parser.from_string(interpolant_from_file.c_str());\n\n\n\n is_interpolant_computed = true;\n\n current_interpolant = liftInterpolant(\n\n mathsat_interpolant_parser.assertions());\n\n\n\n#if _TEST_OUTPUT_\n\n TEST_OUTPUT_CODE(mathsat_interpolant_parser);\n\n#endif\n\n }\n\n}\n\n\n\nvoid AXDInterpolant::smtInterpolOutputFile(){\n\n if(!is_unsat)\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 21, "score": 61853.15660815486 }, { "content": " smtinterpol_file << solver.to_smt2_decls_only();\n\n smtinterpol_file << \"(assert (! (and\" << std::endl;\n\n // This true assertion prevents \n\n // an unary application of and\n\n smtinterpol_file << \"true\" << std::endl;\n\n SmtSolverOutStreamSetup(smtinterpol_file, part_a);\n\n smtinterpol_file << \") :named part_a))\" << std::endl;\n\n smtinterpol_file << \"(assert (! (and\" << std::endl;\n\n // This true assertion prevents \n\n // an unary application of and\n\n smtinterpol_file << \"true\" << std::endl;\n\n SmtSolverOutStreamSetup(smtinterpol_file, part_b);\n\n smtinterpol_file << \") :named part_b))\" << std::endl;\n\n smtinterpol_file << \"(check-sat)\" << std::endl;\n\n smtinterpol_file << \"(get-interpolants part_a part_b)\" << std::endl;\n\n\n\n // Obtain reduced interpolant in <m_file_name>temp.smt2\n\n system((\"java -jar \" + CURRENT_DIR \n\n + \"/bin/smtinterpol-2.5-663-gf15aa217.jar -w \" \n\n + OUTPUT_DIR + \"/\" + m_file_name \n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 22, "score": 61850.838348579455 }, { "content": " interpolant_from_file += \"(check-sat)\\n\";\n\n system((\"rm -rf \" \n\n + OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\").c_str());\n\n\n\n if(is_valid_result){\n\n // Lift interpolant to MaxDiff(Index Theory)\n\n z3::solver z3_interpolant_parser(sig.ctx);\n\n z3_interpolant_parser.from_string(interpolant_from_file.c_str());\n\n\n\n is_interpolant_computed = true;\n\n current_interpolant = liftInterpolant(\n\n z3_interpolant_parser.assertions());\n\n\n\n#if _TEST_OUTPUT_\n\n TEST_OUTPUT_CODE(z3_interpolant_parser);\n\n#endif\n\n }\n\n}\n\n\n\nvoid AXDInterpolant::mathsatOutputFile(){\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 23, "score": 61850.643193305215 }, { "content": " interpolant_from_file += line.erase(0, 1) + \"\\n\";\n\n // The following removes the last parenthesis \n\n // and the extra '\\n'\n\n interpolant_from_file.erase(interpolant_from_file.size() - 2, 2);\n\n is_valid_result = interpolant_from_file.size() > 0;\n\n // Only one parenthesis is needed to close\n\n // the above since the content of (interpolant *)\n\n // includes an additional parenthesis\n\n interpolant_from_file += \")\\n\";\n\n interpolant_from_file += \"(check-sat)\\n\";\n\n //system((\"rm -rf \" \n\n //+ OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\").c_str());\n\n\n\n if(is_valid_result){\n\n // Lift interpolant to MaxDiff(Index Theory)\n\n z3::solver smtinterpol_interpolant_parser(sig.ctx);\n\n smtinterpol_interpolant_parser.from_string(interpolant_from_file.c_str());\n\n\n\n is_interpolant_computed = true;\n\n current_interpolant = liftInterpolant(\n\n smtinterpol_interpolant_parser.assertions());\n\n\n\n#if _TEST_OUTPUT_\n\n TEST_OUTPUT_CODE(smtinterpol_interpolant_parser);\n\n#endif\n\n }\n\n}\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 24, "score": 61850.375009613825 }, { "content": " mathsat_file << solver.to_smt2_decls_only();\n\n mathsat_file << \"(assert (! (and\" << std::endl;\n\n // This true assertion prevents \n\n // an unary application of and\n\n mathsat_file << \"true\" << std::endl;\n\n SmtSolverOutStreamSetup(mathsat_file, part_a);\n\n mathsat_file << \") :interpolation-group part_a))\" << std::endl;\n\n mathsat_file << \"(assert (! (and \" << std::endl;\n\n // This true assertion prevents \n\n // an unary application of and\n\n mathsat_file << \"true\" << std::endl;\n\n SmtSolverOutStreamSetup(mathsat_file, part_b);\n\n mathsat_file << \") :interpolation-group part_b))\" << std::endl;\n\n mathsat_file << \"(check-sat)\" << std::endl;\n\n mathsat_file << \"(get-interpolant (part_a))\" << std::endl;\n\n mathsat_file << \"(exit)\" << std::endl;\n\n\n\n // Obtain reduced interpolant in <m_file_name>temp.smt2\n\n system((CURRENT_DIR \n\n + \"/bin/mathsat \" \n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 25, "score": 61849.2297480949 }, { "content": " // to parse reduced interpolant\n\n std::ifstream result(OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\");\n\n std::string line(\"\"), interpolant_from_file(\"\");\n\n // We consume two lines because\n\n // z3 outputs \"check-sat\" followed\n\n // a line containing \"(interpolants\", followed\n\n // by the interpolant\n\n std::getline(result, line);\n\n std::getline(result, line);\n\n\n\n interpolant_from_file += solver.to_smt2_decls_only();\n\n interpolant_from_file += \"(assert (and\\n\";\n\n while(std::getline(result, line)){\n\n is_valid_result = true;\n\n interpolant_from_file += line + \"\\n\";\n\n }\n\n // Only one parenthesis is needed to close\n\n // the above since the content of (interpolant *)\n\n // includes an additional parenthesis\n\n interpolant_from_file += \")\\n\";\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 26, "score": 61846.672774480525 }, { "content": " + OUTPUT_DIR + \"/\" + m_file_name \n\n + \"_reduced_mathsat.smt2 > \" \n\n + OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\").c_str());\n\n\n\n // Setup *_reduced_interpolant_mathsat.smt2 file\n\n // to parse reduced interpolant\n\n std::ifstream result(OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\");\n\n std::string line(\"\"), interpolant_from_file(\"\");\n\n // We consume one line because\n\n // mathsat outputs \"check-sat\" followed\n\n // by the interpolant\n\n std::getline(result, line);\n\n interpolant_from_file += solver.to_smt2_decls_only();\n\n interpolant_from_file += \"(assert \\n\";\n\n while(std::getline(result, line)){\n\n is_valid_result = true;\n\n interpolant_from_file += line + \"\\n\";\n\n }\n\n interpolant_from_file += \")\\n\";\n\n interpolant_from_file += \"(check-sat)\\n\";\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 27, "score": 61846.15717889502 }, { "content": " + \"_reduced_smtinterpol.smt2 > \"\n\n + OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\").c_str());\n\n\n\n // Setup *_reduced_interpolant_smtinterpol.smt2 file\n\n // to parse reduced interpolant\n\n std::ifstream result(OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\");\n\n std::string line(\"\"), interpolant_from_file(\"\");\n\n // We consume one line because\n\n // mathsat outputs \"check-sat\" followed\n\n // by the interpolant\n\n std::getline(result, line);\n\n interpolant_from_file += solver.to_smt2_decls_only();\n\n interpolant_from_file += \"(assert \\n\";\n\n // SMTINTERPOL returns a single\n\n // line containing a list\n\n // of sequence interpolants\n\n // Thus, we remove the initial and\n\n // last character which are '(' and ')' \n\n // respectively\n\n std::getline(result, line);\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 28, "score": 61845.74856239847 }, { "content": "#include \"AXDInterpolant.h\"\n\n\n\n#define TEST_OUTPUT_CODE(PARSED_FROM_SOLVER_INTERPOLANT) \\\n\n z3::expr_vector _part_a_vector(sig.ctx); \\\n\n z3::expr_vector _part_b_vector(sig.ctx); \\\n\n AB_VectorsSetup(_part_a_vector, part_a); \\\n\n AB_VectorsSetup(_part_b_vector, part_b); \\\n\n if(testOutput(PARSED_FROM_SOLVER_INTERPOLANT.assertions(), \\\n\n _part_a_vector, _part_b_vector)) \\\n\n state_output = fine; \\\n\n else \\\n\n state_output = notfine;\n\n\n\nvoid AXDInterpolant::z3OutputFile(){\n\n if(!is_unsat)\n\n throw \n\n \"Input problem \"\n\n \"is not unsatisfiable.\";\n\n // Setup smt2 file with reduced formulas\n\n // in Index Theory + EUF\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 29, "score": 61845.05334253524 }, { "content": " z3_file << \"true\" << std::endl;\n\n SmtSolverOutStreamSetup(z3_file, part_a);\n\n z3_file << \") :named part_a))\" << std::endl;\n\n z3_file << \"(assert (! (and\" << std::endl;\n\n // This true assertion prevents \n\n // an unary application of and\n\n z3_file << \"true\" << std::endl;\n\n SmtSolverOutStreamSetup(z3_file, part_b);\n\n z3_file << \") :named part_b))\" << std::endl;\n\n z3_file << \"(check-sat)\" << std::endl;\n\n z3_file << \"(get-interpolant part_a part_b)\" << std::endl;\n\n\n\n // Obtain reduced interpolant in <m_file_name>temp.smt2\n\n system((CURRENT_DIR \n\n + \"/bin/z3 \" \n\n + OUTPUT_DIR + \"/\" + m_file_name \n\n + \"_reduced_z3.smt2 > \"\n\n + OUTPUT_DIR + \"/\" + m_file_name + \"temp.smt2\").c_str());\n\n\n\n // Setup *_reduced_interpolant_z3.smt2 file\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 30, "score": 61843.75598395975 }, { "content": " system((\"mkdir -p \" + OUTPUT_DIR).c_str());\n\n std::ofstream z3_file(\n\n OUTPUT_DIR + \"/\" + m_file_name \n\n + \"_reduced_z3.smt2\");\n\n\n\n z3_file \n\n << \"(set-option :produce-interpolants true)\" \n\n << std::endl;\n\n // Setup logic engine\n\n z3_file \n\n << \"(set-logic \" \n\n << ( (sig.is_QF_TO() ||\n\n sig.is_QF_IDL()) ? \n\n \"QF_UFIDL\" : \"QF_UFLIA\") << \")\" << std::endl;\n\n //\"QF_UFLIA\" : \"QF_UFLIA\") << \")\" << std::endl;\n\n\n\n z3_file << solver.to_smt2_decls_only();\n\n z3_file << \"(assert (! (and\" << std::endl;\n\n // This true assertion prevents \n\n // an unary application of and\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 31, "score": 61841.808151311736 }, { "content": " if(!is_unsat)\n\n throw \n\n \"Input problem is not unsatisfiable.\";\n\n // Setup smt2 file with reduced formulas\n\n // in Index Theory + EUF\n\n system((\"mkdir -p \" + OUTPUT_DIR).c_str());\n\n std::ofstream mathsat_file(\n\n OUTPUT_DIR + \"/\" + m_file_name \n\n + \"_reduced_mathsat.smt2\");\n\n\n\n mathsat_file \n\n << \"(set-option :produce-interpolants true)\" \n\n << std::endl;\n\n // Setup logic engine\n\n mathsat_file \n\n << \"(set-logic \" \n\n << ((sig.is_QF_TO() ||\n\n sig.is_QF_IDL()) ? \n\n \"QF_UFIDL\" : \"QF_UFLIA\") << \")\" << std::endl;\n\n\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 32, "score": 61838.869314587384 }, { "content": " throw \n\n \"Input problem is not unsatisfiable.\";\n\n // Setup smt2 file with reduced formulas\n\n // in Index Theory + EUF\n\n system((\"mkdir -p \" + OUTPUT_DIR).c_str());\n\n std::ofstream smtinterpol_file(\n\n OUTPUT_DIR + \"/\" + m_file_name \n\n + \"_reduced_smtinterpol.smt2\");\n\n\n\n smtinterpol_file \n\n << \"(set-option :print-success false)\\n\" \n\n << \"(set-option :produce-interpolants true)\" \n\n << std::endl;\n\n // Setup logic engine\n\n smtinterpol_file \n\n << \"(set-logic \" \n\n << ((sig.is_QF_TO() ||\n\n sig.is_QF_IDL()) ? \n\n \"QF_UFIDL\" : \"QF_UFLIA\") << \")\" << std::endl;\n\n\n", "file_path": "src/AXDInterpolant-OutputFile.cpp", "rank": 33, "score": 61836.27939505367 }, { "content": " m_ctx = s.m_ctx;\n\n m_solver = s.m_solver;\n\n return *this;\n\n }\n\n void set(params const & p) { Z3_solver_set_params(ctx(), m_solver, p); check_error(); }\n\n void set(char const * k, bool v) { params p(ctx()); p.set(k, v); set(p); }\n\n void set(char const * k, unsigned v) { params p(ctx()); p.set(k, v); set(p); }\n\n void set(char const * k, double v) { params p(ctx()); p.set(k, v); set(p); }\n\n void set(char const * k, symbol const & v) { params p(ctx()); p.set(k, v); set(p); }\n\n void set(char const * k, char const* v) { params p(ctx()); p.set(k, v); set(p); }\n\n void push() { Z3_solver_push(ctx(), m_solver); check_error(); }\n\n void pop(unsigned n = 1) { Z3_solver_pop(ctx(), m_solver, n); check_error(); }\n\n void reset() { Z3_solver_reset(ctx(), m_solver); check_error(); }\n\n void add(expr const & e) { assert(e.is_bool()); Z3_solver_assert(ctx(), m_solver, e); check_error(); }\n\n void add(expr const & e, expr const & p) {\n\n assert(e.is_bool()); assert(p.is_bool()); assert(p.is_const());\n\n Z3_solver_assert_and_track(ctx(), m_solver, e, p);\n\n check_error();\n\n }\n\n void add(expr const & e, char const * p) {\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 34, "score": 61477.63592197766 }, { "content": " add(e, ctx().bool_const(p));\n\n }\n\n // fails for some compilers: \n\n // void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); }\n\n void from_file(char const* file) { Z3_solver_from_file(ctx(), m_solver, file); ctx().check_parser_error(); }\n\n void from_string(char const* s) { Z3_solver_from_string(ctx(), m_solver, s); ctx().check_parser_error(); }\n\n\n\n check_result check() { Z3_lbool r = Z3_solver_check(ctx(), m_solver); check_error(); return to_check_result(r); }\n\n check_result check(unsigned n, expr * const assumptions) {\n\n array<Z3_ast> _assumptions(n);\n\n for (unsigned i = 0; i < n; i++) {\n\n check_context(*this, assumptions[i]);\n\n _assumptions[i] = assumptions[i];\n\n }\n\n Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());\n\n check_error();\n\n return to_check_result(r);\n\n }\n\n check_result check(expr_vector assumptions) {\n\n unsigned n = assumptions.size();\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 35, "score": 61474.061756000614 }, { "content": " \\brief Return true if this expression is a constant (i.e., an application with 0 arguments).\n\n */\n\n bool is_const() const { return is_app() && num_args() == 0; }\n\n /**\n\n \\brief Return true if this expression is a quantifier.\n\n */\n\n bool is_quantifier() const { return kind() == Z3_QUANTIFIER_AST; }\n\n /**\n\n \\brief Return true if this expression is a variable.\n\n */\n\n bool is_var() const { return kind() == Z3_VAR_AST; }\n\n /**\n\n \\brief Return true if expression is an algebraic number.\n\n */\n\n bool is_algebraic() const { return 0 != Z3_is_algebraic_number(ctx(), m_ast); }\n\n\n\n /**\n\n \\brief Return true if this expression is well sorted (aka type correct).\n\n */\n\n bool is_well_sorted() const { bool r = Z3_is_well_sorted(ctx(), m_ast) != 0; check_error(); return r; }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 36, "score": 61469.96957382528 }, { "content": " }\n\n\n\n std::string to_smt2_decls_only(char const* status = \"unknown\") {\n\n array<Z3_ast> es(assertions());\n\n Z3_ast const* fmls = es.ptr();\n\n Z3_ast fml = 0;\n\n unsigned sz = es.size();\n\n if (sz > 0) {\n\n --sz;\n\n fml = fmls[sz];\n\n }\n\n else {\n\n fml = ctx().bool_val(true);\n\n }\n\n return std::string(Z3_benchmark_to_smtlib_string_decls_only(\n\n ctx(),\n\n \"\", \"\", status, \"\",\n\n sz,\n\n fmls,\n\n fml));\n\n }\n\n\n\n param_descrs get_param_descrs() { return param_descrs(ctx(), Z3_solver_get_param_descrs(ctx(), m_solver)); }\n\n\n\n };\n\n inline std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 37, "score": 61469.41788273367 }, { "content": "\n\n inline check_result context::compute_interpolant(expr const& pat, params const& p, expr_vector& i, model& m) {\n\n Z3_ast_vector interp = 0;\n\n Z3_model mdl = 0;\n\n Z3_lbool r = Z3_compute_interpolant(*this, pat, p, &interp, &mdl);\n\n switch (r) {\n\n case Z3_L_FALSE:\n\n i = expr_vector(*this, interp);\n\n break;\n\n case Z3_L_TRUE:\n\n m = model(*this, mdl);\n\n break;\n\n case Z3_L_UNDEF:\n\n break;\n\n }\n\n return to_check_result(r);\n\n }\n\n\n\n inline expr_vector context::get_interpolant(expr const& proof, expr const& pat, params const& p) {\n\n return expr_vector(*this, Z3_get_interpolant(*this, proof, pat, p));\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 38, "score": 61469.38068112327 }, { "content": " struct interpolation {};\n\n context() { config c; init(c); }\n\n context(config & c) { init(c); }\n\n context(config & c, interpolation) { init_interp(c); }\n\n ~context() { Z3_del_context(m_ctx); }\n\n operator Z3_context() const { return m_ctx; }\n\n\n\n /**\n\n \\brief Auxiliary method used to check for API usage errors.\n\n */\n\n Z3_error_code check_error() const {\n\n Z3_error_code e = Z3_get_error_code(m_ctx);\n\n if (e != Z3_OK && enable_exceptions())\n\n Z3_THROW(exception(Z3_get_error_msg(m_ctx, e)));\n\n return e;\n\n }\n\n\n\n void check_parser_error() const {\n\n check_error();\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 39, "score": 61468.98666672524 }, { "content": " friend std::ostream & operator<<(std::ostream & out, solver const & s);\n\n\n\n std::string to_smt2(char const* status = \"unknown\") {\n\n array<Z3_ast> es(assertions());\n\n Z3_ast const* fmls = es.ptr();\n\n Z3_ast fml = 0;\n\n unsigned sz = es.size();\n\n if (sz > 0) {\n\n --sz;\n\n fml = fmls[sz];\n\n }\n\n else {\n\n fml = ctx().bool_val(true);\n\n }\n\n return std::string(Z3_benchmark_to_smtlib_string(\n\n ctx(),\n\n \"\", \"\", status, \"\",\n\n sz,\n\n fmls,\n\n fml));\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 40, "score": 61468.9532931074 }, { "content": " void push() {\n\n Z3_optimize_push(ctx(), m_opt);\n\n }\n\n void pop() {\n\n Z3_optimize_pop(ctx(), m_opt);\n\n }\n\n check_result check() { Z3_lbool r = Z3_optimize_check(ctx(), m_opt); check_error(); return to_check_result(r); }\n\n model get_model() const { Z3_model m = Z3_optimize_get_model(ctx(), m_opt); check_error(); return model(ctx(), m); }\n\n void set(params const & p) { Z3_optimize_set_params(ctx(), m_opt, p); check_error(); }\n\n expr lower(handle const& h) {\n\n Z3_ast r = Z3_optimize_get_lower(ctx(), m_opt, h.h());\n\n check_error();\n\n return expr(ctx(), r);\n\n }\n\n expr upper(handle const& h) {\n\n Z3_ast r = Z3_optimize_get_upper(ctx(), m_opt, h.h());\n\n check_error();\n\n return expr(ctx(), r);\n\n }\n\n expr_vector assertions() const { Z3_ast_vector r = Z3_optimize_get_assertions(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }\n\n expr_vector objectives() const { Z3_ast_vector r = Z3_optimize_get_objectives(ctx(), m_opt); check_error(); return expr_vector(ctx(), r); }\n\n stats statistics() const { Z3_stats r = Z3_optimize_get_statistics(ctx(), m_opt); check_error(); return stats(ctx(), r); }\n\n friend std::ostream & operator<<(std::ostream & out, optimize const & s);\n\n void from_file(char const* filename) { Z3_optimize_from_file(ctx(), m_opt, filename); check_error(); }\n\n void from_string(char const* constraints) { Z3_optimize_from_string(ctx(), m_opt, constraints); check_error(); }\n\n std::string help() const { char const * r = Z3_optimize_get_help(ctx(), m_opt); check_error(); return r; }\n\n };\n\n inline std::ostream & operator<<(std::ostream & out, optimize const & s) { out << Z3_optimize_to_string(s.ctx(), s.m_opt); return out; }\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 41, "score": 61468.82592978601 }, { "content": " array<Z3_ast> _assumptions(n);\n\n for (unsigned i = 0; i < n; i++) {\n\n check_context(*this, assumptions[i]);\n\n _assumptions[i] = assumptions[i];\n\n }\n\n Z3_lbool r = Z3_solver_check_assumptions(ctx(), m_solver, n, _assumptions.ptr());\n\n check_error();\n\n return to_check_result(r);\n\n }\n\n model get_model() const { Z3_model m = Z3_solver_get_model(ctx(), m_solver); check_error(); return model(ctx(), m); }\n\n check_result consequences(expr_vector& assumptions, expr_vector& vars, expr_vector& conseq) {\n\n Z3_lbool r = Z3_solver_get_consequences(ctx(), m_solver, assumptions, vars, conseq);\n\n check_error();\n\n return to_check_result(r);\n\n }\n\n std::string reason_unknown() const { Z3_string r = Z3_solver_get_reason_unknown(ctx(), m_solver); check_error(); return r; }\n\n stats statistics() const { Z3_stats r = Z3_solver_get_statistics(ctx(), m_solver); check_error(); return stats(ctx(), r); }\n\n expr_vector unsat_core() const { Z3_ast_vector r = Z3_solver_get_unsat_core(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }\n\n expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }\n\n expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 42, "score": 61468.77398308263 }, { "content": " /**\n\n \\brief Return true if this sort is a regular expression sort.\n\n */\n\n bool is_re() const { return sort_kind() == Z3_RE_SORT; }\n\n /**\n\n \\brief Return true if this sort is a Finite domain sort.\n\n */\n\n bool is_finite_domain() const { return sort_kind() == Z3_FINITE_DOMAIN_SORT; }\n\n\n\n /**\n\n \\brief Return the size of this Bit-vector sort.\n\n\n\n \\pre is_bv()\n\n */\n\n unsigned bv_size() const { assert(is_bv()); unsigned r = Z3_get_bv_sort_size(ctx(), *this); check_error(); return r; }\n\n\n\n /**\n\n \\brief Return the domain of this Array sort.\n\n\n\n \\pre is_array()\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 43, "score": 61468.66113941707 }, { "content": " void add(expr const& e) {\n\n assert(e.is_bool());\n\n Z3_optimize_assert(ctx(), m_opt, e);\n\n }\n\n handle add(expr const& e, unsigned weight) {\n\n assert(e.is_bool());\n\n std::stringstream strm;\n\n strm << weight;\n\n return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, strm.str().c_str(), 0));\n\n }\n\n handle add(expr const& e, char const* weight) {\n\n assert(e.is_bool());\n\n return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, weight, 0));\n\n }\n\n handle maximize(expr const& e) {\n\n return handle(Z3_optimize_maximize(ctx(), m_opt, e));\n\n }\n\n handle minimize(expr const& e) {\n\n return handle(Z3_optimize_minimize(ctx(), m_opt, e));\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 44, "score": 61468.071574780115 }, { "content": " /**\n\n \\brief Return true if this sort is a Bit-vector sort.\n\n */\n\n bool is_bv() const { return sort_kind() == Z3_BV_SORT; }\n\n /**\n\n \\brief Return true if this sort is a Array sort.\n\n */\n\n bool is_array() const { return sort_kind() == Z3_ARRAY_SORT; }\n\n /**\n\n \\brief Return true if this sort is a Datatype sort.\n\n */\n\n bool is_datatype() const { return sort_kind() == Z3_DATATYPE_SORT; }\n\n /**\n\n \\brief Return true if this sort is a Relation sort.\n\n */\n\n bool is_relation() const { return sort_kind() == Z3_RELATION_SORT; }\n\n /**\n\n \\brief Return true if this sort is a Sequence sort.\n\n */\n\n bool is_seq() const { return sort_kind() == Z3_SEQ_SORT; }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 45, "score": 61468.047121064476 }, { "content": " /**\n\n \\brief Return name of sort.\n\n */\n\n symbol name() const { Z3_symbol s = Z3_get_sort_name(ctx(), *this); check_error(); return symbol(ctx(), s); }\n\n /**\n\n \\brief Return true if this sort is the Boolean sort.\n\n */\n\n bool is_bool() const { return sort_kind() == Z3_BOOL_SORT; }\n\n /**\n\n \\brief Return true if this sort is the Integer sort.\n\n */\n\n bool is_int() const { return sort_kind() == Z3_INT_SORT; }\n\n /**\n\n \\brief Return true if this sort is the Real sort.\n\n */\n\n bool is_real() const { return sort_kind() == Z3_REAL_SORT; }\n\n /**\n\n \\brief Return true if this sort is the Integer or Real sort.\n\n */\n\n bool is_arith() const { return is_int() || is_real(); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 46, "score": 61467.766146593596 }, { "content": "\n\n /**\n\n \\brief Return string representation of numeral or algebraic number\n\n This method assumes the expression is numeral or algebraic\n\n\n\n \\pre is_numeral() || is_algebraic()\n\n */\n\n std::string get_decimal_string(int precision) const {\n\n assert(is_numeral() || is_algebraic());\n\n return std::string(Z3_get_numeral_decimal_string(ctx(), m_ast, precision));\n\n }\n\n\n\n /**\n\n \\brief retrieve unique identifier for expression.\n\n */\n\n unsigned id() const { unsigned r = Z3_get_ast_id(ctx(), m_ast); check_error(); return r; }\n\n\n\n /**\n\n \\brief Return int value of numeral, throw if result cannot fit in\n\n machine int\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 47, "score": 61467.446002362354 }, { "content": " }\n\n\n\n inline expr context::constant(symbol const & name, sort const & s) {\n\n Z3_ast r = Z3_mk_const(m_ctx, name, s);\n\n check_error();\n\n return expr(*this, r);\n\n }\n\n inline expr context::constant(char const * name, sort const & s) { return constant(str_symbol(name), s); }\n\n inline expr context::bool_const(char const * name) { return constant(name, bool_sort()); }\n\n inline expr context::int_const(char const * name) { return constant(name, int_sort()); }\n\n inline expr context::real_const(char const * name) { return constant(name, real_sort()); }\n\n inline expr context::bv_const(char const * name, unsigned sz) { return constant(name, bv_sort(sz)); }\n\n\n\n inline expr context::bool_val(bool b) { return b ? expr(*this, Z3_mk_true(m_ctx)) : expr(*this, Z3_mk_false(m_ctx)); }\n\n\n\n inline expr context::int_val(int n) { Z3_ast r = Z3_mk_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }\n\n inline expr context::int_val(unsigned n) { Z3_ast r = Z3_mk_unsigned_int(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }\n\n inline expr context::int_val(int64_t n) { Z3_ast r = Z3_mk_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }\n\n inline expr context::int_val(uint64_t n) { Z3_ast r = Z3_mk_unsigned_int64(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }\n\n inline expr context::int_val(char const * n) { Z3_ast r = Z3_mk_numeral(m_ctx, n, int_sort()); check_error(); return expr(*this, r); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 48, "score": 61467.3715541529 }, { "content": "\n\n /**\n\n \\brief The C++ API uses by defaults exceptions on errors. \n\n For applications that don't work well with exceptions (there should be only few)\n\n you have the ability to turn off exceptions. The tradeoffs are that applications\n\n have to very careful about using check_error() after calls that may result in an\n\n erroneous state.\n\n */\n\n void set_enable_exceptions(bool f) { m_enable_exceptions = f; }\n\n\n\n bool enable_exceptions() const { return m_enable_exceptions; }\n\n\n\n /**\n\n \\brief Update global parameter \\c param with string \\c value.\n\n */\n\n void set(char const * param, char const * value) { Z3_update_param_value(m_ctx, param, value); }\n\n /**\n\n \\brief Update global parameter \\c param with Boolean \\c value.\n\n */\n\n void set(char const * param, bool value) { Z3_update_param_value(m_ctx, param, value ? \"true\" : \"false\"); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 49, "score": 61467.24230576754 }, { "content": " // fails for some compilers: \n\n // void add(expr_vector const& v) { check_context(*this, v); for (expr e : v) add(e); }\n\n unsigned size() const { return Z3_goal_size(ctx(), m_goal); }\n\n expr operator[](int i) const { assert(0 <= i); Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }\n\n Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); }\n\n bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal) != 0; }\n\n unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); }\n\n void reset() { Z3_goal_reset(ctx(), m_goal); }\n\n unsigned num_exprs() const { return Z3_goal_num_exprs(ctx(), m_goal); }\n\n bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal) != 0; }\n\n bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal) != 0; }\n\n expr as_expr() const {\n\n unsigned n = size();\n\n if (n == 0)\n\n return ctx().bool_val(true);\n\n else if (n == 1)\n\n return operator[](0);\n\n else {\n\n array<Z3_ast> args(n);\n\n for (unsigned i = 0; i < n; i++)\n\n args[i] = operator[](i);\n\n return expr(ctx(), Z3_mk_and(ctx(), n, args.ptr()));\n\n }\n\n }\n\n friend std::ostream & operator<<(std::ostream & out, goal const & g);\n\n };\n\n inline std::ostream & operator<<(std::ostream & out, goal const & g) { out << Z3_goal_to_string(g.ctx(), g); return out; }\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 50, "score": 61467.1534486413 }, { "content": " expr string_val(std::string const& s);\n\n\n\n expr num_val(int n, sort const & s);\n\n\n\n /**\n\n \\brief parsing\n\n */\n\n expr parse_string(char const* s);\n\n expr parse_file(char const* file);\n\n\n\n expr parse_string(char const* s, sort_vector const& sorts, func_decl_vector const& decls);\n\n expr parse_file(char const* s, sort_vector const& sorts, func_decl_vector const& decls);\n\n\n\n /**\n\n \\brief Interpolation support\n\n */\n\n check_result compute_interpolant(expr const& pat, params const& p, expr_vector& interp, model& m);\n\n expr_vector get_interpolant(expr const& proof, expr const& pat, params const& p);\n\n\n\n };\n\n\n\n\n\n\n\n\n\n template<typename T>\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 51, "score": 61466.90554983995 }, { "content": " std::ostringstream oss;\n\n oss << value;\n\n Z3_set_param_value(m_cfg, param, oss.str().c_str());\n\n }\n\n };\n\n\n\n enum check_result {\n\n unsat, sat, unknown\n\n };\n\n\n\n inline check_result to_check_result(Z3_lbool l) {\n\n if (l == Z3_L_TRUE) return sat;\n\n else if (l == Z3_L_FALSE) return unsat;\n\n return unknown;\n\n }\n\n\n\n\n\n /**\n\n \\brief A Context manages all other Z3 objects, global configuration options, etc.\n\n */\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 52, "score": 61465.9796194958 }, { "content": " /**\n\n \\brief Update global parameter \\c param with Integer \\c value.\n\n */\n\n void set(char const * param, int value) {\n\n std::ostringstream oss;\n\n oss << value;\n\n Z3_update_param_value(m_ctx, param, oss.str().c_str());\n\n }\n\n\n\n /**\n\n \\brief Interrupt the current procedure being executed by any object managed by this context.\n\n This is a soft interruption: there is no guarantee the object will actually stop.\n\n */\n\n void interrupt() { Z3_interrupt(m_ctx); }\n\n\n\n /**\n\n \\brief Create a Z3 symbol based on the given string.\n\n */\n\n symbol str_symbol(char const * s);\n\n /**\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 53, "score": 61465.72977538604 }, { "content": " }\n\n\n\n\n\n expr denominator() const { \n\n assert(is_numeral());\n\n Z3_ast r = Z3_get_denominator(ctx(), m_ast);\n\n check_error();\n\n return expr(ctx(),r);\n\n }\n\n\n\n operator Z3_app() const { assert(is_app()); return reinterpret_cast<Z3_app>(m_ast); }\n\n\n\n /**\n\n \\brief Return the declaration associated with this application.\n\n This method assumes the expression is an application.\n\n\n\n \\pre is_app()\n\n */\n\n func_decl decl() const { Z3_func_decl f = Z3_get_app_decl(ctx(), *this); check_error(); return func_decl(ctx(), f); }\n\n /**\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 54, "score": 61465.606583020206 }, { "content": " }\n\n\n\n expr eval(expr const & n, bool model_completion=false) const {\n\n check_context(*this, n);\n\n Z3_ast r = 0;\n\n Z3_bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);\n\n check_error();\n\n if (status == Z3_FALSE && ctx().enable_exceptions())\n\n Z3_THROW(exception(\"failed to evaluate expression\"));\n\n return expr(ctx(), r);\n\n }\n\n\n\n unsigned num_consts() const { return Z3_model_get_num_consts(ctx(), m_model); }\n\n unsigned num_funcs() const { return Z3_model_get_num_funcs(ctx(), m_model); }\n\n func_decl get_const_decl(unsigned i) const { Z3_func_decl r = Z3_model_get_const_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }\n\n func_decl get_func_decl(unsigned i) const { Z3_func_decl r = Z3_model_get_func_decl(ctx(), m_model, i); check_error(); return func_decl(ctx(), r); }\n\n unsigned size() const { return num_consts() + num_funcs(); }\n\n func_decl operator[](int i) const {\n\n assert(0 <= i);\n\n return static_cast<unsigned>(i) < num_consts() ? get_const_decl(i) : get_func_decl(i - num_consts());\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 55, "score": 61465.53892063701 }, { "content": " /**\n\n \\brief Return true if this is a real expression.\n\n */\n\n bool is_real() const { return get_sort().is_real(); }\n\n /**\n\n \\brief Return true if this is an integer or real expression.\n\n */\n\n bool is_arith() const { return get_sort().is_arith(); }\n\n /**\n\n \\brief Return true if this is a Bit-vector expression.\n\n */\n\n bool is_bv() const { return get_sort().is_bv(); }\n\n /**\n\n \\brief Return true if this is a Array expression.\n\n */\n\n bool is_array() const { return get_sort().is_array(); }\n\n /**\n\n \\brief Return true if this is a Datatype expression.\n\n */\n\n bool is_datatype() const { return get_sort().is_datatype(); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 56, "score": 61465.32635879207 }, { "content": " expr body() const { assert(is_quantifier()); Z3_ast r = Z3_get_quantifier_body(ctx(), *this); check_error(); return expr(ctx(), r); }\n\n\n\n /**\n\n \\brief Return an expression representing <tt>not(a)</tt>.\n\n\n\n \\pre a.is_bool()\n\n */\n\n friend expr operator!(expr const & a);\n\n\n\n\n\n /**\n\n \\brief Return an expression representing <tt>a and b</tt>.\n\n\n\n \\pre a.is_bool()\n\n \\pre b.is_bool()\n\n */\n\n friend expr operator&&(expr const & a, expr const & b);\n\n\n\n\n\n /**\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 57, "score": 61465.22469356369 }, { "content": " */\n\n sort array_domain() const { assert(is_array()); Z3_sort s = Z3_get_array_sort_domain(ctx(), *this); check_error(); return sort(ctx(), s); }\n\n /**\n\n \\brief Return the range of this Array sort.\n\n\n\n \\pre is_array()\n\n */\n\n sort array_range() const { assert(is_array()); Z3_sort s = Z3_get_array_sort_range(ctx(), *this); check_error(); return sort(ctx(), s); }\n\n };\n\n\n\n /**\n\n \\brief Function declaration (aka function definition). It is the signature of interpreted and uninterpreted functions in Z3.\n\n The basic building block in Z3 is the function application.\n\n */\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 58, "score": 61465.21888538067 }, { "content": " MK_EXPR1(Z3_mk_re_complement, a);\n\n }\n\n inline expr range(expr const& lo, expr const& hi) {\n\n check_context(lo, hi); \n\n Z3_ast r = Z3_mk_re_range(lo.ctx(), lo, hi); \n\n lo.check_error(); \n\n return expr(lo.ctx(), r); \n\n }\n\n\n\n\n\n\n\n\n\n\n\n inline expr interpolant(expr const& a) {\n\n return expr(a.ctx(), Z3_mk_interpolant(a.ctx(), a));\n\n }\n\n\n\n inline expr context::parse_string(char const* s) {\n\n Z3_ast r = Z3_parse_smtlib2_string(*this, s, 0, 0, 0, 0, 0, 0);\n\n check_parser_error();\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 59, "score": 61465.20904135312 }, { "content": " return expr(*this, r); \n\n }\n\n inline expr context::parse_file(char const* s) {\n\n Z3_ast r = Z3_parse_smtlib2_file(*this, s, 0, 0, 0, 0, 0, 0);\n\n check_parser_error();\n\n return expr(*this, r);\n\n }\n\n\n\n inline expr context::parse_string(char const* s, sort_vector const& sorts, func_decl_vector const& decls) {\n\n array<Z3_symbol> sort_names(sorts.size());\n\n array<Z3_symbol> decl_names(decls.size());\n\n array<Z3_sort> sorts1(sorts);\n\n array<Z3_func_decl> decls1(decls);\n\n for (unsigned i = 0; i < sorts.size(); ++i) {\n\n sort_names[i] = sorts[i].name();\n\n }\n\n for (unsigned i = 0; i < decls.size(); ++i) {\n\n decl_names[i] = decls[i].name();\n\n }\n\n Z3_ast r = Z3_parse_smtlib2_string(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 60, "score": 61465.19450908718 }, { "content": " }\n\n\n\n // returns interpretation of constant declaration c.\n\n // If c is not assigned any value in the model it returns \n\n // an expression with a null ast reference.\n\n expr get_const_interp(func_decl c) const {\n\n check_context(*this, c);\n\n Z3_ast r = Z3_model_get_const_interp(ctx(), m_model, c);\n\n check_error();\n\n return expr(ctx(), r);\n\n }\n\n func_interp get_func_interp(func_decl f) const {\n\n check_context(*this, f);\n\n Z3_func_interp r = Z3_model_get_func_interp(ctx(), m_model, f);\n\n check_error();\n\n return func_interp(ctx(), r);\n\n }\n\n\n\n // returns true iff the model contains an interpretation\n\n // for function f.\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 61, "score": 61465.12248382336 }, { "content": "*/\n\n bool is_finite_domain() const { return get_sort().is_finite_domain(); }\n\n\n\n /**\n\n \\brief Return true if this expression is a numeral.\n\n Specialized functions also return representations for the numerals as\n\n small integers, 64 bit integers or rational or decimal strings.\n\n */\n\n bool is_numeral() const { return kind() == Z3_NUMERAL_AST; }\n\n bool is_numeral_i64(int64_t& i) const { bool r = 0 != Z3_get_numeral_int64(ctx(), m_ast, &i); check_error(); return r;}\n\n bool is_numeral_u64(uint64_t& i) const { bool r = 0 != Z3_get_numeral_uint64(ctx(), m_ast, &i); check_error(); return r;}\n\n bool is_numeral_i(int& i) const { bool r = 0 != Z3_get_numeral_int(ctx(), m_ast, &i); check_error(); return r;}\n\n bool is_numeral_u(unsigned& i) const { bool r = 0 != Z3_get_numeral_uint(ctx(), m_ast, &i); check_error(); return r;}\n\n bool is_numeral(std::string& s) const { if (!is_numeral()) return false; s = Z3_get_numeral_string(ctx(), m_ast); check_error(); return true; }\n\n bool is_numeral(std::string& s, unsigned precision) const { if (!is_numeral()) return false; s = Z3_get_numeral_decimal_string(ctx(), m_ast, precision); check_error(); return true; }\n\n /**\n\n \\brief Return true if this expression is an application.\n\n */\n\n bool is_app() const { return kind() == Z3_APP_AST || kind() == Z3_NUMERAL_AST; }\n\n /**\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 62, "score": 61465.122764149084 }, { "content": " /**\n\n \\brief Return true if this is a Relation expression.\n\n */\n\n bool is_relation() const { return get_sort().is_relation(); }\n\n /**\n\n \\brief Return true if this is a sequence expression.\n\n */\n\n bool is_seq() const { return get_sort().is_seq(); }\n\n /**\n\n \\brief Return true if this is a regular expression.\n\n */\n\n bool is_re() const { return get_sort().is_re(); }\n\n\n\n /**\n\n \\brief Return true if this is a Finite-domain expression.\n\n\n\n \\remark Finite-domain is special kind of interpreted sort:\n\n is_bool(), is_bv() and is_finite_domain() are mutually\n\n exclusive.\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 63, "score": 61464.975090601045 }, { "content": " bool has_interp(func_decl f) const {\n\n check_context(*this, f);\n\n return 0 != Z3_model_has_interp(ctx(), m_model, f);\n\n }\n\n\n\n func_interp add_func_interp(func_decl& f, expr& else_val) {\n\n Z3_func_interp r = Z3_add_func_interp(ctx(), m_model, f, else_val);\n\n check_error();\n\n return func_interp(ctx(), r);\n\n }\n\n\n\n void add_const_interp(func_decl& f, expr& value) {\n\n Z3_add_const_interp(ctx(), m_model, f, value);\n\n check_error();\n\n }\n\n\n\n friend std::ostream & operator<<(std::ostream & out, model const & m);\n\n };\n\n inline std::ostream & operator<<(std::ostream & out, model const & m) { out << Z3_model_to_string(m.ctx(), m); return out; }\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 64, "score": 61464.858954082054 }, { "content": "\n\n \\pre is_numeral()\n\n */\n\n int64_t get_numeral_int64() const {\n\n assert(is_numeral());\n\n int64_t result = 0;\n\n if (!is_numeral_i64(result)) {\n\n assert(ctx().enable_exceptions());\n\n if (!ctx().enable_exceptions()) return 0;\n\n Z3_THROW(exception(\"numeral does not fit in machine int64_t\"));\n\n }\n\n return result;\n\n }\n\n\n\n /**\n\n \\brief Return \\c uint64_t value of numeral, throw if result cannot fit in\n\n \\c uint64_t.\n\n\n\n \\pre is_numeral()\n\n */\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 65, "score": 61464.818781269845 }, { "content": "#ifndef Z3PP_H_\n\n#define Z3PP_H_\n\n\n\n#include<cassert>\n\n#include<iostream>\n\n#include<string>\n\n#include<sstream>\n\n#include<z3.h>\n\n#include<limits.h>\n\n\n\n/**\n\n \\defgroup cppapi C++ API\n\n\n\n*/\n\n/*@{*/\n\n\n\n/**\n\n @name C++ API classes and functions\n\n */\n\n/*@{*/\n\n\n\n/**\n\n \\brief Z3 C++ namespace\n\n */\n\nnamespace z3 {\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 66, "score": 61464.77225686511 }, { "content": " unsigned get_num_levels(func_decl& p) { unsigned r = Z3_fixedpoint_get_num_levels(ctx(), m_fp, p); check_error(); return r; }\n\n expr get_cover_delta(int level, func_decl& p) { \n\n Z3_ast r = Z3_fixedpoint_get_cover_delta(ctx(), m_fp, level, p); \n\n check_error(); \n\n return expr(ctx(), r);\n\n }\n\n void add_cover(int level, func_decl& p, expr& property) { Z3_fixedpoint_add_cover(ctx(), m_fp, level, p, property); check_error(); }\n\n stats statistics() const { Z3_stats r = Z3_fixedpoint_get_statistics(ctx(), m_fp); check_error(); return stats(ctx(), r); }\n\n void register_relation(func_decl& p) { Z3_fixedpoint_register_relation(ctx(), m_fp, p); }\n\n expr_vector assertions() const { Z3_ast_vector r = Z3_fixedpoint_get_assertions(ctx(), m_fp); check_error(); return expr_vector(ctx(), r); }\n\n expr_vector rules() const { Z3_ast_vector r = Z3_fixedpoint_get_rules(ctx(), m_fp); check_error(); return expr_vector(ctx(), r); }\n\n void set(params const & p) { Z3_fixedpoint_set_params(ctx(), m_fp, p); check_error(); }\n\n std::string help() const { return Z3_fixedpoint_get_help(ctx(), m_fp); }\n\n param_descrs get_param_descrs() { return param_descrs(ctx(), Z3_fixedpoint_get_param_descrs(ctx(), m_fp)); }\n\n std::string to_string() { return Z3_fixedpoint_to_string(ctx(), m_fp, 0, 0); }\n\n std::string to_string(expr_vector const& queries) {\n\n array<Z3_ast> qs(queries);\n\n return Z3_fixedpoint_to_string(ctx(), m_fp, qs.size(), qs.ptr()); \n\n }\n\n void push() { Z3_fixedpoint_push(ctx(), m_fp); check_error(); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 67, "score": 61464.40979332115 }, { "content": " check_parser_error();\n\n return expr(*this, r);\n\n }\n\n\n\n inline expr context::parse_file(char const* s, sort_vector const& sorts, func_decl_vector const& decls) {\n\n array<Z3_symbol> sort_names(sorts.size());\n\n array<Z3_symbol> decl_names(decls.size());\n\n array<Z3_sort> sorts1(sorts);\n\n array<Z3_func_decl> decls1(decls);\n\n for (unsigned i = 0; i < sorts.size(); ++i) {\n\n sort_names[i] = sorts[i].name();\n\n }\n\n for (unsigned i = 0; i < decls.size(); ++i) {\n\n decl_names[i] = decls[i].name();\n\n }\n\n Z3_ast r = Z3_parse_smtlib2_file(*this, s, sorts.size(), sort_names.ptr(), sorts1.ptr(), decls.size(), decl_names.ptr(), decls1.ptr());\n\n check_parser_error();\n\n return expr(*this, r);\n\n }\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 68, "score": 61464.378222321175 }, { "content": " Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 3, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr exists(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {\n\n check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);\n\n Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };\n\n Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 4, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr exists(expr_vector const & xs, expr const & b) {\n\n array<Z3_app> vars(xs);\n\n Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, vars.size(), vars.ptr(), 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr pble(expr_vector const& es, int const* coeffs, int bound) {\n\n assert(es.size() > 0);\n\n context& ctx = es[0].ctx();\n\n array<Z3_ast> _es(es);\n\n Z3_ast r = Z3_mk_pble(ctx, _es.size(), _es.ptr(), coeffs, bound);\n\n ctx.check_error();\n\n return expr(ctx, r);\n\n }\n\n inline expr pbge(expr_vector const& es, int const* coeffs, int bound) {\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 69, "score": 61464.14882802797 }, { "content": " func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);\n\n func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);\n\n func_decl function(symbol const& name, sort_vector const& domain, sort const& range);\n\n func_decl function(char const * name, sort_vector const& domain, sort const& range);\n\n func_decl function(char const * name, sort const & domain, sort const & range);\n\n func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range);\n\n func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range);\n\n func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & range);\n\n func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & d4, sort const & d5, sort const & range);\n\n\n\n expr constant(symbol const & name, sort const & s);\n\n expr constant(char const * name, sort const & s);\n\n expr bool_const(char const * name);\n\n expr int_const(char const * name);\n\n expr real_const(char const * name);\n\n expr bv_const(char const * name, unsigned sz);\n\n\n\n expr bool_val(bool b);\n\n\n\n expr int_val(int n);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 70, "score": 61464.12630330869 }, { "content": "\n\n It only makes sense to use this function if the caller can ensure that\n\n the result is an integer or if exceptions are enabled. \n\n If exceptions are disabled, then use the is_numeral_u function.\n\n \\pre is_numeral()\n\n */\n\n unsigned get_numeral_uint() const {\n\n assert(is_numeral());\n\n unsigned result = 0;\n\n if (!is_numeral_u(result)) {\n\n assert(ctx().enable_exceptions());\n\n if (!ctx().enable_exceptions()) return 0;\n\n Z3_THROW(exception(\"numeral does not fit in machine uint\"));\n\n }\n\n return result;\n\n }\n\n\n\n /**\n\n \\brief Return \\c int64_t value of numeral, throw if result cannot fit in\n\n \\c int64_t.\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 71, "score": 61464.04694379885 }, { "content": " uint64_t get_numeral_uint64() const {\n\n assert(is_numeral());\n\n uint64_t result = 0;\n\n if (!is_numeral_u64(result)) {\n\n assert(ctx().enable_exceptions());\n\n if (!ctx().enable_exceptions()) return 0;\n\n Z3_THROW(exception(\"numeral does not fit in machine uint64_t\"));\n\n }\n\n return result;\n\n }\n\n\n\n Z3_lbool bool_value() const {\n\n return Z3_get_bool_value(ctx(), m_ast);\n\n }\n\n\n\n expr numerator() const { \n\n assert(is_numeral());\n\n Z3_ast r = Z3_get_numerator(ctx(), m_ast);\n\n check_error();\n\n return expr(ctx(),r);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 72, "score": 61463.55772834858 }, { "content": " Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3, (Z3_app) x4 };\n\n Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 4, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr forall(expr_vector const & xs, expr const & b) {\n\n array<Z3_app> vars(xs);\n\n Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, vars.size(), vars.ptr(), 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr exists(expr const & x, expr const & b) {\n\n check_context(x, b);\n\n Z3_app vars[] = {(Z3_app) x};\n\n Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 1, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr exists(expr const & x1, expr const & x2, expr const & b) {\n\n check_context(x1, b); check_context(x2, b);\n\n Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};\n\n Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, 2, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr exists(expr const & x1, expr const & x2, expr const & x3, expr const & b) {\n\n check_context(x1, b); check_context(x2, b); check_context(x3, b);\n\n Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 73, "score": 61463.449800862574 }, { "content": "\n\n template<> class cast_ast<expr> {\n\n public:\n\n expr operator()(context & c, Z3_ast a) {\n\n assert(Z3_get_ast_kind(c, a) == Z3_NUMERAL_AST ||\n\n Z3_get_ast_kind(c, a) == Z3_APP_AST ||\n\n Z3_get_ast_kind(c, a) == Z3_QUANTIFIER_AST ||\n\n Z3_get_ast_kind(c, a) == Z3_VAR_AST);\n\n return expr(c, a);\n\n }\n\n };\n\n\n\n template<> class cast_ast<sort> {\n\n public:\n\n sort operator()(context & c, Z3_ast a) {\n\n assert(Z3_get_ast_kind(c, a) == Z3_SORT_AST);\n\n return sort(c, reinterpret_cast<Z3_sort>(a));\n\n }\n\n };\n\n\n\n template<> class cast_ast<func_decl> {\n\n public:\n\n func_decl operator()(context & c, Z3_ast a) {\n\n assert(Z3_get_ast_kind(c, a) == Z3_FUNC_DECL_AST);\n\n return func_decl(c, reinterpret_cast<Z3_func_decl>(a));\n\n }\n\n };\n\n\n\n template<typename T>\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 74, "score": 61463.427882032345 }, { "content": "\n\n It only makes sense to use this function if the caller can ensure that\n\n the result is an integer or if exceptions are enabled. \n\n If exceptions are disabled, then use the is_numeral_i function.\n\n\n\n \\pre is_numeral()\n\n */\n\n int get_numeral_int() const { \n\n int result = 0;\n\n if (!is_numeral_i(result)) {\n\n assert(ctx().enable_exceptions());\n\n if (!ctx().enable_exceptions()) return 0;\n\n Z3_THROW(exception(\"numeral does not fit in machine int\"));\n\n }\n\n return result;\n\n }\n\n\n\n /**\n\n \\brief Return uint value of numeral, throw if result cannot fit in\n\n machine uint\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 75, "score": 61463.18478594463 }, { "content": " \\brief Return the number of arguments in this application.\n\n This method assumes the expression is an application.\n\n\n\n \\pre is_app()\n\n */\n\n unsigned num_args() const { unsigned r = Z3_get_app_num_args(ctx(), *this); check_error(); return r; }\n\n /**\n\n \\brief Return the i-th argument of this application.\n\n This method assumes the expression is an application.\n\n\n\n \\pre is_app()\n\n \\pre i < num_args()\n\n */\n\n expr arg(unsigned i) const { Z3_ast r = Z3_get_app_arg(ctx(), *this, i); check_error(); return expr(ctx(), r); }\n\n\n\n /**\n\n \\brief Return the 'body' of this quantifier.\n\n\n\n \\pre is_quantifier()\n\n */\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 76, "score": 61463.132011260794 }, { "content": " \\brief Return an enumeration sort: enum_names[0], ..., enum_names[n-1].\n\n \\c cs and \\c ts are output parameters. The method stores in \\c cs the constants corresponding to the enumerated elements,\n\n and in \\c ts the predicates for testing if terms of the enumeration sort correspond to an enumeration.\n\n */\n\n sort enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts);\n\n\n\n /**\n\n \\brief Return a tuple constructor.\n\n \\c name is the name of the returned constructor,\n\n \\c n are the number of arguments, \\c names and \\c sorts are their projected sorts.\n\n \\c projs is an output paramter. It contains the set of projection functions.\n\n */\n\n func_decl tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs);\n\n\n\n /**\n\n \\brief create an uninterpreted sort with the name given by the string or symbol.\n\n */\n\n sort uninterpreted_sort(char const* name);\n\n sort uninterpreted_sort(symbol const& name);\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 77, "score": 61463.13054498789 }, { "content": " inline expr operator==(expr const & a, int b) { assert(a.is_arith() || a.is_bv()); return a == a.ctx().num_val(b, a.get_sort()); }\n\n inline expr operator==(int a, expr const & b) { assert(b.is_arith() || b.is_bv()); return b.ctx().num_val(a, b.get_sort()) == b; }\n\n\n\n inline expr operator!=(expr const & a, expr const & b) {\n\n check_context(a, b);\n\n Z3_ast args[2] = { a, b };\n\n Z3_ast r = Z3_mk_distinct(a.ctx(), 2, args);\n\n a.check_error();\n\n return expr(a.ctx(), r);\n\n }\n\n inline expr operator!=(expr const & a, int b) { assert(a.is_arith() || a.is_bv()); return a != a.ctx().num_val(b, a.get_sort()); }\n\n inline expr operator!=(int a, expr const & b) { assert(b.is_arith() || b.is_bv()); return b.ctx().num_val(a, b.get_sort()) != b; }\n\n\n\n inline expr operator+(expr const & a, expr const & b) {\n\n check_context(a, b);\n\n Z3_ast r = 0;\n\n if (a.is_arith() && b.is_arith()) {\n\n Z3_ast args[2] = { a, b };\n\n r = Z3_mk_add(a.ctx(), 2, args);\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 78, "score": 61463.088772714946 }, { "content": " check_context(c, t); check_context(c, e);\n\n assert(c.is_bool());\n\n Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);\n\n c.check_error();\n\n return expr(c.ctx(), r);\n\n }\n\n\n\n\n\n /**\n\n \\brief Wraps a Z3_ast as an expr object. It also checks for errors.\n\n This function allows the user to use the whole C API with the C++ layer defined in this file.\n\n */\n\n inline expr to_expr(context & c, Z3_ast a) {\n\n c.check_error();\n\n assert(Z3_get_ast_kind(c, a) == Z3_APP_AST ||\n\n Z3_get_ast_kind(c, a) == Z3_NUMERAL_AST ||\n\n Z3_get_ast_kind(c, a) == Z3_VAR_AST ||\n\n Z3_get_ast_kind(c, a) == Z3_QUANTIFIER_AST);\n\n return expr(c, a);\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 79, "score": 61463.01618615996 }, { "content": " return expr(a.ctx(), r); \\\n\n\n\n\n\n inline expr operator!(expr const & a) { assert(a.is_bool()); _Z3_MK_UN_(a, Z3_mk_not); }\n\n\n\n inline expr is_int(expr const& e) { _Z3_MK_UN_(e, Z3_mk_is_int); }\n\n\n\n#undef _Z3_MK_UN_\n\n\n\n inline expr operator&&(expr const & a, expr const & b) {\n\n check_context(a, b);\n\n assert(a.is_bool() && b.is_bool());\n\n Z3_ast args[2] = { a, b };\n\n Z3_ast r = Z3_mk_and(a.ctx(), 2, args);\n\n a.check_error();\n\n return expr(a.ctx(), r);\n\n }\n\n\n\n inline expr operator&&(expr const & a, bool b) { return a && a.ctx().bool_val(b); }\n\n inline expr operator&&(bool a, expr const & b) { return b.ctx().bool_val(a) && b; }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 80, "score": 61462.95626711087 }, { "content": " func_entry entry(unsigned i) const { Z3_func_entry e = Z3_func_interp_get_entry(ctx(), m_interp, i); check_error(); return func_entry(ctx(), e); }\n\n void add_entry(expr_vector const& args, expr& value) {\n\n Z3_func_interp_add_entry(ctx(), m_interp, args, value);\n\n check_error();\n\n }\n\n void set_else(expr& value) {\n\n Z3_func_interp_set_else(ctx(), m_interp, value);\n\n check_error();\n\n }\n\n };\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 81, "score": 61462.942778700555 }, { "content": " \\brief Return an expression representing <tt>a and b</tt>.\n\n The C++ Boolean value \\c b is automatically converted into a Z3 Boolean constant.\n\n\n\n \\pre a.is_bool()\n\n */\n\n friend expr operator&&(expr const & a, bool b);\n\n /**\n\n \\brief Return an expression representing <tt>a and b</tt>.\n\n The C++ Boolean value \\c a is automatically converted into a Z3 Boolean constant.\n\n\n\n \\pre b.is_bool()\n\n */\n\n friend expr operator&&(bool a, expr const & b);\n\n\n\n /**\n\n \\brief Return an expression representing <tt>a or b</tt>.\n\n\n\n \\pre a.is_bool()\n\n \\pre b.is_bool()\n\n */\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 82, "score": 61462.900646711496 }, { "content": " assert(es.size() > 0);\n\n context& ctx = es[0].ctx();\n\n array<Z3_ast> _es(es);\n\n Z3_ast r = Z3_mk_pbge(ctx, _es.size(), _es.ptr(), coeffs, bound);\n\n ctx.check_error();\n\n return expr(ctx, r);\n\n }\n\n inline expr pbeq(expr_vector const& es, int const* coeffs, int bound) {\n\n assert(es.size() > 0);\n\n context& ctx = es[0].ctx();\n\n array<Z3_ast> _es(es);\n\n Z3_ast r = Z3_mk_pbeq(ctx, _es.size(), _es.ptr(), coeffs, bound);\n\n ctx.check_error();\n\n return expr(ctx, r);\n\n }\n\n inline expr atmost(expr_vector const& es, unsigned bound) {\n\n assert(es.size() > 0);\n\n context& ctx = es[0].ctx();\n\n array<Z3_ast> _es(es);\n\n Z3_ast r = Z3_mk_atmost(ctx, _es.size(), _es.ptr(), bound);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 83, "score": 61462.893612806125 }, { "content": "\n\n // Basic functions for creating quantified formulas.\n\n // The C API should be used for creating quantifiers with patterns, weights, many variables, etc.\n\n inline expr forall(expr const & x, expr const & b) {\n\n check_context(x, b);\n\n Z3_app vars[] = {(Z3_app) x};\n\n Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 1, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr forall(expr const & x1, expr const & x2, expr const & b) {\n\n check_context(x1, b); check_context(x2, b);\n\n Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2};\n\n Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 2, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr forall(expr const & x1, expr const & x2, expr const & x3, expr const & b) {\n\n check_context(x1, b); check_context(x2, b); check_context(x3, b);\n\n Z3_app vars[] = {(Z3_app) x1, (Z3_app) x2, (Z3_app) x3 };\n\n Z3_ast r = Z3_mk_forall_const(b.ctx(), 0, 3, vars, 0, 0, b); b.check_error(); return expr(b.ctx(), r);\n\n }\n\n inline expr forall(expr const & x1, expr const & x2, expr const & x3, expr const & x4, expr const & b) {\n\n check_context(x1, b); check_context(x2, b); check_context(x3, b); check_context(x4, b);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 84, "score": 61462.85730389106 }, { "content": " check_error(); \n\n return expr(ctx(), r); \n\n }\n\n\n\n\n\n /**\n\n \\brief Return a simplified version of this expression.\n\n */\n\n expr simplify() const { Z3_ast r = Z3_simplify(ctx(), m_ast); check_error(); return expr(ctx(), r); }\n\n\n\n expr qf_to_simplify() const { Z3_ast r = Z3_qf_to_simplify(ctx(), m_ast); check_error(); return expr(ctx(), r); }\n\n /**\n\n \\brief Return a simplified version of this expression. The parameter \\c p is a set of parameters for the Z3 simplifier.\n\n */\n\n expr simplify(params const & p) const { Z3_ast r = Z3_simplify_ex(ctx(), m_ast, p); check_error(); return expr(ctx(), r); }\n\n\n\n /**\n\n \\brief Apply substitution. Replace src expressions by dst.\n\n */\n\n expr substitute(expr_vector const& src, expr_vector const& dst);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 85, "score": 61462.81097930315 }, { "content": "\n\n\n\n inline func_decl context::function(char const * name, sort const & domain, sort const & range) {\n\n check_context(domain, range);\n\n Z3_sort args[1] = { domain };\n\n Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 1, args, range);\n\n check_error();\n\n return func_decl(*this, f);\n\n }\n\n\n\n inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & range) {\n\n check_context(d1, range); check_context(d2, range);\n\n Z3_sort args[2] = { d1, d2 };\n\n Z3_func_decl f = Z3_mk_func_decl(m_ctx, str_symbol(name), 2, args, range);\n\n check_error();\n\n return func_decl(*this, f);\n\n }\n\n\n\n inline func_decl context::function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range) {\n\n check_context(d1, range); check_context(d2, range); check_context(d3, range);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 86, "score": 61462.63626870926 }, { "content": " \\brief Create a Z3 symbol based on the given integer.\n\n */\n\n symbol int_symbol(int n);\n\n /**\n\n \\brief Return the Boolean sort.\n\n */\n\n sort bool_sort();\n\n /**\n\n \\brief Return the integer sort.\n\n */\n\n sort int_sort();\n\n /**\n\n \\brief Return the Real sort.\n\n */\n\n sort real_sort();\n\n /**\n\n \\brief Return the Bit-vector sort of size \\c sz. That is, the sort for bit-vectors of size \\c sz.\n\n */\n\n sort bv_sort(unsigned sz);\n\n /**\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 87, "score": 61462.615500966116 }, { "content": " ctx.check_error();\n\n return expr(ctx, r);\n\n }\n\n inline expr atleast(expr_vector const& es, unsigned bound) {\n\n assert(es.size() > 0);\n\n context& ctx = es[0].ctx();\n\n array<Z3_ast> _es(es);\n\n Z3_ast r = Z3_mk_atleast(ctx, _es.size(), _es.ptr(), bound);\n\n ctx.check_error();\n\n return expr(ctx, r);\n\n }\n\n inline expr sum(expr_vector const& args) {\n\n assert(args.size() > 0);\n\n context& ctx = args[0].ctx();\n\n array<Z3_ast> _args(args);\n\n Z3_ast r = Z3_mk_add(ctx, _args.size(), _args.ptr());\n\n ctx.check_error();\n\n return expr(ctx, r);\n\n }\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 88, "score": 61462.57328472198 }, { "content": " r = Z3_mk_unary_minus(a.ctx(), a);\n\n }\n\n else if (a.is_bv()) {\n\n r = Z3_mk_bvneg(a.ctx(), a);\n\n }\n\n else {\n\n // operator is not supported by given arguments.\n\n assert(false);\n\n }\n\n a.check_error();\n\n return expr(a.ctx(), r);\n\n }\n\n\n\n inline expr operator-(expr const & a, expr const & b) {\n\n check_context(a, b);\n\n Z3_ast r = 0;\n\n if (a.is_arith() && b.is_arith()) {\n\n Z3_ast args[2] = { a, b };\n\n r = Z3_mk_sub(a.ctx(), 2, args);\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 89, "score": 61462.53896163898 }, { "content": " std::string key(unsigned i) const { Z3_string s = Z3_stats_get_key(ctx(), m_stats, i); check_error(); return s; }\n\n bool is_uint(unsigned i) const { Z3_bool r = Z3_stats_is_uint(ctx(), m_stats, i); check_error(); return r != 0; }\n\n bool is_double(unsigned i) const { Z3_bool r = Z3_stats_is_double(ctx(), m_stats, i); check_error(); return r != 0; }\n\n unsigned uint_value(unsigned i) const { unsigned r = Z3_stats_get_uint_value(ctx(), m_stats, i); check_error(); return r; }\n\n double double_value(unsigned i) const { double r = Z3_stats_get_double_value(ctx(), m_stats, i); check_error(); return r; }\n\n friend std::ostream & operator<<(std::ostream & out, stats const & s);\n\n };\n\n inline std::ostream & operator<<(std::ostream & out, stats const & s) { out << Z3_stats_to_string(s.ctx(), s); return out; }\n\n\n\n\n\n inline std::ostream & operator<<(std::ostream & out, check_result r) {\n\n if (r == unsat) out << \"unsat\";\n\n else if (r == sat) out << \"sat\";\n\n else out << \"unknown\";\n\n return out;\n\n }\n\n\n\n\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 90, "score": 61462.50334506 }, { "content": " Z3_ast args[5] = { a1, a2, a3, a4, a5 };\n\n Z3_ast r = Z3_mk_app(ctx(), *this, 5, args);\n\n ctx().check_error();\n\n return expr(ctx(), r);\n\n }\n\n\n\n inline expr to_real(expr const & a) { Z3_ast r = Z3_mk_int2real(a.ctx(), a); a.check_error(); return expr(a.ctx(), r); }\n\n\n\n inline func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range) {\n\n return range.ctx().function(name, arity, domain, range);\n\n }\n\n inline func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range) {\n\n return range.ctx().function(name, arity, domain, range);\n\n }\n\n inline func_decl function(char const * name, sort const & domain, sort const & range) {\n\n return range.ctx().function(name, domain, range);\n\n }\n\n inline func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range) {\n\n return range.ctx().function(name, d1, d2, range);\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 91, "score": 61462.43689122179 }, { "content": " }\n\n\n\n inline symbol context::str_symbol(char const * s) { Z3_symbol r = Z3_mk_string_symbol(m_ctx, s); check_error(); return symbol(*this, r); }\n\n inline symbol context::int_symbol(int n) { Z3_symbol r = Z3_mk_int_symbol(m_ctx, n); check_error(); return symbol(*this, r); }\n\n\n\n inline sort context::bool_sort() { Z3_sort s = Z3_mk_bool_sort(m_ctx); check_error(); return sort(*this, s); }\n\n inline sort context::int_sort() { Z3_sort s = Z3_mk_int_sort(m_ctx); check_error(); return sort(*this, s); }\n\n inline sort context::real_sort() { Z3_sort s = Z3_mk_real_sort(m_ctx); check_error(); return sort(*this, s); }\n\n inline sort context::bv_sort(unsigned sz) { Z3_sort s = Z3_mk_bv_sort(m_ctx, sz); check_error(); return sort(*this, s); }\n\n inline sort context::string_sort() { Z3_sort s = Z3_mk_string_sort(m_ctx); check_error(); return sort(*this, s); }\n\n inline sort context::seq_sort(sort& s) { Z3_sort r = Z3_mk_seq_sort(m_ctx, s); check_error(); return sort(*this, r); }\n\n inline sort context::re_sort(sort& s) { Z3_sort r = Z3_mk_re_sort(m_ctx, s); check_error(); return sort(*this, r); }\n\n\n\n inline sort context::array_sort(sort d, sort r) { Z3_sort s = Z3_mk_array_sort(m_ctx, d, r); check_error(); return sort(*this, s); }\n\n inline sort context::array_sort(sort_vector const& d, sort r) {\n\n array<Z3_sort> dom(d);\n\n Z3_sort s = Z3_mk_array_sort_n(m_ctx, dom.size(), dom.ptr(), r); check_error(); return sort(*this, s); \n\n }\n\n\n\n inline sort context::enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts) {\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 92, "score": 61462.3167030193 }, { "content": " array<Z3_symbol> _enum_names(n);\n\n for (unsigned i = 0; i < n; i++) { _enum_names[i] = Z3_mk_string_symbol(*this, enum_names[i]); }\n\n array<Z3_func_decl> _cs(n);\n\n array<Z3_func_decl> _ts(n);\n\n Z3_symbol _name = Z3_mk_string_symbol(*this, name);\n\n sort s = to_sort(*this, Z3_mk_enumeration_sort(*this, _name, n, _enum_names.ptr(), _cs.ptr(), _ts.ptr()));\n\n check_error();\n\n for (unsigned i = 0; i < n; i++) { cs.push_back(func_decl(*this, _cs[i])); ts.push_back(func_decl(*this, _ts[i])); }\n\n return s;\n\n }\n\n inline func_decl context::tuple_sort(char const * name, unsigned n, char const * const * names, sort const* sorts, func_decl_vector & projs) {\n\n array<Z3_symbol> _names(n);\n\n array<Z3_sort> _sorts(n);\n\n for (unsigned i = 0; i < n; i++) { _names[i] = Z3_mk_string_symbol(*this, names[i]); _sorts[i] = sorts[i]; }\n\n array<Z3_func_decl> _projs(n);\n\n Z3_symbol _name = Z3_mk_string_symbol(*this, name);\n\n Z3_func_decl tuple;\n\n sort _ignore_s = to_sort(*this, Z3_mk_tuple_sort(*this, _name, n, _names.ptr(), _sorts.ptr(), &tuple, _projs.ptr()));\n\n check_error();\n\n for (unsigned i = 0; i < n; i++) { projs.push_back(func_decl(*this, _projs[i])); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 93, "score": 61462.26711133746 }, { "content": "\n\n inline expr operator>=(expr const & a, expr const & b) {\n\n check_context(a, b);\n\n Z3_ast r = 0;\n\n if (a.is_arith() && b.is_arith()) {\n\n r = Z3_mk_ge(a.ctx(), a, b);\n\n }\n\n else if (a.is_bv() && b.is_bv()) {\n\n r = Z3_mk_bvsge(a.ctx(), a, b);\n\n }\n\n else {\n\n // operator is not supported by given arguments.\n\n assert(false);\n\n }\n\n a.check_error();\n\n return expr(a.ctx(), r);\n\n }\n\n\n\n inline expr operator/(expr const & a, expr const & b) {\n\n check_context(a, b);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 94, "score": 61462.21272291419 }, { "content": " friend expr operator||(expr const & a, expr const & b);\n\n /**\n\n \\brief Return an expression representing <tt>a or b</tt>.\n\n The C++ Boolean value \\c b is automatically converted into a Z3 Boolean constant.\n\n\n\n \\pre a.is_bool()\n\n */\n\n friend expr operator||(expr const & a, bool b);\n\n\n\n /**\n\n \\brief Return an expression representing <tt>a or b</tt>.\n\n The C++ Boolean value \\c a is automatically converted into a Z3 Boolean constant.\n\n\n\n \\pre b.is_bool()\n\n */\n\n friend expr operator||(bool a, expr const & b);\n\n\n\n friend expr implies(expr const & a, expr const & b);\n\n friend expr implies(expr const & a, bool b);\n\n friend expr implies(bool a, expr const & b);\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 95, "score": 61462.04118352568 }, { "content": " inline expr distinct(expr_vector const& args) {\n\n assert(args.size() > 0);\n\n context& ctx = args[0].ctx();\n\n array<Z3_ast> _args(args);\n\n Z3_ast r = Z3_mk_distinct(ctx, _args.size(), _args.ptr());\n\n ctx.check_error();\n\n return expr(ctx, r);\n\n }\n\n\n\n inline expr concat(expr const& a, expr const& b) {\n\n check_context(a, b);\n\n Z3_ast r;\n\n if (Z3_is_seq_sort(a.ctx(), a.get_sort())) {\n\n Z3_ast _args[2] = { a, b };\n\n r = Z3_mk_seq_concat(a.ctx(), 2, _args);\n\n }\n\n else if (Z3_is_re_sort(a.ctx(), a.get_sort())) {\n\n Z3_ast _args[2] = { a, b };\n\n r = Z3_mk_re_concat(a.ctx(), 2, _args);\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 96, "score": 61462.03616911932 }, { "content": "\n\n /**\n\n \\brief Apply substitution. Replace bound variables by expressions.\n\n */\n\n expr substitute(expr_vector const& dst);\n\n\n\n };\n\n\n\n#define _Z3_MK_BIN_(a, b, binop) \\\n\n check_context(a, b); \\\n\n Z3_ast r = binop(a.ctx(), a, b); \\\n\n a.check_error(); \\\n\n return expr(a.ctx(), r); \\\n\n\n\n\n\n inline expr implies(expr const & a, expr const & b) {\n\n assert(a.is_bool() && b.is_bool()); \n\n _Z3_MK_BIN_(a, b, Z3_mk_implies);\n\n }\n\n inline expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 97, "score": 61462.00300314292 }, { "content": " else {\n\n r = Z3_mk_concat(a.ctx(), a, b);\n\n }\n\n a.ctx().check_error();\n\n return expr(a.ctx(), r);\n\n }\n\n\n\n inline expr concat(expr_vector const& args) {\n\n Z3_ast r;\n\n assert(args.size() > 0);\n\n if (args.size() == 1) {\n\n return args[0];\n\n }\n\n context& ctx = args[0].ctx();\n\n array<Z3_ast> _args(args);\n\n if (Z3_is_seq_sort(ctx, args[0].get_sort())) {\n\n r = Z3_mk_seq_concat(ctx, _args.size(), _args.ptr());\n\n }\n\n else if (Z3_is_re_sort(ctx, args[0].get_sort())) {\n\n r = Z3_mk_re_concat(ctx, _args.size(), _args.ptr());\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 98, "score": 61462.005691367565 }, { "content": "\n\n inline expr operator||(expr const & a, expr const & b) {\n\n check_context(a, b);\n\n assert(a.is_bool() && b.is_bool());\n\n Z3_ast args[2] = { a, b };\n\n Z3_ast r = Z3_mk_or(a.ctx(), 2, args);\n\n a.check_error();\n\n return expr(a.ctx(), r);\n\n }\n\n\n\n inline expr operator||(expr const & a, bool b) { return a || a.ctx().bool_val(b); }\n\n\n\n inline expr operator||(bool a, expr const & b) { return b.ctx().bool_val(a) || b; }\n\n\n\n inline expr operator==(expr const & a, expr const & b) {\n\n check_context(a, b);\n\n Z3_ast r = Z3_mk_eq(a.ctx(), a, b);\n\n a.check_error();\n\n return expr(a.ctx(), r);\n\n }\n", "file_path": "tests/benchmark/include/z3++.h", "rank": 99, "score": 61461.98766228797 } ]
C++
problemes/probleme1xx/probleme185.cpp
ZongoForSpeed/ProjectEuler
2e2d45f984d48a1da8275886c976f909a0de94ce
#include "problemes.h" #include "arithmetique.h" #include <fstream> typedef unsigned long long nombre; typedef std::vector<nombre> vecteur; typedef std::pair<std::string, unsigned short> paire; typedef std::vector<paire> ensemble; namespace { template<typename Iterator> bool cherche_solution(Iterator debut, Iterator fin, std::vector<std::set<char>> &solutions) { if (debut == fin) { for (const auto &s: solutions) if (s.size() != 1) return false; return true; } for (const auto &s: solutions) if (s.empty()) return false; auto essai = *debut; std::set<size_t> test; for (size_t n = 0; n < solutions.size(); ++n) test.insert(n); for (size_t n = 0; n < solutions.size(); ++n) { auto s = solutions[n]; if (solutions[n].size() == 1) { if (*solutions[n].begin() == essai.first[n]) { essai.second--; test.erase(n); } } if (s.find(essai.first[n]) == s.end()) { test.erase(n); } } if (test.size() < essai.second) return false; if (essai.second == 0) { for (size_t n: test) { solutions[n].erase(essai.first[n]); } return cherche_solution(++debut, fin, solutions); } else { std::vector<bool> combinaison(test.size(), true); for (size_t n = 0; n < essai.second; ++n) combinaison.at(n) = false; do { auto s = solutions; bool suivant = false; size_t position = 0; for (size_t n: test) { if (combinaison[position]) s[n].erase(essai.first[n]); else if (s[n].find(essai.first[n]) == s[n].end()) { suivant = true; break; } else s[n] = {essai.first[n]}; ++position; } if (suivant) continue; if (cherche_solution(std::next(debut), fin, s)) { std::swap(s, solutions); return true; } } while (std::next_permutation(combinaison.begin(), combinaison.end())); return false; } } } ENREGISTRER_PROBLEME(185, "Number Mind") { std::ifstream ifs("data/p185_number_mind.txt"); ensemble essais; size_t taille = 0; std::string pattern, correct, ignore; while (ifs >> pattern >> correct >> ignore) { taille = pattern.size(); essais.emplace_back(pattern, correct[1] - '0'); } std::set<char> chiffres{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; std::vector<std::set<char>> solutions; for (size_t n = 0; n < taille; ++n) solutions.push_back(chiffres); cherche_solution(essais.begin(), essais.end(), solutions); std::ostringstream oss; for (const auto &s: solutions) oss << *s.begin(); return oss.str(); }
#include "problemes.h" #include "arithmetique.h" #include <fstream> typedef unsigned long long nombre; typedef std::vector<nombre> vecteur; typedef std::pair<std::string, unsigned short> paire; typedef std::vector<paire> ensemble; namespace { template<typename Iterator> bool cherche_solution(Iterator debut, Iterator fin, std::vector<std::set<char>> &solutions) { if (debut == fin) { for (const auto &s: solutions) if (s.size() != 1) return false; return true; } for (const auto &s: solutions) if (s.empty()) return false; auto essai = *debut; std::set<size_t> test; for (size_t n = 0; n < solutions.size(); ++n) test.insert(n); for (size_t n = 0; n < solutions.size(); ++n) { auto s = solutions[n]; if (solutions[n].size() == 1) { if (*solutions[n].begin() == essai.first[n]) { essai.second--; test.erase(n); } }
} ENREGISTRER_PROBLEME(185, "Number Mind") { std::ifstream ifs("data/p185_number_mind.txt"); ensemble essais; size_t taille = 0; std::string pattern, correct, ignore; while (ifs >> pattern >> correct >> ignore) { taille = pattern.size(); essais.emplace_back(pattern, correct[1] - '0'); } std::set<char> chiffres{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; std::vector<std::set<char>> solutions; for (size_t n = 0; n < taille; ++n) solutions.push_back(chiffres); cherche_solution(essais.begin(), essais.end(), solutions); std::ostringstream oss; for (const auto &s: solutions) oss << *s.begin(); return oss.str(); }
if (s.find(essai.first[n]) == s.end()) { test.erase(n); } } if (test.size() < essai.second) return false; if (essai.second == 0) { for (size_t n: test) { solutions[n].erase(essai.first[n]); } return cherche_solution(++debut, fin, solutions); } else { std::vector<bool> combinaison(test.size(), true); for (size_t n = 0; n < essai.second; ++n) combinaison.at(n) = false; do { auto s = solutions; bool suivant = false; size_t position = 0; for (size_t n: test) { if (combinaison[position]) s[n].erase(essai.first[n]); else if (s[n].find(essai.first[n]) == s[n].end()) { suivant = true; break; } else s[n] = {essai.first[n]}; ++position; } if (suivant) continue; if (cherche_solution(std::next(debut), fin, s)) { std::swap(s, solutions); return true; } } while (std::next_permutation(combinaison.begin(), combinaison.end())); return false; } }
function_block-function_prefix_line
[ { "content": " class numeric_limits<mpz_nombre> : public numeric_limits<long long> {\n\n public:\n\n static constexpr int digits = INT_MAX;\n\n static constexpr int digits10 = INT_MAX;\n\n\n\n static mpz_nombre max() {\n\n return mpz_nombre::puissance(2, digits);\n\n }\n\n\n\n static mpz_nombre min() {\n\n return max().negation();\n\n }\n\n\n\n static mpz_nombre lowest() {\n\n return min();\n\n }\n\n };\n\n\n\n inline string to_string(const mpz_nombre &op) {\n\n return op.to_string();\n\n }\n\n}\n", "file_path": "maths/mpz_nombre.h", "rank": 0, "score": 107969.89425671563 }, { "content": " BOOST_CHECK(m > n);\n\n BOOST_CHECK(n <= m);\n\n BOOST_CHECK(m >= m);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_abs) {\n\n mpz_nombre n(-22632576532575LL);\n\n mpz_nombre m = std::abs(n);\n\n BOOST_CHECK_EQUAL(m.get_unsigned_long_long(), 22632576532575);\n\n\n\n mpz_nombre::abs(n, n);\n\n BOOST_CHECK_EQUAL(n.get_unsigned_long_long(), 22632576532575);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_soustraction) {\n\n mpz_nombre n(22801763489LL);\n\n mpz_nombre m(22632576532575LL);\n\n n -= m;\n\n\n\n BOOST_CHECK_EQUAL(n, -22609774769086);\n", "file_path": "tests/mpz_nombre.cpp", "rank": 1, "score": 88809.25777067729 }, { "content": "\n\n n += m;\n\n BOOST_CHECK_EQUAL(n.get_unsigned_long_long(), 45287954828739);\n\n\n\n mpz_nombre p = n + m;\n\n BOOST_CHECK_EQUAL(p.get_unsigned_long_long(), 67920531361314);\n\n\n\n mpz_nombre q = 42ul + m;\n\n BOOST_CHECK_EQUAL(q.get_unsigned_long_long(), 22632576532617);\n\n\n\n mpz_nombre r = n + 666ul;\n\n BOOST_CHECK_EQUAL(r.get_unsigned_long_long(), 45287954829405);\n\n\n\n r += 400000000000000ull;\n\n BOOST_CHECK_EQUAL(r.get_unsigned_long_long(), 445287954829405);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_negation) {\n\n mpz_nombre n(22632576532575LL);\n\n mpz_nombre m = -n;\n", "file_path": "tests/mpz_nombre.cpp", "rank": 2, "score": 88808.79901541845 }, { "content": "\n\n mpz_nombre q = 42000000000000ul % m;\n\n BOOST_CHECK_EQUAL(q, 75);\n\n\n\n unsigned long r = n % 666ul;\n\n BOOST_CHECK_EQUAL(r, 458);\n\n\n\n r %= 4;\n\n BOOST_CHECK_EQUAL(r, 2);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_divisible) {\n\n mpz_nombre n(228017635LL);\n\n mpz_nombre m(275LL);\n\n\n\n BOOST_CHECK_EQUAL(mpz_nombre::divisible(n, m), false);\n\n BOOST_CHECK_EQUAL(mpz_nombre::divisible(n, 5), true);\n\n BOOST_CHECK_EQUAL(mpz_nombre::divisible(2750000, m), true);\n\n }\n\n\n", "file_path": "tests/mpz_nombre.cpp", "rank": 3, "score": 88808.78107497236 }, { "content": "#include <boost/test/unit_test.hpp>\n\n#include <random>\n\n\n\n#include \"utilitaires.h\"\n\n#include \"mpz_nombre.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_mpz_nombre)\n\n\n\n BOOST_AUTO_TEST_CASE(test_constructeur) {\n\n mpz_nombre n1;\n\n mpz_nombre n2(42);\n\n mpz_nombre n3(-666);\n\n mpz_nombre n4(3.14158);\n\n mpz_nombre n5(22801763489LL);\n\n mpz_nombre n7(\"22801763489\");\n\n\n\n BOOST_CHECK_EQUAL(n1.get_signed_long(), 0);\n\n BOOST_CHECK_EQUAL(n2.to_string(2), \"101010\");\n\n BOOST_CHECK_EQUAL(n3.to_string(6), \"-3030\");\n\n BOOST_CHECK_EQUAL(n4.get_signed_long(), 3);\n", "file_path": "tests/mpz_nombre.cpp", "rank": 4, "score": 88808.54605049643 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"utilitaires.h\"\n\n#include \"mpf_nombre.h\"\n\n\n\n#define EPSILON 0.000000001l\n\n\n\nBOOST_AUTO_TEST_SUITE(test_mpf_nombre)\n\n\n\n BOOST_AUTO_TEST_CASE(test_constructeur) {\n\n mpf_nombre n1;\n\n mpf_nombre n2(42l);\n\n mpf_nombre n3(-666l);\n\n mpf_nombre n4(3.14158);\n\n mpf_nombre n5(22801763489l);\n\n mpf_nombre n7(\"22801763489\");\n\n\n\n BOOST_CHECK_EQUAL(n1.get_signed_long(), 0);\n\n BOOST_CHECK_EQUAL(n2.to_string(2), \"42\");\n\n BOOST_CHECK_EQUAL(n3.to_string(6), \"-666\");\n", "file_path": "tests/mpf_nombre.cpp", "rank": 5, "score": 88807.57981602913 }, { "content": "\n\n std::random_device rd;\n\n std::mt19937 g(rd());\n\n\n\n std::shuffle(v.begin(), v.end(), g);\n\n\n\n std::sort(v.begin(), v.end());\n\n\n\n std::cout << v << std::endl;\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_addition) {\n\n mpz_nombre n(22801763489LL);\n\n mpz_nombre m(22632576532575LL);\n\n n += m;\n\n\n\n BOOST_CHECK_EQUAL(n.get_unsigned_long_long(), 22655378296064);\n\n\n\n n += 100;\n\n BOOST_CHECK_EQUAL(n.get_unsigned_long_long(), 22655378296164);\n", "file_path": "tests/mpz_nombre.cpp", "rank": 6, "score": 88806.94061838707 }, { "content": " BOOST_CHECK_EQUAL(mpz_nombre::PPCM(p, 456755ul), 1114938955);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_chiffres) {\n\n mpz_nombre n(\"31115050367326962860164013941500001\");\n\n\n\n std::deque<unsigned long int> chiffres;\n\n n.boucle_chiffre([&chiffres](unsigned long int d) { chiffres.push_front(d); });\n\n\n\n const std::vector<unsigned long int> resultat{\n\n 3, 1, 1, 1, 5, 0, 5, 0, 3, 6, 7, 3, 2, 6, 9, 6, 2, 8, 6, 0, 1, 6, 4, 0, 1, 3, 9, 4, 1, 5, 0, 0, 0, 0, 1\n\n };\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), chiffres.begin(), chiffres.end());\n\n\n\n BOOST_CHECK_EQUAL(n.nombre_chiffres(), 35);\n\n BOOST_CHECK_EQUAL(n.somme_chiffres(14), 198);\n\n\n\n auto ec = n.extraire_chiffres();\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), ec.begin(), ec.end());\n\n\n\n BOOST_CHECK_EQUAL(n.inverser_nombre().to_string(), \"10000514931046106826962376305051113\");\n\n BOOST_CHECK(!n.palindrome());\n\n mpz_nombre m(\"89123457675432198\");\n\n BOOST_CHECK(m.palindrome());\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/mpz_nombre.cpp", "rank": 7, "score": 88806.4489130361 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"nombre_modulaire.h\"\n\n#include \"utilitaires.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_nombre_modulaires)\n\n\n\n BOOST_AUTO_TEST_CASE(coefficient_binomial) {\n\n size_t n = 1'000'000'000'000'000'000ull;\n\n size_t k = 1'000'000'000ull;\n\n nombre_modulaire Cnk = nombre_modulaire::coefficient_binomial(4999, n, k);\n\n\n\n BOOST_CHECK_EQUAL(\"2982[4999]\", std::to_string(Cnk));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(factoriel_1) {\n\n nombre_modulaire factoriel = nombre_modulaire::factoriel(4999, 5000);\n\n BOOST_CHECK_EQUAL(\"0[4999]\", std::to_string(factoriel));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(factoriel_2) {\n\n nombre_modulaire factoriel = nombre_modulaire::factoriel(4999, 1234);\n\n BOOST_CHECK_EQUAL(\"3912[4999]\", std::to_string(factoriel));\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/nombre_modulaire.cpp", "rank": 8, "score": 88805.20525842265 }, { "content": " BOOST_AUTO_TEST_CASE(test_puissance) {\n\n mpz_nombre n(24);\n\n n = mpz_nombre::puissance(n, 10);\n\n\n\n BOOST_CHECK_EQUAL(n, 63403380965376);\n\n\n\n n = mpz_nombre::puissance_modulaire(n, 5, 1000);\n\n BOOST_CHECK_EQUAL(n, 376);\n\n\n\n mpz_nombre m = mpz_nombre::puissance(9, 10);\n\n BOOST_CHECK_EQUAL(m, 3486784401);\n\n\n\n mpz_nombre p = mpz_nombre::puissance_modulaire(m, 100000, 1024);\n\n BOOST_CHECK_EQUAL(p, 513);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_racine) {\n\n mpz_nombre n(63403380965376);\n\n BOOST_CHECK_EQUAL(mpz_nombre::carre_parfait(n), true);\n\n\n", "file_path": "tests/mpz_nombre.cpp", "rank": 9, "score": 88802.91029806215 }, { "content": " BOOST_CHECK_EQUAL(r.to_string(), \"7778762591831740715041003485375000\");\n\n\n\n r *= 4;\n\n BOOST_CHECK_EQUAL(r.to_string(), \"31115050367326962860164013941500000\");\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_shift) {\n\n mpz_nombre n(228);\n\n\n\n mpz_nombre m = n << 10;\n\n BOOST_CHECK_EQUAL(m, 233472);\n\n\n\n mpz_nombre p = n >> 5;\n\n BOOST_CHECK_EQUAL(p, 7);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_division) {\n\n mpz_nombre n(228017639LL);\n\n mpz_nombre m(275LL);\n\n n /= m;\n", "file_path": "tests/mpz_nombre.cpp", "rank": 10, "score": 88800.087932196 }, { "content": "\n\n BOOST_AUTO_TEST_CASE(test_negation) {\n\n mpf_nombre n(22632576532575LL);\n\n mpf_nombre m = -n;\n\n BOOST_CHECK_CLOSE(m, -22632576532575, EPSILON);\n\n\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_comparaison) {\n\n mpf_nombre n(25413164);\n\n mpf_nombre m(22632576532575);\n\n\n\n BOOST_CHECK(n == 25413164);\n\n BOOST_CHECK(n != 2543164);\n\n BOOST_CHECK(n > 25164);\n\n BOOST_CHECK(n >= 25413164);\n\n BOOST_CHECK(n >= 2543164);\n\n BOOST_CHECK(n <= 25413164);\n\n BOOST_CHECK(!(n <= 2543164));\n\n BOOST_CHECK(n < 213421164);\n", "file_path": "tests/mpf_nombre.cpp", "rank": 11, "score": 88799.68314687353 }, { "content": " BOOST_CHECK(!(n == m));\n\n BOOST_CHECK(n < m);\n\n BOOST_CHECK(m > n);\n\n BOOST_CHECK(n <= m);\n\n BOOST_CHECK(m >= m);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_abs) {\n\n mpf_nombre n(-22632576532575LL);\n\n mpf_nombre m = std::abs(n);\n\n BOOST_CHECK_CLOSE(m, 22632576532575, EPSILON);\n\n\n\n mpf_nombre::abs(n, n);\n\n BOOST_CHECK_CLOSE(n, 22632576532575, EPSILON);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_soustraction) {\n\n mpf_nombre n(22801763489LL);\n\n mpf_nombre m(22632576532575LL);\n\n n -= m;\n", "file_path": "tests/mpf_nombre.cpp", "rank": 12, "score": 88799.5909223954 }, { "content": " BOOST_CHECK_EQUAL(n_or.to_string(2), \"10111110111010101\");\n\n BOOST_CHECK_EQUAL(n_xor.to_string(2), \"1110110010101\");\n\n BOOST_CHECK_EQUAL(n_not.to_string(2), \"-10110000111000110\");\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_pgcd) {\n\n mpz_nombre n(456753);\n\n mpz_nombre m(97643);\n\n mpz_nombre p(158665);\n\n\n\n BOOST_CHECK_EQUAL(mpz_nombre::PGCD(n, m), 1);\n\n BOOST_CHECK_EQUAL(mpz_nombre::PGCD(p, 456755ul), 65);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_ppcm) {\n\n mpz_nombre n(456753u);\n\n mpz_nombre m(97643u);\n\n mpz_nombre p(158665u);\n\n\n\n BOOST_CHECK_EQUAL(mpz_nombre::PPCM(n, m), 44598733179);\n", "file_path": "tests/mpz_nombre.cpp", "rank": 13, "score": 88799.5187851266 }, { "content": " BOOST_CHECK_EQUAL(false, mpz_nombre::premier(n * m - 2, 25));\n\n\n\n mpz_nombre p(\"170141183460469231731687303715884105727\");\n\n BOOST_CHECK(mpz_nombre::premier(p, 25));\n\n BOOST_CHECK_EQUAL(false, mpz_nombre::premier(p - 2, 25));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_suivant) {\n\n mpz_nombre r(\"170141183460469231731687303715884105757\");\n\n mpz_nombre q(\"170141183460469231731687303715884105727\");\n\n mpz_nombre p;\n\n mpz_nombre::premier_suivant(p, q);\n\n BOOST_CHECK_EQUAL(r, p);\n\n for (mpz_nombre i = q + 2; i < r; i += 2) {\n\n BOOST_CHECK_EQUAL(false, mpz_nombre::premier(i, 25));\n\n }\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_stream) {\n\n std::ostringstream oss;\n", "file_path": "tests/mpz_nombre.cpp", "rank": 14, "score": 88799.48975135564 }, { "content": " BOOST_CHECK_EQUAL(n4.get_signed_long(), 3);\n\n BOOST_CHECK_EQUAL(n5.to_string(), \"22801763489\");\n\n BOOST_CHECK_EQUAL(n7.get_signed_long(), 22801763489);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_assignation) {\n\n mpf_nombre n(0);\n\n BOOST_CHECK_CLOSE(n, 0, EPSILON);\n\n\n\n n.set(42l);\n\n BOOST_CHECK_CLOSE(n, 42, EPSILON);\n\n\n\n n.set(-666l);\n\n BOOST_CHECK_CLOSE(n, -666, EPSILON);\n\n\n\n n.set(3.14158);\n\n BOOST_CHECK_CLOSE(n, 3.14158, EPSILON);\n\n\n\n n.set(-22801763489L);\n\n BOOST_CHECK_CLOSE(n, -22801763489, EPSILON);\n", "file_path": "tests/mpf_nombre.cpp", "rank": 15, "score": 88799.13840840971 }, { "content": "\n\n BOOST_AUTO_TEST_CASE(test_trigo) {\n\n BOOST_CHECK_CLOSE(std::cos(mpf_nombre::pi() / 3), 0.5l, EPSILON);\n\n BOOST_CHECK_CLOSE(std::sin(mpf_nombre::pi() / 3), 0.866025403784, EPSILON);\n\n\n\n mpf_nombre sin_pi_3;\n\n mpf_nombre::sin(sin_pi_3, mpf_nombre::pi() / 3);\n\n mpf_nombre sqrt3_2;\n\n mpf_nombre::racine_carre(sqrt3_2, 0.75);\n\n BOOST_CHECK_CLOSE(sin_pi_3, sqrt3_2, EPSILON);\n\n\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/mpf_nombre.cpp", "rank": 16, "score": 88798.91374462153 }, { "content": " mpz_nombre n(22801763489);\n\n oss << n;\n\n\n\n std::istringstream iss(oss.str());\n\n mpz_nombre m;\n\n iss >> m;\n\n\n\n BOOST_CHECK_EQUAL(n, m);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_logique) {\n\n mpz_nombre n(\"10110000111000101\", 2);\n\n mpz_nombre m(\"10111110001010000\", 2);\n\n\n\n mpz_nombre n_and = n & m;\n\n mpz_nombre n_or = n | m;\n\n mpz_nombre n_xor = n ^m;\n\n mpz_nombre n_not = ~n;\n\n\n\n BOOST_CHECK_EQUAL(n_and.to_string(2), \"10110000001000000\");\n", "file_path": "tests/mpz_nombre.cpp", "rank": 17, "score": 88798.3739495573 }, { "content": " }\n\n\n\n\n\n BOOST_AUTO_TEST_CASE(test_multiplication) {\n\n mpf_nombre n(228017639LL);\n\n mpf_nombre m(22632572575LL);\n\n n *= m;\n\n\n\n BOOST_CHECK_CLOSE(n, 5.16062576305e+18, EPSILON);\n\n\n\n n *= 100;\n\n BOOST_CHECK_CLOSE(n, 5.16062576305e+20, EPSILON);\n\n\n\n n *= m;\n\n BOOST_CHECK_CLOSE(n, 1.16798237115e+31, EPSILON);\n\n\n\n mpf_nombre p = n * m;\n\n BOOST_CHECK_CLOSE(p, 2.64344457813e+41, EPSILON);\n\n\n\n mpf_nombre q = 42ul * m;\n", "file_path": "tests/mpf_nombre.cpp", "rank": 18, "score": 88798.15853494743 }, { "content": " BOOST_CHECK_EQUAL(r, 855);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_modulo) {\n\n mpz_nombre n(228017639LL);\n\n mpz_nombre m(275LL);\n\n n %= m;\n\n\n\n BOOST_CHECK_EQUAL(n, 14);\n\n\n\n n %= 10;\n\n BOOST_CHECK_EQUAL(n, 4);\n\n\n\n n.set(2280176);\n\n n %= m;\n\n BOOST_CHECK_EQUAL(n, 151);\n\n\n\n n.set(2280176);\n\n mpz_nombre p = n % m;\n\n BOOST_CHECK_EQUAL(p, 151);\n", "file_path": "tests/mpz_nombre.cpp", "rank": 19, "score": 88798.04164264892 }, { "content": " BOOST_AUTO_TEST_CASE(test_multiplication) {\n\n mpz_nombre n(228017639LL);\n\n mpz_nombre m(22632572575LL);\n\n n *= m;\n\n\n\n BOOST_CHECK_EQUAL(n.to_string(), \"5160625763047650425\");\n\n\n\n n *= 100;\n\n BOOST_CHECK_EQUAL(n.to_string(), \"516062576304765042500\");\n\n\n\n n *= m;\n\n BOOST_CHECK_EQUAL(n.to_string(), \"11679823711459070142704209437500\");\n\n\n\n mpz_nombre p = n * m;\n\n BOOST_CHECK_EQUAL(p.to_string(), \"264344457812803264146768626852218676562500\");\n\n\n\n mpz_nombre q = 42ul * m;\n\n BOOST_CHECK_EQUAL(q.to_string(), \"950568048150\");\n\n\n\n mpz_nombre r = n * 666ul;\n", "file_path": "tests/mpz_nombre.cpp", "rank": 20, "score": 88797.80594006865 }, { "content": " BOOST_CHECK_CLOSE(q, 950568048150, EPSILON);\n\n\n\n mpf_nombre r = n * 666ul;\n\n BOOST_CHECK_CLOSE(r, 7.77876259183e+33, EPSILON);\n\n\n\n r *= 4;\n\n BOOST_CHECK_CLOSE(r, 3.11150503673e+34, EPSILON);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_division) {\n\n mpf_nombre n(228017639LL);\n\n mpf_nombre m(275LL);\n\n n /= m;\n\n\n\n BOOST_CHECK_CLOSE(n, 829155.050909, EPSILON);\n\n\n\n n /= 100;\n\n BOOST_CHECK_CLOSE(n, 8291.55050909, EPSILON);\n\n\n\n n /= m;\n", "file_path": "tests/mpf_nombre.cpp", "rank": 21, "score": 88797.68959594057 }, { "content": " n.set(\"228017634890\", 10);\n\n BOOST_CHECK_EQUAL(n, 228017634890);\n\n\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_swap) {\n\n mpz_nombre n(228017634890);\n\n mpz_nombre m(-22632576532575);\n\n std::swap(n, m);\n\n BOOST_CHECK_EQUAL(m, 228017634890);\n\n BOOST_CHECK_EQUAL(n, -22632576532575);\n\n\n\n n.swap(m);\n\n BOOST_CHECK_EQUAL(m, -22632576532575);\n\n BOOST_CHECK_EQUAL(n, 228017634890);\n\n\n\n std::vector<mpz_nombre> v;\n\n for (size_t k = 0; k <= 12; ++k) {\n\n v.push_back(mpz_nombre::catalan(k));\n\n }\n", "file_path": "tests/mpz_nombre.cpp", "rank": 22, "score": 88797.67140161151 }, { "content": "\n\n n.set(\"228017634890\", 10);\n\n BOOST_CHECK_CLOSE(n, 228017634890, EPSILON);\n\n\n\n mpf_nombre m(-22632576532575);\n\n std::swap(n, m);\n\n BOOST_CHECK_CLOSE(m, 228017634890, EPSILON);\n\n BOOST_CHECK_CLOSE(n, -2.26325765326e+13, EPSILON);\n\n\n\n n.swap(m);\n\n BOOST_CHECK_CLOSE(m, -2.26325765326e+13, EPSILON);\n\n BOOST_CHECK_CLOSE(n, 228017634890, EPSILON);\n\n }\n\n\n\n\n\n BOOST_AUTO_TEST_CASE(test_addition) {\n\n mpf_nombre n(228017634.89);\n\n mpf_nombre m(2263257.6532575l);\n\n n += m;\n\n\n", "file_path": "tests/mpf_nombre.cpp", "rank": 23, "score": 88797.60456192138 }, { "content": " mpz_nombre m;\n\n mpz_nombre::racine_carre(m, n);\n\n BOOST_CHECK_EQUAL(m, 7962624);\n\n BOOST_CHECK_EQUAL(mpz_nombre::carre_parfait(m), false);\n\n\n\n mpz_nombre p;\n\n mpz_nombre::racine(p, n, 10);\n\n BOOST_CHECK_EQUAL(p, 24);\n\n\n\n mpz_nombre q = std::sqrt(n);\n\n BOOST_CHECK_EQUAL(q, 7962624);\n\n\n\n mpz_nombre r = std::cbrt(n);\n\n BOOST_CHECK_EQUAL(r, 39875);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_premier_1) {\n\n mpz_nombre n(22801763489);\n\n BOOST_CHECK(mpz_nombre::premier(n));\n\n\n", "file_path": "tests/mpz_nombre.cpp", "rank": 24, "score": 88797.4583674693 }, { "content": " BOOST_CHECK_EQUAL(m, -22632576532575);\n\n\n\n m.negation();\n\n BOOST_CHECK_EQUAL(m, 22632576532575);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_comparaison) {\n\n mpz_nombre n(25413164);\n\n mpz_nombre m(22632576532575);\n\n\n\n BOOST_CHECK(n == 25413164);\n\n BOOST_CHECK(n != 2543164);\n\n BOOST_CHECK(n > 25164);\n\n BOOST_CHECK(n >= 25413164);\n\n BOOST_CHECK(n >= 2543164);\n\n BOOST_CHECK(n <= 25413164);\n\n BOOST_CHECK(!(n <= 2543164));\n\n BOOST_CHECK(n < 213421164);\n\n BOOST_CHECK(!(n == m));\n\n BOOST_CHECK(n < m);\n", "file_path": "tests/mpz_nombre.cpp", "rank": 25, "score": 88797.00176491172 }, { "content": " n *= 10;\n\n BOOST_CHECK(!mpz_nombre::premier(n));\n\n\n\n mpz_nombre m;\n\n mpz_nombre::premier_suivant(m, n);\n\n BOOST_CHECK_EQUAL(m, 228017634893);\n\n BOOST_CHECK(mpz_nombre::premier(m));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_premier_2) {\n\n mpz_nombre n(\"32416189721\");\n\n BOOST_CHECK(mpz_nombre::premier(n, 25));\n\n BOOST_CHECK(n.premier());\n\n BOOST_CHECK_EQUAL(false, mpz_nombre::premier(n + 44, 25));\n\n\n\n mpz_nombre m(\"2305843009213693951\");\n\n BOOST_CHECK(mpz_nombre::premier(m, 25));\n\n BOOST_CHECK_EQUAL(false, mpz_nombre::premier(m + 44, 25));\n\n\n\n BOOST_CHECK_EQUAL(false, mpz_nombre::premier(n * m, 25));\n", "file_path": "tests/mpz_nombre.cpp", "rank": 26, "score": 88796.97900235327 }, { "content": " BOOST_CHECK_CLOSE(n, 30.1510927603, EPSILON);\n\n\n\n n.set(2280176);\n\n mpf_nombre p = n / m;\n\n BOOST_CHECK_CLOSE(p, 8291.54909091, EPSILON);\n\n\n\n mpf_nombre q = 42000000000000ul / m;\n\n BOOST_CHECK_CLOSE(q, 152727272727, EPSILON);\n\n\n\n mpf_nombre r = n / 666ul;\n\n BOOST_CHECK_CLOSE(r, 3423.68768769, EPSILON);\n\n\n\n r /= 4;\n\n BOOST_CHECK_CLOSE(r, 855.921921922, EPSILON);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_constant) {\n\n BOOST_CHECK_CLOSE(mpf_nombre::pi(), M_PIl, EPSILON);\n\n BOOST_CHECK_CLOSE(mpf_nombre::e(), M_El, EPSILON);\n\n }\n", "file_path": "tests/mpf_nombre.cpp", "rank": 27, "score": 88796.90895996627 }, { "content": " BOOST_CHECK_EQUAL(n5.to_string(), \"22801763489\");\n\n BOOST_CHECK_EQUAL(n7, 22801763489);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_assignation) {\n\n mpz_nombre n;\n\n BOOST_CHECK_EQUAL(n, 0);\n\n\n\n n.set(42);\n\n BOOST_CHECK_EQUAL(n.to_string(2), \"101010\");\n\n\n\n n.set(-666);\n\n BOOST_CHECK_EQUAL(n.to_string(6), \"-3030\");\n\n\n\n n.set(3.14158);\n\n BOOST_CHECK_EQUAL(n.to_string(), \"3\");\n\n\n\n n.set(-22801763489LL);\n\n BOOST_CHECK_EQUAL(n, -22801763489);\n\n\n", "file_path": "tests/mpz_nombre.cpp", "rank": 28, "score": 88795.68033054602 }, { "content": " BOOST_CHECK_CLOSE(n.get_long_double(), 230280892.543257474899, EPSILON);\n\n\n\n n += 100;\n\n BOOST_CHECK_CLOSE(n.get_long_double(), 230280992.543257474899, EPSILON);\n\n\n\n n += m;\n\n BOOST_CHECK_CLOSE(n.get_long_double(), 232544250.196514964104, EPSILON);\n\n\n\n mpf_nombre p = n + m;\n\n BOOST_CHECK_CLOSE(p.get_long_double(), 234807507.849772464018, EPSILON);\n\n\n\n mpf_nombre q = 42ul + m;\n\n BOOST_CHECK_CLOSE(q.get_long_double(), 2263299.65325749991462, EPSILON);\n\n\n\n mpf_nombre r = n + 666ul;\n\n BOOST_CHECK_CLOSE(r.get_long_double(), 232544916.196514964104, EPSILON);\n\n\n\n r += 400000000000000ull;\n\n BOOST_CHECK_CLOSE(r.get_long_double(), 400000232544916.196503, EPSILON);\n\n }\n", "file_path": "tests/mpf_nombre.cpp", "rank": 29, "score": 88794.4205540843 }, { "content": "\n\n n -= 100;\n\n BOOST_CHECK_EQUAL(n, -22609774769186);\n\n\n\n n -= m;\n\n BOOST_CHECK_EQUAL(n, -45242351301761);\n\n\n\n mpz_nombre p = n - m;\n\n BOOST_CHECK_EQUAL(p, -67874927834336);\n\n\n\n mpz_nombre q = 42ul - m;\n\n BOOST_CHECK_EQUAL(q, -22632576532533);\n\n\n\n mpz_nombre r = n - 666ul;\n\n BOOST_CHECK_EQUAL(r, -45242351302427);\n\n\n\n r -= 400000000000000ull;\n\n BOOST_CHECK_EQUAL(r, -445242351302427);\n\n }\n\n\n", "file_path": "tests/mpz_nombre.cpp", "rank": 30, "score": 88789.10032835625 }, { "content": "\n\n BOOST_CHECK_EQUAL(n, 829155);\n\n\n\n n /= 100;\n\n BOOST_CHECK_EQUAL(n, 8291);\n\n\n\n n /= m;\n\n BOOST_CHECK_EQUAL(n, 30);\n\n\n\n n.set(2280176);\n\n mpz_nombre p = n / m;\n\n BOOST_CHECK_EQUAL(p, 8291);\n\n\n\n mpz_nombre q = 42000000000000ul / m;\n\n BOOST_CHECK_EQUAL(q, 152727272727);\n\n\n\n mpz_nombre r = n / 666ul;\n\n BOOST_CHECK_EQUAL(r, 3423);\n\n\n\n r /= 4;\n", "file_path": "tests/mpz_nombre.cpp", "rank": 31, "score": 88789.10032835625 }, { "content": "\n\n BOOST_CHECK_CLOSE(n, -22609774769086, EPSILON);\n\n\n\n n -= 100;\n\n BOOST_CHECK_CLOSE(n, -22609774769186, EPSILON);\n\n\n\n n -= m;\n\n BOOST_CHECK_CLOSE(n, -45242351301761, EPSILON);\n\n\n\n mpf_nombre p = n - m;\n\n BOOST_CHECK_CLOSE(p, -67874927834336, EPSILON);\n\n\n\n mpf_nombre q = 42ul - m;\n\n BOOST_CHECK_CLOSE(q, -22632576532533, EPSILON);\n\n\n\n mpf_nombre r = n - 666ul;\n\n BOOST_CHECK_CLOSE(r, -45242351302427, EPSILON);\n\n\n\n r -= 400000000000000ull;\n\n BOOST_CHECK_CLOSE(r, -445242351302427, EPSILON);\n", "file_path": "tests/mpf_nombre.cpp", "rank": 32, "score": 88788.87672248048 }, { "content": " class Allocator = std::allocator<std::pair<const Key, T> >\n\n >\n\n std::ostream &operator<<(std::ostream &os, const std::map<Key, T, Compare, Allocator> &s) {\n\n os << \"{\" << std::endl;\n\n for (const auto &p: s) {\n\n os << \" \" << p.first << \" => \" << p.second << std::endl;\n\n }\n\n os << \"}\" << std::endl;\n\n return os;\n\n }\n\n\n\n template<class Iterator>\n\n constexpr Iterator next(Iterator it, size_t n) {\n\n advance(it, static_cast<typename std::iterator_traits<Iterator>::difference_type>(n));\n\n return it;\n\n }\n\n\n\n template<typename T>\n\n constexpr ostream &operator<<(ostream &os, std::optional<T> s) {\n\n if (s)\n", "file_path": "maths/utilitaires.h", "rank": 33, "score": 87934.14129070735 }, { "content": " class Iterateur : public boost::iterator_facade<Iterateur, const T, boost::forward_traversal_tag> {\n\n T _source;\n\n size_t _index;\n\n public:\n\n Iterateur(T &s, size_t index) : _source(s), _index(index) {}\n\n\n\n // What we implement is determined by the boost::forward_traversal_tag\n\n // template parameter\n\n private:\n\n friend class boost::iterator_core_access;\n\n\n\n friend class MyContainer;\n\n\n\n void increment() {\n\n if (_index == std::string::npos) {\n\n return;\n\n }\n\n\n\n if (std::next_permutation(_source.begin(), _source.end())) {\n\n ++_index;\n", "file_path": "maths/permutation.h", "rank": 34, "score": 70153.9508762877 }, { "content": " class Iterateur : public boost::iterator_facade<Iterateur, const std::vector<T>, boost::forward_traversal_tag> {\n\n const std::vector<T> &_source;\n\n size_t _taille;\n\n size_t _index;\n\n\n\n std::vector<bool> _indices;\n\n std::vector<T> _courant;\n\n public:\n\n Iterateur(const std::vector<T> &s, size_t t, size_t index) : _source(s), _taille(t), _index(index) {\n\n size_t n = utilitaires::distance(_source.begin(), _source.end());\n\n _indices.assign(n, false);\n\n for (size_t i = 0; i < t; ++i) {\n\n _indices[i] = true;\n\n }\n\n\n\n _courant.assign(_source.begin(), std::next(_source.begin(), _taille));\n\n }\n\n\n\n private:\n\n friend class boost::iterator_core_access;\n", "file_path": "maths/permutation.h", "rank": 35, "score": 65532.20200113826 }, { "content": "class mpf_nombre {\n\n mpfr_ptr _data;\n\n\n\n static long DEFAULT_PRECISION;\n\n static mpfr_rnd_t DEFAULT_ROUNDING;\n\n static mpf_nombre PI;\n\n static mpf_nombre E;\n\n static mpf_nombre PHI;\n\n\n\n static mpf_nombre calcul_pi();\n\n\n\n static mpf_nombre calcul_e();\n\n\n\n static mpf_nombre calcul_phi();\n\n\n\n void init();\n\n\n\n void clear();\n\n\n\n template<typename Type>\n", "file_path": "maths/mpf_nombre.h", "rank": 36, "score": 53888.069543220445 }, { "content": "class mpz_nombre {\n\n mpz_ptr _data;\n\n\n\n void init();\n\n\n\n void clear();\n\n\n\npublic:\n\n // region Constructors\n\n mpz_nombre();\n\n\n\n ~mpz_nombre();\n\n\n\n mpz_nombre(mpz_srcptr op);\n\n\n\n mpz_nombre(const mpz_nombre &op);\n\n\n\n mpz_nombre(mpz_nombre &&op);\n\n\n\n mpz_nombre(unsigned int op);\n", "file_path": "maths/mpz_nombre.h", "rank": 37, "score": 53888.069543220445 }, { "content": "class nombre_modulaire {\n\n template<typename Type>\n\n void set(Type op, std::false_type /*is_signed*/) {\n\n _value = op % _modulo;\n\n }\n\n\n\n template<typename Type>\n\n void set(Type op, std::true_type /*is_signed*/) {\n\n bool negatif = (op < 0);\n\n op = std::abs(op);\n\n _value = static_cast<size_t>(op) % _modulo;\n\n if (negatif) {\n\n _value = _modulo - _value;\n\n }\n\n }\n\n\n\n static std::pair<size_t, nombre_modulaire> factoriel2(size_t modulo, size_t n);\n\n\n\n static void meme_mod(const nombre_modulaire &n1, const nombre_modulaire &n2);\n\n\n", "file_path": "maths/nombre_modulaire.h", "rank": 38, "score": 53888.069543220445 }, { "content": "class multidimension : public std::vector<multidimension<T, N - 1>> {\n\npublic:\n\n typedef typename std::vector<multidimension<T, N - 1>> super_type;\n\n typedef typename super_type::size_type size_type;\n\n typedef typename super_type::value_type value_type;\n\n\n\n explicit multidimension() = default;\n\n\n\n explicit multidimension(size_type count, const value_type &value) : super_type(count, value) {}\n\n\n\n explicit multidimension(size_type count) : super_type(count) {}\n\n\n\n template<typename... Args>\n\n multidimension(size_type count, Args... args) : super_type(count, value_type(args...)) {}\n\n\n\n multidimension(std::initializer_list<value_type> init) : super_type(init) {}\n\n};\n\n\n\ntemplate<typename T>\n", "file_path": "maths/multidimension.h", "rank": 39, "score": 53719.83847099128 }, { "content": "#define BOOST_TEST_DYN_LINK\n\n#define BOOST_TEST_MODULE Project Euler\n\n\n\n#include <boost/test/included/unit_test.hpp>\n", "file_path": "test.cpp", "rank": 40, "score": 48765.38157680607 }, { "content": "#include <boost/test/unit_test.hpp>\n\n#include <numeric>\n\n\n\n#include \"fenwick.h\"\n\n#include \"utilitaires.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_fenwick)\n\n\n\n // BOOST_AUTO_TEST_CASE(test_fenwick, random_fenwick) {\n\n // // Number of elements in the array\n\n // const unsigned long N = 4 * 1024 * 1024; // Elements in the array\n\n // const unsigned long COUNTS = 1'024; // Size of values stored\n\n // typedef unsigned long sum_t; // Should be able to hold N * (COUNTS - 1)\n\n\n\n // // Number of queries to perform\n\n // const size_t NQUERIES = 100;\n\n\n\n // std::vector<std::pair<unsigned long, unsigned long>> queries;\n\n // queries.reserve(NQUERIES);\n\n // unsigned int seed = 329629153ul;\n", "file_path": "tests/fenwick.cpp", "rank": 41, "score": 46550.71991776213 }, { "content": "\n\n BOOST_AUTO_TEST_CASE(pell_bf3) {\n\n auto resultat = diophantienne::pell_bf<long long>(13, 27, 1000);\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(12, 3),\n\n std::make_pair(40, 11),\n\n std::make_pair(220, 61),\n\n std::make_pair(768, 213)\n\n };\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(quad_s) {\n\n auto resultat = diophantienne::quad_s<long long>(8, 9, 72, 1000);\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(3, 0),\n\n std::make_pair(9, 8),\n\n std::make_pair(51, 48),\n\n std::make_pair(297, 280)\n\n };\n", "file_path": "tests/diophantienne.cpp", "rank": 42, "score": 46544.72728743305 }, { "content": " };\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell_funds_bf3) {\n\n auto resultat = diophantienne::pell_funds_bf<long long>(13, 27);\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(12, 3),\n\n std::make_pair(-12, 3),\n\n std::make_pair(40, 11),\n\n std::make_pair(-40, 11)\n\n };\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell_bf1) {\n\n auto resultat = diophantienne::pell_bf<long long>(13, 108, 1000);\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(11, 1),\n\n std::make_pair(15, 3),\n", "file_path": "tests/diophantienne.cpp", "rank": 43, "score": 46544.376683606046 }, { "content": "\n\n BOOST_AUTO_TEST_CASE(pell4_1) {\n\n std::vector<std::pair<long long, long long>> resultat;\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(649, 180),\n\n std::make_pair(421200, 116820)\n\n };\n\n auto callback = [&resultat, &solution](long long x, long long y) {\n\n resultat.push_back(std::make_pair(x, y));\n\n return resultat.size() != solution.size();\n\n };\n\n\n\n diophantienne::pell4<long long>(13, 1, callback);\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell4_2) {\n\n std::vector<std::pair<long long, long long>> resultat;\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(18, 5),\n", "file_path": "tests/diophantienne.cpp", "rank": 44, "score": 46543.91056469341 }, { "content": " BOOST_AUTO_TEST_CASE(pell1_min) {\n\n BOOST_CHECK_EQUAL(diophantienne::pell1_min(13, 1), std::make_pair(649, 180));\n\n BOOST_CHECK_EQUAL(diophantienne::pell1_min(13, -1), std::make_pair(18, 5));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell4_min) {\n\n BOOST_CHECK_EQUAL(diophantienne::pell4_min(13, 1), std::make_pair(11, 3));\n\n BOOST_CHECK_EQUAL(diophantienne::pell4_min(13, -1), std::make_pair(3, 1));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell1_1) {\n\n std::vector<std::pair<long long, long long>> resultat;\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(649, 180),\n\n std::make_pair(842401, 233640)\n\n };\n\n auto callback = [&resultat, &solution](long long x, long long y) {\n\n resultat.push_back(std::make_pair(x, y));\n\n return resultat.size() != solution.size();\n\n };\n", "file_path": "tests/diophantienne.cpp", "rank": 45, "score": 46543.51526854622 }, { "content": "#include <boost/test/unit_test.hpp>\n\n#include \"racine.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_racine)\n\n\n\n BOOST_AUTO_TEST_CASE(test_racine) {\n\n BOOST_CHECK_EQUAL(racine::racine_carre<unsigned long long>(123456789ULL), 11111ULL);\n\n BOOST_CHECK_EQUAL(racine::racine_carre<unsigned long long>(1234567890987654321ULL), 1111111106ULL);\n\n BOOST_CHECK_EQUAL(racine::racine_carre<unsigned long long>(15241578750190521ULL), 123456789ULL);\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/racine.cpp", "rank": 46, "score": 46543.49932960564 }, { "content": " std::make_pair(5841, 1620),\n\n std::make_pair(1895386, 525685)\n\n };\n\n auto callback = [&resultat, &solution](long long x, long long y) {\n\n resultat.push_back(std::make_pair(x, y));\n\n return resultat.size() != solution.size();\n\n };\n\n\n\n diophantienne::pell4<long long>(13, -1, callback);\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell_funds_bf1) {\n\n auto resultat = diophantienne::pell_funds_bf<long long>(13, 108);\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(11, 1),\n\n std::make_pair(-11, 1),\n\n std::make_pair(15, 3),\n\n std::make_pair(-15, 3),\n\n std::make_pair(24, 6),\n", "file_path": "tests/diophantienne.cpp", "rank": 47, "score": 46543.114613402315 }, { "content": " std::make_pair(24, 6),\n\n std::make_pair(41, 11),\n\n std::make_pair(80, 22),\n\n std::make_pair(141, 39),\n\n std::make_pair(249, 69),\n\n std::make_pair(440, 122),\n\n std::make_pair(869, 241)\n\n };\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell_bf2) {\n\n auto resultat = diophantienne::pell_bf<long long>(157, 12, 100000000);\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(13, 1),\n\n std::make_pair(10663, 851),\n\n std::make_pair(579160, 46222)\n\n };\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n", "file_path": "tests/diophantienne.cpp", "rank": 48, "score": 46542.612914435675 }, { "content": " std::make_pair(-24, 6),\n\n std::make_pair(41, 11),\n\n std::make_pair(-41, 11),\n\n std::make_pair(80, 22),\n\n std::make_pair(-80, 22),\n\n std::make_pair(141, 39),\n\n std::make_pair(-141, 39)\n\n };\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell_funds_bf2) {\n\n auto resultat = diophantienne::pell_funds_bf<long long>(157, 12);\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(13, 1),\n\n std::make_pair(-13, 1),\n\n std::make_pair(10663, 851),\n\n std::make_pair(-10663, 851),\n\n std::make_pair(579160, 46222),\n\n std::make_pair(-579160, 46222)\n", "file_path": "tests/diophantienne.cpp", "rank": 49, "score": 46542.217133608334 }, { "content": "\n\n diophantienne::pell1<long long>(13, 1, callback);\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pell1_2) {\n\n std::vector<std::pair<long long, long long>> resultat;\n\n std::vector<std::pair<long long, long long>> solution{\n\n std::make_pair(18, 5),\n\n std::make_pair(23382, 6485),\n\n std::make_pair(30349818, 8417525)\n\n };\n\n auto callback = [&resultat, &solution](long long x, long long y) {\n\n resultat.push_back(std::make_pair(x, y));\n\n return resultat.size() != solution.size();\n\n };\n\n\n\n diophantienne::pell1<long long>(13, -1, callback);\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n", "file_path": "tests/diophantienne.cpp", "rank": 50, "score": 46542.17693522152 }, { "content": "#include <boost/test/unit_test.hpp>\n\n#include \"puissance.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_puissance)\n\n\n\n BOOST_AUTO_TEST_CASE(test_puissance_modulaire) {\n\n BOOST_CHECK_EQUAL(puissance::puissance_modulaire(2u, 10u, 100u), 24u);\n\n BOOST_CHECK_EQUAL(puissance::puissance_modulaire<unsigned long long>(97643u, 276799u, 456753u), 368123u);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(test_puissance) {\n\n BOOST_CHECK_EQUAL(puissance::puissance(2u, 10u), 1024u);\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/puissance.cpp", "rank": 51, "score": 46541.31161763762 }, { "content": " typedef boost::rational<long long> fraction;\n\n\n\n matrice::matrice<fraction> A(3, 3);\n\n A <<= 1, -1, 2,\n\n 3, 2, 1,\n\n 2, -3, -2;\n\n\n\n matrice::vecteur<fraction> b(3);\n\n b <<= 5, 10, -10;\n\n\n\n matrice::vecteur<fraction> resultat(3);\n\n resultat <<= 1, 2, 3;\n\n\n\n matrice::vecteur<fraction> x(3);\n\n bool solution = matrice::resolutionLU(A, b, x);\n\n\n\n BOOST_CHECK_EQUAL(solution, true);\n\n BOOST_CHECK_EQUAL_COLLECTIONS(x.data().begin(), x.data().end(),\n\n resultat.data().begin(), resultat.data().end());\n\n\n", "file_path": "tests/matrice.cpp", "rank": 52, "score": 46539.39716599698 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"polynome.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_polynome)\n\n\n\n BOOST_AUTO_TEST_CASE(initialization_1) {\n\n Polynome<long long> p(10);\n\n BOOST_CHECK_EQUAL(p.taille(), 1);\n\n BOOST_CHECK_EQUAL(p.valeur(42), 10);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(initialization_2) {\n\n Polynome<long long> p{-1, 0, 1};\n\n BOOST_CHECK_EQUAL(p.taille(), 3);\n\n BOOST_CHECK_EQUAL(p.valeur(2), 3);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(comparaison) {\n\n Polynome<long long> p{-1, 0, 1};\n", "file_path": "tests/polynome.cpp", "rank": 53, "score": 46539.17313086763 }, { "content": "#include <boost/test/unit_test.hpp>\n\n#include \"matrice.h\"\n\n\n\n#include <boost/numeric/ublas/assignment.hpp>\n\n#include <boost/rational.hpp>\n\n\n\nBOOST_AUTO_TEST_SUITE(test_matrice)\n\n\n\n BOOST_AUTO_TEST_CASE(puissance) {\n\n matrice::matrice<long long> A(2, 2);\n\n A <<= 1, 1,\n\n 1, 0;\n\n\n\n auto F = matrice::puissance_matrice(A, 40);\n\n\n\n const std::vector<long long> resultat{165580141, 102334155,\n\n 102334155, 63245986};\n\n\n\n BOOST_CHECK_EQUAL(F.size1(), 2);\n\n BOOST_CHECK_EQUAL(F.size2(), 2);\n", "file_path": "tests/matrice.cpp", "rank": 54, "score": 46539.07430411768 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"combinatoire.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_combinatoire)\n\n\n\n BOOST_AUTO_TEST_CASE(coefficient_binomial) {\n\n BOOST_CHECK_EQUAL(35, combinatoire::coefficient_binomial(7, 3));\n\n BOOST_CHECK_EQUAL(70, combinatoire::coefficient_binomial(8, 4));\n\n BOOST_CHECK_EQUAL(1, combinatoire::coefficient_binomial(40, 0));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(catalan) {\n\n BOOST_CHECK_EQUAL(1, combinatoire::catalan(0));\n\n BOOST_CHECK_EQUAL(1, combinatoire::catalan(1));\n\n BOOST_CHECK_EQUAL(16796, combinatoire::catalan<unsigned long long>(10));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(factorielle) {\n\n BOOST_CHECK_EQUAL(120, combinatoire::factorielle(5));\n\n BOOST_CHECK_EQUAL(720, combinatoire::factorielle(6));\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/combinatoire.cpp", "rank": 55, "score": 46538.91689791148 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"multidimension.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_multidimension)\n\n\n\n BOOST_AUTO_TEST_CASE(multidimension_2) {\n\n multidimension<short, 2> matrice{\n\n {7, 53, 183, 439, 863, 497, 383, 563, 79, 973, 287, 63, 343, 169, 583},\n\n {627, 343, 773, 959, 943, 767, 473, 103, 699, 303, 957, 703, 583, 639, 913},\n\n {447, 283, 463, 29, 23, 487, 463, 993, 119, 883, 327, 493, 423, 159, 743},\n\n {217, 623, 3, 399, 853, 407, 103, 983, 89, 463, 290, 516, 212, 462, 350},\n\n {960, 376, 682, 962, 300, 780, 486, 502, 912, 800, 250, 346, 172, 812, 350},\n\n {870, 456, 192, 162, 593, 473, 915, 45, 989, 873, 823, 965, 425, 329, 803},\n\n {973, 965, 905, 919, 133, 673, 665, 235, 509, 613, 673, 815, 165, 992, 326},\n\n {322, 148, 972, 962, 286, 255, 941, 541, 265, 323, 925, 281, 601, 95, 973},\n\n {445, 721, 11, 525, 473, 65, 511, 164, 138, 672, 18, 428, 154, 448, 848},\n\n {414, 456, 310, 312, 798, 104, 566, 520, 302, 248, 694, 976, 430, 392, 198},\n\n {184, 829, 373, 181, 631, 101, 969, 613, 840, 740, 778, 458, 284, 760, 390},\n\n {821, 461, 843, 513, 17, 901, 711, 993, 293, 157, 274, 94, 192, 156, 574},\n", "file_path": "tests/multidimension.cpp", "rank": 56, "score": 46538.721444204944 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"diophantienne.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_diophantienne)\n\n\n\n BOOST_AUTO_TEST_CASE(pqa1) {\n\n auto resultat = diophantienne::PQa(11, 108, 13);\n\n std::vector<long long> fractions{0, 7, 2, 1, 1, 6, 1, 1};\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.first.begin(), resultat.first.end(), fractions.begin(), fractions.end());\n\n BOOST_CHECK_EQUAL(resultat.second, 5);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pqa2) {\n\n auto resultat = diophantienne::PQa(0, 1, 13);\n\n std::vector<long long> fractions{3, 1, 1, 1, 1, 6};\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.first.begin(), resultat.first.end(), fractions.begin(), fractions.end());\n\n BOOST_CHECK_EQUAL(resultat.second, 5);\n\n }\n\n\n", "file_path": "tests/diophantienne.cpp", "rank": 57, "score": 46537.24636975284 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"chiffres.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_chiffres)\n\n\n\n BOOST_AUTO_TEST_CASE(nombre_chiffres) {\n\n BOOST_CHECK_EQUAL(9, chiffres::nombre_chiffres(123456789ULL));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(somme_chiffres) {\n\n BOOST_CHECK_EQUAL(45, chiffres::somme_chiffres(123456789ULL));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(extraire_chiffres) {\n\n auto c = chiffres::extraire_chiffres(123456789ULL);\n\n std::deque<size_t> r{1, 2, 3, 4, 5, 6, 7, 8, 9};\n\n BOOST_CHECK_EQUAL_COLLECTIONS(c.begin(), c.end(), r.begin(), r.end());\n\n }\n\n\n", "file_path": "tests/chiffres.cpp", "rank": 58, "score": 46537.10570263723 }, { "content": " BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(), solution.begin(), solution.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(iterateur_diophantienne1) {\n\n // 10x + 84y + 16 = 0\n\n long long int A = 10, B = 84, C = 16;\n\n size_t compteur = 0;\n\n for (auto s : diophantienne::equation_lineaire(A, B, C)) {\n\n ++compteur;\n\n if (compteur > 10) {\n\n break;\n\n }\n\n BOOST_CHECK_EQUAL(A * s.first + B * s.second + C, 0);\n\n }\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(iterateur_diophantienne2) {\n\n // 10x + 84y - 16 = 0\n\n long long int A = 10, B = 84, C = -16;\n\n size_t compteur = 0;\n", "file_path": "tests/diophantienne.cpp", "rank": 59, "score": 46536.95725893468 }, { "content": " BOOST_AUTO_TEST_CASE(palindrome) {\n\n BOOST_CHECK_EQUAL(false, chiffres::palindrome(123456789ULL));\n\n BOOST_CHECK_EQUAL(true, chiffres::palindrome(123454321ULL));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pandigital) {\n\n BOOST_CHECK_EQUAL(true, chiffres::pandigital(123456789ULL));\n\n BOOST_CHECK_EQUAL(false, chiffres::pandigital(1234567890ULL));\n\n BOOST_CHECK_EQUAL(false, chiffres::pandigital(123454321ULL));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(conversion_nombre) {\n\n std::deque<size_t> c{1, 2, 3, 4, 5, 6, 7, 8, 9};\n\n BOOST_CHECK_EQUAL(123456789ULL, chiffres::conversion_nombre<size_t>(c.begin(), c.end()));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(permutation_chiffres) {\n\n BOOST_CHECK_EQUAL(true, chiffres::permutation_chiffres(123456789ULL, 918273645ULL));\n\n BOOST_CHECK_EQUAL(true, chiffres::permutation_chiffres(123ULL, 1234ULL));\n\n }\n", "file_path": "tests/chiffres.cpp", "rank": 60, "score": 46535.62930457869 }, { "content": " std::vector<bool> crible(taille, true);\n\n std::vector<size_t> phi(taille, 0);\n\n\n\n std::iota(phi.begin(), phi.end(), 0ul);\n\n for (size_t i = 2; i < taille; ++i) {\n\n if (crible[i]) {\n\n for (size_t j = i; j < taille; j += i) {\n\n crible[j] = false;\n\n phi[j] /= i;\n\n phi[j] *= i - 1;\n\n }\n\n }\n\n }\n\n\n\n // std::cout << phi << std::endl;\n\n Fenwick<long long> fenwick(taille);\n\n std::vector<long long> f(taille, 0);\n\n for (size_t n = taille - 1; n > 5; --n) {\n\n size_t k = phi[n];\n\n f[n] = 1 + fenwick.range(k, n - 1);\n\n fenwick.add(k, f[n]);\n\n }\n\n\n\n BOOST_CHECK_EQUAL(482073668, f[6]);\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/fenwick.cpp", "rank": 61, "score": 46535.46199377989 }, { "content": "\n\n // // generate the bounds for all of the queries\n\n // srandom(seed + 1);\n\n // for (unsigned int i = 0; i < NQUERIES; ++i) {\n\n // unsigned long a = static_cast<unsigned long>(random()) % N;\n\n // unsigned long b = static_cast<unsigned long>(random()) % N;\n\n\n\n // if (a > b) {\n\n // std::swap(a, b);\n\n // }\n\n\n\n // queries.emplace_back(a, b);\n\n // }\n\n\n\n // /*****************************************************************/\n\n // /* FLAT ARRAY METHOD */\n\n // /*****************************************************************/\n\n // //std::vector<sum_t> array(N, 0);\n\n // //\n\n // //time1 = clock();\n", "file_path": "tests/fenwick.cpp", "rank": 62, "score": 46534.519888923554 }, { "content": " // /*****************************************************************/\n\n // // Store the same random numbers in a Fenwick tree\n\n // Fenwick<sum_t> fenwick(N);\n\n\n\n // srandom(seed);\n\n // for (unsigned int i = 0; i < N; i++)\n\n // fenwick[i] = static_cast<unsigned long>(random()) % COUNTS;\n\n\n\n // fenwick.initialisation();\n\n\n\n // // perform the queries\n\n // std::vector<sum_t> resultat;\n\n // resultat.reserve(NQUERIES);\n\n // for (auto &t: queries) {\n\n // auto range = fenwick.range(t.first, t.second);\n\n // resultat.push_back(range);\n\n // }\n\n\n\n // std::vector<sum_t> objectif{87981345, 1018050452, 37060257, 133931587, 2082302311, 127607876, 499939565,\n\n // 778250548, 1356376781, 1678639060, 576926234, 810701986, 1196425448, 118049060,\n", "file_path": "tests/fenwick.cpp", "rank": 63, "score": 46534.51227885926 }, { "content": " resultat <<= 35, 39, 17,\n\n 70, -32, 4,\n\n 105, -18, 11;\n\n resultat /= 35;\n\n\n\n matrice::matrice<fraction> X(3, 3);\n\n bool solution = matrice::resolutionLU(A, B, X);\n\n\n\n BOOST_CHECK_EQUAL(solution, true);\n\n BOOST_CHECK_EQUAL_COLLECTIONS(X.data().begin(), X.data().end(),\n\n resultat.data().begin(), resultat.data().end());\n\n\n\n matrice::matrice<fraction> produit = boost::numeric::ublas::prod(A, X);\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(produit.data().begin(), produit.data().end(),\n\n B.data().begin(), B.data().end());\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/matrice.cpp", "rank": 64, "score": 46534.136631537614 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"utilitaires.h\"\n\n#include \"permutation.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_permutation)\n\n\n\n BOOST_AUTO_TEST_CASE(permutation_simple) {\n\n const std::vector<std::vector<int>> resultat{\n\n {1, 2, 3},\n\n {1, 3, 2},\n\n {2, 1, 3},\n\n {2, 3, 1},\n\n {3, 1, 2},\n\n {3, 2, 1}\n\n };\n\n\n\n size_t index = 0;\n\n const std::vector<int> v{1, 2, 3};\n\n for (auto i: permutation::Permutation<std::vector<int>>(v)) {\n", "file_path": "tests/permutation.cpp", "rank": 65, "score": 46534.119962839395 }, { "content": " BOOST_AUTO_TEST_CASE(multiplication) {\n\n Polynome<long long> p{1, -1, 1, -1, 1};\n\n Polynome<long long> q{1, 1,};\n\n Polynome<long long> r{1, 0, 0, 0, 0, 1};\n\n BOOST_CHECK_EQUAL(p * q, r);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(affiche_1) {\n\n Polynome<long long> p{1, -1, 1, -1, 1};\n\n std::ostringstream oss;\n\n oss << p;\n\n BOOST_CHECK_EQUAL(oss.str(), \"X^4 - X^3 + X^2 - X + 1\");\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(affiche_2) {\n\n Polynome<long long> p{1, 1,};\n\n std::ostringstream oss;\n\n oss << p;\n\n BOOST_CHECK_EQUAL(oss.str(), \"X + 1\");\n\n }\n", "file_path": "tests/polynome.cpp", "rank": 66, "score": 46533.67152473613 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"numerique.h\"\n\n#include \"combinatoire.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_numerique)\n\n\n\n BOOST_AUTO_TEST_CASE(ostringstream_signed) {\n\n auto f = combinatoire::factorielle<int128_t>(30);\n\n std::ostringstream oss;\n\n oss << f;\n\n BOOST_CHECK_EQUAL(\"265252859812191058636308480000000\", oss.str());\n\n\n\n int128_t n;\n\n std::istringstream iss(oss.str());\n\n iss >> n;\n\n BOOST_CHECK_EQUAL(n, f);\n\n\n\n std::ostringstream oss2;\n\n oss2 << -f;\n", "file_path": "tests/numerique.cpp", "rank": 67, "score": 46533.500160173644 }, { "content": " Polynome<long long> q{-1, 0, 1};\n\n Polynome<long long> r{1, 0, 1};\n\n BOOST_CHECK_EQUAL(p, q);\n\n BOOST_CHECK_NE(p, r);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(addition) {\n\n Polynome<long long> p{-1, 0, 1};\n\n Polynome<long long> q{0, 1};\n\n Polynome<long long> r{-1, 1, 1};\n\n BOOST_CHECK_EQUAL(p + q, r);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(soustraction) {\n\n Polynome<long long> p{-1, 1, 1};\n\n Polynome<long long> q{0, 0, 1};\n\n Polynome<long long> r{-1, 1};\n\n BOOST_CHECK_EQUAL(p - q, r);\n\n }\n\n\n", "file_path": "tests/polynome.cpp", "rank": 68, "score": 46533.19568492871 }, { "content": "#include <boost/test/unit_test.hpp>\n\n#include <deque>\n\n\n\n#include \"numerique.h\"\n\n#include \"premiers.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_premiers)\n\n\n\n BOOST_AUTO_TEST_CASE(crible) {\n\n const std::vector<size_t> premiers100{2, 3, 5, 7, 11, 13, 17, 19, 23,\n\n 29, 31, 37, 41, 43, 47, 53, 59,\n\n 61, 67, 71, 73, 79, 83, 89, 97};\n\n std::deque<size_t> resultat;\n\n premiers::crible2<size_t>(100ULL, std::back_inserter(resultat));\n\n BOOST_CHECK_EQUAL_COLLECTIONS(premiers100.begin(), premiers100.end(), resultat.begin(), resultat.end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(crible23) {\n\n std::deque<size_t> resultat;\n\n premiers::crible23<size_t>(10000ULL, std::back_inserter(resultat));\n", "file_path": "tests/premiers.cpp", "rank": 69, "score": 46533.19241091446 }, { "content": " // //// Store random numbers in a flat array\n\n // //srandom(seed);\n\n // //for (unsigned long i = 0; i < N; i++)\n\n // // array[i] = static_cast<unsigned long>(random()) % COUNTS;\n\n // //time2 = clock(); // time2 - time1 = time for setup\n\n // //// perform the queries\n\n // //for (auto &t: queries) {\n\n // // sum_t asum = 0;\n\n // // for (unsigned long i = t.first; i < t.second; i++)\n\n // // asum += array[i];\n\n // // printf(\" %lu\", asum);\n\n // //}\n\n // //time3 = clock(); // time3 - time2 = time for queries\n\n // //\n\n // //printf(\"\\nFlat Array:\\n Build: %f\\n Query: %f\\n\",\n\n // // (time2 - time1) * (1.0 / CLOCKS_PER_SEC),\n\n // // (time3 - time2) * (1.0 / CLOCKS_PER_SEC));\n\n\n\n // /*****************************************************************/\n\n // /* FENWICK TREE METHOD */\n", "file_path": "tests/fenwick.cpp", "rank": 70, "score": 46533.13180653553 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"utilitaires.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_utilitaires)\n\n\n\nBOOST_AUTO_TEST_CASE(affiche_vector) {\n\n const std::vector<int> v{1, 1, 2, 3, 5, 8, 13};\n\n std::ostringstream oss;\n\n oss << v;\n\n\n\n BOOST_CHECK_EQUAL(\"[1 1 2 3 5 8 13]\", oss.str());\n\n}\n\n\n\nBOOST_AUTO_TEST_CASE(affiche_deque) {\n\n const std::deque<int> v{1, 1, 2, 3, 5, 8, 13, 21, 34};\n\n std::ostringstream oss;\n\n oss << v;\n\n\n\n BOOST_CHECK_EQUAL(\"[1 1 2 3 5 8 13 21 34]\", oss.str());\n", "file_path": "tests/utilitaires.cpp", "rank": 71, "score": 46533.00611129542 }, { "content": "\n\n bool inversible = matrice::inversionLU(A, inverse);\n\n\n\n BOOST_CHECK_EQUAL(inversible, true);\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.data().begin(), resultat.data().end(),\n\n inverse.data().begin(), inverse.data().end());\n\n\n\n matrice::matrice<fraction> identite(4, 4);\n\n identite <<= 1, 0, 0, 0,\n\n 0, 1, 0, 0,\n\n 0, 0, 1, 0,\n\n 0, 0, 0, 1;\n\n\n\n matrice::matrice<fraction> produit = boost::numeric::ublas::prod(A, inverse);\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(produit.data().begin(), produit.data().end(),\n\n identite.data().begin(), identite.data().end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(resolution_vecteur) {\n", "file_path": "tests/matrice.cpp", "rank": 72, "score": 46532.90165867718 }, { "content": "\n\n BOOST_AUTO_TEST_CASE(affiche_3) {\n\n Polynome<long long> p{1, 0, 0, 0, 0, 1};\n\n std::ostringstream oss;\n\n oss << p;\n\n BOOST_CHECK_EQUAL(oss.str(), \"X^5 + 1\");\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(division_euclidienne_1) {\n\n Polynome<long long> A{0, -2, 3, -1, -1, 1};\n\n Polynome<long long> B{1, -1, 1};\n\n\n\n\n\n Polynome<long long> Q;\n\n Polynome<long long> R;\n\n Polynome<long long>::division_euclidienne(A, B, Q, R);\n\n\n\n Polynome<long long> Q1{1, -2, 0, 1};\n\n Polynome<long long> R1{-1, 1};\n\n\n", "file_path": "tests/polynome.cpp", "rank": 73, "score": 46532.68968709226 }, { "content": " }\n\n\n\n BOOST_AUTO_TEST_CASE(combinaisons_simple) {\n\n const std::vector<std::vector<int>> resultat{\n\n {1, 2, 3},\n\n {1, 2, 4},\n\n {1, 3, 4},\n\n {2, 3, 4}\n\n };\n\n\n\n size_t index = 0;\n\n std::vector<int> iterable{1, 2, 3, 4};\n\n for (auto i : permutation::Combinaisons<int>(iterable, 3)) {\n\n BOOST_CHECK_EQUAL_COLLECTIONS(i.begin(), i.end(),\n\n resultat[index].begin(), resultat[index].end());\n\n ++index;\n\n }\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(combinaisons_doublon) {\n", "file_path": "tests/permutation.cpp", "rank": 74, "score": 46532.453123277926 }, { "content": " matrice::vecteur<fraction> produit = boost::numeric::ublas::prod(A, x);\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(produit.data().begin(), produit.data().end(),\n\n b.data().begin(), b.data().end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(resolution_matrice) {\n\n typedef boost::rational<long long> fraction;\n\n\n\n matrice::matrice<fraction> A(3, 3);\n\n A <<= 1, -1, 2,\n\n 3, 2, 1,\n\n 2, -3, -2;\n\n\n\n matrice::matrice<fraction> B(3, 3);\n\n B <<= 5, 1, 1,\n\n 10, 1, 2,\n\n -10, 6, 0;\n\n\n\n matrice::matrice<fraction> resultat(3, 3);\n", "file_path": "tests/matrice.cpp", "rank": 75, "score": 46532.35687528255 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"polygonal.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_polygonal)\n\n\n\n BOOST_AUTO_TEST_CASE(carre) {\n\n BOOST_CHECK_EQUAL(123456ULL, racine::racine_carre(15241383936ULL));\n\n BOOST_CHECK(polygonal::est_carre(15241383936ULL));\n\n BOOST_CHECK(!polygonal::est_carre(15241383935ULL));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(cubique) {\n\n BOOST_CHECK_EQUAL(12345ULL, racine::racine_cubique(1881365963625ULL));\n\n BOOST_CHECK(polygonal::est_cubique(1881365963625ULL));\n\n BOOST_CHECK(!polygonal::est_cubique(1881365963624ULL));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(triangulaire) {\n\n BOOST_CHECK_EQUAL(5050, polygonal::triangulaire(100));\n", "file_path": "tests/polygonal.cpp", "rank": 76, "score": 46532.302274014146 }, { "content": " BOOST_CHECK_EQUAL(Q, Q1);\n\n BOOST_CHECK_EQUAL(R, R1);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(division_euclidienne_2) {\n\n Polynome<long long> A{-1, 0, 0, 0, 0, 0, 0, 1};\n\n Polynome<long long> B{-1, 1};\n\n\n\n Polynome<long long> Q;\n\n Polynome<long long> R;\n\n\n\n Polynome<long long>::division_euclidienne(A, B, Q, R);\n\n Polynome<long long> Q1{1, 1, 1, 1, 1, 1, 1};\n\n Polynome<long long> R1;\n\n\n\n BOOST_CHECK_EQUAL(Q, Q1);\n\n BOOST_CHECK_EQUAL(R, R1);\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/polynome.cpp", "rank": 77, "score": 46532.25274408124 }, { "content": " BOOST_CHECK_EQUAL(v, -88630LL);\n\n BOOST_CHECK_EQUAL(a * u + b * v, 1); // PGCD(a, b) = 1\n\n }\n\n\n\n BOOST_FIXTURE_TEST_CASE(Bezout2, fixure_arithmetiques) {\n\n long long u, v;\n\n long long a = 456755ULL;\n\n long long b = 158665ULL;\n\n arithmetique::Bezout(a, b, u, v);\n\n\n\n BOOST_CHECK_EQUAL(u, 602LL);\n\n BOOST_CHECK_EQUAL(v, -1733LL);\n\n BOOST_CHECK_EQUAL(a * u + b * v, 65); // PGCD(a, b) = 65\n\n }\n\n\n\n\n\n BOOST_FIXTURE_TEST_CASE(nombre_diviseurs, fixure_arithmetiques) {\n\n BOOST_CHECK_EQUAL(arithmetique::nombre_diviseurs(3246999210ULL, premiers), 640);\n\n }\n\n\n", "file_path": "tests/arithmetique.cpp", "rank": 78, "score": 46531.67442655948 }, { "content": "\n\n BOOST_AUTO_TEST_CASE(inverser_nombre) {\n\n BOOST_CHECK_EQUAL(987654321ULL, chiffres::inverser_nombre(123456789ULL));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(concatener) {\n\n BOOST_CHECK_EQUAL(123456789ULL, chiffres::concatener(12ULL, 3456789ULL));\n\n BOOST_CHECK_EQUAL(123456789ULL, chiffres::concatener(12ULL, 345ULL, 6789ULL));\n\n BOOST_CHECK_EQUAL(123456789ULL, chiffres::concatener(12ULL, 34ULL, 567ULL, 89ULL));\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/chiffres.cpp", "rank": 79, "score": 46531.63074131901 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"pythagoricien.h\"\n\n#include \"utilitaires.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_pythagoricien)\n\n\n\n struct fixture_pythagoricien {\n\n std::set<std::tuple<size_t, size_t, size_t>> triplets;\n\n\n\n fixture_pythagoricien() {\n\n triplets = std::set<std::tuple<size_t, size_t, size_t>>\n\n {\n\n std::make_tuple(3, 4, 5),\n\n std::make_tuple(5, 12, 13),\n\n std::make_tuple(8, 15, 17),\n\n std::make_tuple(7, 24, 25),\n\n\n\n std::make_tuple(20, 21, 29),\n\n std::make_tuple(12, 35, 37),\n", "file_path": "tests/pythagoricien.cpp", "rank": 80, "score": 46531.475013918905 }, { "content": "#include <boost/test/unit_test.hpp>\n\n\n\n#include \"arithmetique.h\"\n\n\n\nBOOST_AUTO_TEST_SUITE(test_arithmetique)\n\n\n\n struct fixure_arithmetiques {\n\n std::vector<size_t> premiers;\n\n\n\n explicit fixure_arithmetiques() {\n\n premiers = std::vector<size_t> {2, 3, 5, 7, 11, 13, 17, 19, 23, 29,\n\n 31, 37, 41, 43, 47, 53, 59, 61, 67,\n\n 71, 73, 79, 83, 89, 97};\n\n }\n\n\n\n ~fixure_arithmetiques() = default;\n\n };\n\n\n\n BOOST_FIXTURE_TEST_CASE(pgcd, fixure_arithmetiques) {\n\n BOOST_CHECK_EQUAL(arithmetique::PGCD(456753ULL, 97643ULL), 1);\n", "file_path": "tests/arithmetique.cpp", "rank": 81, "score": 46531.400033761 }, { "content": " BOOST_CHECK_EQUAL(F(0, 0), 165580141);\n\n BOOST_CHECK_EQUAL(F(1, 0), 102334155);\n\n BOOST_CHECK_EQUAL(F(0, 1), 102334155);\n\n BOOST_CHECK_EQUAL(F(1, 1), 63245986);\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(),\n\n F.data().begin(), F.data().end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(puissance_modulaire) {\n\n matrice::matrice<long long> A(2, 2);\n\n A <<= 1, 1,\n\n 1, 0;\n\n\n\n auto F = matrice::puissance_matrice<long long>(A, 100, 1000000000);\n\n\n\n const std::vector<long long> resultat{817084101, 261915075,\n\n 261915075, 555169026};\n\n\n\n BOOST_CHECK_EQUAL(F.size1(), 2);\n", "file_path": "tests/matrice.cpp", "rank": 82, "score": 46530.72861564622 }, { "content": "\n\n std::vector<int> iterable{1, 2, 3, 4};\n\n for (auto &i: permutation::Arrangements<int>(iterable, 3)) {\n\n BOOST_CHECK_EQUAL_COLLECTIONS(i.begin(), i.end(),\n\n resultat[index].begin(), resultat[index].end());\n\n ++index;\n\n }\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(arrangements_doublon) {\n\n const std::vector<std::string> resultat{\"AB\", \"BA\", \"AD\", \"DA\", \"BB\", \"BD\", \"DB\"};\n\n\n\n size_t index = 0;\n\n\n\n std::vector<char> iterable{'A', 'B', 'B', 'D'};\n\n for (auto &i: permutation::Arrangements<char>(iterable, 2)) {\n\n BOOST_CHECK_EQUAL_COLLECTIONS(i.begin(), i.end(),\n\n resultat[index].begin(), resultat[index].end());\n\n ++index;\n\n }\n", "file_path": "tests/permutation.cpp", "rank": 83, "score": 46530.68210138234 }, { "content": " const std::vector<std::string> resultat{\"AB\", \"AC\", \"AD\", \"BC\", \"BD\", \"CD\"};\n\n\n\n size_t index = 0;\n\n std::vector<char> iterable{'A', 'B', 'C', 'D'};\n\n for (auto i : permutation::Combinaisons<char>(iterable, 2)) {\n\n BOOST_CHECK_EQUAL_COLLECTIONS(i.begin(), i.end(),\n\n resultat[index].begin(), resultat[index].end());\n\n ++index;\n\n }\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/permutation.cpp", "rank": 84, "score": 46530.55569012072 }, { "content": " identite.data().begin(), identite.data().end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(inversion2) {\n\n typedef boost::rational<long long> fraction;\n\n\n\n matrice::matrice<fraction> A(4, 4);\n\n A <<= 1, 1, 1, -1,\n\n 1, 2, 6, 7,\n\n 1, 2, 9, 0,\n\n 2, 5, 9, 15;\n\n\n\n matrice::matrice<fraction> resultat(4, 4);\n\n resultat <<= 99, 132, -44, -55,\n\n -18, -129, 29, 59,\n\n -7, 14, 7, -7,\n\n -3, 17, -8, -3;\n\n resultat /= 77;\n\n\n\n matrice::matrice<fraction> inverse(4, 4);\n", "file_path": "tests/matrice.cpp", "rank": 85, "score": 46530.31424427844 }, { "content": " BOOST_AUTO_TEST_CASE(crible_simple) {\n\n const std::vector<size_t> premiers100{2, 3, 5, 7, 11, 13, 17, 19, 23,\n\n 29, 31, 37, 41, 43, 47, 53, 59,\n\n 61, 67, 71, 73, 79, 83, 89, 97};\n\n std::vector<bool> crible;\n\n premiers::crible_simple(100, crible);\n\n\n\n BOOST_CHECK_EQUAL(100, crible.size());\n\n\n\n for (auto p: premiers100) {\n\n BOOST_CHECK(crible[p]);\n\n }\n\n\n\n size_t compteur = std::accumulate(crible.begin(), crible.end(), 0ul);\n\n BOOST_CHECK_EQUAL(25, compteur);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(miller_rabin) {\n\n uint128_t n = 32416189721ull;\n\n BOOST_CHECK(premiers::miller_rabin<uint128_t>(n, 25));\n", "file_path": "tests/premiers.cpp", "rank": 86, "score": 46530.11171297498 }, { "content": " {34, 124, 4, 878, 450, 476, 712, 914, 838, 669, 875, 299, 823, 329, 699},\n\n {815, 559, 813, 459, 522, 788, 168, 586, 966, 232, 308, 833, 251, 631, 107},\n\n {813, 883, 451, 509, 615, 77, 281, 613, 459, 205, 380, 274, 302, 35, 805}\n\n };\n\n\n\n std::vector<short> ligne1{7, 53, 183, 439, 863, 497, 383, 563, 79, 973, 287, 63, 343, 169, 583};\n\n std::vector<short> ligne7{973, 965, 905, 919, 133, 673, 665, 235, 509, 613, 673, 815, 165, 992, 326};\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(matrice.front().begin(), matrice.front().end(),\n\n ligne1.begin(), ligne1.end());\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(matrice[6].begin(), matrice[6].end(),\n\n ligne7.begin(), ligne7.end());\n\n\n\n BOOST_CHECK_EQUAL(matrice.back().back(), 805);\n\n BOOST_CHECK_EQUAL(matrice[4][10], 250);\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(multidimension_3) {\n\n multidimension<short, 3> matrice\n", "file_path": "tests/multidimension.cpp", "rank": 87, "score": 46529.41538797235 }, { "content": " std::make_tuple(9, 40, 41),\n\n std::make_tuple(28, 45, 53),\n\n\n\n std::make_tuple(11, 60, 61),\n\n std::make_tuple(16, 63, 65),\n\n std::make_tuple(33, 56, 65),\n\n std::make_tuple(48, 55, 73),\n\n\n\n std::make_tuple(13, 84, 85),\n\n std::make_tuple(36, 77, 85),\n\n std::make_tuple(39, 80, 89),\n\n std::make_tuple(65, 72, 97)\n\n };\n\n }\n\n };\n\n\n\n BOOST_FIXTURE_TEST_CASE(nombres_pythagoricien, fixture_pythagoricien) {\n\n Pythagoricien pythagoricien(100);\n\n std::set<std::tuple<size_t, size_t, size_t>> resultat;\n\n for (auto t: pythagoricien) {\n\n resultat.insert(t);\n\n }\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(triplets.begin(), triplets.end(), resultat.begin(), resultat.end());\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/pythagoricien.cpp", "rank": 88, "score": 46528.84128424528 }, { "content": " BOOST_CHECK_EQUAL(\"-265252859812191058636308480000000\", oss2.str());\n\n\n\n int128_t n2;\n\n std::istringstream iss2(oss2.str());\n\n iss2 >> n2;\n\n BOOST_CHECK_EQUAL(n2, -f);\n\n\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(ostringstream_unsigned) {\n\n auto f = combinatoire::factorielle<uint128_t>(30);\n\n std::ostringstream oss;\n\n oss << f;\n\n BOOST_CHECK_EQUAL(\"265252859812191058636308480000000\", oss.str());\n\n\n\n uint128_t n;\n\n std::istringstream iss(oss.str());\n\n iss >> n;\n\n BOOST_CHECK_EQUAL(n, f);\n\n }\n", "file_path": "tests/numerique.cpp", "rank": 89, "score": 46528.68634592027 }, { "content": " BOOST_CHECK_EQUAL(F.size2(), 2);\n\n BOOST_CHECK_EQUAL(F(0, 0), 817084101);\n\n BOOST_CHECK_EQUAL(F(1, 0), 261915075);\n\n BOOST_CHECK_EQUAL(F(0, 1), 261915075);\n\n BOOST_CHECK_EQUAL(F(1, 1), 555169026);\n\n\n\n BOOST_CHECK_EQUAL_COLLECTIONS(resultat.begin(), resultat.end(),\n\n F.data().begin(), F.data().end());\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(inversion1) {\n\n typedef boost::rational<long long> fraction;\n\n\n\n matrice::matrice<fraction> A(3, 3);\n\n A <<= 2, -1, 0,\n\n -1, 2, -1,\n\n 0, -1, 2;\n\n\n\n matrice::matrice<fraction> resultat(3, 3);\n\n resultat <<= 3, 2, 1,\n", "file_path": "tests/matrice.cpp", "rank": 90, "score": 46528.23858228447 }, { "content": " BOOST_CHECK_EQUAL(arithmetique::PGCD(456755ULL, 158665ULL), 65);\n\n }\n\n\n\n BOOST_FIXTURE_TEST_CASE(ppcm, fixure_arithmetiques) {\n\n BOOST_CHECK_EQUAL(arithmetique::PPCM(456753ULL, 97643ULL), 44598733179ULL);\n\n BOOST_CHECK_EQUAL(arithmetique::PPCM(456755ULL, 158665ULL), 1114938955);\n\n }\n\n\n\n BOOST_FIXTURE_TEST_CASE(arrondi, fixure_arithmetiques) {\n\n BOOST_CHECK_EQUAL(arithmetique::arrondi(1000, 101), 10);\n\n BOOST_CHECK_EQUAL(arithmetique::arrondi(12345678, 48), 257202);\n\n }\n\n\n\n BOOST_FIXTURE_TEST_CASE(Bezout1, fixure_arithmetiques) {\n\n long long u, v;\n\n long long a = 456753LL;\n\n long long b = 97643LL;\n\n arithmetique::Bezout(a, b, u, v);\n\n\n\n BOOST_CHECK_EQUAL(u, 18947LL);\n", "file_path": "tests/arithmetique.cpp", "rank": 91, "score": 46527.88367205082 }, { "content": " }\n\n\n\n BOOST_AUTO_TEST_CASE(octagonal) {\n\n BOOST_CHECK_EQUAL(29800, polygonal::octagonal(100));\n\n BOOST_CHECK(polygonal::est_octagonal(5461));\n\n BOOST_CHECK(!polygonal::est_octagonal(5460));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(somme_carres) {\n\n BOOST_CHECK_EQUAL(338350, polygonal::somme_carres(100));\n\n BOOST_CHECK_EQUAL(54301841231, polygonal::somme_carres(5461ll));\n\n BOOST_CHECK_EQUAL(54272018710, polygonal::somme_carres(5460ll));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(somme_cubes) {\n\n BOOST_CHECK_EQUAL(25502500, polygonal::somme_cubes(100));\n\n BOOST_CHECK_EQUAL(222427127548081, polygonal::somme_cubes(5461ll));\n\n BOOST_CHECK_EQUAL(222264266760900, polygonal::somme_cubes(5460ll));\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/polygonal.cpp", "rank": 92, "score": 46527.51042821171 }, { "content": "\n\n BOOST_AUTO_TEST_CASE(numeric_limits_int128) {\n\n BOOST_CHECK_EQUAL(\"170141183460469231731687303715884105727\",\n\n std::to_string(std::numeric_limits<int128_t>::max()));\n\n\n\n BOOST_CHECK_EQUAL(\"-170141183460469231731687303715884105728\",\n\n std::to_string(std::numeric_limits<int128_t>::min()));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(numeric_limits_uint128) {\n\n BOOST_CHECK_EQUAL(\"340282366920938463463374607431768211455\",\n\n std::to_string(std::numeric_limits<uint128_t>::max()));\n\n\n\n BOOST_CHECK_EQUAL(0,\n\n std::numeric_limits<uint128_t>::min());\n\n }\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/numerique.cpp", "rank": 93, "score": 46527.36219703313 }, { "content": "\n\n BOOST_FIXTURE_TEST_CASE(moebius, fixure_arithmetiques) {\n\n BOOST_CHECK_EQUAL(arithmetique::moebius(3246999210ULL, premiers), 0);\n\n BOOST_CHECK_EQUAL(arithmetique::moebius(496ULL, premiers), 0);\n\n BOOST_CHECK_EQUAL(arithmetique::moebius(19ULL, premiers), -1);\n\n BOOST_CHECK_EQUAL(arithmetique::moebius(15ULL, premiers), 1);\n\n }\n\n\n\n BOOST_FIXTURE_TEST_CASE(facteur_carre, fixure_arithmetiques) {\n\n BOOST_CHECK_EQUAL(arithmetique::facteur_carre(3246999210ULL, premiers), true);\n\n BOOST_CHECK_EQUAL(arithmetique::facteur_carre(42315ULL, premiers), false);\n\n }\n\n\n\n BOOST_FIXTURE_TEST_CASE(diviseurs, fixure_arithmetiques) {\n\n auto d = arithmetique::diviseurs(496ULL, premiers);\n\n std::vector<size_t> result{1, 2, 4, 8, 16, 31, 62, 124, 248, 496};\n\n BOOST_CHECK_EQUAL_COLLECTIONS(d.begin(), d.end(), result.begin(), result.end());\n\n }\n\n\n\n BOOST_FIXTURE_TEST_CASE(repunit, fixure_arithmetiques) {\n", "file_path": "tests/arithmetique.cpp", "rank": 94, "score": 46527.239343948044 }, { "content": "}\n\n\n\nBOOST_AUTO_TEST_CASE(affiche_set) {\n\n const std::set<int> v{1, 1, 2, 3, 5, 8, 13, 21, 34};\n\n std::ostringstream oss;\n\n oss << v;\n\n\n\n BOOST_CHECK_EQUAL(\"{1 2 3 5 8 13 21 34}\", oss.str());\n\n}\n\n\n\nBOOST_AUTO_TEST_CASE(affiche_map) {\n\n const std::map<int, std::string> v{{1, \"1\"},\n\n {2, \"3\"},\n\n {5, \"8\"},\n\n {13, \"21\"}};\n\n std::ostringstream oss;\n\n oss << v;\n\n\n\n const std::string result = \"{\\n\"\n\n \" 1 => 1\\n\"\n", "file_path": "tests/utilitaires.cpp", "rank": 95, "score": 46527.13633273574 }, { "content": " for (auto s : diophantienne::equation_lineaire(A, B, C)) {\n\n ++compteur;\n\n if (compteur > 10) {\n\n break;\n\n }\n\n BOOST_CHECK_EQUAL(A * s.first + B * s.second + C, 0);\n\n }\n\n }\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/diophantienne.cpp", "rank": 96, "score": 46526.99963752479 }, { "content": " \" 2 => 3\\n\"\n\n \" 5 => 8\\n\"\n\n \" 13 => 21\\n\"\n\n \"}\\n\";\n\n\n\n BOOST_CHECK_EQUAL(result, oss.str());\n\n}\n\n\n\nBOOST_AUTO_TEST_SUITE_END()\n", "file_path": "tests/utilitaires.cpp", "rank": 97, "score": 46526.94515429852 }, { "content": " BOOST_CHECK(polygonal::est_triangulaire(5050));\n\n BOOST_CHECK(!polygonal::est_triangulaire(5000));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(pentagonal) {\n\n BOOST_CHECK_EQUAL(14950, polygonal::pentagonal(100));\n\n BOOST_CHECK(polygonal::est_pentagonal(3151));\n\n BOOST_CHECK(!polygonal::est_pentagonal(3150));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(hexagonal) {\n\n BOOST_CHECK_EQUAL(19900, polygonal::hexagonal(100));\n\n BOOST_CHECK(polygonal::est_hexagonal(4560));\n\n BOOST_CHECK(!polygonal::est_hexagonal(4550));\n\n }\n\n\n\n BOOST_AUTO_TEST_CASE(heptagonal) {\n\n BOOST_CHECK_EQUAL(24850, polygonal::heptagonal(100));\n\n BOOST_CHECK(polygonal::est_heptagonal(5688));\n\n BOOST_CHECK(!polygonal::est_heptagonal(5689));\n", "file_path": "tests/polygonal.cpp", "rank": 98, "score": 46526.85874061337 } ]
C++
include/zisa/memory/array_view_impl.hpp
1uc/ZisaMemory
9d9689e46e63629f842b04765bc322f32d91758e
#ifndef ARRAY_VIEW_IMPL_HPP #define ARRAY_VIEW_IMPL_HPP namespace zisa { template <class T> auto raw_ptr(T *a) -> decltype(a) { return a; } template <class T, class Indexing> array_view_base<T, Indexing>::array_view_base(array_view_base::shape_type shape, T *ptr, device_type mem_location) : _shape(shape), _ptr(ptr), _mem_location(mem_location) {} template <class T, class Indexing> typename array_view_base<T, Indexing>::size_type array_view_base<T, Indexing>::size() const { return product(_shape); } template <class T, class Indexing> const typename array_view_base<T, Indexing>::shape_type & array_view_base<T, Indexing>::shape() const { return _shape; } template <class T, class Indexing> typename array_view_base<T, Indexing>::size_type array_view_base<T, Indexing>::shape(array_view_base::size_type i) const { return _shape(i); } template <class T, class Indexing> device_type memory_location(const array_view_base<T, Indexing> &view) { return view.memory_location(); } template <class T, int n_dims, template <int> class Indexing> array_view<T, n_dims, Indexing>::array_view(const shape_t<n_dims> &shape, T *ptr, device_type mem_location) : super(shape, ptr, mem_location) {} template <class T, int n_dims, template <int> class Indexing> template <class Array, class Shape> array_view<T, n_dims, Indexing>::array_view( array_base<T, Indexing<n_dims>, Array, Shape> &other) : array_view(zisa::shape(other), zisa::raw_ptr(other), zisa::memory_location(other)) {} template <class T, int n_dims, template <int> class Indexing> array_view<T, n_dims, Indexing>::array_view(std::vector<T> &v) : array_view(shape_t<1>{v.size()}, v.data(), device_type::cpu) {} template <class T, int n_dims, template <int> class Indexing> T *array_view<T, n_dims, Indexing>::raw() const { return this->_ptr; } template <class T, int n_dims, template <int> class Indexing> T &array_view<T, n_dims, Indexing>::operator[](array_view::size_type i) const { return this->_ptr[i]; } template <class T, int n_dims, template <int> class Indexing> template <class... Ints> T &array_view<T, n_dims, Indexing>::operator()(Ints... ints) const { auto l = Indexing<n_dims>::linear_index(this->shape(), integer_cast<size_type>(ints)...); return (*this)[l]; } template <class T, int n_dims, template <int> class Indexing> T *array_view<T, n_dims, Indexing>::begin() const { return this->_ptr; } template <class T, int n_dims, template <int> class Indexing> T *array_view<T, n_dims, Indexing>::end() const { return this->_ptr + this->size(); } template <class T, int n_dims, template <int> class Indexing> T const *array_view<T, n_dims, Indexing>::cbegin() const { return this->_ptr; } template <class T, int n_dims, template <int> class Indexing> T const *array_view<T, n_dims, Indexing>::cend() const { return this->_ptr + this->size(); } template <class T, int n_dims, template <int> class Indexing> void array_view<T, n_dims, Indexing>::copy_data( const array_view<T, n_dims, Indexing> &other) const { copy_data(array_const_view<T, n_dims, Indexing>(other)); } template <class T, int n_dims, template <int> class Indexing> void array_view<T, n_dims, Indexing>::copy_data( const array_const_view<T, n_dims, Indexing> &other) const { assert((*this).shape() == other.shape()); LOG_ERR_IF(this->memory_location() == device_type::cuda, "Implement this."); if (other.raw() != (*this).raw()) { std::copy(other.begin(), other.end(), (*this).begin()); } } } #endif
#ifndef ARRAY_VIEW_IMPL_HPP #define ARRAY_VIEW_IMPL_HPP namespace zisa { template <class T> auto raw_ptr(T *a) -> decltype(a) { return a; } template <class T, class Indexing> array_view_base<T, Indexing>::array_view_base(array_view_base::shape_type shape, T *ptr, device_type mem_location) : _shape(shape), _ptr(ptr), _mem_location(mem_location) {} template <class T, class Indexing> typename array_view_base<T, Indexing>::size_type array_view_base<T, Indexing>::size() const { return product(_shape); } template <class T, class Indexing> const typename array_view_base<T, Indexing>::shape_type & array_view_base<T, Indexing>::shape() const { return _shape; } template <class T, class Indexing> typename array_view_base<T, Indexing>::size_type array_view_base<T, Indexing>::shape(array_view_base::size_type i) const { return _shape(i); } template <class T, class Indexing> device_type memory_location(const array_view_base<T, Indexing> &view) { return view.memory_location(); } template <class T, int n_dims, template <int> class Indexing> array_view<T, n_dims, Indexing>::array_view(const shape_t<n_dims> &shape, T *ptr, device_type mem_location) : super(shape, ptr, mem_location) {} template <class T, int n_dims, template <int> class Indexing> template <class Array, class Shape> array_view<T, n_dims, Indexing>::array_view( array_base<T, Indexing<n_dims>, Array, Shape> &other) : array_view(zisa::shape(other), zisa::raw_ptr(other), zisa::memory_location(other)) {} template <class T, int n_dims, template <int> class Indexing> array_view<T, n_dims, Indexing>::array_view(std::vector<T> &v) : array_view(shape_t<1>{v.size()}, v.data(), device_type::cpu) {} template <class T, int n_dims, template <int> class Indexing> T *array_view<T, n_dims, Indexing>::raw() const { return this->_ptr; } template <class T, int n_dim
int n_dims, template <int> class Indexing> T const *array_view<T, n_dims, Indexing>::cbegin() const { return this->_ptr; } template <class T, int n_dims, template <int> class Indexing> T const *array_view<T, n_dims, Indexing>::cend() const { return this->_ptr + this->size(); } template <class T, int n_dims, template <int> class Indexing> void array_view<T, n_dims, Indexing>::copy_data( const array_view<T, n_dims, Indexing> &other) const { copy_data(array_const_view<T, n_dims, Indexing>(other)); } template <class T, int n_dims, template <int> class Indexing> void array_view<T, n_dims, Indexing>::copy_data( const array_const_view<T, n_dims, Indexing> &other) const { assert((*this).shape() == other.shape()); LOG_ERR_IF(this->memory_location() == device_type::cuda, "Implement this."); if (other.raw() != (*this).raw()) { std::copy(other.begin(), other.end(), (*this).begin()); } } } #endif
s, template <int> class Indexing> T &array_view<T, n_dims, Indexing>::operator[](array_view::size_type i) const { return this->_ptr[i]; } template <class T, int n_dims, template <int> class Indexing> template <class... Ints> T &array_view<T, n_dims, Indexing>::operator()(Ints... ints) const { auto l = Indexing<n_dims>::linear_index(this->shape(), integer_cast<size_type>(ints)...); return (*this)[l]; } template <class T, int n_dims, template <int> class Indexing> T *array_view<T, n_dims, Indexing>::begin() const { return this->_ptr; } template <class T, int n_dims, template <int> class Indexing> T *array_view<T, n_dims, Indexing>::end() const { return this->_ptr + this->size(); } template <class T,
random
[ { "content": "class array_const_view : public array_view_base<const T, Indexing<n_dims>> {\n\n\n\nprivate:\n\n using super = array_view_base<const T, Indexing<n_dims>>;\n\n using size_type = typename super::size_type;\n\n\n\npublic:\n\n ANY_DEVICE_INLINE\n\n array_const_view(const shape_t<n_dims> &shape,\n\n T const *ptr,\n\n device_type mem_location = device_type::unknown)\n\n : super(shape, ptr, mem_location) {}\n\n\n\n template <class Array, class Shape>\n\n array_const_view(const array_base<T, Indexing<n_dims>, Array, Shape> &other)\n\n : array_const_view(zisa::shape(other),\n\n zisa::raw_ptr(other),\n\n zisa::memory_location(other)) {}\n\n\n\n ANY_DEVICE_INLINE\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 0, "score": 235025.09631773861 }, { "content": "class array_view : public array_view_base<T, Indexing<n_dims>> {\n\nprivate:\n\n using super = array_view_base<T, Indexing<n_dims>>;\n\n using size_type = typename super::size_type;\n\n\n\npublic:\n\n ANY_DEVICE_INLINE\n\n array_view(const shape_t<n_dims> &shape,\n\n T *ptr,\n\n device_type mem_location = device_type::unknown);\n\n\n\n template <class Array, class Shape>\n\n array_view(array_base<T, Indexing<n_dims>, Array, Shape> &other);\n\n\n\n array_view(std::vector<T> &v);\n\n\n\n ANY_DEVICE_INLINE T *raw() const;\n\n ANY_DEVICE_INLINE T &operator[](size_type i) const;\n\n\n\n template <class... Ints>\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 1, "score": 187199.53677227077 }, { "content": "class array_const_view;\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing = row_major>\n", "file_path": "include/zisa/memory/array_view_fwd.hpp", "rank": 2, "score": 172997.86280064506 }, { "content": "class array : public detail::array_super_<T, n_dims, Indexing> {\n\nprivate:\n\n using super = detail::array_super_<T, n_dims, Indexing>;\n\n\n\nprotected:\n\n using shape_type = typename super::shape_type;\n\n\n\npublic:\n\n using super::super;\n\n\n\n array(const array &) = default;\n\n array(array &&) noexcept = default;\n\n\n\n array(const array_const_view<T, n_dims, Indexing> &other,\n\n device_type mem_loc);\n\n\n\n explicit array(const array_const_view<T, n_dims, Indexing> &other);\n\n explicit array(const array_view<T, n_dims, Indexing> &other);\n\n\n\n array(T *raw_ptr, const shape_type &shape);\n", "file_path": "include/zisa/memory/array_decl.hpp", "rank": 3, "score": 166367.92751748947 }, { "content": "class array;\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 4, "score": 163842.72401537676 }, { "content": "class array_view;\n\n\n\n}\n\n#endif // ZISA_ARRAY_VIEW_FWD_HPP\n", "file_path": "include/zisa/memory/array_view_fwd.hpp", "rank": 5, "score": 142818.68251159138 }, { "content": "class array_view_base {\n\nprotected:\n\n using size_type = typename array_traits<T *>::size_type;\n\n using shape_type = shape_t<indexing_traits<Indexing>::n_dims, size_type>;\n\n\n\npublic:\n\n ANY_DEVICE\n\n array_view_base(shape_type shape, T *ptr, device_type mem_location);\n\n\n\n ANY_DEVICE_INLINE size_type size() const;\n\n\n\n ANY_DEVICE_INLINE const shape_type &shape() const;\n\n ANY_DEVICE_INLINE size_type shape(size_type i) const;\n\n\n\n ANY_DEVICE_INLINE device_type memory_location() const {\n\n return _mem_location;\n\n }\n\n\n\nprotected:\n\n shape_type _shape;\n\n T *_ptr;\n\n device_type _mem_location;\n\n};\n\n\n\ntemplate <class T, class Indexing>\n\ndevice_type memory_location(const array_view_base<T, Indexing> &view);\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 6, "score": 140764.37667346295 }, { "content": "struct indexing_traits;\n\n\n\ntemplate <class Array>\n", "file_path": "include/zisa/memory/array_base_decl.hpp", "rank": 7, "score": 103166.1268741088 }, { "content": "class array_base {\n\npublic:\n\n using shape_type = Shape;\n\n using size_type = typename array_traits<Array>::size_type;\n\n using pointer = typename array_traits<Array>::pointer;\n\n using const_pointer = typename array_traits<Array>::const_pointer;\n\n\n\npublic:\n\n static constexpr int n_dims = indexing_traits<Indexing>::n_dims;\n\n\n\npublic:\n\n array_base() = default;\n\n\n\n array_base(Shape shape, Array array)\n\n : _shape(std::move(shape)), _array(std::move(array)) {}\n\n\n\n array_base(const array_base &other) = default;\n\n array_base(array_base &&other) noexcept = default;\n\n\n\n ~array_base() = default;\n", "file_path": "include/zisa/memory/array_base_decl.hpp", "rank": 8, "score": 101953.25360160958 }, { "content": "class array_base;\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array_base_fwd.hpp", "rank": 9, "score": 101953.25360160958 }, { "content": " class SFINAE\n\n = typename std::enable_if<all_integral<Ints...>::value, void>::type>\n\n ANY_DEVICE_INLINE shape_t(Ints... ints) noexcept\n\n : _raw_data{integer_cast<Int>(ints)...} {}\n\n\n\n shape_t &operator=(const shape_t &) noexcept = default;\n\n shape_t &operator=(shape_t &&) noexcept = default;\n\n\n\n ANY_DEVICE_INLINE\n\n Int operator[](int_t dim) const {\n\n assert(dim < n_dims);\n\n return _raw_data[dim];\n\n }\n\n\n\n ANY_DEVICE_INLINE\n\n Int &operator[](int_t dim) {\n\n assert(dim < n_dims);\n\n return _raw_data[dim];\n\n }\n\n\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 10, "score": 100857.07797147511 }, { "content": "class locked_ptr {\n\npublic:\n\n locked_ptr() : data(nullptr), index(0), allocator(nullptr) {}\n\n\n\n locked_ptr(T *const data,\n\n int_t index,\n\n std::shared_ptr<block_allocator<T>> allocator)\n\n : data(data), index(index), allocator(std::move(allocator)) {}\n\n\n\n locked_ptr(const locked_ptr &other) = delete;\n\n\n\n locked_ptr(locked_ptr &&other) { *this = std::move(other); }\n\n\n\n ~locked_ptr() {\n\n if (data != nullptr && allocator != nullptr) {\n\n allocator->release(*this);\n\n }\n\n }\n\n\n\n void operator=(const locked_ptr &other) = delete;\n", "file_path": "include/zisa/memory/block_allocator.hpp", "rank": 11, "score": 97345.867527074 }, { "content": "enum class ErasedDataType { DOUBLE, FLOAT, INT, UNSIGNED_LONG, CHAR };\n\n\n\nnamespace detail {\n\n\n\ntemplate <class T>\n", "file_path": "include/zisa/io/hierarchical_file.hpp", "rank": 12, "score": 93957.00745159361 }, { "content": "struct array_traits<T *> {\n\n using pointer = typename std::remove_const<T>::type *;\n\n using const_pointer = typename std::add_const<T>::type *;\n\n using size_type = std::size_t;\n\n};\n\n\n\ntemplate <class T>\n\nANY_DEVICE_INLINE auto raw_ptr(T *a) -> decltype(a);\n\n\n\ntemplate <class T, class Indexing>\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 13, "score": 76815.43079652669 }, { "content": "#ifndef ARRAY_VIEW_HPP_VEWZW\n\n#define ARRAY_VIEW_HPP_VEWZW\n\n\n\n#include \"array_view_decl.hpp\"\n\n#include \"array_view_impl.hpp\"\n\n\n\n#endif // ARRAY_VIEW_HPP\n", "file_path": "include/zisa/memory/array_view.hpp", "rank": 14, "score": 75512.97024025457 }, { "content": " array_const_view(const array_view<T, n_dims, Indexing> &other)\n\n : super(other.shape(), other.raw(), zisa::memory_location(other)) {}\n\n\n\n array_const_view(const std::vector<T> &v)\n\n : array_const_view(shape_t<1>{v.size()}, v.data(), device_type::cpu) {}\n\n\n\n ANY_DEVICE_INLINE const T *raw() const { return this->_ptr; }\n\n ANY_DEVICE_INLINE const T &operator[](size_type i) const {\n\n return this->_ptr[i];\n\n }\n\n\n\n template <class... Ints>\n\n ANY_DEVICE_INLINE const T &operator()(Ints... ints) const {\n\n auto l = Indexing<n_dims>::linear_index(this->shape(),\n\n integer_cast<size_type>(ints)...);\n\n return (*this)[l];\n\n }\n\n\n\n ANY_DEVICE_INLINE T const *begin() const { return this->_ptr; }\n\n ANY_DEVICE_INLINE T const *end() const { return this->_ptr + this->size(); }\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 15, "score": 73681.59031617234 }, { "content": " return a.raw();\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nANY_DEVICE_INLINE auto raw_ptr(const array_const_view<T, n_dims, Indexing> &a)\n\n -> decltype(a.raw()) {\n\n return a.raw();\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid fill(const array_view<T, n_dims, Indexing> &dst, const T &value) {\n\n zisa::fill(raw_ptr(dst), memory_location(dst), dst.size(), value);\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid copy(const array_view<T, n_dims, Indexing> &dst,\n\n const array_const_view<T, n_dims, Indexing> &src) {\n\n\n\n zisa::internal::copy(dst.raw(),\n\n memory_location(dst),\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 17, "score": 73680.21569150838 }, { "content": "}\n\n}\n\n\n\ntemplate <class T, int n_dims>\n\narray_view<T, n_dims, row_major>\n\nslice(const array_view<T, n_dims, row_major> &arr, int_t i0, int_t i1) {\n\n auto const_view\n\n = detail::slice(array_const_view<T, n_dims, row_major>(arr), i0, i1);\n\n return {const_view.shape(), const_cast<T *>(const_view.raw())};\n\n}\n\n\n\ntemplate <class T, int n_dims>\n\narray_const_view<T, n_dims, row_major> const_slice(\n\n const array_const_view<T, n_dims, row_major> &arr, int_t i0, int_t i1) {\n\n return detail::slice(arr, i0, i1);\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nANY_DEVICE_INLINE auto raw_ptr(const array_view<T, n_dims, Indexing> &a)\n\n -> decltype(a.raw()) {\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 20, "score": 73677.42207505243 }, { "content": " const std::string &tag,\n\n bool_dispatch_tag) {\n\n\n\n using scalar_type = typename array_save_traits<bool>::scalar_type;\n\n auto int_arr = std::vector<scalar_type>(arr.size());\n\n std::copy(arr.cbegin(), arr.cend(), int_arr.begin());\n\n\n\n auto int_arr_view = array_const_view<scalar_type, n_dims, row_major>(\n\n arr.shape(), int_arr.data());\n\n\n\n save(writer, int_arr_view, tag);\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid save(HierarchicalWriter &writer,\n\n const array_const_view<T, n_dims, Indexing> &arr,\n\n const std::string &tag) {\n\n\n\n save(writer, arr, tag, typename array_save_traits<T>::dispatch_tag{});\n\n}\n\n\n\n} // namespace zisa\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 22, "score": 73676.20646617339 }, { "content": "\n\n ANY_DEVICE_INLINE T const *cbegin() const { return this->_ptr; }\n\n ANY_DEVICE_INLINE T const *cend() const { return this->_ptr + this->size(); }\n\n};\n\n\n\n#ifndef __CUDACC__\n\ntemplate <class T>\n\narray_const_view(const std::vector<T> &) -> array_const_view<T, 1, row_major>;\n\n#endif\n\n\n\nnamespace detail {\n\ntemplate <class T, int n_dims>\n\narray_const_view<T, n_dims, row_major>\n\nslice(const array_const_view<T, n_dims, row_major> &arr, int_t i0, int_t i1) {\n\n auto sub_shape = arr.shape();\n\n sub_shape[0] = i1 - i0;\n\n\n\n int_t offset = i0 * (product(sub_shape) / (i1 - i0));\n\n auto ptr = arr.raw() + offset;\n\n return {sub_shape, ptr};\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 23, "score": 73676.15883586284 }, { "content": " src.raw(),\n\n memory_location(src),\n\n src.size());\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid copy(const array_view<T, n_dims, Indexing> &dst,\n\n const array_view<T, n_dims, Indexing> &src) {\n\n return zisa::copy(dst, array_const_view<T, n_dims, Indexing>(src));\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid save(HierarchicalWriter &writer,\n\n const array_view<T, n_dims, Indexing> &arr,\n\n const std::string &tag) {\n\n\n\n save(writer, array_const_view<T, n_dims, Indexing>(arr), tag);\n\n}\n\n\n\ntemplate <class T, int n_dims>\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 24, "score": 73675.06191196124 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n#ifndef ZISA_ARRAY_VIEW_FWD_HPP_UEIWQ\n\n#define ZISA_ARRAY_VIEW_FWD_HPP_UEIWQ\n\n\n\n#include <zisa/memory/row_major.hpp>\n\n\n\nnamespace zisa {\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing = row_major>\n", "file_path": "include/zisa/memory/array_view_fwd.hpp", "rank": 27, "score": 73671.2240557667 }, { "content": " ANY_DEVICE_INLINE T &operator()(Ints... ints) const;\n\n\n\n ANY_DEVICE_INLINE T *begin() const;\n\n ANY_DEVICE_INLINE T *end() const;\n\n\n\n ANY_DEVICE_INLINE T const *cbegin() const;\n\n ANY_DEVICE_INLINE T const *cend() const;\n\n\n\n void copy_data(const array_view<T, n_dims, Indexing> &other) const;\n\n void copy_data(const array_const_view<T, n_dims, Indexing> &other) const;\n\n};\n\n\n\n#ifndef __CUDACC__\n\ntemplate <class T>\n\narray_view(std::vector<T> &v) -> array_view<T, 1, row_major>;\n\n#endif\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 28, "score": 73670.77993825519 }, { "content": "void save(HierarchicalWriter &writer,\n\n const array_const_view<T, n_dims, row_major> &arr,\n\n const std::string &tag,\n\n default_dispatch_tag) {\n\n\n\n T const *const data = arr.raw();\n\n const auto &shape = arr.shape();\n\n\n\n auto data_type = erase_data_type<T>();\n\n\n\n std::size_t dims[n_dims];\n\n for (int_t i = 0; i < n_dims; ++i) {\n\n dims[i] = shape(i); // size of (i, j, k) axes\n\n }\n\n\n\n writer.write_array(data, data_type, tag, n_dims, dims);\n\n}\n\n\n\ntemplate <class T, int n_dims>\n\nvoid save(HierarchicalWriter &writer,\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 29, "score": 73665.58092190858 }, { "content": " const array_const_view<T, n_dims, row_major> &arr,\n\n const std::string &tag,\n\n split_array_dispatch_tag) {\n\n\n\n using scalar_type = typename array_save_traits<T>::scalar_type;\n\n auto data_type = erase_data_type<scalar_type>();\n\n\n\n constexpr int_t rank = n_dims + 1;\n\n std::size_t dims[rank];\n\n for (int_t i = 0; i < rank - 1; ++i) {\n\n dims[i] = arr.shape(i);\n\n }\n\n dims[rank - 1] = T::size();\n\n\n\n writer.write_array(arr.raw(), data_type, tag, rank, dims);\n\n}\n\n\n\ntemplate <int n_dims>\n\nvoid save(HierarchicalWriter &writer,\n\n const array_const_view<bool, n_dims, row_major> &arr,\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 30, "score": 73665.28267335717 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n#ifndef ARRAY_VIEW_H_NPPW3\n\n#define ARRAY_VIEW_H_NPPW3\n\n\n\n#include <zisa/config.hpp>\n\n\n\n#include <zisa/io/hierarchical_writer.hpp>\n\n#include <zisa/memory/array_base.hpp>\n\n#include <zisa/memory/array_traits.hpp>\n\n#include <zisa/memory/array_view_fwd.hpp>\n\n#include <zisa/memory/column_major.hpp>\n\n#include <zisa/memory/contiguous_memory.hpp>\n\n#include <zisa/memory/copy.hpp>\n\n#include <zisa/memory/shape.hpp>\n\n#include <zisa/meta/add_const_if.hpp>\n\n#include <zisa/meta/if_t.hpp>\n\n\n\nnamespace zisa {\n\n\n\ntemplate <class T>\n", "file_path": "include/zisa/memory/array_view_decl.hpp", "rank": 31, "score": 73665.00729968806 }, { "content": "struct indexing_traits;\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/row_major.hpp", "rank": 32, "score": 73638.16692259753 }, { "content": "struct indexing_traits;\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/column_major.hpp", "rank": 33, "score": 73638.16692259755 }, { "content": "struct indexing_traits<row_major<3>> {\n\n static constexpr int_t n_dims = 3;\n\n};\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/row_major.hpp", "rank": 34, "score": 70262.80563461724 }, { "content": "struct indexing_traits<column_major<2>> {\n\n static constexpr int_t n_dims = 2;\n\n};\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/column_major.hpp", "rank": 35, "score": 70262.80563461724 }, { "content": "struct indexing_traits<row_major<1>> {\n\n static constexpr int_t n_dims = 1;\n\n};\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/row_major.hpp", "rank": 36, "score": 70262.80563461724 }, { "content": "struct indexing_traits<column_major<4>> {\n\n static constexpr int_t n_dims = 4;\n\n};\n\n\n\n} // namespace zisa\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/column_major.hpp", "rank": 37, "score": 70262.80563461724 }, { "content": "struct indexing_traits<column_major<1>> {\n\n static constexpr int_t n_dims = 1;\n\n};\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/column_major.hpp", "rank": 38, "score": 70262.80563461724 }, { "content": "struct indexing_traits<row_major<4>> {\n\n static constexpr int_t n_dims = 4;\n\n};\n\n\n\n} // namespace zisa\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/row_major.hpp", "rank": 39, "score": 70262.80563461724 }, { "content": "struct indexing_traits<row_major<2>> {\n\n static constexpr int_t n_dims = 2;\n\n};\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/row_major.hpp", "rank": 40, "score": 70262.80563461724 }, { "content": "struct indexing_traits<column_major<3>> {\n\n static constexpr int_t n_dims = 3;\n\n};\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/column_major.hpp", "rank": 41, "score": 70262.80563461724 }, { "content": "class allocator {\n\npublic:\n\n using value_type = T;\n\n using size_type = size_t;\n\n using pointer = T *;\n\n\n\npublic:\n\n allocator() : resource(make_memory_resource<T>(device_type::cpu)) {}\n\n allocator(device_type device) : resource(make_memory_resource<T>(device)) {}\n\n allocator(std::shared_ptr<memory_resource<T>> resource)\n\n : resource(std::move(resource)) {}\n\n allocator(const allocator &alloc) = default;\n\n allocator(allocator &&alloc) = default;\n\n\n\n inline pointer allocate(size_type n) { return resource->allocate(n); }\n\n inline void deallocate(pointer ptr, size_type n) {\n\n resource->deallocate(ptr, n);\n\n }\n\n\n\n template <class... Args>\n", "file_path": "include/zisa/memory/allocator.hpp", "rank": 42, "score": 65539.5362057976 }, { "content": "class memory_resource {\n\npublic:\n\n using value_type = T;\n\n using size_type = std::size_t;\n\n using pointer = T *;\n\n\n\npublic:\n\n virtual ~memory_resource() = default;\n\n\n\n inline pointer allocate(size_type n) { return do_allocate(n); }\n\n inline void deallocate(pointer ptr, size_type n) { do_deallocate(ptr, n); }\n\n\n\n inline device_type device() const { return do_device(); }\n\n\n\nprotected:\n\n virtual pointer do_allocate(size_type n) = 0;\n\n virtual void do_deallocate(pointer ptr, size_type n) = 0;\n\n\n\n virtual device_type do_device() const = 0;\n\n};\n\n\n\n} // namespace zisa\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/memory_resource.hpp", "rank": 43, "score": 63538.76986520287 }, { "content": "class block_allocator;\n\n\n\ntemplate <class T>\n", "file_path": "include/zisa/memory/block_allocator.hpp", "rank": 44, "score": 63538.76986520287 }, { "content": "class block_allocator\n\n : public std::enable_shared_from_this<block_allocator<T>> {\n\npublic:\n\n block_allocator(int_t max_elements) {\n\n free_list.reserve(max_elements);\n\n large_block.reserve(max_elements);\n\n }\n\n\n\n ~block_allocator() {\n\n for (auto &ptr : large_block) {\n\n delete ptr;\n\n }\n\n }\n\n\n\n template <class... Args>\n\n locked_ptr<T> allocate(Args &&...args) {\n\n auto [index, allocated] = acquire();\n\n\n\n if (!allocated) {\n\n large_block[index] = new T(std::forward<Args &&>(args)...);\n", "file_path": "include/zisa/memory/block_allocator.hpp", "rank": 45, "score": 63538.76986520287 }, { "content": "class HierarchicalFile {\n\npublic:\n\n using DataType = ErasedDataType;\n\n\n\npublic:\n\n virtual ~HierarchicalFile() = default;\n\n\n\n /// Open a group.\n\n void open_group(const std::string &group_name);\n\n\n\n /// Close a group.\n\n void close_group();\n\n\n\n /// Close the current group and open another group\n\n void switch_group(const std::string &group_name);\n\n\n\n /// Does this group exist in the file?\n\n bool group_exists(const std::string &group_name) const;\n\n\n\n /// Human readable description of the current hierarchy.\n", "file_path": "include/zisa/io/hierarchical_file.hpp", "rank": 46, "score": 63538.76986520287 }, { "content": "class HDF5Writer;\n", "file_path": "include/zisa/io/hdf5_writer_fwd.hpp", "rank": 47, "score": 62608.78207652447 }, { "content": "class HDF5DataType {\n\npublic:\n\n /// Initialize object.\n\n /** @param h5_type The H5 identifier of the data-type.\n\n * @param size Size in bytes of the data type.\n\n */\n\n HDF5DataType(const hid_t &h5_type, size_t size);\n\n\n\n virtual ~HDF5DataType();\n\n\n\n /// Return the HDF5 identifier of the data-type.\n\n hid_t operator()() const;\n\n\n\npublic:\n\n size_t size; ///< essentially, `sizeof(T)`\n\n\n\nprotected:\n\n hid_t h5_type;\n\n};\n\n\n", "file_path": "include/zisa/io/hdf5_file.hpp", "rank": 48, "score": 62608.78207652447 }, { "content": "class NetCDFFileStructure {\n\nprivate:\n\n using dim_t = std::tuple<std::string, std::size_t>;\n\n using vector_dims_t = std::vector<dim_t>;\n\n\n\n using var_t\n\n = std::tuple<std::string, std::vector<std::string>, ErasedDataType>;\n\n using vector_vars_t = std::vector<var_t>;\n\n\n\npublic:\n\n NetCDFFileStructure(const vector_dims_t &dims, const vector_vars_t &vars);\n\n\n\n /// Does the structure appear to be plausible?\n\n bool is_valid() const;\n\n\n\n const auto &dims() const;\n\n const auto &vars() const;\n\n\n\nprivate:\n\n void add_dim(const dim_t &dim);\n\n void add_dims(const vector_dims_t &dims);\n\n\n\n void add_vars(const vector_vars_t &vars);\n\n void add_var(const var_t &var);\n\n\n\nprivate:\n\n vector_dims_t dims_;\n\n vector_vars_t vars_;\n\n};\n\n\n", "file_path": "include/zisa/io/netcdf_file.hpp", "rank": 49, "score": 61721.42224711478 }, { "content": "class contiguous_memory_base {\n\npublic:\n\n using const_pointer =\n\n typename std::allocator_traits<Allocator>::const_pointer;\n\n using pointer = typename std::allocator_traits<Allocator>::pointer;\n\n using size_type = typename std::allocator_traits<Allocator>::size_type;\n\n\n\npublic:\n\n contiguous_memory_base()\n\n : _raw_data(nullptr), _n_elements(0), _allocator(nullptr) {}\n\n\n\n explicit contiguous_memory_base(size_type n_elements,\n\n const Allocator &allocator = Allocator());\n\n\n\n contiguous_memory_base(const contiguous_memory_base &other);\n\n contiguous_memory_base(contiguous_memory_base &&other) noexcept;\n\n\n\n ~contiguous_memory_base();\n\n\n\n contiguous_memory_base &operator=(const contiguous_memory_base &other);\n", "file_path": "include/zisa/memory/contiguous_memory_base_decl.hpp", "rank": 50, "score": 60873.82513015318 }, { "content": "enum class device_type {\n\n cpu, // CPU\n\n cuda, // NVIDIA GPU through CUDA\n\n unknown // If it's unclear where the memory resides.\n\n};\n\n\n\n} // namespace zisa\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/device_type.hpp", "rank": 51, "score": 60502.31721272063 }, { "content": "/// Read data from HDF5 file sequentially.\n\nclass HDF5SerialReader : public HDF5Reader {\n\nprivate:\n\n using super = HDF5Reader;\n\n\n\npublic:\n\n explicit HDF5SerialReader(const std::string &filename);\n\n\n\nprotected:\n\n virtual std::vector<hsize_t>\n\n do_hdf5_dims(const std::string &tag) const override;\n\n\n\n virtual void do_read_array(void *data,\n\n const HDF5DataType &data_type,\n\n const std::string &tag) const override;\n\n\n\n virtual void do_read_scalar(void *data,\n\n const HDF5DataType &data_type,\n\n const std::string &tag) const override;\n\n\n\n virtual std::string do_read_string(const std::string &tag) const override;\n", "file_path": "include/zisa/io/hdf5_serial_writer.hpp", "rank": 52, "score": 55416.115423788 }, { "content": "class HierarchicalWriter : public virtual HierarchicalFile {\n\npublic:\n\n /// Write a multi-dimensional array to an hierarchical file.\n\n /** @param data Raw pointer to the data.\n\n * @param data_type Data type identifier.\n\n * @param tag Name of the data field in the file.\n\n * @param rank Number of dimension of the array.\n\n * @param dims Size (number of elements) of each dimension.\n\n */\n\n void write_array(void const *data,\n\n const DataType &data_type,\n\n const std::string &tag,\n\n int rank,\n\n std::size_t const *dims);\n\n\n\n /// Write a scalar to an HDF5 file.\n\n /** @param data The scalar to be written to file.\n\n * @param tag Name of the scalar in the HDF5 file.\n\n */\n\n template <typename T>\n", "file_path": "include/zisa/io/hierarchical_writer.hpp", "rank": 53, "score": 54691.29915991804 }, { "content": "/// Read data from a hierarchical file.\n\nclass HierarchicalReader : public virtual HierarchicalFile {\n\npublic:\n\n /// Dimensions of the array named `tag`.\n\n std::vector<std::size_t> dims(const std::string &tag) const {\n\n return do_dims(tag);\n\n }\n\n\n\n /// Low-level function to read an array from disc into memory.\n\n /** Allocating (and managing) the memory, is job of the caller. One can\n\n * use `dims` to query the size of the array.\n\n *\n\n * @param[out] data allocated memory of sufficient size.\n\n * @param[in] data_type Erased data type of the data.\n\n * @param[in] tag Name of the array in the file.\n\n */\n\n void read_array(void *data,\n\n const DataType &data_type,\n\n const std::string &tag) const;\n\n\n\n /// Read a scalar from the hierarchical file.\n", "file_path": "include/zisa/io/hierarchical_reader.hpp", "rank": 54, "score": 54691.29915991804 }, { "content": "/// Representation of the current branch of the opened HDF5 file.\n\nclass HDF5File : public virtual HierarchicalFile {\n\npublic:\n\n virtual ~HDF5File() override;\n\n\n\nprotected:\n\n void do_open_group(const std::string &group_name) override;\n\n void do_close_group() override;\n\n void do_switch_group(const std::string &group_name) override;\n\n bool do_group_exists(const std::string &group_name) const override;\n\n std::string do_hierarchy() const override;\n\n void do_unlink(const std::string &tag) override {\n\n zisa::H5L::unlink(file.top(), tag.c_str(), H5P_DEFAULT);\n\n }\n\n\n\nprotected:\n\n hid_t open_dataset(const std::string &tag) const;\n\n hid_t get_dataspace(const hid_t &dataset) const;\n\n\n\nprotected:\n\n std::stack<hid_t> file; ///< HDF5 file/group identifiers (branch)\n\n std::vector<std::string> path; ///< HDF5 path\n\n};\n\n\n\n} // namespace zisa\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/io/hdf5_file.hpp", "rank": 55, "score": 54691.29915991804 }, { "content": "class NetCDFFile : public virtual HierarchicalFile {\n\npublic:\n\n NetCDFFile(const std::string &filename, const NetCDFFileStructure &structure);\n\n\n\n virtual ~NetCDFFile() override;\n\n\n\nprotected:\n\n virtual void do_open_group(const std::string & /* group_name */) override;\n\n virtual void do_close_group() override;\n\n virtual void do_switch_group(const std::string &group_name) override;\n\n\n\n virtual bool\n\n do_group_exists(const std::string & /* group_name */) const override;\n\n\n\n virtual std::string do_hierarchy() const override;\n\n virtual void do_unlink(const std::string &tag) override;\n\n\n\nprivate:\n\n std::vector<int>\n\n extract_dim_ids(const std::vector<std::string> &dim_names) const;\n", "file_path": "include/zisa/io/netcdf_file.hpp", "rank": 56, "score": 53915.609426131414 }, { "content": "class host_memory_resource : public memory_resource<T> {\n\nprivate:\n\n using super = memory_resource<T>;\n\n\n\npublic:\n\n using value_type = typename super::value_type;\n\n using size_type = typename super::size_type;\n\n using pointer = typename super::pointer;\n\n\n\nprotected:\n\n virtual inline pointer do_allocate(size_type n) override { return new T[n]; }\n\n\n\n virtual inline void do_deallocate(pointer ptr, size_type) override {\n\n delete[] ptr;\n\n }\n\n\n\n virtual inline device_type do_device() const override {\n\n return device_type::cpu;\n\n }\n\n};\n\n\n\ntemplate <class T>\n\ndevice_type memory_location(const host_memory_resource<T> &resource) {\n\n return resource.device();\n\n}\n\n\n\n} // namespace zisa\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/host_memory_resource.hpp", "rank": 57, "score": 53172.48928144148 }, { "content": "class NetCDFWriter : public virtual NetCDFFile,\n\n public virtual HierarchicalWriter {\n\n\n\npublic:\n\n using NetCDFFile::NetCDFFile;\n\n\n\nprotected:\n\n // Redirects `HierarchicalWriter::do_write_array` to the NetCDF\n\n // implementation.\n\n virtual void do_write_array(void const *data,\n\n const DataType & /* data_type */,\n\n const std::string &tag,\n\n int /* rank */,\n\n std::size_t const * /* dims */) override;\n\n\n\n // Redirects `HierarchicalWriter::do_write_array` to the NetCDF\n\n // implementation.\n\n virtual void do_write_scalar(void const *addr,\n\n const DataType & /* data_type */,\n\n const std::string &tag) override;\n", "file_path": "include/zisa/io/netcdf_writer.hpp", "rank": 58, "score": 53172.48928144148 }, { "content": "/// Write data to an HDF5 file, serial version.\n\nclass HDF5SerialWriter : public virtual HDF5Writer {\n\npublic:\n\n explicit HDF5SerialWriter(const std::string &filename);\n\n\n\nprotected:\n\n virtual void do_write_array(const void *data,\n\n const HDF5DataType &data_type,\n\n const std::string &tag,\n\n int rank,\n\n const hsize_t *dims) override;\n\n\n\n using HDF5Writer::do_write_scalar;\n\n\n\n virtual void do_write_scalar(const void *data,\n\n const HDF5DataType &data_type,\n\n const std::string &tag) override;\n\n\n\n virtual void do_write_string(const std::string &data,\n\n const std::string &tag) override;\n\n};\n\n\n", "file_path": "include/zisa/io/hdf5_serial_writer.hpp", "rank": 59, "score": 53172.48928144148 }, { "content": "class cuda_memory_resource : public memory_resource<T> {\n\nprivate:\n\n using super = memory_resource<T>;\n\n\n\npublic:\n\n using value_type = typename super::value_type;\n\n using size_type = typename super::size_type;\n\n using pointer = typename super::pointer;\n\n\n\nprotected:\n\n virtual inline pointer do_allocate(size_type n) override {\n\n pointer ptr = nullptr;\n\n\n\n auto cudaError = cudaMalloc(&ptr, n * sizeof(T));\n\n LOG_ERR_IF(cudaError != cudaSuccess, cuda_error_message(cudaError));\n\n\n\n return ptr;\n\n }\n\n\n\n virtual inline void do_deallocate(pointer ptr, size_type) override {\n", "file_path": "include/zisa/cuda/memory/cuda_memory_resource.hpp", "rank": 60, "score": 52459.92961173665 }, { "content": "class NetCDFSerialWriter : public virtual NetCDFWriter {\n\npublic:\n\n using NetCDFWriter::NetCDFWriter;\n\n\n\nprotected:\n\n virtual void do_write_array(void const *data,\n\n const std::string &tag) override;\n\n\n\n virtual void do_write_scalar(void const *addr,\n\n const std::string &tag) override;\n\n};\n\n\n\n}\n\n#endif /* end of include guard: NETCDF_SERIAL_WRITER_HPP_XWYKVGMU */\n", "file_path": "include/zisa/io/netcdf_serial_writer.hpp", "rank": 61, "score": 51776.08322128776 }, { "content": "struct shape_t {\n\npublic:\n\n ANY_DEVICE shape_t() noexcept {\n\n for (int k = 0; k < n_dims; ++k) {\n\n _raw_data[k] = 0;\n\n }\n\n }\n\n\n\n ANY_DEVICE shape_t(const shape_t &rhs) noexcept {\n\n for (int_t k = 0; k < n_dims; ++k) {\n\n _raw_data[k] = rhs[k];\n\n }\n\n }\n\n\n\n template <class... Ints,\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 62, "score": 50207.21106365196 }, { "content": "/// Interface for writing data to an HDF5 file.\n\nclass HDF5Writer : public virtual HDF5File, public virtual HierarchicalWriter {\n\nprotected:\n\n // Redirects `HierarchicalWriter::do_write_array` to the HDF5 implementation.\n\n virtual void do_write_array(void const *data,\n\n const DataType &data_type,\n\n const std::string &tag,\n\n int rank,\n\n std::size_t const *dims) override;\n\n\n\n // Redirects `HierarchicalWriter::do_write_array` to the HDF5 implementation.\n\n virtual void do_write_scalar(void const *addr,\n\n const DataType &data_type,\n\n const std::string &tag) override;\n\n\n\n // Provides the interface on in the HDF5 world which needs to be implemented.\n\n virtual void do_write_array(void const *data,\n\n const HDF5DataType &data_type,\n\n const std::string &tag,\n\n int rank,\n\n hsize_t const *dims)\n\n = 0;\n\n\n\n // Provides the interface on in the HDF5 world which needs to be implemented.\n\n virtual void do_write_scalar(void const *addr,\n\n const HDF5DataType &data_type,\n\n const std::string &tag)\n\n = 0;\n\n};\n\n\n", "file_path": "include/zisa/io/hdf5_writer.hpp", "rank": 63, "score": 48376.415629452895 }, { "content": "/// Read data from HDF5 file.\n\nclass HDF5Reader : public virtual HDF5File, public virtual HierarchicalReader {\n\nprivate:\n\n using super = HDF5File;\n\n\n\npublic:\n\nprotected:\n\n virtual std::vector<std::size_t>\n\n do_dims(const std::string &tag) const override;\n\n\n\n virtual std::vector<hsize_t> do_hdf5_dims(const std::string &tag) const = 0;\n\n\n\n // Translation from `HierarchicalReader::do_read_array` to HDF5Reader.\n\n virtual void do_read_array(void *data,\n\n const DataType &data_type,\n\n const std::string &tag) const override;\n\n\n\n // This is where the actual functionality is implemented.\n\n virtual void do_read_array(void *data,\n\n const HDF5DataType &data_type,\n\n const std::string &tag) const = 0;\n", "file_path": "include/zisa/io/hdf5_writer.hpp", "rank": 64, "score": 48376.415629452895 }, { "content": "struct array_traits {\n\n using pointer = typename Array::pointer;\n\n using const_pointer = typename Array::const_pointer;\n\n using size_type = typename Array::size_type;\n\n\n\n static inline device_type device(const Array &array) {\n\n return detail::memory_location_<Array>(array);\n\n }\n\n};\n\n\n", "file_path": "include/zisa/memory/array_traits.hpp", "rank": 65, "score": 46561.73975857017 }, { "content": "struct array_traits;\n\n\n\ntemplate <class T, class Indexing, class Array, class Shape>\n", "file_path": "include/zisa/memory/array_base_decl.hpp", "rank": 66, "score": 45816.71561680433 }, { "content": "struct array_save_traits {\n\n using dispatch_tag = default_dispatch_tag;\n\n using scalar_type = T;\n\n};\n\n\n\ntemplate <>\n", "file_path": "include/zisa/memory/array_traits.hpp", "rank": 67, "score": 45816.71561680433 }, { "content": "struct array_save_traits<bool> {\n\n using dispatch_tag = bool_dispatch_tag;\n\n using scalar_type = char;\n\n};\n\n\n\n} // namespace zisa\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array_traits.hpp", "rank": 68, "score": 45095.97204755124 }, { "content": "struct split_array_dispatch_tag {};\n", "file_path": "include/zisa/memory/array_traits.hpp", "rank": 69, "score": 45095.97204755124 }, { "content": " return s0 + (-i);\n\n}\n\n\n\ntemplate <int n_dims, class Int>\n\nANY_DEVICE_INLINE shape_t<n_dims, Int>\n\noperator-(int i, const shape_t<n_dims, Int> &s0) {\n\n return i + (-s0);\n\n}\n\n\n\ntemplate <int n_dims, class Int>\n\nANY_DEVICE_INLINE shape_t<n_dims, Int>\n\noperator-(const shape_t<n_dims, Int> &s0, const shape_t<n_dims, Int> &s1) {\n\n return s0 + (-s1);\n\n}\n\n\n\n} // namespace zisa\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 70, "score": 43391.145008664396 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n#ifndef SHAPE_H_2YNV5\n\n#define SHAPE_H_2YNV5\n\n\n\n#include <assert.h>\n\n#include <initializer_list>\n\n#include <iostream>\n\n\n\n#include <zisa/config.hpp>\n\n#include <zisa/meta/all_integral.hpp>\n\n#include <zisa/utils/integer_cast.hpp>\n\n\n\nnamespace zisa {\n\n\n\ntemplate <int n_dims, class Int = int_t>\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 71, "score": 43389.718123114435 }, { "content": " }\n\n\n\n return nml;\n\n}\n\n\n\ntemplate <int n, class Int>\n\nstd::ostream &operator<<(std::ostream &os, const shape_t<n, Int> &shape) {\n\n os << \"[\";\n\n for (int i = 0; i < n; ++i) {\n\n os << shape(Int(i)) << (i != n - 1 ? \", \" : \"]\");\n\n }\n\n\n\n return os;\n\n}\n\n\n\ntemplate <int n_dims, class Int>\n\nANY_DEVICE_INLINE shape_t<n_dims, Int> operator+(const shape_t<n_dims, Int> &s0,\n\n int i) {\n\n auto s = shape_t<n_dims, Int>();\n\n\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 72, "score": 43389.027397723585 }, { "content": " for (int k = 0; k < s0.size(); ++k) {\n\n s[k] = s0[k] + i;\n\n }\n\n\n\n return s;\n\n}\n\n\n\ntemplate <int n_dims, class Int>\n\nANY_DEVICE_INLINE shape_t<n_dims, Int>\n\noperator+(const shape_t<n_dims, Int> &s0, const shape_t<n_dims, Int> &s1) {\n\n auto s = shape_t<n_dims, Int>();\n\n\n\n for (int k = 0; k < s0.size(); ++k) {\n\n s[k] = s0[k] + s1[k];\n\n }\n\n\n\n return s;\n\n}\n\n\n\ntemplate <int n_dims, class Int>\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 73, "score": 43388.90506503444 }, { "content": "ANY_DEVICE_INLINE shape_t<n_dims, Int>\n\noperator+(int i, const shape_t<n_dims, Int> &s0) {\n\n return s0 + i;\n\n}\n\n\n\ntemplate <int n_dims, class Int>\n\nANY_DEVICE_INLINE shape_t<n_dims, Int>\n\noperator-(const shape_t<n_dims, Int> &s0) {\n\n auto s = shape_t<n_dims, Int>();\n\n\n\n for (int k = 0; k < s0.size(); ++k) {\n\n s[k] = -s0[k];\n\n }\n\n\n\n return s;\n\n}\n\n\n\ntemplate <int n_dims, class Int>\n\nANY_DEVICE_INLINE shape_t<n_dims, Int> operator-(const shape_t<n_dims, Int> &s0,\n\n int i) {\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 74, "score": 43388.659805834825 }, { "content": " static constexpr int_t size(void) { return n_dims; }\n\n\n\n ANY_DEVICE_INLINE\n\n shape_t<1> shape(void) const { return shape_t<1>{n_dims}; }\n\n\n\n ANY_DEVICE_INLINE\n\n Int const *raw() const { return _raw_data; }\n\n\n\n ANY_DEVICE_INLINE\n\n Int *raw() { return _raw_data; }\n\n\n\nprotected:\n\n Int _raw_data[n_dims];\n\n};\n\n\n\ntemplate <int n_dims, class Int>\n\nANY_DEVICE_INLINE Int product(const shape_t<n_dims, Int> &shape) {\n\n Int nml = 1;\n\n for (Int k = 0; k < n_dims; ++k) {\n\n nml *= shape[k];\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 75, "score": 43385.30049264159 }, { "content": " ANY_DEVICE_INLINE\n\n Int operator()(int_t dim) const { return (*this)[dim]; }\n\n\n\n ANY_DEVICE_INLINE\n\n Int &operator()(int_t dim) { return (*this)[dim]; }\n\n\n\n ANY_DEVICE_INLINE\n\n bool operator==(const shape_t &other) const {\n\n for (int_t i = 0; i < n_dims; ++i) {\n\n if ((*this)(i) != other(i))\n\n return false;\n\n }\n\n\n\n return true;\n\n }\n\n\n\n ANY_DEVICE_INLINE\n\n bool operator!=(const shape_t &other) const { return !((*this) == other); }\n\n\n\n ANY_DEVICE_INLINE\n", "file_path": "include/zisa/memory/shape.hpp", "rank": 76, "score": 43382.056785835215 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n#ifndef ARRAY_H_4L4PF\n\n#define ARRAY_H_4L4PF\n\n\n\n#include \"array_decl.hpp\"\n\n#include \"array_impl.hpp\"\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array.hpp", "rank": 77, "score": 41637.83799211554 }, { "content": "}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing>::array(\n\n const array_const_view<T, n_dims, Indexing> &other, device_type device)\n\n : array(other.shape(), device) {\n\n zisa::copy(*this, other);\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing> &array<T, n_dims, Indexing>::operator=(\n\n const array_const_view<T, n_dims, Indexing> &other) {\n\n\n\n if (this->shape() != other.shape()) {\n\n (*this) = array<T, n_dims, Indexing>(other.shape());\n\n }\n\n\n\n // It's pointing to *all* of this array.\n\n if (raw_ptr(*this) == raw_ptr(other)) {\n\n return *this;\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 78, "score": 40619.65831311679 }, { "content": "void copy(array<T, n_dims, Indexing> &dst,\n\n const array<T, n_dims, Indexing> &src) {\n\n\n\n return zisa::copy(array_view<T, n_dims, Indexing>(dst),\n\n array_const_view<T, n_dims, Indexing>(src));\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid copy(array<T, n_dims, Indexing> &dst,\n\n const array_view<T, n_dims, Indexing> &src) {\n\n return zisa::copy(array_view<T, n_dims, Indexing>(dst),\n\n array_const_view<T, n_dims, Indexing>(src));\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid copy(array<T, n_dims, Indexing> &dst,\n\n const array_const_view<T, n_dims, Indexing> &src) {\n\n return zisa::copy(array_view<T, n_dims, Indexing>(dst), src);\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid copy(const array_view<T, n_dims, Indexing> &dst,\n\n const array<T, n_dims, Indexing> &src) {\n\n return zisa::copy(dst, array_const_view<T, n_dims, Indexing>(src));\n\n}\n\n\n\n} // namespace zisa\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array_decl.hpp", "rank": 79, "score": 40616.18398313016 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n#ifndef ARRAY_IMPL_H_1WC9M\n\n#define ARRAY_IMPL_H_1WC9M\n\n\n\n#include \"zisa/memory/array_base.hpp\"\n\n#include \"zisa/memory/array_decl.hpp\"\n\n\n\nnamespace zisa {\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing>::array(T *raw_ptr, const shape_type &shape)\n\n : super(shape, contiguous_memory<T>(product(shape))) {\n\n\n\n auto n = product(shape);\n\n for (int_t i = 0; i < n; ++i) {\n\n (*this)[i] = raw_ptr[i];\n\n }\n\n}\n\n\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 80, "score": 40614.83301542653 }, { "content": "template <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing>::array(const shape_type &shape, device_type device)\n\n : super(shape, contiguous_memory<T>(product(shape), device)) {}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing>::array(const shape_type &shape,\n\n const allocator<T> &alloc)\n\n : super(shape, contiguous_memory<T>(product(shape), alloc)) {}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing>::array(\n\n const array_const_view<T, n_dims, Indexing> &other)\n\n : super(shape, contiguous_memory<T>(product(other.shape()))) {\n\n std::copy(other.begin(), other.end(), this->begin());\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing>::array(const array_view<T, n_dims, Indexing> &other)\n\n : super(shape, contiguous_memory<T>(product(other.shape()))) {\n\n std::copy(other.begin(), other.end(), this->begin());\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 81, "score": 40612.582794476 }, { "content": " }\n\n\n\n std::copy(other.begin(), other.end(), this->begin());\n\n\n\n return *this;\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing> &array<T, n_dims, Indexing>::operator=(\n\n const array_view<T, n_dims, Indexing> &other) {\n\n\n\n (*this) = array_const_view<T, n_dims, Indexing>(other);\n\n return *this;\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n\nvoid save(HierarchicalWriter &writer,\n\n const array<T, n_dims, Indexing> &arr,\n\n const std::string &tag) {\n\n\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 82, "score": 40609.83095719542 }, { "content": "\n\n};\n\n\n\nnamespace random {\n\ntemplate<class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing>\n\nuniform(const T &low, const T &high, const shape_t<n_dims> &shape, device_type device = device_type::cpu);\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing> empty_like(const array<T, n_dims, Indexing> &other) {\n\n return array<T, n_dims, Indexing>(other.shape());\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\nvoid save(HierarchicalWriter &writer,\n\n const array<T, n_dims, Indexing> &arr,\n\n const std::string &tag);\n\n\n\ntemplate <class T, int n_dims, template <int> class Indexing>\n", "file_path": "include/zisa/memory/array_decl.hpp", "rank": 83, "score": 40609.51422678842 }, { "content": " return arr;\n\n}\n\n\n\nnamespace random {\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n\narray<T, n_dims, Indexing> uniform(const T &low,\n\n const T &high,\n\n const shape_t<n_dims> &shape,\n\n device_type device) {\n\n LOG_ERR_IF(device != device_type::cpu, \"Implement first.\");\n\n static_assert(std::is_same<T, double>::value, \"Implement first.\");\n\n\n\n auto n = product(shape);\n\n auto x = array<T, n_dims, Indexing>(shape, device);\n\n\n\n std::random_device r;\n\n auto mt = std::mt19937(r());\n\n auto dist = std::uniform_real_distribution<T>(low, high);\n\n\n\n for (int_t i = 0; i < n; ++i) {\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 84, "score": 40609.366055819926 }, { "content": " explicit array(const shape_type &shape,\n\n device_type device = device_type::cpu);\n\n array(const shape_type &shape, const allocator<T> &alloc);\n\n\n\n array &operator=(const array &) = default;\n\n array &operator=(array &&) noexcept = default;\n\n\n\n array &operator=(const array_const_view<T, n_dims, Indexing> &);\n\n array &operator=(const array_view<T, n_dims, Indexing> &);\n\n\n\n array_view<T, n_dims, Indexing> view() {\n\n return array_view<T, n_dims, Indexing>(*this);\n\n }\n\n\n\n array_const_view<T, n_dims, Indexing> const_view() const {\n\n return array_const_view<T, n_dims, Indexing>(*this);\n\n }\n\n\n\n [[nodiscard]] static array<T, n_dims, row_major>\n\n load(HierarchicalReader &reader, const std::string &tag);\n", "file_path": "include/zisa/memory/array_decl.hpp", "rank": 85, "score": 40607.70885291023 }, { "content": "\n\ntemplate <class T, int n_dims, template <int N> class Indexing = row_major>\n\nusing array_super_\n\n = array_base<T,\n\n Indexing<n_dims>,\n\n contiguous_memory<T>,\n\n shape_t<n_dims, typename contiguous_memory<T>::size_type>>;\n\n\n\n} // namespace detail\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing = row_major>\n", "file_path": "include/zisa/memory/array_decl.hpp", "rank": 86, "score": 40607.70222303586 }, { "content": " auto datatype = erase_data_type<T>();\n\n reader.read_array(arr.raw(), datatype, tag);\n\n}\n\n\n\ntemplate <class T, int n_dims>\n\nvoid load_impl(HierarchicalReader &reader,\n\n array<T, n_dims, row_major> &arr,\n\n const std::string &tag,\n\n bool_dispatch_tag) {\n\n\n\n using scalar_type = typename array_save_traits<T>::scalar_type;\n\n auto datatype = erase_data_type<scalar_type>();\n\n\n\n auto int_arr = array<scalar_type, n_dims, row_major>(arr.shape());\n\n reader.read_array(int_arr.raw(), datatype, tag);\n\n\n\n std::copy(int_arr.cbegin(), int_arr.cend(), arr.begin());\n\n}\n\n\n\ntemplate <class T, int n_dims, template <int N> class Indexing>\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 87, "score": 40603.193517501764 }, { "content": "array<T, n_dims, row_major>\n\narray<T, n_dims, Indexing>::load(HierarchicalReader &reader,\n\n const std::string &tag) {\n\n\n\n static_assert(std::is_same<row_major<n_dims>, Indexing<n_dims>>::value,\n\n \"This has only been implemented for row-major index order.\");\n\n\n\n auto dims = reader.dims(tag);\n\n auto shape = shape_t<n_dims>{};\n\n\n\n // Some types T are stored as an array of fixed size. Such types may require\n\n // an additional dimension (at the end of `dims`).\n\n LOG_ERR_IF(dims.size() < n_dims, \"Dimension mismatch.\");\n\n for (int_t i = 0; i < n_dims; ++i) {\n\n shape[i] = dims[i];\n\n }\n\n\n\n auto arr = array<T, n_dims>(shape, device_type::cpu);\n\n load_impl(reader, arr, tag, typename array_save_traits<T>::dispatch_tag{});\n\n\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 88, "score": 40602.94481425956 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n#ifndef ARRAY_H_TH7WE\n\n#define ARRAY_H_TH7WE\n\n\n\n#include <zisa/config.hpp>\n\n\n\n#include <zisa/memory/array_base_decl.hpp>\n\n#include <zisa/memory/column_major.hpp>\n\n#include <zisa/memory/contiguous_memory.hpp>\n\n#include <zisa/memory/row_major.hpp>\n\n#include <zisa/memory/shape.hpp>\n\n\n\n#include <random>\n\n#include <zisa/memory/array_view.hpp>\n\n\n\nnamespace zisa {\n\n\n\nnamespace detail {\n", "file_path": "include/zisa/memory/array_decl.hpp", "rank": 89, "score": 40598.602752353436 }, { "content": " save(writer, arr.const_view(), tag);\n\n}\n\n\n\ntemplate <class T, int n_dims>\n\nvoid load_impl(HierarchicalReader &reader,\n\n array<T, n_dims, row_major> &arr,\n\n const std::string &tag,\n\n split_array_dispatch_tag) {\n\n\n\n using scalar_type = typename array_save_traits<T>::scalar_type;\n\n auto datatype = erase_data_type<scalar_type>();\n\n reader.read_array(arr.raw(), datatype, tag);\n\n}\n\n\n\ntemplate <class T, int n_dims>\n\nvoid load_impl(HierarchicalReader &reader,\n\n array<T, n_dims, row_major> &arr,\n\n const std::string &tag,\n\n default_dispatch_tag) {\n\n\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 90, "score": 40597.036459508585 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n/* Array traits.\n\n *\n\n */\n\n\n\n#ifndef ARRAY_TRAITS_H_8G39N\n\n#define ARRAY_TRAITS_H_8G39N\n\n\n\n#include <type_traits>\n\n#include <zisa/config.hpp>\n\n#include <zisa/memory/device_type.hpp>\n\n\n\nnamespace zisa {\n\n\n\nnamespace detail {\n\ntemplate <class A>\n\ndevice_type memory_location_(const A &) {\n\n return device_type::unknown;\n", "file_path": "include/zisa/memory/array_traits.hpp", "rank": 91, "score": 40595.96324458236 }, { "content": " x[i] = dist(mt);\n\n }\n\n\n\n return x;\n\n}\n\n}\n\n\n\n} // namespace zisa\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array_impl.hpp", "rank": 92, "score": 40590.02891593458 }, { "content": "}\n\n\n\ntemplate <class A>\n\ndevice_type memory_location_(\n\n const typename std::enable_if<\n\n std::is_same<decltype(std::declval<A>().device()), device_type>::value,\n\n A>::type &a) {\n\n return a.device();\n\n}\n\n}\n\n\n\ntemplate <class Array>\n", "file_path": "include/zisa/memory/array_traits.hpp", "rank": 93, "score": 40590.02145616482 }, { "content": "// SPDX-License-Identifier: MIT\n\n// Copyright (c) 2021 ETH Zurich, Luc Grosheintz-Laval\n\n\n\n#ifndef ARRAY_BASE_H_BQ44X\n\n#define ARRAY_BASE_H_BQ44X\n\n\n\n#include \"array_base_decl.hpp\"\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array_base.hpp", "rank": 94, "score": 40587.19539456684 }, { "content": "template <class T, class Indexing, class Array, class Shape>\n\nANY_DEVICE_INLINE auto shape(const array_base<T, Indexing, Array, Shape> &a)\n\n -> decltype(a.shape()) {\n\n return a.shape();\n\n}\n\n\n\n} // namespace zisa\n\n\n\n#endif /* end of include guard */\n", "file_path": "include/zisa/memory/array_base_decl.hpp", "rank": 95, "score": 39612.71101415685 }, { "content": "}\n\n\n\ntemplate <class T, class Indexing, class Array, class Shape>\n\nANY_DEVICE_INLINE auto raw_ptr(array_base<T, Indexing, Array, Shape> &a)\n\n -> decltype(a.raw()) {\n\n return a.raw();\n\n}\n\n\n\ntemplate <class T, class Indexing, class Array, class Shape>\n\nANY_DEVICE_INLINE auto raw_ptr(const array_base<T, Indexing, Array, Shape> &a)\n\n -> decltype(a.raw()) {\n\n return a.raw();\n\n}\n\n\n\ntemplate <class T, class Indexing, class Array, class Shape>\n\nANY_DEVICE_INLINE auto shape(array_base<T, Indexing, Array, Shape> &a)\n\n -> decltype(a.shape()) {\n\n return a.shape();\n\n}\n\n\n", "file_path": "include/zisa/memory/array_base_decl.hpp", "rank": 96, "score": 39612.445218263165 }, { "content": "}\n\n\n\n#endif\n\n\n\nTEST_CASE(\"array; builds for general Indexing.\", \"[array]\") {\n\n\n\n // The point is to check that `array<double, 3, Indexing>`\n\n // compiles fine. Despite the fact that `save` and `load` only\n\n // work if `Indexing == row_major`.\n\n\n\n auto shape = zisa::shape_t<3>{3ul, 4ul, 2ul};\n\n\n\n auto a = array<double, 3, column_major>(shape);\n\n for (zisa::int_t i = 0; i < a.size(); ++i) {\n\n a[i] = double(i);\n\n }\n\n}\n\n\n\n#if ZISA_HAS_CUDA\n\n\n", "file_path": "test/zisa/unit_test/memory/array.cpp", "rank": 97, "score": 39609.80355548552 }, { "content": " template <class... Ints>\n\n ANY_DEVICE_INLINE const T &operator()(Ints... ints) const {\n\n auto l = Indexing::linear_index(shape(), integer_cast<size_type>(ints)...);\n\n return (*this)[l];\n\n }\n\n\n\n ANY_DEVICE_INLINE const shape_type &shape() const { return _shape; }\n\n ANY_DEVICE_INLINE size_type shape(size_type k) const { return _shape[k]; }\n\n ANY_DEVICE_INLINE size_type size() const { return product(_shape); }\n\n\n\n ANY_DEVICE_INLINE pointer raw() { return raw_ptr(_array); }\n\n ANY_DEVICE_INLINE const_pointer raw() const { return raw_ptr(_array); }\n\n\n\n ANY_DEVICE_INLINE pointer begin() { return _array.begin(); }\n\n ANY_DEVICE_INLINE const_pointer begin() const { return _array.begin(); }\n\n ANY_DEVICE_INLINE const_pointer cbegin() const { return _array.cbegin(); }\n\n\n\n ANY_DEVICE_INLINE pointer end() { return _array.end(); }\n\n ANY_DEVICE_INLINE const_pointer end() const { return _array.end(); }\n\n ANY_DEVICE_INLINE const_pointer cend() const { return _array.cend(); }\n", "file_path": "include/zisa/memory/array_base_decl.hpp", "rank": 98, "score": 39608.91579147159 }, { "content": "\n\n inline device_type device() const {\n\n return array_traits<Array>::device(_array);\n\n }\n\n\n\nprivate:\n\n Shape _shape;\n\n Array _array;\n\n};\n\n\n\ntemplate <class T, class Indexing, class Array, class Shape>\n\ndevice_type memory_location(const array_base<T, Indexing, Array, Shape> &arr) {\n\n return arr.device();\n\n}\n\n\n\ntemplate <class T, class Indexing, class Array, class Shape>\n\nvoid fill(array_base<T, Indexing, Array, Shape> &arr, const T &value) {\n\n // TODO move to a library call of some sort.\n\n int_t n = arr.size();\n\n for (int_t i = 0; i < n; ++i) {\n", "file_path": "include/zisa/memory/array_base_decl.hpp", "rank": 99, "score": 39607.47349803096 } ]
C++
src/developer/debug/unwinder/dwarf_cfi.cc
lalrochhara/fuchsia
f56c62fa108cfd72b8034eeddb4e403f1f69fdbd
#include "src/developer/debug/unwinder/dwarf_cfi.h" #include <algorithm> #include <cinttypes> #include <cstdint> #include <map> #include <string> #include "src/developer/debug/unwinder/dwarf_cfi_parser.h" #include "third_party/crashpad/third_party/glibc/elf/elf.h" namespace unwinder { namespace { struct DwarfCie { uint64_t code_alignment_factor = 0; int64_t data_alignment_factor = 0; RegisterID return_address_register; bool fde_have_augmentation_data = false; uint8_t fde_address_encoding = 0xFF; uint64_t instructions_begin = 0; uint64_t instructions_end = 0; }; struct DwarfFde { uint64_t pc_begin = 0; uint64_t pc_end = 0; uint64_t instructions_begin = 0; uint64_t instructions_end = 0; }; [[nodiscard]] Error DecodeTableEntrySize(uint8_t table_enc, uint64_t& res) { if (table_enc == 0xFF) { return Error("no binary search table"); } if ((table_enc & 0xF0) != 0x30) { return Error("invalid table_enc"); } switch (table_enc & 0x0F) { case 0x02: case 0x0A: res = 4; return Success(); case 0x03: case 0x0B: res = 8; return Success(); case 0x04: case 0x0C: res = 16; return Success(); default: return Error("unsupported table_enc: %#x", table_enc); } } [[nodiscard]] Error DecodeLength(Memory* memory, uint64_t& ptr, uint64_t& length) { uint32_t short_length; if (auto err = memory->Read(ptr, short_length); err.has_err()) { return err; } if (short_length == 0) { return Error("not a valid CIE/FDE"); } if (short_length == 0xFFFFFFFF) { if (auto err = memory->Read(ptr, length); err.has_err()) { return err; } } else { length = short_length; } return Success(); } [[nodiscard]] Error DecodeCIE(Memory* memory, uint64_t cie_ptr, DwarfCie& cie) { uint64_t length; if (auto err = DecodeLength(memory, cie_ptr, length); err.has_err()) { return err; } cie.instructions_end = cie_ptr + length; uint32_t cie_id; if (auto err = memory->Read(cie_ptr, cie_id); err.has_err()) { return err; } if (cie_id) { return Error("not a valid CIE"); } uint8_t version; if (auto err = memory->Read(cie_ptr, version); err.has_err()) { return err; } if (version != 1) { return Error("unsupported CIE version: %d", version); } std::string augmentation_string; while (true) { char ch; if (auto err = memory->Read(cie_ptr, ch); err.has_err()) { return err; } if (ch) { augmentation_string.push_back(ch); } else { break; } } if (auto err = memory->ReadULEB128(cie_ptr, cie.code_alignment_factor); err.has_err()) { return err; } if (auto err = memory->ReadSLEB128(cie_ptr, cie.data_alignment_factor); err.has_err()) { return err; } if (auto err = memory->Read(cie_ptr, cie.return_address_register); err.has_err()) { return err; } if (augmentation_string.empty()) { cie.instructions_begin = cie_ptr; cie.fde_have_augmentation_data = false; } else { if (augmentation_string[0] != 'z') { return Error("invalid augmentation string: %s", augmentation_string.c_str()); } uint64_t augmentation_length; if (auto err = memory->ReadULEB128(cie_ptr, augmentation_length); err.has_err()) { return err; } cie.instructions_begin = cie_ptr + augmentation_length; cie.fde_have_augmentation_data = true; for (char ch : augmentation_string) { switch (ch) { case 'L': uint8_t lsda_encoding; if (auto err = memory->Read(cie_ptr, lsda_encoding); err.has_err()) { return err; } break; case 'P': uint8_t enc; if (auto err = memory->Read(cie_ptr, enc); err.has_err()) { return err; } uint64_t personality; if (auto err = memory->ReadEncoded(cie_ptr, personality, enc, 0); err.has_err()) { return err; } break; case 'R': if (auto err = memory->Read(cie_ptr, cie.fde_address_encoding); err.has_err()) { return err; } break; } } } return Success(); } [[nodiscard]] Error DecodeFDE(Memory* memory, uint64_t fde_ptr, DwarfFde& fde, DwarfCie& cie) { uint64_t length; if (auto err = DecodeLength(memory, fde_ptr, length); err.has_err()) { return err; } fde.instructions_end = fde_ptr + length; uint32_t cie_offset; if (auto err = memory->Read(fde_ptr, cie_offset); err.has_err()) { return err; } if (auto err = DecodeCIE(memory, fde_ptr - 4 - cie_offset, cie); err.has_err()) { return err; } if (auto err = memory->ReadEncoded(fde_ptr, fde.pc_begin, cie.fde_address_encoding); err.has_err()) { return err; } if (auto err = memory->ReadEncoded(fde_ptr, fde.pc_end, cie.fde_address_encoding & 0x0F); err.has_err()) { return err; } fde.pc_end += fde.pc_begin; if (cie.fde_have_augmentation_data) { uint64_t augmentation_length; if (auto err = memory->ReadULEB128(fde_ptr, augmentation_length); err.has_err()) { return err; } fde_ptr += augmentation_length; } fde.instructions_begin = fde_ptr; return Success(); } } Error DwarfCfi::Load(Memory* elf, uint64_t elf_ptr) { Elf64_Ehdr ehdr; if (auto err = elf->Read(+elf_ptr, ehdr); err.has_err()) { return err; } if (strncmp(reinterpret_cast<const char*>(ehdr.e_ident), ELFMAG, SELFMAG) != 0) { return Error("not an ELF image"); } eh_frame_hdr_ptr_ = 0; pc_begin_ = -1; pc_end_ = 0; for (uint64_t i = 0; i < ehdr.e_phnum; i++) { Elf64_Phdr phdr; if (auto err = elf->Read(elf_ptr + ehdr.e_phoff + ehdr.e_phentsize * i, phdr); err.has_err()) { return err; } if (phdr.p_type == PT_GNU_EH_FRAME) { eh_frame_hdr_ptr_ = elf_ptr + phdr.p_vaddr; } else if (phdr.p_type == PT_LOAD && phdr.p_flags & PF_X) { pc_begin_ = std::min(pc_begin_, elf_ptr + phdr.p_vaddr); pc_end_ = std::max(pc_end_, elf_ptr + phdr.p_vaddr + phdr.p_memsz); } } if (!eh_frame_hdr_ptr_) { return Error("no PT_GNU_EH_FRAME segment"); } auto p = eh_frame_hdr_ptr_; uint8_t version; if (auto err = elf->Read(p, version); err.has_err()) { return err; } if (version != 1) { return Error("unknown eh_frame_hdr version %d", version); } uint8_t eh_frame_ptr_enc; uint8_t fde_count_enc; uint64_t eh_frame_ptr; if (auto err = elf->Read<uint8_t>(p, eh_frame_ptr_enc); err.has_err()) { return err; } if (auto err = elf->Read<uint8_t>(p, fde_count_enc); err.has_err()) { return err; } if (auto err = elf->Read<uint8_t>(p, table_enc_); err.has_err()) { return err; } if (auto err = DecodeTableEntrySize(table_enc_, table_entry_size_); err.has_err()) { return err; } if (auto err = elf->ReadEncoded(p, eh_frame_ptr, eh_frame_ptr_enc, eh_frame_hdr_ptr_); err.has_err()) { return err; } if (auto err = elf->ReadEncoded(p, fde_count_, fde_count_enc, eh_frame_hdr_ptr_); err.has_err()) { return err; } table_ptr_ = p; if (fde_count_ == 0) { return Error("empty binary search table"); } elf_ = elf; return Success(); } Error DwarfCfi::Step(Memory* stack, const Registers& current, Registers& next) { uint64_t pc; if (auto err = current.GetPC(pc); err.has_err()) { return err; } if (pc < pc_begin_ || pc >= pc_end_) { return Error("pc %#" PRIx64 " is outside of the executable area", pc); } uint64_t low = 0; uint64_t high = fde_count_; while (low + 1 < high) { uint64_t mid = (low + high) / 2; uint64_t addr = table_ptr_ + mid * table_entry_size_; uint64_t mid_pc; if (auto err = elf_->ReadEncoded(addr, mid_pc, table_enc_, eh_frame_hdr_ptr_); err.has_err()) { return err; } if (pc < mid_pc) { high = mid; } else { low = mid; } } uint64_t addr = table_ptr_ + low * table_entry_size_ + table_entry_size_ / 2; uint64_t fde_ptr; if (auto err = elf_->ReadEncoded(addr, fde_ptr, table_enc_, eh_frame_hdr_ptr_); err.has_err()) { return err; } DwarfCie cie; DwarfFde fde; if (auto err = DecodeFDE(elf_, fde_ptr, fde, cie); err.has_err()) { return err; } if (pc < fde.pc_begin || pc >= fde.pc_end) { return Error("cannot find FDE for pc %#" PRIx64, pc); } DwarfCfiParser cfi_parser(current.arch()); if (auto err = cfi_parser.ParseInstructions(elf_, cie.code_alignment_factor, cie.data_alignment_factor, cie.instructions_begin, cie.instructions_end, -1); err.has_err()) { return err; } cfi_parser.Snapshot(); if (auto err = cfi_parser.ParseInstructions(elf_, cie.code_alignment_factor, cie.data_alignment_factor, fde.instructions_begin, fde.instructions_end, pc - fde.pc_begin); err.has_err()) { return err; } if (auto err = cfi_parser.Step(stack, cie.return_address_register, current, next); err.has_err()) { return err; } return Success(); } }
#include "src/developer/debug/unwinder/dwarf_cfi.h" #include <algorithm> #include <cinttypes> #include <cstdint> #include <map> #include <string> #include "src/developer/debug/unwinder/dwarf_cfi_parser.h" #include "third_party/crashpad/third_party/glibc/elf/elf.h" namespace unwinder { namespace { struct DwarfCie { uint64_t code_alignment_factor = 0; int64_t data_alignment_factor = 0; RegisterID return_address_register; bool fde_have_augmentation_data = false; uint8_t fde_address_encoding = 0xFF; uint64_t instructions_begin = 0; uint64_t instructions_end = 0; }; struct DwarfFde { uint64_t pc_begin = 0; uint64_t pc_end = 0; uint64_t instructions_begin = 0; uint64_t instructions_end = 0; }; [[nodiscard]] Error DecodeTableEntrySize(uint8_t table_enc, uint64_t& res) { if (table_enc == 0xFF) { return Error("no binary search table"); } if ((table_enc & 0xF0) != 0x30) { return Error("invalid table_enc"); } switch (table_enc & 0x0F) { case 0x02: case 0x0A: res = 4; return Success(); case 0x03: case 0x0B: res = 8; return Success(); case 0x04: case 0x0C: res = 16; return Success(); default: return Error("unsupported table_enc: %#x", table_enc); } } [[nodiscard]] Error DecodeLength(Memory* memory, uint64_t& ptr, uint64_t& length) { uint32_t short_length; if (auto err = memory->Read(ptr, short_length); err.has_err()) { return err; } if (short_length == 0) { return Error("not a valid CIE/FDE"); } if (short_length == 0xFFFFFFFF) { if (auto err = memory->Read(ptr, length); err.has_err()) { return err; } } else { length = short_length; } return Success(); } [[nodiscard]] Error DecodeCIE(Memory* memory, uint64_t cie_ptr, DwarfCie& cie) { uint64_t length; if (auto err = DecodeLength(memory, cie_ptr, length); err.has_err()) { return err; } cie.instructions_end = cie_ptr + length; uint32_t cie_id; if (auto err = memory->Read(cie_ptr, cie_id); err.has_err()) { return err; } if (cie_id) { return Error("not a valid CIE"); } uint8_t version; if (auto err = memory->Read(cie_ptr, version); err.has_err()) { return err; } if (version != 1) { return Error("unsupported CIE version: %d", version); } std::string augmentation_string; while (true) { char ch; if (auto err = memory->Read(cie_ptr, ch); err.has_err()) { return err; } if (ch) { augmentation_string.push_back(ch); } else { break; } } if (auto err = memory->ReadULEB128(cie_ptr, cie.code_alignment_factor); err.has_err()) { return err; } if (auto err = memory->ReadSLEB128(cie_ptr, cie.data_alignment_factor); err.has_err()) { return err; } if (auto err = memory->Read(cie_ptr, cie.return_address_register); err.has_err()) { return err; } if (augmentation_string.empty()) { cie.instructions_begin = cie_ptr; cie.fde_have_augmentation_data = false; } else { if (augmentation_string[0] != 'z') { return Error("invalid augmentation string: %s", augmentation_string.c_str()); } uint64_t augmentation_length; if (auto err = memory->ReadULEB128(cie_ptr, augmentation_length); err.has_err()) { return err; } cie.instructions_begin = cie_ptr + augmentation_length; cie.fde_have_augmentation_data = true; for (char ch : augmentation_string) { switch (ch) { case 'L': uint8_t lsda_encoding; if (auto err = memory->Read(cie_ptr, lsda_encoding); err.has_err()) { return err; } break; case 'P': uint8_t enc; if (auto err = memory->Read(cie_ptr, enc); err.has_err()) { return err; } uint64_t personality; if (auto err = memory->ReadEncoded(cie_ptr, personality, enc, 0); err.has_err()) { return err; } break; case 'R': if (auto err = memory->Read(cie_ptr, cie.fde_address_encoding); err.has_err()) { return err; } break; } } } return Success(); } [[nodiscard]] Error DecodeFDE(Memory* memory, uint64_t fde_ptr, DwarfFde& fde, DwarfCie& cie) { uint64_t length; if (auto err = DecodeLength(memory, fde_ptr, length); err.has_err()) { return err; } fde.instructions_end = fde_ptr + length; uint32_t cie_offset; if (auto err = memory->Read(fde_ptr, cie_offset); err.has_err()) { return err; } if (auto err = DecodeCIE(memory, fde_ptr - 4 - cie_offset, cie); err.has_err()) { return err; } if (auto err = memory->ReadEncoded(fde_ptr, fde.pc_begin, cie.fde_address_encoding); err.has_err()) { return err; } if (auto err = memory->ReadEncoded(fde_ptr, fde.pc_end, cie.fde_address_encoding & 0x0F); err.has_err()) { return err; } fde.pc_end += fde.pc_begin; if (cie.fde_have_augmentation_data) { uint64_t augmentation_length; if (auto err = memory->ReadULEB128(fde_ptr, augmentation_length); err.has_err()) { return err; } fde_ptr += augmentation_length; } fde.instructions_begin = fde_ptr; return Success(); } } Error DwarfCfi::Load(Memory* elf, uint64_t elf_ptr) { Elf64_Ehdr ehdr; if (auto err = elf->Read(+elf_ptr, ehdr); err.has_err()) { return err; } if (strncmp(reinterpret_cast<const char*>(ehdr.e_ident), ELFMAG, SELFMAG) != 0) { return Error("not an ELF image"); } eh_frame_hdr_ptr_ = 0; pc_begin_ = -1; pc_end_ = 0; for (uint64_t i = 0; i < ehdr.e_phnum; i++) { Elf64_Phdr phdr; if (auto err = elf->Read(elf_ptr + ehdr.e_phoff + ehdr.e_phentsize * i, phdr); err.has_err()) { return err; } if (phdr.p_type == PT_GNU_EH_FRAME) { eh_frame_hdr_ptr_ = elf_ptr + phdr.p_vaddr; } else if (phdr.p_type == PT_LOAD && phdr.p_flags & PF_X) { pc_begin_ = std::min(pc_begin_, elf_ptr + phdr.p_vaddr); pc_end_ = std::max(pc_end_, elf_ptr + phdr.p_vaddr + phdr.p_memsz); } } if (!eh_frame_hdr_ptr_) { return Error("no PT_GNU_EH_FRAME segment"); } auto p = eh_frame_hdr_ptr_; uint8_t version; if (auto err = elf->Read(p, version); err.has_err()) { return err; } if (version != 1) { return Error("unknown eh_frame_hdr version %d", version); } uint8_t eh_frame_ptr_enc; uint8_t fde_count_enc; uint64_t eh_frame_ptr; if (auto err = elf->Read<uint8_t>(p, eh_frame_ptr_enc); err.has_err()) { return err; } if (auto err = elf->Read<uint8_t>(p, fde_count_enc); err.has_err()) { return err; } if (auto err = elf->Read<uint8_t>(p, table_enc_); err.has_err()) { return err; } if (auto err = DecodeTableEntrySize(table_enc_, table_entry_size_); err.has_err()) { return err; } if (auto err = elf->ReadEncoded(p, eh_frame_ptr, eh_frame_ptr_enc, eh_frame_hdr_ptr_); err.has_err()) { return err; } if (auto err = elf->ReadEncoded(p, fde_count_, fde_count_enc, eh_frame_hdr_ptr_); err.has_err()) { return err; } table_ptr_ = p; if (fde_count_ == 0) { return Error("empty binary search table"); } elf_ = elf; return Success(); } Error DwarfCfi::Step(Memory* stack, const Registers& current, Registers& next) { uint64_t pc; if (auto err = current.GetPC(pc); err.has_err()) { return err; } if (pc < pc_begin_ || pc >= pc_end_) { return Error("pc %#" PRIx64 " is outside of the executable area", pc); } uint64_t low = 0; uint64_t high = fde_count_; while (low + 1 < high) { uint64_t mid = (low + high) / 2; uint64_t addr = table_ptr_ + mid * table_entry_size_; uint64_t mid_pc; if (auto err = elf_->ReadEncoded(addr, mid_pc, table_enc_, eh_frame_hdr_ptr_); err.has_err()) { return err; } if (pc < mid_pc) { high = mid; } else { low = mid; } } uint64_t addr = table_ptr_ + low * table_entry_size_ + table_entry_size_ / 2; uint64_t fde_ptr; if (auto err = elf_->ReadEncoded(addr, fde_ptr, table_enc_, eh_frame_hdr_ptr_); err.has_err()) { return err; } DwarfCie cie; DwarfFde fde; if (auto err = DecodeFDE(elf_, fde_ptr, fde, cie); err.has_err()) { return err; } if (pc < fde.pc_begin || pc >= fde.pc_end) { return Error("cannot find FDE for pc %#" PRIx64, pc); } DwarfCfiParser cfi_parser(current.arch());
cfi_parser.Snapshot(); if (auto err = cfi_parser.ParseInstructions(elf_, cie.code_alignment_factor, cie.data_alignment_factor, fde.instructions_begin, fde.instructions_end, pc - fde.pc_begin); err.has_err()) { return err; } if (auto err = cfi_parser.Step(stack, cie.return_address_register, current, next); err.has_err()) { return err; } return Success(); } }
if (auto err = cfi_parser.ParseInstructions(elf_, cie.code_alignment_factor, cie.data_alignment_factor, cie.instructions_begin, cie.instructions_end, -1); err.has_err()) { return err; }
if_condition
[]
C++
Code/trunk/cpp/Geometry/CartesianMesh/CartesianMesh_base.hh
jlconlin/PhDThesis
8e704613721a800ce1c59576e94f40fa6f7cd986
#ifndef CARTESIANMESH_BASE_HH #define CARTESIANMESH_BASE_HH #include <boost/ptr_container/ptr_vector.hpp> #include "Types.hh" #include "Dimension.hh" #include "GeomId.hh" #include "MeshTraits.hh" #include "Assert.hh" #include "GeometricElementConcept.hh" using boost::ptr_vector; template<typename dimension_type, typename geom_elem> inline typename CartesianMesh<dimension_type>::SizeType numCentering(const CartesianMesh<dimension_type>& mesh); template<typename dimension_type> class CartesianMesh_base : public MeshTraits<dimension_type>, boost::noncopyable { private: BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept); public: typedef dimension_type DimensionType; typedef MeshTraits<DimensionType> Base; public: typename Base::LengthType length() const { return mLength; } typename Base::SizeType numZones() const { return mZones.size() + numGhostZones(); } typename Base::SizeType numNodes() const { return mNodes.size() + numGhostNodes(); } typename Base::SizeType numCorners() const { return mCorners.size() + numGhostCorners(); } typename Base::SizeType numGhostZones() const { if(mGhostZones == 0) return 0; else return mGhostZones->size(); } typename Base::SizeType numGhostNodes() const { if(mGhostNodes == 0) return 0; else return mGhostNodes->size(); } typename Base::SizeType numGhostCorners() const { if(mGhostCorners == 0) return 0; else return mGhostCorners->size(); } typename Base::ZoneIterator zoneBegin() { return typename Base::ZoneIterator( mZones, mZones.begin() ); } typename Base::ZoneIterator zoneEnd() { return typename Base::ZoneIterator( mZones, mZones.end() ); } typename Base::const_ZoneIterator zoneBegin() const { return typename Base::const_ZoneIterator( mZones, mZones.begin() ); } typename Base::const_ZoneIterator zoneEnd() const { return typename Base::const_ZoneIterator(mZones, mZones.end()); } typename Base::NodeIterator nodeBegin() { return typename Base::NodeIterator( mNodes, mNodes.begin() ); } typename Base::NodeIterator nodeEnd() { return typename Base::NodeIterator( mNodes, mNodes.end() ); } typename Base::const_NodeIterator nodeBegin() const { return typename Base::const_NodeIterator( mNodes, mNodes.begin() ); } typename Base::const_NodeIterator nodeEnd() const { return typename Base::const_NodeIterator( mNodes, mNodes.end() ); } typename Base::CornerIterator cornerBegin() { return typename Base::CornerIterator( mCorners, mCorners.begin() ); } typename Base::CornerIterator cornerEnd() { return typename Base::CornerIterator( mCorners, mCorners.end() ); } typename Base::const_CornerIterator cornerBegin() const { return typename Base::const_CornerIterator( mCorners, mCorners.begin() ); } typename Base::const_CornerIterator cornerEnd() const { return typename Base::const_CornerIterator( mCorners, mCorners.end() ); } typename Base::reverse_ZoneIterator zoneRBegin() { return typename Base::reverse_ZoneIterator( zoneEnd() ); } typename Base::reverse_ZoneIterator zoneREnd() { return typename Base::reverse_ZoneIterator( zoneBegin() ); } typename Base::const_reverse_ZoneIterator zoneRBegin() const { return typename Base::const_reverse_ZoneIterator( zoneEnd() ); } typename Base::const_reverse_ZoneIterator zoneREnd() const { return typename Base::const_reverse_ZoneIterator( zoneBegin() ); } typename Base::reverse_NodeIterator nodeRBegin() { return typename Base::reverse_NodeIterator( nodeEnd() ); } typename Base::reverse_NodeIterator nodeREnd() { return typename Base::reverse_NodeIterator( nodeBegin() ); } typename Base::const_reverse_NodeIterator nodeRBegin() const { return typename Base::const_reverse_NodeIterator( nodeEnd() ); } typename Base::const_reverse_NodeIterator nodeREnd() const { return typename Base::const_reverse_NodeIterator( nodeBegin() ); } typename Base::reverse_CornerIterator cornerRBegin() { return typename Base::reverse_CornerIterator( cornerEnd() ); } typename Base::reverse_CornerIterator cornerREnd() { return typename Base::reverse_CornerIterator( cornerBegin() ); } typename Base::const_reverse_CornerIterator cornerRBegin() const { return typename Base::const_reverse_CornerIterator( cornerEnd() ); } typename Base::const_reverse_CornerIterator cornerREnd() const { return typename Base::const_reverse_CornerIterator( cornerBegin() ); } protected: CartesianMesh_base(typename Base::LengthType length_in, typename Base::SizeType num_zones, typename Base::SizeType num_nodes, typename Base::SizeType num_corners, typename Base::SizeType num_ghost_zones, typename Base::SizeType num_ghost_nodes, typename Base::SizeType num_ghost_corners) : mLength(length_in), mZones(num_zones), mNodes(num_nodes), mCorners(num_corners), mGhostZones(0), mGhostNodes(0), mGhostCorners(0) { if(num_ghost_zones != 0) { mGhostZones = new ptr_vector<typename Base::GhostZone>(num_ghost_zones); } if(num_ghost_nodes != 0) { mGhostNodes = new ptr_vector<typename Base::GhostNode>(num_ghost_nodes); } if(num_ghost_corners != 0) { mGhostCorners = new ptr_vector<typename Base::GhostCorner>(num_ghost_corners); } } ~CartesianMesh_base() { if(mGhostZones != 0) { delete mGhostZones; } if(mGhostNodes != 0) { delete mGhostNodes; } if(mGhostCorners != 0) { delete mGhostCorners; } } typename Base::LengthType mLength; ptr_vector<typename Base::Zone> mZones; ptr_vector<typename Base::Node> mNodes; ptr_vector<typename Base::Corner> mCorners; ptr_vector<typename Base::GhostZone>* mGhostZones; ptr_vector<typename Base::GhostNode>* mGhostNodes; ptr_vector<typename Base::GhostCorner>* mGhostCorners; private: CartesianMesh_base(); }; template<typename dimension_type> class CartesianMesh : CartesianMesh_base<dimension_type>, boost::noncopyable { private: CartesianMesh(); }; #endif
#ifndef CARTESIANMESH_BASE_HH #define CARTESIANMESH_BASE_HH #include <boost/ptr_container/ptr_vector.hpp> #include "Types.hh" #include "Dimension.hh" #include "GeomId.hh" #include "MeshTraits.hh" #include "Assert.hh" #include "GeometricElementConcept.hh" using boost::ptr_vector; template<typename dimension_type, typename geom_elem> inline typename CartesianMesh<dimension_type>::SizeType numCentering(const CartesianMesh<dimension_type>& mesh); template<typename dimension_type> class CartesianMesh_base : public MeshTraits<dimension_type>, boost::noncopyable { private: BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept); public: typedef dimension_type DimensionType; typedef MeshTraits<DimensionType> Base; public: typename Base::LengthType length() const { return mLength; } typename Base::SizeType numZones() const { return mZones.size() + numGhostZones(); } typename Base::SizeType numNodes() const { return mNodes.size() + numGhostNodes(); } typename Base::SizeType numCorners() const { return mCorners.size() + numGhostCorners(); } typename Base::SizeType numGhostZones() const { if(mGhostZones == 0) return 0; else return mGhostZones->size(); } typename Base::SizeType numGhostNodes() const { if(mGhostNodes == 0) return 0; else return mGhostNodes->size(); } typename Base::SizeType numGhostCorners() const { if(mGhostCorners == 0)
typename Base::const_NodeIterator nodeEnd() const { return typename Base::const_NodeIterator( mNodes, mNodes.end() ); } typename Base::CornerIterator cornerBegin() { return typename Base::CornerIterator( mCorners, mCorners.begin() ); } typename Base::CornerIterator cornerEnd() { return typename Base::CornerIterator( mCorners, mCorners.end() ); } typename Base::const_CornerIterator cornerBegin() const { return typename Base::const_CornerIterator( mCorners, mCorners.begin() ); } typename Base::const_CornerIterator cornerEnd() const { return typename Base::const_CornerIterator( mCorners, mCorners.end() ); } typename Base::reverse_ZoneIterator zoneRBegin() { return typename Base::reverse_ZoneIterator( zoneEnd() ); } typename Base::reverse_ZoneIterator zoneREnd() { return typename Base::reverse_ZoneIterator( zoneBegin() ); } typename Base::const_reverse_ZoneIterator zoneRBegin() const { return typename Base::const_reverse_ZoneIterator( zoneEnd() ); } typename Base::const_reverse_ZoneIterator zoneREnd() const { return typename Base::const_reverse_ZoneIterator( zoneBegin() ); } typename Base::reverse_NodeIterator nodeRBegin() { return typename Base::reverse_NodeIterator( nodeEnd() ); } typename Base::reverse_NodeIterator nodeREnd() { return typename Base::reverse_NodeIterator( nodeBegin() ); } typename Base::const_reverse_NodeIterator nodeRBegin() const { return typename Base::const_reverse_NodeIterator( nodeEnd() ); } typename Base::const_reverse_NodeIterator nodeREnd() const { return typename Base::const_reverse_NodeIterator( nodeBegin() ); } typename Base::reverse_CornerIterator cornerRBegin() { return typename Base::reverse_CornerIterator( cornerEnd() ); } typename Base::reverse_CornerIterator cornerREnd() { return typename Base::reverse_CornerIterator( cornerBegin() ); } typename Base::const_reverse_CornerIterator cornerRBegin() const { return typename Base::const_reverse_CornerIterator( cornerEnd() ); } typename Base::const_reverse_CornerIterator cornerREnd() const { return typename Base::const_reverse_CornerIterator( cornerBegin() ); } protected: CartesianMesh_base(typename Base::LengthType length_in, typename Base::SizeType num_zones, typename Base::SizeType num_nodes, typename Base::SizeType num_corners, typename Base::SizeType num_ghost_zones, typename Base::SizeType num_ghost_nodes, typename Base::SizeType num_ghost_corners) : mLength(length_in), mZones(num_zones), mNodes(num_nodes), mCorners(num_corners), mGhostZones(0), mGhostNodes(0), mGhostCorners(0) { if(num_ghost_zones != 0) { mGhostZones = new ptr_vector<typename Base::GhostZone>(num_ghost_zones); } if(num_ghost_nodes != 0) { mGhostNodes = new ptr_vector<typename Base::GhostNode>(num_ghost_nodes); } if(num_ghost_corners != 0) { mGhostCorners = new ptr_vector<typename Base::GhostCorner>(num_ghost_corners); } } ~CartesianMesh_base() { if(mGhostZones != 0) { delete mGhostZones; } if(mGhostNodes != 0) { delete mGhostNodes; } if(mGhostCorners != 0) { delete mGhostCorners; } } typename Base::LengthType mLength; ptr_vector<typename Base::Zone> mZones; ptr_vector<typename Base::Node> mNodes; ptr_vector<typename Base::Corner> mCorners; ptr_vector<typename Base::GhostZone>* mGhostZones; ptr_vector<typename Base::GhostNode>* mGhostNodes; ptr_vector<typename Base::GhostCorner>* mGhostCorners; private: CartesianMesh_base(); }; template<typename dimension_type> class CartesianMesh : CartesianMesh_base<dimension_type>, boost::noncopyable { private: CartesianMesh(); }; #endif
return 0; else return mGhostCorners->size(); } typename Base::ZoneIterator zoneBegin() { return typename Base::ZoneIterator( mZones, mZones.begin() ); } typename Base::ZoneIterator zoneEnd() { return typename Base::ZoneIterator( mZones, mZones.end() ); } typename Base::const_ZoneIterator zoneBegin() const { return typename Base::const_ZoneIterator( mZones, mZones.begin() ); } typename Base::const_ZoneIterator zoneEnd() const { return typename Base::const_ZoneIterator(mZones, mZones.end()); } typename Base::NodeIterator nodeBegin() { return typename Base::NodeIterator( mNodes, mNodes.begin() ); } typename Base::NodeIterator nodeEnd() { return typename Base::NodeIterator( mNodes, mNodes.end() ); } typename Base::const_NodeIterator nodeBegin() const { return typename Base::const_NodeIterator( mNodes, mNodes.begin() ); }
random
[ { "content": "class MeshBaseException : public ExceptionBase\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c ExceptionBase base class.\n\n\ttypedef ExceptionBase::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n MeshBaseException(LineNumType line_number, const char* file_in)\n\n : ExceptionBase(line_number, file_in)\n\n { }\n\n};\n\n\n\n/*! \\brief Thrown when a non-existent connected element access is attempted.\n\n *\n\n * This class is thrown when some geometric element attempts to access through\n\n * its connectivity another geometric element that does not actually exist, i.e.\n\n * if a \\c Node on the left boundary attempts to access its left \\c Zone object,\n\n * which obviously would not exist.\n\n * \\par Template Parameters:\n\n * <dl> <dt> \\e source_element </dt>\n\n * <dd> The type of the geometric element that made the bad call. </dd>\n\n * <dt> \\e target_element </dt>\n\n * <dd> The type of geometric element whose access was attempted. </dd> </dl> */\n\ntemplate<typename source_element, typename target_element>\n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 0, "score": 298683.1462251717 }, { "content": "class BadMeshLength : public BadMeshUserData\n\n{\n\nprivate:\n\n /// Requires the \\c dimension_type template parameter satisfies the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n /// Defines the \\c DimensionType type from the \\c dimension_type template parameter.\n\n typedef dimension_type DimensionType;\n\n \n\npublic:\n\n /// Defines the \\c LengthType from the \\c MeshTraits<DimensionType>::LengthType type.\n\n typedef typename MeshTraits<DimensionType>::LengthType LengthType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown and the mesh length.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown,\n\n * and the length given to the mesh constructor.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. \n\n * \\param[in] mesh_length The length given to the mesh constructor. */ \n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 2, "score": 286359.1488029023 }, { "content": "class BadMeshUserData : public MeshBaseException\n\n{\n\npublic:\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n BadMeshUserData(MeshBaseException::LineNumType line_number,\n\n const char* filename)\n\n : MeshBaseException(line_number, filename)\n\n { }\n\n};\n\n\n\n/*! \\brief Thrown when a \\c CartesianMesh object is given a bad length.\n\n *\n\n * This exception is thrown when a \\c CartesianMesh is given an invalid length.\n\n * \\par Template Parameters:\n\n * <dl> <dt> \\e dimension_type </dt>\n\n * <dd> The spatial dimension that the \\c CartesianMesh spans. This type must\n\n * satisfy the \\c DimensionConcept concept. </dd> </dl> */\n\ntemplate<typename dimension_type>\n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 3, "score": 286185.1260563774 }, { "content": "class ElementDoesNotExist : public MeshBaseException\n\n{\n\nprivate:\n\n /// Requires the \\c geom_element type satisfies the \\c GeometricElementConcept concept.\n\n BOOST_CLASS_REQUIRE(geom_element, , GeometricElementConcept);\n\n /// Defines the \\c GeomElementType from the template parameter \\c geom_element.\n\n typedef geom_element GeomElementType;\n\n \n\npublic:\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown and the element id.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown,\n\n * and the id number of the attempted element access.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. \n\n * \\param[in] id_in The id number given to the \\c CartesianMesh to attempt the\n\n * geometric element access. */\n\n ElementDoesNotExist(MeshBaseException::LineNumType line_number,\n\n const char* filename,\n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 4, "score": 285809.7257025615 }, { "content": "class NoElementConnected : public MeshBaseException\n\n{\n\nprivate:\n\n /// Requires that the \\c source_element type satisfy the \\c GeometricElementConcept concept.\n\n BOOST_CLASS_REQUIRE(source_element, , GeometricElementConcept);\n\n\n\n /// Defines the \\c SourceIdType from the \\c source_element::Id type.\n\n typedef typename source_element::Id SourceIdType;\n\n /// Defines the \\c SourceIndexType from the \\c source_element::IndexType type.\n\n typedef typename source_element::IndexType SourceIndexType;\n\npublic:\n\n /// Defines the \\c SourceElementType from the \\c source_element template parameter.\n\n typedef source_element SourceElementType;\n\n /// Defines the \\c TargetElementType from the \\c target_element template parameter.\n\n typedef target_element TargetElementType;\n\n\n\n /*! \\brief Constructor. Takes in the line number and file where the exception is thrown,\n\n * and the source id number and local target id number.\n\n *\n\n * Construtor. Takes in the line number and filename where the exception is thrown. Also\n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 5, "score": 285809.7257025615 }, { "content": "class NegativeZoneLength : public BadMeshUserData\n\n{\n\nprivate:\n\n /// Requires the \\c dimension_type template parameter satisfies the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n /// Defines the \\c DimensionType type from the \\c dimension_type template parameter.\n\n typedef dimension_type DimensionType;\n\npublic:\n\n /// Defines the \\c LengthType from the \\c MeshTraits<DimensionType>::LengthType type.\n\n typedef typename MeshTraits<DimensionType>::LengthType LengthType;\n\n /// Defines the \\c IdType from the \\c MeshTraits<DimensionType>::Zone::Id::IdType type. \n\n typedef typename MeshTraits<DimensionType>::Zone::Id::IdType IdType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown, the id of the negative zone, and the negative length.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown,\n\n * as well as the id number of the \\c Zone with the negative length, and the length itself. \n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. \n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 6, "score": 280347.1524682773 }, { "content": "class Point_base : public boost::noncopyable\n\n{\n\nprivate:\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n \n\npublic:\n\n /// Aliases the \\c dimension_type as a \\c DimensionType.\n\n typedef dimension_type DimensionType;\n\n /// Defines the \\c PointType as a real number.\n\n typedef Real8 PointType;\n\n\n\n\t/*! \\brief Returns a reference to the x-position of the \n\n\t * \\c Point object.\n\n\t *\n\n\t * Returns a reference to the x-position of the \\c Point object.\n\n\t * \\return A reference to the x-position of the \\c Point object. */\n\n\tPointType& x()\n\n\t{\n\n\t return mX;\n\n\t}\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/Point_base.hh", "rank": 7, "score": 280043.0749485686 }, { "content": "class Zone_base : public boost::noncopyable\n\n{\n\nprivate:\n\n /// Requires that the \\c dimension_type satisfies the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n \n\npublic:\n\n /// Aliases the \\c dimension_type as the \\c DimensionType type.\n\n typedef dimension_type DimensionType;\n\n /// Uses the \\c MeshTraits<DimensionType>::LengthType as a \\c LengthType.\n\n\ttypedef typename MeshTraits<DimensionType>::LengthType LengthType;\n\n /// Uses the \\c MeshTraits<DimensionType>::SizeType as a \\c SizeType.\n\n\ttypedef typename MeshTraits<DimensionType>::SizeType SizeType;\n\n /// Uses the \\c MeshTraits<DimensionType>::IndexType as a \\c IndexType.\n\n\ttypedef typename MeshTraits<DimensionType>::IndexType IndexType;\n\n\t\n\n\t/// Defines an identification number type.\n\n\ttypedef GeomId< Zone<DimensionType> > Id;\n\n\t/// Defines the \\c Node type for connectivity.\n\n\ttypedef Node<DimensionType> Node;\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/Zone_base.hh", "rank": 8, "score": 280043.0749485686 }, { "content": "class Node_base : public boost::noncopyable\n\n{\n\nprivate:\n\n /// Requires \\c dimension_type to satisfy the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n\n\npublic:\n\n /// Aliases the \\c dimension_type as \\c DimensionType type.\n\n typedef dimension_type DimensionType;\n\n /// Defines an \\c IndexType for indexing connected elements.\n\n\ttypedef UnsignedInt4 IndexType;\n\n\t/// Defines a \\c PointType for storing spatial points.\n\n typedef Point<DimensionType> PointType;\n\n /// Defines an \\c Id type for storing the id number for a \\c Node object.\n\n\ttypedef GeomId< Node<DimensionType> > Id;\n\n\t/// Defines a \\c Zone type for storing connected \\c Zone objects.\n\n\ttypedef Zone<DimensionType> Zone;\n\n\t/// Defines a \\c Corner type for storing connected \\c Corner objects.\n\n\ttypedef Corner<DimensionType> Corner;\n\n\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/Node_base.hh", "rank": 9, "score": 280043.0749485686 }, { "content": "/// \\brief Thrown when numCentering is given a non-existing geometric sub element.\n\n/// \n\n/// The NoSuchElement exception is thrown by numCentering if a non-existing geometric sub-element \n\n/// is given to it as a template parameter.\n\nclass NoSuchElement : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoSuchElement(unsigned int line_number, const string& file_in)\n\n\t\t: ExceptionBase(line_number, file_in) { }\n\n\t\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{ \n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant element at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/MeshExcept.hh", "rank": 10, "score": 279479.55850490765 }, { "content": "/// \\brief Thrown when a non-existing Zone is referenced through connectivity.\n\n/// \n\n/// The NoZoneConnected class is thrown when attempting to reference a Zone that does not exist,\n\n/// such as asking for the left Zone from a Node on the left boundary.\n\nclass NoZoneConnected : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoZoneConnected(unsigned int line_number, const string& file_in)\n\n\t\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{ \n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant zone at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/MeshExcept.hh", "rank": 11, "score": 276282.11766666593 }, { "content": "/// \\brief Thrown when a non-existing Corner is referenced through connectivity.\n\n///\n\n/// The NoCornerConnected class is thrown when attempting to reference a Corner that does not exist,\n\n/// such as asking for the left Corner from a Node on the left boundary.\n\nclass NoCornerConnected : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoCornerConnected(unsigned int line_number, const string& file_in)\n\n\t\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant corner at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/MeshExcept.hh", "rank": 12, "score": 276282.11766666593 }, { "content": "/// \\brief Thrown when numCentering is given a non-existing geometric sub element.\n\n/// \n\n/// The NoSuchElement exception is thrown by numCentering if a non-existing geometric sub-element \n\n/// is given to it as a template parameter.\n\nclass NoSuchElement : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoSuchElement(unsigned int line_number, const string& file_in)\n\n\t\t: ExceptionBase(line_number, file_in) { }\n\n\t\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{ \n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant element at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/MeshExcept.hh", "rank": 13, "score": 276276.8628034643 }, { "content": "/// \\brief Thrown when numCentering is given a non-existing geometric sub element.\n\n/// \n\n/// The NoSuchElement exception is thrown by numCentering if a non-existing geometric sub-element \n\n/// is given to it as a template parameter.\n\nclass NoSuchElement : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoSuchElement(unsigned int line_number, const string& file_in)\n\n\t\t: ExceptionBase(line_number, file_in) { }\n\n\t\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{ \n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant element at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/MeshExcept.hh", "rank": 14, "score": 276276.8628034643 }, { "content": "class GeomVector_base : public boost::noncopyable\n\n{\n\nprivate:\n\n /// This forces \\c dimension_type to satisfy the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n\n\npublic:\n\n\t/// Aliases the \\c dimension_type as \\c DimensionType.\n\n\ttypedef dimension_type DimensionType;\n\n\t/// Defines the \\c OrdinateType as a real number.\n\n\ttypedef Real8 OrdinateType;\n\n\n\n\t/*! \\brief Returns a reference to the x-axis ordinate data.\n\n\t *\n\n\t * Returns a reference to the x-axis ordinate data.\n\n\t * \\return A reference to the x-axis ordinate data. */\n\n\tOrdinateType& i() \n\n\t{ \n\n\t return mI; \n\n\t}\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/GeomVector_base.hh", "rank": 15, "score": 274412.03264756757 }, { "content": "class SweepIterator_base : public boost::noncopyable\n\n{\n\nprivate:\n\n /// Requires the \\c dimension_type to satisfy the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n /// Requires the \\c container_type to satisfy the \\c MinimalContainerConcept concept.\n\n BOOST_CLASS_REQUIRE(container_type, , MinimalContainerConcept);\n\n /// Define the \\c Zone<dimension_type> as a \\c ZoneType.\n\n typedef Zone<dimension_type> ZoneType;\n\n \n\npublic:\n\n /// Aliases the \\c dimension_type as a \\c DimensionType type.\n\n typedef dimension_type DimensionType;\n\n /// Defines the \\c Angle<DimensionType> as an \\c AngleType type.\n\n typedef Angle<DimensionType> AngleType;\n\n /// Defines the \\c container_type as a \\c ContainerType.\n\n typedef container_type ContainerType;\n\n /// Defines the \\c const_reference type.\n\n typedef typename ContainerType::const_reference const_reference;\n\n \n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/SweepIterator_base.hh", "rank": 16, "score": 274412.03264756757 }, { "content": "/// \\brief Thrown when a non-existing Zone is referenced through connectivity.\n\n/// \n\n/// The NoZoneConnected class is thrown when attempting to reference a Zone that does not exist,\n\n/// such as asking for the left Zone from a Node on the left boundary.\n\nclass NoZoneConnected : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoZoneConnected(unsigned int line_number, const string& file_in)\n\n\t\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{ \n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant zone at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/MeshExcept.hh", "rank": 17, "score": 273177.0310466499 }, { "content": "/// \\brief Thrown when a non-existing Zone is referenced through connectivity.\n\n/// \n\n/// The NoZoneConnected class is thrown when attempting to reference a Zone that does not exist,\n\n/// such as asking for the left Zone from a Node on the left boundary.\n\nclass NoZoneConnected : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoZoneConnected(unsigned int line_number, const string& file_in)\n\n\t\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{ \n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant zone at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/MeshExcept.hh", "rank": 18, "score": 273177.0310466499 }, { "content": "/// \\brief Thrown when a non-existing Corner is referenced through connectivity.\n\n///\n\n/// The NoCornerConnected class is thrown when attempting to reference a Corner that does not exist,\n\n/// such as asking for the left Corner from a Node on the left boundary.\n\nclass NoCornerConnected : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoCornerConnected(unsigned int line_number, const string& file_in)\n\n\t\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant corner at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/MeshExcept.hh", "rank": 19, "score": 273177.0310466499 }, { "content": "/// \\brief Thrown when a non-existing Corner is referenced through connectivity.\n\n///\n\n/// The NoCornerConnected class is thrown when attempting to reference a Corner that does not exist,\n\n/// such as asking for the left Corner from a Node on the left boundary.\n\nclass NoCornerConnected : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tNoCornerConnected(unsigned int line_number, const string& file_in)\n\n\t\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to reference a non-existant corner at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/MeshExcept.hh", "rank": 20, "score": 273177.0310466499 }, { "content": "class NegativeAngleVectorLength : public AngularBaseException\n\n{\n\nprivate:\n\n BOOST_CLASS_REQUIRE(angle_vector_type, , AngleVectorConcept);\n\n \n\npublic:\n\n typedef angle_vector_type AngleVectorType;\n\n typedef typename angle_vector_type::IndexType IndexType;\n\n \n\n NegativeAngleVectorLength(const AngleVectorType& av_in,\n\n const typename IndexType::difference_type length_in,\n\n LineNumType line_number, const char* file_in) \n\n : AngularBaseException(line_number, file_in),\n\n mAngleVector(av_in),\n\n mLength(length_in)\n\n { }\n\n \n\n const AngleVectorType& getAngleVector() const\n\n {\n\n return mAngleVector;\n", "file_path": "Code/trunk/cpp/Geometry/Exception/AngleExcept.hh", "rank": 21, "score": 268306.61571033945 }, { "content": "class SweepIterator : public boost::noncopyable\n\n{\n\nprivate:\n\n /// This default constructor is private to prevent instantiation.\n\n SweepIterator();\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/SweepIterator_base.hh", "rank": 22, "score": 264157.7815934742 }, { "content": "class Node : public Node_base<dimension_type>, boost::noncopyable\n\n{ \n\nprivate:\n\n /// The default constructor is private to prevent instantiation. \n\n Node();\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/Node_base.hh", "rank": 23, "score": 262263.4778019414 }, { "content": "class Point : public Point_base<dimension_type>, boost::noncopyable\n\n{\n\nprivate:\n\n /// The default constructor is private to prevent instantiation.\n\n Point(); \n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/Point_base.hh", "rank": 24, "score": 262263.47780194134 }, { "content": "class Zone : public Zone_base<dimension_type>, boost::noncopyable\n\n{ \n\nprivate:\n\n /// The default constructor is private to prevent instantiation.\n\n Zone();\n\n};\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/Zone_base.hh", "rank": 25, "score": 262263.4778019414 }, { "content": "class CartesianMesh<OneD> : public CartesianMesh_base<OneD>\n\n{\n\nprivate:\n\n /// Defines the base class as the Base type.\n\n typedef CartesianMesh_base<OneD> Base;\n\n \n\npublic:\n\n /// Imports the Zone class from the Base type.\n\n typedef Base::Zone Zone;\n\n /// Imports the Node class from the Base type.\n\n typedef Base::Node Node;\n\n /// Imports the Corner class from the Base type.\n\n typedef Base::Corner Corner;\n\n\n\nprivate:\n\n /// Requires the \\c Zone type to satisfy the \\c ZoneConcept concept.\n\n BOOST_CLASS_REQUIRE(Zone, , ZoneConcept);\n\n /// Requires the \\c Node type to satisfy the \\c NodeConcept concept.\n\n BOOST_CLASS_REQUIRE(Node, , NodeConcept);\n\n /// Requires the \\c Corner type to satisfy the \\c CornerConcept concept.\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/OneD/CartesianMesh1D.hh", "rank": 26, "score": 260492.24657733698 }, { "content": "class DaughterTemplate : public Base<S>{\n\n using Base<S>::_SVar;\n\npublic:\n\n DaughterTemplate(S& init) : Base<S>(init) { }\n\n\n\n void Express(S x) { \n\n cout << \"Expressing Daughter with x = \" << x \n\n << \"\\n\\tBase variables: _SVar = \" << _SVar\n\n << \"\\n\\tDaughter variables: _dVar = \" << _dVar << endl;\n\n }\n\n\n\nprivate:\n\n S _dVar;\n\n\n\n};\n\n\n", "file_path": "Code/trunk/cpp/test/general.hpp", "rank": 27, "score": 258778.08754220174 }, { "content": "/// \\brief The Mesh class is responsible for storing and controlling a problem's spatial \n\n/// domain information.\n\n///\n\n/// The Mesh class is responsible for storing and controlling a problem's spatial \n\n/// domain information. First, the mesh stores the global length and area of the domain.\n\n/// Second, the Mesh also stores the geometric elements, which are (for a one-dimensional\n\n/// mesh), Zones, Nodes, and Corners. Together with these geometric elements, the Mesh\n\n/// stores all of the information necessary to fully describe a problem's spatial domain.\n\nclass Mesh : public MeshTraits, boost::noncopyable\n\n{\n\npublic:\n\n\t// ****** Mesh Constructors ******\n\n /// \\brief Constructor to create a uniform one-dimensional Cartesian Mesh with \\a num_zones\n\n\t/// zones.\n\n\t///\n\n\t/// This constructor creates a uniform (all Zones are of equal length), one-dimensional\n\n\t/// Cartesian Mesh.\n\n\t/// \\param length Length of the spatial domain.\n\n\t/// \\param area Cross-sectional area of the spatial domain.\n\n\t/// \\param num_zones The number of zones to break the spatial domain into.\n\n Mesh(const double length_in, const double area_in, const unsigned int num_zones)\n\n\t\t\t: mLength(length_in),\n\n\t\t\t mArea(area_in),\n\n\t\t\t mNumZones(num_zones),\n\n\t\t\t mZones(), mNodes(), mCorners()\n\n\t{\n\n\t\tvector<double> zone_lengths(num_zones, length_in/num_zones);\n\n\t\tmBuildMesh(zone_lengths);\n", "file_path": "Code/branches/PHYSOR/cpp/Geometry/OneDMesh/OneDCartMesh.hh", "rank": 28, "score": 255642.97040024173 }, { "content": "class GeomVector : public GeomVector_base<dimension_type>, boost::noncopyable\n\n{\n\nprivate:\n\n /// This constructor is private to prevent instantiation.\n\n GeomVector();\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/GeomVector_base.hh", "rank": 29, "score": 254576.55126839975 }, { "content": "/// \\brief The Mesh class is responsible for storing and controlling a problem's spatial \n\n/// domain information.\n\n///\n\n/// The Mesh class is responsible for storing and controlling a problem's spatial \n\n/// domain information. First, the mesh stores the global length and area of the domain.\n\n/// Second, the Mesh also stores the geometric elements, which are (for a one-dimensional\n\n/// mesh), Zones, Nodes, and Corners. Together with these geometric elements, the Mesh\n\n/// stores all of the information necessary to fully describe a problem's spatial domain.\n\nclass Mesh : public MeshTraits, boost::noncopyable\n\n{\n\npublic:\n\n\t// ****** Mesh Constructors ******\n\n /// \\brief Constructor to create a uniform one-dimensional Cartesian Mesh with \\a num_zones\n\n\t/// zones.\n\n\t///\n\n\t/// This constructor creates a uniform (all Zones are of equal length), one-dimensional\n\n\t/// Cartesian Mesh.\n\n\t/// \\param length Length of the spatial domain.\n\n\t/// \\param area Cross-sectional area of the spatial domain.\n\n\t/// \\param num_zones The number of zones to break the spatial domain into.\n\n Mesh(const double length_in, const double area_in, const unsigned int num_zones)\n\n\t\t\t: mLength(length_in),\n\n\t\t\t mArea(area_in),\n\n\t\t\t mNumZones(num_zones),\n\n\t\t\t mZones(), mNodes(), mCorners()\n\n\t{\n\n\t\tvector<double> zone_lengths(num_zones, length_in/num_zones);\n\n\t\tmBuildMesh(zone_lengths);\n", "file_path": "Code/branches/OldGeometry/cpp/Geometry/OneDMesh/OneDCartMesh.hh", "rank": 30, "score": 253968.70046256302 }, { "content": "/// \\brief The Mesh class is responsible for storing and controlling a problem's spatial \n\n/// domain information.\n\n///\n\n/// The Mesh class is responsible for storing and controlling a problem's spatial \n\n/// domain information. First, the mesh stores the global length and area of the domain.\n\n/// Second, the Mesh also stores the geometric elements, which are (for a one-dimensional\n\n/// mesh), Zones, Nodes, and Corners. Together with these geometric elements, the Mesh\n\n/// stores all of the information necessary to fully describe a problem's spatial domain.\n\nclass Mesh : public MeshTraits, boost::noncopyable\n\n{\n\npublic:\n\n\t// ****** Mesh Constructors ******\n\n /// \\brief Constructor to create a uniform one-dimensional Cartesian Mesh with \\a num_zones\n\n\t/// zones.\n\n\t///\n\n\t/// This constructor creates a uniform (all Zones are of equal length), one-dimensional\n\n\t/// Cartesian Mesh.\n\n\t/// \\param length Length of the spatial domain.\n\n\t/// \\param area Cross-sectional area of the spatial domain.\n\n\t/// \\param num_zones The number of zones to break the spatial domain into.\n\n Mesh(const double length_in, const double area_in, const unsigned int num_zones)\n\n\t\t\t: mLength(length_in),\n\n\t\t\t mArea(area_in),\n\n\t\t\t mNumZones(num_zones),\n\n\t\t\t mZones(), mNodes(), mCorners()\n\n\t{\n\n\t\tvector<double> zone_lengths(num_zones, length_in/num_zones);\n\n\t\tmBuildMesh(zone_lengths);\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Geometry/OneDMesh/OneDCartMesh.hh", "rank": 31, "score": 253968.70046256302 }, { "content": "class DaughterString : public Base<std::string>{\n\npublic:\n\n DaughterString(std::string& init) : Base<std::string>(init) { }\n\n\n\n void Express(std::string x) { \n\n cout << \"Expressing Daughter with x = \" << x \n\n << \"\\n\\tBase variables: _SVar = \" << _SVar\n\n << \"\\n\\tDaughter variables: _dVar = \" << _dVar << endl;\n\n }\n\n\n\nprivate:\n\n std::string _dVar;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Code/trunk/cpp/test/general.hpp", "rank": 32, "score": 248613.28028952493 }, { "content": "class Point<OneD> : public Point_base<OneD>\n\n{\n\nprivate:\n\n /// Aliases the \\c Point_base<OneD> as the \\c Base type.\n\n typedef Point_base<OneD> Base;\n\npublic:\n\n /// Imports the \\c Point_base<OneD>::PointType into the \\c Point<OneD> scope.\n\n\ttypedef Base::PointType PointType;\n\n\n\n /*! \\brief Constructor. Takes in the x-position for the \\c Point<OneD> object.\n\n *\n\n * Constructor. Takes in the x-position for the \\c Point<OneD> object.\n\n * \\param[in] x_in The x-position for the \\c Point<OneD> object. */ \n\n\texplicit Point(PointType x_in = 0.0)\n\n\t : Point_base<OneD>(x_in)\n\n\t{ }\n\n\n\n /*! \\brief Copy constructor.\n\n *\n\n * Copy constructor.\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/OneD/Point1D.hh", "rank": 33, "score": 247878.79401605178 }, { "content": "class Node<OneD> : public Node_base<OneD>\n\n{\n\npublic:\n\n /// Imports the \\c Id class from \\c Node_base<OneD> into the \\c Node<OneD> scope.\n\n typedef Node_base<OneD>::Id Id;\n\n /// Imports the \\c PointType class from \\c Node_base<OneD> into the \\c Node<OneD> scope.\n\n typedef Node_base<OneD>::PointType PointType;\n\n /// Imports the \\c Zone class from \\c Node_base<OneD> into the \\c Node<OneD> scope.\n\n typedef Node_base<OneD>::Zone Zone;\n\n /// Imports the \\c IndexType class from \\c Node_base<OneD> into the \\c Node<OneD> scope.\n\n typedef Node_base<OneD>::IndexType IndexType;\n\n\n\n typedef Node_base<OneD>::Corner Corner;\n\n\n\n /*! \\brief Imports the \\c NoElementConnected<Node<OneD>, Zone> exception class \n\n * into the \\c Node<OneD> scope. Thrown when an attempt is made to access a \n\n * non-existent connected \\c Zone. */\n\n typedef NoElementConnected< Node<OneD>, Zone > NoZoneConnected;\n\n /*! \\brief Imports the \\c NoElementConnected<Node<OneD>, Corner> exception class \n\n * into the \\c Node<OneD> scope. Thrown when an attempt is made to access a \n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/OneD/Node1D.hh", "rank": 34, "score": 247878.79401605178 }, { "content": "class Zone<OneD> : public Zone_base<OneD>\n\n{\n\nprivate:\n\n /// Define the \\c Zone_base<OneD> class as \\c Base.\n\n typedef Zone_base<OneD> Base;\n\n \n\npublic:\n\n /// Import the \\c Base::Id type into the \\c Zone scope.\n\n typedef Base::Id Id;\n\n /// Import the \\c Base::LengthType type into the \\c Zone scope.\n\n typedef Base::LengthType LengthType;\n\n /// Import the \\c Base::Node type into the \\c Zone scope.\n\n typedef Base::Node Node;\n\n /// Import the \\c Base::Corner type into the \\c Zone scope.\n\n typedef Base::Corner Corner;\n\n\n\n /*! \\brief Imports the \\c NoElementConnected<Zone<OneD>, Node> exception class \n\n * into the \\c Zone<OneD> scope. Thrown when an attempt is made to access a \n\n * non-existent connected \\c Node. */\n\n typedef NoElementConnected< Zone<OneD>, Node > NoNodeConnected;\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/OneD/Zone1D.hh", "rank": 35, "score": 247878.79401605178 }, { "content": "class GeomVector<OneD> : public GeomVector_base<OneD>\n\n{\n\nprivate:\n\n /// Defines the \\c GeomVector_base<OneD> as the \\c Base type.\n\n typedef GeomVector_base<OneD> Base;\n\n\n\npublic: \n\n /// Imports the \\c GeomVector_base<OneD>::OrdinateType into this scope.\n\n typedef Base::OrdinateType OrdinateType;\n\n\n\n /*! \\brief Copy constructor.\n\n *\n\n * Copy constructor.\n\n * \\param[in] geom_vec_in The \\c GeomVector<OneD> object to copy. */\n\n GeomVector(const GeomVector<OneD>& geom_vec_in)\n\n : GeomVector_base<OneD>(geom_vec_in.mI)\n\n { }\n\n \n\n /*! \\brief Constructor. Takes in the i-ordinate.\n\n *\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/OneD/GeomVector1D.hh", "rank": 36, "score": 240281.15990563008 }, { "content": "class BadMeshArea : public BadMeshUserData\n\n{\n\nprivate:\n\n /// Requires the \\c dimension_type template parameter satisfies the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n /// Defines the \\c DimensionType type from the \\c dimension_type template parameter.\n\n typedef dimension_type DimensionType;\n\n \n\npublic:\n\n /// Defines the \\c LengthType from the \\c MeshTraits<DimensionType>::LengthType type.\n\n typedef typename MeshTraits<DimensionType>::LengthType LengthType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown and the mesh area.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown,\n\n * and the area given to the mesh constructor.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. \n\n * \\param[in] mesh_area The area given to the mesh constructor. */ \n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 37, "score": 237228.17824256653 }, { "content": "class AngularBaseException : public ExceptionBase\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c ExceptionBase base class.\n\n\ttypedef ExceptionBase::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n AngularBaseException(LineNumType line_number, const char* file_in)\n\n : ExceptionBase(line_number, file_in)\n\n { }\n\n};\n\n\n\n\n\n/*! \\brief Thrown when the \\c AngleQuad class is constructed with a bad quadrature order.\n\n *\n\n * This exception class is thrown when an \\c AngleQuad class is constructed with a bad\n\n * quadrature order.\n\n * \\par Template Parameters:\n\n * <dl> <dt> \\e angle_quad_type </dt>\n\n * <dd> The type of the bad \\c AngleQuad object. This type must satisfy the\n\n * \\c AngleQuadConcept concept template. </dd> </dl> */\n\ntemplate<typename angle_quad_type>\n", "file_path": "Code/trunk/cpp/Geometry/Exception/AngleExcept.hh", "rank": 38, "score": 236518.95575023937 }, { "content": "class IteratorBaseException : public ExceptionBase\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c ExceptionBase base class.\n\n typedef ExceptionBase::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n\tIteratorBaseException(LineNumType line_number, const char* filename)\n\n\t\t: ExceptionBase(line_number, filename)\n\n\t{ }\n\n};\n\n\n\n/*! \\brief Exception thrown when an out-of-range \\c Iterator or \n\n * \\c ReverseIterator is dereferenced.\n\n *\n\n * This exception is thrown when an out-of-range \\c Iterator or \n\n * \\c ReverseIterator is dereferenced. */\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 39, "score": 236518.95575023937 }, { "content": "class FieldBaseException : public ExceptionBase\n\n{\n\nprivate:\n\n /// Requires that the \\c field_type satisfy the \\c FieldConcept concept.\n\n BOOST_CLASS_REQUIRE(field_type, , FieldConcept); \n\n \n\npublic:\n\n /// Imports the \\c LineNumType from \\c ExceptionBase.\n\n typedef ExceptionBase::LineNumType LineNumType;\n\n /// Defines the \\c field_type template paramater as \\c FieldType.\n\n typedef field_type FieldType;\n\n \n\n /*! \\brief Constructor. Takes in the \\c Field from which the exception was thrown, and the\n\n * line number and filename.\n\n *\n\n * Constructor. Takes in a reference to the \\c Field from which the exception was thrown.\n\n * Also takes in the line number and the name of the file where the exception was thrown.\n\n * \\param[in] field_in A reference to the \\c Field from which the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] file_in The name of the file where the exception was thrown. */\n", "file_path": "Code/trunk/cpp/Geometry/Exception/FieldExcept.hh", "rank": 40, "score": 236518.95575023937 }, { "content": "class ZeroZones : public BadMeshUserData\n\n{\n\npublic:\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown. \n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n ZeroZones(MeshBaseException::LineNumType line_number,\n\n const char* filename)\n\n : BadMeshUserData(line_number, filename)\n\n { }\n\n\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n\n * \\return A \\c string holding a helpful error message. */ \n\n virtual string msg() const\n\n {\n", "file_path": "Code/trunk/cpp/Geometry/Exception/MeshExcept.hh", "rank": 41, "score": 233260.57103054703 }, { "content": "class PowerMCBase : public Markov<BankSource> {\n\n public:\n\n PowerMCBase(const std::vector<unsigned long>& seed,\n\n const Field<Zone, Material>& field)\n\n : Markov<BankSource>(seed, field) { k = 1; }\n\n\n\n ~PowerMCBase() { }\n\n // Scoring function\n\n void score(BankSource& source, Particle& P);\n\n\n\n // Members used in Python\n\n double k; //Eigenvalue estimate\n\n};\n\n\n\n/*score will score in the source from P.*/\n\nvoid PowerMCBase::score(BankSource& source, Particle& P){\n\n double xi = _r.Fixed();\n\n const Material& mat = _field[*(P.zone())];\n\n int N = P.weight()*(1.0/k)*(mat.nu()*mat.xF()/mat.xT()) + xi;\n\n for( int i = 0; i< N; i++ ){ source.push_back(new Particle(P)); }\n\n}\n\n#endif\n", "file_path": "Code/trunk/cpp/Markov/PowerMCBase.h", "rank": 42, "score": 230516.83399274957 }, { "content": "class Angle_base : public boost::noncopyable\n\n{\n\nprivate:\n\n /// Requires that the \\c dimension_type satisfy the \\c DimensionConcept concept.\n\n BOOST_CLASS_REQUIRE(dimension_type, , DimensionConcept);\n\n\n\npublic:\n\n // ****** Public type declarations ******\n\n /// Alias the \\c dimension_type template parameter as \\c DimensionType.\n\n typedef dimension_type DimensionType;\n\n /// Sets \\c GeomVector<DimensionType> as the \\c AngleType.\n\n\ttypedef GeomVector<DimensionType> AngleType;\n\n\t/// Defines the \\c WeightType.\n\n\ttypedef Real8 WeightType;\n\n /// Defines the \\c OrdinateType from the \\c AngleType.\n\n typedef typename AngleType::OrdinateType OrdinateType;\n\n\t\n\n\t// ****** Data accessors ******\n\n\t/*! \\brief Returns a constant reference to the angle ordinate.\n\n\t *\n", "file_path": "Code/trunk/cpp/Geometry/AngleQuad/Angle_base.hh", "rank": 43, "score": 230516.83399274957 }, { "content": "class PowerBase : public Markov<BankSource> {\n\n public:\n\n PowerBase(const std::vector<unsigned long>& seed,\n\n const Field<Zone, Material>& field)\n\n : Markov<BankSource>(seed, field) { k = 1; }\n\n\n\n ~PowerBase() { }\n\n // Scoring function\n\n void score(BankSource& source, Particle& P);\n\n\n\n // Members used in Python\n\n double k; //Eigenvalue estimate\n\n};\n\n\n\n/*score will score in the source from P.*/\n\nvoid PowerBase::score(BankSource& source, Particle& P){\n\n double xi = _r.Fixed();\n\n const Material& mat = _field[*(P.zone())];\n\n int N = P.weight()*(1.0/k)*(mat.nu()*mat.xF()/mat.xT()) + xi;\n\n for( int i = 0; i< N; i++ ){ source.push_back(new Particle(P)); }\n\n}\n\n#endif\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Markov/PowerBase.h", "rank": 44, "score": 230516.83399274957 }, { "content": "class PowerMCBase : public Markov<BankSource> {\n\n public:\n\n PowerMCBase(const std::vector<unsigned long>& seed,\n\n const Field<Zone, Material>& field)\n\n : Markov<BankSource>(seed, field) { k = 1; }\n\n\n\n ~PowerMCBase() { }\n\n // Scoring function\n\n void score(BankSource& source, Particle& P);\n\n\n\n // Members used in Python\n\n double k; //Eigenvalue estimate\n\n};\n\n\n\n/*score will score in the source from P.*/\n\nvoid PowerMCBase::score(BankSource& source, Particle& P){\n\n double xi = _r.Fixed();\n\n const Material& mat = _field[*(P.zone())];\n\n int N = P.weight()*(1.0/k)*(mat.nu()*mat.xF()/mat.xT()) + xi;\n\n for( int i = 0; i< N; i++ ){ source.push_back(new Particle(P)); }\n\n}\n\n#endif\n", "file_path": "Code/branches/PHYSOR/cpp/Markov/PowerMCBase.h", "rank": 45, "score": 228405.72402313811 }, { "content": "class PowerMCBase : public Markov<BankSource> {\n\n public:\n\n PowerMCBase(const std::vector<unsigned long>& seed,\n\n const Field<Zone, Material>& field)\n\n : Markov<BankSource>(seed, field) { k = 1; }\n\n\n\n ~PowerMCBase() { }\n\n // Scoring function\n\n void score(BankSource& source, Particle& P);\n\n\n\n // Members used in Python\n\n double k; //Eigenvalue estimate\n\n};\n\n\n\n/*score will score in the source from P.*/\n\nvoid PowerMCBase::score(BankSource& source, Particle& P){\n\n double xi = _r.Fixed();\n\n const Material& mat = _field[*(P.zone())];\n\n int N = P.weight()*(1.0/k)*(mat.nu()*mat.xF()/mat.xT()) + xi;\n\n for( int i = 0; i< N; i++ ){ source.push_back(new Particle(P)); }\n\n}\n\n#endif\n", "file_path": "Code/branches/OldGeometry/cpp/Markov/PowerMCBase.h", "rank": 46, "score": 226350.56879698276 }, { "content": "/// \\brief InvalidData is thrown if invalid data is passed to Method or one of its derived classes.\n\n///\n\n/// InvalidData is thrown if invalid data is passed to Method or one of its derived classes. For instance,\n\n/// Diffusion must have nonzero opacities to generate diffusion coefficients. \n\nclass InvalidData : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInvalidData(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Invalid data passed to a transport Method. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/MethodExcept.hh", "rank": 47, "score": 225990.4060967319 }, { "content": "/// \\brief InsaneInput is thrown if the users inputs unphysical data.\n\n///\n\n/// InsaneInput is thrown if the users inputs unphysical data, such as negative temperatures,\n\n/// non-increasing time steps, etc. \n\nclass InsaneInput : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInsaneInput(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Dimension mismatch in input, check for consistency. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/ProblemExcept.hh", "rank": 48, "score": 225984.23349752772 }, { "content": "/// \\brief ModelingError is thrown if a Method commits a modeling error.\n\n///\n\n/// ModelingError is thrown if a Method is commits a modeling error. An example might be\n\n/// if energy is not conserved or if a probability distribution isn't normalized. \n\nclass ModelingError : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tModelingError(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Method has committed a modeling error. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/MethodExcept.hh", "rank": 49, "score": 225984.23349752772 }, { "content": "/// \\brief Thrown when an iterator is made invalid or an invalid location is dereferenced.\n\n///\n\n/// IteratorOutOfRange is thrown whenever an attempt is made to dereference an iterator that \n\n/// does not point to a valid object, or when an iterator is moved outside the an objects\n\n/// range.\n\nclass IteratorOutOfRange : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tIteratorOutOfRange(unsigned int line_number, const string& file_in)\n\n\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to dereference an invalid iterator at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/IteratorExcept.hh", "rank": 50, "score": 225984.23349752772 }, { "content": "/// \\brief AdvancedTooFar is thrown if a Method is asked to calculate past the last time step.\n\n///\n\n/// AdvancedTooFar is thrown if a Method is asked to calculate past the last time step.\n\nclass AdvancedTooFar : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tAdvancedTooFar(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Method has reached the last time step for this problem. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/MethodExcept.hh", "rank": 51, "score": 225984.23349752772 }, { "content": "/// \\brief DimensionMismatch is thrown if the users inputs data that is inconsistent in dimension.\n\n///\n\n/// DimensionMismatch is thrown if the users inputs data that is inconsistent in dimension. An example\n\n/// of this might be if the number of problem regions does not match the number of materials, or if the\n\n/// the number of time delta-ts does not match the number of times requested for output. \n\nclass DimensionMismatch : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tDimensionMismatch(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Dimension mismatch in input, check for consistency. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/ProblemExcept.hh", "rank": 52, "score": 225984.23349752772 }, { "content": "class LowWeightParticle : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception \n\n //was thrown.\n\n\tLowWeightParticle(const Particle& P, unsigned int line_number,\n\n const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n string msg() const {\n\n ostringstream out;\n\n out << \"Particle was killed due to low weight.\\n\";\n\n return out.str();\n\n }\n\n\n\n};\n\n\n", "file_path": "Code/trunk/cpp/Exception/MonteCarloExcept.h", "rank": 53, "score": 225984.23349752772 }, { "content": "/// \\brief InvalidData is thrown if invalid data is passed to Method or one of its derived classes.\n\n///\n\n/// InvalidData is thrown if invalid data is passed to Method or one of its derived classes. For instance,\n\n/// Diffusion must have nonzero opacities to generate diffusion coefficients. \n\nclass InvalidData : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInvalidData(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Invalid data passed to a transport Method. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/MethodExcept.hh", "rank": 54, "score": 223651.70782683336 }, { "content": "/// \\brief InvalidData is thrown if invalid data is passed to Method or one of its derived classes.\n\n///\n\n/// InvalidData is thrown if invalid data is passed to Method or one of its derived classes. For instance,\n\n/// Diffusion must have nonzero opacities to generate diffusion coefficients. \n\nclass InvalidData : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInvalidData(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Invalid data passed to a transport Method. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/MethodExcept.hh", "rank": 55, "score": 223651.70782683336 }, { "content": "/// \\brief DimensionMismatch is thrown if the users inputs data that is inconsistent in dimension.\n\n///\n\n/// DimensionMismatch is thrown if the users inputs data that is inconsistent in dimension. An example\n\n/// of this might be if the number of problem regions does not match the number of materials, or if the\n\n/// the number of time delta-ts does not match the number of times requested for output. \n\nclass DimensionMismatch : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tDimensionMismatch(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Dimension mismatch in input, check for consistency. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/ProblemExcept.hh", "rank": 56, "score": 223645.53522762924 }, { "content": "/// \\brief AdvancedTooFar is thrown if a Method is asked to calculate past the last time step.\n\n///\n\n/// AdvancedTooFar is thrown if a Method is asked to calculate past the last time step.\n\nclass AdvancedTooFar : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tAdvancedTooFar(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Method has reached the last time step for this problem. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/MethodExcept.hh", "rank": 57, "score": 223645.53522762924 }, { "content": "/// \\brief ModelingError is thrown if a Method commits a modeling error.\n\n///\n\n/// ModelingError is thrown if a Method is commits a modeling error. An example might be\n\n/// if energy is not conserved or if a probability distribution isn't normalized. \n\nclass ModelingError : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tModelingError(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Method has committed a modeling error. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/MethodExcept.hh", "rank": 58, "score": 223645.53522762924 }, { "content": "class LowWeightParticle : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception \n\n //was thrown.\n\n\tLowWeightParticle(const Particle& P, unsigned int line_number,\n\n const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n string msg() const {\n\n ostringstream out;\n\n out << \"Particle was killed due to low weight.\\n\";\n\n return out.str();\n\n }\n\n\n\n};\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/MonteCarloExcept.h", "rank": 59, "score": 223645.53522762924 }, { "content": "/// \\brief DimensionMismatch is thrown if the users inputs data that is inconsistent in dimension.\n\n///\n\n/// DimensionMismatch is thrown if the users inputs data that is inconsistent in dimension. An example\n\n/// of this might be if the number of problem regions does not match the number of materials, or if the\n\n/// the number of time delta-ts does not match the number of times requested for output. \n\nclass DimensionMismatch : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tDimensionMismatch(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Dimension mismatch in input, check for consistency. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/ProblemExcept.hh", "rank": 60, "score": 223645.53522762924 }, { "content": "/// \\brief Thrown when an iterator is made invalid or an invalid location is dereferenced.\n\n///\n\n/// IteratorOutOfRange is thrown whenever an attempt is made to dereference an iterator that \n\n/// does not point to a valid object, or when an iterator is moved outside the an objects\n\n/// range.\n\nclass IteratorOutOfRange : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tIteratorOutOfRange(unsigned int line_number, const string& file_in)\n\n\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to dereference an invalid iterator at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/IteratorExcept.hh", "rank": 61, "score": 223645.53522762924 }, { "content": "/// \\brief AdvancedTooFar is thrown if a Method is asked to calculate past the last time step.\n\n///\n\n/// AdvancedTooFar is thrown if a Method is asked to calculate past the last time step.\n\nclass AdvancedTooFar : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tAdvancedTooFar(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Method has reached the last time step for this problem. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/MethodExcept.hh", "rank": 62, "score": 223645.53522762924 }, { "content": "/// \\brief InsaneInput is thrown if the users inputs unphysical data.\n\n///\n\n/// InsaneInput is thrown if the users inputs unphysical data, such as negative temperatures,\n\n/// non-increasing time steps, etc. \n\nclass InsaneInput : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInsaneInput(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Dimension mismatch in input, check for consistency. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/ProblemExcept.hh", "rank": 63, "score": 223645.53522762924 }, { "content": "/// \\brief Thrown when an iterator is made invalid or an invalid location is dereferenced.\n\n///\n\n/// IteratorOutOfRange is thrown whenever an attempt is made to dereference an iterator that \n\n/// does not point to a valid object, or when an iterator is moved outside the an objects\n\n/// range.\n\nclass IteratorOutOfRange : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tIteratorOutOfRange(unsigned int line_number, const string& file_in)\n\n\t\t: ExceptionBase(line_number, file_in) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Attempted to dereference an invalid iterator at line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/IteratorExcept.hh", "rank": 64, "score": 223645.53522762924 }, { "content": "/// \\brief Thrown if an invalid initial condition is attempted to be prescribed.\n\n///\n\n/// InvalidInitialCondition is thrown if the user attempts to specify a negative initial condition.\n\n/// This could later be expanded upon to become more intelligent, if desired.\n\nclass InvalidInitialCondition : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInvalidInitialCondition(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Unphysical initial condition encountered, please check. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/PHYSOR/cpp/Exception/ProblemExcept.hh", "rank": 65, "score": 223645.53522762924 }, { "content": "/// \\brief ModelingError is thrown if a Method commits a modeling error.\n\n///\n\n/// ModelingError is thrown if a Method is commits a modeling error. An example might be\n\n/// if energy is not conserved or if a probability distribution isn't normalized. \n\nclass ModelingError : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tModelingError(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Method has committed a modeling error. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/MethodExcept.hh", "rank": 66, "score": 223645.53522762924 }, { "content": "/// \\brief InsaneInput is thrown if the users inputs unphysical data.\n\n///\n\n/// InsaneInput is thrown if the users inputs unphysical data, such as negative temperatures,\n\n/// non-increasing time steps, etc. \n\nclass InsaneInput : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInsaneInput(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Dimension mismatch in input, check for consistency. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/ProblemExcept.hh", "rank": 67, "score": 223645.53522762924 }, { "content": "class GhostElement : public geom_element\n\n{\n\nprivate:\n\n /*! \\brief Requires that the \\c geom_element type satisfy the \n\n * \\c GeometricElementConcept concept. */\n\n BOOST_CLASS_REQUIRE(geom_element, , GeometricElementConcept);\n\n\n\npublic:\n\n /// Alias the \\c geom_element type as \\c ElementType.\n\n typedef geom_element ElementType;\n\n /// Define the id type for the ghost element.\n\n\ttypedef GeomId< GhostElement<ElementType> > Id;\t\n\n\t\n\n\t/*! \\brief Constructor. Takes in the ghosted element and an id.\n\n\t *\n\n\t * Constructor. Takes in a constant reference to the element that we are ghosting,\n\n\t * plus an id number for this ghost element.\n\n\t * \\param[in] element_in The geometric element we are using as a \"mirror\" for the\n\n\t * ghost element.\n\n\t * \\param[in] id_in The id number of the ghost element.*/\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/GhostElement.hh", "rank": 68, "score": 222722.7594529945 }, { "content": "class LowWeightParticle : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception \n\n //was thrown.\n\n\tLowWeightParticle(const Particle& P, unsigned int line_number,\n\n const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n string msg() const {\n\n ostringstream out;\n\n out << \"Particle was killed due to low weight.\\n\";\n\n return out.str();\n\n }\n\n\n\n};\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/MonteCarloExcept.h", "rank": 69, "score": 221377.04399228684 }, { "content": "class Iterator_AssignmentOutOfRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */ \n\n Iterator_AssignmentOutOfRange(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 70, "score": 221377.04399228684 }, { "content": "class AVAccessOutOfRange : public AngularBaseException\n\n{\n\nprivate:\n\n BOOST_CLASS_REQUIRE(angle_vector_type, , AngleVectorConcept);\n\n\n\npublic:\n\n typedef angle_vector_type AngleVectorType;\n\n typedef typename angle_vector_type::IndexType IndexType;\n\n\n\n AVAccessOutOfRange(const angle_vector_type& av_in,\n\n const IndexType& bad_iter_in,\n\n LineNumType line_number, const char* file_in)\n\n : AngularBaseException(line_number, file_in),\n\n mAngleVector(av_in),\n\n mBadIter(bad_iter_in)\n\n { }\n\n \n\n \n\n const AngleVectorType& getAngleVector() const\n\n {\n", "file_path": "Code/trunk/cpp/Geometry/Exception/AngleExcept.hh", "rank": 71, "score": 221377.04399228684 }, { "content": "class Iterator_DereferenceOutOfRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n Iterator_DereferenceOutOfRange(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 72, "score": 221377.04399228684 }, { "content": "/// \\brief Thrown if an invalid initial condition is attempted to be prescribed.\n\n///\n\n/// InvalidInitialCondition is thrown if the user attempts to specify a negative initial condition.\n\n/// This could later be expanded upon to become more intelligent, if desired.\n\nclass InvalidInitialCondition : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInvalidInitialCondition(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Unphysical initial condition encountered, please check. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/ProblemExcept.hh", "rank": 73, "score": 221377.04399228684 }, { "content": "/// \\brief Thrown if an invalid initial condition is attempted to be prescribed.\n\n///\n\n/// InvalidInitialCondition is thrown if the user attempts to specify a negative initial condition.\n\n/// This could later be expanded upon to become more intelligent, if desired.\n\nclass InvalidInitialCondition : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception was thrown.\n\n\tInvalidInitialCondition(unsigned int line_number, const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n\t/// Prints out a helpful message.\n\n\tstring msg() const\n\n\t{\n\n\t\tostringstream out;\n\n\t\tout << \"Unphysical initial condition encountered, please check. Exception thrown from line \"\n\n\t\t\t<< line() << \" in file \" << file();\n\n\t\treturn out.str();\n\n\t}\n\n};\n\n\n\n\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Exception/ProblemExcept.hh", "rank": 74, "score": 221377.04399228684 }, { "content": "class Iterator_ConstructionOutOfRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */ \n\n Iterator_ConstructionOutOfRange(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 75, "score": 221377.04399228684 }, { "content": "class LowWeightParticle : public ExceptionBase\n\n{\n\npublic:\n\n\t/// The constructor takes the line number and filename where the exception \n\n //was thrown.\n\n\tLowWeightParticle(const Particle& P, unsigned int line_number,\n\n const string& file)\n\n\t\t: ExceptionBase(line_number, file) { }\n\n\n\n string msg() const {\n\n ostringstream out;\n\n out << \"Particle was killed due to low weight.\\n\";\n\n return out.str();\n\n }\n\n\n\n};\n\n\n", "file_path": "Code/branches/OldGeometry/cpp/Exception/MonteCarloExcept.h", "rank": 76, "score": 221377.04399228684 }, { "content": "class BadAngleQuadOrder : public AngularBaseException\n\n{\n\nprivate:\n\n /// Requires the \\c angle_quad_type to satisfy the \\c AngleQuadConcept.\n\n BOOST_CLASS_REQUIRE(angle_quad_type, , AngleQuadConcept);\n\n\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c AngularBaseException base class.\n\n typedef AngularBaseException::LineNumType LineNumType;\n\n /// Defines the \\c AngleQuadType from the \\c angle_quad_type template parameter.\n\n typedef angle_quad_type AngleQuadType;\n\n \n\n /*! \\brief Constructor. Takes in the bad angular quadrature object and the line number\n\n * and filename where the exception was thrown.\n\n *\n\n * Constructor. Takes in the bad \\c AngleQuad angular quadrature object and the\n\n * line number and filename where the exception was thrown.\n\n * \\param[in] angle_quad_in The \\c AngleQuad object where the error occurred.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] file_in The file where the exception was thrown. */\n", "file_path": "Code/trunk/cpp/Geometry/Exception/AngleExcept.hh", "rank": 77, "score": 219175.64515000366 }, { "content": "class Iterator_AdvanceBeyondRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown and the distance advanced.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown\n\n * and the distance of the attempted advance.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. \n\n * \\param[in] n The distance of the attempted advance. */\n\n Iterator_AdvanceBeyondRange(LineNumType line_number,\n\n const char* filename,\n\n UnsignedInt4 n)\n\n : IteratorBaseException(line_number, filename),\n\n mAdvanceDistance(n)\n\n { }\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 78, "score": 219175.64515000366 }, { "content": "class Iterator_IncrementBeyondRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n Iterator_IncrementBeyondRange(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 79, "score": 219175.64515000366 }, { "content": "class AngleQuadRangeError : public AngularBaseException\n\n{\n\nprivate:\n\n /// Requires that the \\c angle_quad_type template parameter satisfies the \\c AngleQuadConcept.\n\n BOOST_CLASS_REQUIRE(angle_quad_type, , AngleQuadConcept);\n\n\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c AngularBaseException base class.\n\n typedef AngularBaseException::LineNumType LineNumType;\n\n /// Defines the \\c AngleQuadType from the \\c angle_quad_type template parameter.\n\n typedef angle_quad_type AngleQuadType;\n\n /// Imports the \\c AngleQuadType::IndexType as \\c IndexType.\n\n typedef typename AngleQuadType::IndexType IndexType;\n\n\n\n /*! \\brief Constructor. Takes the angular quadrature object, the offending index, and the\n\n * line and file where the exception was thrown.\n\n *\n\n * Constructor. Takes the angular quadrature object that threw this exception, the index\n\n * number that caused the error, and the line number and filename where the exception was\n\n * thrown.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/AngleExcept.hh", "rank": 80, "score": 219175.64515000366 }, { "content": "class Iterator_DecrementBeyondRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n Iterator_DecrementBeyondRange(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 81, "score": 219175.64515000366 }, { "content": "class Iterator_CheckedIteratorLacksContainer : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */ \n\n Iterator_CheckedIteratorLacksContainer(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 82, "score": 217038.40561041544 }, { "content": "class RevIter_ReverseIncrementBeyondRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n RevIter_ReverseIncrementBeyondRange(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n\n * \\return A \\c string holding a helpful error message. */ \n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 84, "score": 214962.5607961148 }, { "content": "class RevIter_ReverseDecrementBeyondRange : public IteratorBaseException\n\n{\n\npublic:\n\n /// Imports the \\c LineNumType from the \\c IteratorBaseException base class.\n\n typedef IteratorBaseException::LineNumType LineNumType;\n\n\n\n\t/*! \\brief Constructor. Takes in the line number and filename where the exception \n\n\t * was thrown.\n\n *\n\n * Constructor. Takes in the line number and filename where the exception was thrown.\n\n * \\param[in] line_number The line number where the exception was thrown.\n\n * \\param[in] filename The filename where the exception was thrown. */\n\n RevIter_ReverseDecrementBeyondRange(LineNumType line_number,\n\n const char* filename)\n\n : IteratorBaseException(line_number, filename)\n\n { }\n\n \n\n /*! \\brief Returns a helpful error message.\n\n *\n\n * Returns a \\c string holding a helpful error message.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/IteratorExcept.hh", "rank": 85, "score": 214962.5607961148 }, { "content": "class Angle : public Angle_base<dimension_type>, boost::noncopyable\n\n{ \n\nprivate:\n\n /// The default constructor is private to prevent instantiation.\n\n Angle();\n\n};\n\n\n\n\n\n\n\n/// @}\n\n\n\n#endif\n\n\n", "file_path": "Code/trunk/cpp/Geometry/AngleQuad/Angle_base.hh", "rank": 86, "score": 214902.3845402577 }, { "content": "class WrongSizedField : public FieldBaseException<field_type>\n\n{\n\nprivate:\n\n /// Requires that the \\c field_type satisfy the \\c FieldConcept concept.\n\n BOOST_CLASS_REQUIRE(field_type, , FieldConcept); \n\n\n\npublic:\n\n /// Imports the \\c LineNumType from \\c ExceptionBase.\n\n typedef typename FieldBaseException<field_type>::LineNumType LineNumType;\n\n /// Defines the \\c field_type template paramater as \\c FieldType.\n\n typedef field_type FieldType;\n\n /// Defines the type of the \\c CartesianMesh that corresponds to this \\c Field.\n\n typedef typename FieldType::MeshType MeshType;\n\n\n\n /*! \\brief Constructor. Takes in the \\c Field from which the exception was thrown, the\n\n * \\c CartesianMesh and the line number and filename.\n\n *\n\n * Constructor. Takes in the \\c CartesianMesh that corresponds to the \\c Field from which\n\n * this exception was thrown and a reference to the \\c Field from which the exception was thrown.\n\n * Also takes in the line number and the name of the file where the exception was thrown.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/FieldExcept.hh", "rank": 87, "score": 211036.28385292567 }, { "content": "class FieldRangeError : public FieldBaseException<field_type>\n\n{\n\nprivate:\n\n /// Requires that the \\c field_type satisfy the \\c FieldConcept concept.\n\n BOOST_CLASS_REQUIRE(field_type, , FieldConcept); \n\n\n\npublic:\n\n /// Imports the \\c LineNumType from \\c ExceptionBase.\n\n typedef typename FieldBaseException<field_type>::LineNumType LineNumType;\n\n /// Defines the \\c field_type template paramater as \\c FieldType.\n\n typedef field_type FieldType;\n\n\n\n /*! \\brief Constructor. Takes in the \\c CenteringType object of the attempted access, the\n\n * \\c Field and the line number and filename.\n\n *\n\n * Constructor. Takes in the \\c geom_elem used in the failed data access, and the \\c Field \n\n * from which this exception was thrown.\n\n * Also takes in the line number and the name of the file where the exception was thrown.\n\n * \\param[in] geom_elem A reference to the geometric element used in the attempted data\n\n * access.\n", "file_path": "Code/trunk/cpp/Geometry/Exception/FieldExcept.hh", "rank": 88, "score": 211036.28385292567 }, { "content": "class Iterator : public iterator_facade< Iterator<container_type, base_type>, \n\n typename iterator_traits<base_type>::value_type, \n\n typename iterator_traits<base_type>::iterator_category,\n\n typename iterator_traits<base_type>::reference >\n\n{\n\nprivate:\n\n /*! \\brief Requires that the \\c container_type template parameter satisfy the \n\n * \\c MinimalContainerConcept concept. */\n\n BOOST_CLASS_REQUIRE(container_type, , MinimalContainerConcept);\n\n /*! \\brief Requires that the \\c base_type template parameter satisfy the\n\n * \\c boost::InputIteratorConcept concept. */\n\n BOOST_CLASS_REQUIRE(base_type, boost, InputIteratorConcept);\n\n \n\npublic:\n\n // ****** Type Definitions ******\n\n /// Defines the type of container that is iterated over.\n\n typedef container_type ContainerType;\n\n /// Defines the type of basic iterator that underlies Iterator.\n\n typedef base_type BaseType; \n\n /// Defines the value type that the Iterator points to.\n", "file_path": "Code/trunk/cpp/Geometry/Misc/Iterator.hh", "rank": 89, "score": 203726.807623786 }, { "content": "class Angle<OneD> : public Angle_base<OneD>\n\n{\n\nprivate:\n\n /// Defines \\c Angle_base<OneD> as the \\c Base type.\n\n typedef Angle_base<OneD> Base;\n\n \n\npublic:\n\n /// Imports the \\c AngleType from the \\c Base type.\n\n\ttypedef Base::AngleType AngleType;\n\n\t/// Imports the \\c WeightType from the \\c Base type.\n\n\ttypedef Base::WeightType WeightType;\n\n\n\n\t/*! \\brief Constructor. Takes in an angle and a weight for this quadrature point.\n\n\t *\n\n\t * Constructor. Takes in an angle and a weight for this quadrature point.\n\n\t * \\param[in] angle_in The angle for this quadrature point.\n\n\t * \\param[in] weight_in The weight for this quadrature point. */\n\n\texplicit Angle(const AngleType& angle_in = AngleType(), WeightType weight_in = WeightType() )\n\n\t\t\t: Angle_base<OneD>(angle_in, weight_in)\n\n\t{ }\n", "file_path": "Code/trunk/cpp/Geometry/AngleQuad/OneD/Angle1D.hh", "rank": 90, "score": 201858.939656259 }, { "content": "class Base {\n\npublic:\n\n\n\n virtual void Express(S x) = 0;\n\n\n\nprotected:\n\n Base(S& init) : _bVar(3.7), _SVar(init) { }\n\n S _SVar;\n\n\n\nprivate:\n\n double _bVar;\n\n};\n\n\n\ntemplate<class S>\n", "file_path": "Code/trunk/cpp/test/general.hpp", "rank": 91, "score": 201722.97626992513 }, { "content": "class Iterator : public iterator< typename iterator_traits<Iter>::iterator_category,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::value_type,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::difference_type,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::pointer,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::reference >\n\n{\n\npublic:\n\n\t/// Type of unchecked-iterators we are using\n\n\ttypedef Iter iterator_type;\n\n\n\n\t/// Default constructor.\n\n\tIterator() : mContainer(), mIter() { }\n\n\t/// Constructor taking a container and an iterator into that container\n\n Iterator(const Cont& cont_in, const Iter& x) throw(IteratorOutOfRange)\n\n\t\t\t: mContainer(addressof(cont_in)), mIter(x)\n\n\t{ \n\n#ifndef NITERCHK\n\n\t\tif(mIter > mContainer->end() || mIter < mContainer->begin()-1)\n\n\t\t\tthrow(IteratorOutOfRange(__LINE__, __FILE__));\n\n#endif\n", "file_path": "Code/branches/PHYSOR/cpp/Misc/Iterator.hh", "rank": 92, "score": 200121.63681158694 }, { "content": "class GhostElement< Zone<OneD> > : public Zone<OneD>\n\n{\n\npublic:\n\n /// The ElementType, which for this specialization is always a ghost zone.\n\n typedef Zone<OneD> ElementType;\n\n /// The Id type for one-dimensional ghost zones.\n\n typedef GeomId< GhostElement< Zone<OneD> > > Id;\n\n \n\n /*! \\brief Constructor. Takes a \\c Zone and an \\c Id object.\n\n * \n\n * Constructor. This constructor takes a \\c Zone and an \\c Id object.\n\n * This constructor ensures that the ghost zone has the same length\n\n * as the ghosted zone.\n\n * \\param[in] zone_in The \\c Zone we are ghosting.\n\n * \\param[in] id_in The \\c Id number for this ghost zone. */\n\n GhostElement(const Zone<OneD>& zone_in, const Id& id_in)\n\n : Zone<OneD>( Zone<OneD>::Id( id_in.idNumber() ), \n\n zone_in.length(), zone_in.area() ),\n\n mGhostedElement( addressof( zone_in ) )\n\n { }\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/GhostElement.hh", "rank": 93, "score": 198643.9631391678 }, { "content": "class Iterator : public iterator< typename iterator_traits<Iter>::iterator_category,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::value_type,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::difference_type,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::pointer,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::reference >\n\n{\n\npublic:\n\n\t/// Type of unchecked-iterators we are using\n\n\ttypedef Iter iterator_type;\n\n\n\n\t/// Default constructor.\n\n\tIterator() : mContainer(), mIter() { }\n\n\t/// Constructor taking a container and an iterator into that container\n\n Iterator(const Cont& cont_in, const Iter& x) throw(IteratorOutOfRange)\n\n\t\t\t: mContainer(addressof(cont_in)), mIter(x)\n\n\t{ \n\n#ifndef NITERCHK\n\n\t\tif(mIter > mContainer->end() || mIter < mContainer->begin()-1)\n\n\t\t\tthrow(IteratorOutOfRange(__LINE__, __FILE__));\n\n#endif\n", "file_path": "Code/branches/OldGeometry/cpp/Misc/Iterator.hh", "rank": 94, "score": 197981.79473327936 }, { "content": "class Iterator : public iterator< typename iterator_traits<Iter>::iterator_category,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::value_type,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::difference_type,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::pointer,\n\n\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::reference >\n\n{\n\npublic:\n\n\t/// Type of unchecked-iterators we are using\n\n\ttypedef Iter iterator_type;\n\n\n\n\t/// Default constructor.\n\n\tIterator() : mContainer(), mIter() { }\n\n\t/// Constructor taking a container and an iterator into that container\n\n Iterator(const Cont& cont_in, const Iter& x) throw(IteratorOutOfRange)\n\n\t\t\t: mContainer(addressof(cont_in)), mIter(x)\n\n\t{ \n\n#ifndef NITERCHK\n\n\t\tif(mIter > mContainer->end() || mIter < mContainer->begin()-1)\n\n\t\t\tthrow(IteratorOutOfRange(__LINE__, __FILE__));\n\n#endif\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Misc/Iterator.hh", "rank": 95, "score": 197981.79473327933 }, { "content": "class ReverseIterator : public iterator< typename iterator_traits<Iter>::iterator_category,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::value_type,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::difference_type,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::pointer,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::reference >\n\n{\n\npublic:\n\n\t/// Type of iterator we are reversing over\n\n typedef Iter iterator_type;\n\n\n\n\t/// Default constructor\n\n ReverseIterator() : mIter() { }\n\n /// Constructor taking a forward iterator\n\n explicit ReverseIterator(const Iter& x) throw(IteratorOutOfRange)\n\n\t\t\t: mIter(x)\n\n\t{ }\n\n /// Constructor taking a reverse iterator\n\n template<typename Iter_2>\n\n ReverseIterator(const ReverseIterator<Iter_2>& iter_in)\n\n\t\t\t: mIter(iter_in.base())\n", "file_path": "Code/branches/PHYSOR/cpp/Misc/ReverseIterator.hh", "rank": 96, "score": 195903.42214125206 }, { "content": "class DimensionConcept\n\n{\n\npublic:\n\n /// Alias the \\c dimension_type as a \\c DimensionType.\n\n typedef dimension_type DimensionType;\n\n /// Require the \\c DimensionType to provide a \\c type.\n\n typedef typename DimensionType::type type;\n\n /// Require the \\c DimensionType to provide a \\c value_type.\n\n typedef typename DimensionType::value_type value_type;\n\n\n\n /*! \\brief The constraints method tests that the \\c dimension_type \n\n * provides certain functionality. */\n\n void constraints()\n\n {\n\n function_requires< UnsignedIntegerConcept<value_type> >();\n\n \n\n BOOST_STATIC_ASSERT(DimensionType::value <= 3 \n\n && DimensionType::value != 0);\n\n }\n\n};\n\n\n\n/// @}\n\n\n\n#endif\n\n\n", "file_path": "Code/trunk/cpp/Geometry/CartesianMesh/Dimension.hh", "rank": 97, "score": 195260.57098513894 }, { "content": "/// \\brief The SweepIter class iterates over the zones in a sweep pattern.\n\n///\n\n/// The SweepIter class iterates over the zones in the correct order for a sweeping pattern\n\n/// given the streaming angle \\f$ \\mu \\f$.\n\nclass SweepIter : public iterator< std::bidirectional_iterator_tag, Zone >\n\n{\n\npublic:\n\n\t/// Default constructor.\n\n\tSweepIter()\n\n\t: mMu(0), mCont(0), mIter() { }\n\n\n\n\t/// Constructor taking an angle, a reference to the zone container, and a const_iterator.\n\n SweepIter(double mu, const vector<Zone>& cont_in, const vector<Zone>::const_iterator iter_in)\n\n : mMu(mu), mCont( addressof(cont_in) ), mIter(iter_in) { }\n\n \n\n /// Copy constructor\n\n SweepIter(const SweepIter& iter_in)\n\n : mMu(iter_in.mMu), mCont( iter_in.mCont ), mIter(iter_in.mIter) { }\n\n \n\n /// Retrieve the iterator into the zone vector\n\n const vector<Zone>::const_iterator& iterator() const { return mIter; }\n\n /// Retrieve the container\n\n const vector<Zone>& container() const { return *mCont; }\n\n /// Retrieve the angle\n", "file_path": "Code/branches/PHYSOR/cpp/Geometry/OneDMesh/SweepIter.hh", "rank": 98, "score": 194696.877464734 }, { "content": "class ReverseIterator : public iterator< typename iterator_traits<Iter>::iterator_category,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::value_type,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::difference_type,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::pointer,\n\n\t\t\t\t\t\t\t\t\t\t typename iterator_traits<Iter>::reference >\n\n{\n\npublic:\n\n\t/// Type of iterator we are reversing over\n\n typedef Iter iterator_type;\n\n\n\n\t/// Default constructor\n\n ReverseIterator() : mIter() { }\n\n /// Constructor taking a forward iterator\n\n explicit ReverseIterator(const Iter& x) throw(IteratorOutOfRange)\n\n\t\t\t: mIter(x)\n\n\t{ }\n\n /// Constructor taking a reverse iterator\n\n template<typename Iter_2>\n\n ReverseIterator(const ReverseIterator<Iter_2>& iter_in)\n\n\t\t\t: mIter(iter_in.base())\n", "file_path": "Code/branches/Pre-Prospectus/cpp/Misc/ReverseIterator.hh", "rank": 99, "score": 193883.90786479716 } ]
C++
OpenSees/SRC/element/PFEMElement/TclModelBuilder_addPFEMElement.cpp
kuanshi/ductile-fracture
ccb350564df54f5c5ec3a079100effe261b46650
#include "TclModelBuilder_addPFEMElement.h" #include "PFEMElement2D.h" #include "PFEMElement2DFIC.h" #include "PFEMElement2DCompressible.h" #include "PFEMElement2DBubble.h" #include "PFEMElement2Dmini.h" #include "PFEMElement3D.h" #include <cstring> #include <string> int TclModelBuilder_addPFEMElement2D(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv, Domain *theDomain, TclModelBuilder *theBuilder) { if(argc < 11) { opserr << "Invalid #args: want element PFEMElement2D tag"; opserr << "nd1 nd2 nd3 type rho mu b1 b2 <thickness kappa>\n"; return TCL_ERROR; } int loc = 2; int tag; if(Tcl_GetInt(interp, argv[loc], &tag) != TCL_OK) { opserr<< "WARNING invalid tag "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int nd1; if(Tcl_GetInt(interp, argv[loc], &nd1) != TCL_OK) { opserr<< "WARNING invalid nd1 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int nd2; if(Tcl_GetInt(interp, argv[loc], &nd2) != TCL_OK) { opserr<< "WARNING invalid nd2 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int nd3; if(Tcl_GetInt(interp, argv[loc], &nd3) != TCL_OK) { opserr<< "WARNING invalid nd3 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int type = -1; if(strcmp(argv[loc], "FIC")==0 || strcmp(argv[loc], "fic")==0 || strcmp(argv[loc], "Fic")==0) { type = 0; } else if(strcmp(argv[loc], "quasi-incompressible")==0 || strcmp(argv[loc], "Quasi-Incompressible")==0) { type = 1; } else if(strcmp(argv[loc], "bubble")==0 || strcmp(argv[loc], "Bubble")==0) { type = 2; } else if(strcmp(argv[loc], "mini")==0 || strcmp(argv[loc], "Mini")==0) { type = 3; } else { opserr<<"WARNNG: unknown type for PFEMElement2D \n"; return TCL_ERROR; } loc++; double rho; if(Tcl_GetDouble(interp, argv[loc], &rho) != TCL_OK) { opserr<< "WARNING invalid rho "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double mu; if(Tcl_GetDouble(interp, argv[loc], &mu) != TCL_OK) { opserr<< "WARNING invalid mu "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double b1; if(Tcl_GetDouble(interp, argv[loc], &b1) != TCL_OK) { opserr<< "WARNING invalid b1 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double b2; if(Tcl_GetDouble(interp, argv[loc], &b2) != TCL_OK) { opserr<< "WARNING invalid b2 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double thickness = 1.0; if(argc > loc) { if(Tcl_GetDouble(interp, argv[loc], &thickness) != TCL_OK) { opserr<< "WARNING invalid thickness "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; double kappa = 2.2e9; if(argc > loc) { if(Tcl_GetDouble(interp, argv[loc], &kappa) != TCL_OK) { opserr<< "WARNING invalid kappa "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; int lumped = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &lumped) != TCL_OK) { opserr<< "WARNING invalid lumped "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; int checkJ = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &checkJ) != TCL_OK) { opserr<< "WARNING invalid checkJ "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; Element* ele = 0; if(type == 0) { ele = new PFEMElement2DFIC(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness); } else if(type == 1) { ele = new PFEMElement2DCompressible(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness,kappa); } else if(type == 2) { ele = new PFEMElement2DBubble(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness,kappa); } else if(type == 3) { ele = new PFEMElement2Dmini(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness,kappa,lumped,checkJ); } if (ele == 0) { opserr << "WARNING ran out of memory creating element\n"; opserr << "element: " << tag << endln; return TCL_ERROR; } if (theDomain->addElement(ele) == false) { opserr << "WARNING failed to add element to the domain\n"; opserr << "element: " << tag << endln; delete ele; return TCL_ERROR; } return TCL_OK; } int TclModelBuilder_addPFEMElement3D(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv, Domain *theDomain, TclModelBuilder *theBuilder) { if(argc < 13) { opserr << "Invalid #args: want element PFEMElement3D "; opserr << "tag nd1 nd2 nd3 nd4 type rho mu b1 b2 b3 <kappa lumped checkJ>\n"; return TCL_ERROR; } int loc = 2; int tag; if(Tcl_GetInt(interp, argv[loc], &tag) != TCL_OK) { opserr<< "WARNING invalid tag "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd1; if(Tcl_GetInt(interp, argv[loc], &nd1) != TCL_OK) { opserr<< "WARNING invalid nd1 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd2; if(Tcl_GetInt(interp, argv[loc], &nd2) != TCL_OK) { opserr<< "WARNING invalid nd2 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd3; if(Tcl_GetInt(interp, argv[loc], &nd3) != TCL_OK) { opserr<< "WARNING invalid nd3 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd4; if(Tcl_GetInt(interp, argv[loc], &nd4) != TCL_OK) { opserr<< "WARNING invalid nd4 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; std::string type = argv[loc]; loc++; double rho; if(Tcl_GetDouble(interp, argv[loc], &rho) != TCL_OK) { opserr<< "WARNING invalid rho "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double mu; if(Tcl_GetDouble(interp, argv[loc], &mu) != TCL_OK) { opserr<< "WARNING invalid mu "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double b1; if(Tcl_GetDouble(interp, argv[loc], &b1) != TCL_OK) { opserr<< "WARNING invalid b1 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double b2; if(Tcl_GetDouble(interp, argv[loc], &b2) != TCL_OK) { opserr<< "WARNING invalid b2 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double b3; if(Tcl_GetDouble(interp, argv[loc], &b3) != TCL_OK) { opserr<< "WARNING invalid b3 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double kappa = 2.2e9; if(argc > loc) { if(Tcl_GetDouble(interp, argv[loc], &kappa) != TCL_OK) { opserr<<"WARNING invalid kappa "<<argv[loc]<<": element PFEMElement3D\n"; return TCL_ERROR; } loc++; } int lumped = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &lumped) != TCL_OK) { opserr<<"WARNING invalid lumped "<<argv[loc]<<": element PFEMElement3D\n"; return TCL_ERROR; } loc++; } int check = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &check) != TCL_OK) { opserr<<"WARNING invalid check "<<argv[loc]<<": element PFEMElement3D\n"; return TCL_ERROR; } loc++; } Element* ele = 0; if(type == "pressuregradient" || type == "PressureGradient") { ele = new PFEMElement3D(tag,nd1,nd2,nd3,nd4,rho,mu,b1,b2,b3); } else { opserr<<"element PFEMElement3D type "<<type.c_str()<<" is not known\n"; return TCL_ERROR; } if (ele == 0) { opserr << "WARNING ran out of memory creating element\n"; opserr << "element: " << tag << endln; return TCL_ERROR; } if (theDomain->addElement(ele) == false) { opserr << "WARNING failed to add element to the domain\n"; opserr << "element: " << tag << endln; delete ele; return TCL_ERROR; } return TCL_OK; }
#include "TclModelBuilder_addPFEMElement.h" #include "PFEMElement2D.h" #include "PFEMElement2DFIC.h" #include "PFEMElement2DCompressible.h" #include "PFEMElement2DBubble.h" #include "PFEMElement2Dmini.h" #include "PFEMElement3D.h" #include <cstring> #include <string>
int TclModelBuilder_addPFEMElement3D(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv, Domain *theDomain, TclModelBuilder *theBuilder) { if(argc < 13) { opserr << "Invalid #args: want element PFEMElement3D "; opserr << "tag nd1 nd2 nd3 nd4 type rho mu b1 b2 b3 <kappa lumped checkJ>\n"; return TCL_ERROR; } int loc = 2; int tag; if(Tcl_GetInt(interp, argv[loc], &tag) != TCL_OK) { opserr<< "WARNING invalid tag "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd1; if(Tcl_GetInt(interp, argv[loc], &nd1) != TCL_OK) { opserr<< "WARNING invalid nd1 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd2; if(Tcl_GetInt(interp, argv[loc], &nd2) != TCL_OK) { opserr<< "WARNING invalid nd2 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd3; if(Tcl_GetInt(interp, argv[loc], &nd3) != TCL_OK) { opserr<< "WARNING invalid nd3 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; int nd4; if(Tcl_GetInt(interp, argv[loc], &nd4) != TCL_OK) { opserr<< "WARNING invalid nd4 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; std::string type = argv[loc]; loc++; double rho; if(Tcl_GetDouble(interp, argv[loc], &rho) != TCL_OK) { opserr<< "WARNING invalid rho "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double mu; if(Tcl_GetDouble(interp, argv[loc], &mu) != TCL_OK) { opserr<< "WARNING invalid mu "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double b1; if(Tcl_GetDouble(interp, argv[loc], &b1) != TCL_OK) { opserr<< "WARNING invalid b1 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double b2; if(Tcl_GetDouble(interp, argv[loc], &b2) != TCL_OK) { opserr<< "WARNING invalid b2 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double b3; if(Tcl_GetDouble(interp, argv[loc], &b3) != TCL_OK) { opserr<< "WARNING invalid b3 "<< argv[loc] << ": element PFEMElement3D\n"; return TCL_ERROR; } loc++; double kappa = 2.2e9; if(argc > loc) { if(Tcl_GetDouble(interp, argv[loc], &kappa) != TCL_OK) { opserr<<"WARNING invalid kappa "<<argv[loc]<<": element PFEMElement3D\n"; return TCL_ERROR; } loc++; } int lumped = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &lumped) != TCL_OK) { opserr<<"WARNING invalid lumped "<<argv[loc]<<": element PFEMElement3D\n"; return TCL_ERROR; } loc++; } int check = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &check) != TCL_OK) { opserr<<"WARNING invalid check "<<argv[loc]<<": element PFEMElement3D\n"; return TCL_ERROR; } loc++; } Element* ele = 0; if(type == "pressuregradient" || type == "PressureGradient") { ele = new PFEMElement3D(tag,nd1,nd2,nd3,nd4,rho,mu,b1,b2,b3); } else { opserr<<"element PFEMElement3D type "<<type.c_str()<<" is not known\n"; return TCL_ERROR; } if (ele == 0) { opserr << "WARNING ran out of memory creating element\n"; opserr << "element: " << tag << endln; return TCL_ERROR; } if (theDomain->addElement(ele) == false) { opserr << "WARNING failed to add element to the domain\n"; opserr << "element: " << tag << endln; delete ele; return TCL_ERROR; } return TCL_OK; }
int TclModelBuilder_addPFEMElement2D(ClientData clientData, Tcl_Interp *interp, int argc, TCL_Char **argv, Domain *theDomain, TclModelBuilder *theBuilder) { if(argc < 11) { opserr << "Invalid #args: want element PFEMElement2D tag"; opserr << "nd1 nd2 nd3 type rho mu b1 b2 <thickness kappa>\n"; return TCL_ERROR; } int loc = 2; int tag; if(Tcl_GetInt(interp, argv[loc], &tag) != TCL_OK) { opserr<< "WARNING invalid tag "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int nd1; if(Tcl_GetInt(interp, argv[loc], &nd1) != TCL_OK) { opserr<< "WARNING invalid nd1 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int nd2; if(Tcl_GetInt(interp, argv[loc], &nd2) != TCL_OK) { opserr<< "WARNING invalid nd2 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int nd3; if(Tcl_GetInt(interp, argv[loc], &nd3) != TCL_OK) { opserr<< "WARNING invalid nd3 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; int type = -1; if(strcmp(argv[loc], "FIC")==0 || strcmp(argv[loc], "fic")==0 || strcmp(argv[loc], "Fic")==0) { type = 0; } else if(strcmp(argv[loc], "quasi-incompressible")==0 || strcmp(argv[loc], "Quasi-Incompressible")==0) { type = 1; } else if(strcmp(argv[loc], "bubble")==0 || strcmp(argv[loc], "Bubble")==0) { type = 2; } else if(strcmp(argv[loc], "mini")==0 || strcmp(argv[loc], "Mini")==0) { type = 3; } else { opserr<<"WARNNG: unknown type for PFEMElement2D \n"; return TCL_ERROR; } loc++; double rho; if(Tcl_GetDouble(interp, argv[loc], &rho) != TCL_OK) { opserr<< "WARNING invalid rho "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double mu; if(Tcl_GetDouble(interp, argv[loc], &mu) != TCL_OK) { opserr<< "WARNING invalid mu "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double b1; if(Tcl_GetDouble(interp, argv[loc], &b1) != TCL_OK) { opserr<< "WARNING invalid b1 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double b2; if(Tcl_GetDouble(interp, argv[loc], &b2) != TCL_OK) { opserr<< "WARNING invalid b2 "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } loc++; double thickness = 1.0; if(argc > loc) { if(Tcl_GetDouble(interp, argv[loc], &thickness) != TCL_OK) { opserr<< "WARNING invalid thickness "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; double kappa = 2.2e9; if(argc > loc) { if(Tcl_GetDouble(interp, argv[loc], &kappa) != TCL_OK) { opserr<< "WARNING invalid kappa "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; int lumped = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &lumped) != TCL_OK) { opserr<< "WARNING invalid lumped "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; int checkJ = 0; if(argc > loc) { if(Tcl_GetInt(interp, argv[loc], &checkJ) != TCL_OK) { opserr<< "WARNING invalid checkJ "<< argv[loc] << ": element PFEMElement2D\n"; return TCL_ERROR; } } loc++; Element* ele = 0; if(type == 0) { ele = new PFEMElement2DFIC(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness); } else if(type == 1) { ele = new PFEMElement2DCompressible(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness,kappa); } else if(type == 2) { ele = new PFEMElement2DBubble(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness,kappa); } else if(type == 3) { ele = new PFEMElement2Dmini(tag,nd1,nd2,nd3,rho,mu,b1,b2,thickness,kappa,lumped,checkJ); } if (ele == 0) { opserr << "WARNING ran out of memory creating element\n"; opserr << "element: " << tag << endln; return TCL_ERROR; } if (theDomain->addElement(ele) == false) { opserr << "WARNING failed to add element to the domain\n"; opserr << "element: " << tag << endln; delete ele; return TCL_ERROR; } return TCL_OK; }
function_block-full_function
[ { "content": " CONST char *string;\t\t/* Last string passed to Tcl_RegExpExec. */\n", "file_path": "OpenSees/SRC/tcl/include/tclRegexp.h", "rank": 0, "score": 183596.33256221714 }, { "content": " public TypedIOPort string;\n", "file_path": "OpenSees/SRC/java/kepler/opensees/StringToDouble.java", "rank": 1, "score": 142280.66572606767 }, { "content": "// A first class string type\n\nclass String {\n\npublic:\n\n // Constructors and destructor\n\n String(const char s[] = \"\"); // Constructs a deep copy of a C-string.\n\n // ASSUME: s is a valid C-string.\n\n String(const String& s); // Constructs a deep copy of s.\n\n ~String(); // Deallocates String memory. \n\n\n\n // Assignment operators\n\n String& operator= (const String& rhs); // Assigns a deep copy of rhs. \n\n String& operator+= (const String& rhs); // Adds a deep copy of rhs on the\n\n // end of this string.\n\n\n\n char& operator[](int i); // The element at subscript i. \n\n // ASSUME: i < length of the string\n\n char operator[](int i) const; // The element at subscript i.\n\n // ASSUME: i < length of the string\n\n\n\n int length() const; // Number of string characters.\n\n const char* charString( ) const; // C-String equivalent value.\n", "file_path": "OpenSees/SRC/string/G3string.h", "rank": 2, "score": 133760.52760907522 }, { "content": " char cursorString[20]; /* Used to store a cursor id string. */\n", "file_path": "OpenSees/SRC/tcl/include/tkInt.h", "rank": 3, "score": 124516.9943262054 }, { "content": "char *string;\n", "file_path": "OpenSees/OTHER/Triangle/showme.c", "rank": 4, "score": 124115.46963219905 }, { "content": "class StringContainer\n\n{\n\n public:\n\n StringContainer();\n\n ~StringContainer();\n\n int addString(const char *);\n\n const char *getString(int) const;\n\n const char *operator()(void);\n\n int getNumStrings() const;\n\n void clear(void);\n\n\n\n private:\n\n char **strings;\n\n int numStrings;\n\n};\n\n\n\n#endif\n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.h", "rank": 5, "score": 84974.61283075646 }, { "content": "class StringContainer\n\n{\n\n public:\n\n StringContainer();\n\n ~StringContainer();\n\n int addString(const char *);\n\n const char *getString(int) const;\n\n const char *operator()(void);\n\n int getNumStrings() const;\n\n void clear(void);\n\n\n\n private:\n\n char **strings;\n\n int numStrings;\n\n};\n\n\n\n#endif\n", "file_path": "OpenSees/SRC/utility/StringContainer.h", "rank": 6, "score": 84974.61283075646 }, { "content": "public class StringToDouble extends TypedAtomicActor {\n\n\n\n /** Construct an actor with the given container and name.\n\n * @param container The container.\n\n * @param name The name of this actor.\n\n * @exception IllegalActionException If the actor cannot be contained\n\n * by the proposed container.\n\n * @exception NameDuplicationException If the container already has an\n\n * actor with this name.\n\n */\n\n public StringToDouble(CompositeEntity container, String name)\n\n throws NameDuplicationException, IllegalActionException {\n\n super(container, name);\n\n\n\n string = new TypedIOPort(this, \"string\", true, false);\n\n string.setTypeEquals(BaseType.STRING);\n\n\n\n doublePort = new TypedIOPort(this, \"double\", false, true);\n\n doublePort.setTypeEquals(BaseType.DOUBLE);\n\n }\n\n\n\n ///////////////////////////////////////////////////////////////////\n\n //// public variables ////\n\n\n\n /** The input port, which has type <i>string</i>. */\n\n public TypedIOPort string;\n\n /** The output port, which has type <i>int</i>. */\n\n public TypedIOPort doublePort;\n\n\n\n ///////////////////////////////////////////////////////////////////\n\n //// public methods ////\n\n\n\n /** Consume one string token on the input port and produce a new\n\n * integer token on the output port.\n\n * @exception IllegalActionException If there is no direc/restor.\n\n */\n\n public void fire() throws IllegalActionException {\n\n super.fire();\n\n String _input = ((StringToken)string.get(0)).stringValue();\n\n Double _output = new Double(_input);\n\n doublePort.send(0, new DoubleToken(_output.doubleValue()));\n\n }\n\n\n\n ///////////////////////////////////////////////////////////////////\n\n //// protected members ////\n\n\n\n ///////////////////////////////////////////////////////////////////\n\n //// private methods ////\n\n\n\n ///////////////////////////////////////////////////////////////////\n\n //// private members ////\n", "file_path": "OpenSees/SRC/java/kepler/opensees/StringToDouble.java", "rank": 7, "score": 77843.71757651746 }, { "content": " public void fire() throws IllegalActionException {\n\n super.fire();\n\n String _input = ((StringToken)string.get(0)).stringValue();\n\n Double _output = new Double(_input);\n\n doublePort.send(0, new DoubleToken(_output.doubleValue()));\n", "file_path": "OpenSees/SRC/java/kepler/opensees/StringToDouble.java", "rank": 8, "score": 76919.01572625934 }, { "content": " public TypedIOPort doublePort;\n", "file_path": "OpenSees/SRC/java/kepler/opensees/StringToDouble.java", "rank": 9, "score": 76010.39361000105 }, { "content": "#ifndef _PLSTRING_H\n\n#define _PLSTRING_H\n\n\n\n#include <OPS_Stream.h>\n\n#include <iostream>\n\nusing std::istream;\n\n\n\n// A first class string type\n", "file_path": "OpenSees/SRC/string/G3string.h", "rank": 10, "score": 73627.54508229624 }, { "content": "\n\n // Comparison operators\n\n friend bool operator== (const String& s, const String& t);\n\n friend bool operator!= (const String& s, const String& t);\n\n friend bool operator< (const String& s, const String& t);\n\n friend bool operator<= (const String& s, const String& t);\n\n friend bool operator> (const String& s, const String& t);\n\n friend bool operator>= (const String& s, const String& t);\n\n\n\n friend OPS_Stream& operator<<(OPS_Stream& out, const String& s);\n\n // Writes the C-string equivalent to out.\n\n friend istream& operator>> (istream& in, String & s); \n\n // Reads at most 999 characters up to the next newline from \n\n // from in. The newline is extracted but not assigned. \n\n friend String operator+(const String& s, const String& t); \n\n // A deep copy of s with a deep copy of t appended to the end.\n\n\n\nprivate:\n\n char* info_;\n\n};\n\n\n\n#endif\n\n\n", "file_path": "OpenSees/SRC/string/G3string.h", "rank": 11, "score": 73621.89695457976 }, { "content": "#include <string.h>\n\n#include \"G3string.h\"\n\n\n\nString::String(const char s[])\n\n{\n\n info_ = new char[strlen(s) + 1]; // Leave room for the '\\0'. \n\n strcpy(info_, s); // Copy from s to info.\n\n}\n\n\n\nString::String(const String& s)\n\n{\n\n info_ = new char[strlen(s.info_) + 1]; // Allocate memory for the copy.\n\n strcpy(info_, s.info_); // Copy the argument's characters.\n\n}\n\n\n\nString::~String( )\n\n{\n\n delete [] info_; // Deallocate the array.\n\n}\n\n\n", "file_path": "OpenSees/SRC/string/G3string.cpp", "rank": 12, "score": 71995.1347847162 }, { "content": "{ \n\n return info_;\n\n}\n\n\n\nOPS_Stream& operator<< (OPS_Stream& out, const String& s)\n\n{\n\n out << s.charString();\n\n return out;\n\n}\n\n\n\nistream& operator>> (istream& in, String& s) \n\n{\n\n char buffer[1000]; // Buffer to store the stream characters\n\n in.getline(buffer,1000,'\\n'); // Remove up to 999 characters from in, \n\n // up to and including first occurrence \n\n // of '\\n'. Store all but '\\n' in the \n\n // buffer; terminate the buffer with '\\0'. \n\n s = String(buffer); // Create a new String from the buffer and\n\n // assign it to s.\n\n return in;\n", "file_path": "OpenSees/SRC/string/G3string.cpp", "rank": 13, "score": 71993.07109604166 }, { "content": "// $Revision: 1.1 $\n\n// $Date: 2006-11-08 20:06:10 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/utility/StringContainer.h,v $\n\n \n\n// Written: fmk \n\n// Created: 11/06\n\n//\n\n// Description: This file contains the class definition for StringContainer.\n\n// StringContainer is used to store information about a simulation; this\n\n// includes start and end times; program version, files opened for reading, files\n\n// opened for writing, and all parameters used (specified with pset or -par option\n\n// to program)\n\n//\n\n// What: \"@(#) StringContainer.h, revA\"\n\n\n\n#ifndef StringContainer_h\n\n#define StringContainer_h\n\n\n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.h", "rank": 14, "score": 71992.31031253589 }, { "content": "// $Revision: 1.1 $\n\n// $Date: 2006-11-08 20:06:10 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/utility/StringContainer.h,v $\n\n \n\n// Written: fmk \n\n// Created: 11/06\n\n//\n\n// Description: This file contains the class definition for StringContainer.\n\n// StringContainer is used to store information about a simulation; this\n\n// includes start and end times; program version, files opened for reading, files\n\n// opened for writing, and all parameters used (specified with pset or -par option\n\n// to program)\n\n//\n\n// What: \"@(#) StringContainer.h, revA\"\n\n\n\n#ifndef StringContainer_h\n\n#define StringContainer_h\n\n\n", "file_path": "OpenSees/SRC/utility/StringContainer.h", "rank": 15, "score": 71992.31031253589 }, { "content": "}\n\n\n\nString operator+ (const String& s, const String& t)\n\n{\n\n String temp(s); // temp is a copy of s.\n\n temp += t; // Add t to the end of temp.\n\n return temp; \n\n}\n\n\n\nchar& String::operator[](int i)\n\n{\n\n return info_[i];\n\n} \n\n\n\nchar String::operator[](int i) const\n\n{\n\n return info_[i];\n\n} \n\n\n\nconst char* String::charString() const \n", "file_path": "OpenSees/SRC/string/G3string.cpp", "rank": 16, "score": 71987.6470613427 }, { "content": "}\n\n\n\nint String::length() const\n\n{\n\n return strlen(info_); \n\n}\n\n\n\nbool operator== (const String& s, const String& t)\n\n{\n\n return strcmp(s.info_,t.info_) == 0;\n\n}\n\n\n\nbool operator!= (const String& s, const String& t)\n\n{\n\n return strcmp(s.info_,t.info_) != 0;\n\n}\n\n\n\nbool operator< (const String& s, const String& t)\n\n{\n\n return strcmp(s.info_,t.info_) < 0;\n", "file_path": "OpenSees/SRC/string/G3string.cpp", "rank": 17, "score": 71987.54157057192 }, { "content": "}\n\n\n\nbool operator<= (const String& s, const String& t)\n\n{\n\n return strcmp(s.info_,t.info_) <= 0;\n\n}\n\n\n\nbool operator> (const String& s, const String& t)\n\n{\n\n return strcmp(s.info_,t.info_) > 0;\n\n}\n\n\n\nbool operator>= (const String& s, const String& t)\n\n{\n\n return strcmp(s.info_,t.info_) >= 0;\n\n}\n\n\n\n\n", "file_path": "OpenSees/SRC/string/G3string.cpp", "rank": 18, "score": 71987.50188620813 }, { "content": "String& String::operator= (const String& rhs) \n\n{\n\n if (this != &rhs) { // Cover the case of s = s.\n\n delete [] info_; // Deallocate the old buffer.\n\n info_ = new char[strlen(rhs.info_) +1];// Allocate memory for a new one.\n\n strcpy(info_, rhs.info_); // Copy the characters from the\n\n } // right side to the left\n\n return *this; // Return this object.\n\n} \n\n\n\nString& String::operator+= (const String& s)\n\n{\n\n char* temp = new char[strlen(info_) + strlen(s.info_) + 1]; // Create a new \n\n // array to hold the two string arrays.\n\n strcpy(temp,info_); // Copy the characters from this array into temp. \n\n strcat(temp,s.info_); // Then copy the characters of s.info_ into temp. \n\n\n\n delete [] info_; // Replace the old value for info_ by temp.\n\n info_ = temp;\n\n return *this;\n", "file_path": "OpenSees/SRC/string/G3string.cpp", "rank": 19, "score": 71986.77143283008 }, { "content": "/* ****************************************************************** **\n\n** OpenSees - Open System for Earthquake Engineering Simulation **\n\n** Pacific Earthquake Engineering Research Center **\n\n** **\n\n** **\n\n** (C) Copyright 1999, The Regents of the University of California **\n\n** All Rights Reserved. **\n\n** **\n\n** Commercial use of this program without express permission of the **\n\n** University of California, Berkeley, is strictly prohibited. See **\n\n** file 'COPYRIGHT' in main directory for information on usage and **\n\n** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **\n\n** **\n\n** Developed by: **\n\n** Frank McKenna ([email protected]) **\n\n** Gregory L. Fenves ([email protected]) **\n\n** Filip C. Filippou ([email protected]) **\n\n** **\n\n** ****************************************************************** */\n\n \n", "file_path": "OpenSees/SRC/utility/StringContainer.h", "rank": 20, "score": 71977.55218514844 }, { "content": "/* ****************************************************************** **\n\n** OpenSees - Open System for Earthquake Engineering Simulation **\n\n** Pacific Earthquake Engineering Research Center **\n\n** **\n\n** **\n\n** (C) Copyright 1999, The Regents of the University of California **\n\n** All Rights Reserved. **\n\n** **\n\n** Commercial use of this program without express permission of the **\n\n** University of California, Berkeley, is strictly prohibited. See **\n\n** file 'COPYRIGHT' in main directory for information on usage and **\n\n** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **\n\n** **\n\n** Developed by: **\n\n** Frank McKenna ([email protected]) **\n\n** Gregory L. Fenves ([email protected]) **\n\n** Filip C. Filippou ([email protected]) **\n\n** **\n\n** ****************************************************************** */\n\n \n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.h", "rank": 21, "score": 71977.55218514844 }, { "content": "// $Revision: 1.1 $\n\n// $Date: 2006-11-08 20:06:10 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/utility/StringContainer.cpp,v $\n\n//\n\n// Description: This file contains the class definition for StringContainer.\n\n// SimulationInformation is a stopwatch.\n\n//\n\n// What: \"@(#) SimulationContainer.h, revA\"\n\n\n\n\n\n\n\n#include<StringContainer.h>\n\n#include <OPS_Globals.h>\n\n#include <string.h>\n\n#include <time.h>\n\n#include <math.h>\n\n\n\nStringContainer::StringContainer()\n\n :strings(0), numStrings(0)\n\n{\n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.cpp", "rank": 22, "score": 70433.48728426412 }, { "content": "// $Revision: 1.1 $\n\n// $Date: 2006-11-08 20:06:10 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/utility/StringContainer.cpp,v $\n\n//\n\n// Description: This file contains the class definition for StringContainer.\n\n// SimulationInformation is a stopwatch.\n\n//\n\n// What: \"@(#) SimulationContainer.h, revA\"\n\n\n\n\n\n\n\n#include<StringContainer.h>\n\n#include <OPS_Globals.h>\n\n#include <string.h>\n\n#include <time.h>\n\n#include <math.h>\n\n\n\nStringContainer::StringContainer()\n\n :strings(0), numStrings(0)\n\n{\n", "file_path": "OpenSees/SRC/utility/StringContainer.cpp", "rank": 23, "score": 70433.48728426412 }, { "content": "{\n\n return numStrings;\n\n}\n\n\n\nvoid\n\nStringContainer::clear(void)\n\n{\n\n if (strings != 0) {\n\n for (int i=0; i<numStrings; i++)\n\n delete [] strings[i];\n\n delete [] strings;\n\n }\n\n\n\n numStrings = 0;\n\n strings = 0;\n\n}\n\n\n\nint \n\nStringContainer::addString(const char *theString)\n\n{\n", "file_path": "OpenSees/SRC/utility/StringContainer.cpp", "rank": 24, "score": 70424.731470809 }, { "content": "{\n\n return numStrings;\n\n}\n\n\n\nvoid\n\nStringContainer::clear(void)\n\n{\n\n if (strings != 0) {\n\n for (int i=0; i<numStrings; i++)\n\n delete [] strings[i];\n\n delete [] strings;\n\n }\n\n\n\n numStrings = 0;\n\n strings = 0;\n\n}\n\n\n\nint \n\nStringContainer::addString(const char *theString)\n\n{\n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.cpp", "rank": 25, "score": 70424.731470809 }, { "content": " // if valid theString\n\n if (theString == 0) \n\n return 0;\n\n\n\n // create new array to hold pointers and copy pointers there\n\n char **nextStrings = new char *[numStrings+1];\n\n if (nextStrings == 0) \n\n return -2;\n\n\n\n for (int i=0; i<numStrings; i++)\n\n nextStrings[i] = strings[i];\n\n \n\n // create new pointer for new file name and add to end of array\n\n char *copyString = new char[strlen(theString)+1];\n\n if (copyString == 0)\n\n return -3;\n\n\n\n strcpy(copyString, theString);\n\n\n\n nextStrings[numStrings] = copyString;\n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.cpp", "rank": 26, "score": 70424.69060921413 }, { "content": " // if valid theString\n\n if (theString == 0) \n\n return 0;\n\n\n\n // create new array to hold pointers and copy pointers there\n\n char **nextStrings = new char *[numStrings+1];\n\n if (nextStrings == 0) \n\n return -2;\n\n\n\n for (int i=0; i<numStrings; i++)\n\n nextStrings[i] = strings[i];\n\n \n\n // create new pointer for new file name and add to end of array\n\n char *copyString = new char[strlen(theString)+1];\n\n if (copyString == 0)\n\n return -3;\n\n\n\n strcpy(copyString, theString);\n\n\n\n nextStrings[numStrings] = copyString;\n", "file_path": "OpenSees/SRC/utility/StringContainer.cpp", "rank": 27, "score": 70424.69060921413 }, { "content": "}\n\n\n\nStringContainer::~StringContainer()\n\n{\n\n this->clear();\n\n}\n\n\n\n\n\nconst char *\n\nStringContainer::getString(int num) const\n\n{\n\n if (num >= 0 && num < numStrings)\n\n return strings[num];\n\n\n\n return 0;\n\n}\n\n\n\n\n\nint\n\nStringContainer::getNumStrings(void) const\n", "file_path": "OpenSees/SRC/utility/StringContainer.cpp", "rank": 28, "score": 70424.52746534465 }, { "content": "}\n\n\n\nStringContainer::~StringContainer()\n\n{\n\n this->clear();\n\n}\n\n\n\n\n\nconst char *\n\nStringContainer::getString(int num) const\n\n{\n\n if (num >= 0 && num < numStrings)\n\n return strings[num];\n\n\n\n return 0;\n\n}\n\n\n\n\n\nint\n\nStringContainer::getNumStrings(void) const\n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.cpp", "rank": 29, "score": 70424.52746534465 }, { "content": "\n\n\n\n // delete old array and reset the array pointer\n\n if (strings != 0)\n\n delete [] strings;\n\n strings = nextStrings;\n\n \n\n // increment number of files\n\n numStrings++;\n\n\n\n // return ok\n\n return 0;\n\n}\n", "file_path": "OpenSees/SRC/utility/StringContainer.cpp", "rank": 30, "score": 70424.26545425721 }, { "content": "\n\n\n\n // delete old array and reset the array pointer\n\n if (strings != 0)\n\n delete [] strings;\n\n strings = nextStrings;\n\n \n\n // increment number of files\n\n numStrings++;\n\n\n\n // return ok\n\n return 0;\n\n}\n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.cpp", "rank": 31, "score": 70424.26545425721 }, { "content": "/* ****************************************************************** **\n\n** OpenSees - Open System for Earthquake Engineering Simulation **\n\n** Pacific Earthquake Engineering Research Center **\n\n** **\n\n** **\n\n** (C) Copyright 1999, The Regents of the University of California **\n\n** All Rights Reserved. **\n\n** **\n\n** Commercial use of this program without express permission of the **\n\n** University of California, Berkeley, is strictly prohibited. See **\n\n** file 'COPYRIGHT' in main directory for information on usage and **\n\n** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **\n\n** **\n\n** Developed by: **\n\n** Frank McKenna ([email protected]) **\n\n** Gregory L. Fenves ([email protected]) **\n\n** Filip C. Filippou ([email protected]) **\n\n** **\n\n** ****************************************************************** */\n\n \n", "file_path": "OpenSees/DEVELOPER/core/StringContainer.cpp", "rank": 32, "score": 70414.4173485071 }, { "content": "/* ****************************************************************** **\n\n** OpenSees - Open System for Earthquake Engineering Simulation **\n\n** Pacific Earthquake Engineering Research Center **\n\n** **\n\n** **\n\n** (C) Copyright 1999, The Regents of the University of California **\n\n** All Rights Reserved. **\n\n** **\n\n** Commercial use of this program without express permission of the **\n\n** University of California, Berkeley, is strictly prohibited. See **\n\n** file 'COPYRIGHT' in main directory for information on usage and **\n\n** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **\n\n** **\n\n** Developed by: **\n\n** Frank McKenna ([email protected]) **\n\n** Gregory L. Fenves ([email protected]) **\n\n** Filip C. Filippou ([email protected]) **\n\n** **\n\n** ****************************************************************** */\n\n \n", "file_path": "OpenSees/SRC/utility/StringContainer.cpp", "rank": 33, "score": 70414.4173485071 }, { "content": "EXTERN char *\t\tTkTilePrintProc _ANSI_ARGS_((\n\n\t\t\t ClientData clientData, Tk_Window tkwin,\n\n\t\t\t char *widgRec, int offset,\n", "file_path": "OpenSees/SRC/tcl/include/tkInt.h", "rank": 34, "score": 64706.458450482445 }, { "content": "extern int\t\tread _ANSI_ARGS_((int fd, char *buf, int numBytes));\n", "file_path": "OpenSees/SRC/tcl/include/tkConfig.h", "rank": 35, "score": 64706.458450482445 }, { "content": "\tregoff_t rm_so;\t\t/* start of substring */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 36, "score": 64706.458450482445 }, { "content": " rm_detail_t details;\t/* Detailed information on match (currently\n", "file_path": "OpenSees/SRC/tcl/include/tclRegexp.h", "rank": 37, "score": 63446.28966791192 }, { "content": "EXTERN LRESULT CALLBACK\tTkWinChildProc _ANSI_ARGS_((HWND hwnd, UINT message,\n", "file_path": "OpenSees/SRC/tcl/include/tkWinInt.h", "rank": 38, "score": 63438.87066185596 }, { "content": "\tchar *re_guts;\t\t/* `char *' is more portable than `void *' */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 39, "score": 63438.87066185596 }, { "content": "\tregoff_t rm_eo;\t\t/* end of substring */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 40, "score": 63438.87066185596 }, { "content": "\tregmatch_t rm_extend;\t/* see REG_EXPECT */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 41, "score": 63438.87066185596 }, { "content": "extern uid_t\t\tgetuid _ANSI_ARGS_((void));\n", "file_path": "OpenSees/SRC/tcl/include/tkConfig.h", "rank": 42, "score": 63438.87066185596 }, { "content": "extern int\t\tread _ANSI_ARGS_((int fd, char *buf, int numBytes));\n", "file_path": "OpenSees/SRC/tcl/include/tkConfig.h", "rank": 43, "score": 63438.87066185596 }, { "content": "\tchar *re_fns;\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 44, "score": 63438.87066185596 }, { "content": " regex_t re;\t\t\t/* Compiled re, includes number of\n", "file_path": "OpenSees/SRC/tcl/include/tclRegexp.h", "rank": 45, "score": 63438.87066185596 }, { "content": "\tlong re_info;\t\t/* information about RE */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 46, "score": 63438.87066185596 }, { "content": " int (*tclFileAttrsCmd) _ANSI_ARGS_((Tcl_Interp * interp, int objc, Tcl_Obj *CONST objv[])); /* 17 */\n", "file_path": "OpenSees/SRC/tcl/include/tclIntDecls.h", "rank": 47, "score": 63438.87066185596 }, { "content": "\tint re_magic;\t\t/* magic number */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 48, "score": 63438.87066185596 }, { "content": "\tsize_t re_nsub;\t\t/* number of subexpressions */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 49, "score": 63438.87066185596 }, { "content": "extern int errno;\n", "file_path": "OpenSees/SRC/tcl/include/tkConfig.h", "rank": 50, "score": 63438.87066185596 }, { "content": " regmatch_t *matches;\t/* Array of indices into the Tcl_UniChar\n", "file_path": "OpenSees/SRC/tcl/include/tclRegexp.h", "rank": 51, "score": 63438.87066185596 }, { "content": "\tchar *re_endp;\t\t/* backward compatibility kludge */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 52, "score": 63438.87066185596 }, { "content": "\tint re_csize;\t\t/* sizeof(character) */\n", "file_path": "OpenSees/SRC/tcl/include/regex.h", "rank": 53, "score": 63438.87066185596 }, { "content": " int flags;\t\t\t/* Regexp compile flags. */\n", "file_path": "OpenSees/SRC/tcl/include/tclRegexp.h", "rank": 54, "score": 63438.87066185596 }, { "content": "extern int\t\tclose _ANSI_ARGS_((int fd));\n", "file_path": "OpenSees/SRC/tcl/include/tkConfig.h", "rank": 55, "score": 63438.87066185596 }, { "content": "#include <Renderer.h>\n\n#include <Domain.h>\n\n#include <string.h> \n\n\n\n#include <OPS_Globals.h>\n\n\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n\n\n#include <NDMaterial.h>\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n#include <ID.h>\n\n#include <Renderer.h>\n\n#include <Domain.h>\n\n#include <string.h>\n\n#include <Information.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <ElementResponse.h>\n\n\n\n#include <ElementalLoad.h>\n\n\n\n#define ELE_TAG_VS3D4QuadWithSensitivity 100003\n\n\n", "file_path": "OpenSees/SRC/element/XMUelements/VS3D4QuadWithSensitivity.h", "rank": 57, "score": 17.77796978704837 }, { "content": "#include <ID.h>\n\n#include <Renderer.h>\n\n#include <Domain.h>\n\n#include <string.h>\n\n\n\n#include <OPS_Globals.h>\n\n\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n\n\n#include <NDMaterial.h>\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n#include <ID.h>\n\n#include <Renderer.h>\n\n#include <Domain.h>\n\n#include <string.h>\n\n#include <Information.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <ElementResponse.h>\n\n\n\n#include <ElementalLoad.h>\n\n\n\n#define ELE_TAG_AV3D4QuadWithSensitivity 100009\n\n\n", "file_path": "OpenSees/SRC/element/XMUelements/AV3D4QuadWithSensitivity.h", "rank": 58, "score": 17.725309642831554 }, { "content": "// Written: Minjie\n\n\n\n// Description: misc commands\n\n\n\n#include <elementAPI.h>\n\n#include <Domain.h>\n\n#include <LoadPattern.h>\n\n#include <LoadPatternIter.h>\n\n#include <ElementalLoadIter.h>\n\n#include <Element.h>\n\n#include <Parameter.h>\n\n#include <Node.h>\n\n#include <Pressure_Constraint.h>\n\n#include <TimeSeries.h>\n\n#include <SP_Constraint.h>\n\n#include <Matrix.h>\n\n#include <MeshRegion.h>\n\n#include <StringContainer.h>\n\n#include <fstream>\n\n#include <string>\n", "file_path": "OpenSees/SRC/interpreter/OpenSeesMiscCommands.cpp", "rank": 59, "score": 17.715267914550736 }, { "content": "#include <Python.h>\n\n#include <elementAPI.h>\n\n#include <ElasticMaterial.cpp>\n\n\n\n#include <UniaxialMaterial.h>\n\n#include <string.h>\n\n#include <string>\n\n#include <ID.h>\n\n\n\n#include <StandardStream.h>\n\nStandardStream sserr;\n\nOPS_Stream *opserrPtr = &sserr;\n\n\n\n#include <SimulationInformation.h>\n\nSimulationInformation simulationInfo;\n\nSimulationInformation *theSimulationInfoPtr = 0;\n\n\n\n#include <FE_Datastore.h>\n\nFE_Datastore *theDatabase =0;\n\n\n", "file_path": "OpenSees/SRC/interpreter/OpenSeesCommandsPython.cpp", "rank": 60, "score": 17.43460785467558 }, { "content": "#include <FrictionModel.h>\n\n#include <UniaxialMaterial.h>\n\n\n\n#include <float.h>\n\n#include <math.h>\n\n#include <stdlib.h>\n\n#include <string.h>\n\n\n\n#include <elementAPI.h>\n\n#include <string>\n\n\n\nvoid* OPS_RJWatsonEQS3d()\n\n{\n\n int ndf = OPS_GetNDF();\n\n if (ndf != 6) {\n\n opserr << \"WARNING invalid ndf: \" << ndf;\n\n opserr << \", for space problem need 6 - RJWatsonEqsBearing \\n\";\n\n return 0;\n\n }\n\n \n", "file_path": "OpenSees/SRC/element/frictionBearing/RJWatsonEQS3d.cpp", "rank": 61, "score": 17.424638961533294 }, { "content": "// $Revision: 1.3 $\n\n// $Date: 2002-12-05 22:49:09 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/material/nD/J2BeamFiber3d.cpp,v $\n\n\n\n// Written: MHS\n\n// Created: Aug 2001\n\n//\n\n// Description: Elastic isotropic model where stress \n\n// components 22, 33, 13, and 23 are condensed out.\n\n\n\n#include <J2BeamFiber3d.h> \n\n#include <Channel.h>\n\n#include <string.h>\n\n#include <math.h>\n\n#include <float.h>\n\n\n\n#include <OPS_Globals.h>\n\n#include <elementAPI.h>\n\n#include <string.h>\n\n#include <stdlib.h>\n", "file_path": "OpenSees/SRC/material/nD/J2BeamFiber3d.cpp", "rank": 62, "score": 17.296809401719447 }, { "content": "// $Revision: 1.3 $\n\n// $Date: 2002-12-05 22:49:09 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/material/nD/J2PlateFibre.cpp,v $\n\n\n\n// Written: MHS\n\n// Created: Aug 2001\n\n//\n\n// Description: Elastic isotropic model where stress \n\n// components 22, 33, 13, and 23 are condensed out.\n\n\n\n#include <J2PlateFibre.h> \n\n#include <Channel.h>\n\n#include <string.h>\n\n#include <math.h>\n\n#include <float.h>\n\n\n\n#include <OPS_Globals.h>\n\n#include <elementAPI.h>\n\n#include <string.h>\n\n#include <stdlib.h>\n", "file_path": "OpenSees/SRC/material/nD/J2PlateFibre.cpp", "rank": 63, "score": 17.296809401719447 }, { "content": "// $Revision: 1.3 $\n\n// $Date: 2002-12-05 22:49:09 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/material/nD/J2BeamFiber2d.cpp,v $\n\n\n\n// Written: MHS\n\n// Created: Aug 2001\n\n//\n\n// Description: Elastic isotropic model where stress \n\n// components 22, 33, 13, and 23 are condensed out.\n\n\n\n#include <J2BeamFiber2d.h> \n\n#include <Channel.h>\n\n#include <string.h>\n\n#include <math.h>\n\n#include <float.h>\n\n\n\n#include <OPS_Globals.h>\n\n#include <elementAPI.h>\n\n#include <string.h>\n\n#include <stdlib.h>\n", "file_path": "OpenSees/SRC/material/nD/J2BeamFiber2d.cpp", "rank": 64, "score": 17.296809401719447 }, { "content": "// $Revision: 1.10 $\n\n// $Date: 2009-10-13 21:17:42 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/handler/DataFileStream.cpp,v $\n\n\n\n\n\n#include <DataFileStream.h>\n\n#include <Vector.h>\n\n#include <iostream>\n\n#include <iomanip>\n\n#include <string>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <Message.h>\n\n#include <Matrix.h>\n\n\n\nusing std::cerr;\n\nusing std::ios;\n\nusing std::setiosflags;\n\nusing std::ifstream;\n\nusing std::string;\n", "file_path": "OpenSees/SRC/handler/DataFileStream.cpp", "rank": 65, "score": 17.25087624475745 }, { "content": "// $Revision: 1.10 $\n\n// $Date: 2009-10-13 21:17:42 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/handler/DataFileStream.cpp,v $\n\n\n\n\n\n#include <DataFileStream.h>\n\n#include <Vector.h>\n\n#include <iostream>\n\n#include <iomanip>\n\n#include <string>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <Message.h>\n\n#include <Matrix.h>\n\n\n\nusing std::cerr;\n\nusing std::ios;\n\nusing std::setiosflags;\n\nusing std::ifstream;\n\nusing std::string;\n", "file_path": "OpenSees/DEVELOPER/core/DataFileStream.cpp", "rank": 66, "score": 17.25087624475745 }, { "content": "//#include <MaterialResponse.h>\n\n#include <Parameter.h>\n\n\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <string.h>\n\n\n\n\n\n#include <elementAPI.h>\n\n\n", "file_path": "OpenSees/SRC/material/nD/UWmaterials/PM4Silt.h", "rank": 67, "score": 17.234277915605155 }, { "content": "//#include <MaterialResponse.h>\n\n#include <Parameter.h>\n\n\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <string.h>\n\n\n\n\n\n#include <elementAPI.h>\n\n\n", "file_path": "OpenSees/SRC/material/nD/UWmaterials/PM4Sand.h", "rank": 68, "score": 17.234277915605155 }, { "content": "// $Revision: 1.9 $\n\n// $Date: 2009-03-27 19:18:14 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/utility/File.cpp,v $\n\n \n\n \n\n// Written: fmk \n\n// Created: 09/07\n\n//\n\n// Description: This file contains the class definition for File used in SimulationINformation.\n\n\n\n\n\n#include <map>\n\n#include <string.h>\n\n//#include <string>\n\n//using namespace std;\n\n\n\n\n\n\n\n#include <File.h>\n\n#include <FileIter.h>\n", "file_path": "OpenSees/SRC/utility/File.cpp", "rank": 69, "score": 17.22450903194889 }, { "content": "// $Revision: 1.9 $\n\n// $Date: 2009-03-27 19:18:14 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/utility/File.cpp,v $\n\n \n\n \n\n// Written: fmk \n\n// Created: 09/07\n\n//\n\n// Description: This file contains the class definition for File used in SimulationINformation.\n\n\n\n\n\n#include <map>\n\n#include <string.h>\n\n//#include <string>\n\n//using namespace std;\n\n\n\n\n\n\n\n#include <File.h>\n\n#include <FileIter.h>\n", "file_path": "OpenSees/DEVELOPER/core/File.cpp", "rank": 70, "score": 17.22450903194889 }, { "content": "// $Revision: 1.19 $\n\n// $Date: 2010-06-09 17:43:09 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/domain/pattern/LoadPattern.cpp,v $\n\n \n\n// Written: fmk 07/99\n\n// Revised:\n\n//\n\n// Purpose: This file contains the method definitions for class LoadPattern.\n\n// LoadPattern is a container class.\n\n//\n\n// The LoadPattern interface:\n\n\n\n#include <string.h>\n\n#include <string>\n\n#include <stdlib.h>\n\n\n\n#include <LoadPattern.h>\n\n#include <stdlib.h>\n\n#include <ID.h>\n\n#include <TimeSeries.h>\n", "file_path": "OpenSees/SRC/domain/pattern/LoadPattern.cpp", "rank": 71, "score": 17.18986618884449 }, { "content": "#define VOID void\n\n\n\nextern \"C\" {\n\n#include <triangle.h>\n\n}\n\n#include <string>\n\n#include <Vector.h>\n\n#include <map>\n\n#include <vector>\n\n\n", "file_path": "OpenSees/SRC/element/PFEMElement/PFEMMesher2D.h", "rank": 72, "score": 17.166635698886402 }, { "content": "// $Revision: 1.10 $\n\n// $Date: 2009-10-13 21:17:42 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/handler/DataFileStreamAdd.cpp,v $\n\n\n\n\n\n#include <DataFileStreamAdd.h>\n\n#include <Vector.h>\n\n#include <iostream>\n\n#include <iomanip>\n\n#include <string>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <Message.h>\n\n#include <Matrix.h>\n\n\n\nusing std::cerr;\n\nusing std::ios;\n\nusing std::setiosflags;\n\nusing std::ifstream;\n\nusing std::string;\n", "file_path": "OpenSees/SRC/handler/DataFileStreamAdd.cpp", "rank": 73, "score": 17.159981862492756 }, { "content": "// $Revision: 1.13 $\n\n// $Date: 2009-10-13 21:17:42 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/handler/XmlFileStream.cpp,v $\n\n\n\n#include <XmlFileStream.h>\n\n#include <Vector.h>\n\n#include <Matrix.h>\n\n#include <iostream>\n\n#include <iomanip>\n\n#include <string>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <Message.h>\n\n\n\nusing std::cerr;\n\nusing std::ios;\n\nusing std::setiosflags;\n\nusing std::string;\n\nusing std::ifstream;\n\nusing std::getline;\n", "file_path": "OpenSees/SRC/handler/XmlFileStream.cpp", "rank": 74, "score": 17.115012755363686 }, { "content": "// $Revision: 1.3 $\n\n// $Date: 2009-04-30 23:23:04 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/handler/BinaryFileStream.cpp,v $\n\n\n\n#include <BinaryFileStream.h>\n\n#include <Vector.h>\n\n#include <iostream>\n\n#include <iomanip>\n\n#include <string>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <Message.h>\n\n#include <Matrix.h>\n\n\n\nusing std::cerr;\n\nusing std::ios;\n\nusing std::setiosflags;\n\nusing std::ifstream;\n\nusing std::string;\n\nusing std::getline;\n", "file_path": "OpenSees/DEVELOPER/core/BinaryFileStream.cpp", "rank": 75, "score": 17.115012755363686 }, { "content": "// $Revision: 1.3 $\n\n// $Date: 2009-04-30 23:23:04 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/handler/BinaryFileStream.cpp,v $\n\n\n\n#include <BinaryFileStream.h>\n\n#include <Vector.h>\n\n#include <iostream>\n\n#include <iomanip>\n\n#include <string>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <Message.h>\n\n#include <Matrix.h>\n\n\n\nusing std::cerr;\n\nusing std::ios;\n\nusing std::setiosflags;\n\nusing std::ifstream;\n\nusing std::string;\n\nusing std::getline;\n", "file_path": "OpenSees/SRC/handler/BinaryFileStream.cpp", "rank": 76, "score": 17.115012755363686 }, { "content": "#include <Node.h>\n\n\n\n#include \"FiberSection2dInt.h\"\n\n\n\n#include \"LinearCrdTransf2dInt.h\"\n\n\n\n#include <Matrix.h>\n\n\n\n#include <Vector.h>\n\n\n\n#include <ID.h>\n\n\n\n#include <Renderer.h>\n\n\n\n#include <Domain.h>\n\n\n\n#include <string.h>\n\n\n\n#include <Information.h>\n\n\n", "file_path": "OpenSees/SRC/element/dispBeamColumnInt/DispBeamColumn2dInt.cpp", "rank": 77, "score": 16.922035577828062 }, { "content": "// $Revision: 1.4 $\n\n// $Date: 2008-10-09 21:33:06 $\n\n// $Source: /usr/local/cvs/OpenSees/SRC/utility/PeerNGA.cpp,v $\n\n \n\n \n\n// Written: fmk \n\n// Created: 09/07\n\n//\n\n// Description: This file contains the class definition for File used in SimulationINformation.\n\n//\n\n// What: \"@(#) SimulationInformation.h, revA\"\n\n\n\n\n\n#include <stdio.h>\n\n#include <stdlib.h>\n\n#include <string.h>\n\n#include <StringContainer.h>\n\n\n\n\n\n#ifdef _WIN32\n", "file_path": "OpenSees/SRC/utility/PeerNGA.cpp", "rank": 78, "score": 16.85636232218225 }, { "content": "#include \"DRMInputHandler.h\"\n\n#include <Vector.h>\n\n#include <ID.h>\n\n#include <Message.h>\n\n#include <Matrix.h>\n\n#include <Element.h>\n\n#include <map>\n\n#include <set>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <string>\n\n#include <classTags.h>\n\n\n", "file_path": "OpenSees/SRC/domain/pattern/drm/DRMLoadPatternWrapper.h", "rank": 79, "score": 16.83406736540883 }, { "content": "//\n\n\n\n// Description: This file contains the implementation of the\n\n\n\n// \n\n\n\n//\n\n\n\n// Jinchi Lu and Zhaohui Yang (May 2004)\n\n\n\n\n\n\n\n#include <stdlib.h>\n\n\n\n#include <string.h>\n\n\n\n#include <Domain.h>\n\n\n\n\n\n\n", "file_path": "OpenSees/SRC/element/brick/TclTwenty_Node_BrickCommand.cpp", "rank": 80, "score": 16.606763562714068 }, { "content": "// $Revision: 1.0 $\n\n// $Date: 2019-08-22 $\n\n\n\n// Written: Kuanshi Zhong \n\n// Created: 07/2019\n\n//\n\n\n\n#include <math.h>\n\n\n\n#include <stdlib.h>\n\n#include <MaterialResponse.h>\n\n#include <Information.h>\n\n#include <string.h>\n\n\n\n#include <DuctileFracture.h>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n\n\n#include <OPS_Globals.h>\n", "file_path": "OpenSees/SRC/material/uniaxial/DuctileFracture.cpp", "rank": 81, "score": 16.53992078411818 }, { "content": "\n\n// $Revision$\n\n// $Date$\n\n// $Source$\n\n\n\n// Written: MHS\n\n// Created: 2012\n\n//\n\n// Description: This file contains the class implementation of FiberSection2d.\n\n\n\n#include <stdlib.h>\n\n#include <string.h>\n\n#include <math.h>\n\n\n\n#include <Channel.h>\n\n#include <Vector.h>\n\n#include <Matrix.h>\n\n#include <MatrixUtil.h>\n\n#include <Fiber.h>\n\n#include <classTags.h>\n", "file_path": "OpenSees/SRC/material/section/NDFiberSectionWarping2d.cpp", "rank": 82, "score": 16.466375446512842 }, { "content": "#include <vector>\n\n#include <ConfinedConcrete01.h>\n\n\n\n#include <Matrix.h>\n\n#include <Parameter.h>\n\n\n\n#include <math.h>\n\n#include <float.h>\n\n#include <stdio.h>\n\n#include <string.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <elementAPI.h>\n\n\n\n#define OPS_Export \n\n#define PI 3.14159265358979323846\n\n\n\n/*\n\nUSER INPUT PARAMETERS\n\n\n", "file_path": "OpenSees/SRC/material/uniaxial/ConfinedConcrete01.cpp", "rank": 83, "score": 16.423526578161216 }, { "content": "// $Revision$\n\n// $Date$\n\n// $Source$\n\n\n\n// Written: MHS\n\n// Created: Dec 2012\n\n\n\n#include <stdlib.h>\n\n#include <math.h>\n\n\n\n#include <InitStressNDMaterial.h>\n\n#include <Matrix.h>\n\n#include <ID.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <string.h>\n\n\n\n#include <OPS_Globals.h>\n\n\n\n#include <elementAPI.h>\n", "file_path": "OpenSees/SRC/material/nD/InitStressNDMaterial.cpp", "rank": 84, "score": 16.359611240155033 }, { "content": "#include <elementAPI.h>\n\n\n\n#include <float.h>\n\n#include <math.h>\n\n#include <stdlib.h>\n\n#include <string.h>\n\n\n\n#include <G3Globals.h>\n\n#include <Message.h>\n\nusing namespace std;\n\n#include <iostream>\n\n\n\n#define PI 3.14159l\n\n\n\n\n\n// initialize the class wide variables\n\nMatrix HDR::theMatrix(12,12);\n\nVector HDR::theVector(12);\n\n\n\n\n", "file_path": "OpenSees/SRC/element/elastomericBearing/HDR.cpp", "rank": 85, "score": 16.31248934073788 }, { "content": "#include <N4BiaxialTruss.h>\n\n#include <Information.h>\n\n#include <Parameter.h>\n\n\n\n#include <Domain.h>\n\n#include <Node.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <UniaxialMaterial.h>\n\n#include <Renderer.h>\n\n\n\n#include <math.h>\n\n#include <stdlib.h>\n\n#include <string.h>\n\n\n\n#include <ElementResponse.h>\n\n#include <CompositeResponse.h>\n\n#include <ConcretewBeta.h>\n\n\n\n//#include <fstream>\n", "file_path": "OpenSees/SRC/element/truss/N4BiaxialTruss.cpp", "rank": 86, "score": 16.311998381935606 }, { "content": "// $Revision$\n\n// $Date$\n\n// $Source$\n\n\n\n// Written: MHS\n\n// Created: 2012\n\n//\n\n// Description: This file contains the class implementation of FiberSection2d.\n\n\n\n#include <stdlib.h>\n\n#include <string.h>\n\n#include <math.h>\n\n\n\n#include <Channel.h>\n\n#include <Vector.h>\n\n#include <Matrix.h>\n\n#include <MatrixUtil.h>\n\n#include <Fiber.h>\n\n#include <classTags.h>\n\n#include <NDFiberSection2d.h>\n", "file_path": "OpenSees/SRC/material/section/NDFiberSection2d.cpp", "rank": 87, "score": 16.300985977144236 }, { "content": "// $Revision$\n\n// $Date$\n\n// $Source$\n\n\n\n// Written: MHS\n\n// Created: 2012\n\n//\n\n// Description: This file contains the class implementation of FiberSection3d.\n\n\n\n#include <stdlib.h>\n\n#include <string.h>\n\n#include <math.h>\n\n\n\n#include <Channel.h>\n\n#include <Vector.h>\n\n#include <Matrix.h>\n\n#include <MatrixUtil.h>\n\n#include <Fiber.h>\n\n#include <classTags.h>\n\n#include <NDFiberSection3d.h>\n", "file_path": "OpenSees/SRC/material/section/NDFiberSection3d.cpp", "rank": 88, "score": 16.300985977144236 }, { "content": "#include <iomanip>\n\nusing std::ios;\n\n#include <iostream>\n\nusing std::ofstream;\n\n \n\n#else\n\n\n\n#include <StandardStream.h>\n\n#include <FileStream.h>\n\n#include <DummyStream.h>\n\n\n\nStandardStream sserr;\n\nOPS_Stream *opserrPtr = &sserr;\n\n\n\n#endif\n\n\n\n\n\n#include <stdio.h>\n\n#include <stdlib.h>\n\n#include <string.h>\n", "file_path": "OpenSees/SRC/tcl/commands.cpp", "rank": 89, "score": 16.24982363479195 }, { "content": "\n\n#include <string.h>\n\n\n\n#ifdef _WGL\n\n#include <windows.h>\n\n//#include <GL/glaux.h>\n\n#include <GL/glu.h>\n\n#include <GL/gl.h>\n\n\n\n#elif _GLX\n\n\n\n#include <GL/gl.h>\n\n#include <GL/glx.h>\n\n#include <GL/glu.h>\n\n\n\n#elif _AGL\n\n\n\n#include <OpenGL/glu.h>\n\n#include <OpenGL/gl.h>\n\n\n", "file_path": "OpenSees/SRC/renderer/OpenGlRenderer.cpp", "rank": 90, "score": 16.243073387165957 }, { "content": "", "file_path": "OpenSees/SRC/material/nD/FSAM.cpp", "rank": 91, "score": 16.243073387165957 }, { "content": "#include <string.h>\n\n\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n#include <ID.h>\n\n#include <ArrayOfTaggedObjects.h>\n\n\n\n#include <Domain.h>\n\n#include <Node.h>\n\n#include <NodeIter.h>\n\n#include <SP_Constraint.h>\n\n#include <SP_ConstraintIter.h>\n\n#include <MP_Constraint.h>\n\n\n\n#include <RigidRod.h>\n\n#include <RigidBeam.h>\n\n#include <RigidDiaphragm.h>\n\n\n\n#include <CrdTransf.h>\n\n\n", "file_path": "OpenSees/SRC/modelbuilder/tcl/TclModelBuilder.cpp", "rank": 92, "score": 16.227540092122023 }, { "content": "", "file_path": "OpenSees/SRC/element/HUelements/MultipleNormalSpring.cpp", "rank": 93, "score": 16.227540092122023 }, { "content": "#include <Node.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <Renderer.h>\n\n#include <Information.h>\n\n#include <ElementResponse.h>\n\n\n\n#include <ID.h>\n\n#include <Vector.h>\n\n\n\n#include <float.h>\n\n#define _USE_MATH_DEFINES\n\n#include <math.h>\n\n#include <stdlib.h>\n\n#include <string.h>\n\n#include <elementAPI.h>\n\n\n\nvoid* OPS_YamamotoBiaxialHDR()\n\n{\n\n // 3-dim, 6-dof\n", "file_path": "OpenSees/SRC/element/HUelements/YamamotoBiaxialHDR.cpp", "rank": 94, "score": 16.197006858886624 }, { "content": "\n\n#include <string.h>\n\n\n\n#include <math.h>\n\n#include <float.h>\n\n\n\n\n\n#include <elementAPI.h>\n\n#include <OPS_Globals.h>\n\n\n\n\n\n//#include <iostream>\n\n//#include <fstream>\n\n//using namespace std;\n\n\n\nvoid *\n\nOPS_DoddRestr(void)\n\n{\n\n // Pointer to a uniaxial material that will be returned\n\n UniaxialMaterial *theMaterial = 0;\n", "file_path": "OpenSees/SRC/material/uniaxial/DoddRestr.cpp", "rank": 95, "score": 16.196823805765007 }, { "content": "#include <string.h>\n\n\n\n#include <Renderer.h>\n\n\n\n#ifndef _NOGRAPHICS\n\n\n\n#ifdef _WGL\n\n#include <OpenGLRenderer.h>\n\n#elif _GLX\n\n#include <OpenGLRenderer.h>\n\n#elif _AGL\n\n#include <OpenGLRenderer.h>\n\n#else\n\n#include <X11Renderer.h>\n\n#endif\n\n\n\n#endif\n\n\n\n#include <PlainMap.h>\n\n#include \"TclVideoPlayer.h\"\n", "file_path": "OpenSees/SRC/tcl/TclVideoPlayer.cpp", "rank": 96, "score": 16.187916609939755 }, { "content": "#include <elementAPI.h>\n\n\n\n#include <float.h>\n\n#include <math.h>\n\n#include <stdlib.h>\n\n#include <string.h>\n\n\n\n#include <G3Globals.h>\n\n#include <Message.h>\n\nusing namespace std;\n\n#include <iostream>\n\n\n\n#define PI 3.14159l\n\n\n\n\n\n// initialize the class wide variables\n\nMatrix ElastomericX::theMatrix(12,12);\n\nVector ElastomericX::theVector(12);\n\n\n\n\n", "file_path": "OpenSees/SRC/element/elastomericBearing/ElastomericX.cpp", "rank": 97, "score": 16.187916609939755 }, { "content": "\n\n#include <OPS_Globals.h>\n\n\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n\n\n#include <NDMaterial.h>\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n#include <ID.h>\n\n#include <Renderer.h>\n\n#include <Domain.h>\n\n#include <string.h>\n\n#include <Information.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <ElementResponse.h>\n\n\n\n#include <ElementalLoad.h>\n\n\n\n#define ELE_TAG_ASI3D8QuadWithSensitivity 100002\n\n\n", "file_path": "OpenSees/SRC/element/XMUelements/ASI3D8QuadWithSensitivity.h", "rank": 98, "score": 16.177180106444982 }, { "content": "\n\n#include <OPS_Globals.h>\n\n\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n\n\n#include <NDMaterial.h>\n\n#include <Matrix.h>\n\n#include <Vector.h>\n\n#include <ID.h>\n\n#include <Renderer.h>\n\n#include <Domain.h>\n\n#include <string.h>\n\n#include <Information.h>\n\n#include <Channel.h>\n\n#include <FEM_ObjectBroker.h>\n\n#include <ElementResponse.h>\n\n\n\n#include <ElementalLoad.h>\n\n\n\n\n\n#define ELE_TAG_AC3D8HexWithSensitivity 100001\n\n\n", "file_path": "OpenSees/SRC/element/XMUelements/AC3D8HexWithSensitivity.h", "rank": 99, "score": 16.177180106444982 } ]
C++
OpenTES4/bsa.cpp
Cyril-Meyer/OpenTES4Oblivion
dc2791a5a7ea911d0960d79ce0b9445fcbe329ee
#include "bsa.h" BSA::BSA() {} void BSA::summary() { std::cout << "header" << std::endl; std::cout << this->header.fileId << std::endl; std::cout << this->header.version << std::endl; std::cout << this->header.offset << std::endl; std::cout << this->header.archiveFlags << std::endl; std::cout << this->header.folderCount << std::endl; std::cout << this->header.fileCount << std::endl; std::cout << this->header.totalFolderNameLength << std::endl; std::cout << this->header.totalFileNameLength << std::endl; std::cout << this->header.fileFlags << std::endl; std::cout << "folderRecords" << std::endl; for (std::size_t i = 0; i < this->header.folderCount; ++i) { std::cout << this->folderRecords[i].nameHash << std::endl; std::cout << this->folderRecords[i].count << std::endl; std::cout << this->folderRecords[i].offset << std::endl; } std::cout << "fileRecordBlocks" << std::endl; std::bitset<32> archiveFlags(this->header.archiveFlags); for (std::size_t i = 0; i < this->fileRecordBlocks.size(); ++i) { if (archiveFlags.test(0)) { std::cout << this->fileRecordBlocks[i].name.data << std::endl; } for (std::size_t j = 0; j < this->fileRecordBlocks[i].fileRecords.size(); ++j) { std::cout << " " << this->fileRecordBlocks[i].fileRecords[j].nameHash << std::endl; std::cout << " " << this->fileRecordBlocks[i].fileRecords[j].size << std::endl; std::cout << " " << this->fileRecordBlocks[i].fileRecords[j].offset << std::endl; } } std::cout << "fileNameBlock" << std::endl; if (archiveFlags.test(1)) { for (std::size_t i = 0; i < this->header.fileCount; i++) { std::cout << this->fileNameBlock.fileNames[i].data << std::endl; } } } std::istream& operator>>(std::istream& is, BSA& bsa) { auto read = [](std::istream& is, void* dataptr, uint64_t datasize) { is.read(reinterpret_cast<char*>(dataptr), datasize); }; read(is, &bsa.header.fileId, sizeof(bsa.header.fileId)); read(is, &bsa.header.version, sizeof(bsa.header.version)); read(is, &bsa.header.offset, sizeof(bsa.header.offset)); read(is, &bsa.header.archiveFlags, sizeof(bsa.header.archiveFlags)); read(is, &bsa.header.folderCount, sizeof(bsa.header.folderCount)); read(is, &bsa.header.fileCount, sizeof(bsa.header.fileCount)); read(is, &bsa.header.totalFolderNameLength, sizeof(bsa.header.totalFolderNameLength)); read(is, &bsa.header.totalFileNameLength, sizeof(bsa.header.totalFileNameLength)); read(is, &bsa.header.fileFlags, sizeof(bsa.header.fileFlags)); std::bitset<32> archiveFlags(bsa.header.archiveFlags); for (std::size_t i = 0; i < bsa.header.folderCount; ++i) { BSA::FolderRecord fr; read(is, &fr.nameHash, sizeof(fr.nameHash)); read(is, &fr.count, sizeof(fr.count)); read(is, &fr.offset, sizeof(fr.offset)); bsa.folderRecords.push_back(fr); } uint32_t frfc = 0; for (std::size_t i = 0; i < bsa.header.folderCount; ++i) { frfc += bsa.folderRecords[i].count; } if (frfc != bsa.header.fileCount) { std::cout << "ERROR : fileCount and folderRecord number of files " "doesn't match" << std::endl; return is; } for (uint32_t i = 0; i < bsa.header.folderCount; ++i) { BSA::FileRecordBlocks frb; BSA::BZString bzs; if (archiveFlags.test(0)) { read(is, &bzs.length, sizeof(bzs.length)); bzs.data = new char[bzs.length]; read(is, bzs.data, bzs.length); if (bzs.data[bzs.length - 1] != '\0') { std::cout << "ERROR : invalid bzstring" << std::endl; return is; } } else { bzs.length = 0; bzs.data = nullptr; } frb.name = bzs; for (uint32_t j = 0; j < bsa.folderRecords[i].count; ++j) { BSA::FileRecord fr; read(is, &fr.nameHash, sizeof(fr.nameHash)); read(is, &fr.size, sizeof(fr.size)); read(is, &fr.offset, sizeof(fr.offset)); frb.fileRecords.push_back(fr); } bsa.fileRecordBlocks.push_back(frb); } if (archiveFlags.test(1)) { std::string tmpstr; for (uint32_t i = 0; i < bsa.header.fileCount; i++) { getline(is, tmpstr, '\0'); BSA::ZString zs; zs.data = new char[tmpstr.length()]; for (std::size_t j = 0; j <= tmpstr.length(); j++) { zs.data[j] = tmpstr[j]; } bsa.fileNameBlock.fileNames.push_back(zs); } } if (archiveFlags.test(1)) { std::size_t frbfrs = 0; for (std::size_t i = 0; i < bsa.fileRecordBlocks.size(); ++i) frbfrs += bsa.fileRecordBlocks.at(i).fileRecords.size(); if (frbfrs != bsa.fileNameBlock.fileNames.size()) { std::cout << "ERROR : fileRecords and fileNameBlock number of " "files doesn't match" << std::endl; return is; } } if (archiveFlags.test(1)) { std::size_t c = 0; for (std::size_t i = 0; i < bsa.fileRecordBlocks.size(); ++i) { for (std::size_t j = 0; j < bsa.fileRecordBlocks.at(i).fileRecords.size(); ++j) { bsa.fileRecordBlocks.at(i).fileRecords.at(j).filename = &bsa.fileNameBlock.fileNames.at(c); c++; } } } return is; }
#include "bsa.h" BSA::BSA() {} void BSA::summary() { std::cout << "header" << std::endl; std::cout << this->header.fileId << std::endl; std::cout << this->header.version << std::endl; std::cout << this->header.offset << std::endl; std::cout << this->header.archiveFlags << std::endl; std::cout << this->header.folderCount << std::endl; std::cout << this->header.fileCount << std::endl; std::cout << this->header.totalFolderNameLength << std::endl; std::cout << this->header.totalFileNameLength << std::endl; std::cout << this->header.fileFlags << std::endl; std::cout << "folderRecords" << std::endl; for (std::size_t i = 0; i < this->header.folderCount; ++i) { std::cout << this->folderRecords[i].nameHash << std::endl; std::cout << this->folderRecords[i].count << std::endl; std::cout << this->folderRecords[i].offset << std::endl; } std::cout << "fileRecordBlocks" << std::endl; std::bitset<32> archiveFlags(this->header.archiveFlags); for (std::size_t i = 0; i < this->fileRecordBlocks.size(); ++i) { if (archiveFlags.test(0)) { std::cout << this->fileRecordBlocks[i].name.data << std::endl; } for (std::size_t j = 0; j < this->fileRecordBlocks[i].fileRecords.size(); ++j) { std::cout << " " << this->fileRecordBlocks[i].fileRecords[j].nameHash << std::endl; std::cout << " " << this->fileRecordBlocks[i].fileRecords[j].size << std::endl; std::cout << " " << this->fileRecordBlocks[i].fileRecords[j].offset << std::endl; } } std::cout << "fileNameBlock" << std::endl; if (archiveFlags.test(1)) { for (std::size_t i = 0; i < this->header.fileCount; i++) { std::cout << this->fileNameBlock.fileNames[i].data << std::endl; } } } std::istream& operator>>(std::istream& is, BSA& bsa) { auto read = [](std::istream& is, void* dataptr, uint64_t datasize) { is.read(reinterpret_cast<char*>(dataptr), datasize); }; read(is, &bsa.header.fileId, sizeof(bsa.header.fileId)); read(is, &bsa.header.version, sizeof(bsa.header.version)); read(is, &bsa.header.offset, sizeof(bsa.header.offset)); read(is, &bsa.header.archiveFlags, sizeof(bsa.header.archiveFlags)); read(is, &bsa.header.folderCount, sizeof(bsa.header.folderCount)); read(is, &bsa.header.fileCount, sizeof(bsa.header.fileCount)); read(is, &bsa.header.totalFolderNameLength, sizeof(bsa.header.totalFolderNameLength)); read(is, &bsa.header.totalFileNameLength, sizeof(bsa.header.totalFileNameLength)); read(is, &bsa.header.fileFlags, sizeof(bsa.header.fileFlags)); std::bitset<32> archiveFlags(bsa.header.archiveFlags); for (std::size_t i = 0; i < bsa.header.folderCount; ++i) { BSA::FolderRecord fr; read(is, &fr.nameHash, sizeof(fr.nameHash)); read(is, &fr.count, sizeof(fr.count)); read(is, &fr.offset, sizeof(fr.offset)); bsa.folderRecords.push_back(fr); } uint32_t frfc = 0; for (std::size_t i = 0; i < bsa.header.folderCount; ++i) { frfc += bsa.folderRecords[i].count; } if (frfc != bsa.header.fileCount) { std::cout << "ERROR : fileCount and folderRecord number of files " "doesn't match" << std::endl; return is; } for (uint32_t i = 0; i < bsa.header.folderCount; ++i) { BSA::FileRecordBlocks frb; BSA::BZString bzs;
frb.name = bzs; for (uint32_t j = 0; j < bsa.folderRecords[i].count; ++j) { BSA::FileRecord fr; read(is, &fr.nameHash, sizeof(fr.nameHash)); read(is, &fr.size, sizeof(fr.size)); read(is, &fr.offset, sizeof(fr.offset)); frb.fileRecords.push_back(fr); } bsa.fileRecordBlocks.push_back(frb); } if (archiveFlags.test(1)) { std::string tmpstr; for (uint32_t i = 0; i < bsa.header.fileCount; i++) { getline(is, tmpstr, '\0'); BSA::ZString zs; zs.data = new char[tmpstr.length()]; for (std::size_t j = 0; j <= tmpstr.length(); j++) { zs.data[j] = tmpstr[j]; } bsa.fileNameBlock.fileNames.push_back(zs); } } if (archiveFlags.test(1)) { std::size_t frbfrs = 0; for (std::size_t i = 0; i < bsa.fileRecordBlocks.size(); ++i) frbfrs += bsa.fileRecordBlocks.at(i).fileRecords.size(); if (frbfrs != bsa.fileNameBlock.fileNames.size()) { std::cout << "ERROR : fileRecords and fileNameBlock number of " "files doesn't match" << std::endl; return is; } } if (archiveFlags.test(1)) { std::size_t c = 0; for (std::size_t i = 0; i < bsa.fileRecordBlocks.size(); ++i) { for (std::size_t j = 0; j < bsa.fileRecordBlocks.at(i).fileRecords.size(); ++j) { bsa.fileRecordBlocks.at(i).fileRecords.at(j).filename = &bsa.fileNameBlock.fileNames.at(c); c++; } } } return is; }
if (archiveFlags.test(0)) { read(is, &bzs.length, sizeof(bzs.length)); bzs.data = new char[bzs.length]; read(is, bzs.data, bzs.length); if (bzs.data[bzs.length - 1] != '\0') { std::cout << "ERROR : invalid bzstring" << std::endl; return is; } } else { bzs.length = 0; bzs.data = nullptr; }
if_condition
[ { "content": " def read(self):\n\n # open file\n\n file = open(self.filename, 'rb')\n\n # read file header\n\n self.header = {\n\n \"fileId\": str(file.read(4)),\n\n \"version\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n \"archiveFlags\": bytes_to_int(file.read(4)),\n\n \"folderCount\": bytes_to_int(file.read(4)),\n\n \"fileCount\": bytes_to_int(file.read(4)),\n\n \"totalFolderNameLength\": bytes_to_int(file.read(4)),\n\n \"totalFileNameLength\": bytes_to_int(file.read(4)),\n\n \"fileFlags\": bytes_to_int(file.read(4)),\n\n }\n\n # retrieve archive flags important flags\n\n archive_flags = self.header['archiveFlags']\n\n archive_flags_folder_name = (archive_flags & 0x1)\n\n archive_flags_file_name = (archive_flags & 0x2)\n\n archive_flags_file_compressed = (archive_flags & 0x4)\n\n # read folder records\n\n self.folderRecords = []\n\n for _ in range(self.header['folderCount']):\n\n folder_record = {\n\n \"nameHash\": bytes_to_int(file.read(8)),\n\n \"count\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n }\n\n self.folderRecords.append(folder_record)\n\n # read file record blocs\n\n self.fileRecordBlocks = []\n\n for i in range(self.header['folderCount']):\n\n name = None\n\n if archive_flags_folder_name:\n\n name = utils.read_bzstring(file)\n\n # read file record\n\n file_records = []\n\n for _ in range(self.folderRecords[i]['count']):\n\n file_record = {\n\n \"nameHash\": bytes_to_int(file.read(8)),\n\n \"fileSize\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n }\n\n file_records.append(file_record)\n\n\n\n file_record_block = {\n\n \"name\": name,\n\n \"fileRecord\": file_records,\n\n }\n\n self.fileRecordBlocks.append(file_record_block)\n\n # read file name block\n\n self.fileNameBlock = []\n\n if archive_flags_file_name:\n\n for _ in range(self.header['fileCount']):\n\n self.fileNameBlock.append(utils.read_zstring(file))\n\n # read data\n\n self.files = []\n\n if archive_flags_file_compressed:\n\n # read compressed data\n\n for i in self.fileRecordBlocks:\n\n for j in i['fileRecord']:\n\n # check offset\n\n assert file.tell() == j['offset'], \\\n\n f'current position {file.tell()} in file and offset {j[\"offset\"]} are not equal'\n\n # read compressed file\n\n uncompressed_size = bytes_to_int(file.read(4))\n\n compressed_file = file.read(j['fileSize']-4)\n\n # decompress file\n\n z_obj = zlib.decompressobj()\n\n uncompressed_file = z_obj.decompress(compressed_file)\n\n # check decompressed size\n\n assert uncompressed_size == len(uncompressed_file), \\\n\n f'decompression error, {uncompressed_size} not equal to {len(uncompressed_file)}'\n\n self.files.append(uncompressed_file)\n\n else:\n\n # read uncompressed data\n\n for i in self.fileRecordBlocks:\n\n for j in i['fileRecord']:\n\n self.files.append(file.read(j['fileSize']))\n\n\n\n byte = file.read(1)\n\n if byte:\n\n warnings.warn(f'Enf of read before end of file - {self.filename}')\n\n\n", "file_path": "PyOpenTES4/bsa.py", "rank": 0, "score": 36516.36541381817 }, { "content": "class BSA {\n\npublic:\n\n BSA();\n\n\n\n /**\n\n * @brief summary\n\n * print class information using std::cout\n\n */\n\n void summary();\n\n\n\n /**\n\n * @brief The BString struct\n\n * A string prefixed with a byte length. NOT zero terminated.\n\n */\n\n struct BString {\n\n int8_t length = 0;\n\n char* data = nullptr;\n\n };\n\n\n\n /**\n", "file_path": "OpenTES4/bsa.h", "rank": 1, "score": 28883.4070138076 }, { "content": "class BSA:\n\n def __init__(self, filename):\n\n self.filename = filename\n\n self.header = None\n\n self.folderRecords = None\n\n self.fileRecordBlocks = None\n\n self.fileNameBlock = None\n\n self.files = None\n\n\n\n def __repr__(self):\n\n return str(self.header) + \"\\n\" +\\\n\n str(self.folderRecords) + \"\\n\" +\\\n\n str(self.fileRecordBlocks) + \"\\n\" +\\\n\n str(self.fileNameBlock)\n\n\n\n def read(self):\n\n # open file\n\n file = open(self.filename, 'rb')\n\n # read file header\n\n self.header = {\n\n \"fileId\": str(file.read(4)),\n\n \"version\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n \"archiveFlags\": bytes_to_int(file.read(4)),\n\n \"folderCount\": bytes_to_int(file.read(4)),\n\n \"fileCount\": bytes_to_int(file.read(4)),\n\n \"totalFolderNameLength\": bytes_to_int(file.read(4)),\n\n \"totalFileNameLength\": bytes_to_int(file.read(4)),\n\n \"fileFlags\": bytes_to_int(file.read(4)),\n\n }\n\n # retrieve archive flags important flags\n\n archive_flags = self.header['archiveFlags']\n\n archive_flags_folder_name = (archive_flags & 0x1)\n\n archive_flags_file_name = (archive_flags & 0x2)\n\n archive_flags_file_compressed = (archive_flags & 0x4)\n\n # read folder records\n\n self.folderRecords = []\n\n for _ in range(self.header['folderCount']):\n\n folder_record = {\n\n \"nameHash\": bytes_to_int(file.read(8)),\n\n \"count\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n }\n\n self.folderRecords.append(folder_record)\n\n # read file record blocs\n\n self.fileRecordBlocks = []\n\n for i in range(self.header['folderCount']):\n\n name = None\n\n if archive_flags_folder_name:\n\n name = utils.read_bzstring(file)\n\n # read file record\n\n file_records = []\n\n for _ in range(self.folderRecords[i]['count']):\n\n file_record = {\n\n \"nameHash\": bytes_to_int(file.read(8)),\n\n \"fileSize\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n }\n\n file_records.append(file_record)\n\n\n\n file_record_block = {\n\n \"name\": name,\n\n \"fileRecord\": file_records,\n\n }\n\n self.fileRecordBlocks.append(file_record_block)\n\n # read file name block\n\n self.fileNameBlock = []\n\n if archive_flags_file_name:\n\n for _ in range(self.header['fileCount']):\n\n self.fileNameBlock.append(utils.read_zstring(file))\n\n # read data\n\n self.files = []\n\n if archive_flags_file_compressed:\n\n # read compressed data\n\n for i in self.fileRecordBlocks:\n\n for j in i['fileRecord']:\n\n # check offset\n\n assert file.tell() == j['offset'], \\\n\n f'current position {file.tell()} in file and offset {j[\"offset\"]} are not equal'\n\n # read compressed file\n\n uncompressed_size = bytes_to_int(file.read(4))\n\n compressed_file = file.read(j['fileSize']-4)\n\n # decompress file\n\n z_obj = zlib.decompressobj()\n\n uncompressed_file = z_obj.decompress(compressed_file)\n\n # check decompressed size\n\n assert uncompressed_size == len(uncompressed_file), \\\n\n f'decompression error, {uncompressed_size} not equal to {len(uncompressed_file)}'\n\n self.files.append(uncompressed_file)\n\n else:\n\n # read uncompressed data\n\n for i in self.fileRecordBlocks:\n\n for j in i['fileRecord']:\n\n self.files.append(file.read(j['fileSize']))\n\n\n\n byte = file.read(1)\n\n if byte:\n\n warnings.warn(f'Enf of read before end of file - {self.filename}')\n\n\n", "file_path": "PyOpenTES4/bsa.py", "rank": 2, "score": 27810.56055024093 }, { "content": "\n\n struct FileRecordBlocks {\n\n BZString name; // Only if bit 1 of archive flags is set\n\n std::vector<FileRecord> fileRecords;\n\n };\n\n\n\n struct FileNameBlock {\n\n std::vector<ZString> fileNames;\n\n };\n\n\n\n struct FileBlock {\n\n BString name; // Only if bit 9 of archive flags is set\n\n uint32_t originalSize; // only if compressed file block (else 0)\n\n uint8_t* data;\n\n };\n\n\n\n Header header;\n\n std::vector<FolderRecord> folderRecords;\n\n std::vector<FileRecordBlocks> fileRecordBlocks;\n\n FileNameBlock fileNameBlock; // Only if bit 2 of archive flags is set\n\n std::vector<FileBlock> files;\n\n};\n\n\n\nstd::istream& operator>>(std::istream& is, BSA& bsa);\n\n\n\n#endif // BSA_H\n", "file_path": "OpenTES4/bsa.h", "rank": 3, "score": 13978.332436886294 }, { "content": "#ifndef BSA_H\n\n#define BSA_H\n\n\n\n#include <bitset>\n\n#include <fstream>\n\n#include <iomanip>\n\n#include <iostream>\n\n#include <string>\n\n#include <vector>\n\n\n", "file_path": "OpenTES4/bsa.h", "rank": 4, "score": 13977.765520651246 }, { "content": " * @brief The BZString struct\n\n * A string prefixed with a byte length and terminated with a zero (\\x00).\n\n */\n\n struct BZString {\n\n int8_t length = 0;\n\n char* data = nullptr;\n\n };\n\n\n\n /**\n\n * @brief The ZString struct\n\n * A string terminated with a zero (\\x00).\n\n */\n\n struct ZString {\n\n char* data = nullptr;\n\n };\n\n\n\n struct Header {\n\n int8_t fileId[4];\n\n uint32_t version;\n\n uint32_t offset;\n", "file_path": "OpenTES4/bsa.h", "rank": 5, "score": 13977.690825681771 }, { "content": " uint32_t archiveFlags;\n\n uint32_t folderCount;\n\n uint32_t fileCount;\n\n uint32_t totalFolderNameLength;\n\n uint32_t totalFileNameLength;\n\n uint32_t fileFlags;\n\n };\n\n\n\n struct FolderRecord {\n\n uint64_t nameHash;\n\n uint32_t count;\n\n uint32_t offset;\n\n };\n\n\n\n struct FileRecord {\n\n uint64_t nameHash;\n\n uint32_t size;\n\n uint32_t offset;\n\n ZString* filename = nullptr;\n\n };\n", "file_path": "OpenTES4/bsa.h", "rank": 6, "score": 13975.341140593397 }, { "content": "def read_bzstring(file):\n\n b = bytes_to_int(file.read(1))\n\n zstring = file.read(b)\n\n if zstring[-1] != 0:\n\n raise ValueError\n", "file_path": "PyOpenTES4/utils.py", "rank": 16, "score": 11813.300031894334 }, { "content": "def read_zstring(file):\n\n zstring = \"\"\n\n b = file.read(1)\n\n while b and not b == b'\\x00':\n\n zstring += b.decode(\"utf-8\")\n\n b = file.read(1)\n", "file_path": "PyOpenTES4/utils.py", "rank": 17, "score": 11813.300031894334 }, { "content": "def read_bstring(file):\n\n b = bytes_to_int(file.read(1))\n\n bstring = file.read(b)\n", "file_path": "PyOpenTES4/utils.py", "rank": 18, "score": 11813.300031894334 }, { "content": "import warnings\n\nimport zlib\n\nimport utils\n\nfrom utils import bytes_to_int\n\n\n\n\n\nclass BSA:\n\n def __init__(self, filename):\n\n self.filename = filename\n\n self.header = None\n\n self.folderRecords = None\n\n self.fileRecordBlocks = None\n\n self.fileNameBlock = None\n\n self.files = None\n\n\n\n def __repr__(self):\n\n return str(self.header) + \"\\n\" +\\\n\n str(self.folderRecords) + \"\\n\" +\\\n\n str(self.fileRecordBlocks) + \"\\n\" +\\\n\n str(self.fileNameBlock)\n\n\n\n def read(self):\n\n # open file\n\n file = open(self.filename, 'rb')\n\n # read file header\n\n self.header = {\n\n \"fileId\": str(file.read(4)),\n\n \"version\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n \"archiveFlags\": bytes_to_int(file.read(4)),\n\n \"folderCount\": bytes_to_int(file.read(4)),\n\n \"fileCount\": bytes_to_int(file.read(4)),\n\n \"totalFolderNameLength\": bytes_to_int(file.read(4)),\n\n \"totalFileNameLength\": bytes_to_int(file.read(4)),\n\n \"fileFlags\": bytes_to_int(file.read(4)),\n\n }\n\n # retrieve archive flags important flags\n\n archive_flags = self.header['archiveFlags']\n\n archive_flags_folder_name = (archive_flags & 0x1)\n\n archive_flags_file_name = (archive_flags & 0x2)\n\n archive_flags_file_compressed = (archive_flags & 0x4)\n\n # read folder records\n\n self.folderRecords = []\n\n for _ in range(self.header['folderCount']):\n\n folder_record = {\n\n \"nameHash\": bytes_to_int(file.read(8)),\n\n \"count\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n }\n\n self.folderRecords.append(folder_record)\n\n # read file record blocs\n\n self.fileRecordBlocks = []\n\n for i in range(self.header['folderCount']):\n\n name = None\n\n if archive_flags_folder_name:\n\n name = utils.read_bzstring(file)\n\n # read file record\n\n file_records = []\n\n for _ in range(self.folderRecords[i]['count']):\n\n file_record = {\n\n \"nameHash\": bytes_to_int(file.read(8)),\n\n \"fileSize\": bytes_to_int(file.read(4)),\n\n \"offset\": bytes_to_int(file.read(4)),\n\n }\n\n file_records.append(file_record)\n\n\n\n file_record_block = {\n\n \"name\": name,\n\n \"fileRecord\": file_records,\n\n }\n\n self.fileRecordBlocks.append(file_record_block)\n\n # read file name block\n\n self.fileNameBlock = []\n\n if archive_flags_file_name:\n\n for _ in range(self.header['fileCount']):\n\n self.fileNameBlock.append(utils.read_zstring(file))\n\n # read data\n\n self.files = []\n\n if archive_flags_file_compressed:\n\n # read compressed data\n\n for i in self.fileRecordBlocks:\n\n for j in i['fileRecord']:\n\n # check offset\n\n assert file.tell() == j['offset'], \\\n\n f'current position {file.tell()} in file and offset {j[\"offset\"]} are not equal'\n\n # read compressed file\n\n uncompressed_size = bytes_to_int(file.read(4))\n\n compressed_file = file.read(j['fileSize']-4)\n\n # decompress file\n\n z_obj = zlib.decompressobj()\n\n uncompressed_file = z_obj.decompress(compressed_file)\n\n # check decompressed size\n\n assert uncompressed_size == len(uncompressed_file), \\\n\n f'decompression error, {uncompressed_size} not equal to {len(uncompressed_file)}'\n\n self.files.append(uncompressed_file)\n\n else:\n\n # read uncompressed data\n\n for i in self.fileRecordBlocks:\n\n for j in i['fileRecord']:\n\n self.files.append(file.read(j['fileSize']))\n\n\n\n byte = file.read(1)\n\n if byte:\n\n warnings.warn(f'Enf of read before end of file - {self.filename}')\n\n\n\n return 0\n", "file_path": "PyOpenTES4/bsa.py", "rank": 19, "score": 9402.317308672682 }, { "content": " def __repr__(self):\n\n return str(self.header) + \"\\n\" +\\\n\n str(self.folderRecords) + \"\\n\" +\\\n\n str(self.fileRecordBlocks) + \"\\n\" +\\\n", "file_path": "PyOpenTES4/bsa.py", "rank": 20, "score": 9032.90517295635 }, { "content": " def __init__(self, filename):\n\n self.filename = filename\n\n self.header = None\n\n self.folderRecords = None\n\n self.fileRecordBlocks = None\n\n self.fileNameBlock = None\n", "file_path": "PyOpenTES4/bsa.py", "rank": 21, "score": 9032.90517295635 }, { "content": "#include <fstream>\n\n#include <iostream>\n\n\n\n#include \"bsa.h\"\n\n\n\nint main()\n\n{\n\n std::cout << \"OpenTES4Oblivion\" << std::endl;\n\n\n\n BSA bsaMisc;\n\n BSA bsaMeshes;\n\n\n\n std::ifstream bsaFileMisc(\"Oblivion - Misc.bsa\", std::ios::binary);\n\n\n\n if (bsaFileMisc.is_open()) {\n\n std::cout << \"Oblivion - Misc.bsa\" << std::endl;\n\n\n\n bsaFileMisc >> bsaMisc;\n\n\n\n // bsaMisc.summary();\n", "file_path": "OpenTES4/main.cpp", "rank": 22, "score": 4.2359115264486595 }, { "content": "\n\n bsaFileMisc.close();\n\n }\n\n\n\n std::ifstream bsaFileMeshes(\"Oblivion - Meshes.bsa\", std::ios::binary);\n\n\n\n if (bsaFileMeshes.is_open()) {\n\n std::cout << \"Oblivion - Meshes.bsa\" << std::endl;\n\n\n\n bsaFileMeshes >> bsaMeshes;\n\n\n\n // bsaMeshes.summary();\n\n\n\n bsaFileMeshes.close();\n\n }\n\n\n\n return 0;\n\n}\n", "file_path": "OpenTES4/main.cpp", "rank": 23, "score": 3.0882335233939724 } ]
C++
libuuidpp/libuuidpp.hpp
dagronf/UUID_Wrapper
6ad8e7390d200bb96ef3e6e815650c2d5a2f886c
#pragma once #include <uuid/uuid.h> #include <string> #include <array> #ifndef __APPLE__ #include <string.h> typedef char __uuid_string_t[37]; typedef __uuid_string_t uuid_string_t; #endif static_assert(16 == sizeof(uuid_t), "uuid_t is of unexpected size"); static_assert(37 == sizeof(uuid_string_t), "Unexpected uuid_string_t size"); #include <type_traits> template<typename E> struct enable_bitmask_operators{ static const bool enable=false; }; template<typename E> typename std::enable_if<enable_bitmask_operators<E>::enable,E>::type operator|(E lhs,E rhs){ typedef typename std::underlying_type<E>::type underlying; return static_cast<E>( static_cast<underlying>(lhs) | static_cast<underlying>(rhs)); } template<typename E> typename std::enable_if<enable_bitmask_operators<E>::enable,E>::type operator&(E lhs,E rhs){ typedef typename std::underlying_type<E>::type underlying; return static_cast<E>( static_cast<underlying>(lhs) & static_cast<underlying>(rhs)); } namespace libuuidpp { namespace exception { struct invalid_uuid: public std::runtime_error { invalid_uuid(const char* guid) : std::runtime_error(std::string("libuuidpp exception: invalid guid '") + guid + "'") {} }; }; class uuid { public: static const uuid nil; typedef std::array<unsigned char, sizeof(uuid_t)> binary; inline static uuid random() { return uuid(libuuidpp::uuid::Random); } inline static bool is_valid(const char* uuidString) { uuid_t tmp; return internal_create(uuidString, tmp); } inline static bool is_valid(const std::string& uuidString) { return is_valid(uuidString.c_str()); } inline uuid() { internal_set(libuuidpp::uuid::Nil); } inline uuid(const uuid_t& rawValue) { ::uuid_copy(_rawuuid, rawValue); } inline uuid(const binary& data) { set(data); } inline uuid(const char* guidString) { if (!set(guidString)) { throw exception::invalid_uuid((guidString != NULL) ? guidString : "NULL"); } } inline uuid(const std::string& guidString) : uuid(guidString.c_str()) { } inline uuid(const uuid& right) { ::uuid_copy(_rawuuid, right._rawuuid); } inline bool set(const char* uuidString) { return internal_create(uuidString, _rawuuid); } inline bool set(const std::string& guidString) { return set(guidString.c_str()); } inline void set(const binary& data) { memcpy(_rawuuid, data.data(), data.size()); } inline void set_random() { ::uuid_generate_random(_rawuuid); } inline void set_nil() { ::uuid_clear(_rawuuid); } std::size_t hash() const; inline bool is_nil() const { return ::uuid_is_null(_rawuuid); } inline bool operator!=(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) != 0; } inline bool operator==(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) == 0; } inline bool operator<(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) < 0; } inline bool operator>(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) > 0; } enum class formatting { standard = 0, lowercase = 1 << 0, brackets = 1 << 1 }; std::string string(formatting format = formatting::standard) const; inline uuid::binary data() const { uuid::binary tmp; ::memcpy(tmp.data(), _rawuuid, sizeof(uuid_t)); return tmp; } private: typedef enum CreationState { Nil = 0, Random = 1 } CreationState; static const size_t STR_GUID_LEN = sizeof(uuid_string_t); static const size_t MS_GUID_LEN = STR_GUID_LEN + 1; inline static uuid internal_create(uuid::CreationState creation = uuid::Nil) { return uuid(creation); } inline static bool is_microsoft_formatted(const char* guid) { return ((::strnlen(guid, MS_GUID_LEN + 2) == MS_GUID_LEN) && guid[0] == '{' && guid[STR_GUID_LEN] == '}'); } static bool internal_microsoft_create(const char* uuidString, uuid_t& result); inline static bool internal_uuid_create(const char* uuidString, uuid_t& result) { return (::uuid_parse(uuidString, result) == 0); } static bool internal_create(const char* uuidString, uuid_t& result); inline void internal_set(CreationState creation = uuid::Nil) { (creation == uuid::Random) ? set_random() : set_nil(); } inline uuid(CreationState creation) { internal_set(creation); } ::uuid_t _rawuuid; }; }; namespace std { template<> struct hash<libuuidpp::uuid> { std::size_t operator()(libuuidpp::uuid const& s) const noexcept { return s.hash(); } }; } template<> struct enable_bitmask_operators<libuuidpp::uuid::formatting> { static const bool enable=true; }; namespace libuuidpp { const uuid uuid::nil = uuid::internal_create(libuuidpp::uuid::Nil); std::string uuid::string(libuuidpp::uuid::formatting format) const { std::string result; result.reserve(MS_GUID_LEN); uuid_string_t strVal; bool isBracketed = (format & formatting::brackets) == formatting::brackets; bool isLowercased = (format & formatting::lowercase) == formatting::lowercase; if (isBracketed) { result += "{"; } if (isLowercased) { ::uuid_unparse_lower(_rawuuid, strVal); } else { ::uuid_unparse_upper(_rawuuid, strVal); } result += std::string(strVal); if (isBracketed) { result += "}"; } return result; } std::size_t uuid::hash() const { #if INTPTR_MAX == INT64_MAX static const std::uint64_t FNV_offset_basis = 14695981039346656037UL; static const std::uint64_t FNV_prime = 1099511628211; #elif INTPTR_MAX == INT32_MAX static const std::uint32_t FNV_offset_basis = 2166136261; static const std::uint32_t FNV_prime = 16777619; #else #error Not a supported architecture (32bit or 64bit) #endif std::size_t result = FNV_offset_basis; for (std::size_t offset = 0; offset < sizeof(uuid_t); offset++) { result ^= _rawuuid[offset]; result *= FNV_prime; } return result; } bool uuid::internal_create(const char* uuidString, uuid_t& result) { if (uuidString != nullptr) { if (internal_microsoft_create(uuidString, result)) { return true; } else if (internal_uuid_create(uuidString, result)) { return true; } } ::uuid_clear(result); return false; } bool uuid::internal_microsoft_create(const char* uuidString, uuid_t& result) { if (is_microsoft_formatted(uuidString)) { char temp[STR_GUID_LEN]; ::memset(temp, 0, STR_GUID_LEN); ::memcpy(temp, uuidString+1, STR_GUID_LEN - 1); if (::uuid_parse(temp, result) != 0) { return false; } return true; } return false; } };
#pragma once #include <uuid/uuid.h> #include <string> #include <array> #ifndef __APPLE__ #include <string.h> typedef char __uuid_string_t[37]; typedef __uuid_string_t uuid_string_t; #endif static_assert(16 == sizeof(uuid_t), "uuid_t is of unexpected size"); static_assert(37 == sizeof(uuid_string_t), "Unexpected uuid_string_t size"); #include <type_traits> template<typename E> struct enable_bitmask_operators{ static const bool enable=false; }; template<typename E> typename std::enable_if<enable_bitmask_operators<E>::enable,E>::type operator|(E lhs,E rhs){ typedef typename std::underlying_type<E>::type underlying; return static_cast<E>( static_cast<underlying>(lhs) | static_cast<underlying>(rhs)); } template<typename E> typename std::enable_if<enable_bitmask_operators<E>::enable,E>::type operator&(E lhs,E rhs){ typedef typename std::underlying_type<E>::type underlying; return static_cast<E>( static_cast<underlying>(lhs) & static_cast<underlying>(rhs)); } namespace libuuidpp { namespace exception { struct invalid_uuid: public std::runtime_error { invalid_uuid(const char* guid) : std::runtime_error(std::string("libuuidpp exception: invalid guid '") + guid + "'") {} }; }; class uuid { public: static const uuid nil; typedef std::array<unsigned char, sizeof(uuid_t)> binary; inline static uuid random() { return uuid(libuuidpp::uuid::Random); } inline static bool is_valid(const char* uuidString) { uuid_t tmp; return internal_create(uuidString, tmp); } inline static bool is_valid(const std::string& uuidString) { return is_valid(uuidString.c_str()); } inline uuid() { internal_set(libuuidpp::uuid::Nil); } inline uuid(const uuid_t& rawValue) { ::uuid_copy(_rawuuid, rawValue); } inline uuid(const binary& data) { set(data); } inline uuid(const char* guidString) { if (!set(guidString)) { throw exception::invalid_uuid((guidString != NULL) ? guidString : "NULL"); } } inline uuid(const std::string& guidString) : uuid(guidString.c_str()) { } inline uuid(const uuid& right) { ::uuid_copy(_rawuuid, right._rawuuid); } inline bool set(const char* uuidString) { return internal_create(uuidString, _rawuuid); } inline bool set(const std::string& guidString) { return set(guidString.c_str()); } inline void set(const binary& data) { memcpy(_rawuuid, data.data(), data.size()); } inline void set_random() { ::uuid_generate_random(_rawuuid); } inline void set_nil() { ::uuid_clear(_rawuuid); } std::size_t hash() const; inline bool is_nil() const { return ::uuid_is_null(_rawuuid); } inline bool operator!=(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) != 0; } inline bool operator==(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) == 0; } inline bool operator<(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) < 0; } inline bool operator>(const uuid& right) const { return ::uuid_compare(_rawuuid, right._rawuuid) > 0; } enum class formatting { standard = 0, lowercase = 1 << 0, brackets = 1 << 1 }; std::string string(formatting format = formatting::standard) const; inline uuid::binary data() const { uuid::binary tmp; ::memcpy(tmp.data(), _rawuuid, sizeof(uuid_t)); return tmp; } private: typedef enum CreationState { Nil = 0, Random = 1 } CreationState; static const size_t STR_GUID_LEN = sizeof(uuid_string_t); static const size_t MS_GUID_LEN = STR_GUID_LEN + 1; inline static uuid internal_create(uuid::CreationState creation = uuid::Nil) { return uuid(creation); } inline static bool is_microsoft_formatted(const char* guid) { return ((::strnlen(guid, MS_GUID_LEN + 2) == MS_GUID_LEN) && guid[0] == '{' && guid[STR_GUID_LEN] == '}'); } static bool internal_microsoft_create(const char* uuidString, uuid_t& result); inline static bool internal_uuid_create(const char* uuidString, uuid_t& result) { return (::uuid_parse(uuidString, result) == 0); } static bool internal_create(const char* uuidString, uuid_t& result); inline void internal_set(CreationState creation = uuid::Nil) { (creation == uuid::Random) ? set_random() : set_nil(); } inline uuid(CreationState creation) { internal_set(creation); } ::uuid_t _rawuuid; }; }; namespace std { template<> struct hash<libuuidpp::uuid> { std::size_t operator()(libuuidpp::uuid const& s) const noexcept { return s.hash(); } }; } template<> struct enable_bitmask_operators<libuuidpp::uuid::formatting> { static const bool enable=true; }; namespace libuuidpp { const uuid uuid::nil = uuid::internal_create(libuuidpp::uuid::Nil); std::string uuid::string(libuuidpp::uuid::formatting format) const { std::string result; result.reserve(MS_GUID_LEN); uuid_string_t strVal; bool isBracketed = (format & formatting::brackets) == formatting::brackets; bool isLowercased = (format & formatting::lowercase) == formatting::lowercase; if (isBracketed) { result += "{"; } if (isLowercased) { ::uuid_unparse_lower(_rawuuid, strVal); } else { ::uuid_unparse_upper(_rawuuid, strVal); } result += std::string(strVal); if (isBracketed) { result += "}"; } return result; } std::size_t uuid::hash() const { #if INTPTR_MAX == INT64_MAX static const std::uint64_t FNV_offset_basis = 14695981039346656037UL; static const std::uint64_t FNV_prime = 1099511628211; #elif INTPTR_MAX == INT32_MAX static const std::uint32_t FNV_offset_basis = 2166136261; static const std::uint32_t FNV_prime = 16777619; #else #error Not a supported architecture (32bit or 64bit) #endif std::size_t result = FNV_offset_basis; for (std::size_t offset = 0; offset < sizeof(uuid_t); offset++) { result ^= _rawuuid[offset]; result *= FNV_prime; } return result; } bool uuid::internal_create(const char* uuidString, uuid_t& result) { if (uuidStrin
bool uuid::internal_microsoft_create(const char* uuidString, uuid_t& result) { if (is_microsoft_formatted(uuidString)) { char temp[STR_GUID_LEN]; ::memset(temp, 0, STR_GUID_LEN); ::memcpy(temp, uuidString+1, STR_GUID_LEN - 1); if (::uuid_parse(temp, result) != 0) { return false; } return true; } return false; } };
g != nullptr) { if (internal_microsoft_create(uuidString, result)) { return true; } else if (internal_uuid_create(uuidString, result)) { return true; } } ::uuid_clear(result); return false; }
function_block-function_prefixed
[ { "content": "# libuuidpp - A lightweight C++ UUID class.\n\n\n\nA lightweight C++ class wrapper around the `libuuid` library.\n\n\n\n## Features\n\n\n\n* Compatible with std containers such as `std::vector`, `std::set`, `std::map` etc.\n\n* Handles upper and lower case uuids.\n\n* Automatically handles Microsoft-formatted uuids `{D1ABE846-63D3-4C0A-89EF-68F1A306F6D3}`\n\n* Multiple formats for output strings (uppercase, lowercase, bracketed).\n\n* Equality and greater/lesser comparators.\n\n\n\n## Why?\n\n\n\nI wanted a very simple lightweight UUID class wrapper without having to import boost or some other large framework that would be compatible with the standard library (eg. `std::vector`, `std::map`). I also didn't want to write the UUID generation myself, as here be dragons (especially relating to privacy). libuuid is a well defined and tested generator.\n\n\n\n`libuuid` is installed by default on macOS and is an easy install for other platforms.\n\n\n\n## Usage\n\n\n\nJust add `libuuidpp/libuuidpp.hpp` to your project. Requires `libuuid` and standard C++ libraries (compatible back to C++11, tested up to C++17).\n\n\n\nYou can find a bunch of tests in `main.cpp`.\n\n\n\n## API classes\n\n\n\n### `libuuidpp::uuid`\n\n\n\nThe uuid class\n\n\n\n### `libuuidpp::uuid::formatting`\n\n\n\nA typesafe enum bitfield for describing string output.\n\n\n\n### `libuuidpp::uuid::binary`\n\n\n\nA class used to transport raw binary data in and out of the uuid object.\n\n\n\n## Examples\n\n\n\n### Simple creation\n\n```cpp\n\n// The standard string constructor throws an exception if the guid is invalid\n\nlibuuidpp::uuid uid1(\"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\");\n\nlibuuidpp::uuid uid2(\"d1abe846-63d3-4c0a-89ef-68f1a306f6d3\");\n\nlibuuidpp::uuid uid3(\"{D1ABE846-63D3-4C0A-89EF-68F1A306F6D3}\");\n\n```\n\n\n\n### Creating random UUIDs and nil UUID.\n\n```cpp\n\n// Create a random uuid\n\nauto random_uid = libuuidpp::uuid::random();\n\nassert(!random_uid.is_nil());\n\n\n\n// nil uuid (statically defined)\n\nconst auto& nil_uid = libuuidpp::uuid::nil;\n\nassert(nil_uid.is_nil());\n\n```\n\n\n", "file_path": "README.md", "rank": 19, "score": 8117.7211615866645 }, { "content": "### Binary handling\n\n```cpp\n\n/// Create a uuid object from raw binary data\n\nlibuuidpp::uuid::binary binaryData {\n\n 0xc0, 0x6c, 0x89, 0x2b, 0x50, 0xab, 0x45, 0x85, 0x98, 0x19, 0x5f, 0x4b, 0xa3, 0xb8, 0xf6, 0x9b\n\n};\n\nlibuuidpp::uuid uuid(binaryData);\n\n\n\n/// Get the data back out\n\nconst libuuidpp::uuid::binary roundTrip = raw.data();\n\n```\n\n\n\n### Setting\n\n\n\n#### Constructor throws exceptions for invalid uuids\n\n```cpp\n\ntry {\n\n libuuidpp::uuid my_dodgy_uuid(\"F211F534-8DFB-4269-9A bad\");\n\n\t\n\n // Do something with my_dodgy_uuid\n\n\t\n\n} catch (libuuidpp::exception::invalid_uuid e) {\n\n printf(\"Successfully caught exception during creation\\n\");\n\n}\n\n```\n\n#### Basic setters\n\n```cpp\n\nlibuuidpp::uuid myUUID;\n\nbool didSet = myUUID.set(\"F211F534-8DFB-4269-9AF1-245FA0AB8D87\");\n\nassert(didSet == true);\n\n\n\n/// Attempting assignment to an invalid uuid string\n\ndidSet = myUUID.set(\"D1ABE846-63D3-4C0A-89EF-\");\n\nassert(didSet == false);\n\nassert(myUUID.is_nil());\n\n\n\n/// Set myUUID to a random guid\n\nmyUUID.set_random();\n\nassert(!myUUID.is_nil());\n\n\n\n/// Assigning a new uuid\n\nauto newUUID = libuuidpp::uuid(\"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\");\n\nmyUUID = newUUID;\n\nassert(myUUID == newUUID);\n\n```\n\n### Generate a string from the uuid\n\n```cpp\n\nlibuuidpp::uuid uid1(\"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\");\n\n\n\n// Default output (uppercase, no brackets)\n\nstd::string uidString1 = uid1.str();\n\nassert(uidString1 == \"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\");\n\n\n\n// Lowercase output\n\nstd::string uidString2 = uid1.str(libuuidpp::uuid::formatting::lowercase);\n\nassert(uidString2 == \"d1abe846-63d3-4c0a-89ef-68f1a306f6d3\");\n\n\n\n// Bracketed output\n\nstd::string uidString3 = uid1.str(libuuidpp::uuid::formatting::brackets);\n\nassert(uidString3 == \"{D1ABE846-63D3-4C0A-89EF-68F1A306F6D3}\");\n\n\n\n// Lowercase, Bracketed output\n\nstd::string uidString4 = uid1.str(libuuidpp::uuid::formatting::lowercase | libuuidpp::uuid::formatting::brackets);\n\nassert(uidString4 == \"{d1abe846-63d3-4c0a-89ef-68f1a306f6d3}\");\n\n```\n", "file_path": "README.md", "rank": 20, "score": 8117.026913819676 }, { "content": "### Comparison operators\n\n```cpp\n\nlibuuidpp::uuid uid1(\"d1abe846-63d3-4c0a-89ef-68f1a306f6d3\");\n\nlibuuidpp::uuid uid2(\"{D1ABE846-63D3-4C0A-89EF-68F1A306F6D3}\");\n\nlibuuidpp::uuid uid3(\"84AEEDE7-E056-4F89-BAD1-BF97B96FAAAA\");\n\n\n\n/// uid1 and uid2 resolve to the same uuid value, therefore they are equal\n\nassert(uid1 == uid2);\n\n\n\n/// uid2 and uid3 are different uuids, so they aren't equal\n\nassert(uid2 != uid3);\n\n```\n\n### Lexigraphic sorting support\n\n```cpp\n\nstd::vector<libuuidpp::uuid> result;\n\nfor (size_t c = 0; c < 10; c++) {\n\n result.push_back(libuuidpp::uuid::random());\n\n}\n\nstd::sort(result1.begin(), result1.end(), std::less<libuuidpp::uuid>());\n\nstd::sort(result1.begin(), result1.end(), std::greater<libuuidpp::uuid>());\n\n```\n\n## Thanks\n\n\n\nTypesafe enum bitfield support from Just Software Solutions.\n\n\n\n - See [https://www.justsoftwaresolutions.co.uk/cplusplus/using-enum-classes-as-bitfields.html](https://www.justsoftwaresolutions.co.uk/cplusplus/using-enum-classes-as-bitfields.html)\n\n\n\n## License\n\n\n\n```\n\nBoost Software License - Version 1.0 - August 17th, 2003\n\n\n\nPermission is hereby granted, free of charge, to any person or organization\n\nobtaining a copy of the software and accompanying documentation covered by\n\nthis license (the \"Software\") to use, reproduce, display, distribute,\n\nexecute, and transmit the Software, and to prepare derivative works of the\n\nSoftware, and to permit third-parties to whom the Software is furnished to\n\ndo so, all subject to the following:\n\n\n\nThe copyright notices in the Software and this entire statement, including\n\nthe above license grant, this restriction and the following disclaimer,\n\nmust be included in all copies of the Software, in whole or in part, and\n\nall derivative works of the Software, unless such copies or derivative\n\nworks are solely in the form of machine-executable object code generated by\n\na source language processor.\n\n\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\nFITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT\n\nSHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE\n\nFOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,\n\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n\nDEALINGS IN THE SOFTWARE.\n\n```\n", "file_path": "README.md", "rank": 21, "score": 8106.408531226635 }, { "content": "\t\t\t\t\t \"a0478799-a6dd-4637-a8aa-87f6eb014317\",\n\n\t\t\t\t\t \"Binary data didn't match the string data?\");\n\n\n\n\tconst auto roundTrip = raw.data();\n\n\tDSF_ASSERT_EQUAL(rawData, roundTrip, \"Return trip raw data convert failed\")\n\n\n\n\tlibuuidpp::uuid valString(\"{C06C892B-50AB-4585-9819-5F4BA3B8F69B}\");\n\n\tlibuuidpp::uuid::binary valueExpected {\n\n\t\t0xc0, 0x6c, 0x89, 0x2b, 0x50, 0xab, 0x45, 0x85, 0x98, 0x19, 0x5f, 0x4b, 0xa3, 0xb8, 0xf6, 0x9b\n\n\t};\n\n\tconst auto valBinary = valString.data();\n\n\tDSF_ASSERT_EQUAL(valBinary,\n\n\t\t\t\t\t valueExpected,\n\n\t\t\t\t\t \"Return trip raw data convert failed\")\n\n}\n\n\n\nvoid testHashing() {\n\n\tstd::cout << \"Running test: testHashing\" << std::endl;\n\n\n\n\tconst auto s1 = libuuidpp::uuid::random();\n", "file_path": "main.cpp", "rank": 22, "score": 20.187058242087666 }, { "content": "\tgroup.insert(\"{c06c892b-50ab-4585-9819-5f4ba3b8f69b}\");\n\n\tDSF_ASSERT_EQUAL(1, group.size(), \"Supposedly unique items are not unique\");\n\n\n\n\t// Add 100000 guids, any duplicates will have been removed so check for exact count\n\n\tgroup.clear();\n\n\tconst size_t count = 100000;\n\n\tfor (size_t i = 0; i < count; i++) {\n\n\t\tgroup.insert(libuuidpp::uuid::random());\n\n\t}\n\n\tDSF_ASSERT_EQUAL(count, group.size(), \"Generated some non-unique uuids\");\n\n}\n\n\n\nvoid testBinary() {\n\n\tstd::cout << \"Running test: testBinary\" << std::endl;\n\n\n\n\tlibuuidpp::uuid::binary rawData {\n\n\t\t0xa0, 0x47, 0x87, 0x99, 0xa6, 0xdd, 0x46, 0x37, 0xa8, 0xaa, 0x87, 0xf6, 0xeb, 0x01, 0x43, 0x17\n\n\t};\n\n\tlibuuidpp::uuid raw(rawData);\n\n\tDSF_ASSERT_EQUAL(raw.string(libuuidpp::uuid::formatting::lowercase),\n", "file_path": "main.cpp", "rank": 23, "score": 17.595797857177846 }, { "content": "\n\n\tunorderedSet.clear();\n\n\n\n\t// Create 'count' random guids\n\n\tfor (size_t i = 0; i < count; i++) {\n\n\t\tunorderedSet.insert(libuuidpp::uuid::random());\n\n\t}\n\n\n\n\tstd::set<std::size_t> hashes;\n\n\tstd::for_each(unorderedSet.begin(), unorderedSet.end(), [&hashes](const libuuidpp::uuid& element) {\n\n\t\thashes.insert(element.hash());\n\n\t});\n\n\n\n\t// All of the hashes should be unique. Hashes uses a set, so duplicates will be removed\n\n\tDSF_ASSERT_EQUAL(count, hashes.size(), \"Found duplicates\");\n\n}\n\n\n\nvoid testInvalid() {\n\n\tstd::cout << \"Running test: testInvalid\" << std::endl;\n\n\n", "file_path": "main.cpp", "rank": 24, "score": 17.258024126353767 }, { "content": "\t} catch (libuuidpp::exception::invalid_uuid e) {\n\n\t\tstd::cout << \"Caught exception during creation of valid uuid\" << std::endl;\n\n\t\tDSF_ASSERT(false);\n\n\t}\n\n\n\n\tauto tempStr = temp2->string();\n\n\tDSF_ASSERT(tempStr == \"C06C892B-50AB-4585-9819-5F4BA3B8F69B\");\n\n#endif\n\n\n\n\tauto c1 = libuuidpp::uuid::random();\n\n\tlibuuidpp::uuid c2 = c1;\n\n\tDSF_ASSERT(c1 == c2); // \"Random guids are the same!\"\n\n\n\n\tauto s1 = c1.string();\n\n\tlibuuidpp::uuid c3(s1.c_str());\n\n\tDSF_ASSERT(c1 == c3);\n\n\n\n\tDSF_ASSERT(c1.is_nil() == false);\n\n\n\n\tconst auto& nil = libuuidpp::uuid::nil;\n", "file_path": "main.cpp", "rank": 25, "score": 17.200150874743635 }, { "content": "\tconst auto s2 = libuuidpp::uuid::random();\n\n\tconst auto& nil = libuuidpp::uuid::nil;\n\n\tconst libuuidpp::uuid nilc;\n\n\n\n\tDSF_ASSERT_EQUAL(nil.hash(), nil.hash(), \"Null hash values should be equal\");\n\n\tDSF_ASSERT_EQUAL(nilc.hash(), nilc.hash(), \"Null hash values should be equal\");\n\n\tDSF_ASSERT_EQUAL(nil.hash(), nilc.hash(), \"Null hash values should be equal\");\n\n\tDSF_ASSERT_EQUAL(s1.hash(), s1.hash(), \"Same uuid generated different hashes\");\n\n\tDSF_ASSERT_NOTEQUAL(s1.hash(), s2.hash(), \"Hash values should be different\");\n\n\tDSF_ASSERT_NOTEQUAL(s1.hash(), nil.hash(), \"Hash values should be different\");\n\n\n\n\tstd::unordered_set<libuuidpp::uuid> unorderedSet { s1, s2, s2, nil, nil };\n\n\tDSF_ASSERT_EQUAL(3, unorderedSet.size(), \"Expecting 3 elements\");\n\n\n\n\tunorderedSet.clear();\n\n\tconst size_t count = 100000;\n\n\tfor (size_t i = 0; i < count; i++) {\n\n\t\tunorderedSet.insert(libuuidpp::uuid::random());\n\n\t}\n\n\tDSF_ASSERT_EQUAL(count, unorderedSet.size(), \"Mismatch in unordered_set size - unexpected hashing clash\");\n", "file_path": "main.cpp", "rank": 26, "score": 16.651881493802126 }, { "content": "\tDSF_ASSERT(libuuidpp::uuid::nil.is_nil());\n\n\n\n\tconst auto& nilUUID = libuuidpp::uuid::nil;\n\n\tDSF_ASSERT(nilUUID.is_nil());\n\n\n\n\t// Check that the static nil object is created only once (addresses should be the same)\n\n\tDSF_ASSERT_EQUAL(&libuuidpp::uuid::nil, &libuuidpp::uuid::nil, \"static nils have different addresses?\");\n\n\n\n\tconst libuuidpp::uuid nilc;\n\n\tDSF_ASSERT_NOTEQUAL(&libuuidpp::uuid::nil, &nilc, \"static nil and dynamically created nil have the same address?\");\n\n\n\n\t// Random guid creation\n\n\n\n\tlibuuidpp::uuid c1 = libuuidpp::uuid::random();\n\n\tlibuuidpp::uuid c2 = libuuidpp::uuid::random();\n\n\n\n\tDSF_ASSERT_NOTEQUAL(c1, c2, \"Random guids are the same!\");\n\n\n\n\t// nil guid creation\n\n\n", "file_path": "main.cpp", "rank": 27, "score": 15.835971052739414 }, { "content": "\n\n}\n\n\n\nvoid testAssign() {\n\n\n\n\tstd::cout << \"Running test: testAssign\" << std::endl;\n\n\n\n#if defined(UUID_OPTIONAL_SUPPORT)\n\n\tstd::optional<libuuidpp::uuid> temp1;\n\n\ttry {\n\n\t\ttemp1 = std::make_optional(libuuidpp::uuid(\"This should fail\"));\n\n\t\tstd::cerr << \"Didn't catch exception during creation\" << std::endl;\n\n\t\tDSF_ASSERT(false);\n\n\t} catch (libuuidpp::exception::invalid_uuid e) {\n\n\t\tstd::cout << \"Successfully caught exception during creation\" << std::endl;\n\n\t}\n\n\n\n\tstd::optional<libuuidpp::uuid> temp2;\n\n\ttry {\n\n\t\ttemp2 = std::make_optional(libuuidpp::uuid(\"C06C892B-50AB-4585-9819-5F4BA3B8F69B\"));\n", "file_path": "main.cpp", "rank": 28, "score": 15.349019633508618 }, { "content": "\tDSF_ASSERT_FALSE(libuuidpp::uuid::is_valid(NULL), \"Invalid uuid string should create nil uuid\");\n\n}\n\n\n\nvoid testMap() {\n\n\tstd::cout << \"Running test: testMap\" << std::endl;\n\n\n\n\t/// Adding to a map as the key\n\n\tstd::map<libuuidpp::uuid, std::string> values;\n\n\tlibuuidpp::uuid g1(\"C06C892B-50AB-4585-9819-5F4BA3B8F69B\");\n\n\tlibuuidpp::uuid g11(\"{C06C892B-50AB-4585-9819-5F4BA3B8F69B}\");\n\n\tlibuuidpp::uuid g2(\"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\");\n\n\tlibuuidpp::uuid g3(\"F211F534-8DFB-4269-9AF1-245FA0AB8D87\");\n\n\tvalues[g1] = \"this is a uuid\";\n\n\tvalues[g2] = \"this is another uuid\";\n\n\n\n\tDSF_ASSERT(values[g1] == \"this is a uuid\");\n\n\tDSF_ASSERT(values[g11] == \"this is a uuid\");\n\n\tDSF_ASSERT(values[g2] == \"this is another uuid\");\n\n\n\n\t/// As g3 doesn't exist in the map, the [] operator adds g3 with a default std::string value\n", "file_path": "main.cpp", "rank": 29, "score": 12.906230520969597 }, { "content": "\tDSF_ASSERT(nil.is_nil());\n\n\tDSF_ASSERT(nil != c1);\n\n\n\n\tc1.set_nil();\n\n\tDSF_ASSERT(c1.is_nil());\n\n\n\n\tc1.set_random();\n\n\tDSF_ASSERT(c1 != c3);\n\n\n\n\tstd::string stdguid = \"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\";\n\n\tauto stdguid1 = libuuidpp::uuid(stdguid.c_str());\n\n\tauto sg2 = stdguid1.string();\n\n\tDSF_ASSERT(stdguid == sg2);\n\n}\n\n\n\nvoid testMSGuid() {\n\n\n\n\tstd::cout << \"Running test: testMSGuid\" << std::endl;\n\n\n\n\tstd::string msGuid = \"{D1ABE846-63D3-4C0A-89EF-68F1A306F6D3}\";\n", "file_path": "main.cpp", "rank": 30, "score": 12.780071419048403 }, { "content": "\n\n\tstd::set<libuuidpp::uuid> uuids = { g3, g11, g2, g1 };\n\n\n\n\t// g1 and g11 are the same uuid (even though they have different strings during creation)\n\n\tDSF_ASSERT(uuids.size() == 3);\n\n\n\n\tstd::vector<std::string> uuidStrings;\n\n\tstd::transform(uuids.begin(), uuids.end(),\n\n\t\t\t\t std::back_inserter(uuidStrings),\n\n\t\t\t\t [](const libuuidpp::uuid& uuid) -> std::string\n\n\t\t\t\t {\n\n\t\t\t\t\t return uuid.string(libuuidpp::uuid::formatting::lowercase | libuuidpp::uuid::formatting::brackets);\n\n\t\t\t\t });\n\n\n\n\tstd::vector<std::string> expected = {\n\n\t\t\"{c06c892b-50ab-4585-9819-5f4ba3b8f69b}\",\n\n\t\t\"{d1abe846-63d3-4c0a-89ef-68f1a306f6d3}\",\n\n\t\t\"{f211f534-8dfb-4269-9af1-245fa0ab8d87}\" };\n\n\n\n\tDSF_ASSERT(uuidStrings == expected);\n", "file_path": "main.cpp", "rank": 31, "score": 12.390816970146737 }, { "content": "\tlibuuidpp::uuid test1;\n\n\n\n\t// Make sure that we can successfully parse a goodun\n\n\tDSF_ASSERT(test1.set(\"C06C892B-50AB-4585-9819-5F4BA3B8F69B\") == true);\n\n\tDSF_ASSERT_FALSE(test1.is_nil(), \"Correct uuid string should not be nil\");\n\n\n\n\t// Length and bracket checks\n\n\n\n\t// Check that invalid set automatically sets the value to nil\n\n\tDSF_ASSERT_FALSE(test1.set(\"C56A4180-65AA-42EC-A945-5FD21DEC\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT(test1.is_nil());\n\n\n\n\t// Static validation methods\n\n\tDSF_ASSERT(libuuidpp::uuid::is_valid(\"C06C892B-50AB-4585-9819-5F4BA3B8F69B\"));\n\n\tDSF_ASSERT(libuuidpp::uuid::is_valid(\"{e8e3db08-dc39-48ea-a3db-08dc3958eafb}\"));\n\n\tDSF_ASSERT(libuuidpp::uuid::is_valid(\"{29C49537-2BD1-4DA1-887A-5D0B93514BAD}\"));\n\n\n\n\tDSF_ASSERT_FALSE(libuuidpp::uuid::is_valid(\"{29C49537-2xD1-4DA1-887A-5D0B93514BAD}\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(libuuidpp::uuid::is_valid(\" 33aff347-1028-4fb2-86c7-2cdf06ef3610}\"), \"Invalid uuid string should create nil uuid\");\n\n\n", "file_path": "main.cpp", "rank": 32, "score": 11.913154997467636 }, { "content": "\tDSF_ASSERT(s6 == sGuidlb);\n\n}\n\n\n\nvoid testOrdering() {\n\n\n\n\tstd::cout << \"Running test: testOrdering\" << std::endl;\n\n\n\n\tstd::vector<libuuidpp::uuid> result1;\n\n\tstd::vector<libuuidpp::uuid> result2;\n\n\tfor (size_t c = 0; c < 10; c++) {\n\n\t\tresult1.push_back(libuuidpp::uuid::random());\n\n\t}\n\n\tfor (size_t c = 0; c < 10; c++) {\n\n\t\tresult2.push_back(libuuidpp::uuid::random());\n\n\t}\n\n\n\n\tDSF_ASSERT(result1 != result2);\n\n\n\n\tauto result3 = result1;\n\n\tDSF_ASSERT(result1 == result3);\n", "file_path": "main.cpp", "rank": 33, "score": 11.713485155724209 }, { "content": "\tlibuuidpp::uuid n1, n2;\n\n\tDSF_ASSERT_EQUAL(n1, n2, \"generated uuids are equal\");\n\n\tDSF_ASSERT_NOTEQUAL(n1, c1, \"random and nil guids are equal?\");\n\n\n\n\tuuid_t rawValue;\n\n\t::uuid_generate(rawValue);\n\n\tlibuuidpp::uuid c3(rawValue);\n\n\n\n\t::uuid_string_t stringVal;\n\n\t::uuid_unparse_upper(rawValue, stringVal);\n\n\n\n\tauto rawString = std::string(stringVal);\n\n\tDSF_ASSERT_EQUAL(rawString, c3.string(), \"generated string are not equal\");\n\n\n\n\t// Generate some random guids - check for uniqueness (dumb test really)\n\n\tstd::set<libuuidpp::uuid> group;\n\n\n\n\t// Check that duplicated items are not stored in a set\n\n\tgroup.insert(\"C06C892B-50AB-4585-9819-5F4BA3B8F69B\");\n\n\tgroup.insert(\"{C06C892B-50AB-4585-9819-5F4BA3B8F69B}\");\n", "file_path": "main.cpp", "rank": 34, "score": 11.2806261017063 }, { "content": "\t// Correctly formatted uuid should contain - separators\n\n\tDSF_ASSERT_FALSE(libuuidpp::uuid::is_valid(\"6D059566588D4BF081933253FAFD1426\"), \"Invalid uuid string should create nil uuid\");\n\n\n\n\t// Series of badly formatted\n\n\tDSF_ASSERT_FALSE(test1.set(\" C06C892B-50AB-4585-9819-5F4BA3B8F69B\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"{8078cbe9-2b91-4d82-9e8a-8d27ca5fcfa8\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"C06C892B-50AB-4585-9819-5F4BA3B8F69B}\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"{C06C892B-50AB-4585-9819-5F4BA3B8F69B} \"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"{C06C892B-50AB-4585-9819-5F4BA3B8F69BA}\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"C06C892B-50AB-4585-9819-5F4BA3B8F69BAA\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"{C06C892B-50AB-4585-9819-5F4BA3B8F69BA\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"{ C06C892B-50AB-4585-9819-5F4BA3B8F69B}\"), \"Invalid uuid string should create nil uuid\");\n\n\n\n\t// Invalid chars in the guid\n\n\tDSF_ASSERT_FALSE(test1.set(\"{C06C892B-50AB-4585-9819-5F4&A3B8F69B}\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(test1.set(\"C06C892B-50XB-4585-9819-5F4A3B8F69B\"), \"Invalid uuid string should create nil uuid\");\n\n\n\n\t// Invalid empty string\n\n\tDSF_ASSERT_FALSE(test1.set(\"\"), \"Invalid uuid string should create nil uuid\");\n\n\tDSF_ASSERT_FALSE(libuuidpp::uuid::is_valid(nullptr), \"Invalid uuid string should create nil uuid\");\n", "file_path": "main.cpp", "rank": 35, "score": 11.199405554320144 }, { "content": "\tauto s5 = sGuidl2.string(libuuidpp::uuid::formatting::lowercase | libuuidpp::uuid::formatting::brackets);\n\n\tDSF_ASSERT(sGuidl == s4);\n\n}\n\n\n\nvoid testUpperLower() {\n\n\n\n\tstd::cout << \"Running test: testUpperLower\" << std::endl;\n\n\n\n\tstd::string sGuid = \"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\";\n\n\tstd::string sGuidl = \"d1abe846-63d3-4c0a-89ef-68f1a306f6d3\";\n\n\tstd::string sGuidlb = \"{d1abe846-63d3-4c0a-89ef-68f1a306f6d3}\";\n\n\tstd::string sGuidub = \"{D1ABE846-63D3-4C0A-89EF-68F1A306F6D3}\";\n\n\n\n\tstd::vector<libuuidpp::uuid> vals = { sGuid, sGuidl, sGuidlb, sGuidub };\n\n\tstd::vector<std::string> expected(4, \"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\");\n\n\n\n\t// Maps the vals vector to their string equivalents\n\n\tstd::vector<std::string> uuidStrings;\n\n\tstd::transform(vals.begin(), vals.end(),\n\n\t\t\t\t std::back_inserter(uuidStrings),\n", "file_path": "main.cpp", "rank": 36, "score": 11.12132883943553 }, { "content": "\t\t\t\t [](const libuuidpp::uuid& uuid) -> std::string\n\n\t{\n\n\t\treturn uuid.string();\n\n\t});\n\n\tDSF_ASSERT(uuidStrings == expected);\n\n\n\n\tauto sGuid2 = libuuidpp::uuid(sGuid);\n\n\tauto sGuidl2 = libuuidpp::uuid(sGuidl);\n\n\tDSF_ASSERT(sGuid2 == sGuidl2);\n\n\n\n\tauto s3 = sGuid2.string();\n\n\tDSF_ASSERT(sGuid == s3);\n\n\n\n\tauto s4 = sGuidl2.string(libuuidpp::uuid::formatting::lowercase);\n\n\tDSF_ASSERT(sGuidl == s4);\n\n\n\n\tauto s5 = sGuidl2.string();\n\n\tDSF_ASSERT(s4 != s5);\n\n\n\n\tauto s6 = sGuidl2.string(libuuidpp::uuid::formatting::lowercase | libuuidpp::uuid::formatting::brackets);\n", "file_path": "main.cpp", "rank": 37, "score": 10.61528568570835 }, { "content": "\tstd::string sGuid = \"D1ABE846-63D3-4C0A-89EF-68F1A306F6D3\";\n\n\tstd::string sGuidl = \"d1abe846-63d3-4c0a-89ef-68f1a306f6d3\";\n\n\n\n\tauto msGuid2 = libuuidpp::uuid(msGuid);\n\n\tauto sGuid2 = libuuidpp::uuid(sGuid);\n\n\tauto sGuidl2 = libuuidpp::uuid(sGuidl);\n\n\tDSF_ASSERT(msGuid2 == sGuid2);\n\n\n\n\t/// Check that a lowercase version matches\n\n\tDSF_ASSERT(msGuid2 == sGuidl2);\n\n\n\n\tauto s2 = msGuid2.string(libuuidpp::uuid::formatting::brackets);\n\n\tDSF_ASSERT(msGuid == s2);\n\n\n\n\tauto s3 = sGuid2.string();\n\n\tDSF_ASSERT(sGuid == s3);\n\n\n\n\tauto s4 = sGuidl2.string(libuuidpp::uuid::formatting::lowercase);\n\n\tDSF_ASSERT(sGuidl == s4);\n\n\n", "file_path": "main.cpp", "rank": 38, "score": 10.554300347093399 }, { "content": "\tDSF_ASSERT(values[g3] == \"\");\n\n\n\n\t/// Adding to a map as the valuetype\n\n\tstd::map<std::string, libuuidpp::uuid> mapper;\n\n\tmapper[\"cat\"] = g1;\n\n\tmapper[\"dog\"] = g2;\n\n\n\n\tconst auto& m1 = mapper[\"cat\"];\n\n\tconst auto& m2 = mapper[\"dog\"];\n\n\tDSF_ASSERT(!m1.is_nil());\n\n\tDSF_ASSERT(!m2.is_nil());\n\n\n\n\t/// Asking for a key that doesn't exist returns a null guid.\n\n\tauto ret = mapper.find(\"caterpillar\");\n\n\tDSF_ASSERT(ret == mapper.end());\n\n\n\n\tconst auto& m3 = mapper[\"caterpillar\"];\n\n\tDSF_ASSERT(m3.is_nil());\n\n\n\n\t// Set stuff\n", "file_path": "main.cpp", "rank": 39, "score": 10.013529605626239 }, { "content": "\tresult4.push_back(result4[2]);\n\n\tstd::sort(result4.begin(), result4.end());\n\n\tduplicate = std::adjacent_find(result4.begin(), result4.end());\n\n\tDSF_ASSERT(duplicate != result4.end());\n\n}\n\n\n\nint main(int argc, const char * argv[]) {\n\n\t// insert code here...\n\n\tstd::cout << \"Starting tests...\\n\";\n\n\n\n\ttestSimple();\n\n\ttestBinary();\n\n\ttestInvalid();\n\n\ttestMap();\n\n\ttestHashing();\n\n\ttestAssign();\n\n\ttestOrdering();\n\n\ttestMSGuid();\n\n\ttestUpperLower();\n\n\n\n\tstd::cout << \"... tests complete\\n\";\n\n\n\n\treturn 0;\n\n}\n\n\n\n\n", "file_path": "main.cpp", "rank": 40, "score": 9.617017218230426 }, { "content": "\n\n\tstd::sort(result1.begin(), result1.end(), std::less<libuuidpp::uuid>());\n\n\tDSF_ASSERT(result1 != result3);\n\n\tstd::sort(result3.begin(), result3.end(), std::less<libuuidpp::uuid>());\n\n\tDSF_ASSERT(result1 == result3);\n\n\n\n\tauto find = std::find(result1.begin(), result1.end(), libuuidpp::uuid::nil);\n\n\tDSF_ASSERT(find == result1.end());\n\n\n\n\tauto duplicate = std::adjacent_find(result1.begin(), result1.end());\n\n\tDSF_ASSERT(duplicate == result1.end());\n\n\n\n\tstd::vector<libuuidpp::uuid> result4;\n\n\tfor (size_t c = 0; c < 100; c++) {\n\n\t\tresult4.push_back(libuuidpp::uuid::random());\n\n\t}\n\n\tduplicate = std::adjacent_find(result4.begin(), result4.end());\n\n\tstd::sort(result4.begin(), result4.end());\n\n\tDSF_ASSERT(duplicate == result4.end());\n\n\n", "file_path": "main.cpp", "rank": 41, "score": 9.549022478434756 }, { "content": "// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\n// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT\n\n// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE\n\n// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,\n\n// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n\n// DEALINGS IN THE SOFTWARE.\n\n//\n\n\n\n#include <iostream>\n\n#include <vector>\n\n#include <map>\n\n#include <set>\n\n#include <algorithm>\n\n#include <unordered_set>\n\n\n\n#if __cplusplus == 201703\t\t// C++17 std::optional support\n\n#define UUID_OPTIONAL_SUPPORT 1\n\n#include <optional>\n\n#endif\n", "file_path": "main.cpp", "rank": 42, "score": 7.184216214452288 }, { "content": "\n\n#include \"libuuidpp/libuuidpp.hpp\"\n\n\n\n/// Simple test harness\n\n\n\n#define DSF_ASSERT(ASSERTION) if (!(ASSERTION)) \\\n\n{ std::cerr << \"ASSERTION: Line \" << __LINE__ << \", file: \" << __FILE__ << \"\\n\"; abort(); }\n\n#define DSF_ASSERT_FALSE(ASSERTION, msg) if ((ASSERTION)) \\\n\n{ std::cerr << \"ASSERTION: Line \" << __LINE__ << \", file: \" << __FILE__ << \", message: '\" << msg << \"'\\n\"; abort(); }\n\n#define DSF_ASSERT_MSG(ASSERTION, msg) if (!(ASSERTION)) \\\n\n{ std::cerr << \"ASSERTION: Line \" << __LINE__ << \", file: \" << __FILE__ << \", message: '\" << msg << \"'\\n\"; abort(); }\n\n#define DSF_ASSERT_EQUAL(AVAL, BVAL, msg) if ((AVAL) != (BVAL)) \\\n\n{ std::cerr << \"ASSERTION: Line \" << __LINE__ << \", file: \" << __FILE__ << \", message: '\" << msg << \"'\\n\"; abort(); }\n\n#define DSF_ASSERT_NOTEQUAL(AVAL, BVAL, msg) if ((AVAL) == (BVAL)) \\\n\n{ std::cerr << \"ASSERTION: Line \" << __LINE__ << \", file: \" << __FILE__ << \", message: '\" << msg << \"'\\n\"; abort(); }\n\n\n\nvoid testSimple() {\n\n\n\n\tstd::cout << \"Running test: testSimple\" << std::endl;\n\n\n", "file_path": "main.cpp", "rank": 43, "score": 5.7462008134464675 }, { "content": "//\n\n// main.cpp\n\n// libuuidpp tests\n\n//\n\n// Boost Software License - Version 1.0 - August 17th, 2003\n\n//\n\n// Permission is hereby granted, free of charge, to any person or organization\n\n// obtaining a copy of the software and accompanying documentation covered by\n\n// this license (the \"Software\") to use, reproduce, display, distribute,\n\n// execute, and transmit the Software, and to prepare derivative works of the\n\n// Software, and to permit third-parties to whom the Software is furnished to\n\n// do so, all subject to the following:\n\n//\n\n// The copyright notices in the Software and this entire statement, including\n\n// the above license grant, this restriction and the following disclaimer,\n\n// must be included in all copies of the Software, in whole or in part, and\n\n// all derivative works of the Software, unless such copies or derivative\n\n// works are solely in the form of machine-executable object code generated by\n\n// a source language processor.\n\n//\n", "file_path": "main.cpp", "rank": 44, "score": 3.08650261099255 } ]
C++
Base/QTGUI/qSlicerExtensionsManagerDialog.cxx
TheInterventionCentre/NorMIT-Plan-App
765ed9a5dccc1cc134b65ccabe93fc132baeb2ea
#include <QPushButton> #include "qSlicerApplication.h" #include "qSlicerExtensionsManagerDialog.h" #include "qSlicerExtensionsManagerModel.h" #include "qSlicerSettingsExtensionsPanel.h" #include "ui_qSlicerExtensionsManagerDialog.h" class qSlicerExtensionsManagerDialogPrivate: public Ui_qSlicerExtensionsManagerDialog { Q_DECLARE_PUBLIC(qSlicerExtensionsManagerDialog); protected: qSlicerExtensionsManagerDialog* const q_ptr; public: qSlicerExtensionsManagerDialogPrivate(qSlicerExtensionsManagerDialog& object); void init(); bool RestartRequested; QStringList PreviousModulesAdditionalPaths; QStringList PreviousExtensionsScheduledForUninstall; QVariantMap PreviousExtensionsScheduledForUpdate; }; qSlicerExtensionsManagerDialogPrivate::qSlicerExtensionsManagerDialogPrivate(qSlicerExtensionsManagerDialog& object) :q_ptr(&object) { } void qSlicerExtensionsManagerDialogPrivate::init() { Q_Q(qSlicerExtensionsManagerDialog); this->setupUi(q); QPushButton * restartButton = this->ButtonBox->button(QDialogButtonBox::Ok); restartButton->setText("Restart"); q->setRestartRequested(false); QSettings * settings = qSlicerCoreApplication::application()->revisionUserSettings(); this->PreviousModulesAdditionalPaths = settings->value("Modules/AdditionalPaths").toStringList(); this->PreviousExtensionsScheduledForUninstall = settings->value("Extensions/ScheduledForUninstall").toStringList(); this->PreviousExtensionsScheduledForUpdate = settings->value("Extensions/ScheduledForUpdate").toMap(); qSlicerSettingsExtensionsPanel * extensionsPanel = qobject_cast<qSlicerSettingsExtensionsPanel*>( qSlicerApplication::application()->settingsDialog()->panel("Extensions")); Q_ASSERT(extensionsPanel); if (extensionsPanel) { QObject::connect(extensionsPanel, SIGNAL(extensionsServerUrlChanged(QString)), this->ExtensionsManagerWidget, SLOT(refreshInstallWidget())); } } qSlicerExtensionsManagerDialog::qSlicerExtensionsManagerDialog(QWidget *_parent) : Superclass(_parent) , d_ptr(new qSlicerExtensionsManagerDialogPrivate(*this)) { Q_D(qSlicerExtensionsManagerDialog); d->init(); } qSlicerExtensionsManagerDialog::~qSlicerExtensionsManagerDialog() { } qSlicerExtensionsManagerModel* qSlicerExtensionsManagerDialog::extensionsManagerModel()const { Q_D(const qSlicerExtensionsManagerDialog); return d->ExtensionsManagerWidget->extensionsManagerModel(); } void qSlicerExtensionsManagerDialog::setExtensionsManagerModel(qSlicerExtensionsManagerModel* model) { Q_D(qSlicerExtensionsManagerDialog); if (this->extensionsManagerModel() == model) { return; } disconnect(this, SLOT(onModelUpdated())); d->ExtensionsManagerWidget->setExtensionsManagerModel(model); if (model) { this->onModelUpdated(); connect(model, SIGNAL(modelUpdated()), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionInstalled(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionScheduledForUninstall(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionCancelledScheduleForUninstall(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionScheduledForUpdate(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionCancelledScheduleForUpdate(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionEnabledChanged(QString,bool)), this, SLOT(onModelUpdated())); } } bool qSlicerExtensionsManagerDialog::restartRequested()const { Q_D(const qSlicerExtensionsManagerDialog); return d->RestartRequested; } void qSlicerExtensionsManagerDialog::setRestartRequested(bool value) { Q_D(qSlicerExtensionsManagerDialog); d->RestartRequested = value; d->RestartRequestedLabel->setVisible(value); d->ButtonBox->button(QDialogButtonBox::Ok)->setEnabled(value); } void qSlicerExtensionsManagerDialog::onModelUpdated() { Q_D(qSlicerExtensionsManagerDialog); Q_ASSERT(this->extensionsManagerModel()); bool shouldRestart = false; qSlicerCoreApplication * coreApp = qSlicerCoreApplication::application(); if (d->PreviousModulesAdditionalPaths != coreApp->revisionUserSettings()->value("Modules/AdditionalPaths").toStringList() || d->PreviousExtensionsScheduledForUninstall != coreApp->revisionUserSettings()->value("Extensions/ScheduledForUninstall").toStringList() || d->PreviousExtensionsScheduledForUpdate != coreApp->revisionUserSettings()->value("Extensions/ScheduledForUpdate").toMap()) { shouldRestart = true; } this->setRestartRequested(shouldRestart); }
#include <QPushButton> #include "qSlicerApplication.h" #include "qSlicerExtensionsManagerDialog.h" #include "qSlicerExtensionsManagerModel.h" #include "qSlicerSettingsExtensionsPanel.h" #include "ui_qSlicerExtensionsManagerDialog.h" class qSlicerExtensionsManagerDialogPrivate: public Ui_qSlicerExtensionsManagerDialog { Q_DECLARE_PUBLIC(qSlicerExtensionsManagerDialog); protected: qSlicerExtensionsManagerDialog* const q_ptr; public: qSlicerExtensionsManagerDialogPrivate(qSlicerExtensionsManagerDialog& object); void init(); bool RestartRequested; QStringList PreviousModulesAdditionalPaths; QStringList PreviousExtensionsScheduledForUninstall; QVariantMap PreviousExtensionsScheduledForUpdate; }; qSlicerExtensionsManagerDialogPrivate::qSlicerExtensionsManagerDialogPrivate(qSlicerExtensionsManagerDialog& object) :q_ptr(&object) { } void qSlicerExtensionsManagerDialogPrivate::init() { Q_Q(qSlicerExtensionsManagerDialog); this->setupUi(q); QPushButton * restartButton = this->ButtonBox->button(QDialogButtonBox::Ok); restartButton->setText("Restart"); q->setRestartRequested(false); QSettings * settings = qSlicerCoreApplication::application(
lication * coreApp = qSlicerCoreApplication::application(); if (d->PreviousModulesAdditionalPaths != coreApp->revisionUserSettings()->value("Modules/AdditionalPaths").toStringList() || d->PreviousExtensionsScheduledForUninstall != coreApp->revisionUserSettings()->value("Extensions/ScheduledForUninstall").toStringList() || d->PreviousExtensionsScheduledForUpdate != coreApp->revisionUserSettings()->value("Extensions/ScheduledForUpdate").toMap()) { shouldRestart = true; } this->setRestartRequested(shouldRestart); }
)->revisionUserSettings(); this->PreviousModulesAdditionalPaths = settings->value("Modules/AdditionalPaths").toStringList(); this->PreviousExtensionsScheduledForUninstall = settings->value("Extensions/ScheduledForUninstall").toStringList(); this->PreviousExtensionsScheduledForUpdate = settings->value("Extensions/ScheduledForUpdate").toMap(); qSlicerSettingsExtensionsPanel * extensionsPanel = qobject_cast<qSlicerSettingsExtensionsPanel*>( qSlicerApplication::application()->settingsDialog()->panel("Extensions")); Q_ASSERT(extensionsPanel); if (extensionsPanel) { QObject::connect(extensionsPanel, SIGNAL(extensionsServerUrlChanged(QString)), this->ExtensionsManagerWidget, SLOT(refreshInstallWidget())); } } qSlicerExtensionsManagerDialog::qSlicerExtensionsManagerDialog(QWidget *_parent) : Superclass(_parent) , d_ptr(new qSlicerExtensionsManagerDialogPrivate(*this)) { Q_D(qSlicerExtensionsManagerDialog); d->init(); } qSlicerExtensionsManagerDialog::~qSlicerExtensionsManagerDialog() { } qSlicerExtensionsManagerModel* qSlicerExtensionsManagerDialog::extensionsManagerModel()const { Q_D(const qSlicerExtensionsManagerDialog); return d->ExtensionsManagerWidget->extensionsManagerModel(); } void qSlicerExtensionsManagerDialog::setExtensionsManagerModel(qSlicerExtensionsManagerModel* model) { Q_D(qSlicerExtensionsManagerDialog); if (this->extensionsManagerModel() == model) { return; } disconnect(this, SLOT(onModelUpdated())); d->ExtensionsManagerWidget->setExtensionsManagerModel(model); if (model) { this->onModelUpdated(); connect(model, SIGNAL(modelUpdated()), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionInstalled(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionScheduledForUninstall(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionCancelledScheduleForUninstall(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionScheduledForUpdate(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionCancelledScheduleForUpdate(QString)), this, SLOT(onModelUpdated())); connect(model, SIGNAL(extensionEnabledChanged(QString,bool)), this, SLOT(onModelUpdated())); } } bool qSlicerExtensionsManagerDialog::restartRequested()const { Q_D(const qSlicerExtensionsManagerDialog); return d->RestartRequested; } void qSlicerExtensionsManagerDialog::setRestartRequested(bool value) { Q_D(qSlicerExtensionsManagerDialog); d->RestartRequested = value; d->RestartRequestedLabel->setVisible(value); d->ButtonBox->button(QDialogButtonBox::Ok)->setEnabled(value); } void qSlicerExtensionsManagerDialog::onModelUpdated() { Q_D(qSlicerExtensionsManagerDialog); Q_ASSERT(this->extensionsManagerModel()); bool shouldRestart = false; qSlicerCoreApp
random
[ { "content": "class DiffusionTensor3DTransform : public Object\n\n{\n\npublic:\n\n typedef TData DataType;\n\n typedef double TransformType;\n\n typedef DiffusionTensor3DTransform Self;\n\n typedef Point<TransformType, 3> PointType;\n\n typedef DiffusionTensor3D<DataType> TensorDataType;\n\n typedef DiffusionTensor3DExtended<DataType> InternalTensorDataType;\n\n typedef Matrix<TransformType, 3, 3> MatrixTransformType;\n\n typedef Matrix<DataType, 3, 3> MatrixDataType;\n\n typedef MatrixExtended<TransformType, 3, 3> InternalMatrixTransformType;\n\n typedef MatrixExtended<DataType, 3, 3> InternalMatrixDataType;\n\n typedef SmartPointer<Self> Pointer;\n\n typedef SmartPointer<const Self> ConstPointer;\n\n\n\n /** Run-time type information (and related methods). */\n\n itkTypeMacro(DiffusionTensor3DTransform, Object);\n\n\n\n // /Evaluate the position of the transformed tensor\n", "file_path": "Modules/CLI/ResampleDTIVolume/itkDiffusionTensor3DTransform.h", "rank": 0, "score": 261695.11366328096 }, { "content": "class NewOtsuThresholdImageCalculator : public Object\n\n{\n\npublic:\n\n /** Standard class typedefs. */\n\n typedef NewOtsuThresholdImageCalculator Self;\n\n typedef Object Superclass;\n\n typedef SmartPointer<Self> Pointer;\n\n typedef SmartPointer<const Self> ConstPointer;\n\n\n\n /** Method for creation through the object factory. */\n\n itkNewMacro(Self);\n\n\n\n /** Run-time type information (and related methods). */\n\n itkTypeMacro(NewOtsuThresholdImageCalculator, Object);\n\n\n\n /** Type definition for the input image. */\n\n typedef TInputImage ImageType;\n\n\n\n /** Pointer type for the image. */\n\n typedef typename TInputImage::Pointer ImagePointer;\n", "file_path": "Libs/vtkITK/itkNewOtsuThresholdImageCalculator.h", "rank": 1, "score": 261695.11366328096 }, { "content": "class DiffusionTensor3DWrite : public Object\n\n{\n\npublic:\n\n typedef TData DataType;\n\n typedef DiffusionTensor3DWrite Self;\n\n typedef DiffusionTensor3D<DataType> TensorDataType;\n\n typedef Image<TensorDataType, 3> DiffusionImageType;\n\n typedef MetaDataDictionary DictionaryType;\n\n typedef ImageFileWriter<DiffusionImageType> WriterType;\n\n typedef SmartPointer<Self> Pointer;\n\n typedef SmartPointer<const Self> ConstPointer;\n\n typedef std::vector<std::vector<double> > DoubleVectorType;\n\n typedef MetaDataObject<DoubleVectorType> MetaDataDoubleVectorType;\n\n typedef MetaDataObject<std::string> MetaDataIntType;\n\n\n\n /** Run-time type information (and related methods). */\n\n itkTypeMacro(DiffusionTensor3DWrite, Object);\n\n\n\n itkNewMacro( Self );\n\n // /Set input tensor image\n", "file_path": "Modules/CLI/ResampleDTIVolume/itkDiffusionTensor3DWrite.h", "rank": 2, "score": 261695.11366328096 }, { "content": "class ImageToImageRegistrationHelper : public Object\n\n{\n\n\n\npublic:\n\n\n\n typedef ImageToImageRegistrationHelper Self;\n\n typedef Object Superclass;\n\n typedef SmartPointer<Self> Pointer;\n\n typedef SmartPointer<const Self> ConstPointer;\n\n\n\n itkTypeMacro( ImageToImageRegistrationHelper, Object );\n\n\n\n itkNewMacro( Self );\n\n\n\n //\n\n // Custom Typedefs\n\n //\n\n typedef TImage ImageType;\n\n\n\n typedef typename TImage::PixelType PixelType;\n", "file_path": "Modules/CLI/ExpertAutomatedRegistration/ITKRegistrationHelper/itkImageToImageRegistrationHelper.h", "rank": 3, "score": 254102.0637583048 }, { "content": "class ImageRegionMomentsCalculator : public Object\n\n{\n\npublic:\n\n /** Standard class typedefs. */\n\n typedef ImageRegionMomentsCalculator<TImage> Self;\n\n typedef Object Superclass;\n\n typedef SmartPointer<Self> Pointer;\n\n typedef SmartPointer<const Self> ConstPointer;\n\n\n\n /** Method for creation through the object factory. */\n\n itkNewMacro(Self);\n\n\n\n /** Run-time type information (and related methods). */\n\n itkTypeMacro(ImageRegionMomentsCalculator, Object);\n\n\n\n /** Extract the dimension of the image. */\n\n itkStaticConstMacro(ImageDimension, unsigned int,\n\n TImage::ImageDimension);\n\n\n\n /** Standard scalar type within this class. */\n", "file_path": "Modules/CLI/ExpertAutomatedRegistration/ITKRegistrationHelper/itkImageRegionMomentsCalculator.h", "rank": 4, "score": 254102.0637583048 }, { "content": "class qMRMLNodeObject : public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n qMRMLNodeObject(vtkMRMLNode* node, QObject* parent = 0);\n\n\n\n void setProcessEvents(bool process);\n\n bool processEvents()const;\n\n\n\n void setMessage(const QString& message);\n\n QString message()const;\n\n\n\npublic slots:\n\n void modify();\n\n\n\nprotected:\n\n vtkMRMLNode* Node;\n\n bool ProcessEvents;\n\n QString Message;\n\n};\n", "file_path": "Libs/MRML/Widgets/Testing/qMRMLNodeObject.h", "rank": 5, "score": 250459.06919927883 }, { "content": "class ITK_ABI_EXPORT DiffusionTensor3DRead : public Object\n\n{\n\npublic:\n\n typedef TData DataType;\n\n typedef DiffusionTensor3DRead Self;\n\n typedef Matrix<double, 3, 3> MatrixType;\n\n typedef DiffusionTensor3D<DataType> TensorDataType;\n\n typedef Image<TensorDataType, 3> DiffusionImageType;\n\n typedef typename DiffusionImageType::Pointer DiffusionImagePointer;\n\n typedef ImageFileReader<DiffusionImageType> FileReaderType;\n\n typedef MetaDataDictionary DictionaryType;\n\n typedef MetaDataObject<std::string> MetaDataStringType;\n\n typedef std::vector<std::vector<double> > DoubleVectorType;\n\n typedef MetaDataObject<DoubleVectorType> MetaDataDoubleVectorType;\n\n typedef SmartPointer<Self> Pointer;\n\n typedef SmartPointer<const Self> ConstPointer;\n\n\n\n /** Run-time type information (and related methods). */\n\n itkTypeMacro(DiffusionTensor3DRead, Object);\n\n\n", "file_path": "Modules/CLI/ResampleDTIVolume/itkDiffusionTensor3DRead.h", "rank": 6, "score": 243622.60366305686 }, { "content": "class qMRMLNodeObject : public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n qMRMLNodeObject(vtkMRMLNode* node, QObject* parent = 0);\n\n\n\npublic slots:\n\n void modifyNode();\n\n};\n", "file_path": "Libs/MRML/Widgets/Testing/qMRMLSliceWidgetTest1Helper.h", "rank": 7, "score": 238079.21085132007 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qMRMLTableViewPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLTableView);\n\nprotected:\n\n qMRMLTableView* const q_ptr;\n\npublic:\n\n qMRMLTableViewPrivate(qMRMLTableView& object);\n\n ~qMRMLTableViewPrivate();\n\n\n\n virtual void init();\n\n\n\n void setMRMLScene(vtkMRMLScene* scene);\n\n vtkMRMLScene *mrmlScene();\n\n\n\n bool verifyTableModelAndNode(const char* methodName) const;\n\n\n\npublic slots:\n\n /// Handle MRML scene event\n", "file_path": "Libs/MRML/Widgets/qMRMLTableView_p.h", "rank": 8, "score": 228989.2311868862 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qMRMLSliceViewPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLSliceView);\n\nprotected:\n\n qMRMLSliceView* const q_ptr;\n\npublic:\n\n qMRMLSliceViewPrivate(qMRMLSliceView& object);\n\n ~qMRMLSliceViewPrivate();\n\n\n\n virtual void init();\n\n\n\n void setMRMLScene(vtkMRMLScene* scene);\n\n\n\npublic slots:\n\n /// Handle MRML scene event\n\n void onSceneStartProcessing();\n\n void onSceneEndProcessing();\n\n\n\n void updateWidgetFromMRML();\n\n\n\nprotected:\n\n void initDisplayableManagers();\n\n\n\n vtkMRMLDisplayableManagerGroup* DisplayableManagerGroup;\n\n vtkMRMLScene* MRMLScene;\n\n vtkMRMLSliceNode* MRMLSliceNode;\n\n QColor InactiveBoxColor;\n\n\n", "file_path": "Libs/MRML/Widgets/qMRMLSliceView_p.h", "rank": 9, "score": 228989.2311868862 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qMRMLChartViewPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLChartView);\n\nprotected:\n\n qMRMLChartView* const q_ptr;\n\npublic:\n\n qMRMLChartViewPrivate(qMRMLChartView& object);\n\n ~qMRMLChartViewPrivate();\n\n\n\n virtual void init();\n\n\n\n void setMRMLScene(vtkMRMLScene* scene);\n\n vtkMRMLScene *mrmlScene();\n\n\n\npublic slots:\n\n /// Handle MRML scene event\n\n void startProcessing();\n\n void endProcessing();\n", "file_path": "Libs/MRML/Widgets/qMRMLChartView_p.h", "rank": 10, "score": 228989.2311868862 }, { "content": "// -----------------------------------------------------------------------------\n\nclass qMRMLVolumeWidgetPrivate : public QObject\n\n{\n\n Q_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLVolumeWidget);\n\nprotected:\n\n qMRMLVolumeWidget* const q_ptr;\n\n\n\npublic:\n\n qMRMLVolumeWidgetPrivate(qMRMLVolumeWidget& object);\n\n virtual ~qMRMLVolumeWidgetPrivate();\n\n\n\n virtual void init();\n\n\n\n /// Update the range and single step of the input GUI elements such as\n\n /// sliders and spinboxes.\n\n void updateRangeForVolumeDisplayNode(vtkMRMLScalarVolumeDisplayNode*);\n\n /// Block all the signals emitted by the widgets that are impacted by the\n\n /// range.\n\n /// To be reimplemented in subclasses\n\n virtual bool blockSignals(bool block);\n", "file_path": "Libs/MRML/Widgets/qMRMLVolumeWidget_p.h", "rank": 11, "score": 228989.2311868862 }, { "content": "//------------------------------------------------------------------------------\n\nclass qMRMLEventLoggerPrivate: public QObject\n\n{\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLEventLogger);\n\nprotected:\n\n qMRMLEventLogger* const q_ptr;\n\npublic:\n\n qMRMLEventLoggerPrivate(qMRMLEventLogger& object);\n\n typedef QObject Superclass;\n\n\n\n void init();\n\n\n\n void setMRMLScene(vtkMRMLScene* scene);\n\n\n\nprivate:\n\n vtkWeakPointer<vtkMRMLScene> MRMLScene;\n\n\n\n QList<QString> EventToListen;\n\n QHash<QString, QString> EventNameToConnectionIdMap;\n\n\n\n bool ConsoleOutputEnabled;\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/qMRMLEventLogger_p.h", "rank": 12, "score": 228989.2311868862 }, { "content": "class qSlicerViewersToolBarPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qSlicerViewersToolBar);\n\n\n\nprotected:\n\n qSlicerViewersToolBar* const q_ptr;\n\n\n\npublic:\n\n qSlicerViewersToolBarPrivate(qSlicerViewersToolBar& object);\n\n\n\n void init();\n\n void setMRMLScene(vtkMRMLScene* newScene);\n\n void updateWidgetFromMRML();\n\n\n\npublic slots:\n\n\n\n void OnMRMLSceneStartClose();\n\n void OnMRMLSceneEndImport();\n", "file_path": "Base/QTGUI/qSlicerViewersToolBar_p.h", "rank": 13, "score": 226042.28118664637 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qSlicerCLIModuleWidgetPrivate: public QObject,\n\n public Ui_qSlicerCLIModuleWidget\n\n{\n\n Q_OBJECT\n\n Q_DECLARE_PUBLIC(qSlicerCLIModuleWidget);\n\nprotected:\n\n qSlicerCLIModuleWidget* const q_ptr;\n\npublic:\n\n typedef qSlicerCLIModuleWidgetPrivate Self;\n\n qSlicerCLIModuleWidgetPrivate(qSlicerCLIModuleWidget& object);\n\n\n\n ///\n\n /// Convenient function to cast vtkSlicerLogic into vtkSlicerCLIModuleLogic\n\n vtkSlicerCLIModuleLogic* logic()const;\n\n\n\n ///\n\n /// Convenient function to cast vtkMRMLNode into vtkMRMLCommandLineModuleNode\n\n vtkMRMLCommandLineModuleNode* commandLineModuleNode()const;\n\n\n\n /// Convenient method to cast qSlicerAbstractModule into qSlicerCLIModule\n", "file_path": "Base/QTCLI/qSlicerCLIModuleWidget_p.h", "rank": 14, "score": 226042.28118664637 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qMRMLSceneViewMenuPrivate : public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLSceneViewMenu);\n\nprotected:\n\n qMRMLSceneViewMenu* const q_ptr;\n\npublic:\n\n typedef QObject Superclass;\n\n qMRMLSceneViewMenuPrivate(qMRMLSceneViewMenu& object);\n\n\n\n /// \\brief Clear and update menu given the list of existing vtkMRMLSceneViewNode\n\n /// associated with the current scene\n\n void resetMenu();\n\n\n\npublic slots:\n\n\n\n void onMRMLNodeAdded(vtkObject* mrmlScene, vtkObject * mrmlNode);\n\n\n\n /// Add menu entry corresponding to \\a sceneViewNode\n", "file_path": "Libs/MRML/Widgets/qMRMLSceneViewMenu_p.h", "rank": 15, "score": 223208.94362983707 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qMRMLExpandingWebViewPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLExpandingWebView);\n\nprotected:\n\n qMRMLExpandingWebView* const q_ptr;\n\npublic:\n\n qMRMLExpandingWebViewPrivate(qMRMLExpandingWebView& object);\n\n ~qMRMLExpandingWebViewPrivate();\n\n\n\n virtual void init();\n\n\n\n void setMRMLScene(vtkMRMLScene* scene);\n\n vtkMRMLScene *mrmlScene();\n\n\n\npublic slots:\n\n /// Handle MRML scene events\n\n void startProcessing();\n\n void endProcessing();\n\n\n\nprotected:\n\n\n\n vtkMRMLScene* MRMLScene;\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/qMRMLExpandingWebView_p.h", "rank": 16, "score": 223208.94362983707 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qMRMLThreeDViewPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLThreeDView);\n\nprotected:\n\n qMRMLThreeDView* const q_ptr;\n\npublic:\n\n qMRMLThreeDViewPrivate(qMRMLThreeDView& object);\n\n ~qMRMLThreeDViewPrivate();\n\n\n\n virtual void init();\n\n\n\n void setMRMLScene(vtkMRMLScene* scene);\n\n\n\n /// Loop over all CameraNode from the scene and return the one having\n\n /// its activeTag matching \\a viewNode ID\n\n// vtkMRMLCameraNode* lookUpMRMLCameraNode(vtkMRMLViewNode* viewNode);\n\n\n\npublic slots:\n", "file_path": "Libs/MRML/Widgets/qMRMLThreeDView_p.h", "rank": 17, "score": 223208.94362983707 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qMRMLSliceInformationWidgetPrivate: public QObject,\n\n public Ui_qMRMLSliceInformationWidget\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLSliceInformationWidget);\n\nprotected:\n\n qMRMLSliceInformationWidget* const q_ptr;\n\npublic:\n\n qMRMLSliceInformationWidgetPrivate(qMRMLSliceInformationWidget& object);\n\n ~qMRMLSliceInformationWidgetPrivate();\n\n\n\n void setupUi(qMRMLWidget* widget);\n\n\n\npublic slots:\n\n /// Update widget state using the associated MRML slice node\n\n void updateWidgetFromMRMLSliceNode();\n\n\n\n\n\n\n\npublic:\n\n vtkMRMLSliceNode* MRMLSliceNode;\n\n QButtonGroup* SliceSpacingModeGroup;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/qMRMLSliceInformationWidget_p.h", "rank": 18, "score": 223208.94362983707 }, { "content": "class Q_SLICER_BASE_QTGUI_EXPORT qSlicerWidget : public QWidget, public virtual qSlicerObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\npublic:\n\n qSlicerWidget(QWidget *parent=0, Qt::WindowFlags f=0);\n\n virtual ~qSlicerWidget();\n\n\n\npublic slots:\n\n virtual void setMRMLScene(vtkMRMLScene* scene);\n\n\n\nsignals:\n\n void mrmlSceneChanged(vtkMRMLScene*);\n\n\n\nprotected:\n\n QScopedPointer<qSlicerWidgetPrivate> d_ptr;\n\n\n\nprivate:\n\n Q_DECLARE_PRIVATE(qSlicerWidget);\n\n Q_DISABLE_COPY(qSlicerWidget);\n\n};\n\n\n\n#endif\n", "file_path": "Base/QTGUI/qSlicerWidget.h", "rank": 19, "score": 223074.94899856334 }, { "content": "/// \\brief Stores information about the relationship between a Subject and an Observer.\n\n///\n\n/// The Observation is a record of\n\n/// - a subject (vtkObject)\n\n/// - an event type (unsigned long)\n\n/// - an objserver (vtkObject)\n\n/// - a callback (vtkCallbackCommand)\n\n/// - optional comment strings\n\n/// This class can be used by the vtkEventBroker to keep track of the registered observers\n\n/// that it manages, and it can be used by the event queue to keep track of which\n\n/// events have been triggered so it can invoke them later\n\n//\n\n/// \\note This class does not add or remove observers itself; it just keeps track of them\n\n/// for the event broker.\n\nclass VTK_MRML_EXPORT vtkObservation : public vtkObject\n\n{\n\n public:\n\n\n\n /// The Usual vtk class functions\n\n static vtkObservation *New();\n\n vtkTypeMacro(vtkObservation,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n ///\n\n /// Accessors\n\n /// - note that AssignObject methods do not register the pointers\n\n /// - it is assumed that the EventBroker will attach DeleteEvent\n\n /// observers to these objects and will thereby know when they\n\n /// are no longer valid\n\n virtual void SetEventBroker(vtkEventBroker* eventBroker);\n\n vtkGetObjectMacro (EventBroker, vtkEventBroker);\n\n vtkGetMacro (InEventQueue, int);\n\n vtkSetMacro (InEventQueue, int);\n\n vtkGetObjectMacro (ObservationCallbackCommand, vtkCallbackCommand);\n", "file_path": "Libs/MRML/Core/vtkObservation.h", "rank": 20, "score": 222112.2346212237 }, { "content": "class QMRML_WIDGETS_EXPORT qMRMLUtils : public QObject\n\n{\n\n Q_OBJECT;\n\npublic:\n\n typedef qMRMLUtils Self;\n\n qMRMLUtils(QObject* parent = 0);\n\n virtual ~qMRMLUtils();\n\n\n\n ///\n\n /// Convert a vtkMatrix to a QVector\n\n Q_INVOKABLE static void vtkMatrixToQVector(vtkMatrix4x4* matrix, QVector<double> & vector);\n\n\n\n ///\n\n Q_INVOKABLE static void getTransformInCoordinateSystem(vtkMRMLNode* transformNode, bool global,\n\n vtkTransform* transform);\n\n Q_INVOKABLE static void getTransformInCoordinateSystem(vtkMRMLTransformNode* transformNode,\n\n bool global, vtkTransform* transform);\n\n\n\n /// Retrieve the number of visible view node associated with \\a scene\n\n Q_INVOKABLE static int countVisibleViewNode(vtkMRMLScene* scene);\n", "file_path": "Libs/MRML/Widgets/qMRMLUtils.h", "rank": 21, "score": 222100.75030607326 }, { "content": "class qSlicerMouseModeToolBarPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n QVTK_OBJECT\n\n Q_DECLARE_PUBLIC(qSlicerMouseModeToolBar);\n\n\n\nprotected:\n\n qSlicerMouseModeToolBar* const q_ptr;\n\n\n\npublic:\n\n qSlicerMouseModeToolBarPrivate(qSlicerMouseModeToolBar& object);\n\n\n\n void init();\n\n void setMRMLScene(vtkMRMLScene* newScene);\n\n void updateWidgetFromMRML();\n\n /// given an place node class name, find the action associated with it and set it\n\n /// checked, update the cursor, update the icon on the button\n\n void updateWidgetToPlace(const char *placeNodeClassName);\n\n\n\npublic slots:\n", "file_path": "Base/QTGUI/qSlicerMouseModeToolBar_p.h", "rank": 22, "score": 220482.77269345452 }, { "content": "class qSlicerBaseQTGUIPythonQtDecorators : public QObject\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n\n\n qSlicerBaseQTGUIPythonQtDecorators()\n\n {\n\n PythonQt::self()->registerClass(&qSlicerAbstractModuleWidget::staticMetaObject);\n\n PythonQt::self()->registerClass(&qSlicerPythonManager::staticMetaObject);\n\n PythonQt::self()->registerClass(&qSlicerCommandOptions::staticMetaObject);\n\n#ifdef Slicer_USE_QtTesting\n\n PythonQt::self()->registerClass(&ctkQtTestingUtility::staticMetaObject);\n\n#endif\n\n PythonQt::self()->registerClass(&ctkErrorLogModel::staticMetaObject);\n\n PythonQt::self()->registerClass(&ctkErrorLogTerminalOutput::staticMetaObject);\n\n // Note: Use registerCPPClassForPythonQt to register pure Cpp classes\n\n }\n\n\n\npublic slots:\n", "file_path": "Base/QTGUI/qSlicerBaseQTGUIPythonQtDecorators.h", "rank": 23, "score": 217857.80111078295 }, { "content": "/// \\brief Class that manages adding and deleting of observers with events.\n\n///\n\n/// Class that manages adding and deleting of obserevers with events\n\n/// This class keeps track of obserevers and events added to each vtk object.\n\n/// It caches tags returned by AddObserver method so that observers can be removed properly.\n\nclass VTK_MRML_EXPORT vtkMRMLLogic : public vtkObject\n\n{\n\npublic:\n\n /// The Usual vtk class functions\n\n static vtkMRMLLogic *New();\n\n vtkTypeMacro(vtkMRMLLogic,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent){ this->Superclass::PrintSelf(os, indent); }\n\n\n\n vtkMRMLScene* GetScene() {return this->Scene;};\n\n void SetScene(vtkMRMLScene* scene) {this->Scene = scene;};\n\n\n\n void RemoveUnreferencedStorageNodes();\n\n\n\n void RemoveUnreferencedDisplayNodes();\n\n\n\n /// Get application home directory.\n\n /// The path is retrieved from the environment variable defined by MRML_APPLICATION_HOME_DIR_ENV.\n\n static std::string GetApplicationHomeDirectory();\n\n\n\n /// Get application share subdirectory.\n", "file_path": "Libs/MRML/Core/vtkMRMLLogic.h", "rank": 24, "score": 216332.56924320714 }, { "content": "/// \\brief Manages adding and deleting of obserevers with events.\n\n///\n\n/// Class that manages adding and deleting of obserevers with events\n\n/// This class keeps track of obserevers and events added to each vtk object\n\n/// it caches tags returned by AddObserver method so that obserevers can be removed properly.\n\nclass VTK_MRML_EXPORT vtkObserverManager : public vtkObject\n\n{\n\n public:\n\n\n\n /// The Usual vtk class functions\n\n static vtkObserverManager *New();\n\n vtkTypeMacro(vtkObserverManager,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// set vtkObject to a specified pointer and remove all observers for all events\n\n void SetObject(vtkObject **nodePtr, vtkObject *node);\n\n\n\n /// set vtkObject to a specified pointer, remove all observers for all events, add observer for Modify event\n\n void SetAndObserveObject(vtkObject **nodePtr, vtkObject *node, float priority=0.0, bool logWarningIfSameObservationExists=true);\n\n\n\n /// set vtkObject to a specified pointer, remove all observers for all events, add observers for specified events\n\n void SetAndObserveObjectEvents(vtkObject **nodePtr, vtkObject *node, vtkIntArray *events, vtkFloatArray *priorities=0, bool logWarningIfSameObservationExists=true);\n\n\n\n /// remove all observers for all events\n\n void RemoveObjectEvents(vtkObject *nodePtr);\n", "file_path": "Libs/MRML/Core/vtkObserverManager.h", "rank": 25, "score": 216332.0530152082 }, { "content": "/// \\ingroup SegmentationCore\n\n/// \\brief This class encapsulates a segment that is part of a segmentation\n\n/// \\details\n\n/// A \\sa vtkSegmentation can contain multiple segments (this class) each of which represent\n\n/// one anatomical or other structure (in labelmap terms, a \"label\"). Each segmentation can\n\n/// contain the structure in multiple representations.\n\n/// Default representation types include Binary labelmap and Closed surface, but additional\n\n/// custom representations can be added (see description of \\sa vtkSegmentation).\n\n/// \n\nclass vtkSegmentationCore_EXPORT vtkSegment : public vtkObject\n\n{\n\n typedef std::map<std::string, vtkSmartPointer<vtkDataObject> > RepresentationMap;\n\n\n\npublic:\n\n static const double SEGMENT_COLOR_VALUE_INVALID[4];\n\n\n\n static vtkSegment* New();\n\n vtkTypeMacro(vtkSegment, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// Set attributes from name/value pairs\n\n virtual void ReadXMLAttributes(const char** atts);\n\n\n\n /// Write this object's information to a MRML file in XML format.\n\n void WriteXML(ostream& of, int nIndent);\n\n\n\n /// Deep copy one segment into another\n\n virtual void DeepCopy(vtkSegment* source);\n\n\n", "file_path": "Libs/vtkSegmentationCore/vtkSegment.h", "rank": 26, "score": 216330.8729272122 }, { "content": "/// \\brief A set of MRML Nodes that supports serialization and undo/redo.\n\n///\n\n/// vtkMRMLScene represents and provides methods to manipulate a list of\n\n/// MRML objects. The list is core and duplicate entries are not prevented.\n\n//\n\n/// \\sa vtkMRMLNode\n\n/// \\sa vtkCollection\n\nclass VTK_MRML_EXPORT vtkMRMLScene : public vtkObject\n\n{\n\n ///\n\n /// make the vtkMRMLSceneViewNode a friend since it has internal vtkMRMLScene\n\n /// so that it can call protected methods, for example UpdateNodeIDs()\n\n /// but that's the only class that is allowed to do so\n\n friend class vtkMRMLSceneViewNode;\n\n\n\npublic:\n\n static vtkMRMLScene *New();\n\n vtkTypeMacro(vtkMRMLScene, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// Set URL (file name) of the scene\n\n void SetURL(const char *url);\n\n\n\n /// Get URL (file name) of the scene\n\n const char *GetURL();\n\n\n\n /// Set Root directory, where URL is pointing\n", "file_path": "Libs/MRML/Core/vtkMRMLScene.h", "rank": 27, "score": 216330.63196961692 }, { "content": "/// \\brief Class that manages adding and deleting of observers with events.\n\n///\n\n/// This class keeps track of observers and events added to each vtk object.\n\n/// It caches tags returned by AddObserver method so that observers can be\n\n/// removed properly.\n\n/// See also:\n\n/// http://wiki.na-mic.org/Wiki/index.php/Slicer3:EventBroker\n\n/// http://en.wikipedia.org/wiki/Observer_pattern\n\n//\n\n/// Other interesting observer implementations:\n\n/// http://xlobject.sourceforge\n\n/// http://sigslot.sourceforge.net/\n\n/// http://doc.trolltech.com/4.3/signalsandslots.html\n\nclass VTK_MRML_EXPORT vtkEventBroker : public vtkObject\n\n{\n\npublic:\n\n vtkTypeMacro(vtkEventBroker, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n typedef std::set< vtkObservation * > ObservationVector;\n\n\n\n ///\n\n /// Return the singleton instance with no reference counting.\n\n static vtkEventBroker* GetInstance();\n\n\n\n ///\n\n /// This is a singleton pattern New. There will only be ONE\n\n /// reference to a vtkEventBroker object per process. Clients that\n\n /// call this must call Delete on the object so that the reference\n\n /// counting will work. The single instance will be unreferenced when\n\n /// the program exits.\n\n static vtkEventBroker* New();\n\n\n", "file_path": "Libs/MRML/Core/vtkEventBroker.h", "rank": 28, "score": 216330.34804460904 }, { "content": "/// \\ingroup SegmentationCore\n\n/// \\brief This class encapsulates a segmentation that can contain multiple segments and multiple representations for each segment\n\n/// \\details\n\n/// The primary purpose of this class is to serve as a container to store the segments (in labelmap analogy the \"labels\").\n\n/// Also provides generic functions on the segmentation level. Performs conversion to a specified representation, extracts\n\n/// geometry information etc.\n\n/// \n\n/// Main points to remember:\n\n/// * Each segment has the same set of representations. This means that if segments are copied/moved between segmentations,\n\n/// then conversion will take place if possible (if not then copy will fail)\n\n/// * Default representations types are\n\n/// * Binary labelmap (vtkOrientedImageData)\n\n/// * Closed surface (vtkPolyData)\n\n/// * Additional representations can be defined (SlicerRT adds three: Planar contour, Fractional labelmap, Ribbon model)\n\n/// * Conversion between representations are driven by a conversion graph in which the nodes are the representations and the edges\n\n/// are conversion rules\n\n/// * When converting with the default method (\\sa CreateRepresentation without specifying a path), then the path with the lowest\n\n/// cost is used (rules have a cost field that gives a ballpark value for the conversion cost)\n\n/// * Representation types can be defined by registering conversion algorithms (rules) that specify their source and target\n\n/// representations, and an estimated cost metric\n\n/// * Master representation\n\n/// * Privileged representation type. Can be any of the available representations, but usually it's the original representation\n\n/// of the data (binary labelmap for editing, binary or fractional labelmap for DICOM SEG, planar contour for DICOM RT, etc.)\n\n/// * Using the proper master representation ensures that no information is lost, which is crucial to avoid discrepancies that can\n\n/// never be solved when data is permanently lost in conversion\n\n/// * Properties\n\n/// * All conversions use it as source (up-to-date representations along conversion path are used if available)\n\n/// * When changed all other representations are invalidated (and is re-converted later from master)\n\n/// * It is the representation that is saved to disk\n\n/// \n\n/// Schematic illustration of the segmentation container:\n\n/// \n\n/// +=============================================+\n\n/// | Patient (vtkSegmentation) |\n\n/// +======================+======================+\n\n/// | Brain (vtkSegment) | Tumor (vtkSegment) |\n\n/// +======================+======================+\n\n/// Binary labelmap | vtkOrientedImageData | vtkOrientedImageData |\n\n/// +----------------------+----------------------+\n\n/// Closed surface | vtkPolyData | vtkPolyData |\n\n/// +----------------------+----------------------+\n\n/// Custom representation | vtkDataObject | vtkDataObject |\n\n/// +----------------------+----------------------+\n\n/// \n\nclass vtkSegmentationCore_EXPORT vtkSegmentation : public vtkObject\n\n{\n\npublic:\n\n enum\n\n {\n\n /// Invoked when content of the master representation in a segment is changed.\n\n MasterRepresentationModified = 62100,\n\n /// Invoked when content of any representation (including the master representation) in a segment is changed.\n\n RepresentationModified,\n\n /// Invoked if new segment is added\n\n SegmentAdded,\n\n /// Invoked if a segment is removed\n\n SegmentRemoved,\n\n /// Invoked if a segment is modified (name changed, tags changed, etc).\n\n /// Note: the event is not invoked when content of a representation in a segment is changed.\n\n SegmentModified,\n\n /// Invoked if a representation is created or removed in the segments (e.g., created by conversion from master).\n\n ContainedRepresentationNamesModified\n\n };\n\n\n", "file_path": "Libs/vtkSegmentationCore/vtkSegmentation.h", "rank": 29, "score": 216329.27325755273 }, { "content": "/// \\brief Abstract Superclass for all specific types of MRML nodes.\n\n///\n\n/// This node encapsulates the functionality common to all types of MRML nodes.\n\n/// This includes member variables for ID, Description, and Options,\n\n/// as well as member functions to Copy() and Write().\n\nclass VTK_MRML_EXPORT vtkMRMLNode : public vtkObject\n\n{\n\n /// make the vtkMRMLScene a friend so that AddNodeNoNotify can call\n\n /// SetID, but that's the only class that is allowed to do so\n\n friend class vtkMRMLScene;\n\n friend class vtkMRMLSceneViewNode;\n\n\n\npublic:\n\n vtkTypeMacro(vtkMRMLNode,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// \\brief Create instance of the default node. Like New only virtual.\n\n ///\n\n /// \\note Subclasses should implement this method\n\n virtual vtkMRMLNode* CreateNodeInstance() = 0;\n\n\n\n /// Set node attributes\n\n ///\n\n /// \\note\n\n /// Subclasses should implement this method.\n", "file_path": "Libs/MRML/Core/vtkMRMLNode.h", "rank": 30, "score": 216325.71785453238 }, { "content": "/// \\brief MRML object to represent a 3D point.\n\n///\n\n/// \\deprecated Used for backward compatibility for Slicer3 fiducial lists, please use the Annotation Module MRML nodes\n\n/// \\sa vtkMRMLAnnotationNode, vtkMRMLAnnotationFiducialNode\n\nclass VTK_MRML_EXPORT vtkMRMLFiducial : public vtkObject\n\n{\n\npublic:\n\n /// \\deprecated Used for backward compatibility for Slicer3 fiducial lists, please use the Annotation Module MRML nodes\n\n /// \\sa vtkMRMLAnnotationNode, vtkMRMLAnnotationFiducialNode\n\n ///\n\n static vtkMRMLFiducial *New();\n\n vtkTypeMacro(vtkMRMLFiducial,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n //--------------------------------------------------------------------------\n\n /// MRML methods\n\n //--------------------------------------------------------------------------\n\n\n\n ///\n\n /// Set node attributes\n\n virtual void ReadXMLAttributes( const char** atts);\n\n\n\n ///\n\n /// Set node attributes from an unparsed string of keys and values\n", "file_path": "Libs/MRML/Core/vtkMRMLFiducial.h", "rank": 31, "score": 216325.64656575897 }, { "content": "/// Node factory that can be used by qMRML widgets to easily create nodes\n\n/// If you want more control over the node creation, you can add attributes,\n\n/// specify a base node name or connect to signals to customize the node\n\nclass QMRML_WIDGETS_EXPORT qMRMLNodeFactory : public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n\n\n /// Convenient typedef\n\n typedef QHash<QString,QString> AttributeType;\n\n\n\n /// Constructors\n\n typedef QObject Superclass;\n\n explicit qMRMLNodeFactory(QObject* parent = 0);\n\n virtual ~qMRMLNodeFactory();\n\n\n\n /// Get MRML scene.\n\n /// By default, there is no scene.\n\n vtkMRMLScene* mrmlScene()const;\n\n\n\n ///\n\n /// Create and add a node given its \\a className to the scene associated\n\n /// with the factory. The function will fire the signals:\n", "file_path": "Libs/MRML/Widgets/qMRMLNodeFactory.h", "rank": 32, "score": 216320.46274902415 }, { "content": "class VTK_MRML_EXPORT vtkCacheManager : public vtkObject\n\n{\n\n public:\n\n\n\n /// The Usual vtk class functions\n\n static vtkCacheManager *New();\n\n vtkTypeMacro(vtkCacheManager, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n vtkGetMacro (InsufficientFreeBufferNotificationFlag, int );\n\n vtkSetMacro (InsufficientFreeBufferNotificationFlag, int );\n\n\n\n ///\n\n /// Sets the name of the directory to use for local file caching\n\n /// Does some checking to make sure this is a valid directory\n\n /// on the local system. Makes sure there's NO \"/\" at the end\n\n /// of the string, or kwsys/SystemTools will not see as a valid dir.\n\n virtual void SetRemoteCacheDirectory (const char *dir );\n\n\n\n ///\n", "file_path": "Libs/MRML/Core/vtkCacheManager.h", "rank": 33, "score": 216320.46274902415 }, { "content": "class QMRML_WIDGETS_EXPORT qMRMLEventLogger: public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n typedef QObject Superclass;\n\n explicit qMRMLEventLogger(QObject* parent = 0);\n\n virtual ~qMRMLEventLogger();\n\n\n\n ///\n\n /// Set the MRML \\a scene that should be listened for events\n\n void setMRMLScene(vtkMRMLScene* scene);\n\n\n\n ///\n\n /// Return true if the corresponding event if listened by the eventLogger\n\n bool listeningNodeAddedEvent();\n\n bool listeningNodeRemovedEvent();\n\n bool listeningNewSceneEvent();\n\n bool listeningSceneClosedEvent();\n\n bool listeningSceneAboutToBeClosedEvent();\n\n bool listeningMetadataAddedEvent();\n", "file_path": "Libs/MRML/Widgets/qMRMLEventLogger.h", "rank": 34, "score": 216320.46274902415 }, { "content": "class VTK_MRML_EXPORT vtkURIHandler : public vtkObject\n\n{\n\npublic:\n\n /// The Usual vtk class functions\n\n //static vtkURIHandler *New() { return NULL; };\n\n static vtkURIHandler *New();\n\n vtkTypeMacro(vtkURIHandler, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n vtkGetStringMacro (HostName);\n\n vtkSetStringMacro (HostName);\n\n\n\n ///\n\n /// virtual methods to be defined in subclasses.\n\n /// (Maybe these should be defined to handle default file operations)\n\n virtual void StageFileRead ( const char *source, const char * destination );\n\n virtual void StageFileWrite ( const char *source, const char * destination );\n\n\n\n ///\n\n /// various Read/Write method footprints useful to redefine in specific handlers.\n", "file_path": "Libs/MRML/Core/vtkURIHandler.h", "rank": 35, "score": 216320.46274902415 }, { "content": "class VTK_MRML_EXPORT vtkDataTransfer : public vtkObject\n\n{\n\n public:\n\n\n\n /// The Usual vtk class functions\n\n static vtkDataTransfer *New();\n\n vtkTypeMacro(vtkDataTransfer, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n vtkGetStringMacro ( SourceURI );\n\n vtkSetStringMacro ( SourceURI );\n\n vtkGetStringMacro ( DestinationURI );\n\n vtkSetStringMacro ( DestinationURI );\n\n vtkGetObjectMacro ( Handler, vtkURIHandler );\n\n virtual void SetHandler(vtkURIHandler* uriHandler);\n\n vtkGetMacro ( TransferType, int );\n\n vtkSetMacro ( TransferType, int );\n\n vtkGetMacro ( TransferID, int );\n\n vtkSetMacro ( TransferID, int );\n\n vtkGetMacro ( SizeOnDisk, int );\n\n vtkSetMacro ( SizeOnDisk, int );\n", "file_path": "Libs/MRML/Core/vtkDataTransfer.h", "rank": 36, "score": 216320.46274902415 }, { "content": "class VTK_MRML_EXPORT vtkTagTable : public vtkObject\n\n{\n\n public:\n\n /// The Usual vtk class functions\n\n static vtkTagTable *New();\n\n vtkTypeMacro(vtkTagTable, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n ///\n\n /// Get the vtkTable that contains user-defined attribute/value pairs.\n\n vtkGetStringMacro ( Name );\n\n vtkSetStringMacro ( Name );\n\n\n\n vtkGetMacro ( RestoreSelectionState, int);\n\n vtkSetMacro ( RestoreSelectionState, int);\n\n\n\n ///\n\n /// Method that sets up default and required tags for a service.\n\n /// Each derived class should fill out this method.\n\n virtual void Initialize() { };\n", "file_path": "Libs/MRML/Core/vtkTagTable.h", "rank": 37, "score": 216320.46274902415 }, { "content": "class VTK_MRML_EXPORT vtkPermissionPrompter : public vtkObject\n\n{\n\n public:\n\n\n\n /// The Usual vtk class functions\n\n static vtkPermissionPrompter *New();\n\n vtkTypeMacro(vtkPermissionPrompter, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n ///\n\n /// Member for storing a user name, if required\n\n vtkGetStringMacro ( Username );\n\n vtkSetStringMacro ( Username );\n\n\n\n ///\n\n /// Member for storing a password, if required\n\n vtkGetStringMacro ( Password );\n\n vtkSetStringMacro ( Password );\n\n\n\n vtkGetStringMacro (HostName );\n", "file_path": "Libs/MRML/Core/vtkPermissionPrompter.h", "rank": 38, "score": 216320.46274902415 }, { "content": " /// \\brief Class to hold information about a node reference\n\n class VTK_MRML_EXPORT vtkMRMLNodeReference : public vtkObject\n\n {\n\n public:\n\n vtkTypeMacro(vtkMRMLNodeReference,vtkObject);\n\n static vtkMRMLNodeReference *New();\n\n void PrintSelf(ostream& vtkNotUsed(os), vtkIndent vtkNotUsed(indent)){};\n\n\n\n public:\n\n vtkSetStringMacro(ReferenceRole);\n\n vtkGetStringMacro(ReferenceRole);\n\n\n\n vtkSetStringMacro(ReferencedNodeID);\n\n vtkGetStringMacro(ReferencedNodeID);\n\n\n\n /// \\brief Set the events that will be observed when the referenced node\n\n /// will be available.\n\n ///\n\n /// If set to NULL then the default event list (specified for the role) will be observed.\n\n /// If set to an empty event list then no events will be observed.\n\n void SetEvents(vtkIntArray* events);\n", "file_path": "Libs/MRML/Core/vtkMRMLNode.h", "rank": 39, "score": 213600.5259066248 }, { "content": "class VTK_SLICER_BASE_LOGIC_EXPORT vtkSystemInformation : public vtkObject\n\n{\n\npublic:\n\n static vtkSystemInformation *New();\n\n vtkTypeMacro(vtkSystemInformation,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n const char * GetVendorString();\n\n const char * GetVendorID();\n\n const char * GetTypeID();\n\n const char * GetFamilyID();\n\n const char * GetModelName();\n\n const char * GetModelID();\n\n const char * GetSteppingCode();\n\n const char * GetExtendedProcessorName();\n\n const char * GetProcessorSerialNumber();\n\n int GetProcessorCacheSize();\n\n int GetLogicalProcessorsPerPhysical();\n\n float GetProcessorClockFrequency();\n\n int GetProcessorAPICID();\n", "file_path": "Base/Logic/vtkSystemInformation.h", "rank": 40, "score": 213594.29181264158 }, { "content": "class VTK_SLICER_BASE_LOGIC_EXPORT vtkSlicerTask : public vtkObject\n\n{\n\npublic:\n\n static vtkSlicerTask *New();\n\n vtkTypeMacro(vtkSlicerTask,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n typedef vtkMRMLAbstractLogic::TaskFunctionPointer TaskFunctionPointer;\n\n\n\n ///\n\n /// Set the function and object to call for the task.\n\n void SetTaskFunction(vtkMRMLAbstractLogic*, TaskFunctionPointer, void *clientdata);\n\n\n\n ///\n\n /// Execute the task.\n\n virtual void Execute();\n\n\n\n ///\n\n /// The type of task - this can be used, for example, to decide\n\n /// how many concurrent threads should be allowed\n", "file_path": "Base/Logic/vtkSlicerTask.h", "rank": 41, "score": 213594.29181264158 }, { "content": "//------------------------------------------------------------------------------\n\nclass Q_SLICER_BASE_QTGUI_EXPORT qSlicerFileDialog : public QObject\n\n{\n\n Q_OBJECT\n\n Q_ENUMS(IOAction)\n\n Q_PROPERTY(QString description READ description)\n\n\n\npublic:\n\n typedef QObject Superclass;\n\n qSlicerFileDialog(QObject* parent =0);\n\n virtual ~qSlicerFileDialog();\n\n\n\n virtual qSlicerIO::IOFileType fileType()const = 0;\n\n\n\n /// Unique name of the reader/writer\n\n /// \\sa filetype()\n\n virtual QString description()const = 0;\n\n\n\n enum IOAction\n\n {\n\n Read,\n", "file_path": "Base/QTGUI/qSlicerFileDialog.h", "rank": 42, "score": 213594.29181264158 }, { "content": "//-----------------------------------------------------------------------------\n\nclass qSlicerSegmentEditorAbstractEffectPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n Q_DECLARE_PUBLIC(qSlicerSegmentEditorAbstractEffect);\n\nprotected:\n\n qSlicerSegmentEditorAbstractEffect* const q_ptr;\n\npublic:\n\n qSlicerSegmentEditorAbstractEffectPrivate(qSlicerSegmentEditorAbstractEffect& object);\n\n ~qSlicerSegmentEditorAbstractEffectPrivate();\n\nsignals:\n\n // Signals that are used for effects to request operations from the editor\n\n // without having any dependency on the editor.\n\n void selectEffectSignal(QString);\n\n void updateVolumeSignal(void*,bool&);\n\n void saveStateForUndoSignal();\n\npublic:\n\n /// Segment editor parameter set node\n\n vtkWeakPointer<vtkMRMLSegmentEditorNode> ParameterSetNode;\n\n\n\n /// MRML scene\n", "file_path": "Modules/Loadable/Segmentations/EditorEffects/qSlicerSegmentEditorAbstractEffect_p.h", "rank": 43, "score": 212889.7227884783 }, { "content": "/// \\ingroup SlicerRt_QtModules_Segmentations\n\n/// \\brief Private implementation of the segment editor paint effect\n\nclass qSlicerSegmentEditorPaintEffectPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n Q_DECLARE_PUBLIC(qSlicerSegmentEditorPaintEffect);\n\nprotected:\n\n qSlicerSegmentEditorPaintEffect* const q_ptr;\n\npublic:\n\n typedef QObject Superclass;\n\n qSlicerSegmentEditorPaintEffectPrivate(qSlicerSegmentEditorPaintEffect& object);\n\n ~qSlicerSegmentEditorPaintEffectPrivate();\n\n\n\n /// Depending on the \\sa DelayedPaint mode, either paint the given point or queue\n\n /// it up with a marker for later painting\n\n void paintAddPoint(qMRMLWidget* viewWidget, double pixelPositionWorld[3]);\n\n\n\n /// Update paint circle glyph\n\n void updateBrush(qMRMLWidget* viewWidget, BrushPipeline* brush);\n\n\n\n /// Update brushes\n\n void updateBrushes();\n", "file_path": "Modules/Loadable/Segmentations/EditorEffects/qSlicerSegmentEditorPaintEffect_p.h", "rank": 44, "score": 212889.7227884783 }, { "content": "/// \\ingroup SegmentationCore\n\n/// \\brief Class that can convert between different representations of a segment.\n\nclass vtkSegmentationCore_EXPORT vtkSegmentationConverter : public vtkObject\n\n{\n\npublic:\n\n typedef std::vector< vtkSmartPointer<vtkSegmentationConverterRule> > ConverterRulesListType;\n\n\n\n typedef std::vector<vtkSegmentationConverterRule*> ConversionPathType; // Contains a list of converter rule names\n\n typedef std::pair<ConversionPathType, unsigned int> ConversionPathAndCostType;\n\n typedef std::vector<ConversionPathAndCostType> ConversionPathAndCostListType;\n\n\n\n /// Default representation types\n\n /// In binary and fractional labelmaps values <=0 are considered background voxels (outside), values>0 are foreground (inside).\n\n static const char* GetSegmentationBinaryLabelmapRepresentationName() { return \"Binary labelmap\"; };\n\n static const char* GetSegmentationFractionalLabelmapRepresentationName() { return \"Fractional labelmap\"; };\n\n static const char* GetSegmentationPlanarContourRepresentationName() { return \"Planar contour\"; };\n\n static const char* GetSegmentationClosedSurfaceRepresentationName() { return \"Closed surface\"; };\n\n\n\n // Common conversion parameters\n\n // ----------------------------\n\n /// Reference image geometry conversion parameter\n\n /// Contains serialized matrix and extent\n", "file_path": "Libs/vtkSegmentationCore/vtkSegmentationConverter.h", "rank": 45, "score": 210975.34803645647 }, { "content": "/// \\ingroup vtkSegmentationCore\n\n/// \\brief Algorithm class for computing topological hierarchy of multiple poly data models.\n\n/// The levels of the models are determined according to the models they contain, an outer\n\n/// model always having larger level value than the inner ones. To determine whether a model\n\n/// contains another, their bounding boxes are considered. It is possible to constrain a gap\n\n/// or allow the inner model to protrude the surface of the outer one. The size of this gap\n\n/// or allowance is defined as a factor /sa ContainConstraintFactor of the outer model size.\n\n/// This algorithm can be used to automatically determine optimal opacities in complex scenes.\n\nclass vtkSegmentationCore_EXPORT vtkTopologicalHierarchy : public vtkObject\n\n{\n\npublic:\n\n\n\n static vtkTopologicalHierarchy *New();\n\n vtkTypeMacro(vtkTopologicalHierarchy, vtkObject );\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// Get output topological hierarchy levels\n\n virtual vtkIntArray* GetOutputLevels();\n\n\n\n /// Compute topological hierarchy levels for input poly data models using\n\n /// their bounding boxes.\n\n /// This function has to be explicitly called!\n\n /// Output can be get using GetOutputLevels()\n\n virtual void Update();\n\n\n\n /// Set input poly data collection\n\n vtkSetObjectMacro(InputPolyDataCollection, vtkPolyDataCollection);\n\n\n", "file_path": "Libs/vtkSegmentationCore/vtkTopologicalHierarchy.h", "rank": 46, "score": 210973.41649971745 }, { "content": "class VTK_ADDON_EXPORT vtkAddonMathUtilities : public vtkObject\n\n{\n\npublic:\n\n static vtkAddonMathUtilities *New();\n\n vtkTypeMacro(vtkAddonMathUtilities,vtkObject);\n\n virtual void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n static bool MatrixAreEqual(const vtkMatrix4x4* m1,\n\n const vtkMatrix4x4* m2,\n\n double tolerance = 1e-3);\n\n\n\n static bool MatrixAreEqual(const vtkMatrix4x4 *m1,\n\n const vtkMatrix3x3 *m2,\n\n double tolerance = 1e-3);\n\n\n\n static bool MatrixAreEqual(const vtkMatrix3x3 *m1,\n\n const vtkMatrix4x4 *m2,\n\n double tolerance = 1e-3);\n\n\n\n static bool MatrixAreEqual(const vtkMatrix3x3 *m1,\n", "file_path": "Libs/vtkAddon/vtkAddonMathUtilities.h", "rank": 47, "score": 210969.32022997006 }, { "content": "class Q_SLICER_BASE_QTCORE_EXPORT qSlicerModuleManager : public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n typedef QObject Superclass;\n\n qSlicerModuleManager(QObject* newParent = 0);\n\n virtual ~qSlicerModuleManager();\n\n\n\n /// Print internal state using qDebug()\n\n virtual void printAdditionalInfo();\n\n\n\n /// Return a pointer to the current module factory manager\n\n Q_INVOKABLE qSlicerModuleFactoryManager * factoryManager()const;\n\n\n\n /// Return the list of all the loaded modules\n\n Q_INVOKABLE QStringList modulesNames()const;\n\n\n\n /// Return the loaded module identified by \\a name\n\n Q_INVOKABLE qSlicerAbstractCoreModule* module(const QString& name)const;\n\n\n", "file_path": "Base/QTCore/qSlicerModuleManager.h", "rank": 48, "score": 210969.32022997006 }, { "content": "/// \\ingroup SegmentationCore\n\nclass vtkSegmentationCore_EXPORT vtkSegmentationHistory : public vtkObject\n\n{\n\npublic:\n\n static vtkSegmentationHistory* New();\n\n vtkTypeMacro(vtkSegmentationHistory, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// Selects a segmentation that the states will be stored of. Current state of the segmentation is not stored.\n\n /// \\param segmentation Segmentation to store. Deletes all stored states of the previously set segmentation.\n\n void SetSegmentation(vtkSegmentation* segmentation);\n\n\n\n /// Get segmentation that the states will be stored of.\n\n vtkGetMacro(Segmentation, vtkSegmentation*);\n\n\n\n /// Saves all master representations of the segmentation in its current state.\n\n /// States more recent than the last restored state are removed.\n\n /// \\return Success flag\n\n bool SaveState();\n\n\n\n /// Restores previous state of the segmentation.\n", "file_path": "Libs/vtkSegmentationCore/vtkSegmentationHistory.h", "rank": 49, "score": 210969.32022997006 }, { "content": "class Q_SLICER_BASE_QTAPP_EXPORT qSlicerApplicationHelper : public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n typedef QObject Superclass;\n\n typedef qSlicerApplicationHelper Self;\n\n\n\n qSlicerApplicationHelper(QObject * parent = 0);\n\n virtual ~qSlicerApplicationHelper();\n\n\n\n static void setupModuleFactoryManager(qSlicerModuleFactoryManager * moduleFactoryManager);\n\n\n\n static void showMRMLEventLoggerWidget();\n\n\n\nprivate:\n\n Q_DISABLE_COPY(qSlicerApplicationHelper);\n\n};\n\n\n\n#endif\n", "file_path": "Base/QTApp/qSlicerApplicationHelper.h", "rank": 50, "score": 210969.32022997006 }, { "content": "class VTK_MRML_EXPORT vtkDataIOManager : public vtkObject\n\n{\n\n public:\n\n\n\n /// The Usual vtk class functions\n\n static vtkDataIOManager *New();\n\n vtkTypeMacro(vtkDataIOManager,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n vtkGetObjectMacro ( DataTransferCollection, vtkCollection );\n\n void SetDataTransferCollection(vtkCollection* dataTransfer );\n\n vtkGetObjectMacro ( CacheManager, vtkCacheManager );\n\n virtual void SetCacheManager(vtkCacheManager* cacheManager);\n\n vtkGetMacro ( EnableAsynchronousIO, int );\n\n vtkGetMacro ( InUpdateCallbackFlag, int );\n\n vtkSetMacro ( InUpdateCallbackFlag, int );\n\n\n\n ///\n\n /// Get/Set the DataFileFormatHelper object\n\n vtkDataFileFormatHelper* GetFileFormatHelper();\n\n virtual void SetFileFormatHelper(vtkDataFileFormatHelper* helper);\n", "file_path": "Libs/MRML/Core/vtkDataIOManager.h", "rank": 51, "score": 210969.32022997006 }, { "content": "class qSlicerBaseQTBasePythonQtDecorators : public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n\n\n qSlicerBaseQTBasePythonQtDecorators()\n\n {\n\n PythonQt::self()->registerClass(&qSlicerCoreApplication::staticMetaObject);\n\n PythonQt::self()->registerClass(&qSlicerAbstractCoreModule::staticMetaObject);\n\n PythonQt::self()->registerCPPClass(\"qSlicerUtils\", 0, \"qSlicerBaseQTCore\");\n\n // Note: Use registerCPPClassForPythonQt to register pure Cpp classes\n\n }\n\n\n\npublic slots:\n\n\n\n //----------------------------------------------------------------------------\n\n // qSlicerCoreApplication\n\n\n\n //----------------------------------------------------------------------------\n\n // static methods\n", "file_path": "Base/QTCore/qSlicerBaseQTCorePythonQtDecorators.h", "rank": 52, "score": 210536.70470846392 }, { "content": "class qSlicerBaseQTAppPythonQtDecorators : public QObject\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n\n\n qSlicerBaseQTAppPythonQtDecorators()\n\n {\n\n }\n\n\n\npublic slots:\n\n\n\n //----------------------------------------------------------------------------\n\n // qSlicerApplicationHelper\n\n\n\n //----------------------------------------------------------------------------\n\n void static_qSlicerApplicationHelper_setupModuleFactoryManager(qSlicerModuleFactoryManager * moduleFactoryManager)\n\n {\n\n qSlicerApplicationHelper::setupModuleFactoryManager(moduleFactoryManager);\n\n }\n\n};\n\n\n\n//-----------------------------------------------------------------------------\n\nvoid initqSlicerBaseQTAppPythonQtDecorators()\n\n{\n\n PythonQt::self()->addDecorators(new qSlicerBaseQTAppPythonQtDecorators);\n\n}\n\n\n\n#endif\n", "file_path": "Base/QTApp/qSlicerBaseQTAppPythonQtDecorators.h", "rank": 53, "score": 210536.70470846392 }, { "content": "/// \\brief Superclass for MRML logic classes.\n\n///\n\n/// Superclass for all MRML logic classes.\n\n/// When a scene is set, SetMRMLScene(vtkMRMLScene*),\n\n/// - UnobserveMRMLScene() is called if a scene was previously set,\n\n/// - SetMRMLSceneInternal() is called to observe the scene events\n\n/// (e.g. StartImportEvent, EndBatchProcessEvent...)\n\n/// - ObserveMRMLScene() is called to initialize the scene from the logic\n\n/// - UpdateMRMLScene() is called to initialize the logic from the scene\n\n/// Later, when events are fired by the scene, corresponding methods\n\n/// (e.g. OnMRMLSceneNodeAdded, OnMRMLEndBatchProcess...) are called in the\n\n/// logic if the events have been previously observed in SetMRMLSceneInternal()\n\nclass VTK_MRML_LOGIC_EXPORT vtkMRMLAbstractLogic : public vtkObject\n\n{\n\npublic:\n\n /// Typedef for member functions of MRMLLogic that can be used as\n\n /// scheduled tasks.\n\n typedef void (vtkMRMLAbstractLogic::*TaskFunctionPointer)(void *clientdata);\n\n\n\n static vtkMRMLAbstractLogic *New();\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n vtkTypeMacro(vtkMRMLAbstractLogic, vtkObject);\n\n\n\n /// Get access to overall application state\n\n virtual vtkMRMLApplicationLogic* GetMRMLApplicationLogic()const;\n\n virtual void SetMRMLApplicationLogic(vtkMRMLApplicationLogic* logic);\n\n\n\n /// Return a reference to the current MRML scene\n\n vtkMRMLScene * GetMRMLScene()const;\n\n\n\n /// Set and observe the MRMLScene\n\n void SetMRMLScene(vtkMRMLScene * newScene);\n", "file_path": "Libs/MRML/Logic/vtkMRMLAbstractLogic.h", "rank": 54, "score": 208452.0694072922 }, { "content": "/// \\brief Provides tools.\n\n///\n\n/// Utility functions associated to FreeSurfer data.\n\nclass VTK_FreeSurfer_EXPORT vtkFSSurfaceHelper: public vtkObject\n\n{\n\npublic:\n\n static vtkFSSurfaceHelper* New();\n\n\n\n /// Convenience method to compute a volume's Vox2RAS-tkreg Matrix\n\n static void ComputeTkRegVox2RASMatrix(double* spacing, int* dimensions, vtkMatrix4x4 *M );\n\n\n\n /// Computes matrix we need to register V1Node to V2Node given the\n\n /// \"register.dat\" matrix from tkregister2 (FreeSurfer)\n\n static void TranslateFreeSurferRegistrationMatrixIntoSlicerRASToRASMatrix(\n\n double* V1Spacing, int* V1Dim, vtkMatrix4x4* V1IJKToRASMatrix,\n\n double* V2Spacing, int* V2Dim, vtkMatrix4x4* V2RASToIJKMatrix,\n\n vtkMatrix4x4 *FSRegistrationMatrix, vtkMatrix4x4 *RAS2RASMatrix);\n\n\n\nprotected:\n\n vtkFSSurfaceHelper();\n\n};\n\n\n\n#endif\n", "file_path": "Libs/FreeSurfer/vtkFSSurfaceHelper.h", "rank": 55, "score": 208440.01568814437 }, { "content": "//-----------------------------------------------------------------------------\n\nclass QMRML_WIDGETS_EXPORT qMRMLViewControllerBarPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLViewControllerBar);\n\n\n\nprotected:\n\n qMRMLViewControllerBar* const q_ptr;\n\n\n\npublic:\n\n typedef QObject Superclass;\n\n qMRMLViewControllerBarPrivate(qMRMLViewControllerBar& object);\n\n virtual ~qMRMLViewControllerBarPrivate();\n\n\n\n virtual void init();\n\n virtual void setColor(QColor color);\n\n virtual QColor color()const;\n\n\n\n QToolButton* PinButton;\n\n QLabel* ViewLabel;\n\n ctkPopupWidget* PopupWidget;\n", "file_path": "Libs/MRML/Widgets/qMRMLViewControllerBar_p.h", "rank": 56, "score": 208440.01568814437 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLROIWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLROIWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLROIWidgetPlugin.h", "rank": 57, "score": 208440.01568814437 }, { "content": "/// \\ingroup SlicerRt_QtModules_Segmentations\n\n/// \\brief Private implementation of the segment editor abstract label effect\n\nclass qSlicerSegmentEditorAbstractLabelEffectPrivate: public QObject\n\n{\n\n Q_OBJECT\n\n Q_DECLARE_PUBLIC(qSlicerSegmentEditorAbstractLabelEffect);\n\nprotected:\n\n qSlicerSegmentEditorAbstractLabelEffect* const q_ptr;\n\npublic:\n\n typedef QObject Superclass;\n\n qSlicerSegmentEditorAbstractLabelEffectPrivate(qSlicerSegmentEditorAbstractLabelEffect& object);\n\n ~qSlicerSegmentEditorAbstractLabelEffectPrivate();\n\n\n\nprotected slots:\n\n\n\npublic:\n\n};\n\n\n\n#endif\n", "file_path": "Modules/Loadable/Segmentations/EditorEffects/qSlicerSegmentEditorAbstractLabelEffect_p.h", "rank": 58, "score": 208264.99728106515 }, { "content": "class qMRMLAnnotationDisplayNodePointPropertyWidgetPrivate: public QObject,\n\n public Ui_qMRMLAnnotationDisplayNodePointPropertyWidget\n\n{\n\n Q_OBJECT\n\n Q_DECLARE_PUBLIC(qMRMLAnnotationDisplayNodePointPropertyWidget);\n\nprotected:\n\n qMRMLAnnotationDisplayNodePointPropertyWidget* const q_ptr;\n\n\n\npublic:\n\n\n\n qMRMLAnnotationDisplayNodePointPropertyWidgetPrivate(qMRMLAnnotationDisplayNodePointPropertyWidget& object);\n\n typedef qMRMLAnnotationDisplayNodePointPropertyWidgetPrivate Self;\n\n void setupUi(qMRMLAnnotationDisplayNodePropertyWidget * widget);\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Modules/Loadable/Annotations/Widgets/qMRMLAnnotationDisplayNodePointPropertyWidget_p.h", "rank": 59, "score": 206070.4574459475 }, { "content": "/// \\brief qSlicerAbstractCoreModule is the base class of any module in Slicer.\n\n//\n\n/// Core modules, Loadable modules, CLI modules derive from it.\n\n/// It is responsible to create the UI and the Logic:\n\n/// createWidgetRepresentation() and createLogic() must be reimplemented in\n\n/// derived classes.\n\n/// A Slicer module has a name and a title: The name is its UID, the title\n\n/// displayed to the user.\n\n/// When a MRML scene is set to the module, the module set the scene to the\n\n/// UI widget and the logic.\n\nclass Q_SLICER_BASE_QTCORE_EXPORT qSlicerAbstractCoreModule : public QObject\n\n{\n\n /// Any object deriving from QObject must have the Q_OBJECT macro in\n\n /// order to have the signal/slots working and the meta-class name valid.\n\n Q_OBJECT\n\n\n\n /// The following properties are added to the meta-class\n\n /// and though are available through PythonQt.\n\n\n\n /// This property contains the name of the module.\n\n /// e.g. \"Volumes\", \"VolumeRendering\", \"SampleData\"...\n\n /// The name identifies a module and must be unique.\n\n /// In comparison to \\a title, \\a name contains only letter characters,\n\n /// no space/hyphen/apostrophe.\n\n /// The module name is set by the module factory (the registered item key\n\n /// string).\n\n /// Because \\a name is unique, slots and functions that take a module as\n\n /// argument should use \\name and not \\a title.\n\n Q_PROPERTY(QString name READ name)\n\n\n", "file_path": "Base/QTCore/qSlicerAbstractCoreModule.h", "rank": 60, "score": 206013.0054838387 }, { "content": "/// \\ingroup SegmentationCore\n\n/// \\brief Abstract converter rule class. Subclasses perform conversions between specific\n\n/// representation types. They define source and target type and provide ways to create those\n\n/// types of objects.\n\nclass vtkSegmentationCore_EXPORT vtkSegmentationConverterRule : public vtkObject\n\n{\n\npublic:\n\n /// Conversion parameter list type. Maps the conversion parameter name to a pair consisting of the\n\n /// value of the parameter (the default value if it is defined in the converter rule) and the\n\n /// description of the parameter that appears as tooltip in the conversion parameters widget\n\n /// ( name => (value, description) )\n\n typedef std::map<std::string, std::pair<std::string, std::string> > ConversionParameterListType;\n\n\n\n /// Constant to use for converter rules with \"infinite\" computational cost (i.e. disabled)\n\n /// It's about UINT_MAX / 400 (allows us to have a few hundred disabled rules)\n\n static unsigned int GetConversionInfiniteCost() { return 10000000; };\n\n\n\npublic:\n\n //static vtkSegmentationConverterRule* New();\n\n vtkTypeMacro(vtkSegmentationConverterRule, vtkObject);\n\n\n\n /// Create instance of the default node. Similar to New but virtual method.\n\n /// Subclasses should implement this method by\n\n virtual vtkSegmentationConverterRule* CreateRuleInstance() = 0;\n", "file_path": "Libs/vtkSegmentationCore/vtkSegmentationConverterRule.h", "rank": 61, "score": 206012.1005431629 }, { "content": "/// \\ingroup SegmentationCore\n\n/// \\brief Class that can create vtkSegmentationConverter instances.\n\n///\n\n/// This singleton class is a repository of all segmentation converter rules.\n\n/// Singleton pattern adopted from vtkEventBroker class.\n\nclass vtkSegmentationCore_EXPORT vtkSegmentationConverterFactory : public vtkObject\n\n{\n\npublic:\n\n typedef std::vector< vtkSmartPointer<vtkSegmentationConverterRule> > RuleListType;\n\n\n\n vtkTypeMacro(vtkSegmentationConverterFactory, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// Create a copy of all registered converter rules.\n\n /// The rule argument is overwritten (any previous content is cleared) with rules\n\n /// copied from the list of all registered rules.\n\n void CopyConverterRules(RuleListType &rules);\n\n\n\n /// Add a converter rule.\n\n /// The factory (and all converter classes it creates) will keep a reference to this rule object,\n\n /// and it will not be deleted until all these referring classes are deleted.\n\n void RegisterConverterRule(vtkSegmentationConverterRule* rule);\n\n\n\n /// Remove a converter rule from the factory.\n\n /// This does not affect converters that have already been created.\n", "file_path": "Libs/vtkSegmentationCore/vtkSegmentationConverterFactory.h", "rank": 62, "score": 206008.39796927685 }, { "content": "class Q_SLICER_BASE_QTCORE_EXPORT qSlicerExtensionsManagerModel : public QObject\n\n{\n\n Q_OBJECT\n\n Q_PROPERTY(int numberOfInstalledExtensions READ numberOfInstalledExtensions)\n\n Q_PROPERTY(QStringList installedExtensions READ installedExtensions)\n\n Q_PROPERTY(QStringList enabledExtensions READ enabledExtensions)\n\n Q_PROPERTY(QUrl serverUrl READ serverUrl)\n\n Q_PROPERTY(QUrl serverUrlWithPackagePath READ serverUrlWithPackagePath)\n\n Q_PROPERTY(QUrl serverUrlWithExtensionsStorePath READ serverUrlWithExtensionsStorePath)\n\n Q_PROPERTY(QString extensionsInstallPath READ extensionsInstallPath)\n\n Q_PROPERTY(bool newExtensionEnabledByDefault READ newExtensionEnabledByDefault WRITE setNewExtensionEnabledByDefault)\n\n Q_PROPERTY(QString extensionsSettingsFilePath READ extensionsSettingsFilePath WRITE setExtensionsSettingsFilePath)\n\n Q_PROPERTY(QString slicerRevision READ slicerRevision WRITE setSlicerRevision)\n\n Q_PROPERTY(QString slicerOs READ slicerOs WRITE setSlicerOs)\n\n Q_PROPERTY(QString slicerArch READ slicerArch WRITE setSlicerArch)\n\n Q_PROPERTY(QString slicerVersion READ slicerVersion WRITE setSlicerVersion)\n\npublic:\n\n /// Superclass typedef\n\n typedef QObject Superclass;\n\n\n", "file_path": "Base/QTCore/qSlicerExtensionsManagerModel.h", "rank": 63, "score": 206001.2419076654 }, { "content": "class VTK_MRML_EXPORT vtkDataFileFormatHelper : public vtkObject\n\n{\n\n public:\n\n\n\n /// The Usual vtk class functions\n\n static vtkDataFileFormatHelper *New();\n\n vtkTypeMacro(vtkDataFileFormatHelper, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n static std::string GetFileExtensionFromFormatString(\n\n const char* fileformat);\n\n const char* GetClassNameFromFormatString(\n\n const char* fileformat);\n\n\n\n ///\n\n /// Get the itkimageio supported file formats.\n\n //vtkGetObjectMacro ( ITKSupportedWriteFileFormats, vtkStringArray);\n\n virtual vtkStringArray* GetITKSupportedWriteFileFormats();\n\n virtual vtkStringArray* GetITKSupportedReadFileFormats()\n\n {\n", "file_path": "Libs/MRML/Core/vtkDataFileFormatHelper.h", "rank": 64, "score": 206001.2419076654 }, { "content": "class Q_SLICER_BASE_QTCORE_EXPORT qSlicerExtensionDownloadTask : public QObject\n\n{\n\n Q_OBJECT\n\n Q_PROPERTY(QVariantMap metadata READ metadata WRITE setMetadata)\n\n Q_PROPERTY(QString extensionName READ extensionName WRITE setExtensionName)\n\n Q_PROPERTY(QString archiveName READ archiveName WRITE setArchiveName)\n\n Q_PROPERTY(QNetworkReply* reply READ reply)\n\n\n\npublic:\n\n /// Constructor.\n\n ///\n\n /// The task takes ownership of the reply and will delete it when the task\n\n /// is destroyed.\n\n explicit qSlicerExtensionDownloadTask(QNetworkReply* reply,\n\n QObject* parent = 0);\n\n\n\n /// Destructor.\n\n virtual ~qSlicerExtensionDownloadTask();\n\n\n\n /// Get extension metadata.\n", "file_path": "Base/QTCore/qSlicerExtensionDownloadTask.h", "rank": 65, "score": 206001.2419076654 }, { "content": "/// \\ingroup SegmentationCore\n\n/// \\brief Calculate oversampling factor based on model properties using fuzzy logics\n\nclass vtkSegmentationCore_EXPORT vtkCalculateOversamplingFactor : public vtkObject\n\n{\n\npublic:\n\n static vtkCalculateOversamplingFactor *New();\n\n vtkTypeMacro(vtkCalculateOversamplingFactor, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\npublic:\n\n /// Calculate oversampling factor for the input model and its rasterization reference volume\n\n /// based on model properties using fuzzy logics.\n\n bool CalculateOversamplingFactor();\n\n\n\n /// Apply oversampling factor on image data geometry.\n\n /// Changes spacing and extent of oversampling factor is not 1 (and sensible)\n\n static void ApplyOversamplingOnImageGeometry(vtkOrientedImageData* imageData, double oversamplingFactor);\n\n\n\nprotected:\n\n /// Calculate relative structure size from input model and rasterization reference volume\n\n double CalculateRelativeStructureSize();\n\n\n", "file_path": "Libs/vtkSegmentationCore/vtkCalculateOversamplingFactor.h", "rank": 66, "score": 206001.2419076654 }, { "content": "//-----------------------------------------------------------------------------\n\nclass Q_SLICER_BASE_QTCLI_EXPORT qSlicerWidgetValueWrapper: public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n qSlicerWidgetValueWrapper(const QString& _name, const QString& _label, QObject* parent);\n\n virtual ~qSlicerWidgetValueWrapper();\n\n virtual QVariant value() = 0;\n\n QString label(){ return this->Label; }\n\n QString name(){ return this->Name; }\n\n\n\n virtual void setValue(const QString& _value) = 0;\n\n\n\n static QString toString(const QString& _value)\n\n {\n\n return _value;\n\n }\n\n\n\n static bool toBool(const QString& _value)\n\n {\n\n return (_value.compare(\"true\", Qt::CaseInsensitive) == 0);\n", "file_path": "Base/QTCLI/qSlicerCLIModuleUIHelper.h", "rank": 67, "score": 206001.2419076654 }, { "content": "/// Container class for objects that can be loaded from DICOM files into Slicer.\n\n/// Each plugin returns a list of instances from its evaluate method and accepts\n\n/// a list of these in its load method corresponding to the things the user has\n\n/// selected for loading\n\nclass Q_SLICER_MODULE_DICOMLIB_WIDGETS_EXPORT qSlicerDICOMLoadable : public QObject\n\n{\n\n Q_OBJECT\n\n\n\n /// Name exposed to the user for the node\n\n Q_PROPERTY(QString name READ name WRITE setName)\n\n /// Extra information the user sees on mouse over of the thing\n\n Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip)\n\n /// Things the user should know before loading this data\n\n Q_PROPERTY(QString warning READ warning WRITE setWarning)\n\n /// The file list of the data to be loaded\n\n Q_PROPERTY(QStringList files READ files WRITE setFiles)\n\n /// Is the object checked for loading by default\n\n Q_PROPERTY(bool selected READ selected WRITE setSelected)\n\n /// Confidence - from 0 to 1 where 0 means low chance\n\n /// that the user actually wants to load their data this\n\n /// way up to 1, which means that the plugin is very confident\n\n /// that this is the best way to load the data.\n\n /// When more than one plugin marks the same series as\n\n /// selected, the one with the highest confidence is\n", "file_path": "Modules/Scripted/DICOMLib/Widgets/qSlicerDICOMLoadable.h", "rank": 68, "score": 203659.08246314852 }, { "content": "/// Container class for things that can be loaded from DICOM files into Slicer.\n\n/// Each plugin returns a list of instances from its evaluate method and accepts\n\n/// a list of these in its load method corresponding to the things the user has\n\n/// selected for loading\n\nclass Q_SLICER_MODULE_DICOMLIB_WIDGETS_EXPORT qSlicerDICOMExportable : public QObject\n\n{\n\n Q_OBJECT\n\n\n\n /// Name exposed to the user for the export method\n\n Q_PROPERTY(QString name READ name WRITE setName)\n\n /// Extra information the user sees on mouse over of the export option\n\n Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip)\n\n /// ID of MRML node to be exported\n\n Q_PROPERTY(QString nodeID READ nodeID WRITE setNodeID)\n\n /// Class of the plugin that created this exportable\n\n Q_PROPERTY(QString pluginClass READ pluginClass WRITE setPluginClass)\n\n /// Target directory to export this exportable\n\n Q_PROPERTY(QString directory READ directory WRITE setDirectory)\n\n /// Confidence - from 0 to 1 where 0 means that the plugin\n\n /// cannot export the given node, up to 1 that means that the\n\n /// plugin considers itself the best plugin to export the node\n\n /// (in case of specialized objects, e.g. RT dose volume)\n\n Q_PROPERTY(double confidence READ confidence WRITE setConfidence)\n\n /// Pseudo-tags offered by the plugin that are to be filled out for export.\n", "file_path": "Modules/Scripted/DICOMLib/Widgets/qSlicerDICOMExportable.h", "rank": 69, "score": 203653.66633005746 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLRangeWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLRangeWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLRangeWidgetPlugin.h", "rank": 70, "score": 203648.223827651 }, { "content": "//-----------------------------------------------------------------------------\n\nclass Q_SLICER_BASE_QTCLI_EXPORT qSlicerCLIModuleUIHelper: public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n\n\n qSlicerCLIModuleUIHelper(qSlicerCLIModuleWidget* cliModuleWidget);\n\n virtual ~qSlicerCLIModuleUIHelper();\n\n\n\n /// Create the widget associated with the given \\a moduleParameter\n\n /// The caller is responsible to delete the widget.\n\n /// Note also that if the widget is added to a layout, Qt will\n\n /// be responsible to delete the widget.\n\n QWidget* createTagWidget(const ModuleParameter& moduleParameter);\n\n\n\n ///\n\n /// Update \\a commandLineModuleNode properties using value entered from the UI\n\n void updateMRMLCommandLineModuleNode(vtkMRMLCommandLineModuleNode* commandLineModuleNode);\n\n\n\n /// Update user interface using the given \\a commandLineModuleNode parameters\n\n void updateUi(vtkMRMLCommandLineModuleNode* commandLineModuleNode);\n", "file_path": "Base/QTCLI/qSlicerCLIModuleUIHelper.h", "rank": 71, "score": 203648.223827651 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLTransformSlidersPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLTransformSlidersPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLTransformSlidersPlugin.h", "rank": 72, "score": 203648.223827651 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLListWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLListWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLListWidgetPlugin.h", "rank": 73, "score": 203648.223827651 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLLayoutWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLLayoutWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLLayoutWidgetPlugin.h", "rank": 74, "score": 203648.223827651 }, { "content": "class VTK_SLICER_EDITORLIB_MODULE_LOGIC_EXPORT vtkImageStash : public vtkObject\n\n{\n\npublic:\n\n static vtkImageStash *New();\n\n vtkTypeMacro(vtkImageStash,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n ///\n\n /// The stash image:\n\n /// This image data will have the Scalars removed\n\n /// and they will be stored in a local compressed data\n\n /// array inside this class when the Stash method is called.\n\n /// You must call Unstash to have the scalars put back into\n\n /// this image data.\n\n vtkSetObjectMacro(StashImage, vtkImageData);\n\n vtkGetObjectMacro(StashImage, vtkImageData);\n\n\n\n ///\n\n /// The stashed scalars:\n\n /// this is the zlib compressed image scalar data\n", "file_path": "Modules/Scripted/EditorLib/Logic/vtkImageStash.h", "rank": 75, "score": 203648.223827651 }, { "content": "class qSlicerSubjectHierarchyModuleWidgetsPythonQtDecorators : public QObject\n\n{\n\n Q_OBJECT\n\npublic:\n\n\n\n qSlicerSubjectHierarchyModuleWidgetsPythonQtDecorators()\n\n {\n\n //PythonQt::self()->registerClass(&qSlicerSubjectHierarchyPluginHandler::staticMetaObject);\n\n // Note: Use registerCPPClassForPythonQt to register pure Cpp classes\n\n }\n\n\n\npublic slots:\n\n\n\n //----------------------------------------------------------------------------\n\n // qSlicerSubjectHierarchyPluginHandler\n\n\n\n //----------------------------------------------------------------------------\n\n // static methods\n\n\n\n //----------------------------------------------------------------------------\n", "file_path": "Modules/Loadable/SubjectHierarchy/Widgets/qSlicerSubjectHierarchyModuleWidgetsPythonQtDecorators.h", "rank": 76, "score": 201897.6694308523 }, { "content": "/// \\brief Factory where displayable manager classes are registered.\n\n///\n\n/// A displayable manager class is responsible to represent a\n\n/// MRMLDisplayable node in a renderer.\n\nclass VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLDisplayableManagerFactory : public vtkObject\n\n{\n\npublic:\n\n static vtkMRMLDisplayableManagerFactory* New();\n\n vtkTypeMacro(vtkMRMLDisplayableManagerFactory,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n enum\n\n {\n\n DisplayableManagerFactoryRegisteredEvent = 30100,\n\n DisplayableManagerFactoryUnRegisteredEvent = 30101\n\n };\n\n\n\n /// Return True if Displayable Manager identified by \\a vtkClassName\n\n /// is already registered.\n\n bool IsDisplayableManagerRegistered(const char* vtkClassName);\n\n\n\n /// Register Displayable Manager identified by \\a vtkClassOrScriptName\n\n /// Returns True if displayable manager was successfully registered\n\n /// \\a vtkClassOrScriptName should be either:\n", "file_path": "Libs/MRML/DisplayableManager/vtkMRMLDisplayableManagerFactory.h", "rank": 77, "score": 201383.41731570027 }, { "content": "/// \\brief DisplayableManagerGroup is a collection of DisplayableManager.\n\n///\n\n/// It also provides method allowing to either call RenderRequest\n\n/// or SetAndObserveMRMLDisplayableNode on all member of the group.\n\n/// When the displayable managers in the group request the view to be\n\n/// refreshed, the group fires a vtkCommand::UpdateEvent event.\n\n/// This event can be observed and trigger a Render on the render window.\n\nclass VTK_MRML_DISPLAYABLEMANAGER_EXPORT vtkMRMLDisplayableManagerGroup : public vtkObject\n\n{\n\npublic:\n\n\n\n static vtkMRMLDisplayableManagerGroup *New();\n\n vtkTypeMacro(vtkMRMLDisplayableManagerGroup,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n /// Convenient method equivalent to call SetAndObserveDisplayableManagerFactory, SetRenderer,\n\n /// then instantiate and add all displayable managers registered within the \\a factory.\n\n /// \\sa SetAndObserveDisplayableManagerFactory SetRenderer\n\n /// \\sa AddDisplayableManager InstantiateDisplayableManager\n\n void Initialize(vtkMRMLDisplayableManagerFactory * factory, vtkRenderer * renderer);\n\n\n\n /// Set and observe DisplayableManager factory\n\n void SetAndObserveDisplayableManagerFactory(vtkMRMLDisplayableManagerFactory * factory);\n\n\n\n /// Add a DisplayableManager and initialize it if required\n\n void AddDisplayableManager(vtkMRMLAbstractDisplayableManager * displayableManager);\n\n\n", "file_path": "Libs/MRML/DisplayableManager/vtkMRMLDisplayableManagerGroup.h", "rank": 78, "score": 201381.1443967662 }, { "content": "/// Loading modules into slicer happens in multiple steps:\n\n/// 1) module factories must be registered into the factory manager:\n\n/// qSlicerModuleFactoryManager* factoryManager = app->moduleManager()->factoryManager();\n\n/// factoryManager->registerFactory(new qSlicerLoadableModuleFactory);\n\n/// ...\n\n/// 2) directories where the modules to load are located must be passed to the factory manager\n\n/// factoryManager->addSearchPath(app->slicerHome() + \"/\" + Slicer_QTSCRIPTEDMODULES_LIB_DIR + \"/\" );\n\n/// factoryManager->addSearchPath(app->slicerHome() + \"/\" + Slicer_CLIMODULES_LIB_DIR + \"/\" );\n\n/// ...\n\n/// 3) Optionally:\n\n/// - specify module names to ignore: For startup speed-up and memory consummation,\n\n/// it can be useful to not load some modules:\n\n/// factoryManager->setModulesToIgnore(QStringList(QString(\"Data\")));\n\n/// - specify an explicit list of modules to register/instantiate/load. All other discovered\n\n/// modules won't be loaded.\n\n/// 4) scan the directories and test which file is a module and register it (not instantiated yet)\n\n/// For each file in the search paths, the factory manager asks each registered\n\n/// factory if they can load the file. If there is a factory that supports the\n\n/// file, the manager associates the factory to the file path, otherwise the\n\n/// file is discarded.\n\n/// factoryManager->registerModules();\n\n/// 5) Instantiate all the registered modules\n\n/// factoryManager->instantiateModules();\n\n/// 6) Connect each module with the scene and the application\n\n/// The application logic and the scene are passed to each module.\n\n/// The order of initialization is defined with the dependencies of the modules.\n\n/// If module B depends of module A, it is assured that module B is initialized/setup after A.\n\n/// factoryManager->loadModules();\n\nclass Q_SLICER_BASE_QTCORE_EXPORT qSlicerAbstractModuleFactoryManager : public QObject\n\n{\n\n Q_OBJECT\n\n /// This property holds the paths where the modules are located.\n\n /// At registration time (registerModules), the paths are scanned and module\n\n /// discovered.\n\n /// A module can be a library (dll, so),\n\n /// an executable (exe), a python file (py) or any other file type supported\n\n /// by the registered factories.\n\n /// The search is not recursive, you need to provide each subdirectory\n\n /// manually.\n\n ///\n\n /// \\todo In qSlicerAbstractModuleFactoryManager, should the module search recursively descend \\a searchPaths\n\n Q_PROPERTY(QStringList searchPaths READ searchPaths WRITE setSearchPaths)\n\n\n\n /// This property holds the names of the modules to ignore at registration time.\n\n ///\n\n /// Due to the large amount of modules to load, it can be faster (and less\n\n /// overwhelming) to load only a subset of the modules.\n\n Q_PROPERTY(QStringList modulesToIgnore READ modulesToIgnore WRITE setModulesToIgnore NOTIFY modulesToIgnoreChanged)\n", "file_path": "Base/QTCore/qSlicerAbstractModuleFactoryManager.h", "rank": 79, "score": 201379.06257691752 }, { "content": "/// \\ingroup SegmentationCore\n\n/// \\brief Utility functions for resampling oriented image data\n\nclass vtkSegmentationCore_EXPORT vtkOrientedImageDataResample : public vtkObject\n\n{\n\npublic:\n\n static vtkOrientedImageDataResample *New();\n\n vtkTypeMacro(vtkOrientedImageDataResample,vtkObject);\n\n\n\n enum\n\n {\n\n OPERATION_MINIMUM,\n\n OPERATION_MAXIMUM,\n\n OPERATION_MASKING\n\n };\n\n\n\n /// Resample an oriented image data to match the geometry of a reference geometry matrix.\n\n /// Origin and dimensions are determined from the contents of the input image.\n\n /// \\param inputImage Oriented image to resample\n\n /// \\param referenceGeometryMatrix Matrix containing the desired geometry\n\n /// \\param outputImage Output image\n\n /// \\param linearInterpolation True if linear interpolation is requested (fractional labelmap), or false for nearest neighbor (binary labelmap). Default is false.\n\n /// \\return Success flag\n", "file_path": "Libs/vtkSegmentationCore/vtkOrientedImageDataResample.h", "rank": 80, "score": 201376.5164002522 }, { "content": "/// \\ingroup Slicer_QtModules_SubjectHierarchy_Widgets\n\nclass Q_SLICER_MODULE_DICOMLIB_WIDGETS_EXPORT qSlicerDICOMExportDialog : public QObject\n\n{\n\npublic:\n\n Q_OBJECT\n\n\n\npublic:\n\n typedef QObject Superclass;\n\n qSlicerDICOMExportDialog(QObject* parent = NULL);\n\n virtual ~qSlicerDICOMExportDialog();\n\n\n\npublic:\n\n /// Show dialog\n\n /// \\param nodeToSelect Node is selected in the tree if given\n\n virtual bool exec(vtkMRMLSubjectHierarchyNode* nodeToSelect=NULL);\n\n\n\n /// Set MRML scene\n\n Q_INVOKABLE void setMRMLScene(vtkMRMLScene* scene);\n\n\n\n /// Python compatibility function for showing dialog (calls \\a exec)\n\n Q_INVOKABLE bool execDialog(vtkMRMLSubjectHierarchyNode* nodeToSelect=NULL) { return this->exec(nodeToSelect); };\n", "file_path": "Modules/Scripted/DICOMLib/Widgets/qSlicerDICOMExportDialog.h", "rank": 81, "score": 199181.9765651346 }, { "content": "class VTK_SLICER_EDITORLIB_MODULE_LOGIC_EXPORT vtkImageSlicePaint : public vtkObject\n\n{\n\npublic:\n\n static vtkImageSlicePaint *New();\n\n vtkTypeMacro(vtkImageSlicePaint,vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\n\n\n ///\n\n /// Sets/Gets the PaintRegion in IJK (pixel) coordinates of the Working image\n\n vtkSetVector3Macro(TopLeft, int);\n\n vtkGetVector3Macro(TopLeft, int);\n\n vtkSetVector3Macro(TopRight, int);\n\n vtkGetVector3Macro(TopRight, int);\n\n vtkSetVector3Macro(BottomLeft, int);\n\n vtkGetVector3Macro(BottomLeft, int);\n\n vtkSetVector3Macro(BottomRight, int);\n\n vtkGetVector3Macro(BottomRight, int);\n\n\n\n ///\n", "file_path": "Modules/Scripted/EditorLib/Logic/vtkImageSlicePaint.h", "rank": 82, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLColorTableViewPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLColorTableViewPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLColorTableViewPlugin.h", "rank": 83, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLDisplayNodeWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLDisplayNodeWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n\n\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLDisplayNodeWidgetPlugin.h", "rank": 84, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLCaptureToolBarPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLCaptureToolBarPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLCaptureToolBarPlugin.h", "rank": 85, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLClipNodeWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLClipNodeWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n\n\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLClipNodeWidgetPlugin.h", "rank": 86, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLVolumeThresholdWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLVolumeThresholdWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n\n\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLVolumeThresholdWidgetPlugin.h", "rank": 87, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLSliceControllerWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLSliceControllerWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLSliceControllerWidgetPlugin.h", "rank": 88, "score": 199181.9765651346 }, { "content": "/// VTK implementation of \\sa qSlicerDICOMLoadable\n\nclass VTK_SLICER_DICOMLIB_MODULE_LOGIC_EXPORT vtkSlicerDICOMLoadable : public vtkObject\n\n{\n\npublic:\n\n static vtkSlicerDICOMLoadable *New();\n\n vtkTypeMacro(vtkSlicerDICOMLoadable, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\npublic:\n\n vtkGetStringMacro(Name);\n\n vtkSetStringMacro(Name);\n\n\n\n vtkGetStringMacro(Tooltip);\n\n vtkSetStringMacro(Tooltip);\n\n\n\n vtkGetStringMacro(Warning);\n\n vtkSetStringMacro(Warning);\n\n\n\n vtkGetObjectMacro(Files, vtkStringArray);\n\n\n\n vtkGetMacro(Selected, bool);\n", "file_path": "Modules/Scripted/DICOMLib/Logic/vtkSlicerDICOMLoadable.h", "rank": 89, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLColorListViewPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLColorListViewPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLColorListViewPlugin.h", "rank": 90, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLSliceInformationWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLSliceInformationWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLSliceInformationWidgetPlugin.h", "rank": 91, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLNodeComboBoxPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLNodeComboBoxPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLNodeComboBoxPlugin.h", "rank": 92, "score": 199181.9765651346 }, { "content": "/// VTK implementation of \\sa qSlicerDICOMExportable\n\nclass VTK_SLICER_DICOMLIB_MODULE_LOGIC_EXPORT vtkSlicerDICOMExportable : public vtkObject\n\n{\n\npublic:\n\n static vtkSlicerDICOMExportable *New();\n\n vtkTypeMacro(vtkSlicerDICOMExportable, vtkObject);\n\n void PrintSelf(ostream& os, vtkIndent indent);\n\n\n\npublic:\n\n vtkGetStringMacro(Name);\n\n vtkSetStringMacro(Name);\n\n\n\n vtkGetStringMacro(Tooltip);\n\n vtkSetStringMacro(Tooltip);\n\n\n\n vtkGetStringMacro(NodeID);\n\n vtkSetStringMacro(NodeID);\n\n\n\n vtkGetStringMacro(PluginClass);\n\n vtkSetStringMacro(PluginClass);\n\n\n", "file_path": "Modules/Scripted/DICOMLib/Logic/vtkSlicerDICOMExportable.h", "rank": 93, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLLinearTransformSliderPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLLinearTransformSliderPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLLinearTransformSliderPlugin.h", "rank": 94, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLSceneFactoryWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLSceneFactoryWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n};\n\n\n\n#endif\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLSceneFactoryWidgetPlugin.h", "rank": 95, "score": 199181.9765651346 }, { "content": "class QMRML_WIDGETS_PLUGINS_EXPORT qMRMLWindowLevelWidgetPlugin : public QObject,\n\n public qMRMLWidgetsAbstractPlugin\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n qMRMLWindowLevelWidgetPlugin(QObject *_parent = 0);\n\n\n\n QWidget *createWidget(QWidget *_parent);\n\n QString domXml() const;\n\n QIcon icon() const;\n\n QString includeFile() const;\n\n bool isContainer() const;\n\n QString name() const;\n\n\n\n};\n\n\n\n#endif\n\n\n", "file_path": "Libs/MRML/Widgets/DesignerPlugins/qMRMLWindowLevelWidgetPlugin.h", "rank": 96, "score": 199181.9765651346 }, { "content": "class MRMLIDImageIO_EXPORT MRMLIDImageIOFactory : public ObjectFactoryBase\n\n{\n\npublic:\n\n /** Standard class typedefs. */\n\n typedef MRMLIDImageIOFactory Self;\n\n typedef ObjectFactoryBase Superclass;\n\n typedef SmartPointer<Self> Pointer;\n\n typedef SmartPointer<const Self> ConstPointer;\n\n\n\n /** Class methods used to interface with the registered factories. */\n\n virtual const char* GetITKSourceVersion(void) const ITK_OVERRIDE;\n\n virtual const char* GetDescription(void) const ITK_OVERRIDE;\n\n\n\n /** Method for class instantiation. */\n\n itkFactorylessNewMacro(Self);\n\n static MRMLIDImageIOFactory* FactoryNew() { return new MRMLIDImageIOFactory;}\n\n\n\n /** Run-time type information (and related methods). */\n\n itkTypeMacro(MRMLIDImageIOFactory, ObjectFactoryBase);\n\n\n", "file_path": "Libs/MRML/IDImageIO/itkMRMLIDImageIOFactory.h", "rank": 97, "score": 199181.9765651346 }, { "content": "class Q_SLICER_BASE_QTCORE_EXPORT qSlicerAbstractModuleRepresentation : virtual public qSlicerObject\n\n{\n\npublic:\n\n\n\n typedef qSlicerObject Superclass;\n\n qSlicerAbstractModuleRepresentation();\n\n virtual ~qSlicerAbstractModuleRepresentation();\n\n\n\n /// Set/Get module name\n\n QString moduleName()const;\n\n\n\n /// Returns the module the representation belongs to.\n\n /// The module is set right before setup() is called.\n\n qSlicerAbstractCoreModule* module()const;\n\n\n\n /// Allows other modules to select input and output nodes in the module's GUI.\n\n /// There may be multiple node selectors in a module widget, you can select between them\n\n /// using the role argument.\n\n /// Context can be specified to make a selection within that node (for example, a markup list\n\n /// node may contain multiple markups; context can be used to select a specific item).\n", "file_path": "Base/QTCore/qSlicerAbstractModuleRepresentation.h", "rank": 98, "score": 197863.96431080392 }, { "content": "/// \\ingroup SlicerRt_QtModules_Segmentations\n\n/// \\class qSlicerSegmentEditorEffectFactory\n\n/// \\brief Singleton class managing segment editor effect plugins\n\nclass Q_SLICER_SEGMENTATIONS_EFFECTS_EXPORT qSlicerSegmentEditorEffectFactory : public QObject\n\n{\n\n Q_OBJECT\n\n\n\npublic:\n\n /// Instance getter for the singleton class\n\n /// \\return Instance object\n\n Q_INVOKABLE static qSlicerSegmentEditorEffectFactory* instance();\n\n\n\n /// Allows cleanup of the singleton at application exit\n\n static void setInstance(qSlicerSegmentEditorEffectFactory* instance);\n\n\n\npublic:\n\n /// Register a effect\n\n /// \\return True if effect registered successfully, false otherwise\n\n Q_INVOKABLE bool registerEffect(qSlicerSegmentEditorAbstractEffect* effect);\n\n\n\n /// Get list of registered effects\n\n Q_INVOKABLE QList<qSlicerSegmentEditorAbstractEffect*> registeredEffects() { return m_RegisteredEffects; };\n\n\n", "file_path": "Modules/Loadable/Segmentations/EditorEffects/qSlicerSegmentEditorEffectFactory.h", "rank": 99, "score": 197067.47933379596 } ]
C++
main/sw/source/ui/docvw/SidebarTxtControlAcc.cxx
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
#include "precompiled_sw.hxx" #include <SidebarTxtControlAcc.hxx> #include <SidebarTxtControl.hxx> #include <svl/brdcst.hxx> #include <toolkit/awt/vclxaccessiblecomponent.hxx> #include <editeng/unoedsrc.hxx> #include <editeng/unoforou.hxx> #include <editeng/unoviwou.hxx> #include <editeng/unoedhlp.hxx> #include <svx/AccessibleTextHelper.hxx> #include <editeng/outliner.hxx> namespace css = ::com::sun::star; namespace sw { namespace sidebarwindows { class SidebarTextEditSource : public SvxEditSource, public SfxBroadcaster { public: SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl ); virtual ~SidebarTextEditSource(); virtual SvxEditSource* Clone() const; virtual SvxTextForwarder* GetTextForwarder(); virtual SvxViewForwarder* GetViewForwarder(); virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False ); virtual void UpdateData(); virtual SfxBroadcaster& GetBroadcaster() const; DECL_LINK( NotifyHdl, EENotify* ); private: SidebarTxtControl& mrSidebarTxtControl; SvxOutlinerForwarder mTextForwarder; SvxDrawOutlinerViewForwarder mViewForwarder; }; SidebarTextEditSource::SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl ) : SvxEditSource() , mrSidebarTxtControl( rSidebarTxtControl ) , mTextForwarder( *(rSidebarTxtControl.GetTextView()->GetOutliner()), sal_False ) , mViewForwarder( *(rSidebarTxtControl.GetTextView()) ) { if ( mrSidebarTxtControl.GetTextView() ) { mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) ); } } SidebarTextEditSource::~SidebarTextEditSource() { if ( mrSidebarTxtControl.GetTextView() ) { mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() ); } } SvxEditSource* SidebarTextEditSource::Clone() const { return new SidebarTextEditSource( mrSidebarTxtControl ); } SvxTextForwarder* SidebarTextEditSource::GetTextForwarder() { return &mTextForwarder; } SvxViewForwarder* SidebarTextEditSource::GetViewForwarder() { return &mViewForwarder; } SvxEditViewForwarder* SidebarTextEditSource::GetEditViewForwarder( sal_Bool ) { return &mViewForwarder; } void SidebarTextEditSource::UpdateData() { } SfxBroadcaster& SidebarTextEditSource::GetBroadcaster() const { return *( const_cast< SidebarTextEditSource* > (this) ); } IMPL_LINK(SidebarTextEditSource, NotifyHdl, EENotify*, pNotify) { if ( pNotify ) { ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( pNotify ) ); if( aHint.get() ) { Broadcast( *aHint.get() ); } } return 0; } class SidebarTxtControlAccessibleContext : public VCLXAccessibleComponent { public: explicit SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl ); virtual ~SidebarTxtControlAccessibleContext(); virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); using WeakAggComponentImplHelperBase::addEventListener; using WeakAggComponentImplHelperBase::removeEventListener; virtual void SAL_CALL addEventListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeEventListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener) throw (::com::sun::star::uno::RuntimeException); protected: virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); private: SidebarTxtControl& mrSidebarTxtControl; ::accessibility::AccessibleTextHelper* mpAccessibleTextHelper; ::vos::OMutex maMutex; void defunc(); }; SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl ) : VCLXAccessibleComponent( rSidebarTxtControl.GetWindowPeer() ) , mrSidebarTxtControl( rSidebarTxtControl ) , mpAccessibleTextHelper( 0 ) , maMutex() { ::std::auto_ptr<SvxEditSource> pEditSource( new SidebarTextEditSource( mrSidebarTxtControl ) ); mpAccessibleTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource ); mpAccessibleTextHelper->SetEventSource( mrSidebarTxtControl.GetWindowPeer() ); } SidebarTxtControlAccessibleContext::~SidebarTxtControlAccessibleContext() { defunc(); } void SidebarTxtControlAccessibleContext::defunc() { delete mpAccessibleTextHelper; mpAccessibleTextHelper = 0; } sal_Int32 SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException) { vos::OGuard aGuard( maMutex ); sal_Int32 nChildCount( 0 ); if ( mpAccessibleTextHelper ) { nChildCount = mpAccessibleTextHelper->GetChildCount(); } return nChildCount; } css::uno::Reference< css::accessibility::XAccessible > SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChild( sal_Int32 i ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ) { vos::OGuard aGuard( maMutex ); css::uno::Reference< css::accessibility::XAccessible > xChild; if ( mpAccessibleTextHelper ) { xChild = mpAccessibleTextHelper->GetChild( i ); } return xChild; } void SAL_CALL SidebarTxtControlAccessibleContext::addEventListener ( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener) throw (css::uno::RuntimeException) { vos::OGuard aGuard( maMutex ); if ( mpAccessibleTextHelper ) { mpAccessibleTextHelper->AddEventListener(xListener); } } void SAL_CALL SidebarTxtControlAccessibleContext::removeEventListener ( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener) throw (css::uno::RuntimeException) { vos::OGuard aGuard( maMutex ); if ( mpAccessibleTextHelper ) { mpAccessibleTextHelper->RemoveEventListener(xListener); } } void SidebarTxtControlAccessibleContext::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { if ( mpAccessibleTextHelper ) { switch ( rVclWindowEvent.GetId() ) { case VCLEVENT_OBJECT_DYING: { defunc(); } break; case VCLEVENT_WINDOW_GETFOCUS: case VCLEVENT_CONTROL_GETFOCUS: { mpAccessibleTextHelper->SetFocus( sal_True ); } break; case VCLEVENT_WINDOW_LOSEFOCUS: case VCLEVENT_CONTROL_LOSEFOCUS: { mpAccessibleTextHelper->SetFocus( sal_False ); } break; } } VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); } SidebarTxtControlAccessible::SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl ) : VCLXWindow() , mrSidebarTxtControl( rSidebarTxtControl ) { SetWindow( &mrSidebarTxtControl ); } SidebarTxtControlAccessible::~SidebarTxtControlAccessible() { } css::uno::Reference< css::accessibility::XAccessibleContext > SidebarTxtControlAccessible::CreateAccessibleContext() { SidebarTxtControlAccessibleContext* pAccContext( new SidebarTxtControlAccessibleContext( mrSidebarTxtControl ) ); css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext ); return xAcc; } } }
#include "precompiled_sw.hxx" #include <SidebarTxtControlAcc.hxx> #include <SidebarTxtControl.hxx> #include <svl/brdcst.hxx> #include <toolkit/awt/vclxaccessiblecomponent.hxx> #include <editeng/unoedsrc.hxx> #include <editeng/unoforou.hxx> #include <editeng/unoviwou.hxx> #include <editeng/unoedhlp.hxx> #include <svx/AccessibleTextHelper.hxx> #include <editeng/outliner.hxx> namespace css = ::com::sun::star; namespace sw { namespace sidebarwindows { class SidebarTextEditSource : public SvxEditSource, public SfxBroadcaster { public: SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl ); virtual ~SidebarTextEditSource(); virtual SvxEditSource* Clone() const; virtual SvxTextForwarder* GetTextForwarder(); virtual SvxViewForwarder* GetViewForwarder(); virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False ); virtual void UpdateData(); virtual SfxBroadcaster& GetBroadcaster() const; DECL_LINK( NotifyHdl, EENotify* ); private: SidebarTxtControl& mrSidebarTxtControl; SvxOutlinerForwarder mTextForwarder; SvxDrawOutlinerViewForwarder mViewForwarder; }; SidebarTextEditSource::SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl ) : SvxEditSource() , mrSidebarTxtControl( rSidebarTxtControl ) , mTextForwarder( *(rSidebarTxtControl.GetTextView()->GetOutliner()), sal_False ) , mViewForwarder( *(rSidebarTxtControl.GetTextView()) ) {
} SidebarTextEditSource::~SidebarTextEditSource() { if ( mrSidebarTxtControl.GetTextView() ) { mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() ); } } SvxEditSource* SidebarTextEditSource::Clone() const { return new SidebarTextEditSource( mrSidebarTxtControl ); } SvxTextForwarder* SidebarTextEditSource::GetTextForwarder() { return &mTextForwarder; } SvxViewForwarder* SidebarTextEditSource::GetViewForwarder() { return &mViewForwarder; } SvxEditViewForwarder* SidebarTextEditSource::GetEditViewForwarder( sal_Bool ) { return &mViewForwarder; } void SidebarTextEditSource::UpdateData() { } SfxBroadcaster& SidebarTextEditSource::GetBroadcaster() const { return *( const_cast< SidebarTextEditSource* > (this) ); } IMPL_LINK(SidebarTextEditSource, NotifyHdl, EENotify*, pNotify) { if ( pNotify ) { ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( pNotify ) ); if( aHint.get() ) { Broadcast( *aHint.get() ); } } return 0; } class SidebarTxtControlAccessibleContext : public VCLXAccessibleComponent { public: explicit SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl ); virtual ~SidebarTxtControlAccessibleContext(); virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); using WeakAggComponentImplHelperBase::addEventListener; using WeakAggComponentImplHelperBase::removeEventListener; virtual void SAL_CALL addEventListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeEventListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener) throw (::com::sun::star::uno::RuntimeException); protected: virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); private: SidebarTxtControl& mrSidebarTxtControl; ::accessibility::AccessibleTextHelper* mpAccessibleTextHelper; ::vos::OMutex maMutex; void defunc(); }; SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl ) : VCLXAccessibleComponent( rSidebarTxtControl.GetWindowPeer() ) , mrSidebarTxtControl( rSidebarTxtControl ) , mpAccessibleTextHelper( 0 ) , maMutex() { ::std::auto_ptr<SvxEditSource> pEditSource( new SidebarTextEditSource( mrSidebarTxtControl ) ); mpAccessibleTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource ); mpAccessibleTextHelper->SetEventSource( mrSidebarTxtControl.GetWindowPeer() ); } SidebarTxtControlAccessibleContext::~SidebarTxtControlAccessibleContext() { defunc(); } void SidebarTxtControlAccessibleContext::defunc() { delete mpAccessibleTextHelper; mpAccessibleTextHelper = 0; } sal_Int32 SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException) { vos::OGuard aGuard( maMutex ); sal_Int32 nChildCount( 0 ); if ( mpAccessibleTextHelper ) { nChildCount = mpAccessibleTextHelper->GetChildCount(); } return nChildCount; } css::uno::Reference< css::accessibility::XAccessible > SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChild( sal_Int32 i ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ) { vos::OGuard aGuard( maMutex ); css::uno::Reference< css::accessibility::XAccessible > xChild; if ( mpAccessibleTextHelper ) { xChild = mpAccessibleTextHelper->GetChild( i ); } return xChild; } void SAL_CALL SidebarTxtControlAccessibleContext::addEventListener ( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener) throw (css::uno::RuntimeException) { vos::OGuard aGuard( maMutex ); if ( mpAccessibleTextHelper ) { mpAccessibleTextHelper->AddEventListener(xListener); } } void SAL_CALL SidebarTxtControlAccessibleContext::removeEventListener ( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener) throw (css::uno::RuntimeException) { vos::OGuard aGuard( maMutex ); if ( mpAccessibleTextHelper ) { mpAccessibleTextHelper->RemoveEventListener(xListener); } } void SidebarTxtControlAccessibleContext::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { if ( mpAccessibleTextHelper ) { switch ( rVclWindowEvent.GetId() ) { case VCLEVENT_OBJECT_DYING: { defunc(); } break; case VCLEVENT_WINDOW_GETFOCUS: case VCLEVENT_CONTROL_GETFOCUS: { mpAccessibleTextHelper->SetFocus( sal_True ); } break; case VCLEVENT_WINDOW_LOSEFOCUS: case VCLEVENT_CONTROL_LOSEFOCUS: { mpAccessibleTextHelper->SetFocus( sal_False ); } break; } } VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); } SidebarTxtControlAccessible::SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl ) : VCLXWindow() , mrSidebarTxtControl( rSidebarTxtControl ) { SetWindow( &mrSidebarTxtControl ); } SidebarTxtControlAccessible::~SidebarTxtControlAccessible() { } css::uno::Reference< css::accessibility::XAccessibleContext > SidebarTxtControlAccessible::CreateAccessibleContext() { SidebarTxtControlAccessibleContext* pAccContext( new SidebarTxtControlAccessibleContext( mrSidebarTxtControl ) ); css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext ); return xAcc; } } }
if ( mrSidebarTxtControl.GetTextView() ) { mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) ); }
if_condition
[]
C++
Operations/albaOpExporterAnsysCommon.cpp
IOR-BIC/ALBA
b574968b05d9a3a2756dd2ac61d015a0d20232a4
#include "albaDefines.h" #include "albaOpExporterAnsysCommon.h" #include "albaOpImporterAnsysCommon.h" #include "albaDecl.h" #include "albaGUI.h" #include "albaSmartPointer.h" #include "albaTagItem.h" #include "albaTagArray.h" #include "albaVME.h" #include "albaVMEMesh.h" #include "albaVMEMeshAnsysTextExporter.h" #include "albaAbsMatrixPipe.h" #include <iostream> #include <fstream> #include "vtkALBASmartPointer.h" #include "vtkUnstructuredGrid.h" #include "vtkCellArray.h" #include "vtkDoubleArray.h" #include "vtkIntArray.h" #include "vtkPointData.h" #include "vtkCellData.h" #include "vtkFieldData.h" #include "vtkTransform.h" #include "vtkTransformFilter.h" #include <vcl_string.h> #include <vcl_fstream.h> #include <vcl_sstream.h> #include <vcl_map.h> #include <vcl_vector.h> #include "wx/stdpaths.h" albaCxxAbstractTypeMacro(albaOpExporterAnsysCommon); albaOpExporterAnsysCommon::albaOpExporterAnsysCommon(const wxString &label) : albaOpExporterFEMCommon(label) { m_AnsysOutputFileNameFullPath = ""; } albaOpExporterAnsysCommon::~albaOpExporterAnsysCommon() { } void albaOpExporterAnsysCommon::OpRun() { Init(); CreateGui(); } void albaOpExporterAnsysCommon::OnOK() { albaString wildcard = GetWildcard(); m_AnsysOutputFileNameFullPath = ""; wxString f; f = albaGetSaveFile("",wildcard).c_str(); if(!f.IsEmpty()) { m_AnsysOutputFileNameFullPath = f; Write(); } } void albaOpExporterAnsysCommon::OpStop(int result) { HideGui(); albaEventMacro(albaEvent(this,result)); } void albaOpExporterAnsysCommon::Init() { albaVMEMesh *input = albaVMEMesh::SafeDownCast(m_Input); assert(input); vtkUnstructuredGrid *inputUGrid = input->GetUnstructuredGridOutput()->GetUnstructuredGridData(); if(inputUGrid != NULL) { m_TotalElements = inputUGrid->GetNumberOfPoints(); m_TotalElements += inputUGrid->GetNumberOfCells(); vtkDataArray *materialsIDArray = NULL; materialsIDArray = inputUGrid->GetCellData()->GetArray("EX"); if (materialsIDArray != NULL) { m_TotalElements += materialsIDArray->GetNumberOfTuples(); } } } int albaOpExporterAnsysCommon::compareElem(const void *p1, const void *p2) { ExportElement *a, *b; a = (ExportElement *)p1; b = (ExportElement *)p2; double result; result = a->elementType - b->elementType; if (result < 0) return -1; else if (result > 0) return 1; else { result = a->matID - b->matID; if (result < 0) return -1; else if (result > 0) return 1; else { result = a->elementID - b->elementID; if (result < 0) return -1; else if (result > 0) return 1; else assert(0); } } } ExportElement *albaOpExporterAnsysCommon::CreateExportElements(albaVMEMesh * input, int rowsNumber, vtkUnstructuredGrid * inputUGrid, FILE * file) { vtkIntArray *elementIdArray = input->GetElementsIDArray(); vtkIntArray *nodesIDArray = input->GetNodesIDArray(); vtkIntArray *typeArray = input->GetElementsTypeArray(); vtkIntArray *realArray = input->GetElementsRealArray(); ExportElement *exportVector = new ExportElement[rowsNumber]; int currType=-1; for (int rowID = 0 ; rowID < rowsNumber ; rowID++) { exportVector[rowID].elementID = elementIdArray ? elementIdArray->GetValue(rowID) : rowID+1; exportVector[rowID].matID = GetMatIdArray() ? GetMatIdArray()[rowID] : 1; exportVector[rowID].elementType = typeArray ? typeArray->GetValue(rowID) : 1; exportVector[rowID].elementReal = realArray ? realArray->GetValue(rowID) : 1; exportVector[rowID].cellID=rowID; } qsort(exportVector, rowsNumber, sizeof(ExportElement), compareElem); for (int rowID = 0 ; rowID < rowsNumber ; rowID++) { if(currType != exportVector[rowID].elementType) { int mode; vtkCell *currentCell = inputUGrid->GetCell(exportVector[rowID].cellID); vtkIdList *idList = currentCell->GetPointIds(); int cellNpoints=currentCell->GetNumberOfPoints(); switch (cellNpoints) { case 4: mode = 285; break; case 8: mode = 45; break; case 10: mode = 187; break; case 20: mode = 186; break; default: mode = -1; break; } currType = exportVector[rowID].elementType; fprintf(file,"ET,%d,%d\n", currType, mode); } } return exportVector; }
#include "albaDefines.h" #include "albaOpExporterAnsysCommon.h" #include "albaOpImporterAnsysCommon.h" #include "albaDecl.h" #include "albaGUI.h" #include "albaSmartPointer.h" #include "albaTagItem.h" #include "albaTagArray.h" #include "albaVME.h" #include "albaVMEMesh.h" #include "albaVMEMeshAnsysTextExporter.h" #include "albaAbsMatrixPipe.h" #include <iostream> #include <fstream> #include "vtkALBASmartPointer.h" #include "vtkUnstructuredGrid.h" #include "vtkCellArray.h" #include "vtkDoubleArray.h" #include "vtkIntArray.h" #include "vtkPointData.h" #include "vtkCellData.h" #include "vtkFieldData.h" #include "vtkTransform.h" #include "vtkTransformFilter.h" #include <vcl_string.h> #include <vcl_fstream.h> #include <vcl_sstream.h> #include <vcl_map.h> #include <vcl_vector.h> #include "wx/stdpaths.h" albaCxxAbstractTypeMacro(albaOpExporterAnsysCommon); albaOpExporterAnsysCommon::albaOpExporterAnsysCommon(const wxString &label) : albaOpExporterFEMCommon(label) { m_AnsysOutputFileNameFullPath = ""; } albaOpExporterAnsysCommon::~albaOpExporterAnsysCommon() { } void albaOpExporterAnsysCommon::OpRun() { Init(); CreateGui(); } void albaOpExporterAnsysCommon::OnOK() { albaString wildcard = GetWildcard(); m_AnsysOutputFileNameFullPath = ""; wxString f; f = albaGetSaveFile("",wildcard).c_str(); if(!f.IsEmpty()) { m_AnsysOutputFileNameFullPath = f; Write(); } } void albaOpExporterAnsysCommon::OpStop(int result) { HideGui(); albaEventMacro(albaEvent(this,result)); } void albaOpExporterAnsysCommon::Init() { albaVMEMesh *input = albaVMEMesh::SafeDownCast(m_Input); assert(input); vtkUnstructuredGrid *inputUGrid = input->GetUnstructuredGridOutput()->GetUnstructuredGridData(); if(inputUGrid != NULL) { m_TotalElements = inputUGrid->GetNumberOfPoints(); m_TotalElements += inputUGrid->GetNumberOfCells(); vtkDataArray *materialsIDArray = NULL; materialsIDArray = inputUGrid->GetCellData()->GetArray("EX"); if (materialsIDArray != NULL) { m_TotalElements += materialsIDArray->GetNumberOfTuples(); } } } int albaOpExporterAnsysCommon::compareElem(const void *p1, const void *p2) { ExportElement *a, *b; a = (ExportElement *)p1; b = (ExportElement *)p2; double result; result = a->elementType - b->elementType; if (result < 0) return -1; else if (result > 0) return 1; else { result = a->matID - b->matID;
} } ExportElement *albaOpExporterAnsysCommon::CreateExportElements(albaVMEMesh * input, int rowsNumber, vtkUnstructuredGrid * inputUGrid, FILE * file) { vtkIntArray *elementIdArray = input->GetElementsIDArray(); vtkIntArray *nodesIDArray = input->GetNodesIDArray(); vtkIntArray *typeArray = input->GetElementsTypeArray(); vtkIntArray *realArray = input->GetElementsRealArray(); ExportElement *exportVector = new ExportElement[rowsNumber]; int currType=-1; for (int rowID = 0 ; rowID < rowsNumber ; rowID++) { exportVector[rowID].elementID = elementIdArray ? elementIdArray->GetValue(rowID) : rowID+1; exportVector[rowID].matID = GetMatIdArray() ? GetMatIdArray()[rowID] : 1; exportVector[rowID].elementType = typeArray ? typeArray->GetValue(rowID) : 1; exportVector[rowID].elementReal = realArray ? realArray->GetValue(rowID) : 1; exportVector[rowID].cellID=rowID; } qsort(exportVector, rowsNumber, sizeof(ExportElement), compareElem); for (int rowID = 0 ; rowID < rowsNumber ; rowID++) { if(currType != exportVector[rowID].elementType) { int mode; vtkCell *currentCell = inputUGrid->GetCell(exportVector[rowID].cellID); vtkIdList *idList = currentCell->GetPointIds(); int cellNpoints=currentCell->GetNumberOfPoints(); switch (cellNpoints) { case 4: mode = 285; break; case 8: mode = 45; break; case 10: mode = 187; break; case 20: mode = 186; break; default: mode = -1; break; } currType = exportVector[rowID].elementType; fprintf(file,"ET,%d,%d\n", currType, mode); } } return exportVector; }
if (result < 0) return -1; else if (result > 0) return 1; else { result = a->elementID - b->elementID; if (result < 0) return -1; else if (result > 0) return 1; else assert(0); }
if_condition
[ { "content": " function is of type void *, and returns NULL.\n\n Otherwise the type is void which is correct for WIN32\n\n and SPROC\n\n*/ \n\n#ifdef CMAKE_USE_SPROC_INIT\n\ntypedef int mmuThreadProcessIDType;\n\n#endif\n\n\n\n\n\n#ifdef CMAKE_USE_PTHREADS_INIT\n\ntypedef void *(*mmuInternalThreadFunctionType)(void *);\n\ntypedef pthread_t mmuThreadProcessIDType;\n\n#endif\n\n\n\n#ifdef CMAKE_USE_WIN32_THREADS_INIT\n\ntypedef LPTHREAD_START_ROUTINE mmuInternalThreadFunctionType;\n\ntypedef HANDLE mmuThreadProcessIDType;\n\n#endif\n\n\n\n#if !defined(CMAKE_USE_PTHREADS_INIT) && !defined(CMAKE_USE_WIN32_THREADS_INIT)\n\ntypedef void (*mmuInternalThreadFunctionType)(void *);\n\ntypedef int mmuThreadProcessIDType;\n\n#endif\n\n\n\n\n", "file_path": "Base/albaMultiThreader.h", "rank": 0, "score": 233669.75963329288 }, { "content": " def __init__(self):\n\n AbstractRule.__init__(self)\n", "file_path": "qa/Rules/ClassStructureRules/UselessIncludesRule.py", "rank": 1, "score": 98174.05697326675 }, { "content": "static GLboolean _glewInit_GL_ARB_shading_language_include (GLEW_CONTEXT_ARG_DEF_INIT)\n\n{\n\n GLboolean r = GL_FALSE;\n\n\n\n r = ((glCompileShaderIncludeARB = (PFNGLCOMPILESHADERINCLUDEARBPROC)glewGetProcAddress((const GLubyte*)\"glCompileShaderIncludeARB\")) == NULL) || r;\n\n r = ((glDeleteNamedStringARB = (PFNGLDELETENAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glDeleteNamedStringARB\")) == NULL) || r;\n\n r = ((glGetNamedStringARB = (PFNGLGETNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedStringARB\")) == NULL) || r;\n\n r = ((glGetNamedStringivARB = (PFNGLGETNAMEDSTRINGIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedStringivARB\")) == NULL) || r;\n\n r = ((glIsNamedStringARB = (PFNGLISNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glIsNamedStringARB\")) == NULL) || r;\n\n r = ((glNamedStringARB = (PFNGLNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glNamedStringARB\")) == NULL) || r;\n\n\n\n return r;\n", "file_path": "GPUAPI/GLEW/glew.c", "rank": 2, "score": 98174.05697326675 }, { "content": "//----------------------------------------------------------------------------\n\n// Constants :\n\n//----------------------------------------------------------------------------\n\nenum LABEL_EXTRACTOR_WIDGET_ID\n\n{\n\n\tID_LABEL = MINID,\t\n\n ID_SMOOTH,\n\n ID_RADIUS_FACTOR,\n\n ID_STD_DEVIATION,\n\n ID_SAMPLING_RATE,\n\n ID_RADIUS_FACTOR_AFTER,\n\n ID_STD_DEVIATION_AFTER,\n\n ID_LABELS,\n\n\tID_NAME,\n\n};\n\n\n\n//-----------------------------------------------------------------------\n\nbool albaOpLabelExtractor::RetrieveTag()\n\n//----------------------------------------------------------------------\n\n{ \n\n bool tagPresent = m_Input->GetTagArray()->IsTagPresent(\"LABELS\");\n\n if (tagPresent)\n\n {\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 3, "score": 71588.89098228574 }, { "content": "//----------------------------------------------------------------------------\n\n// forward references :\n\n//----------------------------------------------------------------------------\n\nclass albaVMELabeledVolume;\n", "file_path": "Operations/albaOpCreateLabeledVolume.h", "rank": 4, "score": 71588.89098228574 }, { "content": "class albaResultQueryAbstractHandlerSample : public albaResultQueryAbstractHandler\n\n{\n\npublic:\n\n /** constructor */\n\n albaResultQueryAbstractHandlerSample();\n\n /** destructor */\n\n virtual ~albaResultQueryAbstractHandlerSample(){}; \n\n\n\n /** RTTI macro */\n\n albaTypeMacro(albaResultQueryAbstractHandlerSample, albaResultQueryAbstractHandler);\n\n\n\n /** load result of Query */\n\n /*virtual void*/ void LoadQueryResult();\n\n\n\n /** load result of Query */\n\n /*virtual*/ bool IsFailed();\n\n\n\n};\n\n\n\n//----------------------------------------------------------------------------\n", "file_path": "Testing/Common/albaResultQueryAbstractHandlerTest.cpp", "rank": 5, "score": 69280.813882646 }, { "content": " class name: albaResultQueryAbstractHandler\n\n Interface for handle results from a query to a database\n\n*/\n", "file_path": "Common/albaResultQueryAbstractHandler.h", "rank": 6, "score": 69056.61987154378 }, { "content": "class name albaOpCreateLabeledVolume\n\nCreate a albaVMELabeledVolume.\n\n*/\n", "file_path": "Operations/albaOpCreateLabeledVolume.h", "rank": 7, "score": 69007.30752109902 }, { "content": "class ALBA_EXPORT albaVMELabeledVolume : public albaVME\n\n{\n\npublic:\t\n\n\n\n\talbaTypeMacro(albaVMELabeledVolume,albaVME);\n\n\n\n /** Return the value of the label. */\n\n int GetLabelValue( wxString &item ); \n\n\n\n /** Set a tag with the label values. */\n\n void SetLabelTag(albaString label, int component);\n\n\n\n /** Remove a tag. */\n\n void RemoveLabelTag(int component);\n\n\n\n /** Return true if the data associated with the VME is present and updated at the current time.*/\n\n /*virtual*/ bool IsDataAvailable();\n\n\n\n /** Fill the vector of label. */\n\n void FillLabelVector(wxString name, bool checked = TRUE);\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 8, "score": 66605.43366045295 }, { "content": "class ALBA_EXPORT albaOpLabelizeSurface: public albaOp\n\n{\n\npublic:\n\n\talbaOpLabelizeSurface(const wxString &label = \"Labelize Surface\");\n\n\t~albaOpLabelizeSurface(); \n\n\tvirtual void OnEvent(albaEventBase *alba_event);\n\n\n\n\talbaTypeMacro(albaOpLabelizeSurface, albaOp);\n\n\n\n\talbaOp* Copy();\n\n\n\n\tbool Accept(albaVME*node); \n\n\tvoid OpRun();\n\n\tvoid OpDo();\n\n\tvoid OpUndo();\n\n\n\n\tenum GIZMO_TYPE\n\n\t{\n\n\t\tGIZMO_TRANSLATE = 0,\n\n\t\tGIZMO_ROTATE,\n", "file_path": "Operations/albaOpLabelizeSurface.h", "rank": 9, "score": 66605.43366045295 }, { "content": "class ALBA_EXPORT albaOpLabelExtractor: public albaOp\n\n{\n\npublic:\n\n albaOpLabelExtractor(const wxString& label = \"LabelExtractor\");\n\n ~albaOpLabelExtractor(); \n\n\n\n albaTypeMacro(albaOpLabelExtractor, albaOp);\n\n\n\n\n\n\tvirtual void OnEvent(albaEventBase *alba_event);\n\n albaOp* Copy();\n\n\n\n bool Accept(albaVME *vme);\n\n void OpRun();\n\n\n\n /** If labels tags are present retrieve them. */\n\n bool RetrieveTag();\n\n\n\n /** Fill the vector of label. */\n\n void FillLabelVector(wxString name, bool checked = TRUE);\n", "file_path": "Operations/albaOpLabelExtractor.h", "rank": 10, "score": 66605.43366045295 }, { "content": "class ALBA_EXPORT albaVMEOutputNULL : public albaVMEOutput\n\n{\n\npublic:\n\n albaTypeMacro(albaVMEOutputNULL,albaVMEOutput)\n\n\n\n#ifdef ALBA_USE_VTK\n\n /**\n\n Return a VTK dataset corresponding to the current time. This is\n\n the output of the DataPipe currently attached to the VME.\n\n Usually the output is a \"smart copy\" of one of the dataset in \n\n the DataArray. In some cases it can be NULL, e.g. in case the number\n\n of stored Items is 0. Also special VME could not support VTK dataset output.\n\n An event is rised when the output data changes to allow attached classes to \n\n update their input.*/\n\n virtual vtkDataSet *GetVTKData() {return NULL;}\n\n#endif\n\n\n\n /**\n\n Update all the output data structures (data, bounds, matrix and abs matrix).*/\n\n virtual void Update() {}\n", "file_path": "Core/albaVMEOutputNULL.h", "rank": 11, "score": 65516.8583361979 }, { "content": "class albaVMEOutputNULLTest : public albaTest\n\n{\n\npublic: \n\n\n\n // CPPUNIT test suite\n\n CPPUNIT_TEST_SUITE( albaVMEOutputNULLTest );\n\n CPPUNIT_TEST(TestFixture); // just to test that the fixture has no leaks\n\n CPPUNIT_TEST(TestDynamicAllocation);\n\n CPPUNIT_TEST(TestGetVTKData);\n\n\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\nprivate:\n\n void TestFixture();\n\n void TestDynamicAllocation();\n\n void TestGetVTKData();\n\n\n\n bool result;\n\n};\n\n\n\n#endif\n", "file_path": "Testing/Core/albaVMEOutputNULLTest.h", "rank": 12, "score": 65516.8583361979 }, { "content": "class name: albaResultQueryAbstractHandlerTest\n\n Test class for albaResultQueryAbstractHandler\n\n*/\n", "file_path": "Testing/Common/albaResultQueryAbstractHandlerTest.h", "rank": 13, "score": 65512.905921635844 }, { "content": "class albaOpLabelizeSurfaceTest : public albaTest\n\n{\n\n\tCPPUNIT_TEST_SUITE( albaOpLabelizeSurfaceTest );\n\n\tCPPUNIT_TEST( Test );\n\n\tCPPUNIT_TEST_SUITE_END();\n\n\n\nprotected:\n\n\tvoid Test();\n\n};\n\n\n\n#endif\n", "file_path": "Testing/Operations/albaOpLabelizeSurfaceTest.h", "rank": 14, "score": 65466.12408694033 }, { "content": "class albaVMELabeledVolumeTest : public albaTest\n\n{\n\npublic:\n\n\n\n\tCPPUNIT_TEST_SUITE( albaVMELabeledVolumeTest );\n\n CPPUNIT_TEST( TestDynamicAllocation );\n\n CPPUNIT_TEST( TestVolumeCopy );\n\n\tCPPUNIT_TEST( TestGenerateLabeledVolume );\n\n CPPUNIT_TEST( TestRemoveLabelTag );\n\n CPPUNIT_TEST( TestSetLabelTag );\n\n\tCPPUNIT_TEST( TestDeepCopy );\n\n\tCPPUNIT_TEST_SUITE_END();\n\n\n\nprotected:\n\n void TestFixture();\n\n void TestDynamicAllocation();\n\n\tvoid TestVolumeCopy();\n\n\tvoid TestGenerateLabeledVolume();\n\n void TestRemoveLabelTag();\n\n void TestSetLabelTag();\n\n void TestDeepCopy();\n\n};\n\n\n\n#endif\n", "file_path": "Testing/VME/albaVMELabeledVolumeTest.h", "rank": 15, "score": 65466.12408694033 }, { "content": "class albaOpLabelExtractorTest : public albaTest\n\n{\n\npublic:\n\n\n\n\tCPPUNIT_TEST_SUITE( albaOpLabelExtractorTest );\n\n CPPUNIT_TEST( TestDynamicAllocation );\n\n CPPUNIT_TEST( TestLabelRG );\n\n CPPUNIT_TEST( TestLabelSP );\n\n CPPUNIT_TEST( TestLabelSmoothRG );\n\n CPPUNIT_TEST( TestLabelSmoothSP );\n\n\tCPPUNIT_TEST_SUITE_END();\n\n\n\nprotected:\n\n void TestFixture();\n\n void TestDynamicAllocation();\n\n\tvoid TestLabelRG();\n\n void TestLabelSP();\n\n void TestLabelSmoothRG();\n\n void TestLabelSmoothSP();\n\n};\n\n\n\n#endif\n", "file_path": "Testing/Operations/albaOpLabelExtractorTest.h", "rank": 16, "score": 65466.12408694033 }, { "content": "class UselessIncludesRule(AbstractRule):\n\n def __init__(self):\n\n AbstractRule.__init__(self)\n\n self.DictionaryList = []\n\n\n\n def execute(self):\n\n self.dom = xd.parse(self.FullPathInputFile)\n\n className = self.dom.getElementsByTagName('compounddef')[0].getElementsByTagName('compoundname')[0].firstChild.nodeValue\n\n baseClassName = \"\"\n\n try:\n\n baseClassName = self.dom.getElementsByTagName('compounddef')[0].getElementsByTagName('basecompoundref')[0].firstChild.nodeValue\n\n try:\n\n baseClassName = baseClassName[baseClassName.index(\"::\")+2:]\n\n except:\n\n pass\n\n except:\n\n pass\n\n refInclude = \"\" \n\n try: \n\n refInclude = self.dom.getElementsByTagName('compounddef')[0].getElementsByTagName('includes')[0].attributes[\"refid\"].value\n\n except:\n\n pass\n\n \n\n f = open(\"./Rules/ClassStructureRules/\" + self.ParameterList[0], 'r')\n\n lines = f.readlines()\n\n for line in lines:\n\n self.DictionaryList.append(line.replace(\"\\n\",\"\").replace(\"\\r\",\"\"))\n\n \n\n directory = os.path.dirname(self.FullPathInputFile)\n\n \n\n classToIcludeList = []\n\n if(refInclude != \"\"):\n\n xmlFile = os.path.join(directory, refInclude + \".xml\")\n\n extDom = xd.parse(xmlFile)\n\n includeList = extDom.getElementsByTagName('compounddef')[0].getElementsByTagName('includes')\n\n classToIcludeList = [i.firstChild.nodeValue.split('.')[0] for i in includeList]\n\n \n\n #print len(classToIcludeList)\n\n dict = {}\n\n for item in classToIcludeList:\n\n dict[item] = False\n\n #print className, item\n\n if(item == baseClassName or (item + \".h\") in self.DictionaryList):\n\n dict[item] = True\n\n #print item , self.DictionaryList\n\n continue\n\n \n\n members = self.dom.getElementsByTagName('memberdef')\n\n for member in members:\n\n attrs = member.attributes\n\n if(attrs[\"kind\"].value == \"variable\"):\n\n #check type\n\n typeVariable = None\n\n try:\n\n typeVariable = member.getElementsByTagName('definition')[0].firstChild.nodeValue\n\n except:\n\n pass\n\n #check\n\n if(typeVariable != None and item in typeVariable and not((item + \"*\") in typeVariable) and not((item + \" *\") in typeVariable)):\n\n #include correct! exit from for loop\n\n dict[item] = True\n\n continue\n\n else:\n\n pass\n\n elif(attrs.has_key(\"inline\") and attrs[\"inline\"].value == \"yes\"):\n\n returnValue = \"\"\n\n params = \"\"\n\n try:\n\n definition = member.getElementsByTagName('definition')[0].firstChild.nodeValue\n\n except:\n\n pass\n\n try:\n\n params = member.getElementsByTagName('argsstring')[0].firstChild.nodeValue\n\n except:\n\n pass \n\n\n\n if(definition != None and params != None and item in definition or item in params):\n\n dict[item] = True\n\n continue\n\n else:\n\n pass\n\n # search all the member which are not pointers\n\n # search inline functions in which there is the class\n\n \n\n for i in dict.keys():\n\n if(dict[i] == False):\n\n self.MarkedList.append(\"<item>\\n\"\\\n\n + \" <class>\" + str(className) + \"</class>\\n\"\\\n\n + \" <include>\" + i + \".h</include>\\n\"\\\n\n + \"</item>\")\n", "file_path": "qa/Rules/ClassStructureRules/UselessIncludesRule.py", "rank": 17, "score": 64416.57700221175 }, { "content": "class ALBA_EXPORT albaResultQueryAbstractHandler : public albaObject\n\n{\n\npublic:\n\n /** constructor */\n\n albaResultQueryAbstractHandler();\n\n /** destructor */\n\n\tvirtual ~albaResultQueryAbstractHandler(); \n\n \n\n /** RTTI macro */\n\n albaAbstractTypeMacro(albaResultQueryAbstractHandler, albaObject);\n\n\n\n /**Get result as string matrix */\n\n WebRowSetStringDataTable GetResultAsStringMatrix() {return m_MatrixStringResult;};\n\n \n\n /** Get column type as list of string */\n\n WebRowSetColumnTypeVector GetColumnsTypeInformationAsStringVector() {return m_ColumnsTypeInformation;};\n\n\n\n /** Get column name as list of string */\n\n WebRowSetColumnNameVector GetColumnsNameInformationAsStringVector() {return m_ColumnsNameInformation;};\n\n\n", "file_path": "Common/albaResultQueryAbstractHandler.h", "rank": 18, "score": 64411.13067912922 }, { "content": "class albaOpExporterAnsysInputFileTest;\n\n\n", "file_path": "Testing/Operations/albaOpExporterAnsysInputFileTest.h", "rank": 19, "score": 64403.16331999959 }, { "content": "class albaOpImporterAnsysInputFileTest;\n\n\n", "file_path": "Testing/Operations/albaOpImporterAnsysInputFileTest.h", "rank": 20, "score": 64403.16331999959 }, { "content": "class ALBA_EXPORT albaOpCreateLabeledVolume: public albaOp\n\n{\n\npublic:\n\n /** constructor */\n\n albaOpCreateLabeledVolume(const wxString &label = \"Create Labeled Volume\");\n\n /** destructor */\n\n ~albaOpCreateLabeledVolume(); \n\n\n\n /** RTTI macro */\n\n albaTypeMacro(albaOpCreateLabeledVolume, albaOp);\n\n\n\n /** Return a copy of itself, this needs to put the operation into the undo stack. */\n\n /*virtual*/ albaOp* Copy();\n\n\n\n /** Return true for the acceptable vme type. */\n\n /*virtual*/ bool Accept(albaVME*node);\n\n\n\n /** Builds operation's interface. */\n\n /*virtual*/ void OpRun();\n\n \n\n /** Execute the operation. */\n\n /*virtual*/ void OpDo();\n\n\n\nprotected: \n\n albaVMELabeledVolume *m_LabeledVolume;\n\n};\n\n#endif\n", "file_path": "Operations/albaOpCreateLabeledVolume.h", "rank": 21, "score": 64365.135606469994 }, { "content": " \n\nprotected:\n\n albaVMEOutputNULL(); // to be allocated with New()\n\n virtual ~albaVMEOutputNULL(); // to be deleted with Delete()\n\n\n\nprivate:\n\n albaVMEOutputNULL(const albaVMEOutputNULL&); // Not implemented\n\n void operator=(const albaVMEOutputNULL&); // Not implemented\n\n};\n\n\n\n#endif\n", "file_path": "Core/albaVMEOutputNULL.h", "rank": 22, "score": 63851.60346039491 }, { "content": "/*=========================================================================\n\n\n\n Program: ALBA (Agile Library for Biomedical Applications)\n\n Module: albaVMEOutputNULL\n\n Authors: Marco Petrone\n\n \n\n Copyright (c) BIC\n\n All rights reserved. See Copyright.txt or\n\n\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n#ifndef __albaVMEOutputNULL_h\n\n#define __albaVMEOutputNULL_h\n\n//----------------------------------------------------------------------------\n\n// includes :\n\n//----------------------------------------------------------------------------\n\n#include \"albaVMEOutput.h\"\n\n//----------------------------------------------------------------------------\n\n// forward declarations :\n\n//----------------------------------------------------------------------------\n", "file_path": "Core/albaVMEOutputNULL.h", "rank": 23, "score": 63851.17127420086 }, { "content": " void CreateOpDialog();\n\n\n\n /** Remove operation's interface. */\n\n void DeleteOpDialog();\n\n\n\n /** Enable/disable VME widgets.*/\n\n void EnableWidgets(bool enable = true);\n\n\n\n /** Create the pipeline to generate the slice of the volume. */\n\n void CreateSlicePipeline();\n\n\n\n /** Re-slice the volume according to the new coordinate value. */\n\n void UpdateSlice(); \n\n\n\n /** This method returns the min value from the label used as input. */\n\n int GetMin( wxString &item );\n\n\n\n /** This method returns the max value from the label used as input. */\n\n int GetMax( wxString &item );\n\n};\n\n#endif\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 24, "score": 63814.80947917252 }, { "content": "\t\tGIZMO_SCALE,\n\n\t};\n\n\n\n\tvoid SetLutEditor(vtkLookupTable *lut);\n\n\tvoid SetLabelValue(double val){m_LabelValue=val;};\n\n\tvoid SetPlaneDimension(double w,double h);\n\n\tvoid Labelize();\n\n\n\n\tvirtual void OpStop(int result);\n\nprotected: \n\n\n\n\t/** Create the GUI */\n\n\tvoid CreateGui();\n\n\n\n\tvoid ShowClipPlane(bool show);\n\n\tvoid CreateGizmos();\n\n\tvoid AttachInteraction();\n\n\tvoid UpdateISARefSys();\n\n\tvoid Undo();\n\n\n", "file_path": "Operations/albaOpLabelizeSurface.h", "rank": 25, "score": 63813.765991253546 }, { "content": "\n\n /** Modify the vector of label. */\n\n void ModifyLabelVector(int n, wxString name, bool checked);\n\n\n\n /** Remove an item of the vector of label. */\n\n void RemoveItemLabelVector(int n);\n\n\n\n /** Precess events coming from other objects */ \n\n virtual void OnEvent(albaEventBase *alba_event);\n\n\n\n /** Copy the contents of another VMELabeled into this one. */\n\n int DeepCopy(albaVME *a);\n\n\n\n /** Compare with another VMELabeled. */\n\n bool Equals(albaVME *vme);\n\n\n\n /**\n\n Set the Pose matrix of the VME. This function modifies the MatrixVector. You can\n\n set or get the Pose for a specified time. When setting, if the time does not exist\n\n the MatrixVector creates a new KeyMatrix on the fly. When getting, the matrix vector\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 26, "score": 63809.29350602715 }, { "content": " interpolates on the fly according to the matrix interpolator.*/\n\n virtual void SetMatrix(const albaMatrix &mat);\n\n\n\n /**\n\n Return the list of timestamps for this VME. Timestamps list is \n\n obtained merging timestamps for matrixes and VME items*/\n\n virtual void GetLocalTimeStamps(std::vector<albaTimeStamp> &kframes);\n\n\n\n /** Update the VME with the scalar values of the labels. */\n\n virtual void GenerateLabeledVolume();\n\n\n\n /** Set the Link */\n\n void SetVolumeLink(albaVME *n);\n\n\n\n /** Return the Link */\n\n albaVME *GetVolumeLink();\n\n\n\n /** return material attribute of this surface if present */\n\n mmaVolumeMaterial *GetMaterial();\n\n\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 27, "score": 63807.70732745834 }, { "content": "\talbaInteractorGenericMouse\t\t *m_IsaLabelizeWithoutGizmo;\n\n\n\n\tint\t\tm_LabelInside;\n\n\n\n\tbool\tm_PlaneCreated;\n\n\n\n\tdouble m_PlaneWidth;\n\n\tdouble m_PlaneHeight;\n\n\tdouble m_LabelValue;\n\n\n\n\tint\t\tm_GizmoType;\n\n\tint m_UseGizmo;\n\n\n\n\talbaVMESurface\t\t\t\t*m_InputSurface;\n\n\talbaVMESurfaceEditor *m_VmeEditor;\n\n\n\n\talbaVMEGizmo\t\t\t\t*m_ImplicitPlaneGizmo;\n\n\tvtkPlane\t\t\t\t\t*m_ClipperPlane;\n\n\tvtkPlaneSource\t\t*m_PlaneSource;\n\n\tvtkArrowSource\t\t*m_ArrowShape;\n", "file_path": "Operations/albaOpLabelizeSurface.h", "rank": 28, "score": 63807.11191271987 }, { "content": "\n\n // Set the label value\n\n void SetLabel(double labelValue);\n\n\n\n //Set if smooth mode is true\n\n void SmoothMode(bool smoothMode);\n\n\n\n // Create a VMESurface draw from a Volume\n\n\tvoid ExtractLabel();\n\n\n\nprotected: \n\n\n\n /** Get the dataset from linked node. */\n\n void UpdateDataLabel();\n\n\n\n /** Generate the volume depending on the labels selected. */\n\n void GenerateLabeledVolume();\n\n\n\n std::vector<wxString> m_LabelNameVector;\n\n std::vector<bool> m_CheckedVector;\n", "file_path": "Operations/albaOpLabelExtractor.h", "rank": 29, "score": 63804.5830173279 }, { "content": " \n\n wxSlider *m_MinSlider;\n\n wxSlider *m_MaxSlider;\n\n\n\n wxTextCtrl *m_LabelNameCtrl;\n\n wxTextCtrl *m_LabelValueCtrl; \n\n\n\n int m_MinAbsolute, m_MaxAbsolute;\t\n\n int m_Min , m_Max;\n\n int m_MinMin, m_MaxMin;\n\n int m_MinMax, m_MaxMax;\t\n\n int m_MinValue ,m_MaxValue;\n\n\n\n int m_CheckListId;\n\n int m_ItemSelected;\n\n int m_LabelIntValue;\n\n\n\n bool m_CheckMax, m_CheckMin;\n\n bool m_EditMode;\n\n bool m_DataCopied;\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 30, "score": 63803.622465402594 }, { "content": "\n\n /** This method updates the look-up table. */\n\n void UpdateLookUpTable();\n\n\n\n /** If labels tags are present retrieve them. */\n\n void RetrieveTag();\n\n\n\n void CopyDataset();\n\n\n\n /** Updates the tags and the items of the checkBox and call the InternalPreUpadate. */\n\n void UpdateLabel();\n\n\n\n /** update the output data structure */\n\n void InternalPreUpdate();\n\n\n\n\n\n /** Copy the scalars of the VME linked. */\n\n void UpdateScalars();\n\n \n\n /** Builds operation's interface and visualization pipeline. */\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 31, "score": 63802.866832275344 }, { "content": "/*=========================================================================\n\n\n\n Program: ALBA (Agile Library for Biomedical Applications)\n\n Module: albaVMELabeledVolume\n\n Authors: Roberto Mucci\n\n \n\n Copyright (c) BIC\n\n All rights reserved. See Copyright.txt or\n\n\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n \n\n#ifndef __albaVMELabeledVolume_h\n\n#define __albaVMELabeledVolume_h\n\n\n\n//----------------------------------------------------------------------------\n\n// Include:\n\n//----------------------------------------------------------------------------\n\n#include \"albaDefines.h\"\n\n#include \"albaVME.h\"\n\n\n\n//----------------------------------------------------------------------------\n\n// forward references :\n\n//----------------------------------------------------------------------------\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 32, "score": 63802.55335218411 }, { "content": "/*=========================================================================\n\n\n\n Program: ALBA (Agile Library for Biomedical Applications)\n\n Module: albaOpLabelizeSurface\n\n Authors: Matteo Giacomoni\n\n \n\n Copyright (c) BIC\n\n All rights reserved. See Copyright.txt or\n\n\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef __albaOpLabelizeSurface_H__\n\n#define __albaOpLabelizeSurface_H__\n\n\n\n//----------------------------------------------------------------------------\n\n// Include :\n\n//----------------------------------------------------------------------------\n\n#include \"albaDefines.h\"\n\n#include \"albaOp.h\"\n\n\n\n//----------------------------------------------------------------------------\n\n// forward references :\n\n//----------------------------------------------------------------------------\n", "file_path": "Operations/albaOpLabelizeSurface.h", "rank": 33, "score": 63802.45875807205 }, { "content": "\n\n\tdouble m_ValLabel;\n\n int m_SmoothVolume;\n\n float m_RadiusFactor;\n\n float m_StdDev[3];\n\n float m_RadiusFactorAfter;\n\n float m_StdDevAfter[3];\n\n int m_SamplingRate[3];\n\n\twxString m_SurfaceName;\n\n\n\n vtkImageData *m_OutputData;\n\n vtkDataSet *m_Ds;\n\n\talbaVMESurface *m_Vme;\n\n albaGUICheckListBox *m_LabelCheckBox;\n\n albaTagItem *m_TagLabel;\n\n\n\n};\n\n#endif\n", "file_path": "Operations/albaOpLabelExtractor.h", "rank": 34, "score": 63801.88439673765 }, { "content": " ID_DECREASE_SLICE,\n\n ID_OK,\n\n ID_CANCEL,\n\n ID_D_LABEL_NAME,\n\n ID_D_LABEL_VALUE,\n\n ID_D_MIN,\n\n ID_D_MAX,\n\n ID_SLIDER_MIN,\n\n ID_SLIDER_MAX,\n\n ID_LAST,\n\n };\n\n\n\n albaVMELabeledVolume();\n\n virtual ~albaVMELabeledVolume(); \n\n\n\n virtual int InternalStore(albaStorageElement *parent);\n\n virtual int InternalRestore(albaStorageElement *node);\n\n\n\n /** Internally used to create a new instance of the GUI.*/\n\n virtual albaGUI *CreateGui();\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 35, "score": 63801.71145661508 }, { "content": " /** return icon */\n\n static char** GetIcon();\n\n\n\n /** Return the suggested pipe-typename for the visualization of this vme */\n\n virtual albaString GetVisualPipe() {return albaString(\"albaPipeBox\");};\n\n\n\nprotected:\n\n //----------------------------------------------------------------------------\n\n // widget ID's\n\n //----------------------------------------------------------------------------\n\n enum VME_LABELED_VOLUME_DIALOG_ID\n\n {\n\n ID_INSERT_LABEL = Superclass::ID_LAST,\n\n ID_REMOVE_LABEL,\n\n ID_EDIT_LABEL,\n\n ID_LABELS,\n\n ID_FIT,\t\n\n ID_SLICE,\n\n ID_SLICE_SLIDER,\n\n ID_INCREASE_SLICE,\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 36, "score": 63801.128037028735 }, { "content": "/*=========================================================================\n\n\n\n Program: ALBA (Agile Library for Biomedical Applications)\n\n Module: albaOpLabelExtractor\n\n Authors: Paolo Quadrani - porting Roberto Mucci\n\n \n\n Copyright (c) BIC\n\n All rights reserved. See Copyright.txt or\n\n\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef __albaOpLabelExtractor_H__\n\n#define __albaOpLabelExtractor_H__\n\n\n\n\n\n#include \"albaOp.h\"\n\n\n\n\n\n//----------------------------------------------------------------------------\n\n// forward references :\n\n//----------------------------------------------------------------------------\n", "file_path": "Operations/albaOpLabelExtractor.h", "rank": 37, "score": 63799.99674562427 }, { "content": "\t/** Change type of gizmo in the view */\n\n\tvoid ChangeGizmo();\n\n\n\n\tvoid OnEventGizmoPlane(albaEventBase *alba_event);\n\n\tvoid OnEventThis(albaEventBase *alba_event);\n\n\tvoid OnEventGizmoTranslate(albaEventBase *alba_event);\n\n\tvoid OnEventGizmoRotate(albaEventBase *alba_event);\n\n\tvoid OnEventGizmoScale(albaEventBase *alba_event);\n\n\n\n\tvoid PostMultiplyEventMatrix(albaEventBase *alba_event);\n\n\n\n\tvoid SetPlaneDimension();\n\n\n\n\talbaInteractorCompositorMouse *m_IsaCompositorWithoutGizmo;\n\n\talbaInteractorCompositorMouse *m_IsaCompositorWithGizmo;\n\n\talbaInteractorGenericMouse *m_IsaTranslate;\n\n\talbaInteractorGenericMouse *m_IsaRotate;\n\n\talbaInteractorGenericMouse\t\t *m_IsaChangeArrowWithGizmo;\n\n\talbaInteractorGenericMouse\t\t *m_IsaChangeArrowWithoutGizmo;\t\n\n\talbaInteractorGenericMouse\t\t *m_IsaLabelizeWithGizmo;\n", "file_path": "Operations/albaOpLabelizeSurface.h", "rank": 38, "score": 63799.18036657321 }, { "content": " double m_SliceStep;\n\n double m_Bounds[6];\n\n\n\n double m_BBox[6];\n\n double m_Origin[3];\n\n double m_XVect[3];\n\n double m_YVect[3];\n\n \n\n wxString m_ItemLabel;\n\n\n\n vtkWindowLevelLookupTable * m_LookUpTable;\n\n vtkWindowLevelLookupTable * m_LookUpTableColor;\n\n vtkImageData * m_SP;\n\n vtkRectilinearGrid * m_RG;\n\n vtkProbeFilter * m_ProbeFilter;\n\n vtkTexture * m_Texture; \n\n vtkPolyDataMapper * m_SMapper;\n\n vtkActor * m_ActorSlice; \n\n vtkDataSet *m_Dataset;\n\n vtkPolyData *m_Polydata;\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 39, "score": 63796.83230712884 }, { "content": " \n\n\n\n std::vector<wxString> m_LabelNameVector;\n\n std::vector<bool> m_CheckedVector;\n\n\n\n\n\n albaGUICheckListBox *m_LabelCheckBox; \n\n albaGUIDialogPreview *m_Dlg; \n\n albaGUIFloatSlider *m_SliceSlider;\n\n albaRWI *m_Rwi;\n\n albaTagItem *m_TagLabel;\n\n albaVME *m_VolumeLink;\n\n albaTransform *m_Transform;\n\n\n\n wxString m_LabelNameValue; \t\n\n wxString m_LabelValueValue;\n\n\n\n double m_Slice;\n\n double m_SliceMin;\n\n double m_SliceMax;\n", "file_path": "VME/albaVMELabeledVolume.h", "rank": 40, "score": 63795.80247835586 }, { "content": "\tvtkAppendPolyData\t*m_Gizmo;\n\n\tvtkGlyph3D\t\t\t\t*m_Arrow;\n\n\n\n\tvtkALBAClipSurfaceBoundingBox\t*m_ClipperBoundingBox;\n\n\n\n\tstd::vector<vtkPolyData*> m_ResultPolyData;\n\n\tvtkPolyData\t*m_OriginalPolydata;\n\n\n\n\talbaGizmoTranslate\t\t*m_GizmoTranslate;\n\n\talbaGizmoRotate\t\t\t*m_GizmoRotate;\n\n\talbaGizmoScale\t\t\t\t*m_GizmoScale;\n\n};\n\n#endif\n", "file_path": "Operations/albaOpLabelizeSurface.h", "rank": 41, "score": 63792.86722859748 }, { "content": "class albaResultQueryAbstractHandlerTest : public albaTest\n\n{\n\npublic:\n\n\n\n /** Start test suite macro */\n\n\tCPPUNIT_TEST_SUITE( albaResultQueryAbstractHandlerTest );\n\n /** macro for test TestDynamicAllocation */\n\n\tCPPUNIT_TEST( TestDynamicAllocation );\n\n /** macro for test TestStaticAllocation */\n\n\tCPPUNIT_TEST( TestStaticAllocation );\n\n\n\n /** macro for test TestStaticAllocation */\n\n CPPUNIT_TEST( TestGetResultAsStringMatrix );\n\n\n\n /** macro for test TestStaticAllocation */\n\n CPPUNIT_TEST( TestGetColumnsTypeInformationAsStringVector );\n\n\n\n /** macro for test TestStaticAllocation */\n\n CPPUNIT_TEST( TestGetColumnsNameInformationAsStringVector );\n\n\n", "file_path": "Testing/Common/albaResultQueryAbstractHandlerTest.h", "rank": 42, "score": 63345.80111687767 }, { "content": "class albaOpCreateLabeledVolumeTest : public albaTest\n\n{\n\n CPPUNIT_TEST_SUITE( albaOpCreateLabeledVolumeTest );\n\n CPPUNIT_TEST( TestDynamicAllocation );\n\n CPPUNIT_TEST( TestCopy );\n\n CPPUNIT_TEST( TestAccept );\n\n CPPUNIT_TEST( TestOpRun );\n\n CPPUNIT_TEST( TestOpDo );\n\n CPPUNIT_TEST_SUITE_END();\n\n\n\nprotected:\n\n void TestDynamicAllocation();\n\n void TestCopy();\n\n void TestAccept();\n\n void TestOpRun();\n\n void TestOpDo();\n\n};\n\n\n\n#endif\n", "file_path": "Testing/Operations/albaOpCreateLabeledVolumeTest.h", "rank": 43, "score": 63300.56678091263 }, { "content": "// This force to include Window,wxWidgets and VTK exactly in this order.\n\n// Failing in doing this will result in a run-time error saying:\n\n// \"Failure#0: The value of ESP was not properly saved across a function call\"\n\n//----------------------------------------------------------------------------\n\n\n\n\n\n\n\n#include \"albaVMEOutputNULL.h\"\n\n#include \"albaAbsMatrixPipe.h\"\n\n#include \"albaDataPipe.h\"\n\n#include \"albaSmartPointer.h\"\n\n#include \"albaTransform.h\"\n\n#include \"albaIndent.h\"\n\n\n\n#include <assert.h>\n\n\n\n//-------------------------------------------------------------------------\n\nalbaCxxTypeMacro(albaVMEOutputNULL)\n\n//-------------------------------------------------------------------------\n\n\n", "file_path": "Core/albaVMEOutputNULL.cpp", "rank": 44, "score": 61798.04093196581 }, { "content": " /** Get result as string matrix */\n\n WebRowSetQueryObjectsTable GetResultAsObjectsMatrix() {return m_MatrixObjectResult;};\n\n\n\n\n\n /** Get number of records (rows) */\n\n int GetNumberOfRecords() const;\n\n\n\n /** Get number of fields (columns) */\n\n int GetNumberOfFields() const;\n\n\n\n /** load result of Query */\n\n virtual void LoadQueryResult() = 0;\n\n\n\n /** load result of Query */\n\n virtual bool IsFailed() = 0;\n\n\n\nprotected:\n\n /** clear all the results */\n\n virtual void InternalResultReset();\n\n\n", "file_path": "Common/albaResultQueryAbstractHandler.h", "rank": 45, "score": 61796.0015787554 }, { "content": "/*=========================================================================\n\n\n\n Program: ALBA (Agile Library for Biomedical Applications)\n\n Module: albaVMEOutputNULL\n\n Authors: Marco Petrone\n\n \n\n Copyright (c) BIC\n\n All rights reserved. See Copyright.txt or\n\n\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n\n\n\n\n#include \"albaDefines.h\" \n\n//----------------------------------------------------------------------------\n\n// NOTE: Every CPP file in the ALBA must include \"albaDefines.h\" as first.\n", "file_path": "Core/albaVMEOutputNULL.cpp", "rank": 46, "score": 61789.66078310828 }, { "content": "//-------------------------------------------------------------------------\n\nalbaVMEOutputNULL::albaVMEOutputNULL()\n\n//-------------------------------------------------------------------------\n\n{\n\n}\n\n\n\n//-------------------------------------------------------------------------\n\nalbaVMEOutputNULL::~albaVMEOutputNULL()\n\n//-------------------------------------------------------------------------\n\n{\n\n}\n\n\n", "file_path": "Core/albaVMEOutputNULL.cpp", "rank": 47, "score": 61786.57853842674 }, { "content": "REM ----------------------------------------------------------------------------\n\nREM TestComplete Result Copy\n\nREM ----------------------------------------------------------------------------\n\n\n\necho.\n\n\n\ncd ..\n\n\n\nset CheckNameResultsDirectory=GuiTestResult\n\n\n\n\n\nREM delete the directory storing previous results\n\nrmdir /s /q %CheckNameResultsDirectory%\n\n\n\nREM create the directory again the directories for storing XML and HTML file name checking results\n\nmkdir %CheckNameResultsDirectory%\n\n\n\necho creating file name check results... \n\ncd %CheckNameResultsDirectory%\n\nxcopy ..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\Results\\Resultlog \n\n\n\n\n\n\n\n\n\necho.\n", "file_path": "ParabuildScripts/guiTestResults.bat", "rank": 48, "score": 61783.065356000974 }, { "content": "REM BEWARE! These directory names are referenced in MemoryProfile.vbs script so the not change them\n\nset ProfilingResultsDirectory=.\\build\\bin\\Debug\\Coverage\\\n\nset XMLResultsDirectory=%ProfilingResultsDirectory%\\XML\\\n\nset HTMLResultsDirectory=%ProfilingResultsDirectory%\\HTML\\\n\n\n\nREM delete the directory storing previous results\n\nrmdir /s /q %ProfilingResultsDirectory%\n\n\n\nREM create the directory again the directories for storing XML and HTML memory profiling results\n\nmkdir %XMLResultsDirectory%\n\nmkdir %HTMLResultsDirectory%", "file_path": "JenkinsScripts/RemoveCoverageResults.bat", "rank": 49, "score": 61783.034081101105 }, { "content": "REM BEWARE! These directory names are referenced in MemoryProfile.vbs script so the not change them\n\nset ProfilingResultsDirectory=.\\build\\bin\\Debug\\MemoryAllocation\\\n\nset XMLResultsDirectory=%ProfilingResultsDirectory%\\XML\\\n\nset HTMLResultsDirectory=%ProfilingResultsDirectory%\\HTML\\\n\n\n\nREM delete the directory storing previous results\n\nrmdir /s /q %ProfilingResultsDirectory%\n\n\n\nREM create the directory again the directories for storing XML and HTML memory profiling results\n\nmkdir %XMLResultsDirectory%\n\nmkdir %HTMLResultsDirectory%", "file_path": "JenkinsScripts/RemoveProfilingResults.bat", "rank": 50, "score": 61783.02370391632 }, { "content": "// Include:\n\n//----------------------------------------------------------------------------\n\n#include \"albaDefines.h\"\n\n#include \"albaObject.h\"\n\n#include \"albaQueryObject.h\"\n\n#include <vector>\n\n//----------------------------------------------------------------------------\n\n// forward references :\n\n//----------------------------------------------------------------------------\n\n\n\n//----------------------------------------------------------------------------\n\n// typedefs :\n\n//----------------------------------------------------------------------------\n\n\n\ntypedef std::vector<std::vector<std::string> > WebRowSetStringDataTable;\n\ntypedef std::vector<std::string> WebRowSetColumnTypeVector;\n\ntypedef std::vector<std::string> WebRowSetColumnNameVector;\n\n\n\ntypedef std::vector<std::vector<albaQueryObject *> > WebRowSetQueryObjectsTable;\n\n/**\n", "file_path": "Common/albaResultQueryAbstractHandler.h", "rank": 51, "score": 61782.11903618858 }, { "content": " WebRowSetStringDataTable m_MatrixStringResult;\n\n WebRowSetColumnTypeVector m_ColumnsTypeInformation;\n\n WebRowSetColumnNameVector m_ColumnsNameInformation;\n\n\n\n WebRowSetQueryObjectsTable m_MatrixObjectResult;\n\n\n\nprivate:\n\n \n\n\n\n\n\n};\n\n#endif //__albaResultQueryAbstractHandler_H__\n", "file_path": "Common/albaResultQueryAbstractHandler.h", "rank": 52, "score": 61781.835015140896 }, { "content": "/*=========================================================================\n\n\n\n Program: ALBA (Agile Library for Biomedical Applications)\n\n Module: albaResultQueryAbstractHandler\n\n Authors: Daniele Giunchi\n\n \n\n Copyright (c) BIC\n\n All rights reserved. See Copyright.txt or\n\n\n\n\n\n This software is distributed WITHOUT ANY WARRANTY; without even\n\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n\n PURPOSE. See the above copyright notice for more information.\n\n\n\n=========================================================================*/\n\n\n\n#ifndef __albaResultQueryAbstractHandler_H__\n\n#define __albaResultQueryAbstractHandler_H__\n\n\n\n//----------------------------------------------------------------------------\n", "file_path": "Common/albaResultQueryAbstractHandler.h", "rank": 53, "score": 61781.582713619326 }, { "content": "{\n\n\treturn new albaOpLabelizeSurface(m_Label);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nbool albaOpLabelizeSurface::Accept(albaVME*node)\n\n//----------------------------------------------------------------------------\n\n{\n\n\treturn (node != NULL && node->IsALBAType(albaVMESurface));\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::OpRun() \n\n//----------------------------------------------------------------------------\n\n{\n\n\tGetLogicManager()->VmeShow(m_Input, false);\n\n\n\n\talbaNEW(m_VmeEditor);\n\n\tvtkALBASmartPointer<vtkPolyData> inputOriginalPolydata;\n\n\tinputOriginalPolydata->DeepCopy(vtkPolyData::SafeDownCast(albaVMESurface::SafeDownCast(m_Input)->GetOutput()->GetVTKData()));\n\n\tint prova=inputOriginalPolydata->GetNumberOfPoints();\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 54, "score": 61758.13269281897 }, { "content": " for(int i=0; i<6; i++) \n\n m_BBox[i] = 0;\n\n}\n\n//------------------------------------------------------------------------------\n\nalbaVMELabeledVolume::~albaVMELabeledVolume()\n\n//------------------------------------------------------------------------------\n\n{\n\n albaDEL(m_Transform);\n\n if (m_DataCopied)\n\n albaDEL(m_Dataset);\n\n m_VolumeLink = NULL;\n\n m_CheckedVector.clear();\n\n m_LabelNameVector.clear();\n\n\n\n if ( m_Dlg )\n\n DeleteOpDialog();\n\n}\n\n\n\n//-------------------------------------------------------------------------\n\nint albaVMELabeledVolume::DeepCopy(albaVME *a)\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 55, "score": 61756.13411484059 }, { "content": " m_OutputData->GetPointData()->SetScalars(labelScalars);\n\n m_OutputData->Modified();\n\n }\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelExtractor::ExtractLabel()\n\n//----------------------------------------------------------------------------\n\n{\n\n albaVME *vme = NULL;\n\n \n\n if (m_Input->IsA(\"albaVMELabeledVolume\"))\n\n {\n\n UpdateDataLabel();\n\n }\n\n else\n\n {\n\n albaSmartPointer<albaVME> vmeLabeled = m_Input;\n\n m_Ds = vmeLabeled->GetOutput()->GetVTKData();\n\n m_Ds->Update();\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 56, "score": 61755.88531622964 }, { "content": "void albaOpLabelizeSurface::OpStop(int result)\n\n//----------------------------------------------------------------------------\n\n{\n\n\tGetLogicManager()->VmeShow(m_VmeEditor, false);\n\n\tm_VmeEditor->ReparentTo(NULL);\n\n\n\n\tif(m_ImplicitPlaneGizmo)\n\n\t{\n\n\t\tm_ImplicitPlaneGizmo->SetBehavior(NULL);\n\n\t\tGetLogicManager()->VmeRemove(m_ImplicitPlaneGizmo);\n\n\t}\n\n\talbaDEL(m_ImplicitPlaneGizmo);\n\n\n\n\tvtkDEL(m_Gizmo);\n\n\tvtkDEL(m_ArrowShape);\n\n\tvtkDEL(m_PlaneSource);\n\n\tvtkDEL(m_ClipperBoundingBox);\n\n\tvtkDEL(m_Arrow);\n\n\tvtkDEL(m_ClipperPlane);\n\n\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 57, "score": 61754.77937152762 }, { "content": "\tm_Gui->Double(ID_LABEL_VALUE,_(\"Label\"),&m_LabelValue);\n\n\tm_Gui->Lut(ID_LUT,\"lut\",m_VmeEditor->GetMaterial()->m_ColorLut);\n\n\tdouble b[6];\n\n\tm_Input->GetOutput()->GetVMEBounds(b);\n\n\t// bounding box dim\n\n\tm_PlaneWidth = b[1] - b[0];\n\n\tm_PlaneHeight = b[3] - b[2];\n\n\t//m_Gui->Double(ID_PLANE_WIDTH,_(\"plane w.\"),&m_PlaneWidth,0.0);\n\n\t//m_Gui->Double(ID_PLANE_HEIGHT,_(\"plane h.\"),&m_PlaneHeight,0.0);\n\n\tm_Gui->Divider();\n\n\tm_Gui->Button(ID_UNDO,_(\"Undo\"));\n\n\n\n\tm_Gui->Divider(1);\n\n\tm_Gui->OkCancel();\n\n\n\n\tm_Gui->Divider();\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::CreateGizmos()\n\n//----------------------------------------------------------------------------\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 58, "score": 61753.91032109263 }, { "content": "\t\tm_VmeEditor->GetMaterial()->m_ColorLut->Build();\n\n\n\n\t\tvtkALBASmartPointer<vtkDoubleArray> cellScalar;\n\n\t\tcellScalar->SetName(\"CELL_LABEL\");\n\n\t\tcellScalar->SetNumberOfComponents(1);\n\n\t\tcellScalar->SetNumberOfTuples(inputPolydata->GetNumberOfCells());\n\n\t\tfor(int i=0;i<inputPolydata->GetNumberOfCells();i++)\n\n\t\t{\n\n\t\t\tcellScalar->InsertTuple1(i,0.0);\n\n\t\t}\n\n\n\n\t\tinputPolydata->GetCellData()->SetScalars(cellScalar);\n\n\t\tinputPolydata->GetCellData()->Update();\n\n\n\n\t\tinputPolydata->Modified();\n\n\t\tinputPolydata->Update();\n\n\t}\n\n\telse\n\n\t{\n\n\t\tinputPolydata->GetCellData()->SetActiveScalars(\"CELL_LABEL\");\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 59, "score": 61753.16627423765 }, { "content": " m_LabelNameVector.push_back(name);\n\n m_CheckedVector.push_back(checked);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::ModifyLabelVector(int n, wxString name, bool checked)\n\n//----------------------------------------------------------------------------\n\n{\n\n if (n < m_LabelNameVector.size() )\n\n {\n\n m_LabelNameVector[n] = name;\n\n m_CheckedVector[n] = checked;\n\n }\n\n else\n\n return;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::RemoveItemLabelVector(int n)\n\n//----------------------------------------------------------------------------\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 60, "score": 61752.38089854908 }, { "content": "\n\n//----------------------------------------------------------------------------\n\nalbaCxxTypeMacro(albaOpLabelizeSurface);\n\n//----------------------------------------------------------------------------\n\n\n\n//----------------------------------------------------------------------------\n\nalbaOpLabelizeSurface::albaOpLabelizeSurface(const wxString &label) :\n\nalbaOp(label)\n\n//----------------------------------------------------------------------------\n\n{\n\n\tm_OpType\t= OPTYPE_OP;\n\n\tm_Canundo = true;\n\n\tm_InputPreserving = false;\n\n\n\n\tm_ImplicitPlaneGizmo = NULL;\n\n\tm_ClipperPlane = NULL;\n\n\tm_PlaneSource = NULL;\n\n\tm_ArrowShape = NULL;\n\n\tm_Arrow = NULL;\n\n\tm_Gizmo = NULL;\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 61, "score": 61752.32806573719 }, { "content": "#include \"vtkPointData.h\"\n\n#include \"vtkDataSet.h\"\n\n#include \"vtkRenderer.h\"\n\n#include \"vtkRenderWindow.h\"\n\n\n\n#include <list>\n\n#include <vector>\n\n\n\n#define OUTRANGE_SCALAR -1000\n\n\n\n//-------------------------------------------------------------------------\n\nalbaCxxTypeMacro(albaVMELabeledVolume);\n\n//-------------------------------------------------------------------------\n\n\n\n//------------------------------------------------------------------------------\n\nalbaVMELabeledVolume::albaVMELabeledVolume()\n\n//------------------------------------------------------------------------------\n\n{\n\n m_LabelCheckBox = NULL;\n\n m_EditMode = false;\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 62, "score": 61752.20562200514 }, { "content": " break; //exit from loop for only\n\n }\n\n // Check if another value for the label already exists\n\n int currentLabelValue = GetLabelValue( currentLabelName );\n\n if ( currentLabelValue == m_LabelIntValue )\n\n {\n\n int answer = wxMessageBox( \"The value for this label already exists - Continue?\", \"Warning\", wxYES_NO | wxICON_ERROR, NULL);\n\n if (answer == wxNO)\n\n { \n\n m_LabelIntValue = 1;\n\n m_Dlg->TransferDataToWindow();\n\n return;\n\n }\n\n else\n\n break; //exit from loop for only\n\n }\n\n }\n\n }\n\n wxString labelLine; \n\n labelLine.Printf( \"%s %d %d %d\", labelName, m_LabelIntValue, m_Min, m_Max ); \n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 63, "score": 61751.66367524358 }, { "content": "\n\n\tm_ResultPolyData.clear();\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nalbaOpLabelizeSurface::~albaOpLabelizeSurface()\n\n//----------------------------------------------------------------------------\n\n{\n\n\tfor(int i=0;i<m_ResultPolyData.size();i++)\n\n\t{\n\n\t\tvtkDEL(m_ResultPolyData[i]);\n\n\t}\n\n\tm_ResultPolyData.clear();\n\n\n\n\talbaDEL(m_VmeEditor);\n\n\tvtkDEL(m_OriginalPolydata);\n\n}\n\n//----------------------------------------------------------------------------\n\nalbaOp* albaOpLabelizeSurface::Copy() \n\n//----------------------------------------------------------------------------\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 64, "score": 61751.52578611239 }, { "content": " m_LabelCheckBox->Update();\n\n\n\n int noc = m_TagLabel->GetNumberOfComponents();\n\n for ( unsigned int w = 0; w < noc; w++ )\n\n {\n\n wxString componentName = m_TagLabel->GetValue( w );\n\n if ( m_ItemLabel == componentName )\n\n {\n\n SetLabelTag(labelLine.c_str(), w );\n\n }\n\n }\n\n }\n\n GenerateLabeledVolume();\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::SetLabelTag(albaString label, int component )\n\n//----------------------------------------------------------------------------\n\n{\n\n m_TagLabel->SetValue(label, component);\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 65, "score": 61751.48595807047 }, { "content": "\tm_IsaCompositorWithGizmo = NULL;\n\n\tm_IsaCompositorWithoutGizmo = NULL;\n\n\tm_InputSurface = NULL;\n\n\tm_OriginalPolydata = NULL;\n\n\tm_ClipperBoundingBox = NULL;\n\n\n\n\tm_LabelValue = 0.0;\n\n\n\n\tm_LabelInside = 1;\n\n\tm_UseGizmo\t\t= 1;\n\n\tm_GizmoType\t\t= GIZMO_TRANSLATE;\n\n\n\n\tm_PlaneWidth = 0.0;\n\n\tm_PlaneHeight = 0.0;\n\n\n\n\tm_VmeEditor = NULL;\n\n\n\n\tm_GizmoTranslate=NULL;\n\n\tm_GizmoRotate=NULL;\n\n\tm_GizmoScale=NULL;\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 66, "score": 61751.35635691417 }, { "content": "\t\tm_ImplicitPlaneGizmo->SetBehavior(m_IsaCompositorWithoutGizmo);\n\n\telse\n\n\t\tm_ImplicitPlaneGizmo->SetBehavior(m_IsaCompositorWithGizmo);\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::ShowClipPlane(bool show)\n\n//----------------------------------------------------------------------------\n\n{\n\n\tif(show)\n\n\t{\n\n\t\tif(m_ClipperPlane == NULL)\n\n\t\t{\n\n\t\t\tdouble b[6];\n\n\t\t\tm_Input->GetOutput()->GetBounds(b);\n\n\n\n\t\t\t// bounding box dim\n\n\t\t\tdouble xdim = b[1] - b[0];\n\n\t\t\tdouble ydim = b[3] - b[2];\n\n\t\t\tdouble zdim = b[5] - b[4];\n\n\t\t\t\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 67, "score": 61750.98716616801 }, { "content": "\n\n // Check if another name for the label already exists\n\n if( m_TagLabel && m_EditMode == false)\n\n {\n\n int noc = m_TagLabel->GetNumberOfComponents();\n\n for ( unsigned int i = 0; i < noc; i++ )\n\n {\n\n wxString component = m_TagLabel->GetValue( i );\n\n\n\n // Check if another name for the label already exists\n\n wxString currentLabelName = component.BeforeFirst( ' ' ); \n\n if ( currentLabelName == labelName )\n\n { \n\n int answer = wxMessageBox( \"The name of this label already exists - Continue?\", \"Warning\", wxYES_NO | wxICON_ERROR, NULL);\n\n if (answer == wxNO)\n\n { \n\n m_LabelNameCtrl->SetValue( wxEmptyString ); \n\n return;\n\n }\n\n else\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 68, "score": 61750.32190186718 }, { "content": "//----------------------------------------------------------------------------\n\nvoid albaOpLabelExtractor::GenerateLabeledVolume()\n\n//----------------------------------------------------------------------------\n\n{\n\n vtkALBASmartPointer<vtkDataArray> originalScalars = m_OutputData->GetPointData()->GetScalars(); \n\n vtkALBASmartPointer<vtkDataArray> labelScalars = m_OutputData->GetPointData()->GetScalars();\n\n\n\n std::vector<int> minVector;\n\n std::vector<int> maxVector;\n\n std::vector<int> labelIntVector;\n\n\n\n int counter= 0;\n\n //Fill the vectors of range and label value\n\n for (int c = 0; c < m_CheckedVector.size(); c++)\n\n {\n\n if (m_CheckedVector.at(c))\n\n {\n\n wxString label = m_LabelNameVector.at(c);\n\n wxStringTokenizer tkz(label,wxT(' '),wxTOKEN_RET_EMPTY_ALL);\n\n albaString labelName = tkz.GetNextToken().c_str();\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 69, "score": 61750.245965323506 }, { "content": "}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::RemoveLabelTag(int component)\n\n//----------------------------------------------------------------------------\n\n{\n\n m_TagLabel->RemoveValue(component);\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\n void albaVMELabeledVolume::UpdateSlice()\n\n//----------------------------------------------------------------------------\n\n{\n\n m_Origin[2] = m_Slice;\n\n m_SP->SetOrigin( m_Bounds[0], m_Bounds[2], m_Origin[2] );\n\n m_ProbeFilter->Update();\n\n\n\n this->m_Rwi->m_RenFront->ResetCameraClippingRange();\n\n m_Rwi->m_RwiBase->Render();\n\n m_Rwi->m_RenderWindow->SetDesiredUpdateRate(15.f); \n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 70, "score": 61749.66266507643 }, { "content": "}\n\n\n\n//----------------------------------------------------------------------------\n\nint albaVMELabeledVolume::GetMax( wxString &item )\n\n//----------------------------------------------------------------------------\n\n{\n\n wxString tmp = item.AfterFirst( ' ' ); \n\n tmp = tmp.AfterFirst( ' ' ); \n\n tmp = tmp.AfterFirst( ' ' ); \n\n wxString max = tmp.BeforeFirst( ' ' );\n\n long M = 0; \n\n max.ToLong( &M ); \n\n\n\n return (int)M;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::UpdateLookUpTable()\n\n//----------------------------------------------------------------------------\n\n{ \n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 71, "score": 61749.32664037907 }, { "content": " vtkDEL( m_ActorSlice ); \n\n cppDEL( m_Dlg ); \n\n}\n\n\n\n//-------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::SetVolumeLink(albaVME *n)\n\n//-------------------------------------------------------------------------\n\n{\n\n SetLink(\"VolumeLink\", n);\n\n CopyDataset();\n\n Modified();\n\n}\n\n\n\n//-------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::InternalPreUpdate()\n\n//-------------------------------------------------------------------------\n\n{\n\n m_VolumeLink = GetVolumeLink();\n\n EnableWidgets(m_VolumeLink != NULL);\n\n\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 72, "score": 61749.29346899379 }, { "content": "//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::OpDo()\n\n//----------------------------------------------------------------------------\n\n{\n\n\tif(m_VmeEditor)\n\n\t{\n\n\t\talbaVMESurface::SafeDownCast(m_Input)->SetData(vtkPolyData::SafeDownCast(m_VmeEditor->GetOutput()->GetVTKData()),((albaVMESurface*)m_Input)->GetTimeStamp());\n\n\t\talbaSmartPointer<mmaMaterial> mat;\n\n\t\tmat->DeepCopy(m_VmeEditor->GetMaterial());\n\n\t\talbaVMESurface::SafeDownCast(m_Input)->GetSurfaceOutput()->SetMaterial(mat);\n\n\t\talbaVMESurface::SafeDownCast(m_Input)->GetSurfaceOutput()->Update();\n\n\t\talbaVMESurface::SafeDownCast(m_Input)->GetOutput()->Update();\n\n\t\tGetLogicManager()->VmeVisualModeChanged(m_Input);\n\n\t\tGetLogicManager()->CameraUpdate();\n\n\t}\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::OpUndo()\n\n//----------------------------------------------------------------------------\n\n{\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 73, "score": 61748.94626191418 }, { "content": " m_Gui->Enable(ID_EDIT_LABEL,enable);\n\n }\n\n else\n\n {\n\n int noc = m_TagLabel->GetNumberOfComponents();\n\n bool labelPresent = noc != 0;\n\n m_Gui->Enable(ID_INSERT_LABEL,enable);\n\n m_Gui->Enable(ID_REMOVE_LABEL,labelPresent);\n\n m_Gui->Enable(ID_EDIT_LABEL,labelPresent);\n\n }\n\n m_Gui->Update();\n\n }\n\n}\n\n//-------------------------------------------------------------------------\n\nchar** albaVMELabeledVolume::GetIcon() \n\n//-------------------------------------------------------------------------\n\n{\n\n#include \"albaVMEVolume.xpm\"\n\n return albaVMEVolume_xpm;\n\n}\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 74, "score": 61748.86486350934 }, { "content": "// Failing in doing this will result in a run-time error saying:\n\n// \"Failure#0: The value of ESP was not properly saved across a function call\"\n\n//----------------------------------------------------------------------------\n\n\n\n\n\n#include \"albaOpLabelExtractor.h\"\n\n\n\n#include <wx/tokenzr.h>\n\n\n\n#include \"albaDecl.h\"\n\n#include \"albaGUICheckListBox.h\"\n\n#include \"albaOp.h\"\n\n#include \"albaEvent.h\"\n\n#include \"albaGUI.h\"\n\n#include \"albaVME.h\"\n\n#include \"albaVMEVolumeGray.h\"\n\n#include \"albaVMESurface.h\"\n\n#include \"albaTagItem.h\"\n\n#include \"albaTagArray.h\"\n\n\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 75, "score": 61748.657265027454 }, { "content": " if (m_VolumeLink == NULL)\n\n {\n\n return;\n\n }\n\n\n\n if (!m_DataCopied)\n\n {\n\n CopyDataset();\n\n }\n\n GenerateLabeledVolume(); \n\n}\n\n//-------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::CopyDataset()\n\n//-------------------------------------------------------------------------\n\n{\n\n m_VolumeLink = GetVolumeLink();\n\n if (m_VolumeLink)\n\n {\n\n vtkDataSet *data = m_VolumeLink->GetOutput()->GetVTKData();\n\n data->Update();\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 76, "score": 61748.28485244602 }, { "content": "// Failing in doing this will result in a run-time error saying:\n\n// \"Failure#0: The value of ESP was not properly saved across a function call\"\n\n//----------------------------------------------------------------------------\n\n\n\n#include \"albaVMELabeledVolume.h\"\n\n\n\n#include <wx/tokenzr.h>\n\n\n\n#include \"albaGUI.h\"\n\n#include \"albaGUIDialogPreview.h\"\n\n#include \"mmaMaterial.h\"\n\n#include \"mmaVolumeMaterial.h\"\n\n#include \"albaVME.h\"\n\n#include \"albaTransform.h\"\n\n#include \"albaGUIButton.h\"\n\n#include \"albaGUIValidator.h\"\n\n#include \"albaGUICheckListBox.h\"\n\n#include \"albaInteractorExtractIsosurface.h\"\n\n#include \"albaRWIBase.h\"\n\n#include \"albaRWI.h\"\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 77, "score": 61748.19634841352 }, { "content": "}\n\n\n\n//-----------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::RetrieveTag()\n\n//----------------------------------------------------------------------\n\n{ \n\n bool tagPresent = this->GetTagArray()->IsTagPresent(\"LABELS\");\n\n if (!tagPresent)\n\n {\n\n albaTagItem tag_Item;\n\n tag_Item.SetName(\"LABELS\");\n\n this->GetTagArray()->SetTag(tag_Item);\n\n }\n\n m_TagLabel = new albaTagItem;\n\n m_TagLabel = this->GetTagArray()->GetTag( \"LABELS\" );\n\n}\n\n\n\n//-----------------------------------------------------------------------\n\nint albaVMELabeledVolume::InternalStore(albaStorageElement *parent)\n\n//-----------------------------------------------------------------------\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 78, "score": 61748.107942260496 }, { "content": "// Failing in doing this will result in a run-time error saying:\n\n// \"Failure#0: The value of ESP was not properly saved across a function call\"\n\n//----------------------------------------------------------------------------\n\n\n\n#include \"albaOpLabelizeSurface.h\"\n\n#include \"albaGUI.h\"\n\n#include \"mmaMaterial.h\"\n\n#include \"albaAbsMatrixPipe.h\"\n\n#include \"albaInteractorCompositorMouse.h\"\n\n#include \"albaInteractorGenericMouse.h\"\n\n#include \"albaGizmoTranslate.h\"\n\n#include \"albaGizmoRotate.h\"\n\n#include \"albaGizmoScale.h\"\n\n#include \"albaRefSys.h\"\n\n#include \"albaTransform.h\"\n\n\n\n#include \"albaMatrix.h\"\n\n#include \"albaVME.h\"\n\n#include \"albaVMESurface.h\"\n\n#include \"albaVMEGizmo.h\"\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 79, "score": 61748.009749219185 }, { "content": "\talbaVMESurface::SafeDownCast(m_Input)->SetData(m_OriginalPolydata,((albaVMESurface*)m_Input)->GetTimeStamp());\n\n\tGetLogicManager()->CameraUpdate();\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::Labelize()\n\n//----------------------------------------------------------------------------\n\n{\n\n\tvtkALBASmartPointer<vtkTransform> rotate;\n\n\trotate->RotateX(180);\n\n\n\n\tvtkALBASmartPointer<vtkTransformPolyDataFilter> before_transform_plane;\n\n\tvtkALBASmartPointer<vtkTransformPolyDataFilter> transform_plane;\n\n\tif(m_LabelInside==1)//if clip reverse is necessary rotate plane\n\n\t{\n\n\t\tbefore_transform_plane->SetTransform(rotate);\n\n\t\tbefore_transform_plane->SetInput(m_PlaneSource->GetOutput());\n\n\t\tbefore_transform_plane->Update();\n\n\n\n\t\ttransform_plane->SetInput(before_transform_plane->GetOutput());\n\n\t}\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 80, "score": 61747.95519808186 }, { "content": " m_Texture = NULL;\n\n m_SMapper = NULL;\n\n m_ActorSlice = NULL; \n\n\n\n m_LabelNameValue = wxEmptyString;\n\n m_LabelValueValue = wxEmptyString;\n\n\n\n albaNEW(m_Transform);\n\n albaVMEOutputVolume *output = albaVMEOutputVolume::New(); // an output with no data\n\n output->SetTransform(m_Transform); // force my transform in the output\n\n SetOutput(output);\n\n \n\n DependsOnLinkedNodeOn();\n\n\n\n // attach a data pipe which creates a bridge between VTK and ALBA\n\n albaDataPipeCustom *dpipe = albaDataPipeCustom::New();\n\n dpipe->SetDependOnAbsPose(true);\n\n SetDataPipe(dpipe);\n\n dpipe->SetInput(NULL);\n\n \n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 81, "score": 61747.85759340514 }, { "content": "}\n\n\n\n//-------------------------------------------------------------------------\n\nmmaVolumeMaterial * albaVMELabeledVolume::GetMaterial()\n\n//-------------------------------------------------------------------------\n\n{\n\n mmaVolumeMaterial *material = (mmaVolumeMaterial *)GetAttribute(\"VolumeMaterialAttributes\");\n\n if (material == NULL)\n\n {\n\n material = mmaVolumeMaterial::New();\n\n SetAttribute(\"VolumeMaterialAttributes\", material);\n\n if (m_Output)\n\n {\n\n ((albaVMEOutputVolume *)m_Output)->SetMaterial(material);\n\n }\n\n }\n\n return material;\n\n}\n\n//----------------------------------------------------------------------------\n\nint albaVMELabeledVolume::GetLabelValue( wxString &item )\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 82, "score": 61747.35720819402 }, { "content": "\tif(m_ResultPolyData.size()>1)\n\n\t{\n\n\t\tvtkDEL(m_ResultPolyData[m_ResultPolyData.size()-1]);\n\n\t\tm_ResultPolyData.pop_back();\n\n\t\t((albaVMESurface*)m_VmeEditor)->SetData((vtkPolyData*)m_ResultPolyData[m_ResultPolyData.size()-1],m_Input->GetTimeStamp());\n\n\t\t\n\n\t\t((albaVMESurface*)m_VmeEditor)->InvokeEvent(this,VME_OUTPUT_DATA_UPDATE);\n\n\t}\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::UpdateISARefSys()\n\n//----------------------------------------------------------------------------\n\n{\n\n\tm_IsaRotate->GetRotationConstraint()->GetRefSys()->SetMatrix(m_ImplicitPlaneGizmo->GetAbsMatrixPipe()->GetMatrixPointer());\n\n\tm_IsaRotate->GetPivotRefSys()->SetMatrix(m_ImplicitPlaneGizmo->GetAbsMatrixPipe()->GetMatrixPointer());\n\n\n\n\tm_IsaTranslate->GetTranslationConstraint()->GetRefSys()->SetMatrix(m_ImplicitPlaneGizmo->GetAbsMatrixPipe()->GetMatrixPointer());\n\n\tm_IsaTranslate->GetPivotRefSys()->SetMatrix(m_ImplicitPlaneGizmo->GetAbsMatrixPipe()->GetMatrixPointer());\n\n}\n\n//----------------------------------------------------------------------------\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 83, "score": 61747.26630981929 }, { "content": " albaString labelIntStr = tkz.GetNextToken().c_str();\n\n int labelIntValue = atoi(labelIntStr);\n\n labelIntVector.push_back(labelIntValue);\n\n //Set the label value for vtkImageThreshold\n\n m_ValLabel = labelIntValue;\n\n albaString minStr = tkz.GetNextToken().c_str();\n\n int minValue = atof(minStr);\n\n minVector.push_back(minValue);\n\n albaString maxStr = tkz.GetNextToken().c_str();\n\n int mxValue = atof(maxStr);\n\n maxVector.push_back(mxValue);\n\n counter++;\n\n }\n\n }\n\n\n\n //Modify the scalars value, with the value of the label checked\n\n int labelVlaue;\n\n if (counter != 0)\n\n {\n\n int num_tuple = originalScalars->GetNumberOfTuples();\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 84, "score": 61747.23560537335 }, { "content": "\n\n//----------------------------------------------------------------------------\n\nalbaOpLabelExtractor::albaOpLabelExtractor(const wxString& label) :\n\nalbaOp(label)\n\n//----------------------------------------------------------------------------\n\n{\n\n m_OpType\t= OPTYPE_OP;\n\n m_Canundo = true;\n\n\n\n\tm_Vme = NULL;\n\n m_Ds = NULL;\n\n m_OutputData = NULL;\n\n m_TagLabel = NULL;\n\n\tm_ValLabel = 0;\n\n\tm_SurfaceName = \"label 0\";\n\n m_SmoothVolume = 0;\n\n m_RadiusFactor = 0.5;\n\n m_RadiusFactorAfter = 0.5;\n\n m_StdDev[0] = m_StdDev[1] = 1.5;\n\n m_StdDev[2] = 2.0;\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 85, "score": 61746.98004759229 }, { "content": " volumeScalars = rg->GetPointData()->GetScalars(); \n\n }\n\n int numberC = m_TagLabel->GetNumberOfComponents();\n\n bool lastComponent = false;\n\n int numberChecked = 0;\n\n\n\n std::vector<int> minVector;\n\n std::vector<int> maxVector;\n\n std::vector<int> labelIntVector;\n\n\n\n int counter= 0;\n\n //Fill the vectors of range and label value\n\n for (int c = 0; c < m_CheckedVector.size(); c++)\n\n {\n\n if (m_CheckedVector.at(c))\n\n {\n\n wxString label = m_LabelNameVector.at(c);\n\n wxStringTokenizer tkz(label,wxT(' '),wxTOKEN_RET_EMPTY_ALL);\n\n albaString labelName = tkz.GetNextToken().c_str();\n\n albaString labelIntStr = tkz.GetNextToken().c_str();\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 86, "score": 61746.939032067254 }, { "content": " for ( int i = 0; i < num_tuple; i++ )\n\n {\n\n bool modified = false;\n\n double scalarValue = labelScalars->GetComponent( i, 0 );\n\n for (int c = 0; c < labelIntVector.size(); c++)\n\n {\n\n if ( scalarValue >= minVector.at(c) && scalarValue <= maxVector.at(c))\n\n { \n\n labelVlaue = labelIntVector.at(c);\n\n labelScalars->SetTuple1( i, labelVlaue ); \n\n modified = true;\n\n }\n\n }\n\n if (!modified)\n\n {\n\n labelScalars->SetTuple1( i, OUTRANGE_SCALAR ); \n\n }\n\n }\n\n\n\n labelScalars->Modified();\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 87, "score": 61746.911625393186 }, { "content": " m_LookUpTableColor->DeepCopy( m_LookUpTable );\n\n for ( int i = m_Min; i <= m_Max; i++ )\n\n {\n\n vtkIdType index = m_LookUpTableColor->GetIndex( i ); \n\n m_LookUpTableColor->SetTableValue( index, 1.0f, 0.0f, 0.0f );\n\n }\n\n m_Texture->SetLookupTable( m_LookUpTableColor ); \n\n m_Rwi->m_RwiBase->Render(); \n\n} \n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaVMELabeledVolume::EnableWidgets(bool enable)\n\n//----------------------------------------------------------------------------\n\n{\n\n if (m_Gui)\n\n {\n\n if (!enable || !m_VolumeLink)\n\n {\n\n m_Gui->Enable(ID_INSERT_LABEL,enable);\n\n m_Gui->Enable(ID_REMOVE_LABEL,enable);\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 88, "score": 61746.63465470395 }, { "content": " for (int c = 0; c < labelIntVector.size(); c++)\n\n {\n\n if ( scalarValue >= minVector.at(c) && scalarValue <= maxVector.at(c))\n\n { \n\n labelVlaue = labelIntVector.at(c);\n\n labelScalars->SetTuple1( i, labelVlaue ); \n\n modified = true;\n\n }\n\n }\n\n if (!modified)\n\n {\n\n labelScalars->SetTuple1( i, OUTRANGE_SCALAR); \n\n }\n\n }\n\n \n\n labelScalars->Modified();\n\n m_Dataset->GetPointData()->SetScalars(labelScalars);\n\n m_Dataset->Modified();\n\n }\n\n else\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 89, "score": 61746.55440975321 }, { "content": " \n\n vtkALBASmartPointer<vtkALBAContourVolumeMapper> contourMapper;\n\n contourMapper->SetInput((vtkDataSet *)imageToSp->GetOutput());\n\n contourMapper->SetContourValue(m_ValLabel);\n\n\n\n\tvtkALBASmartPointer<vtkPolyData> surface;\n\n contourMapper->GetOutput(0, surface);\t\n\n\tcontourMapper->Update();\n\n\n\n albaNEW(m_Vme);\n\n\tm_Vme->SetData(surface, 0.0);\n\n m_Vme->SetName(m_SurfaceName.c_str());\n\n m_Vme->Update();\n\n m_Output = m_Vme;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelExtractor::SetLabel(double labelValue)\n\n//----------------------------------------------------------------------------\n\n{\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 90, "score": 61746.51447334561 }, { "content": " m_MaxMin = m_MinAbsolute; \n\n m_MaxMax = m_MaxAbsolute;\n\n \n\n m_LabelNameValue = labelName;\n\n m_LabelValueValue = labelIntStr;\n\n m_LabelIntValue = labelValue;\n\n m_Min = min;\n\n m_Max = max;\n\n CreateOpDialog();\n\n m_Dlg->ShowModal(); \n\n } \n\n }\n\n } \n\n else\n\n break;\n\n }\n\n break;\n\n case ID_LABELS:\n\n {\n\n int itemId = e->GetArg();\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 91, "score": 61746.50583757028 }, { "content": " if (albaEvent *e = albaEvent::SafeDownCast(alba_event))\n\n {\n\n switch(e->GetId())\n\n {\n\n\t\t case wxOK:\n\n\t\t\t ExtractLabel();\n\n\t\t\t if(m_Input->GetOutput()->GetVTKData() != NULL)\n\n\t\t\t\t OpStop(OP_RUN_OK);\n\n\t\t\t else\n\n\t\t\t {\n\n\t\t\t\t wxString msg = wxString::Format(\"Label %d not found!\", m_ValLabel);\n\n\t\t\t\t wxMessageBox(msg,\"Warning\");\n\n\t\t\t\t OpStop(OP_RUN_CANCEL);\n\n\t\t\t }\n\n\t\t break;\n\n\t\t case wxCANCEL:\n\n\t\t\t OpStop(OP_RUN_CANCEL);\n\n\t\t break;\n\n case ID_SMOOTH:\n\n m_Gui->Enable(ID_RADIUS_FACTOR,m_SmoothVolume != 0);\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 92, "score": 61746.38297994673 }, { "content": " {\n\n for ( unsigned int i = 0; i < noc; i++ )\n\n {\n\n wxString label = m_TagLabel->GetValue( i );\n\n if ( label != \"\" )\n\n {\n\n myList.push_back( label );\n\n }\n\n } \n\n\n\n int checkListId = 0;\n\n for( myListIter = myList.begin(); myListIter != myList.end(); myListIter++ )\n\n {\n\n for ( unsigned int j = 0; j < noc; j++ )\n\n {\n\n wxString component = m_TagLabel->GetValue( j );\n\n if ( component != \"\" )\n\n {\n\n wxString labelName = *myListIter;\n\n if ( component == labelName )\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 93, "score": 61746.34852942224 }, { "content": " }\n\n }\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelExtractor::UpdateDataLabel()\n\n//----------------------------------------------------------------------------\n\n{\n\n albaVME *linkedNode = m_Input->GetLink(\"VolumeLink\");\n\n albaSmartPointer<albaVME> linkedVolume = linkedNode;\n\n\n\n //Get dataset from volume linked to\n\n vtkDataSet *data = linkedVolume->GetOutput()->GetVTKData();\n\n data->Update();\n\n\n\n //Create a copy of the dataset not to modify the original one\n\n m_Ds = data->NewInstance();\n\n m_Ds->DeepCopy(data);\n\n\n\n}\n\n\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 94, "score": 61746.284704283855 }, { "content": " m_Gui->Vector(ID_SAMPLING_RATE,_(\"sample rate\"),m_SamplingRate, 1, MAXINT,_(\"sampling rate for volume sub-sampling.\"));\n\n m_Gui->Divider();\n\n m_Gui->Float(ID_RADIUS_FACTOR_AFTER,_(\"rad. factor\"),&m_RadiusFactorAfter,0.1,MAXFLOAT,0,2,_(\"max distance to consider for the smooth.\"));\n\n m_Gui->Vector(ID_STD_DEVIATION_AFTER,_(\"std dev.\"),m_StdDevAfter, 0.1, MAXFLOAT,2,_(\"standard deviation for the smooth.\"));\n\n m_Gui->Divider(2);\n\n m_Gui->Divider();\n\n\n\n if (m_Input->IsA(\"albaVMELabeledVolume\"))\n\n {\n\n m_LabelCheckBox = m_Gui->CheckList(ID_LABELS,_(\"Labels\"),360,_(\"Chose label to extract\"));\n\n\n\n typedef std::list< wxString > LIST;\n\n LIST myList; \n\n LIST::iterator myListIter; \n\n\n\n // If there is a tag named \"LABELS\" then I have to load the labels in the correct position in the listbox\n\n if (RetrieveTag())\n\n {\n\n int noc = m_TagLabel->GetNumberOfComponents();\n\n if(noc != 0)\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 95, "score": 61746.27754736759 }, { "content": " m_TagLabel = new albaTagItem;\n\n m_TagLabel = m_Input->GetTagArray()->GetTag( \"LABELS\" );\n\n return tagPresent;\n\n }\n\n else\n\n return !tagPresent;\n\n}\n\n\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelExtractor::OpRun() \n\n//----------------------------------------------------------------------------\n\n{\n\n\tm_Gui = new albaGUI(this);\n\n\tm_Gui->SetListener(this);\n\n\n\n m_Gui->Bool(ID_SMOOTH,_(\"smooth\"),&m_SmoothVolume,0,_(\"gaussian smooth for extracting big surface\"));\n\n m_Gui->Divider(2);\n\n m_Gui->Float(ID_RADIUS_FACTOR,_(\"rad. factor\"),&m_RadiusFactor,0.1,MAXFLOAT,0,2,_(\"max distance to consider for the smooth.\"));\n\n m_Gui->Vector(ID_STD_DEVIATION,_(\"std dev.\"),m_StdDev, 0.1, MAXFLOAT,2,_(\"standard deviation for the smooth.\"));\n\n m_Gui->Divider();\n", "file_path": "Operations/albaOpLabelExtractor.cpp", "rank": 96, "score": 61746.23982850289 }, { "content": "\tnewPolyData2->Update();\n\n\n\n\tvtkALBASmartPointer<vtkAppendPolyData> append;\n\n\tappend->SetInput(newPolyData1);\n\n\tappend->AddInput(newPolyData2);\n\n\tappend->Update();\n\n\n\n\n\n\tvtkALBASmartPointer<vtkCleanPolyData> clean;\n\n\tclean->SetInput(append.GetPointer()->GetOutput());\n\n\tclean->Update();\n\n\n\n\tvtkALBASmartPointer<vtkTransformPolyDataFilter> transform_data_output;\n\n\ttransform_data_output->SetTransform(m_VmeEditor->GetAbsMatrixPipe()->GetVTKTransform()->GetInverse());\n\n\ttransform_data_output->SetInput(clean->GetOutput());\n\n\ttransform_data_output->Update();\n\n\n\n\tint result=(m_VmeEditor)->SetData(transform_data_output->GetOutput(),m_VmeEditor->GetTimeStamp());\n\n\n\n\tif(result==ALBA_OK)\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 97, "score": 61746.22744165996 }, { "content": " m_LabelIntValue = atoi(labelIntStr);\n\n labelIntVector.push_back(m_LabelIntValue);\n\n albaString minStr = tkz.GetNextToken().c_str();\n\n m_MinValue = atof(minStr);\n\n minVector.push_back(m_MinValue);\n\n albaString maxStr = tkz.GetNextToken().c_str();\n\n m_MaxValue = atof(maxStr);\n\n maxVector.push_back(m_MaxValue);\n\n counter++;\n\n }\n\n }\n\n \n\n int labelVlaue;\n\n if (counter != 0)\n\n {\n\n int not = volumeScalars->GetNumberOfTuples();\n\n for ( int i = 0; i < not; i++ )\n\n {\n\n bool modified = false;\n\n double scalarValue = volumeScalars->GetComponent( i, 0 );\n", "file_path": "VME/albaVMELabeledVolume.cpp", "rank": 98, "score": 61746.22287704076 }, { "content": "\t{\n\n\t\tvtkPolyData *poly;\n\n\t\tvtkNEW(poly);\n\n\t\tpoly->DeepCopy(transform_data_output->GetOutput());\n\n\t\tpoly->Update();\n\n\t\tm_ResultPolyData.push_back(poly);\n\n\t}\n\n\n\n\t((albaVMESurface*)m_VmeEditor)->Modified();\n\n\t((albaVMESurface*)m_VmeEditor)->Update();\n\n\n\n\t((albaVMESurface*)m_VmeEditor)->InvokeEvent(this, VME_OUTPUT_DATA_UPDATE);\n\n\n\n\t/*m_Gui->Enable(ID_UNDO,m_ResultPolyData.size()>1);\n\n\tm_Gui->Enable(wxOK,m_ResultPolyData.size()>1);*/\n\n}\n\n//----------------------------------------------------------------------------\n\nvoid albaOpLabelizeSurface::ChangeGizmo()\n\n//----------------------------------------------------------------------------\n\n{\n", "file_path": "Operations/albaOpLabelizeSurface.cpp", "rank": 99, "score": 61746.17499723435 } ]
C++
src/test_suites/oclc/oclc_miscellaneous_vector_functions/src/vec_step.cpp
intel/cassian
8e9594f053f9b9464066c8002297346580e4aa2a
#include <algorithm> #include <cassian/catch2_utils/catch2_utils.hpp> #include <cassian/cli/cli.hpp> #include <cassian/runtime/openclc_type_tuples.hpp> #include <cassian/runtime/runtime.hpp> #include <cassian/test_harness/test_harness.hpp> #include <cassian/utility/metaprogramming.hpp> #include <cassian/utility/utility.hpp> #include <catch2/catch.hpp> #include <cstddef> #include <numeric> #include <string> #include <test_config.hpp> #include <vector> namespace ca = cassian; namespace { template <typename T> int get_reference() { using data_host_type = typename T::host_type; if constexpr (ca::is_vector_v<data_host_type>) { return data_host_type::size_in_memory; } return 1; } template <typename T> std::string get_build_options() { const std::string clc_data_type = T::device_type; std::string build_options = " -D DATA_TYPE=" + clc_data_type; return build_options; } ca::Kernel create_kernel(const std::string &path, const std::string &name, const std::string &build_options, cassian::Runtime *runtime, const std::string &program_type) { const std::string source = ca::load_text_file(ca::get_asset(path)); return runtime->create_kernel(name, source, build_options, program_type); } std::vector<int> generate_input(const size_t elements) { std::vector<int> input(elements); std::iota(input.begin(), input.end(), 0); return input; } template <typename T> std::vector<int> run_data_type_kernel(const cassian::Kernel &kernel, const size_t global_work_size, const std::vector<T> &input, cassian::Runtime *runtime) { std::vector<ca::Buffer> buffers; ca::Buffer input_buffer = runtime->create_buffer(sizeof(T) * input.size()); runtime->write_buffer_from_vector(input_buffer, input); buffers.push_back(input_buffer); ca::Buffer output_buffer = runtime->create_buffer(sizeof(int) * global_work_size); buffers.push_back(output_buffer); runtime->set_kernel_argument(kernel, 0, input_buffer); runtime->set_kernel_argument(kernel, 1, output_buffer); runtime->run_kernel(kernel, global_work_size); std::vector<int> output = runtime->read_buffer_to_vector<int>(output_buffer); for (auto &buffer : buffers) { runtime->release_buffer(buffer); } return output; } template <typename T> std::vector<int> run_pure_type_kernel(const cassian::Kernel &kernel, const size_t global_work_size, cassian::Runtime *runtime) { std::vector<ca::Buffer> buffers; ca::Buffer output_buffer = runtime->create_buffer(sizeof(int) * global_work_size); buffers.push_back(output_buffer); runtime->set_kernel_argument(kernel, 0, output_buffer); runtime->run_kernel(kernel, global_work_size); std::vector<int> output = runtime->read_buffer_to_vector<int>(output_buffer); for (auto &buffer : buffers) { runtime->release_buffer(buffer); } return output; } using GentypeTypes = ca::TupleConcat<ca::ScalarTypes, ca::VectorTypes>::type; template <typename T> std::string test_name() { return std::string(T::type_name); } TEMPLATE_LIST_TEST_CASE_CUSTOM_NAME("vec_step_data_type", "", GentypeTypes, test_name<TestType>) { const TestConfig &config = get_test_config(); ca::Requirements requirements; requirements.arithmetic_type<typename TestType::scalar_type>(); if (ca::should_skip_test(requirements, *config.runtime())) { return; } ca::Runtime *runtime = config.runtime(); const std::string program_type = config.program_type(); const size_t global_work_size = config.work_size(); using data_host_type = typename TestType::host_type; const std::vector<data_host_type> input(global_work_size, data_host_type(123)); const std::string build_options = get_build_options<TestType>(); ca::Kernel kernel = create_kernel("kernels/oclc_miscellaneous_vector_functions/vec_step.cl", "test_data_type", build_options, runtime, program_type); const std::vector<int> output = run_data_type_kernel(kernel, global_work_size, input, runtime); runtime->release_kernel(kernel); const std::vector<int> reference = std::vector<int>(global_work_size, get_reference<TestType>()); REQUIRE_THAT(output, Catch::Equals(reference)); } TEMPLATE_LIST_TEST_CASE_CUSTOM_NAME("vec_step_pure_type", "", GentypeTypes, test_name<TestType>) { const TestConfig &config = get_test_config(); ca::Requirements requirements; requirements.arithmetic_type<typename TestType::scalar_type>(); if (ca::should_skip_test(requirements, *config.runtime())) { return; } ca::Runtime *runtime = config.runtime(); const std::string program_type = config.program_type(); const size_t global_work_size = config.work_size(); const std::string build_options = get_build_options<TestType>(); ca::Kernel kernel = create_kernel("kernels/oclc_miscellaneous_vector_functions/vec_step.cl", "test_pure_type", build_options, runtime, program_type); using data_host_type = typename TestType::host_type; const std::vector<int> output = run_pure_type_kernel<data_host_type>(kernel, global_work_size, runtime); runtime->release_kernel(kernel); const std::vector<int> reference = std::vector<int>(global_work_size, get_reference<TestType>()); REQUIRE_THAT(output, Catch::Equals(reference)); } }
#include <algorithm> #include <cassian/catch2_utils/catch2_utils.hpp> #include <cassian/cli/cli.hpp> #include <cassian/runtime/openclc_type_tuples.hpp> #include <cassian/runtime/runtime.hpp> #include <cassian/test_harness/test_harness.hpp> #include <cassian/utility/metaprogramming.hpp> #include <cassian/utility/utility.hpp> #include <catch2/catch.hpp> #include <cstddef> #include <numeric> #include <string> #include <test_config.hpp> #include <vector> namespace ca = cassian; namespace { template <typename T>
template <typename T> std::string get_build_options() { const std::string clc_data_type = T::device_type; std::string build_options = " -D DATA_TYPE=" + clc_data_type; return build_options; } ca::Kernel create_kernel(const std::string &path, const std::string &name, const std::string &build_options, cassian::Runtime *runtime, const std::string &program_type) { const std::string source = ca::load_text_file(ca::get_asset(path)); return runtime->create_kernel(name, source, build_options, program_type); } std::vector<int> generate_input(const size_t elements) { std::vector<int> input(elements); std::iota(input.begin(), input.end(), 0); return input; } template <typename T> std::vector<int> run_data_type_kernel(const cassian::Kernel &kernel, const size_t global_work_size, const std::vector<T> &input, cassian::Runtime *runtime) { std::vector<ca::Buffer> buffers; ca::Buffer input_buffer = runtime->create_buffer(sizeof(T) * input.size()); runtime->write_buffer_from_vector(input_buffer, input); buffers.push_back(input_buffer); ca::Buffer output_buffer = runtime->create_buffer(sizeof(int) * global_work_size); buffers.push_back(output_buffer); runtime->set_kernel_argument(kernel, 0, input_buffer); runtime->set_kernel_argument(kernel, 1, output_buffer); runtime->run_kernel(kernel, global_work_size); std::vector<int> output = runtime->read_buffer_to_vector<int>(output_buffer); for (auto &buffer : buffers) { runtime->release_buffer(buffer); } return output; } template <typename T> std::vector<int> run_pure_type_kernel(const cassian::Kernel &kernel, const size_t global_work_size, cassian::Runtime *runtime) { std::vector<ca::Buffer> buffers; ca::Buffer output_buffer = runtime->create_buffer(sizeof(int) * global_work_size); buffers.push_back(output_buffer); runtime->set_kernel_argument(kernel, 0, output_buffer); runtime->run_kernel(kernel, global_work_size); std::vector<int> output = runtime->read_buffer_to_vector<int>(output_buffer); for (auto &buffer : buffers) { runtime->release_buffer(buffer); } return output; } using GentypeTypes = ca::TupleConcat<ca::ScalarTypes, ca::VectorTypes>::type; template <typename T> std::string test_name() { return std::string(T::type_name); } TEMPLATE_LIST_TEST_CASE_CUSTOM_NAME("vec_step_data_type", "", GentypeTypes, test_name<TestType>) { const TestConfig &config = get_test_config(); ca::Requirements requirements; requirements.arithmetic_type<typename TestType::scalar_type>(); if (ca::should_skip_test(requirements, *config.runtime())) { return; } ca::Runtime *runtime = config.runtime(); const std::string program_type = config.program_type(); const size_t global_work_size = config.work_size(); using data_host_type = typename TestType::host_type; const std::vector<data_host_type> input(global_work_size, data_host_type(123)); const std::string build_options = get_build_options<TestType>(); ca::Kernel kernel = create_kernel("kernels/oclc_miscellaneous_vector_functions/vec_step.cl", "test_data_type", build_options, runtime, program_type); const std::vector<int> output = run_data_type_kernel(kernel, global_work_size, input, runtime); runtime->release_kernel(kernel); const std::vector<int> reference = std::vector<int>(global_work_size, get_reference<TestType>()); REQUIRE_THAT(output, Catch::Equals(reference)); } TEMPLATE_LIST_TEST_CASE_CUSTOM_NAME("vec_step_pure_type", "", GentypeTypes, test_name<TestType>) { const TestConfig &config = get_test_config(); ca::Requirements requirements; requirements.arithmetic_type<typename TestType::scalar_type>(); if (ca::should_skip_test(requirements, *config.runtime())) { return; } ca::Runtime *runtime = config.runtime(); const std::string program_type = config.program_type(); const size_t global_work_size = config.work_size(); const std::string build_options = get_build_options<TestType>(); ca::Kernel kernel = create_kernel("kernels/oclc_miscellaneous_vector_functions/vec_step.cl", "test_pure_type", build_options, runtime, program_type); using data_host_type = typename TestType::host_type; const std::vector<int> output = run_pure_type_kernel<data_host_type>(kernel, global_work_size, runtime); runtime->release_kernel(kernel); const std::vector<int> reference = std::vector<int>(global_work_size, get_reference<TestType>()); REQUIRE_THAT(output, Catch::Equals(reference)); } }
int get_reference() { using data_host_type = typename T::host_type; if constexpr (ca::is_vector_v<data_host_type>) { return data_host_type::size_in_memory; } return 1; }
function_block-full_function
[ { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_VECTOR_VECTOR_HPP\n\n#define CASSIAN_VECTOR_VECTOR_HPP\n\n\n\n#include <algorithm>\n\n#include <array>\n\n#include <cstddef>\n\n#include <functional>\n\n#include <initializer_list>\n\n#include <sstream>\n\n#include <stdexcept>\n\n#include <string>\n\n#include <type_traits>\n\n#include <vector>\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 0, "score": 166960.65098467225 }, { "content": " * @tparam TYPE type to extract vector size\n\n * @returns 1\n\n *\n\n */\n\ntemplate <typename TYPE,\n\n typename std::enable_if_t<std::is_integral_v<TYPE>, int> = 0>\n\nint get_vector_size() {\n\n return 1;\n\n}\n\n\n\n} // namespace cassian\n\n#endif\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 1, "score": 166948.40119518444 }, { "content": " * cassian::Vector\n\n */\n\ntemplate <typename T> using make_signed_t = typename MakeSigned<T>::type;\n\n\n\n/**\n\n * MakeUnsigned works as std::make_unsigned but works with cassian::Vector\n\n */\n\ntemplate <typename T, typename ENABLE = void> struct MakeUnsigned {\n\n /**\n\n * Make unsigned\n\n */\n\n using type = std::make_unsigned_t<T>;\n\n};\n\n/**\n\n * MakeUnsigned works same as std::make_unsigned but works with cassian::Vector\n\n */\n\ntemplate <typename T> struct MakeUnsigned<T, typename T::is_vector> {\n\n /**\n\n * Make unsigned\n\n */\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 2, "score": 166945.38432577747 }, { "content": "\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Exception class used when a Vector can't be constructed with a given number\n\n * of elements.\n\n */\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 3, "score": 166945.00528544476 }, { "content": " */\n\n using is_vector = void; // used for template metaprograming\n\n\n\nprivate:\n\n std::array<T, SIZE_IN_MEMORY> data_;\n\n};\n\n\n\n/**\n\n * Convert Vector to string representation.\n\n *\n\n * @param[in] value object to convert.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n\ntemplate <typename T, int N, int SIZE_IN_MEMORY = N>\n\nstd::string to_string(const Vector<T, N, SIZE_IN_MEMORY> &value) {\n\n std::stringstream ss;\n\n ss << \"{\";\n\n for (size_t i = 0; i < value.size(); ++i) {\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 4, "score": 166944.95296363067 }, { "content": " * MakeSigned works same as std::make_signed but works with cassian::Vector\n\n */\n\ntemplate <typename T, typename ENABLE = void> struct MakeSigned {\n\n /**\n\n * Make signed\n\n */\n\n using type = std::make_signed_t<T>;\n\n};\n\n/**\n\n * MakeSigned works as std::make_signed but works with cassian::Vector\n\n */\n\ntemplate <typename T> struct MakeSigned<T, typename T::is_vector> {\n\n /**\n\n * Make signed\n\n */\n\n using type = Vector<std::make_signed_t<typename T::value_type>,\n\n T::vector_size, T::size_in_memory>;\n\n};\n\n/**\n\n * cassian::make_signed_t works same as std::make_signed_t but it works with\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 5, "score": 166944.72695455517 }, { "content": " ss << std::to_string(+value[i]);\n\n if (i < value.size() - 1) {\n\n ss << \", \";\n\n }\n\n }\n\n ss << \"}\";\n\n return ss.str();\n\n}\n\n\n\n/**\n\n * Append string representation of Vector object to a stream.\n\n *\n\n * @param[in] os stream to use.\n\n * @param[in] value object to convert.\n\n * @returns used stream.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n\ntemplate <typename T, int N, int SIZE_IN_MEMORY = N>\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 6, "score": 166943.41363977443 }, { "content": " using type = Vector<std::make_unsigned_t<typename T::value_type>,\n\n T::vector_size, T::size_in_memory>;\n\n};\n\n/**\n\n * cassian::make_unsigned_t works same as std::make_unsigned_t but it works with\n\n * cassian::Vector\n\n */\n\ntemplate <typename T> using make_unsigned_t = typename MakeUnsigned<T>::type;\n\n\n\n/**\n\n * Apply equal operator on Vectors component-wise.\n\n *\n\n * @param[in] lhs input a.\n\n * @param[in] rhs input b.\n\n * @returns output.\n\n * @tparam OUTPUT_TYPE the type of output.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 7, "score": 166943.15368212757 }, { "content": "std::ostream &operator<<(std::ostream &os,\n\n const Vector<T, N, SIZE_IN_MEMORY> &value) {\n\n os << to_string(value);\n\n return os;\n\n}\n\n\n\n/**\n\n * Meta class for vector types.\n\n *\n\n * @tparam T scalar type.\n\n */\n\ntemplate <typename T, typename ENABLE = void> struct IsVector {\n\n /**\n\n * Scalar type.\n\n */\n\n static const bool value = false;\n\n};\n\n\n\n/**\n\n * Meta class for vector types.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 8, "score": 166943.0519303801 }, { "content": " * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n\ntemplate <typename T, int N, int SIZE_IN_MEMORY = N> class Vector {\n\npublic:\n\n /**\n\n * Default constructor.\n\n */\n\n Vector() = default;\n\n\n\n /**\n\n * Construct Vector from std::initializer_list.\n\n *\n\n * @param[in] list std::initializer_list from which Vector should be\n\n * constructed.\n\n * @throws cassian::VectorBadNumberOfElementsException Thrown if list has\n\n * different number of elements than constructed Vector.\n\n */\n\n Vector(std::initializer_list<T> list) {\n\n const int list_size = static_cast<int>(list.size());\n\n if (list_size == N) {\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 9, "score": 166942.11584807088 }, { "content": " const T &rhs) {\n\n const Vector<T, N, SIZE_IN_MEMORY> vector_rhs(rhs);\n\n return not_equal_component_wise<OUTPUT_TYPE>(lhs, vector_rhs);\n\n}\n\n\n\n/**\n\n * Apply not operator on a Vector component-wise.\n\n *\n\n * @param[in] v input.\n\n * @returns output.\n\n * @tparam OUTPUT_TYPE the type of output.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n\ntemplate <typename OUTPUT_TYPE, typename T, int N, int SIZE_IN_MEMORY = N>\n\nOUTPUT_TYPE not_component_wise(const Vector<T, N, SIZE_IN_MEMORY> &v) {\n\n using scalar_type = cassian::scalar_type_v<OUTPUT_TYPE>;\n\n OUTPUT_TYPE output;\n\n for (size_t i = 0; i < output.size(); ++i) {\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 10, "score": 166941.41842917225 }, { "content": "template <typename OUTPUT_TYPE, typename T, int N, int SIZE_IN_MEMORY = N>\n\nOUTPUT_TYPE equal_component_wise(const Vector<T, N, SIZE_IN_MEMORY> &lhs,\n\n const Vector<T, N, SIZE_IN_MEMORY> &rhs) {\n\n using scalar_type = cassian::scalar_type_v<OUTPUT_TYPE>;\n\n OUTPUT_TYPE output;\n\n for (size_t i = 0; i < output.size(); ++i) {\n\n output[i] = lhs[i] == rhs[i] ? scalar_type(-1) : scalar_type(0);\n\n }\n\n return output;\n\n}\n\n\n\n/**\n\n * Apply equal operator on a Vector and scalar component-wise.\n\n *\n\n * @param[in] lhs input a.\n\n * @param[in] rhs input b.\n\n * @returns output.\n\n * @tparam OUTPUT_TYPE the type of output.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 11, "score": 166941.16411715923 }, { "content": " *\n\n * @tparam T vector type.\n\n */\n\ntemplate <typename T> struct IsVector<T, typename T::is_vector> {\n\n /**\n\n * Vector type.\n\n */\n\n static const bool value = true;\n\n};\n\n\n\n/**\n\n * Returns true if T is a Vector class.\n\n *\n\n * @tparam T type.\n\n */\n\ntemplate <typename T> constexpr bool is_vector_v = IsVector<T>::value;\n\n\n\n/**\n\n * Metafunction to enable a function declaration if T is a Vector.\n\n *\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 12, "score": 166939.78073544125 }, { "content": " * @tparam T type.\n\n */\n\ntemplate <typename T>\n\nusing EnableIfIsVector = std::enable_if_t<is_vector_v<T>, int>;\n\n\n\n/**\n\n * Metafunction to enable a function declaration if T is a scalar.\n\n *\n\n * @tparam T type.\n\n */\n\ntemplate <typename T>\n\nusing EnableIfIsScalar = std::enable_if_t<!is_vector_v<T>, int>;\n\n\n\n/**\n\n * Metafunction to enable a function declaration if T is integral.\n\n *\n\n * @tparam T type.\n\n */\n\ntemplate <typename T>\n\nusing EnableIfIsIntegral = std::enable_if_t<std::is_integral<T>::value, int>;\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 13, "score": 166939.17002711943 }, { "content": "};\n\n\n\n/**\n\n * Meta class for scalar types.\n\n *\n\n * @tparam T vector type.\n\n */\n\ntemplate <typename T> struct ScalarType<T, typename T::is_vector> {\n\n /**\n\n * Scalar type.\n\n */\n\n using value = typename T::value_type;\n\n};\n\n\n\n/**\n\n * Scalar type.\n\n */\n\ntemplate <typename T> using scalar_type_v = typename ScalarType<T>::value;\n\n\n\n/**\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 14, "score": 166938.80150212932 }, { "content": "template <typename OUTPUT_TYPE, typename T, int N, int SIZE_IN_MEMORY = N>\n\nOUTPUT_TYPE equal_component_wise(const Vector<T, N, SIZE_IN_MEMORY> &lhs,\n\n const T &rhs) {\n\n const Vector<T, N, SIZE_IN_MEMORY> vector_rhs(rhs);\n\n return equal_component_wise<OUTPUT_TYPE>(lhs, vector_rhs);\n\n}\n\n\n\n/**\n\n * Apply not equal operator on Vectors component-wise.\n\n *\n\n * @param[in] lhs input a.\n\n * @param[in] rhs input b.\n\n * @returns output.\n\n * @tparam OUTPUT_TYPE the type of output.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n\ntemplate <typename OUTPUT_TYPE, typename T, int N, int SIZE_IN_MEMORY = N>\n\nOUTPUT_TYPE not_equal_component_wise(const Vector<T, N, SIZE_IN_MEMORY> &lhs,\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 15, "score": 166938.64879483494 }, { "content": "template <typename OUTPUT_TYPE, typename T, int N, int SIZE_IN_MEMORY = N>\n\nOUTPUT_TYPE not_equal_component_wise(const T &lhs,\n\n const Vector<T, N, SIZE_IN_MEMORY> &rhs) {\n\n const Vector<T, N, SIZE_IN_MEMORY> vector_lhs(lhs);\n\n return not_equal_component_wise<OUTPUT_TYPE>(vector_lhs, rhs);\n\n}\n\n\n\n/**\n\n * Apply not equal operator on a Vector and scalar component-wise.\n\n *\n\n * @param[in] lhs input a.\n\n * @param[in] rhs input b.\n\n * @returns output.\n\n * @tparam OUTPUT_TYPE the type of output.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n\ntemplate <typename OUTPUT_TYPE, typename T, int N, int SIZE_IN_MEMORY = N>\n\nOUTPUT_TYPE not_equal_component_wise(const Vector<T, N, SIZE_IN_MEMORY> &lhs,\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 16, "score": 166938.63161674404 }, { "content": " output[i] = !v[i] ? scalar_type(-1) : scalar_type(0);\n\n }\n\n return output;\n\n}\n\n\n\n/**\n\n * Get vector size. For scalar types return 1.\n\n *\n\n * @tparam TYPE type to extract vector size\n\n * @tparam N disables function when TYPE::vector_size doesn't exist\n\n * @returns vector size\n\n *\n\n */\n\ntemplate <typename TYPE, int N = TYPE::vector_size> int get_vector_size() {\n\n return N;\n\n}\n\n\n\n/**\n\n * @overload for scalar types\n\n *\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 17, "score": 166938.4627463174 }, { "content": " std::copy(list.begin(), list.end(), data_.begin());\n\n } else {\n\n throw VectorBadNumberOfElementsException(\"initializer list\", N,\n\n list_size);\n\n }\n\n }\n\n\n\n /**\n\n * Construct Vector from std::vector.\n\n *\n\n * @param[in] vector std::vector from which Vector should be constructed.\n\n * @throws cassian::VectorBadNumberOfElementsException Thrown if vector has\n\n * different number of elements than constructed Vector.\n\n */\n\n explicit Vector(std::vector<T> vector) {\n\n const int vector_size = static_cast<int>(vector.size());\n\n if (vector.size() == N) {\n\n std::move(vector.begin(), vector.end(), data_.begin());\n\n } else {\n\n throw VectorBadNumberOfElementsException(\"std::vector\", N, vector_size);\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 18, "score": 166938.1847812732 }, { "content": " const Vector<T, N, SIZE_IN_MEMORY> &rhs) {\n\n using scalar_type = cassian::scalar_type_v<OUTPUT_TYPE>;\n\n OUTPUT_TYPE output;\n\n for (size_t i = 0; i < output.size(); ++i) {\n\n output[i] = lhs[i] != rhs[i] ? scalar_type(-1) : scalar_type(0);\n\n }\n\n return output;\n\n}\n\n\n\n/**\n\n * Apply not equal operator on a Vector and scalar component-wise.\n\n *\n\n * @param[in] lhs input a.\n\n * @param[in] rhs input b.\n\n * @returns output.\n\n * @tparam OUTPUT_TYPE the type of output.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 19, "score": 166937.7324854386 }, { "content": " * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n\ntemplate <typename OUTPUT_TYPE, typename T, int N, int SIZE_IN_MEMORY = N>\n\nOUTPUT_TYPE equal_component_wise(const T &lhs,\n\n const Vector<T, N, SIZE_IN_MEMORY> &rhs) {\n\n const Vector<T, N, SIZE_IN_MEMORY> vector_lhs(lhs);\n\n return equal_component_wise<OUTPUT_TYPE>(vector_lhs, rhs);\n\n}\n\n\n\n/**\n\n * Apply equal operator on a Vector and scalar component-wise.\n\n *\n\n * @param[in] lhs input a.\n\n * @param[in] rhs input b.\n\n * @returns output.\n\n * @tparam OUTPUT_TYPE the type of output.\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n\n * @tparam SIZE_IN_MEMORY size of vector in memory in elements.\n\n */\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 20, "score": 166937.70499233916 }, { "content": " */\n\n friend Vector operator%(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n lhs_vector %= rhs;\n\n return lhs_vector;\n\n }\n\n\n\n /**\n\n * Modulo operator.\n\n *\n\n * @param[in] lhs Vector to modulo.\n\n * @param[in] rhs scalar to modulo.\n\n * @returns result of modulo.\n\n * @overload\n\n */\n\n friend Vector operator%(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n lhs %= rhs_vector;\n\n return lhs;\n\n }\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 21, "score": 166934.2454750566 }, { "content": " * @returns result of subtraction.\n\n * @overload\n\n */\n\n friend Vector operator-(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n lhs_vector -= rhs;\n\n return lhs_vector;\n\n }\n\n\n\n /**\n\n * Subtraction operator.\n\n *\n\n * @param[in] lhs Vector to subtract.\n\n * @param[in] rhs scalar to subtract.\n\n * @returns result of subtraction.\n\n * @overload\n\n */\n\n friend Vector operator-(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n lhs -= rhs_vector;\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 22, "score": 166934.23720788755 }, { "content": " * @returns result of multiplication.\n\n */\n\n friend Vector operator*(Vector lhs, const Vector &rhs) {\n\n lhs *= rhs;\n\n return lhs;\n\n }\n\n\n\n /**\n\n * Multiplication operator.\n\n *\n\n * @param[in] lhs scalar to multiply.\n\n * @param[in] rhs Vector to multiply.\n\n * @returns result of multiplication.\n\n * @overload\n\n */\n\n friend Vector operator*(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n lhs_vector *= rhs;\n\n return lhs_vector;\n\n }\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 23, "score": 166934.19288197465 }, { "content": " *\n\n * @param[in] lhs Vector to add.\n\n * @param[in] rhs Vector to add.\n\n * @returns result of addition.\n\n */\n\n friend Vector operator+(Vector lhs, const Vector &rhs) {\n\n lhs += rhs;\n\n return lhs;\n\n }\n\n\n\n /**\n\n * Addition operator.\n\n *\n\n * @param[in] lhs scalar to add.\n\n * @param[in] rhs Vector to add.\n\n * @returns result of addition.\n\n * @overload\n\n */\n\n friend Vector operator+(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 24, "score": 166934.1782502622 }, { "content": " *\n\n * @param[in] lhs scalar to compare.\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if any value is not equal.\n\n */\n\n friend bool operator!=(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n return lhs_vector != rhs;\n\n }\n\n\n\n /**\n\n * Not equal operator.\n\n *\n\n * @param[in] lhs Vector to compare.\n\n * @param[in] rhs scalar to compare.\n\n * @returns true if any value is not equal.\n\n */\n\n friend bool operator!=(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n return lhs != rhs_vector;\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 25, "score": 166934.13954836378 }, { "content": " */\n\n friend bool operator<(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n return lhs_vector < rhs;\n\n }\n\n\n\n /**\n\n * Less than operator.\n\n *\n\n * @param[in] lhs Vector to compare.\n\n * @param[in] rhs scalar to compare.\n\n * @returns true if all lhs values are less than rhs values.\n\n */\n\n friend bool operator<(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n return lhs < rhs_vector;\n\n }\n\n\n\n /**\n\n * Greater than operator.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 26, "score": 166934.1235328709 }, { "content": " lhs_vector += rhs;\n\n return lhs_vector;\n\n }\n\n\n\n /**\n\n * Addition operator.\n\n *\n\n * @param[in] lhs Vector to add.\n\n * @param[in] rhs scalar to add.\n\n * @returns result of addition.\n\n * @overload\n\n */\n\n friend Vector operator+(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n lhs += rhs_vector;\n\n return lhs;\n\n }\n\n\n\n /**\n\n * Subtraction assignment operator.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 27, "score": 166934.1274934368 }, { "content": " *\n\n * @param[in] rhs Vector to subtract.\n\n * @returns this after subtraction.\n\n */\n\n Vector &operator-=(const Vector &rhs) {\n\n std::transform(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), data_.begin(), std::minus<T>());\n\n return *this;\n\n }\n\n\n\n /**\n\n * Subtraction operator.\n\n *\n\n * @param[in] lhs Vector to subtract.\n\n * @param[in] rhs Vector to subtract.\n\n * @returns result of subtraction.\n\n */\n\n friend Vector operator-(Vector lhs, const Vector &rhs) {\n\n lhs -= rhs;\n\n return lhs;\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 28, "score": 166934.11821977526 }, { "content": " }\n\n }\n\n\n\n /**\n\n * Construct Vector from a scalar.\n\n *\n\n * @param[in] scalar value which will be used to fill a Vector.\n\n */\n\n explicit Vector(T scalar) { std::fill(data_.begin(), data_.end(), scalar); }\n\n\n\n /**\n\n * Copy constructor.\n\n */\n\n Vector(const Vector &) = default;\n\n\n\n /**\n\n * Move constructor.\n\n */\n\n Vector(Vector &&) noexcept = default;\n\n\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 29, "score": 166934.0984932004 }, { "content": " * Division operator.\n\n *\n\n * @param[in] lhs scalar to divide.\n\n * @param[in] rhs Vector to divide.\n\n * @returns result of division.\n\n * @overload\n\n */\n\n friend Vector operator/(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n lhs_vector /= rhs;\n\n return lhs_vector;\n\n }\n\n\n\n /**\n\n * Division operator.\n\n *\n\n * @param[in] lhs Vector to divide.\n\n * @param[in] rhs scalar to divide.\n\n * @returns result of division.\n\n * @overload\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 30, "score": 166934.09175411562 }, { "content": " */\n\n Vector &operator/=(const Vector &rhs) {\n\n std::transform(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), data_.begin(), std::divides<T>());\n\n return *this;\n\n }\n\n\n\n /**\n\n * Division operator.\n\n *\n\n * @param[in] lhs Vector to divide.\n\n * @param[in] rhs Vector to divide.\n\n * @returns result of division.\n\n */\n\n friend Vector operator/(Vector lhs, const Vector &rhs) {\n\n lhs /= rhs;\n\n return lhs;\n\n }\n\n\n\n /**\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 31, "score": 166934.09175411556 }, { "content": " */\n\n friend Vector operator/(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n lhs /= rhs_vector;\n\n return lhs;\n\n }\n\n\n\n /**\n\n * Modulo assignment operator.\n\n *\n\n * @param[in] rhs Vector to modulo.\n\n * @returns this after modulo.\n\n */\n\n Vector &operator%=(const Vector &rhs) {\n\n static_assert(std::is_integral<T>::value,\n\n \"Modulo operator is defined only for integral types\");\n\n std::transform(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), data_.begin(), std::modulus<T>());\n\n return *this;\n\n }\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 32, "score": 166934.0865222719 }, { "content": " */\n\n friend bool operator>=(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n return lhs >= rhs_vector;\n\n }\n\n\n\n /**\n\n * Addition assignment operator.\n\n *\n\n * @param[in] rhs Vector to add.\n\n * @returns this after addition.\n\n */\n\n Vector &operator+=(const Vector &rhs) {\n\n std::transform(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), data_.begin(), std::plus<T>());\n\n return *this;\n\n }\n\n\n\n /**\n\n * Addition operator.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 33, "score": 166934.07992791967 }, { "content": "\n\n /**\n\n * Multiplication operator.\n\n *\n\n * @param[in] lhs Vector to multiply.\n\n * @param[in] rhs scalar to multiply.\n\n * @returns result of multiplication.\n\n * @overload\n\n */\n\n friend Vector operator*(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n lhs *= rhs_vector;\n\n return lhs;\n\n }\n\n\n\n /**\n\n * Division assignment operator.\n\n *\n\n * @param[in] rhs Vector to divide.\n\n * @returns this after division.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 34, "score": 166934.06474827987 }, { "content": " /**\n\n * Destructor.\n\n */\n\n ~Vector() = default;\n\n\n\n /**\n\n * Copy assignment operator.\n\n */\n\n Vector &operator=(const Vector &) = default;\n\n\n\n /**\n\n * Move assignment operator.\n\n */\n\n Vector &operator=(Vector &&) noexcept = default;\n\n\n\n /**\n\n * Equal operator.\n\n *\n\n * @param[in] rhs Vector to compare against.\n\n * @returns true if all values are equal.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 35, "score": 166934.05241271894 }, { "content": " */\n\n bool operator==(const Vector &rhs) const {\n\n return std::equal(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), rhs.data_.begin() + vector_size);\n\n };\n\n\n\n /**\n\n * Equal operator.\n\n *\n\n * @param[in] lhs scalar to compare.\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all values are equal.\n\n */\n\n friend bool operator==(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n return lhs_vector == rhs;\n\n }\n\n\n\n /**\n\n * Equal operator.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 36, "score": 166934.05055030427 }, { "content": " *\n\n * @param[in] lhs Vector to compare.\n\n * @param[in] rhs scalar to compare.\n\n * @returns true if all values are equal.\n\n */\n\n friend bool operator==(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n return lhs == rhs_vector;\n\n }\n\n\n\n /**\n\n * Not equal operator.\n\n *\n\n * @param[in] rhs Vector to compare against.\n\n * @returns true if any value is not equal.\n\n */\n\n bool operator!=(const Vector &rhs) const { return !(*this == rhs); };\n\n\n\n /**\n\n * Not equal operator.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 37, "score": 166934.03135241033 }, { "content": " *\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are greater than rhs values.\n\n */\n\n bool operator>(const Vector &rhs) const {\n\n return std::equal(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), rhs.data_.begin() + vector_size,\n\n [](T a, T b) -> bool { return a > b; });\n\n };\n\n\n\n /**\n\n * Greater than operator.\n\n *\n\n * @param[in] lhs scalar to compare.\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are greater than rhs values.\n\n */\n\n friend bool operator>(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n return lhs_vector > rhs;\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 38, "score": 166934.0343734522 }, { "content": " *\n\n * @param[in] lhs Vector to compare.\n\n * @param[in] rhs scalar to compare.\n\n * @returns true if all lhs values are less than or equal to rhs values.\n\n */\n\n friend bool operator<=(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n return lhs <= rhs_vector;\n\n }\n\n\n\n /**\n\n * Greater than or equal operator.\n\n *\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are greater than or equal to rhs values.\n\n */\n\n bool operator>=(const Vector &rhs) const {\n\n return std::equal(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), rhs.data_.begin() + vector_size,\n\n [](T a, T b) -> bool { return a >= b; });\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 39, "score": 166934.01889211228 }, { "content": "\n\n /**\n\n * Modulo operator.\n\n *\n\n * @param[in] lhs Vector to module.\n\n * @param[in] rhs Vector to module.\n\n * @returns result of module.\n\n */\n\n friend Vector operator%(Vector lhs, const Vector &rhs) {\n\n lhs %= rhs;\n\n return lhs;\n\n }\n\n\n\n /**\n\n * Modulo operator.\n\n *\n\n * @param[in] lhs scalar to modulo.\n\n * @param[in] rhs Vector to modulo.\n\n * @returns result of modulo.\n\n * @overload\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 40, "score": 166934.01363257275 }, { "content": " bool operator<=(const Vector &rhs) const {\n\n return std::equal(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), rhs.data_.begin() + vector_size,\n\n [](T a, T b) -> bool { return a <= b; });\n\n };\n\n\n\n /**\n\n * Less than or equal operator.\n\n *\n\n * @param[in] lhs scalar to compare.\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are less than or equal to rhs values.\n\n */\n\n friend bool operator<=(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n return lhs_vector <= rhs;\n\n }\n\n\n\n /**\n\n * Less than or equal operator.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 41, "score": 166933.99833720032 }, { "content": " Vector output(*this);\n\n --(*this);\n\n return output;\n\n }\n\n\n\n /**\n\n * Size of vector.\n\n *\n\n * @returns number of elements in vector.\n\n */\n\n int size() const { return N; }\n\n\n\n /**\n\n * Get element from vector.\n\n *\n\n * @param[in] index index of an element to return.\n\n * @returns vector element.\n\n */\n\n T &operator[](int index) {\n\n if (index < N) {\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 42, "score": 166933.961566185 }, { "content": "\n\n /**\n\n * Pre-increment operator.\n\n *\n\n * @returns this after increment operation.\n\n */\n\n Vector &operator++() {\n\n std::for_each(data_.begin(), data_.begin() + vector_size,\n\n [](T &a) { ++a; });\n\n return *this;\n\n }\n\n\n\n /**\n\n * Post-increment operator.\n\n *\n\n * @returns Vector after increment operation.\n\n */\n\n Vector operator++(int) {\n\n Vector output(*this);\n\n ++(*this);\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 43, "score": 166933.961566185 }, { "content": " }\n\n\n\n /**\n\n * Unary minus operator.\n\n *\n\n * @param[in] lhs Vector to negate.\n\n * @returns result of negation.\n\n */\n\n friend Vector operator-(const Vector &lhs) {\n\n Vector v(lhs);\n\n std::transform(v.data_.begin(), v.data_.begin() + v.vector_size,\n\n v.data_.begin(), std::negate<T>());\n\n return v;\n\n }\n\n\n\n /**\n\n * Subtraction operator.\n\n *\n\n * @param[in] lhs scalar to subtract.\n\n * @param[in] rhs Vector to subtract.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 44, "score": 166933.96011787295 }, { "content": " return lhs;\n\n }\n\n\n\n /**\n\n * Multiplication assignment operator.\n\n *\n\n * @param[in] rhs Vector to multiply.\n\n * @returns this after multiplication.\n\n */\n\n Vector &operator*=(const Vector &rhs) {\n\n std::transform(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), data_.begin(), std::multiplies<T>());\n\n return *this;\n\n }\n\n\n\n /**\n\n * Multiplication operator.\n\n *\n\n * @param[in] lhs Vector to multiply.\n\n * @param[in] rhs Vector to multiply.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 45, "score": 166933.96011787295 }, { "content": " }\n\n\n\n /**\n\n * Greater than operator.\n\n *\n\n * @param[in] lhs Vector to compare.\n\n * @param[in] rhs scalar to compare.\n\n * @returns true if all lhs values are greater than rhs values.\n\n */\n\n friend bool operator>(Vector lhs, const T &rhs) {\n\n Vector rhs_vector(rhs);\n\n return lhs > rhs_vector;\n\n }\n\n\n\n /**\n\n * Less than or equal operator.\n\n *\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are less than or equal to rhs values.\n\n */\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 46, "score": 166933.92243724788 }, { "content": " };\n\n\n\n /**\n\n * Greater than or equal operator.\n\n *\n\n * @param[in] lhs scalar to compare.\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are greater than or equal to rhs values.\n\n */\n\n friend bool operator>=(const T &lhs, const Vector &rhs) {\n\n Vector lhs_vector(lhs);\n\n return lhs_vector >= rhs;\n\n }\n\n\n\n /**\n\n * Greater than or equal operator.\n\n *\n\n * @param[in] lhs Vector to compare.\n\n * @param[in] rhs scalar to compare.\n\n * @returns true if all lhs values are greater than or equal to rhs values.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 47, "score": 166933.8778063828 }, { "content": " throw VectorAccessViolationException(index, N);\n\n }\n\n\n\n /**\n\n * Vector type.\n\n */\n\n using value_type = T;\n\n\n\n /**\n\n * Compile-time vector size.\n\n */\n\n constexpr static int vector_size = N;\n\n\n\n /**\n\n * Compile-time size in memory.\n\n */\n\n constexpr static int size_in_memory = SIZE_IN_MEMORY;\n\n\n\n /**\n\n * Metadata needed to distinguish vector-like data types.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 48, "score": 166933.85419425942 }, { "content": " return output;\n\n }\n\n\n\n /**\n\n * Pre-decrement operator.\n\n *\n\n * @returns this after decrement operation.\n\n */\n\n Vector &operator--() {\n\n std::for_each(data_.begin(), data_.begin() + vector_size,\n\n [](T &a) { --a; });\n\n return *this;\n\n }\n\n\n\n /**\n\n * Post-decrement operator.\n\n *\n\n * @returns Vector after decrement operation.\n\n */\n\n Vector operator--(int) {\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 49, "score": 166933.82999910502 }, { "content": " }\n\n\n\n /**\n\n * Less than operator.\n\n *\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are less than rhs values.\n\n */\n\n bool operator<(const Vector &rhs) const {\n\n return std::equal(data_.begin(), data_.begin() + vector_size,\n\n rhs.data_.begin(), rhs.data_.begin() + vector_size,\n\n [](T a, T b) -> bool { return a < b; });\n\n };\n\n\n\n /**\n\n * Less than operator.\n\n *\n\n * @param[in] lhs scalar to compare.\n\n * @param[in] rhs Vector to compare.\n\n * @returns true if all lhs values are less than rhs values.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 50, "score": 166933.74189607476 }, { "content": " return data_[index];\n\n }\n\n throw VectorAccessViolationException(index, N);\n\n }\n\n\n\n /**\n\n * Get iterator of a vector beginning.\n\n *\n\n */\n\n constexpr auto begin() const { return data_.begin(); }\n\n\n\n /**\n\n * Get const element from vector.\n\n *\n\n * @overload\n\n */\n\n const T &operator[](int index) const {\n\n if (index < N) {\n\n return data_[index];\n\n }\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 51, "score": 166933.5552188118 }, { "content": "\n\n/**\n\n * Metafunction to enable a function declaration if T is floating point.\n\n *\n\n * @tparam T type.\n\n */\n\ntemplate <typename T>\n\nusing EnableIfIsFloatingPoint =\n\n std::enable_if_t<std::is_floating_point<T>::value, int>;\n\n\n\n/**\n\n * Meta class for scalar types.\n\n *\n\n * @tparam T scalar type.\n\n */\n\ntemplate <typename T, typename ENABLE = void> struct ScalarType {\n\n /**\n\n * Scalar type.\n\n */\n\n using value = T;\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 52, "score": 166933.19875974176 }, { "content": "class VectorAccessViolationException : public std::logic_error {\n\npublic:\n\n /**\n\n * Construct exception with preformatted error message.\n\n *\n\n * @param[in] index accessed index.\n\n * @param[in] size size of vector.\n\n */\n\n VectorAccessViolationException(int index, int size)\n\n : std::logic_error(error_message(index, size)) {}\n\n\n\nprivate:\n\n std::string static error_message(int index, int size);\n\n};\n\n\n\n/**\n\n * Static vector implementation.\n\n *\n\n * @tparam T the type of vector elements.\n\n * @tparam N the number of vector elements.\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 53, "score": 155994.40382709014 }, { "content": "class VectorBadNumberOfElementsException : public std::logic_error {\n\npublic:\n\n /**\n\n * Construct exception with preformatted error message.\n\n *\n\n * @param[in] source source of the invalid number of elements.\n\n * @param[in] expected expected number of elements.\n\n * @param[in] actual actual number of elements.\n\n */\n\n VectorBadNumberOfElementsException(const std::string &source, int expected,\n\n int actual)\n\n : std::logic_error(error_message(source, expected, actual)) {}\n\n\n\nprivate:\n\n std::string static error_message(const std::string &source, int expected,\n\n int actual);\n\n};\n\n\n\n/**\n\n * Exception class used when a trying to access element at index greater or\n\n * equal vector size\n\n */\n", "file_path": "src/core/vector/include/cassian/vector/vector.hpp", "rank": 54, "score": 154493.97667164032 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_RUNTIME_RUNTIME_HPP\n\n#define CASSIAN_RUNTIME_RUNTIME_HPP\n\n\n\n#include <algorithm>\n\n#include <array>\n\n#include <cstddef>\n\n#include <cstdint>\n\n#include <optional>\n\n#include <sstream>\n\n#include <stdexcept>\n\n#include <string>\n\n#include <type_traits>\n\n#include <vector>\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 55, "score": 100806.0195040686 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_REFERENCE_DP4A_HPP\n\n#define CASSIAN_REFERENCE_DP4A_HPP\n\n\n\n#include <cstddef>\n\n#include <cstdint>\n\n#include <vector>\n\n\n\n#include <cassian/vector/vector.hpp>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n", "file_path": "src/core/reference/include/cassian/reference/dp4a.hpp", "rank": 56, "score": 100804.57742784992 }, { "content": "namespace fs = std::filesystem;\n\n#endif\n\n#include <stdexcept>\n\n#include <string>\n\n#include <type_traits>\n\n#include <vector>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Load text file.\n\n *\n\n * @param[in] file_path path to a file to read.\n\n * @returns text read from a file.\n\n */\n\nstd::string load_text_file(const std::string &file_path);\n\n\n", "file_path": "src/core/utility/include/cassian/utility/utility.hpp", "rank": 57, "score": 100803.75127398015 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_UTILITY_MATH_HPP\n\n#define CASSIAN_UTILITY_MATH_HPP\n\n\n\n#include <cassian/vector/vector.hpp>\n\n#include <cmath>\n\n#include <limits>\n\n#include <numeric>\n\n\n\nnamespace cassian {\n\n\n\n/**\n\n * Computes dot product of two vectors\n\n * @param[in] a input vector.\n", "file_path": "src/core/utility/include/cassian/utility/math.hpp", "rank": 58, "score": 100803.15971931555 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_UTILITY_UTILITY_HPP\n\n#define CASSIAN_UTILITY_UTILITY_HPP\n\n\n\n#include <cassert>\n\n#include <cassian/vector/vector.hpp>\n\n#include <cstddef>\n\n#include <cstdint>\n\n#include <cstring>\n\n#ifdef CASSIAN_OLD_GNU\n\n#include <experimental/filesystem>\n\nnamespace fs = std::experimental::filesystem;\n\n#else\n\n#include <filesystem>\n", "file_path": "src/core/utility/include/cassian/utility/utility.hpp", "rank": 59, "score": 100802.32962385922 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_RUNTIME_FACTORY_HPP\n\n#define CASSIAN_RUNTIME_FACTORY_HPP\n\n\n\n#include <cassian/cli/cli.hpp>\n\n#include <cassian/runtime/runtime.hpp>\n\n#include <memory>\n\n#include <stdexcept>\n\n#include <string>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n", "file_path": "src/core/runtime/include/cassian/runtime/factory.hpp", "rank": 60, "score": 100798.47965417188 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_RANDOM_RANDOM_HPP\n\n#define CASSIAN_RANDOM_RANDOM_HPP\n\n\n\n#include <algorithm>\n\n#include <cstdint>\n\n#include <limits>\n\n#include <random>\n\n#include <vector>\n\n\n\n#include <cassian/fp_types/bfloat.hpp>\n\n#include <cassian/fp_types/half.hpp>\n\n#include <cassian/fp_types/tfloat.hpp>\n\n#include <cassian/vector/vector.hpp>\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 61, "score": 100798.43023412861 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_SYSTEM_FACTORY_HPP\n\n#define CASSIAN_SYSTEM_FACTORY_HPP\n\n\n\n#include <cassian/system/library.hpp>\n\n#include <memory>\n\n#include <string>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n", "file_path": "src/core/system/include/cassian/system/factory.hpp", "rank": 62, "score": 100798.36726740938 }, { "content": "/**\n\n * Compute dp4a reference from regular elements.\n\n *\n\n * This function implements algorithm for computing `dot(a, b) + c`.\n\n *\n\n * @tparam A_TYPE the type of input_a.\n\n * @tparam B_TYPE the type of input_b.\n\n * @param[in] input_a a operand.\n\n * @param[in] input_b b operand.\n\n * @param[in] input_c c operand.\n\n * @returns `dot(a, b) + c`.\n\n */\n\ntemplate <typename A_TYPE, typename B_TYPE>\n\nstd::vector<int32_t> dp4a(const std::vector<A_TYPE> &input_a,\n\n const std::vector<B_TYPE> &input_b,\n\n const std::vector<int32_t> &input_c);\n\n\n\n} // namespace cassian\n\n#endif\n", "file_path": "src/core/reference/include/cassian/reference/dp4a.hpp", "rank": 63, "score": 100798.32493640191 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_MAIN_CONFIG_HPP\n\n#define CASSIAN_MAIN_CONFIG_HPP\n\n\n\n#include <memory>\n\n#include <string>\n\n\n\n#include <cassian/cli/cli.hpp>\n\n#include <cassian/runtime/runtime.hpp>\n\n\n\nnamespace cassian {\n\nnamespace test {\n\n\n", "file_path": "src/core/main/include/cassian/main/config.hpp", "rank": 64, "score": 100798.30855255334 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_IMAGE_IMAGE_HPP\n\n#define CASSIAN_IMAGE_IMAGE_HPP\n\n\n\n#include <stdexcept>\n\n#include <vector>\n\n\n\n#include <cassian/random/random.hpp>\n\n#include <cassian/runtime/image_properties.hpp>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n", "file_path": "src/core/image/include/cassian/image/image.hpp", "rank": 65, "score": 100798.13011673458 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_UTILITY_VERSION_HPP\n\n#define CASSIAN_UTILITY_VERSION_HPP\n\n\n\n#include <string>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Get version string.\n\n *\n", "file_path": "src/core/utility/include/cassian/utility/version.hpp", "rank": 66, "score": 100798.03131427511 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_CLI_CLI_HPP\n\n#define CASSIAN_CLI_CLI_HPP\n\n\n\n#include <string>\n\n#include <unordered_map>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Class for parsing command line arguments.\n\n */\n", "file_path": "src/core/cli/include/cassian/cli/cli.hpp", "rank": 67, "score": 100797.684740332 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_SYSTEM_LIBRARY_HPP\n\n#define CASSIAN_SYSTEM_LIBRARY_HPP\n\n\n\n#include <stdexcept>\n\n#include <string>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Interface for a system specific, shared library management.\n\n */\n", "file_path": "src/core/system/include/cassian/system/library.hpp", "rank": 68, "score": 100797.684740332 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_RUNTIME_FEATURE_HPP\n\n#define CASSIAN_RUNTIME_FEATURE_HPP\n\n\n\n#include <string>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Runtime features.\n\n */\n", "file_path": "src/core/runtime/include/cassian/runtime/feature.hpp", "rank": 69, "score": 100797.11882682968 }, { "content": " * Returned value of an argument.\n\n *\n\n * @tparam T the type of returned argument value.\n\n * @param[in] name argument name.\n\n * @returns argument value.\n\n * @note T must define a constructor accepting std::string.\n\n */\n\n template <typename T> T get(const std::string &name) const;\n\n\n\nprivate:\n\n std::unordered_map<std::string, std::string> arguments_;\n\n};\n\n\n\ntemplate <typename T> T CommandLineParser::get(const std::string &name) const {\n\n return T(arguments_.at(name));\n\n}\n\n\n\n} // namespace cassian\n\n#endif\n", "file_path": "src/core/cli/include/cassian/cli/cli.hpp", "rank": 70, "score": 100795.15433907293 }, { "content": "\n\n#include <cassian/fp_types/bfloat.hpp>\n\n#include <cassian/fp_types/half.hpp>\n\n#include <cassian/fp_types/tfloat.hpp>\n\n#include <cassian/runtime/access_qualifier.hpp>\n\n#include <cassian/runtime/device_properties.hpp>\n\n#include <cassian/runtime/feature.hpp>\n\n#include <cassian/runtime/image_properties.hpp>\n\n#include <cassian/runtime/program_descriptor.hpp>\n\n#include <cassian/runtime/sampler_properties.hpp>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * API agnostic representation of a compute buffer.\n\n */\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 71, "score": 100793.85397939649 }, { "content": "/**\n\n * Generate random Vector value.\n\n *\n\n * @overload\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsVector<T> = 0>\n\nT generate_value(const int seed) {\n\n using scalar_type = scalar_type_v<T>;\n\n const scalar_type min = std::numeric_limits<scalar_type>::min();\n\n const scalar_type max = std::numeric_limits<scalar_type>::max();\n\n return generate_value<T>(min, max, seed);\n\n}\n\n\n\n/**\n\n * Generate vector of random scalar values in range [min, max].\n\n *\n\n * @param[in] size Number of values to generate.\n\n * @param[in] min Minimum value.\n\n * @param[in] max Maximum value.\n\n * @param[in] seed Random seed.\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 72, "score": 100793.25293631869 }, { "content": " return output;\n\n}\n\n\n\n/**\n\n * Unpack a vector into smaller data type. Overload when unpacking from\n\n * cassian::Vector\n\n *\n\n * @overload\n\n */\n\ntemplate <typename OUTPUT_TYPE, typename VALUE_TYPE, int N, int SIZE_IN_MEMORY>\n\nstd::vector<OUTPUT_TYPE>\n\nunpack_vector(const std::vector<Vector<VALUE_TYPE, N, SIZE_IN_MEMORY>> &input,\n\n const int step = 1) {\n\n static_assert(std::is_same<OUTPUT_TYPE, VALUE_TYPE>::value,\n\n \"When unpacking ca::Vector OUTPUT_TYPE needs to be same as \"\n\n \"VECTOR::value_type\");\n\n assert(step > 0);\n\n\n\n std::vector<VALUE_TYPE> output(input.size() * N);\n\n\n", "file_path": "src/core/utility/include/cassian/utility/utility.hpp", "rank": 73, "score": 100793.21905366905 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_LOGGING_LOGGING_HPP\n\n#define CASSIAN_LOGGING_LOGGING_HPP\n\n\n\n#include <iostream>\n\n\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Namespace for logging related functions.\n\n */\n\nnamespace logging {\n\n\n\n/**\n\n * Class implementing logging capabilities.\n\n */\n", "file_path": "src/core/logging/include/cassian/logging/logging.hpp", "rank": 74, "score": 100792.51345007909 }, { "content": " * @returns version string.\n\n */\n\nstd::string get_version();\n\n\n\n/**\n\n * Print version string.\n\n */\n\nvoid print_version();\n\n\n\n} // namespace cassian\n\n#endif\n", "file_path": "src/core/utility/include/cassian/utility/version.hpp", "rank": 75, "score": 100791.74177711915 }, { "content": "/*\n\n * Copyright (C) 2021 Intel Corporation\n\n *\n\n * SPDX-License-Identifier: MIT\n\n *\n\n */\n\n\n\n#ifndef CASSIAN_UTILITY_METAPROGRAMMING_HPP\n\n#define CASSIAN_UTILITY_METAPROGRAMMING_HPP\n\n\n\n#include <tuple>\n\n#include <type_traits>\n\n\n\nnamespace cassian {\n\n\n\n/**\n\n * Iterates over @c std::integer_sequence.\n\n * Example usage:\n\n * @code{.cpp}\n\n * static_for(std::index_sequence<2, 3, 4, 8, 16>{}, [&](auto i) {\n", "file_path": "src/core/utility/include/cassian/utility/metaprogramming.hpp", "rank": 76, "score": 100791.36262301511 }, { "content": "std::vector<T> generate_vector(const int size, const int seed) {\n\n std::vector<T> data(size);\n\n std::generate(data.begin(), data.end(),\n\n [&] { return generate_value<T>(seed); });\n\n return data;\n\n}\n\n\n\n} // namespace cassian\n\n\n\n#endif\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 77, "score": 100790.58649847076 }, { "content": "\n\n return data_[index];\n\n }\n\n\n\nprivate:\n\n const ImageDimensions dimensions_;\n\n std::vector<pixel_type> data_;\n\n};\n\n\n\n} // namespace cassian\n\n#endif\n", "file_path": "src/core/image/include/cassian/image/image.hpp", "rank": 78, "score": 100790.39465897255 }, { "content": " * @param[in] str string to convert.\n\n * @returns converted string.\n\n */\n\nstd::string convert_to_forward_slashes(const std::string &str);\n\n\n\n/**\n\n * Convert typed-value to string. Switches between arithmetic std and\n\n * cassian to_string function\n\n *\n\n * @tparam T the type to log.\n\n * @param[in] value typed value to convert.\n\n * @returns string returned from another to_string function.\n\n */\n\ntemplate <typename T> std::string to_string(const T &value) {\n\n if constexpr (std::is_arithmetic_v<T>) {\n\n return std::to_string(value);\n\n } else {\n\n return to_string(value);\n\n }\n\n}\n", "file_path": "src/core/utility/include/cassian/utility/utility.hpp", "rank": 79, "score": 100790.26535298128 }, { "content": " std::memcpy(&output[output_offset], tmp.data(), sizeof(OUTPUT_TYPE));\n\n }\n\n }\n\n\n\n return output;\n\n}\n\n\n\n/**\n\n * Pack a vector into larger data type. Overload when packing into\n\n * cassian::Vector\n\n *\n\n * @overload\n\n */\n\ntemplate <typename VECTOR>\n\nstd::vector<Vector<typename VECTOR::value_type, VECTOR::vector_size,\n\n VECTOR::size_in_memory>>\n\npack_vector(const std::vector<typename VECTOR::value_type> &input,\n\n int step = 1) {\n\n assert(step > 0);\n\n\n", "file_path": "src/core/utility/include/cassian/utility/utility.hpp", "rank": 80, "score": 100790.04538231212 }, { "content": " * @tparam T type of generated values.\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsVector<T> = 0>\n\nstd::vector<T> generate_vector(const int size, const scalar_type_v<T> min,\n\n const scalar_type_v<T> max, const int seed) {\n\n std::vector<T> data(size);\n\n std::generate(data.begin(), data.end(),\n\n [&] { return generate_value<T>(min, max, seed); });\n\n return data;\n\n}\n\n\n\n/**\n\n * Generate vector of random values.\n\n *\n\n * @param[in] size Number of values to generate.\n\n * @param[in] seed Random seed.\n\n * @returns vector of generated values.\n\n * @tparam T type of generated value.\n\n */\n\ntemplate <typename T>\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 81, "score": 100789.99909380506 }, { "content": "\n\n/**\n\n * Cassian namespace.\n\n */\n\nnamespace cassian {\n\n\n\n/**\n\n * Generate random scalar value in range [min, max].\n\n *\n\n * @param[in] min Minimum value.\n\n * @param[in] max Maximum value.\n\n * @param[in] seed Random seed.\n\n * @returns generated value.\n\n * @tparam T type of generated value.\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsScalar<T> = 0>\n\nT generate_value(const T min, const T max, const int seed) {\n\n static std::default_random_engine engine(seed);\n\n std::uniform_int_distribution<T> distribution(min, max);\n\n return distribution(engine);\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 82, "score": 100789.97936268209 }, { "content": " *\n\n * @param[in] sampler sampler to release.\n\n * @throws cassian::RuntimeException Thrown if runtime encountered a fatal\n\n * error.\n\n * @note After releasing, sampler must not be used anymore.\n\n * @note Sampler must not be in use when calling this function.\n\n */\n\n virtual void release_sampler(const Sampler &sampler) = 0;\n\n\n\n /**\n\n * Read buffer to std::vector.\n\n *\n\n * @tparam T std::vector type.\n\n * @param[in] buffer buffer to read.\n\n * @returns std::vector with read buffer data.\n\n * @throws cassian::RuntimeException Thrown if runtime encountered a fatal\n\n * error.\n\n */\n\n template <typename T>\n\n std::vector<T> read_buffer_to_vector(const Buffer &buffer);\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 83, "score": 100789.96562789287 }, { "content": " *\n\n * @overload\n\n */\n\ntemplate <>\n\nhalf generate_value<half>(const half min, const half max, const int seed);\n\n\n\n/**\n\n * Generate random value.\n\n *\n\n * @param[in] seed Random seed.\n\n * @returns generated value.\n\n * @tparam T type of generated value.\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsScalar<T> = 0>\n\nT generate_value(const int seed) {\n\n const T min = std::numeric_limits<T>::min();\n\n const T max = std::numeric_limits<T>::max();\n\n return generate_value(min, max, seed);\n\n}\n\n\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 84, "score": 100789.78572421057 }, { "content": " ~FinalAction() { act(); }\n\n\n\nprivate:\n\n A act;\n\n};\n\n\n\n/**\n\n * Creates FinalAction object instance\n\n *\n\n * @tparam A type for callable object\n\n * @param[in] act callable object\n\n */\n\ntemplate <typename A> FinalAction<A> finally(A act) {\n\n return FinalAction<A>{act};\n\n}\n\n\n\n} // namespace cassian\n\n#endif\n", "file_path": "src/core/utility/include/cassian/utility/utility.hpp", "rank": 85, "score": 100789.62743632834 }, { "content": " * Load shared library.\n\n *\n\n * Library name must contain all system specific parts like:\n\n * - `lib` prefix;\n\n * - `.dll`/`.so` suffix;\n\n *\n\n * @param[in] name library name.\n\n * @returns pointer to an object implementing cassian::Library interface.\n\n * @throws cassian::LibraryNotFoundException Thrown if `name` library is not\n\n * found in the system.\n\n * @note library is unloaded when pointer is freed.\n\n */\n\nstd::unique_ptr<Library> load_library(const std::string &name);\n\n\n\n} // namespace cassian\n\n#endif\n", "file_path": "src/core/system/include/cassian/system/factory.hpp", "rank": 86, "score": 100789.5759840341 }, { "content": " * as `a` but with a length of 1.\n\n * @param[in] a input vector.\n\n * @returns vector.\n\n */\n\ntemplate <typename T, EnableIfIsVector<T> = 0> T normalize(const T &a) {\n\n using scalar_type = scalar_type_v<T>;\n\n for (auto i = 0; i < T::vector_size; i++) {\n\n if (std::isnan(a[i])) {\n\n return T(std::numeric_limits<scalar_type>::quiet_NaN());\n\n }\n\n }\n\n T result = a;\n\n if (std::find_if(a.begin(), a.begin() + T::vector_size,\n\n [](const scalar_type &val) { return std::isinf(val); }) !=\n\n a.begin() + T::vector_size) {\n\n for (size_t i = 0; i < T::vector_size; i++) {\n\n result[i] = std::isinf(a[i]) ? std::copysign(1.0, a[i]) : 0.0 * a[i];\n\n }\n\n }\n\n long double norm = 0.0;\n", "file_path": "src/core/utility/include/cassian/utility/math.hpp", "rank": 87, "score": 100789.21355825446 }, { "content": "\n\n /**\n\n * Write buffer from std::vector.\n\n *\n\n * @tparam T std::vector type.\n\n * @param[in] buffer buffer to write.\n\n * @param[in] data vector with data to write.\n\n * @throws cassian::RuntimeException Thrown if runtime encountered a fatal\n\n * error.\n\n */\n\n template <typename T>\n\n void write_buffer_from_vector(const Buffer &buffer,\n\n const std::vector<T> &data);\n\n\n\n /**\n\n * Create kernel.\n\n *\n\n * @param[in] kernel_name kernel name.\n\n * @param[in] source kernel source code.\n\n * @param[in] build_options build options to use during kernel construction.\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 88, "score": 100789.15311274845 }, { "content": " * @returns vector of generated values.\n\n * @tparam T type of generated values.\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsScalar<T> = 0>\n\nstd::vector<T> generate_vector(const int size, const T min, const T max,\n\n const int seed) {\n\n std::vector<T> data(size);\n\n std::generate(data.begin(), data.end(),\n\n [&] { return generate_value<T>(min, max, seed); });\n\n return data;\n\n}\n\n\n\n/**\n\n * Generate vector of random Vector values in range [min, max].\n\n *\n\n * @param[in] size Number of values to generate.\n\n * @param[in] min Minimum scalar value.\n\n * @param[in] max Maximum scalar value.\n\n * @param[in] seed Random seed.\n\n * @returns vector of generated values.\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 89, "score": 100788.69283376618 }, { "content": " for (size_t i = 0; i < T::vector_size; i++) {\n\n norm += static_cast<long double>(result[i]) *\n\n static_cast<long double>(result[i]);\n\n }\n\n if (norm == 0.0) {\n\n return result;\n\n }\n\n norm = std::sqrt(norm);\n\n for (size_t i = 0; i < T::vector_size; i++) {\n\n result[i] /= norm;\n\n }\n\n return result;\n\n}\n\n\n\ntemplate <typename T, EnableIfIsScalar<T> = 0> T normalize(const T &a) {\n\n if (std::isnan(a)) {\n\n return std::numeric_limits<T>::quiet_NaN();\n\n }\n\n if (std::isinf(a)) {\n\n T result = std::isinf(a) ? std::copysign(1.0, a) : 0.0 * a;\n", "file_path": "src/core/utility/include/cassian/utility/math.hpp", "rank": 90, "score": 100788.53445619083 }, { "content": " * @param[in] file_path path to output file.\n\n */\n\nvoid save_binary_file(const std::vector<uint8_t> &data,\n\n const std::string &file_path);\n\n\n\n/**\n\n * Combine bytes from multiple elements into single, larger element.\n\n *\n\n * @tparam IN input data type.\n\n * @tparam OUT output data type.\n\n * @param[in] input elements to combine.\n\n * @returns combined elements.\n\n */\n\ntemplate <typename OUT, typename IN>\n\nOUT combine_bytes(const std::vector<IN> &input) {\n\n const size_t bits = 8;\n\n OUT output = 0;\n\n for (size_t i = 0; i < input.size(); ++i) {\n\n output |= uint8_t(input[i]) << (i * bits);\n\n }\n", "file_path": "src/core/utility/include/cassian/utility/utility.hpp", "rank": 91, "score": 100788.34738103059 }, { "content": " */\n\n virtual Kernel create_kernel_from_multiple_programs(\n\n const std::string &kernel_name,\n\n const std::vector<ProgramDescriptor> &program_descriptors,\n\n const std::string &linker_options = \"\") = 0;\n\n\n\n /**\n\n * Set buffer as kernel argument.\n\n *\n\n * @param[in] kernel kernel to use.\n\n * @param[in] argument_index argument index.\n\n * @param[in] buffer buffer to set as kernel argument.\n\n * @throws cassian::RuntimeException Thrown if runtime encountered a fatal\n\n * error.\n\n */\n\n virtual void set_kernel_argument(const Kernel &kernel, int argument_index,\n\n const Buffer &buffer) = 0;\n\n\n\n /**\n\n * Set image as kernel argument.\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 92, "score": 100787.97639045578 }, { "content": " return value;\n\n}\n\n\n\n/**\n\n * Generate random Vector value in range [min, max]. If specialization\n\n * is floating point the range is [min, max). Use std::nextafter as max\n\n * parameter to close interval.\n\n *\n\n * @param[in] min Minimum scalar value.\n\n * @param[in] max Maximum scalar value.\n\n * @param[in] seed Random seed.\n\n * @returns generated value.\n\n * @tparam T type of generated value.\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsVector<T> = 0>\n\nT generate_value(const scalar_type_v<T> min, const scalar_type_v<T> max,\n\n const int seed) {\n\n using scalar_type = scalar_type_v<T>;\n\n std::vector<scalar_type> data(T::vector_size);\n\n std::generate(data.begin(), data.end(),\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 93, "score": 100787.96450849103 }, { "content": " [&] { return generate_value<scalar_type>(min, max, seed); });\n\n return T(data);\n\n}\n\n\n\n/**\n\n * Generate random Vector value in range [min, max] \\ except. If specialization\n\n * is floating point the range is [min, max) \\ except. Use std::nextafter as max\n\n * parameter to close interval.\n\n *\n\n * @param[in] min Minimum scalar value.\n\n * @param[in] max Maximum scalar value.\n\n * @param[in] seed Random seed.\n\n * @param[in] except except values vector.\n\n * @returns generated value.\n\n * @tparam T type of generated value.\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsVector<T> = 0>\n\nT generate_value(const scalar_type_v<T> min, const scalar_type_v<T> max,\n\n const int seed, const std::vector<scalar_type_v<T>> &except) {\n\n T generated_value;\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 94, "score": 100787.76915667873 }, { "content": "}\n\n\n\n/**\n\n * Generate random scalar value in range [min, max] \\ except.\n\n *\n\n * @param[in] min Minimum value.\n\n * @param[in] max Maximum value.\n\n * @param[in] seed Random seed.\n\n * @param[in] except except values vector.\n\n * @returns generated value.\n\n * @tparam T type of generated value.\n\n */\n\ntemplate <typename T, typename cassian::EnableIfIsScalar<T> = 0>\n\nT generate_value(const T min, const T max, const int seed,\n\n const std::vector<T> &except) {\n\n auto value = generate_value(min, max, seed);\n\n while (!except.empty() &&\n\n std::find(except.begin(), except.end(), value) != except.end()) {\n\n value = generate_value(min, max, seed);\n\n }\n", "file_path": "src/core/random/include/cassian/random/random.hpp", "rank": 95, "score": 100787.37194119932 }, { "content": "/**\n\n * Specialization for Tfloat.\n\n */\n\ntemplate <>\n\nstd::vector<Tfloat>\n\nRuntime::read_buffer_to_vector<Tfloat>(const Buffer &buffer);\n\n\n\ntemplate <typename T>\n\nvoid Runtime::write_buffer_from_vector(const Buffer &buffer,\n\n const std::vector<T> &data) {\n\n write_buffer(buffer, data.data());\n\n}\n\n\n\n/**\n\n * Specialization for Bfloat.\n\n */\n\ntemplate <>\n\nvoid Runtime::write_buffer_from_vector<Bfloat>(const Buffer &buffer,\n\n const std::vector<Bfloat> &data);\n\n\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 96, "score": 100787.03498348579 }, { "content": " * Vector<int, i.value> v();\n\n * })\n\n * @endcode\n\n *\n\n * @param[in] seq std::integer_sequence of numbers to iterate through\n\n * @param[in] func Lambda function containing loop body. It should take\n\n * one parameter. Compile-time constant integer is\n\n * accessible using std::integral_constant::value member.\n\n */\n\ntemplate <typename F, typename T, T... ints>\n\nvoid static_for(std::integer_sequence<T, ints...> seq, F func) {\n\n (void)seq;\n\n (func(std::integral_constant<T, ints>{}), ...);\n\n}\n\n\n\nnamespace detail {\n\n\n\n/**\n\n * Helper struct for CartesianProduct.\n\n * Creates @c std::tuple containing tuples with first type = T, and second type\n", "file_path": "src/core/utility/include/cassian/utility/metaprogramming.hpp", "rank": 97, "score": 100786.6999581161 }, { "content": "/**\n\n * Specialization for Half.\n\n */\n\ntemplate <>\n\nvoid Runtime::write_buffer_from_vector<Half>(const Buffer &buffer,\n\n const std::vector<Half> &data);\n\n\n\n/**\n\n * Specialization for Tfloat.\n\n */\n\ntemplate <>\n\nvoid Runtime::write_buffer_from_vector<Tfloat>(const Buffer &buffer,\n\n const std::vector<Tfloat> &data);\n\n\n\n/**\n\n * Exception class used when a runtime encounters a fatal error.\n\n */\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 98, "score": 100786.52986241228 }, { "content": "std::vector<T> Runtime::read_buffer_to_vector(const Buffer &buffer) {\n\n const size_t elements = buffer.size / sizeof(T);\n\n std::vector<T> output(elements);\n\n read_buffer(buffer, output.data());\n\n return output;\n\n}\n\n\n\n/**\n\n * Specialization for Bfloat.\n\n */\n\ntemplate <>\n\nstd::vector<Bfloat>\n\nRuntime::read_buffer_to_vector<Bfloat>(const Buffer &buffer);\n\n\n\n/**\n\n * Specialization for Half.\n\n */\n\ntemplate <>\n\nstd::vector<Half> Runtime::read_buffer_to_vector<Half>(const Buffer &buffer);\n\n\n", "file_path": "src/core/runtime/include/cassian/runtime/runtime.hpp", "rank": 99, "score": 100786.51242202985 } ]
C++
Sankore-3.1/src/gui/UBDownloadWidget.cpp
eaglezzb/rsdc
cce881f6542ff206bf286cf798c8ec8da3b51d50
#include <QDebug> #include <QHeaderView> #include <QStyleOptionProgressBarV2> #include <QApplication> #include "UBDownloadWidget.h" #include "globals/UBGlobals.h" #include "core/UBApplication.h" #include "core/memcheck.h" UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(parent) , mpLayout(NULL) , mpBttnLayout(NULL) , mpTree(NULL) , mpCancelBttn(NULL) , mpItem(NULL) { setObjectName(name); setWindowTitle(tr("Downloading files")); SET_STYLE_SHEET(); resize(400, 300); mpLayout = new QVBoxLayout(this); setLayout(mpLayout); mpTree = new QTreeWidget(this); mpTree->setRootIsDecorated(false); mpTree->setColumnCount(2); mpTree->header()->setStretchLastSection(false); mpTree->header()->setResizeMode(eItemColumn_Desc, QHeaderView::Stretch); mpTree->header()->setResizeMode(eItemColumn_Close, QHeaderView::Custom); mpTree->resizeColumnToContents(eItemColumn_Close); mpTree->header()->close(); mpLayout->addWidget(mpTree, 1); mpBttnLayout = new QHBoxLayout(); mpBttnLayout->addStretch(1); mpCancelBttn = new QPushButton(tr("Cancel"), this); mpCancelBttn->setObjectName("DockPaletteWidgetButton"); mpBttnLayout->addWidget(mpCancelBttn, 0); mpLayout->addLayout(mpBttnLayout); connect(UBDownloadManager::downloadManager(), SIGNAL(fileAddedToDownload()), this, SLOT(onFileAddedToDownload())); connect(UBDownloadManager::downloadManager(), SIGNAL(downloadUpdated(int,qint64,qint64)), this, SLOT(onDownloadUpdated(int,qint64,qint64))); connect(UBDownloadManager::downloadManager(), SIGNAL(downloadFinished(int)), this, SLOT(onDownloadFinished(int))); connect(mpCancelBttn, SIGNAL(clicked()), this, SLOT(onCancelClicked())); connect(mpTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onItemClicked(QTreeWidgetItem*,int))); } UBDownloadWidget::~UBDownloadWidget() { if(NULL != mpCancelBttn) { delete mpCancelBttn; mpCancelBttn = NULL; } if(NULL != mpTree) { delete mpTree; mpTree = NULL; } if(NULL != mpBttnLayout) { delete mpBttnLayout; mpBttnLayout = NULL; } if(NULL != mpLayout) { delete mpLayout; mpLayout = NULL; } } void UBDownloadWidget::onFileAddedToDownload() { if(NULL != mpTree) { mpTree->clear(); addCurrentDownloads(); addPendingDownloads(); } } void UBDownloadWidget::addCurrentDownloads() { QVector<sDownloadFileDesc> actualDL = UBDownloadManager::downloadManager()->currentDownloads(); qDebug() << "Actual downloads size: " << actualDL.size(); for(int i=0; i<actualDL.size();i++) { mpItem = new QTreeWidgetItem(mpTree); mpItem->setText(eItemColumn_Desc, actualDL.at(i).name); mpItem->setData(eItemColumn_Desc, Qt::UserRole, QVariant(actualDL.at(i).id)); mpItem->setIcon(eItemColumn_Close, QIcon(":images/close.svg")); mpTree->addTopLevelItem(mpItem); mpItem = new QTreeWidgetItem(mpTree); mpItem->setData(eItemColumn_Desc, Qt::UserRole, actualDL.at(i).currentSize); mpItem->setData(eItemColumn_Desc, Qt::UserRole + 1, actualDL.at(i).totalSize); mpItem->setData(eItemColumn_Desc, Qt::UserRole + 2, actualDL.at(i).id); mpTree->addTopLevelItem(mpItem); mpTree->setItemDelegateForRow(((i+1)*2)-1, &mProgressBarDelegate); } } void UBDownloadWidget::addPendingDownloads() { QVector<sDownloadFileDesc> pendingDL = UBDownloadManager::downloadManager()->pendingDownloads(); for(int i=0; i<pendingDL.size(); i++) { mpItem = new QTreeWidgetItem(mpTree); mpItem->setText(eItemColumn_Desc, pendingDL.at(i).name); mpItem->setData(eItemColumn_Desc, Qt::UserRole, QVariant(pendingDL.at(i).id)); mpTree->addTopLevelItem(mpItem); } } void UBDownloadWidget::onDownloadUpdated(int id, qint64 crnt, qint64 total) { if(NULL != mpTree) { QAbstractItemModel* model = mpTree->model(); if(NULL != model) { for(int i=0; i< model->rowCount(); i++) { QModelIndex currentIndex = model->index(i, eItemColumn_Desc); if(id == currentIndex.data(Qt::UserRole + 2)) { model->setData(currentIndex, crnt, Qt::UserRole); model->setData(currentIndex, total, Qt::UserRole + 1); break; } } } } } void UBDownloadWidget::onDownloadFinished(int id) { Q_UNUSED(id); onFileAddedToDownload(); } void UBDownloadWidget::onCancelClicked() { UBDownloadManager::downloadManager()->cancelDownloads(); } void UBDownloadWidget::onItemClicked(QTreeWidgetItem *pItem, int col) { if( eItemColumn_Close == col && "" != pItem->text(eItemColumn_Desc)){ UBDownloadManager::downloadManager()->cancelDownload(pItem->data(eItemColumn_Desc, Qt::UserRole).toInt()); } } UBDownloadProgressDelegate::UBDownloadProgressDelegate(QObject *parent):QItemDelegate(parent) { } void UBDownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionProgressBarV2 opt; opt.rect = option.rect; opt.minimum = 0; opt.maximum = index.data(Qt::UserRole + 1).toInt(); opt.progress = index.data(Qt::UserRole).toInt(); if(0 == index.column()){ QApplication::style()->drawControl(QStyle::CE_ProgressBar, &opt, painter, 0); } }
#include <QDebug> #include <QHeaderView> #include <QStyleOptionProgressBarV2> #include <QApplication> #include "UBDownloadWidget.h" #include "globals/UBGlobals.h" #include "core/UBApplication.h" #include "core/memcheck.h" UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(parent) , mpLayout(NULL) , mpBttnLayout(NULL) , mpTree(NULL) , mpCancelBttn(NULL) , mpItem(NULL) { setObjectName(name); setWindowTitle(tr("Downloading files")); SET_STYLE_SHEET(); resize(400, 300); mpLayout = new QVBoxLayout(this); setLayout(mpLayout); mpTree = new QTreeWidget(this); mpTree->setRootIsDecorated(false); mpTree->setColumnCount(2); mpTree->header()->setStretchLastSection(false); mpTree->header()->setResizeMode(eItemColumn_Desc, QHeaderView::Stretch); mpTree->header()->setResizeMode(eItemColumn_Close, QHeaderView::Custom); mpTree->resizeColumnToContents(eItemColumn_Close); mpTree->header()->close(); mpLayout->addWidget(mpTree, 1); mpBttnLayout = new QHBoxLayout(); mpBttnLayout->addStretch(1); mpCancelBttn = new QPushButton(tr
n_Desc, Qt::UserRole, QVariant(actualDL.at(i).id)); mpItem->setIcon(eItemColumn_Close, QIcon(":images/close.svg")); mpTree->addTopLevelItem(mpItem); mpItem = new QTreeWidgetItem(mpTree); mpItem->setData(eItemColumn_Desc, Qt::UserRole, actualDL.at(i).currentSize); mpItem->setData(eItemColumn_Desc, Qt::UserRole + 1, actualDL.at(i).totalSize); mpItem->setData(eItemColumn_Desc, Qt::UserRole + 2, actualDL.at(i).id); mpTree->addTopLevelItem(mpItem); mpTree->setItemDelegateForRow(((i+1)*2)-1, &mProgressBarDelegate); } } void UBDownloadWidget::addPendingDownloads() { QVector<sDownloadFileDesc> pendingDL = UBDownloadManager::downloadManager()->pendingDownloads(); for(int i=0; i<pendingDL.size(); i++) { mpItem = new QTreeWidgetItem(mpTree); mpItem->setText(eItemColumn_Desc, pendingDL.at(i).name); mpItem->setData(eItemColumn_Desc, Qt::UserRole, QVariant(pendingDL.at(i).id)); mpTree->addTopLevelItem(mpItem); } } void UBDownloadWidget::onDownloadUpdated(int id, qint64 crnt, qint64 total) { if(NULL != mpTree) { QAbstractItemModel* model = mpTree->model(); if(NULL != model) { for(int i=0; i< model->rowCount(); i++) { QModelIndex currentIndex = model->index(i, eItemColumn_Desc); if(id == currentIndex.data(Qt::UserRole + 2)) { model->setData(currentIndex, crnt, Qt::UserRole); model->setData(currentIndex, total, Qt::UserRole + 1); break; } } } } } void UBDownloadWidget::onDownloadFinished(int id) { Q_UNUSED(id); onFileAddedToDownload(); } void UBDownloadWidget::onCancelClicked() { UBDownloadManager::downloadManager()->cancelDownloads(); } void UBDownloadWidget::onItemClicked(QTreeWidgetItem *pItem, int col) { if( eItemColumn_Close == col && "" != pItem->text(eItemColumn_Desc)){ UBDownloadManager::downloadManager()->cancelDownload(pItem->data(eItemColumn_Desc, Qt::UserRole).toInt()); } } UBDownloadProgressDelegate::UBDownloadProgressDelegate(QObject *parent):QItemDelegate(parent) { } void UBDownloadProgressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionProgressBarV2 opt; opt.rect = option.rect; opt.minimum = 0; opt.maximum = index.data(Qt::UserRole + 1).toInt(); opt.progress = index.data(Qt::UserRole).toInt(); if(0 == index.column()){ QApplication::style()->drawControl(QStyle::CE_ProgressBar, &opt, painter, 0); } }
("Cancel"), this); mpCancelBttn->setObjectName("DockPaletteWidgetButton"); mpBttnLayout->addWidget(mpCancelBttn, 0); mpLayout->addLayout(mpBttnLayout); connect(UBDownloadManager::downloadManager(), SIGNAL(fileAddedToDownload()), this, SLOT(onFileAddedToDownload())); connect(UBDownloadManager::downloadManager(), SIGNAL(downloadUpdated(int,qint64,qint64)), this, SLOT(onDownloadUpdated(int,qint64,qint64))); connect(UBDownloadManager::downloadManager(), SIGNAL(downloadFinished(int)), this, SLOT(onDownloadFinished(int))); connect(mpCancelBttn, SIGNAL(clicked()), this, SLOT(onCancelClicked())); connect(mpTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onItemClicked(QTreeWidgetItem*,int))); } UBDownloadWidget::~UBDownloadWidget() { if(NULL != mpCancelBttn) { delete mpCancelBttn; mpCancelBttn = NULL; } if(NULL != mpTree) { delete mpTree; mpTree = NULL; } if(NULL != mpBttnLayout) { delete mpBttnLayout; mpBttnLayout = NULL; } if(NULL != mpLayout) { delete mpLayout; mpLayout = NULL; } } void UBDownloadWidget::onFileAddedToDownload() { if(NULL != mpTree) { mpTree->clear(); addCurrentDownloads(); addPendingDownloads(); } } void UBDownloadWidget::addCurrentDownloads() { QVector<sDownloadFileDesc> actualDL = UBDownloadManager::downloadManager()->currentDownloads(); qDebug() << "Actual downloads size: " << actualDL.size(); for(int i=0; i<actualDL.size();i++) { mpItem = new QTreeWidgetItem(mpTree); mpItem->setText(eItemColumn_Desc, actualDL.at(i).name); mpItem->setData(eItemColum
random
[ { "content": "\t\tSSL_CIPHER *new_cipher;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/ssl3.h", "rank": 0, "score": 129144.86743968823 }, { "content": "X509V3_EXT_NEW ext_new;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/x509v3.h", "rank": 1, "score": 129138.11819616328 }, { "content": "\t\tconst EVP_MD *new_hash;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/ssl3.h", "rank": 2, "score": 129138.11819616328 }, { "content": "pitem *pitem_new(PQ_64BIT priority, void *data);\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/pqueue.h", "rank": 3, "score": 129138.11819616328 }, { "content": "pqueue pqueue_new(void);\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/pqueue.h", "rank": 4, "score": 129138.11819616328 }, { "content": "\tCRYPTO_EX_new *new_func;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/crypto.h", "rank": 5, "score": 129138.11819616328 }, { "content": "\tASN1_new_func *asn1_new;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/asn1t.h", "rank": 6, "score": 129138.11819616328 }, { "content": "\tint new_session;/* 1 if we are to use a new session.\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/ssl.h", "rank": 7, "score": 129138.11819616328 }, { "content": "\tASN1_ex_new_func *prim_new;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/asn1t.h", "rank": 8, "score": 129138.11819616328 }, { "content": "\tchar *keytab_file;\t/* S\t NULL (/etc/krb5.keytab) */\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/kssl.h", "rank": 9, "score": 129110.89737241171 }, { "content": "\tconst char *err_file[ERR_NUM_ERRORS];\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/err.h", "rank": 10, "score": 129110.89737241171 }, { "content": " FT_Byte last_char;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftwinfnt.h", "rank": 11, "score": 127099.45324464793 }, { "content": " FT_Byte first_char;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftwinfnt.h", "rank": 12, "score": 127099.45324464793 }, { "content": " FT_Byte break_char;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftwinfnt.h", "rank": 13, "score": 127099.45324464793 }, { "content": " FT_Byte default_char;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftwinfnt.h", "rank": 14, "score": 127099.45324464793 }, { "content": "\t\tconst EVP_CIPHER *new_sym_enc;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/ssl3.h", "rank": 15, "score": 127075.19388028208 }, { "content": " FT_Raster_NewFunc raster_new;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftimage.h", "rank": 16, "score": 127075.19388028208 }, { "content": "\tASN1_ex_new_func *asn1_ex_new;\n", "file_path": "Sankore-ThirdParty/openssl/0.9.8i/include/openssl/asn1t.h", "rank": 17, "score": 127075.19388028208 }, { "content": " FT_UShort file_type;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftwinfnt.h", "rank": 18, "score": 127048.40789714921 }, { "content": " FT_Char FileName[6];\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/tttables.h", "rank": 19, "score": 127048.40789714921 }, { "content": " FT_ULong file_size;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftwinfnt.h", "rank": 20, "score": 127048.40789714921 }, { "content": "extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,\n\n extrafield_local, size_extrafield_local,\n\n extrafield_global, size_extrafield_global,\n\n comment, method, level, raw,\n\n windowBits, memLevel, strategy,\n", "file_path": "Sankore-ThirdParty/quazip/quazip-0.3/zip.c", "rank": 21, "score": 125793.77882277481 }, { "content": " FT_Short xAvgCharWidth;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/tttables.h", "rank": 22, "score": 125101.01979005462 }, { "content": " FT_UShort* char_index;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/t1types.h", "rank": 23, "score": 125101.01979005462 }, { "content": " FT_CMap_CharIndexFunc char_index;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftobjs.h", "rank": 24, "score": 125101.01979005462 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Load_Char( FT_Face face,\n\n FT_ULong char_code,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 25, "score": 125101.01979005462 }, { "content": " FT_UShort usDefaultChar;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/tttables.h", "rank": 26, "score": 125101.01979005462 }, { "content": " FT_Int num_chars;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/t1types.h", "rank": 27, "score": 125101.01979005462 }, { "content": " FT_String** char_name;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/t1types.h", "rank": 28, "score": 125101.01979005462 }, { "content": " FT_CMap_CharNextFunc char_next;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftobjs.h", "rank": 29, "score": 125101.01979005462 }, { "content": " FT_UShort usBreakChar;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/tttables.h", "rank": 30, "score": 125101.01979005462 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Stroker_New( FT_Library library,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftstroke.h", "rank": 31, "score": 125084.35006910993 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face( FT_Library library,\n\n const char* filepathname,\n\n FT_Long face_index,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 32, "score": 125077.14186497979 }, { "content": "FT_BEGIN_HEADER\n\n\n\n\n\n /*************************************************************************/\n\n /* */\n\n /* <Section> */\n\n /* sizes_management */\n\n /* */\n\n /* <Title> */\n\n /* Size Management */\n\n /* */\n\n /* <Abstract> */\n\n /* Managing multiple sizes per face. */\n\n /* */\n\n /* <Description> */\n\n /* When creating a new face object (e.g., with @FT_New_Face), an */\n\n /* @FT_Size object is automatically created and used to store all */\n\n /* pixel-size dependent information, available in the `face->size' */\n\n /* field. */\n\n /* */\n\n /* It is however possible to create more sizes for a given face, */\n\n /* mostly in order to manage several character pixel sizes of the */\n\n /* same font family and style. See @FT_New_Size and @FT_Done_Size. */\n\n /* */\n\n /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */\n\n /* modify the contents of the current `active' size; you thus need */\n\n /* to use @FT_Activate_Size to change it. */\n\n /* */\n\n /* 99% of applications won't need the functions provided here, */\n\n /* especially if they use the caching sub-system, so be cautious */\n\n /* when using these. */\n\n /* */\n\n /*************************************************************************/\n\n\n\n\n\n /*************************************************************************/\n\n /* */\n\n /* <Function> */\n\n /* FT_New_Size */\n\n /* */\n\n /* <Description> */\n\n /* Create a new size object from a given face object. */\n\n /* */\n\n /* <Input> */\n\n /* face :: A handle to a parent face object. */\n\n /* */\n\n /* <Output> */\n\n /* asize :: A handle to a new size object. */\n\n /* */\n\n /* <Return> */\n\n /* FreeType error code. 0~means success. */\n\n /* */\n\n /* <Note> */\n\n /* You need to call @FT_Activate_Size in order to select the new size */\n\n /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */\n\n /* @FT_Load_Glyph, @FT_Load_Char, etc. */\n\n /* */\n\n FT_EXPORT( FT_Error )\n\n FT_New_Size( FT_Face face,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftsizes.h", "rank": 33, "score": 125077.14186497979 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Library( FT_Memory memory,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftmodapi.h", "rank": 34, "score": 125077.14186497979 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_Manager_New( FT_Library library,\n\n FT_UInt max_faces,\n\n FT_UInt max_sizes,\n\n FT_ULong max_bytes,\n\n FTC_Face_Requester requester,\n\n FT_Pointer req_data,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftcache.h", "rank": 35, "score": 125077.14186497979 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Outline_New( FT_Library library,\n\n FT_UInt numPoints,\n\n FT_Int numContours,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftoutln.h", "rank": 36, "score": 125077.14186497979 }, { "content": " FT_Face_AttachFunc attach_file;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftdriver.h", "rank": 37, "score": 125050.77704813395 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Attach_File( FT_Face face,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 38, "score": 125050.77704813395 }, { "content": " FT_EXPORT( FT_ULong )\n\n FT_Get_First_Char( FT_Face face,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 39, "score": 123164.45777851199 }, { "content": " FT_CMap_CharVarIndexFunc char_var_index;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftobjs.h", "rank": 40, "score": 123164.45777851199 }, { "content": " FT_UShort usLastCharIndex;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/tttables.h", "rank": 41, "score": 123164.45777851199 }, { "content": " FT_EXPORT( FT_UInt )\n\n FT_Get_Char_Index( FT_Face face,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 42, "score": 123164.45777851199 }, { "content": " FT_CMap_CharVarIsDefaultFunc char_var_default;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftobjs.h", "rank": 43, "score": 123164.45777851199 }, { "content": " FT_UShort usFirstCharIndex;\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/tttables.h", "rank": 44, "score": 123164.45777851199 }, { "content": " FT_EXPORT( FT_ULong )\n\n FT_Get_Next_Char( FT_Face face,\n\n FT_ULong char_code,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 45, "score": 123164.45777851199 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Set_Char_Size( FT_Face face,\n\n FT_F26Dot6 char_width,\n\n FT_F26Dot6 char_height,\n\n FT_UInt horz_resolution,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 46, "score": 123164.45777851199 }, { "content": " FT_BASE( FT_Error )\n\n FT_Stream_New( FT_Library library,\n\n const FT_Open_Args* args,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftstream.h", "rank": 47, "score": 123147.47484075185 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_ImageCache_New( FTC_Manager manager,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftcache.h", "rank": 48, "score": 123140.94948337856 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Memory_Face( FT_Library library,\n\n const FT_Byte* file_base,\n\n FT_Long file_size,\n\n FT_Long face_index,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 49, "score": 123140.94948337856 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_Outline_New_Internal( FT_Memory memory,\n\n FT_UInt numPoints,\n\n FT_Int numContours,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftoutln.h", "rank": 50, "score": 123140.94948337856 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face_From_FOND( FT_Library library,\n\n Handle fond,\n\n FT_Long face_index,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftmac.h", "rank": 51, "score": 123140.94948337856 }, { "content": " FT_EXPORT( FT_UInt32* )\n\n FT_Face_GetCharsOfVariant( FT_Face face,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 52, "score": 121286.93770355797 }, { "content": " FT_BASE( FT_Char )\n\n FT_Stream_ReadChar( FT_Stream stream,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftstream.h", "rank": 53, "score": 121286.93770355797 }, { "content": " FT_EXPORT( FT_UInt32* )\n\n FT_Face_GetVariantsOfChar( FT_Face face,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 54, "score": 121286.93770355797 }, { "content": " FT_BASE( FT_Char )\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftstream.h", "rank": 55, "score": 121286.93770355797 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_CMapCache_New( FTC_Manager manager,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftcache.h", "rank": 56, "score": 121270.66020148697 }, { "content": " FT_BASE( FT_Error )\n\n FT_GlyphLoader_New( FT_Memory memory,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftgloadr.h", "rank": 57, "score": 121270.65481742095 }, { "content": " FT_BASE( FT_Error )\n\n FT_CMap_New( FT_CMap_Class clazz,\n\n FT_Pointer init_data,\n\n FT_CharMap charmap,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftobjs.h", "rank": 58, "score": 121270.53701260674 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face_From_FSSpec( FT_Library library,\n\n const FSSpec *spec,\n\n FT_Long face_index,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftmac.h", "rank": 59, "score": 121263.7877690818 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_New_Face_From_FSRef( FT_Library library,\n\n const FSRef *ref,\n\n FT_Long face_index,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftmac.h", "rank": 60, "score": 121263.7877690818 }, { "content": " FT_EXPORT( FT_Error )\n\n FTC_SBitCache_New( FTC_Manager manager,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftcache.h", "rank": 61, "score": 121263.7877690818 }, { "content": " FT_BASE( FT_Error )\n\n FT_New_GlyphSlot( FT_Face face,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/internal/ftobjs.h", "rank": 62, "score": 121263.7877690818 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_GetFile_From_Mac_Name( const char* fontName,\n\n FSSpec* pathSpec,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftmac.h", "rank": 63, "score": 121238.22676323459 }, { "content": " FT_EXPORT( FT_UInt )\n\n FT_Face_GetCharVariantIndex( FT_Face face,\n\n FT_ULong charcode,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 64, "score": 119465.80000022614 }, { "content": " FT_EXPORT( FT_Int )\n\n FT_Face_GetCharVariantIsDefault( FT_Face face,\n\n FT_ULong charcode,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/freetype.h", "rank": 65, "score": 119465.80000022614 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_GetFile_From_Mac_ATS_Name( const char* fontName,\n\n FSSpec* pathSpec,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftmac.h", "rank": 66, "score": 119417.8204604284 }, { "content": " FT_EXPORT( FT_Error )\n\n FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,\n\n UInt8* path,\n\n UInt32 maxPathSize,\n", "file_path": "Sankore-ThirdParty/freetype/freetype-2.4.6/include/freetype/ftmac.h", "rank": 67, "score": 117651.2726968361 }, { "content": "extern int ZEXPORT unzGetFilePos(file, file_pos)\n", "file_path": "Sankore-ThirdParty/quazip/quazip-0.3/unzip.c", "rank": 68, "score": 117038.64668891537 }, { "content": "int ZEXPORT gzsetparams(file, level, strategy)\n", "file_path": "Sankore-ThirdParty/zlib/zlib-1.2.5/gzwrite.c", "rank": 69, "score": 117030.12945452155 }, { "content": "const char * ZEXPORT gzerror(file, errnum)\n", "file_path": "Sankore-ThirdParty/zlib/zlib-1.2.5/gzlib.c", "rank": 70, "score": 117030.12945452155 }, { "content": "extern int ZEXPORT zipClose (file, global_comment)\n", "file_path": "Sankore-ThirdParty/quazip/quazip-0.3/zip.c", "rank": 71, "score": 117030.12945452155 }, { "content": "char * ZEXPORT gzgets(file, buf, len)\n", "file_path": "Sankore-ThirdParty/zlib/zlib-1.2.5/gzread.c", "rank": 72, "score": 117030.12945452155 }, { "content": " char *file;\n", "file_path": "Sankore-ThirdParty/zlib/zlib-1.2.5/minigzip.c", "rank": 73, "score": 117030.12945452155 }, { "content": "#include <QFile>\n\n#include <QFileInfo>\n\n#include <QDebug>\n\n\n\n#include \"TextDocument.h\"\n\n#include \"core/globalDefs.h\"\n\n\n\nTextDocument::TextDocument(const QString& docName, const char *name, QWidget *parent):DocumentWidget(docName, name, parent)\n\n{\n\n mPath = docName;\n\n mpWidget = new QTextEdit(this);\n\n dynamic_cast<QTextEdit*>(mpWidget)->setTabStopWidth(40);\n\n mpLayout->addWidget(mpWidget);\n\n setHighlighter();\n\n\n\n QFile f(docName);\n\n if(f.exists())\n\n {\n\n if(f.open(QIODevice::ReadOnly))\n\n {\n", "file_path": "Sankore-AppToolkit/src/gui/TextDocument.cpp", "rank": 74, "score": 24.26227545587836 }, { "content": "}\n\n\n\nFileManagementDlg::FileManagementDlg(eDialogType type, const char *name, QWidget *parent) : QDialog(parent)\n\n , mpLayout(NULL)\n\n , mpLabel(NULL)\n\n , mpLineEdit(NULL)\n\n , mpBttn(NULL)\n\n , mpHLayout(NULL)\n\n{\n\n setObjectName(name);\n\n setFixedSize(300, 100);\n\n mType = type;\n\n mpLayout = new QVBoxLayout();\n\n setLayout(mpLayout);\n\n\n\n switch(type)\n\n {\n\n case eDialogType_NewFile:\n\n setWindowTitle(tr(\"Add New File\"));\n\n mpHLayout = new QHBoxLayout();\n", "file_path": "Sankore-AppToolkit/src/gui/ProjectTree.cpp", "rank": 75, "score": 20.952222881495288 }, { "content": "#include <QDebug>\n\n#include <QFileInfo>\n\n#include <QUrl>\n\n#include <QCursor>\n\n#include <QMessageBox>\n\n#include <QHeaderView>\n\n\n\n#include \"ProjectTree.h\"\n\n#include \"core/globalDefs.h\"\n\n\n\nProjectTree::ProjectTree(QWidget *parent, const char *name):QTreeWidget(parent)\n\n , pItem(NULL)\n\n , mpContextMenu(NULL)\n\n , mpActionNew(NULL)\n\n , mpActionRename(NULL)\n\n , mpActionDelete(NULL)\n\n{\n\n setObjectName(name);\n\n connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(onItemDoubleClicked(QTreeWidgetItem*,int)));\n\n\n", "file_path": "Sankore-AppToolkit/src/gui/ProjectTree.cpp", "rank": 76, "score": 20.944648922028925 }, { "content": "\n\n\n\n\n\n#include \"UBHttpFileDownloader.h\"\n\n\n\n#include \"network/UBNetworkAccessManager.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\nUBHttpFileDownloader::UBHttpFileDownloader(QObject *parent)\n\n : QObject(parent)\n\n{\n\n // NOOP\n\n}\n\n\n\n\n\nUBHttpFileDownloader::~UBHttpFileDownloader()\n\n{\n\n // NOOP\n\n}\n", "file_path": "Sankore-3.1/src/network/UBHttpFileDownloader.cpp", "rank": 77, "score": 20.856950260289295 }, { "content": "\n\n\n\n\n\n#include <QtGui>\n\n#include <QTextCodec>\n\n\n\n#include \"frameworks/UBPlatformUtils.h\"\n\n#include \"frameworks/UBFileSystemUtils.h\"\n\n\n\n#include \"UBApplication.h\"\n\n#include \"UBSettings.h\"\n\n\n\n/* Uncomment this for memory leaks detection */\n\n/*\n\n#if defined(WIN32) && defined(_DEBUG)\n\n #define _CRTDBG_MAP_ALLOC\n\n #include <stdlib.h>\n\n #include <crtdbg.h>\n\n #define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )\n\n #define new DEBUG_NEW\n", "file_path": "Sankore-3.1/src/core/main.cpp", "rank": 78, "score": 20.641954531576168 }, { "content": " if(fi.isDir())\n\n {\n\n pParentItem = pCrntItem;\n\n qsNewPath = QString(\"%0%1%2\").arg(qsPath).arg(QDir::separator()).arg(dlg.name());\n\n }\n\n else\n\n {\n\n pParentItem = pCrntItem->parent();\n\n qsNewPath = QString(\"%0%1%2\").arg(fi.path()).arg(QDir::separator()).arg(dlg.name());\n\n }\n\n QFile newFile(qsNewPath);\n\n if(newFile.exists())\n\n {\n\n QMessageBox::critical(parentWidget(), tr(\"Error\"), tr(\"You cannot create this file because it already exists.\"));\n\n }\n\n else\n\n {\n\n // Create the file\n\n if(newFile.open(QIODevice::WriteOnly))\n\n {\n", "file_path": "Sankore-AppToolkit/src/gui/ProjectTree.cpp", "rank": 79, "score": 20.30545642642408 }, { "content": "#include \"Dict.h\"\n\n#include \"XRef.h\"\n\n#include \"Catalog.h\"\n\n#include \"Page.h\"\n\n#include \"PDFDoc.h\"\n\n#include \"TextOutputDev.h\"\n\n#include \"CharTypes.h\"\n\n#include \"UnicodeMap.h\"\n\n#include \"Error.h\"\n\n#include \"config.h\"\n\n\n\nstatic void printInfoString(FILE *f, Dict *infoDict, const char *key,\n\n\t\t\t const char *text1, const char *text2,\n\n\t\t\t UnicodeMap *uMap);\n\nstatic void printInfoDate(FILE *f, Dict *infoDict, const char *key,\n\n\t\t\t const char *fmt);\n\n\n\nstatic int firstPage = 1;\n\nstatic int lastPage = 0;\n\nstatic GBool physLayout = gFalse;\n", "file_path": "Sankore-ThirdParty/xpdf/xpdf-3.03/xpdf/pdftotext.cc", "rank": 80, "score": 20.256411653956683 }, { "content": "#include <QUrl>\n\n#include <QApplication>\n\n\n\n#include \"HelpViewer.h\"\n\n#include \"core/globalDefs.h\"\n\n\n\nHelpViewer::HelpViewer(QWidget *parent, const char *name):QWebView(parent)\n\n{\n\n setObjectName(name);\n\n\n\n QString qsDocFiles;\n\n QString qsDocFilename = \"doc/index.htm\";\n\n\n\n#ifdef Q_WS_MAC\n\n qsDocFiles = QString(\"%0/../Resources/%1\").arg(QApplication::applicationDirPath()).arg(qsDocFilename);\n\n#else\n\n qsDocFiles = qsDocFilename;\n\n#endif\n\n\n\n load(QUrl(qsDocFiles));\n\n}\n\n\n\nHelpViewer::~HelpViewer()\n\n{\n\n\n\n}\n", "file_path": "Sankore-AppToolkit/src/gui/HelpViewer.cpp", "rank": 81, "score": 20.25191793095807 }, { "content": "#include \"core/UBApplicationController.h\"\n\n\n\n#include \"gui/UBDockTeacherGuideWidget.h\"\n\n#include \"gui/UBTeacherGuideWidget.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\n/**\n\n * \\brief Constructor\n\n * @param parent as the parent widget\n\n * @param name as the object name\n\n */\n\nUBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGraphicsView(parent)\n\n , mScene(NULL)\n\n , mNbColumns(1)\n\n , mThumbnailWidth(0)\n\n , mThumbnailMinWidth(100)\n\n{\n\n setObjectName(name);\n\n mScene = new QGraphicsScene(this);\n", "file_path": "Sankore-3.1/src/gui/UBDocumentNavigator.cpp", "rank": 82, "score": 20.251090779173843 }, { "content": "#include <QFileInfo>\n\n#include <QDebug>\n\n\n\n#include \"DocumentTab.h\"\n\n#include \"core/globalDefs.h\"\n\n#include \"TextDocument.h\"\n\n#include \"WebDocument.h\"\n\n\n\nDocumentTab::DocumentTab(QWidget *parent, const char *name):QTabWidget(parent)\n\n{\n\n setObjectName(name);\n\n setTabsClosable(true);\n\n\n\n connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(onTabCloseRequest(int)));\n\n}\n\n\n\nDocumentTab::~DocumentTab()\n\n{\n\n if(!mWidgets.empty())\n\n {\n", "file_path": "Sankore-AppToolkit/src/gui/DocumentTab.cpp", "rank": 83, "score": 20.027986327438285 }, { "content": "\n\n\n\n\n\n#include \"UBDockDownloadWidget.h\"\n\n#include \"core/UBApplication.h\"\n\n\n\n#include \"globals/UBGlobals.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\nUBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name)\n\n , mpLayout(NULL)\n\n , mpDLWidget(NULL)\n\n{\n\n mName = \"DownloadWidget\";\n\n mVisibleState = false;\n\n\n\n SET_STYLE_SHEET();\n\n\n\n mpLayout = new QVBoxLayout(this);\n", "file_path": "Sankore-3.1/src/gui/UBDockDownloadWidget.cpp", "rank": 84, "score": 19.38450667790762 }, { "content": "\n\n\n\n\n\n#include \"UBQuickTimeFile.h\"\n\n\n\n#include <AudioToolbox/AudioToolbox.h>\n\n\n\n#include \"UBAudioQueueRecorder.h\"\n\n#include <QtGui>\n\n\n\n#include \"core/memcheck.h\"\n\n\n\nQQueue<UBQuickTimeFile::VideoFrame> UBQuickTimeFile::frameQueue;\n\nQMutex UBQuickTimeFile::frameQueueMutex;\n\nQWaitCondition UBQuickTimeFile::frameBufferNotEmpty;\n\n\n\n\n\nUBQuickTimeFile::UBQuickTimeFile(QObject * pParent)\n\n : QThread(pParent)\n\n , mVideoCompressionSession(0)\n", "file_path": "Sankore-3.1/src/podcast/quicktime/UBQuickTimeFile.cpp", "rank": 85, "score": 19.361965620191203 }, { "content": "\n\n\n\n\n\n#include \"UBDownloadManager.h\"\n\n#include \"core/UBApplication.h\"\n\n#include \"core/UBPersistenceManager.h\"\n\n#include \"gui/UBMainWindow.h\"\n\n#include \"board/UBBoardController.h\"\n\n#include \"board/UBBoardPaletteManager.h\"\n\n#include \"frameworks/UBFileSystemUtils.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\n\n\nUBAsyncLocalFileDownloader::UBAsyncLocalFileDownloader(sDownloadFileDesc desc, QByteArray data, QObject *parent)\n\n: QThread(parent)\n\n, mDesc(desc)\n\n, mData(data)\n\n, m_bAborting(false)\n\n{\n", "file_path": "Sankore-3.1/src/core/UBDownloadManager.cpp", "rank": 86, "score": 19.34429559437859 }, { "content": "\n\n\n\n\n\n#include \"UBWindowsMediaFile.h\"\n\n\n\n#include <QtGui>\n\n\n\n#include \"core/UBApplication.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\nUBWindowsMediaFile::UBWindowsMediaFile(QObject * pParent)\n\n : QObject(pParent)\n\n , mWMhDC(0)\n\n , mWMWriter(0)\n\n , mPushSink(0)\n\n , mVideoInputIndex(0)\n\n , mWMProfile(0)\n\n , mWMInputVideoProps(0)\n\n , mWMInputAudioProps(0)\n", "file_path": "Sankore-3.1/src/podcast/windowsmedia/UBWindowsMediaFile.cpp", "rank": 87, "score": 19.224752949138118 }, { "content": "#include <QHeaderView>\n\n\n\n#include \"OptionsDlg.h\"\n\n#include \"core/globalDefs.h\"\n\n\n\nOptionsDlg::OptionsDlg(QWidget *parent, const char *name):QDialog(parent)\n\n , mpLayout(NULL)\n\n , mpHLayout(NULL)\n\n , mpTree(NULL)\n\n , mpStack(NULL)\n\n , mpButtons(NULL)\n\n{\n\n setObjectName(name);\n\n setModal(true);\n\n resize(DLG_WIDTH, DLG_HEIGHT);\n\n\n\n mpLayout = new QVBoxLayout();\n\n setLayout(mpLayout);\n\n\n\n mpHLayout = new QHBoxLayout();\n", "file_path": "Sankore-AppToolkit/src/gui/OptionsDlg.cpp", "rank": 88, "score": 19.02528203507665 }, { "content": "\n\n s = new GString();\n\n for (p = path; *p; ++p) {\n\n if (*p < 0x80) {\n\n s->append((char)*p);\n\n } else if (*p < 0x800) {\n\n s->append((char)(0xc0 | ((*p >> 6) & 0x1f)));\n\n s->append((char)(0x80 | (*p & 0x3f)));\n\n } else {\n\n s->append((char)(0xe0 | ((*p >> 12) & 0x0f)));\n\n s->append((char)(0x80 | ((*p >> 6) & 0x3f)));\n\n s->append((char)(0x80 | (*p & 0x3f)));\n\n }\n\n }\n\n return s;\n\n}\n\n#endif\n\n\n\nFILE *openFile(const char *path, const char *mode) {\n\n#ifdef WIN32\n", "file_path": "Sankore-ThirdParty/xpdf/xpdf-3.03/goo/gfile.cc", "rank": 89, "score": 18.99408262476025 }, { "content": "\n\n\n\n\n\n#include <QDebug>\n\n#include <QNetworkProxy>\n\n#include <QNetworkDiskCache>\n\n\n\n#include \"core/UBSettings.h\"\n\n\n\n#include \"UBDownloadThread.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\n/**\n\n * \\brief Constructor\n\n * @param parent as the parent object\n\n * @param name as the object name\n\n */\n\nUBDownloadThread::UBDownloadThread(QObject *parent, const char *name):QThread(parent)\n\n , mbRun(false)\n", "file_path": "Sankore-3.1/src/core/UBDownloadThread.cpp", "rank": 90, "score": 18.974217552580942 }, { "content": "// if(!file.open(QIODevice::ReadOnly)) {\n\n// qWarning() << \"Import failed. Cause: file.open(): \" << zip.getZipError();\n\n// return \"\";\n\n// }\n\n file.open(QIODevice::ReadOnly);\n\n if(file.getZipError()!= UNZ_OK) {\n\n qWarning() << \"Import failed. Cause: file.getFileName(): \" << zip.getZipError();\n\n return \"\";\n\n }\n\n\n\n QString newFileName = documentRootFolder + \"/\" + file.getActualFileName();\n\n\n\n QFileInfo newFileInfo(newFileName);\n\n rootDir.mkpath(newFileInfo.absolutePath());\n\n\n\n out.setFileName(newFileName);\n\n out.open(QIODevice::WriteOnly);\n\n\n\n while(file.getChar(&c))\n\n out.putChar(c);\n", "file_path": "Sankore-3.1/src/adaptors/UBImportCFF.cpp", "rank": 91, "score": 18.889293316814936 }, { "content": "\n\n\n\n\n\n#include \"UBWindowsMediaVideoEncoder.h\"\n\n\n\n#include <QtGui>\n\n\n\n#include \"frameworks/UBFileSystemUtils.h\"\n\n\n\n#include \"core/UBApplication.h\"\n\n\n\n#include \"UBWindowsMediaFile.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\nUBWindowsMediaVideoEncoder::UBWindowsMediaVideoEncoder(QObject* pParent)\n\n : UBAbstractVideoEncoder(pParent)\n\n , mWMVideo(0)\n\n , mWaveRecorder(0)\n\n , mRecordAudio(true)\n", "file_path": "Sankore-3.1/src/podcast/windowsmedia/UBWindowsMediaVideoEncoder.cpp", "rank": 92, "score": 18.700169614925976 }, { "content": "\n\n\n\n\n\n#include <QFileDialog>\n\n\n\n#include \"UBUpdateDlg.h\"\n\n#include \"core/UBApplication.h\"\n\n#include \"UBMainWindow.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\nUBUpdateDlg::UBUpdateDlg(QWidget *parent, int nbFiles, const QString& bkpPath)\n\n : QDialog(parent)\n\n , mMainLayout(NULL)\n\n , mNbFilesLabel(NULL)\n\n , mBkpLabel(NULL)\n\n , mBkpPath(NULL)\n\n , mBrowseBttn(NULL)\n\n , mpDlgBttn(NULL)\n\n , mLayout(NULL)\n", "file_path": "Sankore-3.1/src/gui/UBUpdateDlg.cpp", "rank": 93, "score": 18.561151251509145 }, { "content": " root.mkpath(newFileInfo.absolutePath());\n\n\n\n out.setFileName(newFileName);\n\n out.open(QIODevice::WriteOnly);\n\n\n\n // Slow like hell (on GNU/Linux at least), but it is not my fault.\n\n // Not ZIP/UNZIP package's fault either.\n\n // The slowest thing here is out.putChar(c).\n\n QByteArray outFileContent = file.readAll();\n\n if (out.write(outFileContent) == -1)\n\n {\n\n // qWarning() << \"ZIP expand failed. Cause: Unable to write file\";\n\n // this may happen if we are decompressing a directory\n\n }\n\n\n\n while(file.getChar(&c))\n\n out.putChar(c);\n\n\n\n out.close();\n\n\n", "file_path": "Sankore-3.1/src/frameworks/UBFileSystemUtils.cpp", "rank": 94, "score": 18.50495515019746 }, { "content": "\n\n\n\n\n\n#include \"UBPageNavigationWidget.h\"\n\n#include \"core/UBApplication.h\"\n\n\n\n#include \"board/UBBoardController.h\"\n\n\n\n#include \"document/UBDocumentContainer.h\"\n\n\n\n#include \"globals/UBGlobals.h\"\n\n\n\n#include \"core/memcheck.h\"\n\n\n\n/**\n\n * \\brief Constructor\n\n * @param parent as the parent widget\n\n * @param name as the object name\n\n */\n\nUBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)\n", "file_path": "Sankore-3.1/src/gui/UBPageNavigationWidget.cpp", "rank": 95, "score": 18.50037294710396 }, { "content": "#include \"gfile.h\"\n\n#include \"FoFiTrueType.h\"\n\n#include \"FoFiType1C.h\"\n\n#include \"SplashFTFontFile.h\"\n\n#include \"SplashFTFontEngine.h\"\n\n\n\n#ifdef VMS\n\n#if (__VMS_VER < 70000000)\n\nextern \"C\" int unlink(char *filename);\n\n#endif\n\n#endif\n\n\n\n//------------------------------------------------------------------------\n\n\n\nstatic void fileWrite(void *stream, const char *data, int len) {\n\n fwrite(data, 1, len, (FILE *)stream);\n\n}\n\n\n\n//------------------------------------------------------------------------\n\n// SplashFTFontEngine\n", "file_path": "Sankore-ThirdParty/xpdf/xpdf-3.03/splash/SplashFTFontEngine.cc", "rank": 96, "score": 18.46579421277498 }, { "content": "\n\n\n\n\n\n#include \"UBResources.h\"\n\n\n\n#include <QtGui>\n\n\n\n#include \"core/UBApplication.h\"\n\n#include \"core/UBSettings.h\"\n\n#include \"frameworks/UBFileSystemUtils.h\"\n\n#include \"core/memcheck.h\"\n\n\n\n\n\nUBResources* UBResources::sSingleton = 0;\n\n\n\nUBResources::UBResources(QObject* pParent)\n\n : QObject(pParent)\n\n{\n\n // NOOP\n\n}\n", "file_path": "Sankore-3.1/src/gui/UBResources.cpp", "rank": 97, "score": 18.45114984885999 }, { "content": "#include \"DocumentWidget.h\"\n\n#include \"core/globalDefs.h\"\n\n\n\nDocumentWidget::DocumentWidget(const QString& docName, const char *name, QWidget *parent):QWidget(parent)\n\n{\n\n setObjectName(name);\n\n mName = docName;\n\n\n\n mpLayout = new QVBoxLayout();\n\n setLayout(mpLayout);\n\n}\n\n\n\nDocumentWidget::~DocumentWidget()\n\n{\n\n DELETEPTR(mpWidget);\n\n DELETEPTR(mpLayout);\n\n}\n\n\n\nQWidget* DocumentWidget::widget()\n\n{\n", "file_path": "Sankore-AppToolkit/src/gui/DocumentWidget.cpp", "rank": 98, "score": 18.361126786779586 }, { "content": "};\n\n\n\nFileReader *FileReader::make(char *fileName) {\n\n FILE *fA;\n\n\n\n if (!(fA = fopen(fileName, \"rb\"))) {\n\n return NULL;\n\n }\n\n return new FileReader(fA);\n\n}\n\n\n\nFileReader::FileReader(FILE *fA) {\n\n f = fA;\n\n bufPos = 0;\n\n bufLen = 0;\n\n}\n\n\n\nFileReader::~FileReader() {\n\n fclose(f);\n\n}\n", "file_path": "Sankore-ThirdParty/xpdf/xpdf-3.03/fofi/FoFiIdentifier.cc", "rank": 99, "score": 18.34424585771272 } ]
C++
libs/semanticsearch/src/semanticsearch/query/query_executor.cpp
devjsc/ledger
5681480faf6e2aeee577f149c17745d6ab4d4ab3
#include "semanticsearch/query/query_executor.hpp" #include <cassert> namespace fetch { namespace semanticsearch { QueryExecutor::QueryExecutor(SharedSemanticSearchModule instance, ErrorTracker &error_tracker) : error_tracker_(error_tracker) , semantic_search_module_{std::move(instance)} {} void QueryExecutor::Execute(Query const &query, Agent agent) { agent_ = std::move(agent); error_tracker_.SetSource(query.source, query.filename); if (query.statements.empty()) { return; } for (auto const &stmt : query.statements) { switch (stmt[0].properties) { case QueryInstruction::PROP_CTX_MODEL: ExecuteDefine(stmt); break; case QueryInstruction::PROP_CTX_SET: ExecuteSet(stmt); break; case QueryInstruction::PROP_CTX_STORE: ExecuteStore(stmt); break; default: error_tracker_.RaiseRuntimeError("Unknown statement type.", stmt[0].token); return; } if (error_tracker_.HasErrors()) { break; } } } QueryExecutor::Vocabulary QueryExecutor::GetInstance(std::string const &name) { assert(context_.Has(name)); return context_.Get(name); } void QueryExecutor::ExecuteStore(CompiledStatement const &stmt) { using Type = QueryInstruction::Type; if (stmt[1].type != Type::IDENTIFIER) { error_tracker_.RaiseSyntaxError("Expected variable name.", stmt[1].token); return; } auto name = static_cast<std::string>(stmt[1].token); if (!context_.Has(name)) { error_tracker_.RaiseSyntaxError("Vairable not defined", stmt[1].token); return; } auto obj = context_.Get(name); auto model_name = context_.GetModelName(name); if (!semantic_search_module_->HasModel(model_name)) { error_tracker_.RaiseSyntaxError("Could not find model '" + model_name + "'", stmt[1].token); return; } auto model = semantic_search_module_->GetModel(model_name); if (model == nullptr) { error_tracker_.RaiseInternalError("Model '" + model_name + "' is null.", stmt[1].token); return; } model->VisitSubmodelsWithVocabulary( [this, stmt](std::string, std::string mname, Vocabulary obj) { auto model = semantic_search_module_->GetModel(mname); if (model == nullptr) { error_tracker_.RaiseSyntaxError("Could not find model '" + mname + "'", stmt[1].token); return; } SemanticPosition position = model->Reduce(obj); assert(semantic_search_module_->advertisement_register() != nullptr); semantic_search_module_->advertisement_register()->AdvertiseAgent(agent_->id, mname, position); agent_->RegisterVocabularyLocation(mname, position); }, obj); } void QueryExecutor::ExecuteSet(CompiledStatement const &stmt) { using Type = QueryInstruction::Type; std::size_t i = 3; if (stmt.size() < i) { error_tracker_.RaiseSyntaxError("Set statment has incorrect syntax.", stmt[0].token); return; } if (stmt[1].type != Type::IDENTIFIER) { error_tracker_.RaiseSyntaxError("Expected variable name.", stmt[1].token); return; } if (stmt[2].type != Type::IDENTIFIER) { error_tracker_.RaiseSyntaxError("Expected variable type.", stmt[2].token); return; } std::vector<QueryVariant> stack; std::vector<Vocabulary> scope_objects; Vocabulary last; int scope_depth = 0; QueryVariant object_name = NewQueryVariant(static_cast<std::string>(stmt[1].token), TYPE_KEY, stmt[1].token); stack.push_back(object_name); QueryVariant model_name = NewQueryVariant(static_cast<std::string>(stmt[2].token), TYPE_KEY, stmt[2].token); stack.push_back(model_name); while (i < stmt.size()) { auto x = stmt[i]; switch (x.type) { case Type::PUSH_SCOPE: { ++scope_depth; auto obj = VocabularyInstance::New<PropertyMap>({}); scope_objects.push_back(obj); break; } case Type::POP_SCOPE: --scope_depth; last = scope_objects.back(); scope_objects.pop_back(); { QueryVariant s = NewQueryVariant(last, TYPE_INSTANCE, x.token); stack.push_back(s); } break; case Type::ATTRIBUTE: { auto value = stack.back(); stack.pop_back(); auto key = stack.back(); stack.pop_back(); auto object = scope_objects.back(); assert(object != nullptr); std::string name = static_cast<std::string>(key->As<Token>()); switch (value->type()) { case TYPE_INTEGER: object->Insert(name, VocabularyInstance::New<Int>(value->As<Int>())); break; case TYPE_FLOAT: object->Insert(name, VocabularyInstance::New<Float>(value->As<Float>())); break; case TYPE_STRING: object->Insert(name, VocabularyInstance::New<String>(value->As<String>())); break; case TYPE_INSTANCE: object->Insert(name, value->As<Vocabulary>()); break; default: break; } } break; case Type::SEPARATOR: break; case Type::IDENTIFIER: { auto obj = context_.Get(static_cast<std::string>( x.token)); QueryVariant ele = NewQueryVariant(obj, TYPE_INSTANCE, x.token); stack.push_back(ele); break; } case Type::FLOAT: { QueryVariant ele = NewQueryVariant(Float(x.token.AsFloat()), TYPE_FLOAT, x.token); stack.push_back(ele); break; } case Type::INTEGER: { QueryVariant ele = NewQueryVariant(Int(atol(std::string(x.token).c_str())), TYPE_INTEGER, x.token); stack.push_back(ele); break; } case Type::STRING: { std::string str = static_cast<std::string>(x.token.SubArray(1, x.token.size() - 2)); QueryVariant ele = NewQueryVariant(str, TYPE_STRING, x.token); stack.push_back(ele); break; } case Type::OBJECT_KEY: { QueryVariant ele = NewQueryVariant(x.token, TYPE_KEY, x.token); stack.push_back(ele); break; } default: break; } ++i; } if (static_cast<bool>(last)) { auto value = stack.back(); stack.pop_back(); auto model_var = stack.back(); stack.pop_back(); auto key = stack.back(); stack.pop_back(); auto name_of_model = model_var->As<std::string>(); auto model = semantic_search_module_->GetModel(name_of_model); if (model == nullptr) { error_tracker_.RaiseRuntimeError("Could not find model '" + name_of_model + "'.", stmt[stmt.size() - 1].token); return; } if (!model->Validate(last)) { error_tracker_.RaiseRuntimeError("Instance does not match model requirements.", stmt[stmt.size() - 1].token); return; } context_.Set(key->As<std::string>(), last, name_of_model); } else { error_tracker_.RaiseRuntimeError( "No object instance was created, only declared. This is not supported yet.", stmt[stmt.size() - 1].token); return; } } void QueryExecutor::ExecuteDefine(CompiledStatement const &stmt) { std::size_t i = 1; stack_.clear(); std::vector<ModelInterfaceBuilder> scope_models; ModelInterfaceBuilder last; int scope_depth = 0; using Type = QueryInstruction::Type; while (i < stmt.size()) { auto x = stmt[i]; switch (x.type) { case Type::PUSH_SCOPE: ++scope_depth; scope_models.push_back(semantic_search_module_->NewProxy()); break; case Type::POP_SCOPE: --scope_depth; last = scope_models.back(); scope_models.pop_back(); { QueryVariant s = NewQueryVariant(last.model(), TYPE_MODEL, x.token); stack_.push_back(s); } break; case Type::ATTRIBUTE: { QueryVariant value = stack_.back(); stack_.pop_back(); QueryVariant key = stack_.back(); stack_.pop_back(); auto model = scope_models.back(); if (TypeMismatch<ModelField>(value, x.token)) { return; } if (TypeMismatch<Token>(key, x.token)) { return; } if (value->As<ModelField>() == nullptr) { error_tracker_.RaiseInternalError("Attribute value is null.", x.token); break; } if (model.model() == nullptr) { error_tracker_.RaiseInternalError("Model is null.", x.token); break; } model.Field(static_cast<std::string>(key->As<Token>()), value->As<ModelField>()); } break; case Type::SEPARATOR: break; case Type::IDENTIFIER: if (scope_depth == 0) { QueryVariant ele = NewQueryVariant(x.token, TYPE_KEY, x.token); stack_.push_back(ele); } else { auto field_name = static_cast<std::string>(x.token); if (!semantic_search_module_->HasField(field_name)) { error_tracker_.RaiseRuntimeError( "Could not find field: " + static_cast<std::string>(x.token), x.token); return; } QueryVariant ele = NewQueryVariant(semantic_search_module_->GetField(field_name), TYPE_MODEL, x.token); stack_.push_back(ele); } break; case Type::FLOAT: { QueryVariant ele = NewQueryVariant(x.token.AsFloat(), TYPE_FLOAT, x.token); stack_.push_back(ele); break; } case Type::INTEGER: { QueryVariant ele = NewQueryVariant(Int(atol(std::string(x.token).c_str())), TYPE_INTEGER, x.token); stack_.push_back(ele); break; } case Type::STRING: { std::string str = static_cast<std::string>(x.token.SubArray(1, x.token.size() - 2)); QueryVariant ele = NewQueryVariant(str, TYPE_STRING, x.token); stack_.push_back(ele); break; } case Type::OBJECT_KEY: { QueryVariant ele = NewQueryVariant(x.token, TYPE_KEY, x.token); stack_.push_back(ele); break; } case Type::FUNCTION: { QueryVariant ele = NewQueryVariant(x.token, TYPE_FUNCTION_NAME, x.token); stack_.push_back(ele); break; } case Type::EXECUTE_CALL: { if (stack_.empty()) { std::cerr << "INTERNAL ERROR!" << std::endl; exit(-1); } std::vector<void const *> args; std::vector<std::type_index> arg_signature; uint64_t n = stack_.size() - 1; while ((n != 0) && (stack_[n]->type() != TYPE_FUNCTION_NAME)) { auto arg = stack_[n]; args.push_back(arg->data()); arg_signature.push_back(arg->type_index()); --n; } std::reverse(args.begin(), args.end()); std::reverse(arg_signature.begin(), arg_signature.end()); if (TypeMismatch<Token>(stack_[n], stack_[n]->token())) { return; } auto function_name = static_cast<std::string>(stack_[n]->As<Token>()); if (!semantic_search_module_->HasFunction(function_name)) { error_tracker_.RaiseRuntimeError("Function '" + function_name + "' does not exist.", stack_[n]->token()); return; } auto & function = (*semantic_search_module_)[function_name]; std::type_index ret_type = function.return_type(); if (!function.ValidateSignature(ret_type, arg_signature)) { error_tracker_.RaiseRuntimeError( "Call to '" + function_name + "' does not match signature.", stack_[n]->token()); return; } QueryVariant ret; try { ret = function(args); } catch (std::runtime_error const &e) { error_tracker_.RaiseRuntimeError(e.what(), stack_[n]->token()); return; } for (std::size_t j = 0; j < args.size(); ++j) { stack_.pop_back(); } stack_.pop_back(); stack_.push_back(ret); break; } default: std::cout << "'" << x.token << "' - TODO IMPLEMENT " << std::endl; break; } ++i; } if (bool(last)) { auto value = stack_.back(); stack_.pop_back(); auto key = stack_.back(); stack_.pop_back(); semantic_search_module_->AddModel(static_cast<std::string>(key->As<Token>()), last.model()); } else { std::cout << "NOT READY: " << last.model() << std::endl; } } } }
#include "semanticsearch/query/query_executor.hpp" #include <cassert> namespace fetch { namespace semanticsearch { QueryExecutor::QueryExecutor(SharedSemanticSearchModule instance, ErrorTracker &error_tracker) : error_tracker_(error_tracker) , semantic_search_module_{std::move(instance)} {} void QueryExecutor::Execute(Query const &query, Agent agent) { agent_ = std::move(agent); error_tracker_.SetSource(query.source, query.filename); if (query.statements.empty()) { return; } for (auto const &stmt : query.statements) { switch (stmt[0].properties) { case QueryInstruction::PROP_CTX_MODEL: ExecuteDefine(stmt); break; case QueryInstruction::PROP_CTX_SET: ExecuteSet(stmt); break; case QueryInstruction::PROP_CTX_STORE: ExecuteStore(stmt); break; default: error_tracker_.RaiseRuntimeError("Unknown statement type.", stmt[0].token); return; } if (error_tracker_.HasErrors()) { break; } } } QueryExecutor::Vocabulary QueryExecutor::GetInstance(std::string const &name) { assert(context_.Has(name)); return context_.Get(name); } void QueryExecutor::ExecuteStore(CompiledStatement const &stmt) { using Type = QueryInstruction::Type; if (stmt[1].type != Type::IDENTIFIER) { error_tracker_.RaiseSyntaxError("Expected variable name.", stmt[1].token); return; } auto name = static_cast<std::string>(stmt[1].token); if (!context_.Has(name)) { error_tracker_.RaiseSyntaxError("Vairable not defined", stmt[1].token); return; } auto obj = context_.Get(name); auto model_name = context_.GetModelName(name); if (!semantic_search_module_->HasModel(model_name)) { error_tracker_.RaiseSyntaxError("Could not find model '" + model_name + "'", stmt[1].token); return; } auto model = semantic_search_module_->GetModel(model_name); if (model == nullptr) { error_tracker_.RaiseInternalError("Model '" + model_name + "' is null.", stmt[1].token); return; }
; } void QueryExecutor::ExecuteSet(CompiledStatement const &stmt) { using Type = QueryInstruction::Type; std::size_t i = 3; if (stmt.size() < i) { error_tracker_.RaiseSyntaxError("Set statment has incorrect syntax.", stmt[0].token); return; } if (stmt[1].type != Type::IDENTIFIER) { error_tracker_.RaiseSyntaxError("Expected variable name.", stmt[1].token); return; } if (stmt[2].type != Type::IDENTIFIER) { error_tracker_.RaiseSyntaxError("Expected variable type.", stmt[2].token); return; } std::vector<QueryVariant> stack; std::vector<Vocabulary> scope_objects; Vocabulary last; int scope_depth = 0; QueryVariant object_name = NewQueryVariant(static_cast<std::string>(stmt[1].token), TYPE_KEY, stmt[1].token); stack.push_back(object_name); QueryVariant model_name = NewQueryVariant(static_cast<std::string>(stmt[2].token), TYPE_KEY, stmt[2].token); stack.push_back(model_name); while (i < stmt.size()) { auto x = stmt[i]; switch (x.type) { case Type::PUSH_SCOPE: { ++scope_depth; auto obj = VocabularyInstance::New<PropertyMap>({}); scope_objects.push_back(obj); break; } case Type::POP_SCOPE: --scope_depth; last = scope_objects.back(); scope_objects.pop_back(); { QueryVariant s = NewQueryVariant(last, TYPE_INSTANCE, x.token); stack.push_back(s); } break; case Type::ATTRIBUTE: { auto value = stack.back(); stack.pop_back(); auto key = stack.back(); stack.pop_back(); auto object = scope_objects.back(); assert(object != nullptr); std::string name = static_cast<std::string>(key->As<Token>()); switch (value->type()) { case TYPE_INTEGER: object->Insert(name, VocabularyInstance::New<Int>(value->As<Int>())); break; case TYPE_FLOAT: object->Insert(name, VocabularyInstance::New<Float>(value->As<Float>())); break; case TYPE_STRING: object->Insert(name, VocabularyInstance::New<String>(value->As<String>())); break; case TYPE_INSTANCE: object->Insert(name, value->As<Vocabulary>()); break; default: break; } } break; case Type::SEPARATOR: break; case Type::IDENTIFIER: { auto obj = context_.Get(static_cast<std::string>( x.token)); QueryVariant ele = NewQueryVariant(obj, TYPE_INSTANCE, x.token); stack.push_back(ele); break; } case Type::FLOAT: { QueryVariant ele = NewQueryVariant(Float(x.token.AsFloat()), TYPE_FLOAT, x.token); stack.push_back(ele); break; } case Type::INTEGER: { QueryVariant ele = NewQueryVariant(Int(atol(std::string(x.token).c_str())), TYPE_INTEGER, x.token); stack.push_back(ele); break; } case Type::STRING: { std::string str = static_cast<std::string>(x.token.SubArray(1, x.token.size() - 2)); QueryVariant ele = NewQueryVariant(str, TYPE_STRING, x.token); stack.push_back(ele); break; } case Type::OBJECT_KEY: { QueryVariant ele = NewQueryVariant(x.token, TYPE_KEY, x.token); stack.push_back(ele); break; } default: break; } ++i; } if (static_cast<bool>(last)) { auto value = stack.back(); stack.pop_back(); auto model_var = stack.back(); stack.pop_back(); auto key = stack.back(); stack.pop_back(); auto name_of_model = model_var->As<std::string>(); auto model = semantic_search_module_->GetModel(name_of_model); if (model == nullptr) { error_tracker_.RaiseRuntimeError("Could not find model '" + name_of_model + "'.", stmt[stmt.size() - 1].token); return; } if (!model->Validate(last)) { error_tracker_.RaiseRuntimeError("Instance does not match model requirements.", stmt[stmt.size() - 1].token); return; } context_.Set(key->As<std::string>(), last, name_of_model); } else { error_tracker_.RaiseRuntimeError( "No object instance was created, only declared. This is not supported yet.", stmt[stmt.size() - 1].token); return; } } void QueryExecutor::ExecuteDefine(CompiledStatement const &stmt) { std::size_t i = 1; stack_.clear(); std::vector<ModelInterfaceBuilder> scope_models; ModelInterfaceBuilder last; int scope_depth = 0; using Type = QueryInstruction::Type; while (i < stmt.size()) { auto x = stmt[i]; switch (x.type) { case Type::PUSH_SCOPE: ++scope_depth; scope_models.push_back(semantic_search_module_->NewProxy()); break; case Type::POP_SCOPE: --scope_depth; last = scope_models.back(); scope_models.pop_back(); { QueryVariant s = NewQueryVariant(last.model(), TYPE_MODEL, x.token); stack_.push_back(s); } break; case Type::ATTRIBUTE: { QueryVariant value = stack_.back(); stack_.pop_back(); QueryVariant key = stack_.back(); stack_.pop_back(); auto model = scope_models.back(); if (TypeMismatch<ModelField>(value, x.token)) { return; } if (TypeMismatch<Token>(key, x.token)) { return; } if (value->As<ModelField>() == nullptr) { error_tracker_.RaiseInternalError("Attribute value is null.", x.token); break; } if (model.model() == nullptr) { error_tracker_.RaiseInternalError("Model is null.", x.token); break; } model.Field(static_cast<std::string>(key->As<Token>()), value->As<ModelField>()); } break; case Type::SEPARATOR: break; case Type::IDENTIFIER: if (scope_depth == 0) { QueryVariant ele = NewQueryVariant(x.token, TYPE_KEY, x.token); stack_.push_back(ele); } else { auto field_name = static_cast<std::string>(x.token); if (!semantic_search_module_->HasField(field_name)) { error_tracker_.RaiseRuntimeError( "Could not find field: " + static_cast<std::string>(x.token), x.token); return; } QueryVariant ele = NewQueryVariant(semantic_search_module_->GetField(field_name), TYPE_MODEL, x.token); stack_.push_back(ele); } break; case Type::FLOAT: { QueryVariant ele = NewQueryVariant(x.token.AsFloat(), TYPE_FLOAT, x.token); stack_.push_back(ele); break; } case Type::INTEGER: { QueryVariant ele = NewQueryVariant(Int(atol(std::string(x.token).c_str())), TYPE_INTEGER, x.token); stack_.push_back(ele); break; } case Type::STRING: { std::string str = static_cast<std::string>(x.token.SubArray(1, x.token.size() - 2)); QueryVariant ele = NewQueryVariant(str, TYPE_STRING, x.token); stack_.push_back(ele); break; } case Type::OBJECT_KEY: { QueryVariant ele = NewQueryVariant(x.token, TYPE_KEY, x.token); stack_.push_back(ele); break; } case Type::FUNCTION: { QueryVariant ele = NewQueryVariant(x.token, TYPE_FUNCTION_NAME, x.token); stack_.push_back(ele); break; } case Type::EXECUTE_CALL: { if (stack_.empty()) { std::cerr << "INTERNAL ERROR!" << std::endl; exit(-1); } std::vector<void const *> args; std::vector<std::type_index> arg_signature; uint64_t n = stack_.size() - 1; while ((n != 0) && (stack_[n]->type() != TYPE_FUNCTION_NAME)) { auto arg = stack_[n]; args.push_back(arg->data()); arg_signature.push_back(arg->type_index()); --n; } std::reverse(args.begin(), args.end()); std::reverse(arg_signature.begin(), arg_signature.end()); if (TypeMismatch<Token>(stack_[n], stack_[n]->token())) { return; } auto function_name = static_cast<std::string>(stack_[n]->As<Token>()); if (!semantic_search_module_->HasFunction(function_name)) { error_tracker_.RaiseRuntimeError("Function '" + function_name + "' does not exist.", stack_[n]->token()); return; } auto & function = (*semantic_search_module_)[function_name]; std::type_index ret_type = function.return_type(); if (!function.ValidateSignature(ret_type, arg_signature)) { error_tracker_.RaiseRuntimeError( "Call to '" + function_name + "' does not match signature.", stack_[n]->token()); return; } QueryVariant ret; try { ret = function(args); } catch (std::runtime_error const &e) { error_tracker_.RaiseRuntimeError(e.what(), stack_[n]->token()); return; } for (std::size_t j = 0; j < args.size(); ++j) { stack_.pop_back(); } stack_.pop_back(); stack_.push_back(ret); break; } default: std::cout << "'" << x.token << "' - TODO IMPLEMENT " << std::endl; break; } ++i; } if (bool(last)) { auto value = stack_.back(); stack_.pop_back(); auto key = stack_.back(); stack_.pop_back(); semantic_search_module_->AddModel(static_cast<std::string>(key->As<Token>()), last.model()); } else { std::cout << "NOT READY: " << last.model() << std::endl; } } } }
model->VisitSubmodelsWithVocabulary( [this, stmt](std::string, std::string mname, Vocabulary obj) { auto model = semantic_search_module_->GetModel(mname); if (model == nullptr) { error_tracker_.RaiseSyntaxError("Could not find model '" + mname + "'", stmt[1].token); return; } SemanticPosition position = model->Reduce(obj); assert(semantic_search_module_->advertisement_register() != nullptr); semantic_search_module_->advertisement_register()->AdvertiseAgent(agent_->id, mname, position); agent_->RegisterVocabularyLocation(mname, position); }, obj)
call_expression
[ { "content": " enum class Type\n\n {\n\n UNKNOWN = 0,\n\n SET_CONTEXT,\n\n PUSH_SCOPE,\n\n POP_SCOPE,\n\n\n\n FUNCTION = 50,\n\n EXECUTE_CALL,\n\n\n\n // Operators come first and are ordered according to precendence\n\n // That is: DO not change the order unless you intensionally\n\n // want to change the behaviour of the program.\n\n MULTIPLY = 100,\n\n ADD,\n\n SUB,\n\n\n\n EQUAL,\n\n NOT_EQUAL,\n\n LESS_THAN,\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_instruction.hpp", "rank": 0, "score": 289331.1386359479 }, { "content": "struct MapSerializer<fetch::ml::model::ModelConfig<DataType>, D>\n\n{\n\n using Type = fetch::ml::model::ModelConfig<DataType>;\n\n using DriverType = D;\n\n\n\n // public member variables\n\n static uint8_t const EARLY_STOPPING = 1;\n\n static uint8_t const TEST = 2;\n\n static uint8_t const PATIENCE = 3;\n\n static uint8_t const MIN_DELTA = 4;\n\n static uint8_t const LEARNING_RATE_PARAM = 6;\n\n static uint8_t const BATCH_SIZE = 7;\n\n static uint8_t const SUSBET_SIZE = 8;\n\n static uint8_t const PRINT_STATS = 9;\n\n\n\n template <typename Constructor>\n\n static void Serialize(Constructor &map_constructor, Type const &sp)\n\n {\n\n auto map = map_constructor(9);\n\n\n", "file_path": "libs/ml/include/ml/model/model_config.hpp", "rank": 1, "score": 270665.2542752603 }, { "content": "type InnerProduct(array_type const &A, array_type const &B)\n\n{\n\n type ret{0};\n\n\n\n ret = A.in_parallel().SumReduce(\n\n [](auto const &a, auto const &b) {\n\n auto d = a - b;\n\n return d * d;\n\n },\n\n B);\n\n\n\n return ret;\n\n}\n\n\n\nint main(int argc, char const **argv)\n\n{\n\n if (argc != 2)\n\n {\n\n std::cout << std::endl;\n\n std::cout << \"Usage: \" << argv[0] << \" [array size] \" << std::endl;\n", "file_path": "libs/vectorise/examples/03_sum_reduce_fetch/main.cpp", "rank": 2, "score": 256100.03522125137 }, { "content": "type InnerProduct(array_type const &A, array_type const &B)\n\n{\n\n type ret = 0;\n\n\n\n ret = A.in_parallel().SumReduce(\n\n [](auto const &a, auto const &b) {\n\n auto d = a - b;\n\n return d * d;\n\n },\n\n B);\n\n\n\n return ret;\n\n}\n\n\n\nint main(int /*argc*/, char ** /*argv*/)\n\n{\n\n array_type A, B;\n\n\n\n double product = InnerProduct(A, B);\n\n std::cout << \"product = \" << product << std::endl;\n\n\n\n return 0;\n\n}\n", "file_path": "libs/vectorise/examples/04_product_reduce_fetch/main.cpp", "rank": 3, "score": 256100.03522125137 }, { "content": "struct ArgumentsToTypeVector<R, void>\n\n{\n\n static void Apply(std::vector<std::type_index> & /*args*/)\n\n {}\n\n};\n\n\n\n/* This code converts a vector of type-erased types\n\n * into the types matching the argument types.\n\n */\n\ntemplate <uint64_t N, typename... UsedArgs>\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/args_resolver.hpp", "rank": 4, "score": 255810.43422285342 }, { "content": "type Reduction(array_type const &A)\n\n{\n\n type ret{0};\n\n\n\n ret = A.in_parallel().Reduce([](auto const &a, auto const &b) { return a + b; },\n\n [](vector_type const &a) -> type { return reduce(a); });\n\n\n\n return ret;\n\n}\n\n\n\nint main(int argc, char const **argv)\n\n{\n\n if (argc != 2)\n\n {\n\n std::cout << std::endl;\n\n std::cout << \"Usage: \" << argv[0] << \" [array size] \" << std::endl;\n\n std::cout << std::endl;\n\n return 0;\n\n }\n\n\n", "file_path": "libs/vectorise/examples/02_reduction_fetch/main.cpp", "rank": 5, "score": 251146.5771658036 }, { "content": "class Switch : public fetch::ml::ops::Ops<T>\n\n{\n\npublic:\n\n using TensorType = T;\n\n using DataType = typename TensorType::Type;\n\n using SizeType = fetch::math::SizeType;\n\n using ArrayPtrType = std::shared_ptr<TensorType>;\n\n using VecTensorType = typename Ops<T>::VecTensorType;\n\n using SPType = OpSwitchSaveableParams<T>;\n\n using MyType = Switch<TensorType>;\n\n\n\n Switch() = default;\n\n\n\n explicit Switch(SPType const &sp)\n\n : Ops<T>(sp)\n\n {}\n\n\n\n ~Switch() override = default;\n\n\n\n std::shared_ptr<OpsSaveableParams> GetOpSaveableParams() override\n", "file_path": "libs/ml/include/ml/ops/switch.hpp", "rank": 6, "score": 223860.00393159877 }, { "content": "struct MapSerializer<ml::model::Model<TensorType>, D>\n\n{\n\n using Type = ml::model::Model<TensorType>;\n\n using DriverType = D;\n\n\n\n // protected member variables\n\n static uint8_t const GRAPH = 1;\n\n static uint8_t const MODEL_CONFIG = 2;\n\n static uint8_t const DATALOADER_PTR = 3;\n\n static uint8_t const DATALOADER_TYPE = 4;\n\n static uint8_t const OPTIMISER_PTR = 5;\n\n static uint8_t const OPTIMISER_TYPE = 6;\n\n\n\n static uint8_t const INPUT_NODE_NAME = 7;\n\n static uint8_t const LABEL_NODE_NAME = 8;\n\n static uint8_t const OUTPUT_NODE_NAME = 9;\n\n static uint8_t const ERROR_NODE_NAME = 10;\n\n\n\n static uint8_t const LOSS_SET_FLAG = 11;\n\n static uint8_t const OPTIMISER_SET_FLAG = 12;\n", "file_path": "libs/ml/include/ml/model/model.hpp", "rank": 7, "score": 218022.4973769128 }, { "content": "struct Invoke<ClassType, MemberFunctionPointer, void, UsedArgs...>\n\n{\n\n static void MemberFunction(SerializerType &result, ClassType &cls, MemberFunctionPointer &m,\n\n UsedArgs &... args)\n\n {\n\n result << uint8_t(0);\n\n (cls.*m)(args...);\n\n };\n\n};\n\n\n\n/* Struct used for unrolling arguments in a function signature.\n\n * @UsedArgs are the unpacked arguments.\n\n */\n\ntemplate <typename ClassType, typename MemberFunctionPointer, typename ReturnType,\n\n typename... UsedArgs>\n", "file_path": "libs/network/include/network/service/callable_class_member.hpp", "rank": 8, "score": 213207.68423119298 }, { "content": "type InnerProduct(array_type const &A, array_type const &B)\n\n{\n\n type ret{0};\n\n\n\n for (std::size_t i = 0; i < A.size(); ++i)\n\n {\n\n type d = A[i] - B[i];\n\n ret += d * d;\n\n }\n\n\n\n return ret;\n\n}\n\n\n\nint main(int argc, char const **argv)\n\n{\n\n\n\n if (argc != 2)\n\n {\n\n std::cout << std::endl;\n\n std::cout << \"Usage: \" << argv[0] << \" [array size] \" << std::endl;\n", "file_path": "libs/vectorise/examples/03_sum_reduce/ordinary_solution.cpp", "rank": 9, "score": 210272.00089386024 }, { "content": "class Sequential : public Model<TensorType>\n\n{\n\npublic:\n\n using SizeType = fetch::math::SizeType;\n\n using DataType = typename TensorType::Type;\n\n using CostFunctionType = fetch::ml::ops::CrossEntropyLoss<TensorType>;\n\n using OptimiserType = fetch::ml::OptimiserType;\n\n using DataLoaderPtrType = typename Model<TensorType>::DataLoaderPtrType;\n\n\n\n Sequential();\n\n Sequential(Sequential const &other) = default;\n\n explicit Sequential(ModelConfig<DataType> model_config);\n\n ~Sequential() override = default;\n\n\n\n template <typename LayerType, typename... Params>\n\n void Add(Params... params);\n\n\n\n template <typename X, typename D>\n\n friend struct serializers::MapSerializer;\n\n\n", "file_path": "libs/ml/include/ml/model/sequential.hpp", "rank": 10, "score": 205855.93084630012 }, { "content": "struct MemberFunctionTraits<void, R (C::*)(Args...) const>\n\n{\n\n using ReturnType = R;\n\n using ArgsTupleType = std::tuple<Args...>;\n\n};\n\ntemplate <typename R, typename C, typename... Args>\n", "file_path": "libs/meta/include/meta/callable/callable_traits.hpp", "rank": 11, "score": 205655.82208797312 }, { "content": "struct Query\n\n{\n\n using ConstByteArray = fetch::byte_array::ConstByteArray;\n\n ConstByteArray source;\n\n ConstByteArray filename;\n\n std::vector<CompiledStatement> statements;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query.hpp", "rank": 12, "score": 204031.11548877592 }, { "content": "\n\n#include \"core/byte_array/byte_array.hpp\"\n\n#include \"core/byte_array/const_byte_array.hpp\"\n\n#include \"core/byte_array/consumers.hpp\"\n\n#include \"core/byte_array/tokenizer/tokenizer.hpp\"\n\n\n\n#include <vector>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query.hpp", "rank": 13, "score": 201113.7491416155 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/query/query_instruction.hpp\"\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query.hpp", "rank": 14, "score": 201112.79322393824 }, { "content": "class DNNRegressor : public Model<TensorType>\n\n{\n\npublic:\n\n using SizeType = fetch::math::SizeType;\n\n using DataType = typename TensorType::Type;\n\n using CostFunctionType = fetch::ml::ops::MeanSquareErrorLoss<TensorType>;\n\n using OptimiserType = fetch::ml::OptimiserType;\n\n using DataLoaderPtrType = typename Model<TensorType>::DataLoaderPtrType;\n\n\n\n DNNRegressor() = default;\n\n DNNRegressor(DNNRegressor const &other) = default;\n\n ~DNNRegressor() override = default;\n\n\n\n DNNRegressor(ModelConfig<DataType> model_config, std::vector<SizeType> const &hidden_layers);\n\n};\n\n\n\n/**\n\n * constructor sets up the neural net architecture and optimiser\n\n * @tparam TensorType\n\n * @param data_loader_ptr pointer to the dataloader for running the optimiser\n", "file_path": "libs/ml/include/ml/model/dnn_regressor.hpp", "rank": 15, "score": 199220.0237408324 }, { "content": "class DNNClassifier : public Model<TensorType>\n\n{\n\npublic:\n\n using SizeType = fetch::math::SizeType;\n\n using DataType = typename TensorType::Type;\n\n using CostFunctionType = fetch::ml::ops::CrossEntropyLoss<TensorType>;\n\n using OptimiserType = fetch::ml::OptimiserType;\n\n using DataLoaderPtrType = typename Model<TensorType>::DataLoaderPtrType;\n\n\n\n DNNClassifier() = default;\n\n DNNClassifier(DNNClassifier const &other) = default;\n\n ~DNNClassifier() override = default;\n\n\n\n DNNClassifier(ModelConfig<DataType> model_config, std::vector<SizeType> const &hidden_layers);\n\n};\n\n\n\n/**\n\n * constructor sets up the neural net architecture and optimiser\n\n * @tparam TensorType\n\n * @param data_loader_ptr pointer to the dataloader for running the optimiser\n", "file_path": "libs/ml/include/ml/model/dnn_classifier.hpp", "rank": 16, "score": 199220.0237408324 }, { "content": "class VMModel : public fetch::vm::Object\n\n{\n\npublic:\n\n using DataType = fetch::vm_modules::math::DataType;\n\n using TensorType = fetch::math::Tensor<DataType>;\n\n using ModelType = fetch::ml::model::Model<TensorType>;\n\n using ModelPtrType = std::shared_ptr<ModelType>;\n\n using ModelConfigType = fetch::ml::model::ModelConfig<DataType>;\n\n using ModelConfigPtrType = std::shared_ptr<fetch::ml::model::ModelConfig<DataType>>;\n\n using GraphType = fetch::ml::Graph<TensorType>;\n\n using TensorDataloader = fetch::ml::dataloaders::TensorDataLoader<TensorType, TensorType>;\n\n using TensorDataloaderPtr = std::shared_ptr<TensorDataloader>;\n\n using VMTensor = fetch::vm_modules::math::VMTensor;\n\n\n\n VMModel(fetch::vm::VM *vm, fetch::vm::TypeId type_id);\n\n\n\n VMModel(fetch::vm::VM *vm, fetch::vm::TypeId type_id,\n\n fetch::vm::Ptr<fetch::vm::String> const &model_category);\n\n\n\n VMModel(fetch::vm::VM *vm, fetch::vm::TypeId type_id, std::string const &model_category);\n", "file_path": "libs/vm-modules/include/vm_modules/ml/model/model.hpp", "rank": 17, "score": 198672.188464703 }, { "content": "type Reduction(array_type const &A)\n\n{\n\n type ret = 0;\n\n\n\n for (float i : A)\n\n {\n\n ret += i;\n\n }\n\n\n\n return ret;\n\n}\n\n\n\nint main(int argc, char const **argv)\n\n{\n\n std::vector<type> A;\n\n if (argc != 2)\n\n {\n\n std::cout << std::endl;\n\n std::cout << \"Usage: \" << argv[0] << \" [array size] \" << std::endl;\n\n std::cout << std::endl;\n", "file_path": "libs/vectorise/examples/02_reduction/ordinary_solution.cpp", "rank": 18, "score": 198535.96208472 }, { "content": " enum\n\n {\n\n TYPE_NONE = 0,\n\n TYPE_MODEL = 10,\n\n TYPE_INSTANCE,\n\n TYPE_KEY,\n\n TYPE_STRING,\n\n TYPE_INTEGER,\n\n TYPE_FLOAT,\n\n\n\n TYPE_FUNCTION_NAME\n\n };\n\n\n\n // TODO(private issue AEA-128): combine these three into a single execute statement.\n\n void ExecuteStore(CompiledStatement const &stmt);\n\n void ExecuteSet(CompiledStatement const &stmt);\n\n void ExecuteDefine(CompiledStatement const &stmt);\n\n\n\n template <typename T>\n\n bool TypeMismatch(QueryVariant const &var, Token token)\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_executor.hpp", "rank": 19, "score": 197222.233550629 }, { "content": " {\n\n if (!var->IsType<T>())\n\n {\n\n auto type_a = semantic_search_module_->GetName<T>();\n\n auto type_b = semantic_search_module_->GetName(var->type_index());\n\n error_tracker_.RaiseInternalError(\"Expected \" + type_a + \", but found other type \" + type_b,\n\n std::move(token));\n\n return true;\n\n }\n\n return false;\n\n }\n\n\n\n ErrorTracker & error_tracker_;\n\n std::vector<QueryVariant> stack_;\n\n ExecutionContext context_;\n\n SharedSemanticSearchModule semantic_search_module_;\n\n Agent agent_{nullptr};\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_executor.hpp", "rank": 20, "score": 197215.21693077145 }, { "content": " INTERNAL_OPEN_GROUP,\n\n INTERNAL_CLOSE_GROUP\n\n };\n\n\n\n enum\n\n {\n\n PROP_NO_PROP = 0ull,\n\n PROP_CTX_MODEL,\n\n PROP_CTX_STORE,\n\n PROP_CTX_SET,\n\n PROP_CTX_FIND,\n\n\n\n PROP_IS_OPERATOR = 1ul << 16,\n\n PROP_IS_GROUP = 1ul << 17,\n\n PROP_IS_GROUP_OPEN = 1ul << 18,\n\n PROP_IS_CALL = 1ul << 19\n\n };\n\n\n\n Type type = Type::UNKNOWN;\n\n uint64_t properties = PROP_NO_PROP;\n\n int consumes = 2;\n\n Token token;\n\n};\n\n\n\nusing CompiledStatement = std::vector<QueryInstruction>;\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_instruction.hpp", "rank": 21, "score": 197211.77258214226 }, { "content": " bool Match(ConstByteArray const &token) const;\n\n void SkipUntilEOL();\n\n void SkipWhitespaces();\n\n void SkipChar();\n\n void SkipChars(uint64_t const &length);\n\n\n\n void SkipUntil(uint8_t byte);\n\n\n\n ErrorTracker &error_tracker_;\n\n ByteArray document_;\n\n uint64_t position_{0};\n\n uint64_t char_index_{0};\n\n int line_{0};\n\n\n\n std::vector<Statement> statements_;\n\n\n\n std::vector<ConstByteArray> keywords_ = {\"model\", \"store\", \"find\", \"var\", \"subspace\", \"schema\"};\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_compiler.hpp", "rank": 22, "score": 197206.76158881577 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/query/error_tracker.hpp\"\n\n#include \"semanticsearch/query/execution_context.hpp\"\n\n#include \"semanticsearch/schema/vocabulary_instance.hpp\"\n\n#include \"semanticsearch/semantic_search_module.hpp\"\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_executor.hpp", "rank": 23, "score": 197205.92805941642 }, { "content": "#include \"core/byte_array/const_byte_array.hpp\"\n\n#include \"core/byte_array/consumers.hpp\"\n\n#include \"core/byte_array/tokenizer/tokenizer.hpp\"\n\n\n\n#include \"semanticsearch/query/error_tracker.hpp\"\n\n#include \"semanticsearch/query/query.hpp\"\n\n\n\n#include <vector>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_compiler.hpp", "rank": 24, "score": 197201.15004570823 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"core/byte_array/byte_array.hpp\"\n\n#include \"core/byte_array/const_byte_array.hpp\"\n\n#include \"core/byte_array/consumers.hpp\"\n\n#include \"core/byte_array/tokenizer/tokenizer.hpp\"\n\n\n\n#include <vector>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_instruction.hpp", "rank": 25, "score": 197192.24509104964 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"core/byte_array/byte_array.hpp\"\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_compiler.hpp", "rank": 26, "score": 197179.35765690348 }, { "content": " LESS_THAN_EQUAL,\n\n MORE_THAN,\n\n MORE_THAN_EQUAL,\n\n\n\n SUBSCOPE,\n\n VAR_TYPE,\n\n ASSIGN,\n\n ATTRIBUTE,\n\n SEPARATOR,\n\n\n\n OBJECT_KEY,\n\n\n\n // Literals\n\n FLOAT,\n\n INTEGER,\n\n STRING,\n\n\n\n IDENTIFIER,\n\n\n\n // Only used for compilation\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_instruction.hpp", "rank": 27, "score": 197177.69648052406 }, { "content": "struct QueryInstruction\n\n{\n\n using ConstByteArray = fetch::byte_array::ConstByteArray;\n\n using ByteArray = fetch::byte_array::ByteArray;\n\n using Token = fetch::byte_array::Token;\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_instruction.hpp", "rank": 28, "score": 197098.57604697032 }, { "content": "class QueryCompiler\n\n{\n\npublic:\n\n using ConstByteArray = fetch::byte_array::ConstByteArray;\n\n using ByteArray = fetch::byte_array::ByteArray;\n\n using Token = fetch::byte_array::Token;\n\n\n\n explicit QueryCompiler(ErrorTracker &error_tracker);\n\n Query operator()(ByteArray doc, ConstByteArray const &filename = \"(internal)\");\n\n\n\nprivate:\n\n struct Statement\n\n {\n\n std::vector<Token> tokens;\n\n int type;\n\n };\n\n\n\n std::vector<QueryInstruction> AssembleStatement(Statement const &stmt);\n\n void Tokenise();\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_compiler.hpp", "rank": 29, "score": 197098.57604697032 }, { "content": "class QueryExecutor\n\n{\n\npublic:\n\n using VocabularySchema = SemanticSearchModule::VocabularySchema;\n\n using ModelField = SemanticSearchModule::ModelField;\n\n using Token = fetch::byte_array::Token;\n\n using Vocabulary = std::shared_ptr<VocabularyInstance>;\n\n using SharedModelRegister = ModelRegister::SharedModelRegister;\n\n\n\n using Int = int; // TODO(private issue AEA-126): Get rid of these\n\n using Float = double;\n\n using String = std::string;\n\n\n\n QueryExecutor(SharedSemanticSearchModule instance, ErrorTracker &error_tracker);\n\n void Execute(Query const &query, Agent agent);\n\n Vocabulary GetInstance(std::string const &name);\n\n\n\nprivate:\n\n using PropertyMap = std::map<std::string, std::shared_ptr<VocabularyInstance>>;\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/query_executor.hpp", "rank": 30, "score": 197098.57604697032 }, { "content": " , value_{std::move(value)}\n\n {}\n\n\n\n T value_;\n\n};\n\n\n\nusing QueryVariant = std::shared_ptr<AbstractQueryVariant>;\n\n\n\ntemplate <typename T>\n\nQueryVariant NewQueryVariant(\n\n T val, int type = 0,\n\n AbstractQueryVariant::Token token = static_cast<AbstractQueryVariant::Token>(\"\"))\n\n{\n\n return SpecialisedQueryVariant<T>::New(std::move(val), type, std::move(token));\n\n}\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/abstract_query_variant.hpp", "rank": 31, "score": 193434.98854420625 }, { "content": "class AgentDirectory\n\n{\n\npublic:\n\n using AgentId = AgentProfile::AgentId;\n\n using ConstByteArray = fetch::byte_array::ConstByteArray;\n\n using Agent = AgentProfile::Agent;\n\n\n\n AgentId RegisterAgent(ConstByteArray const &pk);\n\n Agent GetAgent(ConstByteArray const &pk);\n\n bool UnregisterAgent(ConstByteArray const &pk);\n\n bool RegisterVocabularyLocation(AgentId id, std::string model, SemanticPosition position);\n\n\n\nprivate:\n\n AgentId counter_{0};\n\n std::unordered_map<ConstByteArray, AgentId> pk_to_id_;\n\n std::map<AgentId, Agent> agents_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/agent_directory.hpp", "rank": 32, "score": 193431.56122202356 }, { "content": "struct AgentProfile\n\n{\n\n using Identity = fetch::crypto::Identity;\n\n using Agent = std::shared_ptr<AgentProfile>;\n\n using AgentId = uint64_t;\n\n\n\n static Agent New(AgentId id)\n\n {\n\n return Agent(new AgentProfile(id));\n\n }\n\n\n\n void RegisterVocabularyLocation(std::string model, SemanticPosition position)\n\n {\n\n VocabularyLocation loc;\n\n\n\n loc.model = std::move(model);\n\n loc.position = std::move(position);\n\n\n\n locations.insert(std::move(loc));\n\n }\n", "file_path": "libs/semanticsearch/include/semanticsearch/agent_profile.hpp", "rank": 33, "score": 193431.56122202356 }, { "content": "#include \"core/byte_array/const_byte_array.hpp\"\n\n#include \"core/byte_array/tokenizer/tokenizer.hpp\"\n\n\n\n#include <memory>\n\n#include <stdexcept>\n\n#include <typeindex>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/abstract_query_variant.hpp", "rank": 34, "score": 193428.0184247696 }, { "content": " }\n\n return *reinterpret_cast<T *>(data());\n\n }\n\n\n\n template <typename T>\n\n bool IsType() const\n\n {\n\n return std::type_index(typeid(T)) == type_index_;\n\n }\n\n\n\n template <typename T>\n\n T const &As() const\n\n {\n\n if (std::type_index(typeid(T)) != type_index_)\n\n {\n\n auto t = std::type_index(typeid(T));\n\n throw std::runtime_error(\"Type mismatch in QueryVariant: stored \" +\n\n std::string(type_index_.name()) + \" vs. requested \" +\n\n std::string(t.name()));\n\n }\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/abstract_query_variant.hpp", "rank": 35, "score": 193425.14993921365 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"core/byte_array/byte_array.hpp\"\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/abstract_query_variant.hpp", "rank": 36, "score": 193414.5814790188 }, { "content": " return *reinterpret_cast<T const *>(data());\n\n }\n\n\n\n template <typename T>\n\n friend class SpecialisedQueryVariant;\n\n\n\nprivate:\n\n AbstractQueryVariant(int32_t type, Token token, std::type_index type_index)\n\n : type_{type}\n\n , token_{std::move(token)}\n\n , type_index_{type_index}\n\n {}\n\n\n\n int32_t type_;\n\n Token token_;\n\n std::type_index type_index_;\n\n};\n\n\n\ntemplate <typename T>\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/abstract_query_variant.hpp", "rank": 37, "score": 193414.58312639286 }, { "content": "struct hash<fetch::byte_array::ByteArray> : public hash<fetch::byte_array::ConstByteArray>\n\n{\n\n};\n\n\n\n} // namespace std\n", "file_path": "libs/core/include/core/byte_array/const_byte_array.hpp", "rank": 38, "score": 192430.03290344155 }, { "content": "struct MapSerializer<ml::model::Sequential<TensorType>, D>\n\n{\n\n using Type = ml::model::Sequential<TensorType>;\n\n using DriverType = D;\n\n static uint8_t const BASE_MODEL = 1;\n\n static uint8_t const LAYER_COUNT = 2;\n\n static uint8_t const PREV_LAYER_STR = 3;\n\n\n\n template <typename Constructor>\n\n static void Serialize(Constructor &map_constructor, Type const &sp)\n\n {\n\n auto map = map_constructor(3);\n\n\n\n // serialize the optimiser parent class\n\n auto base_pointer = static_cast<ml::model::Model<TensorType> const *>(&sp);\n\n map.Append(BASE_MODEL, *base_pointer);\n\n map.Append(LAYER_COUNT, sp.layer_count_);\n\n map.Append(PREV_LAYER_STR, sp.prev_layer_);\n\n }\n\n\n", "file_path": "libs/ml/include/ml/model/sequential.hpp", "rank": 39, "score": 191044.84589822163 }, { "content": "class AbstractQueryVariant\n\n{\n\npublic:\n\n using Token = fetch::byte_array::Token;\n\n\n\n virtual ~AbstractQueryVariant() = default;\n\n virtual void const *data() const = 0;\n\n\n\n void SetType(int type);\n\n int type() const;\n\n void SetToken(Token token);\n\n Token token() const;\n\n std::type_index type_index() const;\n\n\n\n template <typename T>\n\n explicit operator T() const\n\n {\n\n if (std::type_index(typeid(T)) != type_index_)\n\n {\n\n throw std::runtime_error(\"Type mismatch in QueryVariant.\");\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/abstract_query_variant.hpp", "rank": 40, "score": 190662.68495294751 }, { "content": "struct hash<fetch::byte_array::ConstByteArray>\n\n{\n\n std::size_t operator()(fetch::byte_array::ConstByteArray const &value) const noexcept\n\n {\n\n uint64_t h = 2166136261U;\n\n uint64_t i;\n\n\n\n for (i = 0; i < value.size(); ++i)\n\n {\n\n h = (h * 16777619) ^ value[i];\n\n }\n\n\n\n return h;\n\n }\n\n};\n\n\n\ntemplate <>\n", "file_path": "libs/core/include/core/byte_array/const_byte_array.hpp", "rank": 41, "score": 190184.78026413923 }, { "content": "class ModelRegister\n\n{\n\npublic:\n\n using VocabularySchema = std::shared_ptr<PropertiesToSubspace>;\n\n using SharedModelRegister = std::shared_ptr<ModelRegister>;\n\n\n\n ModelRegister() = default;\n\n virtual ~ModelRegister() = default;\n\n\n\n void AddModel(std::string const &name, VocabularySchema const &object);\n\n VocabularySchema GetModel(std::string const &name);\n\n bool HasModel(std::string const &name);\n\n\n\n virtual void OnAddModel(std::string const &name, VocabularySchema const &object) = 0;\n\n\n\nprivate:\n\n std::unordered_map<std::string, VocabularySchema> models_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/schema/model_register.hpp", "rank": 42, "score": 189768.15197451258 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/agent_profile.hpp\"\n\n#include \"semanticsearch/index/base_types.hpp\"\n\n\n\n#include <map>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/agent_directory.hpp", "rank": 43, "score": 186585.56477191346 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/index/base_types.hpp\"\n\n#include \"semanticsearch/location.hpp\"\n\n\n\n#include <crypto/identity.hpp>\n\n#include <memory>\n\n#include <string>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/agent_profile.hpp", "rank": 44, "score": 186581.22698532534 }, { "content": "\n\n Identity identity;\n\n AgentId id;\n\n std::set<VocabularyLocation> locations;\n\n\n\nprivate:\n\n explicit AgentProfile(AgentId i)\n\n : id(i)\n\n {}\n\n};\n\n\n\nusing Agent = AgentProfile::Agent;\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/agent_profile.hpp", "rank": 45, "score": 186580.03747222526 }, { "content": " }\n\n\n\n AgentIdSet FindAgents(SemanticPosition position, SemanticCoordinateType granularity)\n\n {\n\n return index_.Find(granularity, std::move(position));\n\n }\n\n\n\n VocabularySchema model() const\n\n {\n\n return object_model_;\n\n }\n\n\n\nprivate:\n\n VocabularySchema object_model_;\n\n InMemoryDBIndex index_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/model_advertisement.hpp", "rank": 46, "score": 186553.55047096146 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/index/in_memory_db_index.hpp\"\n\n#include \"semanticsearch/schema/properties_map.hpp\"\n\n#include \"semanticsearch/schema/vocabulary_instance.hpp\"\n\n\n\n#include <string>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/model_advertisement.hpp", "rank": 47, "score": 186542.7546661555 }, { "content": "struct UnrollPointers<0, ClassType, MemberFunctionPointer, ReturnType, UsedArgs...>\n\n{\n\n template <typename... remaining_args>\n\n struct LoopOver\n\n {\n\n static void Unroll(SerializerType &result, ClassType &cls, MemberFunctionPointer &m,\n\n CallableArgumentList const & /*additional_args*/, SerializerType &s,\n\n UsedArgs &... used)\n\n {\n\n UnrollArguments<ClassType, MemberFunctionPointer, ReturnType, UsedArgs...>::template LoopOver<\n\n CountArguments<remaining_args...>::value, remaining_args...>::Unroll(result, cls, m, s,\n\n used...);\n\n }\n\n };\n\n};\n\n} // namespace details\n\n\n\n/* A member function wrapper that takes a serialized input.\n\n * @C is the class type to which the member function belongs.\n\n * @F is the function signature.\n\n *\n\n * This module should be benchmarked against the more general class\n\n * <Function>. If there is no notable performance difference this\n\n * implementation should be dropped to keep the code base small and\n\n * simple.\n\n *\n\n * TODO(issue 23):\n\n */\n\ntemplate <typename C, typename F, std::size_t N = 0>\n", "file_path": "libs/network/include/network/service/callable_class_member.hpp", "rank": 48, "score": 186489.75173495465 }, { "content": "struct MapSerializer<ml::model::DNNClassifier<TensorType>, D>\n\n{\n\n using Type = ml::model::DNNClassifier<TensorType>;\n\n using DriverType = D;\n\n static uint8_t const BASE_MODEL = 1;\n\n\n\n template <typename Constructor>\n\n static void Serialize(Constructor &map_constructor, Type const &sp)\n\n {\n\n auto map = map_constructor(1);\n\n\n\n // serialize the optimiser parent class\n\n auto base_pointer = static_cast<ml::model::Model<TensorType> const *>(&sp);\n\n map.Append(BASE_MODEL, *base_pointer);\n\n }\n\n\n\n template <typename MapDeserializer>\n\n static void Deserialize(MapDeserializer &map, Type &sp)\n\n {\n\n auto base_pointer = static_cast<ml::model::Model<TensorType> *>(&sp);\n\n map.ExpectKeyGetValue(BASE_MODEL, *base_pointer);\n\n }\n\n};\n\n} // namespace serializers\n\n\n\n} // namespace fetch\n", "file_path": "libs/ml/include/ml/model/dnn_classifier.hpp", "rank": 49, "score": 185171.6367080124 }, { "content": "struct MapSerializer<ml::model::DNNRegressor<TensorType>, D>\n\n{\n\n using Type = ml::model::DNNRegressor<TensorType>;\n\n using DriverType = D;\n\n static uint8_t const BASE_MODEL = 1;\n\n\n\n template <typename Constructor>\n\n static void Serialize(Constructor &map_constructor, Type const &sp)\n\n {\n\n auto map = map_constructor(1);\n\n\n\n // serialize the optimiser parent class\n\n auto base_pointer = static_cast<ml::model::Model<TensorType> const *>(&sp);\n\n map.Append(BASE_MODEL, *base_pointer);\n\n }\n\n\n\n template <typename MapDeserializer>\n\n static void Deserialize(MapDeserializer &map, Type &sp)\n\n {\n\n auto base_pointer = static_cast<ml::model::Model<TensorType> *>(&sp);\n\n map.ExpectKeyGetValue(BASE_MODEL, *base_pointer);\n\n }\n\n};\n\n} // namespace serializers\n\n\n\n} // namespace fetch\n", "file_path": "libs/ml/include/ml/model/dnn_regressor.hpp", "rank": 50, "score": 185171.6367080124 }, { "content": "class BuiltinQueryFunction\n\n{\n\npublic:\n\n using CallerSignature = std::function<QueryVariant(std::vector<void const *> &)>;\n\n using Function = std::shared_ptr<BuiltinQueryFunction>;\n\n\n\n template <typename R, typename... Args>\n\n static Function New(std::function<R(Args...)> caller)\n\n {\n\n // Creating a shared builtin query function and\n\n // computes a list of type indices for the function arguments\n\n Function ret = Function(new BuiltinQueryFunction(std::type_index(typeid(R))));\n\n details::ArgumentsToTypeVector<R, Args...>::Apply(ret->arguments_);\n\n\n\n // Creating a type converter which converts type-erased void* arguments\n\n // into their original types\n\n ret->caller_ = [caller](std::vector<void const *> &args) -> QueryVariant {\n\n R return_value;\n\n\n\n // Calls the original caller function\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/builtin_query_function.hpp", "rank": 51, "score": 182957.0748567484 }, { "content": "class ModelInterfaceBuilder\n\n{\n\npublic:\n\n using ModelField = std::shared_ptr<VocabularyToSubspaceMapInterface>;\n\n using VocabularySchema = std::shared_ptr<PropertiesToSubspace>;\n\n\n\n explicit ModelInterfaceBuilder(VocabularySchema model = nullptr,\n\n SemanticSearchModule *factory = nullptr);\n\n\n\n explicit operator bool() const;\n\n ModelInterfaceBuilder &Field(std::string const &name, std::string const &type);\n\n ModelInterfaceBuilder &Field(std::string const &name, ModelInterfaceBuilder proxy);\n\n ModelInterfaceBuilder &Field(std::string const &name, ModelField const &model);\n\n\n\n ModelInterfaceBuilder Vocabulary(std::string const &name);\n\n\n\n VocabularySchema const &model() const\n\n {\n\n return model_;\n\n }\n\n\n\nprivate:\n\n VocabularySchema model_;\n\n SemanticSearchModule *factory_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/model_interface_builder.hpp", "rank": 52, "score": 182942.14231966884 }, { "content": "class Model\n\n{\n\npublic:\n\n using DataType = typename TensorType::Type;\n\n using SizeType = fetch::math::SizeType;\n\n using GraphType = Graph<TensorType>;\n\n using DataLoaderType = dataloaders::DataLoader<TensorType, TensorType>;\n\n using ModelOptimiserType = optimisers::Optimiser<TensorType>;\n\n using GraphPtrType = typename std::shared_ptr<GraphType>;\n\n using DataLoaderPtrType = typename std::shared_ptr<DataLoaderType>;\n\n using OptimiserPtrType = typename std::shared_ptr<ModelOptimiserType>;\n\n\n\n explicit Model(ModelConfig<DataType> model_config = ModelConfig<DataType>())\n\n : model_config_(std::move(model_config))\n\n {}\n\n Model(Model const &other)\n\n {\n\n graph_ptr_.reset(other.graph_ptr_.get());\n\n dataloader_ptr_.reset(other.dataloader_ptr_.get());\n\n optimiser_ptr_.reset(other.optimiser_ptr_.get());\n", "file_path": "libs/ml/include/ml/model/model.hpp", "rank": 53, "score": 182395.61360096958 }, { "content": " {\n\n return type_;\n\n }\n\n\n\n void Walk(std::function<void(std::string, Vocabulary)> const &callback,\n\n std::string const & name = \"\");\n\n Vocabulary &operator[](std::string const &name);\n\n void Insert(std::string const &name, Vocabulary const &value);\n\n\n\nprivate:\n\n VocabularyInstance(std::type_index type, void *data)\n\n : type_(type)\n\n , data_(data)\n\n {}\n\n\n\n std::type_index type_;\n\n void * data_{nullptr};\n\n\n\n template <typename T>\n\n friend class DataToSubspaceMap;\n\n friend class PropertiesToSubspace;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/schema/vocabulary_instance.hpp", "rank": 54, "score": 182340.81674328088 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include <functional>\n\n#include <map>\n\n#include <string>\n\n#include <type_traits>\n\n#include <typeindex>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/schema/vocabulary_instance.hpp", "rank": 55, "score": 182327.7758122146 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/query/query.hpp\"\n\n#include \"semanticsearch/schema/vocabulary_instance.hpp\"\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/execution_context.hpp", "rank": 56, "score": 182309.89438753968 }, { "content": " }\n\n\n\n std::string GetModelName(std::string const &name)\n\n {\n\n return models_[name];\n\n }\n\n\n\nprivate:\n\n std::map<std::string, Vocabulary> context_;\n\n std::map<std::string, std::string> models_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/execution_context.hpp", "rank": 57, "score": 182303.8621102495 }, { "content": " }\n\n Type type() const\n\n {\n\n return type_;\n\n }\n\n int line() const\n\n {\n\n return token_.line();\n\n }\n\n uint64_t character() const\n\n {\n\n return token_.character();\n\n }\n\n\n\nprivate:\n\n ConstByteArray filename_;\n\n ConstByteArray source_;\n\n ConstByteArray message_;\n\n Token token_;\n\n Type type_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_message.hpp", "rank": 58, "score": 182303.00211263497 }, { "content": " bool HasErrors() const;\n\n\n\nprivate:\n\n void PrintLine(int line, uint64_t character, uint64_t char_end = uint64_t(-1)) const;\n\n void PrintErrorMessage(ErrorMessage const &error);\n\n\n\n ConstByteArray source_;\n\n ConstByteArray filename_;\n\n std::vector<ErrorMessage> errors_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_tracker.hpp", "rank": 59, "score": 182301.043911967 }, { "content": "#include \"core/byte_array/const_byte_array.hpp\"\n\n#include \"core/byte_array/consumers.hpp\"\n\n#include \"core/byte_array/tokenizer/tokenizer.hpp\"\n\n#include \"core/commandline/vt100.hpp\"\n\n\n\n#include <vector>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_message.hpp", "rank": 60, "score": 182296.1056854471 }, { "content": "\n\n#include <core/byte_array/byte_array.hpp>\n\n#include <core/byte_array/const_byte_array.hpp>\n\n#include <core/byte_array/consumers.hpp>\n\n#include <core/byte_array/tokenizer/tokenizer.hpp>\n\n#include <vector>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_tracker.hpp", "rank": 61, "score": 182295.85806048443 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/query/error_message.hpp\"\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_tracker.hpp", "rank": 62, "score": 182293.32209769974 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/schema/properties_map.hpp\"\n\n\n\n#include <memory>\n\n#include <unordered_map>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/schema/model_register.hpp", "rank": 63, "score": 182286.4728693481 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"core/byte_array/byte_array.hpp\"\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_message.hpp", "rank": 64, "score": 182283.58175397458 }, { "content": " , message_(std::move(message))\n\n , token_(std::move(token))\n\n , type_(type)\n\n {}\n\n\n\n ConstByteArray filename() const\n\n {\n\n return filename_;\n\n }\n\n ConstByteArray source() const\n\n {\n\n return source_;\n\n }\n\n ConstByteArray message() const\n\n {\n\n return message_;\n\n }\n\n Token token() const\n\n {\n\n return token_;\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_message.hpp", "rank": 65, "score": 182277.6560652008 }, { "content": "#include <set>\n\n#include <vector>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n\nusing DBIndexType = uint64_t;\n\nusing SemanticCoordinateType = uint64_t; // Always internal 0 -> 1\n\nusing SemanticPosition = std::vector<SemanticCoordinateType>;\n\n\n\nusing DBIndexList = std::set<DBIndexType>;\n\nusing DBIndexListPtr = std::shared_ptr<DBIndexList>;\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/index/base_types.hpp", "rank": 66, "score": 182174.54775018923 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include <memory>\n", "file_path": "libs/semanticsearch/include/semanticsearch/index/base_types.hpp", "rank": 67, "score": 182146.79686800533 }, { "content": "struct std::hash<fetch::network::Uri> : private std::hash<fetch::byte_array::ConstByteArray>\n\n{\n\n std::size_t operator()(fetch::network::Uri const &x) const\n\n {\n\n return std::hash<fetch::byte_array::ConstByteArray>::operator()(x.uri());\n\n }\n\n};\n", "file_path": "libs/network/include/network/uri.hpp", "rank": 68, "score": 182051.81534822332 }, { "content": "class SpecialisedQueryVariant final : public AbstractQueryVariant\n\n{\n\npublic:\n\n using Token = fetch::byte_array::Token;\n\n using QueryVariant = std::shared_ptr<AbstractQueryVariant>;\n\n\n\n static QueryVariant New(T value, int32_t type = 0, Token token = static_cast<Token>(\"\"))\n\n {\n\n return QueryVariant(new SpecialisedQueryVariant<T>(std::move(value), type, std::move(token),\n\n std::type_index(typeid(T))));\n\n }\n\n\n\n void const *data() const override\n\n {\n\n return reinterpret_cast<void const *>(&value_);\n\n }\n\n\n\nprivate:\n\n SpecialisedQueryVariant(T value, int32_t type, Token token, std::type_index type_index)\n\n : AbstractQueryVariant(type, std::move(token), type_index)\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/abstract_query_variant.hpp", "rank": 69, "score": 181563.59564195637 }, { "content": "class VocabularyInstance : public std::enable_shared_from_this<VocabularyInstance>\n\n{\n\npublic:\n\n using Vocabulary = std::shared_ptr<VocabularyInstance>;\n\n using PropertyMap = std::map<std::string, std::shared_ptr<VocabularyInstance>>;\n\n\n\n template <typename T>\n\n static Vocabulary New(T data)\n\n {\n\n // TODO(private issue 143): add destructor\n\n Vocabulary ret;\n\n ret.reset(new VocabularyInstance(std::type_index(typeid(T)), new T(data)));\n\n\n\n return ret;\n\n }\n\n\n\n VocabularyInstance() = delete;\n\n VocabularyInstance(VocabularyInstance const &other) = delete;\n\n VocabularyInstance &operator=(VocabularyInstance const &other) = delete;\n\n std::type_index type() const\n", "file_path": "libs/semanticsearch/include/semanticsearch/schema/vocabulary_instance.hpp", "rank": 70, "score": 179104.08854688812 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/module/args_resolver.hpp\"\n\n#include \"semanticsearch/query/abstract_query_variant.hpp\"\n\n\n\n#include <functional>\n\n#include <memory>\n\n#include <vector>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/builtin_query_function.hpp", "rank": 71, "score": 178252.100887338 }, { "content": " details::VectorToArguments<sizeof...(Args)>::template Unroll<R, Args...>::Apply(\n\n 0, caller, return_value, args);\n\n\n\n // Creating a resulting variant for the return type.\n\n return NewQueryVariant(return_value);\n\n };\n\n\n\n return ret;\n\n }\n\n\n\n bool ValidateSignature(std::type_index const &ret, std::vector<std::type_index> const &args);\n\n QueryVariant operator()(std::vector<void const *> &args);\n\n std::type_index return_type() const;\n\n\n\nprivate:\n\n explicit BuiltinQueryFunction(std::type_index return_type)\n\n : return_type_(return_type)\n\n {}\n\n\n\n std::vector<std::type_index> arguments_;\n\n std::type_index return_type_;\n\n\n\n CallerSignature caller_;\n\n};\n\n\n\n} // namespace semanticsearch\n\n} // namespace fetch\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/builtin_query_function.hpp", "rank": 72, "score": 178249.8641776989 }, { "content": "#pragma once\n\n//------------------------------------------------------------------------------\n\n//\n\n// Copyright 2018-2019 Fetch.AI Limited\n\n//\n\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n\n// you may not use this file except in compliance with the License.\n\n// You may obtain a copy of the License at\n\n//\n\n// http://www.apache.org/licenses/LICENSE-2.0\n\n//\n\n// Unless required by applicable law or agreed to in writing, software\n\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\n// See the License for the specific language governing permissions and\n\n// limitations under the License.\n\n//\n\n//------------------------------------------------------------------------------\n\n\n\n#include \"semanticsearch/schema/properties_map.hpp\"\n\n#include \"semanticsearch/schema/subspace_map_interface.hpp\"\n\n\n\n#include <memory>\n\n\n\nnamespace fetch {\n\nnamespace semanticsearch {\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/model_interface_builder.hpp", "rank": 73, "score": 178233.24168027364 }, { "content": "class VocabularyAdvertisement\n\n{\n\npublic:\n\n using Vocabulary = std::shared_ptr<VocabularyInstance>;\n\n using Index = uint64_t;\n\n using VocabularySchema = std::shared_ptr<PropertiesToSubspace>;\n\n using AgentId = uint64_t;\n\n using AgentIdSet = std::shared_ptr<std::set<AgentId>>;\n\n\n\n explicit VocabularyAdvertisement(VocabularySchema object_model)\n\n : object_model_(std::move(object_model))\n\n {}\n\n\n\n void SubscribeAgent(AgentId aid, SemanticPosition position)\n\n {\n\n SemanticSubscription rel;\n\n rel.position = std::move(position);\n\n rel.index = aid; // TODO(private issue AEA-129): Change to agent id\n\n\n\n index_.AddRelation(rel);\n", "file_path": "libs/semanticsearch/include/semanticsearch/model_advertisement.hpp", "rank": 74, "score": 178203.49976042839 }, { "content": "class Agent;\n", "file_path": "libs/oef-core/include/oef-core/agents/Agents.hpp", "rank": 75, "score": 177864.4518536752 }, { "content": "class Agent\n\n{\n\npublic:\n\n Agent(std::string key, std::shared_ptr<OefAgentEndpoint> endpoint)\n\n {\n\n this->key = std::move(key);\n\n this->endpoint = std::move(endpoint);\n\n }\n\n\n\n ~Agent() = default;\n\n\n\n Notification::NotificationBuilder send(std::shared_ptr<google::protobuf::Message> s);\n\n\n\n void run_sending();\n\n\n\n std::string getPublicKey()\n\n {\n\n return key;\n\n }\n\n\n", "file_path": "libs/oef-core/include/oef-core/agents/Agent.hpp", "rank": 76, "score": 177864.4518536752 }, { "content": "class Weights : public fetch::ml::ops::Variable<T>\n\n{\n\npublic:\n\n using TensorType = T;\n\n using SizeType = fetch::math::SizeType;\n\n using DataType = typename TensorType::Type;\n\n using ArrayPtrType = std::shared_ptr<TensorType>;\n\n using VecTensorType = typename Variable<T>::VecTensorType;\n\n using SPType = OpWeightsSaveableParams<TensorType>;\n\n using WeightsPtrType = typename std::shared_ptr<Weights<TensorType>>;\n\n\n\npublic:\n\n Weights() = default;\n\n\n\n explicit Weights(SPType const &sp)\n\n : Variable<T>(sp)\n\n {}\n\n\n\n ~Weights() override = default;\n\n\n", "file_path": "libs/ml/include/ml/ops/weights.hpp", "rank": 77, "score": 175943.044694561 }, { "content": "struct MapSerializer<fetch::ml::dataloaders::DataLoader<LabelType, InputType>, D>\n\n{\n\n using Type = fetch::ml::dataloaders::DataLoader<LabelType, InputType>;\n\n using DriverType = D;\n\n\n\n static uint8_t const RANDOM_MODE = 1;\n\n static uint8_t const SIZE_NOT_SET = 2;\n\n static uint8_t const CUR_TRAINING_PAIR_FIRST = 3;\n\n static uint8_t const CUR_TRAINING_PAIR_SECOND = 4;\n\n static uint8_t const RET_PAIR_FIRST = 5;\n\n static uint8_t const RET_PAIR_SECOND = 6;\n\n\n\n template <typename Constructor>\n\n static void Serialize(Constructor &map_constructor, Type const &sp)\n\n {\n\n auto map = map_constructor(6);\n\n\n\n map.Append(RANDOM_MODE, sp.random_mode_);\n\n map.Append(SIZE_NOT_SET, sp.size_not_set_);\n\n map.Append(CUR_TRAINING_PAIR_FIRST, sp.cur_training_pair_.first);\n", "file_path": "libs/ml/include/ml/dataloaders/dataloader.hpp", "rank": 78, "score": 175660.80987024822 }, { "content": "class ErrorTracker\n\n{\n\npublic:\n\n using ConstByteArray = fetch::byte_array::ConstByteArray;\n\n using Token = fetch::byte_array::Token;\n\n using SharedErrorTracker = std::shared_ptr<ErrorTracker>;\n\n\n\n ErrorTracker() = default;\n\n\n\n explicit operator bool()\n\n {\n\n return !errors_.empty();\n\n }\n\n\n\n void Print();\n\n void RaiseSyntaxError(ConstByteArray message, Token token);\n\n void RaiseRuntimeError(ConstByteArray message, Token token);\n\n void RaiseInternalError(ConstByteArray message, Token token);\n\n void SetSource(ConstByteArray source, ConstByteArray filename);\n\n void ClearErrors();\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_tracker.hpp", "rank": 79, "score": 174345.4958219476 }, { "content": "class ExecutionContext\n\n{\n\npublic:\n\n using ConstByteArray = fetch::byte_array::ConstByteArray;\n\n using Vocabulary = std::shared_ptr<VocabularyInstance>;\n\n\n\n Vocabulary Get(std::string const &name)\n\n {\n\n return context_[name];\n\n }\n\n\n\n void Set(std::string const &name, Vocabulary object, std::string type)\n\n {\n\n models_[name] = std::move(type);\n\n context_[name] = std::move(object);\n\n }\n\n\n\n bool Has(std::string const &name)\n\n {\n\n return context_.find(name) != context_.end();\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/execution_context.hpp", "rank": 80, "score": 174345.4958219476 }, { "content": "class ErrorMessage\n\n{\n\npublic:\n\n using ConstByteArray = fetch::byte_array::ConstByteArray;\n\n using Token = fetch::byte_array::Token;\n\n\n\n enum Type\n\n {\n\n WARNING,\n\n SYNTAX_ERROR,\n\n RUNTIME_ERROR,\n\n INTERNAL_ERROR,\n\n INFO,\n\n APPEND\n\n };\n\n\n\n ErrorMessage(ConstByteArray filename, ConstByteArray source, ConstByteArray message, Token token,\n\n Type type = SYNTAX_ERROR)\n\n : filename_(std::move(filename))\n\n , source_(std::move(source))\n", "file_path": "libs/semanticsearch/include/semanticsearch/query/error_message.hpp", "rank": 81, "score": 174345.4958219476 }, { "content": "enum class MetricType\n\n{\n\n LOSS,\n\n ACCURACY\n\n};\n\n\n\ntemplate <typename TensorType>\n", "file_path": "libs/ml/include/ml/model/model.hpp", "rank": 82, "score": 174230.25573304683 }, { "content": "struct MapSerializer<fetch::ml::dataloaders::TensorDataLoader<LabelType, InputType>, D>\n\n{\n\n using Type = fetch::ml::dataloaders::TensorDataLoader<LabelType, InputType>;\n\n using DriverType = D;\n\n\n\n static uint8_t const BASE_DATA_LOADER = 1;\n\n static uint8_t const TRAIN_CURSOR = 2;\n\n static uint8_t const TEST_CURSOR = 3;\n\n static uint8_t const VALIDATION_CURSOR = 4;\n\n static uint8_t const TEST_OFFSET = 5;\n\n static uint8_t const VALIDATION_OFFSET = 6;\n\n static uint8_t const TEST_TO_TRAIN_RATIO = 7;\n\n static uint8_t const VALIDATION_TO_TRAIN_RATIO = 8;\n\n static uint8_t const N_SAMPLES = 9;\n\n static uint8_t const N_TRAIN_SAMPLES = 10;\n\n static uint8_t const N_TEST_SAMPLES = 11;\n\n static uint8_t const N_VALIDATION_SAMPLES = 12;\n\n static uint8_t const DATA = 13;\n\n static uint8_t const LABELS = 14;\n\n\n", "file_path": "libs/ml/include/ml/dataloaders/tensor_dataloader.hpp", "rank": 83, "score": 170612.25695277023 }, { "content": "struct ArgumentsToTypeVector\n\n{\n\n static void Apply(std::vector<std::type_index> &args)\n\n {\n\n args.push_back(std::type_index(typeid(A)));\n\n ArgumentsToTypeVector<R, Args...>::Apply(args);\n\n }\n\n};\n\n\n\ntemplate <typename R, typename A>\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/args_resolver.hpp", "rank": 84, "score": 170519.19920289444 }, { "content": "class SemanticSearchModule;\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/model_interface_builder.hpp", "rank": 85, "score": 167095.2075889893 }, { "content": "class AdvertisementRegister : public ModelRegister\n\n{\n\npublic:\n\n using Vocabulary = std::shared_ptr<VocabularyInstance>;\n\n using SharedModel = std::shared_ptr<VocabularyAdvertisement>;\n\n using SharedModelRegister = ModelRegister::SharedModelRegister;\n\n using Index = VocabularyAdvertisement::Index;\n\n using AgentId = VocabularyAdvertisement::AgentId;\n\n using AgentIdSet = VocabularyAdvertisement::AgentIdSet;\n\n\n\n AdvertisementRegister() = default;\n\n\n\n bool CreateModel(std::string const &name, VocabularySchema const &object);\n\n SharedModel GetAdvertisementModel(std::string const &name);\n\n void AdvertiseAgent(AgentId aid, std::string const &name, SemanticPosition const &position);\n\n AgentIdSet FindAgents(std::string const &name, SemanticPosition const &position,\n\n SemanticCoordinateType granularity);\n\n AgentIdSet FindAgents(std::string const &name, Vocabulary const &object,\n\n SemanticCoordinateType granularity);\n\n\n", "file_path": "libs/semanticsearch/include/semanticsearch/advertisement_register.hpp", "rank": 86, "score": 167095.2075889893 }, { "content": "struct ArgumentsToTypeVector<R, A>\n\n{\n\n static void Apply(std::vector<std::type_index> &args)\n\n {\n\n args.push_back(std::type_index(typeid(A)));\n\n }\n\n};\n\n\n\ntemplate <typename R>\n", "file_path": "libs/semanticsearch/include/semanticsearch/module/args_resolver.hpp", "rank": 87, "score": 166982.6294867155 }, { "content": "struct Type;\n\nusing TypePtr = std::shared_ptr<Type>;\n\nusing TypePtrArray = std::vector<TypePtr>;\n\nusing Operators = std::unordered_set<Operator>;\n\n\n", "file_path": "libs/vm/include/vm/node.hpp", "rank": 88, "score": 163534.13204099747 }, { "content": "struct IsMathImpl<float, ReturnType>\n\n{\n\n using Type = ReturnType;\n\n};\n\ntemplate <typename ReturnType>\n", "file_path": "libs/vectorise/include/vectorise/meta/math_type_traits.hpp", "rank": 89, "score": 160372.88851432505 }, { "content": "struct IsMathImpl<double, ReturnType>\n\n{\n\n using Type = ReturnType;\n\n};\n\ntemplate <typename ReturnType>\n", "file_path": "libs/vectorise/include/vectorise/meta/math_type_traits.hpp", "rank": 90, "score": 160372.88851432505 }, { "content": "struct IsMathImpl<int, ReturnType>\n\n{\n\n using Type = ReturnType;\n\n};\n\ntemplate <typename ReturnType>\n", "file_path": "libs/vectorise/include/vectorise/meta/math_type_traits.hpp", "rank": 91, "score": 160372.88851432505 }, { "content": "struct MakeParameterType<T, std::enable_if_t<fetch::vm::IsPtr<T>::value>>\n\n{\n\n using type = T const &;\n\n};\n\n\n\n} // namespace vm\n\n} // namespace fetch\n", "file_path": "libs/vm/include/vm/module/base.hpp", "rank": 92, "score": 160215.04038607207 }, { "content": "struct MakeParameterType<T, std::enable_if_t<fetch::vm::IsVariant<T>::value>>\n\n{\n\n using type = T const &;\n\n};\n\ntemplate <typename T>\n", "file_path": "libs/vm/include/vm/module/base.hpp", "rank": 93, "score": 160215.04038607207 }, { "content": "struct MakeParameterType<T, std::enable_if_t<fetch::vm::IsPrimitive<T>::value>>\n\n{\n\n using type = T;\n\n};\n\ntemplate <typename T>\n", "file_path": "libs/vm/include/vm/module/base.hpp", "rank": 94, "score": 160215.04038607207 }, { "content": "struct IsMathArrayImpl<Tensor<DataType, ContainerType>, ReturnType>\n\n{\n\n using Type = ReturnType;\n\n};\n\ntemplate <typename DataType, typename ReturnType>\n\nusing IfIsMathArray = typename IsMathArrayImpl<DataType, ReturnType>::Type;\n\n\n\ntemplate <typename DataType, typename ReturnType>\n\nusing IfIsMathFixedPointArray =\n\n IfIsFixedPoint<typename DataType::Type, IfIsMathArray<DataType, ReturnType>>;\n\n\n\ntemplate <typename DataType, typename ReturnType>\n\nusing IfIsMathNonFixedPointArray =\n\n IfIsNotFixedPoint<typename DataType::Type, IfIsMathArray<DataType, ReturnType>>;\n\n\n\n} // namespace meta\n\n} // namespace math\n\n} // namespace fetch\n", "file_path": "libs/math/include/math/meta/math_type_traits.hpp", "rank": 95, "score": 159978.50571165458 }, { "content": "class ConstByteArray;\n\n}\n\n\n\nnamespace crypto {\n\n\n\nbool IsFetchIdentity(byte_array::ConstByteArray const &identity);\n\n\n\n} // namespace crypto\n\n} // namespace fetch\n", "file_path": "libs/crypto/include/crypto/fetch_identity.hpp", "rank": 96, "score": 158915.38260329622 }, { "content": "class ConstByteArray;\n\n} // namespace byte_array\n\n\n\nnamespace meta {\n\n\n\ntemplate <typename... T>\n", "file_path": "libs/meta/include/meta/type_traits.hpp", "rank": 97, "score": 158826.862043779 }, { "content": " enum class Type\n\n {\n\n INVALID,\n\n NORMAL,\n\n SMART_OR_SYNERGETIC_CONTRACT\n\n };\n\n\n\n using ConstByteArray = byte_array::ConstByteArray;\n\n using Tokens = std::vector<ConstByteArray>;\n\n\n\n // Construction / Destruction\n\n Identifier() = default;\n\n explicit Identifier(ConstByteArray identifier);\n\n Identifier(Identifier const &) = default;\n\n Identifier(Identifier &&) = default;\n\n ~Identifier() = default;\n\n\n\n // Accessors\n\n Type type() const;\n\n ConstByteArray name() const;\n", "file_path": "libs/ledger/include/ledger/identifier.hpp", "rank": 98, "score": 156104.24774416786 }, { "content": " enum class Type\n\n {\n\n UNDEFINED,\n\n INTEGER,\n\n FLOATING_POINT,\n\n FIXED_POINT,\n\n BOOLEAN,\n\n STRING,\n\n NULL_VALUE,\n\n ARRAY,\n\n OBJECT,\n\n };\n\n\n\n constexpr Type type() const\n\n {\n\n return type_;\n\n }\n\n\n\nprivate:\n\n using VariantList = std::vector<Variant>;\n", "file_path": "libs/variant/include/variant/variant.hpp", "rank": 99, "score": 156104.24774416786 } ]
C++
ipc/src/client_endpoint_com.cpp
tyoma/micro-profiler
32f6981c643b93997752d414f631fd6684772b28
#include <ipc/endpoint.h> #include <atlbase.h> #include <common/module.h> #include <common/string.h> #include <ipc/com/init.h> #include <functional> using namespace std; namespace micro_profiler { namespace ipc { namespace com { class inbound_stream : public ISequentialStream { public: inbound_stream(channel &underlying); ~inbound_stream(); STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject); STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release(); STDMETHODIMP Read(void *, ULONG, ULONG *); STDMETHODIMP Write(const void *message, ULONG size, ULONG *written); private: unsigned _references; channel &_underlying; }; class client_session : public channel { public: client_session(const char *destination_endpoint_id, channel &inbound); virtual void disconnect() throw(); virtual void message(const_byte_range payload); private: static shared_ptr<void> create_activation_context(); static shared_ptr<void> lock_activation_context(const shared_ptr<void> &ctx); private: channel &_inbound; com_initialize _com_initialize; CComPtr<ISequentialStream> _stream; DWORD _sink_cookie; }; inbound_stream::inbound_stream(channel &underlying) : _references(0), _underlying(underlying) { } inbound_stream::~inbound_stream() { _underlying.disconnect(); } STDMETHODIMP inbound_stream::QueryInterface(REFIID riid, void **object) { if (IID_IUnknown != riid && IID_ISequentialStream != riid) return E_NOINTERFACE; *object = (ISequentialStream *)this; AddRef(); return S_OK; } STDMETHODIMP_(ULONG) inbound_stream::AddRef() { return ++_references; } STDMETHODIMP_(ULONG) inbound_stream::Release() { unsigned int r = --_references; if (!r) delete this; return r; } STDMETHODIMP inbound_stream::Read(void *, ULONG, ULONG *) { return E_NOTIMPL; } STDMETHODIMP inbound_stream::Write(const void *buffer, ULONG size, ULONG * ) { return _underlying.message(const_byte_range(static_cast<const byte *>(buffer), size)), S_OK; } client_session::client_session(const char *destination_endpoint_id, channel &inbound) : _inbound(inbound) { shared_ptr<void> ctx = create_activation_context(); shared_ptr<void> ctx_lock = lock_activation_context(ctx); const guid_t id = from_string(destination_endpoint_id); CComPtr<inbound_stream> sink(new inbound_stream(inbound)); if (S_OK != _stream.CoCreateInstance(id, NULL, CLSCTX_LOCAL_SERVER)) throw connection_refused(destination_endpoint_id); CComQIPtr<IConnectionPoint>(_stream)->Advise(sink, &_sink_cookie); } void client_session::disconnect() throw() { } void client_session::message(const_byte_range payload) { ULONG written; _stream->Write(payload.begin(), static_cast<ULONG>(payload.length()), &written); } shared_ptr<void> client_session::create_activation_context() { ACTCTX ctx = { sizeof(ACTCTX), }; HMODULE hmodule = (HMODULE)get_module_info((void *)&create_activation_context).base; ctx.hModule = hmodule; ctx.lpResourceName = ISOLATIONAWARE_MANIFEST_RESOURCE_ID; ctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID; HANDLE hcontext = ::CreateActCtx(&ctx); return INVALID_HANDLE_VALUE == hcontext ? shared_ptr<void>() : shared_ptr<void>(hcontext, &::ReleaseActCtx); } shared_ptr<void> client_session::lock_activation_context(const shared_ptr<void> &ctx) { ULONG_PTR cookie; return ctx && ::ActivateActCtx(ctx.get(), &cookie) ? shared_ptr<void>(reinterpret_cast<void*>(cookie), bind(&::DeactivateActCtx, 0, cookie)) : shared_ptr<void>(); } channel_ptr_t connect_client(const char *destination_endpoint_id, channel &inbound) { return channel_ptr_t(new client_session(destination_endpoint_id, inbound)); } } } }
#include <ipc/endpoint.h> #include <atlbase.h> #include <common/module.h> #include <common/string.h> #include <ipc/com/init.h> #include <functional> using namespace std; namespace micro_profiler { namespace ipc { namespace com { class inbound_stream : public ISequentialStream { public: inbound_stream(channel &underlying); ~inbound_stream(); STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject); STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release(); STDMETHODIMP Read(void *, ULONG, ULONG *); STDMETHODIMP Write(const void *message, ULONG size, ULONG *written); private: unsigned _references; channel &_underlying; }; class client_session : public channel { public: client_session(const char *destination_endpoint_id, channel &inbound); virtual void disconnect() throw(); virtual void message(const_byte_range payload); private: static shared_ptr<void> create_activation_context(); static shared_ptr<void> lock_activation_context(const shared_ptr<void> &ctx); private: channel &_inbound; com_initialize _com_initialize; CComPtr<ISequentialStream> _stream; DWORD _sink_cookie; }; inbound_stream::inbound_stream(channel &underlying) : _references(0), _underlying(underlying) { } inbound_stream::~inbound_stream() { _underlying.disconnect(); } STDMETHODIMP inbound_stream::QueryInterface(REFIID riid, void **object) { if (IID_IUnknown != riid && IID_ISequentialStream != riid) return E_NOINTERFACE; *object = (ISequentialStream *)this; AddRef(); return S_OK; } STDMETHODIMP_(ULONG) inbound_stream::AddRef() { return ++_references; } STDMETHODIMP_(ULONG) inbound_stream::Release() { unsigned int r = --_references; if (!r) delete this; return r; } STDMETHODIMP inbound_stream::Read(void *, ULONG, ULONG *) { return E_NOTIMPL; } STDMETHODIMP inbound_stream::Write(const void *buffer, ULONG size, ULONG * ) { return _underlying.message(const_byte_range(static_cast<const byte *>(buffer), size)), S_OK; } client_session::client_session(const char *destination_endpoint_id, channel &inbound) : _inbound(inbound) { shared_ptr<void> ctx = create_activation_context(); shared_ptr<void> ctx_lock = lock_activation_context(ctx); const guid_t id = from_string(destination_endpoint_id); CComPtr<inbound_stream> sink(new inbound_stream(inbound)); if (S_OK != _stream.CoCreateInstance(id, NULL, CLSCTX_LOCAL_SERVER)) throw connection_refused(destination_endpoint_id); CComQIPtr<IConnectionPoint>(_stream)->Advise(sink, &_sink_cookie); } void client_session::disconnect() throw() { } void client_session::message(const_byte_range payload) { ULONG written; _stream->Write(payload.begin(), static_cast<ULONG>(payload.length()), &written); } shared_ptr<void> client_session::create_activation_context() { ACTCTX ctx = { sizeof(ACTCTX), }; HMODULE hmodule = (HMODULE)get_module_info((void *)&create_activation_context).base; ctx.hModule = hmodule; ctx.lpResourceName = ISOLATIONAWARE_MANIFEST_RESOURCE_ID; ctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID; HANDLE hcontext = ::CreateActCtx(&ctx); return INVALID_HANDLE_VALUE == hcontext ? shared_ptr<void>() : shared_ptr<void>(hcontext, &::ReleaseActCtx); }
channel_ptr_t connect_client(const char *destination_endpoint_id, channel &inbound) { return channel_ptr_t(new client_session(destination_endpoint_id, inbound)); } } } }
shared_ptr<void> client_session::lock_activation_context(const shared_ptr<void> &ctx) { ULONG_PTR cookie; return ctx && ::ActivateActCtx(ctx.get(), &cookie) ? shared_ptr<void>(reinterpret_cast<void*>(cookie), bind(&::DeactivateActCtx, 0, cookie)) : shared_ptr<void>(); }
function_block-full_function
[ { "content": "\t\t\tclass session : public ISequentialStream, public IConnectionPoint, public /*outbound*/ ipc::channel,\n\n\t\t\t\tpublic CComObjectRoot\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tBEGIN_COM_MAP(session)\n\n\t\t\t\t\tCOM_INTERFACE_ENTRY(ISequentialStream)\n\n\t\t\t\t\tCOM_INTERFACE_ENTRY(IConnectionPoint)\n\n\t\t\t\tEND_COM_MAP()\n\n\n\n\t\t\t\tvoid FinalRelease();\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tchannel_ptr_t inbound;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\t// ISequentialStream methods\n\n\t\t\t\tSTDMETHODIMP Read(void *, ULONG, ULONG *);\n\n\t\t\t\tSTDMETHODIMP Write(const void *message, ULONG size, ULONG *written);\n\n\n\n\t\t\t\t// IConnectionPoint methods\n", "file_path": "ipc/com/endpoint.h", "rank": 0, "score": 326805.7874631604 }, { "content": "\t\t\t\tclass channel : public ipc::channel\n\n\t\t\t\t{\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tstd::function<void (const_byte_range payload)> on_message;\n\n\t\t\t\t\tstd::function<void ()> on_disconnect;\n\n\n\n\t\t\t\tprivate:\n\n\t\t\t\t\tvirtual void disconnect() throw();\n\n\t\t\t\t\tvirtual void message(const_byte_range payload);\n\n\t\t\t\t};\n\n\n", "file_path": "ipc/tests/mocks.h", "rank": 1, "score": 321074.07106002304 }, { "content": "\t\t\t\tclass session : public ipc::channel\n\n\t\t\t\t{\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tsession();\n\n\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tipc::channel *outbound;\n\n\t\t\t\t\tstd::vector< std::vector<byte> > payloads_log;\n\n\t\t\t\t\tunsigned disconnections;\n\n\t\t\t\t\tstd::function<void()> received_message;\n\n\t\t\t\t\tstd::function<void()> disconnected;\n\n\n\n\t\t\t\tprivate:\n\n\t\t\t\t\tvirtual void disconnect() throw();\n\n\t\t\t\t\tvirtual void message(const_byte_range payload);\n\n\t\t\t\t};\n\n\n", "file_path": "ipc/tests/mocks.h", "rank": 3, "score": 298075.79394406226 }, { "content": "\t\t\tclass outbound_channel : public ipc::channel\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\toutbound_channel();\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tbool disconnected;\n\n\t\t\t\tstd::vector<unsigned int /*persistent_id*/> requested_metadata;\n\n\t\t\t\tstd::vector< std::vector<unsigned int /*thread_id*/> > requested_threads;\n\n\t\t\t\tunsigned requested_upadtes;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tvirtual void disconnect() throw();\n\n\t\t\t\tvirtual void message(const_byte_range payload);\n\n\t\t\t};\n\n\t\t}\n\n\t}\n\n}\n", "file_path": "frontend/tests/mock_channel.h", "rank": 4, "score": 294214.12043725804 }, { "content": "\t\tclass controllee_session : public ipc::channel\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tcontrollee_session(ipc::channel &outbound);\n\n\n\n\t\t\tvoid disconnect_client();\n\n\t\t\tvoid send(const_byte_range payload);\n\n\n\n\t\t\tvirtual void disconnect() throw();\n\n\t\t\tvirtual void message(const_byte_range payload);\n\n\n\n\t\tpublic:\n\n\t\t\tstd::vector< std::vector<byte> > messages;\n\n\n\n\t\tprivate:\n\n\t\t\tipc::channel *_outbound;\n\n\t\t\tmt::event _ready;\n\n\t\t};\n\n\n\n\t\ttemplate <typename SessionT = controllee_session>\n", "file_path": "test-helpers/process.h", "rank": 6, "score": 280470.0181342943 }, { "content": "\t\t\t\tclass valid_sink : public CComObjectRoot, public ISequentialStream\n\n\t\t\t\t{\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tBEGIN_COM_MAP(valid_sink)\n\n\t\t\t\t\t\tCOM_INTERFACE_ENTRY(ISequentialStream)\n\n\t\t\t\t\tEND_COM_MAP()\n\n\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tvalid_sink()\n\n\t\t\t\t\t\t: _destroyed(0)\n\n\t\t\t\t\t{\t}\n\n\n\n\t\t\t\t\tvoid set_destroyed(bool &destroyed)\n\n\t\t\t\t\t{\t_destroyed = &destroyed;\t}\n\n\n\n\t\t\t\t\tvoid FinalRelease()\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tif (_destroyed)\n\n\t\t\t\t\t\t\t*_destroyed = true;\n\n\t\t\t\t\t}\n", "file_path": "ipc/tests/COMEndpointServerDuplexTests.cpp", "rank": 7, "score": 279231.6162602297 }, { "content": "\tclass file_id : std::pair<unsigned long long, unsigned long long>, std::shared_ptr<void>\n\n\t{\n\n\tpublic:\n\n\t\tfile_id(const std::string &path);\n\n\n\n\t\tbool operator ==(const file_id &rhs) const;\n\n\n\n\tprivate:\n\n\t\ttemplate <typename T>\n\n\t\tfriend struct std::hash;\n\n\t};\n\n\n\n\n\n\n\n\tinline bool file_id::operator ==(const file_id &rhs) const\n\n\t{\treturn *this == static_cast<const std::pair<unsigned long long, unsigned long long> &>(rhs);\t}\n\n}\n\n\n\nnamespace std\n\n{\n", "file_path": "common/file_id.h", "rank": 8, "score": 271899.495257596 }, { "content": "\t\t\tclass frontend : public ipc::channel\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\texplicit frontend(shared_ptr<frontend_state> state);\n\n\t\t\t\tfrontend(const frontend &other);\n\n\t\t\t\t~frontend();\n\n\n\n\t\t\t\tvirtual void disconnect() throw();\n\n\t\t\t\tvirtual void message(const_byte_range payload);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tconst frontend &operator =(const frontend &rhs);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tmutable shared_ptr<frontend_state> _state;\n\n\t\t\t};\n\n\n\n\n\n\t\t\tipc::channel_ptr_t frontend_state::create()\n\n\t\t\t{\treturn ipc::channel_ptr_t(new frontend(shared_from_this()));\t}\n", "file_path": "micro-profiler.tests/mock_frontend.cpp", "rank": 9, "score": 270450.1125408769 }, { "content": "\t\tclass client_session : public channel\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\ttypedef std::function<void (deserializer &payload_deserializer)> callback_t;\n\n\n\n\t\tpublic:\n\n\t\t\t// User establishes and controls the connection.\n\n\t\t\ttemplate <typename ChannelFactoryT>\n\n\t\t\tclient_session(const ChannelFactoryT &connection_factory);\n\n\n\n\t\t\t// Connection is established and controlled by an outside entity.\n\n\t\t\tclient_session(channel &outbound);\n\n\n\n\t\t\tvirtual ~client_session();\n\n\n\n\t\t\tvoid disconnect_session() throw();\n\n\n\n\t\t\ttemplate <typename MessageCallbackT>\n\n\t\t\tvoid subscribe(std::shared_ptr<void> &handle, int message_id, const MessageCallbackT &callback);\n\n\n", "file_path": "ipc/client_session.h", "rank": 10, "score": 267506.9295124965 }, { "content": "\t\t\t\tclass wrong_sink : public CComObjectRoot, public IUnknown\n\n\t\t\t\t{\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tBEGIN_COM_MAP(wrong_sink)\n\n\t\t\t\t\t\tCOM_INTERFACE_ENTRY(IUnknown)\n\n\t\t\t\t\tEND_COM_MAP()\n\n\t\t\t\t};\n\n\n", "file_path": "ipc/tests/COMEndpointServerDuplexTests.cpp", "rank": 11, "score": 259329.38736569963 }, { "content": "\t\tclass server_session : public channel, noncopyable\n\n\t\t{\n\n\t\tpublic:\n", "file_path": "ipc/server_session.h", "rank": 12, "score": 254474.14260405552 }, { "content": "\t\t\tclass server : public CComClassFactory\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tvoid set_server(const std::shared_ptr<ipc::server> &factory);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tSTDMETHODIMP CreateInstance(IUnknown *outer, REFIID riid, void **object);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tstd::shared_ptr<ipc::server> _session_factory;\n\n\t\t\t};\n\n\t\t}\n\n\t}\n\n}\n", "file_path": "ipc/com/endpoint.h", "rank": 13, "score": 252929.4295037996 }, { "content": "\t\t\tclass client_session : public channel\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tclient_session(const host_port &hp, channel &inbound);\n\n\t\t\t\t~client_session();\n\n\n\n\t\t\t\tvirtual void disconnect() throw();\n\n\t\t\t\tvirtual void message(const_byte_range payload);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tvoid worker(channel *inbound);\n\n\t\t\t\tstatic int open(const host_port &hp);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tsockets_initializer _initializer;\n\n\t\t\t\tsocket_handle _socket;\n\n\t\t\t\tunique_ptr<mt::thread> _thread;\n\n\t\t\t};\n\n\n\n\n", "file_path": "ipc/src/client_endpoint_sockets.cpp", "rank": 14, "score": 252019.25030282928 }, { "content": "\t\tclass marshalled_passive_session : public channel, noncopyable\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tmarshalled_passive_session(std::shared_ptr<scheduler::queue> queue, channel &outbound);\n\n\t\t\t~marshalled_passive_session();\n\n\n\n\t\t\tvoid create_underlying(std::shared_ptr<server> underlying_server);\n\n\n\n\t\tprivate:\n", "file_path": "ipc/marshalled_session.h", "rank": 15, "score": 249320.34604634534 }, { "content": "\t\tclass command_handler : public ipc::channel, noncopyable\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tcommand_handler(mt::event &exit, const char *destination_endpoint)\n\n\t\t\t\t: _exit(exit)\n\n\t\t\t{\t_commander_channel = ipc::connect_client(destination_endpoint, *this);\t}\n\n\n\n\t\tprivate:\n\n\t\t\tvirtual void disconnect() throw()\n\n\t\t\t{\t_exit.set();\t}\n\n\n\n\t\t\tvirtual void message(const_byte_range payload)\n\n\t\t\t{\n\n\t\t\t\tvector_adapter reader(payload);\n\n\t\t\t\tstrmd::deserializer<vector_adapter> archive(reader);\n\n\t\t\t\trunner_commands c;\n\n\t\t\t\tstring data1, data2;\n\n\n\n\t\t\t\tswitch (archive(c), c)\n\n\t\t\t\t{\n", "file_path": "micro-profiler.tests/guineapigs/guinea_runner.cpp", "rank": 16, "score": 248878.3219732191 }, { "content": "\t\tclass image : private std::shared_ptr<void>\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\texplicit image(std::string path);\n\n\n\n\t\t\tbyte *base_ptr() const;\n\n\t\t\tlong_address_t base() const;\n\n\t\t\tconst char *absolute_path() const;\n\n\t\t\tvoid *get_symbol_address(const char *name) const;\n\n\t\t\tunsigned get_symbol_rva(const char *name) const;\n\n\t\t\ttemplate <typename T>\n\n\t\t\tT *get_symbol(const char *name) const;\n\n\n\n\t\tprivate:\n\n\t\t\tbyte *_base;\n\n\t\t\tstd::string _fullpath;\n\n\t\t};\n\n\n", "file_path": "test-helpers/helpers.h", "rank": 17, "score": 244397.4383936341 }, { "content": "\t\tclass marshalled_passive_session::outbound_wrapper : public channel, noncopyable\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\toutbound_wrapper(channel &underlying);\n\n\n\n\t\t\tvoid stop();\n\n\n\n\t\tprivate:\n\n\t\t\tvirtual void disconnect() throw() override;\n\n\t\t\tvirtual void message(const_byte_range payload) override;\n\n\n\n\t\tprivate:\n\n\t\t\tconst std::shared_ptr<lifetime> _lifetime;\n\n\t\t\tchannel &_underlying;\n\n\t\t};\n\n\n\n\n\n\n\n\t\ttemplate <typename ConnectionFactoryT, typename ServerSessionFactoryT>\n\n\t\tinline marshalled_active_session::marshalled_active_session(const ConnectionFactoryT &connection_factory,\n\n\t\t\t\tstd::shared_ptr<scheduler::queue> queue, const ServerSessionFactoryT &server_session_factory)\n\n\t\t\t: _queue(queue)\n\n\t\t{\n\n\t\t\t_connection_outbound = connection_factory(*this);\n\n\t\t\t_server_inbound = server_session_factory(*_connection_outbound);\n\n\t\t}\n\n\n\n\t}\n\n}\n", "file_path": "ipc/marshalled_session.h", "rank": 18, "score": 233557.6943039728 }, { "content": "\t\t\tclass socket_handler : public /*outbound*/ channel, noncopyable\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tenum status { proceed, remove_this, exit, };\n\n\t\t\t\ttypedef std::function<status (socket_handler &self, const socket_handle &s)> handler_t;\n\n\t\t\t\ttypedef std::shared_ptr<socket_handler> ptr_t;\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tsocket_handler(unsigned id_, socket_handle &s, const socket_handle &aux_socket,\n\n\t\t\t\t\tconst handler_t &initial_handler);\n\n\t\t\t\t~socket_handler() throw();\n\n\n\n\t\t\t\ttemplate <typename ContainerT>\n\n\t\t\t\tstatic void run(ContainerT &handlers);\n\n\n\n\t\t\t\tvirtual void disconnect() throw();\n\n\t\t\t\tvirtual void message(const_byte_range payload);\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tconst unsigned id;\n\n\t\t\t\thandler_t handler;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tsocket_handle _socket;\n\n\t\t\t\tconst socket_handle &_aux_socket;\n\n\t\t\t};\n\n\n", "file_path": "ipc/src/server_endpoint_sockets.h", "rank": 19, "score": 233557.6943039728 }, { "content": "\t\tclass FauxFrontend : public IUnknown, public CComObjectRoot, public CComCoClass<FauxFrontend>\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tDECLARE_REGISTRY_RESOURCEID(IDR_PROFILER_FRONTEND)\n\n\t\t\tBEGIN_COM_MAP(FauxFrontend)\n\n\t\t\t\tCOM_INTERFACE_ENTRY(IUnknown)\n\n\t\t\tEND_COM_MAP()\n\n\t\t};\n\n\n\n\n\n\n\n\t\tshared_ptr<hive> open_configuration(const vector<string> &configuration_path)\n\n\t\t{\n\n\t\t\tauto h = registry_hive::open_user_settings(\"Software\");\n\n\n\n\t\t\tfor (auto i = configuration_path.begin(); i != configuration_path.end(); ++i)\n\n\t\t\t\th = h->create(i->c_str());\n\n\t\t\treturn h;\n\n\t\t}\n\n\t}\n", "file_path": "standalone/application_win32.cpp", "rank": 20, "score": 232627.7270294888 }, { "content": "\t\t\t\tclass server : public ipc::server\n\n\t\t\t\t{\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tstd::vector< std::shared_ptr<session> > sessions;\n\n\t\t\t\t\tstd::function<void (const std::shared_ptr<session> &new_session)> session_created;\n\n\n\n\t\t\t\tprivate:\n\n\t\t\t\t\tvirtual channel_ptr_t create_session(ipc::channel &outbound);\n\n\n\n\t\t\t\tprivate:\n\n\t\t\t\t\tmt::mutex _mutex;\n\n\t\t\t\t};\n\n\n\n\n\n\n\n\t\t\t\tinline void channel::disconnect() throw()\n\n\t\t\t\t{\n\n\t\t\t\t\tif (on_disconnect)\n\n\t\t\t\t\t\ton_disconnect();\n\n\t\t\t\t}\n", "file_path": "ipc/tests/mocks.h", "rank": 21, "score": 225563.89245304617 }, { "content": "\t\tclass runner_controller : public ipc::server\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tbool wait_connection();\n\n\n\n\t\tpublic:\n\n\t\t\tstd::vector< std::shared_ptr<SessionT> > sessions;\n\n\n\n\t\tprivate:\n\n\t\t\t// ipc::server methods\n\n\t\t\tvirtual ipc::channel_ptr_t create_session(ipc::channel &outbound);\n\n\n\n\t\tprivate:\n\n\t\t\tmt::event _ready;\n\n\t\t};\n\n\n\n\n\n\n\n\t\tstd::shared_ptr<running_process> create_process(const std::string &executable_path,\n\n\t\t\tconst std::string &command_line);\n", "file_path": "test-helpers/process.h", "rank": 22, "score": 209333.87115159153 }, { "content": "\tclass frontend : public ipc::client_session, noncopyable\n\n\t{\n\n\tpublic:\n\n\t\ttypedef frontend_ui_context session_type;\n\n\n\n\tpublic:\n\n\t\tfrontend(ipc::channel &outbound);\n\n\t\t~frontend();\n\n\n\n\tpublic:\n\n\t\tstd::function<void (const session_type &ui_context)> initialized;\n\n\n\n\tprivate:\n\n\t\ttypedef std::list< std::shared_ptr<void> > requests_t;\n\n\n\n\tprivate:\n\n\t\t// ipc::channel methods\n\n\t\tvirtual void disconnect() throw() override;\n\n\n\n\t\tvoid init_patcher();\n", "file_path": "frontend/frontend.h", "rank": 23, "score": 203037.12298805304 }, { "content": "\t\tclass logging_server : public ipc::server, noncopyable\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tlogging_server(const shared_ptr<ipc::server> &server, const string &endpoint_id)\n\n\t\t\t\t: _server(server), _endpoint_id(endpoint_id)\n\n\t\t\t{\t}\n\n\n\n\t\t\tvirtual ipc::channel_ptr_t create_session(ipc::channel &outbound) override\n\n\t\t\t{\n\n\t\t\t\tLOG(PREAMBLE \"creating frontend server session...\") % A(_endpoint_id);\n\n\t\t\t\treturn _server->create_session(outbound);\n\n\t\t\t}\n\n\n\n\t\tprivate:\n\n\t\t\tconst shared_ptr<ipc::server> _server;\n\n\t\t\tconst string _endpoint_id;\n\n\t\t};\n\n\n\n\t\tshared_ptr<void> try_run_server(const string &endpoint_id, const shared_ptr<ipc::server> &server)\n\n\t\ttry\n", "file_path": "frontend/src/untested/ipc_manager.cpp", "rank": 24, "score": 201940.12910223968 }, { "content": "\tclass file_hive : public hive, public std::enable_shared_from_this<file_hive>\n\n\t{\n\n\tpublic:\n\n\t\tstatic std::shared_ptr<hive> open_ini(const char *path);\n\n\n\n\tprivate:\n\n\t\tfile_hive(const char *path);\n\n\n\n\t\tvirtual std::shared_ptr<hive> create(const char *name) override;\n\n\t\tvirtual std::shared_ptr<const hive> open(const char *name) const override;\n\n\n\n\t\tvirtual void store(const char *name, int value) override;\n\n\t\tvirtual void store(const char *name, const char *value) override;\n\n\n\n\t\tvirtual bool load(const char *name, int &value) const override;\n\n\t\tvirtual bool load(const char *name, std::string &value) const override;\n\n\t};\n\n}\n", "file_path": "common/configuration_file.h", "rank": 25, "score": 199777.81539067515 }, { "content": "\tclass frontend_manager : public ipc::server, noncopyable\n\n\t{\n\n\tpublic:\n\n\t\tstruct instance\n\n\t\t{\n\n\t\t\tstd::string title;\n\n\t\t\tstd::shared_ptr<frontend_ui> ui;\n\n\t\t};\n\n\n\n\tpublic:\n\n\t\ttemplate <typename FrontendFactoryT, typename FrontendUIFactoryT>\n\n\t\tfrontend_manager(FrontendFactoryT frontend_factory, FrontendUIFactoryT ui_factory);\n\n\t\t~frontend_manager();\n\n\n\n\t\tvoid close_all() throw();\n\n\n\n\t\tsize_t instances_count() const throw();\n\n\t\tconst instance *get_instance(unsigned index) const throw();\n\n\t\tconst instance *get_active() const throw();\n\n\n", "file_path": "frontend/frontend_manager.h", "rank": 26, "score": 199180.08071221865 }, { "content": "\tclass function_hint : public wpl::view\n\n\t{\n\n\tpublic:\n\n\t\tfunction_hint(wpl::gcontext::text_engine_type &text_services);\n\n\n\n\t\tvoid apply_styles(const wpl::stylesheet &stylesheet_);\n\n\n\n\t\tvoid set_model(std::shared_ptr<wpl::richtext_table_model> model);\n\n\t\tbool select(wpl::table_model_base::index_type index);\n\n\t\tbool is_active() const;\n\n\t\tagge::box<int> get_box() const;\n\n\n\n\tprivate:\n\n\t\tvirtual void draw(wpl::gcontext &context, wpl::gcontext::rasterizer_ptr &rasterizer) const override;\n\n\n\n\t\tvoid update_text_and_calculate_locations(wpl::table_model_base::index_type index);\n\n\n\n\tprivate:\n\n\t\twpl::gcontext::text_engine_type &_text_services;\n\n\t\tstd::shared_ptr<wpl::richtext_table_model> _model;\n", "file_path": "frontend/function_hint.h", "rank": 27, "score": 196274.68206914118 }, { "content": "\t\tclass unordered_map : std::list< std::pair<const KeyT, ValueT> >\n\n\t\t{\n\n\t\tprivate:\n\n\t\t\tenum { initial_nbuckets = 16, };\n\n\t\t\ttypedef std::list< std::pair<const KeyT, ValueT> > base_t;\n\n\n\n\t\tpublic:\n\n\t\t\ttypedef KeyT key_type;\n\n\t\t\ttypedef ValueT mapped_type;\n\n\t\t\ttypedef std::pair<const KeyT, ValueT> value_type;\n\n\t\t\ttypedef unsigned short internal_size_type;\n\n\t\t\tusing typename base_t::const_iterator;\n\n\t\t\tusing typename base_t::iterator;\n\n\n\n\t\tpublic:\n\n\t\t\tusing base_t::begin;\n\n\t\t\tusing base_t::end;\n\n\t\t\tusing base_t::empty;\n\n\t\t\tusing base_t::size;\n\n\n", "file_path": "common/unordered_map.h", "rank": 28, "score": 193696.98479875407 }, { "content": "\tclass thread_monitor : public std::enable_shared_from_this<thread_monitor>\n\n\t{\n\n\tpublic:\n\n\t\ttypedef unsigned int thread_id;\n\n\t\ttypedef unsigned long long native_thread_id;\n\n\t\ttypedef std::pair<thread_id, thread_info> value_type;\n\n\n\n\tpublic:\n\n\t\tthread_monitor(mt::thread_callbacks &callbacks);\n\n\n\n\t\tvirtual thread_id register_self();\n\n\n\n\t\ttemplate <typename OutputIteratorT, typename IteratorT>\n\n\t\tvoid get_info(OutputIteratorT destination, IteratorT begin_id, IteratorT end_id) const;\n\n\n\n\tprotected:\n\n\t\tstruct live_thread_info;\n\n\n\n\t\ttypedef containers::unordered_map<native_thread_id, live_thread_info> running_threads_map;\n\n\t\ttypedef containers::unordered_map<thread_id, thread_info> threads_map;\n", "file_path": "collector/thread_monitor.h", "rank": 29, "score": 192579.32080453407 }, { "content": "\t\tclass buffer_deleter;\n\n\n\n\t\ttypedef std::unique_ptr<buffer, buffer_deleter> buffer_ptr;\n\n\n\n\tprivate:\n\n\t\tvoid create_buffer(buffer_ptr &new_buffer);\n\n\t\tvoid start_buffer(buffer_ptr &ready_buffer) throw();\n\n\t\tvoid adjust_empty_buffers(const buffering_policy &policy, size_t base_n);\n\n\n\n\tprivate:\n\n\t\tE *_ptr;\n\n\t\tunsigned int _n_left;\n\n\n\n\t\tunsigned int _id;\n\n\t\tbuffer_ptr _active_buffer;\n\n\t\tpolyq::circular_buffer< buffer_ptr, polyq::static_entry<buffer_ptr> > _ready_buffers;\n\n\t\tbuffer_ptr *_empty_buffers_top;\n\n\t\tsize_t _allocated_buffers;\n\n\n\n\t\tbuffering_policy _policy;\n", "file_path": "collector/buffers_queue.h", "rank": 30, "score": 192529.94935912458 }, { "content": "\t\tclass message_loop_android : public message_loop\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tmessage_loop_android()\n\n\t\t\t\t: _exit(false), _looper(ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS))\n\n\t\t\t{\tALooper_acquire(_looper);\t}\n\n\n\n\t\t\t~message_loop_android()\n\n\t\t\t{\tALooper_release(_looper);\t}\n\n\n\n\t\t\tvirtual void run() override\n\n\t\t\t{\n\n\t\t\t\tint dummy[2];\n\n\t\t\t\tvoid *vdummy;\n\n\n\n\t\t\t\twhile (!_exit && ALOOPER_POLL_ERROR != ALooper_pollOnce(-1, &dummy[0], &dummy[1], &vdummy))\n\n\t\t\t\t{\t}\n\n\t\t\t}\n\n\n\n\t\t\tvirtual void exit() override\n", "file_path": "scheduler/tests/helpers_android.cpp", "rank": 31, "score": 191091.6151219264 }, { "content": "\t\tclass message_loop_win32 : public message_loop\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tmessage_loop_win32()\n\n\t\t\t\t: _thread_id(::GetCurrentThreadId())\n\n\t\t\t{\t}\n\n\n\n\t\t\tvirtual void run() override\n\n\t\t\t{\n\n\t\t\t\tMSG msg = {};\n\n\n\n\t\t\t\twhile (::GetMessage(&msg, NULL, 0, 0) && WM_QUIT != msg.message)\n\n\t\t\t\t\t::DispatchMessage(&msg);\n\n\t\t\t}\n\n\n\n\t\t\tvirtual void exit() override\n\n\t\t\t{\t::PostThreadMessage(_thread_id, WM_QUIT, 0, 0);\t}\n\n\n\n\t\tprivate:\n\n\t\t\tunsigned _thread_id;\n", "file_path": "scheduler/tests/helpers_win32.cpp", "rank": 32, "score": 191091.6151219264 }, { "content": "\t\tclass marshalled_active_session : channel, noncopyable\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\ttemplate <typename ConnectionFactoryT, typename ServerSessionFactoryT>\n\n\t\t\tmarshalled_active_session(const ConnectionFactoryT &connection_factory,\n\n\t\t\t\tstd::shared_ptr<scheduler::queue> queue, const ServerSessionFactoryT &server_session_factory);\n\n\n\n\t\tprivate:\n\n\t\t\tvirtual void disconnect() throw() override;\n\n\t\t\tvirtual void message(const_byte_range payload) override;\n\n\n\n\t\tprivate:\n\n\t\t\tchannel_ptr_t _connection_outbound, _server_inbound;\n\n\t\t\tscheduler::private_queue _queue;\n\n\t\t};\n\n\n\n\n", "file_path": "ipc/marshalled_session.h", "rank": 33, "score": 189098.27727653447 }, { "content": "\t\tclass marshalled_server : public server, noncopyable\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tmarshalled_server(std::shared_ptr<server> underlying, std::shared_ptr<scheduler::queue> queue);\n\n\t\t\t~marshalled_server();\n\n\n\n\t\t\tvoid stop();\n\n\n\n\t\tprivate:\n\n\t\t\tvirtual channel_ptr_t create_session(channel &outbound) override;\n\n\n\n\t\tprivate:\n\n\t\t\tconst std::shared_ptr<lifetime> _lifetime;\n\n\t\t\tstd::shared_ptr<server> _underlying;\n\n\t\t\tconst std::shared_ptr<scheduler::queue> _queue;\n\n\t\t};\n\n\t}\n\n}\n", "file_path": "ipc/marshalled_server.h", "rank": 34, "score": 183337.99562135275 }, { "content": "\tclass buffers_queue<E>::buffer_deleter\n\n\t{\n\n\tpublic:\n\n\t\tbuffer_deleter();\n\n\t\texplicit buffer_deleter(allocator &allocator_);\n\n\n\n\t\tvoid operator ()(buffer *object) throw();\n\n\n\n\tprivate:\n\n\t\tallocator *_allocator;\n\n\t};\n\n\n\n\n\n\n\n\ttemplate <typename E>\n\n\tinline buffers_queue<E>::buffers_queue(allocator &allocator_, const buffering_policy &policy, unsigned int id)\n\n\t\t: _id(id), _ready_buffers(policy.max_buffers()), _allocated_buffers(0), _policy(policy),\n\n\t\t\t_empty_buffers(new buffer_ptr[policy.max_buffers()]), _allocator(allocator_)\n\n\t{\n\n\t\tbuffer_ptr b;\n", "file_path": "collector/buffers_queue.h", "rank": 35, "score": 179627.0793618212 }, { "content": "\t\t\tvirtual void disconnect() throw() = 0;\n", "file_path": "ipc/endpoint.h", "rank": 36, "score": 179509.95297381445 }, { "content": "\tclass threads_model : public wpl::list_model<std::string>, noncopyable\n\n\t{\n\n\tpublic:\n\n\t\tthreads_model(std::shared_ptr<const tables::threads> threads);\n\n\n\n\t\tbool get_key(unsigned int &thread_id, index_type index) const throw();\n\n\n\n\t\tvirtual index_type get_count() const throw() override;\n\n\t\tvirtual void get_value(index_type index, std::string &text) const override;\n\n\t\tvirtual std::shared_ptr<const wpl::trackable> track(index_type index) const override;\n\n\n\n\tprivate:\n\n\t\ttypedef views::ordered<tables::threads> view_type;\n\n\t\ttypedef trackables_provider<view_type> trackables_type;\n\n\n\n\tprivate:\n\n\t\tconst std::shared_ptr<const tables::threads> _underlying;\n\n\t\tconst std::shared_ptr<view_type> _view;\n\n\t\tconst std::shared_ptr<trackables_type> _trackables;\n\n\t\twpl::slot_connection _invalidation;\n\n\t};\n\n}\n", "file_path": "frontend/threads_model.h", "rank": 37, "score": 179435.95875718273 }, { "content": "\t\t\tclass frontend_state : noncopyable, public std::enable_shared_from_this<frontend_state>\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\texplicit frontend_state(const std::shared_ptr<void> &ownee = std::shared_ptr<void>());\n\n\n\n\t\t\t\tipc::channel_ptr_t create();\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tstd::function<void ()> constructed;\n\n\t\t\t\tstd::function<void ()> destroyed;\n\n\n\n\t\t\t\tstd::function<void (const initialization_data &id)> initialized;\n\n\t\t\t\tstd::function<void (unsigned token, const loaded_modules &m)> modules_loaded;\n\n\t\t\t\tstd::function<void (unsigned token, const thread_statistics_map &u)> updated;\n\n\t\t\t\tstd::function<void (unsigned token, const unloaded_modules &m)> modules_unloaded;\n\n\t\t\t\tstd::function<void (unsigned token, const module_info_metadata &md)> metadata_received;\n\n\t\t\t\tstd::function<void (unsigned token, const std::vector< std::pair<unsigned /*thread_id*/, thread_info> > &threads)> threads_received;\n\n\t\t\t\tstd::function<void (unsigned token, const patch_manager::apply_results &results)> activation_response_received;\n\n\t\t\t\tstd::function<void (unsigned token, const patch_manager::revert_results &results)> revert_response_received;\n\n\n", "file_path": "micro-profiler.tests/mock_frontend.h", "rank": 38, "score": 177927.36064859768 }, { "content": "\t\t\t\tclass sequential_stream\n\n\t\t\t\t{\n\n\t\t\t\tpublic:\n\n\t\t\t\t\tsequential_stream(const CLSID &id)\n\n\t\t\t\t\t\t: _frontend(0)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\t::CoCreateInstance(id, NULL, CLSCTX_LOCAL_SERVER, IID_ISequentialStream, (void **)&_frontend);\n\n\t\t\t\t\t\tassert_not_null(_frontend);\n\n\t\t\t\t\t}\n\n\n\n\t\t\t\t\tsequential_stream(const sequential_stream &other)\n\n\t\t\t\t\t\t: _frontend(other._frontend)\n\n\t\t\t\t\t{\t_frontend->AddRef();\t}\n\n\n\n\t\t\t\t\t~sequential_stream()\n\n\t\t\t\t\t{\t_frontend->Release();\t}\n\n\n\n\t\t\t\t\tbool operator()(const void *buffer, size_t size)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tULONG written;\n", "file_path": "ipc/tests/helpers_com.cpp", "rank": 39, "score": 170499.35546884098 }, { "content": "\tclass calls_collector_thread : public buffers_queue<call_record>\n\n\t{\n\n\tpublic:\n\n\t\ttypedef std::function<void (unsigned int id, const call_record *calls, size_t count)> reader_t;\n\n\n\n\tpublic:\n\n\t\texplicit calls_collector_thread(allocator &allocator_, const buffering_policy &policy, unsigned int id);\n\n\n\n\t\tvoid on_enter(const void **stack_ptr, timestamp_t timestamp, const void *callee) throw();\n\n\t\tconst void *on_exit(const void **stack_ptr, timestamp_t timestamp) throw();\n\n\n\n\t\tvoid track(const void *callee, timestamp_t timestamp) throw();\n\n\n\n\t\tvoid flush();\n\n\n\n\tprivate:\n\n\t\tpod_vector<return_entry> _return_stack;\n\n\t};\n\n\n\n\n\n\n\n\tFORCE_INLINE void calls_collector_thread::track(const void *callee, timestamp_t timestamp) throw()\n\n\t{\n\n\t\tauto &c = current();\n\n\n\n\t\tc.timestamp = timestamp, c.callee = callee;\n\n\t\tpush();\n\n\t}\n\n}\n", "file_path": "collector/calls_collector_thread.h", "rank": 40, "score": 169682.2995140495 }, { "content": "\t\t\tclass socket_handle : noncopyable\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tsocket_handle();\n\n\t\t\t\t~socket_handle();\n\n\n\n\t\t\t\toperator int() const;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tint _socket;\n\n\t\t\t};\n\n\n", "file_path": "ipc/tests/helpers_sockets.h", "rank": 41, "score": 167560.28881072742 }, { "content": "\t\t\tclass socket_handle : noncopyable\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\ttemplate <typename T>\n\n\t\t\t\texplicit socket_handle(T s);\n\n\t\t\t\tsocket_handle(socket_handle &other);\n\n\t\t\t\t~socket_handle();\n\n\n\n\t\t\t\tvoid reset() throw();\n\n\t\t\t\tvoid reset(int s);\n\n\t\t\t\toperator int() const;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tint _socket;\n\n\t\t\t};\n\n\n\n\n\n\n\n\t\t\tinline host_port::host_port(const char *address, const char *default_host)\n\n\t\t\t{\n", "file_path": "ipc/src/socket_helpers.h", "rank": 42, "score": 167560.28881072742 }, { "content": "\tclass trackables_provider<UnderlyingT>::trackable : public wpl::trackable\n\n\t{\n\n\tpublic:\n\n\t\ttrackable(key_type key_, size_t current_index_) : key(key_), current_index(current_index_) {\t}\n\n\t\tvirtual size_t index() const override {\treturn current_index;\t}\n\n\n\n\tpublic:\n\n\t\tkey_type key;\n\n\t\tsize_t current_index;\n\n\t};\n\n\n\n\n\n\n\n\ttemplate <typename UnderlyingT>\n\n\tinline trackables_provider<UnderlyingT>::trackables_provider(const UnderlyingT &underlying)\n\n\t\t: _underlying(underlying), _trackables(std::make_shared<trackables_t>())\n\n\t{\t}\n\n\n\n\ttemplate <typename UnderlyingT>\n\n\tinline trackables_provider<UnderlyingT>::~trackables_provider()\n", "file_path": "frontend/trackables_provider.h", "rank": 43, "score": 165399.73391991862 }, { "content": "\tclass variant<T, void>\n\n\t{\n\n\tpublic:\n\n\t\tvariant(const T &from)\n\n\t\t\t: _type(0), _value(from)\n\n\t\t{\t}\n\n\n\n\t\tunsigned int get_type() const\n\n\t\t{\treturn _type;\t}\n\n\n\n\t\tvoid change_type(unsigned int type)\n\n\t\t{\t_type = type;\t}\n\n\n\n\t\ttemplate <typename V>\n\n\t\ttypename V::return_type visit(const V &visitor) const\n\n\t\t{\treturn visitor(_value);\t}\n\n\n\n\t\ttemplate <typename V>\n\n\t\ttypename V::return_type visit(const V &visitor)\n\n\t\t{\treturn visitor(_value);\t}\n", "file_path": "math/variant.h", "rank": 44, "score": 153428.9315956888 }, { "content": "\tclass functions_list : public statistics_model_impl< wpl::richtext_table_model, views::filter<statistic_types::map_detailed> >\n\n\t{\n\n\tpublic:\n\n\t\ttypedef statistic_types::map_detailed::value_type value_type;\n\n\n\n\tpublic:\n\n\t\tfunctions_list(std::shared_ptr<tables::statistics> statistics, double tick_interval_,\n\n\t\t\tstd::shared_ptr<symbol_resolver> resolver_, std::shared_ptr<const tables::threads> threads_);\n\n\t\tvirtual ~functions_list();\n\n\n\n\t\ttemplate <typename PredicateT>\n\n\t\tvoid set_filter(const PredicateT &predicate);\n\n\t\tvoid set_filter();\n\n\n\n\t\tvoid clear();\n\n\t\tvoid print(std::string &content) const;\n\n\n\n\tprivate:\n\n\t\ttypedef statistics_model_impl< wpl::richtext_table_model, views::filter<statistic_types::map_detailed> > base;\n\n\n", "file_path": "frontend/function_list.h", "rank": 45, "score": 148952.51101605932 }, { "content": "\t\tclass ref_attribute_impl : public attribute\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tref_attribute_impl(const char *name_, const T &value);\n\n\n\n\t\tprivate:\n\n\t\t\tvirtual void format_value(buffer_t &buffer) const;\n\n\n\n\t\tprivate:\n\n\t\t\tconst T &_value;\n\n\t\t};\n\n\n", "file_path": "logger/log.h", "rank": 46, "score": 146466.39119402465 }, { "content": "\tclass pool_allocator : public allocator\n\n\t{\n\n\tprivate:\n\n\t\tstruct entry\n\n\t\t{\n\n\t\t\tstd::size_t size;\n\n\t\t};\n\n\n\n\tpublic:\n\n\t\tenum {\toverhead = sizeof(entry)\t};\n\n\n\n\tpublic:\n\n\t\tpool_allocator(allocator &underlying);\n\n\t\t~pool_allocator();\n\n\n\n\t\tvirtual void *allocate(std::size_t length) override;\n\n\t\tvirtual void deallocate(void *memory) throw() override;\n\n\n\n\tprivate:\n\n\t\ttypedef std::vector<entry *> free_bin_t;\n", "file_path": "common/pool_allocator.h", "rank": 47, "score": 146466.39119402465 }, { "content": "\t\t\tclass tracer : public calls_collector_i\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tvirtual void read_collected(acceptor &a) override;\n\n\t\t\t\tvirtual void flush() override;\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tstd::function<void (acceptor &a)> on_read_collected;\n\n\t\t\t\tstd::function<void ()> on_flush;\n\n\t\t\t};\n\n\n\n\n\n\n\n\t\t\tinline void tracer::read_collected(acceptor &a)\n\n\t\t\t{\n\n\t\t\t\tif (on_read_collected)\n\n\t\t\t\t\ton_read_collected(a);\n\n\t\t\t}\n\n\n\n\t\t\tinline void tracer::flush()\n\n\t\t\t{\n\n\t\t\t\tif (on_flush)\n\n\t\t\t\t\ton_flush();\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n", "file_path": "collector/tests/mocks.h", "rank": 48, "score": 146466.39119402465 }, { "content": "\tclass ui_queue : public queue\n\n\t{\n\n\tpublic:\n\n\t\tui_queue(const clock &clock_);\n\n\t\t~ui_queue();\n\n\n\n\t\tvirtual void schedule(std::function<void ()> &&task, mt::milliseconds defer_by) override;\n\n\n\n\t\tvoid stop();\n\n\n\n\tprivate:\n\n\t\tstruct impl;\n\n\n\n\tprivate:\n\n\t\tscheduler::task_queue _tasks;\n\n\t\tstd::shared_ptr<impl> _impl;\n\n\t};\n\n}\n", "file_path": "scheduler/ui_queue.h", "rank": 49, "score": 146466.39119402465 }, { "content": "\tclass histogram : std::vector<Y>\n\n\t{\n\n\tpublic:\n\n\t\ttypedef std::vector<Y> base_t;\n\n\t\ttypedef ScaleT scale_type;\n\n\t\ttypedef typename scale_type::value_type x_type;\n\n\t\ttypedef Y y_type;\n\n\n\n\tpublic:\n\n\t\tvoid set_scale(const scale_type &scale_);\n\n\t\tconst scale_type &get_scale() const;\n\n\n\n\t\tusing base_t::size;\n\n\t\tusing base_t::begin;\n\n\t\tusing base_t::end;\n\n\n\n\t\tvoid add(x_type value, y_type d = 1);\n\n\n\n\t\ttemplate <typename IteratorT /*partition*/>\n\n\t\tvoid find_partitions(IteratorT first, IteratorT last) const;\n", "file_path": "math/histogram.h", "rank": 50, "score": 145127.65842280193 }, { "content": "\tclass about_ui : public wpl::stack\n\n\t{\n\n\tpublic:\n\n\t\tabout_ui(const wpl::factory &factory_);\n\n\n\n\tprivate:\n\n\t\tvoid on_link(const std::string &address);\n\n\n\n\tprivate:\n\n\t\tstd::vector<wpl::slot_connection> _connections;\n\n\t\tstd::shared_ptr<wpl::button> _close_button;\n\n\n\n\tpublic:\n\n\t\twpl::signal<void (const std::string &address)> link;\n\n\t\twpl::signal<void ()> &close;\n\n\t};\n\n}\n", "file_path": "frontend/about_ui.h", "rank": 51, "score": 144428.82171258074 }, { "content": "\tclass registry_hive : public hive\n\n\t{\n\n\tpublic:\n\n\t\tregistry_hive(std::shared_ptr<void> key);\n\n\n\n\t\tstatic std::shared_ptr<hive> open_user_settings(const char *registry_path);\n\n\n\n\tprivate:\n\n\t\t// hive methods\n\n\t\tvirtual std::shared_ptr<hive> create(const char *name) override;\n\n\t\tvirtual std::shared_ptr<const hive> open(const char *name) const override;\n\n\t\tvirtual void store(const char *name, int value) override;\n\n\t\tvirtual void store(const char *name, const char *value) override;\n\n\t\tvirtual bool load(const char *name, int &value) const override;\n\n\t\tvirtual bool load(const char *name, std::string &value) const override;\n\n\n\n\t\toperator HKEY() const;\n\n\n\n\tprivate:\n\n\t\tstd::shared_ptr<void> _key;\n\n\t};\n\n}\n", "file_path": "common/win32/configuration_registry.h", "rank": 52, "score": 143731.42772876847 }, { "content": "\tclass private_queue\n\n\t{\n\n\tpublic:\n\n\t\texplicit private_queue(std::shared_ptr<queue> underlying);\n\n\t\t~private_queue();\n\n\n\n\t\tvoid schedule(std::function<void ()> &&task, mt::milliseconds defer_by = mt::milliseconds(0));\n\n\n\n\tprivate:\n\n\t\tstruct control_block;\n\n\n\n\tprivate:\n\n\t\tprivate_queue(const private_queue &other);\n\n\t\tvoid operator =(const private_queue &rhs);\n\n\n\n\tprivate:\n\n\t\tstd::shared_ptr<queue> _underlying;\n\n\t\tstd::shared_ptr<control_block> _control_block;\n\n\t};\n\n}\n", "file_path": "scheduler/private_queue.h", "rank": 53, "score": 142965.8536003438 }, { "content": "\tclass buffers_queue\n\n\t{\n\n\tpublic:\n\n\t\ttypedef E value_type;\n\n\n\n\tpublic:\n\n\t\tbuffers_queue(allocator &allocator_, const buffering_policy &policy, unsigned int id);\n\n\n\n\t\tunsigned int get_id() throw();\n\n\n\n\t\tE &current() throw();\n\n\t\tvoid push() throw();\n\n\t\tvoid flush() throw();\n\n\n\n\t\ttemplate <typename ReaderT>\n\n\t\tvoid read_collected(const ReaderT &reader);\n\n\n\n\t\tvoid set_buffering_policy(const buffering_policy &policy);\n\n\n\n\tprivate:\n\n\t\tstruct buffer;\n", "file_path": "collector/buffers_queue.h", "rank": 54, "score": 142932.4429510645 }, { "content": "\t\tclass com_event\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tcom_event();\n\n\n\n\t\t\tvoid set();\n\n\t\t\tvoid wait();\n\n\n\n\t\tprivate:\n\n\t\t\tstd::shared_ptr<void> _handle;\n\n\t\t};\n\n\t}\n\n}\n", "file_path": "test-helpers/com.h", "rank": 55, "score": 142028.69649476206 }, { "content": "\tclass selection_model : public selection<typename key_traits<typename UnderlyingT::value_type>::key_type>,\n\n\t\tnoncopyable\n\n\t{\n\n\tpublic:\n\n\t\ttypedef wpl::dynamic_set_model::index_type index_type;\n\n\t\ttypedef key_traits<typename UnderlyingT::value_type> selection_key_type;\n\n\t\ttypedef typename selection_key_type::key_type key_type;\n\n\n\n\tpublic:\n\n\t\tselection_model(const UnderlyingT &underlying);\n\n\n\n\t\t// wpl::dynamic_set_model methods\n\n\t\tvirtual void clear() throw() override;\n\n\t\tvirtual void add(index_type item) override;\n\n\t\tvirtual void remove(index_type item) override;\n\n\t\tvirtual bool contains(index_type item) const throw() override;\n\n\n\n\t\t// selection<...> methods\n\n\t\tvirtual void enumerate(const std::function<void (const key_type &key)> &callback) const override;\n\n\n", "file_path": "frontend/selection_model.h", "rank": 56, "score": 140221.70591159002 }, { "content": "\tclass calls_collector : public calls_collector_i, public thread_queue_manager<calls_collector_thread>\n\n\t{\n\n\tpublic:\n\n\t\tcalls_collector(allocator &allocator_, size_t trace_limit, thread_monitor &thread_monitor_,\n\n\t\t\tmt::thread_callbacks &thread_callbacks);\n\n\n\n\t\tvirtual void read_collected(acceptor &a) override;\n\n\t\tvirtual void flush() override;\n\n\n\n\t\tstatic void CC_(fastcall) on_enter(calls_collector *instance, const void **stack_ptr,\n\n\t\t\ttimestamp_t timestamp, const void *callee) _CC(fastcall);\n\n\t\tstatic const void *CC_(fastcall) on_exit(calls_collector *instance, const void **stack_ptr,\n\n\t\t\ttimestamp_t timestamp) _CC(fastcall);\n\n\n\n\t\tvoid track(timestamp_t timestamp, const void *callee);\n\n\n\n\tprivate:\n\n\t\ttypedef thread_queue_manager<calls_collector_thread> base_t;\n\n\n\n\tprivate:\n\n\t\tcalls_collector_thread &construct_thread_trace();\n\n\t};\n\n}\n", "file_path": "collector/calls_collector.h", "rank": 57, "score": 139595.67281464557 }, { "content": "\tclass tables_ui : public wpl::stack\n\n\t{\n\n\tpublic:\n\n\t\ttables_ui(const wpl::factory &factory_, const frontend_ui_context &context, hive &configuration);\n\n\n\n\t\tvoid save(hive &configuration);\n\n\n\n\tpublic:\n\n\t\twpl::signal<void(const std::string &file, unsigned line)> open_source;\n\n\n\n\tprivate:\n\n\t\tstatic std::pair<statistic_types::key, bool> get_first_item(const selection<statistic_types::key> &selection_);\n\n\n\n\t\ttemplate <typename ModelT, typename SelectionModelT>\n\n\t\tvoid attach_section(wpl::listview &lv, piechart *pc, function_hint *hint, std::shared_ptr<headers_model> cm,\n\n\t\t\tstd::shared_ptr<ModelT> model, std::shared_ptr<SelectionModelT> selection_);\n\n\n\n\tprivate:\n\n\t\tconst std::shared_ptr<headers_model> _cm_main;\n\n\t\tconst std::shared_ptr<headers_model> _cm_parents;\n\n\t\tconst std::shared_ptr<headers_model> _cm_children;\n\n\n\n\t\tstd::shared_ptr<wpl::listview> _lv_main;\n\n\n\n\t\tstd::vector<wpl::slot_connection> _connections;\n\n\t};\n\n}\n", "file_path": "frontend/tables_ui.h", "rank": 58, "score": 138787.041915369 }, { "content": "\t\t\tclass queue : public scheduler::queue\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tvirtual void schedule(std::function<void ()> &&task, mt::milliseconds defer_by = mt::milliseconds(0)) override;\n\n\n\n\t\t\t\tvoid run_one();\n\n\t\t\t\tvoid run_till_end();\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tstd::deque< std::pair<std::function<void ()>, mt::milliseconds > > tasks;\n\n\t\t\t};\n\n\n\n\n\n\n\n\t\t\tinline void queue::schedule(std::function<void ()> &&task, mt::milliseconds defer_by)\n\n\t\t\t{\n\n\t\t\t\ttasks.emplace_back(std::make_pair(std::move(task), defer_by));\n\n\t\t\t\ttask = std::function<void ()>();\n\n\t\t\t}\n\n\n", "file_path": "test-helpers/mock_queue.h", "rank": 59, "score": 138787.041915369 }, { "content": "\t\tclass multithreaded_logger : public logger, noncopyable\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\ttypedef std::function<void (const char *text)> writer_t;\n\n\t\t\ttypedef std::function<datetime ()> time_provider_t;\n\n\n\n\t\tpublic:\n\n\t\t\tmultithreaded_logger(const writer_t &writer, const time_provider_t &time_provider);\n\n\t\t\t~multithreaded_logger();\n\n\n\n\t\t\tvirtual void begin(const char *message, level level_) throw();\n\n\t\t\tvirtual void add_attribute(const attribute &a) throw();\n\n\t\t\tvirtual void commit() throw();\n\n\n\n\t\tprivate:\n\n\t\t\tbuffer_t &get_buffer();\n\n\n\n\t\tprivate:\n\n\t\t\tconst writer_t _writer;\n\n\t\t\tconst time_provider_t _time_provider;\n\n\t\t\tstd::list<buffer_t> _buffer_container;\n\n\t\t\tmt::tls<buffer_t> _buffers;\n\n\t\t\tmt::mutex _construction_mutex;\n\n\t\t};\n\n\t}\n\n}\n", "file_path": "logger/multithreaded_logger.h", "rank": 60, "score": 138787.041915369 }, { "content": "\t\t\tclass allocation_monitor : public allocator\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tstd::function<void (size_t length, void *memory)> allocated;\n\n\t\t\t\tstd::function<void (void *memory)> freeing;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tvirtual void *allocate(std::size_t length) override\n\n\t\t\t\t{\n\n\t\t\t\t\tauto memory = malloc(length);\n\n\n\n\t\t\t\t\ttry\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tif (allocated)\n\n\t\t\t\t\t\t\tallocated(length, memory);\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcatch (...)\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tfree(memory);\n\n\t\t\t\t\t\tthrow;\n", "file_path": "common/tests/PoolAllocatorTests.cpp", "rank": 61, "score": 138719.50191642868 }, { "content": "\tclass linear_display_scale : public display_scale_base\n\n\t{\n\n\tpublic:\n\n\t\ttemplate <typename T>\n\n\t\tlinear_display_scale(const linear_scale<T> &scale, T divisor, int pixel_size);\n\n\n\n\t\tfloat operator [](float value) const;\n\n\n\n\tprivate:\n\n\t\tconst float _near, _display_k;\n\n\t};\n\n\n\n\n", "file_path": "math/display_scale.h", "rank": 62, "score": 138719.50191642868 }, { "content": "\t\t\tclass mock_hive : public hive\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\ttypedef map<string, int> int_values_map;\n\n\t\t\t\ttypedef map<string, string> str_values_map;\n\n\t\t\t\t\n\n\t\t\tpublic:\n\n\t\t\t\tmock_hive(int_values_map &int_values, str_values_map &str_values, const char *prefix = \"\");\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tconst mock_hive &operator =(const mock_hive &rhs);\n\n\n\n\t\t\t\tvirtual shared_ptr<hive> create(const char *name);\n\n\t\t\t\tvirtual shared_ptr<const hive> open(const char *name) const;\n\n\n\n\t\t\t\tvirtual void store(const char *name, int value);\n\n\t\t\t\tvirtual void store(const char *name, const char *value);\n\n\n\n\t\t\t\tvirtual bool load(const char *name, int &value) const;\n\n\t\t\t\tvirtual bool load(const char *name, string &value) const;\n", "file_path": "frontend/tests/HeadersModelTests.cpp", "rank": 63, "score": 138719.50191642868 }, { "content": "\tclass log_display_scale : public display_scale_base\n\n\t{\n\n\tpublic:\n\n\t\ttemplate <typename T>\n\n\t\tlog_display_scale(const log_scale<T> &scale, T divisor, int pixel_size);\n\n\n\n\t\tfloat operator [](float value) const;\n\n\n\n\tprivate:\n\n\t\tconst float _near, _display_k;\n\n\t};\n\n\n\n\n\n\n\n\tinline display_scale_base::display_scale_base(unsigned samples, int pixel_size)\n\n\t\t: _bin_width(static_cast<float>(pixel_size) / samples)\n\n\t{\t}\n\n\n\n\tinline std::pair<float, float> display_scale_base::at(unsigned int index) const\n\n\t{\n", "file_path": "math/display_scale.h", "rank": 64, "score": 138719.50191642868 }, { "content": "namespace std\n\n{\n\n\tnamespace tr1 { }\n\n\tusing namespace tr1;\n", "file_path": "build.props/emit-tr1-to-std.h", "rank": 65, "score": 138554.59795387727 }, { "content": "\t\t\tvirtual void message(const_byte_range payload) = 0;\n", "file_path": "ipc/endpoint.h", "rank": 66, "score": 138333.24655992072 }, { "content": "\tclass function_patch : noncopyable\n\n\t{\n\n\tpublic:\n\n\t\ttemplate <typename T>\n\n\t\tfunction_patch(void *target, T *interceptor, executable_memory_allocator &allocator_);\n\n\n\n\t\tconst void *target() const;\n\n\t\tbool active() const;\n\n\t\tbool activate(bool atomic);\n\n\t\tbool revert();\n\n\t\tvoid detach();\n\n\n\n\tprivate:\n\n\t\tstd::shared_ptr<void> _trampoline;\n\n\t\tjumper _jumper;\n\n\t};\n\n\n\n\n\n\n\n\ttemplate <typename T>\n", "file_path": "patcher/function_patch.h", "rank": 67, "score": 136270.26267424936 }, { "content": "\t\t\tclass queue : public scheduler::queue\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tvector< pair<function<void ()>, mt::milliseconds> > tasks;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tvirtual void schedule(function<void ()> &&task, mt::milliseconds defer_by) override\n\n\t\t\t\t{\ttasks.emplace_back(make_pair(move(task), defer_by));\t}\n\n\t\t\t};\n\n\t\t}\n\n\n\n\t\tbegin_test_suite( PrivateQueueTests )\n\n\t\t\ttest( SchedulingIsDelegatedToUnderlyingQueue )\n\n\t\t\t{\n\n\t\t\t\t// INIT\n\n\t\t\t\tconst auto u = make_shared<mocks::queue>();\n\n\t\t\t\tauto a = false;\n\n\t\t\t\tauto b = false;\n\n\n\n\t\t\t\t// INIT / ACT\n", "file_path": "scheduler/tests/MiscTests.cpp", "rank": 68, "score": 136209.12880448048 }, { "content": "\t\t\tclass allocator : public micro_profiler::allocator\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tallocator();\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tsize_t allocated, operations;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tvirtual void *allocate(size_t length) override;\n\n\t\t\t\tvirtual void deallocate(void *memory) throw() override;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tdefault_allocator _underlying;\n\n\t\t\t};\n\n\n\n\n\n\n\n\t\t\tinline allocator::allocator()\n\n\t\t\t\t: allocated(0), operations(0)\n", "file_path": "collector/tests/mocks_allocator.h", "rank": 69, "score": 136209.12880448048 }, { "content": "\t\t\tclass thread_callbacks : public mt::thread_callbacks\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tunsigned invoke_destructors();\n\n\t\t\t\tunsigned invoke_destructors(mt::thread::id thread_id);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tvirtual void at_thread_exit(const atexit_t &handler) override;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tmt::mutex _mutex;\n\n\t\t\t\tcontainers::unordered_map< mt::thread::id, std::vector<atexit_t> > _destructors;\n\n\t\t\t};\n\n\n\n\n", "file_path": "collector/tests/mocks.h", "rank": 70, "score": 136209.12880448048 }, { "content": "\tclass headers_model : public wpl::headers_model\n\n\t{\n\n\tpublic:\n\n\t\tstruct column;\n\n\t\tenum sort_direction\t{\tdir_none, dir_ascending, dir_descending\t};\n\n\n\n\tpublic:\n\n\t\ttemplate <size_t N>\n\n\t\theaders_model(const column (&columns)[N], index_type sort_column, bool sort_ascending);\n\n\n\n\t\tvoid store(hive &configuration) const;\n\n\t\tvoid update(const hive &configuration);\n\n\n\n\t\tvirtual index_type get_count() const throw() override;\n\n\t\tvirtual void get_value(index_type index, short int &width) const throw() override;\n\n\t\tvirtual std::pair<index_type, bool> get_sort_order() const throw() override;\n\n\t\tvirtual void set_width(index_type index, short int width) override;\n\n\t\tvirtual agge::full_alignment get_alignment(index_type index) const override;\n\n\t\tvirtual agge::full_alignment get_header_alignment(index_type index) const override;\n\n\t\tvirtual void get_caption(index_type index, agge::richtext_t &caption) const override;\n", "file_path": "frontend/headers_model.h", "rank": 71, "score": 136209.12880448048 }, { "content": "\tclass ipc_manager : noncopyable\n\n\t{\n\n\tpublic:\n\n\t\ttypedef std::pair<unsigned short /*start*/, unsigned short /*size*/> port_range;\n\n\n\n\tpublic:\n\n\t\tipc_manager(std::shared_ptr<ipc::server> server, std::shared_ptr<scheduler::queue> queue, port_range range_,\n\n\t\t\tconst guid_t *com_server_id);\n\n\t\t~ipc_manager();\n\n\n\n\t\tunsigned short get_sockets_port() const;\n\n\t\tbool remote_sockets_enabled() const;\n\n\t\tvoid enable_remote_sockets(bool enable);\n\n\n\n\t\tbool com_enabled() const;\n\n\t\tvoid enable_com(bool enable);\n\n\n\n\tprivate:\n\n\t\tstatic std::shared_ptr<void> probe_create_server(const std::shared_ptr<ipc::server> &server,\n\n\t\t\tipc::ip_v4 interface_, unsigned short &port, port_range range_);\n", "file_path": "frontend/ipc_manager.h", "rank": 72, "score": 135710.80581083093 }, { "content": "\tclass analyzer : public calls_collector_i::acceptor, noncopyable\n\n\t{\n\n\tpublic:\n\n\t\ttypedef containers::unordered_map<unsigned int, thread_analyzer> thread_analyzers;\n\n\t\ttypedef thread_analyzers::const_iterator const_iterator;\n\n\t\ttypedef std::pair<unsigned int, thread_analyzer> value_type;\n\n\n\n\tpublic:\n\n\t\tanalyzer(const overhead& overhead_);\n\n\n\n\t\tvoid clear() throw();\n\n\t\tsize_t size() const throw();\n\n\t\tconst_iterator begin() const throw();\n\n\t\tconst_iterator end() const throw();\n\n\t\tbool has_data() const throw();\n\n\n\n\t\tvirtual void accept_calls(unsigned int threadid, const call_record *calls, size_t count) override;\n\n\n\n\tprivate:\n\n\t\tconst overhead _overhead;\n\n\t\tthread_analyzers _thread_analyzers;\n\n\t};\n\n}\n", "file_path": "collector/analyzer.h", "rank": 73, "score": 134672.92344967992 }, { "content": "\t\t\tclass const_iterator;\n\n\t\t\ttypedef typename U::value_type value_type;\n\n\t\t\ttypedef typename U::const_reference const_reference;\n\n\t\t\ttypedef const_reference reference;\n\n\t\t\ttypedef std::function<bool (const value_type &value)> predicate_t;\n\n\n\n\t\tpublic:\n\n\t\t\tfilter(const U &underlying);\n\n\n\n\t\t\ttemplate <typename PredicateT>\n\n\t\t\tvoid set_filter(const PredicateT &predicate);\n\n\t\t\tvoid set_filter();\n\n\n\n\t\t\tconst_iterator begin() const throw();\n\n\t\t\tconst_iterator end() const throw();\n\n\n\n\t\tprivate:\n\n\t\t\tbool match(const value_type &value) const;\n\n\n\n\t\tprivate:\n\n\t\t\tconst U &_underlying;\n\n\t\t\tpredicate_t _predicate;\n\n\n\n\t\tprivate:\n\n\t\t\tfriend class const_iterator;\n\n\t\t};\n\n\n\n\t\ttemplate <class U>\n", "file_path": "views/filter.h", "rank": 74, "score": 134620.48367916333 }, { "content": "\t\t\tclass const_iterator;\n\n\t\t\ttypedef typename X::const_reference const_reference;\n\n\t\t\ttypedef const_iterator iterator;\n\n\t\t\ttypedef typename X::const_reference reference;\n\n\t\t\ttypedef typename X::value_type value_type;\n\n\n\n\t\tpublic:\n\n\t\t\tflatten(const U &underlying_, const X &transform_ = X());\n\n\n\n\t\t\tconst_iterator begin() const;\n\n\t\t\tconst_iterator end() const;\n\n\n\n\t\tpublic:\n\n\t\t\tconst U &underlying;\n\n\t\t\tconst X transform;\n\n\n\n\t\tprivate:\n\n\t\t\tvoid operator =(const flatten &rhs);\n\n\t\t};\n\n\n\n\t\ttemplate <class U, class X>\n", "file_path": "views/flatten.h", "rank": 75, "score": 134620.48367916333 }, { "content": "\tclass buffering_policy\n\n\t{\n\n\tpublic:\n\n\t\tenum {\tbuffer_size = 384 /*entries*/,\t};\n\n\n\n\tpublic:\n\n\t\tbuffering_policy(size_t max_allocation, double max_empty_factor, double min_empty_factor);\n\n\n\n\t\tsize_t max_buffers() const;\n\n\t\tsize_t max_empty() const;\n\n\t\tsize_t min_empty() const;\n\n\n\n\tprivate:\n\n\t\tsize_t _max_buffers, _max_empty, _min_empty;\n\n\t};\n\n\n\n\n\n\n\n\tinline guid_t::operator const GUID &() const\n\n\t{\treturn *reinterpret_cast<const GUID *>(values);\t}\n", "file_path": "common/types.h", "rank": 76, "score": 134596.83201870864 }, { "content": "\tclass function_hint;\n\n\n", "file_path": "frontend/piechart.h", "rank": 77, "score": 134378.2381897387 }, { "content": "\t\tclass dbghelp_image_info : public image_info\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tdbghelp_image_info(const shared_ptr<dbghelp> &dbghelp_, const string &path);\n\n\n\n\t\tprivate:\n\n\t\t\tvirtual string get_path() const override;\n\n\t\t\tvirtual void enumerate_functions(const symbol_callback_t &callback) const override;\n\n\t\t\tvirtual void enumerate_files(const file_callback_t &callback) const override;\n\n\n\n\t\tprivate:\n\n\t\t\tstring _path;\n\n\t\t\tshared_ptr<dbghelp> _dbghelp;\n\n\t\t\tlong_address_t _base;\n\n\t\t};\n\n\n\n\n\n\n\n\t\tdbghelp::dbghelp()\n\n\t\t{\n", "file_path": "common/src/image_info_win32.cpp", "rank": 78, "score": 134237.5302475882 }, { "content": "\tclass thread_callbacks_impl : public thread_callbacks\n\n\t{\n\n\tpublic:\n\n\t\tthread_callbacks_impl();\n\n\t\t~thread_callbacks_impl();\n\n\n\n\t\tvirtual void at_thread_exit(const atexit_t &handler);\n\n\n\n\tprivate:\n\n\t\ttypedef vector<atexit_t> destructors_t;\n\n\n\n\tprivate:\n\n\t\tstatic void invoke_destructors(void *destructors);\n\n\n\n\tprivate:\n\n\t\tmt::mutex _mutex;\n\n\t\tlist<destructors_t> _all_destructors;\n\n\t\tpthread_key_t _thread_destructors;\n\n\t};\n\n\n", "file_path": "mt/src/thread_callbacks_unix.cpp", "rank": 79, "score": 134237.5302475882 }, { "content": "\t\tclass elf_image_info : public image_info\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\telf_image_info(const string &path);\n\n\n\n\t\tprivate:\n\n\t\t\tvirtual string get_path() const override;\n\n\t\t\tvirtual void enumerate_functions(const symbol_callback_t &callback) const override;\n\n\n\n\t\tprivate:\n\n\t\t\tstring _path;\n\n\t\t\tshared_ptr<const symreader::mapped_region> _image;\n\n\t\t};\n\n\n\n\n\n\n\n\t\telf_image_info::elf_image_info(const string &path)\n\n\t\t\t: _path(path), _image(symreader::map_file(path.c_str()))\n\n\t\t{\n\n\t\t\tif (!_image->first)\n", "file_path": "common/src/image_info_unix.cpp", "rank": 80, "score": 134237.5302475882 }, { "content": "\t\t\tclass running_process_impl : public running_process\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\trunning_process_impl(const string &executable_path, const string &command_line)\n\n\t\t\t\t{\n\n\t\t\t\t\tSTARTUPINFOA si = { };\n\n\t\t\t\t\tstring path = executable_path;\n\n\t\t\t\t\tvector<char> cl2(command_line.begin(), command_line.end());\n\n\n\n\t\t\t\t\tif (path.find(\".exe\") == string::npos)\n\n\t\t\t\t\t\tpath += \".exe\";\n\n\t\t\t\t\tcl2.push_back(char());\n\n\n\n\t\t\t\t\tsi.cb = sizeof(si);\n\n\t\t\t\t\tif (!::CreateProcessA(path.c_str(), &cl2[0], NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS , NULL,\n\n\t\t\t\t\t\tNULL, &si, &_process))\n\n\t\t\t\t\t{\n\n\t\t\t\t\t\tDWORD err = ::GetLastError();\n\n\t\t\t\t\t\terr;\n\n\t\t\t\t\t\tthrow runtime_error(\"Cannot run child process!\");\n", "file_path": "test-helpers/src/process_win32.cpp", "rank": 81, "score": 134237.5302475882 }, { "content": "\tclass thread_callbacks_impl : public thread_callbacks\n\n\t{\n\n\tpublic:\n\n\t\tvoid notify_thread_exit() throw();\n\n\n\n\t\tvirtual void at_thread_exit(const atexit_t &handler);\n\n\n\n\tprivate:\n\n\t\ttypedef vector<atexit_t> destructors_t;\n\n\n\n\tprivate:\n\n\t\tmt::mutex _mutex;\n\n\t\tlist<destructors_t> _all_destructors;\n\n\t\tmt::tls<destructors_t> _thread_destructors;\n\n\t};\n\n\n\n\n\n\n\n\tvoid thread_callbacks_impl::notify_thread_exit() throw()\n\n\t{\n", "file_path": "mt/src/thread_callbacks_win32.cpp", "rank": 82, "score": 134237.5302475882 }, { "content": "\t\t\tvirtual channel_ptr_t create_session(channel &outbound) = 0;\n", "file_path": "ipc/endpoint.h", "rank": 83, "score": 134213.6757041122 }, { "content": "\t\tclass lifetime\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tlifetime()\n\n\t\t\t\t: _alive(true)\n\n\t\t\t{\t}\n\n\n\n\t\t\tvoid mark_destroyed()\n\n\t\t\t{\n\n\t\t\t\tmt::lock_guard<mt::mutex> l(_mtx);\n\n\n\n\t\t\t\t_alive = false;\n\n\t\t\t}\n\n\n\n\t\t\ttemplate <typename F>\n\n\t\t\tvoid execute_safe(const F &f)\n\n\t\t\t{\n\n\t\t\t\tmt::lock_guard<mt::mutex> l(_mtx);\n\n\n\n\t\t\t\tif (_alive)\n", "file_path": "ipc/src/lifetime.h", "rank": 84, "score": 133900.64670686063 }, { "content": "\t\tclass lifetime;\n\n\n", "file_path": "ipc/marshalled_server.h", "rank": 85, "score": 133900.64670686063 }, { "content": "\t\tclass lifetime;\n\n\n", "file_path": "ipc/marshalled_session.h", "rank": 86, "score": 133900.64670686063 }, { "content": "\t\t\tclass response;\n\n\t\t\ttypedef unsigned long long token_t;\n\n\n\n\t\tpublic:\n\n\t\t\tserver_session(channel &outbound, std::shared_ptr<scheduler::queue> queue = std::shared_ptr<scheduler::queue>());\n\n\n\n\t\t\tvoid set_disconnect_handler(const std::function<void ()> &handler);\n\n\n\n\t\t\ttemplate <typename F>\n\n\t\t\tvoid add_handler(int request_id, const F &handler);\n\n\n\n\t\t\ttemplate <typename FormatterT>\n\n\t\t\tvoid message(int message_id, const FormatterT &message_formatter);\n\n\n\n\t\tprivate:\n\n\t\t\ttemplate <typename ArgumentsT, typename U>\n\n\t\t\tstruct handler_thunk;\n\n\t\t\ttypedef std::function<void (response &response_, deserializer &payload)> handler_t;\n\n\n\n\t\tprivate:\n", "file_path": "ipc/server_session.h", "rank": 87, "score": 133900.64670686063 }, { "content": "\t\t\tclass thread_monitor : public micro_profiler::thread_monitor\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tthread_monitor();\n\n\n\n\t\t\t\tthread_monitor::thread_id get_id(mt::thread::id tid) const;\n\n\t\t\t\tthread_monitor::thread_id get_this_thread_id() const;\n\n\n\n\t\t\t\tvoid add_info(thread_id id, const thread_info &info);\n\n\n\n\t\t\tpublic:\n\n\t\t\t\tthread_id provide_this_id;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tvirtual thread_id register_self() override;\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tunsigned _next_id;\n\n\t\t\t\tcontainers::unordered_map<mt::thread::id, thread_monitor::thread_id> _ids;\n\n\t\t\t\tmutable mt::mutex _mtx;\n\n\t\t\t};\n\n\n\n\n", "file_path": "collector/tests/mocks.h", "rank": 88, "score": 133775.11610302917 }, { "content": "\t\t\tclass symbol_resolver : public micro_profiler::symbol_resolver\n\n\t\t\t{\n\n\t\t\tpublic:\n\n\t\t\t\tsymbol_resolver(std::shared_ptr<tables::modules> modules, std::shared_ptr<tables::module_mappings> mappings);\n\n\n\n\t\t\t\tvirtual const std::string &symbol_name_by_va(long_address_t address) const;\n\n\n\n\t\t\t\tstatic std::string to_string_address(long_address_t value);\n\n\n\n\t\t\t\ttemplate <typename T, size_t n>\n\n\t\t\t\tstatic std::shared_ptr<symbol_resolver> create(T (&symbols)[n]);\n\n\n\n\t\t\tprivate:\n\n\t\t\t\tmutable containers::unordered_map<long_address_t, std::string> _names;\n\n\t\t\t};\n\n\t\t}\n\n\t}\n\n}\n", "file_path": "frontend/tests/mocks.h", "rank": 89, "score": 133775.11610302917 }, { "content": "\tclass process_list : public wpl::richtext_table_model\n\n\t{\n\n\tpublic:\n\n\t\ttypedef std::function<void (const process::enumerate_callback_t &callback)> process_enumerator_t;\n\n\n\n\tpublic:\n\n\t\tvoid update(const process_enumerator_t &enumerator);\n\n\n\n\t\tstd::shared_ptr<process> get_process(index_type row) const;\n\n\t\tvoid set_order(index_type column, bool ascending);\n\n\n\n\t\tvirtual index_type get_count() const throw() override;\n\n\t\tvirtual void get_text(index_type row, index_type column, agge::richtext_t &text) const override;\n\n\n\n\tprivate:\n\n\t\ttypedef std::vector< std::shared_ptr<process> > process_container_t;\n\n\n\n\tprivate:\n\n\t\ttemplate <typename PredicateT>\n\n\t\tvoid init_sorter(const PredicateT &p);\n\n\n\n\tprivate:\n\n\t\tstd::vector< std::shared_ptr<process> > _processes;\n\n\t\tstd::function<void (process_container_t &processes)> _sorter;\n\n\t};\n\n}\n", "file_path": "frontend/process_list.h", "rank": 90, "score": 133775.11610302917 }, { "content": "\tclass statistics_model_impl : public BaseT, noncopyable\n\n\t{\n\n\tpublic:\n\n\t\ttypedef typename BaseT::index_type index_type;\n\n\t\ttypedef typename key_traits<typename U::value_type>::key_type key_type;\n\n\n\n\tpublic:\n\n\t\tstatistics_model_impl(std::shared_ptr<U> underlying, double tick_interval_,\n\n\t\t\tstd::shared_ptr<symbol_resolver> resolver_, std::shared_ptr<const tables::threads> threads_);\n\n\n\n\t\tstd::shared_ptr<U> get_underlying() const;\n\n\n\n\t\t// wpl::richtext_table_model methods\n\n\t\tvirtual index_type get_count() const throw() override;\n\n\t\tvirtual void get_text(index_type item, index_type subitem, agge::richtext_t &text) const override;\n\n\t\tvirtual std::shared_ptr<const wpl::trackable> track(index_type row) const override;\n\n\n\n\t\t// linked_statistics methods\n\n\t\tvirtual void fetch() /*override*/;\n\n\t\tvirtual void set_order(index_type column, bool ascending) /*override*/;\n", "file_path": "frontend/statistics_model.h", "rank": 91, "score": 133775.11610302917 }, { "content": "\tclass image_patch_ui : public wpl::stack\n\n\t{\n\n\tpublic:\n\n\t\timage_patch_ui(const wpl::factory &factory_, std::shared_ptr<image_patch_model> model,\n\n\t\t\tstd::shared_ptr<const tables::patches> patches);\n\n\n\n\tprivate:\n\n\t\tvoid check_selection(const selection<symbol_key> &selection_);\n\n\n\n\tprivate:\n\n\t\tstd::shared_ptr<image_patch_model> _model;\n\n\t\tstd::vector<wpl::slot_connection> _connections;\n\n\t\tstd::unordered_set<symbol_key> _to_apply, _to_revert;\n\n\t};\n\n}\n", "file_path": "frontend/image_patch_ui.h", "rank": 92, "score": 133775.11610302917 }, { "content": "\t\tclass process : public micro_profiler::process\n\n\t\t{\n\n\t\tpublic:\n\n\t\t\tprocess(unsigned int pid, const string &name_)\n\n\t\t\t\t: _pid(pid), _name(name_), _hprocess(::OpenProcess(rights, FALSE, pid), &::CloseHandle)\n\n\t\t\t{\n\n\t\t\t\tif (!_hprocess)\n\n\t\t\t\t\tthrow runtime_error(\"\");\n\n\t\t\t}\n\n\n\n\t\t\tvirtual unsigned get_pid() const\n\n\t\t\t{\treturn _pid;\t}\n\n\n\n\t\t\tvirtual string name() const\n\n\t\t\t{\treturn _name;\t}\n\n\n\n\t\t\tvirtual void remote_execute(injection_function_t *injection, const_byte_range payload)\n\n\t\t\t{\n\n\t\t\t\tconst mapped_module m = get_module_info(&g_dummy);\n\n\t\t\t\tconst shared_ptr<void> fpath = foreign_allocate(m.path.size() + 1);\n", "file_path": "injector/src/process_win32.cpp", "rank": 93, "score": 133775.11610302917 }, { "content": "\t\tstd::size_t operator ()(unsigned int key) const throw();\n", "file_path": "common/hash.h", "rank": 94, "score": 133601.9436251504 }, { "content": "\t\ttypedef void (injection_function_t)(const_byte_range payload);\n", "file_path": "injector/process.h", "rank": 95, "score": 133571.5183711627 }, { "content": "\t\tunsigned int id = 0;\n", "file_path": "common/serialization.h", "rank": 96, "score": 133553.23543054127 }, { "content": "\t\tunsigned int id; // Identifier assigned or existed before for a dormant patch.\n", "file_path": "patcher/interface.h", "rank": 97, "score": 133553.23543054127 }, { "content": "\t\ttypedef std::function<void (const std::shared_ptr<process> &entry)> enumerate_callback_t;\n", "file_path": "injector/process.h", "rank": 98, "score": 133303.3979497558 } ]
C++
test/ese/src/devlibtest/stat/statunit/movingavg.cxx
ScriptBox99/Extensible-Storage-Engine
3bcf428c8a041733043e18fd9ae55cffeba307b2
#include "statunittest.hxx" #include "stat.hxx" class MovingAverageTest : public UNITTEST { private: static MovingAverageTest s_instance; protected: MovingAverageTest() {} public: ~MovingAverageTest() {} public: const char * SzName() const; const char * SzDescription() const; bool FRunUnderESE98() const; bool FRunUnderESENT() const; bool FRunUnderESE97() const; ERR ErrTest(); }; MovingAverageTest MovingAverageTest::s_instance; const char * MovingAverageTest::SzName() const { return "MovingAverage"; }; const char * MovingAverageTest::SzDescription() const { return "Tests the statistic libraries' moving average support."; } bool MovingAverageTest::FRunUnderESE98() const { return true; } bool MovingAverageTest::FRunUnderESENT() const { return true; } bool MovingAverageTest::FRunUnderESE97() const { return true; } ERR MovingAverageTest::ErrTest() { wprintf( L"\tTesting Moving Average support ...\n"); #define TestTest( ftest ) if ( !(ftest) ) \ { \ wprintf(L" [line=%d] Test( %S ) failed w/ %d\n", __LINE__, #ftest, (DWORD)(ftest) ); \ STATAssertSz( fFalse, "HaltTest" ); \ } printf( "\tSingle-sample moving average...\n" ); CMovingAverage< ULONG, 1 > avgOneSample( 10 ); TestTest( 10 == avgOneSample.GetLastSample() ); TestTest( 10 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 12 ); TestTest( 12 == avgOneSample.GetLastSample() ); TestTest( 12 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 15 ); TestTest( 15 == avgOneSample.GetLastSample() ); TestTest( 15 == avgOneSample.GetAverage() ); avgOneSample.Reset( 20 ); TestTest( 20 == avgOneSample.GetLastSample() ); TestTest( 20 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 30 ); TestTest( 30 == avgOneSample.GetLastSample() ); TestTest( 30 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 5 ); TestTest( 5 == avgOneSample.GetLastSample() ); TestTest( 5 == avgOneSample.GetAverage() ); printf( "\tTwo-sample moving average...\n" ); CMovingAverage< LONG, 2 > avgTwoSamples( 100 ); TestTest( 100 == avgTwoSamples.GetLastSample() ); TestTest( 100 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 50 ); TestTest( 50 == avgTwoSamples.GetLastSample() ); TestTest( 75 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 10 ); TestTest( 10 == avgTwoSamples.GetLastSample() ); TestTest( 30 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 60 ); TestTest( 60 == avgTwoSamples.GetLastSample() ); TestTest( 35 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 80 ); TestTest( 80 == avgTwoSamples.GetLastSample() ); TestTest( 70 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( -30 ); TestTest( -30 == avgTwoSamples.GetLastSample() ); TestTest( 25 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( -10 ); TestTest( -10 == avgTwoSamples.GetLastSample() ); TestTest( -20 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 110 ); TestTest( 110 == avgTwoSamples.GetLastSample() ); TestTest( 50 == avgTwoSamples.GetAverage() ); avgTwoSamples.Reset( -30 ); TestTest( -30 == avgTwoSamples.GetLastSample() ); TestTest( -30 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( -40 ); TestTest( -40 == avgTwoSamples.GetLastSample() ); TestTest( -35 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 240 ); TestTest( 240 == avgTwoSamples.GetLastSample() ); TestTest( 100 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 60 ); TestTest( 60 == avgTwoSamples.GetLastSample() ); TestTest( 150 == avgTwoSamples.GetAverage() ); printf( "\tFive-sample moving average...\n" ); CMovingAverage< INT, 5 > avgFiveSamples( -1000 ); TestTest( -1000 == avgFiveSamples.GetLastSample() ); TestTest( -1000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -800 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 500 ); TestTest( 500 == avgFiveSamples.GetLastSample() ); TestTest( -500 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 5000 ); TestTest( 5000 == avgFiveSamples.GetLastSample() ); TestTest( 700 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( -10000 ); TestTest( -10000 == avgFiveSamples.GetLastSample() ); TestTest( -1100 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 1000 ); TestTest( 1000 == avgFiveSamples.GetLastSample() ); TestTest( -700 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 10000 ); TestTest( 10000 == avgFiveSamples.GetLastSample() ); TestTest( 1300 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 5000 ); TestTest( 5000 == avgFiveSamples.GetLastSample() ); TestTest( 2200 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( -100000 ); TestTest( -100000 == avgFiveSamples.GetLastSample() ); TestTest( -18800 == avgFiveSamples.GetAverage() ); avgFiveSamples.Reset( -10000 ); TestTest( -10000 == avgFiveSamples.GetLastSample() ); TestTest( -10000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -8000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -6000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -4000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -2000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( 0 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 10000 ); TestTest( 10000 == avgFiveSamples.GetLastSample() ); TestTest( 2000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 1000 ); TestTest( 1000 == avgFiveSamples.GetLastSample() ); TestTest( 2200 == avgFiveSamples.GetAverage() ); return JET_errSuccess; }
#include "statunittest.hxx" #include "stat.hxx" class MovingAverageTest : public UNITTEST { private: static MovingAverageTest s_instance; protected: MovingAverageTest() {} public: ~MovingAverageTest() {} public: const char * SzName() const; const char * SzDescription() const; bool FRunUnderESE98() const; bool FRunUnderESENT() const; bool FRunUnderESE97() const; ERR ErrTest(); }; MovingAverageTest MovingAverageTest::s_instance; const char * MovingAverageTest::SzName() const { return "MovingAverage"; }; const char * MovingAverageTest::SzDescription() const { return "Tests the statistic libraries' moving average support."; } bool MovingAverageTest::FRunUnderESE98() const { return true; } bool MovingAverageTest::FRunUnderESENT() const { return true; } bool MovingAverageTest::FRunUnderESE97() const { return true; } ERR MovingAverageTest::ErrTest() { wprintf( L"\tTesting Moving Average support ...\n"); #define TestTest( ftest ) if ( !(ftest) ) \ { \ wprintf(L" [line=%d] Test( %S ) failed w/ %d\n", __LINE__, #ftest, (DWORD)(ftest) ); \ STATAssertSz( fFalse, "HaltTest" ); \ } printf( "\tSingle-sample moving average...\n" ); CMovingAverage< ULONG, 1 > avgOneSample( 10 ); TestTest( 10 == avgOneSample.GetLastSample() ); TestTest( 10 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 12 ); TestTest( 12 == avgOneSample.GetLastSample() ); TestTest( 12 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 15 ); TestTest( 15 == avgOneSample.GetLastSample() ); TestTest( 15 == avgOneSample.GetAverage() ); avgOneSample.Reset( 20 ); TestTest( 20 == avgOneSample.GetLastSample() ); TestTest( 20 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 30 ); TestTest( 30 == avgOneSample.GetLastSample() ); TestTest( 30 == avgOneSample.GetAverage() ); avgOneSample.AddSample( 5 ); TestTest( 5 == avgOneSample.GetLastSample() ); TestTest( 5 == avgOneSample.GetAverage() ); printf( "\tTwo-sample moving average...\n" ); CMovingAverage< LONG, 2 > avgTwoSamples( 100 ); TestTest( 100 == avgTwoSamples.GetLastSample() ); TestTest( 100 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 50 ); TestTest( 50 == avgTwoSamples.GetLastSample() ); TestTest( 75 == avgTwoSamples.GetAverag
e() ); avgTwoSamples.AddSample( 10 ); TestTest( 10 == avgTwoSamples.GetLastSample() ); TestTest( 30 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 60 ); TestTest( 60 == avgTwoSamples.GetLastSample() ); TestTest( 35 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 80 ); TestTest( 80 == avgTwoSamples.GetLastSample() ); TestTest( 70 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( -30 ); TestTest( -30 == avgTwoSamples.GetLastSample() ); TestTest( 25 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( -10 ); TestTest( -10 == avgTwoSamples.GetLastSample() ); TestTest( -20 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 110 ); TestTest( 110 == avgTwoSamples.GetLastSample() ); TestTest( 50 == avgTwoSamples.GetAverage() ); avgTwoSamples.Reset( -30 ); TestTest( -30 == avgTwoSamples.GetLastSample() ); TestTest( -30 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( -40 ); TestTest( -40 == avgTwoSamples.GetLastSample() ); TestTest( -35 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 240 ); TestTest( 240 == avgTwoSamples.GetLastSample() ); TestTest( 100 == avgTwoSamples.GetAverage() ); avgTwoSamples.AddSample( 60 ); TestTest( 60 == avgTwoSamples.GetLastSample() ); TestTest( 150 == avgTwoSamples.GetAverage() ); printf( "\tFive-sample moving average...\n" ); CMovingAverage< INT, 5 > avgFiveSamples( -1000 ); TestTest( -1000 == avgFiveSamples.GetLastSample() ); TestTest( -1000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -800 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 500 ); TestTest( 500 == avgFiveSamples.GetLastSample() ); TestTest( -500 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 5000 ); TestTest( 5000 == avgFiveSamples.GetLastSample() ); TestTest( 700 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( -10000 ); TestTest( -10000 == avgFiveSamples.GetLastSample() ); TestTest( -1100 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 1000 ); TestTest( 1000 == avgFiveSamples.GetLastSample() ); TestTest( -700 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 10000 ); TestTest( 10000 == avgFiveSamples.GetLastSample() ); TestTest( 1300 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 5000 ); TestTest( 5000 == avgFiveSamples.GetLastSample() ); TestTest( 2200 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( -100000 ); TestTest( -100000 == avgFiveSamples.GetLastSample() ); TestTest( -18800 == avgFiveSamples.GetAverage() ); avgFiveSamples.Reset( -10000 ); TestTest( -10000 == avgFiveSamples.GetLastSample() ); TestTest( -10000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -8000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -6000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -4000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( -2000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 0 ); TestTest( 0 == avgFiveSamples.GetLastSample() ); TestTest( 0 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 10000 ); TestTest( 10000 == avgFiveSamples.GetLastSample() ); TestTest( 2000 == avgFiveSamples.GetAverage() ); avgFiveSamples.AddSample( 1000 ); TestTest( 1000 == avgFiveSamples.GetLastSample() ); TestTest( 2200 == avgFiveSamples.GetAverage() ); return JET_errSuccess; }
function_block-function_prefixed
[]
C++
app/DiskFSTree.cpp
Toysoft/ciderpress
640959dad551ba75a48bd3c49629579730ead351
#include "StdAfx.h" #include "DiskFSTree.h" #include "ChooseAddTargetDialog.h" #include "../reformat/Charset.h" using namespace DiskImgLib; bool DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree) { ASSERT(pDiskFS != NULL); ASSERT(pTree != NULL); pTree->SetImageList(&fTreeImageList, TVSIL_NORMAL); return AddDiskFS(pTree, TVI_ROOT, pDiskFS, 1); } bool DiskFSTree::AddDiskFS(CTreeCtrl* pTree, HTREEITEM parent, DiskImgLib::DiskFS* pDiskFS, int depth) { const DiskFS::SubVolume* pSubVol; TargetData* pTarget; HTREEITEM hLocalRoot; TVITEM tvi; TVINSERTSTRUCT tvins; pTarget = AllocTargetData(); pTarget->kind = kTargetDiskFS; pTarget->pDiskFS = pDiskFS; pTarget->pFile = NULL; tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; CString volumeId(Charset::ConvertMORToUNI(pDiskFS->GetVolumeID())); int index = fStringHolder.Add(volumeId); tvi.pszText = (LPWSTR)(LPCWSTR) fStringHolder.GetAt(index); tvi.cchTextMax = 0; if (pDiskFS->GetReadWriteSupported() && !pDiskFS->GetFSDamaged()) { tvi.iImage = kTreeImageHardDriveRW; pTarget->selectable = true; } else { tvi.iImage = kTreeImageHardDriveRO; pTarget->selectable = false; } tvi.iSelectedImage = tvi.iImage; tvi.lParam = (LPARAM) pTarget; tvins.item = tvi; tvins.hInsertAfter = parent; tvins.hParent = parent; hLocalRoot = pTree->InsertItem(&tvins); if (hLocalRoot == NULL) { LOGW("Tree root InsertItem failed"); return false; } pSubVol = pDiskFS->GetNextSubVolume(NULL); while (pSubVol != NULL) { if (!AddDiskFS(pTree, hLocalRoot, pSubVol->GetDiskFS(), depth+1)) return false; pSubVol = pDiskFS->GetNextSubVolume(pSubVol); } if (fIncludeSubdirs && pDiskFS->GetReadWriteSupported() && !pDiskFS->GetFSDamaged()) { AddSubdir(pTree, hLocalRoot, pDiskFS, NULL, depth); } if (fExpandDepth == -1 || depth <= fExpandDepth) pTree->Expand(hLocalRoot, TVE_EXPAND); if (parent == TVI_ROOT) { pTree->Select(hLocalRoot, TVGN_CARET); } return true; } DiskImgLib::A2File* DiskFSTree::AddSubdir(CTreeCtrl* pTree, HTREEITEM parent, DiskImgLib::DiskFS* pDiskFS, DiskImgLib::A2File* pParentFile, int depth) { A2File* pFile; TargetData* pTarget; HTREEITEM hLocalRoot; TVITEM tvi; TVINSERTSTRUCT tvins; pFile = pDiskFS->GetNextFile(pParentFile); if (pFile == NULL && pParentFile == NULL) { return NULL; } if (pParentFile == NULL) { if (pFile->IsVolumeDirectory()) { pParentFile = pFile; pFile = pDiskFS->GetNextFile(pFile); } hLocalRoot = parent; } else { pTarget = AllocTargetData(); pTarget->kind = kTargetSubdir; pTarget->selectable = true; pTarget->pDiskFS = pDiskFS; pTarget->pFile = pParentFile; tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; CString fileNameW(pParentFile->GetFileName()); int index = fStringHolder.Add(fileNameW); tvi.pszText = (LPWSTR)(LPCWSTR) fStringHolder.GetAt(index); tvi.cchTextMax = 0; tvi.iImage = kTreeImageFolderClosed; tvi.iSelectedImage = kTreeImageFolderOpen; tvi.lParam = (LPARAM) pTarget; tvins.item = tvi; tvins.hInsertAfter = parent; tvins.hParent = parent; hLocalRoot = pTree->InsertItem(&tvins); if (hLocalRoot == NULL) { LOGW("Tree insert '%ls' failed", tvi.pszText); return NULL; } } while (pFile != NULL) { if (pFile->IsDirectory()) { ASSERT(!pFile->IsVolumeDirectory()); if (pFile->GetParent() == pParentFile) { pFile = AddSubdir(pTree, hLocalRoot, pDiskFS, pFile, depth+1); if (pFile == NULL) break; } else { break; } } else { pFile = pDiskFS->GetNextFile(pFile); } } if (fExpandDepth == -1 || depth <= fExpandDepth) pTree->Expand(hLocalRoot, TVE_EXPAND); return pFile; } DiskFSTree::TargetData* DiskFSTree::AllocTargetData(void) { TargetData* pNew = new TargetData; if (pNew == NULL) return NULL; pNew->pNext = fpTargetData; fpTargetData = pNew; return pNew; } void DiskFSTree::FreeAllTargetData(void) { TargetData* pTarget; TargetData* pNext; pTarget = fpTargetData; while (pTarget != NULL) { pNext = pTarget->pNext; delete pTarget; pTarget = pNext; } fpTargetData = NULL; }
#include "StdAfx.h" #include "DiskFSTree.h" #include "ChooseAddTargetDialog.h" #include "../reformat/Charset.h" using namespace DiskImgLib; bool DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree) { ASSERT(pDiskFS != NULL); ASSERT(pTree != NULL); pTree->SetImageList(&fTreeImageList, TVSIL_NORMAL); return AddDiskFS(pTree, TVI_ROOT, pDiskFS, 1); } bool DiskFSTree::AddDiskFS(CTreeCtrl* pTree, HTREEITEM parent, DiskImgLib::DiskFS* pDiskFS, int depth) { const DiskFS::SubVolume* pSubVol; TargetData* pTarget; HTREEITEM hLocalRoot; TVITEM tvi; TVINSERTSTRUCT tvins; pTarget = AllocTargetData(); pTarget->kind = kTargetDiskFS; pTarget->pDiskFS = pDiskFS; pTarget->pFile = NULL; tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; CString volumeId(Charset::ConvertMORToUNI(pDiskFS->GetVolumeID())); int index = fStringHolder.Add(volumeId); tvi.pszText = (LPWSTR)(LPCWSTR) fStringHolder.GetAt(index); tvi.cchTextMax = 0; if (pDiskFS->GetReadWriteSupported() && !pDiskFS->GetFSDamaged()) { tvi.iImage = kTreeImageHardDriveRW; pTarget->selectable = true; } else { tvi.iImage = kTreeImageHardDriveRO; pTarget->selectable = false; } tvi.iSelectedImage = tvi.iImage; tvi.lParam = (LPARAM) pTarget; tvins.item = tvi; tvins.hInsertAfter = parent; tvins.hParent = parent; hLocalRoot = pTree->InsertItem(&tvins); if (hLocalRoot == NULL) { LOGW("Tree root InsertItem failed"); return false; } pSubVol = pDiskFS->GetNextSubVolume(NULL); while (pSubVol != NULL) { if (!AddDiskFS(pTree, hLocalRoot, pSubVol->GetDiskFS(), depth+1)) return false; pSubVol = pDiskFS->GetNextSubVolume(pSubVol); } if (fIncludeSubdirs && pDiskFS->GetReadWriteSupported() && !pDiskFS->GetFSDamaged()) { AddSubdir(pTree, hLocalRoot, pDiskFS, NULL, depth); } if (fExpandDepth == -1 || depth <= fExpandDepth) pTree->Expand(hLocalRoot, TVE_EXPAND); if (parent == TVI_ROOT) { pTree->Select(hLocalRoot, TVGN_CARET); } return true; } DiskImgLib::A2File* DiskFSTree::AddSubdir(CTreeCtrl* pTree, HTREEITEM parent, DiskImgLib::DiskFS* pDiskFS, DiskImgLib::A2File* pParentFile, int depth) { A2File* pFile; TargetData* pTarget; HTREEITEM hLocalRoot; TVITEM tvi; TVINSERTSTRUCT tvins; pFile = pDiskFS->GetNextFile(pParentFile); if (pFile == NULL && pParentFile == NULL) { return NULL; } if (pParentFile == NULL) { if (pFile->IsVolumeDirectory()) { pParentFile = pFile; pFile = pDiskFS->GetNextFile(pFile); } hLocalRoot = parent; } else { pTarget = AllocTargetData(); pTarget->kind = kTargetSubdir; pTarget->selectable = true; pTarget->pDiskFS = pDiskFS; pTarget->pFile = pParentFile; tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; CString fileNameW(pParentFile->GetFileName()); int index = fStringHolder.Add(fileNameW); tvi.pszText = (LPWSTR)(LPCWSTR) fStringHolder.GetAt(index); tvi.cchTextMax = 0; tvi.iImage = kTreeImageFolderClosed; tvi.iSelectedImage = kTreeImageFolderOpen; tvi.lParam = (LPARAM) pTarget; tvins.item = tvi; tvins.hInsertAfter = parent; tvins.hParent = parent; hLocalRoot = pTree->InsertItem(&tvins); if (hLocalRoot == NULL) { LOGW("Tree insert '%ls' failed", tvi.pszText); return NULL; } } while (pFile != NULL) { if (pFile->IsDirectory()) { ASSERT(!pFile->IsVolumeDirectory()); if (pFile->GetParent() == pParentFile) { pFile = AddSubdir(pTree, hLocalRoot, pDiskFS, pFile, depth+1); if (pFile == NULL) break; } else { break; } } else { pFile = pDiskFS->GetNextFile(pFile); } } if (fExpandDepth == -1 || depth <= fExpandDepth) pTree->Expand(hLocalRoot, TVE_EXPAND); return pFile; }
void DiskFSTree::FreeAllTargetData(void) { TargetData* pTarget; TargetData* pNext; pTarget = fpTargetData; while (pTarget != NULL) { pNext = pTarget->pNext; delete pTarget; pTarget = pNext; } fpTargetData = NULL; }
DiskFSTree::TargetData* DiskFSTree::AllocTargetData(void) { TargetData* pNew = new TargetData; if (pNew == NULL) return NULL; pNew->pNext = fpTargetData; fpTargetData = pNew; return pNew; }
function_block-full_function
[ { "content": " uch depth[2*L_CODES+1];\n", "file_path": "zlib/deflate.h", "rank": 0, "score": 93639.98853513303 }, { "content": " uInt insert; /* bytes at end of window left to insert */\n", "file_path": "zlib/deflate.h", "rank": 1, "score": 93630.98532131276 }, { "content": "local int build_bl_tree(s)\n", "file_path": "zlib/trees.c", "rank": 2, "score": 93608.07720701321 }, { "content": "local int gz_avail(state)\n", "file_path": "zlib/gzread.c", "rank": 3, "score": 93605.356769784 }, { "content": "local int gz_init(state)\n", "file_path": "zlib/gzwrite.c", "rank": 4, "score": 93602.05526818347 }, { "content": "local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,\n", "file_path": "zlib/inflate.c", "rank": 5, "score": 93596.13390992681 }, { "content": "local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));\n", "file_path": "zlib/deflate.c", "rank": 6, "score": 93596.13390992681 }, { "content": "#define true (!false)\n\n\n\n\n", "file_path": "nufxlib/samples/ImgConv.c", "rank": 7, "score": 89928.77524166822 }, { "content": "class UseSelectionDialog : public CDialog {\n\npublic:\n\n UseSelectionDialog(int selCount, CWnd* pParentWnd = NULL, int rsrcID = IDD_USE_SELECTION) :\n\n CDialog(rsrcID, pParentWnd), fSelectedCount(selCount)\n\n {\n\n // init values; these should be overridden before DoModal\n\n fFilesToAction = 0;\n\n }\n\n virtual ~UseSelectionDialog(void) {}\n\n\n\n // set up dialog parameters; must be called before DoModal\n\n void Setup(int titleID, int okLabelID, int countID, int countsID,\n\n int allID)\n\n {\n\n fTitleID = titleID;\n\n fOkLabelID = okLabelID;\n\n fSelCountID = countID;\n\n fSelCountsID = countsID;\n\n fAllID = allID;\n\n }\n", "file_path": "app/UseSelectionDialog.h", "rank": 8, "score": 59595.161554119884 }, { "content": "// The filter index is saved in the registry, so if you reorder this list\n\n// you will briefly annoy existing users.\n\nenum FilterIndex {\n\n kFilterIndexFIRST = 1, // first index, must be non-Generic\n\n kFilterIndexNuFX = 1,\n\n kFilterIndexBinaryII = 2,\n\n kFilterIndexACU = 3,\n\n kFilterIndexAppleSingle = 4,\n\n kFilterIndexDiskImage = 5,\n\n kFilterIndexLASTNG = 5, // last non-Generic index\n\n\n\n kFilterIndexGeneric = 6, // *.* filter used\n\n kFilterIndexMAX = 6 // highest valid number\n\n};\n\n\n", "file_path": "app/Main.h", "rank": 9, "score": 55458.328233552515 }, { "content": "\n\n enum { kActionSelection = 0, kActionAll = 1 };\n\n int fFilesToAction;\n\n\n\nprotected:\n\n virtual BOOL OnInitDialog(void) override;\n\n virtual void DoDataExchange(CDataExchange* pDX) override;\n\n\n\n afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo) {\n\n return MyApp::HandleHelpInfo(lpHelpInfo);\n\n }\n\n\n\nprivate:\n\n int fSelectedCount;\n\n\n\n /* dialog parameters */\n\n int fTitleID;\n\n int fOkLabelID;\n\n int fSelCountID;\n\n int fSelCountsID;\n\n int fAllID;\n\n\n\n DECLARE_MESSAGE_MAP()\n\n};\n\n\n\n#endif /*APP_USESELECTIONDIALOG_H*/\n", "file_path": "app/UseSelectionDialog.h", "rank": 10, "score": 55451.57734176381 }, { "content": "/*\n\n * CiderPress\n\n * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.\n\n * See the file LICENSE for distribution terms.\n\n */\n\n/*\n\n * Acknowledge and clarify a request to do something, e.g. delete files.\n\n */\n\n#ifndef APP_USESELECTIONDIALOG_H\n\n#define APP_USESELECTIONDIALOG_H\n\n\n\n#include \"resource.h\"\n\n\n\n/*\n\n * Straightforward confirmation.\n\n */\n", "file_path": "app/UseSelectionDialog.h", "rank": 11, "score": 55443.72347069881 }, { "content": "/*\n\n * CiderPress\n\n * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.\n\n * See the file LICENSE for distribution terms.\n\n */\n\n#include \"stdafx.h\"\n\n#include \"UseSelectionDialog.h\"\n\n\n\nBEGIN_MESSAGE_MAP(UseSelectionDialog, CDialog)\n\n ON_WM_HELPINFO()\n\n //ON_COMMAND(IDHELP, OnHelp)\n\nEND_MESSAGE_MAP()\n\n\n\n\n\nBOOL UseSelectionDialog::OnInitDialog(void)\n\n{\n\n CString str;\n\n CString selStr;\n\n CWnd* pWnd;\n\n\n", "file_path": "app/UseSelectionDialog.cpp", "rank": 12, "score": 53201.7114220574 }, { "content": " CheckedLoadString(&str, fTitleID);\n\n SetWindowText(str);\n\n\n\n pWnd = GetDlgItem(IDC_USE_ALL);\n\n ASSERT(pWnd != NULL);\n\n CheckedLoadString(&str, fAllID);\n\n pWnd->SetWindowText(str);\n\n\n\n pWnd = GetDlgItem(IDOK);\n\n ASSERT(pWnd != NULL);\n\n CheckedLoadString(&str, fOkLabelID);\n\n pWnd->SetWindowText(str);\n\n\n\n return TRUE;\n\n}\n\n\n\nvoid UseSelectionDialog::DoDataExchange(CDataExchange* pDX)\n\n{\n\n DDX_Radio(pDX, IDC_USE_SELECTED, fFilesToAction);\n\n}\n", "file_path": "app/UseSelectionDialog.cpp", "rank": 13, "score": 53200.5552312211 }, { "content": " CDialog::OnInitDialog();\n\n\n\n /* grab the radio button with the selection count */\n\n pWnd = GetDlgItem(IDC_USE_SELECTED);\n\n ASSERT(pWnd != NULL);\n\n\n\n /* set the string using a string table entry */\n\n if (fSelectedCount == 1) {\n\n CheckedLoadString(&str, fSelCountID);\n\n pWnd->SetWindowText(str);\n\n } else {\n\n CheckedLoadString(&str, fSelCountsID);\n\n selStr.Format((LPCWSTR) str, fSelectedCount);\n\n pWnd->SetWindowText(selStr);\n\n\n\n if (fSelectedCount == 0)\n\n pWnd->EnableWindow(FALSE);\n\n }\n\n\n\n /* set the other strings */\n", "file_path": "app/UseSelectionDialog.cpp", "rank": 14, "score": 53194.3031891208 }, { "content": "int n_insert(node *np, byte *record, unsigned int *reclen)\n\n{\n\n /* check for free space */\n\n\n\n if (np->nd.ndNRecs >= HFS_MAX_NRECS ||\n\n *reclen + 2 > NODEFREE(*np))\n\n return split(np, record, reclen);\n\n\n\n n_insertx(np, record, *reclen);\n\n *reclen = 0;\n\n\n\n return bt_putnode(np);\n", "file_path": "diskimg/libhfs/node.c", "rank": 15, "score": 49215.98589065552 }, { "content": "void n_index(const node *np, byte *record, unsigned int *reclen)\n\n{\n\n const byte *key = HFS_NODEREC(*np, 0);\n\n\n\n if (np->bt == &np->bt->f.vol->cat)\n\n {\n\n /* force the key length to be 0x25 */\n\n\n\n HFS_SETKEYLEN(record, 0x25);\n\n memset(record + 1, 0, 0x25);\n\n memcpy(record + 1, key + 1, HFS_RECKEYLEN(key));\n\n }\n\n else\n\n memcpy(record, key, HFS_RECKEYSKIP(key));\n\n\n\n d_putul(HFS_RECDATA(record), np->nnum);\n\n\n\n if (reclen)\n\n *reclen = HFS_RECKEYSKIP(record) + 4;\n", "file_path": "diskimg/libhfs/node.c", "rank": 16, "score": 49204.8905500282 }, { "content": "void n_index(const node *, byte *, unsigned int *);\n", "file_path": "diskimg/libhfs/node.h", "rank": 17, "score": 49197.62585950512 }, { "content": "int n_insert(node *, byte *, unsigned int *);\n", "file_path": "diskimg/libhfs/node.h", "rank": 18, "score": 49196.449760267584 }, { "content": "#define IDS_FAILED 111\n", "file_path": "mdc/resource.h", "rank": 19, "score": 49194.13442054864 }, { "content": "#define IDS_FAILED 2023\n", "file_path": "app/resource.h", "rank": 20, "score": 49194.13442054864 }, { "content": " uint16_t used; /* mark as uninteresting */\n", "file_path": "nufxlib/NufxLib.h", "rank": 21, "score": 49192.08519711983 }, { "content": "#define IDC_USE_ALL 1193\n", "file_path": "app/resource.h", "rank": 22, "score": 49185.50694918639 }, { "content": " ULongInt\tbthRoot;\t/* number of root node */\n", "file_path": "diskimg/libhfs/apple.h", "rank": 23, "score": 47422.7777028922 }, { "content": "int bt_insert(btree *bt, const byte *record, unsigned int reclen)\n\n{\n\n node root;\n\n byte newrec[HFS_MAX_RECLEN];\n\n\n\n if (bt->hdr.bthRoot == 0)\n\n {\n\n /* create root node */\n\n\n\n n_init(&root, bt, ndLeafNode, 1);\n\n if (n_new(&root) == -1 ||\n\n\t bt_putnode(&root) == -1)\n\n\tgoto fail;\n\n\n\n bt->hdr.bthDepth = 1;\n\n bt->hdr.bthRoot = root.nnum;\n\n bt->hdr.bthFNode = root.nnum;\n\n bt->hdr.bthLNode = root.nnum;\n\n\n\n bt->flags |= HFS_BT_UPDATE_HDR;\n\n }\n\n else if (bt_getnode(&root, bt, bt->hdr.bthRoot) == -1)\n\n goto fail;\n\n\n\n memcpy(newrec, record, reclen);\n\n\n\n if (insertx(&root, newrec, &reclen) == -1)\n\n goto fail;\n\n\n\n if (reclen)\n\n {\n\n byte oroot[HFS_MAX_RECLEN];\n\n unsigned int orootlen;\n\n\n\n /* root node was split; create a new root */\n\n\n\n n_index(&root, oroot, &orootlen);\n\n\n\n n_init(&root, bt, ndIndxNode, root.nd.ndNHeight + 1);\n\n if (n_new(&root) == -1)\n\n\tgoto fail;\n\n\n\n ++bt->hdr.bthDepth;\n\n bt->hdr.bthRoot = root.nnum;\n\n\n\n bt->flags |= HFS_BT_UPDATE_HDR;\n\n\n\n /* insert index records for new root */\n\n\n\n n_search(&root, oroot);\n\n n_insertx(&root, oroot, orootlen);\n\n\n\n n_search(&root, newrec);\n\n n_insertx(&root, newrec, reclen);\n\n\n\n if (bt_putnode(&root) == -1)\n\n\tgoto fail;\n\n }\n\n\n\n ++bt->hdr.bthNRecs;\n\n bt->flags |= HFS_BT_UPDATE_HDR;\n\n\n\n return 0;\n\n\n\nfail:\n\n return -1;\n", "file_path": "diskimg/libhfs/btree.c", "rank": 24, "score": 47421.15068864529 }, { "content": " ULONG ReturnCode; \n", "file_path": "diskimg/CP_ntddscsi.h", "rank": 25, "score": 47416.15710403755 }, { "content": " UInteger\tbthDepth;\t/* current depth of tree */\n", "file_path": "diskimg/libhfs/apple.h", "rank": 26, "score": 47415.53123454727 }, { "content": "int bt_insert(btree *, const byte *, unsigned int);\n", "file_path": "diskimg/libhfs/btree.h", "rank": 27, "score": 47413.81388897092 }, { "content": "#define IDC_CASSIMPTARG_INT 1422\n", "file_path": "app/resource.h", "rank": 28, "score": 47404.375635465876 }, { "content": "#define IDC_USE_SELECTED 1192\n", "file_path": "app/resource.h", "rank": 29, "score": 47403.2675912085 }, { "content": "#define IDD_USE_SELECTION 147\n", "file_path": "app/resource.h", "rank": 30, "score": 47403.2675912085 }, { "content": " Boolean used;\n", "file_path": "nufxlib/NufxLibPriv.h", "rank": 31, "score": 47403.2675912085 }, { "content": " LongInt\tdrLsMod;\t/* date and time of last modification */\n", "file_path": "diskimg/libhfs/apple.h", "rank": 32, "score": 45758.10966192414 }, { "content": "#define IDC_ADDFILES_INCLUDE_SUBFOLDERS 1180\n", "file_path": "app/resource.h", "rank": 33, "score": 45757.50567782844 }, { "content": "#define IDS_NLIST_DATA_FAILED 2149\n", "file_path": "app/resource.h", "rank": 34, "score": 45753.694970172844 }, { "content": "#define FAIL_BAD gSuppressError = false;\n\n\n\n\n", "file_path": "nufxlib/samples/TestBasic.c", "rank": 35, "score": 45753.694970172844 }, { "content": "#define IDS_DEFILE_OPEN_FAILED 2049\n", "file_path": "app/resource.h", "rank": 36, "score": 45753.694970172844 }, { "content": "#define IDS_DEFILE_FIND_FAILED 2047\n", "file_path": "app/resource.h", "rank": 37, "score": 45753.694970172844 }, { "content": "#define FAIL_OK gSuppressError = true;\n", "file_path": "nufxlib/samples/TestBasic.c", "rank": 38, "score": 45753.694970172844 }, { "content": "static NuError Nu_ResetUsedFlags(NuArchive* pArchive, NuRecordSet* pRecordSet)\n\n{\n\n NuError err = kNuErrNone;\n\n NuRecord* pRecord;\n\n\n\n pRecord = Nu_RecordSet_GetListHead(pRecordSet);\n\n while (pRecord != NULL) {\n\n err = Nu_RecordResetUsedFlags(pArchive, pRecord);\n\n if (err != kNuErrNone) {\n\n Assert(0);\n\n break;\n\n }\n\n\n\n pRecord = pRecord->pNext;\n\n }\n\n\n\n return err;\n", "file_path": "nufxlib/Deferred.c", "rank": 39, "score": 45751.84154784641 }, { "content": " BOOLEAN UseDiskDump;\n", "file_path": "diskimg/CP_ntddscsi.h", "rank": 40, "score": 45745.67086937868 }, { "content": "#define kFlagUseTmp (1 << 4)\n\n\n\n\n", "file_path": "nufxlib/samples/Launder.c", "rank": 41, "score": 45745.67086937868 }, { "content": "#define IDH_USE_ALL 1193\n", "file_path": "app/Help/PopUpIds.h", "rank": 42, "score": 45745.67086937868 }, { "content": " BOOLEAN AdapterUsesPio;\n", "file_path": "diskimg/CP_ntddscsi.h", "rank": 43, "score": 45745.67086937868 }, { "content": "NuError Nu_HeaderIOFailed(NuArchive* pArchive, FILE* fp)\n\n{\n\n if (feof(fp) || ferror(fp))\n\n return kNuErrFile;\n\n else\n\n return kNuErrNone;\n", "file_path": "nufxlib/ArchiveIO.c", "rank": 44, "score": 44207.83604868612 }, { "content": "static NuError Nu_RecordResetUsedFlags(NuArchive* pArchive, NuRecord* pRecord)\n\n{\n\n NuThread* pThread;\n\n long idx;\n\n\n\n Assert(pArchive != NULL);\n\n Assert(pRecord != NULL);\n\n\n\n /* these should already be clear */\n\n if (pRecord->pThreadMods) {\n\n Assert(0);\n\n return kNuErrInternal;\n\n }\n\n\n\n /* these might still be set */\n\n for (idx = 0; idx < (long)pRecord->recTotalThreads; idx++) {\n\n pThread = Nu_GetThread(pRecord, idx);\n\n Assert(pThread != NULL);\n\n\n\n pThread->used = false;\n\n }\n\n\n\n /* and this */\n\n pRecord->dirtyHeader = false;\n\n\n\n return kNuErrNone;\n", "file_path": "nufxlib/Deferred.c", "rank": 45, "score": 44205.5734005915 }, { "content": "#define IDH_CASSIMPTARG_INT 1422\n", "file_path": "app/Help/PopUpIds.h", "rank": 46, "score": 44201.11622477282 }, { "content": "#define IDH_USE_SELECTED 1192\n", "file_path": "app/Help/PopUpIds.h", "rank": 47, "score": 44200.08305447269 }, { "content": "#define IDH_ADDFILES_INCLUDE_SUBFOLDERS 1180\n", "file_path": "app/Help/PopUpIds.h", "rank": 48, "score": 42766.5832459142 }, { "content": "NuError Nu_HeaderIOFailed(NuArchive* pArchive, FILE* fp);\n", "file_path": "nufxlib/NufxLibPriv.h", "rank": 49, "score": 42763.021623754845 }, { "content": "class RecompressOptionsDialog : public UseSelectionDialog {\n\npublic:\n\n RecompressOptionsDialog(int selCount, CWnd* pParentWnd = NULL) :\n\n UseSelectionDialog(selCount, pParentWnd, IDD_RECOMPRESS_OPTS)\n\n {\n\n fCompressionType = 0;\n\n }\n\n virtual ~RecompressOptionsDialog(void) {}\n\n\n\n // maps directly to NuThreadFormat enum\n\n int fCompressionType;\n\n\n\nprivate:\n\n virtual BOOL OnInitDialog(void) override;\n\n virtual void DoDataExchange(CDataExchange* pDX) override;\n\n\n\n /*\n\n * Load strings into the combo box. Only load formats supported by the\n\n * NufxLib DLL.\n\n *\n", "file_path": "app/RecompressOptionsDialog.h", "rank": 50, "score": 42755.52201534079 }, { "content": "class ConvFileOptionsDialog : public UseSelectionDialog {\n\npublic:\n\n ConvFileOptionsDialog(int selCount, CWnd* pParentWnd = NULL) :\n\n UseSelectionDialog(selCount, pParentWnd, IDD_CONVFILE_OPTS)\n\n {\n\n fPreserveEmptyFolders = FALSE;\n\n }\n\n virtual ~ConvFileOptionsDialog(void) {}\n\n\n\n //BOOL fConvDOSText;\n\n //BOOL fConvPascalText;\n\n BOOL fPreserveEmptyFolders;\n\n\n\nprivate:\n\n virtual void DoDataExchange(CDataExchange* pDX) override;\n\n\n\n //DECLARE_MESSAGE_MAP()\n\n};\n\n\n\n#endif /*APP_CONFFILEOPTIONSDIALOG_H*/\n", "file_path": "app/ConvFileOptionsDialog.h", "rank": 51, "score": 40132.2897421687 }, { "content": "class ConvDiskOptionsDialog : public UseSelectionDialog {\n\npublic:\n\n ConvDiskOptionsDialog(int selCount, CWnd* pParentWnd = NULL) :\n\n UseSelectionDialog(selCount, pParentWnd, IDD_CONVDISK_OPTS)\n\n {\n\n fDiskSizeIdx = 0;\n\n //fAllowLower = fSparseAlloc = FALSE;\n\n fVolName = L\"NEW.DISK\";\n\n fNumBlocks = -1;\n\n }\n\n virtual ~ConvDiskOptionsDialog(void) {}\n\n\n\n int fDiskSizeIdx;\n\n //BOOL fAllowLower;\n\n //BOOL fSparseAlloc;\n\n CString fVolName;\n\n\n\n long fNumBlocks; // computed when DoModal finishes\n\n\n\nprivate:\n", "file_path": "app/ConvDiskOptionsDialog.h", "rank": 52, "score": 40132.2897421687 }, { "content": "private:\n\n /*\n\n * Load the specified DiskFS into the tree, recursively adding any\n\n * sub-volumes. Pass in an initial depth of 1.\n\n *\n\n * Returns true on success.\n\n */\n\n bool AddDiskFS(CTreeCtrl* pTree, HTREEITEM root,\n\n DiskImgLib::DiskFS* pDiskFS, int depth);\n\n\n\n /*\n\n * Add the subdir and all of the subdirectories of the current subdir.\n\n *\n\n * The files are held in a linear list in the DiskFS, so we have to\n\n * reconstruct the hierarchy from the path names. Pass in NULL for the\n\n * root volume.\n\n *\n\n * Returns a pointer to the next A2File in the list (i.e. the first one\n\n * that we couldn't digest). This assumes that the contents of a\n\n * subdirectory are grouped together in the linear list, so that we can\n", "file_path": "app/DiskFSTree.h", "rank": 57, "score": 36.544556779242974 }, { "content": " * in. If the fssep is '\\0' (as is the case for DOS 3.3), then the entire\n\n * pathname is returned.\n\n *\n\n * Always returns a pointer to a string; never returns NULL.\n\n */\n\n static const WCHAR* FilenameOnly(const WCHAR* pathname, WCHAR fssep);\n\n\n\n /*\n\n * Test to see if a wide-to-narrow filename conversion failed.\n\n *\n\n * Returns true if all is well, false with *pErrMsg set if something\n\n * went wrong.\n\n */\n\n static bool TestNarrowConversion(const CString& original,\n\n const CStringA& converted, CString* pErrMsg) {\n\n int index = converted.ReverseFind('?');\n\n if (index < 0) {\n\n // no '?' is good\n\n } else if (index == 2 && converted.Left(4) == \"\\\\\\\\?\\\\\") {\n\n // Win32 file namespace path strings start with \"\\\\?\\\". If that's\n", "file_path": "util/PathName.h", "rank": 59, "score": 35.16528685719828 }, { "content": " pListView->InsertItem(itemIndex, driveName);\n\n pListView->SetItemText(itemIndex, 1, remark);\n\n pListView->SetItemData(itemIndex, aspiAddr);\n\n itemIndex++;\n\n }\n\n }\n\n\n\n delete[] deviceArray;\n\n#endif\n\n }\n\n\n\n *pItemIndex = itemIndex;\n\n return true;\n\n}\n\n\n\nbool OpenVolumeDialog::HasPhysicalDriveWin9x(int unit, CString* pRemark)\n\n{\n\n HANDLE handle = NULL;\n\n const int VWIN32_DIOC_DOS_INT13 = 4;\n\n const int CARRY_FLAG = 1;\n", "file_path": "app/OpenVolumeDialog.cpp", "rank": 61, "score": 31.19040539420343 }, { "content": " return false;\n\n name++;\n\n }\n\n\n\n return true;\n\n}\n\n\n\n/*\n\n * Return \"true\" if \"name\" is valid for use as an HFS file name.\n\n */\n\n/*static*/ bool DiskFSHFS::IsValidFileName(const char* name)\n\n{\n\n if (name == NULL)\n\n return false;\n\n\n\n int len = strlen(name);\n\n if (len < 1 || len > A2FileHFS::kMaxFileName)\n\n return false;\n\n\n\n while (*name != '\\0') {\n", "file_path": "diskimg/HFS.cpp", "rank": 62, "score": 30.995069764701668 }, { "content": " return dierr;\n\n\n\n return kDIErrNone;\n\n}\n\n\n\n/*\n\n * Get the state of an entry in the block use map.\n\n *\n\n * Returns \"true\" if it's in use, \"false\" otherwise.\n\n */\n\nbool DiskFSProDOS::GetBlockUseEntry(long block) const\n\n{\n\n assert(block >= 0 && block < fTotalBlocks);\n\n assert(fBlockUseMap != NULL);\n\n\n\n int offset;\n\n uint8_t mask;\n\n\n\n offset = block / 8;\n\n mask = 0x80 >> (block & 0x07);\n", "file_path": "diskimg/ProDOS.cpp", "rank": 64, "score": 30.35034892613418 }, { "content": " uint8_t mask;\n\n\n\n offset = block / 8;\n\n mask = 0x80 >> (block & 0x07);\n\n if (!inUse)\n\n fBlockUseMap[offset] |= mask;\n\n else\n\n fBlockUseMap[offset] &= ~mask;\n\n}\n\n\n\n/*\n\n * Check for entries in the block use map past the point where they should be.\n\n *\n\n * Returns \"true\" if bogus entries were found, \"false\" if all is well.\n\n */\n\nbool DiskFSProDOS::ScanForExtraEntries(void) const\n\n{\n\n assert(fBlockUseMap != NULL);\n\n\n\n int offset, endOffset;\n", "file_path": "diskimg/ProDOS.cpp", "rank": 65, "score": 29.95141267827531 }, { "content": " */\n\nbool DiskImg::CheckForBadBlocks(long startBlock, int numBlocks)\n\n{\n\n int i;\n\n\n\n if (fpBadBlockMap == NULL)\n\n return false;\n\n\n\n for (i = startBlock; i < startBlock+numBlocks; i++) {\n\n if (fpBadBlockMap->IsSet(i))\n\n return true;\n\n }\n\n return false;\n\n}\n\n\n\n/*\n\n * Write a block of data to a DiskImg.\n\n *\n\n * Returns immediately when a block write fails. Does not try to write all\n\n * blocks before returning failure.\n", "file_path": "diskimg/DiskImg.cpp", "rank": 66, "score": 29.27121765010991 }, { "content": " * Handle a bulk extraction.\n\n */\n\n void DoBulkExtract(SelectionSet* pSelSet,\n\n const ExtractOptionsDialog* pExtOpts);\n\n\n\n /*\n\n * Extract a single entry.\n\n *\n\n * If pHolder is non-NULL, it holds the data from the file, and can be\n\n * used for formatted or non-formatted output. If it's NULL, we need to\n\n * extract the data ourselves.\n\n *\n\n * Returns true on success, false on failure.\n\n */\n\n bool ExtractEntry(GenericEntry* pEntry, int thread,\n\n ReformatHolder* pHolder, const ExtractOptionsDialog* pExtOpts,\n\n bool* pOverwriteExisting, bool* pOvwrForAll);\n\n\n\n /*\n\n * Open an output file.\n", "file_path": "app/Main.h", "rank": 67, "score": 28.687712474187844 }, { "content": " for (int i = 0; i < argc; i++) {\n\n LOGI(\" %d '%ls'\", i, argv[i]);\n\n }\n\n\n\n /*\n\n * Figure out what the arguments are.\n\n */\n\n const WCHAR* filename = NULL;\n\n const WCHAR* dispName = NULL;\n\n FilterIndex filterIndex = kFilterIndexGeneric;\n\n bool temp = false;\n\n\n\n for (int i = 1; i < argc; i++) {\n\n if (argv[i][0] == '-') {\n\n if (wcsicmp(argv[i], L\"-mode\") == 0) {\n\n if (i == argc-1) {\n\n LOGI(\"WARNING: -mode specified without mode\");\n\n } else\n\n i++;\n\n if (wcsicmp(argv[i], kModeNuFX) == 0)\n", "file_path": "app/Main.cpp", "rank": 68, "score": 28.5662385231819 }, { "content": " CDialog::OnInitDialog();\n\n\n\n CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_ADD_TARGET_TREE);\n\n\n\n ASSERT(fpDiskFS != NULL);\n\n ASSERT(pTree != NULL);\n\n\n\n fDiskFSTree.fIncludeSubdirs = true;\n\n fDiskFSTree.fExpandDepth = -1;\n\n if (!fDiskFSTree.BuildTree(fpDiskFS, pTree)) {\n\n LOGI(\"Tree load failed!\");\n\n OnCancel();\n\n }\n\n\n\n int count = pTree->GetCount();\n\n LOGI(\"ChooseAddTargetDialog tree has %d items\", count);\n\n if (count <= 1) {\n\n LOGI(\" Skipping out of target selection\");\n\n // adding to root volume of the sole DiskFS\n\n fpChosenDiskFS = fpDiskFS;\n", "file_path": "app/ChooseAddTargetDialog.cpp", "rank": 69, "score": 27.819130649825468 }, { "content": " return cp1;\n\n if (towlower(*cp1a) != towlower(*cp2))\n\n break;\n\n }\n\n }\n\n }\n\n }\n\n return NULL;\n\n}\n\n\n\nvoid VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc)\n\n{\n\n bool inWhiteSpace = true;\n\n bool inQuote = false;\n\n WCHAR* cp = mangle;\n\n int idx = 0;\n\n\n\n while (*cp != '\\0') {\n\n ASSERT(!inWhiteSpace || !inQuote);\n\n if (!inQuote && (*cp == ' ' || *cp == '\\t')) {\n", "file_path": "util/Util.cpp", "rank": 70, "score": 27.546933435272386 }, { "content": " * hfslib functions convert to time_t for us.\n\n */\n\n fCreateWhen = dirEntry->crdate;\n\n fModWhen = dirEntry->mddate;\n\n}\n\n\n\n/*\n\n * Return \"true\" if \"name\" is valid for use as an HFS volume name.\n\n */\n\n/*static*/ bool DiskFSHFS::IsValidVolumeName(const char* name)\n\n{\n\n if (name == NULL)\n\n return false;\n\n\n\n int len = strlen(name);\n\n if (len < 1 || len > kMaxVolumeName)\n\n return false;\n\n\n\n while (*name != '\\0') {\n\n if (*name == A2FileHFS::kFssep)\n", "file_path": "diskimg/HFS.cpp", "rank": 71, "score": 27.301039403843234 }, { "content": " int len;\n\n int result = -1;\n\n\n\n ASSERT(dirName != NULL);\n\n ASSERT(pErrMsg != NULL);\n\n\n\n LOGI(\"+++ DESCEND: '%ls'\", (LPCWSTR) dirName);\n\n\n\n dirp = OpenDir(dirName);\n\n if (dirp == NULL) {\n\n pErrMsg->Format(L\"Failed on '%ls': %hs\", dirName, strerror(errno));\n\n goto bail;\n\n }\n\n\n\n fssep = kLocalFssep;\n\n\n\n /* could use readdir_r, but we don't care about reentrancy here */\n\n while ((entry = ReadDir(dirp)) != NULL) {\n\n /* skip the dotsies */\n\n if (wcscmp(entry->d_name, L\".\") == 0 || wcscmp(entry->d_name, L\"..\") == 0)\n", "file_path": "mdc/Main.cpp", "rank": 73, "score": 26.77142362772284 }, { "content": "\n\n\n\n/*\n\n * Convert a track encoded as one or more pulse streams to nibbles.\n\n *\n\n * This decompresses the pulse streams in \"inputBuf\", then converts them\n\n * to nibble form in \"nibbleBuf\".\n\n *\n\n * \"*pNibbleLen\" should hold the maximum size of the buffer. On success,\n\n * it will hold the actual number of bytes used.\n\n *\n\n * Returns \"true\" on success, \"false\" on failure.\n\n */\n\nbool WrapperFDI::DecodePulseTrack(const uint8_t* inputBuf, long inputLen,\n\n int bitRate, uint8_t* nibbleBuf, long* pNibbleLen)\n\n{\n\n const int kSizeValueMask = 0x003fffff;\n\n const int kSizeCompressMask = 0x00c00000;\n\n const int kSizeCompressShift = 22;\n\n PulseIndexHeader hdr;\n", "file_path": "diskimg/FDI.cpp", "rank": 74, "score": 26.40661564097852 }, { "content": " if (fBlockUseMap[offset] & mask)\n\n return false;\n\n else\n\n return true;\n\n}\n\n\n\n/*\n\n * Change the state of an entry in the block use map.\n\n */\n\nvoid DiskFSProDOS::SetBlockUseEntry(long block, bool inUse)\n\n{\n\n assert(block >= 0 && block < fTotalBlocks);\n\n assert(fBlockUseMap != NULL);\n\n\n\n if (block == 0 && !inUse) {\n\n // shouldn't happen\n\n assert(false);\n\n }\n\n\n\n int offset;\n", "file_path": "diskimg/ProDOS.cpp", "rank": 75, "score": 26.38585511008108 }, { "content": "#include <stdio.h>\n\n#include <string.h>\n\n#include <unistd.h>\n\n#include <assert.h>\n\n#include \"../diskimg/DiskImg.h\"\n\n#include \"../nufxlib/NufxLib.h\"\n\n\n\nusing namespace DiskImgLib;\n\n\n\n#define nil NULL\n\n#define NELEM(x) (sizeof(x) / sizeof((x)[0]))\n\n\n\nFILE* gLog = nil;\n\npid_t gPid = getpid();\n\n\n\nconst int kTrackLen = 4096;\n\nconst int kNumSymbols = 256;\n\nconst int kNumFavorites = 20;\n\nconst int kRLEDelim = 0x97; // value MUST have high bit set\n\nconst int kNumTracks = 35;\n\n\n\n/* I suspect this is random garbage, but it's consistent for me */\n\nconst unsigned long kDDDProSignature = 0xd0bfc903;\n\n\n\n\n\n/*\n\n * Class for getting and putting bits to and from a file.\n\n */\n", "file_path": "linux/PackDDD.cpp", "rank": 76, "score": 26.37596194477581 }, { "content": "}\n\n\n\n/*\n\n * Convert the EOL markers in a buffer. The output is written to the work\n\n * buffer. The input buffer may be CR, LF, or CRLF.\n\n *\n\n * If \"stripHiBits\" is set, the high bit of each character is cleared before\n\n * the value is considered.\n\n *2\n\n * If \"stripNulls\" is true, no null values will make it through.\n\n */\n\nvoid ReformatText::ConvertEOL(const uint8_t* srcBuf, long srcLen,\n\n bool stripHiBits, bool stripNulls)\n\n{\n\n uint8_t ch;\n\n int mask;\n\n\n\n assert(!fUseRTF); // else we have to use RTFPrintChar\n\n\n\n if (stripHiBits)\n", "file_path": "reformat/ReformatBase.cpp", "rank": 77, "score": 26.04473852276724 }, { "content": " *\n\n * Returns 0 if there's no data, which can only happen if \"remLen\" is zero\n\n * (i.e. we hit EOF).\n\n */\n\n/*static*/ int NiftyList::ScanLine(const char* pData, long remLen)\n\n{\n\n bool atEOL = false;\n\n int lineLen = 0;\n\n\n\n while (remLen--) {\n\n if (*pData == '\\r' || *pData == '\\n')\n\n atEOL = true;\n\n else if (atEOL)\n\n break;\n\n pData++;\n\n lineLen++;\n\n }\n\n\n\n return lineLen;\n\n}\n", "file_path": "reformat/NiftyList.cpp", "rank": 78, "score": 25.79775838643139 }, { "content": "\n\n GenericArchive* CreateArchiveInstance(FilterIndex filterIndex) const;\n\n\n\n /*\n\n * Load an archive, using the appropriate GenericArchive subclass.\n\n *\n\n * \"filename\" is the full path to the file, \"extension\" is the\n\n * filetype component of the name (without the leading '.'), \"filterIndex\"\n\n * is the offset into the set of filename filters used in the standard\n\n * file dialog, and \"readOnly\" reflects the state of the stdfile dialog\n\n * checkbox.\n\n *\n\n * Returns 0 on success, nonzero on failure.\n\n */\n\n int LoadArchive(const WCHAR* filename, const WCHAR* extension,\n\n FilterIndex filterIndex, bool readOnly);\n\n\n\n /*\n\n * Open a raw disk volume. Useful for ProDOS-formatted 1.44MB floppy disks\n\n * and CFFA flash cards.\n", "file_path": "app/Main.h", "rank": 79, "score": 25.111734041290212 }, { "content": "}\n\n\n\nGenericArchive* MainWindow::CreateArchiveInstance(FilterIndex filterIndex) const\n\n{\n\n GenericArchive* pOpenArchive = NULL;\n\n\n\n switch (filterIndex) {\n\n case kFilterIndexNuFX: pOpenArchive = new NufxArchive; break;\n\n case kFilterIndexBinaryII: pOpenArchive = new BnyArchive; break;\n\n case kFilterIndexACU: pOpenArchive = new AcuArchive; break;\n\n case kFilterIndexAppleSingle: pOpenArchive = new AppleSingleArchive; break;\n\n case kFilterIndexDiskImage: pOpenArchive = new DiskArchive; break;\n\n default: ASSERT(false); break;\n\n }\n\n\n\n return pOpenArchive;\n\n}\n\n\n\nint MainWindow::LoadArchive(const WCHAR* fileName, const WCHAR* extension,\n\n FilterIndex filterIndex, bool readOnly)\n", "file_path": "app/Main.cpp", "rank": 80, "score": 25.066848460667103 }, { "content": " long fEndSample;\n\n unsigned char fChecksum;\n\n bool fChecksumGood;\n\n };\n\n\n\n /*\n\n * Analyze the contents of a WAV file.\n\n *\n\n * Returns true if it found anything at all, false if not.\n\n */\n\n bool AnalyzeWAV(void);\n\n\n\n /*\n\n * Add an entry to the list.\n\n *\n\n * Layout: index format length checksum start-offset\n\n */\n\n void AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType);\n\n\n\n enum {\n", "file_path": "app/CassetteDialog.h", "rank": 81, "score": 24.873579721840038 }, { "content": " // Return true on success, false if something failed and we want to keep\n\n // the dialog open.\n\n virtual bool MyDataExchange(bool saveAndValidate) { return true; }\n\n\n\n // Handles a click on the \"help\" button.\n\n virtual void HandleHelp() {}\n\n\n\nprivate:\n\n DECLARE_COPY_AND_OPEQ(SelectFilesDialog)\n\n\n\n /*\n\n * Finishes configuring the file dialog.\n\n */\n\n virtual void OnInitDone() override;\n\n\n\n /*\n\n * Tracks changes to the current directory.\n\n *\n\n * Updates fCurrentDirectory with the path currently being used by the\n\n * dialog. For items with no path (e.g. Computer or Libraries), this\n", "file_path": "util/SelectFilesDialog.h", "rank": 82, "score": 24.790773285697263 }, { "content": " result = OwnExtension(ext, kFileTypeAssoc[idx].progId);\n\n } else {\n\n LOGI(\" SetFileAssoc: do nothing with '%ls'\", ext);\n\n /* do nothing */\n\n }\n\n\n\n return 0;\n\n}\n\n\n\nbool MyRegistry::GetAssocState(const WCHAR* ext) const\n\n{\n\n WCHAR buf[260];\n\n HKEY hExtKey = NULL;\n\n int res;\n\n bool result = false;\n\n\n\n HKEY hClassesKey = NULL;\n\n if (OpenHKCUSoftwareClasses(&hClassesKey) != ERROR_SUCCESS) {\n\n LOGW(\"GetAssocState failed to open HKCU\");\n\n return result;\n", "file_path": "app/Registry.cpp", "rank": 83, "score": 24.778233601873215 }, { "content": " // set/get individual pixel values; the \"RGB\" functions always set\n\n // alpha to zero, while \"RGBA\" follow the current alpha mode\n\n\n\n void FASTCALL GetPixelRGB(int x, int y, RGBQUAD* pRgbQuad) const;\n\n void FASTCALL SetPixelRGB(int x, int y, const RGBQUAD* pRgbQuad);\n\n void FASTCALL GetPixelRGBA(int x, int y, RGBQUAD* pRgbQuad) const;\n\n void FASTCALL SetPixelRGBA(int x, int y, const RGBQUAD* pRgbQuad);\n\n void FASTCALL GetPixelIndex(int x, int y, int* pIdx) const;\n\n void FASTCALL SetPixelIndex(int x, int y, int idx);\n\n\n\n // Return a pointer to the raw pixel storage.\n\n void* GetPixelBuf(void) const { return mpPixels; }\n\n\n\n // Return the DIB handle; keep in mind that this HBITMAP is different\n\n // from a DDB HBITMAP, and many calls that take an HBITMAP will fail.\n\n HBITMAP GetHandle(void) {\n\n if (mhBitmap == NULL && mpFileBuffer != NULL)\n\n ConvertBufToDIBSection();\n\n return mhBitmap;\n\n }\n", "file_path": "util/MyDIBitmap.h", "rank": 84, "score": 24.69481255218193 }, { "content": "static int Nu_SQCmpTrees(SQState* pSqState, int a, int b)\n\n{\n\n if (pSqState->node[a].weight > pSqState->node[b].weight)\n\n return true;\n\n if (pSqState->node[a].weight == pSqState->node[b].weight)\n\n if (pSqState->node[a].tdepth > pSqState->node[b].tdepth)\n\n return true;\n\n return false;\n", "file_path": "nufxlib/Squeeze.c", "rank": 85, "score": 24.50415930815239 }, { "content": " /* pointer to directory entry (update dir if file size or dates change) */\n\n uint16_t fParentDirBlock; // directory block\n\n int fParentDirIdx; // index in dir block\n\n\n\n /* these are only valid if storageType == kStorageExtended */\n\n ExtendedInfo fExtData;\n\n ExtendedInfo fExtRsrc;\n\n\n\n void SetPathName(const char* basePath, const char* fileName);\n\n static time_t ConvertProDate(ProDate proDate);\n\n static ProDate ConvertProDate(time_t unixDate);\n\n\n\n /* returns \"true\" if AppleWorks aux type is used for lower-case name */\n\n static bool UsesAppleWorksAuxType(uint8_t fileType) {\n\n return (fileType >= 0x19 && fileType <= 0x1b);\n\n }\n\n\n\n#if 0\n\n /* change fPathName; should only be used by DiskFS rename */\n\n void SetPathName(const char* name) {\n", "file_path": "diskimg/DiskImgDetail.h", "rank": 86, "score": 24.40720651469844 }, { "content": " bool isWin9x = IsWin9x();\n\n int itemIndex = *pItemIndex;\n\n\n\n ASSERT(pListView != NULL);\n\n\n\n drivesAvailable = GetLogicalDrives();\n\n if (drivesAvailable == 0) {\n\n LOGI(\"GetLogicalDrives failed, err=0x%08lx\", drivesAvailable);\n\n return false;\n\n }\n\n LOGI(\"GetLogicalDrives returned 0x%08lx\", drivesAvailable);\n\n\n\n // SetErrorMode(SEM_FAILCRITICALERRORS)\n\n\n\n /* run through the list, from A-Z */\n\n int i;\n\n for (i = 0; i < kMaxLogicalDrives; i++) {\n\n fVolumeInfo[i].driveType = DRIVE_UNKNOWN;\n\n\n\n if ((drivesAvailable >> i) & 0x01) {\n", "file_path": "app/OpenVolumeDialog.cpp", "rank": 87, "score": 24.40322304959824 }, { "content": " WCHAR driveName[] = L\"_:\\\\\";\n\n driveName[0] = 'A' + i;\n\n\n\n unsigned int driveType;\n\n const WCHAR* driveTypeComment = NULL;\n\n BOOL result;\n\n\n\n driveType = fVolumeInfo[i].driveType = GetDriveType(driveName);\n\n switch (driveType) {\n\n case DRIVE_UNKNOWN:\n\n // The drive type cannot be determined.\n\n break;\n\n case DRIVE_NO_ROOT_DIR:\n\n // The root path is invalid. For example, no volume is mounted at the path.\n\n break;\n\n case DRIVE_REMOVABLE:\n\n // The disk can be removed from the drive.\n\n driveTypeComment = L\"Removable\";\n\n break;\n\n case DRIVE_FIXED:\n", "file_path": "app/OpenVolumeDialog.cpp", "rank": 88, "score": 24.38022447633507 }, { "content": " ASSERT(pOutput->GetTextBuf() != NULL);\n\n int err = 0;\n\n if (fwrite(pOutput->GetTextBuf(),\n\n pOutput->GetTextLen(), 1, fp) != 1)\n\n err = errno;\n\n if (err != 0) {\n\n errMsg.Format(L\"Unable to save reformatted file '%ls': %hs\\n\",\n\n (LPCWSTR) outputPath, strerror(err));\n\n fpActionProgress->MessageBox(errMsg, failed,\n\n MB_OK | MB_ICONERROR);\n\n writeFailed = true;\n\n } else {\n\n SET_PROGRESS_UPDATE(100);\n\n }\n\n } else if (pOutput->GetOutputKind() == ReformatOutput::kOutputBitmap) {\n\n LOGI(\" Writing bitmap\");\n\n ASSERT(pOutput->GetDIB() != NULL);\n\n int err = pOutput->GetDIB()->WriteToFile(fp);\n\n if (err != 0) {\n\n errMsg.Format(L\"Unable to save bitmap '%ls': %hs\\n\",\n", "file_path": "app/Actions.cpp", "rank": 89, "score": 24.11423846841045 }, { "content": "{\n\n static const WCHAR kFileArchive[] = L\"This appears to be a file archive.\";\n\n GenericArchive::OpenResult openResult;\n\n const FilterIndex origFilterIndex = filterIndex;\n\n GenericArchive* pOpenArchive = NULL;\n\n\n\n LOGI(\"LoadArchive: '%ls' ro=%d idx=%d\", fileName, readOnly, filterIndex);\n\n\n\n /* close any existing archive to avoid weirdness from re-open */\n\n CloseArchive();\n\n\n\n /*\n\n * If they used the \"All Files (*.*)\" filter, try guess based\n\n * on the file extension.\n\n */\n\n if (filterIndex == kFilterIndexGeneric) {\n\n int i;\n\n\n\n for (i = 0; i < NELEM(gExtensionToIndex); i++) {\n\n if (wcsicmp(extension, gExtensionToIndex[i].extension) == 0) {\n", "file_path": "app/Main.cpp", "rank": 90, "score": 23.968348937684112 }, { "content": "/*\n\n * Make a control larger by the same delta as the parent window.\n\n */\n\nvoid StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY,\n\n bool redraw = true);\n\n\n\n/*\n\n * Stretch and move a control.\n\n */\n\nvoid MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY,\n\n int stretchX, int stretchY, bool redraw = true);\n\n\n\n/*\n\n * Move a control so it maintains its same position relative to the bottom\n\n * and right edges.\n\n */\n\nHDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,\n\n bool redraw = true);\n\n\n\n/*\n", "file_path": "util/Util.h", "rank": 91, "score": 23.927909903494278 }, { "content": "int MyRegistry::DisownExtension(const WCHAR* ext) const\n\n{\n\n ASSERT(ext != NULL);\n\n ASSERT(ext[0] == '.');\n\n if (ext == NULL || wcslen(ext) < 2)\n\n return -1;\n\n\n\n if (RegDeleteKeyHKCU(ext) == ERROR_SUCCESS) {\n\n LOGI(\" HKCU\\\\%ls\\\\%ls subtree deleted\", kFileAssocBase, ext);\n\n } else {\n\n LOGW(\" Failed deleting HKCU\\\\%ls\\\\'%ls'\", kFileAssocBase, ext);\n\n return -1;\n\n }\n\n\n\n return 0;\n\n}\n\n\n\nint MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* progIdKeyName) const\n\n{\n\n ASSERT(ext != NULL);\n", "file_path": "app/Registry.cpp", "rank": 92, "score": 23.719821189194327 }, { "content": "static const char kEmptyFolderMarker[] = \".$$EmptyFolder\";\n\n\n\n\n\n/*\n\n * ===========================================================================\n\n * DiskEntry\n\n * ===========================================================================\n\n */\n\n\n\nint DiskEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,\n\n CString* pErrMsg) const\n\n{\n\n DIError dierr;\n\n A2FileDescr* pOpenFile = NULL;\n\n char* dataBuf = NULL;\n\n bool rsrcFork;\n\n bool needAlloc = true;\n\n int result = -1;\n\n\n\n ASSERT(fpFile != NULL);\n", "file_path": "app/DiskArchive.cpp", "rank": 93, "score": 23.573678797297024 }, { "content": " return;\n\n }\n\n len = pParent->SendMessage(CDM_GETFOLDERIDLIST, len,\n\n (LPARAM) pidlFolder);\n\n ASSERT(len > 0); // should fail earlier, or not at all\n\n\n\n WCHAR buf[MAX_PATH];\n\n BOOL result = SHGetPathFromIDList(pidlFolder, buf);\n\n if (result) {\n\n fCurrentDirectory = buf;\n\n } else {\n\n fCurrentDirectory = L\"\";\n\n }\n\n CoTaskMemFree((LPVOID) pidlFolder);\n\n }\n\n\n\n LOGD(\"OnFolderChange: '%ls'\", (LPCWSTR) fCurrentDirectory);\n\n}\n\n\n\nBOOL SelectFilesDialog::OnFileNameOK()\n", "file_path": "util/SelectFilesDialog.cpp", "rank": 94, "score": 23.44936364765088 }, { "content": "void ShowFailureMsg(CWnd* pWnd, int msgId, int titleStrID);\n\n\n\n\n\n/*\n\n * Returns \"true\" if we're running on Win9x (Win95, Win98, WinME), \"false\"\n\n * if not (could be WinNT/2K/XP or even Win31 with Win32s).\n\n */\n\nbool IsWin9x(void);\n\n\n\n/*\n\n * Wrapper for CString::LoadString that checks the return value and logs a\n\n * complaint if the load fails.\n\n */\n\nvoid CheckedLoadString(CString* pString, UINT nID);\n\n\n\n/*\n\n * ====================================\n\n * Miscellaneous functions\n\n * ====================================\n\n */\n", "file_path": "util/Util.h", "rank": 95, "score": 23.397288660456383 }, { "content": " virtual void PostNcDestroy();\n\n //}}AFX_VIRTUAL\n\n\n\npublic:\n\n BOOL Create(CWnd* pParentWnd = NULL) {\n\n return CDialog::Create(IDD_PROGRESS, pParentWnd);\n\n }\n\n void SetCurrentFile(const WCHAR* fileName);\n\n\n\n// Implementation\n\nprotected:\n\n // Generated message map functions\n\n //{{AFX_MSG(ProgressDlg)\n\n virtual void OnCancel();\n\n //}}AFX_MSG\n\n DECLARE_MESSAGE_MAP()\n\n};\n\n\n\n//{{AFX_INSERT_LOCATION}}\n\n// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\n\n\n\n#endif // !defined(AFX_PROGRESSDLG_H__94B5552B_1337_4FA4_A336_32FA9544ADAC__INCLUDED_)\n", "file_path": "mdc/ProgressDlg.h", "rank": 96, "score": 23.38632512873862 }, { "content": "#define OneStateCount(_val) ((_val) & 0xff)\n\n\n\n/*\n\n * Convert our collection of pulse streams into (what we hope will be)\n\n * Apple II nibble form.\n\n *\n\n * This modifies the contents of the minStream, maxStream, and idxStream\n\n * arrays.\n\n *\n\n * \"*pNibbleLen\" should hold the maximum size of the buffer. On success,\n\n * it will hold the actual number of bytes used.\n\n */\n\nbool WrapperFDI::ConvertPulseStreamsToNibbles(PulseIndexHeader* pHdr, int bitRate,\n\n uint8_t* nibbleBuf, long* pNibbleLen)\n\n{\n\n uint32_t* fakeIdxStream = NULL;\n\n bool result = false;\n\n int i;\n\n\n\n /*\n", "file_path": "diskimg/FDI.cpp", "rank": 97, "score": 23.27449651382105 }, { "content": " dierr = SaveVolBitmap();\n\n FreeVolBitmap();\n\n if (dierr != kDIErrNone)\n\n return dierr;\n\n\n\n return kDIErrNone;\n\n}\n\n\n\n/*\n\n * Get the state of an entry in the VTOC sector use map.\n\n *\n\n * Returns \"true\" if it's in use, \"false\" otherwise.\n\n */\n\nbool DiskFSDOS33::GetSectorUseEntry(long track, int sector) const\n\n{\n\n assert(fVTOCLoaded);\n\n assert(track >= 0 && track < fpImg->GetNumTracks());\n\n assert(sector >= 0 && sector < fpImg->GetNumSectPerTrack());\n\n\n\n uint32_t val, mask;\n", "file_path": "diskimg/DOS33.cpp", "rank": 98, "score": 23.23130831447392 }, { "content": " * Returns a pointer to the pixel storage on success, or NULL on failure.\n\n */\n\n void* Create(int width, int height, int bitsPerPixel, int colorsUsed,\n\n bool dibSection = false);\n\n\n\n /*\n\n * Set the values in the color table.\n\n */\n\n void SetColorTable(const RGBQUAD* pColorTable);\n\n\n\n const RGBQUAD* GetColorTable(void) const { return mpColorTable; }\n\n\n\n /*\n\n * Zero out a bitmap's pixels. Does not touch the color table.\n\n */\n\n void ClearPixels(void);\n\n\n\n /*\n\n * Create a DDB from the current bitmap in the specified DC, and return its\n\n * handle. The returned handle must eventually be disposed with DeleteObject.\n", "file_path": "util/MyDIBitmap.h", "rank": 99, "score": 23.01072730005132 } ]
C++
include/dll/datasets/imagenet.hpp
jw-j/dll
2a72ec0a5c8d52de5565eb5075bc44f078955fca
#pragma once #include <vector> #include <unordered_map> #include <utility> #include <string> #include <dirent.h> #include <opencv2/highgui/highgui.hpp> namespace dll { namespace imagenet { inline void read_files(std::vector<std::pair<size_t, size_t>>& files, std::unordered_map<size_t, float>& label_map, const std::string& file_path){ files.reserve(1200000); struct dirent* entry; auto dir = opendir(file_path.c_str()); while ((entry = readdir(dir))) { std::string file_name(entry->d_name); if (file_name.find("n") != 0) { continue; } std::string label_name(file_name.begin() + 1, file_name.end()); size_t label = std::atoi(label_name.c_str()); auto l = label_map.size(); label_map[label] = l; struct dirent* sub_entry; auto sub_dir = opendir((file_path + "/" + file_name).c_str()); while ((sub_entry = readdir(sub_dir))) { std::string image_name(sub_entry->d_name); if (image_name.find("n") != 0){ continue; } std::string image_number(image_name.begin() + image_name.find('_') + 1, image_name.end() - 5); size_t image = std::atoi(image_number.c_str()); files.emplace_back(label, image); } } } struct image_iterator : std::iterator< std::input_iterator_tag, etl::fast_dyn_matrix<float, 3, 256, 256>, ptrdiff_t, etl::fast_dyn_matrix<float, 3, 256, 256>*, etl::fast_dyn_matrix<float, 3, 256, 256>& > { using value_type = etl::fast_dyn_matrix<float, 3, 256, 256>; std::string imagenet_path; std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files; std::shared_ptr<std::unordered_map<size_t, float>> labels; size_t index; image_iterator(const std::string& imagenet_path, std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files, std::shared_ptr<std::unordered_map<size_t, float>> labels, size_t index) : imagenet_path(imagenet_path), files(files), labels(labels), index(index) { } image_iterator(image_iterator&& rhs) = default; image_iterator(const image_iterator& rhs) = default; image_iterator& operator=(image_iterator&& rhs) = default; image_iterator& operator=(const image_iterator& rhs) = default; image_iterator& operator++(){ ++index; return *this; } image_iterator operator++(int){ cpp_unreachable("Should never be called"); return *this; } value_type operator*() { auto& image_file = (*files)[index]; auto label = std::string("/n") + (image_file.first < 10000000 ? "0" : "") + std::to_string(image_file.first); auto image_path = std::string(imagenet_path) + "/train" + label + label + "_" + std::to_string(image_file.second) + ".JPEG"; auto mat = cv::imread(image_path.c_str(), cv::IMREAD_ANYCOLOR | cv::IMREAD_ANYDEPTH); value_type image; if (!mat.data || mat.empty()) { std::cerr << "ERROR: Failed to read image: " << image_path << std::endl; image = 0; return image; } if (mat.cols != 256 || mat.rows != 256) { std::cerr << "ERROR: Image of invalid size: " << image_path << std::endl; image = 0; return image; } if (cpp_likely(mat.channels() == 3)) { for (size_t x = 0; x < 256; ++x) { for (size_t y = 0; y < 256; ++y) { auto pixel = mat.at<cv::Vec3b>(y, x); image(0, x, y) = pixel.val[0]; image(1, x, y) = pixel.val[1]; image(2, x, y) = pixel.val[2]; } } } else { for (size_t x = 0; x < 256; ++x) { for (size_t y = 0; y < 256; ++y) { image(0, x, y) = mat.at<unsigned char>(y, x); } } image(1) = 0; image(2) = 0; } return image; } bool operator==(const image_iterator& rhs) const { return index == rhs.index; } bool operator!=(const image_iterator& rhs) const { return index != rhs.index; } }; struct label_iterator : std::iterator< std::input_iterator_tag, float, ptrdiff_t, float*, float& > { std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files; std::shared_ptr<std::unordered_map<size_t, float>> labels; size_t index; label_iterator(std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files, std::shared_ptr<std::unordered_map<size_t, float>> labels, size_t index) : files(files), labels(labels), index(index) { } label_iterator(const label_iterator& rhs) = default; label_iterator(label_iterator&& rhs) = default; label_iterator& operator=(const label_iterator& rhs) = default; label_iterator& operator=(label_iterator&& rhs) = default; label_iterator& operator++(){ ++index; return *this; } label_iterator operator++(int){ auto it = *this; ++index; return it; } float operator*() const { return (*labels)[(*files)[index].first]; } bool operator==(const label_iterator& rhs) const { return index == rhs.index; } bool operator!=(const label_iterator& rhs) const { return index != rhs.index; } }; } template<typename... Parameters> auto make_imagenet_dataset(const std::string& folder, Parameters&&... ){ auto train_files = std::make_shared<std::vector<std::pair<size_t, size_t>>>(); auto labels = std::make_shared<std::unordered_map<size_t, float>>(); imagenet::read_files(*train_files, *labels, std::string(folder) + "train"); std::random_device rd; std::default_random_engine engine(rd()); std::shuffle(train_files->begin(), train_files->end(), engine); imagenet::image_iterator iit(folder, train_files, labels, 0); imagenet::image_iterator iend(folder, train_files, labels, train_files->size()); imagenet::label_iterator lit(train_files, labels, 0); imagenet::label_iterator lend(train_files, labels, train_files->size()); return make_dataset_holder( make_generator(iit, iend, lit, lend, train_files->size(), 1000, dll::outmemory_data_generator_desc<Parameters..., dll::categorical>{}), make_generator(iit, iend, lit, lend, train_files->size(), 1000, dll::outmemory_data_generator_desc<Parameters..., dll::categorical>{})); } }
#pragma once #include <vector> #include <unordered_map> #include <utility> #include <string> #include <dirent.h> #include <opencv2/highgui/highgui.hpp> namespace dll { namespace imagenet { inline void read_files(std::vector<std::pair<size_t, size_t>>& files, std::unordered_map<size_t, float>& label_map, const std::string& file_path){ files.reserve(1200000); struct dirent* entry; auto dir = opendir(file_path.c_str()); while ((entry = readdir(dir))) { std::string file_name(entry->d_name); if (file_name.find("n") != 0) { continue; } std::string label_name(file_name.begin() + 1, file_name.end()); size_t label = std::atoi(label_name.c_str()); auto l = label_map.size(); label_map[label] = l; struct dirent* sub_entry; auto sub_dir = opendir((file_path + "/" + file_name).c_str()); while ((sub_entry = readdir(sub_dir))) { std::string image_name(sub_entry->d_name); if (image_name.find("n") != 0){ continue; } std::string image_number(image_name.begin() + image_name.find('_') + 1, image_name.end() - 5); size_t image = std::atoi(image_number.c_str()); files.emplace_back(label, image); } } } struct image_iterator : std::iterator< std::input_iterator_tag, etl::fast_dyn_matrix<float, 3, 256, 256>, ptrdiff_t, etl::fast_dyn_matrix<float, 3, 256, 256>*, etl::fast_dyn_matrix<float, 3, 256, 256>& > { using value_type = etl::fast_dyn_matrix<float, 3, 256, 256>; std::string imagenet_path; std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files; std::shared_ptr<std::unordered_map<size_t, float>> labels; size_t index; image_iterator(const std::string& imagenet_path, std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files, std::shared_ptr<std::unordered_map<size_t, float>> labels, size_t index) : imagenet_path(imagenet_path), files(files), labels(labels), index(index) { } image_iterator(image_iterator&& rhs) = default; image_iterator(const image_iterator& rhs) = default; image_iterator& operator=(image_iterator&& rhs) = default; image_iterator& operator=(const image_iterator& rhs) = default; image_iterator& operator++(){ ++index; return *this; } image_iterator operator++(int){ cpp_unreachable("Should never be called"); return *this; } value_type operator*() { auto& image_file = (*files)[index]; auto label = std::string("/n") + (image_file.first < 10000000 ? "0" : "") + std::to_string(image_file.first); auto image_path = std::string(imagenet_path) + "/train" + label + label + "_" + std::to_string(image_file.second) + ".JPEG"; auto mat = cv::imread(image_path.c_str(), cv::IMREAD_ANYCOLOR | cv::IMREAD_ANYDEPTH); value_type image; if (!mat.data || mat.empty()) { std::cerr << "ERROR: Failed to read image: " << image_path << std::endl; image = 0; return image; } if (mat.cols != 256 || mat.rows != 256) { std::cerr << "ERROR: Image of invalid size: " << image_path << std::endl; image = 0; return image; } if (cpp_likely(mat.channels() == 3)) { for (size_t x = 0; x < 256; ++x) { for (size_t y = 0; y < 256; ++y) { auto pixel = mat.at<cv::Vec3b>(y, x); image(0, x, y) = pixel.val[0]; image(1, x, y) = pixel.val[1]; image(2, x, y) = pixel.val[2]; } } } else { for (size_t x = 0; x < 256; ++x) { for (size_t y = 0; y < 256; ++y) { image(0, x, y) = mat.at<unsigned char>(y, x); } } image(1) = 0; image(2) = 0; } return image; } bool operator==(const image_iterator& rhs) const { return index == rhs.index; } bool operator!=(const image_iterator& rhs) const { return index != rhs.index; } }; struct label_iterator : std::iterator< std::input_iterator_tag, float, ptrdiff_t, float*, float& > { std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files; std::shared_ptr<std::unordered_map<size_t, float>> labels; size_t index; label_iterator(std::shared_ptr<std::vector<std::pair<size_t, size_t>>> files, s
l_iterator&& rhs) = default; label_iterator& operator++(){ ++index; return *this; } label_iterator operator++(int){ auto it = *this; ++index; return it; } float operator*() const { return (*labels)[(*files)[index].first]; } bool operator==(const label_iterator& rhs) const { return index == rhs.index; } bool operator!=(const label_iterator& rhs) const { return index != rhs.index; } }; } template<typename... Parameters> auto make_imagenet_dataset(const std::string& folder, Parameters&&... ){ auto train_files = std::make_shared<std::vector<std::pair<size_t, size_t>>>(); auto labels = std::make_shared<std::unordered_map<size_t, float>>(); imagenet::read_files(*train_files, *labels, std::string(folder) + "train"); std::random_device rd; std::default_random_engine engine(rd()); std::shuffle(train_files->begin(), train_files->end(), engine); imagenet::image_iterator iit(folder, train_files, labels, 0); imagenet::image_iterator iend(folder, train_files, labels, train_files->size()); imagenet::label_iterator lit(train_files, labels, 0); imagenet::label_iterator lend(train_files, labels, train_files->size()); return make_dataset_holder( make_generator(iit, iend, lit, lend, train_files->size(), 1000, dll::outmemory_data_generator_desc<Parameters..., dll::categorical>{}), make_generator(iit, iend, lit, lend, train_files->size(), 1000, dll::outmemory_data_generator_desc<Parameters..., dll::categorical>{})); } }
td::shared_ptr<std::unordered_map<size_t, float>> labels, size_t index) : files(files), labels(labels), index(index) { } label_iterator(const label_iterator& rhs) = default; label_iterator(label_iterator&& rhs) = default; label_iterator& operator=(const label_iterator& rhs) = default; label_iterator& operator=(labe
random
[ { "content": "struct random_crop : value_pair_conf_elt<random_crop_id, size_t, X, Y> {};\n\n\n\n/*!\n\n * \\brief Elastic distortion\n\n */\n\ntemplate <size_t C, size_t K = 9>\n", "file_path": "include/dll/base_conf.hpp", "rank": 0, "score": 284440.7828568713 }, { "content": "struct converter_one<std::vector<T_F, A>, etl::dyn_matrix<T_T, 1>> {\n\n static_assert(std::is_convertible<T_F, T_T>::value, \"DLL cannot convert your value type to the weight type (one)\");\n\n\n\n /*!\n\n * \\brief Convert from the given container into the specific type\n\n * \\param l The layer for which to convert\n\n * \\param from The container to convert from\n\n * \\return the converted result\n\n */\n\n template<typename L>\n\n static etl::dyn_matrix<T_T, 1> convert(const L&, const std::vector<T_F, A>& from){\n\n debug_convert(\"converter::one\");\n\n etl::dyn_matrix<T_T, 1> c;\n\n c = from;\n\n return c;\n\n }\n\n};\n\n\n\n// Convert a list<T_F> to a dyn_vector<T_T>\n\n\n\n/*!\n\n * \\copydoc converter_one\n\n */\n\ntemplate<typename T_F, typename T_T, typename A>\n", "file_path": "include/dll/util/converter.hpp", "rank": 1, "score": 277641.09570838197 }, { "content": "struct fake_label_array {\n\n using value_type = V;\n\n using this_type = fake_label_array<value_type>;\n\n\n\n value_type value;\n\n\n\n fake_label_array(value_type v)\n\n : value(v) {}\n\n\n\n double operator[](size_t i) const {\n\n if (i == value) {\n\n return 1.0;\n\n } else {\n\n return 0.0;\n\n }\n\n }\n\n};\n\n\n\ntemplate <typename Iterator>\n\nstd::vector<fake_label_array<std::remove_cv_t<typename std::iterator_traits<Iterator>::value_type>>> make_fake(Iterator first, Iterator last) {\n", "file_path": "include/dll/util/labels.hpp", "rank": 2, "score": 265176.9558043879 }, { "content": "struct auto_timer {\n\n const char* name; ///< The name of the timer\n\n std::chrono::time_point<std::chrono::steady_clock> start; ///< The start time\n\n std::chrono::time_point<std::chrono::steady_clock> end; ///< The end time\n\n\n\n /*!\n\n * \\brief Create an auto_timer witht the given name\n\n * \\param name The name of the timer\n\n */\n\n auto_timer(const char* name) : name(name) {\n\n start = std::chrono::steady_clock::now();\n\n }\n\n\n\n /*!\n\n * \\brief Destructs the timer, effectively incrementing the timer.\n\n */\n\n ~auto_timer() {\n\n end = std::chrono::steady_clock::now();\n\n auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();\n\n\n", "file_path": "include/dll/util/timers.hpp", "rank": 3, "score": 258686.65767264448 }, { "content": "struct is_generator_impl<T, decltype((void)T::dll_generator, 0)> : std::true_type {};\n\n\n\n/*!\n\n * \\brief Traits to test if a type is DLL generator or not\n\n */\n\ntemplate <typename T>\n\nconstexpr bool is_generator = is_generator_impl<T>::value;\n\n\n\n/*!\n\n * \\brief Helper to tell from the generator description if it is\n\n * augmenting the data\n\n */\n\ntemplate<typename Desc>\n\nconstexpr bool is_augmented =\n\n (Desc::random_crop_x > 0 && Desc::random_crop_y > 0)\n\n || Desc::HorizontalMirroring || Desc::VerticalMirroring || Desc::Noise || Desc::ElasticDistortion;\n\n\n\n/*!\n\n * \\brief Helper to tell from the generator description if it is\n\n * threaded.\n\n */\n\ntemplate<typename Desc>\n\nstatic constexpr bool is_threaded = Desc::Threaded;\n\n\n\n} // end of namespace dll\n\n\n\n#include \"dll/generators/inmemory_data_generator.hpp\"\n\n#include \"dll/generators/outmemory_data_generator.hpp\"\n", "file_path": "include/dll/generators.hpp", "rank": 4, "score": 247894.685443361 }, { "content": "struct converter_one<std::vector<T_F, A>, etl::dyn_matrix<T_T, D>> {\n\n static_assert(std::is_convertible<T_F, T_T>::value, \"DLL cannot convert your value type to the weight type (one)\");\n\n\n\n /*!\n\n * \\brief Convert from the given container into the specific type\n\n * \\param l The layer for which to convert\n\n * \\param from The container to convert from\n\n * \\return the converted result\n\n */\n\n template<typename L>\n\n static etl::dyn_matrix<T_T, D> convert(const L& l, const std::vector<T_F, A>& from){\n\n debug_convert(\"converter::one\");\n\n etl::dyn_matrix<T_T, D> converted;\n\n l.prepare_input(converted);\n\n converted = from;\n\n return converted;\n\n }\n\n};\n\n\n\n// Convert a list<T_F> to a dyn_matrix<T_T, D>\n\n\n\n/*!\n\n * \\copydoc converter_one\n\n */\n\ntemplate<typename T_F, typename T_T, typename A, size_t D>\n", "file_path": "include/dll/util/converter.hpp", "rank": 7, "score": 243676.88061547733 }, { "content": "struct converter_one<std::vector<T_F, A>, etl::fast_dyn_matrix<T_T, Dims...>> {\n\n static_assert(std::is_convertible<T_F, T_T>::value, \"DLL cannot convert your value type to the weight type (one)\");\n\n\n\n /*!\n\n * \\brief Convert from the given container into the specific type\n\n * \\param l The layer for which to convert\n\n * \\param from The container to convert from\n\n * \\return the converted result\n\n */\n\n template<typename L>\n\n static etl::fast_dyn_matrix<T_T, Dims...> convert(const L&, const std::vector<T_F, A>& from){\n\n debug_convert(\"converter::one\");\n\n etl::fast_dyn_matrix<T_T, Dims...> c;\n\n c = from;\n\n return c;\n\n }\n\n};\n\n\n\n// Convert a list<T_F> to a fast_dyn_matrix<T_T, Dims...>\n\n\n\n/*!\n\n * \\copydoc converter_one\n\n */\n\ntemplate<typename T_F, typename T_T, typename A, size_t... Dims>\n", "file_path": "include/dll/util/converter.hpp", "rank": 8, "score": 240473.11091447232 }, { "content": "struct sequence_add <std::index_sequence<I...>, N> {\n\n using type = std::index_sequence<I..., N>;\n\n};\n\n\n\ntemplate <typename T, size_t F, size_t L, typename Acc, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 9, "score": 237429.75926227216 }, { "content": "struct get_value<D> : cpp::auto_constant<D> {};\n\n\n\n/*!\n\n * \\brief Extract the value corresponding to the given configuration element from the parameters.\n\n * \\tparam D The configuration element type\n\n * \\tparam Args The arguments to extract the value from\n\n */\n\ntemplate <typename D, typename... Args>\n\nconstexpr const auto get_value_v = get_value<D, Args...>::value;\n\n\n\n/*!\n\n * \\brief Extract the first value corresponding to the given configuration element from the parameters.\n\n * \\tparam D The configuration element type\n\n * \\tparam Args The arguments to extract the value from\n\n */\n\ntemplate <typename D, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 10, "score": 233489.25109846765 }, { "content": "struct batch_size : value_conf_elt<batch_size_id, size_t, B> {};\n\n\n\n/*!\n\n * \\brief Sets the big batch size.\n\n *\n\n * This is the number of minibatch that the DBN will load at once.\n\n *\n\n * \\tparam B The big batch size\n\n */\n\ntemplate <size_t B>\n", "file_path": "include/dll/base_conf.hpp", "rank": 11, "score": 233183.8541005827 }, { "content": "struct dyn_layers_t <dll::detail::layers<Labels, Layers...>> {\n\n using dyn_t = dll::detail::layers<Labels, typename Layers::desc::dyn_layer_t...>;\n\n};\n\n\n\ntemplate <template <typename> class DBN_T, typename Layers, typename... Parameters>\n", "file_path": "include/dll/dbn_desc.hpp", "rank": 12, "score": 231431.09440118214 }, { "content": "struct validate_weight_type_impl< I, DBN, T, std::enable_if_t<(I == DBN::layers_t::size - 1)> > {\n\n static constexpr bool value = weight_type_same<I, DBN, T>::value;\n\n};\n\n\n\ntemplate <size_t I, typename DBN, typename T>\n", "file_path": "include/dll/dbn_detail.hpp", "rank": 13, "score": 229272.8819218221 }, { "content": "struct validate_weight_type_impl< I, DBN, T, std::enable_if_t<(I < DBN::layers_t::size - 1)> > {\n\n static constexpr bool value = weight_type_same<I, DBN, T>::value && validate_weight_type_impl<I + 1, DBN, T>::value;\n\n};\n\n\n\ntemplate <typename DBN, typename T>\n", "file_path": "include/dll/dbn_detail.hpp", "rank": 14, "score": 229272.8819218221 }, { "content": "struct big_batch_size : value_conf_elt<big_batch_size_id, size_t, B> {};\n\n\n\n/*!\n\n * \\brief Sets the updater type\n\n * \\tparam UT The updater type\n\n */\n\ntemplate <updater_type UT>\n", "file_path": "include/dll/base_conf.hpp", "rank": 15, "score": 228351.4816077628 }, { "content": "struct for_each_impl<D, 1, std::index_sequence<I...>> {\n\n D& dbn;\n\n\n\n for_each_impl(D& dbn)\n\n : dbn(dbn) {}\n\n\n\n template <typename Functor>\n\n void for_each_layer(Functor&& functor) {\n\n functor(dbn.template layer_get<0>());\n\n }\n\n\n\n template <typename Functor>\n\n void for_each_layer_i(Functor&& functor) {\n\n functor(dbn.template layer_get<0>(), 0);\n\n }\n\n\n\n template <typename Functor>\n\n void for_each_layer_pair(Functor&& functor) {\n\n cpp_unused(functor);\n\n // Nothing to do here\n", "file_path": "include/dll/dbn_detail.hpp", "rank": 16, "score": 227608.53908734157 }, { "content": "struct validate_label_layers<L1, L2, Layers...> : cpp::bool_constant_c<\n\n cpp::and_u<\n\n L1::output_size() <= L2::input_size(),\n\n validate_label_layers<L2, Layers...>::value>> {};\n\n\n\n} // end of namespace detail\n\n\n\nnamespace detail {\n\n\n\n/*!\n\n * \\brief A leaf in the list of layers.\n\n */\n\ntemplate <size_t I, typename T>\n", "file_path": "include/dll/dbn_layers.hpp", "rank": 17, "score": 225480.8727049497 }, { "content": "struct build_dyn_layer_t <Layer, Desc, std::index_sequence<I...>, Args...> {\n\n using type = Layer<Desc<cpp::nth_type_t<I, Args...>...>>;\n\n};\n\n\n\ntemplate <typename Index, size_t N>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 18, "score": 224535.92551801988 }, { "content": "struct conditional_constant_v1<false, V1, V2> : cpp::auto_constant<V2> {};\n\n\n\n/*!\n\n * \\brief A conditional constant extracting the member value_2 from V1 or value V2 depending on the condition\n\n * \\tparam C The boolean value\n\n * \\tparam V1 The first value class\n\n * \\tparam V2 The second value class\n\n */\n\ntemplate <bool C, typename V1, typename V2>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 19, "score": 220991.15266661355 }, { "content": "struct conditional_constant_v2<false, V1, V2> : cpp::auto_constant<V2> {};\n\n\n\ntemplate <typename V, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 20, "score": 220991.15266661355 }, { "content": "struct copy : value_conf_elt<copy_id, size_t, C> {};\n\n\n\n/*!\n\n * \\brief Sets the random cropping size\n\n * \\tparam B The minibatch size\n\n */\n\ntemplate <size_t X, size_t Y>\n", "file_path": "include/dll/base_conf.hpp", "rank": 21, "score": 220599.29825140198 }, { "content": "struct noise : value_conf_elt<noise_id, size_t, N> {};\n\n\n\n/*!\n\n * \\brief Sets the prescaling factor\n\n * \\tparam S The scaling factor\n\n */\n\ntemplate <size_t S>\n", "file_path": "include/dll/base_conf.hpp", "rank": 22, "score": 220599.29825140198 }, { "content": "struct sgd_context<DBN, rbm_impl<Desc>, L> {\n\n using layer_t = rbm_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto num_visible = layer_t::num_visible;\n\n static constexpr auto num_hidden = layer_t::num_hidden;\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, num_visible> input;\n\n etl::fast_matrix<weight, batch_size, num_hidden> output;\n\n etl::fast_matrix<weight, batch_size, num_hidden> errors;\n\n\n\n sgd_context(layer_t& /*layer*/)\n\n : output(0.0), errors(0.0) {}\n\n};\n\n\n\n/*!\n\n * \\brief specialization of cg_context for rbm\n\n */\n\ntemplate <typename Desc>\n", "file_path": "include/dll/rbm/rbm_impl.hpp", "rank": 23, "score": 220221.30116069884 }, { "content": "struct binarize_pre : value_conf_elt<binarize_pre_id, size_t, B> {};\n\n\n\n/*!\n\n * \\brief Normalize the inputs\n\n */\n", "file_path": "include/dll/base_conf.hpp", "rank": 24, "score": 214930.15944975824 }, { "content": "struct elastic_distortion : value_conf_elt<elastic_distortion_id, size_t, K> {};\n\n\n\n/*!\n\n * \\brief Sets the noise\n\n * \\tparam N The percent of noise\n\n */\n\ntemplate <size_t N>\n", "file_path": "include/dll/base_conf.hpp", "rank": 25, "score": 214930.15944975824 }, { "content": "struct scale_pre : value_conf_elt<scale_pre_id, size_t, S> {};\n\n\n\n/*!\n\n * \\brief Sets the binarize threshold\n\n * \\tparam B The binarize threshold\n\n */\n\ntemplate <size_t B>\n", "file_path": "include/dll/base_conf.hpp", "rank": 26, "score": 214930.15944975818 }, { "content": "struct sgd_context<DBN, mp_2d_layer_impl<Desc>, L> {\n\n using layer_t = mp_2d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t I1 = layer_t::I1; ///< The input first dimension\n\n static constexpr size_t I2 = layer_t::I2; ///< The input second dimension\n\n static constexpr size_t I3 = layer_t::I3; ///< The input third dimension\n\n\n\n static constexpr size_t O1 = layer_t::O1; ///< The padding first dimension\n\n static constexpr size_t O2 = layer_t::O2; ///< The padding second dimension\n\n static constexpr size_t O3 = layer_t::O3; ///< The padding third dimension\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, I1, I2, I3> input;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> output;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> errors;\n\n\n\n sgd_context(mp_2d_layer_impl<Desc>& /*layer*/){}\n\n};\n\n\n\n/*!\n\n * \\brief Standard max pooling layer (3D pooling)\n\n */\n\ntemplate <typename Desc>\n", "file_path": "include/dll/pooling/mp_layer_impl.hpp", "rank": 27, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, rectifier_layer_impl<Desc>, L> {\n\n using layer_t = rectifier_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/rectifier_layer_impl.hpp", "rank": 28, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, shape_1d_layer_impl<Desc>, L> {\n\n using layer_t = shape_1d_layer_impl<Desc>;\n\n using weight = typename DBN::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, layer_t::Size> input;\n\n etl::fast_matrix<weight, batch_size, layer_t::Size> output;\n\n etl::fast_matrix<weight, batch_size, layer_t::Size> errors;\n\n\n\n sgd_context(const shape_1d_layer_impl<Desc>& /* layer */){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/shape_1d_layer_impl.hpp", "rank": 29, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, normalize_layer_impl<Desc>, L> {\n\n using layer_t = normalize_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/normalize_layer_impl.hpp", "rank": 30, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, dropout_layer_impl<Desc>, L> {\n\n using layer_t = dropout_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dropout_layer_impl.hpp", "rank": 31, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, conv_rbm_impl<Desc>, L> {\n\n using layer_t = conv_rbm_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t NV1 = layer_t::NV1;\n\n static constexpr size_t NV2 = layer_t::NV2;\n\n static constexpr size_t NH1 = layer_t::NH1;\n\n static constexpr size_t NH2 = layer_t::NH2;\n\n static constexpr size_t NW1 = layer_t::NW1;\n\n static constexpr size_t NW2 = layer_t::NW2;\n\n static constexpr size_t NC = layer_t::NC;\n\n static constexpr size_t K = layer_t::K;\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, NC, NV1, NV2> input;\n\n etl::fast_matrix<weight, batch_size, K, NH1, NH2> output;\n\n etl::fast_matrix<weight, batch_size, K, NH1, NH2> errors;\n\n\n\n sgd_context(layer_t& /*layer*/)\n\n : output(0.0), errors(0.0) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/rbm/conv_rbm_impl.hpp", "rank": 32, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, lcn_layer_impl<Desc>, L> {\n\n using layer_t = lcn_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/lcn_layer_impl.hpp", "rank": 33, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, shape_3d_layer_impl<Desc>, L> {\n\n using layer_t = shape_3d_layer_impl<Desc>;\n\n using weight = typename DBN::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, layer_t::C, layer_t::H, layer_t::W> input;\n\n etl::fast_matrix<weight, batch_size, layer_t::C, layer_t::H, layer_t::W> output;\n\n etl::fast_matrix<weight, batch_size, layer_t::C, layer_t::H, layer_t::W> errors;\n\n\n\n sgd_context(const shape_3d_layer_impl<Desc>& /* layer */){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/shape_3d_layer_impl.hpp", "rank": 34, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, dyn_rbm_impl<Desc>, L> {\n\n using layer_t = dyn_rbm_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 2> input;\n\n etl::dyn_matrix<weight, 2> output;\n\n etl::dyn_matrix<weight, 2> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.num_visible, 0.0), output(batch_size, layer.num_hidden, 0.0), errors(batch_size, layer.num_hidden, 0.0) {}\n\n};\n\n\n\n/*!\n\n * \\brief Specialzation of cg_context for dyn_rbm_impl\n\n */\n\ntemplate <typename Desc>\n", "file_path": "include/dll/rbm/dyn_rbm_impl.hpp", "rank": 35, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, mp_3d_layer_impl<Desc>, L> {\n\n using layer_t = mp_3d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t I1 = layer_t::I1; ///< The input first dimension\n\n static constexpr size_t I2 = layer_t::I2; ///< The input second dimension\n\n static constexpr size_t I3 = layer_t::I3; ///< The input third dimension\n\n\n\n static constexpr size_t O1 = layer_t::O1; ///< The padding first dimension\n\n static constexpr size_t O2 = layer_t::O2; ///< The padding second dimension\n\n static constexpr size_t O3 = layer_t::O3; ///< The padding third dimension\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, I1, I2, I3> input;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> output;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> errors;\n\n\n\n sgd_context(mp_3d_layer_impl<Desc>& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/pooling/mp_layer_impl.hpp", "rank": 36, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, deconv_layer_impl<Desc>, L> {\n\n using layer_t = deconv_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t NV1 = layer_t::NV1;\n\n static constexpr size_t NV2 = layer_t::NV2;\n\n static constexpr size_t NH1 = layer_t::NH1;\n\n static constexpr size_t NH2 = layer_t::NH2;\n\n static constexpr size_t NW1 = layer_t::NW1;\n\n static constexpr size_t NW2 = layer_t::NW2;\n\n static constexpr size_t NC = layer_t::NC;\n\n static constexpr size_t K = layer_t::K;\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, NC, NV1, NV2> input;\n\n etl::fast_matrix<weight, batch_size, K, NH1, NH2> output;\n\n etl::fast_matrix<weight, batch_size, K, NH1, NH2> errors;\n\n\n\n sgd_context(layer_t& /* layer */)\n\n : output(0.0), errors(0.0) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/deconv_layer_impl.hpp", "rank": 37, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, conv_layer_impl<Desc>, L> {\n\n using layer_t = conv_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t NV1 = layer_t::NV1;\n\n static constexpr size_t NV2 = layer_t::NV2;\n\n static constexpr size_t NH1 = layer_t::NH1;\n\n static constexpr size_t NH2 = layer_t::NH2;\n\n static constexpr size_t NW1 = layer_t::NW1;\n\n static constexpr size_t NW2 = layer_t::NW2;\n\n static constexpr size_t NC = layer_t::NC;\n\n static constexpr size_t K = layer_t::K;\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, NC, NV1, NV2> input;\n\n etl::fast_matrix<weight, batch_size, K, NH1, NH2> output;\n\n etl::fast_matrix<weight, batch_size, K, NH1, NH2> errors;\n\n\n\n sgd_context(conv_layer_impl<Desc>& /* layer */)\n\n : output(0.0), errors(0.0) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/conv_layer_impl.hpp", "rank": 38, "score": 214554.8044468202 }, { "content": "struct full_sgd_context : sgd_context<DBN, Layer, L> {\n\n using context_type = sgd_context<DBN, Layer, L>; ///< The parent context type\n\n\n\n /*!\n\n * \\brief The updater context\n\n */\n\n updater_context<DBN::updater, decay_layer_traits<Layer>::is_neural_layer(), Layer> up;\n\n\n\n /*!\n\n * \\brief Construct the full_sgd_context for the given layer\n\n */\n\n full_sgd_context(Layer& layer) : context_type(layer), up(layer) {\n\n // Nothing else to init\n\n }\n\n};\n\n\n\n/*!\n\n * \\brief Build the context for a DBN for the given sequence of layers\n\n * \\param dbn The DBN to build the context from\n\n */\n", "file_path": "include/dll/trainer/stochastic_gradient_descent.hpp", "rank": 39, "score": 214554.80444682026 }, { "content": "struct sgd_context<DBN, random_layer_impl<Desc>, L> {\n\n using layer_t = random_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/random_layer_impl.hpp", "rank": 40, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, binarize_layer_impl<Desc>, L> {\n\n using layer_t = binarize_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n/*!\n\n * \\brief Specialization of cg_context for binarize_layer_impl\n\n */\n\ntemplate <typename Desc>\n", "file_path": "include/dll/transform/binarize_layer_impl.hpp", "rank": 41, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, avgp_3d_layer_impl<Desc>, L> {\n\n using layer_t = avgp_3d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t I1 = layer_t::I1; ///< The input first dimension\n\n static constexpr size_t I2 = layer_t::I2; ///< The input second dimension\n\n static constexpr size_t I3 = layer_t::I3; ///< The input third dimension\n\n\n\n static constexpr size_t O1 = layer_t::O1; ///< The padding first dimension\n\n static constexpr size_t O2 = layer_t::O2; ///< The padding second dimension\n\n static constexpr size_t O3 = layer_t::O3; ///< The padding third dimension\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, I1, I2, I3> input;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> output;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> errors;\n\n\n\n sgd_context(avgp_3d_layer_impl<Desc>& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/pooling/avgp_layer_impl.hpp", "rank": 42, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, dense_layer_impl<Desc>, L> {\n\n using layer_t = dense_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto num_visible = layer_t::num_visible;\n\n static constexpr auto num_hidden = layer_t::num_hidden;\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, num_visible> input;\n\n etl::fast_matrix<weight, batch_size, num_hidden> output;\n\n etl::fast_matrix<weight, batch_size, num_hidden> errors;\n\n\n\n sgd_context(const dense_layer_impl<Desc>& /* layer */)\n\n : output(0.0), errors(0.0) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dense_layer_impl.hpp", "rank": 43, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, activation_layer_impl<Desc>, L> {\n\n using layer_t = activation_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/activation_layer_impl.hpp", "rank": 44, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, upsample_3d_layer_impl<Desc>, L> {\n\n using layer_t = upsample_3d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t I1 = layer_t::I1; ///< The input first dimension\n\n static constexpr size_t I2 = layer_t::I2; ///< The input second dimension\n\n static constexpr size_t I3 = layer_t::I3; ///< The input third dimension\n\n\n\n static constexpr size_t O1 = layer_t::O1; ///< The padding first dimension\n\n static constexpr size_t O2 = layer_t::O2; ///< The padding second dimension\n\n static constexpr size_t O3 = layer_t::O3; ///< The padding third dimension\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, I1, I2, I3> input;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> output;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> errors;\n\n\n\n sgd_context(layer_t& /*layer*/) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/pooling/upsample_layer_impl.hpp", "rank": 45, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, avgp_2d_layer_impl<Desc>, L> {\n\n using layer_t = avgp_2d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t I1 = layer_t::I1; ///< The input first dimension\n\n static constexpr size_t I2 = layer_t::I2; ///< The input second dimension\n\n static constexpr size_t I3 = layer_t::I3; ///< The input third dimension\n\n\n\n static constexpr size_t O1 = layer_t::O1; ///< The padding first dimension\n\n static constexpr size_t O2 = layer_t::O2; ///< The padding second dimension\n\n static constexpr size_t O3 = layer_t::O3; ///< The padding third dimension\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, I1, I2, I3> input;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> output;\n\n etl::fast_matrix<weight, batch_size, O1, O2, O3> errors;\n\n\n\n sgd_context(avgp_2d_layer_impl<Desc>& /*layer*/){}\n\n};\n\n\n\n/*!\n\n * \\brief Standard average pooling layer\n\n */\n\ntemplate <typename Desc>\n", "file_path": "include/dll/pooling/avgp_layer_impl.hpp", "rank": 46, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, conv_same_layer_impl<Desc>, L> {\n\n using layer_t = conv_same_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr size_t NV1 = layer_t::NV1;\n\n static constexpr size_t NV2 = layer_t::NV2;\n\n static constexpr size_t NC = layer_t::NC;\n\n static constexpr size_t K = layer_t::K;\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, NC, NV1, NV2> input;\n\n etl::fast_matrix<weight, batch_size, K, NV1, NV2> output;\n\n etl::fast_matrix<weight, batch_size, K, NV1, NV2> errors;\n\n\n\n sgd_context(layer_t& /* layer */)\n\n : output(0.0), errors(0.0) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/conv_same_layer_impl.hpp", "rank": 47, "score": 214554.8044468202 }, { "content": "struct sgd_context<DBN, scale_layer_impl<Desc>, L> {\n\n using layer_t = scale_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/scale_layer_impl.hpp", "rank": 48, "score": 214554.8044468202 }, { "content": "struct label_cache_helper<Desc, T, LIterator, std::enable_if_t<etl::is_1d<typename std::iterator_traits<LIterator>::value_type>>> {\n\n using cache_type = etl::dyn_matrix<T, 2>; ///< The type of the cache\n\n using big_cache_type = etl::dyn_matrix<T, 3>; ///< The type of the big cache\n\n\n\n static constexpr size_t batch_size = Desc::BatchSize; ///< The size of the generated batches\n\n static constexpr size_t big_batch_size = Desc::BigBatchSize; ///< The number of batches kept in cache\n\n\n\n static_assert(!Desc::Categorical, \"Cannot make such vector labels categorical\");\n\n\n\n /*!\n\n * \\brief Init the cache\n\n * \\param n The size of the cache\n\n * \\param n_classes The number of classes\n\n * \\param it An iterator to an element\n\n * \\param cache The cache to initialize\n\n */\n\n static void init(size_t n, size_t n_classes, const LIterator& it, cache_type& cache) {\n\n auto one = *it;\n\n cache = cache_type(n, etl::dim<0>(one));\n\n\n", "file_path": "include/dll/generators/label_cache_helper.hpp", "rank": 49, "score": 214530.6627228975 }, { "content": "struct label_cache_helper<Desc, T, LIterator, std::enable_if_t<etl::is_3d<typename std::iterator_traits<LIterator>::value_type>>> {\n\n using cache_type = etl::dyn_matrix<T, 4>; ///< The type of the cache\n\n using big_cache_type = etl::dyn_matrix<T, 5>; ///< The type of the big cache\n\n\n\n static constexpr size_t batch_size = Desc::BatchSize; ///< The size of the generated batches\n\n static constexpr size_t big_batch_size = Desc::BigBatchSize; ///< The number of batches kept in cache\n\n\n\n static_assert(!Desc::Categorical, \"Cannot make such matrix labels categorical\");\n\n\n\n /*!\n\n * \\brief Init the cache\n\n * \\param n The size of the cache\n\n * \\param n_classes The number of classes\n\n * \\param it An iterator to an element\n\n * \\param cache The cache to initialize\n\n */\n\n static void init(size_t n, size_t n_classes, const LIterator& it, cache_type& cache) {\n\n auto one = *it;\n\n cache = cache_type(n, etl::dim<0>(one), etl::dim<1>(one), etl::dim<2>(one));\n\n\n", "file_path": "include/dll/generators/label_cache_helper.hpp", "rank": 50, "score": 214530.6627228975 }, { "content": "struct label_predictor {\n\n /*!\n\n * \\brief Return the predicted label for the given image using the given DBN\n\n */\n\n template <typename T, typename V>\n\n size_t operator()(T& dbn, V& image) {\n\n return dbn->predict_labels(image, 10);\n\n }\n\n};\n\n\n\ntemplate <typename DBN, typename Functor, typename Samples, typename Labels>\n\ndouble test_set(DBN& dbn, const Samples& images, const Labels& labels, Functor&& f) {\n\n return test_set(dbn, images.begin(), images.end(), labels.begin(), labels.end(), std::forward<Functor>(f));\n\n}\n\n\n\ntemplate <typename DBN, typename Functor, typename Iterator, typename LIterator>\n\ndouble test_set(DBN& dbn, Iterator first, Iterator last, LIterator lfirst, LIterator /*llast*/, Functor&& f) {\n\n size_t success = 0;\n\n size_t images = 0;\n\n\n", "file_path": "include/dll/test.hpp", "rank": 51, "score": 211833.9773784324 }, { "content": "struct timer_t {\n\n const char* name; ///< The name of the timer\n\n std::atomic<size_t> count; ///< The number of times it was incremented\n\n std::atomic<size_t> duration; ///< The total duration\n\n\n\n /*!\n\n * \\brief Initialize an empty counter\n\n */\n\n timer_t()\n\n : name(nullptr), count(0), duration(0) {}\n\n\n\n /*!\n\n * \\brief Copy a timer\n\n */\n\n timer_t(const timer_t& rhs)\n\n : name(rhs.name), count(rhs.count.load()), duration(rhs.duration.load()) {}\n\n\n\n /*!\n\n * \\brief Copy assign a timer\n\n */\n", "file_path": "include/dll/util/timers.hpp", "rank": 52, "score": 211566.74668838768 }, { "content": "struct is_valid;\n\n\n\ntemplate <typename V, typename T1, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 53, "score": 211566.74668838768 }, { "content": "struct timers_t {\n\n std::array<timer_t, max_timers> timers; ///< The timers\n\n std::mutex lock; ///< The lock to protect the timers\n\n\n\n /*!\n\n * \\brief Reset the status of the timers\n\n */\n\n void reset(){\n\n std::lock_guard<std::mutex> l(lock);\n\n\n\n for(auto& timer : timers){\n\n timer.name = nullptr;\n\n timer.duration = 0;\n\n timer.count = 0;\n\n }\n\n }\n\n};\n\n\n\n/*!\n\n * \\brief Get a reference to the timer structure\n", "file_path": "include/dll/util/timers.hpp", "rank": 54, "score": 211566.74668838768 }, { "content": "struct batch {\n\n using size_type = size_t; ///< The size type of the batch\n\n using value_type = typename std::decay_t<Iterator>::value_type; ///< The value type of the batch\n\n\n\n Iterator first; ///< The iterator to the first element\n\n Iterator last; ///< The iterator to the past the end element\n\n\n\n /*!\n\n * \\brief Create a batch\n\n * \\param first The first element of the batch\n\n * \\param first The past-the-end element of the batch\n\n */\n\n batch(Iterator&& first, Iterator&& last)\n\n : first(std::forward<Iterator>(first)),\n\n last(std::forward<Iterator>(last)) {\n\n cpp_assert(std::distance(first, last) > 0, \"Batch cannot be empty or reversed\");\n\n }\n\n\n\n /*!\n\n * \\brief Return an iterator pointing to the first element of the batch\n", "file_path": "include/dll/util/batch.hpp", "rank": 55, "score": 211566.74668838768 }, { "content": "struct cannot_convert {\n\n /*!\n\n * \\brief False flag for TMP purpose\n\n */\n\n static constexpr bool value = false;\n\n};\n\n\n\n/*!\n\n * \\brief Converter utility to converty from type *From* to type *To*.\n\n */\n\ntemplate<typename From, typename To, typename Enable = void>\n", "file_path": "include/dll/util/converter.hpp", "rank": 56, "score": 211566.74668838768 }, { "content": "struct rbm_training_context {\n\n double reconstruction_error = 0.0; ///< The mean reconstruction error\n\n double free_energy = 0.0; ///< The mean free energy\n\n double sparsity = 0.0; ///< The mean sparsity\n\n\n\n double batch_error = 0.0; ///< The mean reconstruction error for the last batch\n\n double batch_sparsity = 0.0; ///< The mean sparsity for the last batch\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/trainer/rbm_training_context.hpp", "rank": 57, "score": 209312.7974210647 }, { "content": "struct sgd_context<DBN, dyn_shape_3d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_shape_3d_layer_impl<Desc>;\n\n using weight = typename DBN::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n using inputs_t = etl::dyn_matrix<weight, 4>;\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& layer) : input(batch_size, layer.C, layer.W, layer.H), output(batch_size, layer.C, layer.W, layer.H), errors(batch_size, layer.C, layer.W, layer.H){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/dyn_shape_3d_layer_impl.hpp", "rank": 58, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_mp_3d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_mp_3d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.i1, layer.i2, layer.i3),\n\n output(batch_size, layer.i1 / layer.c1, layer.i2 / layer.c2, layer.i3 / layer.c3),\n\n errors(batch_size, layer.i1 / layer.c1, layer.i2 / layer.c2, layer.i3 / layer.c3) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/pooling/dyn_mp_layer_impl.hpp", "rank": 59, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_deconv_layer_impl<Desc>, L> {\n\n using layer_t = dyn_deconv_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.nc, layer.nv1, layer.nv2),\n\n output(batch_size, layer.k, layer.nh1, layer.nh2),\n\n errors(batch_size, layer.k, layer.nh1, layer.nh2) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dyn_deconv_layer_impl.hpp", "rank": 60, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_mp_2d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_mp_2d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.i1, layer.i2, layer.i3),\n\n output(batch_size, layer.i1, layer.i2 / layer.c1, layer.i3 / layer.c2),\n\n errors(batch_size, layer.i1, layer.i2 / layer.c1, layer.i3 / layer.c2) {}\n\n};\n\n\n\n/*!\n\n * \\brief Standard dyn max pooling layer\n\n */\n\ntemplate <typename Desc>\n", "file_path": "include/dll/pooling/dyn_mp_layer_impl.hpp", "rank": 61, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_avgp_2d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_avgp_2d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.i1, layer.i2, layer.i3),\n\n output(batch_size, layer.i1, layer.i2 / layer.c1, layer.i3 / layer.c2),\n\n errors(batch_size, layer.i1, layer.i2 / layer.c1, layer.i3 / layer.c2) {}\n\n};\n\n\n\n/*!\n\n * \\brief Standard average pooling layer\n\n */\n\ntemplate <typename Desc>\n", "file_path": "include/dll/pooling/dyn_avgp_layer_impl.hpp", "rank": 62, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, batch_normalization_4d_layer_impl<Desc>, L> {\n\n using layer_t = batch_normalization_4d_layer_impl<Desc>; ///< The current layer type\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, layer_t::Kernels, layer_t::W, layer_t::H> input; ///< A batch of input\n\n etl::fast_matrix<weight, batch_size, layer_t::Kernels, layer_t::W, layer_t::H> output; ///< A batch of output\n\n etl::fast_matrix<weight, batch_size, layer_t::Kernels, layer_t::W, layer_t::H> errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/batch_normalization_4d_layer_impl.hpp", "rank": 63, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_conv_same_layer_impl<Desc>, L> {\n\n using layer_t = dyn_conv_same_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.nc, layer.nv1, layer.nv2),\n\n output(batch_size, layer.k, layer.nv1, layer.nv2), errors(batch_size, layer.k, layer.nv1, layer.nv2) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dyn_conv_same_layer_impl.hpp", "rank": 64, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, batch_normalization_2d_layer_impl<Desc>, L> {\n\n using layer_t = batch_normalization_2d_layer_impl<Desc>; ///< The current layer type\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::fast_matrix<weight, batch_size, Desc::Input> input; ///< A batch of input\n\n etl::fast_matrix<weight, batch_size, Desc::Input> output; ///< A batch of output\n\n etl::fast_matrix<weight, batch_size, Desc::Input> errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/batch_normalization_2d_layer_impl.hpp", "rank": 65, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_lcn_layer_impl<Desc>, L> {\n\n using layer_t = dyn_lcn_layer_impl<Desc>; ///< The current layer type\n\n using previous_layer = typename DBN::template layer_type<L - 1>; ///< The previous layer type\n\n using previous_context = sgd_context<DBN, previous_layer, L - 1>; ///< The previous layer's context\n\n using inputs_t = decltype(std::declval<previous_context>().output); ///< The type of inputs\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& /*layer*/){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/dyn_lcn_layer_impl.hpp", "rank": 66, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_avgp_3d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_avgp_3d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.i1, layer.i2, layer.i3),\n\n output(batch_size, layer.i1 / layer.c1, layer.i2 / layer.c2, layer.i3 / layer.c3),\n\n errors(batch_size, layer.i1 / layer.c1, layer.i2 / layer.c2, layer.i3 / layer.c3) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/pooling/dyn_avgp_layer_impl.hpp", "rank": 67, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_conv_layer_impl<Desc>, L> {\n\n using layer_t = dyn_conv_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.nc, layer.nv1, layer.nv2),\n\n output(batch_size, layer.k, layer.nh1, layer.nh2), errors(batch_size, layer.k, layer.nh1, layer.nh2) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dyn_conv_layer_impl.hpp", "rank": 68, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_upsample_3d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_upsample_3d_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.i1, layer.i2, layer.i3),\n\n output(batch_size, layer.i1 * layer.c1, layer.i2 * layer.c2, layer.i3 * layer.c3),\n\n errors(batch_size, layer.i1 * layer.c1, layer.i2 * layer.c2, layer.i3 * layer.c3) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/pooling/dyn_upsample_layer_impl.hpp", "rank": 69, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_shape_1d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_shape_1d_layer_impl<Desc>;\n\n using weight = typename DBN::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n using inputs_t = etl::dyn_matrix<weight, 2>;\n\n\n\n inputs_t input; ///< A batch of input\n\n inputs_t output; ///< A batch of output\n\n inputs_t errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& layer) : input(batch_size, layer.S), output(batch_size, layer.S), errors(batch_size, layer.S){}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/transform/dyn_shape_1d_layer_impl.hpp", "rank": 70, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_dense_layer_impl<Desc>, L> {\n\n using layer_t = dyn_dense_layer_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 2> input;\n\n etl::dyn_matrix<weight, 2> output;\n\n etl::dyn_matrix<weight, 2> errors;\n\n\n\n sgd_context(layer_t& layer) : input(batch_size, layer.num_visible, 0.0), output(batch_size, layer.num_hidden, 0.0), errors(batch_size, layer.num_hidden, 0.0) {}\n\n};\n\n\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dyn_dense_layer_impl.hpp", "rank": 71, "score": 209261.76706147043 }, { "content": "struct sgd_context<DBN, dyn_conv_rbm_impl<Desc>, L> {\n\n using layer_t = dyn_conv_rbm_impl<Desc>;\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input;\n\n etl::dyn_matrix<weight, 4> output;\n\n etl::dyn_matrix<weight, 4> errors;\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.nc, layer.nv1, layer.nv2),\n\n output(batch_size, layer.k, layer.nh1, layer.nh2), errors(batch_size, layer.k, layer.nh1, layer.nh2) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/rbm/dyn_conv_rbm_impl.hpp", "rank": 72, "score": 209261.76706147043 }, { "content": "struct label_cache_helper;\n\n\n\n/*!\n\n * \\brief Helper to create and initialize a cache for labels.\n\n *\n\n * This version makes the label categorical.\n\n */\n\ntemplate <typename Desc, typename T, typename LIterator>\n", "file_path": "include/dll/generators/label_cache_helper.hpp", "rank": 73, "score": 209256.22228308965 }, { "content": "struct default_dbn_watcher {\n\n static constexpr bool ignore_sub = false; ///< For pretraining of a DBN, indicates if the regular RBM watcher should be used (false) or ignored (true)\n\n static constexpr bool replace_sub = false; ///< For pretraining of a DBN, indicates if the DBN watcher should replace (true) the RBM watcher or not (false)\n\n\n\n size_t ft_max_epochs = 0; ///< The maximum number of epochs\n\n dll::stop_timer ft_epoch_timer; ///< Timer for an epoch\n\n dll::stop_timer ft_batch_timer; ///< Timer for a batch\n\n cpp::stop_watch<std::chrono::seconds> watch; ///< Timer for the entire training\n\n\n\n /*!\n\n * \\brief Indicates that the pretraining has begun for the given\n\n * DBN\n\n * \\param dbn The DBN being pretrained\n\n * \\param max_epochs The maximum number of epochs\n\n */\n\n void pretraining_begin(const DBN& dbn, size_t max_epochs) {\n\n std::cout << \"DBN: Pretraining begin for \" << max_epochs << \" epochs\" << std::endl;\n\n cpp_unused(dbn);\n\n }\n\n\n", "file_path": "include/dll/watcher.hpp", "rank": 74, "score": 208143.72524829075 }, { "content": "struct default_rbm_watcher {\n\n cpp::stop_watch<std::chrono::seconds> watch; ///< Timer for the entire training\n\n\n\n /*!\n\n * \\brief Indicates that the training of the given RBM started.\n\n * \\param rbm The rbm that started training.\n\n */\n\n template <typename RBM = R>\n\n void training_begin(const RBM& rbm) {\n\n using rbm_t = std::decay_t<RBM>;\n\n\n\n std::cout << \"Train RBM with \\\"\" << RBM::desc::template trainer_t<RBM>::name() << \"\\\"\" << std::endl;\n\n\n\n rbm.display();\n\n\n\n std::cout << \"With parameters:\" << std::endl;\n\n\n\n if(std::is_same<typename rbm_t::weight, float>::value){\n\n std::cout << \" single-precision\" << std::endl;\n\n } else if(std::is_same<typename rbm_t::weight, double>::value){\n", "file_path": "include/dll/watcher.hpp", "rank": 75, "score": 208143.72524829075 }, { "content": "struct training_desc {\n\n size_t epochs = 25;\n\n double learning_rate = stupid_default;\n\n double momentum = stupid_default;\n\n size_t batch_size = 0;\n\n\n\n std::string decay = \"none\";\n\n double l1_weight_cost = stupid_default;\n\n double l2_weight_cost = stupid_default;\n\n\n\n std::string trainer = \"none\";\n\n\n\n bool verbose = false;\n\n};\n\n\n", "file_path": "include/dll/processor/processor.hpp", "rank": 76, "score": 208138.5510125068 }, { "content": "struct get_value_l;\n\n\n\n/*!\n\n * \\copydoc get_value_l\n\n */\n\ntemplate <typename D, typename... T>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 77, "score": 207828.30467693185 }, { "content": "struct sequence_add;\n\n\n\ntemplate <size_t... I, size_t N>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 78, "score": 207828.30467693185 }, { "content": "struct get_value;\n\n\n\n/*!\n\n * \\copydoc get_value\n\n */\n\ntemplate <typename D, typename T2, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 79, "score": 207828.30467693185 }, { "content": "struct converter_one {\n\n static_assert(cannot_convert<From, To>::value, \"DLL does not know how to convert your input type (one)\");\n\n};\n\n\n\n// No conversion\n\n// This should only happen when used from converter_many\n\n\n\n/*!\n\n * \\copydoc converter_one\n\n */\n\ntemplate<typename From>\n", "file_path": "include/dll/util/converter.hpp", "rank": 80, "score": 207828.30467693188 }, { "content": "struct get_value_1;\n\n\n\n/*!\n\n * \\copydoc get_value_1\n\n */\n\ntemplate <typename D, typename T2, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 81, "score": 207828.30467693185 }, { "content": "struct stop_timer {\n\n std::chrono::time_point<std::chrono::steady_clock> start_time; ///< The start time\n\n\n\n /*!\n\n * \\brief Start the timer\n\n */\n\n void start() {\n\n start_time = std::chrono::steady_clock::now();\n\n }\n\n\n\n /*!\n\n * \\brief Stop the timer and get the elapsed since start\n\n * \\return elapsed time since start()\n\n */\n\n size_t stop() const {\n\n auto end = std::chrono::steady_clock::now();\n\n return std::chrono::duration_cast<std::chrono::milliseconds>(end - start_time).count();\n\n }\n\n};\n\n\n", "file_path": "include/dll/util/timers.hpp", "rank": 82, "score": 207828.30467693185 }, { "content": "struct get_value_2;\n\n\n\n/*!\n\n * \\copydoc get_value_2\n\n */\n\ntemplate <typename D, typename T2, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 83, "score": 207828.30467693185 }, { "content": "struct converter_many {\n\n static_assert(cannot_convert<From, To>::value, \"DLL does not know how to convert your input type (many)\");\n\n};\n\n\n\n// Only convert the sub types not the outer container\n\ntemplate<template<typename...> class Container, typename From, typename To>\n", "file_path": "include/dll/util/converter.hpp", "rank": 84, "score": 207828.30467693188 }, { "content": "struct get_type;\n\n\n\n/*!\n\n * \\copydoc get_type\n\n */\n\ntemplate <typename D, typename T2, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 85, "score": 207828.30467693188 }, { "content": "struct get_value_l<D, cpp::type_list<T...>> : cpp::auto_constant<get_value<D, T...>> {};\n\n\n\n/*!\n\n * \\brief Extract the type corresponding to the given configuration element from\n\n * the list of the parameters.\n\n * \\tparam D The configuration element type\n\n * \\tparam Args The arguments to extract the type from\n\n */\n\ntemplate <typename D, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 86, "score": 206126.6154566121 }, { "content": "struct converter_one <From, From> {\n\n /*!\n\n * \\brief Convert from the given container into the specific type\n\n * \\param l The layer for which to convert\n\n * \\param from The container to convert from\n\n * \\return the converted result\n\n */\n\n template<typename L>\n\n static const From& convert(const L&, const From& from){\n\n return from;\n\n }\n\n};\n\n\n\n// Convert a vector<T_F> to a dyn_vector<T_T>\n\n\n\n/*!\n\n * \\copydoc converter_one\n\n */\n\ntemplate<typename T_F, typename T_T, typename A>\n", "file_path": "include/dll/util/converter.hpp", "rank": 87, "score": 205657.28456934472 }, { "content": "struct no_epoch_error_id;\n", "file_path": "include/dll/base_conf.hpp", "rank": 88, "score": 204546.43688897716 }, { "content": "struct early_training_id;\n\n\n\n/*!\n\n * \\brief Sets the minibatch size\n\n * \\tparam B The minibatch size\n\n */\n\ntemplate <size_t B>\n", "file_path": "include/dll/base_conf.hpp", "rank": 89, "score": 204538.75018689985 }, { "content": "struct batch_size_id;\n", "file_path": "include/dll/base_conf.hpp", "rank": 90, "score": 204516.30655443203 }, { "content": "struct validate_label_layers;\n\n\n\ntemplate <typename Layer>\n", "file_path": "include/dll/dbn_layers.hpp", "rank": 91, "score": 204491.39702062242 }, { "content": "struct label_cache_helper<Desc, T, LIterator, std::enable_if_t<Desc::Categorical && !etl::is_etl_expr<typename std::iterator_traits<LIterator>::value_type>>> {\n\n using cache_type = etl::dyn_matrix<T, 2>; ///< The type of the cache\n\n using big_cache_type = etl::dyn_matrix<T, 3>; ///< The type of the big cache\n\n\n\n static constexpr size_t batch_size = Desc::BatchSize; ///< The size of the generated batches\n\n static constexpr size_t big_batch_size = Desc::BigBatchSize; ///< The number of batches kept in cache\n\n\n\n /*!\n\n * \\brief Init the cache\n\n * \\param n The size of the cache\n\n * \\param n_classes The number of classes\n\n * \\param it An iterator to an element\n\n * \\param cache The cache to initialize\n\n */\n\n static void init(size_t n, size_t n_classes, const LIterator& it, cache_type& cache) {\n\n cache = cache_type(n, n_classes);\n\n cache = T(0);\n\n\n\n cpp_unused(it);\n\n }\n", "file_path": "include/dll/generators/label_cache_helper.hpp", "rank": 92, "score": 204370.99071949517 }, { "content": "struct label_cache_helper<Desc, T, LIterator, std::enable_if_t<!Desc::Categorical && !etl::is_etl_expr<typename std::iterator_traits<LIterator>::value_type>>> {\n\n using cache_type = etl::dyn_matrix<T, 1>; ///< The type of the cache\n\n using big_cache_type = etl::dyn_matrix<T, 2>; ///< The type of the big cache\n\n\n\n static constexpr size_t batch_size = Desc::BatchSize; ///< The size of the generated batches\n\n static constexpr size_t big_batch_size = Desc::BigBatchSize; ///< The number of batches kept in cache\n\n\n\n /*!\n\n * \\brief Init the cache\n\n * \\param n The size of the cache\n\n * \\param n_classes The number of classes\n\n * \\param it An iterator to an element\n\n * \\param cache The cache to initialize\n\n */\n\n static void init(size_t n, size_t n_classes, const LIterator& it, cache_type& cache) {\n\n cache = cache_type(n);\n\n\n\n cpp_unused(it);\n\n cpp_unused(n_classes);\n\n }\n", "file_path": "include/dll/generators/label_cache_helper.hpp", "rank": 93, "score": 204370.99071949517 }, { "content": "struct sgd_context<DBN, dyn_batch_normalization_4d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_batch_normalization_4d_layer_impl<Desc>; ///< The current layer type\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 4> input; ///< A batch of input\n\n etl::dyn_matrix<weight, 4> output; ///< A batch of output\n\n etl::dyn_matrix<weight, 4> errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& layer)\n\n : input(batch_size, layer.Kernels, layer.W, layer.H), output(batch_size, layer.Kernels, layer.W, layer.H), errors(batch_size, layer.Kernels, layer.W, layer.H) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dyn_batch_normalization_4d_layer_impl.hpp", "rank": 94, "score": 204306.44669919563 }, { "content": "struct sgd_context<DBN, dyn_batch_normalization_2d_layer_impl<Desc>, L> {\n\n using layer_t = dyn_batch_normalization_2d_layer_impl<Desc>; ///< The current layer type\n\n using weight = typename layer_t::weight; ///< The data type for this layer\n\n\n\n static constexpr auto batch_size = DBN::batch_size;\n\n\n\n etl::dyn_matrix<weight, 2> input; ///< A batch of input\n\n etl::dyn_matrix<weight, 2> output; ///< A batch of output\n\n etl::dyn_matrix<weight, 2> errors; ///< A batch of errors\n\n\n\n sgd_context(layer_t& layer) : input(batch_size, layer.Input), output(batch_size, layer.Input), errors(batch_size, layer.Input) {}\n\n};\n\n\n\n} //end of dll namespace\n", "file_path": "include/dll/neural/dyn_batch_normalization_2d_layer_impl.hpp", "rank": 95, "score": 204306.44669919563 }, { "content": "struct conditional_constant_v1;\n\n\n\n/*!\n\n * \\copydoc conditional_constant_v1\n\n */\n\ntemplate <typename V1, typename V2>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 96, "score": 204234.50567836658 }, { "content": "struct conditional_constant_v2;\n\n\n\n/*!\n\n * \\copydoc conditional_constant_v2\n\n */\n\ntemplate <typename V1, typename V2>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 97, "score": 204234.50567836658 }, { "content": "struct get_template_type;\n\n\n\n/*!\n\n * \\copydoc get_template_type\n\n */\n\ntemplate <typename D, typename T2, typename... Args>\n", "file_path": "include/dll/util/tmp.hpp", "rank": 98, "score": 204234.50567836658 } ]
C++
torch/csrc/jit/testing/module_differ.cpp
aaditya-panik/pytorch
731c8255b7e8ed5435bfa09c7e0ad5f60bcc91d4
#include <torch/csrc/jit/testing/module_differ.h> #include <torch/csrc/jit/mobile/interpreter.h> #include <iostream> #include <sstream> #include <string> #include <unordered_map> #include <vector> namespace torch { namespace jit { template <typename It> bool ivalueListEquals( It lbegin, It lend, It rbegin, It rend, bool print, int print_indent) { int i = 0; const std::string indent(print_indent, '\t'); for (; lbegin != lend && rbegin != rend; ++lbegin, ++rbegin, ++i) { if (!ivalueEquals(*lbegin, *rbegin, print, print_indent + 1)) { std::cout << indent << "list element differs at position " << i << std::endl; return false; } } return true; } bool ivalueEquals( const IValue& lhs, const IValue& rhs, bool print, int print_indent) { const std::string indent(print_indent, '\t'); if (lhs.tagKind() != rhs.tagKind()) { if (print) { std::cout << indent << "lhs is type: " << lhs.tagKind() << "rhs is type: " << rhs.tagKind() << std::endl; } return false; } if (lhs.isCapsule()) { return true; } if (lhs.isDouble() || lhs.isComplexDouble() || lhs.isInt() || lhs.isBool() || lhs.isString() || lhs.isDevice() || lhs.isCapsule() || lhs.isRRef() || lhs.isEnum() || lhs.isIntList() || lhs.isDoubleList() || lhs.isBoolList() || lhs.isNone()) { if (lhs != rhs) { if (print) { std::cout << indent << "lhs is " << lhs << " || rhs is " << rhs << std::endl; } return false; } return true; } if (lhs.isTensor()) { const auto& lt = lhs.toTensor(); const auto& rt = rhs.toTensor(); std::stringstream lsize; std::stringstream rsize; for (const auto x : lt.sizes()) { lsize << x << ","; } for (const auto x : rt.sizes()) { rsize << x << ","; } if (lsize.str() != lsize.str()) { if (print) { std::cout << indent << "left tensor is of shape " << lsize.str() << "but right tensor is of shape " << rsize.str() << std::endl; } return false; } if (lt.allclose(rt)) { return true; } else { if (print) { std::cout << indent << "rhs and lhs has are not close" << std::endl; } return false; } } if (lhs.isGenericDict()) { const auto& ldict = lhs.toGenericDict(); const auto& rdict = rhs.toGenericDict(); if (ldict.size() != rdict.size()) { if (print) { std::cout << indent << "lhs and rhs are dicts of different sizes: " << ldict.size() << " vs. " << rdict.size() << std::endl; } return false; } for (const auto& kv : ldict) { auto rhs_iter = rdict.find(kv.key()); if (rhs_iter == rdict.end()) { if (print) { std::cout << indent << "rhs missing key: " << kv.key() << std::endl; } } if (!ivalueEquals( kv.value(), rhs_iter->value(), print, print_indent + 1)) { if (print) { std::cout << indent << "for key: " << kv.key() << " value differs." << std::endl; } return false; } } return true; } else if (lhs.isTensorList() || lhs.isList()) { const auto& vec = lhs.toList(); const auto& rvec = rhs.toList(); return ivalueListEquals( vec.begin(), vec.end(), rvec.begin(), rvec.end(), print, print_indent); } else if (lhs.isTuple()) { const auto vec = lhs.toTuple()->elements(); const auto rvec = rhs.toTuple()->elements(); return ivalueListEquals( vec.begin(), vec.end(), rvec.begin(), rvec.end(), print, print_indent); } else if (lhs.isObject()) { auto lobj = lhs.toObject(); auto robj = rhs.toObject(); auto ltype = lobj->type(); auto rtype = robj->type(); if (ltype->name() != rtype->name()) { if (print) { std::cerr << indent << "left object is of type: " << ltype->name()->qualifiedName() << " but right obj is of type: " << rtype->name()->qualifiedName() << std::endl; } return false; } auto getstate = ltype->findMethod("__getstate__"); if (getstate != nullptr) { return ivalueEquals( (*getstate)({lobj}), (*getstate)({robj}), print, print_indent + 1); } for (int i = 0; i < ltype->numAttributes(); i++) { if (!ivalueEquals( lobj->getSlot(i), robj->getSlot(i), print, print_indent + 1)) { std::cout << "attribute differs at position " << i << std::endl; return false; } } return true; } std::cerr << " I am here and should not be: " << rhs.tagKind() << std::endl; return false; } template <typename T, typename COMP, typename PRINTER> bool vectorEqual( const std::vector<T>& lhs, const std::vector<T>& rhs, bool print, COMP comparator, PRINTER printer) { if (lhs.size() != rhs.size()) { if (print) { std::cout << "lhs and rhs has different size: " << lhs.size() << "vs. " << rhs.size() << std::endl; } return false; } for (int i = 0; i < lhs.size(); i++) { if (!comparator(lhs[i], rhs[i])) { if (print) { std::cout << i << "th element of lhs and rhs differs \n lhs is " << printer(lhs[i]) << " rhs is " << printer(rhs[i]) << std::endl; } return false; } } return true; } bool moduleFunctionEquals( const mobile::Function& lhs, const mobile::Function& rhs, bool print) { const auto* lhs_code = lhs.get_code().get(); const auto* rhs_code = rhs.get_code().get(); if (print) { std::cout << "> Diffing instructions..." << std::endl; } auto ins_equal = [](Instruction lins, Instruction rins) -> bool { return (lins.op == rins.op && lins.N == rins.N && lins.X == rins.X); }; auto id = [](auto ins) { return ins; }; if (vectorEqual( lhs_code->instructions_, rhs_code->instructions_, true, ins_equal, id)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } if (print) { std::cout << "> Diffing constants..." << std::endl; } if (ivalueListEquals( lhs_code->constants_.begin(), lhs_code->constants_.end(), rhs_code->constants_.begin(), rhs_code->constants_.end(), true, 2)) { std::cout << " pass" << std::endl; } else { std::cout << " fail" << std::endl; return false; } if (print) { std::cout << "> Diffing operators ..." << std::endl; } auto equals = [](auto op1, auto op2) -> bool { return op1 == op2; }; if (vectorEqual(lhs_code->op_names_, rhs_code->op_names_, true, equals, id)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } if (lhs_code->register_size_ != rhs_code->register_size_) { std::cout << "Register size differs: " << lhs_code->register_size_ << " vs. " << rhs_code->register_size_ << std::endl; return false; } if (print) { std::cout << "> Diffing debug handles..." << std::endl; } if (vectorEqual( lhs_code->debug_handles_, rhs_code->debug_handles_, true, equals, id)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } auto type_eq = [](auto t1, auto t2) { return t1->str() == t2->str(); }; auto type_print = [](auto t1) { return t1->str(); }; if (print) { std::cout << "> Diffing types..." << std::endl; } if (vectorEqual( lhs_code->types_, rhs_code->types_, true, type_eq, type_print)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } if (print) { std::cout << "> Diffing schema..." << std::endl; } if (toString(lhs.getSchema()) == toString(rhs.getSchema())) { std::cout << " pass." << std::endl; } else { std::cout << " lhs is " << lhs.getSchema() << std::endl; std::cout << " rhs is " << rhs.getSchema() << std::endl; std::cout << " fail." << std::endl; return false; } return true; } bool moduleEquals(const mobile::Module& lhs, const mobile::Module& rhs) { std::unordered_map<std::string, const mobile::Function*> lhs_name_to_func; std::unordered_map<std::string, const mobile::Function*> rhs_name_to_func; for (const auto& func : lhs.compilation_unit().methods()) { lhs_name_to_func[func->name()] = func.get(); } for (const auto& func : rhs.compilation_unit().methods()) { rhs_name_to_func[func->name()] = func.get(); } for (const auto& name_func : lhs_name_to_func) { auto rhs_func = rhs_name_to_func.find(name_func.first); if (rhs_func == rhs_name_to_func.end()) { std::cout << "Method with name: " << name_func.first << " only exists in lhs"; } std::cout << "comparing method with name " << name_func.first << std::endl; if (moduleFunctionEquals(*name_func.second, *rhs_func->second, true)) { std::cout << "pass" << std::endl; } else { std::cout << "fail" << std::endl; return false; } } std::cout << "Diffing m._ivalue()..." << std::endl; if (ivalueEquals(lhs._ivalue(), rhs._ivalue(), true, 0)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } return true; } } }
#include <torch/csrc/jit/testing/module_differ.h> #include <torch/csrc/jit/mobile/interpreter.h> #include <iostream> #include <sstream> #include <string> #include <unordered_map> #include <vector> namespace torch { namespace jit { template <typename It> bool ivalueListEquals( It lbegin, It lend, It rbegin, It rend, bool print, int print_indent) { int i = 0; const std::string indent(print_indent, '\t'); for (; lbegin != lend && rbegin != rend; ++lbegin, ++rbegin, ++i) { if (!ivalueEquals(*lbegin, *rbegin, print, print_indent + 1)) { std::cout << indent << "list element differs at position " << i << std::endl; return false; } } return true; } bool ivalueEquals( const IValue& lhs, const IValue& rhs, bool print, int print_indent) { const std::string indent(print_indent, '\t'); if (lhs.tagKind() != rhs.tagKind()) { if (print) { std::cout << indent << "lhs is type: " << lhs.tagKind() << "rhs is type: " << rhs.tagKind() << std::endl; } return false; } if (lhs.isCapsule()) { return true; } if (lhs.isDouble() || lhs.isComplexDouble() || lhs.isInt() || lhs.isBool() || lhs.isString() || lhs.isDevice() || lhs.isCapsule() || lhs.isRRef() || lhs.isEnum() || lhs.isIntList() || lhs.isDoubleList() || lhs.isBoolList() || lhs.isNone()) { if (lhs != rhs) { if (print) { std::cout << indent << "lhs is " << lhs << " || rhs is " << rhs << std::endl; } return false; } return true; } if (lhs.isTensor()) { const auto& lt = lhs.toTensor(); const auto& rt = rhs.toTensor(); std::stringstream lsize; std::stringstream rsize; for (const auto x : lt.sizes()) { lsize << x << ","; } for (const auto x : rt.sizes()) { rsize << x << ","; } if (lsize.str() != lsize.str()) { if (print) { std::cout << indent << "left tensor is of shape " << lsize.str() << "but right tensor is of shape " << rsize.str() << std::endl; } return false; } if (lt.allclose(rt)) { return true; } else { if (print) { std::cout << indent << "rhs and lhs has are not close" << std::endl; } return false; } } if (lhs.isGenericDict()) { const auto& ldict = lhs.toGenericDict(); const auto& rdict = rhs.toGenericDict(); if (ldict.size() != rdict.size()) { if (print) { std::cout << indent << "lhs and rhs are dicts of different sizes: " << ldict.size() << " vs. " << rdict.size() << std::endl; } return false; } for (const auto& kv : ldict) { auto rhs_iter = rdict.find(kv.key()); if (rhs_iter == rdict.end()) { if (print) { std::cout << indent << "rhs missing key: " << kv.key() << std::endl; } } if (!ivalueEquals( kv.value(), rhs_iter->value(), print, print_indent + 1)) { if (print) { std::cout << indent << "for key: " << kv.key() << " value differs." << std::endl; } return false; } } return true; } else if (lhs.isTensorList() || lhs.isList()) { const auto& vec = lhs.toList(); const auto& rvec = rhs.toList(); return ivalueListEquals( vec.begin(), vec.end(), rvec.begin(), rvec.end(), print, print_indent); } else if (lhs.isTuple()) { const auto vec = lhs.toTuple()->elements(); const auto rvec = rhs.toTuple()->elements(); return ivalueListEquals( vec.begin(), vec.end(), rvec.begin(), rvec.end(), print, print_indent); } else if (lhs.isObject()) { auto lobj = lhs.toObject(); auto robj = rhs.toObject(); auto ltype = lobj->type(); auto rtype = robj->type(); if (ltype->name() != rtype->name()) { if (print) { std::cerr << indent << "left object is of type: " << ltype->name()->qualifiedName() << " but right obj is of type: " << rtype->name()->qualifiedName() << std::endl; } return false; } auto getstate = ltype->findMethod("__getstate__"); if (getstate != nullptr) { return ivalueEquals( (*getstate)({lobj}), (*getstate)({robj}), print, print_indent + 1); } for (int i = 0; i < ltype->numAttributes(); i++) { if (!ivalueEquals( lobj->getSlot(i), robj->getSlot(i), print, print_indent + 1)) { std::cout << "attribute differs at position " << i << std::endl; return false; } } return true; } std::cerr << " I am here and should not be: " << rhs.tagKind() << std::endl; return false; } template <typename T, typename COMP, typename PRINTER> bool vectorEqual( const std::vector<T>& lhs, const std::vector<T>& rhs, bool print, COMP comparator, PRINTER printer) { if (lhs.size() != rhs.size()) { if (print) { std::cout << "lhs and rhs has different size: " << lhs.size() << "vs. " << rhs.size() << std::endl; } return false; } for (int i = 0; i < lhs.size(); i++) { if (!comparator(lhs[i], rhs[i])) { if (print) { std::cout << i << "th element of lhs and rhs differs \n lhs is " << printer(lhs[i]) << " rhs is " << printer(rhs[i]) << std::endl; } return false; } } return true; } bool moduleFunctionEquals( const mobile::Function& lhs, const mobile::Function& rhs, bool print) { const auto* lhs_code = lhs.get_code().get(); const auto* rhs_code = rhs.get_code().get(); if (print) { std::cout << "> Diffing instructions..." << std::endl; } auto ins_equal = [](Instruction lins, Instruction rins) -> bool { return (lins.op == rins.op && lins.N == rins.N && lins.X == rins.X); }; auto id = [](auto ins) { return ins; }; if (vectorEqual( lhs_code->instructions_, rhs_code->instructions_, true, ins_equal, id)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } if (print) { std::cout << "> Diffing constants..." << std::endl; } if (ivalueListEquals( lhs_code->constants_.begin(), lhs_code->constants_.end(), rhs_code->constants_.begin(), rhs_code->constants_.end(), true, 2)) { std::cout << " pass" << std::endl; } else { std::cout << " fail" << std::endl; return false; } if (print) { std::cout << "> Diffing operators ..." << std::endl; } auto equals = [](auto op1, auto op2) -> bool { return op1 == op2; }; if (vectorEqual(lhs_code->op_names_, rhs_code->op_names_, true, equals, id)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } if (lhs_code->register_size_ != rhs_code->register_size_) { std::cout << "Register size differs: " << lhs_code->register_size_ << " vs. " << rhs_code->register_size_ << std::endl; return false; } if (print) { std::cout << "> Diffing debug handles..." << std::endl; } if (
) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } auto type_eq = [](auto t1, auto t2) { return t1->str() == t2->str(); }; auto type_print = [](auto t1) { return t1->str(); }; if (print) { std::cout << "> Diffing types..." << std::endl; } if (vectorEqual( lhs_code->types_, rhs_code->types_, true, type_eq, type_print)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } if (print) { std::cout << "> Diffing schema..." << std::endl; } if (toString(lhs.getSchema()) == toString(rhs.getSchema())) { std::cout << " pass." << std::endl; } else { std::cout << " lhs is " << lhs.getSchema() << std::endl; std::cout << " rhs is " << rhs.getSchema() << std::endl; std::cout << " fail." << std::endl; return false; } return true; } bool moduleEquals(const mobile::Module& lhs, const mobile::Module& rhs) { std::unordered_map<std::string, const mobile::Function*> lhs_name_to_func; std::unordered_map<std::string, const mobile::Function*> rhs_name_to_func; for (const auto& func : lhs.compilation_unit().methods()) { lhs_name_to_func[func->name()] = func.get(); } for (const auto& func : rhs.compilation_unit().methods()) { rhs_name_to_func[func->name()] = func.get(); } for (const auto& name_func : lhs_name_to_func) { auto rhs_func = rhs_name_to_func.find(name_func.first); if (rhs_func == rhs_name_to_func.end()) { std::cout << "Method with name: " << name_func.first << " only exists in lhs"; } std::cout << "comparing method with name " << name_func.first << std::endl; if (moduleFunctionEquals(*name_func.second, *rhs_func->second, true)) { std::cout << "pass" << std::endl; } else { std::cout << "fail" << std::endl; return false; } } std::cout << "Diffing m._ivalue()..." << std::endl; if (ivalueEquals(lhs._ivalue(), rhs._ivalue(), true, 0)) { std::cout << " pass." << std::endl; } else { std::cout << " fail." << std::endl; return false; } return true; } } }
vectorEqual( lhs_code->debug_handles_, rhs_code->debug_handles_, true, equals, id)
call_expression
[]